summaryrefslogtreecommitdiff
path: root/apps/codecs/libcook/cook_fixpoint.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/libcook/cook_fixpoint.h')
-rw-r--r--apps/codecs/libcook/cook_fixpoint.h60
1 files changed, 16 insertions, 44 deletions
diff --git a/apps/codecs/libcook/cook_fixpoint.h b/apps/codecs/libcook/cook_fixpoint.h
index 30e5a3eee2..57c217dc43 100644
--- a/apps/codecs/libcook/cook_fixpoint.h
+++ b/apps/codecs/libcook/cook_fixpoint.h
@@ -79,28 +79,28 @@ static inline FIXP fixp_pow2_neg(FIXP x, int i)
79#else 79#else
80static inline FIXP fixp_mult_su(FIXP a, FIXPU b) 80static inline FIXP fixp_mult_su(FIXP a, FIXPU b)
81{ 81{
82 int32_t hb = (a >> 16) * b; 82 int32_t hb = (a >> 16) * b;
83 uint32_t lb = (a & 0xffff) * b; 83 uint32_t lb = (a & 0xffff) * b;
84 84
85 return hb + (lb >> 16) + ((lb & 0x8000) >> 15); 85 return hb + (lb >> 16) + ((lb & 0x8000) >> 15);
86} 86}
87#endif 87#endif
88 88
89/* Faster version of the above using 32x32=64 bit multiply */ 89/* Faster version of the above using 32x32=64 bit multiply */
90#ifdef ROCKBOX 90#ifdef ROCKBOX
91#define fixmul31(x,y) (MULT31(x,y)) 91#define fixmul31(x,y) (MULT31(x,y))
92#else 92#else
93static inline int32_t fixmul31(int32_t x, int32_t y) 93static inline int32_t fixmul31(int32_t x, int32_t y)
94{ 94{
95 int64_t temp; 95 int64_t temp;
96 96
97 temp = x; 97 temp = x;
98 temp *= y; 98 temp *= y;
99 99
100 temp >>= 31; //16+31-16 = 31 bits 100 temp >>= 31; //16+31-16 = 31 bits
101 101
102 return (int32_t)temp; 102 return (int32_t)temp;
103} 103}
104#endif 104#endif
105 105
106/** 106/**
@@ -166,7 +166,8 @@ static void scalar_dequant_math(COOKContext *q, int index,
166 */ 166 */
167#include "../lib/mdct_lookup.h" 167#include "../lib/mdct_lookup.h"
168 168
169static inline void imlt_math(COOKContext *q, FIXP *in) 169void imlt_math(COOKContext *q, FIXP *in) ICODE_ATTR;
170void imlt_math(COOKContext *q, FIXP *in)
170{ 171{
171 const int n = q->samples_per_channel; 172 const int n = q->samples_per_channel;
172 const int step = 2 << (10 - av_log2(n)); 173 const int step = 2 << (10 - av_log2(n));
@@ -203,7 +204,8 @@ static inline void imlt_math(COOKContext *q, FIXP *in)
203 * @param gain gain correction to apply first to output buffer 204 * @param gain gain correction to apply first to output buffer
204 * @param buffer data to overlap 205 * @param buffer data to overlap
205 */ 206 */
206static inline void overlap_math(COOKContext *q, int gain, FIXP buffer[]) 207void overlap_math(COOKContext *q, int gain, FIXP buffer[]) ICODE_ATTR;
208void overlap_math(COOKContext *q, int gain, FIXP buffer[])
207{ 209{
208 int i; 210 int i;
209#ifdef ROCKBOX 211#ifdef ROCKBOX
@@ -280,33 +282,3 @@ static inline FIXP cplscale_math(FIXP x, int table, int i)
280{ 282{
281 return fixp_mult_su(x, cplscales[table-2][i]); 283 return fixp_mult_su(x, cplscales[table-2][i]);
282} 284}
283
284
285/**
286 * Final converion from floating point values to
287 * signed, 16 bit sound samples. Round and clip.
288 *
289 * @param q pointer to the COOKContext
290 * @param out pointer to the output buffer
291 * @param chan 0: left or single channel, 1: right channel
292 */
293static inline void output_math(COOKContext *q, register int16_t *out, int chan)
294{
295#ifdef ROCKBOX
296 register REAL_T * mono_output_ptr = q->mono_mdct_output;
297 register REAL_T * mono_output_end = mono_output_ptr + q->samples_per_channel;
298 out += chan;
299 const int STEP = q->nb_channels;
300 while( mono_output_ptr < mono_output_end )
301 {
302 *out = CLIP_TO_15(fixp_pow2_neg(*mono_output_ptr++, 11));
303 out += STEP;
304 }
305#else
306 int j;
307 for (j = 0; j < q->samples_per_channel; j++) {
308 out[chan + q->nb_channels * j] =
309 av_clip(fixp_pow2(q->mono_mdct_output[j], -11), -32768, 32767);
310 }
311#endif
312}