Commit 0ee6276d authored by multrus's avatar multrus
Browse files

[cleanup] accept HARM_2454_TCX_RES_Q_SPEC

parent 0e798db4
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -84,7 +84,6 @@
#define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR      /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */
#define NONBE_1122_KEEP_EVS_MODE_UNCHANGED              /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR.  */
#define HARM_HQ_CORE_KEEP_BE                            /* hack to keep all BE after HQ core functions harmonization; pending resolving issues #2450, #2451, #2452 */
#define HARM_2454_TCX_RES_Q_SPEC                        /* FhG: harmonization of tcx_res_Q_spec_fx() and tcx_res_Q_spec_ivas_fx() */
#define FIX_FLOAT_1535_ARI_RES_Q_CLEANUP                /* FhG: remove dead code from tcx_ari_res_Q_spec() */
#define HQ_ALIGN_DUPLICATED_CODE                        /* Eri: Align duplicated code */
#define FIX_2467_RENAME_GSC_FUNCTION                    /* VA: basop issue 2467: Removal of unused function/table and renaming of _ivas_fx versions to default ones. */
+0 −8
Original line number Diff line number Diff line
@@ -3589,19 +3589,11 @@ void QuantizeTCXSpectrum_fx(
            resQBits = tcx_res_Q_gain_fx( gain_tcx_opt_fx, gain_tcx_opt_e, gain_tcx_fx, gain_tcx_e, sqQ + L_spec, resQTargetBits );
            IF( st->tcxonly )
            {
#ifdef HARM_2454_TCX_RES_Q_SPEC
                resQBits = tcx_res_Q_spec_fx( x_orig_fx, x_orig_e, spectrum_fx, *spectrum_e, L_spec, *gain_tcx_fx, *gain_tcx_e, sqQ + L_spec, resQTargetBits, resQBits, st->hTcxCfg->sq_rounding, NULL );
#else
                resQBits = tcx_res_Q_spec_ivas_fx( x_orig_fx, x_orig_e, spectrum_fx, *spectrum_e, L_spec, *gain_tcx_fx, *gain_tcx_e, sqQ + L_spec, resQTargetBits, resQBits, st->hTcxCfg->sq_rounding, NULL );
#endif
            }
            ELSE
            {
#ifdef HARM_2454_TCX_RES_Q_SPEC
                resQBits = tcx_res_Q_spec_fx( x_orig_fx, x_orig_e, spectrum_fx, *spectrum_e, L_spec, *gain_tcx_fx, *gain_tcx_e, sqQ + L_spec, resQTargetBits, resQBits, st->hTcxCfg->sq_rounding, lf_deemph_fact_fx );
#else
                resQBits = tcx_res_Q_spec_ivas_fx( x_orig_fx, x_orig_e, spectrum_fx, *spectrum_e, L_spec, *gain_tcx_fx, *gain_tcx_e, sqQ + L_spec, resQTargetBits, resQBits, st->hTcxCfg->sq_rounding, lf_deemph_fact_fx );
#endif
            }
        }
    }
+0 −15
Original line number Diff line number Diff line
@@ -1296,21 +1296,6 @@ Word16 tcx_res_Q_spec_fx(
    Word16 sq_round,
    const Word16 lf_deemph_factors[] );

#ifndef HARM_2454_TCX_RES_Q_SPEC
Word16 tcx_res_Q_spec_ivas_fx(
    Word32 *x_orig,
    Word16 x_orig_e,
    Word32 *x_Q,
    Word16 x_Q_e,
    Word16 L_frame,
    Word16 sqGain,
    Word16 sqGain_e,
    Word16 *prm,
    Word16 sqTargetBits,
    Word16 bits,
    Word16 sq_round,
    const Word16 lf_deemph_factors[] );
#endif
/* compute noise-measure flags for spectrum filling and quantization (0: tonal, 1: noise-like) */
void ComputeSpectrumNoiseMeasure_fx(
    const Word32 *powerSpec,
+0 −183
Original line number Diff line number Diff line
@@ -3392,7 +3392,6 @@ Word16 tcx_res_Q_gain_fx(
    return bits;
}

#ifndef HARM_2454_TCX_RES_Q_SPEC
Word16 tcx_res_Q_spec_fx(
    Word32 *x_orig,
    Word16 x_orig_e,
@@ -3407,188 +3406,6 @@ Word16 tcx_res_Q_spec_fx(
    Word16 sq_round,
    const Word16 lf_deemph_factors[] /* 1Q14 */
)
{
    Word16 i;
    Word16 fac_m, fac_p;
    Word32 tmp1, tmp2;
    Word16 s, s2, lf_deemph_factor;
    Word16 c;
    Word32 thres;

    /* Limit the number of residual bits */
    sqTargetBits = s_min( sqTargetBits, NPRM_RESQ );

    /* Requantize the spectrum line-by-line */
    fac_m = shr( sq_round, 1 );
    fac_p = sub( 0x4000, fac_m );

    /* exponent difference of x_orig and x_Q * sqGain */
    s = sub( x_orig_e, add( x_Q_e, sqGain_e ) );

    lf_deemph_factor = 0x4000;
    move16();
    s2 = sub( x_Q_e, 1 );

    FOR( i = 0; i < L_frame; i++ )
    {
        IF( GE_16( bits, sub( sqTargetBits, kMaxEstimatorUndershoot ) ) )
        {
            fac_m = 0;
            move16();
            fac_p = 0;
            move16();

            IF( GE_16( bits, s_min( NPRM_RESQ, add( sqTargetBits, kMaxEstimatorOvershoot ) ) ) )
            {
                BREAK;
            }
        }

        test();
        test();
        IF( ( x_Q[i] != 0 ) && ( ( lf_deemph_factors == NULL ) || ( GT_16( lf_deemph_factors[i], 0x2000 ) ) ) )
        {
            tmp1 = L_add( x_orig[i], 0 );
            tmp2 = Mpy_32_16_1( x_Q[i], sqGain );
            IF( s > 0 )
            {
                tmp2 = L_shr( tmp2, s );
            }
            IF( s < 0 )
            {
                tmp1 = L_shl( tmp1, s );
            }

            if ( lf_deemph_factors != NULL )
            {
                lf_deemph_factor = lf_deemph_factors[i];
                move16();
            }

            IF( LT_32( tmp1, tmp2 ) )
            {
                prm[bits] = 0;
                move16();
                bits = add( bits, 1 );

                IF( x_Q[i] > 0 )
                {
                    tmp1 = L_mult( fac_m, lf_deemph_factor );
                }
                IF( x_Q[i] < 0 )
                {
                    tmp1 = L_mult( fac_p, lf_deemph_factor );
                }
                x_Q[i] = L_sub( x_Q[i], L_shr( tmp1, s2 ) );
                move32();
            }
            ELSE
            {
                prm[bits] = 1;
                move16();
                bits = add( bits, 1 );

                IF( x_Q[i] > 0 )
                {
                    tmp1 = L_mult( fac_p, lf_deemph_factor );
                }
                IF( x_Q[i] < 0 )
                {
                    tmp1 = L_mult( fac_m, lf_deemph_factor );
                }
                x_Q[i] = L_add( x_Q[i], L_shr( tmp1, s2 ) );
                move32();
            }
        }
    }

    /*Quantize zeroed-line of the spectrum*/
    c = sub( 21627 /*0.66f Q15*/, mult_r( sq_round, 21627 /*0.66f Q15*/ ) );

    FOR( i = 0; i < L_frame; i++ )
    {
        IF( GE_16( bits, sub( sqTargetBits, 2 ) ) )
        {
            BREAK;
        }

        test();
        test();
        IF( ( x_Q[i] == 0 ) && ( ( lf_deemph_factors == NULL ) || ( GT_16( lf_deemph_factors[i], 0x2000 ) ) ) )
        {
            if ( lf_deemph_factors != NULL )
            {
                lf_deemph_factor = lf_deemph_factors[i];
                move16();
            }

            thres = L_mult( c, lf_deemph_factor );
            tmp1 = L_shl( Mpy_32_16_1( thres, sqGain ), sub( sqGain_e, x_orig_e ) );

            IF( GT_32( x_orig[i], tmp1 ) )
            {
                prm[bits] = 1;
                move16();
                bits = add( bits, 1 );

                prm[bits] = 1;
                move16();
                bits = add( bits, 1 );

                x_Q[i] = L_shl( thres, sub( 1, x_Q_e ) );
                move32();
            }
            ELSE IF( L_add( x_orig[i], tmp1 ) < 0 )
            {
                prm[bits] = 1;
                move16();
                bits = add( bits, 1 );

                prm[bits] = 0;
                move16();
                bits = add( bits, 1 );

                x_Q[i] = L_shl( L_negate( thres ), sub( 1, x_Q_e ) );
                move32();
            }
            ELSE
            {
                prm[bits] = 0;
                move16();
                bits = add( bits, 1 );
            }
        }
    }

    /*Be sure that every possible bits are initialized*/
    FOR( i = bits; i < NPRM_RESQ; i++ )
    {
        prm[i] = 0;
        move16();
    }


    return bits;
}


Word16 tcx_res_Q_spec_ivas_fx(
#else
Word16 tcx_res_Q_spec_fx(
#endif
    Word32 *x_orig,
    Word16 x_orig_e,
    Word32 *x_Q,
    Word16 x_Q_e,
    Word16 L_frame,
    Word16 sqGain,
    Word16 sqGain_e,
    Word16 *prm,
    Word16 sqTargetBits,
    Word16 bits,
    Word16 sq_round,
    const Word16 lf_deemph_factors[] /* 1Q14 */
)
{
    Word16 i;
    Word16 fac_m, fac_p;