Commit 91cc7458 authored by vaclav's avatar vaclav
Browse files

harmonization of code - decoder side

parent 1a5759e0
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -940,6 +940,7 @@ void ivas_param_ism_params_to_masa_param_mapping(
    Decoder_Struct *st_ivas                                     /* i/o: IVAS decoder structure                      */
);


#ifdef PARAM_ISM_DTX_CNG
/*----------------------------------------------------------------------------------*
 * ISM DTX prototypes
@@ -949,6 +950,11 @@ ivas_error ivas_ism_dtx_open(
    Encoder_Struct *st_ivas                                     /* i/o: IVAS encoder structure              */
);

ivas_error ivas_ism_dtx_dec(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure              */
    int16_t *nb_bits_metadata                                   /* o  : number of metadata bits             */
);

void ivas_param_ism_metadata_dtx_enc(
    BSTR_ENC_HANDLE hBstr,                                      /* i/o: bitstream handle                    */
    ISM_METADATA_HANDLE hIsmMeta[],                             /* i  : ISM metadata handles                */
+8 −6
Original line number Diff line number Diff line
@@ -2227,7 +2227,8 @@ ivas_error init_encoder(
    const int16_t interval_SID,      /* i  : interval for SID update                */
    const int16_t vad_only_flag      /* i  : flag to indicate front-VAD structure   */
#ifdef PARAM_ISM_DTX_CNG
    ,const ISM_MODE ism_mode
    ,
    const ISM_MODE ism_mode /* i  : ISM mode                               */
#endif
);

@@ -8521,7 +8522,8 @@ void generate_comfort_noise_dec_hf(
    float **bufferImag,         /* o  : Imaginary part of input bands                           */
    HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables   */
#ifdef PARAM_ISM_DTX_CNG
    , int16_t cng_flag          /*i: CNG Flag */
    ,
    int16_t cng_flag /*i: CNG Flag */
#endif
);

+9 −8
Original line number Diff line number Diff line
@@ -139,18 +139,19 @@ ivas_error ivas_dec(
    else if ( st_ivas->ivas_format == ISM_FORMAT )
    {
        /* Metadata decoding and configuration */
        if ( st_ivas->ism_mode == ISM_MODE_PARAM )
        {
            ivas_ism_metadata_dec( ivas_total_brate, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hDirAC->hParamIsm );

#ifdef PARAM_ISM_DTX_CNG
            /* read the SID metadata */
            if (ivas_total_brate == IVAS_SID_5k2)
        if ( ivas_total_brate == IVAS_SID_5k2 || ivas_total_brate == FRAME_NO_DATA )
        {
            if ( ( error = ivas_ism_dtx_dec( st_ivas, nb_bits_metadata ) ) != IVAS_ERR_OK )
            {
                ivas_param_ism_metadata_dtx_dec(st_ivas);
                nb_bits_metadata[1] = nb_bits_metadata[0];
                return error;
            }
        }
        else
#endif
            if ( st_ivas->ism_mode == ISM_MODE_PARAM )
        {
            ivas_ism_metadata_dec( ivas_total_brate, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hDirAC->hParamIsm );
        }
        else /* ISM_MODE_DISC */
        {
+139 −0
Original line number Diff line number Diff line
@@ -43,3 +43,142 @@
#include "debug.h"
#endif
#include "wmc_auto.h"


#ifdef PARAM_ISM_DTX_CNG
/*-------------------------------------------------------------------*
 * ivas_ism_preprocessing()
 *
 * 
 *-------------------------------------------------------------------*/

static void ivas_ism_preprocessing(
    Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure              */
    const int16_t sce_id     /* i  : SCE # identifier                    */
)
{
    int32_t ivas_total_brate;
    SCE_DEC_HANDLE hSCE;
    Decoder_State *st;

    hSCE = st_ivas->hSCE[sce_id];
    st = hSCE->hCoreCoder[0];

    ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;

    if ( ( ivas_total_brate == IVAS_SID_5k2 || ivas_total_brate == FRAME_NO_DATA ) )
    {
        /* reset the bitstream to atleast read the cng type and bandwidth for non transmitted SCE */
        st->bit_stream = st_ivas->hSCE[0]->hCoreCoder[0]->bit_stream;

        if ( sce_id == st_ivas->hISMDTX.sce_id_dtx )
        {
            st->read_sid_info = 1; /*  read the sid info from bitstream  */
        }
        else
        {
            st->read_sid_info = 0; /* do not read the sid info from bitstream but use the estimated noise */
        }

        st->cng_paramISM_flag = 1;
    }
    else
    {
        st->cng_paramISM_flag = 0;
    }

    return;
}


/*-------------------------------------------------------------------*
 * ivas_ism_dtx_dec()
 *
 * ISM DTX Metadata decoding routine
 *-------------------------------------------------------------------*/

ivas_error ivas_ism_dtx_dec(
    Decoder_Struct *st_ivas,  /* i/o: IVAS decoder structure    */
    int16_t *nb_bits_metadata /* o  : number of metadata bits   */
)
{
    int16_t nBits;
    int16_t ch, num_obj, num_obj_prev;
    int32_t ivas_total_brate;
    DEC_CORE_HANDLE st0;

    ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;

    if ( st_ivas->nchan_transport == 1 )
    {
        nb_bits_metadata[0] = ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC;

        return IVAS_ERR_OK;
    }

    if ( st_ivas->ism_mode == ISM_MODE_PARAM )
    {
        num_obj_prev = st_ivas->hDirAC->hParamIsm->num_obj;
    }
    else /* ism_mode == ISM_MODE_DISC */
    {
        num_obj_prev = st_ivas->nchan_transport;
    }

    st0 = st_ivas->hSCE[0]->hCoreCoder[0];

    /* read number of objects */
    if ( !st_ivas->bfi && ivas_total_brate == IVAS_SID_5k2 )
    {
        num_obj = 1;
        while ( get_next_indice( st0, 1 ) == 1 && num_obj < MAX_NUM_OBJECTS )
        {
            num_obj++;
        }

        if ( num_obj != num_obj_prev )
        {
            /* IVAS_fmToDo: more work needed when the number of transported objects is not constant */
            return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "wrong number of objects signalled!" );
        }

        ivas_ism_dec_config( st_ivas, num_obj );

        if ( st_ivas->ism_mode == ISM_MODE_PARAM )
        {
            st_ivas->hDirAC->hParamIsm->num_obj = num_obj;
        }
        else /* ism_mode == ISM_MODE_DISC */
        {
            st_ivas->nchan_transport = num_obj;
        }
    }
    else
    {
        num_obj = num_obj_prev;
    }

    /* Metadata decoding and dequantization  */
    ivas_param_ism_metadata_dtx_dec( st_ivas );

    /* Since the SID bits are already read, nBits represent remaining bits */
    nBits = ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS;
    st0->bit_stream += nBits;
    st0->next_bit_pos = 0;

    for ( ch = 0; ch < st_ivas->nchan_transport; ch++ )
    {
        nb_bits_metadata[ch] = ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC;
    }

    if ( st_ivas->ism_mode == ISM_MODE_PARAM )
    {
        for ( ch = 0; ch < st_ivas->nchan_transport; ch++ )
        {
            ivas_ism_preprocessing( st_ivas, ch );
        }
    }

    return IVAS_ERR_OK;
}
#endif
+9 −4
Original line number Diff line number Diff line
@@ -90,13 +90,11 @@ ivas_error ivas_ism_metadata_dec(
        nb_bits_metadata[0] = ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC;

#ifdef DEBUGGING
#ifndef PARAM_ISM_DTX_CNG
        /* sanity check */
        if ( *nchan_transport != 1 )
        {
            return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "\n!!! Error: SID/CNG frame not expect for decoding more than 1 object. Exiting.\n\n" );
        }
#endif
#endif

        pop_wmops();
@@ -501,6 +499,13 @@ ivas_error ivas_ism_metadata_dec(
        hSCE[ch]->hCoreCoder[0]->bit_stream = hSCE[ch - 1]->hCoreCoder[0]->bit_stream + ( hSCE[ch - 1]->hCoreCoder[0]->total_brate / FRAMES_PER_SEC );
    }

#ifdef PARAM_ISM_DTX_CNG
    for ( ch = 0; ch < *nchan_transport; ch++ )
    {
        hSCE[ch]->hCoreCoder[0]->cng_paramISM_flag = 0;
    }
#endif

    pop_wmops();

    return error;
Loading