Commit 5c474a75 authored by norvell's avatar norvell
Browse files

Merge with main

parents d465cf95 7bb94b29
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -150,6 +150,7 @@
#define AGC_ENABLE_FOR_LBR                              /* Issue 168: Enable AGC for low bit rate (1 TC) */
#endif
#define FIX_I173_I174                                   /* Issues 173 and 174: Remove frame and subframe index from ISm metadata and headtracking respectively. */
#define FIX_TCX_DEC_RECONF_BFI

/* ################## End DEVELOPMENT switches ######################### */
/* clang-format on */
+70 −0
Original line number Diff line number Diff line
@@ -51,7 +51,14 @@
 * Local prototypes
 *-------------------------------------------------------------*/

#ifdef FIX_TCX_DEC_RECONF_BFI
static void dec_prm_tcx( Decoder_State *st, int16_t param[], int16_t param_lpc[], int16_t *total_nbbits, const int16_t last_element_mode, int16_t *bitsRead );
#else
static void dec_prm_tcx( Decoder_State *st, int16_t param[], int16_t param_lpc[], int16_t *total_nbbits, int16_t *bitsRead );
#endif
#ifdef FIX_TCX_DEC_RECONF_BFI
static void stereo_tcx_dec_mode_switch_reconf( Decoder_State *st, const int16_t MCT_flag, const int16_t last_element_mode );
#endif


/*-------------------------------------------------------------*
@@ -66,7 +73,9 @@ void stereo_tcx_init_dec(
    const int16_t last_element_mode /* i  : element mode of previous frame      */
)
{
#ifndef FIX_TCX_DEC_RECONF_BFI
    int16_t frame_size_index;
#endif
    TCX_LTP_DEC_HANDLE hTcxLtpDec = st->hTcxLtpDec;
    TCX_DEC_HANDLE hTcxDec = st->hTcxDec;

@@ -125,9 +134,19 @@ void stereo_tcx_init_dec(
        }
    }

#ifdef FIX_TCX_DEC_RECONF_BFI
    if ( ( st->bits_frame_nominal != st->last_bits_frame_nominal ) ||
         ( st->bwidth != st->last_bwidth ) ||
         ( st->last_core != TCX_20_CORE && st->last_core != TCX_10_CORE && !( st->prev_bfi == 1 && st->last_core == ACELP_CORE && st->last_con_tcx == 1 ) ) ||
         ( st->idchan == 1 && st->element_mode == IVAS_CPE_MDCT && last_element_mode != IVAS_CPE_MDCT ) )
#else
    if ( ( st->bits_frame_nominal != st->last_bits_frame_nominal ) || ( st->bwidth != st->last_bwidth ) || ( st->last_core != TCX_20_CORE && st->last_core != TCX_10_CORE && !( st->prev_bfi == 1 && st->last_core == ACELP_CORE && st->last_con_tcx == 1 ) ) || ( st->idchan == 1 && st->element_mode == IVAS_CPE_MDCT && last_element_mode != IVAS_CPE_MDCT ) )
#endif
    {
        /*re-initialization*/
#ifdef FIX_TCX_DEC_RECONF_BFI
        stereo_tcx_dec_mode_switch_reconf( st, MCT_flag, last_element_mode );
#else
        st->rate_switching_init = 1;

        /* Identify frame type - TCX Reconfiguration */
@@ -151,6 +170,7 @@ void stereo_tcx_init_dec(

        /* Reconfigure Core */
        mode_switch_decoder_LPD( st, st->bwidth, st->bits_frame_nominal * FRAMES_PER_SEC, st->last_bits_frame_nominal * FRAMES_PER_SEC, frame_size_index, MCT_flag, last_element_mode );
#endif
    }

    return;
@@ -284,7 +304,11 @@ void stereo_tcx_core_dec(
        tcx_current_overlap_mode = st->hTcxCfg->tcx_curr_overlap_mode;
#endif

#ifdef FIX_TCX_DEC_RECONF_BFI
        dec_prm_tcx( st, param, param_lpc, &total_nbbits, last_element_mode, &bitsRead );
#else
        dec_prm_tcx( st, param, param_lpc, &total_nbbits, &bitsRead );
#endif

#ifdef FIX_IVAS_337 /*IVAS-337 consider BER */
        if ( !st->rate_switching_init && st->BER_detect )
@@ -808,6 +832,9 @@ static void dec_prm_tcx(
    int16_t param[],       /* o  : decoded parameters              */
    int16_t param_lpc[],   /* o  : LPC parameters                  */
    int16_t *total_nbbits, /* i/o: number of bits / decoded bits   */
#ifdef FIX_TCX_DEC_RECONF_BFI
    const int16_t last_element_mode,
#endif
    int16_t *bitsRead      /* o  : number of read bits             */
)
{
@@ -861,6 +888,14 @@ static void dec_prm_tcx(
            st->prev_bfi = 1;
        }

#ifdef FIX_TCX_DEC_RECONF_BFI
        /* possible need for reconfiguration can only be decided correctly once last_core_from_bs has been decoded */
        if ( ( st->last_core != st->last_core_from_bs ) && ( st->last_core_from_bs != TCX_20_CORE && st->last_core_from_bs != TCX_10_CORE && !( st->prev_bfi == 1 && st->last_core_from_bs == ACELP_CORE && st->last_con_tcx == 1 ) ) )
        {
            stereo_tcx_dec_mode_switch_reconf( st, 0, last_element_mode );
        }
#endif

        st->last_core = st->last_core_from_bs;

        /*for TCX 10 force last_core to be TCX since ACELP as previous core is forbidden*/
@@ -923,3 +958,38 @@ static void dec_prm_tcx(

    return;
}

#ifdef FIX_TCX_DEC_RECONF_BFI
static void stereo_tcx_dec_mode_switch_reconf(
    Decoder_State *st,
    const int16_t MCT_flag,
    const int16_t last_element_mode
)
{
    int16_t frame_size_index;

    st->rate_switching_init = 1;

    /* Identify frame type - TCX Reconfiguration */
    for ( frame_size_index = 0; frame_size_index < FRAME_SIZE_NB; frame_size_index++ )
    {
        if ( frame_size_index < FRAME_SIZE_NB - 1 )
        {
            if ( ( FrameSizeConfig[frame_size_index].frame_bits <= st->bits_frame_nominal ) && ( FrameSizeConfig[frame_size_index + 1].frame_bits > st->bits_frame_nominal ) )
            {
                break;
            }
        }
        else
        {
            if ( FrameSizeConfig[frame_size_index].frame_bits <= st->bits_frame_nominal )
            {
                break;
            }
        }
    }

    /* Reconfigure Core */
    mode_switch_decoder_LPD( st, st->bwidth, st->bits_frame_nominal * FRAMES_PER_SEC, st->last_bits_frame_nominal * FRAMES_PER_SEC, frame_size_index, MCT_flag, last_element_mode );
}
#endif