Skip to content

Missing one sub-frame in the last part of the function decod_gen_2sbfr_ivas_fx()

in 30632c9d, in the very low bit rate mode, the filling of the second part of the excitation is sometime missing. Below, you can find the proposed corrections.

        /*----------------------------------------------------------------------*
         * Find the total excitation
         *----------------------------------------------------------------------*/
#ifdef FIX_MISSING_SUBFR /* Don't need the if/else as here L_frame==L_FRAME all the time */

        Rescale_exc(st->hMusicPF->dct_post_old_exc_fx, &exc[i_subfr], (bwe_exc != NULL) ? &bwe_exc[i_subfr * HIBND_ACB_L_FAC] : NULL, st->hGSCDec->last_exc_dct_in_fx,
                2 * L_SUBFR, 2 * L_SUBFR* HIBND_ACB_L_FAC, gain_code, &(st->Q_exc), st->Q_subfr, exc2, i_subfr, st->coder_type);

#else        
        IF(EQ_16(st->L_frame, L_FRAME))
        {
            Rescale_exc(st->hMusicPF->dct_post_old_exc_fx, &exc[i_subfr], (bwe_exc != NULL) ? &bwe_exc[i_subfr * HIBND_ACB_L_FAC] : NULL, st->hGSCDec->last_exc_dct_in_fx,
                L_SUBFR, L_SUBFR* HIBND_ACB_L_FAC, gain_code, &(st->Q_exc), st->Q_subfr, exc2, i_subfr, st->coder_type);
        }
        ELSE
        {
            Rescale_exc(st->hMusicPF->dct_post_old_exc_fx, &exc[i_subfr],  (bwe_exc != NULL) ? &bwe_exc[i_subfr * 2] : NULL, st->hGSCDec->last_exc_dct_in_fx,
            L_SUBFR, L_SUBFR * 2, gain_code, &(st->Q_exc),  st->Q_subfr, exc2, i_subfr,  st->coder_type);
        }
#endif

#ifdef FIX_MISSING_SUBFR
         Acelp_dec_total_exc(exc, exc2, gain_code16, gain_pit, i_subfr, code, 2 * L_SUBFR);
#else 
         Acelp_dec_total_exc(exc, exc2, gain_code16, gain_pit, i_subfr, code, L_SUBFR);
#endif
        /*-----------------------------------------------------------------*
         * Prepare TBE excitation
         *-----------------------------------------------------------------*/

#ifdef FIX_MISSING_SUBFR
        prep_tbe_exc_ivas_fx( L_frame, 2 * L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR], bwe_exc, 0, NULL, st->Q_exc, T0, T0_frac, GENERIC, st->core_brate, st->element_mode, st->idchan, st->hBWE_TD != NULL, st->tdm_LRTD_flag );
#else
        prep_tbe_exc_ivas_fx( L_frame, L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR], bwe_exc, 0, NULL, st->Q_exc, T0, T0_frac, GENERIC, st->core_brate, st->element_mode, st->idchan, st->hBWE_TD != NULL, st->tdm_LRTD_flag );
#endif
        voice_factors[i_subfr / L_SUBFR + 1] = voice_factors[i_subfr / L_SUBFR];

        /*----------------------------------------------------------------*
         * Excitation enhancements (update of total excitation signal)
         * called twice because adapting it to double the subfr length would need lot of modifications
         *----------------------------------------------------------------*/
#ifdef FIX_MISSING_SUBFR
        enhancer_fx( st->core_brate, 0, GENERIC, i_subfr, L_frame, voice_fac, st->stab_fac_fx, norm_gain_code, gain_inov, &st->gc_threshold_fx, code, exc2 + i_subfr, gain_pit, &st->dm_fx, st->Q_exc);

        enhancer_fx( st->core_brate, 0, GENERIC, i_subfr, L_frame, voice_fac, st->stab_fac_fx, norm_gain_code, gain_inov, &st->gc_threshold_fx, code + L_SUBFR, exc2 + i_subfr + L_SUBFR, gain_pit, &st->dm_fx, st->Q_exc);
#else
        enhancer_fx( st->core_brate, 0, GENERIC, i_subfr, L_frame, voice_fac, st->stab_fac_fx, norm_gain_code, gain_inov, &st->gc_threshold_fx, code, exc2, gain_pit, &st->dm_fx, st->Q_exc);

        enhancer_fx( st->core_brate, 0, GENERIC, i_subfr, L_frame, voice_fac, st->stab_fac_fx, norm_gain_code, gain_inov, &st->gc_threshold_fx, code + L_SUBFR, exc2 + L_SUBFR, gain_pit, &st->dm_fx, st->Q_exc);

#endif