Commit bca9f984 authored by Fabian Bauer's avatar Fabian Bauer
Browse files

add macro HARMONIZE_2543_SQ_gain and code

parent 26ae1a66
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -97,6 +97,7 @@
#define FIX_BASOP_2509_EVS_CONCEAL_UNINIT_MEM           /* FhG: BASOP 2509: st->hTcxCfg->psychParamsCurrent is not initialized */
#define HARMONIZE_2499_CONFIGUREFDCNGDEC                /* FhG: basop issue 2499: harmonoize configureFdCngDec */
#define FIX_BASOP_2530_IVAS_DECISION_MAT                /* VA: Fix ambiguous usage of extract_l() */
#define HARMONIZE_2543_SQ_gain                          /* FhG: Harmonize SQ_gain */


/* #################### End BE switches ################################## */
+24 −0
Original line number Diff line number Diff line
@@ -1432,10 +1432,18 @@ void QuantizeSpectrum_fx(

                /* Quantize original spectrum */

#ifdef HARMONIZE_2543_SQ_gain
                sqGain = SQ_gain_fx( OriginalSpectrum, OriginalSpectrum_e,
                                     shl( mult( hTcxEnc->tcx_target_bits_fac, sqTargetBits ), 1 ),
                                     L_spec,
                                     &sqGain_e,
                                     EVS_MONO );
#else
                sqGain = SQ_gain_fx( OriginalSpectrum, OriginalSpectrum_e,
                                     shl( mult( hTcxEnc->tcx_target_bits_fac, sqTargetBits ), 1 ),
                                     L_spec,
                                     &sqGain_e );
#endif

                tcx_scalar_quantization_fx( OriginalSpectrum, OriginalSpectrum_e,
                                            sqQ,
@@ -1524,10 +1532,18 @@ void QuantizeSpectrum_fx(
                PeriodicityIndex = -1;
                move16();

#ifdef HARMONIZE_2543_SQ_gain
                sqGain = SQ_gain_fx( spectrum, *spectrum_e,
                                     shl( mult( hTcxEnc->tcx_target_bits_fac, sqTargetBits ), 1 ),
                                     L_spec,
                                     &sqGain_e,
                                     EVS_MONO );
#else
                sqGain = SQ_gain_fx( spectrum, *spectrum_e,
                                     shl( mult( hTcxEnc->tcx_target_bits_fac, sqTargetBits ), 1 ),
                                     L_spec,
                                     &sqGain_e );
#endif

                /* Quantize spectrum */

@@ -3027,7 +3043,11 @@ void QuantizeTCXSpectrum_fx(
            }

            /* Quantize original spectrum */
#ifdef HARMONIZE_2543_SQ_gain
            sqGain_fx = SQ_gain_fx( spectrum_fx, *spectrum_e, ( mult( hTcxEnc->tcx_target_bits_fac, shl( sqTargetBits, 1 ) ) ), L_spec, &sqGain_e, st->element_mode );
#else
            sqGain_fx = SQ_gain_ivas_fx( spectrum_fx, *spectrum_e, ( mult( hTcxEnc->tcx_target_bits_fac, shl( sqTargetBits, 1 ) ) ), L_spec, &sqGain_e );
#endif

            tcx_scalar_quantization_ivas_fx( spectrum_fx, *spectrum_e, sqQ, L_spec, sqGain_fx, sqGain_e, st->hTcxCfg->sq_rounding, hTcxEnc->memQuantZeros, st->tcxonly );

@@ -3118,7 +3138,11 @@ void QuantizeTCXSpectrum_fx(
            }
            ELSE
            {
#ifdef HARMONIZE_2543_SQ_gain
                sqGain_fx = SQ_gain_fx( spectrum_fx, *spectrum_e, shl( mult( hTcxEnc->tcx_target_bits_fac, sqTargetBits ), 1 ), L_spec, &sqGain_e, st->element_mode );
#else
                sqGain_fx = SQ_gain_ivas_fx( spectrum_fx, *spectrum_e, shl( mult( hTcxEnc->tcx_target_bits_fac, sqTargetBits ), 1 ), L_spec, &sqGain_e );
#endif
            }
            /* Quantize spectrum */
            tcx_scalar_quantization_ivas_fx( spectrum_fx, *spectrum_e, sqQ, L_spec, sqGain_fx, sqGain_e, st->hTcxCfg->sq_rounding, hTcxEnc->memQuantZeros, st->tcxonly );
+11 −0
Original line number Diff line number Diff line
@@ -1081,6 +1081,16 @@ void AdaptLowFreqEmph_fx(
    const Word16 lg );

/* o  : SQ gain                   */
#ifdef HARMONIZE_2543_SQ_gain
Word16 SQ_gain_fx(
    Word32 x[],         /* i  :  vector to quantize        */
    Word16 x_e,         /* i  :  exponent                  */
    Word16 nbitsSQ,     /* i  :  number of bits targeted   */
    Word16 lg,          /* i  :  vector size (2048 max)    */
    Word16 *gain_e,     /* o  :  SQ gain exponent          */
    Word16 element_mode /* i  :  is EVS or not             */
);
#else
Word16 SQ_gain_fx(
    Word32 x[],     /* i  :  vector to quantize        */
    Word16 x_e,     /* i  :  exponent                  */
@@ -1097,6 +1107,7 @@ Word16 SQ_gain_ivas_fx(
    Word16 lg,      /* i  :  vector size (2048 max)    */
    Word16 *gain_e  /* o  : SQ gain exponent          */
);
#endif

/* o  : SQ gain                   */
Word16 SQ_gain_estimate_fx(
+23 −7
Original line number Diff line number Diff line
@@ -827,7 +827,7 @@ void PsychAdaptLowFreqEmph_fx(
    return;
}


#ifndef HARMONIZE_2543_SQ_gain
/* o: SQ gain  */
Word16 SQ_gain_fx(
    Word32 x[],      /* i  :  vector to quantize        */
@@ -941,15 +941,27 @@ Word16 SQ_gain_fx(

    return tmp16;
}

#endif

/* o: SQ gain  */
#ifdef HARMONIZE_2543_SQ_gain
Word16 SQ_gain_fx(
    Word32 x[],         /* i  : vector to quantize        */
    Word16 x_e,         /* i  : exponent                  */
    Word16 nbitsSQ,     /* i  : number of bits targeted   */
    Word16 lg,          /* i  : vector size (2048 max)    */
    Word16 *gain_e,     /* o  : SQ gain exponent          */
    Word16 element_mode /* i  : is EVS or not             */
)
#else
Word16 SQ_gain_ivas_fx(
    Word32 x[],     /* i  : vector to quantize        */
    Word16 x_e,     /* i  : exponent                  */
    Word16 nbitsSQ, /* i  : number of bits targeted   */
    Word16 lg,      /* i  : vector size (2048 max)    */
    Word16 *gain_e ) /* o  : SQ gain exponent          */
    Word16 *gain_e  /* o  : SQ gain exponent          */
)
#endif
{
    Word16 i, iter, lg_4, s, tmp16;
    Word32 ener, tmp32;
@@ -1009,7 +1021,11 @@ Word16 SQ_gain_ivas_fx(
        s = shl( sub( x_e, s ), 1 );

        /* log */
#ifdef HARMONIZE_2543_SQ_gain
        IF( EQ_32( ener, 1 ) && GT_16( element_mode, EVS_MONO ) )
#else
        IF( EQ_32( ener, 1 ) )
#endif
        {
            en[i] = -131072; /* log10(0.01) in Q16 */
            move32();