diff options
Diffstat (limited to 'apps/codecs')
-rw-r--r-- | apps/codecs/libcook/cook_fixpoint.h | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/apps/codecs/libcook/cook_fixpoint.h b/apps/codecs/libcook/cook_fixpoint.h index f92d717f20..8848d89af7 100644 --- a/apps/codecs/libcook/cook_fixpoint.h +++ b/apps/codecs/libcook/cook_fixpoint.h | |||
@@ -35,10 +35,12 @@ | |||
35 | * in C using two 32 bit integer multiplications. | 35 | * in C using two 32 bit integer multiplications. |
36 | */ | 36 | */ |
37 | 37 | ||
38 | #ifdef ROCKBOX | ||
38 | /* get definitions of MULT31, MULT31_SHIFT15, CLIP_TO_15, vect_add, from codelib */ | 39 | /* get definitions of MULT31, MULT31_SHIFT15, CLIP_TO_15, vect_add, from codelib */ |
39 | #include "asm_arm.h" | 40 | #include "asm_arm.h" |
40 | #include "asm_mcf5249.h" | 41 | #include "asm_mcf5249.h" |
41 | #include "codeclib_misc.h" | 42 | #include "codeclib_misc.h" |
43 | #endif | ||
42 | 44 | ||
43 | /* The following table is taken from libavutil/mathematics.c */ | 45 | /* The following table is taken from libavutil/mathematics.c */ |
44 | const uint8_t ff_log2_tab[256] ={ | 46 | const uint8_t ff_log2_tab[256] ={ |
@@ -83,11 +85,34 @@ static inline FIXP fixp_pow2_neg(FIXP x, int i) | |||
83 | * @param a fix point value | 85 | * @param a fix point value |
84 | * @param b fix point fraction, 0 <= b < 1 | 86 | * @param b fix point fraction, 0 <= b < 1 |
85 | */ | 87 | */ |
86 | 88 | #ifdef ROCKBOX | |
87 | #define fixp_mult_su(x,y) (MULT31_SHIFT15(x,y)) | 89 | #define fixp_mult_su(x,y) (MULT31_SHIFT15(x,y)) |
90 | #else | ||
91 | static inline FIXP fixp_mult_su(FIXP a, FIXPU b) | ||
92 | { | ||
93 | int32_t hb = (a >> 16) * b; | ||
94 | uint32_t lb = (a & 0xffff) * b; | ||
95 | |||
96 | return hb + (lb >> 16) + ((lb & 0x8000) >> 15); | ||
97 | } | ||
98 | #endif | ||
88 | 99 | ||
89 | /* Faster version of the above using 32x32=64 bit multiply */ | 100 | /* Faster version of the above using 32x32=64 bit multiply */ |
101 | #ifdef ROCKBOX | ||
90 | #define fixmul31(x,y) (MULT31(x,y)) | 102 | #define fixmul31(x,y) (MULT31(x,y)) |
103 | #else | ||
104 | static inline int32_t fixmul31(int32_t x, int32_t y) | ||
105 | { | ||
106 | int64_t temp; | ||
107 | |||
108 | temp = x; | ||
109 | temp *= y; | ||
110 | |||
111 | temp >>= 31; //16+31-16 = 31 bits | ||
112 | |||
113 | return (int32_t)temp; | ||
114 | } | ||
115 | #endif | ||
91 | 116 | ||
92 | /* math functions taken from libavutil/common.h */ | 117 | /* math functions taken from libavutil/common.h */ |
93 | 118 | ||
@@ -241,6 +266,7 @@ static inline void imlt_math(COOKContext *q, FIXP *in) | |||
241 | static inline void overlap_math(COOKContext *q, int gain, FIXP buffer[]) | 266 | static inline void overlap_math(COOKContext *q, int gain, FIXP buffer[]) |
242 | { | 267 | { |
243 | int i; | 268 | int i; |
269 | #ifdef ROCKBOX | ||
244 | if(LIKELY(gain == 0)) | 270 | if(LIKELY(gain == 0)) |
245 | { | 271 | { |
246 | vect_add(q->mono_mdct_output, buffer, q->samples_per_channel); | 272 | vect_add(q->mono_mdct_output, buffer, q->samples_per_channel); |
@@ -255,6 +281,12 @@ static inline void overlap_math(COOKContext *q, int gain, FIXP buffer[]) | |||
255 | (q->mono_mdct_output[i] >> -gain) + ((q->mono_mdct_output[i] >> (-gain-1)) & 1)+ buffer[i]; | 281 | (q->mono_mdct_output[i] >> -gain) + ((q->mono_mdct_output[i] >> (-gain-1)) & 1)+ buffer[i]; |
256 | } | 282 | } |
257 | } | 283 | } |
284 | #else | ||
285 | for(i=0 ; i<q->samples_per_channel ; i++) { | ||
286 | q->mono_mdct_output[i] = | ||
287 | fixp_pow2(q->mono_mdct_output[i], gain) + buffer[i]; | ||
288 | } | ||
289 | #endif | ||
258 | } | 290 | } |
259 | 291 | ||
260 | 292 | ||
@@ -320,6 +352,7 @@ static inline FIXP cplscale_math(FIXP x, int table, int i) | |||
320 | */ | 352 | */ |
321 | static inline void output_math(COOKContext *q, register int16_t *out, int chan) | 353 | static inline void output_math(COOKContext *q, register int16_t *out, int chan) |
322 | { | 354 | { |
355 | #ifdef ROCKBOX | ||
323 | register REAL_T * mono_output_ptr = q->mono_mdct_output; | 356 | register REAL_T * mono_output_ptr = q->mono_mdct_output; |
324 | register REAL_T * mono_output_end = mono_output_ptr + q->samples_per_channel; | 357 | register REAL_T * mono_output_end = mono_output_ptr + q->samples_per_channel; |
325 | out += chan; | 358 | out += chan; |
@@ -329,4 +362,11 @@ static inline void output_math(COOKContext *q, register int16_t *out, int chan) | |||
329 | *out = CLIP_TO_15(fixp_pow2_neg(*mono_output_ptr++, 11)); | 362 | *out = CLIP_TO_15(fixp_pow2_neg(*mono_output_ptr++, 11)); |
330 | out += STEP; | 363 | out += STEP; |
331 | } | 364 | } |
365 | #else | ||
366 | int j; | ||
367 | for (j = 0; j < q->samples_per_channel; j++) { | ||
368 | out[chan + q->nb_channels * j] = | ||
369 | av_clip(fixp_pow2(q->mono_mdct_output[j], -11), -32768, 32767); | ||
370 | } | ||
371 | #endif | ||
332 | } | 372 | } |