From 12f110d5cd55507546a367aef58aa494b173cb61 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Mon, 4 Aug 2025 17:23:29 +0300 Subject: [PATCH 1/5] Port float MR 1542 to BASOP --- lib_com/options.h | 1 + lib_dec/ivas_init_dec_fx.c | 20 +++ lib_dec/ivas_masa_dec_fx.c | 273 +++++++++++++++++++++++-------------- lib_enc/ivas_masa_enc_fx.c | 43 +++++- 4 files changed, 231 insertions(+), 106 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 67aafdc6e..fe0e950f3 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -112,6 +112,7 @@ #define NONBE_FIX_1063_DIV_BY_ZERO_SUMNRG /* VoiceAge: issue 1063: division by zero for angle_rot feature in the UNCLR classifier */ #define FIX_1060_USAN_ARRAY_BOUNDS /* FhG: issue 1060: USAN array-bounds errors */ #define NONBE_FIX_SBA_SIGNALING_BITS_B /* FhG: issue 1061: option B: signal sba order additionally in OSBA */ +#define NONBE_FIX_1074_NOBJ_SIGNAL_OMASA_LBR /* Nok: issue 1074 fixing number of objects signaling in OMASA low rate */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index e119b37c4..a641810cb 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -390,6 +390,25 @@ ivas_error ivas_dec_setup( /* this should be non-zero if original input format was MASA_ISM_FORMAT */ st_ivas->nchan_ism = add( st_ivas->bit_stream[L_sub( res_dec, 3 )], shl( st_ivas->bit_stream[L_sub( res_dec, 2 )], 1 ) ); +#ifdef NONBE_FIX_1074_NOBJ_SIGNAL_OMASA_LBR + /* the input_ivas_format should be MASA_ISM_FORMAT, but we cannot initialize it now */ + /* info about the number of objects: + '00' - MASA format at the encoder + '01' - MASA_ISM_FORMAT at the encoder, with 4 objects + '10' - MASA_ISM_FORMAT at the encoder, with 3 objects + '11' - MASA_ISM_FORMAT at the encoder, with 1 or 2 objects + reading if 1 or 2 objects is performed later + */ + st_ivas->nchan_ism = sub( 5, st_ivas->nchan_ism ); + + test(); + IF( EQ_16( st_ivas->nchan_transport, 1 ) && EQ_16( st_ivas->nchan_ism, 2 ) ) + { + st_ivas->nchan_ism = 1; + move16(); + } + /* for MASA_ISM_FORMAT at input the number of MASA transport channels is always 2 and the corresponding bit is not used here*/ +#else IF( GT_16( st_ivas->nchan_ism, 0 ) ) { /* the input_ivas_format should be MASA_ISM_FORMAT, but we cannot initialize it now */ @@ -400,6 +419,7 @@ ivas_error ivas_dec_setup( move16(); } /* for MASA_ISM_FORMAT at input the number of MASA transport channels is always 2 */ +#endif st_ivas->nchan_transport = 2; element_mode_flag = 1; move16(); diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c index f66970710..001609695 100644 --- a/lib_dec/ivas_masa_dec_fx.c +++ b/lib_dec/ivas_masa_dec_fx.c @@ -184,98 +184,126 @@ ivas_error ivas_masa_decode_fx( test(); IF( NE_32( ivas_format, MC_FORMAT ) || NE_16( st_ivas->mc_mode, MC_MODE_MCMASA ) ) { - IF( NE_32( ivas_format, MASA_ISM_FORMAT ) ) +#ifdef NONBE_FIX_1074_NOBJ_SIGNAL_OMASA_LBR + Word16 bits_per_frame = extract_l( Mpy_32_32( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); + if ( EQ_32( ivas_format, MASA_FORMAT ) ) { - /* number of transport channels is always 2 for MASA_ISM format */ - /* the number of MASA transport channels was read in ivas_dec_setup() */ - st->next_bit_pos = sub( st->next_bit_pos, MASA_TRANSP_BITS ); - *nb_bits_read = add( *nb_bits_read, MASA_TRANSP_BITS ); - move16(); + /* re-read the number of objects, needed in case of bad frame */ + st_ivas->nchan_ism = sub( 5, add( st_ivas->bit_stream[bits_per_frame - 3], i_mult( 2, st_ivas->bit_stream[bits_per_frame - 2] ) ) ); } - test(); - IF( EQ_32( ivas_format, MASA_ISM_FORMAT ) && NE_32( st_ivas->ism_mode, ISM_MODE_NONE ) ) + IF( EQ_32( ivas_format, MASA_FORMAT ) && NE_16( st_ivas->nchan_ism, 5 ) ) { - /* the number of objects was read */ - st->next_bit_pos = sub( st->next_bit_pos, NO_BITS_MASA_ISM_NO_OBJ ); - *nb_bits_read = add( *nb_bits_read, NO_BITS_MASA_ISM_NO_OBJ ); - move16(); - move16(); - - IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) + /* there was OMASA in the input */ + hMasa->config.input_ivas_format = MASA_ISM_FORMAT; + move32(); + IF( LT_16( st_ivas->nchan_ism, 3 ) ) { - /* read index of separated object */ - /* nchan_ism should be > 1*/ + /* was read in ivas_init_dec() to distinguish between 1 and 2 objects */ + if ( EQ_16( st_ivas->bit_stream[bits_per_frame - 1], 0 ) ) + { + st_ivas->nchan_ism = 1; + move16(); + } + st->next_bit_pos = sub( st->next_bit_pos, MASA_TRANSP_BITS ); + *nb_bits_read = add( *nb_bits_read, MASA_TRANSP_BITS ); + move16(); + move16(); + + /* the two reserved bits were already read in ivas_init_dec()*/ + byteBuffer = st->bit_stream[( st->next_bit_pos )--]; byteBuffer = st->bit_stream[( st->next_bit_pos )--]; move16(); - *nb_bits_read = add( *nb_bits_read, 1 ); move16(); - st_ivas->hMasaIsmData->idx_separated_ism = extract_l( L_add( L_shl( byteBuffer, 1 ), st->bit_stream[( st->next_bit_pos )--] ) ); + *nb_bits_read = add( *nb_bits_read, MASA_HEADER_BITS ); + move16(); + /* read number of directions */ + byteBuffer = st->bit_stream[( st->next_bit_pos )--]; move16(); *nb_bits_read = add( *nb_bits_read, 1 ); move16(); + hMasa->config.numberOfDirections = (UWord8) L_add( byteBuffer, 1 ); + move16(); } ELSE { - st_ivas->hMasaIsmData->idx_separated_ism = -1; + /* if there are 3 or 4 objects the number of transport channels bit is given to MASA format + and used to read number of directions*/ + byteBuffer = st->bit_stream[( st->next_bit_pos )--]; + move16(); + *nb_bits_read = add( *nb_bits_read, 1 ); + move16(); + hMasa->config.numberOfDirections = (UWord8) L_add( byteBuffer, 1 ); + move16(); + + /* the two reserved bits were already read in ivas_init_dec()*/ + byteBuffer = st->bit_stream[( st->next_bit_pos )--]; + byteBuffer = st->bit_stream[( st->next_bit_pos )--]; + move16(); + move16(); + *nb_bits_read = add( *nb_bits_read, MASA_HEADER_BITS ); + move16(); + } + } + ELSE + { +#endif + IF( NE_32( ivas_format, MASA_ISM_FORMAT ) ) + { + /* number of transport channels is always 2 for MASA_ISM format */ + /* the number of MASA transport channels was read in ivas_dec_setup() */ + st->next_bit_pos = sub( st->next_bit_pos, MASA_TRANSP_BITS ); + *nb_bits_read = add( *nb_bits_read, MASA_TRANSP_BITS ); move16(); } - /* read ISM importance flag (one per object) */ - IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) + test(); + IF( EQ_32( ivas_format, MASA_ISM_FORMAT ) && NE_32( st_ivas->ism_mode, ISM_MODE_NONE ) ) { - ism_imp = 0; + /* the number of objects was read */ + st->next_bit_pos = sub( st->next_bit_pos, NO_BITS_MASA_ISM_NO_OBJ ); + *nb_bits_read = add( *nb_bits_read, NO_BITS_MASA_ISM_NO_OBJ ); + move16(); move16(); - FOR( i = 0; i < ISM_METADATA_FLAG_BITS; i++ ) + IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) { + /* read index of separated object */ + /* nchan_ism should be > 1*/ byteBuffer = st->bit_stream[( st->next_bit_pos )--]; move16(); *nb_bits_read = add( *nb_bits_read, 1 ); move16(); - ism_imp = add( shl( ism_imp, 1 ), (Word16) byteBuffer ); - } - st_ivas->hIsmMetaData[0]->ism_imp = ism_imp; - move16(); - } - - IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) - { - ism_imp = 0; - move16(); - FOR( i = 0; i < ISM_METADATA_FLAG_BITS; i++ ) - { - byteBuffer = st->bit_stream[( st->next_bit_pos )--]; + st_ivas->hMasaIsmData->idx_separated_ism = extract_l( L_add( L_shl( byteBuffer, 1 ), st->bit_stream[( st->next_bit_pos )--] ) ); move16(); *nb_bits_read = add( *nb_bits_read, 1 ); move16(); - ism_imp = add( shl( ism_imp, 1 ), (Word16) byteBuffer ); + } + ELSE + { + st_ivas->hMasaIsmData->idx_separated_ism = -1; move16(); } - st_ivas->hIsmMetaData[0]->ism_imp = ism_imp; - move16(); - /* reset */ - st_ivas->hIsmMetaData[0]->ism_md_null_flag = 0; - move16(); - st_ivas->hIsmMetaData[0]->ism_md_lowrate_flag = 0; - move16(); - IF( EQ_16( st_ivas->hIsmMetaData[0]->ism_imp, ISM_NO_META ) ) + /* read ISM importance flag (one per object) */ + IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) { - /* read flags */ - st_ivas->hIsmMetaData[0]->ism_md_null_flag = st->bit_stream[( st->next_bit_pos )--]; - move16(); - *nb_bits_read = add( *nb_bits_read, ISM_METADATA_MD_FLAG_BITS ); - move16(); - st_ivas->hIsmMetaData[0]->ism_md_lowrate_flag = st->bit_stream[( st->next_bit_pos )--]; + ism_imp = 0; move16(); - *nb_bits_read = add( *nb_bits_read, ISM_METADATA_INACTIVE_FLAG_BITS ); + + FOR( i = 0; i < ISM_METADATA_FLAG_BITS; i++ ) + { + byteBuffer = st->bit_stream[( st->next_bit_pos )--]; + move16(); + *nb_bits_read = add( *nb_bits_read, 1 ); + move16(); + ism_imp = add( shl( ism_imp, 1 ), (Word16) byteBuffer ); + } + st_ivas->hIsmMetaData[0]->ism_imp = ism_imp; move16(); } - } - ELSE IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) - { - FOR( ch = 0; ch < st_ivas->nchan_ism; ch++ ) + + IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) { ism_imp = 0; move16(); @@ -286,66 +314,104 @@ ivas_error ivas_masa_decode_fx( *nb_bits_read = add( *nb_bits_read, 1 ); move16(); ism_imp = add( shl( ism_imp, 1 ), (Word16) byteBuffer ); + move16(); } - st_ivas->hIsmMetaData[ch]->ism_imp = ism_imp; + st_ivas->hIsmMetaData[0]->ism_imp = ism_imp; move16(); /* reset */ - st_ivas->hIsmMetaData[ch]->ism_md_null_flag = 0; + st_ivas->hIsmMetaData[0]->ism_md_null_flag = 0; move16(); - st_ivas->hIsmMetaData[ch]->ism_md_lowrate_flag = 0; + st_ivas->hIsmMetaData[0]->ism_md_lowrate_flag = 0; move16(); - IF( EQ_16( st_ivas->hIsmMetaData[ch]->ism_imp, ISM_NO_META ) ) + IF( EQ_16( st_ivas->hIsmMetaData[0]->ism_imp, ISM_NO_META ) ) { /* read flags */ - st_ivas->hIsmMetaData[ch]->ism_md_null_flag = st->bit_stream[( st->next_bit_pos )--]; + st_ivas->hIsmMetaData[0]->ism_md_null_flag = st->bit_stream[( st->next_bit_pos )--]; move16(); *nb_bits_read = add( *nb_bits_read, ISM_METADATA_MD_FLAG_BITS ); move16(); - st_ivas->hIsmMetaData[ch]->ism_md_lowrate_flag = st->bit_stream[( st->next_bit_pos )--]; + st_ivas->hIsmMetaData[0]->ism_md_lowrate_flag = st->bit_stream[( st->next_bit_pos )--]; move16(); *nb_bits_read = add( *nb_bits_read, ISM_METADATA_INACTIVE_FLAG_BITS ); move16(); } } - st_ivas->flag_omasa_brate = 0; - move16(); - test(); - IF( GE_16( st_ivas->nchan_ism, 3 ) && EQ_32( ivas_total_brate, IVAS_128k ) ) + ELSE IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) { - st_ivas->flag_omasa_brate = st->bit_stream[( st->next_bit_pos )--]; - move16(); - *nb_bits_read = add( *nb_bits_read, 1 ); + FOR( ch = 0; ch < st_ivas->nchan_ism; ch++ ) + { + ism_imp = 0; + move16(); + FOR( i = 0; i < ISM_METADATA_FLAG_BITS; i++ ) + { + byteBuffer = st->bit_stream[( st->next_bit_pos )--]; + move16(); + *nb_bits_read = add( *nb_bits_read, 1 ); + move16(); + ism_imp = add( shl( ism_imp, 1 ), (Word16) byteBuffer ); + } + st_ivas->hIsmMetaData[ch]->ism_imp = ism_imp; + move16(); + + /* reset */ + st_ivas->hIsmMetaData[ch]->ism_md_null_flag = 0; + move16(); + st_ivas->hIsmMetaData[ch]->ism_md_lowrate_flag = 0; + move16(); + IF( EQ_16( st_ivas->hIsmMetaData[ch]->ism_imp, ISM_NO_META ) ) + { + /* read flags */ + st_ivas->hIsmMetaData[ch]->ism_md_null_flag = st->bit_stream[( st->next_bit_pos )--]; + move16(); + *nb_bits_read = add( *nb_bits_read, ISM_METADATA_MD_FLAG_BITS ); + move16(); + st_ivas->hIsmMetaData[ch]->ism_md_lowrate_flag = st->bit_stream[( st->next_bit_pos )--]; + move16(); + *nb_bits_read = add( *nb_bits_read, ISM_METADATA_INACTIVE_FLAG_BITS ); + move16(); + } + } + st_ivas->flag_omasa_brate = 0; move16(); + test(); + IF( GE_16( st_ivas->nchan_ism, 3 ) && EQ_32( ivas_total_brate, IVAS_128k ) ) + { + st_ivas->flag_omasa_brate = st->bit_stream[( st->next_bit_pos )--]; + move16(); + *nb_bits_read = add( *nb_bits_read, 1 ); + move16(); + } } } - } #ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT - /* read 2 bits: - '00' - MASA format at the encoder - '01' - MASA_ISM_FORMAT at the encoder, with 1 object - '10' - MASA_ISM_FORMAT at the encoder, with 2 objects - '11' - MASA_ISM_FORMAT at the encoder, with 3 or 4 objects - reading if 3 or 4 object is performed later - */ - byteBuffer = st->bit_stream[st->next_bit_pos]; - move16(); - st->next_bit_pos = sub( st->next_bit_pos, 1 ); - byteBuffer = add( byteBuffer, shl( st->bit_stream[st->next_bit_pos], 1 ) ); - st->next_bit_pos = sub( st->next_bit_pos, 1 ); +#ifndef NONBE_FIX_1074_NOBJ_SIGNAL_OMASA_LBR + /* read 2 bits: + '00' - MASA format at the encoder + '01' - MASA_ISM_FORMAT at the encoder, with 1 object + '10' - MASA_ISM_FORMAT at the encoder, with 2 objects + '11' - MASA_ISM_FORMAT at the encoder, with 3 or 4 objects + reading if 3 or 4 object is performed later + */ +#endif + byteBuffer = st->bit_stream[st->next_bit_pos]; + move16(); + st->next_bit_pos = sub( st->next_bit_pos, 1 ); + byteBuffer = add( byteBuffer, shl( st->bit_stream[st->next_bit_pos], 1 ) ); + st->next_bit_pos = sub( st->next_bit_pos, 1 ); - test(); - IF( EQ_16( byteBuffer, 0 ) && EQ_32( ivas_format, MASA_FORMAT ) ) - { - hMasa->config.input_ivas_format = MASA_FORMAT; - move32(); - } - ELSE - { - hMasa->config.input_ivas_format = MASA_ISM_FORMAT; - move32(); - } + test(); + IF( EQ_16( byteBuffer, 0 ) && EQ_32( ivas_format, MASA_FORMAT ) ) + { + hMasa->config.input_ivas_format = MASA_FORMAT; + move32(); + } + ELSE + { + hMasa->config.input_ivas_format = MASA_ISM_FORMAT; + move32(); + } #else /* read the MASA_ISM_FORMAT bit */ byteBuffer = st->bit_stream[( st->next_bit_pos )--]; @@ -364,15 +430,18 @@ ivas_error ivas_masa_decode_fx( byteBuffer = st->bit_stream[( st->next_bit_pos )--]; move16(); #endif - *nb_bits_read = add( *nb_bits_read, MASA_HEADER_BITS ); + *nb_bits_read = add( *nb_bits_read, MASA_HEADER_BITS ); - /* read number of directions */ - byteBuffer = st->bit_stream[( st->next_bit_pos )--]; - move16(); - *nb_bits_read = add( *nb_bits_read, 1 ); - move16(); - hMasa->config.numberOfDirections = (UWord8) L_add( byteBuffer, 1 ); - move16(); + /* read number of directions */ + byteBuffer = st->bit_stream[( st->next_bit_pos )--]; + move16(); + *nb_bits_read = add( *nb_bits_read, 1 ); + move16(); + hMasa->config.numberOfDirections = (UWord8) L_add( byteBuffer, 1 ); + move16(); +#ifdef NONBE_FIX_1074_NOBJ_SIGNAL_OMASA_LBR + } +#endif } ELSE { diff --git a/lib_enc/ivas_masa_enc_fx.c b/lib_enc/ivas_masa_enc_fx.c index 72cc9d78d..a1b34f992 100644 --- a/lib_enc/ivas_masa_enc_fx.c +++ b/lib_enc/ivas_masa_enc_fx.c @@ -537,6 +537,19 @@ ivas_error ivas_masa_encode_fx( test(); IF( EQ_32( ivas_format, MASA_ISM_FORMAT ) && EQ_32( ism_mode, ISM_MODE_NONE ) ) { +#ifdef NONBE_FIX_1074_NOBJ_SIGNAL_OMASA_LBR + /* use the MASA number of transport channels bit to signal if there are 1 or 2 objects */ + test(); + IF( EQ_16( nchan_ism, 1 ) || EQ_16( nchan_ism, 2 ) ) + { + push_next_indice( hMetaData, sub( nchan_ism, 1 ), MASA_TRANSP_BITS ); + } + ELSE + { + /* for 3 or 4 objects write already the number of MASA directions */ + push_next_indice( hMetaData, sub( hQMetaData->no_directions, 1 ), MASA_TRANSP_BITS ); + } +#else /* use the MASA number of transport channels bit to signal if there are 3 or 4 objects */ IF( EQ_16( nchan_ism, 4 ) ) { @@ -546,6 +559,7 @@ ivas_error ivas_masa_encode_fx( { push_next_indice( hMetaData, 0, MASA_TRANSP_BITS ); } +#endif } ELSE { @@ -563,6 +577,16 @@ ivas_error ivas_masa_encode_fx( IF( EQ_32( ivas_format, MASA_ISM_FORMAT ) && EQ_32( ism_mode, ISM_MODE_NONE ) ) { #ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT +#ifdef NONBE_FIX_1074_NOBJ_SIGNAL_OMASA_LBR + IF( GE_16( nchan_ism, 3 ) ) /* if 3 or 4 objects */ + { + push_next_indice( hMetaData, sub( 5, nchan_ism ), MASA_HEADER_BITS ); + } + ELSE + { + push_next_indice( hMetaData, 3, MASA_HEADER_BITS ); + } +#else IF( LE_16( nchan_ism, 3 ) ) { push_next_indice( hMetaData, nchan_ism, MASA_HEADER_BITS ); @@ -571,6 +595,7 @@ ivas_error ivas_masa_encode_fx( { push_next_indice( hMetaData, sub( nchan_ism, 1 ), MASA_HEADER_BITS ); } +#endif hQMetaData->metadata_max_bits = sub( hQMetaData->metadata_max_bits, MASA_HEADER_BITS ); move16(); #else @@ -590,10 +615,20 @@ ivas_error ivas_masa_encode_fx( hQMetaData->metadata_max_bits = sub( hQMetaData->metadata_max_bits, MASA_HEADER_BITS ); move16(); } - /* write number of directions */ - push_next_indice( hMetaData, sub( hQMetaData->no_directions, 1 ), 1 ); - hQMetaData->metadata_max_bits = sub( hQMetaData->metadata_max_bits, 1 ); - move16(); +#ifdef NONBE_FIX_1074_NOBJ_SIGNAL_OMASA_LBR + test(); + test(); + test(); + IF( !( EQ_32( ivas_format, MASA_ISM_FORMAT ) && EQ_32( ism_mode, ISM_MODE_NONE ) && GT_16( nchan_ism, 2 ) ) ) + { +#endif + /* write number of directions */ + push_next_indice( hMetaData, sub( hQMetaData->no_directions, 1 ), 1 ); + hQMetaData->metadata_max_bits = sub( hQMetaData->metadata_max_bits, 1 ); + move16(); +#ifdef NONBE_FIX_1074_NOBJ_SIGNAL_OMASA_LBR + } +#endif /* write subframe mode */ IF( EQ_16( hQMetaData->q_direction[0].cfg.nblocks, 1 ) ) -- GitLab From 0ff65c56ee0fe25147325bcf2c32ea8d10eb85ac Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Mon, 4 Aug 2025 19:46:29 +0300 Subject: [PATCH 2/5] Fix bug in port --- lib_dec/ivas_init_dec_fx.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index a641810cb..6f810ad48 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -390,27 +390,27 @@ ivas_error ivas_dec_setup( /* this should be non-zero if original input format was MASA_ISM_FORMAT */ st_ivas->nchan_ism = add( st_ivas->bit_stream[L_sub( res_dec, 3 )], shl( st_ivas->bit_stream[L_sub( res_dec, 2 )], 1 ) ); + IF( GT_16( st_ivas->nchan_ism, 0 ) ) + { #ifdef NONBE_FIX_1074_NOBJ_SIGNAL_OMASA_LBR - /* the input_ivas_format should be MASA_ISM_FORMAT, but we cannot initialize it now */ - /* info about the number of objects: - '00' - MASA format at the encoder - '01' - MASA_ISM_FORMAT at the encoder, with 4 objects - '10' - MASA_ISM_FORMAT at the encoder, with 3 objects - '11' - MASA_ISM_FORMAT at the encoder, with 1 or 2 objects - reading if 1 or 2 objects is performed later - */ - st_ivas->nchan_ism = sub( 5, st_ivas->nchan_ism ); + /* the input_ivas_format should be MASA_ISM_FORMAT, but we cannot initialize it now */ + /* info about the number of objects: + '00' - MASA format at the encoder + '01' - MASA_ISM_FORMAT at the encoder, with 4 objects + '10' - MASA_ISM_FORMAT at the encoder, with 3 objects + '11' - MASA_ISM_FORMAT at the encoder, with 1 or 2 objects + reading if 1 or 2 objects is performed later + */ + st_ivas->nchan_ism = sub( 5, st_ivas->nchan_ism ); - test(); - IF( EQ_16( st_ivas->nchan_transport, 1 ) && EQ_16( st_ivas->nchan_ism, 2 ) ) - { - st_ivas->nchan_ism = 1; - move16(); - } - /* for MASA_ISM_FORMAT at input the number of MASA transport channels is always 2 and the corresponding bit is not used here*/ + test(); + IF( EQ_16( st_ivas->nchan_transport, 1 ) && EQ_16( st_ivas->nchan_ism, 2 ) ) + { + st_ivas->nchan_ism = 1; + move16(); + } + /* for MASA_ISM_FORMAT at input the number of MASA transport channels is always 2 and the corresponding bit is not used here*/ #else - IF( GT_16( st_ivas->nchan_ism, 0 ) ) - { /* the input_ivas_format should be MASA_ISM_FORMAT, but we cannot initialize it now */ test(); IF( EQ_16( st_ivas->nchan_transport, 2 ) && EQ_16( st_ivas->nchan_ism, 3 ) ) -- GitLab From 0c9f5d29781889be6a70968d07142636ca10c678 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Tue, 5 Aug 2025 11:46:41 +0300 Subject: [PATCH 3/5] Code review fixes --- lib_dec/ivas_masa_dec_fx.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c index 001609695..98acace00 100644 --- a/lib_dec/ivas_masa_dec_fx.c +++ b/lib_dec/ivas_masa_dec_fx.c @@ -186,7 +186,7 @@ ivas_error ivas_masa_decode_fx( { #ifdef NONBE_FIX_1074_NOBJ_SIGNAL_OMASA_LBR Word16 bits_per_frame = extract_l( Mpy_32_32( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); - if ( EQ_32( ivas_format, MASA_FORMAT ) ) + IF( EQ_32( ivas_format, MASA_FORMAT ) ) { /* re-read the number of objects, needed in case of bad frame */ st_ivas->nchan_ism = sub( 5, add( st_ivas->bit_stream[bits_per_frame - 3], i_mult( 2, st_ivas->bit_stream[bits_per_frame - 2] ) ) ); @@ -200,15 +200,13 @@ ivas_error ivas_masa_decode_fx( IF( LT_16( st_ivas->nchan_ism, 3 ) ) { /* was read in ivas_init_dec() to distinguish between 1 and 2 objects */ - if ( EQ_16( st_ivas->bit_stream[bits_per_frame - 1], 0 ) ) + IF( EQ_16( st_ivas->bit_stream[bits_per_frame - 1], 0 ) ) { st_ivas->nchan_ism = 1; move16(); } st->next_bit_pos = sub( st->next_bit_pos, MASA_TRANSP_BITS ); *nb_bits_read = add( *nb_bits_read, MASA_TRANSP_BITS ); - move16(); - move16(); /* the two reserved bits were already read in ivas_init_dec()*/ byteBuffer = st->bit_stream[( st->next_bit_pos )--]; @@ -216,14 +214,11 @@ ivas_error ivas_masa_decode_fx( move16(); move16(); *nb_bits_read = add( *nb_bits_read, MASA_HEADER_BITS ); - move16(); /* read number of directions */ byteBuffer = st->bit_stream[( st->next_bit_pos )--]; move16(); *nb_bits_read = add( *nb_bits_read, 1 ); - move16(); hMasa->config.numberOfDirections = (UWord8) L_add( byteBuffer, 1 ); - move16(); } ELSE { @@ -232,9 +227,7 @@ ivas_error ivas_masa_decode_fx( byteBuffer = st->bit_stream[( st->next_bit_pos )--]; move16(); *nb_bits_read = add( *nb_bits_read, 1 ); - move16(); hMasa->config.numberOfDirections = (UWord8) L_add( byteBuffer, 1 ); - move16(); /* the two reserved bits were already read in ivas_init_dec()*/ byteBuffer = st->bit_stream[( st->next_bit_pos )--]; @@ -242,7 +235,6 @@ ivas_error ivas_masa_decode_fx( move16(); move16(); *nb_bits_read = add( *nb_bits_read, MASA_HEADER_BITS ); - move16(); } } ELSE -- GitLab From 6861b8c130cf21ac6ebff75d073ab1a4335e5600 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Thu, 7 Aug 2025 11:15:00 +0300 Subject: [PATCH 4/5] Add a fix to account for bad frame situations and additional use of ivas_get_nchan_buffers_dec compared to float version. --- lib_rend/ivas_output_init_fx.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib_rend/ivas_output_init_fx.c b/lib_rend/ivas_output_init_fx.c index 752928f91..b30ce1fd1 100644 --- a/lib_rend/ivas_output_init_fx.c +++ b/lib_rend/ivas_output_init_fx.c @@ -388,7 +388,12 @@ Word16 ivas_get_nchan_buffers_dec_fx( } #ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT test(); +#ifdef NONBE_FIX_1074_NOBJ_SIGNAL_OMASA_LBR + test(); + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) && GT_16( st_ivas->nchan_ism, 0 ) && LT_16( st_ivas->nchan_ism, 5 ) ) /* Last condition needed only in BASOP */ +#else IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) && GT_16( st_ivas->nchan_ism, 0 ) ) +#endif { nchan_out_buff = add( st_ivas->nchan_ism, CPE_CHANNELS ); } -- GitLab From 98ebaa00ebd5a5687d9052b1778c554982e188a2 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Thu, 7 Aug 2025 15:35:00 +0300 Subject: [PATCH 5/5] Change i_mult to shl --- lib_dec/ivas_masa_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c index 623b66238..ba90382ae 100644 --- a/lib_dec/ivas_masa_dec_fx.c +++ b/lib_dec/ivas_masa_dec_fx.c @@ -189,7 +189,7 @@ ivas_error ivas_masa_decode_fx( IF( EQ_32( ivas_format, MASA_FORMAT ) ) { /* re-read the number of objects, needed in case of bad frame */ - st_ivas->nchan_ism = sub( 5, add( st_ivas->bit_stream[bits_per_frame - 3], i_mult( 2, st_ivas->bit_stream[bits_per_frame - 2] ) ) ); + st_ivas->nchan_ism = sub( 5, add( st_ivas->bit_stream[bits_per_frame - 3], shl( st_ivas->bit_stream[bits_per_frame - 2], 1 ) ) ); } test(); IF( EQ_32( ivas_format, MASA_FORMAT ) && NE_16( st_ivas->nchan_ism, 5 ) ) -- GitLab