Commit 12383203 authored by vaclav's avatar vaclav
Browse files

issue 1264: Fix bitstream synchronization between encoder and decoder in ACELP...

issue 1264: Fix bitstream synchronization between encoder and decoder in ACELP GSC in OMASA; under NONBE_FIX_GSC_BSTR
parent 014cf4f5
Loading
Loading
Loading
Loading
Loading
+42 −11
Original line number Diff line number Diff line
@@ -542,6 +542,9 @@ ivas_error config_acelp1(
    ACELP_config *acelp_cfg,        /* i  : ACELP bit-allocation            */
    const int16_t signaling_bits,   /* i  : number of signaling bits        */
    const int16_t coder_type,       /* i  : coder type                      */
#ifdef NONBE_FIX_GSC_BSTR
    const int16_t inactive_coder_type_flag, /* i  : AVQ (0) or GSC (1) IC flag      */
#endif
    const int16_t tc_subfr,             /* i  : TC subfr ID                     */
    const int16_t tc_call,              /* i  : TC call number (0,1,2,3,5(DEC)) */
    int16_t *nBits_es_Pred,             /* o  : number of bits for Es_pred Q    */
@@ -775,7 +778,11 @@ ivas_error config_acelp1(
        }

        /* gain Q bit-budget - part 1 */
#ifdef NONBE_FIX_GSC_BSTR
        if ( ( coder_type != UNVOICED && coder_type != AUDIO && coder_type != INACTIVE && !( core_brate <= ACELP_8k00 && coder_type != TRANSITION ) ) || ( coder_type == INACTIVE && !inactive_coder_type_flag ) )
#else
        if ( ( coder_type != UNVOICED && coder_type != AUDIO && coder_type != INACTIVE && !( core_brate <= ACELP_8k00 && coder_type != TRANSITION ) ) || ( coder_type == INACTIVE && total_brate > MAX_GSC_INACTIVE_BRATE ) )
#endif
        {
            *nBits_es_Pred = Es_pred_bits_tbl[BIT_ALLOC_IDX( core_brate, coder_type, -1, -1 )];
            bits -= *nBits_es_Pred;
@@ -868,7 +875,11 @@ ivas_error config_acelp1(
    }
    else if ( core_brate >= ACELP_11k60 && ( coder_type != AUDIO && !( coder_type == INACTIVE && L_frame == L_FRAME ) ) )
    {
#ifdef NONBE_FIX_GSC_BSTR
        if ( coder_type == INACTIVE && L_frame == L_FRAME16k && inactive_coder_type_flag ) /* GSC Inactive @16kHz */
#else
        if ( coder_type == INACTIVE && L_frame == L_FRAME16k && total_brate <= MAX_GSC_INACTIVE_BRATE ) /* GSC Inactive @16kHz */
#endif
        {
            acelp_cfg->ltf_mode = FULL_BAND;
        }
@@ -1052,7 +1063,11 @@ ivas_error config_acelp1(
        acelp_cfg->fixed_cdk_index[2] = -1;
        acelp_cfg->fixed_cdk_index[3] = -1;
    }
#ifdef NONBE_FIX_GSC_BSTR
    else if ( ( coder_type != INACTIVE && nb_subfr == NB_SUBFR && coder_type != AUDIO ) || ( nb_subfr == NB_SUBFR16k && ( !inactive_coder_type_flag || coder_type != INACTIVE ) ) || core == HQ_CORE )
#else
    else if ( ( coder_type != INACTIVE && nb_subfr == NB_SUBFR && coder_type != AUDIO ) || ( nb_subfr == NB_SUBFR16k && ( total_brate > MAX_GSC_INACTIVE_BRATE || coder_type != INACTIVE ) ) || core == HQ_CORE )
#endif
    {
        /* pitch Q & gain Q bit-budget - part 2*/
        for ( i = 0; i < nb_subfr; i++ )
@@ -1100,7 +1115,11 @@ ivas_error config_acelp1(
        }

        /* algebraic codebook bit-budget */
#ifdef NONBE_FIX_GSC_BSTR
        if ( flag_hardcoded || ( core_brate_inp >= MIN_BRATE_AVQ_EXC && coder_type != INACTIVE ) || ( !inactive_coder_type_flag && coder_type == INACTIVE ) )
#else
        if ( flag_hardcoded || ( core_brate_inp >= MIN_BRATE_AVQ_EXC && coder_type != INACTIVE ) || ( total_brate > MAX_GSC_INACTIVE_BRATE && coder_type == INACTIVE ) )
#endif
        {
            for ( i = 0; i < nb_subfr; i++ )
            {
@@ -1187,7 +1206,11 @@ ivas_error config_acelp1(
        }

        /* AVQ codebook */
#ifdef NONBE_FIX_GSC_BSTR
        if ( ( core_brate_inp >= MIN_BRATE_AVQ_EXC && coder_type != INACTIVE ) || ( !inactive_coder_type_flag && coder_type == INACTIVE ) )
#else
        if ( ( core_brate_inp >= MIN_BRATE_AVQ_EXC && coder_type != INACTIVE ) || ( total_brate > MAX_GSC_INACTIVE_BRATE && coder_type == INACTIVE ) )
#endif
        {
            for ( i = 0; i < nb_subfr; i++ )
            {
@@ -1222,7 +1245,11 @@ ivas_error config_acelp1(
            }
        }
    }
#ifdef NONBE_FIX_GSC_BSTR
    else if ( ( coder_type == UNVOICED && tdm_low_rate_mode == 1 && element_mode == IVAS_CPE_TD ) || ( ( coder_type == INACTIVE || coder_type == AUDIO ) && nb_subfr == NB_SUBFR ) || ( coder_type == INACTIVE && inactive_coder_type_flag ) )
#else
    else if ( ( coder_type == UNVOICED && tdm_low_rate_mode == 1 && element_mode == IVAS_CPE_TD ) || ( ( coder_type == INACTIVE || coder_type == AUDIO ) && nb_subfr == NB_SUBFR ) || ( coder_type == INACTIVE && total_brate <= MAX_GSC_INACTIVE_BRATE ) )
#endif
    {
        int32_t Local_BR, Pitch_BR;
        int16_t Pitch_CT;
@@ -1315,7 +1342,11 @@ ivas_error config_acelp1(
    /* sanity check */
    if ( ( coder_type != INACTIVE && nb_subfr == NB_SUBFR && coder_type != AUDIO ) || nb_subfr == NB_SUBFR16k )
    {
#ifdef NONBE_FIX_GSC_BSTR
        if ( ( L_frame == L_FRAME16k && coder_type == INACTIVE && inactive_coder_type_flag ) || ( GSC_IVAS_mode > 0 && L_frame == L_FRAME16k ) ) /* GSC Inactive @16kHz */
#else
        if ( ( L_frame == L_FRAME16k && coder_type == INACTIVE && total_brate <= MAX_GSC_INACTIVE_BRATE ) || ( GSC_IVAS_mode > 0 && L_frame == L_FRAME16k ) ) /* GSC Inactive @16kHz */
#endif
        {
            acelp_cfg->ubits = 0;
        }
+15 −6
Original line number Diff line number Diff line
@@ -63,8 +63,13 @@ void inact_switch_ematch(
    float dct_exc_tmp[],      /* i  : GSC excitation in DCT domain        */
    float lt_ener_per_band[], /* i/o: Long term energy per band           */
    const int16_t coder_type, /* i  : Coder type                          */
#ifdef NONBE_FIX_GSC_BSTR
    const int16_t inactive_coder_type_flag, /* i  : AVQ (0) or GSC (1) IC flag   */
#endif
    const int16_t L_frame, /* i  : Frame length                        */
#ifndef NONBE_FIX_GSC_BSTR
    const int32_t total_brate, /* i  : Total bitrate                       */
#endif
    const int16_t bfi,               /* i  : frame lost indicator                */
    const int16_t last_core,         /* i  : Last core used                      */
    const int16_t last_codec_mode,   /* i  : Last codec mode                     */
@@ -105,7 +110,11 @@ void inact_switch_ematch(
            lt_ener_per_band[i] = Ener_per_bd[i];
        }
    }
#ifdef NONBE_FIX_GSC_BSTR
    else if ( coder_type == INACTIVE && inactive_coder_type_flag )
#else
    else if ( coder_type == INACTIVE && total_brate <= MAX_GSC_INACTIVE_BRATE )
#endif
    {
        /* Find spectrum and energy per band for inactive frames */
        edct( exc2, dct_exc_tmp, L_frame, element_mode );
+1 −0
Original line number Diff line number Diff line
@@ -172,6 +172,7 @@
#define NONBE_1217_OBJ_EDIT_FOA                         /* VA/Nokia: isse 1217: fix crash in object editing to FOA output in ParamISM */
#define NONBE_FIX_1255_OBJ_EDIT_JBM                     /* VA: issue 1255: restore object editing in JBM */
#define NONBE_FIX_1262_OSBA_STEREO                      /* FhG: issue 1262: Fix missing scaling factor for OSBA stereo output */
#define NONBE_FIX_GSC_BSTR                              /* VA: issue 1264: Fix bitstream synchronization between encoder and decoder in ACELP GSC in OMASA */

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

+25 −17
Original line number Diff line number Diff line
@@ -3568,8 +3568,13 @@ void inact_switch_ematch(
    float dct_exc_tmp[],      /* i  : GSC excitation in DCT domain                */
    float lt_ener_per_band[], /* i/o: long-term energy per band                   */
    const int16_t coder_type, /* i  : coder type                                  */
#ifdef NONBE_FIX_GSC_BSTR
    const int16_t inactive_coder_type_flag, /* i  : AVQ (0) or GSC (1) IC flag                  */
#endif
    const int16_t L_frame, /* i  : frame length                                */
#ifndef NONBE_FIX_GSC_BSTR
    const int32_t total_brate, /* i  : Total bitrate                               */
#endif
    const int16_t bfi,               /* i  : frame lost indicator                        */
    const int16_t last_core,         /* i  : Last core used                              */
    const int16_t last_codec_mode,   /* i  : Last codec mode                             */
@@ -9104,6 +9109,9 @@ ivas_error config_acelp1(
    ACELP_config *acelp_cfg,        /* i  : ACELP bit-allocation                */
    const int16_t signaling_bits,   /* i  : number of signaling bits            */
    const int16_t coder_type,       /* i  : coder type                          */
#ifdef NONBE_FIX_GSC_BSTR
    const int16_t inactive_coder_type_flag, /* i  : AVQ (0) or GSC (1) IC flag          */
#endif
    const int16_t tc_subfr,             /* i  : TC subfr ID                         */
    const int16_t tc_call,              /* i  : TC call number (0,1,2)              */
    int16_t *nBits_es_Pred,             /* o  : number of bits for Es_pred Q        */
+8 −0
Original line number Diff line number Diff line
@@ -332,7 +332,11 @@ void FEC_exc_estim(
     * Replicate the last spectrum in case the last good frame was coded by GSC
     *-----------------------------------------------------------------*/

#ifdef NONBE_FIX_GSC_BSTR
    if ( ( st->last_coder_type == AUDIO || st->last_good == INACTIVE_CLAS ) && st->inactive_coder_type_flag && !st->Opt_AMR_WB )
#else
    if ( ( st->last_coder_type == AUDIO || st->last_good == INACTIVE_CLAS ) && st->total_brate <= MAX_GSC_INACTIVE_BRATE && !st->Opt_AMR_WB )
#endif
    {
        /* Replication of the last spectrum, with a slight downscaling of its dynamic */
        st->GSC_noisy_speech = st->Last_GSC_noisy_speech_flag;
@@ -405,7 +409,11 @@ void FEC_exc_estim(
     * Total excitation
     *-----------------------------------------------------------------*/

#ifdef NONBE_FIX_GSC_BSTR
    if ( ( st->last_coder_type == AUDIO || st->last_good == INACTIVE_CLAS ) && st->inactive_coder_type_flag && !st->Opt_AMR_WB )
#else
    if ( ( st->last_coder_type == AUDIO || st->last_good == INACTIVE_CLAS ) && st->total_brate <= MAX_GSC_INACTIVE_BRATE && !st->Opt_AMR_WB )
#endif
    {
        /* For GSC - the excitation is already computed */
        mvr2r( exc, exc2, st->L_frame );
Loading