Loading lib_enc/cod_tcx_fx.c +46 −15 Original line number Diff line number Diff line Loading @@ -1594,6 +1594,7 @@ void QuantizeSpectrum_fx( phm_cfg = hm_cfg; move16(); } #ifndef FIX_BASOP_2546_HARMONIZE_TCX_SCALAR sqBits = tcx_scalar_quantization_rateloop_fx(spectrum, *spectrum_e, sqQ, L_spec, Loading @@ -1609,6 +1610,36 @@ void QuantizeSpectrum_fx( hTcxCfg->tcxRateLoopOpt, tcxonly, phm_cfg ); #else Word16 max_iter = 4; move16(); IF(EQ_16(st->element_mode, IVAS_CPE_MDCT)) { max_iter = 2; move16(); } sqBits = tcx_scalar_quantization_rateloop_ivas_fx(spectrum, *spectrum_e, sqQ, L_spec, &sqGain, &sqGain_e, hTcxCfg->sq_rounding, hTcxEnc->memQuantZeros, prm_lastnz, /* lastnz */ sqTargetBits, &nEncoded, &stop, sqBits_noStop, sqBits, hTcxCfg->tcxRateLoopOpt, tcxonly, phm_cfg, max_iter, st->element_mode); //sqBits = tcx_scalar_quantization_rateloop_ivas_fx(spectrum_fx, *spectrum_e, sqQ, L_spec, &sqGain_fx, &sqGain_e, st->hTcxCfg->sq_rounding, hTcxEnc->memQuantZeros, prm_lastnz, /* lastnz */ sqTargetBits, &nEncoded, &stop, sqBits_noStop, sqBits, st->hTcxCfg->tcxRateLoopOpt, st->tcxonly, phm_cfg, max_iter, st->element_mode); #endif // !FIX_BASOP_2546_HARMONIZE_TCX_SCALAR IF( ctxHmBits > 0 ) /* Mapping tool is enabled */ { Loading lib_enc/tcx_utils_enc_fx.c +121 −9 Original line number Diff line number Diff line Loading @@ -1753,13 +1753,73 @@ Word16 tcx_scalar_quantization_rateloop_ivas_fx( move16(); Word16 tmp, fac1, fac2; Word32 tmp32; Word16 lastnz, saturated, minSqGain = 0; move16(); /* Init */ saturated = 0; move16(); /* minSqGain = (float) sqrt( (float) NORM_MDCT_FACTOR / (float) L_frame ); in Q14*/ #ifndef FIX_BASOP_2546_HARMONIZE_TCX_SCALAR SWITCH(L_frame) { case 80: minSqGain = 23170; BREAK; case 100: minSqGain = 20724; BREAK; case 160: minSqGain = 16384; BREAK; case 200: minSqGain = 14654; BREAK; case 240: minSqGain = 13377; BREAK; case 300: minSqGain = 11965; BREAK; case 320: minSqGain = 11585; BREAK; case 400: minSqGain = 10362; BREAK; case 480: minSqGain = 9459; BREAK; case 600: minSqGain = 8461; BREAK; case 640: minSqGain = 8192; BREAK; case 800: minSqGain = 7327; BREAK; case 960: minSqGain = 6689; BREAK; case 1200: minSqGain = 5983; BREAK; case 1440: minSqGain = 5461; BREAK; case 1800: minSqGain = 4885; BREAK; case 2048: minSqGain = 4579; BREAK; default: assert(0); } move16(); #else IF(NE_16(element_mode, EVS_MONO)) { SWITCH(L_frame) { case 80: Loading Loading @@ -1817,6 +1877,9 @@ Word16 tcx_scalar_quantization_rateloop_ivas_fx( assert(0); } move16(); } #endif // !FIX_BASOP_2546_HARMONIZE_TCX_SCALAR sqGain = *gain; move16(); sqGain_e = *gain_e; Loading Loading @@ -1876,8 +1939,15 @@ Word16 tcx_scalar_quantization_rateloop_ivas_fx( lb_e = sqGain_e; move16(); w_lb = add( sub( stopFlag, target ), kDampen ); #ifndef FIX_BASOP_2546_HARMONIZE_TCX_SCALAR saturated = 0; move16(); #else IF(NE_16(element_mode, EVS_MONO)) { saturated = 0; move16(); } #endif // !FIX_BASOP_2546_HARMONIZE_TCX_SCALAR IF( ubfound != 0 ) { /* common exponent for addition */ Loading Loading @@ -1938,7 +2008,21 @@ Word16 tcx_scalar_quantization_rateloop_ivas_fx( sqGain = mult( sqGain, sub( tmp, add( mod_adjust1, (Word16) 0x8000 ) ) ); sqGain = normalize16( sqGain, &sqGain_e ); } #ifndef FIX_BASOP_2546_HARMONIZE_TCX_SCALAR Word16 shift_tmp = s_max( sqGain_e, 1 ); move16(); test(); IF( LT_16( shl( sqGain, sub( sqGain_e, shift_tmp ) ), shl( minSqGain, sub( 1, shift_tmp ) ) ) && EQ_16( tcxRateLoopOpt, 3 ) ) { sqGain = minSqGain; move16(); sqGain_e = 1; move16(); saturated = 1; move16(); } #else IF(NE_16(element_mode, EVS_MONO )) { Word16 shift_tmp = s_max(sqGain_e, 1); move16(); test(); Loading @@ -1952,10 +2036,18 @@ Word16 tcx_scalar_quantization_rateloop_ivas_fx( move16(); } } #endif // !FIX_BASOP_2546_HARMONIZE_TCX_SCALAR } #ifndef FIX_BASOP_2546_HARMONIZE_TCX_SCALAR ELSE { BREAK; /* we cannot go any lower anyway*/ } #else ELSE IF(NE_16(element_mode, EVS_MONO)){ BREAK; /* we cannot go any lower anyway*/ } #endif // FIX_BASOP_2546_HARMONIZE_TCX_SCALAR } ELSE /* tcxRateLoopOpt != 2 */ { Loading Loading @@ -2013,8 +2105,16 @@ Word16 tcx_scalar_quantization_rateloop_ivas_fx( } /* Quantize spectrum */ #ifndef FIX_BASOP_2546_HARMONIZE_TCX_SCALAR tcx_scalar_quantization_ivas_fx(x, x_e, xq, L_frame, sqGain, sqGain_e, offset, memQuantZeros_fx, tcxonly); #else IF(EQ_16(element_mode, EVS_MONO)) { tcx_scalar_quantization_fx(x, x_e, xq, L_frame, sqGain, sqGain_e, offset, memQuantZeros_fx, tcxonly); } ELSE{ tcx_scalar_quantization_ivas_fx(x, x_e, xq, L_frame, sqGain, sqGain_e, offset, memQuantZeros_fx, tcxonly); } #endif // !FIX_BASOP_2546_HARMONIZE_TCX_SCALAR /* Estimate bitrate */ stopFlag = 1; move16(); Loading @@ -2023,8 +2123,11 @@ Word16 tcx_scalar_quantization_rateloop_ivas_fx( stopFlag = 0; move16(); } #ifndef FIX_BASOP_2546_HARMONIZE_TCX_SCALAR IF(GT_16(element_mode, EVS_MONO)) #else IF(NE_16(element_mode, EVS_MONO)) #endif // !FIX_BASOP_2546_HARMONIZE_TCX_SCALAR { sqBits = RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( xq, L_frame, &lastnz, nEncoded, target, &stopFlag, 0, hm_cfg ); } Loading Loading @@ -2066,8 +2169,17 @@ Word16 tcx_scalar_quantization_rateloop_ivas_fx( IF( GE_16( tcxRateLoopOpt, 1 ) ) { #ifndef FIX_BASOP_2546_HARMONIZE_TCX_SCALAR /* Quantize spectrum */ tcx_scalar_quantization_ivas_fx(x, x_e, xq, L_frame, *gain, *gain_e, offset, memQuantZeros_fx, tcxonly); #else IF(EQ_16(element_mode, EVS_MONO)) { tcx_scalar_quantization_fx(x, x_e, xq, L_frame, *gain, *gain_e, offset, memQuantZeros_fx, tcxonly); } ELSE{ tcx_scalar_quantization_ivas_fx(x, x_e, xq, L_frame, *gain, *gain_e, offset, memQuantZeros_fx, tcxonly); } #endif // !FIX_BASOP_2546_HARMONIZE_TCX_SCALAR /* Output */ *nEncoded = old_nEncoded; Loading Loading
lib_enc/cod_tcx_fx.c +46 −15 Original line number Diff line number Diff line Loading @@ -1594,6 +1594,7 @@ void QuantizeSpectrum_fx( phm_cfg = hm_cfg; move16(); } #ifndef FIX_BASOP_2546_HARMONIZE_TCX_SCALAR sqBits = tcx_scalar_quantization_rateloop_fx(spectrum, *spectrum_e, sqQ, L_spec, Loading @@ -1609,6 +1610,36 @@ void QuantizeSpectrum_fx( hTcxCfg->tcxRateLoopOpt, tcxonly, phm_cfg ); #else Word16 max_iter = 4; move16(); IF(EQ_16(st->element_mode, IVAS_CPE_MDCT)) { max_iter = 2; move16(); } sqBits = tcx_scalar_quantization_rateloop_ivas_fx(spectrum, *spectrum_e, sqQ, L_spec, &sqGain, &sqGain_e, hTcxCfg->sq_rounding, hTcxEnc->memQuantZeros, prm_lastnz, /* lastnz */ sqTargetBits, &nEncoded, &stop, sqBits_noStop, sqBits, hTcxCfg->tcxRateLoopOpt, tcxonly, phm_cfg, max_iter, st->element_mode); //sqBits = tcx_scalar_quantization_rateloop_ivas_fx(spectrum_fx, *spectrum_e, sqQ, L_spec, &sqGain_fx, &sqGain_e, st->hTcxCfg->sq_rounding, hTcxEnc->memQuantZeros, prm_lastnz, /* lastnz */ sqTargetBits, &nEncoded, &stop, sqBits_noStop, sqBits, st->hTcxCfg->tcxRateLoopOpt, st->tcxonly, phm_cfg, max_iter, st->element_mode); #endif // !FIX_BASOP_2546_HARMONIZE_TCX_SCALAR IF( ctxHmBits > 0 ) /* Mapping tool is enabled */ { Loading
lib_enc/tcx_utils_enc_fx.c +121 −9 Original line number Diff line number Diff line Loading @@ -1753,13 +1753,73 @@ Word16 tcx_scalar_quantization_rateloop_ivas_fx( move16(); Word16 tmp, fac1, fac2; Word32 tmp32; Word16 lastnz, saturated, minSqGain = 0; move16(); /* Init */ saturated = 0; move16(); /* minSqGain = (float) sqrt( (float) NORM_MDCT_FACTOR / (float) L_frame ); in Q14*/ #ifndef FIX_BASOP_2546_HARMONIZE_TCX_SCALAR SWITCH(L_frame) { case 80: minSqGain = 23170; BREAK; case 100: minSqGain = 20724; BREAK; case 160: minSqGain = 16384; BREAK; case 200: minSqGain = 14654; BREAK; case 240: minSqGain = 13377; BREAK; case 300: minSqGain = 11965; BREAK; case 320: minSqGain = 11585; BREAK; case 400: minSqGain = 10362; BREAK; case 480: minSqGain = 9459; BREAK; case 600: minSqGain = 8461; BREAK; case 640: minSqGain = 8192; BREAK; case 800: minSqGain = 7327; BREAK; case 960: minSqGain = 6689; BREAK; case 1200: minSqGain = 5983; BREAK; case 1440: minSqGain = 5461; BREAK; case 1800: minSqGain = 4885; BREAK; case 2048: minSqGain = 4579; BREAK; default: assert(0); } move16(); #else IF(NE_16(element_mode, EVS_MONO)) { SWITCH(L_frame) { case 80: Loading Loading @@ -1817,6 +1877,9 @@ Word16 tcx_scalar_quantization_rateloop_ivas_fx( assert(0); } move16(); } #endif // !FIX_BASOP_2546_HARMONIZE_TCX_SCALAR sqGain = *gain; move16(); sqGain_e = *gain_e; Loading Loading @@ -1876,8 +1939,15 @@ Word16 tcx_scalar_quantization_rateloop_ivas_fx( lb_e = sqGain_e; move16(); w_lb = add( sub( stopFlag, target ), kDampen ); #ifndef FIX_BASOP_2546_HARMONIZE_TCX_SCALAR saturated = 0; move16(); #else IF(NE_16(element_mode, EVS_MONO)) { saturated = 0; move16(); } #endif // !FIX_BASOP_2546_HARMONIZE_TCX_SCALAR IF( ubfound != 0 ) { /* common exponent for addition */ Loading Loading @@ -1938,7 +2008,21 @@ Word16 tcx_scalar_quantization_rateloop_ivas_fx( sqGain = mult( sqGain, sub( tmp, add( mod_adjust1, (Word16) 0x8000 ) ) ); sqGain = normalize16( sqGain, &sqGain_e ); } #ifndef FIX_BASOP_2546_HARMONIZE_TCX_SCALAR Word16 shift_tmp = s_max( sqGain_e, 1 ); move16(); test(); IF( LT_16( shl( sqGain, sub( sqGain_e, shift_tmp ) ), shl( minSqGain, sub( 1, shift_tmp ) ) ) && EQ_16( tcxRateLoopOpt, 3 ) ) { sqGain = minSqGain; move16(); sqGain_e = 1; move16(); saturated = 1; move16(); } #else IF(NE_16(element_mode, EVS_MONO )) { Word16 shift_tmp = s_max(sqGain_e, 1); move16(); test(); Loading @@ -1952,10 +2036,18 @@ Word16 tcx_scalar_quantization_rateloop_ivas_fx( move16(); } } #endif // !FIX_BASOP_2546_HARMONIZE_TCX_SCALAR } #ifndef FIX_BASOP_2546_HARMONIZE_TCX_SCALAR ELSE { BREAK; /* we cannot go any lower anyway*/ } #else ELSE IF(NE_16(element_mode, EVS_MONO)){ BREAK; /* we cannot go any lower anyway*/ } #endif // FIX_BASOP_2546_HARMONIZE_TCX_SCALAR } ELSE /* tcxRateLoopOpt != 2 */ { Loading Loading @@ -2013,8 +2105,16 @@ Word16 tcx_scalar_quantization_rateloop_ivas_fx( } /* Quantize spectrum */ #ifndef FIX_BASOP_2546_HARMONIZE_TCX_SCALAR tcx_scalar_quantization_ivas_fx(x, x_e, xq, L_frame, sqGain, sqGain_e, offset, memQuantZeros_fx, tcxonly); #else IF(EQ_16(element_mode, EVS_MONO)) { tcx_scalar_quantization_fx(x, x_e, xq, L_frame, sqGain, sqGain_e, offset, memQuantZeros_fx, tcxonly); } ELSE{ tcx_scalar_quantization_ivas_fx(x, x_e, xq, L_frame, sqGain, sqGain_e, offset, memQuantZeros_fx, tcxonly); } #endif // !FIX_BASOP_2546_HARMONIZE_TCX_SCALAR /* Estimate bitrate */ stopFlag = 1; move16(); Loading @@ -2023,8 +2123,11 @@ Word16 tcx_scalar_quantization_rateloop_ivas_fx( stopFlag = 0; move16(); } #ifndef FIX_BASOP_2546_HARMONIZE_TCX_SCALAR IF(GT_16(element_mode, EVS_MONO)) #else IF(NE_16(element_mode, EVS_MONO)) #endif // !FIX_BASOP_2546_HARMONIZE_TCX_SCALAR { sqBits = RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( xq, L_frame, &lastnz, nEncoded, target, &stopFlag, 0, hm_cfg ); } Loading Loading @@ -2066,8 +2169,17 @@ Word16 tcx_scalar_quantization_rateloop_ivas_fx( IF( GE_16( tcxRateLoopOpt, 1 ) ) { #ifndef FIX_BASOP_2546_HARMONIZE_TCX_SCALAR /* Quantize spectrum */ tcx_scalar_quantization_ivas_fx(x, x_e, xq, L_frame, *gain, *gain_e, offset, memQuantZeros_fx, tcxonly); #else IF(EQ_16(element_mode, EVS_MONO)) { tcx_scalar_quantization_fx(x, x_e, xq, L_frame, *gain, *gain_e, offset, memQuantZeros_fx, tcxonly); } ELSE{ tcx_scalar_quantization_ivas_fx(x, x_e, xq, L_frame, *gain, *gain_e, offset, memQuantZeros_fx, tcxonly); } #endif // !FIX_BASOP_2546_HARMONIZE_TCX_SCALAR /* Output */ *nEncoded = old_nEncoded; Loading