From d2101c208a9766ab2c7660a285ce8edf79708317 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 5 Apr 2023 12:38:14 +0200 Subject: [PATCH 1/6] Issue 387: fix MD discontinuity in ISM FEC; under FIX_387_ISM_MD_FEC --- lib_com/ivas_stat_com.h | 4 ++++ lib_com/options.h | 3 ++- lib_enc/ivas_ism_metadata_enc.c | 37 +++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index eedb65dbf3..a4defd144f 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -75,6 +75,10 @@ typedef struct float last_true_elevation; /* MD smoothing in DTX- last true Q elevation value */ #endif +#ifdef FIX_387_ISM_MD_FEC + int16_t ism_md_fec_cnt_enc; /* counter of continuous frames where MD are not transmitted */ +#endif + } ISM_METADATA_FRAME, *ISM_METADATA_HANDLE; diff --git a/lib_com/options.h b/lib_com/options.h index 6d97909f18..395229fc96 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -150,8 +150,9 @@ #define NCHAN_ISM_PARAMETER /* VA: make 'nchan_ism' parameter part of st_ivas/hEncoderConfig */ #define FIX_382_MASA_META_FRAMING_ASYNC /* Nokia: Issue 382: detect potential MASA metadata framing offset */ - #define SBA2MONO /* FhG: Issue 365: Adapt processing of SBA mono output to be in line with stereo output (less delay, lower complexity) */ +#define FIX_387_ISM_MD_FEC /* VA: Issue 387: fix MD discontinuity in ISM FEC */ + /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c index 5b45d909f1..f40f235e20 100644 --- a/lib_enc/ivas_ism_metadata_enc.c +++ b/lib_enc/ivas_ism_metadata_enc.c @@ -56,6 +56,10 @@ #define ISM_MAX_RADIUS_DIFF_IDX ( ISM_RADIUS_NBITS - 1 /*zero*/ - 1 /*sign*/ ) #define ISM_FEC_MAX 10 +#ifdef FIX_387_ISM_MD_FEC +#define ISM_MD_FEC_DIFF 10 +#define ISM_MD_FEC_CNT_MAX 25 +#endif #define INTER_OBJECT_PARAM_CHECK ( ( ISM_FEC_MAX / 2 ) - 2 ) /* note: constant must be less than (ISM_FEC_MAX / number of coded parameters) */ @@ -252,6 +256,15 @@ ivas_error ivas_ism_metadata_enc( hIsmMeta[ch]->ism_metadata_flag = 0; } #endif + +#ifdef FIX_387_ISM_MD_FEC + if ( ( fabsf( hIsmMeta[ch]->azimuth - hIsmMeta[ch]->last_true_azimuth ) > ISM_MD_FEC_DIFF ) || + ( fabsf( hIsmMeta[ch]->elevation - hIsmMeta[ch]->last_true_elevation ) > ISM_MD_FEC_DIFF ) || + hIsmMeta[ch]->ism_md_fec_cnt_enc == ISM_MD_FEC_CNT_MAX ) + { + hIsmMeta[ch]->ism_metadata_flag = 1; + } +#endif } } @@ -362,6 +375,12 @@ ivas_error ivas_ism_metadata_enc( { nb_bits_metadata[ch] = hBstr->nb_bits_tot - nb_bits_start; } + +#ifdef FIX_387_ISM_MD_FEC + /* Updates */ + hIsmMeta[ch]->last_true_azimuth = hIsmMeta[ch]->azimuth; + hIsmMeta[ch]->last_true_elevation = hIsmMeta[ch]->elevation; +#endif } } @@ -498,6 +517,16 @@ ivas_error ivas_ism_metadata_enc( for ( ch = 0; ch < nchan_ism; ch++ ) { hIsmMeta[ch]->last_ism_metadata_flag = hIsmMeta[ch]->ism_metadata_flag; +#ifdef FIX_387_ISM_MD_FEC + if ( hIsmMeta[ch]->ism_metadata_flag == 0 ) + { + hIsmMeta[ch]->ism_md_fec_cnt_enc++; + } + else + { + hIsmMeta[ch]->ism_md_fec_cnt_enc = 0; + } +#endif } for ( ch = 0; ch < nchan_transport; ch++ ) @@ -581,6 +610,10 @@ ivas_error ivas_ism_metadata_enc_create( st_ivas->hIsmMetaData[ch]->last_azimuth = 0.0f; st_ivas->hIsmMetaData[ch]->last_elevation = 0.0f; #endif + +#ifdef FIX_387_ISM_MD_FEC + st_ivas->hIsmMetaData[ch]->ism_md_fec_cnt_enc = 0; +#endif } if ( ( error = ivas_ism_config( st_ivas->hEncoderConfig->ivas_total_brate, nchan_transport, n_ISms, NULL, NULL, NULL, element_brate_tmp, NULL, NULL ) ) != IVAS_ERR_OK ) @@ -1064,6 +1097,10 @@ void ivas_ism_metadata_sid_enc( hIsmMetaData->angle[0].last_azimuth_idx = idx_azimuth << ( ISM_AZIMUTH_NBITS - nBits_azimuth ); hIsmMetaData->angle[0].last_elevation_idx = idx_elevation << ( ISM_ELEVATION_NBITS - nBits_elevation ); } + +#ifdef FIX_387_ISM_MD_FEC + hIsmMetaData->ism_md_fec_cnt_enc = 0; +#endif } } -- GitLab From dbd3fd77792eaf884028c8788e02120fbd11712c Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 5 Apr 2023 12:50:00 +0200 Subject: [PATCH 2/6] fix MSAN error --- lib_enc/ivas_ism_metadata_enc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c index f40f235e20..e83de0b320 100644 --- a/lib_enc/ivas_ism_metadata_enc.c +++ b/lib_enc/ivas_ism_metadata_enc.c @@ -612,6 +612,8 @@ ivas_error ivas_ism_metadata_enc_create( #endif #ifdef FIX_387_ISM_MD_FEC + st_ivas->hIsmMetaData[ch]->last_true_azimuth = 0.0f; + st_ivas->hIsmMetaData[ch]->last_true_elevation = 0.0f; st_ivas->hIsmMetaData[ch]->ism_md_fec_cnt_enc = 0; #endif } -- GitLab From 32c44f70a455f7b759fbfbd4468468e104db834c Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 11 Apr 2023 10:38:25 +0200 Subject: [PATCH 3/6] extend FIX_387_ISM_MD_FEC to send MD in inactive frames in several consecutive frames --- lib_com/ivas_stat_com.h | 3 ++- lib_enc/ivas_ism_metadata_enc.c | 25 +++++++++++++++++++------ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index a4defd144f..841620e7ce 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -76,7 +76,8 @@ typedef struct #endif #ifdef FIX_387_ISM_MD_FEC - int16_t ism_md_fec_cnt_enc; /* counter of continuous frames where MD are not transmitted */ + int16_t ism_md_fec_cnt_enc; /* counter of continuous frames where MD are not transmitted */ + int16_t ism_md_inc_diff_cnt; /* counter of continuous frames where MD are transmitted in inactive segments when MD significantly changes */ #endif } ISM_METADATA_FRAME, *ISM_METADATA_HANDLE; diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c index e83de0b320..46ffc223ee 100644 --- a/lib_enc/ivas_ism_metadata_enc.c +++ b/lib_enc/ivas_ism_metadata_enc.c @@ -57,8 +57,9 @@ #define ISM_FEC_MAX 10 #ifdef FIX_387_ISM_MD_FEC -#define ISM_MD_FEC_DIFF 10 -#define ISM_MD_FEC_CNT_MAX 25 +#define ISM_MD_FEC_DIFF 10 +#define ISM_MD_INC_DIFF_CNT_MAX 6 +#define ISM_MD_FEC_CNT_MAX 25 #endif #define INTER_OBJECT_PARAM_CHECK ( ( ISM_FEC_MAX / 2 ) - 2 ) /* note: constant must be less than (ISM_FEC_MAX / number of coded parameters) */ @@ -258,11 +259,20 @@ ivas_error ivas_ism_metadata_enc( #endif #ifdef FIX_387_ISM_MD_FEC - if ( ( fabsf( hIsmMeta[ch]->azimuth - hIsmMeta[ch]->last_true_azimuth ) > ISM_MD_FEC_DIFF ) || - ( fabsf( hIsmMeta[ch]->elevation - hIsmMeta[ch]->last_true_elevation ) > ISM_MD_FEC_DIFF ) || - hIsmMeta[ch]->ism_md_fec_cnt_enc == ISM_MD_FEC_CNT_MAX ) + /* in inactive frames, send MD 1) in ISM_MD_INC_DIFF_CNT_MAX consecutive frames when MD significantly change, 2) at kleast every ISM_MD_FEC_DIFF frames */ + if ( hIsmMeta[ch]->ism_metadata_flag == 0 ) { - hIsmMeta[ch]->ism_metadata_flag = 1; + if ( ( fabsf( hIsmMeta[ch]->azimuth - hIsmMeta[ch]->last_true_azimuth ) > ISM_MD_FEC_DIFF ) || + ( fabsf( hIsmMeta[ch]->elevation - hIsmMeta[ch]->last_true_elevation ) > ISM_MD_FEC_DIFF ) ) + { + hIsmMeta[ch]->ism_metadata_flag = 1; + hIsmMeta[ch]->ism_md_inc_diff_cnt = 0; + } + else if ( hIsmMeta[ch]->ism_md_inc_diff_cnt < ISM_MD_INC_DIFF_CNT_MAX || + hIsmMeta[ch]->ism_md_fec_cnt_enc == ISM_MD_FEC_CNT_MAX ) + { + hIsmMeta[ch]->ism_metadata_flag = 1; + } } #endif } @@ -526,6 +536,7 @@ ivas_error ivas_ism_metadata_enc( { hIsmMeta[ch]->ism_md_fec_cnt_enc = 0; } + hIsmMeta[ch]->ism_md_inc_diff_cnt = min( hIsmMeta[ch]->ism_md_inc_diff_cnt++, ISM_MD_INC_DIFF_CNT_MAX ); #endif } @@ -615,6 +626,7 @@ ivas_error ivas_ism_metadata_enc_create( st_ivas->hIsmMetaData[ch]->last_true_azimuth = 0.0f; st_ivas->hIsmMetaData[ch]->last_true_elevation = 0.0f; st_ivas->hIsmMetaData[ch]->ism_md_fec_cnt_enc = 0; + st_ivas->hIsmMetaData[ch]->ism_md_inc_diff_cnt = ISM_MD_INC_DIFF_CNT_MAX; #endif } @@ -1102,6 +1114,7 @@ void ivas_ism_metadata_sid_enc( #ifdef FIX_387_ISM_MD_FEC hIsmMetaData->ism_md_fec_cnt_enc = 0; + hIsmMeta[ch]->ism_md_inc_diff_cnt = ISM_MD_INC_DIFF_CNT_MAX; #endif } } -- GitLab From 7d964601be414972fbfa9c516f49c8018ab15f7e Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 11 Apr 2023 11:15:47 +0200 Subject: [PATCH 4/6] ensure absolute coding of MD --- lib_enc/ivas_ism_metadata_enc.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c index 46ffc223ee..2cbd0f90f9 100644 --- a/lib_enc/ivas_ism_metadata_enc.c +++ b/lib_enc/ivas_ism_metadata_enc.c @@ -268,10 +268,23 @@ ivas_error ivas_ism_metadata_enc( hIsmMeta[ch]->ism_metadata_flag = 1; hIsmMeta[ch]->ism_md_inc_diff_cnt = 0; } - else if ( hIsmMeta[ch]->ism_md_inc_diff_cnt < ISM_MD_INC_DIFF_CNT_MAX || - hIsmMeta[ch]->ism_md_fec_cnt_enc == ISM_MD_FEC_CNT_MAX ) + else if ( hIsmMeta[ch]->ism_md_inc_diff_cnt < ISM_MD_INC_DIFF_CNT_MAX ) { hIsmMeta[ch]->ism_metadata_flag = 1; + + if ( hIsmMeta[ch]->ism_md_inc_diff_cnt % 2 == 0 ) + { + hIsmMeta[ch]->angle[0].azimuth_diff_cnt = ISM_FEC_MAX; + } + else + { + hIsmMeta[ch]->angle[0].elevation_diff_cnt = ISM_FEC_MAX; + } + } + else if ( hIsmMeta[ch]->ism_md_fec_cnt_enc == ISM_MD_FEC_CNT_MAX ) + { + hIsmMeta[ch]->ism_metadata_flag = 1; + hIsmMeta[ch]->angle[0].azimuth_diff_cnt = ISM_FEC_MAX; } } #endif -- GitLab From b277b91ab9fb62f0d3fb647d387d7a2bb8298be1 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 11 Apr 2023 11:18:32 +0200 Subject: [PATCH 5/6] fix compilation warning --- lib_enc/ivas_ism_metadata_enc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c index 2cbd0f90f9..22518fb946 100644 --- a/lib_enc/ivas_ism_metadata_enc.c +++ b/lib_enc/ivas_ism_metadata_enc.c @@ -549,7 +549,7 @@ ivas_error ivas_ism_metadata_enc( { hIsmMeta[ch]->ism_md_fec_cnt_enc = 0; } - hIsmMeta[ch]->ism_md_inc_diff_cnt = min( hIsmMeta[ch]->ism_md_inc_diff_cnt++, ISM_MD_INC_DIFF_CNT_MAX ); + hIsmMeta[ch]->ism_md_inc_diff_cnt = min( ( hIsmMeta[ch]->ism_md_inc_diff_cnt )++, ISM_MD_INC_DIFF_CNT_MAX ); #endif } -- GitLab From 290c8f04e67ddcf1923f90a9ed5125503596d431 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 11 Apr 2023 11:41:25 +0200 Subject: [PATCH 6/6] fix compilation warning --- lib_enc/ivas_ism_metadata_enc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c index 22518fb946..b3038c2d08 100644 --- a/lib_enc/ivas_ism_metadata_enc.c +++ b/lib_enc/ivas_ism_metadata_enc.c @@ -549,7 +549,8 @@ ivas_error ivas_ism_metadata_enc( { hIsmMeta[ch]->ism_md_fec_cnt_enc = 0; } - hIsmMeta[ch]->ism_md_inc_diff_cnt = min( ( hIsmMeta[ch]->ism_md_inc_diff_cnt )++, ISM_MD_INC_DIFF_CNT_MAX ); + hIsmMeta[ch]->ism_md_inc_diff_cnt++; + hIsmMeta[ch]->ism_md_inc_diff_cnt = min( hIsmMeta[ch]->ism_md_inc_diff_cnt, ISM_MD_INC_DIFF_CNT_MAX ); #endif } -- GitLab