Commit 647937cb authored by vaillancour's avatar vaillancour
Browse files

Removal of unnecessary scaling

parent 8056dfd7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -100,7 +100,7 @@
#define FIX_2274_OOB_INDEXING_IN_CORRMATRIX             /* FhG: fix OOB indexing complaint */
#define FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH /* FhG: fix oob indexing USAN complaint */
#define FIX_2287_MCT_MDCT_STEREO_DATA_MALLOC_SIZE       /* FhG: correct allocation size for STEREO_MDCT_DEC_DATA struct */

#define FIX_2280_REDUCTION_UNNECESSARY_SCALING          /* VA: reduction of unnecessary scaling */
/* #################### End BE switches ################################## */

/* #################### Start NON-BE switches ############################ */
+4 −0
Original line number Diff line number Diff line
@@ -10321,7 +10321,11 @@ ivas_error acelp_core_dec_fx(
    Decoder_State *st,                   /* i/o: decoder state structure                                                 */
    Word16 output_fx[],                  /* o  : synthesis @internal Fs                                                  */
    Word16 synth_fx16[],                 /* o  : synthesis                                                               */
#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING
    Word32 save_hb_synth_fx32[],         /* o  : HB synthesis                                                            Q0*/
#else
    Word16 save_hb_synth_fx16[],         /* o  : HB synthesis                                                            */
#endif
    Word32 bwe_exc_extended_fx[],        /* i/o: bandwidth extended excitation                                           */
    Word16 *voice_factors_fx,            /* o  : voicing factors                                                         */
    Word16 old_syn_12k8_16k_fx[],        /* o  : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE  */
+18 −1
Original line number Diff line number Diff line
@@ -55,7 +55,11 @@ ivas_error acelp_core_dec_fx(
    Decoder_State *st,                   /* i/o: decoder state structure                                                 */
    Word16 output_fx[],                  /* o  : synthesis @internal Fs                                                  Q_syn*/
    Word16 synth_fx16[],                 /* o  : synthesis                                                               Q_syn2*/
#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING
    Word32 save_hb_synth_fx32[],         /* o  : HB synthesis                                                            Q0*/
#else
    Word16 save_hb_synth_fx16[],         /* o  : HB synthesis                                                            Q0*/
#endif
    Word32 bwe_exc_extended_fx[],        /* i/o: bandwidth extended excitation                                           2*Q_exc*/
    Word16 *voice_factors_fx,            /* o  : voicing factors                                                         Q15*/
    Word16 old_syn_12k8_16k_fx[],        /* o  : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE  Q_syn2-1*/
@@ -74,7 +78,11 @@ ivas_error acelp_core_dec_fx(
    const Word16 read_sid_info           /* i  : read SID info flag                          */
)
{
#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING
    Word32 synth_fx[960];
#else
    Word32 synth_fx[960], save_hb_synth_fx[960] /*, bwe_exc_extended_fx[L_FRAME32k + NL_BUFF_OFFSET]*/;
#endif
    Word16 old_exc_fx[L_EXC_DEC], *exc_fx;                                           /* excitation signal buffer              */
    Word16 syn_tmp_fx[L_FRAME16k + L_SUBFR], *psyn_fx;                               /* synthesis signal buffer               */
    Word16 output_frame;                                                             /* frame length at output sampling freq. */
@@ -2008,7 +2016,11 @@ ivas_error acelp_core_dec_fx(
                }
            }

#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING
            IF( save_hb_synth_fx32 != NULL )
#else
            IF( save_hb_synth_fx16 != NULL )
#endif
            {
                /* save and then zero-out lowband */
                max_real = 0;
@@ -2049,8 +2061,11 @@ ivas_error acelp_core_dec_fx(
                    }
                }

#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING
                cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx32, -1, sub( Q11, Q_real ), -10, st->cldfbSynHB );
#else
                cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx, -1, sub( Q11, Q_real ), -10, st->cldfbSynHB );

#endif
                /* restore lowband */
                FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
                {
@@ -2333,6 +2348,7 @@ ivas_error acelp_core_dec_fx(

    IF( NE_16( st->element_mode, EVS_MONO ) )
    {
#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING
#ifdef FIX_2252_SCALING_SAVE_HB_SYNTH
        IF( save_hb_synth_fx16 != NULL )
#else
@@ -2345,6 +2361,7 @@ ivas_error acelp_core_dec_fx(
            Copy_Scale_sig_32_16( save_hb_synth_fx, save_hb_synth_fx16, L_FRAME48k, 0 ); // Q0
#endif
        }
#endif
        Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 ); // Q_syn2
    }

+10 −3
Original line number Diff line number Diff line
@@ -479,6 +479,7 @@ ivas_error ivas_core_dec_fx(
        {
            /* ACELP core decoder */
            Word16 old_syn_12k8_16k_fx_16[L_FRAME16k];
#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING
            Word16 save_hb_synth_fx_arr[L_FRAME48k], *save_hb_synth_16_fx;

            IF( save_hb_synth_32_fx )
@@ -489,7 +490,7 @@ ivas_error ivas_core_dec_fx(
            {
                save_hb_synth_16_fx = NULL;
            }

#endif
            IF( st->cldfbAna )
            {
                scale_sig32( st->cldfbAna->cldfb_state_fx, st->cldfbAna->cldfb_size, Q11 - Q10 ); // Q11
@@ -529,7 +530,11 @@ ivas_error ivas_core_dec_fx(
            st->Q_syn_factor = 0;
            move16();

#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING
            IF( NE_32( ( error = acelp_core_dec_fx( st, output_16_fx[n], synth_16_fx[n], save_hb_synth_32_fx, bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx_16, sharpFlag[n], pitch_buf_fx[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lsfQ_PCh_fx, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hStereoCng, read_sid_info ) ), IVAS_ERR_OK ) )
#else
            IF( NE_32( ( error = acelp_core_dec_fx( st, output_16_fx[n], synth_16_fx[n], save_hb_synth_16_fx, bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx_16, sharpFlag[n], pitch_buf_fx[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lsfQ_PCh_fx, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hStereoCng, read_sid_info ) ), IVAS_ERR_OK ) )
#endif
            {
                return error;
            }
@@ -555,14 +560,16 @@ ivas_error ivas_core_dec_fx(
                move16();
            }
            move16();

            IF( save_hb_synth_32_fx )
            {
#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING
                Copy_Scale_sig_16_32_DEPREC( save_hb_synth_16_fx, save_hb_synth_32_fx, output_frame, Q11 ); // Q11
#else
                Scale_sig32( save_hb_synth_32_fx, output_frame, Q11 ); // Q0 -> Q11
#endif
                hSCE->q_save_hb_synth_fx = Q11;
                move16();
            }

            Copy_Scale_sig_16_32_DEPREC( old_syn_12k8_16k_fx_16, old_syn_12k8_16k_fx[n], L_FRAME16k, Q11 - ( -Q1 ) ); // Q(11 - (-1))
        }