Loading lib_com/ari_hm.c +188 −0 Original line number Diff line number Diff line Loading @@ -100,6 +100,70 @@ void UnmapIndex( return; } void UnmapIndex_fx( const Word16 PeriodicityIndex, const Word16 Bandwidth, const Word16 LtpPitchLag, const Word8 SmallerLags, Word16 *FractionalResolution, Word32 *Lag ) { Word16 LtpPitchIndex, Multiplier; Word16 Lag16; test(); IF ((LtpPitchLag > 0) && (s_and(PeriodicityIndex, kLtpHmFlag) != 0)) { LtpPitchIndex = shr(PeriodicityIndex, 9); Multiplier = s_and(PeriodicityIndex, 0xff); assert(0 <= LtpPitchIndex && LtpPitchIndex <= 16); assert(1 <= Multiplier && Multiplier <= (1 << NumRatioBits[Bandwidth][LtpPitchIndex])); *FractionalResolution = kLtpHmFractionalResolution; move16(); *Lag = L_shr(L_mult0(LtpPitchLag, Ratios_fx[Bandwidth][LtpPitchIndex][Multiplier-1]), 8); move32(); } ELSE { IF (LT_16(PeriodicityIndex, 16)) { *FractionalResolution = 3; move16(); Lag16 = add(PeriodicityIndex, GET_ADJ2(0, 6, 3)); } ELSE IF (LT_16(PeriodicityIndex, 80)) { *FractionalResolution = 4; move16(); Lag16 = add(PeriodicityIndex, GET_ADJ2(16, 8, 4)); } ELSE IF (LT_16(PeriodicityIndex, 208)) { *FractionalResolution = 3; move16(); Lag16 = add(PeriodicityIndex, GET_ADJ2(80, 12, 3)); } ELSE { test(); IF (LT_16(PeriodicityIndex, 224)||SmallerLags!=0) { *FractionalResolution = 1; move16(); Lag16 = add(PeriodicityIndex, GET_ADJ2(208, 28, 1)); } ELSE { *FractionalResolution = 0; move16(); Lag16 = add(PeriodicityIndex, GET_ADJ2(224, 188, 0)); } } *Lag = L_deposit_l(Lag16); } } /*-------------------------------------------------------------------* * ConfigureContextHm() Loading Loading @@ -196,6 +260,27 @@ int16_t CountIndexBits( return 8; } Word16 CountIndexBits_fx( Word16 Bandwidth, Word16 PeriodicityIndex ) { Word16 result; Word16 PeriodicityIndexS; result = 8; move16(); PeriodicityIndexS = shr(PeriodicityIndex, 9); if (s_and(PeriodicityIndex, kLtpHmFlag) != 0) { result = NumRatioBits[Bandwidth][PeriodicityIndexS]; move16(); } return result; } #define WMC_TOOL_SKIP /*-------------------------------------------------------------------* Loading Loading @@ -256,6 +341,61 @@ int16_t tcx_hm_render( return 0; } Word32 tcx_hm_render_fx( const Word32 lag, /* i: pitch lag Q0 */ const Word16 fract_res, /* i: fractional resolution of the lag Q0 */ Word16 p[] /* o: harmonic model Q13 */ ) { Word16 k, tmp, height; Word16 PeakDeviation; Word32 f0, tmp32; /* Set up overall shape */ f0 = L_shl(lag, sub(15, fract_res)); /* Q31 */ tmp32 = Mpy_32_16_1(f0, -26474); tmp32 = L_shr_r(BASOP_Util_InvLog2(L_shl(tmp32, 7)), 2); tmp32 = L_sub(603979776L, tmp32); tmp32 = L_add(L_add(tmp32, tmp32), Mpy_32_16_1(tmp32, 26214)); height = round_fx(tmp32); /* Q13 */ tmp32 = Mpy_32_16_1(f0, -18910); tmp32 = L_shr_r(BASOP_Util_InvLog2(L_shl(tmp32, 7)), 2); tmp32 = L_sub(1395864371L, tmp32); PeakDeviation = round_fx(tmp32); /* Q14 */ IF( GT_16(13915,PeakDeviation)) { /* A bit error was encountered */ return 1; } ELSE { tmp = div_s(13915, PeakDeviation); tmp = mult_r(tmp, tmp); /* Q15 */ } tmp = div_s(13915, PeakDeviation); tmp = mult_r(tmp, tmp); /* Q15 */ /* Render the prototype peak */ p[kTcxHmParabolaHalfWidth] = height; move16(); FOR (k=1; k<=kTcxHmParabolaHalfWidth; ++k) { p[kTcxHmParabolaHalfWidth+k] = round_fx(Mpy_32_16_1(BASOP_Util_InvLog2(L_shl(L_mult0(i_mult2(negate(k),k), tmp),10)), height)); } /* Mirror */ FOR (k=-kTcxHmParabolaHalfWidth; k<0; ++k) { p[kTcxHmParabolaHalfWidth+k] = p[kTcxHmParabolaHalfWidth-k]; move16(); } return 0; } /*-------------------------------------------------------------------* * tcx_hm_modify_envelope() Loading Loading @@ -302,4 +442,52 @@ void tcx_hm_modify_envelope( return; } void tcx_hm_modify_envelope_fx( const Word16 gain, /* i: HM gain Q11 */ const Word32 lag, /* i: pitch lag Q0 */ const Word16 fract_res, /* i: fractional resolution of the lag Q0 */ const Word16 p[], /* i: harmonic model Q13 */ Word32 env[], /* i/o: envelope Q16 */ const Word16 L_frame /* i: number of spectral lines Q0 */ ) { Word16 k, h, x, l1,l2, L_frame_m1, L_frame_for_loop; Word16 inv_shape[2*kTcxHmParabolaHalfWidth+1]; IF ( gain == 0 ) { return; } FOR (k=0; k<2*kTcxHmParabolaHalfWidth+1; ++k) { /* Q24 = Q11 * Q13; 512 = 1.0 in Q24 format */ inv_shape[k] = div_s(512, add(512, mult_r(gain, p[k]))); move16(); } h = 1; move16(); k = extract_l(L_shr(lag,fract_res)); L_frame_m1 = sub(L_frame,1); L_frame_for_loop = add(L_frame,kTcxHmParabolaHalfWidth - 1); WHILE ( LE_16(k,L_frame_for_loop)) { l1 = s_max(0, sub(k,kTcxHmParabolaHalfWidth)); l2 = s_min(add(k,kTcxHmParabolaHalfWidth), L_frame_m1); FOR (x=l1; x<=l2; ++x) { env[x] = Mpy_32_16_1(env[x], inv_shape[x-k+kTcxHmParabolaHalfWidth]); move32(); } h = add(h,1); k = extract_l(L_shr(imult3216(lag,h),fract_res)); } } #undef WMC_TOOL_SKIP lib_com/prot.h +60 −0 Original line number Diff line number Diff line Loading @@ -7580,6 +7580,12 @@ int16_t ari_start_decoding_14bits_prm( int16_t bp, Tastat *s ); Word16 ari_start_decoding_14bits_prm_fx( const Word16 *ptr, Word16 bp, Tastat *s ); void ari_decode_14bits_s17_ext( Decoder_State *st, uint16_t *res, Loading Loading @@ -7699,6 +7705,23 @@ void tcx_arith_decode_envelope( const int16_t low_complexity /* i : low-complexity flag */ ); void tcx_arith_decode_envelope_fx( Decoder_State *st, /* i/o: coder state */ Word32 q_spectrum[], /* o : quantised MDCT coefficients */ Word16 *q_spectrum_e, /* o : MDCT exponent */ const Word16 L_frame, /* i : frame or MDCT length */ Word16 L_spec, /* i : length w/o BW limitation */ const Word16 A_ind[], /* i : quantised LPC coefficients */ const Word16 target_bits, /* i : number of available bits */ const Word16 prm[], /* i : bitstream parameters */ const Word16 use_hm, /* i : use HM in current frame? */ const Word16 prm_hm[], /* i : HM parameter area */ Word16 tcxltp_pitch, /* i : TCX LTP pitch in FD, -1 if n/a*/ Word16 *arith_bits, /* o : bits used for ari. coding */ Word16 *signaling_bits, /* o : bits used for signaling */ const Word16 low_complexity /* i : low-complexity flag */ ); void UnmapIndex( const int16_t PeriodicityIndex, const int16_t Bandwidth, Loading @@ -7707,6 +7730,14 @@ void UnmapIndex( int16_t *FractionalResolution, int32_t *Lag ); void UnmapIndex_fx( const Word16 PeriodicityIndex, const Word16 Bandwidth, const Word16 LtpPitchLag, const Word8 SmallerLags, Word16 *FractionalResolution, Word32 *Lag); /*! r: PeriodicityIndex */ int16_t SearchPeriodicityIndex( const float Mdct[], /* i : Coefficients, Mdct[0..NumCoeffs-1] */ Loading Loading @@ -7735,6 +7766,10 @@ int16_t CountIndexBits( const int16_t Bandwidth, /* o : NB, 1: (S)WB */ const int16_t PeriodicityIndex ); Word16 CountIndexBits_fx( Word16 Bandwidth, /* 0: NB, 1: (S)WB */ Word16 PeriodicityIndex ); int16_t DecodeIndex( Decoder_State *st, const int16_t Bandwidth, /* o : NB, 1: (S)WB */ Loading @@ -7749,6 +7784,12 @@ int16_t tcx_hm_render( Word16 p[] /* o : harmonic model (Q13) */ ); Word32 tcx_hm_render_fx( const Word32 lag, /* i: pitch lag Q0 */ const Word16 fract_res, /* i: fractional resolution of the lag Q0 */ Word16 p[] /* o: harmonic model Q13 */ ); void tcx_hm_modify_envelope( const Word16 gain, /* i : HM gain (Q11) */ const int16_t lag, Loading @@ -7758,6 +7799,15 @@ void tcx_hm_modify_envelope( const int16_t L_frame /* i : number of spectral lines */ ); void tcx_hm_modify_envelope_fx( const Word16 gain, /* i: HM gain Q11 */ const Word32 lag, /* i: pitch lag Q0 */ const Word16 fract_res, /* i: fractional resolution of the lag Q0 */ const Word16 p[], /* i: harmonic model Q13 */ Word32 env[], /* i/o: envelope Q16 */ const Word16 L_frame /* i: number of spectral lines Q0 */ ); void tcx_hm_analyse( const float abs_spectrum[], /* i : absolute spectrum */ const int16_t L_frame, /* i : number of spectral lines */ Loading @@ -7780,6 +7830,16 @@ void tcx_hm_decode( int16_t *hm_bits /* o : bit consumption */ ); void tcx_hm_decode_fx( const Word16 L_frame, /* i : number of spectral lines */ Word32 env[], /* i/o: envelope shape (Q16) */ const Word16 targetBits, /* i : target bit budget */ const Word16 coder_type, /* i : GC/VC coder type */ const Word16 prm_hm[], /* i : HM parameters */ const Word16 LtpPitchLag, /* i : LTP pitch lag or -1 if none */ Word16 *hm_bits /* o : bit consumption */ ); void coder_tcx( Encoder_State *st, /* i/o: encoder state structure */ TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ Loading lib_com/rom_com.c +121 −0 Original line number Diff line number Diff line Loading @@ -26354,6 +26354,127 @@ const float * const Ratios[2][17] = } }; /* 7Q8 */ const Word16 Ratios_WB_2_fx[32] = /* 2 */{ 768, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 2816, 3072, 3328, 3584, 3840, 4096, 4352, 4608, 4864, 5120, 5376, 5632, 6144, 6656, 7168, 7680, 8192, 8704, 9216, 9728, 10240, 15360, 16384, 18432 }; const Word16 Ratios_WB_3_fx[32] = /* 3 */{ 256, 512, 768, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 3072, 3584, 4096, 4608, 5120, 5632, 6144, 6656, 7168, 7680, 8192, 8704, 9216, 9728, 10240, 11264, 12288, 13824, 15360, 17408, 19968, 20480 }; const Word16 Ratios_WB_4_fx[32] = /* 4 */{ 384, 512, 640, 768, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 3072, 3584, 4096, 4608, 5120, 5632, 6144, 6656, 7168, 7680, 8192, 8704, 9216, 9728, 10240, 10752, 11264, 12288, 13312, 13824, 17408 }; const Word16 Ratios_WB_5_fx[32] = /* 5 */{ 256, 384, 512, 640, 768, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 2816, 3072, 3328, 3584, 3840, 4096, 4608, 5120, 5632, 6144, 6656, 7168, 7680, 8192, 8704, 9216, 10240, 11264, 12288, 13824 }; const Word16 Ratios_WB_6_fx[32] = /* 6 */{ 256, 384, 512, 640, 768, 896, 1024, 1152, 1280, 1408, 1536, 1664, 1792, 1920, 2048, 2304, 2560, 2816, 3072, 3328, 3584, 3840, 4096, 4608, 5120, 5632, 6144, 6656, 7168, 8704, 10240, 10496 }; const Word16 Ratios_WB_7_fx[32] = /* 7 */{ 256, 384, 512, 640, 768, 896, 1024, 1152, 1280, 1536, 1792, 2048, 2304, 2560, 2816, 3072, 3328, 3584, 3840, 4096, 4352, 4608, 4864, 5120, 5376, 5760, 6144, 6400, 6912, 7168, 7680, 8960 }; const Word16 Ratios_WB_8_fx[16] = /* 8 */{ 128, 256, 384, 512, 640, 768, 896, 1024, 1152, 1280, 1408, 1536, 1792, 2048, 2304, 2560 }; const Word16 Ratios_WB_9_fx[16] = /* 9 */{ 256, 512, 640, 768, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 3072, 3840, 4096, 4608, 6912 }; const Word16 Ratios_WB_10_fx[16] = /* 10 */{ 256, 384, 512, 640, 768, 896, 1024, 1280, 1536, 2048, 2560, 3840, 4608, 5632, 6144, 6656 }; const Word16 Ratios_WB_11_fx[16] = /* 11 */{ 256, 384, 512, 640, 768, 896, 1024, 1280, 1536, 2048, 2560, 3072, 3328, 3584, 4608, 5376 }; const Word16 Ratios_WB_12_fx[16] = /* 12 */{ 128, 256, 384, 512, 640, 768, 1024, 1280, 1536, 2048, 2304, 2816, 3072, 3456, 4096, 5120 }; const Word16 Ratios_WB_13_fx[16] = /* 13 */{ 128, 256, 384, 512, 640, 768, 1024, 1280, 1536, 1792, 2048, 2560, 2816, 3072, 3584, 5120 }; const Word16 Ratios_WB_14_fx[16] = /* 14 */{ 128, 256, 384, 512, 640, 768, 1024, 1152, 1536, 1920, 2304, 2560, 3072, 3584, 3840, 4608 }; const Word16 Ratios_WB_15_fx[16] = /* 15 */{ 128, 256, 320, 384, 448, 512, 640, 768, 896, 1024, 1152, 1280, 1536, 2048, 2304, 3584 }; const Word16 Ratios_WB_16_fx[4] = /* 16 */{ 128, 256, 512, 1024 }; const Word16 Ratios_WB_17_fx[4] = /* 17 */{ 256, 384, 512, 1024 }; const Word16 Ratios_WB_18_fx[4] = /* 18 */{ 256, 512, 768, 1024 }; /******************************************************************************/ /* 7Q8 */ const Word16 Ratios_NB_2_fx[32] = /* 2 */{ 768, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 2816, 3072, 3328, 3584, 3840, 4096, 4352, 4608, 4864, 5120, 5376, 5632, 5888, 6144, 6400, 6656, 6912, 7168, 7680, 8192, 8704, 9216, 9728, 10240 }; const Word16 Ratios_NB_3_fx[16] = /* 3 */{ 128, 256, 512, 768, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 3072, 4096, 5120, 6144, 7680 }; const Word16 Ratios_NB_4_fx[16] = /* 4 */{ 512, 768, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 3072, 3584, 4096, 4608, 5120, 6144, 7680 }; const Word16 Ratios_NB_5_fx[16] = /* 5 */{ 512, 768, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 3072, 3584, 4096, 4608, 5120, 6144, 7680 }; const Word16 Ratios_NB_6_fx[16] = /* 6 */{ 512, 640, 768, 896, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 3072, 3584, 4096, 4608, 5120 }; const Word16 Ratios_NB_7_fx[16] = /* 7 */{ 256, 512, 640, 768, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 3072, 3584, 4096, 4608, 5120 }; const Word16 Ratios_NB_8_fx[16] = /* 8 */{ 256, 384, 512, 640, 768, 896, 1024, 1152, 1280, 1536, 1792, 2048, 2304, 2560, 3072, 4096 }; const Word16 Ratios_NB_9_fx[8] = /* 9 */{ 256, 512, 768, 1024, 1280, 1536, 2048, 2560 }; const Word16 Ratios_NB_10_fx[8] = /* 10 */{ 256, 512, 768, 1024, 1280, 1536, 2048, 2560 }; const Word16 Ratios_NB_11_fx[8] = /* 11 */{ 256, 384, 512, 768, 1024, 1280, 1536, 2048 }; const Word16 Ratios_NB_12_fx[8] = /* 12 */{ 256, 512, 640, 768, 1024, 1280, 1536, 2048 }; const Word16 Ratios_NB_13_fx[4] = /* 13 */{ 256, 512, 768, 1024 }; const Word16 Ratios_NB_14_fx[4] = /* 14 */{ 256, 512, 1024, 1536 }; const Word16 Ratios_NB_15_fx[4] = /* 15 */{ 256, 512, 768, 1024 }; const Word16 Ratios_NB_16_fx[4] = /* 16 */{ 256, 384, 512, 1024 }; const Word16 Ratios_NB_17_fx[4] = /* 17 */{ 256, 384, 512, 768 }; const Word16 Ratios_NB_18_fx[4] = /* 18 */{ 128, 256, 512, 768 }; /******************************************************************************/ const Word16 *const Ratios_fx[2][17] = { /* NB */ { Ratios_NB_2_fx, Ratios_NB_3_fx, Ratios_NB_4_fx, Ratios_NB_5_fx, Ratios_NB_6_fx, Ratios_NB_7_fx, Ratios_NB_8_fx, Ratios_NB_9_fx, Ratios_NB_10_fx, Ratios_NB_11_fx, Ratios_NB_12_fx, Ratios_NB_13_fx, Ratios_NB_14_fx, Ratios_NB_15_fx , Ratios_NB_16_fx , Ratios_NB_17_fx , Ratios_NB_18_fx }, /* WB */ { Ratios_WB_2_fx, Ratios_WB_3_fx, Ratios_WB_4_fx, Ratios_WB_5_fx, Ratios_WB_6_fx, Ratios_WB_7_fx, Ratios_WB_8_fx, Ratios_WB_9_fx, Ratios_WB_10_fx, Ratios_WB_11_fx, Ratios_WB_12_fx, Ratios_WB_13_fx, Ratios_WB_14_fx, Ratios_WB_15_fx , Ratios_WB_16_fx , Ratios_WB_17_fx , Ratios_WB_18_fx } }; #define QGC(x) FL2WORD16_SCALE(x, 4) const Word16 qGains[2][1 << kTcxHmNumGainBits] = { lib_com/rom_com.h +36 −0 Original line number Diff line number Diff line Loading @@ -1473,6 +1473,42 @@ extern const float Ratios_NB_17[4]; extern const float Ratios_NB_18[4]; extern const float *const Ratios[2][17]; extern const Word16 Ratios_WB_2_fx[32]; extern const Word16 Ratios_WB_3_fx[32]; extern const Word16 Ratios_WB_4_fx[32]; extern const Word16 Ratios_WB_5_fx[32]; extern const Word16 Ratios_WB_6_fx[32]; extern const Word16 Ratios_WB_7_fx[32]; extern const Word16 Ratios_WB_8_fx[16]; extern const Word16 Ratios_WB_9_fx[16]; extern const Word16 Ratios_WB_10_fx[16]; extern const Word16 Ratios_WB_11_fx[16]; extern const Word16 Ratios_WB_12_fx[16]; extern const Word16 Ratios_WB_13_fx[16]; extern const Word16 Ratios_WB_14_fx[16]; extern const Word16 Ratios_WB_15_fx[16]; extern const Word16 Ratios_WB_16_fx[4]; extern const Word16 Ratios_WB_17_fx[4]; extern const Word16 Ratios_WB_18_fx[4]; extern const Word16 Ratios_NB_2_fx[32]; extern const Word16 Ratios_NB_3_fx[16]; extern const Word16 Ratios_NB_4_fx[16]; extern const Word16 Ratios_NB_5_fx[16]; extern const Word16 Ratios_NB_6_fx[16]; extern const Word16 Ratios_NB_7_fx[16]; extern const Word16 Ratios_NB_8_fx[16]; extern const Word16 Ratios_NB_9_fx[8]; extern const Word16 Ratios_NB_10_fx[8]; extern const Word16 Ratios_NB_11_fx[8]; extern const Word16 Ratios_NB_12_fx[8]; extern const Word16 Ratios_NB_13_fx[4]; extern const Word16 Ratios_NB_14_fx[4]; extern const Word16 Ratios_NB_15_fx[4]; extern const Word16 Ratios_NB_16_fx[4]; extern const Word16 Ratios_NB_17_fx[4]; extern const Word16 Ratios_NB_18_fx[4]; extern const Word16 *const Ratios_fx[2][17]; extern const Word16 qGains[2][1 << kTcxHmNumGainBits]; /*----------------------------------------------------------------------------------* Loading lib_dec/ari_dec.c +27 −0 Original line number Diff line number Diff line Loading @@ -100,6 +100,33 @@ int16_t ari_start_decoding_14bits_prm( return bp; } Word16 ari_start_decoding_14bits_prm_fx( const Word16 *ptr, Word16 bp, Tastat *s ) { Word32 val; Word16 i; const Word16 *p; val = L_deposit_l(0); p = ptr + bp; FOR(i = 0; i < cbitsnew; i++) { val = L_or(L_shl(val, 1), *(p + i)); } s->low = L_deposit_l(0); s->high = ari_q4new; move32(); s->value = val; move32(); return add(bp, i); } /*--------------------------------------------------------------- * ari_decode_14bits_s17_ext() * Loading Loading
lib_com/ari_hm.c +188 −0 Original line number Diff line number Diff line Loading @@ -100,6 +100,70 @@ void UnmapIndex( return; } void UnmapIndex_fx( const Word16 PeriodicityIndex, const Word16 Bandwidth, const Word16 LtpPitchLag, const Word8 SmallerLags, Word16 *FractionalResolution, Word32 *Lag ) { Word16 LtpPitchIndex, Multiplier; Word16 Lag16; test(); IF ((LtpPitchLag > 0) && (s_and(PeriodicityIndex, kLtpHmFlag) != 0)) { LtpPitchIndex = shr(PeriodicityIndex, 9); Multiplier = s_and(PeriodicityIndex, 0xff); assert(0 <= LtpPitchIndex && LtpPitchIndex <= 16); assert(1 <= Multiplier && Multiplier <= (1 << NumRatioBits[Bandwidth][LtpPitchIndex])); *FractionalResolution = kLtpHmFractionalResolution; move16(); *Lag = L_shr(L_mult0(LtpPitchLag, Ratios_fx[Bandwidth][LtpPitchIndex][Multiplier-1]), 8); move32(); } ELSE { IF (LT_16(PeriodicityIndex, 16)) { *FractionalResolution = 3; move16(); Lag16 = add(PeriodicityIndex, GET_ADJ2(0, 6, 3)); } ELSE IF (LT_16(PeriodicityIndex, 80)) { *FractionalResolution = 4; move16(); Lag16 = add(PeriodicityIndex, GET_ADJ2(16, 8, 4)); } ELSE IF (LT_16(PeriodicityIndex, 208)) { *FractionalResolution = 3; move16(); Lag16 = add(PeriodicityIndex, GET_ADJ2(80, 12, 3)); } ELSE { test(); IF (LT_16(PeriodicityIndex, 224)||SmallerLags!=0) { *FractionalResolution = 1; move16(); Lag16 = add(PeriodicityIndex, GET_ADJ2(208, 28, 1)); } ELSE { *FractionalResolution = 0; move16(); Lag16 = add(PeriodicityIndex, GET_ADJ2(224, 188, 0)); } } *Lag = L_deposit_l(Lag16); } } /*-------------------------------------------------------------------* * ConfigureContextHm() Loading Loading @@ -196,6 +260,27 @@ int16_t CountIndexBits( return 8; } Word16 CountIndexBits_fx( Word16 Bandwidth, Word16 PeriodicityIndex ) { Word16 result; Word16 PeriodicityIndexS; result = 8; move16(); PeriodicityIndexS = shr(PeriodicityIndex, 9); if (s_and(PeriodicityIndex, kLtpHmFlag) != 0) { result = NumRatioBits[Bandwidth][PeriodicityIndexS]; move16(); } return result; } #define WMC_TOOL_SKIP /*-------------------------------------------------------------------* Loading Loading @@ -256,6 +341,61 @@ int16_t tcx_hm_render( return 0; } Word32 tcx_hm_render_fx( const Word32 lag, /* i: pitch lag Q0 */ const Word16 fract_res, /* i: fractional resolution of the lag Q0 */ Word16 p[] /* o: harmonic model Q13 */ ) { Word16 k, tmp, height; Word16 PeakDeviation; Word32 f0, tmp32; /* Set up overall shape */ f0 = L_shl(lag, sub(15, fract_res)); /* Q31 */ tmp32 = Mpy_32_16_1(f0, -26474); tmp32 = L_shr_r(BASOP_Util_InvLog2(L_shl(tmp32, 7)), 2); tmp32 = L_sub(603979776L, tmp32); tmp32 = L_add(L_add(tmp32, tmp32), Mpy_32_16_1(tmp32, 26214)); height = round_fx(tmp32); /* Q13 */ tmp32 = Mpy_32_16_1(f0, -18910); tmp32 = L_shr_r(BASOP_Util_InvLog2(L_shl(tmp32, 7)), 2); tmp32 = L_sub(1395864371L, tmp32); PeakDeviation = round_fx(tmp32); /* Q14 */ IF( GT_16(13915,PeakDeviation)) { /* A bit error was encountered */ return 1; } ELSE { tmp = div_s(13915, PeakDeviation); tmp = mult_r(tmp, tmp); /* Q15 */ } tmp = div_s(13915, PeakDeviation); tmp = mult_r(tmp, tmp); /* Q15 */ /* Render the prototype peak */ p[kTcxHmParabolaHalfWidth] = height; move16(); FOR (k=1; k<=kTcxHmParabolaHalfWidth; ++k) { p[kTcxHmParabolaHalfWidth+k] = round_fx(Mpy_32_16_1(BASOP_Util_InvLog2(L_shl(L_mult0(i_mult2(negate(k),k), tmp),10)), height)); } /* Mirror */ FOR (k=-kTcxHmParabolaHalfWidth; k<0; ++k) { p[kTcxHmParabolaHalfWidth+k] = p[kTcxHmParabolaHalfWidth-k]; move16(); } return 0; } /*-------------------------------------------------------------------* * tcx_hm_modify_envelope() Loading Loading @@ -302,4 +442,52 @@ void tcx_hm_modify_envelope( return; } void tcx_hm_modify_envelope_fx( const Word16 gain, /* i: HM gain Q11 */ const Word32 lag, /* i: pitch lag Q0 */ const Word16 fract_res, /* i: fractional resolution of the lag Q0 */ const Word16 p[], /* i: harmonic model Q13 */ Word32 env[], /* i/o: envelope Q16 */ const Word16 L_frame /* i: number of spectral lines Q0 */ ) { Word16 k, h, x, l1,l2, L_frame_m1, L_frame_for_loop; Word16 inv_shape[2*kTcxHmParabolaHalfWidth+1]; IF ( gain == 0 ) { return; } FOR (k=0; k<2*kTcxHmParabolaHalfWidth+1; ++k) { /* Q24 = Q11 * Q13; 512 = 1.0 in Q24 format */ inv_shape[k] = div_s(512, add(512, mult_r(gain, p[k]))); move16(); } h = 1; move16(); k = extract_l(L_shr(lag,fract_res)); L_frame_m1 = sub(L_frame,1); L_frame_for_loop = add(L_frame,kTcxHmParabolaHalfWidth - 1); WHILE ( LE_16(k,L_frame_for_loop)) { l1 = s_max(0, sub(k,kTcxHmParabolaHalfWidth)); l2 = s_min(add(k,kTcxHmParabolaHalfWidth), L_frame_m1); FOR (x=l1; x<=l2; ++x) { env[x] = Mpy_32_16_1(env[x], inv_shape[x-k+kTcxHmParabolaHalfWidth]); move32(); } h = add(h,1); k = extract_l(L_shr(imult3216(lag,h),fract_res)); } } #undef WMC_TOOL_SKIP
lib_com/prot.h +60 −0 Original line number Diff line number Diff line Loading @@ -7580,6 +7580,12 @@ int16_t ari_start_decoding_14bits_prm( int16_t bp, Tastat *s ); Word16 ari_start_decoding_14bits_prm_fx( const Word16 *ptr, Word16 bp, Tastat *s ); void ari_decode_14bits_s17_ext( Decoder_State *st, uint16_t *res, Loading Loading @@ -7699,6 +7705,23 @@ void tcx_arith_decode_envelope( const int16_t low_complexity /* i : low-complexity flag */ ); void tcx_arith_decode_envelope_fx( Decoder_State *st, /* i/o: coder state */ Word32 q_spectrum[], /* o : quantised MDCT coefficients */ Word16 *q_spectrum_e, /* o : MDCT exponent */ const Word16 L_frame, /* i : frame or MDCT length */ Word16 L_spec, /* i : length w/o BW limitation */ const Word16 A_ind[], /* i : quantised LPC coefficients */ const Word16 target_bits, /* i : number of available bits */ const Word16 prm[], /* i : bitstream parameters */ const Word16 use_hm, /* i : use HM in current frame? */ const Word16 prm_hm[], /* i : HM parameter area */ Word16 tcxltp_pitch, /* i : TCX LTP pitch in FD, -1 if n/a*/ Word16 *arith_bits, /* o : bits used for ari. coding */ Word16 *signaling_bits, /* o : bits used for signaling */ const Word16 low_complexity /* i : low-complexity flag */ ); void UnmapIndex( const int16_t PeriodicityIndex, const int16_t Bandwidth, Loading @@ -7707,6 +7730,14 @@ void UnmapIndex( int16_t *FractionalResolution, int32_t *Lag ); void UnmapIndex_fx( const Word16 PeriodicityIndex, const Word16 Bandwidth, const Word16 LtpPitchLag, const Word8 SmallerLags, Word16 *FractionalResolution, Word32 *Lag); /*! r: PeriodicityIndex */ int16_t SearchPeriodicityIndex( const float Mdct[], /* i : Coefficients, Mdct[0..NumCoeffs-1] */ Loading Loading @@ -7735,6 +7766,10 @@ int16_t CountIndexBits( const int16_t Bandwidth, /* o : NB, 1: (S)WB */ const int16_t PeriodicityIndex ); Word16 CountIndexBits_fx( Word16 Bandwidth, /* 0: NB, 1: (S)WB */ Word16 PeriodicityIndex ); int16_t DecodeIndex( Decoder_State *st, const int16_t Bandwidth, /* o : NB, 1: (S)WB */ Loading @@ -7749,6 +7784,12 @@ int16_t tcx_hm_render( Word16 p[] /* o : harmonic model (Q13) */ ); Word32 tcx_hm_render_fx( const Word32 lag, /* i: pitch lag Q0 */ const Word16 fract_res, /* i: fractional resolution of the lag Q0 */ Word16 p[] /* o: harmonic model Q13 */ ); void tcx_hm_modify_envelope( const Word16 gain, /* i : HM gain (Q11) */ const int16_t lag, Loading @@ -7758,6 +7799,15 @@ void tcx_hm_modify_envelope( const int16_t L_frame /* i : number of spectral lines */ ); void tcx_hm_modify_envelope_fx( const Word16 gain, /* i: HM gain Q11 */ const Word32 lag, /* i: pitch lag Q0 */ const Word16 fract_res, /* i: fractional resolution of the lag Q0 */ const Word16 p[], /* i: harmonic model Q13 */ Word32 env[], /* i/o: envelope Q16 */ const Word16 L_frame /* i: number of spectral lines Q0 */ ); void tcx_hm_analyse( const float abs_spectrum[], /* i : absolute spectrum */ const int16_t L_frame, /* i : number of spectral lines */ Loading @@ -7780,6 +7830,16 @@ void tcx_hm_decode( int16_t *hm_bits /* o : bit consumption */ ); void tcx_hm_decode_fx( const Word16 L_frame, /* i : number of spectral lines */ Word32 env[], /* i/o: envelope shape (Q16) */ const Word16 targetBits, /* i : target bit budget */ const Word16 coder_type, /* i : GC/VC coder type */ const Word16 prm_hm[], /* i : HM parameters */ const Word16 LtpPitchLag, /* i : LTP pitch lag or -1 if none */ Word16 *hm_bits /* o : bit consumption */ ); void coder_tcx( Encoder_State *st, /* i/o: encoder state structure */ TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ Loading
lib_com/rom_com.c +121 −0 Original line number Diff line number Diff line Loading @@ -26354,6 +26354,127 @@ const float * const Ratios[2][17] = } }; /* 7Q8 */ const Word16 Ratios_WB_2_fx[32] = /* 2 */{ 768, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 2816, 3072, 3328, 3584, 3840, 4096, 4352, 4608, 4864, 5120, 5376, 5632, 6144, 6656, 7168, 7680, 8192, 8704, 9216, 9728, 10240, 15360, 16384, 18432 }; const Word16 Ratios_WB_3_fx[32] = /* 3 */{ 256, 512, 768, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 3072, 3584, 4096, 4608, 5120, 5632, 6144, 6656, 7168, 7680, 8192, 8704, 9216, 9728, 10240, 11264, 12288, 13824, 15360, 17408, 19968, 20480 }; const Word16 Ratios_WB_4_fx[32] = /* 4 */{ 384, 512, 640, 768, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 3072, 3584, 4096, 4608, 5120, 5632, 6144, 6656, 7168, 7680, 8192, 8704, 9216, 9728, 10240, 10752, 11264, 12288, 13312, 13824, 17408 }; const Word16 Ratios_WB_5_fx[32] = /* 5 */{ 256, 384, 512, 640, 768, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 2816, 3072, 3328, 3584, 3840, 4096, 4608, 5120, 5632, 6144, 6656, 7168, 7680, 8192, 8704, 9216, 10240, 11264, 12288, 13824 }; const Word16 Ratios_WB_6_fx[32] = /* 6 */{ 256, 384, 512, 640, 768, 896, 1024, 1152, 1280, 1408, 1536, 1664, 1792, 1920, 2048, 2304, 2560, 2816, 3072, 3328, 3584, 3840, 4096, 4608, 5120, 5632, 6144, 6656, 7168, 8704, 10240, 10496 }; const Word16 Ratios_WB_7_fx[32] = /* 7 */{ 256, 384, 512, 640, 768, 896, 1024, 1152, 1280, 1536, 1792, 2048, 2304, 2560, 2816, 3072, 3328, 3584, 3840, 4096, 4352, 4608, 4864, 5120, 5376, 5760, 6144, 6400, 6912, 7168, 7680, 8960 }; const Word16 Ratios_WB_8_fx[16] = /* 8 */{ 128, 256, 384, 512, 640, 768, 896, 1024, 1152, 1280, 1408, 1536, 1792, 2048, 2304, 2560 }; const Word16 Ratios_WB_9_fx[16] = /* 9 */{ 256, 512, 640, 768, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 3072, 3840, 4096, 4608, 6912 }; const Word16 Ratios_WB_10_fx[16] = /* 10 */{ 256, 384, 512, 640, 768, 896, 1024, 1280, 1536, 2048, 2560, 3840, 4608, 5632, 6144, 6656 }; const Word16 Ratios_WB_11_fx[16] = /* 11 */{ 256, 384, 512, 640, 768, 896, 1024, 1280, 1536, 2048, 2560, 3072, 3328, 3584, 4608, 5376 }; const Word16 Ratios_WB_12_fx[16] = /* 12 */{ 128, 256, 384, 512, 640, 768, 1024, 1280, 1536, 2048, 2304, 2816, 3072, 3456, 4096, 5120 }; const Word16 Ratios_WB_13_fx[16] = /* 13 */{ 128, 256, 384, 512, 640, 768, 1024, 1280, 1536, 1792, 2048, 2560, 2816, 3072, 3584, 5120 }; const Word16 Ratios_WB_14_fx[16] = /* 14 */{ 128, 256, 384, 512, 640, 768, 1024, 1152, 1536, 1920, 2304, 2560, 3072, 3584, 3840, 4608 }; const Word16 Ratios_WB_15_fx[16] = /* 15 */{ 128, 256, 320, 384, 448, 512, 640, 768, 896, 1024, 1152, 1280, 1536, 2048, 2304, 3584 }; const Word16 Ratios_WB_16_fx[4] = /* 16 */{ 128, 256, 512, 1024 }; const Word16 Ratios_WB_17_fx[4] = /* 17 */{ 256, 384, 512, 1024 }; const Word16 Ratios_WB_18_fx[4] = /* 18 */{ 256, 512, 768, 1024 }; /******************************************************************************/ /* 7Q8 */ const Word16 Ratios_NB_2_fx[32] = /* 2 */{ 768, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 2816, 3072, 3328, 3584, 3840, 4096, 4352, 4608, 4864, 5120, 5376, 5632, 5888, 6144, 6400, 6656, 6912, 7168, 7680, 8192, 8704, 9216, 9728, 10240 }; const Word16 Ratios_NB_3_fx[16] = /* 3 */{ 128, 256, 512, 768, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 3072, 4096, 5120, 6144, 7680 }; const Word16 Ratios_NB_4_fx[16] = /* 4 */{ 512, 768, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 3072, 3584, 4096, 4608, 5120, 6144, 7680 }; const Word16 Ratios_NB_5_fx[16] = /* 5 */{ 512, 768, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 3072, 3584, 4096, 4608, 5120, 6144, 7680 }; const Word16 Ratios_NB_6_fx[16] = /* 6 */{ 512, 640, 768, 896, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 3072, 3584, 4096, 4608, 5120 }; const Word16 Ratios_NB_7_fx[16] = /* 7 */{ 256, 512, 640, 768, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 3072, 3584, 4096, 4608, 5120 }; const Word16 Ratios_NB_8_fx[16] = /* 8 */{ 256, 384, 512, 640, 768, 896, 1024, 1152, 1280, 1536, 1792, 2048, 2304, 2560, 3072, 4096 }; const Word16 Ratios_NB_9_fx[8] = /* 9 */{ 256, 512, 768, 1024, 1280, 1536, 2048, 2560 }; const Word16 Ratios_NB_10_fx[8] = /* 10 */{ 256, 512, 768, 1024, 1280, 1536, 2048, 2560 }; const Word16 Ratios_NB_11_fx[8] = /* 11 */{ 256, 384, 512, 768, 1024, 1280, 1536, 2048 }; const Word16 Ratios_NB_12_fx[8] = /* 12 */{ 256, 512, 640, 768, 1024, 1280, 1536, 2048 }; const Word16 Ratios_NB_13_fx[4] = /* 13 */{ 256, 512, 768, 1024 }; const Word16 Ratios_NB_14_fx[4] = /* 14 */{ 256, 512, 1024, 1536 }; const Word16 Ratios_NB_15_fx[4] = /* 15 */{ 256, 512, 768, 1024 }; const Word16 Ratios_NB_16_fx[4] = /* 16 */{ 256, 384, 512, 1024 }; const Word16 Ratios_NB_17_fx[4] = /* 17 */{ 256, 384, 512, 768 }; const Word16 Ratios_NB_18_fx[4] = /* 18 */{ 128, 256, 512, 768 }; /******************************************************************************/ const Word16 *const Ratios_fx[2][17] = { /* NB */ { Ratios_NB_2_fx, Ratios_NB_3_fx, Ratios_NB_4_fx, Ratios_NB_5_fx, Ratios_NB_6_fx, Ratios_NB_7_fx, Ratios_NB_8_fx, Ratios_NB_9_fx, Ratios_NB_10_fx, Ratios_NB_11_fx, Ratios_NB_12_fx, Ratios_NB_13_fx, Ratios_NB_14_fx, Ratios_NB_15_fx , Ratios_NB_16_fx , Ratios_NB_17_fx , Ratios_NB_18_fx }, /* WB */ { Ratios_WB_2_fx, Ratios_WB_3_fx, Ratios_WB_4_fx, Ratios_WB_5_fx, Ratios_WB_6_fx, Ratios_WB_7_fx, Ratios_WB_8_fx, Ratios_WB_9_fx, Ratios_WB_10_fx, Ratios_WB_11_fx, Ratios_WB_12_fx, Ratios_WB_13_fx, Ratios_WB_14_fx, Ratios_WB_15_fx , Ratios_WB_16_fx , Ratios_WB_17_fx , Ratios_WB_18_fx } }; #define QGC(x) FL2WORD16_SCALE(x, 4) const Word16 qGains[2][1 << kTcxHmNumGainBits] = {
lib_com/rom_com.h +36 −0 Original line number Diff line number Diff line Loading @@ -1473,6 +1473,42 @@ extern const float Ratios_NB_17[4]; extern const float Ratios_NB_18[4]; extern const float *const Ratios[2][17]; extern const Word16 Ratios_WB_2_fx[32]; extern const Word16 Ratios_WB_3_fx[32]; extern const Word16 Ratios_WB_4_fx[32]; extern const Word16 Ratios_WB_5_fx[32]; extern const Word16 Ratios_WB_6_fx[32]; extern const Word16 Ratios_WB_7_fx[32]; extern const Word16 Ratios_WB_8_fx[16]; extern const Word16 Ratios_WB_9_fx[16]; extern const Word16 Ratios_WB_10_fx[16]; extern const Word16 Ratios_WB_11_fx[16]; extern const Word16 Ratios_WB_12_fx[16]; extern const Word16 Ratios_WB_13_fx[16]; extern const Word16 Ratios_WB_14_fx[16]; extern const Word16 Ratios_WB_15_fx[16]; extern const Word16 Ratios_WB_16_fx[4]; extern const Word16 Ratios_WB_17_fx[4]; extern const Word16 Ratios_WB_18_fx[4]; extern const Word16 Ratios_NB_2_fx[32]; extern const Word16 Ratios_NB_3_fx[16]; extern const Word16 Ratios_NB_4_fx[16]; extern const Word16 Ratios_NB_5_fx[16]; extern const Word16 Ratios_NB_6_fx[16]; extern const Word16 Ratios_NB_7_fx[16]; extern const Word16 Ratios_NB_8_fx[16]; extern const Word16 Ratios_NB_9_fx[8]; extern const Word16 Ratios_NB_10_fx[8]; extern const Word16 Ratios_NB_11_fx[8]; extern const Word16 Ratios_NB_12_fx[8]; extern const Word16 Ratios_NB_13_fx[4]; extern const Word16 Ratios_NB_14_fx[4]; extern const Word16 Ratios_NB_15_fx[4]; extern const Word16 Ratios_NB_16_fx[4]; extern const Word16 Ratios_NB_17_fx[4]; extern const Word16 Ratios_NB_18_fx[4]; extern const Word16 *const Ratios_fx[2][17]; extern const Word16 qGains[2][1 << kTcxHmNumGainBits]; /*----------------------------------------------------------------------------------* Loading
lib_dec/ari_dec.c +27 −0 Original line number Diff line number Diff line Loading @@ -100,6 +100,33 @@ int16_t ari_start_decoding_14bits_prm( return bp; } Word16 ari_start_decoding_14bits_prm_fx( const Word16 *ptr, Word16 bp, Tastat *s ) { Word32 val; Word16 i; const Word16 *p; val = L_deposit_l(0); p = ptr + bp; FOR(i = 0; i < cbitsnew; i++) { val = L_or(L_shl(val, 1), *(p + i)); } s->low = L_deposit_l(0); s->high = ari_q4new; move32(); s->value = val; move32(); return add(bp, i); } /*--------------------------------------------------------------- * ari_decode_14bits_s17_ext() * Loading