From 69cbe8190b778f0081efd1b19e076cae2e301622 Mon Sep 17 00:00:00 2001 From: Sean Bartell Date: Wed, 1 Jun 2011 17:25:09 -0400 Subject: [PATCH] Fix libcook bugs introduced in r22055. --- apps/codecs/lib/codeclib_misc.h | 7 +++++++ apps/codecs/libcook/cook_fixpoint.h | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/apps/codecs/lib/codeclib_misc.h b/apps/codecs/lib/codeclib_misc.h index f3ec209..f3b1805 100644 --- a/apps/codecs/lib/codeclib_misc.h +++ b/apps/codecs/lib/codeclib_misc.h @@ -65,6 +65,7 @@ static inline int32_t MULT32(int32_t x, int32_t y) { magic.whole = (int64_t)x * y; return magic.halves.hi; } + static inline int32_t MULT31(int32_t x, int32_t y) { return MULT32(x,y)<<1; } @@ -75,6 +76,12 @@ static inline int32_t MULT31_SHIFT15(int32_t x, int32_t y) { return ((uint32_t)(magic.halves.lo)>>15) | ((magic.halves.hi)<<17); } +static inline int32_t MULT31_SHIFT16(int32_t x, int32_t y) { + union magic magic; + magic.whole = (int64_t)x * y; + return ((uint32_t)(magic.halves.lo)>>16) | ((magic.halves.hi)<<16); +} + #else /* 32 bit multiply, more portable but less accurate */ diff --git a/apps/codecs/libcook/cook_fixpoint.h b/apps/codecs/libcook/cook_fixpoint.h index c8a17c6..fc26ed5 100644 --- a/apps/codecs/libcook/cook_fixpoint.h +++ b/apps/codecs/libcook/cook_fixpoint.h @@ -68,7 +68,7 @@ static inline FIXP fixp_pow2(FIXP x, int i) * @param b fix point fraction, 0 <= b < 1 */ #ifdef ROCKBOX -#define fixp_mult_su(x,y) (MULT31_SHIFT15(x,y)) +#define fixp_mult_su(x,y) (MULT31_SHIFT16(x,y)) #else static inline FIXP fixp_mult_su(FIXP a, FIXPU b) { @@ -130,18 +130,18 @@ static void scalar_dequant_math(COOKContext *q, int index, int* subband_coef_sign, REAL_T *mlt_p) { /* Num. half bits to right shift */ - const int s = (33 - quant_index + av_log2(q->samples_per_channel)) >> 1; + const int s = 33 - quant_index + av_log2(q->samples_per_channel); const FIXP *table = quant_tables[s & 1][index]; FIXP f; int i; - if(s >= 32) + if(s >= 64) memset(mlt_p, 0, sizeof(REAL_T)*SUBBAND_SIZE); else { for(i=0 ; i>s; + f = (table[subband_coef_index[i]]) >> (s >> 1); /* noise coding if subband_coef_index[i] == 0 */ if (((subband_coef_index[i] == 0) && cook_random(q)) || ((subband_coef_index[i] != 0) && subband_coef_sign[i])) -- 1.7.5.2