From 5b8a29fac2424aadd68265c91b6def28d3f5e970 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 1 Jun 2023 15:54:12 +0200 Subject: [PATCH 1/2] fix ISM decoder crash if first received frame is an SID; under FIX_522_ISM_FIRST_SID --- lib_com/ivas_prot.h | 3 +-- lib_com/options.h | 2 ++ lib_dec/ivas_init_dec.c | 38 +++++++++++++++++++++++++++++++++ lib_dec/ivas_ism_dec.c | 17 ++++----------- lib_dec/ivas_ism_metadata_dec.c | 31 +++++++++++++++------------ 5 files changed, 62 insertions(+), 29 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index f455c552a5..562aa97076 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -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 , diff --git a/lib_com/options.h b/lib_com/options.h index 8a491e2499..0db902b2bb 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -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 */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 2452b34edb..7ddac809ea 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -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 } /*-------------------------------------------------------------------* diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index fe98ca0dcb..186dc29f7f 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -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; diff --git a/lib_dec/ivas_ism_metadata_dec.c b/lib_dec/ivas_ism_metadata_dec.c index a39c496ab6..e275055768 100644 --- a/lib_dec/ivas_ism_metadata_dec.c +++ b/lib_dec/ivas_ism_metadata_dec.c @@ -138,18 +138,18 @@ static void ism_metadata_smooth( *-------------------------------------------------------------------------*/ ivas_error ivas_ism_metadata_dec( - const int32_t ism_total_brate, /* i : ISM total bitrate */ - const int16_t nchan_ism, /* i : number of ISM channels */ - int16_t *nchan_transport, /* o : number of transport channels */ - ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ - SCE_DEC_HANDLE hSCE[], /* i/o: SCE decoder handles */ - const int16_t bfi, /* i : bfi flag */ - int16_t nb_bits_metadata[], /* o : number of metadata bits */ - ISM_MODE ism_mode, /* i : ISM mode */ - ISM_DTX_DATA_DEC hISMDTX, /* i/o: ISM DTX structure */ - const PARAM_ISM_CONFIG_HANDLE hParamIsm, /* i : Param ISM Config Handle */ - int16_t *ism_extmeta_active, /* i/o: Extended metadata active in renderer*/ - int16_t *ism_extmeta_cnt /* i/o: Number of change frames observed*/ + const int32_t ism_total_brate, /* i : ISM total bitrate */ + const int16_t nchan_ism, /* i : number of ISM channels */ + int16_t *nchan_transport, /* o : number of transport channels */ + ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ + SCE_DEC_HANDLE hSCE[], /* i/o: SCE decoder handles */ + const int16_t bfi, /* i : bfi flag */ + int16_t nb_bits_metadata[], /* o : number of metadata bits */ + ISM_MODE ism_mode, /* i : ISM mode */ + ISM_DTX_DATA_DEC hISMDTX, /* i/o: ISM DTX structure */ + const PARAM_ISM_CONFIG_HANDLE hParamIsm, /* i : Param ISM Config Handle */ + int16_t *ism_extmeta_active, /* i/o: Extended metadata active in renderer */ + int16_t *ism_extmeta_cnt /* i/o: Number of change frames observed */ ) { int16_t ch, nb_bits_start = 0, last_bit_pos; @@ -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] ); } @@ -604,7 +607,7 @@ static void decode_angle_indices( DEC_CORE_HANDLE st0, /* i/o: bitstream handle */ ISM_METADATA_ANGLE_HANDLE angle, /* i/o: angle handle */ const int16_t non_diegetic_flag, /* i : Non diegetic flag */ - int16_t *flag_abs_angle1 /* o : Azimuth/yaw encoding mode */ + int16_t *flag_abs_angle1 /* o : Azimuth/yaw encoding mode */ ) { int16_t idx_angle1, nbits_diff_angle1, diff, sgn; -- GitLab From a7438ae02c567216b35d2ca8e4448a1ececf0888 Mon Sep 17 00:00:00 2001 From: kiene Date: Thu, 1 Jun 2023 16:23:20 +0200 Subject: [PATCH 2/2] use correct files in config for sidstart test --- scripts/config/ci_linux_sidstart_test.json | 30 +++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/scripts/config/ci_linux_sidstart_test.json b/scripts/config/ci_linux_sidstart_test.json index 3436d9eaea..be3915efd8 100644 --- a/scripts/config/ci_linux_sidstart_test.json +++ b/scripts/config/ci_linux_sidstart_test.json @@ -2,24 +2,24 @@ "afspPath": "not_needed", "utilPath": "/tools", "inpaths": { - "MONO": "/usr/local/testv/test_mono.wav", - "STEREO": "/usr/local/testv/test_stereo.wav", + "MONO": "/usr/local/testv/stv48n.wav", + "STEREO": "/usr/local/testv/stvST48n.wav", "FOA": "/usr/local/ltv/ltv48_FOA.wav", "HOA2": "/usr/local/ltv/ltv48_HOA2.wav", "HOA3": "/usr/local/ltv/ltv48_HOA3.wav", "SBA": "/usr/local/ltv/ltv48_HOA3.wav", - "MASA1TC1DIR": "/usr/local/testv/test_MASA_1dir1TC.wav", - "MASA1TC2DIR": "/usr/local/testv/test_MASA_2dir1TC.wav", - "MASA2TC1DIR": "/usr/local/testv/test_MASA_1dir2TC.wav", - "MASA2TC2DIR": "/usr/local/testv/test_MASA_2dir2TC.wav", - "5_1": "/usr/local/testv/test_MC51.wav", - "5_1_2": "/usr/local/testv/test_MC51p2.wav", - "5_1_4": "/usr/local/testv/test_MC51p4.wav", - "7_1": "/usr/local/testv/test_MC71.wav", - "7_1_4": "/usr/local/testv/test_MC71p4.wav", - "ISM1": "/usr/local/testv/test_mono.wav", - "ISM2": "/usr/local/testv/test_ISM_2obj.wav", - "ISM3": "/usr/local/testv/test_ISM_3obj.wav", - "ISM4": "/usr/local/testv/test_ISM_4obj.wav" + "MASA1TC1DIR": "/usr/local/testv/stv1MASA1TC48n.wav", + "MASA1TC2DIR": "/usr/local/testv/stv2MASA1TC48c.wav", + "MASA2TC1DIR": "/usr/local/testv/stv1MASA2TC48n.wav", + "MASA2TC2DIR": "/usr/local/testv/stv2MASA2TC48c.wav", + "5_1": "/usr/local/testv/stv51MC48c.wav", + "5_1_2": "/usr/local/testv/stv512MC48c.wav", + "5_1_4": "/usr/local/testv/stv514MC48c.wav", + "7_1": "/usr/local/testv/stv71MC48c.wav", + "7_1_4": "/usr/local/testv/stv714MC48c.wav", + "ISM1": "/usr/local/testv/stv1ISM48s.wav", + "ISM2": "/usr/local/testv/stv2ISM48s.wav", + "ISM3": "/usr/local/testv/stv3ISM48s.wav", + "ISM4": "/usr/local/testv/stv4ISM48s.wav" } } -- GitLab