Commit 62ce3743 authored by Fabian Bauer's avatar Fabian Bauer
Browse files

create macro to test evs-precision in ivas-case

parent bc3120e8
Loading
Loading
Loading
Loading
Loading
+27 −9
Original line number Diff line number Diff line
@@ -1941,7 +1941,7 @@ void perform_noise_estimation_enc_ivas_fx(
 * Generate a bitstream out of the partition levels
 *-------------------------------------------------------------------*/
#ifdef FIX_2489_HARMONIZE_FdCng_encodeSID
#define FIX_2489_HARMONIZE_FdCng_encodeSID_IVASHP /* FhG: check FdCng_encodeSID higher precision in IVAS case - development  */
#define FIX_2489_HARMONIZE_FdCng_encodeSID_IVASHP /* FhG: activate FdCng_encodeSID higher precision in IVAS case - development  */
void FdCng_encodeSID_fx(
    Encoder_State *corest /* i/o: encoder state structure     */
)
@@ -1972,7 +1972,10 @@ void FdCng_encodeSID_fx(

    /* Convert to LOG */
    e_fx = L_deposit_l( 0 );

#ifdef FIX_2489_HARMONIZE_FdCng_encodeSID_IVASHP
    IF( element_mode == 0 )
#endif
    {
        Word16 normShiftN = BASOP_util_norm_s_bands2shift( N );
        Word16 normFacN = getNormReciprocalWord16( N );
@@ -1989,6 +1992,7 @@ void FdCng_encodeSID_fx(
        }
        e_fx = L_shl( Mpy_32_16_1( e_fx, shl( normFacN, sub( normShiftN, 1 ) ) ), 1 );
    }
#ifdef FIX_2489_HARMONIZE_FdCng_encodeSID_IVASHP
    ELSE
    {
        set_zero_fx( v_fx, FDCNG_VQ_MAX_LEN );
@@ -2008,12 +2012,15 @@ void FdCng_encodeSID_fx(
            e_fx = L_add( e_fx, L_shr( v_fx[i], 1 ) ); // Q19, add one bit headroom
        }
    }
#endif

    /* Normalize MSVQ input */

    gain_fx = 0;
    move32();
#ifdef FIX_2489_HARMONIZE_FdCng_encodeSID_IVASHP
    IF( element_mode == 0 )
#endif
    {
        Word16 normFacGain = getNormReciprocalWord16( N_GAIN_MAX - N_GAIN_MIN );
        Word16 normShiftGain = BASOP_util_norm_s_bands2shift( N_GAIN_MAX - N_GAIN_MIN );
@@ -2024,6 +2031,7 @@ void FdCng_encodeSID_fx(
        }
        gain_fx = L_shl( Mpy_32_16_1( gain_fx, shl( normFacGain, sub( normShiftGain, 1 ) ) ), 1 );
    }
#ifdef FIX_2489_HARMONIZE_FdCng_encodeSID_IVASHP
    ELSE
    {
        FOR( i = N_GAIN_MIN; i < N_GAIN_MAX; i++ )
@@ -2040,6 +2048,7 @@ void FdCng_encodeSID_fx(
            move32();
        }
    }
#endif

    /*MSVQ*/
    IF( element_mode == 0 )
@@ -2098,7 +2107,9 @@ void FdCng_encodeSID_fx(
    }

    /* Compute gain */
#ifdef FIX_2489_HARMONIZE_FdCng_encodeSID_IVASHP
    IF( element_mode == 0 )
#endif
    {
        Word16 normShiftN = BASOP_util_norm_s_bands2shift( N );
        Word16 normFacN = getNormReciprocalWord16( N );
@@ -2109,12 +2120,8 @@ void FdCng_encodeSID_fx(
            gain_fx = L_add( gain_fx, L_shr( v_fx[i], normShiftN ) );
        }
        gain_fx = L_sub( e_fx, L_shl( Mpy_32_16_1( gain_fx, shl( normFacN, sub( normShiftN, 1 ) ) ), 1 ) );

        /* Apply bitrate-dependant scale */
        {
            apply_scale( &gain_fx, hFdCngCom->CngBandwidth, hFdCngCom->CngBitrate, scaleTableMono, SIZE_SCALE_TABLE_MONO );
        }
    }
#ifdef FIX_2489_HARMONIZE_FdCng_encodeSID_IVASHP
    ELSE
    {
        Word16 v_e = sub( 31, sub( 20, find_guarded_bits_fx( N ) ) );
@@ -2127,25 +2134,32 @@ void FdCng_encodeSID_fx(
        e_fx = L_shl( e_fx, sub( 12, v_e ) );                           // Q = 31 - v_e
        gain_fx = Mpy_32_16_1( L_sub( e_fx, gain_fx ), div_s( 1, N ) ); // Q = 31 - v_e
        gain_fx = L_shl( gain_fx, sub( v_e, 8 ) );                      // Q23
    }
#endif

    /* Apply bitrate-dependant scale */
        apply_scale( &gain_fx, hFdCngCom->CngBandwidth, hFdCngCom->CngBitrate, scaleTableStereo, SIZE_SCALE_TABLE_STEREO );
    }
    apply_scale( &gain_fx, hFdCngCom->CngBandwidth, hFdCngCom->CngBitrate, 
      ( element_mode == 0 ) ? ( scaleTableMono ) : ( scaleTableStereo ), 
      ( element_mode == 0 ) ? ( SIZE_SCALE_TABLE_MONO  ) : ( SIZE_SCALE_TABLE_STEREO ) );


    /* Quantize gain */
#ifdef FIX_2489_HARMONIZE_FdCng_encodeSID_IVASHP
    IF( element_mode == 0 )
#endif
    {
        /*Q14.23 format */
        gain_fx = L_add( gain_fx, L_shr( gain_fx, 1 ) );
        gain_fx = L_add( gain_fx, 507510784l /*60.5 Q23*/ );
        index = extract_l( L_shr( gain_fx, WORD32_BITS - 1 - 8 ) );
    }
#ifdef FIX_2489_HARMONIZE_FdCng_encodeSID_IVASHP
    ELSE
    {
        temp = Madd_32_32( L_shl( GAIN_Q_OFFSET_IVAS_FX_Q0, 22 ), gain_fx, 1610612736 /*1.5 in Q30*/ ); // Q22
        index = extract_l( L_shr( L_add( temp, ONE_IN_Q21 ), 22 ) );                                    // Q0
    }
#endif

    if ( index < 0 )
    {
@@ -2160,7 +2174,9 @@ void FdCng_encodeSID_fx(
    }

    /* Apply gain and undo log */
#ifdef FIX_2489_HARMONIZE_FdCng_encodeSID_IVASHP
    IF( element_mode == 0 )
#endif
    {
        Word32 E_ExpLd64;
        /* gain Q14.23 format */
@@ -2203,6 +2219,7 @@ void FdCng_encodeSID_fx(
            move32();
        }
    }
#ifdef FIX_2489_HARMONIZE_FdCng_encodeSID_IVASHP
    ELSE
    {
        Word16 v_e = sub( 31, sub( 20, find_guarded_bits_fx( N ) ) );
@@ -2224,6 +2241,7 @@ void FdCng_encodeSID_fx(
            move32();
        }
    }
#endif

    /* NB last band energy compensation */
    IF( EQ_16( hFdCngCom->CngBandwidth, NB ) )