diff options
Diffstat (limited to 'lib/rbcodec')
-rw-r--r-- | lib/rbcodec/codecs/libopus/celt/fixed_generic.h | 27 | ||||
-rw-r--r-- | lib/rbcodec/codecs/opus.c | 6 |
2 files changed, 33 insertions, 0 deletions
diff --git a/lib/rbcodec/codecs/libopus/celt/fixed_generic.h b/lib/rbcodec/codecs/libopus/celt/fixed_generic.h index 71e28d62a8..d2271e7972 100644 --- a/lib/rbcodec/codecs/libopus/celt/fixed_generic.h +++ b/lib/rbcodec/codecs/libopus/celt/fixed_generic.h | |||
@@ -42,8 +42,35 @@ | |||
42 | /** 16x32 multiplication, followed by a 16-bit shift right (round-to-nearest). Results fits in 32 bits */ | 42 | /** 16x32 multiplication, followed by a 16-bit shift right (round-to-nearest). Results fits in 32 bits */ |
43 | #define MULT16_32_P16(a,b) ADD32(MULT16_16((a),SHR((b),16)), PSHR(MULT16_16((a),((b)&0x0000ffff)),16)) | 43 | #define MULT16_32_P16(a,b) ADD32(MULT16_16((a),SHR((b),16)), PSHR(MULT16_16((a),((b)&0x0000ffff)),16)) |
44 | 44 | ||
45 | #if defined(CPU_COLDFIRE) | ||
46 | static inline int32_t MULT16_32_Q15(int32_t a, int32_t b) | ||
47 | { | ||
48 | asm volatile ("lsl.l #8, %[a];" | ||
49 | "lsl.l #8, %[a];" | ||
50 | "mac.l %[a], %[b], %%acc0;" | ||
51 | "movclr.l %%acc0, %[a];" | ||
52 | : [a] "+d" (a) | ||
53 | : [b] "d" (b) | ||
54 | : "cc"); | ||
55 | return a; | ||
56 | } | ||
57 | |||
58 | #elif defined(CPU_ARM) | ||
59 | static inline int32_t MULT16_32_Q15(int32_t a, int32_t b) | ||
60 | { | ||
61 | int32_t lo, hi; | ||
62 | asm volatile("smull %[lo], %[hi], %[a], %[b] \n\t" | ||
63 | "mov %[lo], %[lo], lsr #15 \n\t" | ||
64 | "orr %[hi], %[lo], %[hi], lsl #17 \n\t" | ||
65 | : [lo] "=&r" (lo), [hi] "=&r" (hi) | ||
66 | : [a] "r" (a), [b] "r" (b) ); | ||
67 | return(hi); | ||
68 | } | ||
69 | |||
70 | #else | ||
45 | /** 16x32 multiplication, followed by a 15-bit shift right. Results fits in 32 bits */ | 71 | /** 16x32 multiplication, followed by a 15-bit shift right. Results fits in 32 bits */ |
46 | #define MULT16_32_Q15(a,b) ADD32(SHL(MULT16_16((a),SHR((b),16)),1), SHR(MULT16_16SU((a),((b)&0x0000ffff)),15)) | 72 | #define MULT16_32_Q15(a,b) ADD32(SHL(MULT16_16((a),SHR((b),16)),1), SHR(MULT16_16SU((a),((b)&0x0000ffff)),15)) |
73 | #endif | ||
47 | 74 | ||
48 | /** 32x32 multiplication, followed by a 31-bit shift right. Results fits in 32 bits */ | 75 | /** 32x32 multiplication, followed by a 31-bit shift right. Results fits in 32 bits */ |
49 | #define MULT32_32_Q31(a,b) ADD32(ADD32(SHL(MULT16_16(SHR((a),16),SHR((b),16)),1), SHR(MULT16_16SU(SHR((a),16),((b)&0x0000ffff)),15)), SHR(MULT16_16SU(SHR((b),16),((a)&0x0000ffff)),15)) | 76 | #define MULT32_32_Q31(a,b) ADD32(ADD32(SHL(MULT16_16(SHR((a),16),SHR((b),16)),1), SHR(MULT16_16SU(SHR((a),16),((b)&0x0000ffff)),15)), SHR(MULT16_16SU(SHR((b),16),((a)&0x0000ffff)),15)) |
diff --git a/lib/rbcodec/codecs/opus.c b/lib/rbcodec/codecs/opus.c index 19bdb8daae..cf2d69738f 100644 --- a/lib/rbcodec/codecs/opus.c +++ b/lib/rbcodec/codecs/opus.c | |||
@@ -332,6 +332,12 @@ enum codec_status codec_run(void) | |||
332 | } | 332 | } |
333 | global_stack = 0; | 333 | global_stack = 0; |
334 | 334 | ||
335 | #if defined(CPU_COLDFIRE) | ||
336 | /* EMAC rounding is disabled because of MULT16_32_Q15, which will be | ||
337 | inaccurate with rounding in its current incarnation */ | ||
338 | coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE); | ||
339 | #endif | ||
340 | |||
335 | /* pre-init the ogg_sync_state buffer, so it won't need many reallocs */ | 341 | /* pre-init the ogg_sync_state buffer, so it won't need many reallocs */ |
336 | ogg_sync_init(&oy); | 342 | ogg_sync_init(&oy); |
337 | oy.storage = 64*1024; | 343 | oy.storage = 64*1024; |