Commit 96982056 authored by Vladimir Malenovsky's avatar Vladimir Malenovsky
Browse files

merge main to branch

parents a4543377 e678e508
Loading
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -213,6 +213,8 @@
    <ClCompile Include="..\lib_dec\ivas_core_dec_fx.c" />
    <ClCompile Include="..\lib_dec\ivas_cpe_dec_fx.c" />
    <ClCompile Include="..\lib_dec\ivas_decision_matrix_dec_fx.c" />
    <ClCompile Include="..\lib_dec\ivas_dec_fx.c" />
    <ClCompile Include="..\lib_dec\ivas_dec_render_fx.c" />
    <ClCompile Include="..\lib_dec\ivas_dirac_dec_fx.c" />
    <ClCompile Include="..\lib_dec\ivas_dirac_output_synthesis_cov_fx.c" />
    <ClCompile Include="..\lib_dec\ivas_entropy_decoder_fx.c" />
@@ -222,7 +224,6 @@
    <ClCompile Include="..\lib_dec\ivas_ism_metadata_dec_fx.c" />
    <ClCompile Include="..\lib_dec\ivas_ism_param_dec_fx.c" />
    <ClCompile Include="..\lib_dec\ivas_ism_renderer_fx.c" />
    <ClCompile Include="..\lib_dec\ivas_jbm_dec_fx.c" />
    <ClCompile Include="..\lib_dec\ivas_lfe_dec_fx.c" />
    <ClCompile Include="..\lib_dec\ivas_lfe_plc_fx.c" />
    <ClCompile Include="..\lib_dec\ivas_ls_custom_dec_fx.c" />
+6 −6
Original line number Diff line number Diff line
@@ -326,9 +326,6 @@
    <ClCompile Include="..\lib_dec\vlpc_2st_dec_fx.c">
      <Filter>decoder_all_c</Filter>
    </ClCompile>
    <ClCompile Include="..\lib_dec\ivas_binRenderer_internal_fx.c">
      <Filter>decoder_ivas_c</Filter>
    </ClCompile>
    <ClCompile Include="..\lib_dec\ivas_core_dec_fx.c">
      <Filter>decoder_ivas_c</Filter>
    </ClCompile>
@@ -362,9 +359,6 @@
    <ClCompile Include="..\lib_dec\ivas_ism_renderer_fx.c">
      <Filter>decoder_ivas_c</Filter>
    </ClCompile>
    <ClCompile Include="..\lib_dec\ivas_jbm_dec_fx.c">
      <Filter>decoder_ivas_c</Filter>
    </ClCompile>
    <ClCompile Include="..\lib_dec\ivas_ls_custom_dec_fx.c">
      <Filter>decoder_ivas_c</Filter>
    </ClCompile>
@@ -509,6 +503,12 @@
    <ClCompile Include="..\lib_dec\rom_dec_fx.c">
      <Filter>decoder_all_c</Filter>
    </ClCompile>
    <ClCompile Include="..\lib_dec\ivas_dec_fx.c">
      <Filter>decoder_ivas_c</Filter>
    </ClCompile>
    <ClCompile Include="..\lib_dec\ivas_dec_render_fx.c">
      <Filter>decoder_ivas_c</Filter>
    </ClCompile>
  </ItemGroup>
  <ItemGroup>
    <ClInclude Include="..\lib_dec\lib_dec.h" />
+0 −2
Original line number Diff line number Diff line
@@ -911,9 +911,7 @@ static bool parseCmdlIVAS_dec(
    arg->inputFormat = IVAS_DEC_INPUT_FORMAT_G192;
    arg->non_diegetic_pan_enabled = false;
    arg->non_diegetic_pan_gain = 0.f;
#ifdef FIX_2318_CLANG_DECODER
    arg->non_diegetic_pan_gain_fx = 0;
#endif
    arg->tsmEnabled = false;
    arg->render_num_subframes = IVAS_RENDER_NUM_SUBFR_20MS;
    arg->aeSequence.count = 0;
+5 −0
Original line number Diff line number Diff line
@@ -996,6 +996,11 @@ ivas_error openCldfb(
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" );
    }

#ifdef FIX_2319_CLDFB_INIT_FLAGS
    hs->flags = 0;
    move16();
#endif

    hs->type = type;
    move16();

+0 −283
Original line number Diff line number Diff line
@@ -602,112 +602,6 @@ return;
 *-------------------------------------------------------*/

void cng_params_postupd_fx(
#ifndef HARM_NON_LINEARITY
    const Word16 ho_circ_ptr,          /* i  : pointer for CNG averaging buffers                  Q0    */
    Word16 *cng_buf_cnt,               /* i/o: counter for CNG store buffers                      Q0    */
    const Word16 *const cng_exc2_buf,  /* i  : Excitation buffer                                  Q_exc */
    const Word16 *const cng_Qexc_buf,  /* i  : Q_exc buffer                                       Q0    */
    const Word32 *const cng_brate_buf, /* i  : bit rate buffer                                    Q0    */
    Word32 ho_env_circ[]               /* i/o: Envelope buffer                                    Q6    */
)
{
    Word16 i, j;
    Word16 Q_exc;
    const Word16 *exc2;
    Word16 fft_io[L_FFT];
    Word32 sp[129];
    Word16 *ptR, *ptI;
    Word32 env[NUM_ENV_CNG];
    Word32 L_tmp;
    Word16 tmp;
    Word16 temp_lo_fx, temp_hi_fx;
    Word16 exp_pow;
    Word16 exp1;
    Word16 CNG_mode;
    Word16 ptr;
    Word32 last_active_brate;

    ptr = add( sub( ho_circ_ptr, *cng_buf_cnt ), 1 );
    IF( ptr < 0 )
    {
        ptr = add( ptr, HO_HIST_SIZE );
    }

    FOR( j = 0; j < *cng_buf_cnt; j++ )
    {
        exc2 = &cng_exc2_buf[ptr * L_FFT];
        Q_exc = cng_Qexc_buf[ptr];
        move16();
        last_active_brate = cng_brate_buf[ptr];
        move32();

        /* calculate the spectrum of residual signal */
        Copy( exc2, fft_io, L_FFT );

        fft_rel_fx( fft_io, L_FFT, LOG2_L_FFT );

        ptR = &fft_io[1];
        ptI = &fft_io[L_FFT - 1];
        FOR( i = 0; i < NUM_ENV_CNG; i++ )
        {
            /* sp[i] = 2.0f*(*ptR * *ptR + *ptI * *ptI)/L_FFT; */
            L_tmp = L_mult_sat( *ptR, *ptR );                     /* 2*Q_exc+1 */
            L_tmp = L_add_sat( L_tmp, L_mult_sat( *ptI, *ptI ) ); /* 2*Q_exc+1 */
            L_tmp = L_add_sat( L_tmp, L_tmp );                    /* 2*Q_exc+1 */
            L_tmp = Mult_32_16( L_tmp, 128 );                     /* 2*Q_exc+1 */
            tmp = add( add( Q_exc, Q_exc ), 1 );
            sp[i] = L_shr( L_tmp, sub( tmp, 6 ) );
            move32(); /* Q6 */

            ptR++;
            ptI--;
        }

        Copy32( sp, env, NUM_ENV_CNG );
        {

            CNG_mode = get_cng_mode( last_active_brate );

            /* att = 1/pow(2,ENR_ATT_fx[CNG_mode]); */
            L_tmp = L_shl( L_deposit_l( ENR_ATT_fx[CNG_mode] ), 8 ); /* 16 */
            temp_lo_fx = L_Extract_lc( L_tmp, &temp_hi_fx );

            exp_pow = sub( 14, temp_hi_fx );
            L_tmp = Pow2( 14, temp_lo_fx );             /* Qexp_pow */
            L_tmp = L_shl( L_tmp, sub( 13, exp_pow ) ); /* Q13 */
            tmp = extract_l( L_tmp );                   /* Q13 */

            exp1 = norm_s( tmp );
            tmp = shl( tmp, exp1 );           /*Q(exp1+13) */
            tmp = div_s( 16384, tmp );        /*Q(15+14-exp1-13) */
            tmp = shr( tmp, sub( 1, exp1 ) ); /* Q15 */
        }

        FOR( i = 0; i < NUM_ENV_CNG; i++ )
        {
            env[i] = Mult_32_16( env[i], tmp );
            move32();
        }

        /* update the circular buffer of old residual envelope */
        Copy32( env, &( ho_env_circ[(ptr) *NUM_ENV_CNG] ), NUM_ENV_CNG );

        ptr = add( ptr, 1 );
        if ( EQ_16( ptr, HO_HIST_SIZE ) )
        {
            ptr = 0;
            move16();
        }
    }

    *cng_buf_cnt = 0;
    move16();

    return;
}

void cng_params_postupd_ivas_fx(
#endif
    const Word16 ho_circ_ptr,          /* i  : pointer for CNG averaging buffers                  Q0    */
    Word16 *cng_buf_cnt,               /* i/o: counter for CNG store buffers                      Q0    */
    const Word16 *const cng_exc2_buf,  /* i  : Excitation buffer                                  Q_exc */
@@ -833,183 +727,8 @@ void cng_params_postupd_ivas_fx(
 *
 * update CNG parameters
 *-------------------------------------------------------*/
#ifndef HARM_NON_LINEARITY
void cng_params_upd_fx(
    const Word16 lsp_new[],        /* i  : LSP aprameters                                     Q15   */
    const Word16 exc2[],           /* i  : current enhanced excitation                        Q_exc */
    const Word16 L_frame,          /* i  : frame length                                       Q0    */
    Word16 *ho_circ_ptr,           /* i/o: pointer for CNG averaging buffers                  Q0    */
    Word32 ho_ener_circ[],         /* o  : energy buffer for CNG averaging                    Q6    */
    Word16 *ho_circ_size,          /* i/o: size of DTX hangover history buffer for averaging  Q0    */
    Word16 ho_lsp_circ[],          /* o  : old LSP buffer for CNG averaging                   Q15   */
    const Word16 Q_exc,            /* i  : Q value of excitation                                    */
    const Word16 enc_dec_flag,     /* i  : Flag indicating encoder or decoder (ENC,DEC)             */
    Word32 ho_env_circ[],          /* i/o: Envelope buffer                                    Q6    */
    Word16 *cng_buf_cnt,           /* i/o: Counter of postponed FFT-processing instances            */
    Word16 cng_exc2_buf[],         /* i/o: Excitation buffer                                  Q_exc */
    Word16 cng_Qexc_buf[],         /* i/o: Q_exc buffer                                       Q0    */
    Word32 cng_brate_buf[],        /* i/o: last_active_brate buffer                           Q0    */
    const Word32 last_active_brate /* i  : Last active bit rate                               Q0    */
)
{
    Word32 L_ener, L_tmp;
    Word16 i, j;
    const Word16 *pt_exc2;
    Word16 tmpv, maxv, scale;
    Word16 fft_io[L_FRAME16k];
    Word32 sp[129];
    Word16 *ptR, *ptI;
    Word32 env[NUM_ENV_CNG];
    Word16 exp1;
    Word16 CNG_mode;
    Word16 tmp;
    Word16 temp_lo_fx, temp_hi_fx;
    Word16 exp_pow;

    /* update the pointer to circular buffer of old LSP vectors */
    *ho_circ_ptr = add( *ho_circ_ptr, 1 );
    move16();

    if ( EQ_16( *ho_circ_ptr, HO_HIST_SIZE ) )
    {
        *ho_circ_ptr = 0;
        move16();
    }

    /* update the circular buffer of old LSP vectors with the new LSP vector */
    Copy( lsp_new, &( ho_lsp_circ[( *ho_circ_ptr ) * M] ), M );

    /* calculate the residual signal energy */
    /*enr = dotp( exc2, exc2, L_frame ) / L_frame; */

    maxv = 0;
    move16();
    FOR( i = 0; i < L_frame; i++ )
    {
        maxv = s_max( maxv, abs_s( exc2[i] ) );
    }
    scale = norm_s( maxv );

    pt_exc2 = exc2;
    L_ener = 0;
    move32();
    IF( EQ_16( L_frame, L_FRAME ) )
    {
        FOR( j = 0; j < 128; j++ )
        {
            tmpv = shl( *pt_exc2, scale );
            L_tmp = L_mult0( tmpv, tmpv ); /* 2*(Q_exc+scale) */
            pt_exc2++;
            tmpv = shl( *pt_exc2, scale );
            L_tmp = L_mac0_sat( L_tmp, tmpv, tmpv );
            pt_exc2++;
            L_ener = L_add_sat( L_ener, L_shr_sat( L_tmp, 7 ) ); /* Q(2*(Q_exc+scale)+1) ,division by L_frame done here */
        }
    }
    ELSE /* L_FRAME16k */
    {
        FOR( j = 0; j < 160; j++ )
        {
            tmpv = shl( *pt_exc2, scale );
            L_tmp = L_mult0( tmpv, tmpv ); /* 2*(Q_exc+scale) */
            pt_exc2++;
            tmpv = shl( *pt_exc2, scale );
            L_tmp = L_mac0_sat( L_tmp, tmpv, tmpv );
            pt_exc2++;
            L_ener = L_add_sat( L_ener, L_shr_sat( Mult_32_16( L_tmp, 26214 /* 256/320, Q15 */ ), 7 ) ); /* Q(2*(Q_exc+scale)+15+1-16+1) ,division by L_frame done here */
        }
    }
    L_ener = L_shr_sat( L_ener, sub( shl( add( Q_exc, scale ), 1 ), 5 ) ); /* Q6 (2*(Q_exc+scale)+1-2*(Q_exc+scale)+5) */

    /* update the circular buffer of old energies */
    ho_ener_circ[*ho_circ_ptr] = L_ener;
    move32();

    IF( enc_dec_flag == ENC )
    {
        /* Store residual signal for postponed FFT-processing*/
        *cng_buf_cnt = add( *cng_buf_cnt, 1 );
        move16();
        if ( GT_16( *cng_buf_cnt, HO_HIST_SIZE ) )
        {
            *cng_buf_cnt = HO_HIST_SIZE;
            move16();
        }
        Copy( exc2, &( cng_exc2_buf[( *ho_circ_ptr ) * L_FFT] ), L_FFT );
        cng_Qexc_buf[*ho_circ_ptr] = Q_exc;
        move16();
        cng_brate_buf[*ho_circ_ptr] = last_active_brate;
        move32();
    }
    ELSE
    {
        /* calculate the spectrum of residual signal */
        Copy( exc2, fft_io, L_frame );

        fft_rel_fx( fft_io, L_FFT, LOG2_L_FFT );

        ptR = &fft_io[1];
        ptI = &fft_io[L_FFT - 1];
        FOR( i = 0; i < NUM_ENV_CNG; i++ )
        {
            /* sp[i] = 2.0f*(*ptR * *ptR + *ptI * *ptI)/L_FFT; */
            L_tmp = L_mult_sat( *ptR, *ptR );                     /* 2*Q_exc+1 */
            L_tmp = L_add_sat( L_tmp, L_mult_sat( *ptI, *ptI ) ); /* 2*Q_exc+1 */
            L_tmp = L_add_sat( L_tmp, L_tmp );                    /* 2*Q_exc+1 */
            L_tmp = Mult_32_16( L_tmp, 128 );                     /* 2*Q_exc+1 */
            tmp = add( add( Q_exc, Q_exc ), 1 );
            sp[i] = L_shr( L_tmp, sub( tmp, 6 ) );
            move32(); /* Q6 */

            ptR++;
            ptI--;
        }

        Copy32( sp, env, NUM_ENV_CNG );
        {
            CNG_mode = get_cng_mode( last_active_brate );
            /* att = 1/pow(2,ENR_ATT_fx[CNG_mode]); */
            L_tmp = L_shl( L_deposit_l( ENR_ATT_fx[CNG_mode] ), 8 ); /* 16 */
            temp_lo_fx = L_Extract_lc( L_tmp, &temp_hi_fx );

            exp_pow = sub( 14, temp_hi_fx );
            L_tmp = Pow2( 14, temp_lo_fx );             /* Qexp_pow */
            L_tmp = L_shl( L_tmp, sub( 13, exp_pow ) ); /* Q13 */
            tmp = extract_l( L_tmp );                   /* Q13 */

            exp1 = norm_s( tmp );
            tmp = shl( tmp, exp1 );           /*Q(exp1+13) */
            tmp = div_s( 16384, tmp );        /*Q(15+14-exp1-13) */
            tmp = shr( tmp, sub( 1, exp1 ) ); /* Q15 */
        }

        FOR( i = 0; i < NUM_ENV_CNG; i++ )
        {
            env[i] = Mult_32_16( env[i], tmp );
            move32();
        }

        /* update the circular buffer of old residual envelope */
        /* Copy32( env, &(ho_env_circ[add(shl(*ho_circ_ptr,4),shl(*ho_circ_ptr,2))]), NUM_ENV_CNG ); */
        Copy32( env, &( ho_env_circ[( *ho_circ_ptr ) * NUM_ENV_CNG] ), NUM_ENV_CNG );
    }
    *ho_circ_size = add( *ho_circ_size, 1 );
    move16();
    if ( GT_16( *ho_circ_size, HO_HIST_SIZE ) )
    {
        *ho_circ_size = HO_HIST_SIZE;
        move16();
    }

    return;
}
#endif

#ifdef HARM_NON_LINEARITY
void cng_params_upd_fx(
#else
void cng_params_upd_ivas_fx(
#endif
    const Word16 lsp_new[],         /* i  : LSP aprameters                                     Q15   */
    const Word16 exc2[],            /* i  : current enhanced excitation                        Q_exc */
    const Word16 L_frame,           /* i  : frame length                                       Q0    */
@@ -1187,9 +906,7 @@ void cng_params_upd_ivas_fx(
        /* update the circular buffer of old residual envelope */
        /* Copy32( env, &(ho_env_circ[add(shl(*ho_circ_ptr,4),shl(*ho_circ_ptr,2))]), NUM_ENV_CNG ); */
        Copy32( env, &( ho_env_circ[( *ho_circ_ptr ) * NUM_ENV_CNG] ), NUM_ENV_CNG );
#ifdef HARM_NON_LINEARITY
        IF( NE_16( element_mode, EVS_MONO ) )
#endif
        {
            scale_sig32( &( ho_env_circ[( *ho_circ_ptr ) * NUM_ENV_CNG] ), NUM_ENV_CNG, shift ); // Q(6+shift)
        }
Loading