Commit 9ec0c0f4 authored by vaclav's avatar vaclav
Browse files

fixes for bitrate switching in DTX; changes are within DISCRETE_ISM_DTX_CNG;...

fixes for bitrate switching in DTX; changes are within DISCRETE_ISM_DTX_CNG; BE in non-switching conditions
parent eed45821
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -886,6 +886,9 @@ ivas_error ivas_ism_enc_config(

ivas_error ivas_ism_dec_config(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure                      */
#ifdef DISCRETE_ISM_DTX_CNG
    const ISM_MODE last_ism_mode,                               /* i/o: last ISM mode                               */
#endif
    const int16_t num_obj                                       /* i  : number of objects in the bitstream          */
);

+4 −0
Original line number Diff line number Diff line
@@ -109,7 +109,11 @@ ivas_error ivas_dec_setup(
                k--;
            }

#ifdef DISCRETE_ISM_DTX_CNG
            ivas_ism_dec_config( st_ivas, st_ivas->ism_mode, num_obj );
#else
            ivas_ism_dec_config( st_ivas, num_obj );
#endif
        }
        else if ( st_ivas->ivas_format == SBA_FORMAT )
        {
+28 −1
Original line number Diff line number Diff line
@@ -207,11 +207,16 @@ static ivas_error ivas_ism_bitrate_switching(
/*! r : ISM format mode */
ivas_error ivas_ism_dec_config(
    Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure              */
#ifdef DISCRETE_ISM_DTX_CNG
    const ISM_MODE last_ism_mode, /* i/o: last ISM mode                       */
#endif
    const int16_t num_obj /* i  : number of objects in the bitstream  */
)
{
    int32_t ivas_total_brate;
#ifndef DISCRETE_ISM_DTX_CNG
    ISM_MODE last_ism_mode;
#endif
    ivas_error error;
    int16_t nchan_transport_old;

@@ -219,8 +224,10 @@ ivas_error ivas_ism_dec_config(

    ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;

#ifndef DISCRETE_ISM_DTX_CNG
    /* store last frame ISM mode */
    last_ism_mode = st_ivas->ism_mode;
#endif

    /* Assumes that num of input objects are constant */
    nchan_transport_old = num_obj;
@@ -248,7 +255,9 @@ ivas_error ivas_ism_dec_config(
        if ( st_ivas->ini_active_frame != 0 )
        {
            /* ISM bit-rate switching */
#ifndef DISCRETE_ISM_DTX_CNG
            if ( st_ivas->hDecoderConfig->last_ivas_total_brate != IVAS_SID_5k2 && st_ivas->hDecoderConfig->last_ivas_total_brate != FRAME_NO_DATA )
#endif
            {
                if ( ( st_ivas->ism_mode != last_ism_mode ) || ( st_ivas->hDecoderConfig->ivas_total_brate != st_ivas->hDecoderConfig->last_ivas_total_brate ) )
                {
@@ -259,6 +268,23 @@ ivas_error ivas_ism_dec_config(
    }
    else if ( !st_ivas->bfi && ivas_total_brate == IVAS_SID_5k2 )
    {
#ifdef DISCRETE_ISM_DTX_CNG
        st_ivas->nchan_transport = num_obj;
        if ( st_ivas->ism_mode == ISM_MODE_PARAM )
        {
            st_ivas->nchan_transport = 2;
            if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_EXTERNAL )
            {
                st_ivas->hDecoderConfig->nchan_out = num_obj;
            }
        }

        /* ISM mode switching */
        if ( st_ivas->ism_mode != last_ism_mode )
        {
            ivas_ism_bitrate_switching( st_ivas, nchan_transport_old, last_ism_mode, num_obj );
        }
#else
#ifdef PARAM_ISM_DTX_CNG
        if ( last_ism_mode == ISM_MODE_PARAM )
        {
@@ -269,6 +295,7 @@ ivas_error ivas_ism_dec_config(
        {
            st_ivas->nchan_transport = num_obj;
        }
#endif
    }

    switch ( num_obj )
+25 −1
Original line number Diff line number Diff line
@@ -67,6 +67,9 @@ static void ivas_ism_preprocessing(
    {
        /* reset the bitstream to at least read the cng type and bandwidth for non transmitted SCE */
        st->bit_stream = st_ivas->hSCE[0]->hCoreCoder[0]->bit_stream;
#ifdef DISCRETE_ISM_DTX_CNG
        st->next_bit_pos = 0; /* note: needed in paramISM -> discISM switching */
#endif

        if ( sce_id == st_ivas->hISMDTX.sce_id_dtx )
        {
@@ -106,6 +109,7 @@ ivas_error ivas_ism_dtx_dec(
#ifdef DISCRETE_ISM_DTX_CNG
    int16_t md_diff_flag[MAX_NUM_OBJECTS];
    int16_t flag_noisy_speech, sce_id_dtx;
    ISM_MODE last_ism_mode;
#endif

    ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
@@ -128,9 +132,9 @@ ivas_error ivas_ism_dtx_dec(
        num_obj_prev = st_ivas->nchan_transport;
    }

    /* read number of objects */
    if ( !st_ivas->bfi && ivas_total_brate == IVAS_SID_5k2 )
    {
        /* read number of objects */
        num_obj = 1;
        pos = (int16_t) ( ( ivas_total_brate / FRAMES_PER_SEC ) - 1 - SID_FORMAT_NBITS );

@@ -139,6 +143,9 @@ ivas_error ivas_ism_dtx_dec(
            ( num_obj )++;
            pos--;
        }
#ifdef DISCRETE_ISM_DTX_CNG
        pos--;
#endif

        if ( num_obj != num_obj_prev )
        {
@@ -146,6 +153,22 @@ ivas_error ivas_ism_dtx_dec(
            return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "wrong number of objects signalled!" );
        }

#ifdef DISCRETE_ISM_DTX_CNG
        last_ism_mode = st_ivas->ism_mode;

        /* read ism_mode */
        if ( num_obj > 2 )
        {
            pos -= num_obj; /* SID metadata flags */

            short idx = get_indice( st_ivas->hSCE[0]->hCoreCoder[0], pos, 1 );

            ISM_MODE ism_mode_bstr = (ISM_MODE) ( idx + 1 );
            st_ivas->ism_mode = ism_mode_bstr;
        }

        ivas_ism_dec_config( st_ivas, last_ism_mode, num_obj );
#else
        ivas_ism_dec_config( st_ivas, num_obj );

        if ( st_ivas->ism_mode == ISM_MODE_PARAM )
@@ -156,6 +179,7 @@ ivas_error ivas_ism_dtx_dec(
        {
            st_ivas->nchan_transport = num_obj;
        }
#endif
    }
    else
    {
+1 −5
Original line number Diff line number Diff line
@@ -849,11 +849,7 @@ ivas_error ivas_ism_metadata_sid_dec(
        {
            idx = get_next_indice( st0, 1 );
            ism_mode_bstr = (ISM_MODE) ( idx + 1 );

            if ( ism_mode_bstr != ism_mode )
            {
                return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "\n!!! Error: Switching ISM mode in CNG not verified yet. Exiting.\n\n" );
            }
            /* note: ISM mode was already read and used for configuration in in ivas_ism_dtx_dec() */

            if ( ism_mode_bstr == ISM_MODE_PARAM )
            {
Loading