diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 048cf6d48d57ee9a42e53370b0dd1d8c1187d83f..11f6bd56f680f1f6ad3f479d568e4eed0b7e5a2f 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1131,7 +1131,11 @@ enum #define MASA_TRANSP_BITS 1 #define NO_BITS_MASA_ISM_NO_OBJ 2 +#ifdef NON_BE_FIX_BASOP_819_THRESHOLD_MASA2TOTAL +#define MASA2TOTAL_THR 0.9799999f +#else #define MASA2TOTAL_THR 0.98f +#endif #define BITS_MASA2TOTTAL_DCT0 6 #define STEP_M2T 0.1f #define MASA_HEADER_BITS 2 diff --git a/lib_com/options.h b/lib_com/options.h index 3d38d6c7e9068d869aaf16b0d095fb9f98d06535..8363b602659c8ed896786e5491a3982844a260e6 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -74,6 +74,7 @@ #define NONBE_FIX_1132_THRESHOLD_POW_IN_SWB_TBE /* VA: issue 1132: prevent division by extremely low energy value in SWB TBE */ #define NON_BE_FIX_807_MASA_DTX_BRSW /* Nokia: adds fix to check existence of DTX encoder for secondary channel in TD mode */ +#define NON_BE_FIX_BASOP_819_THRESHOLD_MASA2TOTAL /* Nokia: add fix for precision limitation in comparison with masa2total energy ratio threshold */ /* #################### End FIXES switches ############################ */ #define BASOP_NOGLOB /* Disable global symbols in BASOPs, Overflow/Carry in BASOPs disabled, additional BASOPs in case of Overflow */ diff --git a/lib_dec/ivas_qmetadata_dec.c b/lib_dec/ivas_qmetadata_dec.c index afbb98f0d2508e3f40a3d59dd053c049e754eb63..930136a735f15b7d496c64c1c596605b724dbb7f 100644 --- a/lib_dec/ivas_qmetadata_dec.c +++ b/lib_dec/ivas_qmetadata_dec.c @@ -580,7 +580,6 @@ int16_t ivas_qmetadata_dec_decode( bits_dir_target += bits_dir_raw; bits_dir_used += bits_dir; - } /* move 2 dir data to its correct subband */ @@ -785,11 +784,11 @@ int16_t ivas_qmetadata_dec_decode_hr_384_512( hQMetaData->q_direction[1].cfg.nbands = codedBands; } } - ivas_qmetadata_entropy_decode_diffuseness_hr_512( bitstream, index, &( hQMetaData->q_direction[0] ) ); + ivas_qmetadata_entropy_decode_diffuseness_hr_512( bitstream, index, &( hQMetaData->q_direction[0] ) ); if ( hQMetaData->no_directions == 2 ) { - ivas_qmetadata_entropy_decode_diffuseness_hr_512( bitstream, index, &( hQMetaData->q_direction[1] ) ); + ivas_qmetadata_entropy_decode_diffuseness_hr_512( bitstream, index, &( hQMetaData->q_direction[1] ) ); } @@ -879,7 +878,7 @@ int16_t ivas_qmetadata_dec_decode_hr_384_512( if ( all_coherence_zero == 0 ) { - read_surround_coherence_hr( bitstream, index, hQMetaData ); + read_surround_coherence_hr( bitstream, index, hQMetaData ); } else { @@ -923,7 +922,6 @@ int16_t ivas_qmetadata_dec_decode_hr_384_512( /* Decode quantized directions frame-wise */ ivas_qmetadata_raw_decode_dir_512( q_direction, bitstream, index, nbands, start_band, sph_grid16 ); - } if ( hQMetaData->no_directions == 2 ) @@ -4119,7 +4117,9 @@ void ivas_omasa_decode_masa_to_total( float q_dct_data[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_FREQUENCY_BANDS], dct_data_tmp[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_FREQUENCY_BANDS]; int16_t n_streams, len_stream; - +#ifdef NON_BE_FIX_BASOP_819_THRESHOLD_MASA2TOTAL + int32_t int_tmp; +#endif /* Setup coding parameters */ n_streams = 1; len_stream = nbands * nblocks; @@ -4174,6 +4174,10 @@ void ivas_omasa_decode_masa_to_total( { masa_to_total_energy_ratio[i][j] = max( 0.0f, q_dct_data[k] ); masa_to_total_energy_ratio[i][j] = min( 1.0f, masa_to_total_energy_ratio[i][j] ); +#ifdef NON_BE_FIX_BASOP_819_THRESHOLD_MASA2TOTAL + int_tmp = (int32_t) ( MASA_SUR_COH_PRECISION * masa_to_total_energy_ratio[i][j] ); + masa_to_total_energy_ratio[i][j] = (float) ( int_tmp * MASA_SUR_COH_THRESHOLD ); +#endif k++; } } @@ -4185,6 +4189,10 @@ void ivas_omasa_decode_masa_to_total( for ( j = 0; j < nbands; j++ ) { masa_to_total_energy_ratio[i][j] = masa_to_total_energy_ratio[0][j]; +#ifdef NON_BE_FIX_BASOP_819_THRESHOLD_MASA2TOTAL + int_tmp = (int32_t) ( MASA_SUR_COH_PRECISION * masa_to_total_energy_ratio[i][j] ); + masa_to_total_energy_ratio[i][j] = (float) ( int_tmp * MASA_SUR_COH_THRESHOLD ); +#endif } } } @@ -4196,6 +4204,10 @@ void ivas_omasa_decode_masa_to_total( for ( i = 0; i < nblocks; i++ ) { masa_to_total_energy_ratio[i][j] = masa_to_total_energy_ratio[i][0]; +#ifdef NON_BE_FIX_BASOP_819_THRESHOLD_MASA2TOTAL + int_tmp = (int32_t) ( MASA_SUR_COH_PRECISION * masa_to_total_energy_ratio[i][j] ); + masa_to_total_energy_ratio[i][j] = (float) ( int_tmp * MASA_SUR_COH_THRESHOLD ); +#endif } } } diff --git a/lib_enc/ivas_qmetadata_enc.c b/lib_enc/ivas_qmetadata_enc.c index e3316c9ca38d9a3a5d97447319350dfb3846a7d4..cf2b34dd0825844e6d8550898d1785a217c2d4e7 100644 --- a/lib_enc/ivas_qmetadata_enc.c +++ b/lib_enc/ivas_qmetadata_enc.c @@ -165,7 +165,6 @@ ivas_error ivas_qmetadata_enc_encode( error = IVAS_ERR_OK; - /* Save initial position in bitstream */ bit_pos_0 = hMetaData->nb_bits_tot; bit_pos_start = bit_pos_0; @@ -442,8 +441,6 @@ ivas_error ivas_qmetadata_enc_encode( } extra_bits = hQMetaData->metadata_max_bits - ( hMetaData->nb_bits_tot - bit_pos_0 ); - - } /* Requantized directions */ @@ -570,7 +567,7 @@ ivas_error ivas_qmetadata_enc_encode_hr_384_512( /* encode 2 direction subbands position */ if ( ndirections == 2 && bits_sph_idx == 11 ) { - write_2dir_info( hMetaData, hQMetaData->twoDirBands, hQMetaData->q_direction[0].cfg.nbands, hQMetaData->numTwoDirBands ); + write_2dir_info( hMetaData, hQMetaData->twoDirBands, hQMetaData->q_direction[0].cfg.nbands, hQMetaData->numTwoDirBands ); d = 0; for ( i = hQMetaData->q_direction[1].cfg.start_band; i < hQMetaData->q_direction[1].cfg.nbands; i++ ) { @@ -2657,7 +2654,6 @@ static int16_t ivas_qmetadata_reorder_azimuth_index( { /* for North and South poles, a single azimuth direction exists */ azimuth_index_reordered = 0; - } return azimuth_index_reordered; @@ -5277,7 +5273,6 @@ static void transform_azimuth_dir2( } - static int16_t divide_GR_orders( const int16_t *q_idx, const int16_t GR1, @@ -5575,7 +5570,9 @@ void ivas_omasa_encode_masa_to_total( float dct_data[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_FREQUENCY_BANDS]; int16_t bits_pos, nb_bits; int16_t n_streams, len_stream; - +#ifdef NON_BE_FIX_BASOP_819_THRESHOLD_MASA2TOTAL + int32_t int_tmp; +#endif bits_pos = hMetaData->nb_bits_tot; k = 0; @@ -5726,6 +5723,10 @@ void ivas_omasa_encode_masa_to_total( { masa_to_total_energy_ratio[i][j] = max( 0.0f, q_dct_data[k] ); masa_to_total_energy_ratio[i][j] = min( 1.0f, masa_to_total_energy_ratio[i][j] ); +#ifdef NON_BE_FIX_BASOP_819_THRESHOLD_MASA2TOTAL + int_tmp = (int32_t) ( MASA_SUR_COH_PRECISION * masa_to_total_energy_ratio[i][j] ); + masa_to_total_energy_ratio[i][j] = (float) ( int_tmp * MASA_SUR_COH_THRESHOLD ); +#endif k++; } }