diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 6d986b520bc56ff148dab958057e7edc678a5779..68c4464b64c4f94824bcdb89fadf1ded8f6a585e 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -119,8 +119,8 @@ typedef enum AUDIO_CONFIG_ISM2, /* ISM2 */ AUDIO_CONFIG_ISM3, /* ISM3 */ AUDIO_CONFIG_ISM4, /* ISM4 */ - AUDIO_CONFIG_MASA1, /* MASA1 */ // TODO: seems not to be used - AUDIO_CONFIG_MASA2, /* MASA2 */ // TODO: seems not to be used + AUDIO_CONFIG_MASA1, /* MASA1 */ + AUDIO_CONFIG_MASA2, /* MASA2 */ AUDIO_CONFIG_EXTERNAL /* external renderer */ } AUDIO_CONFIG; diff --git a/lib_com/ivas_masa_com.c b/lib_com/ivas_masa_com.c index 0ca65e4da372e35537c68b6c71dcf2575fce1d88..a45c7fd673eb8ffd8d0eea5b19705e27579aa8b4 100644 --- a/lib_com/ivas_masa_com.c +++ b/lib_com/ivas_masa_com.c @@ -897,6 +897,10 @@ void reconstruct_ism_ratios( void ivas_omasa_modify_masa_energy_ratios( IVAS_QMETADATA_HANDLE hQMetaData /* i/o: q_metadata handle */ +#ifdef FIX_672_NOKIA_TODO + , + float masa_to_total_energy_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_MAXIMUM_CODING_SUBBANDS] +#endif ) { int16_t i, m, d, b; @@ -916,7 +920,11 @@ void ivas_omasa_modify_masa_energy_ratios( { for ( d = 0; d < hQMetaData->no_directions; d++ ) { +#ifdef FIX_672_NOKIA_TODO + hQMetaData->q_direction[d].band_data[b].energy_ratio[m] = hQMetaData->q_direction[d].band_data[b].energy_ratio[m] * masa_to_total_energy_ratio[i][b]; +#else hQMetaData->q_direction[d].band_data[b].energy_ratio[m] = hQMetaData->q_direction[d].band_data[b].energy_ratio[m] * hQMetaData->masa_to_total_energy_ratio[i][b]; +#endif } } } diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index f029892be9154614c52b3be72a59d88221acd78f..c299e999cf9749bebf70306124b6ad325c8e83e7 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5991,7 +5991,11 @@ void ivas_omasa_set_edited_objects( ); #endif void ivas_omasa_encode_masa_to_total( +#ifdef FIX_672_NOKIA_TODO + float masa_to_total_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], +#else IVAS_QMETADATA_HANDLE hQMetaData, +#endif BSTR_ENC_HANDLE hMetaData, const int16_t low_bitrate_mode, const int16_t nbands, @@ -6008,6 +6012,10 @@ void ivas_omasa_decode_masa_to_total( void ivas_omasa_modify_masa_energy_ratios( IVAS_QMETADATA_HANDLE hQMetaData /* i/o: q_metadata handle */ +#ifdef FIX_672_NOKIA_TODO + , + float masa_to_total_energy_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_MAXIMUM_CODING_SUBBANDS] +#endif ); #endif diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 975fb77a7150d49c77c2a4a3ace871d751da00d8..476dae42ab2d779dfa38199106446cf6d70faa25 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -484,6 +484,9 @@ typedef struct ivas_masa_config_struct uint8_t useCoherence; uint8_t coherencePresent; uint8_t mergeRatiosOverSubframes; +#ifdef FIX_672_NOKIA_TODO + IVAS_FORMAT input_ivas_format; +#endif } MASA_CODEC_CONFIG; @@ -576,9 +579,11 @@ typedef struct ivas_masa_qmetadata_frame_struct int16_t ec_flag; float dir_comp_ratio; uint8_t is_masa_ivas_format; +#ifndef FIX_672_NOKIA_TODO #ifdef MASA_AND_OBJECTS float masa_to_total_energy_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; /* TODO Nokia: This should be moved to some other place and reserved only when needed. */ #endif +#endif } IVAS_QMETADATA, *IVAS_QMETADATA_HANDLE; diff --git a/lib_com/options.h b/lib_com/options.h index f5a82aa3fda524316083bd7f443cbf66bcbe63de..7415cb9fcadef39ff770e383a9a2829cc9146a11 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -220,6 +220,7 @@ #define FIX_613_DIRAC_NULL_PTR_USAN /* Nokia: Issue #613: USAN in DirAC decoder setup */ #define FIX_647_SILENT_W_PARAMBIN /* Nokia: Issue #647: Fix silent W SH inputs in parametric binauralizer */ +#define FIX_672_NOKIA_TODO /* Nokia: Issue #672: Resolve Nokia TODOs */ #define MASA_AND_OBJECTS /* Nokia: Combination of MASA and objects */ #define SBA_AND_OBJECTS diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index dc2a4f9a0a7bab8c32b97a12ddd82ff138374cd6..bce8d4e3ded800eeedc4c0ea90d6cd6fc7aeb963 100755 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -570,7 +570,11 @@ ivas_error ivas_dec( /* Set the number of objects for the parametric rendering */ dirac_bs_md_write_idx = 0; +#ifdef FIX_672_NOKIA_TODO + if ( st_ivas->hSpatParamRendCom != NULL ) +#else if ( st_ivas->hDirAC != NULL ) /* TODO: should this check for st_ivas->hSpatParamRendCom != NULL ? */ +#endif { st_ivas->hSpatParamRendCom->numIsmDirections = 0; if ( st_ivas->ism_mode != ISM_MASA_MODE_DISC && st_ivas->ism_mode != ISM_MASA_MODE_MASA_ONE_OBJ ) diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 2a6ee7f1efa7c4a03fcb38dad0478c1b01c2946b..4e84f63edb9b212a92845d43cd423448fcde3aa5 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -1832,8 +1832,13 @@ void ivas_dirac_dec_render_sf( float Cldfb_ImagBuffer_Binaural[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; #endif #ifdef MASA_AND_OBJECTS +#ifdef FIX_672_NOKIA_TODO + float Cldfb_RealBuffer_Temp[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer_Temp[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; +#else float Cldfb_RealBuffer_Temp[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; /* Todo Nokia: Temporary, to be removed once function calls have been refactored to accept another size */ float Cldfb_ImagBuffer_Temp[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; /* Todo Nokia: Temporary, to be removed once function calls have been refactored to accept another size */ +#endif #endif int16_t index, num_freq_bands; @@ -2036,7 +2041,9 @@ void ivas_dirac_dec_render_sf( } #ifdef MASA_AND_OBJECTS +#ifndef FIX_672_NOKIA_TODO // Todo OMASA JBM: This might need adjustments +#endif if ( st_ivas->ivas_format == MASA_ISM_FORMAT && nchan_transport == 2 ) { for ( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) @@ -2085,7 +2092,9 @@ void ivas_dirac_dec_render_sf( } } #ifdef MASA_AND_OBJECTS +#ifndef FIX_672_NOKIA_TODO // Todo OMASA JBM: This might need adjustments +#endif else if ( st_ivas->ivas_format == MASA_ISM_FORMAT && nchan_transport == 2 ) { for ( ch = 0; ch < nchan_transport; ch++ ) diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 5090cf8a0db92f6ff0bbc4673f6df5b5a85a8589..442b1336116ea8ff87c6b112c546e65fb1c33edc 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -77,9 +77,11 @@ static ivas_error ivas_masa_dec_config( Decoder_Struct *st_ivas ); static int16_t ivas_decode_masaism_metadata( IVAS_QMETADATA_HANDLE hQMetaData, MASA_DECODER_HANDLE hMasa, MASA_ISM_DATA_HANDLE hMasaIsmData, const int16_t nchan_ism, uint16_t *bit_stream, int16_t *next_bit_pos, const int16_t idx_separated_object, const int16_t ism_imp, const int16_t dirac_bs_md_write_idx, const int16_t dirac_md_buffer_length ); static void decode_index_slice( int16_t index, int16_t *ratio_idx_ism, const int16_t nchan_ism, const int16_t K ); - +#ifdef FIX_672_NOKIA_TODO +static void decode_ism_ratios( uint16_t *bit_stream, int16_t *next_bit_pos, float masa_to_total_energy_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], float ratio_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], const int16_t nchan_ism, const int16_t nbands, const int16_t nblocks, const int16_t idx_separated_object ); +#else static void decode_ism_ratios( uint16_t *bit_stream, int16_t *next_bit_pos, IVAS_QMETADATA_HANDLE hQMetaData, float ratio_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], const int16_t nchan_ism, const int16_t nbands, const int16_t nblocks, const int16_t idx_separated_object ); - +#endif static void read_ism_ratio_index( int16_t ratio_ism_idx[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], const int16_t nchan_ism, const int16_t numCodingBands, const int16_t sf, int16_t ratio_ism_idx_prev_sf[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], uint16_t *bit_stream, int16_t *next_bit_pos, float *masa_to_total_energy_ratio, const int16_t idx_sep_obj, int16_t *num_zeros ); #endif @@ -257,9 +259,25 @@ ivas_error ivas_masa_decode( } } #endif + +#ifdef FIX_672_NOKIA_TODO + /* read the MASA_ISM_FORMAT bit */ + byteBuffer = st->bit_stream[( st->next_bit_pos )--]; + if ( byteBuffer == 1 ) + { + hMasa->config.input_ivas_format = MASA_ISM_FORMAT; + } + else + { + hMasa->config.input_ivas_format = MASA_FORMAT; + } + /* reserved bit */ + byteBuffer = st->bit_stream[( st->next_bit_pos )--]; +#else /* Placeholder for descriptive metadata content */ byteBuffer = st->bit_stream[( st->next_bit_pos )--]; byteBuffer += st->bit_stream[( st->next_bit_pos )--]; +#endif *nb_bits_read += MASA_HEADER_BITS; /* read number of directions */ @@ -383,7 +401,12 @@ ivas_error ivas_masa_decode( if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode != ISM_MASA_MODE_DISC && st_ivas->ism_mode != ISM_MASA_MODE_MASA_ONE_OBJ ) { /* Modify spatial metadata based on the MASA-to-total energy ratios */ - ivas_omasa_modify_masa_energy_ratios( hQMetaData ); + ivas_omasa_modify_masa_energy_ratios( hQMetaData +#ifdef FIX_672_NOKIA_TODO + , + st_ivas->hMasaIsmData->masa_to_total_energy_ratio +#endif + ); } #endif @@ -473,7 +496,9 @@ ivas_error ivas_masa_decode( if ( st_ivas->hDirAC != NULL ) { #ifdef MASA_AND_OBJECTS +#ifndef FIX_672_NOKIA_TODO // Todo OMASA JBM: This might need adjustments +#endif dirac_bs_md_write_idx = st_ivas->hSpatParamRendCom->dirac_bs_md_write_idx; /* Store the write-index for this frame */ #endif ivas_qmetadata_to_dirac( hQMetaData, st_ivas->hDirAC, hMasa, st_ivas->hSpatParamRendCom, ivas_total_brate, ivas_format, 0, 0 ); @@ -500,7 +525,9 @@ ivas_error ivas_masa_decode( { for ( block = 0; block < MAX_PARAM_SPATIAL_SUBFRAMES; block++ ) { +#ifndef FIX_672_NOKIA_TODO // Todo OMASA JBM: This might need adjustments +#endif meta_write_index = ( dirac_bs_md_write_idx + block ) % st_ivas->hSpatParamRendCom->dirac_md_buffer_length; for ( b = 0; b < st_ivas->hSpatParamRendCom->num_freq_bands; b++ ) @@ -1408,7 +1435,9 @@ ivas_error ivas_masa_dec_reconfigure( sts = st_ivas->hCPE[cpe_id]->hCoreCoder; sts[0]->bit_stream = bit_stream + num_bits; num_bits += (int16_t) ( st_ivas->hCPE[cpe_id]->element_brate / FRAMES_PER_SEC ); +#ifndef FIX_672_NOKIA_TODO /* Todo: Nokia make for MASA_ISM*/ +#endif if ( ( ivas_total_brate < MASA_STEREO_MIN_BITRATE && last_ivas_total_brate >= MASA_STEREO_MIN_BITRATE ) || ( ivas_total_brate < MASA_STEREO_MIN_BITRATE && last_ivas_total_brate == FRAME_NO_DATA ) ) { @@ -1658,7 +1687,11 @@ void ivas_spar_param_to_masa_param_mapping( #endif hSpatParamRendCom->numSimultaneousDirections = 1; #ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN +#ifdef FIX_672_NOKIA_TODO + hDiffuseDist = st_ivas->hDiracDecBin[0]->hDiffuseDist; +#else hDiffuseDist = st_ivas->hDiracDecBin[0]->hDiffuseDist; /* TODO: this may need to use different pose indices */ +#endif #else hDiffuseDist = st_ivas->hDiracDecBin->hDiffuseDist; #endif @@ -2033,7 +2066,9 @@ static void create_masa_ext_out_meta( } #ifdef MASA_AND_OBJECTS +#ifndef FIX_672_NOKIA_TODO // Todo OMASA JBM: There is a lot of metadata access here via dirac indices, they could be wrong post JBM. +#endif static void decode_index_slice( int16_t index, /* i : index to decode */ int16_t *ratio_idx_ism, /* o : decodec array of integers */ @@ -2358,9 +2393,13 @@ static void read_ism_ratio_index( static void decode_ism_ratios( - uint16_t *bit_stream, /* i : bitstream */ - int16_t *next_bit_pos, /* i/o: position in bitstream */ - IVAS_QMETADATA_HANDLE hQMetaData, /* i : Metadata handle */ + uint16_t *bit_stream, /* i : bitstream */ + int16_t *next_bit_pos, /* i/o: position in bitstream */ +#ifdef FIX_672_NOKIA_TODO + float masa_to_total_energy_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i: masa_to_total energy ratios */ +#else + IVAS_QMETADATA_HANDLE hQMetaData, /* i : Metadata handle */ +#endif float ratio_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], /* o : ISM ratios */ const int16_t n_ism, /* i : number of objects */ const int16_t nbands, /* i : number of subbands */ @@ -2379,8 +2418,11 @@ static void decode_ism_ratios( for ( sf = 0; sf < numSf; sf++ ) { /* read ism ratio indexes */ +#ifdef FIX_672_NOKIA_TODO + read_ism_ratio_index( ratio_ism_idx, n_ism, nbands, sf, ratio_ism_idx_prev_sf, bit_stream, next_bit_pos, masa_to_total_energy_ratio[sf], idx_separated_object, &num_zeros ); +#else read_ism_ratio_index( ratio_ism_idx, n_ism, nbands, sf, ratio_ism_idx_prev_sf, bit_stream, next_bit_pos, hQMetaData->masa_to_total_energy_ratio[sf], idx_separated_object, &num_zeros ); - +#endif /* save previous subframe index values */ if ( sf < numSf - 1 ) { @@ -2401,7 +2443,11 @@ static void decode_ism_ratios( /* rotate */ for ( band = 0; band < nbands; band++ ) { +#ifdef FIX_672_NOKIA_TODO + if ( masa_to_total_energy_ratio[sf][band] < MASA2TOTAL_THR ) +#else if ( hQMetaData->masa_to_total_energy_ratio[sf][band] < MASA2TOTAL_THR ) +#endif { tmp = ratio_ism[sf][band][n_ism - 1]; ratio_ism[sf][band][n_ism - 1] = ratio_ism[sf][band][0]; @@ -2462,11 +2508,19 @@ static int16_t ivas_decode_masaism_metadata( nblocks = hQMetaData->q_direction->cfg.nblocks; /* Read MASA-to-total energy ratios */ +#ifdef FIX_672_NOKIA_TODO + ivas_omasa_decode_masa_to_total( bit_stream, next_bit_pos, hMasaIsmData->masa_to_total_energy_ratio, nbands, nblocks ); +#else ivas_omasa_decode_masa_to_total( bit_stream, next_bit_pos, hQMetaData->masa_to_total_energy_ratio, nbands, nblocks ); +#endif if ( nchan_ism > 1 ) { /* read ISM ratios */ +#ifdef FIX_672_NOKIA_TODO + decode_ism_ratios( bit_stream, next_bit_pos, hMasaIsmData->masa_to_total_energy_ratio, energy_ratio_ism, nchan_ism, nbands, nblocks, idx_separated_object ); +#else decode_ism_ratios( bit_stream, next_bit_pos, hQMetaData, energy_ratio_ism, nchan_ism, nbands, nblocks, idx_separated_object ); +#endif } else { @@ -2480,8 +2534,11 @@ static int16_t ivas_decode_masaism_metadata( } /* read ISM metadata */ +#ifdef FIX_672_NOKIA_TODO + calculate_nbits_meta( nchan_ism, energy_ratio_ism, hMasaIsmData->masa_to_total_energy_ratio, nblocks, nbands, bits_ism, idx_separated_object, ism_imp ); +#else calculate_nbits_meta( nchan_ism, energy_ratio_ism, hQMetaData->masa_to_total_energy_ratio, nblocks, nbands, bits_ism, idx_separated_object, ism_imp ); - +#endif for ( obj = 0; obj < nchan_ism; obj++ ) { index = 0; @@ -2547,7 +2604,11 @@ static int16_t ivas_decode_masaism_metadata( { for ( dir = 0; dir < nchan_ism; dir++ ) { +#ifdef FIX_672_NOKIA_TODO + energy_ratio_ism[sf][band][dir] *= ( 1.0f - hMasaIsmData->masa_to_total_energy_ratio[sf][band] ); +#else energy_ratio_ism[sf][band][dir] *= ( 1.0f - hQMetaData->masa_to_total_energy_ratio[sf][band] ); +#endif } } } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 1defa26d393367b67ef3ba3c10cf20b23cc8c4b8..c785ecff98a2c8d149e9de5682b261249061bbaa 100755 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -858,6 +858,9 @@ typedef struct ivas_masa_ism_data_structure int16_t azimuth_ism[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; int16_t elevation_ism[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; float energy_ratio_ism[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR][CLDFB_NO_CHANNELS_MAX]; +#ifdef FIX_672_NOKIA_TODO + float masa_to_total_energy_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; +#endif int16_t azimuth_ism_edited[MAX_NUM_OBJECTS]; int16_t elevation_ism_edited[MAX_NUM_OBJECTS]; diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index e9ab1849b14a66b2bf093e5553c6a8023c00a9c7..93dc83e83cc493fdf2553cd4fb404694df55c8f7 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -626,12 +626,12 @@ ivas_error ivas_init_encoder( { return error; } - +#ifndef FIX_672_NOKIA_TODO for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { set_f( st_ivas->hQMetaData->masa_to_total_energy_ratio[i], 0, MASA_FREQUENCY_BANDS ); } - +#endif if ( ( error = ivas_masa_enc_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; diff --git a/lib_enc/ivas_masa_enc.c b/lib_enc/ivas_masa_enc.c index d41711b81f6c04e47286a6322ba155a5a72dc8dd..cbc5b145728e9ac00d57e2486a5d140be9826e04 100644 --- a/lib_enc/ivas_masa_enc.c +++ b/lib_enc/ivas_masa_enc.c @@ -188,7 +188,12 @@ ivas_error ivas_masa_enc_open( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for OMASA data encoder\n" ) ); } - +#ifdef FIX_672_NOKIA_TODO + for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) + { + set_f( hOmasaData->masa_to_total_energy_ratio[i], 0, MASA_FREQUENCY_BANDS ); + } +#endif hOmasaData->lp_noise_CPE = -1; hOmasaData->omasa_stereo_sw_cnt = OMASA_STEREO_SW_CNT_MAX; @@ -500,10 +505,27 @@ ivas_error ivas_masa_encode( } #endif +#ifdef FIX_672_NOKIA_TODO + if ( ivas_format == MASA_ISM_FORMAT && ism_mode == ISM_MODE_NONE ) + { + /* signal MASA_ISM_FORMAT to decoder */ + push_next_indice( hMetaData, 1, 1 ); + /* write reserved bit */ + push_next_indice( hMetaData, 0, MASA_HEADER_BITS - 1 ); + hQMetaData->metadata_max_bits -= MASA_HEADER_BITS; + } + else + { + /* the MASA_ISM_FORMAT is not signalled here */ + /* write reserved bits */ + push_next_indice( hMetaData, 0, MASA_HEADER_BITS ); + hQMetaData->metadata_max_bits -= MASA_HEADER_BITS; + } +#else /* write placeholder data for descriptive metadata */ push_next_indice( hMetaData, 0, MASA_HEADER_BITS ); hQMetaData->metadata_max_bits -= MASA_HEADER_BITS; - +#endif /* write number of directions */ push_next_indice( hMetaData, hQMetaData->no_directions - 1, 1 ); hQMetaData->metadata_max_bits -= 1; @@ -555,7 +577,14 @@ ivas_error ivas_masa_encode( } else { +#ifdef FIX_672_NOKIA_TODO + if ( ivas_format == MASA_ISM_FORMAT ) + { + hMasa->data.hOmasaData->masa_to_total_energy_ratio[0][0] = -1; /* signals NOT to adjust the energy ratios */ + } +#else hQMetaData->masa_to_total_energy_ratio[0][0] = -1; /* signals NOT to adjust the energy ratios */ +#endif } #endif @@ -600,7 +629,11 @@ ivas_error ivas_masa_encode( if ( ivas_format == MASA_ISM_FORMAT && ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) { /* Modify spatial metadata based on the MASA-to-total energy ratios */ +#ifdef FIX_672_NOKIA_TODO + ivas_omasa_modify_masa_energy_ratios( hQMetaData, hMasa->data.hOmasaData->masa_to_total_energy_ratio ); +#else ivas_omasa_modify_masa_energy_ratios( hQMetaData ); +#endif } #endif @@ -2740,10 +2773,14 @@ void ivas_merge_masa_metadata( float energyTimesRatioISM; float energyTimesRatioMASA[2]; float total_diff_nrg; +#ifndef FIX_672_NOKIA_TODO int16_t brange[2]; +#endif float eneBand; float energyMerged[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; +#ifndef FIX_672_NOKIA_TODO int16_t bin; +#endif numCodingBands = hMasa->config.numCodingBands; numDirections = hMasa->config.numberOfDirections; @@ -2757,9 +2794,11 @@ void ivas_merge_masa_metadata( int16_t merge_dest; float dir_sum; uint8_t band_n_dirs; +#ifndef FIX_672_NOKIA_TODO brange[0] = band; brange[1] = band + 1; /* TODO: if this stays, remove the unnecessary range loop from the code */ +#endif if ( numDirections == 1 || ( numDirections == 2 && hMasa->data.twoDirBands[band] == 0 ) ) { band_n_dirs = 1; @@ -2770,12 +2809,16 @@ void ivas_merge_masa_metadata( } /* Compute energies */ +#ifdef FIX_672_NOKIA_TODO + eneBand = hMasa->data.energy[sf][band]; +#else /* MASA energy is in the full 24 band resolution, whereas the ISM energy is already in the coding band resolution */ eneBand = 0.0f; for ( bin = brange[0]; bin < brange[1]; bin++ ) { eneBand += hMasa->data.energy[sf][bin]; } +#endif energyMerged[sf][band] = eneBand + hMasa->data.hOmasaData->energy_ism[sf][band]; /* Compute weights */ @@ -2816,7 +2859,7 @@ void ivas_merge_masa_metadata( hMeta->directional_meta[merge_dest].energy_ratio[sf][band] = min( dir_sum, hOMasaMeta->directional_meta[0].energy_ratio[sf][band] ); /* clip with original ISM dir */ hMeta->common_meta.diffuse_to_total_ratio[sf][band] = 1.0f - hMeta->directional_meta[merge_dest].energy_ratio[sf][band]; - if ( hMasa->config.useCoherence ) /* TODO: is this correct condition? */ + if ( hMasa->config.useCoherence ) { hMeta->directional_meta[merge_dest].spread_coherence[sf][band] = hOMasaMeta->directional_meta[0].spread_coherence[sf][band]; hMeta->common_meta.surround_coherence[sf][band] = hOMasaMeta->common_meta.surround_coherence[sf][band]; @@ -3548,7 +3591,11 @@ static void ivas_encode_masaism_metadata( { if ( sum_f( hOmasaData->energy_ism[sf], omasa_nbands ) == 0.0f ) { +#ifdef FIX_672_NOKIA_TODO + hOmasaData->masa_to_total_energy_ratio[sf][0] = 1.0f; +#else hQMetaData->masa_to_total_energy_ratio[sf][0] = 1.0f; +#endif } else { @@ -3579,7 +3626,11 @@ static void ivas_encode_masaism_metadata( { hOmasaData->energy_ratio_ism[sf][0][obj] = energy_ism_ind[obj] / energy_ism; } +#ifdef FIX_672_NOKIA_TODO + hOmasaData->masa_to_total_energy_ratio[sf][0] = eneBand / ( eneBand + energy_ism + EPSILON ); +#else hQMetaData->masa_to_total_energy_ratio[sf][0] = eneBand / ( eneBand + energy_ism + EPSILON ); +#endif } } } @@ -3614,7 +3665,11 @@ static void ivas_encode_masaism_metadata( if ( energy_ism == 0.0f ) { +#ifdef FIX_672_NOKIA_TODO + hOmasaData->masa_to_total_energy_ratio[0][band] = 1.0f; +#else hQMetaData->masa_to_total_energy_ratio[0][band] = 1.0f; +#endif } else { @@ -3633,13 +3688,21 @@ static void ivas_encode_masaism_metadata( eneBand += hMasa->data.energy[sf][bin]; } } +#ifdef FIX_672_NOKIA_TODO + hOmasaData->masa_to_total_energy_ratio[0][band] = eneBand / ( eneBand + energy_ism + EPSILON ); +#else hQMetaData->masa_to_total_energy_ratio[0][band] = eneBand / ( eneBand + energy_ism + EPSILON ); +#endif } } #ifdef FIX_675_WB_OMASA for ( band = nbands_work; band < numCodingBands; band++ ) { +#ifdef FIX_672_NOKIA_TODO + hOmasaData->masa_to_total_energy_ratio[0][band] = 1.0f; +#else hQMetaData->masa_to_total_energy_ratio[0][band] = 1.0f; +#endif for ( obj = 0; obj < nchan_ism; obj++ ) { @@ -3660,7 +3723,11 @@ static void ivas_encode_masaism_metadata( { if ( hOmasaData->energy_ism[sf][band] == 0.0f ) { +#ifdef FIX_672_NOKIA_TODO + hOmasaData->masa_to_total_energy_ratio[sf][band] = 1.0f; +#else hQMetaData->masa_to_total_energy_ratio[sf][band] = 1.0f; +#endif } else { @@ -3672,13 +3739,21 @@ static void ivas_encode_masaism_metadata( { eneBand += hMasa->data.energy[sf][bin]; } +#ifdef FIX_672_NOKIA_TODO + hOmasaData->masa_to_total_energy_ratio[sf][band] = eneBand / ( eneBand + hOmasaData->energy_ism[sf][band] + EPSILON ); +#else hQMetaData->masa_to_total_energy_ratio[sf][band] = eneBand / ( eneBand + hOmasaData->energy_ism[sf][band] + EPSILON ); +#endif } } #ifdef FIX_675_WB_OMASA for ( band = nbands_work; band < numCodingBands; band++ ) { +#ifdef FIX_672_NOKIA_TODO + hOmasaData->masa_to_total_energy_ratio[sf][band] = 1.0f; +#else hQMetaData->masa_to_total_energy_ratio[sf][band] = 1.0f; +#endif for ( obj = 0; obj < nchan_ism; obj++ ) { @@ -3688,8 +3763,11 @@ static void ivas_encode_masaism_metadata( #endif } } - +#ifdef FIX_672_NOKIA_TODO + ivas_omasa_encode_masa_to_total( hOmasaData->masa_to_total_energy_ratio, hMetaData, low_bitrate_mode, numCodingBands, numSf ); +#else ivas_omasa_encode_masa_to_total( hQMetaData, hMetaData, low_bitrate_mode, numCodingBands, numSf ); +#endif /* quantize ism_ratios */ if ( nchan_ism > 1 ) @@ -3711,9 +3789,16 @@ static void ivas_encode_masaism_metadata( } /* Quantize ISM ratios */ +#ifdef FIX_672_NOKIA_TODO + quantize_ratio_ism_vector( ratio_ism[band], ratio_ism_idx[band], nchan_ism, hOmasaData->masa_to_total_energy_ratio[sf][band], idx_separated_object ); +#else quantize_ratio_ism_vector( ratio_ism[band], ratio_ism_idx[band], nchan_ism, hQMetaData->masa_to_total_energy_ratio[sf][band], idx_separated_object ); - +#endif +#ifdef FIX_672_NOKIA_TODO + if ( n_ism_tmp == numCodingBands && ratio_ism_idx[band][idx_separated_object] != 0 && hOmasaData->masa_to_total_energy_ratio[sf][band] < MASA2TOTAL_THR ) +#else if ( n_ism_tmp == numCodingBands && ratio_ism_idx[band][idx_separated_object] != 0 && hQMetaData->masa_to_total_energy_ratio[sf][band] < MASA2TOTAL_THR ) +#endif { i = 0; while ( ratio_ism_idx[band][idx_separated_object] > 0 ) @@ -3741,7 +3826,11 @@ static void ivas_encode_masaism_metadata( rotate = 1; for ( band = 0; band < numCodingBands; band++ ) { +#ifdef FIX_672_NOKIA_TODO + if ( hOmasaData->masa_to_total_energy_ratio[sf][band] < MASA2TOTAL_THR ) +#else if ( hQMetaData->masa_to_total_energy_ratio[sf][band] < MASA2TOTAL_THR ) +#endif { tmp = ratio_ism_idx[band][nchan_ism - 1]; ratio_ism_idx[band][nchan_ism - 1] = ratio_ism_idx[band][0]; @@ -3764,7 +3853,11 @@ static void ivas_encode_masaism_metadata( { for ( band = 0; band < numCodingBands; band++ ) { +#ifdef FIX_672_NOKIA_TODO + if ( hOmasaData->masa_to_total_energy_ratio[sf][band] < MASA2TOTAL_THR ) +#else if ( hQMetaData->masa_to_total_energy_ratio[sf][band] < MASA2TOTAL_THR ) +#endif { if ( ratio_ism_idx[band][idx_separated_object] == 0 && sf == 0 ) { @@ -3778,11 +3871,19 @@ static void ivas_encode_masaism_metadata( /* encode data for current subframe */ if ( sf > 0 && n_ism_tmp == numCodingBands ) { +#ifdef FIX_672_NOKIA_TODO + encode_ratio_ism_subframe( ratio_ism_idx, nchan_ism, numCodingBands, sf, ratio_ism_idx_prev_sf, hMetaData, hOmasaData->masa_to_total_energy_ratio[sf], 1, idx_separated_object ); +#else encode_ratio_ism_subframe( ratio_ism_idx, nchan_ism, numCodingBands, sf, ratio_ism_idx_prev_sf, hMetaData, hQMetaData->masa_to_total_energy_ratio[sf], 1, idx_separated_object ); +#endif } else { +#ifdef FIX_672_NOKIA_TODO + encode_ratio_ism_subframe( ratio_ism_idx, nchan_ism, numCodingBands, sf, ratio_ism_idx_prev_sf, hMetaData, hOmasaData->masa_to_total_energy_ratio[sf], 0, idx_separated_object ); +#else encode_ratio_ism_subframe( ratio_ism_idx, nchan_ism, numCodingBands, sf, ratio_ism_idx_prev_sf, hMetaData, hQMetaData->masa_to_total_energy_ratio[sf], 0, idx_separated_object ); +#endif } /* calculate quantized ISM ratios */ @@ -3796,7 +3897,11 @@ static void ivas_encode_masaism_metadata( { for ( band = 0; band < numCodingBands; band++ ) { +#ifdef FIX_672_NOKIA_TODO + if ( hOmasaData->masa_to_total_energy_ratio[sf][band] < MASA2TOTAL_THR ) +#else if ( hQMetaData->masa_to_total_energy_ratio[sf][band] < MASA2TOTAL_THR ) +#endif { tmp = ratio_ism_idx[band][nchan_ism - 1]; ratio_ism_idx[band][nchan_ism - 1] = ratio_ism_idx[band][0]; @@ -3806,9 +3911,11 @@ static void ivas_encode_masaism_metadata( } } } - +#ifdef FIX_672_NOKIA_TODO + calculate_nbits_meta( nchan_ism, hOmasaData->q_energy_ratio_ism, hOmasaData->masa_to_total_energy_ratio, numSf, numCodingBands, bits_ism, idx_separated_object, ism_imp ); +#else calculate_nbits_meta( nchan_ism, hOmasaData->q_energy_ratio_ism, hQMetaData->masa_to_total_energy_ratio, numSf, numCodingBands, bits_ism, idx_separated_object, ism_imp ); - +#endif /* quantize directions */ for ( obj = 0; obj < nchan_ism; obj++ ) { diff --git a/lib_enc/ivas_omasa_enc.c b/lib_enc/ivas_omasa_enc.c index 4d013c623a54681bb942ccc923546c75c50243c8..3006a0d6eb7a14f967ef191230a322607e031d19 100644 --- a/lib_enc/ivas_omasa_enc.c +++ b/lib_enc/ivas_omasa_enc.c @@ -523,7 +523,7 @@ void ivas_omasa_enc( uint8_t numCodingBands_orig, joinedSubframes_orig; hOMasaMeta = &OMasaMeta; - hOMasaMeta->num_dirs = 1; /* TODO: hard-coding for now */ + hOMasaMeta->num_dirs = 1; /* merge MASA directions before adding ISM to the mixture */ if ( hMasa->config.numberOfDirections == 2 ) diff --git a/lib_enc/ivas_qmetadata_enc.c b/lib_enc/ivas_qmetadata_enc.c index bb89a61995b604aaf975c894c875f0ded4b8797a..176aba8f545f78f1c33a0d1eaa5e5b045bead019 100644 --- a/lib_enc/ivas_qmetadata_enc.c +++ b/lib_enc/ivas_qmetadata_enc.c @@ -6401,7 +6401,11 @@ static int16_t write_stream_dct_coeffs_omasa( *------------------------------------------------------------------------*/ void ivas_omasa_encode_masa_to_total( +#ifdef FIX_672_NOKIA_TODO + float masa_to_total_energy_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], +#else IVAS_QMETADATA_HANDLE hQMetaData, +#endif BSTR_ENC_HANDLE hMetaData, const int16_t low_bitrate_mode, const int16_t nbands, @@ -6434,7 +6438,11 @@ void ivas_omasa_encode_masa_to_total( { for ( j = 0; j < nblocks; j++ ) { +#ifdef FIX_672_NOKIA_TODO + data[k] = masa_to_total_energy_ratio[j][i]; +#else data[k] = hQMetaData->masa_to_total_energy_ratio[j][i]; +#endif k++; } } @@ -6575,8 +6583,13 @@ void ivas_omasa_encode_masa_to_total( { for ( j = 0; j < nbands; j++ ) { +#ifdef FIX_672_NOKIA_TODO + 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] ); +#else hQMetaData->masa_to_total_energy_ratio[i][j] = max( 0.0f, q_dct_data[k] ); hQMetaData->masa_to_total_energy_ratio[i][j] = min( 1.0f, hQMetaData->masa_to_total_energy_ratio[i][j] ); +#endif k++; } } diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index 138e09b5c4f22b262465123de8a6d493ca538d40..91bed51e3ed08d67fd3c29811e929a974cc1f6b0 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -808,6 +808,9 @@ typedef struct ivas_omasa_encoder_one_data_struct float energy_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; float energy_ratio_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS]; float q_energy_ratio_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS]; +#ifdef FIX_672_NOKIA_TODO + float masa_to_total_energy_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; +#endif float lp_noise_CPE; /* LP filtered total noise estimation */ int16_t omasa_stereo_sw_cnt; diff --git a/lib_rend/ivas_dirac_ana.c b/lib_rend/ivas_dirac_ana.c index 6d2b8861bb66a3054d4afed3d2b452e318236a20..a0d1a5ab947dede7a9958f3423f0219fd4e06d0b 100644 --- a/lib_rend/ivas_dirac_ana.c +++ b/lib_rend/ivas_dirac_ana.c @@ -364,7 +364,9 @@ static void ivas_dirac_param_est_ana( energyRatio[block_m_idx][band_m_idx] = 1.0f - diffuseness_m[band_m_idx]; } +#ifndef FIX_672_NOKIA_TODO /* Todo Nokia: Implement coherence analysis */ +#endif for ( band_m_idx = 0; band_m_idx < hDirAC->nbands; band_m_idx++ ) { spreadCoherence[block_m_idx][band_m_idx] = 0.0f; diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 2b882468eb60f5526ba8a2a33f3c348f80d9d608..c93296e289e13d7ee838e53c6411ea5c72f87632 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -1106,8 +1106,10 @@ static void ivas_dirac_dec_binaural_internal( /* update this counter only after the last rendering of split directions */ #endif +#ifndef FIX_672_NOKIA_TODO #ifdef MASA_AND_OBJECTS // Todo OMASA JBM: This change could have some side effects +#endif #endif hSpatParamRendCom->slots_rendered += hSpatParamRendCom->subframe_nbslots[subframe]; hSpatParamRendCom->subframes_rendered++; @@ -2466,7 +2468,11 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices( if ( ivas_format == MASA_ISM_FORMAT ) { +#ifdef FIX_672_NOKIA_TODO + gainFactor = 0.7943f * sqrtf( hDiracDecBin->earlyPartEneCorrection[bin] ); +#else gainFactor = 0.7943f * sqrtf( hDiracDecBin->earlyPartEneCorrection[bin] ); /* Todo Nokia: Temporary gain for roughly matching the loudness of other processing paths. */ +#endif } else { @@ -3485,7 +3491,9 @@ float configure_reqularization_factor( * *-------------------------------------------------------------------*/ +#ifndef FIX_672_NOKIA_TODO // Todo OMASA JBM: This might need further adjustments +#endif void ivas_omasa_preProcessStereoTransportsForMovedObjects( Decoder_Struct *st_ivas, float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], @@ -3530,7 +3538,9 @@ void ivas_omasa_preProcessStereoTransportsForMovedObjects( } /* Perform object-movement based processing */ +#ifndef FIX_672_NOKIA_TODO // Todo OMASA JBM: Fixed but might be still wrong somehow +#endif nSlots = hSpatParamRendCom->subframe_nbslots[subframe]; dirac_read_idx = hSpatParamRendCom->render_to_md_map[subframe]; diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index b4b9f71e01faa77eab644621e20e4e7f9ff0110a..ff81b05264a866a0def00f64ec78270122f85109 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -1361,8 +1361,10 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls( indexFast = min( l, alphaMaxBinFast ); /* Estimate the smoothness of the directions based on the diffuseness parameter */ +#ifndef FIX_672_NOKIA_TODO /* TODO: check this, seems buggy in the case of parame estim on the decoder side, because the pointer here points already to the following subframe, ist this intended?*/ +#endif instDirectionSmoothness = 1.0f - diffuseness_vector[l]; instDirectionSmoothness = min( max( instDirectionSmoothness, 0.0f ), 1.0f );