Commit f48f63ab authored by Markus Werner's avatar Markus Werner
Browse files

Merge branch...

Merge branch '2250-large-differences-between-basop-and-float-after-application-of-the-upmix-acelp-bwe-in' into 'main'

[Non-be]Large differences between BASOP and float after application of the upmix ACELP BWE in ivas_sba_dirac_stereo_dec()

See merge request !2621
parents 769b238b 0a057a72
Loading
Loading
Loading
Loading
Loading
+1 −0
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           */
+1 −0
Original line number Diff line number Diff line
@@ -98,6 +98,7 @@
#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() */

/* ##################### 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 );
    }
+3 −3
Original line number Diff line number Diff line
@@ -895,7 +895,7 @@ void ivas_wb_tbe_dec_fx(

        GenShapedWBExcitation_ivas_fx( shaped_wb_excitation + L_SHB_LAHEAD / 4, lpc_wb, exc4kWhtnd, hBWE_TD->mem_csfilt_fx,
                                       hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->mem_genSHBexc_filt_down_wb2_fx,
                                       hBWE_TD->mem_genSHBexc_filt_down_wb3_fx, hBWE_TD->state_lpc_syn_fx, coder_type,
                                       hBWE_TD->mem_genSHBexc_filt_down_wb3_fx, hBWE_TD->state_lpc_syn_fx, coder_type, st_fx->element_mode,
                                       bwe_exc_extended_16, Q_bwe_exc_ext, hBWE_TD->bwe_seed, vf_modified, uv_flag, st_fx->igf );

        curr_pow = 0;
@@ -1535,7 +1535,7 @@ void wb_tbe_dec_fx(

        GenShapedWBExcitation_fx( shaped_wb_excitation + L_SHB_LAHEAD / 4, lpc_wb, exc4kWhtnd, hBWE_TD->mem_csfilt_fx,
                                  hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->mem_genSHBexc_filt_down_wb2_fx,
                                  hBWE_TD->mem_genSHBexc_filt_down_wb3_fx, hBWE_TD->state_lpc_syn_fx, coder_type,
                                  hBWE_TD->mem_genSHBexc_filt_down_wb3_fx, hBWE_TD->state_lpc_syn_fx, coder_type, st_fx->element_mode,
                                  bwe_exc_extended_16, Q_bwe_exc_ext, hBWE_TD->bwe_seed, vf_modified, uv_flag, st_fx->igf );

        curr_pow = 0;
@@ -2653,7 +2653,7 @@ void swb_tbe_dec_fx(
    /* Calculate the 6 to 14 kHz (or 7.5 - 15.5 kHz) SHB excitation signal from the low band ACELP core excitation */
    GenShapedSHBExcitation_fx( shaped_shb_excitation + L_SHB_LAHEAD, lpc_shb, White_exc16k,
                               hBWE_TD->mem_csfilt_fx, hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->state_lpc_syn_fx,
                               coder_type, bwe_exc_extended_16, hBWE_TD->bwe_seed, vf_modified, st_fx->extl,
                               coder_type, st_fx->element_mode, bwe_exc_extended_16, hBWE_TD->bwe_seed, vf_modified, st_fx->extl,
                               &( hBWE_TD->tbe_demph_fx ), &( hBWE_TD->tbe_premph_fx ), lpc_shb_sf, shb_ener_sf_32,
                               shb_res_gshape, shb_res_dummy, &vind, formant_fac, hBWE_TD->fb_state_lpc_syn_fx,
                               &( hBWE_TD->fb_tbe_demph_fx ), &Q_bwe_exc, &Q_bwe_exc_fb, Q_shb, n_mem2, hBWE_TD->prev_Q_bwe_syn, st_fx->total_brate, st_fx->prev_bfi );
Loading