Commit 22823834 by Jean-Marc Valin

### fixed-point: added cheap celt_div() division using a reciprocal

parent ba238d87
 ... @@ -126,7 +126,7 @@ void normalise_bands(const CELTMode *m, const celt_sig_t *freq, celt_norm_t *X, ... @@ -126,7 +126,7 @@ void normalise_bands(const CELTMode *m, const celt_sig_t *freq, celt_norm_t *X, shift = celt_zlog2(bank[i*C+c])-13; shift = celt_zlog2(bank[i*C+c])-13; E = VSHR32(bank[i*C+c], shift); E = VSHR32(bank[i*C+c], shift); if (E>0) if (E>0) g = DIV32_16(QCONST32(1.f,28),MULT16_16_Q14(E,sqrtC_1[C-1])); g = EXTRACT16(celt_div(QCONST32(1.f,28),MULT16_16_Q14(E,sqrtC_1[C-1]))); else else g = 0; g = 0; for (j=B*eBands[i];j
 ... @@ -45,6 +45,7 @@ ... @@ -45,6 +45,7 @@ #define celt_cos_norm(x) (cos((.5f*M_PI)*(x))) #define celt_cos_norm(x) (cos((.5f*M_PI)*(x))) #define celt_atan atan #define celt_atan atan #define celt_rcp(x) (1.f/(x)) #define celt_rcp(x) (1.f/(x)) #define celt_div(a,b) ((a)/(b)) #endif #endif ... @@ -202,6 +203,8 @@ static inline celt_word32_t celt_rcp(celt_word32_t x) ... @@ -202,6 +203,8 @@ static inline celt_word32_t celt_rcp(celt_word32_t x) return VSHR32(EXTEND32(frac),i-16); return VSHR32(EXTEND32(frac),i-16); } } #define celt_div(a,b) MULT32_32_Q31(a,celt_rcp(b)) #endif /* FIXED_POINT */ #endif /* FIXED_POINT */ ... ...
 ... @@ -106,7 +106,7 @@ static void quant_energy_mono(const CELTMode *m, celt_ener_t *eBands, celt_word1 ... @@ -106,7 +106,7 @@ static void quant_energy_mono(const CELTMode *m, celt_ener_t *eBands, celt_word1 celt_word16_t f; /* Q8 */ celt_word16_t f; /* Q8 */ celt_word16_t mean = MULT16_16_Q15(Q15ONE-coef,eMeans[i]); celt_word16_t mean = MULT16_16_Q15(Q15ONE-coef,eMeans[i]); x = amp2dB(eBands[i]); x = amp2dB(eBands[i]); f = DIV32_16(SHL32(EXTEND32(x-mean-MULT16_16_Q15(coef,oldEBands[i])-prev),8),base_resolution); f = EXTRACT16(celt_div(SHL32(EXTEND32(x-mean-MULT16_16_Q15(coef,oldEBands[i])-prev),8),base_resolution)); #ifdef FIXED_POINT #ifdef FIXED_POINT /* Rounding to nearest integer here is really important! */ /* Rounding to nearest integer here is really important! */ qi = (f+128)>>8; qi = (f+128)>>8; ... @@ -149,7 +149,7 @@ static void quant_energy_mono(const CELTMode *m, celt_ener_t *eBands, celt_word1 ... @@ -149,7 +149,7 @@ static void quant_energy_mono(const CELTMode *m, celt_ener_t *eBands, celt_word1 if (q2 > frac[i]-1) if (q2 > frac[i]-1) q2 = frac[i]-1; q2 = frac[i]-1; ec_enc_uint(enc, q2, frac[i]); ec_enc_uint(enc, q2, frac[i]); offset = DIV32_16(SHL16(q2,8)+QCONST16(.5,8),frac[i])-QCONST16(.5f,8); offset = EXTRACT16(celt_div(SHL16(q2,8)+QCONST16(.5,8),frac[i])-QCONST16(.5f,8)); oldEBands[i] += PSHR32(MULT16_16(DB_SCALING*6,offset),8); oldEBands[i] += PSHR32(MULT16_16(DB_SCALING*6,offset),8); /*printf ("%f ", error[i] - offset);*/ /*printf ("%f ", error[i] - offset);*/ } } ... @@ -199,7 +199,7 @@ static void unquant_energy_mono(const CELTMode *m, celt_ener_t *eBands, celt_wor ... @@ -199,7 +199,7 @@ static void unquant_energy_mono(const CELTMode *m, celt_ener_t *eBands, celt_wor if (ec_dec_tell(dec, 0) - bits +EC_ILOG(frac[i])> budget) if (ec_dec_tell(dec, 0) - bits +EC_ILOG(frac[i])> budget) break; break; q2 = ec_dec_uint(dec, frac[i]); q2 = ec_dec_uint(dec, frac[i]); offset = DIV32_16(SHL16(q2,8)+QCONST16(.5,8),frac[i])-QCONST16(.5f,8); offset = EXTRACT16(celt_div(SHL16(q2,8)+QCONST16(.5,8),frac[i])-QCONST16(.5f,8)); oldEBands[i] += PSHR32(MULT16_16(DB_SCALING*6,offset),8); oldEBands[i] += PSHR32(MULT16_16(DB_SCALING*6,offset),8); } } for (i=0;inbEBands;i++) for (i=0;inbEBands;i++) ... ...
 ... @@ -378,7 +378,7 @@ void intra_prediction(celt_norm_t *x, celt_mask_t *W, int N, int K, celt_norm_t ... @@ -378,7 +378,7 @@ void intra_prediction(celt_norm_t *x, celt_mask_t *W, int N, int K, celt_norm_t xy = MAC16_16(xy, x[j], Y[i+N-j-1]); xy = MAC16_16(xy, x[j], Y[i+N-j-1]); yy = MAC16_16(yy, Y[i+N-j-1], Y[i+N-j-1]); yy = MAC16_16(yy, Y[i+N-j-1], Y[i+N-j-1]); } } score = DIV32(MULT16_16(ROUND16(xy,14),ROUND16(xy,14)), ROUND16(yy,14)); score = celt_div(MULT16_16(ROUND16(xy,14),ROUND16(xy,14)), ROUND16(yy,14)); if (score > best_score) if (score > best_score) { { best_score = score; best_score = score; ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!