diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index f20fd0ab8859890a26173579c5641624c0ae09d6..cb7a67a2b1a2f91e55076b2a73bc1b55a3d06718 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -1826,14 +1826,15 @@ void stereo_tdm_prep_dwnmx ( const float *input1, /* i : right channel input */ const int16_t input_frame /* i : frame lenght */ ); + int16_t stereo_tdm_ener_analysis( +#ifdef OMASA_TUNING_TD_STEREO + const int16_t ivas_format, /* i : IVAS format */ +#endif CPE_ENC_HANDLE hCPE, /* i : CPE structure */ const int16_t input_frame, /* i : Number of samples */ int16_t *tdm_SM_or_LRTD_Pri, /* o : channel combination scheme flag in TD stereo OR LRTD primary channel */ int16_t *tdm_ratio_idx_SM /* o : TDM ratio index for SM mode */ -#ifdef OMASA_TUNING_TD_STEREO - ,const int16_t isOmasa /* i : flag that indicates OMASA format */ -#endif ); void stereo_tdm_downmix( @@ -1852,13 +1853,12 @@ void stereo_td_init_dec( ); void tdm_configure_dec( +#ifdef OMASA_TUNING_TD_STEREO + const int16_t ivas_format, /* i : IVAS format */ +#endif CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ int16_t *tdm_ratio_idx, /* o : ratio index */ const int16_t nb_bits_metadata /* i : number of metadata bits */ -#ifdef OMASA_TUNING_TD_STEREO - ,const int16_t IsOmasa /* i : flag that indicates OMASA format */ -#endif - ); void tdm_upmix_plain( @@ -1905,6 +1905,9 @@ void tdm_ol_pitch_comparison( ); void tdm_configure_enc( +#ifdef OMASA_TUNING_TD_STEREO + const int16_t ivas_format, /* i : IVAS format */ +#endif CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */ const float Etot_last[CPE_CHANNELS], /* i/o: Energy of last frame */ const int16_t tdm_SM_or_LRTD_Pri, /* i : channel combination scheme flag in TD stereo OR LRTD primary channel */ @@ -1912,9 +1915,6 @@ void tdm_configure_enc( const int16_t tdm_ratio_idx_SM, /* i : ratio index in SM mode */ const int16_t attack_flag, /* i : Primary channel attack flag */ const int16_t nb_bits_metadata /* i : number of metadata bits */ -#ifdef OMASA_TUNING_TD_STEREO - ,const int16_t IsOmasa /* i : flag that indicates OMASA format */ -#endif ); ivas_error signaling_enc_secondary( @@ -1924,6 +1924,9 @@ ivas_error signaling_enc_secondary( ); void tdm_bit_alloc( +#ifdef OMASA_TUNING_TD_STEREO + const int16_t ivas_format, /* i : IVAS format */ +#endif const int32_t element_brate_wo_meta, /* i : element bitrate without metadata */ const int16_t tdm_lp_reuse_flag, /* i : LPC reusage flag */ int32_t *total_brate_pri, /* o : Allocated primary channel bitrate */ @@ -1938,9 +1941,6 @@ void tdm_bit_alloc( const int16_t tdm_LRTD_flag, /* i : LRTD stereo mode flag */ const int16_t coder_type0, /* i : coder type (temporary in the encoder, from bitstream in decoder) */ const int16_t tdm_inst_ratio_idx /* i : instantaneous correlation ratio index */ -#ifdef OMASA_TUNING_TD_STEREO - ,const int16_t IsOmasa /* i : flag that indicates OMASA format */ -#endif ); void td_stereo_param_updt( diff --git a/lib_com/ivas_stereo_td_bit_alloc.c b/lib_com/ivas_stereo_td_bit_alloc.c index ac56cd65377c768b6f02308ea67e65b5b162cc03..48c5eaf8ae5a463474d480075e22369b2580147d 100644 --- a/lib_com/ivas_stereo_td_bit_alloc.c +++ b/lib_com/ivas_stereo_td_bit_alloc.c @@ -74,6 +74,9 @@ *-------------------------------------------------------------------*/ void tdm_bit_alloc( +#ifdef OMASA_TUNING_TD_STEREO + const int16_t ivas_format, /* i : IVAS format */ +#endif const int32_t element_brate_wo_meta, /* i : element bitrate without metadata */ const int16_t tdm_lp_reuse_flag, /* i : LPC reusage flag */ int32_t *total_brate_pri, /* o : Allocated primary channel bitrate */ @@ -88,10 +91,6 @@ void tdm_bit_alloc( const int16_t tdm_LRTD_flag, /* i : LRTD stereo mode flag */ const int16_t coder_type0, /* i : coder type (temporary in the encoder, from bitstream in decoder) */ const int16_t tdm_inst_ratio_idx_ref /* i : instantaneous correlation ratio idx */ -#ifdef OMASA_TUNING_TD_STEREO - , - const int16_t IsOmasa /* i : flag that indicates OMASA format */ -#endif ) { int16_t idx, four_subfr_fcb, two_subfr_fcb; @@ -141,7 +140,7 @@ void tdm_bit_alloc( /* secondary channel bitrate allocation based on the energy scaling ratio */ #ifdef OMASA_TUNING_TD_STEREO - if ( ( IsOmasa == 0 && ( ( coder_type != UNVOICED ) || tdm_LRTD_flag == 1 ) ) || ( IsOmasa == 1 && coder_type > UNVOICED ) ) + if ( ( ivas_format != MASA_ISM_FORMAT && ( ( coder_type != UNVOICED ) || tdm_LRTD_flag == 1 ) ) || ( ivas_format == MASA_ISM_FORMAT && coder_type > UNVOICED ) ) #else if ( ( coder_type != UNVOICED ) || tdm_LRTD_flag == 1 ) #endif diff --git a/lib_com/options.h b/lib_com/options.h index 8d94dd3c1e6f9253c199509aa6693dcb95a362d5..767b2c4a1f5c1bd5c94992af1aa809027e3c3c75 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -60,11 +60,11 @@ /*#define DEBUG_MODE_INFO*/ /* output most important parameters to the subdirectory "res/" */ #ifdef DEBUG_MODE_INFO -#define DEBUG_MODE_ACELP /* output most important ACELP core parameters to the subdirectory "res/" */ +/*#define DEBUG_MODE_ACELP*/ /* output most important ACELP core parameters to the subdirectory "res/" */ /*#define DEBUG_MODE_TCX*/ /* output most important TCX core parameters to the subdirectory "res/" */ -/*#define DEBUG_MODE_DFT */ /* output most important DFT stereo parameters to the subdirectory "res/" */ -#define DEBUG_MODE_TD /* output most important TD stereo parameters to the subdirectory "res/ */ -//#define DEBUG_MODE_DIRAC /* output most important DIRAC parameters to the subdirectory "res/" */ +/*#define DEBUG_MODE_DFT */ /* output most important DFT stereo parameters to the subdirectory "res/" */ +/*#define DEBUG_MODE_TD*/ /* output most important TD stereo parameters to the subdirectory "res/ */ +/*#define DEBUG_MODE_DIRAC*/ /* output most important DIRAC parameters to the subdirectory "res/" */ /*#define DEBUG_MODE_MDCT*/ /* output most important MDCT parameters to the subdirectory "res/" */ /*#define DEBUG_MODE_PARAM_MC */ /* output Parametric MC paramters to the subdirectory "res/" */ /*#define DEBUG_MODE_PARAM_ISM*/ /* output Parametric ISM paramters to the subdirectory "res/" */ diff --git a/lib_dec/ivas_cpe_dec.c b/lib_dec/ivas_cpe_dec.c index f78f5f08c86e8f660b8cb964084f169249d2e26b..74f22590adda8536f2a3091905f3ef7c31082701 100755 --- a/lib_dec/ivas_cpe_dec.c +++ b/lib_dec/ivas_cpe_dec.c @@ -413,12 +413,11 @@ ivas_error ivas_cpe_dec( { if ( !st_ivas->bfi ) { - tdm_configure_dec( hCPE, &tdm_ratio_idx, nb_bits_metadata + tdm_configure_dec( #ifdef OMASA_TUNING_TD_STEREO - , - ( st_ivas->ivas_format == MASA_ISM_FORMAT || ( st_ivas->ivas_format == MASA_FORMAT && st_ivas->hDecoderConfig->ivas_total_brate == IVAS_24k4 ) ) + st_ivas->ivas_format, #endif - ); + hCPE, &tdm_ratio_idx, nb_bits_metadata ); sts[1]->bit_stream = sts[0]->bit_stream + ( sts[0]->total_brate / FRAMES_PER_SEC ); } @@ -597,12 +596,14 @@ ivas_error ivas_cpe_dec( dbgwrite( output[j], sizeof( float ), output_frame, 1, fname( debug_dir, "output.cpe", j, cpe_id, DEC ) ); } +#ifdef MASA_AND_OBJECTS if ( st_ivas->ivas_format != MASA_ISM_FORMAT ) { tmpF = 0; dbgwrite( &tmpF, sizeof( float ), 1, output_frame, fname( debug_dir, "output.sce", 0, cpe_id, DEC ) ); dbgwrite( &tmpF, sizeof( float ), 1, output_frame, fname( debug_dir, "output.mct", 0, cpe_id, DEC ) ); } +#endif } } #endif diff --git a/lib_dec/ivas_dirac_output_synthesis_dec.c b/lib_dec/ivas_dirac_output_synthesis_dec.c index e1379628110a3af60c5771bced7d0b9997a64fcd..0bb09f7c2a8e40dbdb1e5305c4b92432ddaa38e8 100644 --- a/lib_dec/ivas_dirac_output_synthesis_dec.c +++ b/lib_dec/ivas_dirac_output_synthesis_dec.c @@ -1526,6 +1526,7 @@ void ivas_dirac_dec_compute_directional_responses( num_channels_dir = hDirAC->num_outputs_dir; azimuth = hDirAC->azimuth[hDirAC->dirac_read_idx]; elevation = hDirAC->elevation[hDirAC->dirac_read_idx]; + #ifdef MASA_AND_OBJECTS if ( hDirAC->numParametricDirections == 2 ) #else diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index c91b31b28865976dc31578ab0916333bc07c02d0..20bd5c18f9f0d1a9248bb1a671b1d218db139fdb 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -119,6 +119,8 @@ ivas_error ivas_masa_decode( int16_t i, ch, ism_imp; #ifdef FIX_OMASA_DELAY_COMP int16_t dirac_bs_md_write_idx; + + dirac_bs_md_write_idx = 0; #endif ism_imp = 0; #endif @@ -1566,6 +1568,9 @@ void ivas_spar_param_to_masa_param_mapping( /* Set values */ hDirAC = st_ivas->hDirAC; +#ifdef MASA_AND_OBJECTS + hDirAC->numParametricDirections = 1; +#endif hDirAC->numSimultaneousDirections = 1; hDiffuseDist = st_ivas->hDirAC->hDiffuseDist; nchan_transport = st_ivas->nchan_transport; diff --git a/lib_dec/ivas_sce_dec.c b/lib_dec/ivas_sce_dec.c index ccb5fcca897687c9b335b3e2ef6036b86fe6c40b..dc44097d9d731606fb46aa5ef962d33baae40229 100755 --- a/lib_dec/ivas_sce_dec.c +++ b/lib_dec/ivas_sce_dec.c @@ -326,12 +326,14 @@ ivas_error ivas_sce_dec( dbgwrite( output, sizeof( float ), output_frame, 1, fname( debug_dir, "output.sce", 0, sce_id, DEC ) ); +#ifdef MASA_AND_OBJECTS if ( st_ivas->ivas_format != MASA_ISM_FORMAT ) { tmpF = 0; dbgwrite( &tmpF, sizeof( float ), 1, output_frame, fname( debug_dir, "output.cpe", 0, sce_id, DEC ) ); dbgwrite( &tmpF, sizeof( float ), 1, output_frame, fname( debug_dir, "output.mct", 0, sce_id, DEC ) ); } +#endif } } #endif diff --git a/lib_dec/ivas_stereo_td_dec.c b/lib_dec/ivas_stereo_td_dec.c index e613e8ea2e8dd96bda26f5a30bb8ef4a1392a2a5..d8e817638a0e2fabf432d7a4db044baa2ddfcb7d 100644 --- a/lib_dec/ivas_stereo_td_dec.c +++ b/lib_dec/ivas_stereo_td_dec.c @@ -84,14 +84,12 @@ void stereo_td_init_dec( *-------------------------------------------------------------------*/ void tdm_configure_dec( +#ifdef OMASA_TUNING_TD_STEREO + const int16_t ivas_format, /* i : IVAS format */ +#endif CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ int16_t *tdm_ratio_idx, /* o : ratio index */ const int16_t nb_bits_metadata /* i : number of metadata bits */ -#ifdef OMASA_TUNING_TD_STEREO - , - const int16_t IsOmasa /* i : flag that indicates OMASA format*/ -#endif - ) { STEREO_TD_DEC_DATA_HANDLE hStereoTD; @@ -291,7 +289,7 @@ void tdm_configure_dec( /* set the BW of the secondary channel */ #ifdef MASA_AND_OBJECTS - if ( hStereoTD->tdm_LRTD_flag && sts[1]->bits_frame_channel > IVAS_16k4 / FRAMES_PER_SEC ) + if ( hStereoTD->tdm_LRTD_flag && sts[1]->bits_frame_channel >= IVAS_16k4 / FRAMES_PER_SEC ) #else if ( hStereoTD->tdm_LRTD_flag && hCPE->element_brate > IVAS_13k2 ) #endif @@ -310,15 +308,15 @@ void tdm_configure_dec( *----------------------------------------------------------------*/ #ifdef MASA_AND_OBJECTS - tdm_bit_alloc( hCPE->element_brate - nb_bits_metadata * FRAMES_PER_SEC + hCPE->brate_surplus, - hStereoTD->tdm_lp_reuse_flag, &( sts[0]->total_brate ), &( sts[1]->total_brate ), - &hStereoTD->tdm_low_rate_mode, sts[1]->coder_type, *tdm_ratio_idx, hStereoTD->tdm_Pitch_reuse_flag, - sts[0]->bwidth, sts[1]->bwidth, sts[0]->flag_ACELP16k, hStereoTD->tdm_LRTD_flag, mod_ct, tdm_inst_ratio_idx + tdm_bit_alloc( #ifdef OMASA_TUNING_TD_STEREO - , - IsOmasa + ivas_format, #endif - ); + + hCPE->element_brate - nb_bits_metadata * FRAMES_PER_SEC + hCPE->brate_surplus, + hStereoTD->tdm_lp_reuse_flag, &( sts[0]->total_brate ), &( sts[1]->total_brate ), + &hStereoTD->tdm_low_rate_mode, sts[1]->coder_type, *tdm_ratio_idx, hStereoTD->tdm_Pitch_reuse_flag, + sts[0]->bwidth, sts[1]->bwidth, sts[0]->flag_ACELP16k, hStereoTD->tdm_LRTD_flag, mod_ct, tdm_inst_ratio_idx ); #else tdm_bit_alloc( hCPE->element_brate - nb_bits_metadata * FRAMES_PER_SEC, hStereoTD->tdm_lp_reuse_flag, &( sts[0]->total_brate ), &( sts[1]->total_brate ), &hStereoTD->tdm_low_rate_mode, sts[1]->coder_type, *tdm_ratio_idx, hStereoTD->tdm_Pitch_reuse_flag, sts[0]->bwidth, sts[1]->bwidth, sts[0]->flag_ACELP16k, hStereoTD->tdm_LRTD_flag, mod_ct, tdm_inst_ratio_idx ); #endif diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index bfa7d867567bab7effa86ba17d8c640f49a3c733..48a343bec190af7b78530511654b20a8babd93f2 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -435,12 +435,11 @@ ivas_error ivas_cpe_enc( else if ( hCPE->element_mode == IVAS_CPE_TD ) { /* Determine the energy ratio between the 2 channels */ - tdm_ratio_idx = stereo_tdm_ener_analysis( hCPE, input_frame, &tdm_SM_or_LRTD_Pri, &tdm_ratio_idx_SM + tdm_ratio_idx = stereo_tdm_ener_analysis( #ifdef OMASA_TUNING_TD_STEREO - , - st_ivas->hOMasa != NULL + ivas_format, #endif - ); + hCPE, input_frame, &tdm_SM_or_LRTD_Pri, &tdm_ratio_idx_SM ); /* Compute the downmix signal based on the ratio index */ stereo_tdm_downmix( hCPE->hStereoTD, sts[0]->input, sts[1]->input, input_frame, tdm_ratio_idx, ( ( hCPE->hStereoTD->tdm_LRTD_flag == 0 ) ? tdm_SM_or_LRTD_Pri : 0 ), tdm_ratio_idx_SM ); @@ -606,12 +605,11 @@ ivas_error ivas_cpe_enc( { tdm_ol_pitch_comparison( hCPE, pitch_fr, voicing_fr ); - tdm_configure_enc( hCPE, Etot_last, tdm_SM_or_LRTD_Pri, tdm_ratio_idx, tdm_ratio_idx_SM, attack_flag[0], nb_bits_metadata + tdm_configure_enc( #ifdef OMASA_TUNING_TD_STEREO - , - st_ivas->hOMasa != NULL + ivas_format, #endif - ); + hCPE, Etot_last, tdm_SM_or_LRTD_Pri, tdm_ratio_idx, tdm_ratio_idx_SM, attack_flag[0], nb_bits_metadata ); if ( hEncoderConfig->Opt_DTX_ON ) { diff --git a/lib_enc/ivas_masa_enc.c b/lib_enc/ivas_masa_enc.c index 5e81132ced7dd039b946a76fdb011928bf994010..67c935d187ea9109c73bba70d20653c48196bb63 100644 --- a/lib_enc/ivas_masa_enc.c +++ b/lib_enc/ivas_masa_enc.c @@ -67,20 +67,6 @@ static void reduce_metadata_further( MASA_ENCODER_HANDLE hMasa, IVAS_QMETADATA_H #endif ); -static void quantize_ratio_ism_vector( const float *ratio_ism, int16_t *idx, const int16_t nchan_ism, const float masa_to_total_energy_ratio, const int16_t idx_sep_object ); - -static int16_t index_slice_enum( const int16_t *ratio_ism_idx, const int16_t nchan_ism ); - -static int16_t encode_ratio_ism_subframe( const int16_t ratio_ism_idx[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], const int16_t nchan_ism, const int16_t numCodingBands, const int16_t sf, const int16_t ratio_ism_idx_prev_sf[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], BSTR_ENC_HANDLE hMetaData, const float *masa_to_total_energy_ratio, const int16_t shift_one, const int16_t idx_sep_obj ); - -static void transform_index_and_GR_encode( int16_t *diff_idx, const int16_t len, const int16_t GR_order, BSTR_ENC_HANDLE hMetaData ); - -static void transform_difference_index( const int16_t *diff_idx, int16_t *idx, const int16_t len ); - -static void independent_coding_ratio_ism_idx( const int16_t ratio_ism_idx[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], const float *masa_to_total_energy_ratio, const int16_t nchan_ism, const int16_t numCodingBands, const int16_t bits_index, BSTR_ENC_HANDLE hMetaData ); - -static void remove_sep_obj( int16_t *diff_idx, const int16_t nchan_ism, const int16_t idx_sep_obj ); - #else static void reduce_metadata_further( MASA_ENCODER_HANDLE hMasa, IVAS_QMETADATA_HANDLE hqmetadata, const IVAS_FORMAT ivas_format ); #endif @@ -764,6 +750,7 @@ ivas_error ivas_masa_enc_config( { #ifdef FIX_382_MASA_META_FRAMING_ASYNC detect_framing_async( hMasa ); /* detect the offset, set 1sf/4sf mode based on this. potentially also shift the metadata using a history buffer */ + if ( hMasa->data.sync_state.frame_mode == MASA_FRAME_1SF && hMasa->data.sync_state.prev_offset != 0 ) { /* average over sub-frames */ @@ -2871,7 +2858,7 @@ static void transform_index_and_GR_encode( int16_t *diff_idx, /* i : differenc eindex to encode */ const int16_t len, /* i : input length */ const int16_t GR_order, /* i : GR order */ - BSTR_ENC_HANDLE hMetaData /* i/o: bitstream */ + BSTR_ENC_HANDLE hMetaData /* i/o: metadata bitstream handle */ ) { int16_t i; @@ -2893,7 +2880,7 @@ static void transform_index_and_GR_encode( static int16_t try_differential( const int16_t numCodingBands, const float *masa_to_total_energy_ratio, - const int16_t ratio_ism_idx[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], + int16_t ratio_ism_idx[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], const int16_t nchan_ism, const int16_t bits_index, int16_t *p_b_signif ) @@ -2945,7 +2932,7 @@ static void differential_coding_first_subframe( BSTR_ENC_HANDLE hMetaData, const float *masa_to_total_energy_ratio, const int16_t b_signif, - const int16_t ratio_ism_idx[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], + int16_t ratio_ism_idx[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], const int16_t nchan_ism, const int16_t numCodingBands, const int16_t bits_index ) @@ -2982,12 +2969,12 @@ static void differential_coding_first_subframe( static void independent_coding_ratio_ism_idx( - const int16_t ratio_ism_idx[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], /* i : ISM ratios */ - const float *masa_to_total_energy_ratio, /* i : MASA to total ratios */ - const int16_t nchan_ism, /* i : number of objects */ - const int16_t numCodingBands, /* i : number of subbands */ - const int16_t bits_index, /* i : number of bits per index */ - BSTR_ENC_HANDLE hMetaData /* i/o: bitstream */ + int16_t ratio_ism_idx[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], /* i : ISM ratios */ + const float *masa_to_total_energy_ratio, /* i : MASA to total ratios */ + const int16_t nchan_ism, /* i : number of objects */ + const int16_t numCodingBands, /* i : number of subbands */ + const int16_t bits_index, /* i : number of bits per index */ + BSTR_ENC_HANDLE hMetaData /* i/o: metadata bitstream handle */ ) { int16_t b, index; @@ -3040,14 +3027,16 @@ static void estimate_bits_subband_ism_ratio( /* take difference with respect to previous subframe */ v_sub_s( ratio_ism_idx, ratio_ism_idx_ref, diff_idx, nchan_ism ); + if ( shift_one ) { remove_sep_obj( diff_idx, nchan_ism, idx_sep_obj ); } + /* transform difference index into positive */ transform_difference_index( diff_idx, diff_idx, nchan_ism - 1 - shift_one ); - /* GR encoding */ + /* GR encoding */ for ( i = 0; i < nchan_ism - 1 - shift_one; i++ ) { nbits0 += ivas_qmetadata_encode_extended_gr_length( diff_idx[i], 100, 0 ); @@ -3062,11 +3051,11 @@ static void estimate_bits_subband_ism_ratio( static int16_t encode_ratio_ism_subframe( - const int16_t ratio_ism_idx[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], + int16_t ratio_ism_idx[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], const int16_t nchan_ism, - const int16_t numCodingBands, + const uint8_t numCodingBands, const int16_t sf, - const int16_t ratio_ism_idx_prev_sf[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], + int16_t ratio_ism_idx_prev_sf[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], BSTR_ENC_HANDLE hMetaData, const float *masa_to_total_energy_ratio, const int16_t shift_one, @@ -3289,6 +3278,7 @@ static int16_t encode_ratio_ism_subframe( { /* take difference with respect to previous subframe */ v_sub_s( ratio_ism_idx[0], ratio_ism_idx_prev_sf[0], diff_idx, nchan_ism ); + if ( shift_one ) { remove_sep_obj( diff_idx, nchan_ism, idx_sep_obj_local ); @@ -3478,8 +3468,10 @@ static void ivas_encode_masaism_metadata( assert( ( hMasa->data.energy_ratio_ism[sf][band][obj] >= 0 ) && ( hMasa->data.energy_ratio_ism[sf][band][obj] <= 1 ) ); ratio_ism[band][obj] = hMasa->data.energy_ratio_ism[sf][band][obj]; } + /* Quantize ISM ratios */ quantize_ratio_ism_vector( ratio_ism[band], ratio_ism_idx[band], hMasa->data.nchan_ism, hQMetaData->masa_to_total_energy_ratio[sf][band], idx_separated_object ); + if ( n_ism_tmp == numCodingBands && ratio_ism_idx[band][idx_separated_object] != 0 && hQMetaData->masa_to_total_energy_ratio[sf][band] < MASA2TOTAL_THR ) { i = 0; @@ -3553,7 +3545,6 @@ static void ivas_encode_masaism_metadata( encode_ratio_ism_subframe( ratio_ism_idx, hMasa->data.nchan_ism, numCodingBands, sf, ratio_ism_idx_prev_sf, hMetaData, hQMetaData->masa_to_total_energy_ratio[sf], 0, idx_separated_object ); } - /* calculate quantized ISM ratios */ /* save previous subframe indexes */ for ( band = 0; band < numCodingBands; band++ ) diff --git a/lib_enc/ivas_omasa_enc.c b/lib_enc/ivas_omasa_enc.c index 002a4d52c786d2ad26fe315b0052aa9417db175e..677558db09b5f03b96dbc751045364a6cd57ddd0 100644 --- a/lib_enc/ivas_omasa_enc.c +++ b/lib_enc/ivas_omasa_enc.c @@ -72,7 +72,9 @@ ivas_error ivas_omasa_enc_open( ) { int16_t i, j; +#ifndef FIX_OMASA_DELAY_COMP float tmp_f; +#endif OMASA_ENC_HANDLE hOMasa; int16_t numAnalysisChannels; int16_t input_frame; @@ -236,13 +238,11 @@ ivas_error ivas_omasa_enc_config( { int16_t k, sce_id, nSCE_old; int32_t ivas_total_brate, ism_total_brate; - ISM_MODE ism_mode_old; ENCODER_CONFIG_HANDLE hEncoderConfig; ivas_error error; hEncoderConfig = st_ivas->hEncoderConfig; ivas_total_brate = hEncoderConfig->ivas_total_brate; - ism_mode_old = st_ivas->ism_mode; nSCE_old = st_ivas->nSCE; st_ivas->ism_mode = ivas_omasa_ism_mode_select( ivas_total_brate, hEncoderConfig->nchan_ism ); diff --git a/lib_enc/ivas_stereo_td_analysis.c b/lib_enc/ivas_stereo_td_analysis.c index 5ef8001b7a556ea2af4b99679fa8d5f99e42723f..ee07ae2f52999747858ef1620ac240d3ff8c822d 100644 --- a/lib_enc/ivas_stereo_td_analysis.c +++ b/lib_enc/ivas_stereo_td_analysis.c @@ -111,14 +111,13 @@ static float Comp_diff_lt_corr( CPE_ENC_HANDLE hCPE, const int16_t IsSideMono, c *-------------------------------------------------------------------*/ int16_t stereo_tdm_ener_analysis( +#ifdef OMASA_TUNING_TD_STEREO + const int16_t ivas_format, /* i : IVAS format */ +#endif CPE_ENC_HANDLE hCPE, /* i : CPE structure */ const int16_t input_frame, /* i : Number of samples */ int16_t *tdm_SM_or_LRTD_Pri, /* o : channel combination scheme flag in TD stereo OR LRTD primary channel */ int16_t *tdm_ratio_idx_SM /* o : TDM ratio index for SM mode */ -#ifdef OMASA_TUNING_TD_STEREO - , - const int16_t isOmasa /* i : flag that indicates OMASA format */ -#endif ) { float rms_R, rms_L; @@ -200,7 +199,7 @@ int16_t stereo_tdm_ener_analysis( *----------------------------------------------------------------*/ #ifdef OMASA_TUNING_TD_STEREO - if ( isOmasa ) + if ( ivas_format == MASA_ISM_FORMAT ) { if ( ( hCPE->hStereoClassif->lrtd_mode == 1 || hCPE->hStereoTD->prev_fr_LRTD_TD_dec == 1 ) && ( hCPE->element_brate - 50 * FRAMES_PER_SEC + hCPE->brate_surplus + hCPE->brate_surplus < 15000 ) ) @@ -209,6 +208,7 @@ int16_t stereo_tdm_ener_analysis( } } #endif + rms_thd = RMS_MIN; if ( hCPE->hStereoClassif->lrtd_mode == 1 ) { diff --git a/lib_enc/ivas_stereo_td_enc.c b/lib_enc/ivas_stereo_td_enc.c index 7c0649c5ab013c137ce578cf97634143e4809cf0..d8c8086562c854395b63457f63560443d9f0fdc2 100644 --- a/lib_enc/ivas_stereo_td_enc.c +++ b/lib_enc/ivas_stereo_td_enc.c @@ -302,6 +302,9 @@ ivas_error stereo_set_tdm( *-------------------------------------------------------------------*/ void tdm_configure_enc( +#ifdef OMASA_TUNING_TD_STEREO + const int16_t ivas_format, /* i : IVAS format */ +#endif CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */ const float Etot_last[CPE_CHANNELS], /* i/o: Energy of last frame */ const int16_t tdm_SM_or_LRTD_Pri, /* i : channel combination scheme flag in TD stereo OR LRTD primary channel */ @@ -309,10 +312,6 @@ void tdm_configure_enc( const int16_t tdm_ratio_idx_SM, /* i : ratio index in SM mode */ const int16_t attack_flag, /* i : Primary channel attack flag */ const int16_t nb_bits_metadata /* i : number of metadata bits */ -#ifdef OMASA_TUNING_TD_STEREO - , - const int16_t IsOmasa /* i : flag that indicates OMASA format */ -#endif ) { int16_t tdm_ratio_bit_alloc_idx, mod_ct; @@ -485,15 +484,14 @@ void tdm_configure_enc( *----------------------------------------------------------------*/ #ifdef MASA_AND_OBJECTS - tdm_bit_alloc( hCPE->element_brate - nb_bits_metadata * FRAMES_PER_SEC + hCPE->brate_surplus, - hStereoTD->tdm_lp_reuse_flag, &( sts[0]->total_brate ), &( sts[1]->total_brate ), - &( hStereoTD->tdm_low_rate_mode ), sts[1]->coder_type, tdm_ratio_bit_alloc_idx, hStereoTD->tdm_Pitch_reuse_flag, - sts[0]->bwidth, sts[1]->bwidth, sts[0]->flag_ACELP16k, hStereoTD->tdm_LRTD_flag, mod_ct, hStereoTD->tdm_inst_ratio_idx + tdm_bit_alloc( #ifdef OMASA_TUNING_TD_STEREO - , - IsOmasa + ivas_format, #endif - ); + hCPE->element_brate - nb_bits_metadata * FRAMES_PER_SEC + hCPE->brate_surplus, + hStereoTD->tdm_lp_reuse_flag, &( sts[0]->total_brate ), &( sts[1]->total_brate ), + &( hStereoTD->tdm_low_rate_mode ), sts[1]->coder_type, tdm_ratio_bit_alloc_idx, hStereoTD->tdm_Pitch_reuse_flag, + sts[0]->bwidth, sts[1]->bwidth, sts[0]->flag_ACELP16k, hStereoTD->tdm_LRTD_flag, mod_ct, hStereoTD->tdm_inst_ratio_idx ); #else tdm_bit_alloc( hCPE->element_brate - nb_bits_metadata * FRAMES_PER_SEC, hStereoTD->tdm_lp_reuse_flag, &( sts[0]->total_brate ), &( sts[1]->total_brate ), &( hStereoTD->tdm_low_rate_mode ), sts[1]->coder_type, tdm_ratio_bit_alloc_idx, hStereoTD->tdm_Pitch_reuse_flag, sts[0]->bwidth, sts[1]->bwidth, sts[0]->flag_ACELP16k, hStereoTD->tdm_LRTD_flag, mod_ct, hStereoTD->tdm_inst_ratio_idx ); #endif diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 3d2420632d86ccac487ab5aeb6737bb9afb2631d..4249b4790e2f38fa01d849fa72eeb11385364e26 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -5312,6 +5312,9 @@ static void copyMasaMetadataToDiracRenderer( int16_t meta_write_index; #endif +#ifdef MASA_AND_OBJECTS + hDirAC->numParametricDirections = meta->descriptive_meta.numberOfDirections; +#endif hDirAC->numSimultaneousDirections = meta->descriptive_meta.numberOfDirections + 1; for ( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ )