Commit 5b8a29fa authored by vaclav's avatar vaclav
Browse files

fix ISM decoder crash if first received frame is an SID; under FIX_522_ISM_FIRST_SID

parent 59b30768
Loading
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -1019,8 +1019,7 @@ ivas_error ivas_ism_enc_config(
);

ivas_error ivas_ism_dec_config(
    Decoder_Struct *st_ivas                                     /* i/o: IVAS decoder structure                      */
    ,
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure                      */
    const ISM_MODE last_ism_mode                                /* i/o: last ISM mode                               */
#ifdef JBM_TSM_ON_TCS
    ,
+2 −0
Original line number Diff line number Diff line
@@ -231,6 +231,8 @@

#define FIX_TODO_NON_DIEGETIC_PAN_NOT_IMPLELENTED_IN_RENDERER /* ..\apps\renderer.c(240):  .... (todo: implementation)",*/
#define REMOVE_OBS_CODE                                 /* FhG: Remove unnecessary assignement after LFE cleanup (Issue #451)*/
#define FIX_522_ISM_FIRST_SID                           /* VA: fix ISM decoder crash if first received frame is an SID */


/* ################## End DEVELOPMENT switches ######################### */
/* clang-format on */
+38 −0
Original line number Diff line number Diff line
@@ -309,6 +309,44 @@ ivas_error ivas_dec_setup(
                st_ivas->hDecoderConfig->ivas_total_brate = ivas_total_brate;
            }
        }

#ifdef FIX_522_ISM_FIRST_SID
        if ( st_ivas->ini_frame == 0 && st_ivas->ivas_format == ISM_FORMAT )
        {
            /* read the number of objects */
            st_ivas->nchan_transport = 1;
            nchan_ism = 1;
            k = (int16_t) ( ( ivas_total_brate / FRAMES_PER_SEC ) - 1 ) - SID_FORMAT_NBITS;
            while ( st_ivas->bit_stream[k] && nchan_ism < MAX_NUM_OBJECTS )
            {
                nchan_ism++;
                k--;
            }
            k--;

            st_ivas->nchan_ism = nchan_ism;

            /* read ism_mode */
            if ( nchan_ism > 2 )
            {
                k -= nchan_ism; /* SID metadata flags */
                idx = st_ivas->bit_stream[k];
                st_ivas->ism_mode = (ISM_MODE) ( idx + 1 );
            }

#ifdef JBM_TSM_ON_TCS
            if ( ( error = ivas_ism_dec_config( st_ivas, st_ivas->ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK )
            {
                return error;
            }
#else
            if ( ( error = ivas_ism_dec_config( st_ivas, st_ivas->ism_mode ) ) != IVAS_ERR_OK )
            {
                return error;
            }
#endif
        }
#endif
    }

    /*-------------------------------------------------------------------*
+4 −13
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ static ivas_error ivas_ism_bitrate_switching(
#ifdef JBM_TSM_ON_TCS
    ,
    uint16_t *nSamplesRendered, /* o  : number of samples rendered          */
    int16_t *data               /* o  : rendered samples                    */
    int16_t *data               /* o  : flushed PCM samples                 */
#endif
)
{
@@ -74,7 +74,6 @@ static ivas_error ivas_ism_bitrate_switching(
#endif

    error = IVAS_ERR_OK;

    nCPE_old = st_ivas->nCPE;
    nSCE_old = st_ivas->nSCE;

@@ -225,12 +224,7 @@ static ivas_error ivas_ism_bitrate_switching(
            ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin );

            /* Open Crend Binaural renderer */
            if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ),
                                                st_ivas->intern_config,
                                                st_ivas->hOutSetup.output_config,
                                                st_ivas->hRenderConfig,
                                                st_ivas->hSetOfHRTF,
                                                st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK )
            if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK )
            {
                return error;
            }
@@ -389,13 +383,12 @@ static ivas_error ivas_ism_bitrate_switching(
 *-------------------------------------------------------------------------*/

ivas_error ivas_ism_dec_config(
    Decoder_Struct *st_ivas /* i/o: IVAS decoder structure              */
    ,
    Decoder_Struct *st_ivas,     /* i/o: IVAS decoder structure              */
    const ISM_MODE last_ism_mode /* i/o: last ISM mode                       */
#ifdef JBM_TSM_ON_TCS
    ,
    uint16_t *nSamplesRendered, /* o  : number of samples flushed when the renderer granularity changes */
    int16_t *data
    int16_t *data               /* o  : flushed PCM samples                  */
#endif
)
{
@@ -404,10 +397,8 @@ ivas_error ivas_ism_dec_config(
    int16_t nchan_transport_old;

    error = IVAS_ERR_OK;

    ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;


    /* Assumes that num of input objects are constant */
    nchan_transport_old = st_ivas->nchan_ism;

+17 −14
Original line number Diff line number Diff line
@@ -176,7 +176,6 @@ ivas_error ivas_ism_metadata_dec(

    push_wmops( "ism_meta_dec" );


    /* initialization */
    st0 = hSCE[0]->hCoreCoder[0];
    ism_metadata_flag_global = 0;
@@ -579,6 +578,10 @@ ivas_error ivas_ism_metadata_dec_create(

        st_ivas->hIsmMetaData[ch]->last_true_azimuth = 0;
        st_ivas->hIsmMetaData[ch]->last_true_elevation = 0;
#ifdef FIX_522_ISM_FIRST_SID
        st_ivas->hIsmMetaData[ch]->last_azimuth = 0;
        st_ivas->hIsmMetaData[ch]->last_elevation = 0;
#endif

        ivas_ism_reset_metadata( st_ivas->hIsmMetaData[ch] );
    }