Commit 6f187732 authored by vaillancour's avatar vaillancour
Browse files

merge main

parents e71cea0d f48f63ab
Loading
Loading
Loading
Loading
Loading
+0 −110
Original line number Diff line number Diff line
@@ -58,11 +58,7 @@ ivas_error createFdCngCom_fx(
 *
 *-------------------------------------------------------------------*/

#ifdef FIX_2245_INIT_FD_CNG_EVS
void initFdCngCom(
#else
void ivas_initFdCngCom_fx(
#endif
    HANDLE_FD_CNG_COM hFdCngCom,
    Word16 scale )
{
@@ -178,112 +174,6 @@ void ivas_initFdCngCom_fx(
    return;
}

#ifndef FIX_2245_INIT_FD_CNG_EVS
void initFdCngCom( HANDLE_FD_CNG_COM hFdCngCom, Word16 scale )
{
    /* Calculate CLDFB scaling factor */
    /* shl(i_mult2(scale, scale), 3) does not fit in 16 bit */
    /*hFdCngCom->scalingFactor = div_s(1, shl(i_mult2(scale, scale), 3));*/
    assert( 2048 /*1.0/(1<<4) Q15*/ < mult( scale, scale ) );
    /* Exponent invScalingFactor: -16 = -(2*7 (scale) + 2 (8.0) */
    hFdCngCom->invScalingFactor = shl( mult( scale, scale ), 1 );
    move16();
    /* Exponent scalingFactor: -15 = -(2*7 (scale) + 2 (8.0) - 1 (1.0)) */
    hFdCngCom->scalingFactor = div_s( 0x4000, hFdCngCom->invScalingFactor );
    move16();

    /* Initialize the overlap-add */
    set16_fx( hFdCngCom->timeDomainBuffer, 0, L_FRAME16k );
    hFdCngCom->olapBufferAna = NULL;
    set16_fx( hFdCngCom->olapBufferAna_fx, 0, FFTLEN );

    set16_fx( hFdCngCom->olapBufferSynth, 0, FFTLEN );
    hFdCngCom->olapBufferSynth2 = NULL;

    /* Initialize the comfort noise generation */
    set32_fx( hFdCngCom->fftBuffer, 0, FFTLEN );
    set32_fx( hFdCngCom->cngNoiseLevel, 0, FFTCLDFBLEN );
    set16_fx( &hFdCngCom->cngNoiseLevelExp, 0, 1 );

    /* Initialize quantizer */
    set32_fx( hFdCngCom->sidNoiseEst, 0, NPART );
    set16_fx( &hFdCngCom->sidNoiseEstExp, 0, 1 );
    set16_fx( hFdCngCom->A_cng, 0, M + 1 );
    hFdCngCom->A_cng[0] = 4096 /*1.f Q12*/; /* 3Q12 */
    move16();

    /* Set some counters and flags */
    hFdCngCom->inactive_frame_counter = 0; /* Either SID or zero frames */
    move16();
    hFdCngCom->active_frame_counter = 0;
    move16();
    hFdCngCom->frame_type_previous = ACTIVE_FRAME;
    move16();
    hFdCngCom->flag_noisy_speech = 0;
    move16();
    hFdCngCom->likelihood_noisy_speech = 0;
    move16();
    hFdCngCom->numCoreBands = 0;
    move16();
    hFdCngCom->stopBand = 0;
    move16();
    hFdCngCom->startBand = 0;
    move16();
    hFdCngCom->stopFFTbin = 0;
    move16();
    hFdCngCom->frameSize = 0;
    move16();
    hFdCngCom->fftlen = 0;
    move16();
    hFdCngCom->seed = 0;
    move16();
    // hFdCngCom->seed2 = 1;
    // move16();
    // hFdCngCom->seed3 = 2;
    // move16();
    hFdCngCom->CngBitrate = -1;
    move16();

    /* Initialize noise estimation algorithm */
    set32_fx( hFdCngCom->periodog, 0, PERIODOGLEN );
    mhvals( MSNUMSUBFR * MSSUBFRLEN, &( hFdCngCom->msM_win ) );
    mhvals( MSSUBFRLEN, &( hFdCngCom->msM_subwin ) );
    set32_fx( hFdCngCom->msPeriodogSum, 0, 2 );
    hFdCngCom->msPeriodogSum_exp[0] = 0;
    move16();
    hFdCngCom->msPeriodogSum_exp[1] = 0;
    move16();
    set32_fx( hFdCngCom->msPsdSum, 0, 2 );
    set16_fx( hFdCngCom->msSlope, 0, 2 );
    set32_fx( hFdCngCom->msQeqInvAv, 0, 2 );
    hFdCngCom->msQeqInvAv_exp[0] = 0;
    move16();
    hFdCngCom->msQeqInvAv_exp[1] = 0;
    move16();
    hFdCngCom->msFrCnt_init_counter = 0;
    move16();
    hFdCngCom->msFrCnt_init_thresh = 1;
    move16();
    hFdCngCom->init_old = 0;
    move16();
    hFdCngCom->offsetflag = 0;
    move16();
    hFdCngCom->msFrCnt = MSSUBFRLEN;
    move16();
    hFdCngCom->msMinBufferPtr = 0;
    move16();
    hFdCngCom->msAlphaCor[0] = 644245120l /*0.3f Q31*/;
    move16();
    hFdCngCom->msAlphaCor[1] = 644245120l /*0.3f Q31*/;
    move16();
    set16_fx( hFdCngCom->psize, 0, NPART );
    /* Initialize exponents */
    hFdCngCom->exp_cldfb_periodog = 0;
    move16();

    return;
}
#endif
/*-------------------------------------------------------------------
 * deleteFdCngCom()
 *
+1 −10
Original line number Diff line number Diff line
@@ -1884,6 +1884,7 @@ void GenShapedWBExcitation_ivas_fx(
    Word16 *mem_genSHBexc_filt_down3,                           /* i/o : memory                        Q_bwe_exc*/
    Word16 *state_lpc_syn,                                      /* i/o : memory                        Q_bwe_exc*/
    const Word16 coder_type,                                    /* i : coding type                              */
    const Word16 element_mode,                                  /* i : element mode                             */
    const Word16 *bwe_exc_extended,                             /* i : bwidth extended exciatation     Q_bwe_exc*/
    const Word16 Q_bwe_exc,
    Word16 bwe_seed[],                                          /* i/o : random number generator seed           */
@@ -1990,16 +1991,6 @@ ivas_error stereo_memory_dec_fx(
    const Word16 nchan_transport                                /* i  : number of transport channels            */
);

#ifndef FIX_2245_INIT_FD_CNG_EVS
void initFdCngDec_ivas_fx(
    DEC_CORE_HANDLE st,                                         /* i/o: decoder state structure                 */
    Word16 scale 
);

void ivas_initFdCngCom_fx( 
    HANDLE_FD_CNG_COM hFdCngCom, Word16 scale 
);
#endif
Word16 set_ACELP_flag_IVAS(
    const Word16 element_mode,                                  /* i  : element mode                            */
    const Word32 element_brate,                                 /* i  : element bitrate                         */
+1 −5
Original line number Diff line number Diff line
@@ -86,8 +86,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 FIX_1435_MOVE_STEREO_PANNING                    /* VA: issue 1435: do the EVS stereo panning in the renderer */
#define FIX_BASOP_2201_HARMONIZE_HRTF_FILE_READER_CREND /* OR : Fix issue basop 2201 hrtf_file_reader crend differs between basop ivas-main and ivas-float-update */
#define FIX_2245_INIT_FD_CNG_EVS                        /* Dolby/VA: Issue 2245: initialize FD CNG with EVS-type of init function */
#define FIX_2252_SCALING_SAVE_HB_SYNTH                  /* VA: issue 2252: fix use-of-uninit-value in save_hb_synth_fx[] scaling in FOA decoding with bitstream that starts with an SID */
#define FIX_2248_EVS_ASSERT                             /* VA: Include _sat in an EVS related part of the code */
#define FIX_2254_IMPROV_COMPLEXITY_BE                   /* VA: BE small complexity reduction  */
@@ -98,12 +96,10 @@
/* any switch which is non-be wrt. TS 26.251 V3.0 */

#define FIX_1454_FIX_STEREO_TO_FOA_JBM                  /* VA: issue 1454: fix buggy stereo to FOA in JBM */
#define FIX_2015_PREMPH_SAT_ALT_PART2                   /* VA: Add missing scaling factor to be passed to AVQ_cod() */
#define FIX_2253_CORRECT_GSC_MINIMUM_PIT_SEARCH         /* VA: Fix Issue 2253 where the encoder and decoder could get out of sync */
#define NONBE_FIX_1967_SBA_DECODER_MONO_OUT_BIG_DIFFERENCES /* Dolby: Fix basop issue 1967 */
#define FIX_1461_CNG_BW_SWITCHING                       /* Eri: float issue 1461: Stereo parameters are not updated when SID/NODATA forces BW to stay the same */
#define FIX_2041_SPECTRAL_GAPS_FOR_INACTIVE_FRAMES      /* FhG: Using rounding in multiplication to improve precision in cngNoiseLevel[] */
#define FIX_2264_OUT_OF_BOUND_READING_IN_LOG2_NORM_LC   /* VA: Fix issue 2264 by adding a proper safeguard in log2 and by adding a missing normalization in swb_pre_proc_ivas_fx()*/
#define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT  /* Dolby: Issue 2250:  random vector generation in GenShapedSHBExcitation() */
#define FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE  /* VA: Precision improvement without increasing complexity, or complexity reduction that might be not BE on the LSB */

/* ##################### End NON-BE switches ########################### */
+2 −0
Original line number Diff line number Diff line
@@ -2992,6 +2992,7 @@ void GenShapedWBExcitation_fx(
    Word16 *mem_genSHBexc_filt_down3, /* i/o : memory                                 */
    Word16 *state_lpc_syn,            /* i/o : memory                                 */
    const Word16 coder_type,          /* i   : coding type                            */
    const Word16 element_mode,        /* i :   element mode                           */
    const Word16 *bwe_exc_extended,   /* i   : bandwidth extended exciatation         */
    const Word16 Q_bwe_exc,
    Word16 bwe_seed[],            /* i/o : random number generator seed           */
@@ -3014,6 +3015,7 @@ void GenShapedSHBExcitation_fx(
    Word16 *mem_genSHBexc_filt_down_shb, /* i/o: memory */
    Word16 *state_lpc_syn,               /* i/o: memory */
    const Word16 coder_type,             /* i : coding type */
    const Word16 element_mode,           /* i : element mode */
    const Word16 *bwe_exc_extended,      /* i : bandwidth extended excitation */
    Word16 bwe_seed[],                   /* i/o: random number generator seed */
    Word16 voice_factors[],              /* i : voicing factor*/
+61 −14
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@
 * Local function prototypes
 *-----------------------------------------------------------------*/

static void create_random_vector_fx( Word16 output[], const Word16 length, Word16 seed[] );
static void create_random_vector_fx( Word16 output[], const Word16 length, Word16 seed[], Word16 element_mode );
static void flip_spectrum_fx( const Word16 input[], Word16 output[], const Word16 length );
static void Calc_st_filt_tbe( Word16 *apond2, Word16 *apond1, Word16 *parcor0, Word16 *sig_ltp_ptr, Word16 *mem_zero );
static void Hilbert_transform_fx( Word32 tmp_R[], Word32 tmp_I[], Word32 *tmpi_R, Word32 *tmpi_I, const Word16 length, const Word16 HB_stage_id );
@@ -1415,6 +1415,7 @@ void GenShapedWBExcitation_ivas_fx(
    Word16 *mem_genSHBexc_filt_down3, /* i/o : memory Q_bwe_exc*/
    Word16 *state_lpc_syn,            /* i/o : memory Q_bwe_exc*/
    const Word16 coder_type,          /* i : coding type */
    const Word16 element_mode,        /* i : element mode */
    const Word16 *bwe_exc_extended,   /* i : bwidth extended exciatation Q_bwe_exc*/
    const Word16 Q_bwe_exc,
    Word16 bwe_seed[],            /* i/o : random number generator seed */
@@ -1478,7 +1479,7 @@ void GenShapedWBExcitation_ivas_fx(

    IF( uv_flag )
    {
        create_random_vector_fx( exc4kWhtnd, L_FRAME16k / 4, bwe_seed );
        create_random_vector_fx( exc4kWhtnd, L_FRAME16k / 4, bwe_seed, element_mode );
        IF( LT_16( Q_bwe_exc, 5 ) )
        {

@@ -1554,7 +1555,7 @@ void GenShapedWBExcitation_ivas_fx(
            move32(); /* Q_bwe_exc+16 */
        }

        create_random_vector_fx( exc4k, L_FRAME16k / 4, bwe_seed );
        create_random_vector_fx( exc4k, L_FRAME16k / 4, bwe_seed, element_mode );

        /* Ensure pow22 is greater than zero when computing normalization */
        Lmax = 0;
@@ -1661,6 +1662,7 @@ void GenShapedWBExcitation_fx(
    Word16 *mem_genSHBexc_filt_down3, /* i/o : memory                            Q(Q_bwe_exc) */
    Word16 *state_lpc_syn,            /* i/o : memory                            Q(Q_bwe_exc) */
    const Word16 coder_type,          /* i : coding type                                      */
    const Word16 element_mode,        /* i : element mode                                     */
    const Word16 *bwe_exc_extended,   /* i : bwidth extended exciatation         Q(Q_bwe_exc) */
    const Word16 Q_bwe_exc,           /* i : Q for memories                                   */
    Word16 bwe_seed[],                /* i/o : random number generator seed                   */
@@ -1727,7 +1729,7 @@ void GenShapedWBExcitation_fx(

    IF( uv_flag )
    {
        create_random_vector_fx( exc4kWhtnd, L_FRAME16k / 4, bwe_seed );
        create_random_vector_fx( exc4kWhtnd, L_FRAME16k / 4, bwe_seed, element_mode );
        IF( LT_16( Q_bwe_exc, 5 ) )
        {
            FOR( i = 0; i < L_FRAME16k / 4; i++ )
@@ -1802,7 +1804,7 @@ void GenShapedWBExcitation_fx(
            move32(); /* Q_bwe_exc+16 */
        }

        create_random_vector_fx( exc4k, L_FRAME16k / 4, bwe_seed );
        create_random_vector_fx( exc4k, L_FRAME16k / 4, bwe_seed, element_mode );

        /* Ensure pow22 is greater than zero when computing normalization */
        Lmax = 0;
@@ -2074,6 +2076,7 @@ void GenShapedSHBExcitation_fx(
    Word16 *mem_genSHBexc_filt_down_shb, /* i/o: memory */
    Word16 *state_lpc_syn,               /* i/o: memory */
    const Word16 coder_type,             /* i : coding type */
    const Word16 element_mode,           /* i : element mode */
    const Word16 *bwe_exc_extended,      /* i : bwidth extended excitation */
    Word16 bwe_seed[],                   /* i/o: random number generator seed */
    Word16 voice_factors[],              /* i : voicing factor*/
@@ -2293,8 +2296,8 @@ void GenShapedSHBExcitation_fx(
    {
        /* create a random excitation - Reuse exc16k memory */
        White_exc16k = exc16k;
        create_random_vector_fx( White_exc16k, L_FRAME, bwe_seed );
        create_random_vector_fx( White_exc16k + L_FRAME, L_FRAME16k - L_FRAME, bwe_seed );
        create_random_vector_fx( White_exc16k, L_FRAME, bwe_seed, element_mode );
        create_random_vector_fx( White_exc16k + L_FRAME, L_FRAME16k - L_FRAME, bwe_seed, element_mode );

        L_tmp = L_deposit_l( 0 );
        tmp = add( *Q_bwe_exc, 1 );
@@ -2978,8 +2981,8 @@ void GenShapedSHBExcitation_ivas_enc_fx(
    ELSE
    {
        /* create a random excitation - Reuse exc16k memory */
        create_random_vector_fx( White_exc16k, L_FRAME, bwe_seed );                        // Q5
        create_random_vector_fx( White_exc16k + L_FRAME, L_FRAME16k - L_FRAME, bwe_seed ); // Q5
        create_random_vector_fx( White_exc16k, L_FRAME, bwe_seed, element_mode );                        // Q5
        create_random_vector_fx( White_exc16k + L_FRAME, L_FRAME16k - L_FRAME, bwe_seed, element_mode ); // Q5

        L_tmp = L_deposit_l( 0 );
        tmp = add( *Q_bwe_exc, 1 );
@@ -4006,8 +4009,8 @@ void GenShapedSHBExcitation_ivas_dec_fx(
        /* create a random excitation - Reuse exc16k memory */
        White_exc16k = exc16k;
        move16();
        create_random_vector_fx( White_exc16k, L_FRAME, bwe_seed );                        // Q5
        create_random_vector_fx( White_exc16k + L_FRAME, L_FRAME16k - L_FRAME, bwe_seed ); // Q5
        create_random_vector_fx( White_exc16k, L_FRAME, bwe_seed, element_mode );                        // Q5
        create_random_vector_fx( White_exc16k + L_FRAME, L_FRAME16k - L_FRAME, bwe_seed, element_mode ); // Q5

        L_tmp = L_deposit_l( 0 );
        tmp = add( *Q_bwe_exc, 1 );
@@ -6109,24 +6112,68 @@ void non_linearity_ivas_fx(
void create_random_vector_fx(
    Word16 output[],     /* o : output random vector Q5*/
    const Word16 length, /* i : length of random vector */
    Word16 seed[]        /* i/o: start seed */
    Word16 seed[],       /* i/o: start seed */
    Word16 element_mode  /* i : element mode */
)
{
    Word16 i, j, k;
    Word16 scale1, scale2;
    Word32 L_tmp;
    /*
      Note: the constant 2144047674 is 0.0078f in Q38 from the float reference.
      It should read 0.0078125f, which is 1/128.Since 0.0078f is nor exactly
      depictable in fixed point, rounding has to be performed to get the same
      j and k values for any input (e.g. if Random() returns 5000)
    */

#ifdef FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT
    if ( element_mode != EVS_MONO )
    {
        L_tmp = L_abs( Mpy_32_16_r( 2144047674, Random( &seed[0] ) ) ); /*Q23 */
    }
    else
    {
        L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[0] ) ) ); /*Q23 */
    }
#else
    L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[0] ) ) );     /*Q23 */
#endif

    j = extract_l( L_shr( L_tmp, 23 ) );
    j = s_and( j, 0xff );

#ifdef FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT
    if ( element_mode != EVS_MONO )
    {
        L_tmp = L_abs( Mpy_32_16_r( 2144047674, Random( &seed[1] ) ) ); /*Q23 */
    }
    else
    {
        L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */
    }

#else
    L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) );     /*Q23 */
#endif

    k = extract_l( L_shr( L_tmp, 23 ) );
    k = s_and( k, 0xff );

    WHILE( EQ_16( k, j ) )
    {
#ifdef FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT
        if ( element_mode != EVS_MONO )
        {
            L_tmp = L_abs( Mpy_32_16_r( 2144047674, Random( &seed[1] ) ) ); /*Q23 */
        }
        else
        {
            L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */
        }
#else
        L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */
#endif

        k = extract_l( L_shr( L_tmp, 23 ) );
        k = s_and( k, 0xff );
    }
Loading