Commit 6d95f903 authored by vaclav's avatar vaclav
Browse files

harmonize function save_synthesis_hq_fec_fx()

parent 4653aa3d
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -9712,7 +9712,8 @@ void addBassPostFilter_ivas_fx(
    Word32 **iAnalysis_fx,
    HANDLE_CLDFB_FILTER_BANK cldfb );
Word32 ism_dequant_meta_fx(                                /* o  : Q22*/
/* o  : Q22*/
Word32 ism_dequant_meta_fx(
    const Word16 idx,              /* i  : quantizer index              */
    const Word32 borders_fx[],     /* i  : level borders                Q22*/
    const Word32 q_step_fx,        /* i  : quantization step            Q22   */
@@ -9722,10 +9723,13 @@ Word32 ism_dequant_meta_fx( /* o : Q22*/
void save_synthesis_hq_fec_fx(
    Decoder_State *st,         /* i/o: decoder state structure     */
    const Word16 synth_fx[],   /* i  : decoded synthesis (EVS)     */
    const Word32 output_fx[],  /* i  : decoded synthesis           */
    const Word16 output_frame, /* i  : decoded synthesis           */
    const Word16 Qpostd,       /* i  : Q value of delayed signal   */
    CPE_DEC_HANDLE hCPE        /* i  : CPE decoder structure       */
);
void calculate_nbits_meta_fx(
    const Word16 nchan_ism,
    Word32 q_energy_ratio_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], // Q30
+19 −18
Original line number Diff line number Diff line
@@ -1964,8 +1964,10 @@ static void Next_good_after_burst_erasures_fx(

void save_synthesis_hq_fec_fx(
    Decoder_State *st,         /* i/o: decoder state structure     */
    const Word16 synth_fx[],   /* i  : decoded synthesis (EVS)     */
    const Word32 output_fx[],  /* i  : decoded synthesis           */
    const Word16 output_frame, /* i  : decoded synthesis           */
    const Word16 Qpostd,       /* i  : Q value of delayed signal   */
    CPE_DEC_HANDLE hCPE        /* i  : CPE decoder structure       */
)
{
@@ -2004,44 +2006,43 @@ void save_synthesis_hq_fec_fx(
    test();
    IF( ( EQ_16( st->codec_mode, MODE1 ) && st->hTcxDec != NULL ) && ( ( ( st->core == ACELP_CORE ) && !( EQ_16( st->bfi, 1 ) && EQ_16( st->con_tcx, 1 ) ) ) || EQ_16( st->core, HQ_CORE ) ) )
    {
        Copy( st->hTcxDec->synth_history_fx + output_frame, st->hTcxDec->synth_history_fx, add( sub( output_frame, post_hq_delay ), NS2SA_FX2( st->output_Fs, PH_ECU_MEM_NS ) ) );
        FOR( Word16 i = 0; i < output_frame; i++ )
        {
            st->hTcxDec->old_synthFB_fx[( ( i + output_frame ) - post_hq_delay )] = extract_h( L_shl_sat( output_fx[i], 16 ) ); // Q16
            move16();
        }

        IF( st->element_mode == EVS_MONO )
        {
            Copy( st->hTcxDec->synth_history_fx + output_frame, st->hTcxDec->synth_history_fx, add( sub( output_frame, post_hq_delay ), NS2SA_FX2( st->output_Fs, PH_ECU_MEM_NS ) ) ); /*hTcxDec->q_synth_history_fx*/
            Copy_Scale_sig( synth_fx, st->hTcxDec->old_synthFB_fx + sub( output_frame, post_hq_delay ), output_frame, negate( Qpostd ) );                                              /* output_sp not initialized yet */
            /* reset the remaining buffer, which is read in TCX concealment the necessary samples to fill
               this buffer are not available for all cases, the impact on the output is limited */

            set16_fx( st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), post_hq_delay ), 0, post_hq_delay );

            IF( GE_16( output_frame, L_FRAME16k ) )
            {
                Copy( st->prev_synth_buffer_fx, st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS ) ), NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) );
            }
            ELSE
            {
                Copy( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) );
                Copy_Scale_sig( st->prev_synth_buffer_fx, st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS ) ), NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), negate( st->Qprev_synth_buffer_fx ) ); /*Q0*/
            }

            IF( st->core != ACELP_CORE )
            IF( NE_16( st->core, ACELP_CORE ) )
            {
                IF( GE_16( output_frame, L_FRAME16k ) )
                {
                    Copy( st->delay_buf_out_fx, st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ) ), NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ) );
                    Copy( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) );
                    Copy_Scale_sig( st->delay_buf_out_fx, st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ) ), NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ), negate( Qpostd ) );                      /*Q0*/
                    Copy_Scale_sig( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ), negate( st->hHQ_core->Q_old_wtda ) ); /*Q0*/
                }
                ELSE
                {
                    Copy( st->delay_buf_out_fx, st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS ) ), NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ) );
                    Copy( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ), NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) );

                    Copy_Scale_sig( st->delay_buf_out_fx, st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS ) ), NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ), negate( Qpostd ) );                                                                                          /*Q0*/
                    Copy_Scale_sig( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ), NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ), negate( st->hHQ_core->Q_old_wtda ) ); /*Q0*/
                }
            }
        }
        ELSE
        {
            Copy( st->hTcxDec->synth_history_fx + output_frame, st->hTcxDec->synth_history_fx, add( sub( output_frame, post_hq_delay ), NS2SA_FX2( st->output_Fs, PH_ECU_MEM_NS ) ) );
            FOR( Word16 i = 0; i < output_frame; i++ )
            {
                st->hTcxDec->old_synthFB_fx[( ( i + output_frame ) - post_hq_delay )] = extract_h( L_shl_sat( output_fx[i], 16 ) ); // Q16
                move16();
            }

            IF( st->core != ACELP_CORE )
            {
                Copy( st->delay_buf_out_fx, st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), post_hq_delay ), post_hq_delay );
+13 −35
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ ivas_error evs_dec_fx(
    Word16 core_switching_flag;
    Word16 unbits;
    Word16 hq_core_type;
    Word16 post_hq_delay;
    Word32 bwe_exc_extended_fx[L_FRAME32k + NL_BUFF_OFFSET];
    Word16 voice_factors_fx[NB_SUBFR16k];
    Word16 hb_synth_fx[L_FRAME48k];
@@ -492,7 +491,10 @@ ivas_error evs_dec_fx(
            Scale_sig( st_fx->prev_synth_buffer_fx, tmps, sub( exp, st_fx->Qprev_synth_buffer_fx ) ); /*exp*/
            st_fx->Qprev_synth_buffer_fx = exp;
            move16();
            delay_signal( synth_fx, output_frame, st_fx->prev_synth_buffer_fx, tmps ); /*exp, t_fx->Qprev_synth_buffer_fx*/
            Copy( synth_fx, tmp_buffer_fx, output_frame );                                  /*exp*/
            Copy( st_fx->prev_synth_buffer_fx, synth_fx, tmps );                            /*st_fx->Qprev_synth_buffer_fx*/
            Copy( tmp_buffer_fx, synth_fx + tmps, output_frame - tmps );                    /*exp*/
            Copy( tmp_buffer_fx + output_frame - tmps, st_fx->prev_synth_buffer_fx, tmps ); /*exp*/
        }
        ELSE
        {
@@ -631,14 +633,16 @@ ivas_error evs_dec_fx(

                Copy( tmp_buffer_fx, st_fx->hb_prev_synth_buffer_fx, tmps ); /*Q15 - hBWE_TD->prev_hb_synth_fx_exp*/
            }

            /* Delay hb_synth */
            tmp16 = sub( hb_synth_fx_exp, hBWE_TD->prev_hb_synth_fx_exp );
            IF( tmp16 != 0 )
            {
                Scale_sig( st_fx->hb_prev_synth_buffer_fx, tmps, tmp16 ); /*Q15 - hb_synth_fx_exp*/
            }
            delay_signal( hb_synth_fx, output_frame, st_fx->hb_prev_synth_buffer_fx, tmps ); /*Q15 - hb_synth_fx_exp, Q15 - hb_synth_fx_exp*/
            Copy( hb_synth_fx, tmp_buffer_fx, output_frame );                                        /*Q15 - hb_synth_fx_exp*/
            Copy( st_fx->hb_prev_synth_buffer_fx, hb_synth_fx, tmps );                               /*Q15 - hb_synth_fx_exp*/
            Copy( tmp_buffer_fx, hb_synth_fx + tmps, sub( output_frame, tmps ) );                    /*Q15 - hb_synth_fx_exp*/
            Copy( tmp_buffer_fx + sub( output_frame, tmps ), st_fx->hb_prev_synth_buffer_fx, tmps ); /*Q15 - hb_synth_fx_exp*/

            st_fx->old_bwe_delay = tmps;
            move16();
@@ -1198,9 +1202,10 @@ ivas_error evs_dec_fx(
        /* Delay compensation for TD-BWE*/
        IF( GE_16( output_frame, L_FRAME16k ) )
        {
            Scale_sig( st_fx->prev_synth_buffer_fx, delay_tdbwe, negate( timeIn_e ) );
            delay_signal( output_sp, output_frame, st_fx->prev_synth_buffer_fx, delay_tdbwe ); /*timeIn_e, st_fx->q_prev_synth_buffer_fx*/
            Scale_sig( st_fx->prev_synth_buffer_fx, delay_tdbwe, timeIn_e );
            Copy( output_sp, tmp_buffer_fx, output_frame );                                                                         /*timeIn_e*/
            Copy_Scale_sig( st_fx->prev_synth_buffer_fx, output_sp, delay_tdbwe, negate( timeIn_e ) );                              /*st_fx->q_prev_synth_buffer_fx*/
            Copy( tmp_buffer_fx, output_sp + delay_tdbwe, sub( output_frame, delay_tdbwe ) );                                       /*timeIn_e*/
            Copy_Scale_sig( tmp_buffer_fx + sub( output_frame, delay_tdbwe ), st_fx->prev_synth_buffer_fx, delay_tdbwe, timeIn_e ); /*timeIn_e*/
        }

        test();
@@ -1336,35 +1341,8 @@ ivas_error evs_dec_fx(
     * Save synthesis for HQ FEC
     *----------------------------------------------------------------*/

    post_hq_delay = NS2SA_FX2( st_fx->output_Fs, POST_HQ_DELAY_NS );
    IF( EQ_16( st_fx->codec_mode, MODE1 ) )
    {

        Copy( hTcxDec->synth_history_fx + output_frame, hTcxDec->synth_history_fx, add( sub( output_frame, post_hq_delay ), NS2SA_FX2( st_fx->output_Fs, PH_ECU_MEM_NS ) ) ); /*hTcxDec->q_synth_history_fx*/
        Copy_Scale_sig( synth_fx, hTcxDec->old_synthFB_fx + sub( output_frame, post_hq_delay ), output_frame, negate( Qpostd ) );                                             /* output_sp not initialized yet */
        /* reset the remaining buffer, which is read in TCX concealment the necessary samples to fill
           this buffer are not available for all cases, the impact on the output is limited */
        set16_fx( hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), post_hq_delay ), 0, post_hq_delay );

        IF( GE_16( output_frame, L_FRAME16k ) )
        {
            Copy_Scale_sig( st_fx->prev_synth_buffer_fx, hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS ) ), NS2SA_FX2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), negate( st_fx->Qprev_synth_buffer_fx ) ); /*Q0*/
        }
        IF( NE_16( st_fx->core, ACELP_CORE ) )
        {
            IF( GE_16( output_frame, L_FRAME16k ) )
            {
                Copy_Scale_sig( synth_fx + output_frame, hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st_fx->output_Fs, DELAY_CLDFB_NS ) ), NS2SA_FX2( st_fx->output_Fs, DELAY_CLDFB_NS ), negate( Qpostd ) );           /*Q0*/
                Copy_Scale_sig( hHQ_core->old_out_fx + NS2SA_FX2( st_fx->output_Fs, N_ZERO_MDCT_NS ), hTcxDec->old_synthFB_fx + shl( output_frame, 1 ), NS2SA_FX2( st_fx->output_Fs, PH_ECU_LOOKAHEAD_NS ), negate( hHQ_core->Q_old_wtda ) ); /*Q0*/
            }
            ELSE
            {
    save_synthesis_hq_fec_fx( st_fx, synth_fx, NULL, output_frame, 0, NULL );

                Copy_Scale_sig( synth_fx + output_frame, hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS ) ), NS2SA_FX2( st_fx->output_Fs, DELAY_CLDFB_NS ), negate( Qpostd ) );                                                                                  /*Q0*/
                Copy_Scale_sig( hHQ_core->old_out_fx + NS2SA_FX2( st_fx->output_Fs, N_ZERO_MDCT_NS ), hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ), NS2SA_FX2( st_fx->output_Fs, PH_ECU_LOOKAHEAD_NS ), negate( hHQ_core->Q_old_wtda ) ); /*Q0*/
            }
        }
    }
    /*----------------------------------------------------------------*
     * HP filtering
     *----------------------------------------------------------------*/
+1 −1
Original line number Diff line number Diff line
@@ -1667,7 +1667,7 @@ ivas_error ivas_core_dec_fx(
            move16();
        }
        /* Save synthesis for HQ FEC */
        save_synthesis_hq_fec_fx( st, output_fx_loc, output_frame, hCPE );
        save_synthesis_hq_fec_fx( st, NULL, output_fx_loc, output_frame, 0, hCPE );

        /* Updates */

+1 −1
Original line number Diff line number Diff line
@@ -467,7 +467,7 @@ ivas_error ivas_mct_dec_fx(
            sts[n]->q_prev_synth_buffer_fx = 0;
            move16();

            save_synthesis_hq_fec_fx( sts[n], output_fx_, output_frame, hCPE );
            save_synthesis_hq_fec_fx( sts[n], NULL, output_fx_, output_frame, 0, hCPE );

            /* CoreCoder common updates */
            ivas_updt_dec_common_fx( hCPE->hCoreCoder[n], NORMAL_HQ_CORE, -1, output_fx[( cpe_id * CPE_CHANNELS ) + n], 11 );