Commit f1392288 authored by vaclav's avatar vaclav
Browse files

- Merge remote-tracking branch 'remotes/origin/main' into...

- Merge remote-tracking branch 'remotes/origin/main' into basop-2404-harmonization-of-signal-classification
parents b17f0ba9 ac0742ee
Loading
Loading
Loading
Loading
Loading
+64 −9
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ static Word16 VDQ_vec_fx( Word16 *Qvec_out_fx, const Word16 *mean_dic_fx, const


/*========================================================================*/
/* FUNCTION : void Comp_and_apply_gain_enc_fx                             */
/* FUNCTION : void Comp_and_apply_gain_fx                                 */
/*------------------------------------------------------------------------*/
/* PURPOSE :  Compute and apply the quantized per band gain               */
/*------------------------------------------------------------------------*/
@@ -70,12 +70,19 @@ static Word16 VDQ_vec_fx( Word16 *Qvec_out_fx, const Word16 *mean_dic_fx, const
/* _ None                                                                 */
/*========================================================================*/

#ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX
Word16 Comp_and_apply_gain_fx(
#else
void Comp_and_apply_gain_fx(
#endif
    Word16 exc_diffQ[],      /* i/o: Quantized excitation                  */
    Word16 Ener_per_bd_iQ[], /* i  : Target ener per band              Q13 */
    Word16 Ener_per_bd_yQ[], /* i/o: Ener per band for norm vector   i->Q13/o->Q13 */
    Word16 Mbands_gn,        /* i  : number of bands                       */
    const Word16 ReUseGain,  /* i  : Reuse the gain in Ener_per_bd_yQ      */
#ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX
    const Word16 Flag_adj_q_exc, /* i  : Flag allowing Q_exc adjustment   */
#endif
    Word16 Qexc_diff,
    Word16 Q_exc )
{
@@ -83,6 +90,11 @@ void Comp_and_apply_gain_fx(
    Word16 StartBin, NB_Qbins;
    Word16 y_gain;
    Word16 L16, frac, exp1, tmp_exp;
#ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX
    Word16 Q_adapt;
    Word16 Q_exc_diffQ[L_FRAME16k];
    Word32 exc_diffQ32[L_FRAME16k];
#endif
    Word32 L32;

    /* Recreate excitation for local synthesis and decoder */
@@ -92,6 +104,7 @@ void Comp_and_apply_gain_fx(
    move16();

    tmp_exp = add( 14, sub( Q_exc, Qexc_diff ) ); /* In case of reuse, it can be computed outside the loop*/

    FOR( i_band = 0; i_band < Mbands_gn; i_band++ )
    {
        StartBin = add( StartBin, NB_Qbins );
@@ -126,7 +139,24 @@ void Comp_and_apply_gain_fx(
            Ener_per_bd_yQ[i_band] = shl_sat( y_gain, sub( exp1, 13 ) );
            move16(); /*Q1     */
            tmp_exp = add( add( exp1, 1 ), sub( Q_exc, Qexc_diff ) );

#ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX
            IF( Flag_adj_q_exc != 0 )
            {
                FOR( i = StartBin; i < NB_Qbins + StartBin; i++ )
                {
                    exc_diffQ32[i] = L_mult( exc_diffQ[i], y_gain ); /*Qexc_diff+15 */
                    move32();
                    Q_exc_diffQ[i] = Q_exc;
                    if ( exc_diffQ[i] )
                    {
                        Q_exc_diffQ[i] = sub( Q_exc_diffQ[i], tmp_exp );
                        move16();
                    }
                }
            }
            ELSE
#endif
            {
                FOR( i = StartBin; i < NB_Qbins + StartBin; i++ )
                {
                    L32 = L_mult( exc_diffQ[i], y_gain );                     /*Qexc_diff+15 */
@@ -135,8 +165,29 @@ void Comp_and_apply_gain_fx(
                }
            }
        }

    }
#ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX
    Q_adapt = Q_exc;
    move16();
    test();
    IF( EQ_16( ReUseGain, 0 ) && Flag_adj_q_exc != 0 )
    {
        Word16 total_bins = add( StartBin, NB_Qbins );
        move16();
        FOR( i = 0; i < total_bins; i++ )
        {
            Q_adapt = s_min( Q_adapt, add( Q_exc_diffQ[i], norm_l( exc_diffQ32[i] ) ) );
            move16();
        }
        FOR( i = 0; i < total_bins; i++ )
        {
            exc_diffQ[i] = round_fx( L_shl( exc_diffQ32[i], sub( Q_adapt, Q_exc_diffQ[i] ) ) ); /*Q_exc*/
        }
    }
    return Q_adapt;
#else
    return;
#endif
}
#ifndef FIX_2338_HARM_GSC_GAIN_COMP

@@ -422,7 +473,7 @@ static void GSC_gain_adj(
    }
    ELSE
    {
        Gain_off = 0;
        Gain_off = 0; /* For higher bitrate, thus for L_frame == L_FRAME16k as well */
        move16();

        test();
@@ -460,7 +511,11 @@ static void GSC_gain_adj(
        }

        /*mimic ACELP decay of energy for low rates*/
#ifndef FIX_2406_FIX_GAIN_ON_INACTIVE
        FOR( i = 0; i < MBANDS_GN; i++ )
#else
        FOR( i = 0; i < Mbands_gn; i++ )
#endif
        {
            old_y_gain[i] = y_gain_tmp[i];
            move16();
@@ -475,7 +530,7 @@ static void GSC_gain_adj(


/*==========================================================================*/
/* FUNCTION : Word16 gsc_gaindec_ivas_fx()                                  */
/* FUNCTION : Word16 gsc_gaindec_fx()                                       */
/*--------------------------------------------------------------------------*/
/* PURPOSE  :  Generic signal frequency band decoding and application       */
/*--------------------------------------------------------------------------*/
+31 −3
Original line number Diff line number Diff line
@@ -1069,6 +1069,9 @@ void highband_exc_dct_in_ivas_fx(
    Word16 frac, exp, tmp1;
    Word16 tmp2;
    Word16 *end, Q_hb_exc;
#ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX
    Word16 Flag_adj_q_exc, old_Q_exc;
#endif

    FOR( j = 10; j < MBANDS_GN; j++ )
    {
@@ -1340,10 +1343,9 @@ void highband_exc_dct_in_ivas_fx(
            move16();
        }
    }
#ifndef FIX_2338_HARM_GSC_GAIN_COMP
#if !defined FIX_2338_HARM_GSC_GAIN_COMP && !defined FIX_2380_HARM_GSC_GAIN_COMP_FX
    IF( EQ_16( element_mode, EVS_MONO ) )
    {
#endif
        Comp_and_apply_gain_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Qexc_diffQ, *Q_exc );

        IF( exc_wo_nf != NULL )
@@ -1351,7 +1353,6 @@ void highband_exc_dct_in_ivas_fx(
            Comp_and_apply_gain_fx( exc_wo_nf, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 1, Qexc_diffQ, *Q_exc );
            Vr_add( exc_dct_in, exc_wo_nf, exc_wo_nf, L_frame );
        }
#ifndef FIX_2338_HARM_GSC_GAIN_COMP
    }
    ELSE
    {
@@ -1382,7 +1383,34 @@ void highband_exc_dct_in_ivas_fx(
            Scale_sig( exc_dct_in, L_frame, sub( *Q_exc, Q_old ) );
        }
    }
#elif defined FIX_2380_HARM_GSC_GAIN_COMP_FX
    Flag_adj_q_exc = 0;
    move16();
    IF( NE_16( element_mode, EVS_MONO ) && lt_ener_per_band_fx != NULL ) /* to keep all EVS BE */
    {
        Flag_adj_q_exc = 1;
        move16();
    }
    old_Q_exc = *Q_exc;
    move16();
    *Q_exc = Comp_and_apply_gain_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Flag_adj_q_exc, Qexc_diffQ, *Q_exc );
    Scale_sig( exc_dct_in, L_frame, sub( *Q_exc, old_Q_exc ) );

    IF( exc_wo_nf != NULL )
    {
        Comp_and_apply_gain_fx( exc_wo_nf, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 1, Flag_adj_q_exc, Qexc_diffQ, *Q_exc );
        Vr_add( exc_dct_in, exc_wo_nf, exc_wo_nf, L_frame );
    }
#else /* #if defined FIX_2338_HARM_GSC_GAIN_COMP */
        Comp_and_apply_gain_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Qexc_diffQ, *Q_exc );

        IF( exc_wo_nf != NULL )
        {
            Comp_and_apply_gain_fx( exc_wo_nf, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 1, Qexc_diffQ, *Q_exc );
            Vr_add( exc_dct_in, exc_wo_nf, exc_wo_nf, L_frame );
        }
#endif

    /*--------------------------------------------------------------------------------------*
     * add the correction layer to the LF bins,
     * and add the quantized pulses or the noise for the higher part of the spectrum
+12 −0
Original line number Diff line number Diff line
@@ -1587,8 +1587,12 @@ void ivas_hq_core_dec_fx(
    const Word16 output_frame,                                  /* i  : output frame length                     */
    const Word16 hq_core_type,                                  /* i  : HQ core type                            */
    const Word16 core_switching_flag,                           /* i  : ACELP->HQ switching frame flag          */
#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING
    Word32 *output_32_fx                                        /* o  : synthesis @internal_Fs, Q11             */
#else
    Word16 output[],
    Word16 *Q_output 
#endif
);

#ifndef HARMONIZE_TBE
@@ -1890,7 +1894,11 @@ void GenShapedWBExcitation_ivas_fx(
/* o : Q_syn_hb*/
Word16 ivas_wb_bwe_dec_fx(
    Decoder_State *st_fx,                                       /* i/o: decoder state structure                 */
#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING
    Word32 output_fx32[],                                       /* o  : synthesis @internal Fs               Q11*/
#else
    const Word16 output[],                                      /* i  : suntehsis @ internal Fs Q_input         */
    #endif
    Word16 *synth_fx,                                           /* i/o: ACELP core synthesis/final synthesis   Q0/Qpost */
    Word16 *hb_synth_fx,                                        /* o  : SHB synthesis/final synthesis          Q_syn_hb */
    const Word16 use_cldfb_for_dft,                             /* i  : flag to use of CLDFB for DFT Stereo     */
@@ -2088,7 +2096,11 @@ void ivas_buffer_deinterleaved_to_interleaved_fx(
void stereo_tcx_core_dec_fx(
    Decoder_State *st,                                          /* i/o: decoder state structure                     */
    const FRAME_MODE frameMode,                                 /* i  : Decoder frame mode                          */
#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING
    Word32 *signal_out_32_fx,                                   /* o  : synthesis @internal_Fs, Q11                 */
#else
    Word16 *signal_out,                                         /* o  : synthesis @internal_Fs, Q0                  */
#endif
    Word16 *signal_outFB,                                       /* o  : synthesis @output_Fs, Q0                    */
    Word16 pitch_buf[],                                         /* o  : floating pitch for each subframe, Q6        */
    const Word16 sba_dirac_stereo_flag,                         /* i  : signal stereo output for SBA DirAC          */
+6 −0
Original line number Diff line number Diff line
@@ -87,6 +87,10 @@
#define FIX_2397_COPY_AQ_MDCT_CORE_BFI                  /* FhG: prevent copying of uninit memory in MDCT stereo core if bfi is set */
#define HARMONIZE_TBE                                   /* VA: harmonize core-coder TBE function duplications */
#define FIX_2405_HARM_SMC_INIT                          /* VA, basop 2405, harmonisation of SMC init */
#define FIX_2280_REDUCTION_UNNECESSARY_SCALING          /* VA: reduction of unnecessary scaling */
#define FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE    /* VA: reduction of unnecessary scaling, non-BE part */
#define FIX_2403_COMBINE_PITCH_OL                       /* VA : basop 2403, reusing common code between EVS and IVAS in pitch_ol */
#define HARMONIZE_ACELP_ENC                             /* VA: basop issue 2400: Remove duplicated main ACELP encoder function */
#define FIX_2404_HARM_SIGNAL_CLAS                       /* VA: basop-2404, harmonize signal_clas and signa_ivas_clas */

/* #################### End BE switches ################################## */
@@ -99,6 +103,8 @@
#define FIX_BASOP_2361_OTR                              /* FhG: Basop issue 2361: Orientation tracking tests for equivalent rotations fail */
#define FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER           /* FhG/VA: basop issue 2396: keep TC channel pointers in one constant place during decoding and rendering */
#define FIX_2408_FD_BWE_UPDATE                          /* VA: basop issue 2408: bug-fix in the FD BWE memory updates in wb_pre_proc_ivas_fx()  */
#define FIX_2380_HARM_GSC_GAIN_COMP_FX                  /* VA: basop issue 2380 & 2381: Fix issue when switching from CNG low energy to active content with high energy */
#define FIX_2406_FIX_GAIN_ON_INACTIVE                   /* VA: basop issue 2406: gain between 6.4 and 8kHz was too weak during inactive content with Fs=16kHz  */

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

+49 −16
Original line number Diff line number Diff line
@@ -1703,14 +1703,22 @@ void Ener_per_band_comp_ivas_fx(
    const Word16 L_frame        /* i  : frame length                      */
);
#ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX
Word16 Comp_and_apply_gain_fx(
#else
void Comp_and_apply_gain_fx(
#endif
    Word16 exc_diffQ[],      /* i/o: Quantized excitation                  */
    Word16 Ener_per_bd_iQ[], /* i  : Target ener per band              Q13 */
    Word16 Ener_per_bd_yQ[], /* i/o: Ener per band for norm vector   i->Q13/o->Q13 */
    Word16 Mbands_gn,        /* i  : number of bands                       */
    const Word16 ReUseGain,  /* i  : Reuse the gain in Ener_per_bd_yQ      */
#ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX
    const Word16 Flag_adj_q_exc, /* i  : Ener_per_bd_iQ of lt_ener_per_band_fx   */
#endif
    Word16 Qexc_diff,
    Word16 Q_exc );
#ifndef FIX_2338_HARM_GSC_GAIN_COMP
void Comp_and_apply_gain_ivas_fx(
    Word16 exc_diffQ[],      /* i/o: Quantized excitation                  */
@@ -7574,8 +7582,13 @@ ivas_error core_switching_pre_dec_fx(
ivas_error core_switching_post_dec_fx(
    Decoder_State *st_fx, /* i/o: decoder state structure                                                           */
    Word16 *synth,        /* i/o: output synthesis                                                            Qsynth*/
#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING
    Word32 *output_fx,        /* i/o: LB synth/upsampled LB synth                                                    Q11*/
    Word32 output_mem_fx32[], /* i  : OLA memory from last TCX/HQ frame                                               Qx*/
#else
    Word32 *output_fx,           /* i/o: LB synth/upsampled LB synth                                                     Q4*/
    Word16 output_mem_fx[],      /* i  : OLA memory from last TCX/HQ frame                                               Qx*/
#endif
    const Word16 use_cldfb_for_dft,     /* i  : flag to use of CLDFB for DFT Stereo                                             Q0*/
    const Word16 output_frame,          /* i  : frame length                                                                    Q0*/
    const Word16 core_switching_flag,   /* i  : ACELP->HQ switching flag                                                        Q0*/
@@ -10110,9 +10123,17 @@ Word16 swb_bwe_dec_fx32(
ivas_error acelp_core_dec_fx(
    Decoder_State *st, /* i/o: decoder state structure                                                 */
#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING
    Word32 output_fx32[], /* o  : synthesis @internal Fs                                               Q11*/
#else
    Word16 output_fx[],          /* o  : synthesis @internal Fs                                                  */
#endif
    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  */
@@ -10846,7 +10867,11 @@ ivas_error init_encoder_fx(
    const Word32 element_brate  /* i  : element bitrate                      */
);
#ifdef HARMONIZE_ACELP_ENC
ivas_error acelp_core_enc_fx(
#else
ivas_error acelp_core_enc_ivas_fx(
#endif
    Encoder_State *st,                  /* i/o: encoder state structure                 */
    const Word16 inp[],                 /* i  : input signal of the current frame       Q_new*/
    Word16 A[NB_SUBFR16k * ( M + 1 )],  /* i  : A(z) unquantized for the 4 subframes    Q12*/
@@ -10859,12 +10884,20 @@ ivas_error acelp_core_enc_ivas_fx(
    Word32 bwe_exc_extended_fx[],       /* i/o: bandwidth extended excitation           st->prev_Q_bwe_exc*/
    Word16 *voice_factors_fx,           /* o  : voicing factors                         Q15*/
    Word16 old_syn_12k8_16k[],          /* o  : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE        q_old_syn_12k8_16*/
    Word16 *q_old_syn_12k8_16,
#ifndef HARMONIZE_ACELP_ENC
    Word16 *q_old_syn_12k8_16, /* o  : Q factor of old_syn_12k8_16k[]          */
#endif
    Word16 pitch_buf[NB_SUBFR16k],       /* o  : floating pitch for each subframe        Q6*/
    Word16 *unbits,                      /* o  : number of unused bits                   Q0*/
    STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle                */
    Word16 tdm_lsfQ_PCh[M],              /* i  : Q LSFs for primary channel              X2.56*/
    const Word16 Q_new );
#ifdef HARMONIZE_ACELP_ENC
    const Word16 Q_new, /* i  : Scaling factor                          */
    const Word16 shift  /* i  : Shift need to obtain 12 bits vectors    */
#else
    const Word16 Q_new
#endif
);
void flip_and_downmix_generic_fx32(
    Word32 input[],                      /* i : input spectrum Qx*/
Loading