Commit 2fcce6c5 authored by Manuel Jander's avatar Manuel Jander
Browse files

Correct scale error in DFT stereo synthesis. Improve scale of...

Correct scale error in DFT stereo synthesis. Improve scale of L_old_wtda_swb_fx to avoid saturation.
parent bcecaa9e
Loading
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -621,8 +621,9 @@ ivas_error ivas_core_enc_fx(
        IF( st->hBWE_FD != NULL )
        {
#ifdef NONBE_FIX_ISSUE_2206
            Scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, sub( st->q_inp, st->Q_old_wtda ) ); // s_min( st->Q_old_wtda, st->q_inp );
            st->Q_old_wtda = st->q_inp;
            Word16 tmp = norm_arr( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k );
            scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, tmp );
            st->Q_old_wtda = add( st->Q_old_wtda, tmp );
            move16();
#else
            Scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, sub( negate( 1 ), st->Q_old_wtda ) ); // Q(-1)
+1 −0
Original line number Diff line number Diff line
@@ -348,6 +348,7 @@ void pre_proc_front_ivas_fx(
    Word16 Q_old_in = st->q_inp;
    move16();

    assert( st->q_inp32 == st->q_old_inp32 );
    Q_min = add( sub( 15, st->exp_old_inp_12k8 ), norm_arr( st->old_inp_12k8_fx, L_INP_MEM ) );
    input_frame_full = shl( input_frame, 1 ); //(old frame input length + new frame input length)
    Q_min = s_min( Q_min, sub( add( L_norm_arr( st->input32_fx - input_frame, input_frame_full ), st->q_inp32 ), 16 ) );
+7 −5
Original line number Diff line number Diff line
@@ -542,17 +542,17 @@ void pre_proc_ivas_fx(

#ifdef NONBE_FIX_ISSUE_2206
    Word16 shift = norm_arr( st->old_inp_12k8_fx, L_INP_MEM );
    Scale_sig( st->old_inp_12k8_fx, L_INP_MEM, shift ); /* exp(st->exp_old_inp_12k8 - shift) */
    scale_sig( st->old_inp_12k8_fx, L_INP_MEM, shift ); /* exp(st->exp_old_inp_12k8 - shift) */
    st->exp_old_inp_12k8 = sub( st->exp_old_inp_12k8, shift );
    move16();
    shift = norm_arr( st->old_inp_16k_fx, L_INP_MEM );
    Scale_sig( st->old_inp_16k_fx, L_INP_MEM, shift ); /* exp(st->exp_old_inp_12k8 - shift) */
    scale_sig( st->old_inp_16k_fx, L_INP_MEM, shift ); /* exp(st->exp_old_inp_12k8 - shift) */
    st->exp_old_inp_16k = sub( st->exp_old_inp_16k, shift );
    move16();
    IF( st->hBWE_FD != NULL )
    {
        shift = norm_arr( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k );
        Scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, shift ); /* exp(st->exp_old_inp_12k8 - shift) */
        scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, shift ); /* exp(st->exp_old_inp_12k8 - shift) */
        st->Q_old_wtda = add( st->Q_old_wtda, shift );
        move16();
    }
@@ -1021,7 +1021,8 @@ void ivas_compute_core_buffers_fx(
            IF( EQ_16( st->bwidth, WB ) )
            {
#ifdef NONBE_FIX_ISSUE_2206
                Word16 wtda_q = s_min( st->Q_old_wtda, Q_old_inp_16k );
                //Word16 wtda_q = s_min( st->Q_old_wtda, Q_old_inp_16k );
                Word16 wtda_q = s_min( add( st->Q_old_wtda, norm_arr( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k ) ) , Q_old_inp_16k );
                Copy_Scale_sig( new_inp_16k_fx - delay, st->hBWE_FD->old_input_wb_fx, delay, sub( -1, Q_old_inp_16k ) ); /* Scaling to Q(-1) */
                scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, sub( wtda_q, st->Q_old_wtda ) );                  /* st->Q_old_wtda->wtda_q */
                Copy_Scale_sig( new_inp_16k_fx - STEREO_DFT_OVL_16k, st->hBWE_FD->L_old_wtda_swb_fx + L_FRAME16k - STEREO_DFT_OVL_16k + delay, sub( STEREO_DFT_OVL_16k, delay ), sub( wtda_q, Q_old_inp_16k ) );
@@ -1045,7 +1046,8 @@ void ivas_compute_core_buffers_fx(
            IF( EQ_16( st->bwidth, WB ) && st->hBWE_FD != NULL )
            {
#ifdef NONBE_FIX_ISSUE_2206
                Word16 wtda_q = s_min( st->Q_old_wtda, Q_old_inp_16k );
                //Word16 wtda_q = s_min( st->Q_old_wtda, Q_old_inp_16k );
                Word16 wtda_q = s_min( add( st->Q_old_wtda, norm_arr( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k ) ) , Q_old_inp_16k );
                Copy_Scale_sig( new_inp_16k_fx + L_FILT16k - delay, st->hBWE_FD->old_input_wb_fx, delay, sub( -1, Q_old_inp_16k ) ); /* Scaling to Q(-1) */
                scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, sub( wtda_q, st->Q_old_wtda ) );                              /* st->Q_old_wtda->wtda_q */
                Copy_Scale_sig( new_inp_16k_fx - L_MEM_RECALC_16K, st->hBWE_FD->L_old_wtda_swb_fx + L_FRAME16k - L_MEM_RECALC_16K - L_FILT16k + delay, sub( L_MEM_RECALC_16K + L_FILT16k, delay ), sub( wtda_q, Q_old_inp_16k ) );
+7 −6
Original line number Diff line number Diff line
@@ -1600,17 +1600,19 @@ Word32 stereo_dft_enc_synthesize_fx(
    scale_sig32( tmp_fx, NFFT, scal_fac );
    rfft_fx( tmp_fx, trigo_enc_fx, NFFT, +1 );
    tmp_q = sub( Q31, sub( DFT_in_fx_e, scal_fac ) );
    *q_output = s_min( *q_output, s_min( tmp_q, *mem_q ) );
    *q_output = s_min( *q_output, s_min( add( tmp_q, sub( L_norm_arr( tmp_fx, NFFT ), 1 ) ), *mem_q ) );
    move16();
    mem_shift = sub( *q_output, *mem_q );
    tmp_shift = sub( *q_output, tmp_q );
    *mem_q = tmp_q;
    *mem_q = *q_output;
    move16();

    scale_sig32( tmp_fx, NFFT, tmp_shift );

    FOR( i = 0; i < ovl; i++ )
    {
        // output[offset + i] = mem[i] + tmp[zp + i] * win[i];
        output_fx[offset + i] = L_add( L_shl( mem_fx[i], mem_shift ), L_shl( Mpy_32_32( tmp_fx[zp + i], win_fx[i] ), tmp_shift ) );
        output_fx[offset + i] = L_add( L_shl( mem_fx[i], mem_shift ), Mpy_32_32(  tmp_fx[zp + i], win_fx[i] ) );
        move32();
        // mem[i] = tmp[zp + N + i] * win[ovl - 1 - i];
        mem_fx[i] = Mpy_32_32( tmp_fx[zp + N + i], win_fx[ovl - 1 - i] );
@@ -1620,8 +1622,7 @@ Word32 stereo_dft_enc_synthesize_fx(
    /*Middle->Copy*/
    FOR( i = 0; i < N - ovl; i++ )
    {
        // output_fx[offset + ovl + i] = tmp[zp + ovl + i];
        output_fx[offset + ovl + i] = L_shl( tmp_fx[zp + ovl + i], tmp_shift );
        output_fx[offset + ovl + i] = tmp_fx[zp + ovl + i];
        move32();
    }

@@ -1637,7 +1638,7 @@ Word32 stereo_dft_enc_synthesize_fx(
        Word16 L_temp_e;
        Word32 L_temp = BASOP_Util_Divide3232_Scale_newton( L_sub_sat( tmp_fx[zp + N + i], ifft_deviation ), L_deposit_h( win_ana_fx[ovl - 1 - i] ), &L_temp_e );
        L_temp = L_shl_sat( L_temp, L_temp_e );
        output_fx[offset + N + i] = L_shl( L_add_sat( L_temp, ifft_deviation ), tmp_shift ); // *q_output
        output_fx[offset + N + i] =  L_add_sat( L_temp, ifft_deviation ); // *q_output
        move32();
    }
#else
+7 −0
Original line number Diff line number Diff line
@@ -768,6 +768,10 @@ void stereo_switching_enc_fx(

        /* reset DFT synthesis overlap memory @8kHz, secondary channel */
        set32_fx( hCPE->hStereoDft->output_mem_res_8k_fx, 0, STEREO_DFT_OVL_8k );
#ifdef NONBE_FIX_ISSUE_2206
        hCPE->hStereoDft->output_mem_res_8k_q = Q15;
        move16();
#endif

        hCPE->hCoreCoder[1]->vad_flag = 0;
        move16();
@@ -952,6 +956,9 @@ void stereo_switching_enc_fx(
        {
            /* cross-fade overlap region of DFT Stereo downmix and original stereo channels */
            tmp_fx = div_s( 64, shl( sts[0]->encoderLookahead_FB, Q6 ) ); /* Q15 */
#ifdef NONBE_FIX_ISSUE_2206
            assert( sts[0]->q_old_inp32 == sts[1]->q_old_inp32 );
#endif
            FOR( i = 0; i < sts[0]->encoderLookahead_FB; i++ )
            {
                sts[1]->input32_fx[-sts[0]->encoderLookahead_FB + i] = ( Mpy_32_16_1( L_add( imult3216( sts[0]->input32_fx[-sts[0]->encoderLookahead_FB + i], sts[0]->encoderLookahead_FB - i ), imult3216( sts[1]->input32_fx[-sts[0]->encoderLookahead_FB + i], i ) ), tmp_fx ) ); /* sts[0]->q_inp32 */
Loading