Commit d51b093c authored by vaclav's avatar vaclav
Browse files

fix FIX_2320_OOB_SCE_SWITCHING

parent 8c4042de
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -145,6 +145,7 @@
#define FIX_2315_AGC_MEMORY_RESET                       /* VA: basop issue 2315: fix reset of the AGC memory */
#define FIX_2312_CONDITION_MISSING_GSC_DEC_LR           /* VA: basop issue 2297: addition of condition missing in the GSC gain decoder at low-rate */
#define FIX_2313_HF_RESET_16KHZ                         /* VA: basop issue 2313: Call hf_synth_reset_fx() also for 16 kHz output_Fs */
#define FIX_2320_OOB_SCE_SWITCHING                      /* VA: basop issue 2320: Correct the length of the buffer to be scaled in SCE/CPE switching */

/* ##################### End NON-BE switches ########################### */

+43 −4
Original line number Diff line number Diff line
@@ -227,6 +227,9 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
        Word16 q_com_cpe = Q15, q_com_cpe32 = Q31;
        move16();
        move16();
#ifdef FIX_2320_OOB_SCE_SWITCHING
        Word16 len_fir = NS2SA_FX2( hEncoderConfig->input_Fs, DELAY_FIR_RESAMPL_NS );
#endif
        IF( nSCE_old > 0 )
        {
            FOR( k = 0; k < nSCE_old; k++ )
@@ -236,8 +239,13 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
                st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp = add( st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp, shift );
                move16();
                q_com_sce = s_min( q_com_sce, st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp );
#ifdef FIX_2320_OOB_SCE_SWITCHING
                shift = sub( getScaleFactor16( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, add( input_frame, len_fir ) ), Q1 );
                scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, add( input_frame, len_fir ), shift ); /*  st_ivas->hSCE[k]->hCoreCoder[0]->q_inp + shift */
#else
                shift = sub( getScaleFactor16( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ) ), Q1 );
                scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift ); /*  st_ivas->hSCE[k]->hCoreCoder[0]->q_inp + shift */
#endif
                st_ivas->hSCE[k]->hCoreCoder[0]->q_inp = add( st_ivas->hSCE[k]->hCoreCoder[0]->q_inp, shift );
                move16();
                q_com_sce = s_min( q_com_sce, st_ivas->hSCE[k]->hCoreCoder[0]->q_inp );
@@ -247,8 +255,13 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
                st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp32 = add( st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp32, shift );
                move16();
                q_com_sce32 = s_min( q_com_sce32, st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp32 );
#ifdef FIX_2320_OOB_SCE_SWITCHING
                shift = sub( getScaleFactor32( st_ivas->hSCE[k]->hCoreCoder[0]->input32_fx, add( input_frame, len_fir ) ), Q1 );
                scale_sig32( st_ivas->hSCE[k]->hCoreCoder[0]->input32_fx, add( input_frame, len_fir ), shift ); /*  st_ivas->hSCE[k]->hCoreCoder[0]->q_inp + shift */
#else
                shift = sub( getScaleFactor32( st_ivas->hSCE[k]->hCoreCoder[0]->input32_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ) ), Q1 );
                scale_sig32( st_ivas->hSCE[k]->hCoreCoder[0]->input32_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift ); /*  st_ivas->hSCE[k]->hCoreCoder[0]->q_inp + shift */
#endif
                st_ivas->hSCE[k]->hCoreCoder[0]->q_inp32 = add( st_ivas->hSCE[k]->hCoreCoder[0]->q_inp32, shift );
                move16();
                q_com_sce32 = s_min( q_com_sce32, st_ivas->hSCE[k]->hCoreCoder[0]->q_inp32 );
@@ -267,8 +280,13 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
                    st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp = add( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp, shift );
                    move16();
                    q_com_cpe = s_min( q_com_cpe, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp );
#ifdef FIX_2320_OOB_SCE_SWITCHING
                    shift = sub( getScaleFactor16( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, add( input_frame, len_fir ) ), Q1 );
                    scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, add( input_frame, len_fir ), shift ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp + shift */
#else
                    shift = sub( getScaleFactor16( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ) ), Q1 );
                    scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp + shift */
#endif
                    st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp = add( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp, shift );
                    move16();
                    q_com_cpe = s_min( q_com_cpe, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp );
@@ -278,8 +296,13 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
                    st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp32 = add( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp32, shift );
                    move16();
                    q_com_cpe32 = s_min( q_com_cpe32, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp32 );
#ifdef FIX_2320_OOB_SCE_SWITCHING
                    shift = sub( getScaleFactor32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input32_fx, add( input_frame, len_fir ) ), Q1 );
                    scale_sig32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input32_fx, add( input_frame, len_fir ), shift ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp + shift */
#else
                    shift = sub( getScaleFactor32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input32_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ) ), Q1 );
                    scale_sig32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input32_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift );                                                    /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp + shift */
#endif
                    st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp32 = add( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp32, shift );
                    move16();
                    q_com_cpe32 = s_min( q_com_cpe32, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp32 );
@@ -294,10 +317,18 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
                scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->old_input_signal_fx, input_frame, sub( q_com, st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp ) ); /* q_com */
                st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp = q_com;
                move16();
#ifdef FIX_2320_OOB_SCE_SWITCHING
                scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, add( input_frame, len_fir ), sub( q_com, st_ivas->hSCE[k]->hCoreCoder[0]->q_inp ) ); /* q_com */
#else
                scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), sub( q_com, st_ivas->hSCE[k]->hCoreCoder[0]->q_inp ) );                  /* q_com */
#endif
                st_ivas->hSCE[k]->hCoreCoder[0]->q_inp = q_com;
                move16();
#ifdef FIX_2320_OOB_SCE_SWITCHING
                Copy_Scale_sig_16_32_DEPREC( st_ivas->hSCE[k]->hCoreCoder[0]->input_buff_fx, st_ivas->hSCE[k]->hCoreCoder[0]->input_buff32_fx, add( shl( input_frame, 1 ), len_fir ), Q6 ); /* Q6 + q_com */
#else
                Copy_Scale_sig_16_32_DEPREC( st_ivas->hSCE[k]->hCoreCoder[0]->input_buff_fx, st_ivas->hSCE[k]->hCoreCoder[0]->input_buff32_fx, L_FRAME48k + NS2SA( 48000, IVAS_FB_ENC_DELAY_NS ) + L_FRAME48k, Q6 );               /* Q6 + q_com */
#endif
                st_ivas->hSCE[k]->hCoreCoder[0]->q_inp32 = add( Q6, q_com );
                st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp32 = add( Q6, q_com );
                move16();
@@ -314,10 +345,18 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
                    scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->old_input_signal_fx, input_frame, sub( q_com, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp ) ); /* q_com */
                    st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp = q_com;
                    move16();
#ifdef FIX_2320_OOB_SCE_SWITCHING
                    scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, add( input_frame, len_fir ), sub( q_com, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp ) ); /* q_com */
#else
                    scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), sub( q_com, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp ) );    /* q_com */
#endif
                    st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp = q_com;
                    move16();
#ifdef FIX_2320_OOB_SCE_SWITCHING
                    Copy_Scale_sig_16_32_DEPREC( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff_fx, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff32_fx, add( shl( input_frame, 1 ), len_fir ), Q6 ); /* Q6 + q_com */
#else
                    Copy_Scale_sig_16_32_DEPREC( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff_fx, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff32_fx, L_FRAME48k + NS2SA( 48000, IVAS_FB_ENC_DELAY_NS ) + L_FRAME48k, Q6 ); /* Q6 + q_com */
#endif
                    st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp32 = add( Q6, q_com );
                    st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp32 = add( Q6, q_com );
                    move16();
+15 −1
Original line number Diff line number Diff line
@@ -437,10 +437,18 @@ ivas_error ivas_cpe_enc_fx(
     * Temporal inter-channel alignment, stereo adjustment
     *----------------------------------------------------------------*/

#ifdef FIX_2320_OOB_SCE_SWITCHING
    Word16 len_input_buff = add( shl( input_frame, 1 ), NS2SA_FX2( hEncoderConfig->input_Fs, DELAY_FIR_RESAMPL_NS ) );
    shift = s_min( L_norm_arr( sts[0]->input_buff32_fx, len_input_buff ), L_norm_arr( sts[1]->input_buff32_fx, len_input_buff ) );
    q_min = add( sts[0]->q_inp32, sub( shift, find_guarded_bits_fx( input_frame ) ) );
    scale_sig32( sts[1]->input_buff32_fx, len_input_buff, sub( q_min, sts[1]->q_inp32 ) ); /* q_min */
    scale_sig32( sts[0]->input_buff32_fx, len_input_buff, sub( q_min, sts[0]->q_inp32 ) ); /* q_min */
#else
    shift = s_min( L_norm_arr( sts[0]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), L_norm_arr( sts[1]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ) );
    q_min = add( sts[0]->q_inp32, sub( shift, find_guarded_bits_fx( input_frame ) ) );
    scale_sig32( sts[1]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), sub( q_min, sts[1]->q_inp32 ) ); /* q_min */
    scale_sig32( sts[0]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), sub( q_min, sts[0]->q_inp32 ) ); /* q_min */
#endif
    sts[0]->q_inp32 = sts[1]->q_inp32 = sts[0]->q_old_inp32 = sts[1]->q_old_inp32 = q_min;
    move16();
    move16();
@@ -449,11 +457,17 @@ ivas_error ivas_cpe_enc_fx(

    stereo_tca_enc_fx( hCPE, input_frame );

#ifdef FIX_2320_OOB_SCE_SWITCHING
    shift = sub( add( L_norm_arr( sts[0]->input_buff32_fx, len_input_buff ), sts[0]->q_inp32 ), 16 );
    shift = s_min( shift, sub( add( L_norm_arr( sts[1]->input_buff32_fx, len_input_buff ), sts[1]->q_inp32 ), 16 ) );
    Copy_Scale_sig32_16( sts[0]->input_buff32_fx, sts[0]->input_buff_fx, len_input_buff, sub( add( Q16, shift ), sts[0]->q_inp32 ) ); // shift
    Copy_Scale_sig32_16( sts[1]->input_buff32_fx, sts[1]->input_buff_fx, len_input_buff, sub( add( Q16, shift ), sts[1]->q_inp32 ) ); // shift
#else
    shift = sub( add( L_norm_arr( sts[0]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), sts[0]->q_inp32 ), 16 );
    shift = s_min( shift, sub( add( L_norm_arr( sts[1]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), sts[1]->q_inp32 ), 16 ) );
    Copy_Scale_sig32_16( sts[0]->input_buff32_fx, sts[0]->input_buff_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), sub( add( Q16, shift ), sts[0]->q_inp32 ) ); // shift
    Copy_Scale_sig32_16( sts[1]->input_buff32_fx, sts[1]->input_buff_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), sub( add( Q16, shift ), sts[1]->q_inp32 ) ); // shift

#endif
    sts[0]->q_inp = sts[1]->q_inp = sts[0]->q_old_inp = sts[1]->q_old_inp = shift;
    move16();
    move16();