From 5e520fbdbb96b8d19dcde9dcee30b4c5ae1eaf15 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 13 Oct 2025 15:10:55 +0200 Subject: [PATCH 01/31] port changes from the float branch 1680_ref_port_object_editing_implementation --- lib_com/ivas_cnst.h | 5 + lib_com/ivas_prot_fx.h | 5 +- lib_com/options.h | 3 + lib_dec/ivas_dirac_dec_fx.c | 11 ++ lib_dec/ivas_init_dec_fx.c | 17 ++- lib_dec/ivas_ism_dec_fx.c | 25 ++++ lib_dec/ivas_ism_param_dec_fx.c | 215 ++++++++++++++++++-------------- lib_dec/ivas_ism_renderer_fx.c | 26 ++++ lib_dec/ivas_jbm_dec_fx.c | 28 +++++ lib_dec/ivas_masa_dec_fx.c | 8 ++ lib_dec/ivas_omasa_dec_fx.c | 89 +++++++++++++ lib_dec/ivas_stat_dec.h | 21 ++++ lib_dec/lib_dec_fx.c | 215 ++++++++++++++++++++++++++++++++ 13 files changed, 569 insertions(+), 99 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 69822b590..5414adafc 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1326,6 +1326,11 @@ enum #define MASA_MAXIMUM_TWO_DIR_BANDS 24 #define NBITS_HR_COH 4 #define OMASA_TDREND_MATCHING_GAIN_FX 26026 +#ifdef OMASA_OBJECT_EDITING +#define OMASA_GAIN_EDIT_THR 0.06f /* OMASA gain change threshold */ +#define OMASA_AZI_EDIT_THR 1.0f /* OMASA-DISC azimuth change threshold */ +#define OMASA_ELE_EDIT_THR 2.0f /* OMASA-DISC elevation change threshold */ +#endif #define MASA_INV_ANGLE_AT_EQUATOR_DEG_Q30 (1453366656l) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index f226e5d95..1bc7c574a 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -3937,8 +3937,11 @@ void ivas_set_ism_importance_interformat_fx( const Word16 lp_noise_CPE_fx, /* i : LP filtered total noise estimation */ Word16 ism_imp[] /* o : ISM importance flags */ ); - +#ifdef OMASA_OBJECT_EDITING +void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( +#else void ivas_omasa_preProcessStereoTransportsForMovedObjects_fx( +#endif Decoder_Struct *st_ivas, Word32 inRe_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /*cldfb_buf_q*/ Word32 inIm_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /*cldfb_buf_q*/ diff --git a/lib_com/options.h b/lib_com/options.h index 9891ef397..b0749ec7d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -160,6 +160,9 @@ #define FIX_HRTF_LOAD_API // solves API conflicts between HRTF and object-editing features #define TMP_FIX_SPLIT_REND // temporary fix to split-rendering (it follows the later state of the framework but it is needed now because of current test-conditions) #define TMP_FIX_OMASA_SR_BE // temporary fix to keep OMASA split-rendering BE +#define OBJ_EDITING_EXAMPLE /* obj editing example code in decoder.c */ +#define OMASA_OBJECT_EDITING /* Nokia: object editing interface for OMASA */ +#define OBJ_EDITING_PARAMISM_BIN /* Nokia: object editing for ParamISM to binaural */ #endif /* #################### End BASOP porting switches ############################ */ diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index 6d36b3429..a4c7df45e 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -2881,6 +2881,16 @@ void ivas_dirac_dec_render_sf_fx( move16(); } +#ifdef OMASA_OBJECT_EDITING + if ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) + { +#ifdef FIX_1319_STACK_SBA_DECODER + ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( st_ivas, Cldfb_RealBuffer_Binaural_fx[0], Cldfb_ImagBuffer_Binaural_fx[0], &cldfb_buf_q, hSpatParamRendCom->num_freq_bands, subframe_idx ); +#else + ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( st_ivas, Cldfb_RealBuffer_Temp_fx, Cldfb_ImagBuffer_Temp_fx, &cldfb_buf_q, hSpatParamRendCom->num_freq_bands, subframe_idx ); +#endif + } +#else test(); IF( ( NE_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && NE_16( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) ) { @@ -2890,6 +2900,7 @@ void ivas_dirac_dec_render_sf_fx( ivas_omasa_preProcessStereoTransportsForMovedObjects_fx( st_ivas, Cldfb_RealBuffer_Temp_fx, Cldfb_ImagBuffer_Temp_fx, &cldfb_buf_q, hSpatParamRendCom->num_freq_bands, subframe_idx ); #endif } +#endif } FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 21db1c479..531795684 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -1867,7 +1867,17 @@ ivas_error ivas_init_decoder_fx( IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) ) { st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed2 = st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed3; - move16(); + move16(); +#ifdef OBJ_EDITING_PARAMISM_BIN + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + { + /* reusing OMASA function for allocating and initializing MASA_ISM rendering handle (even though not in OMASA) */ + if ( ( error = ivas_omasa_data_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#endif } ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MODE_DISC ) ) { @@ -2232,13 +2242,15 @@ ivas_error ivas_init_decoder_fx( } reset_indices_dec( st_ivas->hSCE[0]->hCoreCoder[0] ); - +#ifndef OMASA_OBJECT_EDITING IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) { +#endif if ( ( error = ivas_ism_metadata_dec_create_fx( st_ivas, st_ivas->nchan_ism, NULL ) ) != IVAS_ERR_OK ) { return error; } +#ifndef OMASA_OBJECT_EDITING } else { @@ -2247,6 +2259,7 @@ ivas_error ivas_init_decoder_fx( return error; } } +#endif } ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) { diff --git a/lib_dec/ivas_ism_dec_fx.c b/lib_dec/ivas_ism_dec_fx.c index d7caec1ac..42b013211 100644 --- a/lib_dec/ivas_ism_dec_fx.c +++ b/lib_dec/ivas_ism_dec_fx.c @@ -213,6 +213,10 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( { /* close the parametric binaural renderer */ ivas_dirac_dec_close_binaural_data_fx( st_ivas->hDiracDecBin ); +#ifdef OBJ_EDITING_PARAMISM_BIN + /* Close omasa data struct (used for object editing) */ + ivas_omasa_data_close( &st_ivas->hMasaIsmData ); +#endif /* Open the TD Binaural renderer */ test(); @@ -248,6 +252,11 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( /* close the parametric binaural renderer */ ivas_dirac_dec_close_binaural_data_fx( st_ivas->hDiracDecBin ); +#ifdef OBJ_EDITING_PARAMISM_BIN + /* Close omasa data struct (used for object editing) */ + ivas_omasa_data_close( &st_ivas->hMasaIsmData ); +#endif + /* Open Crend Binaural renderer */ #ifdef FIX_CREND_SIMPLIFY_CODE IF( NE_32( ( error = ivas_rend_openCrend_fx( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hHrtfCrend, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, 0, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) ) @@ -283,6 +292,14 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( { return error; } + +#ifdef OBJ_EDITING_PARAMISM_BIN + /* Open omasa data struct (used for object editing) */ + if ( ( error = ivas_omasa_data_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif /* Close the TD Binaural renderer */ ivas_td_binaural_close_fx( &st_ivas->hBinRendererTd ); @@ -311,6 +328,14 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( return error; } +#ifdef OBJ_EDITING_PARAMISM_BIN + /* Open omasa data struct (used for object editing) */ + if ( ( error = ivas_omasa_data_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif + /* close the crend binaural renderer */ #ifdef FIX_CREND_SIMPLIFY_CODE ivas_rend_closeCrend_fx( &( st_ivas->hCrendWrapper ) ); diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 973d726b0..819c3e6d7 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -1035,8 +1035,8 @@ void ivas_ism_dec_digest_tc_fx( elevation_fx = L_shl( elevation_fx, Q22 ); // Q22 efap_determine_gains_fx( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains_fx[i], azimuth_fx, elevation_fx, EFAP_MODE_EFAP ); #ifdef OBJ_EDITING_API - // TODO: Enable gain editing feature - // v_multc_fixed( st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIsmMetaData[i]->edited_gain_fx, st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hEFAPdata->numSpk ); + //TODO: align Q values properly + v_multc_fixed( st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIsmMetaData[i]->edited_gain_fx, st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hEFAPdata->numSpk ); #endif } } @@ -1984,15 +1984,26 @@ void ivas_param_ism_params_to_masa_param_mapping_fx( Word16 azimuth[2]; Word16 elevation[2]; Word16 power_ratio_fx[2]; /* Q15 */ +#ifdef OBJ_EDITING_PARAMISM_BIN + MASA_ISM_DATA_HANDLE hMasaIsmData; + int16_t obj; + int16_t obj_idx; +#endif #ifndef OBJ_EDITING_API Word32 ivas_total_brate; #endif hParamIsmDec = st_ivas->hParamIsmDec; + move16(); hSpatParamRendCom = st_ivas->hSpatParamRendCom; + move16(); nBins = hSpatParamRendCom->num_freq_bands; move16(); +#ifdef OBJ_EDITING_PARAMISM_BIN + hMasaIsmData = st_ivas->hMasaIsmData; + move16(); +#endif #ifndef OBJ_EDITING_API ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; move32(); @@ -2012,138 +2023,150 @@ void ivas_param_ism_params_to_masa_param_mapping_fx( } #endif - IF( GT_16( st_ivas->nchan_ism, 1 ) ) + + IF( st_ivas->hISMDTX.dtx_flag ) { - IF( st_ivas->hISMDTX.dtx_flag ) - { - Word32 energy_ratio_fx; /* Q30 */ - energy_ratio_fx = L_mult0( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence_fx, st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence_fx ); /* Q15 + Q15 -> Q30 */ + Word32 energy_ratio_fx; /* Q30 */ + energy_ratio_fx = L_mult0( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence_fx, st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence_fx ); /* Q15 + Q15 -> Q30 */ - hSpatParamRendCom->numSimultaneousDirections = 1; - move16(); - azimuth[0] = extract_l( L_shr( L_add( hParamIsmDec->azimuth_values_fx[0], ONE_IN_Q21 ), 22 ) ); // Q0 - move16(); - elevation[0] = extract_l( L_shr( L_add( hParamIsmDec->elevation_values_fx[0], ONE_IN_Q21 ), 22 ) ); // Q0 - move16(); + hSpatParamRendCom->numSimultaneousDirections = 1; + move16(); + azimuth[0] = extract_l( L_shr( L_add( hParamIsmDec->azimuth_values_fx[0], ONE_IN_Q21 ), 22 ) ); // Q0 + move16(); + elevation[0] = extract_l( L_shr( L_add( hParamIsmDec->elevation_values_fx[0], ONE_IN_Q21 ), 22 ) ); // Q0 + move16(); - FOR( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) + FOR( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) + { + FOR( bin_idx = 0; bin_idx < nBins; bin_idx++ ) { - FOR( bin_idx = 0; bin_idx < nBins; bin_idx++ ) - { - hSpatParamRendCom->azimuth[sf_idx][bin_idx] = azimuth[0]; - move16(); - hSpatParamRendCom->elevation[sf_idx][bin_idx] = elevation[0]; - move16(); - hSpatParamRendCom->energy_ratio1_fx[sf_idx][bin_idx] = energy_ratio_fx; - move16(); - hSpatParamRendCom->spreadCoherence_fx[sf_idx][bin_idx] = 0; - move16(); - hSpatParamRendCom->surroundingCoherence_fx[sf_idx][bin_idx] = 0; - move16(); - } + hSpatParamRendCom->azimuth[sf_idx][bin_idx] = azimuth[0]; + move16(); + hSpatParamRendCom->elevation[sf_idx][bin_idx] = elevation[0]; + move16(); + hSpatParamRendCom->energy_ratio1_fx[sf_idx][bin_idx] = energy_ratio_fx; + move16(); + hSpatParamRendCom->spreadCoherence_fx[sf_idx][bin_idx] = 0; + move16(); + hSpatParamRendCom->surroundingCoherence_fx[sf_idx][bin_idx] = 0; + move16(); } } - ELSE + } + ELSE + { + hSpatParamRendCom->numSimultaneousDirections = 2; + move16(); + FOR( band_idx = 0; band_idx < hParamIsmDec->hParamIsm->nbands; band_idx++ ) { - hSpatParamRendCom->numSimultaneousDirections = 2; + brange[0] = hParamIsmDec->hParamIsm->band_grouping[band_idx]; move16(); - FOR( band_idx = 0; band_idx < hParamIsmDec->hParamIsm->nbands; band_idx++ ) - { - brange[0] = hParamIsmDec->hParamIsm->band_grouping[band_idx]; - move16(); #ifdef OBJ_EDITING_API - brange[1] = hParamIsmDec->hParamIsm->band_grouping[band_idx + 1]; - move16(); + brange[1] = hParamIsmDec->hParamIsm->band_grouping[band_idx + 1]; + move16(); - azimuth[0] = extract_l( L_shr( L_add( hParamIsmDec->edited_azimuth_values_fx[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][0]], ( 1 << 21 ) ), 22 ) ); // Q0 - move16(); - elevation[0] = extract_l( L_shr( L_add( hParamIsmDec->edited_elevation_values_fx[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][0]], ( 1 << 21 ) ), 22 ) ); // Q0 - move16(); + azimuth[0] = extract_l( L_shr( L_add( hParamIsmDec->edited_azimuth_values_fx[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][0]], ( 1 << 21 ) ), 22 ) ); // Q0 + move16(); + elevation[0] = extract_l( L_shr( L_add( hParamIsmDec->edited_elevation_values_fx[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][0]], ( 1 << 21 ) ), 22 ) ); // Q0 + move16(); #else - brange[1] = hParamIsmDec->hParamIsm->band_grouping[band_idx + 1]; - move16(); + brange[1] = hParamIsmDec->hParamIsm->band_grouping[band_idx + 1]; + move16(); - azimuth[0] = extract_l( L_shr( L_add( hParamIsmDec->azimuth_values_fx[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][0]], ( 1 << 21 ) ), 22 ) ); // Q0 - move16(); - elevation[0] = extract_l( L_shr( L_add( hParamIsmDec->elevation_values_fx[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][0]], ( 1 << 21 ) ), 22 ) ); // Q0 - move16(); + azimuth[0] = extract_l( L_shr( L_add( hParamIsmDec->azimuth_values_fx[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][0]], ( 1 << 21 ) ), 22 ) ); // Q0 + move16(); + elevation[0] = extract_l( L_shr( L_add( hParamIsmDec->elevation_values_fx[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][0]], ( 1 << 21 ) ), 22 ) ); // Q0 + move16(); #endif - power_ratio_fx[0] = hParamIsmDec->power_ratios_fx[band_idx][0][0]; - move16(); + power_ratio_fx[0] = hParamIsmDec->power_ratios_fx[band_idx][0][0]; + move16(); #ifdef OBJ_EDITING_API - azimuth[1] = extract_l( L_shr( L_add( hParamIsmDec->edited_azimuth_values_fx[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][1]], ( 1 << 21 ) ), 22 ) ); // Q0 - move16(); - elevation[1] = extract_l( L_shr( L_add( hParamIsmDec->edited_elevation_values_fx[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][1]], ( 1 << 21 ) ), 22 ) ); // Q0 - move16(); + azimuth[1] = extract_l( L_shr( L_add( hParamIsmDec->edited_azimuth_values_fx[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][1]], ( 1 << 21 ) ), 22 ) ); // Q0 + move16(); + elevation[1] = extract_l( L_shr( L_add( hParamIsmDec->edited_elevation_values_fx[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][1]], ( 1 << 21 ) ), 22 ) ); // Q0 + move16(); #else - azimuth[1] = extract_l( L_shr( L_add( hParamIsmDec->azimuth_values_fx[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][1]], ( 1 << 21 ) ), 22 ) ); // Q0 - move16(); - elevation[1] = extract_l( L_shr( L_add( hParamIsmDec->elevation_values_fx[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][1]], ( 1 << 21 ) ), 22 ) ); // Q0 - move16(); + azimuth[1] = extract_l( L_shr( L_add( hParamIsmDec->azimuth_values_fx[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][1]], ( 1 << 21 ) ), 22 ) ); // Q0 + move16(); + elevation[1] = extract_l( L_shr( L_add( hParamIsmDec->elevation_values_fx[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][1]], ( 1 << 21 ) ), 22 ) ); // Q0 + move16(); #endif - power_ratio_fx[1] = hParamIsmDec->power_ratios_fx[band_idx][0][1]; - move16(); - - FOR( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) - { - FOR( bin_idx = brange[0]; bin_idx < brange[1]; bin_idx++ ) - { - hSpatParamRendCom->azimuth[sf_idx][bin_idx] = azimuth[0]; - move16(); - hSpatParamRendCom->elevation[sf_idx][bin_idx] = elevation[0]; - move16(); - hSpatParamRendCom->energy_ratio1_fx[sf_idx][bin_idx] = L_shl( power_ratio_fx[0], Q15 ); // Q30 - move32(); - hSpatParamRendCom->azimuth2[sf_idx][bin_idx] = azimuth[1]; - move16(); - hSpatParamRendCom->elevation2[sf_idx][bin_idx] = elevation[1]; - move16(); - hSpatParamRendCom->energy_ratio2_fx[sf_idx][bin_idx] = L_shl( power_ratio_fx[1], Q15 ); // Q30 - move32(); - } - } - } + power_ratio_fx[1] = hParamIsmDec->power_ratios_fx[band_idx][0][1]; + move16(); FOR( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) { - FOR( bin_idx = 0; bin_idx < nBins; bin_idx++ ) + FOR( bin_idx = brange[0]; bin_idx < brange[1]; bin_idx++ ) { - hSpatParamRendCom->spreadCoherence_fx[sf_idx][bin_idx] = 0; + hSpatParamRendCom->azimuth[sf_idx][bin_idx] = azimuth[0]; + move16(); + hSpatParamRendCom->elevation[sf_idx][bin_idx] = elevation[0]; move16(); - hSpatParamRendCom->spreadCoherence2_fx[sf_idx][bin_idx] = 0; + hSpatParamRendCom->energy_ratio1_fx[sf_idx][bin_idx] = L_shl( power_ratio_fx[0], Q15 ); // Q30 + move32(); + hSpatParamRendCom->azimuth2[sf_idx][bin_idx] = azimuth[1]; move16(); - hSpatParamRendCom->surroundingCoherence_fx[sf_idx][bin_idx] = 0; + hSpatParamRendCom->elevation2[sf_idx][bin_idx] = elevation[1]; move16(); + hSpatParamRendCom->energy_ratio2_fx[sf_idx][bin_idx] = L_shl( power_ratio_fx[1], Q15 ); // Q30 + move32(); } } } - } - ELSE - { - hSpatParamRendCom->numSimultaneousDirections = 1; - move16(); - azimuth[0] = extract_l( L_shr( ( L_add( hParamIsmDec->azimuth_values_fx[0], ( 1 << 21 ) ) ), 22 ) ); // Q0 - move16(); - elevation[0] = extract_l( L_shr( L_add( hParamIsmDec->elevation_values_fx[0], ( 1 << 21 ) ), 22 ) ); // Q0 - move16(); FOR( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) { FOR( bin_idx = 0; bin_idx < nBins; bin_idx++ ) { - hSpatParamRendCom->azimuth[sf_idx][bin_idx] = azimuth[0]; - move16(); - hSpatParamRendCom->elevation[sf_idx][bin_idx] = elevation[0]; - move16(); - hSpatParamRendCom->energy_ratio1_fx[sf_idx][bin_idx] = ONE_IN_Q30; /* 1.0f in Q30 */ - move32(); hSpatParamRendCom->spreadCoherence_fx[sf_idx][bin_idx] = 0; move16(); + hSpatParamRendCom->spreadCoherence2_fx[sf_idx][bin_idx] = 0; + move16(); hSpatParamRendCom->surroundingCoherence_fx[sf_idx][bin_idx] = 0; move16(); } } + +#ifdef OBJ_EDITING_PARAMISM_BIN + for ( obj = 0; obj < st_ivas->nchan_ism; obj++ ) + { + for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) + { + hMasaIsmData->azimuth_ism[obj][sf_idx] = (int16_t) roundf( hParamIsmDec->azimuth_values_fx[obj] ); + hMasaIsmData->elevation_ism[obj][sf_idx] = (int16_t) roundf( hParamIsmDec->elevation_values_fx[obj] ); + } + + hMasaIsmData->azimuth_ism_edited[obj] = (int16_t) roundf( hParamIsmDec->edited_azimuth_values_fx[obj] ); + hMasaIsmData->elevation_ism_edited[obj] = (int16_t) roundf( hParamIsmDec->edited_elevation_values_fx[obj] ); + + for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) + { + set_zero( hMasaIsmData->energy_ratio_ism_fx[obj][sf_idx], CLDFB_NO_CHANNELS_MAX ); + } + } + + for ( obj = 0; obj < MAX_PARAM_ISM_WAVE; obj++ ) + { + for ( band_idx = 0; band_idx < hParamIsmDec->hParamIsm->nbands; band_idx++ ) + { + brange[0] = hParamIsmDec->hParamIsm->band_grouping[band_idx]; + brange[1] = hParamIsmDec->hParamIsm->band_grouping[band_idx + 1]; + + obj_idx = hParamIsmDec->hParamIsm->obj_indices[band_idx][0][obj]; + power_ratio_fx[obj] = hParamIsmDec->power_ratios_fx[band_idx][0][obj]; + + for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) + { + for ( bin_idx = brange[0]; bin_idx < brange[1]; bin_idx++ ) + { + hMasaIsmData->energy_ratio_ism_fx[obj_idx][sf_idx][bin_idx] = power_ratio_fx[obj]; + } + } + } + } +#endif } + return; } diff --git a/lib_dec/ivas_ism_renderer_fx.c b/lib_dec/ivas_ism_renderer_fx.c index 36234bf47..66e47ad6d 100644 --- a/lib_dec/ivas_ism_renderer_fx.c +++ b/lib_dec/ivas_ism_renderer_fx.c @@ -622,17 +622,43 @@ void ivas_omasa_separate_object_render_jbm_fx( IF( single_separated ) { +#ifdef OMASA_OBJECT_EDITING + if ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ && st_ivas->hMasaIsmData->ism_dir_is_edited[st_ivas->hMasaIsmData->idx_separated_ism] ) + { + azimuth = st_ivas->hMasaIsmData->azimuth_ism_edited[st_ivas->hMasaIsmData->idx_separated_ism]; + elevation = st_ivas->hMasaIsmData->elevation_ism_edited[st_ivas->hMasaIsmData->idx_separated_ism]; + } + else + { + azimuth = st_ivas->hMasaIsmData->azimuth_separated_ism[md_idx]; + elevation = st_ivas->hMasaIsmData->elevation_separated_ism[md_idx]; + } +#else azimuth = st_ivas->hMasaIsmData->azimuth_separated_ism[md_idx]; move16(); elevation = st_ivas->hMasaIsmData->elevation_separated_ism[md_idx]; move16(); +#endif } ELSE { +#ifdef OMASA_OBJECT_EDITING + if ( st_ivas->hMasaIsmData->ism_dir_is_edited[obj] ) + { + azimuth = st_ivas->hMasaIsmData->azimuth_ism_edited[obj]; + elevation = st_ivas->hMasaIsmData->elevation_ism_edited[obj]; + } + else + { + azimuth = st_ivas->hMasaIsmData->azimuth_ism[obj][md_idx]; + elevation = st_ivas->hMasaIsmData->elevation_ism[obj][md_idx]; + } +#else azimuth = st_ivas->hMasaIsmData->azimuth_ism[obj][md_idx]; move16(); elevation = st_ivas->hMasaIsmData->elevation_ism[obj][md_idx]; move16(); +#endif } if ( st_ivas->hOutSetup.is_planar_setup ) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 767979d8a..e4b147e79 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -4653,10 +4653,38 @@ void ivas_jbm_dec_prepare_renderer( test(); IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) ) { +#ifdef OMASA_OBJECT_EDITING + float gainIsm; + gainIsm = OMASA_TDREND_MATCHING_GAIN; + + if ( st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) + { + gainIsm *= st_ivas->hMasaIsmData->gain_ism_edited[n]; + } + + v_multc( st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], gainIsm, st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available ); +#else v_multc_fixed_16( st_ivas->hTcBuffer->tc_fx[CPE_CHANNELS + n], OMASA_TDREND_MATCHING_GAIN_FX, st_ivas->hTcBuffer->tc_fx[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available ); +#endif } delay_signal32_fx( st_ivas->hTcBuffer->tc_fx[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available, st_ivas->hMasaIsmData->delayBuffer_fx[n], st_ivas->hMasaIsmData->delayBuffer_size ); + //TODO: check if tis is a bug in main already + } +#ifdef OMASA_OBJECT_EDITING + if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) + { + int16_t tcBufferSize; + tcBufferSize = st_ivas->hSpatParamRendCom->num_slots * st_ivas->hSpatParamRendCom->slot_size; + + if ( st_ivas->hMasaIsmData->masa_gain_is_edited ) + { + for ( int16_t ch = 0; ch < 2; ch++ ) + { + v_multc( st_ivas->hTcBuffer->tc[ch], st_ivas->hMasaIsmData->gain_masa_edited, st_ivas->hTcBuffer->tc[ch], tcBufferSize ); + } + } } +#endif } } ELSE IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) ) diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c index c333cc21e..e1291552a 100644 --- a/lib_dec/ivas_masa_dec_fx.c +++ b/lib_dec/ivas_masa_dec_fx.c @@ -837,9 +837,14 @@ ivas_error ivas_masa_dec_open_fx( move32(); /* ISM metadata */ +#ifdef OMASA_OBJECT_EDITING + test(); + IF ( EQ_16(st_ivas->ivas_format, MASA_FORMAT) && NE_16(st_ivas->hIsmMetaData[0], NULL ) ) +#else test(); test(); IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && st_ivas->hIsmMetaData[0] != NULL && EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) +#endif { /* these are not needed -> clean. EXT metafile writer in OMASA needs only the number of ISMs and writes default null-data */ ivas_ism_metadata_close( st_ivas->hIsmMetaData, 0 ); @@ -3358,6 +3363,9 @@ static Word16 ivas_decode_masaism_metadata_fx( FOR( obj = 0; obj < nchan_ism; obj++ ) { +#ifdef OMASA_OBJECT_EDITING + hMasaIsmData->bits_ism[obj] = bits_ism[obj]; +#endif index = 0; move16(); IF( LT_16( bits_ism[obj], 8 ) ) /* if low resolution, can look to the past */ diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index 7278b9968..0198db19a 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -315,7 +315,11 @@ ivas_error ivas_omasa_data_open_fx( ) { MASA_ISM_DATA_HANDLE hMasaIsmData; +#ifdef OMASA_OBJECT_EDITING + Word16 ch; +#else Word16 ch, bin; +#endif Word16 sf, obj_idx; IF( ( hMasaIsmData = (MASA_ISM_DATA_HANDLE) malloc( sizeof( MASA_ISM_DATA ) ) ) == NULL ) @@ -323,6 +327,27 @@ ivas_error ivas_omasa_data_open_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MASA ISM data\n" ) ); } +#ifdef OMASA_OBJECT_EDITING + FOR ( Word16 band_idx = 0; band_idx < MASA_FREQUENCY_BANDS; band_idx++ ) + { + FOR ( ch = 0; ch < 2; ch++ ) + { + hMasaIsmData->ismPreprocMatrix_fx[ch][ch][band_idx] = 32767; /* 1.0f in Q15 */ + move16(); + hMasaIsmData->ismPreprocMatrix_fx[1 - ch][ch][band_idx] = 0; // Q15 + move16(); + hMasaIsmData->eneMoveIIR_fx[ch][band_idx] = 0; // Q22 + move32(); + hMasaIsmData->enePreserveIIR_fx[ch][band_idx] = 0; // Q22 + move32(); + } + hMasaIsmData->eneOrigIIR_fx[band_idx] = 0; // TODO: check Q + hMasaIsmData->preprocEneTarget_fx[band_idx] = 0; // Q19 + hMasaIsmData->preprocEneRealized_fx[band_idx] = 0; // Q19 + } + + hMasaIsmData->objectsEdited = 0; +#else FOR( bin = 0; bin < CLDFB_NO_CHANNELS_MAX; bin++ ) { FOR( ch = 0; ch < 2; ch++ ) @@ -344,17 +369,28 @@ ivas_error ivas_omasa_data_open_fx( hMasaIsmData->objectsMoved = 0; move16(); +#endif hMasaIsmData->delayBuffer_fx = NULL; + move16(); FOR( ch = 0; ch < MAX_NUM_OBJECTS; ch++ ) { +#ifdef OMASA_OBJECT_EDITING + hMasaIsmData->ism_dir_is_edited[ch] = 0; + hMasaIsmData->ism_gain_is_edited[ch] = 0; +#else hMasaIsmData->ism_is_edited[ch] = 0; +#endif move16(); hMasaIsmData->q_elevation_old_fx[ch] = 0; // Q22 move32(); hMasaIsmData->q_azimuth_old_fx[ch] = 0; // Q22 move32(); } +#ifdef OMASA_OBJECT_EDITING + hMasaIsmData->masa_gain_is_edited = 0; + hMasaIsmData->idx_separated_ism = -1; +#endif FOR( obj_idx = 0; obj_idx < MAX_NUM_OBJECTS; obj_idx++ ) { @@ -479,7 +515,12 @@ ivas_error ivas_omasa_dec_config_fx( #endif ) { + +#ifdef OMASA_OBJECT_EDITING + Word16 k, sce_id, nSCE_old, nchan_hp20_old, numCldfbAnalyses_old, numCldfbSyntheses_old; +#else Word16 k, sce_id, nSCE_old, nchan_hp20_old, numCldfbAnalyses_old, numCldfbSyntheses_old, n_MD; +#endif Word32 ivas_total_brate, ism_total_brate, cpe_brate; Word32 brate_SCE, brate_CPE; ISM_MODE ism_mode_old; @@ -609,6 +650,22 @@ ivas_error ivas_omasa_dec_config_fx( IF( NE_16( ism_mode_old, st_ivas->ism_mode ) ) { /* ISM MD reconfig. */ +#ifdef OMASA_OBJECT_EDITING + if ( st_ivas->hIsmMetaData[0] == NULL ) + { + if ( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nchan_ism, NULL ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else + { + for ( k = 0; k < st_ivas->nchan_ism; k++ ) + { + ivas_ism_reset_metadata_handle_dec( st_ivas->hIsmMetaData[k] ); + } + } +#else n_MD = 0; move16(); @@ -669,6 +726,7 @@ ivas_error ivas_omasa_dec_config_fx( } st_ivas->hCPE[0]->element_brate = L_sub( ivas_total_brate, ism_total_brate ); +#endif /*-----------------------------------------------------------------* * Renderer selection @@ -1125,13 +1183,44 @@ void ivas_omasa_dirac_rend_jbm_fx( IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) || EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) { Copy32( &output_f[CPE_CHANNELS][st_ivas->hTcBuffer->n_samples_rendered], data_separated_objects[0], *nSamplesRendered ); +#ifdef OMASA_OBJECT_EDITING + if ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) + { + /* Gain separated object, if edited */ + for ( n = 0; n < st_ivas->nchan_ism; n++ ) + { + if ( st_ivas->hMasaIsmData->ism_gain_is_edited[n] && st_ivas->hMasaIsmData->idx_separated_ism == n ) + { + v_multc( data_separated_objects[0], st_ivas->hMasaIsmData->gain_ism_edited[n], data_separated_objects[0], *nSamplesRendered ); + } + } + } +#endif } + ELSE { FOR( n = 0; n < st_ivas->nchan_ism; n++ ) { Copy32( &output_f[n + CPE_CHANNELS][st_ivas->hTcBuffer->n_samples_rendered], data_separated_objects[n], *nSamplesRendered ); +#ifdef OMASA_OBJECT_EDITING + /* Gain discrete objects, if edited */ + if ( st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) + { + v_multc( data_separated_objects[n], st_ivas->hMasaIsmData->gain_ism_edited[n], data_separated_objects[n], *nSamplesRendered ); + } +#endif } +#ifdef OMASA_OBJECT_EDITING + /* Gain MASA part, if edited */ + if ( st_ivas->hMasaIsmData->masa_gain_is_edited ) + { + for ( int16_t ch = 0; ch < 2; ch++ ) + { + v_multc( output_f[ch], st_ivas->hMasaIsmData->gain_masa_edited, output_f[ch], *nSamplesRendered ); + } + } +#endif } } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index edf9729ce..3fa9c4452 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -962,12 +962,22 @@ typedef struct ivas_masa_ism_data_structure Word16 azimuth_ism_edited[MAX_NUM_OBJECTS]; Word16 elevation_ism_edited[MAX_NUM_OBJECTS]; +#ifdef OMASA_OBJECT_EDITING + UWord16 ism_dir_is_edited[MAX_NUM_OBJECTS]; +#else UWord8 ism_is_edited[MAX_NUM_OBJECTS]; +#endif #ifdef OBJ_EDITING_API Word32 gain_ism[MAX_NUM_OBJECTS]; Word32 gain_masa; #endif +#ifdef OMASA_OBJECT_EDITING + Word32 gain_ism_edited[MAX_NUM_OBJECTS]; + UWord8 ism_gain_is_edited[MAX_NUM_OBJECTS]; + UWord32 gain_masa_edited; + UWord8 masa_gain_is_edited; +#endif Word16 idx_separated_ism; Word16 azimuth_separated_ism[MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; Word16 elevation_separated_ism[MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; @@ -975,12 +985,23 @@ typedef struct ivas_masa_ism_data_structure Word32 q_azimuth_old_fx[MAX_NUM_OBJECTS]; /* Q22 */ Word32 q_elevation_old_fx[MAX_NUM_OBJECTS]; /* Q22 */ +#ifdef OMASA_OBJECT_EDITING + UWord16 objectsEdited; + Word32 preprocEneTarget[MASA_FREQUENCY_BANDS]; /*Q-19*/ + Word32 preprocEneRealized[MASA_FREQUENCY_BANDS]; /*Q-19*/ + Word32 ismPreprocMatrix[2][2][MASA_FREQUENCY_BANDS]; /*Q-15*/ + Word32 eneMoveIIR[2][MASA_FREQUENCY_BANDS]; /*Q-22*/ + Word32 enePreserveIIR[2][MASA_FREQUENCY_BANDS]; /*Q-22*/ + Word32 eneOrigIIR[MASA_FREQUENCY_BANDS]; + Word16 bits_ism[MAX_NUM_OBJECTS]; +#else Word16 ismPreprocMatrix_fx[2][2][CLDFB_NO_CHANNELS_MAX]; /* Q15 */ UWord8 objectsMoved; Word32 eneMoveIIR_fx[2][CLDFB_NO_CHANNELS_MAX]; /*Q-22*/ Word32 enePreserveIIR_fx[2][CLDFB_NO_CHANNELS_MAX]; /*Q-22*/ Word32 preprocEneTarget_fx[CLDFB_NO_CHANNELS_MAX]; /*Q-19*/ Word32 preprocEneRealized_fx[CLDFB_NO_CHANNELS_MAX]; /*Q-19*/ +#endif Word32 **delayBuffer_fx; /* Q11 */ Word16 delayBuffer_size; diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 051876ff9..8e4899de1 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -38,6 +38,9 @@ #include "ivas_prot_rend_fx.h" #include "prot_fx.h" #include "isar_prot.h" +#ifdef OMASA_OBJECT_EDITING +#include "ivas_rom_com.h" +#endif #include "lib_isar_pre_rend.h" #include "ivas_prot_fx.h" #include "jbm_jb4sb.h" @@ -3891,7 +3894,11 @@ ivas_error IVAS_DEC_GetSamplesDecoder( { IF( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) { +#ifdef OMASA_OBJECT_EDITING + IF ( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) +#else IF( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) +#edndif { Word16 obj; ISM_METADATA_HANDLE *hIsmMetaData = hIvasDec->st_ivas->hIsmMetaData; @@ -3943,6 +3950,9 @@ ivas_error IVAS_DEC_GetEditableParameters( IVAS_EDITABLE_PARAMETERS *hIvasEditableParameters ) { ivas_error error; +#ifdef OMASA_OBJECT_EDITING + int16_t dirac_read_idx; +#endif test(); test(); @@ -4023,6 +4033,57 @@ ivas_error IVAS_DEC_GetEditableParameters( assert( 0 && "This should never happen!" ); } } +#ifdef OMASA_OBJECT_EDITING + else if ( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT && ( hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) + { + /* object editing possible only in two highest OMASA modes */ + int16_t obj; + + if ( hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + { + for ( obj = 0; obj < hIvasEditableParameters->num_obj; obj++ ) + { + hIvasEditableParameters->ism_metadata[obj].azimuth_fx = hIvasDec->st_ivas->hIsmMetaData[obj]->azimuth_fx; + hIvasEditableParameters->ism_metadata[obj].elevation_fx = hIvasDec->st_ivas->hIsmMetaData[obj]->elevation_fx; + hIvasEditableParameters->ism_metadata[obj].yaw_fx = hIvasDec->st_ivas->hIsmMetaData[obj]->yaw_fx; + hIvasEditableParameters->ism_metadata[obj].pitch_fx = hIvasDec->st_ivas->hIsmMetaData[obj]->pitch_fx; + hIvasEditableParameters->ism_metadata[obj].radius_fx = hIvasDec->st_ivas->hIsmMetaData[obj]->radius_fx; + + /* reset the otherwise unused "gain" field for the object */ + hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain_fx = ONE_IN_Q31; //TODO: check Q value + hIvasEditableParameters->ism_metadata[obj].gain = hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain_fx; + hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = hIvasDec->st_ivas->hIsmMetaData[obj]->non_diegetic_flag; + } + } + else + { + /* Handle MONO output */ + if ( hIvasDec->st_ivas->renderer_type != RENDERER_MONO_DOWNMIX ) + { + dirac_read_idx = hIvasDec->st_ivas->hSpatParamRendCom->render_to_md_map[hIvasDec->st_ivas->hSpatParamRendCom->subframes_rendered]; + } + else + { + dirac_read_idx = 0; + } + + for ( obj = 0; obj < hIvasEditableParameters->num_obj; obj++ ) + { + hIvasEditableParameters->ism_metadata[obj].azimuth = hIvasDec->st_ivas->hMasaIsmData->azimuth_ism[obj][dirac_read_idx]; + hIvasEditableParameters->ism_metadata[obj].elevation = hIvasDec->st_ivas->hMasaIsmData->elevation_ism[obj][dirac_read_idx]; + + hIvasEditableParameters->ism_metadata[obj].yaw_fx = hIvasDec->st_ivas->hIsmMetaData[obj]->yaw; + hIvasEditableParameters->ism_metadata[obj].pitch_fx = hIvasDec->st_ivas->hIsmMetaData[obj]->pitch; + hIvasEditableParameters->ism_metadata[obj].radius_fx = hIvasDec->st_ivas->hIsmMetaData[obj]->radius; + + /* reset the otherwise unused "gain" field for the object */ + hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain_fx = ONE_IN_Q31; + hIvasEditableParameters->ism_metadata[obj].gain = hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain; + hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = hIvasDec->st_ivas->hIsmMetaData[obj]->non_diegetic_flag; + } + } + } +#endif error = IVAS_ERR_OK; @@ -4041,6 +4102,10 @@ ivas_error IVAS_DEC_SetEditableParameters( IVAS_EDITABLE_PARAMETERS hIvasEditableParameters ) { ivas_error error; +#ifdef OMASA_OBJECT_EDITING + int16_t dirac_read_idx; +#endif + if ( !( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || ( hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT && hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) || @@ -4090,13 +4155,163 @@ ivas_error IVAS_DEC_SetEditableParameters( int16_t obj; for ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) { +#ifdef OBJ_EDITING_PARAMISM_BIN + hIvasDec->st_ivas->hParamIsmDec->edited_azimuth_values[obj] = hIvasEditableParameters.ism_metadata[obj].azimuth; + hIvasDec->st_ivas->hParamIsmDec->edited_elevation_values[obj] = hIvasEditableParameters.ism_metadata[obj].elevation; + hIvasDec->st_ivas->hMasaIsmData->gain_ism_edited[obj] = hIvasEditableParameters.ism_metadata[obj].gain; + + /* Detect direction editing in Param-ISM mode */ + if ( fabsf( hIvasDec->st_ivas->hParamIsmDec->azimuth_values[obj] - hIvasEditableParameters.ism_metadata[obj].azimuth ) > OMASA_AZI_EDIT_THR || + fabsf( hIvasDec->st_ivas->hParamIsmDec->elevation_values[obj] - hIvasEditableParameters.ism_metadata[obj].elevation ) > OMASA_ELE_EDIT_THR ) + { + hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited[obj] = 1u; + } + else + { + hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited[obj] = 0u; + } + + /* Detect gain editing in Param-ISM mode */ + if ( fabsf( 1.0f - hIvasEditableParameters.ism_metadata[obj].gain ) > OMASA_GAIN_EDIT_THR ) + { + hIvasDec->st_ivas->hMasaIsmData->ism_gain_is_edited[obj] = 1u; + } + else + { + hIvasDec->st_ivas->hMasaIsmData->ism_gain_is_edited[obj] = 0u; + } +#endif } +#ifdef OBJ_EDITING_PARAMISM_BIN + /* MASA is not present with the ISM format */ + hIvasDec->st_ivas->hMasaIsmData->masa_gain_is_edited = 0u; +#endif } else { assert( 0 && "This should never happen!" ); } } +#ifdef OMASA_OBJECT_EDITING + else if ( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT && ( hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) + { + int16_t obj; + int32_t id_th; + float threshold_azi, threshold_ele; + + for ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) + { + if ( hIvasDec->st_ivas->hMasaIsmData != NULL ) + { + /* copy relevant fields also to OMASA structs, but only if the value has been changed. original values are in st_ivas->hIsmMetaData */ + /* first, need to convert float values to ints used internally */ + int16_t new_azi, new_ele; + if ( hIvasEditableParameters.ism_metadata[obj].azimuth > 0.0f ) + { + new_azi = (int16_t) ( hIvasEditableParameters.ism_metadata[obj].azimuth + 0.5f ); + } + else + { + new_azi = (int16_t) ( hIvasEditableParameters.ism_metadata[obj].azimuth - 0.5f ); + } + + if ( hIvasEditableParameters.ism_metadata[obj].elevation > 0.0f ) + { + new_ele = (int16_t) ( hIvasEditableParameters.ism_metadata[obj].elevation + 0.5f ); + } + else + { + new_ele = (int16_t) ( hIvasEditableParameters.ism_metadata[obj].elevation - 0.5f ); + } + + if ( hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) + { + /* Handle MONO output */ + if ( hIvasDec->st_ivas->renderer_type != RENDERER_MONO_DOWNMIX ) + { + dirac_read_idx = hIvasDec->st_ivas->hSpatParamRendCom->render_to_md_map[hIvasDec->st_ivas->hSpatParamRendCom->subframes_rendered]; + } + else + { + dirac_read_idx = 0; + } + + /* determine thresholds for detecting object metadata edit for direction based on quantization resolution of the spatial direction parameters. + * these depend from the number of bits used to transmit the directions, + * which in turn depends from the object priority and importance: + * importance -> priority -> number of bits -> elevation resolution -> elevation ring index -> azimuth resolution. + * leading to elevation_resolution -> elevation threshold and azimuth resolution -> azimuth threshold */ + id_th = (int) ( fabsf( (float) hIvasDec->st_ivas->hMasaIsmData->elevation_ism[obj][dirac_read_idx] ) / delta_theta_masa[hIvasDec->st_ivas->hMasaIsmData->bits_ism[obj] - 3] + 0.5f ); + threshold_azi = 360.0f / (float) no_phi_masa[hIvasDec->st_ivas->hMasaIsmData->bits_ism[obj] - 1][id_th]; + threshold_ele = delta_theta_masa[hIvasDec->st_ivas->hMasaIsmData->bits_ism[obj] - 3]; + + if ( ( (float) abs( new_azi - hIvasDec->st_ivas->hMasaIsmData->azimuth_ism[obj][dirac_read_idx] ) > threshold_azi ) || + ( (float) abs( new_ele - hIvasDec->st_ivas->hMasaIsmData->elevation_ism[obj][dirac_read_idx] ) > threshold_ele ) ) + { + /* at least one of the threshold is exceeded, so use new direction value and set editing detection flag */ + hIvasDec->st_ivas->hMasaIsmData->azimuth_ism_edited[obj] = new_azi; + hIvasDec->st_ivas->hMasaIsmData->elevation_ism_edited[obj] = new_ele; + + hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited[obj] = 1u; + } + else + { + hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited[obj] = 0u; + } + } + else + { + /* detect editing in ISM_MASA_MODE_DISC. optionally, add quantization-resolution -based thresholds */ + if ( fabsf( hIvasDec->st_ivas->hIsmMetaData[obj]->azimuth - hIvasEditableParameters.ism_metadata[obj].azimuth ) > OMASA_AZI_EDIT_THR || + fabsf( hIvasDec->st_ivas->hIsmMetaData[obj]->elevation - hIvasEditableParameters.ism_metadata[obj].elevation ) > OMASA_ELE_EDIT_THR ) + { + hIvasDec->st_ivas->hMasaIsmData->azimuth_ism_edited[obj] = new_azi; + hIvasDec->st_ivas->hMasaIsmData->elevation_ism_edited[obj] = new_ele; + + hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited[obj] = 1u; + } + else + { + hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited[obj] = 0u; + } + } + + /* compare pre-edit gain and the edited one to detect editing */ + if ( fabsf( hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain - hIvasEditableParameters.ism_metadata[obj].gain ) > OMASA_GAIN_EDIT_THR ) + { + hIvasDec->st_ivas->hMasaIsmData->ism_gain_is_edited[obj] = 1u; + hIvasDec->st_ivas->hMasaIsmData->gain_ism_edited[obj] = hIvasEditableParameters.ism_metadata[obj].gain; + } + else + { + hIvasDec->st_ivas->hMasaIsmData->ism_gain_is_edited[obj] = 0u; + } + } + + /* Copy edited values to hIsmMetaData struct */ + if ( hIvasDec->st_ivas->hIsmMetaData[obj] != NULL ) + { + hIvasDec->st_ivas->hIsmMetaData[obj]->azimuth = hIvasEditableParameters.ism_metadata[obj].azimuth; + hIvasDec->st_ivas->hIsmMetaData[obj]->elevation = hIvasEditableParameters.ism_metadata[obj].elevation; + hIvasDec->st_ivas->hIsmMetaData[obj]->yaw = hIvasEditableParameters.ism_metadata[obj].yaw; + hIvasDec->st_ivas->hIsmMetaData[obj]->pitch = hIvasEditableParameters.ism_metadata[obj].pitch; + hIvasDec->st_ivas->hIsmMetaData[obj]->radius = hIvasEditableParameters.ism_metadata[obj].radius; + hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain = hIvasEditableParameters.ism_metadata[obj].gain; + hIvasDec->st_ivas->hIsmMetaData[obj]->non_diegetic_flag = hIvasEditableParameters.ism_metadata[obj].non_diegetic_flag; + } + } + + if ( fabsf( hIvasEditableParameters.gain_bed - 1.0f ) > OMASA_GAIN_EDIT_THR ) + { + hIvasDec->st_ivas->hMasaIsmData->gain_masa_edited = hIvasEditableParameters.gain_bed; + hIvasDec->st_ivas->hMasaIsmData->masa_gain_is_edited = 1u; + } + else + { + hIvasDec->st_ivas->hMasaIsmData->masa_gain_is_edited = 0u; + } + } +#endif return error; } -- GitLab From 2ddaef28d81e73a52293751563947b2bbfcae811 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 14 Oct 2025 10:38:03 +0200 Subject: [PATCH 02/31] copy remaining changes from 1680_ref_port_object_editing_implementation --- .../ivas_dirac_dec_binaural_functions_fx.c | 785 ++++++++++++++++++ lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 14 + lib_rend/ivas_objectRenderer_fx.c | 9 + lib_rend/ivas_objectRenderer_sources_fx.c | 37 + lib_rend/ivas_prot_rend_fx.h | 8 + 5 files changed, 853 insertions(+) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 8f063a897..b547cd8aa 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -985,11 +985,22 @@ static void ivas_dirac_dec_binaural_internal_fx( test(); test(); test(); +#ifdef OMASA_OBJECT_EDITING +#ifdef OBJ_EDITING_PARAMISM_BIN + if ( ( st_ivas->ivas_format == MASA_ISM_FORMAT && ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) ) ) ) || st_ivas->ivas_format == ISM_FORMAT ) +#else + if ( st_ivas->ivas_format == MASA_ISM_FORMAT && ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) ) ) ) +#endif + { + ivas_omasa_preProcessStereoTransportsForEditedObjects( st_ivas, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, nBins, subframe ); + } +#else IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_16( nchan_transport, 2 ) && NE_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && NE_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) { /* Un-tested function. No test-case is hitting.*/ ivas_omasa_preProcessStereoTransportsForMovedObjects_fx( st_ivas, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, &q_inp, nBins, subframe ); } +#endif IF( hCombinedOrientationData ) { @@ -1737,6 +1748,13 @@ static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices_fx( UWord16 ismDirIndex; ismDirIndex = sub( dirIndex, hSpatParamRendCom->numParametricDirections ); assert( hMasaIsmData != NULL && "hMasaIsmData should not be NULL if we use it" ); +#ifdef OMASA_OBJECT_EDITING + if ( hMasaIsmData->ism_dir_is_edited[ismDirIndex] ) + { + aziDeg = hMasaIsmData->azimuth_ism_edited[ismDirIndex]; + eleDeg = hMasaIsmData->elevation_ism_edited[ismDirIndex]; + } +#else IF( hMasaIsmData->ism_is_edited[ismDirIndex] ) { aziDeg = hMasaIsmData->azimuth_ism_edited[ismDirIndex]; @@ -1744,6 +1762,7 @@ static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices_fx( eleDeg = hMasaIsmData->elevation_ism_edited[ismDirIndex]; move16(); } +#endif ELSE { aziDeg = hMasaIsmData->azimuth_ism[ismDirIndex][dirac_read_idx]; @@ -2598,17 +2617,51 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( { IF( EQ_16( ism_mode, ISM_MASA_MODE_DISC ) ) { +#ifdef OMASA_OBJECT_EDITING + if ( hMasaIsmData->ism_dir_is_edited[chB] ) + { + aziDeg = hMasaIsmData->azimuth_ism_edited[chB]; + move16(); + eleDeg = hMasaIsmData->elevation_ism_edited[chB]; + move16(); + } + else + { + aziDeg = hMasaIsmData->azimuth_ism[chB][dirac_read_idx]; + move16(); + eleDeg = hMasaIsmData->elevation_ism[chB][dirac_read_idx]; + move16(); + } +#else aziDeg = hMasaIsmData->azimuth_ism[chB][dirac_read_idx]; move16(); eleDeg = hMasaIsmData->elevation_ism[chB][dirac_read_idx]; move16(); +#endif } ELSE { +#ifdef OMASA_OBJECT_EDITING + if ( ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ && hMasaIsmData->ism_dir_is_edited[hMasaIsmData->idx_separated_ism] ) + { + aziDeg = hMasaIsmData->azimuth_ism_edited[hMasaIsmData->idx_separated_ism]; + move16(); + eleDeg = hMasaIsmData->elevation_ism_edited[hMasaIsmData->idx_separated_ism]; + move16(); + } + else + { + aziDeg = hMasaIsmData->azimuth_separated_ism[dirac_read_idx]; + move16(); + eleDeg = hMasaIsmData->elevation_separated_ism[dirac_read_idx]; + move16(); + } +#else aziDeg = hMasaIsmData->azimuth_separated_ism[dirac_read_idx]; move16(); eleDeg = hMasaIsmData->elevation_separated_ism[dirac_read_idx]; move16(); +#endif instantChange = 1; move16(); } @@ -4958,6 +5011,53 @@ static void getDirectPartGains_fx( IF( renderStereoOutputInsteadOfBinaural ) /* In stereo (i.e. non-binaural) rendering mode */ { +#ifdef OMASA_OBJECT_EDITING + *lImagp = 0.0f; + *rImagp = 0.0f; + if ( aziDeg == gainCache->azi && eleDeg == gainCache->ele ) + { + *lRealp = gainCache->shVec[0]; /* Reused memory */ + *rRealp = gainCache->shVec[1]; /* Reused memory */ + } + else + { + /* Convert azi and ele to an azi value of the cone of confusion */ + aziRad = (float) aziDeg * PI_OVER_180; + eleRad = (float) eleDeg * PI_OVER_180; + y = ( sinf( aziRad ) * cosf( eleRad ) ); + mappedX = sqrtf( max( 0.0f, 1.0f - ( y * y ) ) ); + aziRadMapped = atan2f( y, mappedX ); + + /* Determine the real valued amplitude panning gains */ + if ( aziRadMapped >= LsAngleRad ) + { /* Left side */ + *lRealp = 1.0f; + *rRealp = 0.0f; + } + else if ( aziRadMapped <= -LsAngleRad ) + { /* Right side */ + *lRealp = 0.0f; + *rRealp = 1.0f; + } + else /* Tangent panning law */ + { + A = tanf( aziRadMapped ) / tanf( LsAngleRad ); + A2 = ( A - 1.0f ) / max( 0.001f, A + 1.0f ); + A3 = 1.0f / ( A2 * A2 + 1.0f ); + *lRealp = sqrtf( A3 ); + *rRealp = sqrtf( 1.0f - A3 ); + } + /* Scaling to have the same expected gain as for the HRTF rendering */ + *lRealp *= SQRT2; + *rRealp *= SQRT2; + + /* Store to gain cache */ + gainCache->azi = aziDeg; + gainCache->ele = eleDeg; + gainCache->shVec[0] = *lRealp; /* Reuse memory */ + gainCache->shVec[1] = *rRealp; /* Reuse memory */ + } +#else /* Convert azi and ele to an azi value of the cone of confusion */ // y = ( sinf( aziRad ) * cosf( eleRad ) ); @@ -5065,6 +5165,7 @@ static void getDirectPartGains_fx( move32(); move32(); move32(); +#endif } ELSE /* In regular binaural rendering mode */ { @@ -5246,6 +5347,688 @@ Word16 configure_reqularization_factor_fx( return reqularizationFactor; } + +#ifdef OMASA_OBJECT_EDITING +/*-------------------------------------------------------------------* + * ivas_omasa_preProcessStereoTransportsForEditedObjects() + * + * + *-------------------------------------------------------------------*/ + +void ivas_omasa_preProcessStereoTransportsForEditedObjects( + Decoder_Struct *st_ivas, + float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + const int16_t nBins, + const int16_t subframe ) +{ + int16_t bin, ch, inCh, outCh, ismDirIndex, slot, band_idx, bin_lo, bin_hi, max_band, n_ism; + SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; + MASA_ISM_DATA_HANDLE hMasaIsmData; +#ifdef OBJ_EDITING_PARAMISM_BIN + PARAM_ISM_DEC_HANDLE hParamIsmDec; +#endif + uint8_t enableCentering; + int16_t dirac_read_idx; + int16_t nSlots; + float panGainsOut[4][2]; + float panGainsIn[4][2]; + float panEnesOut[4][2]; + float panEnesIn[4][2]; + uint8_t ismGainEdited[4]; + uint8_t ismDirEdited[4]; + uint8_t masaGainEdited; +#ifdef OBJ_EDITING_PARAMISM_BIN + uint8_t masaIsmMode; +#endif + + hSpatParamRendCom = st_ivas->hSpatParamRendCom; + hMasaIsmData = st_ivas->hMasaIsmData; +#ifdef OBJ_EDITING_PARAMISM_BIN + hParamIsmDec = st_ivas->hParamIsmDec; + + if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) + { + masaIsmMode = 1u; + } + else + { + masaIsmMode = 0u; + } +#endif + + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_FOA || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA2 || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA3 ) + { + enableCentering = 0; + } + else + { + enableCentering = 1; + } + +#ifdef OBJ_EDITING_PARAMISM_BIN + if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC || st_ivas->ivas_format == ISM_FORMAT ) +#else + if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) +#endif + { + n_ism = st_ivas->nchan_ism; + } + else + { + n_ism = hSpatParamRendCom->numIsmDirections; + } + + for ( ismDirIndex = 0; ismDirIndex < n_ism; ismDirIndex++ ) + { + ismGainEdited[ismDirIndex] = hMasaIsmData->ism_gain_is_edited[ismDirIndex]; + ismDirEdited[ismDirIndex] = hMasaIsmData->ism_dir_is_edited[ismDirIndex]; + } + masaGainEdited = hMasaIsmData->masa_gain_is_edited; + + /* Bypass processing until first object is moved or gained */ + if ( hMasaIsmData->objectsEdited == 0 ) + { + for ( ismDirIndex = 0; ismDirIndex < n_ism; ismDirIndex++ ) + { + if ( ismDirEdited[ismDirIndex] ) + { + hMasaIsmData->objectsEdited = 1; + } + + if ( ismGainEdited[ismDirIndex] ) + { + hMasaIsmData->objectsEdited = 1; + } + } + + if ( masaGainEdited ) + { + hMasaIsmData->objectsEdited = 1; + } + + if ( hMasaIsmData->objectsEdited == 0 ) + { + /* No objects have moved so far */ + return; + } + } + + /* OMASA gaining for discrete OMASA mode with stereo_param/bin_room_param renderer */ + if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + { + /* ISM gaining */ + for ( ch = 0; ch < n_ism; ch++ ) + { + if ( st_ivas->hMasaIsmData->ism_gain_is_edited[ch] ) + { + for ( slot = 0; slot < hSpatParamRendCom->subframe_nbslots[subframe]; slot++ ) + { + float gain; + gain = st_ivas->hMasaIsmData->gain_ism_edited[ch]; + v_multc( inRe[ch + 2][slot], gain, inRe[ch + 2][slot], nBins ); + v_multc( inIm[ch + 2][slot], gain, inIm[ch + 2][slot], nBins ); + } + } + } + + /* MASA gaining */ + for ( ch = 0; ch < 2; ch++ ) + { + if ( masaGainEdited ) + { + for ( slot = 0; slot < hSpatParamRendCom->subframe_nbslots[subframe]; slot++ ) + { + float gain_masa; + gain_masa = st_ivas->hMasaIsmData->gain_masa_edited; + v_multc( inRe[ch][slot], gain_masa, inRe[ch][slot], nBins ); + v_multc( inIm[ch][slot], gain_masa, inIm[ch][slot], nBins ); + } + } + } + } +#ifdef OBJ_EDITING_PARAMISM_BIN + else if ( st_ivas->ivas_format == ISM_FORMAT && st_ivas->hISMDTX.dtx_flag ) /* If dtx on, perform just the smoothing of the processing gains */ + { + float totalTargetEne; + float ismPreprocMtxNew[2][2]; + float ismPreprocMtxIncrement[2][2]; + float nSlotDiv; + float outSlotRe[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + float outSlotIm[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + float eqVal; + + nSlots = hSpatParamRendCom->subframe_nbslots[subframe]; + nSlotDiv = 1.0f / ( (float) nSlots ); + + /* Use diagonal mixing matrix as the instant mixing matrix, to slowly fade away the editing during dtx */ + for ( ch = 0; ch < 2; ch++ ) + { + ismPreprocMtxNew[ch][ch] = 1.0f; + ismPreprocMtxNew[1 - ch][ch] = 0.0f; + } + + /* Determine the highest band */ + max_band = 0; + while ( max_band < MAX_PARAM_ISM_NBANDS && hParamIsmDec->hParamIsm->band_grouping[max_band] < nBins ) + { + max_band++; + } + + /* Init out array */ + for ( int k = 0; k < nSlots; k++ ) + { + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + set_zero( outSlotRe[ch][k], CLDFB_NO_CHANNELS_MAX ); + set_zero( outSlotIm[ch][k], CLDFB_NO_CHANNELS_MAX ); + } + } + + /* Perform the processing in frequency bands */ + for ( band_idx = 0; band_idx < max_band; band_idx++ ) + { + bin_lo = hParamIsmDec->hParamIsm->band_grouping[band_idx]; + bin_hi = min( hParamIsmDec->hParamIsm->band_grouping[band_idx + 1], nBins ); + + /* Determine transport energies */ + totalTargetEne = 0.0f; + for ( slot = 0; slot < nSlots; slot++ ) + { + for ( ch = 0; ch < 2; ch++ ) + { + for ( bin = bin_lo; bin < bin_hi; bin++ ) + { + totalTargetEne += inRe[ch][slot][bin] * inRe[ch][slot][bin]; + totalTargetEne += inIm[ch][slot][bin] * inIm[ch][slot][bin]; + } + } + } + + /* Get increment value for temporal interpolation */ + for ( inCh = 0; inCh < 2; inCh++ ) + { + for ( outCh = 0; outCh < 2; outCh++ ) + { + ismPreprocMtxIncrement[outCh][inCh] = ( ismPreprocMtxNew[outCh][inCh] - hMasaIsmData->ismPreprocMatrix[outCh][inCh][band_idx] ) * nSlotDiv; + } + } + + /* Mix signals */ + hMasaIsmData->preprocEneTarget[band_idx] *= STEREO_PREPROCESS_IIR_FACTOR; + hMasaIsmData->preprocEneRealized[band_idx] *= STEREO_PREPROCESS_IIR_FACTOR; + hMasaIsmData->preprocEneTarget[band_idx] += totalTargetEne; + + for ( outCh = 0; outCh < 2; outCh++ ) + { + for ( slot = 0; slot < nSlots; slot++ ) + { + for ( inCh = 0; inCh < 2; inCh++ ) + { + hMasaIsmData->ismPreprocMatrix[outCh][inCh][band_idx] += ismPreprocMtxIncrement[outCh][inCh]; + for ( bin = bin_lo; bin < bin_hi; bin++ ) + { + outSlotRe[outCh][slot][bin] += inRe[inCh][slot][bin] * hMasaIsmData->ismPreprocMatrix[outCh][inCh][band_idx]; + outSlotIm[outCh][slot][bin] += inIm[inCh][slot][bin] * hMasaIsmData->ismPreprocMatrix[outCh][inCh][band_idx]; + } + } + + for ( bin = bin_lo; bin < bin_hi; bin++ ) + { + hMasaIsmData->preprocEneRealized[band_idx] += ( outSlotRe[outCh][slot][bin] * outSlotRe[outCh][slot][bin] ) + ( outSlotIm[outCh][slot][bin] * outSlotIm[outCh][slot][bin] ); + } + } + } + + eqVal = fminf( 4.0f, sqrtf( hMasaIsmData->preprocEneTarget[band_idx] / fmaxf( 1e-12f, hMasaIsmData->preprocEneRealized[band_idx] ) ) ); + + for ( ch = 0; ch < 2; ch++ ) + { + for ( slot = 0; slot < nSlots; slot++ ) + { + for ( bin = bin_lo; bin < bin_hi; bin++ ) + { + inRe[ch][slot][bin] = outSlotRe[ch][slot][bin] * eqVal; + inIm[ch][slot][bin] = outSlotIm[ch][slot][bin] * eqVal; + } + } + } + } + } +#endif + else /* Other processing modes */ + { + float subframeEne; + float subframeEneCh[2]; + float normEnes[2]; + float ratioAccOrig; + float ratioAccNew; + float ratio; + float ismEneThis; + float ismTargetEneThis; + float ismTargetEneThisCh[2]; + float totalTargetEneCh[2]; + float totalTargetEne; + float masaTargetEneThisCh[2]; + float ismPreprocMtxNew[2][2]; + float ismPreprocMtxIncrement[2][2]; + float eneMove[2]; + float enePreserve[2]; + float ismRatioAcc; + float remainderNormEne; + float centeringFactor; + float eneMoveThis; + float enePreserveThis; + float normVal; + float eqVal; + float outSlotRe[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + float outSlotIm[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + float newRatios[6]; + float gainIsmThis; + float gainMasaPow2; + float nSlotDiv; + float tempDivisor; + float masaEneThisCh[2]; + float ratioAccNewDivisor; + + + gainMasaPow2 = 1.0f; + if ( masaGainEdited ) + { + gainMasaPow2 = hMasaIsmData->gain_masa_edited; + gainMasaPow2 *= gainMasaPow2; + } + + nSlots = hSpatParamRendCom->subframe_nbslots[subframe]; + dirac_read_idx = hSpatParamRendCom->render_to_md_map[subframe]; + nSlotDiv = 1.0f / ( (float) nSlots ); + + /* Determine panning gains and energies for each object */ + for ( ismDirIndex = 0; ismDirIndex < n_ism; ismDirIndex++ ) + { + /* Get input and output panning gains */ + ivas_get_stereo_panning_gains( hMasaIsmData->azimuth_ism[ismDirIndex][dirac_read_idx], + hMasaIsmData->elevation_ism[ismDirIndex][dirac_read_idx], + panGainsIn[ismDirIndex] ); + + if ( ismDirEdited[ismDirIndex] ) + { + ivas_get_stereo_panning_gains( hMasaIsmData->azimuth_ism_edited[ismDirIndex], + hMasaIsmData->elevation_ism_edited[ismDirIndex], + panGainsOut[ismDirIndex] ); + } + else + { + /* When not edited, input and output pan gains are the same */ + for ( ch = 0; ch < 2; ch++ ) + { + panGainsOut[ismDirIndex][ch] = panGainsIn[ismDirIndex][ch]; + } + } + /* Determine pan enes */ + for ( ch = 0; ch < 2; ch++ ) + { + panEnesOut[ismDirIndex][ch] = panGainsOut[ismDirIndex][ch] * panGainsOut[ismDirIndex][ch]; + panEnesIn[ismDirIndex][ch] = panGainsIn[ismDirIndex][ch] * panGainsIn[ismDirIndex][ch]; + } + } + + /* Determine the highest band */ + max_band = 0; +#ifdef OBJ_EDITING_PARAMISM_BIN + if ( masaIsmMode ) + { +#endif + while ( max_band < MASA_FREQUENCY_BANDS && MASA_band_grouping_24[max_band] < nBins ) + { + max_band++; + } +#ifdef OBJ_EDITING_PARAMISM_BIN + } + else + { + while ( max_band < MAX_PARAM_ISM_NBANDS && hParamIsmDec->hParamIsm->band_grouping[max_band] < nBins ) + { + max_band++; + } + } +#endif + + /* Init out array */ + for ( int k = 0; k < nSlots; k++ ) + { + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + set_zero( outSlotRe[ch][k], CLDFB_NO_CHANNELS_MAX ); + set_zero( outSlotIm[ch][k], CLDFB_NO_CHANNELS_MAX ); + } + } + + /* Perform the processing in frequency bands */ + for ( band_idx = 0; band_idx < max_band; band_idx++ ) + { + ratioAccOrig = 0.0f; + ratioAccNew = 0.0f; + ismRatioAcc = 0.0f; + + set_zero( subframeEneCh, 2 ); + set_zero( ismPreprocMtxNew[0], 2 ); + set_zero( ismPreprocMtxNew[1], 2 ); + set_zero( eneMove, 2 ); + set_zero( enePreserve, 2 ); +#ifdef OBJ_EDITING_PARAMISM_BIN + if ( masaIsmMode ) + { +#endif + bin_lo = MASA_band_grouping_24[band_idx]; + bin_hi = min( MASA_band_grouping_24[band_idx + 1], nBins ); +#ifdef OBJ_EDITING_PARAMISM_BIN + } + else + { + bin_lo = hParamIsmDec->hParamIsm->band_grouping[band_idx]; + bin_hi = min( hParamIsmDec->hParamIsm->band_grouping[band_idx + 1], nBins ); + } +#endif + + /* Determine transport normalized energies and subframe energy */ + for ( slot = 0; slot < nSlots; slot++ ) + { + for ( ch = 0; ch < 2; ch++ ) + { + for ( bin = bin_lo; bin < bin_hi; bin++ ) + { + subframeEneCh[ch] += inRe[ch][slot][bin] * inRe[ch][slot][bin]; + subframeEneCh[ch] += inIm[ch][slot][bin] * inIm[ch][slot][bin]; + } + } + } + subframeEne = subframeEneCh[0] + subframeEneCh[1]; + totalTargetEneCh[0] = subframeEneCh[0]; + totalTargetEneCh[1] = subframeEneCh[1]; + masaEneThisCh[0] = subframeEneCh[0]; + masaEneThisCh[1] = subframeEneCh[1]; + + /* Gain editing */ + /* For each object, estimate new target energy per channel based on the applied gain */ + for ( ismDirIndex = 0; ismDirIndex < n_ism; ismDirIndex++ ) + { + ratio = hMasaIsmData->energy_ratio_ism[ismDirIndex][dirac_read_idx][bin_lo]; + ratioAccOrig += ratio; + + /* Calculate MASA energy as a residual of original channel energies subtracted with ISM energies */ + for ( ch = 0; ch < 2; ch++ ) + { + masaEneThisCh[ch] -= panEnesIn[ismDirIndex][ch] * ratio * subframeEne; + } + + /* Calculate target energy, gained ratio for accumulation, and transports gains, if ism gain is edited */ + if ( ismGainEdited[ismDirIndex] ) + { + gainIsmThis = hMasaIsmData->gain_ism_edited[ismDirIndex]; + /* ISM original energy */ + ismEneThis = ratio * subframeEne; + + /* ISM target energy */ + ismTargetEneThis = ( gainIsmThis * gainIsmThis ) * ismEneThis; + + ratio *= gainIsmThis * gainIsmThis; + + /* Determine panning energies and channel target energies */ + for ( ch = 0; ch < 2; ch++ ) + { + ismTargetEneThisCh[ch] = panEnesIn[ismDirIndex][ch] * ismTargetEneThis; /* Ism target energy per channel */ + totalTargetEneCh[ch] -= panEnesIn[ismDirIndex][ch] * ismEneThis; /* Reduce original ism energy */ + totalTargetEneCh[ch] += ismTargetEneThisCh[ch]; /* Add ism target energy per channel */ + } + + /* If separated ism edited, apply gain directly to the separated ism */ + if ( ismDirIndex == hMasaIsmData->idx_separated_ism ) + { + /* Separated object gaining is done elsewhere with DIRAC renderer */ + if ( st_ivas->renderer_type != RENDERER_DIRAC ) + { + /* Gain transport channel of separated ism */ + for ( slot = 0; slot < nSlots; slot++ ) + { + for ( bin = bin_lo; bin < bin_hi; bin++ ) + { + inRe[2][slot][bin] = gainIsmThis * inRe[2][slot][bin]; + inIm[2][slot][bin] = gainIsmThis * inIm[2][slot][bin]; + } + } + } + } + } + ratioAccNew += ratio; + } + +#ifdef OBJ_EDITING_PARAMISM_BIN + if ( masaIsmMode ) + { +#endif + /* MASA original ratios */ + ratio = hSpatParamRendCom->energy_ratio1[dirac_read_idx][bin_lo] + hSpatParamRendCom->energy_ratio2[dirac_read_idx][bin_lo]; + ratioAccOrig += ratio; + + /* Estimate MASA original energies and determine adjusted target energies and gained ratio for accumulation, if a gain is applied to MASA */ + if ( masaGainEdited ) + { + /* Gained MASA ratio */ + ratio *= gainMasaPow2; + + /* Calculate MASA target energies and add to total target energy estimation */ + for ( ch = 0; ch < 2; ch++ ) + { + masaEneThisCh[ch] = fmaxf( masaEneThisCh[ch], 0.0f ); /* MASA original energy per channel */ + masaTargetEneThisCh[ch] = gainMasaPow2 * masaEneThisCh[ch]; /* MASA target energy per channel */ + totalTargetEneCh[ch] -= masaEneThisCh[ch]; /* Reduce original energy per channel */ + totalTargetEneCh[ch] += masaTargetEneThisCh[ch]; /* Add target energy per channel */ + } + } + + ratioAccNew += ratio; +#ifdef OBJ_EDITING_PARAMISM_BIN + } +#endif + + /* Limit target energies to non-negative values */ + for ( ch = 0; ch < 2; ch++ ) + { + totalTargetEneCh[ch] = max( totalTargetEneCh[ch], 0.0f ); + } + + /* Diffuse ratio accumulation based on gaining */ + if ( masaGainEdited ) + { + ratioAccNew += gainMasaPow2 * ( 1 - ratioAccOrig ); + } + else + { + ratioAccNew += ( 1.0f - ratioAccOrig ); + } + + ratioAccNewDivisor = 1.0f / fmaxf( 1e-12f, ratioAccNew ); /* New target total energy ratio divider */ + + /* Determine and process object energy ratios based on gaining */ + for ( ismDirIndex = 0; ismDirIndex < n_ism; ismDirIndex++ ) + { + newRatios[ismDirIndex + 2] = hMasaIsmData->energy_ratio_ism_fx[ismDirIndex][dirac_read_idx][bin_lo]; /* Determine original object energy ratio */ + if ( ismGainEdited[ismDirIndex] ) + { + gainIsmThis = hMasaIsmData->gain_ism_edited[ismDirIndex]; + newRatios[ismDirIndex + 2] *= ( gainIsmThis * gainIsmThis ); /* Gain original object energy ratio, if edited */ + } + newRatios[ismDirIndex + 2] *= ratioAccNewDivisor; /* Divide with new target total ratio */ + } + + /* Determine and process MASA energy ratios based on gaining */ + newRatios[0] = hSpatParamRendCom->energy_ratio1_fx[dirac_read_idx][bin_lo]; + newRatios[1] = hSpatParamRendCom->energy_ratio2_fx[dirac_read_idx][bin_lo]; + if ( masaGainEdited ) + { + newRatios[0] *= gainMasaPow2; + newRatios[1] *= gainMasaPow2; + } + newRatios[0] *= ratioAccNewDivisor; + newRatios[1] *= ratioAccNewDivisor; + + /* Set adjusted energy ratios */ + for ( bin = bin_lo; bin < bin_hi; bin++ ) + { + for ( ismDirIndex = 0; ismDirIndex < n_ism; ismDirIndex++ ) + { + hMasaIsmData->energy_ratio_ism_fx[ismDirIndex][dirac_read_idx][bin] = newRatios[ismDirIndex + 2]; + } + hSpatParamRendCom->energy_ratio1_fx[dirac_read_idx][bin] = newRatios[0]; + hSpatParamRendCom->energy_ratio2_fx[dirac_read_idx][bin] = newRatios[1]; + } + + /* Direction editing */ + /* Determine new energetic values after gaining */ + totalTargetEne = totalTargetEneCh[0] + totalTargetEneCh[1]; + tempDivisor = 1.0f / fmaxf( 1e-12f, totalTargetEne ); + normEnes[0] = totalTargetEneCh[0] * tempDivisor; + normEnes[1] = totalTargetEneCh[1] * tempDivisor; + + /* For each ismDir, determine moved and preserve energy ratio per channel */ + for ( ismDirIndex = 0; ismDirIndex < n_ism; ismDirIndex++ ) + { + ratio = hMasaIsmData->energy_ratio_ism[ismDirIndex][dirac_read_idx][bin_lo]; + + ismRatioAcc += ratio; + + if ( enableCentering ) + { + centeringFactor = fmaxf( 0.0f, 2.0f * fabsf( panEnesIn[ismDirIndex][0] - panEnesOut[ismDirIndex][0] ) - 1.0f ); + for ( ch = 0; ch < 2; ch++ ) + { + panEnesOut[ismDirIndex][ch] *= ( 1.0f - centeringFactor ); + panEnesOut[ismDirIndex][ch] += 0.5f * centeringFactor; + } + } + + for ( ch = 0; ch < 2; ch++ ) + { + eneMoveThis = fmaxf( 0.0f, panEnesIn[ismDirIndex][ch] - panEnesOut[ismDirIndex][ch] ); + enePreserveThis = panEnesIn[ismDirIndex][ch] - eneMoveThis; + + eneMove[ch] += ratio * eneMoveThis; + enePreserve[ch] += ratio * enePreserveThis; + + /* Subtract object parts from normEnes */ + normEnes[ch] -= panEnesIn[ismDirIndex][ch] * ratio; + } + } + + /* Any remaining (non-object) energy is set to be preserved at both channels */ + remainderNormEne = fmaxf( 0.0f, ( 1.0f - ismRatioAcc ) - normEnes[0] - normEnes[1] ); + + /* Normalize */ + for ( ch = 0; ch < 2; ch++ ) + { + enePreserve[ch] += fmaxf( 0.0f, normEnes[ch] + remainderNormEne / 2.0f ); + normVal = 1.0f / fmaxf( EPSILON, eneMove[ch] + enePreserve[ch] ); + normVal *= fminf( 10.0f, totalTargetEneCh[ch] / fmaxf( EPSILON, subframeEneCh[ch] ) ); + eneMove[ch] *= normVal; + enePreserve[ch] *= normVal; + } + + /* Temporally average target energy */ + hMasaIsmData->eneOrigIIR[band_idx] *= STEREO_PREPROCESS_IIR_FACTOR; + hMasaIsmData->eneOrigIIR[band_idx] += totalTargetEne; + + /* Temporally average energy moving and preserving, and generate the transport signal preprocessing matrix for + * gaining objects and moving objects between left and right */ + for ( ch = 0; ch < 2; ch++ ) + { + hMasaIsmData->eneMoveIIR[ch][band_idx] *= STEREO_PREPROCESS_IIR_FACTOR; + hMasaIsmData->eneMoveIIR[ch][band_idx] += eneMove[ch] * totalTargetEne; + hMasaIsmData->enePreserveIIR[ch][band_idx] *= STEREO_PREPROCESS_IIR_FACTOR; + hMasaIsmData->enePreserveIIR[ch][band_idx] += enePreserve[ch] * totalTargetEne; + normVal = 1.0f / fmaxf( EPSILON, hMasaIsmData->eneOrigIIR[band_idx] ); + ismPreprocMtxNew[ch][ch] = fminf( 4.0f, sqrtf( hMasaIsmData->enePreserveIIR[ch][band_idx] * normVal ) ); + ismPreprocMtxNew[1 - ch][ch] = fminf( 4.0f, sqrtf( hMasaIsmData->eneMoveIIR[ch][band_idx] * normVal ) ); + } + + /* Get increment value for temporal interpolation */ + for ( inCh = 0; inCh < 2; inCh++ ) + { + for ( outCh = 0; outCh < 2; outCh++ ) + { + ismPreprocMtxIncrement[outCh][inCh] = ( ismPreprocMtxNew[outCh][inCh] - hMasaIsmData->ismPreprocMatrix[outCh][inCh][band_idx] ) * nSlotDiv; + } + } + + /* Mix signals */ + hMasaIsmData->preprocEneTarget[band_idx] *= STEREO_PREPROCESS_IIR_FACTOR; + hMasaIsmData->preprocEneRealized[band_idx] *= STEREO_PREPROCESS_IIR_FACTOR; + hMasaIsmData->preprocEneTarget[band_idx] += totalTargetEne; + + for ( outCh = 0; outCh < 2; outCh++ ) + { + for ( slot = 0; slot < nSlots; slot++ ) + { + for ( inCh = 0; inCh < 2; inCh++ ) + { + hMasaIsmData->ismPreprocMatrix[outCh][inCh][band_idx] += ismPreprocMtxIncrement[outCh][inCh]; + for ( bin = bin_lo; bin < bin_hi; bin++ ) + { + outSlotRe[outCh][slot][bin] += inRe[inCh][slot][bin] * hMasaIsmData->ismPreprocMatrix[outCh][inCh][band_idx]; + outSlotIm[outCh][slot][bin] += inIm[inCh][slot][bin] * hMasaIsmData->ismPreprocMatrix[outCh][inCh][band_idx]; + } + } + + for ( bin = bin_lo; bin < bin_hi; bin++ ) + { + hMasaIsmData->preprocEneRealized[band_idx] += ( outSlotRe[outCh][slot][bin] * outSlotRe[outCh][slot][bin] ) + ( outSlotIm[outCh][slot][bin] * outSlotIm[outCh][slot][bin] ); + } + } + } + + eqVal = fminf( 4.0f, sqrtf( hMasaIsmData->preprocEneTarget[band_idx] / fmaxf( 1e-12f, hMasaIsmData->preprocEneRealized[band_idx] ) ) ); + + for ( ch = 0; ch < 2; ch++ ) + { + for ( slot = 0; slot < nSlots; slot++ ) + { + for ( bin = bin_lo; bin < bin_hi; bin++ ) + { + inRe[ch][slot][bin] = outSlotRe[ch][slot][bin] * eqVal; + inIm[ch][slot][bin] = outSlotIm[ch][slot][bin] * eqVal; + } + } + } + } + +#ifdef OBJ_EDITING_PARAMISM_BIN + if ( !masaIsmMode ) + { + int16_t obj_idx1, obj_idx2; + + for ( band_idx = 0; band_idx < hParamIsmDec->hParamIsm->nbands; band_idx++ ) + { + bin_lo = hParamIsmDec->hParamIsm->band_grouping[band_idx]; + bin_hi = hParamIsmDec->hParamIsm->band_grouping[band_idx + 1]; + + obj_idx1 = hParamIsmDec->hParamIsm->obj_indices[band_idx][0][0]; + obj_idx2 = hParamIsmDec->hParamIsm->obj_indices[band_idx][0][1]; + + for ( bin = bin_lo; bin < bin_hi; bin++ ) + { + hSpatParamRendCom->energy_ratio1_fx[dirac_read_idx][bin] = hMasaIsmData->energy_ratio_ism_fx[obj_idx1][dirac_read_idx][bin]; + hSpatParamRendCom->energy_ratio2_fx[dirac_read_idx][bin] = hMasaIsmData->energy_ratio_ism_fx[obj_idx2][dirac_read_idx][bin]; + } + } + } +#endif + } + + return; +} +#else + + /*-------------------------------------------------------------------* * ivas_omasa_preProcessStereoTransportsForMovedObjects_fx() * @@ -5951,6 +6734,8 @@ static void ivas_masa_ext_rend_parambin_internal_fx( return; } +#endif + void ivas_masa_ext_rend_parambin_render_fx( MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA ext rend structure */ COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index 574a6950e..79c29464c 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -2853,10 +2853,17 @@ void ivas_dirac_dec_compute_directional_responses_fx( FOR( dir = 0; dir < hSpatParamRendCom->numIsmDirections; dir++ ) { +#ifdef OMASA_OBJECT_EDITING + IF ( hMasaIsm->ism_dir_is_edited[dir] ) + { + ivas_dirac_dec_get_response( hMasaIsm->azimuth_ism_edited[dir], hMasaIsm->elevation_ism_edited[dir], direct_response_temp_fx, hDirACRend->hOutSetup.ambisonics_order ); + } +#else IF( hMasaIsm->ism_is_edited[dir] ) { ivas_dirac_dec_get_response_fx( hMasaIsm->azimuth_ism_edited[dir], hMasaIsm->elevation_ism_edited[dir], direct_response_temp_fx, hDirACRend->hOutSetup.ambisonics_order, Q29 ); } +#endif ELSE { ivas_dirac_dec_get_response_fx( hMasaIsm->azimuth_ism[dir][md_idx], hMasaIsm->elevation_ism[dir][md_idx], direct_response_temp_fx, hDirACRend->hOutSetup.ambisonics_order, Q29 ); @@ -3104,10 +3111,17 @@ void ivas_dirac_dec_compute_directional_responses_fx( FOR( dir = 0; dir < hSpatParamRendCom->numIsmDirections; dir++ ) { +#ifdef OMASA_OBJECT_EDITING + IF ( hMasaIsm->ism_dir_is_edited[dir] ) + { + vbap_determine_gains( hVBAPdata, direct_response_temp_fx, hMasaIsm->azimuth_ism_edited[dir], hMasaIsm->elevation_ism_edited[dir], 1 ); + } +#else IF( hMasaIsm->ism_is_edited[dir] ) { vbap_determine_gains_fx( hVBAPdata, direct_response_temp_fx, hMasaIsm->azimuth_ism_edited[dir], hMasaIsm->elevation_ism_edited[dir], 1 ); } +#endif ELSE { vbap_determine_gains_fx( hVBAPdata, direct_response_temp_fx, hMasaIsm->azimuth_ism[dir][md_idx], hMasaIsm->elevation_ism[dir][md_idx], 1 ); diff --git a/lib_rend/ivas_objectRenderer_fx.c b/lib_rend/ivas_objectRenderer_fx.c index 463c03158..4d92fd819 100644 --- a/lib_rend/ivas_objectRenderer_fx.c +++ b/lib_rend/ivas_objectRenderer_fx.c @@ -649,6 +649,12 @@ ivas_error TDREND_Update_object_positions_fx( return error; } #endif +#ifdef OBJ_EDITING_INTERFACE + if ( ( error = TDREND_MIX_SRC_SetGain( hBinRendererTd, nS, hIsmMetaData[nS]->gain ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif IF( hIsmMetaData[nS]->non_diegetic_flag ) { @@ -955,6 +961,9 @@ ivas_error ivas_td_binaural_renderer_ext_fx( move32(); hIsmMetaData[0]->radius_fx = currentPos->radius_fx; move32(); +#ifdef OBJ_EDITING_INTERFACE + hIsmMetaData[0]->gain = ONE_IN_Q30; //TODO: check Q value +#endif hIsmMetaData[0]->non_diegetic_flag = currentPos->non_diegetic_flag; move16(); } diff --git a/lib_rend/ivas_objectRenderer_sources_fx.c b/lib_rend/ivas_objectRenderer_sources_fx.c index 90ac586ee..bce7ce409 100644 --- a/lib_rend/ivas_objectRenderer_sources_fx.c +++ b/lib_rend/ivas_objectRenderer_sources_fx.c @@ -49,6 +49,9 @@ static Word16 TDREND_SRC_SPATIAL_GetDirGain_fx( const TDREND_DirAtten_t *DirAtte static Word16 TDREND_SRC_SPATIAL_GetDistGain_fx( const TDREND_DistAtten_t *DistAtten_p, const Word32 Dist_fx, const Word16 Dist_e ); static void TDREND_SRC_SPATIAL_SetDirAtten_fx( TDREND_SRC_SPATIAL_t *SrcSpatial_p, const TDREND_DirAtten_t *DirAtten_p ); static void TDREND_SRC_SPATIAL_SetDistAtten( TDREND_SRC_SPATIAL_t *SrcSpatial_p, const TDREND_DistAtten_t *DistAtten_p ); +#ifdef OBJ_EDITING_INTERFACE +static void TDREND_SRC_SPATIAL_SetGain( const TDREND_SRC_t *Src_p, const float Gain ); +#endif static ivas_error TDREND_SRC_REND_Alloc( TDREND_SRC_REND_t **SrcRend_pp ); static void TDREND_SRC_SPATIAL_Dealloc( TDREND_SRC_SPATIAL_t *SrcSpatial_p ); @@ -129,6 +132,24 @@ ivas_error TDREND_MIX_SRC_SetDir_fx( return IVAS_ERR_OK; } +#ifdef OBJ_EDITING_INTERFACE +/*-------------------------------------------------------------------* + * TDREND_MIX_SRC_SetSourceGain() + * + * Set source gain + --------------------------------------------------------------------*/ + +ivas_error TDREND_MIX_SRC_SetGain( + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ + const int16_t SrcInd, /* i : Source index */ + const float Gain /* i : Gain */ +) +{ + TDREND_SRC_SPATIAL_SetGain( hBinRendererTd->Sources[SrcInd], Gain ); + + return IVAS_ERR_OK; +} +#endif /*-------------------------------------------------------------------* * TDREND_MIX_SRC_SetDirAtten() @@ -680,6 +701,22 @@ static void TDREND_SRC_SPATIAL_SetDistAtten( return; } +#ifdef OBJ_EDITING_INTERFACE +/*-------------------------------------------------------------------* + * TDREND_SRC_SPATIAL_SetGain() + * + * Set the object gain + --------------------------------------------------------------------*/ + +static void TDREND_SRC_SPATIAL_SetGain( + const TDREND_SRC_t *Src_p, /* i : Directional attenuation specification */ + const float Gain /* i : Front-pointing vector */ +) +{ + Src_p->SrcRend_p->SrcGain_p[0] = Gain; +} +#endif + /*-------------------------------------------------------------------* * TDREND_SRC_SPATIAL_GetDirGain() * diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index 68c312ff0..97772fc78 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -778,6 +778,14 @@ ivas_error TDREND_MIX_SRC_SetDir_fx( const Word16 Vec_p_q /* i : Direction vector q */ ); +#ifdef OBJ_EDITING_INTERFACE +ivas_error TDREND_MIX_SRC_SetGain( + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ + const int16_t SrcInd, /* i : Source index */ + const float Gain /* i : Gain */ +); +#endif + ivas_error TDREND_MIX_SRC_SetDirAtten_fx( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ const Word16 SrcInd, /* i : Source index */ -- GitLab From ab85f0a2a7708b0c43da4c1ca6778fed6c1bc759 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 14 Oct 2025 12:21:04 +0200 Subject: [PATCH 03/31] convert some code parts to basop --- lib_dec/ivas_init_dec_fx.c | 2 +- lib_dec/ivas_ism_dec_fx.c | 8 +-- lib_dec/ivas_jbm_dec_fx.c | 22 ++++--- lib_dec/ivas_masa_dec_fx.c | 2 +- lib_dec/ivas_omasa_dec_fx.c | 22 ++++--- lib_dec/ivas_stat_dec.h | 12 ++-- lib_dec/lib_dec_fx.c | 127 +++++++++++++++++++----------------- 7 files changed, 103 insertions(+), 92 deletions(-) diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 531795684..ffdce4af0 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -1872,7 +1872,7 @@ ivas_error ivas_init_decoder_fx( if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) { /* reusing OMASA function for allocating and initializing MASA_ISM rendering handle (even though not in OMASA) */ - if ( ( error = ivas_omasa_data_open( st_ivas ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_omasa_data_open_fx( st_ivas ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_ism_dec_fx.c b/lib_dec/ivas_ism_dec_fx.c index c28b8ffbe..f44b0374e 100644 --- a/lib_dec/ivas_ism_dec_fx.c +++ b/lib_dec/ivas_ism_dec_fx.c @@ -232,7 +232,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( ivas_dirac_dec_close_binaural_data_fx( st_ivas->hDiracDecBin ); #ifdef OBJ_EDITING_PARAMISM_BIN /* Close omasa data struct (used for object editing) */ - ivas_omasa_data_close( &st_ivas->hMasaIsmData ); + ivas_omasa_data_close_fx( &st_ivas->hMasaIsmData ); #endif /* Open the TD Binaural renderer */ @@ -271,7 +271,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( #ifdef OBJ_EDITING_PARAMISM_BIN /* Close omasa data struct (used for object editing) */ - ivas_omasa_data_close( &st_ivas->hMasaIsmData ); + ivas_omasa_data_close_fx( &st_ivas->hMasaIsmData ); #endif /* Open Crend Binaural renderer */ @@ -312,7 +312,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( #ifdef OBJ_EDITING_PARAMISM_BIN /* Open omasa data struct (used for object editing) */ - if ( ( error = ivas_omasa_data_open( st_ivas ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_omasa_data_open_fx( st_ivas ) ) != IVAS_ERR_OK ) { return error; } @@ -347,7 +347,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( #ifdef OBJ_EDITING_PARAMISM_BIN /* Open omasa data struct (used for object editing) */ - if ( ( error = ivas_omasa_data_open( st_ivas ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_omasa_data_open_fx( st_ivas ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index e4b147e79..5646d1f97 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -4654,15 +4654,16 @@ void ivas_jbm_dec_prepare_renderer( IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) ) { #ifdef OMASA_OBJECT_EDITING - float gainIsm; - gainIsm = OMASA_TDREND_MATCHING_GAIN; + Word32 gainIsm; + gainIsm = OMASA_TDREND_MATCHING_GAIN_FX; - if ( st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) + IF ( st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) { - gainIsm *= st_ivas->hMasaIsmData->gain_ism_edited[n]; + //gainIsm *= st_ivas->hMasaIsmData->gain_ism_edited[n]; + assert( 0 && "Insert actual basop code here!"); } - v_multc( st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], gainIsm, st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available ); + v_multc_fixed_16( st_ivas->hTcBuffer->tc_fx[CPE_CHANNELS + n], gainIsm, st_ivas->hTcBuffer->tc_fx[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available ); #else v_multc_fixed_16( st_ivas->hTcBuffer->tc_fx[CPE_CHANNELS + n], OMASA_TDREND_MATCHING_GAIN_FX, st_ivas->hTcBuffer->tc_fx[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available ); #endif @@ -4671,16 +4672,17 @@ void ivas_jbm_dec_prepare_renderer( //TODO: check if tis is a bug in main already } #ifdef OMASA_OBJECT_EDITING - if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) + IF ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) { - int16_t tcBufferSize; + Word16 tcBufferSize; tcBufferSize = st_ivas->hSpatParamRendCom->num_slots * st_ivas->hSpatParamRendCom->slot_size; - if ( st_ivas->hMasaIsmData->masa_gain_is_edited ) + IF ( st_ivas->hMasaIsmData->masa_gain_is_edited ) { - for ( int16_t ch = 0; ch < 2; ch++ ) + FOR ( Word16 ch = 0; ch < 2; ch++ ) { - v_multc( st_ivas->hTcBuffer->tc[ch], st_ivas->hMasaIsmData->gain_masa_edited, st_ivas->hTcBuffer->tc[ch], tcBufferSize ); + //v_multc_fixed_16( st_ivas->hTcBuffer->tc_fx[ch], st_ivas->hMasaIsmData->gain_masa_edited, st_ivas->hTcBuffer->tc_fx[ch], tcBufferSize ); + assert( 0 && "Insert actual basop code here!"); } } } diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c index e1291552a..e6eb495d2 100644 --- a/lib_dec/ivas_masa_dec_fx.c +++ b/lib_dec/ivas_masa_dec_fx.c @@ -839,7 +839,7 @@ ivas_error ivas_masa_dec_open_fx( /* ISM metadata */ #ifdef OMASA_OBJECT_EDITING test(); - IF ( EQ_16(st_ivas->ivas_format, MASA_FORMAT) && NE_16(st_ivas->hIsmMetaData[0], NULL ) ) + IF ( EQ_16(st_ivas->ivas_format, MASA_FORMAT) && st_ivas->hIsmMetaData[0] == NULL ) #else test(); test(); diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index 0198db19a..e84d6b832 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -653,7 +653,7 @@ ivas_error ivas_omasa_dec_config_fx( #ifdef OMASA_OBJECT_EDITING if ( st_ivas->hIsmMetaData[0] == NULL ) { - if ( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nchan_ism, NULL ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_ism_metadata_dec_create_fx( st_ivas, st_ivas->nchan_ism, NULL ) ) != IVAS_ERR_OK ) { return error; } @@ -662,7 +662,7 @@ ivas_error ivas_omasa_dec_config_fx( { for ( k = 0; k < st_ivas->nchan_ism; k++ ) { - ivas_ism_reset_metadata_handle_dec( st_ivas->hIsmMetaData[k] ); + ivas_ism_reset_metadata_handle_dec_fx( st_ivas->hIsmMetaData[k] ); } } #else @@ -1184,14 +1184,16 @@ void ivas_omasa_dirac_rend_jbm_fx( { Copy32( &output_f[CPE_CHANNELS][st_ivas->hTcBuffer->n_samples_rendered], data_separated_objects[0], *nSamplesRendered ); #ifdef OMASA_OBJECT_EDITING - if ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) + IF ( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) { /* Gain separated object, if edited */ - for ( n = 0; n < st_ivas->nchan_ism; n++ ) + FOR ( n = 0; n < st_ivas->nchan_ism; n++ ) { - if ( st_ivas->hMasaIsmData->ism_gain_is_edited[n] && st_ivas->hMasaIsmData->idx_separated_ism == n ) + test(); + IF ( st_ivas->hMasaIsmData->ism_gain_is_edited[n] && EQ_16(st_ivas->hMasaIsmData->idx_separated_ism, n ) ) { - v_multc( data_separated_objects[0], st_ivas->hMasaIsmData->gain_ism_edited[n], data_separated_objects[0], *nSamplesRendered ); + //v_multc( data_separated_objects[0], st_ivas->hMasaIsmData->gain_ism_edited[n], data_separated_objects[0], *nSamplesRendered ); + assert ( 0 && "Insert proper basop code here!"); } } } @@ -1205,9 +1207,10 @@ void ivas_omasa_dirac_rend_jbm_fx( Copy32( &output_f[n + CPE_CHANNELS][st_ivas->hTcBuffer->n_samples_rendered], data_separated_objects[n], *nSamplesRendered ); #ifdef OMASA_OBJECT_EDITING /* Gain discrete objects, if edited */ - if ( st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) + IF ( st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) { - v_multc( data_separated_objects[n], st_ivas->hMasaIsmData->gain_ism_edited[n], data_separated_objects[n], *nSamplesRendered ); + //v_multc( data_separated_objects[n], st_ivas->hMasaIsmData->gain_ism_edited[n], data_separated_objects[n], *nSamplesRendered ); + assert( 00 && "Insert proper basop code here!"); } #endif } @@ -1217,7 +1220,8 @@ void ivas_omasa_dirac_rend_jbm_fx( { for ( int16_t ch = 0; ch < 2; ch++ ) { - v_multc( output_f[ch], st_ivas->hMasaIsmData->gain_masa_edited, output_f[ch], *nSamplesRendered ); + //v_multc( output_f[ch], st_ivas->hMasaIsmData->gain_masa_edited, output_f[ch], *nSamplesRendered ); + assert( 00 && "Insert proper basop code here!"); } } #endif diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 3fa9c4452..494c8739b 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -987,12 +987,12 @@ typedef struct ivas_masa_ism_data_structure #ifdef OMASA_OBJECT_EDITING UWord16 objectsEdited; - Word32 preprocEneTarget[MASA_FREQUENCY_BANDS]; /*Q-19*/ - Word32 preprocEneRealized[MASA_FREQUENCY_BANDS]; /*Q-19*/ - Word32 ismPreprocMatrix[2][2][MASA_FREQUENCY_BANDS]; /*Q-15*/ - Word32 eneMoveIIR[2][MASA_FREQUENCY_BANDS]; /*Q-22*/ - Word32 enePreserveIIR[2][MASA_FREQUENCY_BANDS]; /*Q-22*/ - Word32 eneOrigIIR[MASA_FREQUENCY_BANDS]; + Word32 preprocEneTarget_fx[MASA_FREQUENCY_BANDS]; /*Q-19*/ + Word32 preprocEneRealized_fx[MASA_FREQUENCY_BANDS]; /*Q-19*/ + Word32 ismPreprocMatrix_fx[2][2][MASA_FREQUENCY_BANDS]; /*Q-15*/ + Word32 eneMoveIIR_fx[2][MASA_FREQUENCY_BANDS]; /*Q-22*/ + Word32 enePreserveIIR_fx[2][MASA_FREQUENCY_BANDS]; /*Q-22*/ + Word32 eneOrigIIR_fx[MASA_FREQUENCY_BANDS]; Word16 bits_ism[MAX_NUM_OBJECTS]; #else Word16 ismPreprocMatrix_fx[2][2][CLDFB_NO_CHANNELS_MAX]; /* Q15 */ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index e11aaf32d..f1990f69b 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -3902,7 +3902,7 @@ ivas_error IVAS_DEC_GetSamplesDecoder( IF ( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) #else IF( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) -#edndif +#endif { Word16 obj; ISM_METADATA_HANDLE *hIsmMetaData = hIvasDec->st_ivas->hIsmMetaData; @@ -3951,7 +3951,8 @@ ivas_error IVAS_DEC_GetSamplesDecoder( ivas_error IVAS_DEC_GetEditableParameters( IVAS_DEC_HANDLE hIvasDec, - IVAS_EDITABLE_PARAMETERS *hIvasEditableParameters ) + IVAS_EDITABLE_PARAMETERS *hIvasEditableParameters +) { ivas_error error; #ifdef OMASA_OBJECT_EDITING @@ -4055,7 +4056,7 @@ ivas_error IVAS_DEC_GetEditableParameters( /* reset the otherwise unused "gain" field for the object */ hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain_fx = ONE_IN_Q31; //TODO: check Q value - hIvasEditableParameters->ism_metadata[obj].gain = hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain_fx; + hIvasEditableParameters->ism_metadata[obj].gain_fx = hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain_fx; hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = hIvasDec->st_ivas->hIsmMetaData[obj]->non_diegetic_flag; } } @@ -4076,13 +4077,13 @@ ivas_error IVAS_DEC_GetEditableParameters( hIvasEditableParameters->ism_metadata[obj].azimuth = hIvasDec->st_ivas->hMasaIsmData->azimuth_ism[obj][dirac_read_idx]; hIvasEditableParameters->ism_metadata[obj].elevation = hIvasDec->st_ivas->hMasaIsmData->elevation_ism[obj][dirac_read_idx]; - hIvasEditableParameters->ism_metadata[obj].yaw_fx = hIvasDec->st_ivas->hIsmMetaData[obj]->yaw; - hIvasEditableParameters->ism_metadata[obj].pitch_fx = hIvasDec->st_ivas->hIsmMetaData[obj]->pitch; - hIvasEditableParameters->ism_metadata[obj].radius_fx = hIvasDec->st_ivas->hIsmMetaData[obj]->radius; + hIvasEditableParameters->ism_metadata[obj].yaw_fx = hIvasDec->st_ivas->hIsmMetaData[obj]->yaw_fx; + hIvasEditableParameters->ism_metadata[obj].pitch_fx = hIvasDec->st_ivas->hIsmMetaData[obj]->pitch_fx; + hIvasEditableParameters->ism_metadata[obj].radius_fx = hIvasDec->st_ivas->hIsmMetaData[obj]->radius_fx; /* reset the otherwise unused "gain" field for the object */ hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain_fx = ONE_IN_Q31; - hIvasEditableParameters->ism_metadata[obj].gain = hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain; + hIvasEditableParameters->ism_metadata[obj].gain_fx = hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain_fx; hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = hIvasDec->st_ivas->hIsmMetaData[obj]->non_diegetic_flag; } } @@ -4107,11 +4108,11 @@ ivas_error IVAS_DEC_SetEditableParameters( { ivas_error error; #ifdef OMASA_OBJECT_EDITING - int16_t dirac_read_idx; + Word16 dirac_read_idx; #endif - if ( !( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || + IF ( !( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || ( hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT && hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) || ( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT && ( hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) ) || hIvasDec->st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) @@ -4119,7 +4120,8 @@ ivas_error IVAS_DEC_SetEditableParameters( return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Object editing no supported in this operation mode." ); } - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + test(); + IF ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } @@ -4130,12 +4132,14 @@ ivas_error IVAS_DEC_SetEditableParameters( assert( hIvasEditableParameters.num_obj == hIvasDec->st_ivas->nchan_ism ); #endif - if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) + test(); + IF ( EQ_16(hIvasDec->st_ivas->ivas_format, ISM_FORMAT) || EQ_16( hIvasDec->st_ivas->ivas_format, SBA_ISM_FORMAT ) ) { - if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + test(); + IF ( EQ_16( hIvasDec->st_ivas->ism_mode, ISM_MODE_DISC ) || EQ_16( hIvasDec->st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) { - int16_t obj; - for ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) + Word16 obj; + FOR ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) { hIvasDec->st_ivas->hIsmMetaData[obj]->edited_azimuth_fx = hIvasEditableParameters.ism_metadata[obj].azimuth_fx; hIvasDec->st_ivas->hIsmMetaData[obj]->edited_elevation_fx = hIvasEditableParameters.ism_metadata[obj].elevation_fx; @@ -4149,40 +4153,40 @@ ivas_error IVAS_DEC_SetEditableParameters( hIvasDec->st_ivas->hIsmMetaData[obj]->non_diegetic_flag = hIvasEditableParameters.ism_metadata[obj].non_diegetic_flag; } - if ( hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + IF ( hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { hIvasDec->st_ivas->hSbaIsmData->gain_bed_fx = hIvasEditableParameters.gain_bed_fx; } } - else if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) + ELSE IF ( EQ_16( hIvasDec->st_ivas->ism_mode, ISM_MODE_PARAM ) ) { int16_t obj; - for ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) + FOR ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) { #ifdef OBJ_EDITING_PARAMISM_BIN - hIvasDec->st_ivas->hParamIsmDec->edited_azimuth_values[obj] = hIvasEditableParameters.ism_metadata[obj].azimuth; - hIvasDec->st_ivas->hParamIsmDec->edited_elevation_values[obj] = hIvasEditableParameters.ism_metadata[obj].elevation; - hIvasDec->st_ivas->hMasaIsmData->gain_ism_edited[obj] = hIvasEditableParameters.ism_metadata[obj].gain; + hIvasDec->st_ivas->hParamIsmDec->edited_azimuth_values_fx[obj] = hIvasEditableParameters.ism_metadata[obj].azimuth; + hIvasDec->st_ivas->hParamIsmDec->edited_elevation_values_fx[obj] = hIvasEditableParameters.ism_metadata[obj].elevation; + hIvasDec->st_ivas->hMasaIsmData->gain_ism_edited[obj] = hIvasEditableParameters.ism_metadata[obj].gain_fx; /* Detect direction editing in Param-ISM mode */ - if ( fabsf( hIvasDec->st_ivas->hParamIsmDec->azimuth_values[obj] - hIvasEditableParameters.ism_metadata[obj].azimuth ) > OMASA_AZI_EDIT_THR || - fabsf( hIvasDec->st_ivas->hParamIsmDec->elevation_values[obj] - hIvasEditableParameters.ism_metadata[obj].elevation ) > OMASA_ELE_EDIT_THR ) + IF ( fabsf( hIvasDec->st_ivas->hParamIsmDec->azimuth_values_fx[obj] - hIvasEditableParameters.ism_metadata[obj].azimuth ) > OMASA_AZI_EDIT_THR || + fabsf( hIvasDec->st_ivas->hParamIsmDec->elevation_values_fx[obj] - hIvasEditableParameters.ism_metadata[obj].elevation ) > OMASA_ELE_EDIT_THR ) { - hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited[obj] = 1u; + hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited[obj] = 1; } - else + ELSE { - hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited[obj] = 0u; + hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited[obj] = 0; } /* Detect gain editing in Param-ISM mode */ - if ( fabsf( 1.0f - hIvasEditableParameters.ism_metadata[obj].gain ) > OMASA_GAIN_EDIT_THR ) + IF ( fabsf( 1.0f - hIvasEditableParameters.ism_metadata[obj].gain_fx ) > OMASA_GAIN_EDIT_THR ) { - hIvasDec->st_ivas->hMasaIsmData->ism_gain_is_edited[obj] = 1u; + hIvasDec->st_ivas->hMasaIsmData->ism_gain_is_edited[obj] = 1; } - else + ELSE { - hIvasDec->st_ivas->hMasaIsmData->ism_gain_is_edited[obj] = 0u; + hIvasDec->st_ivas->hMasaIsmData->ism_gain_is_edited[obj] = 0; } #endif } @@ -4197,45 +4201,45 @@ ivas_error IVAS_DEC_SetEditableParameters( } } #ifdef OMASA_OBJECT_EDITING - else if ( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT && ( hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) + ELSE IF ( EQ_16(hIvasDec->st_ivas->ivas_format, MASA_ISM_FORMAT) && ( EQ_16( hIvasDec->st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) || EQ_16( hIvasDec->st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) ) { - int16_t obj; - int32_t id_th; - float threshold_azi, threshold_ele; + Word16 obj; + Word32 id_th; + Word32 threshold_azi, threshold_ele; - for ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) + FOR ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) { - if ( hIvasDec->st_ivas->hMasaIsmData != NULL ) + IF ( hIvasDec->st_ivas->hMasaIsmData != NULL ) { /* copy relevant fields also to OMASA structs, but only if the value has been changed. original values are in st_ivas->hIsmMetaData */ /* first, need to convert float values to ints used internally */ - int16_t new_azi, new_ele; - if ( hIvasEditableParameters.ism_metadata[obj].azimuth > 0.0f ) + Word16 new_azi, new_ele; + IF ( hIvasEditableParameters.ism_metadata[obj].azimuth > 0.0f ) { new_azi = (int16_t) ( hIvasEditableParameters.ism_metadata[obj].azimuth + 0.5f ); } - else + ELSE { new_azi = (int16_t) ( hIvasEditableParameters.ism_metadata[obj].azimuth - 0.5f ); } - if ( hIvasEditableParameters.ism_metadata[obj].elevation > 0.0f ) + IF ( hIvasEditableParameters.ism_metadata[obj].elevation > 0.0f ) { new_ele = (int16_t) ( hIvasEditableParameters.ism_metadata[obj].elevation + 0.5f ); } - else + ELSE { new_ele = (int16_t) ( hIvasEditableParameters.ism_metadata[obj].elevation - 0.5f ); } - if ( hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) + IF ( EQ_16( hIvasDec->st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) { /* Handle MONO output */ - if ( hIvasDec->st_ivas->renderer_type != RENDERER_MONO_DOWNMIX ) + IF ( NE_16( hIvasDec->st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) ) { dirac_read_idx = hIvasDec->st_ivas->hSpatParamRendCom->render_to_md_map[hIvasDec->st_ivas->hSpatParamRendCom->subframes_rendered]; } - else + ELSE { dirac_read_idx = 0; } @@ -4249,7 +4253,7 @@ ivas_error IVAS_DEC_SetEditableParameters( threshold_azi = 360.0f / (float) no_phi_masa[hIvasDec->st_ivas->hMasaIsmData->bits_ism[obj] - 1][id_th]; threshold_ele = delta_theta_masa[hIvasDec->st_ivas->hMasaIsmData->bits_ism[obj] - 3]; - if ( ( (float) abs( new_azi - hIvasDec->st_ivas->hMasaIsmData->azimuth_ism[obj][dirac_read_idx] ) > threshold_azi ) || + IF ( ( (float) abs( new_azi - hIvasDec->st_ivas->hMasaIsmData->azimuth_ism[obj][dirac_read_idx] ) > threshold_azi ) || ( (float) abs( new_ele - hIvasDec->st_ivas->hMasaIsmData->elevation_ism[obj][dirac_read_idx] ) > threshold_ele ) ) { /* at least one of the threshold is exceeded, so use new direction value and set editing detection flag */ @@ -4258,59 +4262,60 @@ ivas_error IVAS_DEC_SetEditableParameters( hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited[obj] = 1u; } - else + ELSE { hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited[obj] = 0u; } } - else + ELSE { /* detect editing in ISM_MASA_MODE_DISC. optionally, add quantization-resolution -based thresholds */ - if ( fabsf( hIvasDec->st_ivas->hIsmMetaData[obj]->azimuth - hIvasEditableParameters.ism_metadata[obj].azimuth ) > OMASA_AZI_EDIT_THR || - fabsf( hIvasDec->st_ivas->hIsmMetaData[obj]->elevation - hIvasEditableParameters.ism_metadata[obj].elevation ) > OMASA_ELE_EDIT_THR ) + IF ( fabsf( hIvasDec->st_ivas->hIsmMetaData[obj]->azimuth_fx - hIvasEditableParameters.ism_metadata[obj].azimuth_fx ) > OMASA_AZI_EDIT_THR || + fabsf( hIvasDec->st_ivas->hIsmMetaData[obj]->elevation_fx - hIvasEditableParameters.ism_metadata[obj].elevation_fx ) > OMASA_ELE_EDIT_THR ) { hIvasDec->st_ivas->hMasaIsmData->azimuth_ism_edited[obj] = new_azi; hIvasDec->st_ivas->hMasaIsmData->elevation_ism_edited[obj] = new_ele; hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited[obj] = 1u; } - else + ELSE { hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited[obj] = 0u; } } /* compare pre-edit gain and the edited one to detect editing */ - if ( fabsf( hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain - hIvasEditableParameters.ism_metadata[obj].gain ) > OMASA_GAIN_EDIT_THR ) + IF ( fabsf( hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain - hIvasEditableParameters.ism_metadata[obj].gain ) > OMASA_GAIN_EDIT_THR ) { hIvasDec->st_ivas->hMasaIsmData->ism_gain_is_edited[obj] = 1u; hIvasDec->st_ivas->hMasaIsmData->gain_ism_edited[obj] = hIvasEditableParameters.ism_metadata[obj].gain; } - else + ELSE { hIvasDec->st_ivas->hMasaIsmData->ism_gain_is_edited[obj] = 0u; } } /* Copy edited values to hIsmMetaData struct */ - if ( hIvasDec->st_ivas->hIsmMetaData[obj] != NULL ) + IF ( hIvasDec->st_ivas->hIsmMetaData[obj] != NULL ) { - hIvasDec->st_ivas->hIsmMetaData[obj]->azimuth = hIvasEditableParameters.ism_metadata[obj].azimuth; - hIvasDec->st_ivas->hIsmMetaData[obj]->elevation = hIvasEditableParameters.ism_metadata[obj].elevation; - hIvasDec->st_ivas->hIsmMetaData[obj]->yaw = hIvasEditableParameters.ism_metadata[obj].yaw; - hIvasDec->st_ivas->hIsmMetaData[obj]->pitch = hIvasEditableParameters.ism_metadata[obj].pitch; - hIvasDec->st_ivas->hIsmMetaData[obj]->radius = hIvasEditableParameters.ism_metadata[obj].radius; - hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain = hIvasEditableParameters.ism_metadata[obj].gain; + hIvasDec->st_ivas->hIsmMetaData[obj]->azimuth_fx = hIvasEditableParameters.ism_metadata[obj].azimuth_fx; + hIvasDec->st_ivas->hIsmMetaData[obj]->elevation_fx = hIvasEditableParameters.ism_metadata[obj].elevation_fx; + hIvasDec->st_ivas->hIsmMetaData[obj]->yaw_fx = hIvasEditableParameters.ism_metadata[obj].yaw_fx; + hIvasDec->st_ivas->hIsmMetaData[obj]->pitch_fx = hIvasEditableParameters.ism_metadata[obj].pitch_fx; + hIvasDec->st_ivas->hIsmMetaData[obj]->radius_fx = hIvasEditableParameters.ism_metadata[obj].radius_fx; + hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain_fx = hIvasEditableParameters.ism_metadata[obj].gain_fx; hIvasDec->st_ivas->hIsmMetaData[obj]->non_diegetic_flag = hIvasEditableParameters.ism_metadata[obj].non_diegetic_flag; } } - if ( fabsf( hIvasEditableParameters.gain_bed - 1.0f ) > OMASA_GAIN_EDIT_THR ) + IF ( L_abs( sub(hIvasEditableParameters.gain_bed_fx, ONE_IN_Q30) ) > OMASA_GAIN_EDIT_THR ) //TODO: check Q value { - hIvasDec->st_ivas->hMasaIsmData->gain_masa_edited = hIvasEditableParameters.gain_bed; + hIvasDec->st_ivas->hMasaIsmData->gain_masa_edited = hIvasEditableParameters.gain_bed_fx; //TODO: check type + move32(); hIvasDec->st_ivas->hMasaIsmData->masa_gain_is_edited = 1u; } - else + ELSE { hIvasDec->st_ivas->hMasaIsmData->masa_gain_is_edited = 0u; } -- GitLab From 1b4497f0c0f4d895e86ec95b205501f8850a2601 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 14 Oct 2025 12:59:56 +0200 Subject: [PATCH 04/31] continue preliminary basop conversion --- lib_com/ivas_cnst.h | 7 +- lib_com/ivas_prot_fx.h | 3 +- lib_dec/ivas_stat_dec.h | 6 +- lib_dec/lib_dec_fx.c | 31 ++- .../ivas_dirac_dec_binaural_functions_fx.c | 261 +++++++++--------- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 4 +- 6 files changed, 162 insertions(+), 150 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 5414adafc..547bd374f 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1326,10 +1326,11 @@ enum #define MASA_MAXIMUM_TWO_DIR_BANDS 24 #define NBITS_HR_COH 4 #define OMASA_TDREND_MATCHING_GAIN_FX 26026 +//TODO: insert proper Q representations #ifdef OMASA_OBJECT_EDITING -#define OMASA_GAIN_EDIT_THR 0.06f /* OMASA gain change threshold */ -#define OMASA_AZI_EDIT_THR 1.0f /* OMASA-DISC azimuth change threshold */ -#define OMASA_ELE_EDIT_THR 2.0f /* OMASA-DISC elevation change threshold */ +#define OMASA_GAIN_EDIT_THR_FX 0 /* OMASA gain change threshold */ +#define OMASA_AZI_EDIT_THR_FX 1 /* OMASA-DISC azimuth change threshold */ +#define OMASA_ELE_EDIT_THR_FX 2 /* OMASA-DISC elevation change threshold */ #endif #define MASA_INV_ANGLE_AT_EQUATOR_DEG_Q30 (1453366656l) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 1bc7c574a..80155e5a6 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -3947,7 +3947,8 @@ void ivas_omasa_preProcessStereoTransportsForMovedObjects_fx( Word32 inIm_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /*cldfb_buf_q*/ Word16 *cldfb_buf_q, const Word16 nBins, - const Word16 subframe ); + const Word16 subframe +); void ivas_omasa_decode_masa_to_total_fx( diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 494c8739b..ff10ddda1 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -968,14 +968,14 @@ typedef struct ivas_masa_ism_data_structure UWord8 ism_is_edited[MAX_NUM_OBJECTS]; #endif #ifdef OBJ_EDITING_API - Word32 gain_ism[MAX_NUM_OBJECTS]; + Word32 gain_ism_fx[MAX_NUM_OBJECTS]; Word32 gain_masa; #endif #ifdef OMASA_OBJECT_EDITING - Word32 gain_ism_edited[MAX_NUM_OBJECTS]; + Word32 gain_ism_edited_fx[MAX_NUM_OBJECTS]; UWord8 ism_gain_is_edited[MAX_NUM_OBJECTS]; - UWord32 gain_masa_edited; + UWord32 gain_masa_edited_fx; UWord8 masa_gain_is_edited; #endif Word16 idx_separated_ism; diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index f1990f69b..6c51a99d0 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -4166,11 +4166,11 @@ ivas_error IVAS_DEC_SetEditableParameters( #ifdef OBJ_EDITING_PARAMISM_BIN hIvasDec->st_ivas->hParamIsmDec->edited_azimuth_values_fx[obj] = hIvasEditableParameters.ism_metadata[obj].azimuth; hIvasDec->st_ivas->hParamIsmDec->edited_elevation_values_fx[obj] = hIvasEditableParameters.ism_metadata[obj].elevation; - hIvasDec->st_ivas->hMasaIsmData->gain_ism_edited[obj] = hIvasEditableParameters.ism_metadata[obj].gain_fx; + hIvasDec->st_ivas->hMasaIsmData->gain_ism_edited_fx[obj] = hIvasEditableParameters.ism_metadata[obj].gain_fx; /* Detect direction editing in Param-ISM mode */ - IF ( fabsf( hIvasDec->st_ivas->hParamIsmDec->azimuth_values_fx[obj] - hIvasEditableParameters.ism_metadata[obj].azimuth ) > OMASA_AZI_EDIT_THR || - fabsf( hIvasDec->st_ivas->hParamIsmDec->elevation_values_fx[obj] - hIvasEditableParameters.ism_metadata[obj].elevation ) > OMASA_ELE_EDIT_THR ) + IF ( GT_16( L_abs( L_sub( hIvasDec->st_ivas->hParamIsmDec->azimuth_values_fx[obj], hIvasEditableParameters.ism_metadata[obj].azimuth ) ), OMASA_AZI_EDIT_THR_FX ) || + GT_16( L_abs( L_sub( hIvasDec->st_ivas->hParamIsmDec->elevation_values_fx[obj], hIvasEditableParameters.ism_metadata[obj].elevation ) ), OMASA_ELE_EDIT_THR_FX ) ) { hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited[obj] = 1; } @@ -4180,7 +4180,7 @@ ivas_error IVAS_DEC_SetEditableParameters( } /* Detect gain editing in Param-ISM mode */ - IF ( fabsf( 1.0f - hIvasEditableParameters.ism_metadata[obj].gain_fx ) > OMASA_GAIN_EDIT_THR ) + IF (GT_32( L_abs( L_sub( ONE_IN_Q30, hIvasEditableParameters.ism_metadata[obj].gain_fx ) ), OMASA_GAIN_EDIT_THR_FX ) ) // TODO: check Q values { hIvasDec->st_ivas->hMasaIsmData->ism_gain_is_edited[obj] = 1; } @@ -4249,12 +4249,15 @@ ivas_error IVAS_DEC_SetEditableParameters( * which in turn depends from the object priority and importance: * importance -> priority -> number of bits -> elevation resolution -> elevation ring index -> azimuth resolution. * leading to elevation_resolution -> elevation threshold and azimuth resolution -> azimuth threshold */ - id_th = (int) ( fabsf( (float) hIvasDec->st_ivas->hMasaIsmData->elevation_ism[obj][dirac_read_idx] ) / delta_theta_masa[hIvasDec->st_ivas->hMasaIsmData->bits_ism[obj] - 3] + 0.5f ); + //id_th = ( fabsf( (float) hIvasDec->st_ivas->hMasaIsmData->elevation_ism[obj][dirac_read_idx] ) / delta_theta_masa[hIvasDec->st_ivas->hMasaIsmData->bits_ism[obj] - 3] + 0.5f ); + assert(0 && "Insert proper basop code here!"); threshold_azi = 360.0f / (float) no_phi_masa[hIvasDec->st_ivas->hMasaIsmData->bits_ism[obj] - 1][id_th]; - threshold_ele = delta_theta_masa[hIvasDec->st_ivas->hMasaIsmData->bits_ism[obj] - 3]; + threshold_ele = delta_theta_masa_fx[hIvasDec->st_ivas->hMasaIsmData->bits_ism[obj] - 3]; - IF ( ( (float) abs( new_azi - hIvasDec->st_ivas->hMasaIsmData->azimuth_ism[obj][dirac_read_idx] ) > threshold_azi ) || - ( (float) abs( new_ele - hIvasDec->st_ivas->hMasaIsmData->elevation_ism[obj][dirac_read_idx] ) > threshold_ele ) ) + test(); + IF ( ( GT_32( L_abs( L_sub(new_azi, hIvasDec->st_ivas->hMasaIsmData->azimuth_ism[obj][dirac_read_idx]) ), threshold_azi ) ) || + ( GT_32( L_abs( L_sub(new_ele, hIvasDec->st_ivas->hMasaIsmData->elevation_ism[obj][dirac_read_idx]) ), threshold_ele ) ) + ) { /* at least one of the threshold is exceeded, so use new direction value and set editing detection flag */ hIvasDec->st_ivas->hMasaIsmData->azimuth_ism_edited[obj] = new_azi; @@ -4270,8 +4273,8 @@ ivas_error IVAS_DEC_SetEditableParameters( ELSE { /* detect editing in ISM_MASA_MODE_DISC. optionally, add quantization-resolution -based thresholds */ - IF ( fabsf( hIvasDec->st_ivas->hIsmMetaData[obj]->azimuth_fx - hIvasEditableParameters.ism_metadata[obj].azimuth_fx ) > OMASA_AZI_EDIT_THR || - fabsf( hIvasDec->st_ivas->hIsmMetaData[obj]->elevation_fx - hIvasEditableParameters.ism_metadata[obj].elevation_fx ) > OMASA_ELE_EDIT_THR ) + IF ( GT_32( L_abs( L_sub( hIvasDec->st_ivas->hIsmMetaData[obj]->azimuth_fx, hIvasEditableParameters.ism_metadata[obj].azimuth_fx ) ), OMASA_AZI_EDIT_THR_FX ) || + GT_32( L_abs( L_sub( hIvasDec->st_ivas->hIsmMetaData[obj]->elevation_fx, hIvasEditableParameters.ism_metadata[obj].elevation_fx ) ), OMASA_ELE_EDIT_THR_FX ) ) { hIvasDec->st_ivas->hMasaIsmData->azimuth_ism_edited[obj] = new_azi; hIvasDec->st_ivas->hMasaIsmData->elevation_ism_edited[obj] = new_ele; @@ -4285,10 +4288,10 @@ ivas_error IVAS_DEC_SetEditableParameters( } /* compare pre-edit gain and the edited one to detect editing */ - IF ( fabsf( hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain - hIvasEditableParameters.ism_metadata[obj].gain ) > OMASA_GAIN_EDIT_THR ) + IF ( L_abs( L_sub(hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain_fx, hIvasEditableParameters.ism_metadata[obj].gain_fx ) ) > OMASA_GAIN_EDIT_THR_FX ) { hIvasDec->st_ivas->hMasaIsmData->ism_gain_is_edited[obj] = 1u; - hIvasDec->st_ivas->hMasaIsmData->gain_ism_edited[obj] = hIvasEditableParameters.ism_metadata[obj].gain; + hIvasDec->st_ivas->hMasaIsmData->gain_ism_edited_fx[obj] = hIvasEditableParameters.ism_metadata[obj].gain_fx; } ELSE { @@ -4309,9 +4312,9 @@ ivas_error IVAS_DEC_SetEditableParameters( } } - IF ( L_abs( sub(hIvasEditableParameters.gain_bed_fx, ONE_IN_Q30) ) > OMASA_GAIN_EDIT_THR ) //TODO: check Q value + IF ( GE_32( L_abs( L_sub(hIvasEditableParameters.gain_bed_fx, ONE_IN_Q30) ), OMASA_GAIN_EDIT_THR_FX ) ) //TODO: check Q value { - hIvasDec->st_ivas->hMasaIsmData->gain_masa_edited = hIvasEditableParameters.gain_bed_fx; //TODO: check type + hIvasDec->st_ivas->hMasaIsmData->gain_masa_edited_fx = hIvasEditableParameters.gain_bed_fx; //TODO: check type move32(); hIvasDec->st_ivas->hMasaIsmData->masa_gain_is_edited = 1u; } diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index b547cd8aa..977d5cdc7 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -992,7 +992,7 @@ static void ivas_dirac_dec_binaural_internal_fx( if ( st_ivas->ivas_format == MASA_ISM_FORMAT && ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) ) ) ) #endif { - ivas_omasa_preProcessStereoTransportsForEditedObjects( st_ivas, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, nBins, subframe ); + ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( st_ivas, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, &q_inp, nBins, subframe ); } #else IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_16( nchan_transport, 2 ) && NE_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && NE_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) @@ -4995,7 +4995,8 @@ static void getDirectPartGains_fx( Word32 Rmat[3][3], /*Q30*/ PARAMBIN_HRTF_GAIN_CACHE *gainCache, const Word16 isHeadtracked, - HRTFS_PARAMBIN_HANDLE hHrtfParambin ) + HRTFS_PARAMBIN_HANDLE hHrtfParambin +) { // float aziRad, eleRad; Word32 y, mappedX; @@ -5012,51 +5013,53 @@ static void getDirectPartGains_fx( IF( renderStereoOutputInsteadOfBinaural ) /* In stereo (i.e. non-binaural) rendering mode */ { #ifdef OMASA_OBJECT_EDITING - *lImagp = 0.0f; - *rImagp = 0.0f; - if ( aziDeg == gainCache->azi && eleDeg == gainCache->ele ) - { - *lRealp = gainCache->shVec[0]; /* Reused memory */ - *rRealp = gainCache->shVec[1]; /* Reused memory */ - } - else - { - /* Convert azi and ele to an azi value of the cone of confusion */ - aziRad = (float) aziDeg * PI_OVER_180; - eleRad = (float) eleDeg * PI_OVER_180; - y = ( sinf( aziRad ) * cosf( eleRad ) ); - mappedX = sqrtf( max( 0.0f, 1.0f - ( y * y ) ) ); - aziRadMapped = atan2f( y, mappedX ); - - /* Determine the real valued amplitude panning gains */ - if ( aziRadMapped >= LsAngleRad ) - { /* Left side */ - *lRealp = 1.0f; - *rRealp = 0.0f; - } - else if ( aziRadMapped <= -LsAngleRad ) - { /* Right side */ - *lRealp = 0.0f; - *rRealp = 1.0f; - } - else /* Tangent panning law */ - { - A = tanf( aziRadMapped ) / tanf( LsAngleRad ); - A2 = ( A - 1.0f ) / max( 0.001f, A + 1.0f ); - A3 = 1.0f / ( A2 * A2 + 1.0f ); - *lRealp = sqrtf( A3 ); - *rRealp = sqrtf( 1.0f - A3 ); - } - /* Scaling to have the same expected gain as for the HRTF rendering */ - *lRealp *= SQRT2; - *rRealp *= SQRT2; - - /* Store to gain cache */ - gainCache->azi = aziDeg; - gainCache->ele = eleDeg; - gainCache->shVec[0] = *lRealp; /* Reuse memory */ - gainCache->shVec[1] = *rRealp; /* Reuse memory */ - } + + assert (0 && "Insert proper basop code here!)"); + //*lImagp = 0.0f; + //*rImagp = 0.0f; + //if ( aziDeg == gainCache->azi && eleDeg == gainCache->ele ) + //{ + // *lRealp = gainCache->shVec[0]; /* Reused memory */ + // *rRealp = gainCache->shVec[1]; /* Reused memory */ + //} + //else + //{ + // /* Convert azi and ele to an azi value of the cone of confusion */ + // aziRad = (float) aziDeg * PI_OVER_180; + // eleRad = (float) eleDeg * PI_OVER_180; + // y = ( sinf( aziRad ) * cosf( eleRad ) ); + // mappedX = sqrtf( max( 0.0f, 1.0f - ( y * y ) ) ); + // aziRadMapped = atan2f( y, mappedX ); + + // /* Determine the real valued amplitude panning gains */ + // if ( aziRadMapped >= LsAngleRad ) + // { /* Left side */ + // *lRealp = 1.0f; + // *rRealp = 0.0f; + // } + // else if ( aziRadMapped <= -LsAngleRad ) + // { /* Right side */ + // *lRealp = 0.0f; + // *rRealp = 1.0f; + // } + // else /* Tangent panning law */ + // { + // A = tanf( aziRadMapped ) / tanf( LsAngleRad ); + // A2 = ( A - 1.0f ) / max( 0.001f, A + 1.0f ); + // A3 = 1.0f / ( A2 * A2 + 1.0f ); + // *lRealp = sqrtf( A3 ); + // *rRealp = sqrtf( 1.0f - A3 ); + // } + // /* Scaling to have the same expected gain as for the HRTF rendering */ + // *lRealp *= SQRT2; + // *rRealp *= SQRT2; + + // /* Store to gain cache */ + // gainCache->azi = aziDeg; + // gainCache->ele = eleDeg; + // gainCache->shVec[0] = *lRealp; /* Reuse memory */ + // gainCache->shVec[1] = *rRealp; /* Reuse memory */ + //} #else /* Convert azi and ele to an azi value of the cone of confusion */ @@ -5355,12 +5358,14 @@ Word16 configure_reqularization_factor_fx( * *-------------------------------------------------------------------*/ -void ivas_omasa_preProcessStereoTransportsForEditedObjects( +void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( Decoder_Struct *st_ivas, - float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], - float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], - const int16_t nBins, - const int16_t subframe ) + Word32 inRe_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + Word32 inIm_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + Word16 *cldfb_buf_q, + const Word16 nBins, + const Word16 subframe +) { int16_t bin, ch, inCh, outCh, ismDirIndex, slot, band_idx, bin_lo, bin_hi, max_band, n_ism; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; @@ -5457,35 +5462,37 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects( /* OMASA gaining for discrete OMASA mode with stereo_param/bin_room_param renderer */ if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { - /* ISM gaining */ - for ( ch = 0; ch < n_ism; ch++ ) - { - if ( st_ivas->hMasaIsmData->ism_gain_is_edited[ch] ) - { - for ( slot = 0; slot < hSpatParamRendCom->subframe_nbslots[subframe]; slot++ ) - { - float gain; - gain = st_ivas->hMasaIsmData->gain_ism_edited[ch]; - v_multc( inRe[ch + 2][slot], gain, inRe[ch + 2][slot], nBins ); - v_multc( inIm[ch + 2][slot], gain, inIm[ch + 2][slot], nBins ); - } - } - } - - /* MASA gaining */ - for ( ch = 0; ch < 2; ch++ ) - { - if ( masaGainEdited ) - { - for ( slot = 0; slot < hSpatParamRendCom->subframe_nbslots[subframe]; slot++ ) - { - float gain_masa; - gain_masa = st_ivas->hMasaIsmData->gain_masa_edited; - v_multc( inRe[ch][slot], gain_masa, inRe[ch][slot], nBins ); - v_multc( inIm[ch][slot], gain_masa, inIm[ch][slot], nBins ); - } - } - } + assert (0 && "Insert proper basop code here!"); + ///* + ///* ISM gaining */ + //for ( ch = 0; ch < n_ism; ch++ ) + //{ + // if ( st_ivas->hMasaIsmData->ism_gain_is_edited[ch] ) + // { + // for ( slot = 0; slot < hSpatParamRendCom->subframe_nbslots[subframe]; slot++ ) + // { + // float gain; + // gain = st_ivas->hMasaIsmData->gain_ism_edited_fx[ch]; + // v_multc( inRe[ch + 2][slot], gain, inRe[ch + 2][slot], nBins ); + // v_multc( inIm[ch + 2][slot], gain, inIm[ch + 2][slot], nBins ); + // } + // } + //} + + ///* MASA gaining */ + //for ( ch = 0; ch < 2; ch++ ) + //{ + // if ( masaGainEdited ) + // { + // for ( slot = 0; slot < hSpatParamRendCom->subframe_nbslots[subframe]; slot++ ) + // { + // float gain_masa; + // gain_masa = st_ivas->hMasaIsmData->gain_masa_edited_fx; + // v_multc( inRe[ch][slot], gain_masa, inRe[ch][slot], nBins ); + // v_multc( inIm[ch][slot], gain_masa, inIm[ch][slot], nBins ); + // } + // } + //} } #ifdef OBJ_EDITING_PARAMISM_BIN else if ( st_ivas->ivas_format == ISM_FORMAT && st_ivas->hISMDTX.dtx_flag ) /* If dtx on, perform just the smoothing of the processing gains */ @@ -5539,8 +5546,8 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects( { for ( bin = bin_lo; bin < bin_hi; bin++ ) { - totalTargetEne += inRe[ch][slot][bin] * inRe[ch][slot][bin]; - totalTargetEne += inIm[ch][slot][bin] * inIm[ch][slot][bin]; + totalTargetEne += inRe_fx[ch][slot][bin] * inRe_fx[ch][slot][bin]; + totalTargetEne += inIm_fx[ch][slot][bin] * inIm_fx[ch][slot][bin]; } } } @@ -5550,14 +5557,14 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects( { for ( outCh = 0; outCh < 2; outCh++ ) { - ismPreprocMtxIncrement[outCh][inCh] = ( ismPreprocMtxNew[outCh][inCh] - hMasaIsmData->ismPreprocMatrix[outCh][inCh][band_idx] ) * nSlotDiv; + ismPreprocMtxIncrement[outCh][inCh] = ( ismPreprocMtxNew[outCh][inCh] - hMasaIsmData->ismPreprocMatrix_fx[outCh][inCh][band_idx] ) * nSlotDiv; } } /* Mix signals */ - hMasaIsmData->preprocEneTarget[band_idx] *= STEREO_PREPROCESS_IIR_FACTOR; - hMasaIsmData->preprocEneRealized[band_idx] *= STEREO_PREPROCESS_IIR_FACTOR; - hMasaIsmData->preprocEneTarget[band_idx] += totalTargetEne; + hMasaIsmData->preprocEneTarget_fx[band_idx] *= STEREO_PREPROCESS_IIR_FACTOR; + hMasaIsmData->preprocEneRealized_fx[band_idx] *= STEREO_PREPROCESS_IIR_FACTOR; + hMasaIsmData->preprocEneTarget_fx[band_idx] += totalTargetEne; for ( outCh = 0; outCh < 2; outCh++ ) { @@ -5565,22 +5572,22 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects( { for ( inCh = 0; inCh < 2; inCh++ ) { - hMasaIsmData->ismPreprocMatrix[outCh][inCh][band_idx] += ismPreprocMtxIncrement[outCh][inCh]; + hMasaIsmData->ismPreprocMatrix_fx[outCh][inCh][band_idx] += ismPreprocMtxIncrement[outCh][inCh]; for ( bin = bin_lo; bin < bin_hi; bin++ ) { - outSlotRe[outCh][slot][bin] += inRe[inCh][slot][bin] * hMasaIsmData->ismPreprocMatrix[outCh][inCh][band_idx]; - outSlotIm[outCh][slot][bin] += inIm[inCh][slot][bin] * hMasaIsmData->ismPreprocMatrix[outCh][inCh][band_idx]; + outSlotRe[outCh][slot][bin] += inRe_fx[inCh][slot][bin] * hMasaIsmData->ismPreprocMatrix_fx[outCh][inCh][band_idx]; + outSlotIm[outCh][slot][bin] += inIm_fx[inCh][slot][bin] * hMasaIsmData->ismPreprocMatrix_fx[outCh][inCh][band_idx]; } } for ( bin = bin_lo; bin < bin_hi; bin++ ) { - hMasaIsmData->preprocEneRealized[band_idx] += ( outSlotRe[outCh][slot][bin] * outSlotRe[outCh][slot][bin] ) + ( outSlotIm[outCh][slot][bin] * outSlotIm[outCh][slot][bin] ); + hMasaIsmData->preprocEneRealized_fx[band_idx] += ( outSlotRe[outCh][slot][bin] * outSlotRe[outCh][slot][bin] ) + ( outSlotIm[outCh][slot][bin] * outSlotIm[outCh][slot][bin] ); } } } - eqVal = fminf( 4.0f, sqrtf( hMasaIsmData->preprocEneTarget[band_idx] / fmaxf( 1e-12f, hMasaIsmData->preprocEneRealized[band_idx] ) ) ); + eqVal = fminf( 4.0f, sqrtf( hMasaIsmData->preprocEneTarget_fx[band_idx] / fmaxf( 1e-12f, hMasaIsmData->preprocEneRealized_fx[band_idx] ) ) ); for ( ch = 0; ch < 2; ch++ ) { @@ -5588,8 +5595,8 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects( { for ( bin = bin_lo; bin < bin_hi; bin++ ) { - inRe[ch][slot][bin] = outSlotRe[ch][slot][bin] * eqVal; - inIm[ch][slot][bin] = outSlotIm[ch][slot][bin] * eqVal; + inRe_fx[ch][slot][bin] = outSlotRe[ch][slot][bin] * eqVal; + inIm_fx[ch][slot][bin] = outSlotIm[ch][slot][bin] * eqVal; } } } @@ -5635,7 +5642,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects( gainMasaPow2 = 1.0f; if ( masaGainEdited ) { - gainMasaPow2 = hMasaIsmData->gain_masa_edited; + gainMasaPow2 = hMasaIsmData->gain_masa_edited_fx; gainMasaPow2 *= gainMasaPow2; } @@ -5647,13 +5654,13 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects( for ( ismDirIndex = 0; ismDirIndex < n_ism; ismDirIndex++ ) { /* Get input and output panning gains */ - ivas_get_stereo_panning_gains( hMasaIsmData->azimuth_ism[ismDirIndex][dirac_read_idx], + ivas_get_stereo_panning_gains_fx( hMasaIsmData->azimuth_ism[ismDirIndex][dirac_read_idx], hMasaIsmData->elevation_ism[ismDirIndex][dirac_read_idx], panGainsIn[ismDirIndex] ); if ( ismDirEdited[ismDirIndex] ) { - ivas_get_stereo_panning_gains( hMasaIsmData->azimuth_ism_edited[ismDirIndex], + ivas_get_stereo_panning_gains_fx( hMasaIsmData->azimuth_ism_edited[ismDirIndex], hMasaIsmData->elevation_ism_edited[ismDirIndex], panGainsOut[ismDirIndex] ); } @@ -5738,8 +5745,8 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects( { for ( bin = bin_lo; bin < bin_hi; bin++ ) { - subframeEneCh[ch] += inRe[ch][slot][bin] * inRe[ch][slot][bin]; - subframeEneCh[ch] += inIm[ch][slot][bin] * inIm[ch][slot][bin]; + subframeEneCh[ch] += inRe_fx[ch][slot][bin] * inRe_fx[ch][slot][bin]; + subframeEneCh[ch] += inIm_fx[ch][slot][bin] * inIm_fx[ch][slot][bin]; } } } @@ -5753,7 +5760,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects( /* For each object, estimate new target energy per channel based on the applied gain */ for ( ismDirIndex = 0; ismDirIndex < n_ism; ismDirIndex++ ) { - ratio = hMasaIsmData->energy_ratio_ism[ismDirIndex][dirac_read_idx][bin_lo]; + ratio = hMasaIsmData->energy_ratio_ism_fx[ismDirIndex][dirac_read_idx][bin_lo]; ratioAccOrig += ratio; /* Calculate MASA energy as a residual of original channel energies subtracted with ISM energies */ @@ -5765,7 +5772,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects( /* Calculate target energy, gained ratio for accumulation, and transports gains, if ism gain is edited */ if ( ismGainEdited[ismDirIndex] ) { - gainIsmThis = hMasaIsmData->gain_ism_edited[ismDirIndex]; + gainIsmThis = hMasaIsmData->gain_ism_edited_fx[ismDirIndex]; /* ISM original energy */ ismEneThis = ratio * subframeEne; @@ -5793,8 +5800,8 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects( { for ( bin = bin_lo; bin < bin_hi; bin++ ) { - inRe[2][slot][bin] = gainIsmThis * inRe[2][slot][bin]; - inIm[2][slot][bin] = gainIsmThis * inIm[2][slot][bin]; + inRe_fx[2][slot][bin] = gainIsmThis * inRe_fx[2][slot][bin]; + inIm_fx[2][slot][bin] = gainIsmThis * inIm_fx[2][slot][bin]; } } } @@ -5808,7 +5815,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects( { #endif /* MASA original ratios */ - ratio = hSpatParamRendCom->energy_ratio1[dirac_read_idx][bin_lo] + hSpatParamRendCom->energy_ratio2[dirac_read_idx][bin_lo]; + ratio = hSpatParamRendCom->energy_ratio1_fx[dirac_read_idx][bin_lo] + hSpatParamRendCom->energy_ratio2_fx[dirac_read_idx][bin_lo]; ratioAccOrig += ratio; /* Estimate MASA original energies and determine adjusted target energies and gained ratio for accumulation, if a gain is applied to MASA */ @@ -5856,7 +5863,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects( newRatios[ismDirIndex + 2] = hMasaIsmData->energy_ratio_ism_fx[ismDirIndex][dirac_read_idx][bin_lo]; /* Determine original object energy ratio */ if ( ismGainEdited[ismDirIndex] ) { - gainIsmThis = hMasaIsmData->gain_ism_edited[ismDirIndex]; + gainIsmThis = hMasaIsmData->gain_ism_edited_fx[ismDirIndex]; newRatios[ismDirIndex + 2] *= ( gainIsmThis * gainIsmThis ); /* Gain original object energy ratio, if edited */ } newRatios[ismDirIndex + 2] *= ratioAccNewDivisor; /* Divide with new target total ratio */ @@ -5894,7 +5901,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects( /* For each ismDir, determine moved and preserve energy ratio per channel */ for ( ismDirIndex = 0; ismDirIndex < n_ism; ismDirIndex++ ) { - ratio = hMasaIsmData->energy_ratio_ism[ismDirIndex][dirac_read_idx][bin_lo]; + ratio = hMasaIsmData->energy_ratio_ism_fx[ismDirIndex][dirac_read_idx][bin_lo]; ismRatioAcc += ratio; @@ -5935,20 +5942,20 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects( } /* Temporally average target energy */ - hMasaIsmData->eneOrigIIR[band_idx] *= STEREO_PREPROCESS_IIR_FACTOR; - hMasaIsmData->eneOrigIIR[band_idx] += totalTargetEne; + hMasaIsmData->eneOrigIIR_fx[band_idx] *= STEREO_PREPROCESS_IIR_FACTOR; + hMasaIsmData->eneOrigIIR_fx[band_idx] += totalTargetEne; /* Temporally average energy moving and preserving, and generate the transport signal preprocessing matrix for * gaining objects and moving objects between left and right */ for ( ch = 0; ch < 2; ch++ ) { - hMasaIsmData->eneMoveIIR[ch][band_idx] *= STEREO_PREPROCESS_IIR_FACTOR; - hMasaIsmData->eneMoveIIR[ch][band_idx] += eneMove[ch] * totalTargetEne; - hMasaIsmData->enePreserveIIR[ch][band_idx] *= STEREO_PREPROCESS_IIR_FACTOR; - hMasaIsmData->enePreserveIIR[ch][band_idx] += enePreserve[ch] * totalTargetEne; - normVal = 1.0f / fmaxf( EPSILON, hMasaIsmData->eneOrigIIR[band_idx] ); - ismPreprocMtxNew[ch][ch] = fminf( 4.0f, sqrtf( hMasaIsmData->enePreserveIIR[ch][band_idx] * normVal ) ); - ismPreprocMtxNew[1 - ch][ch] = fminf( 4.0f, sqrtf( hMasaIsmData->eneMoveIIR[ch][band_idx] * normVal ) ); + hMasaIsmData->eneMoveIIR_fx[ch][band_idx] *= STEREO_PREPROCESS_IIR_FACTOR; + hMasaIsmData->eneMoveIIR_fx[ch][band_idx] += eneMove[ch] * totalTargetEne; + hMasaIsmData->enePreserveIIR_fx[ch][band_idx] *= STEREO_PREPROCESS_IIR_FACTOR; + hMasaIsmData->enePreserveIIR_fx[ch][band_idx] += enePreserve[ch] * totalTargetEne; + normVal = 1.0f / fmaxf( EPSILON, hMasaIsmData->eneOrigIIR_fx[band_idx] ); + ismPreprocMtxNew[ch][ch] = fminf( 4.0f, sqrtf( hMasaIsmData->enePreserveIIR_fx[ch][band_idx] * normVal ) ); + ismPreprocMtxNew[1 - ch][ch] = fminf( 4.0f, sqrtf( hMasaIsmData->eneMoveIIR_fx[ch][band_idx] * normVal ) ); } /* Get increment value for temporal interpolation */ @@ -5956,14 +5963,14 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects( { for ( outCh = 0; outCh < 2; outCh++ ) { - ismPreprocMtxIncrement[outCh][inCh] = ( ismPreprocMtxNew[outCh][inCh] - hMasaIsmData->ismPreprocMatrix[outCh][inCh][band_idx] ) * nSlotDiv; + ismPreprocMtxIncrement[outCh][inCh] = ( ismPreprocMtxNew[outCh][inCh] - hMasaIsmData->ismPreprocMatrix_fx[outCh][inCh][band_idx] ) * nSlotDiv; } } /* Mix signals */ - hMasaIsmData->preprocEneTarget[band_idx] *= STEREO_PREPROCESS_IIR_FACTOR; - hMasaIsmData->preprocEneRealized[band_idx] *= STEREO_PREPROCESS_IIR_FACTOR; - hMasaIsmData->preprocEneTarget[band_idx] += totalTargetEne; + hMasaIsmData->preprocEneTarget_fx[band_idx] *= STEREO_PREPROCESS_IIR_FACTOR; + hMasaIsmData->preprocEneRealized_fx[band_idx] *= STEREO_PREPROCESS_IIR_FACTOR; + hMasaIsmData->preprocEneTarget_fx[band_idx] += totalTargetEne; for ( outCh = 0; outCh < 2; outCh++ ) { @@ -5971,22 +5978,22 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects( { for ( inCh = 0; inCh < 2; inCh++ ) { - hMasaIsmData->ismPreprocMatrix[outCh][inCh][band_idx] += ismPreprocMtxIncrement[outCh][inCh]; + hMasaIsmData->ismPreprocMatrix_fx[outCh][inCh][band_idx] += ismPreprocMtxIncrement[outCh][inCh]; for ( bin = bin_lo; bin < bin_hi; bin++ ) { - outSlotRe[outCh][slot][bin] += inRe[inCh][slot][bin] * hMasaIsmData->ismPreprocMatrix[outCh][inCh][band_idx]; - outSlotIm[outCh][slot][bin] += inIm[inCh][slot][bin] * hMasaIsmData->ismPreprocMatrix[outCh][inCh][band_idx]; + outSlotRe[outCh][slot][bin] += inRe_fx[inCh][slot][bin] * hMasaIsmData->ismPreprocMatrix_fx[outCh][inCh][band_idx]; + outSlotIm[outCh][slot][bin] += inIm_fx[inCh][slot][bin] * hMasaIsmData->ismPreprocMatrix_fx[outCh][inCh][band_idx]; } } for ( bin = bin_lo; bin < bin_hi; bin++ ) { - hMasaIsmData->preprocEneRealized[band_idx] += ( outSlotRe[outCh][slot][bin] * outSlotRe[outCh][slot][bin] ) + ( outSlotIm[outCh][slot][bin] * outSlotIm[outCh][slot][bin] ); + hMasaIsmData->preprocEneRealized_fx[band_idx] += ( outSlotRe[outCh][slot][bin] * outSlotRe[outCh][slot][bin] ) + ( outSlotIm[outCh][slot][bin] * outSlotIm[outCh][slot][bin] ); } } } - eqVal = fminf( 4.0f, sqrtf( hMasaIsmData->preprocEneTarget[band_idx] / fmaxf( 1e-12f, hMasaIsmData->preprocEneRealized[band_idx] ) ) ); + eqVal = fminf( 4.0f, sqrtf( hMasaIsmData->preprocEneTarget_fx[band_idx] / fmaxf( 1e-12f, hMasaIsmData->preprocEneRealized_fx[band_idx] ) ) ); for ( ch = 0; ch < 2; ch++ ) { @@ -5994,8 +6001,8 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects( { for ( bin = bin_lo; bin < bin_hi; bin++ ) { - inRe[ch][slot][bin] = outSlotRe[ch][slot][bin] * eqVal; - inIm[ch][slot][bin] = outSlotIm[ch][slot][bin] * eqVal; + inRe_fx[ch][slot][bin] = outSlotRe[ch][slot][bin] * eqVal; + inIm_fx[ch][slot][bin] = outSlotIm[ch][slot][bin] * eqVal; } } } @@ -6368,6 +6375,7 @@ void ivas_omasa_preProcessStereoTransportsForMovedObjects_fx( return; } +#endif static void ivas_masa_ext_rend_parambin_internal_fx( @@ -6734,7 +6742,6 @@ static void ivas_masa_ext_rend_parambin_internal_fx( return; } -#endif void ivas_masa_ext_rend_parambin_render_fx( MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA ext rend structure */ diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index 79c29464c..e7bf22110 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -2856,7 +2856,7 @@ void ivas_dirac_dec_compute_directional_responses_fx( #ifdef OMASA_OBJECT_EDITING IF ( hMasaIsm->ism_dir_is_edited[dir] ) { - ivas_dirac_dec_get_response( hMasaIsm->azimuth_ism_edited[dir], hMasaIsm->elevation_ism_edited[dir], direct_response_temp_fx, hDirACRend->hOutSetup.ambisonics_order ); + ivas_dirac_dec_get_response_fx( hMasaIsm->azimuth_ism_edited[dir], hMasaIsm->elevation_ism_edited[dir], direct_response_temp_fx, hDirACRend->hOutSetup.ambisonics_order, Q29 ); } #else IF( hMasaIsm->ism_is_edited[dir] ) @@ -3114,7 +3114,7 @@ void ivas_dirac_dec_compute_directional_responses_fx( #ifdef OMASA_OBJECT_EDITING IF ( hMasaIsm->ism_dir_is_edited[dir] ) { - vbap_determine_gains( hVBAPdata, direct_response_temp_fx, hMasaIsm->azimuth_ism_edited[dir], hMasaIsm->elevation_ism_edited[dir], 1 ); + vbap_determine_gains_fx( hVBAPdata, direct_response_temp_fx, hMasaIsm->azimuth_ism_edited[dir], hMasaIsm->elevation_ism_edited[dir], 1 ); } #else IF( hMasaIsm->ism_is_edited[dir] ) -- GitLab From 00520b58cfe7f89131826c7c1ff7fcd735723c5c Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 14 Oct 2025 13:46:50 +0200 Subject: [PATCH 05/31] fix formatting --- lib_dec/ivas_init_dec_fx.c | 2 +- lib_dec/ivas_ism_dec_fx.c | 2 +- lib_dec/ivas_ism_param_dec_fx.c | 6 +- lib_dec/ivas_jbm_dec_fx.c | 18 ++--- lib_dec/ivas_masa_dec_fx.c | 2 +- lib_dec/ivas_omasa_dec_fx.c | 30 ++++---- lib_dec/ivas_stat_dec.h | 10 +-- lib_dec/lib_dec_fx.c | 70 +++++++++--------- .../ivas_dirac_dec_binaural_functions_fx.c | 72 +++++++++---------- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 4 +- lib_rend/ivas_objectRenderer_fx.c | 2 +- 11 files changed, 107 insertions(+), 111 deletions(-) diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index ffdce4af0..a48a85ec5 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -1867,7 +1867,7 @@ ivas_error ivas_init_decoder_fx( IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) ) { st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed2 = st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed3; - move16(); + move16(); #ifdef OBJ_EDITING_PARAMISM_BIN if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) { diff --git a/lib_dec/ivas_ism_dec_fx.c b/lib_dec/ivas_ism_dec_fx.c index f44b0374e..1ae90aa15 100644 --- a/lib_dec/ivas_ism_dec_fx.c +++ b/lib_dec/ivas_ism_dec_fx.c @@ -309,7 +309,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( { return error; } - + #ifdef OBJ_EDITING_PARAMISM_BIN /* Open omasa data struct (used for object editing) */ if ( ( error = ivas_omasa_data_open_fx( st_ivas ) ) != IVAS_ERR_OK ) diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 819c3e6d7..2a144880d 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -1035,7 +1035,7 @@ void ivas_ism_dec_digest_tc_fx( elevation_fx = L_shl( elevation_fx, Q22 ); // Q22 efap_determine_gains_fx( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains_fx[i], azimuth_fx, elevation_fx, EFAP_MODE_EFAP ); #ifdef OBJ_EDITING_API - //TODO: align Q values properly + // TODO: align Q values properly v_multc_fixed( st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIsmMetaData[i]->edited_gain_fx, st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hEFAPdata->numSpk ); #endif } @@ -2023,7 +2023,7 @@ void ivas_param_ism_params_to_masa_param_mapping_fx( } #endif - + IF( st_ivas->hISMDTX.dtx_flag ) { Word32 energy_ratio_fx; /* Q30 */ @@ -2167,6 +2167,6 @@ void ivas_param_ism_params_to_masa_param_mapping_fx( } #endif } - + return; } diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 5646d1f97..67c4be9e0 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -4657,10 +4657,10 @@ void ivas_jbm_dec_prepare_renderer( Word32 gainIsm; gainIsm = OMASA_TDREND_MATCHING_GAIN_FX; - IF ( st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) + IF( st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) { - //gainIsm *= st_ivas->hMasaIsmData->gain_ism_edited[n]; - assert( 0 && "Insert actual basop code here!"); + // gainIsm *= st_ivas->hMasaIsmData->gain_ism_edited[n]; + assert( 0 && "Insert actual basop code here!" ); } v_multc_fixed_16( st_ivas->hTcBuffer->tc_fx[CPE_CHANNELS + n], gainIsm, st_ivas->hTcBuffer->tc_fx[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available ); @@ -4669,20 +4669,20 @@ void ivas_jbm_dec_prepare_renderer( #endif } delay_signal32_fx( st_ivas->hTcBuffer->tc_fx[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available, st_ivas->hMasaIsmData->delayBuffer_fx[n], st_ivas->hMasaIsmData->delayBuffer_size ); - //TODO: check if tis is a bug in main already + // TODO: check if tis is a bug in main already } #ifdef OMASA_OBJECT_EDITING - IF ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) + IF( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) { Word16 tcBufferSize; tcBufferSize = st_ivas->hSpatParamRendCom->num_slots * st_ivas->hSpatParamRendCom->slot_size; - IF ( st_ivas->hMasaIsmData->masa_gain_is_edited ) + IF( st_ivas->hMasaIsmData->masa_gain_is_edited ) { - FOR ( Word16 ch = 0; ch < 2; ch++ ) + FOR( Word16 ch = 0; ch < 2; ch++ ) { - //v_multc_fixed_16( st_ivas->hTcBuffer->tc_fx[ch], st_ivas->hMasaIsmData->gain_masa_edited, st_ivas->hTcBuffer->tc_fx[ch], tcBufferSize ); - assert( 0 && "Insert actual basop code here!"); + // v_multc_fixed_16( st_ivas->hTcBuffer->tc_fx[ch], st_ivas->hMasaIsmData->gain_masa_edited, st_ivas->hTcBuffer->tc_fx[ch], tcBufferSize ); + assert( 0 && "Insert actual basop code here!" ); } } } diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c index e6eb495d2..e47c5c91c 100644 --- a/lib_dec/ivas_masa_dec_fx.c +++ b/lib_dec/ivas_masa_dec_fx.c @@ -839,7 +839,7 @@ ivas_error ivas_masa_dec_open_fx( /* ISM metadata */ #ifdef OMASA_OBJECT_EDITING test(); - IF ( EQ_16(st_ivas->ivas_format, MASA_FORMAT) && st_ivas->hIsmMetaData[0] == NULL ) + IF( EQ_16( st_ivas->ivas_format, MASA_FORMAT ) && st_ivas->hIsmMetaData[0] == NULL ) #else test(); test(); diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index e84d6b832..2f628ac40 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -328,21 +328,21 @@ ivas_error ivas_omasa_data_open_fx( } #ifdef OMASA_OBJECT_EDITING - FOR ( Word16 band_idx = 0; band_idx < MASA_FREQUENCY_BANDS; band_idx++ ) + FOR( Word16 band_idx = 0; band_idx < MASA_FREQUENCY_BANDS; band_idx++ ) { - FOR ( ch = 0; ch < 2; ch++ ) + FOR( ch = 0; ch < 2; ch++ ) { hMasaIsmData->ismPreprocMatrix_fx[ch][ch][band_idx] = 32767; /* 1.0f in Q15 */ move16(); - hMasaIsmData->ismPreprocMatrix_fx[1 - ch][ch][band_idx] = 0; // Q15 + hMasaIsmData->ismPreprocMatrix_fx[1 - ch][ch][band_idx] = 0; // Q15 move16(); hMasaIsmData->eneMoveIIR_fx[ch][band_idx] = 0; // Q22 move32(); hMasaIsmData->enePreserveIIR_fx[ch][band_idx] = 0; // Q22 move32(); } - hMasaIsmData->eneOrigIIR_fx[band_idx] = 0; // TODO: check Q - hMasaIsmData->preprocEneTarget_fx[band_idx] = 0; // Q19 + hMasaIsmData->eneOrigIIR_fx[band_idx] = 0; // TODO: check Q + hMasaIsmData->preprocEneTarget_fx[band_idx] = 0; // Q19 hMasaIsmData->preprocEneRealized_fx[band_idx] = 0; // Q19 } @@ -1184,16 +1184,16 @@ void ivas_omasa_dirac_rend_jbm_fx( { Copy32( &output_f[CPE_CHANNELS][st_ivas->hTcBuffer->n_samples_rendered], data_separated_objects[0], *nSamplesRendered ); #ifdef OMASA_OBJECT_EDITING - IF ( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) + IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) { /* Gain separated object, if edited */ - FOR ( n = 0; n < st_ivas->nchan_ism; n++ ) + FOR( n = 0; n < st_ivas->nchan_ism; n++ ) { test(); - IF ( st_ivas->hMasaIsmData->ism_gain_is_edited[n] && EQ_16(st_ivas->hMasaIsmData->idx_separated_ism, n ) ) + IF( st_ivas->hMasaIsmData->ism_gain_is_edited[n] && EQ_16( st_ivas->hMasaIsmData->idx_separated_ism, n ) ) { - //v_multc( data_separated_objects[0], st_ivas->hMasaIsmData->gain_ism_edited[n], data_separated_objects[0], *nSamplesRendered ); - assert ( 0 && "Insert proper basop code here!"); + // v_multc( data_separated_objects[0], st_ivas->hMasaIsmData->gain_ism_edited[n], data_separated_objects[0], *nSamplesRendered ); + assert( 0 && "Insert proper basop code here!" ); } } } @@ -1207,10 +1207,10 @@ void ivas_omasa_dirac_rend_jbm_fx( Copy32( &output_f[n + CPE_CHANNELS][st_ivas->hTcBuffer->n_samples_rendered], data_separated_objects[n], *nSamplesRendered ); #ifdef OMASA_OBJECT_EDITING /* Gain discrete objects, if edited */ - IF ( st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) + IF( st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) { - //v_multc( data_separated_objects[n], st_ivas->hMasaIsmData->gain_ism_edited[n], data_separated_objects[n], *nSamplesRendered ); - assert( 00 && "Insert proper basop code here!"); + // v_multc( data_separated_objects[n], st_ivas->hMasaIsmData->gain_ism_edited[n], data_separated_objects[n], *nSamplesRendered ); + assert( 00 && "Insert proper basop code here!" ); } #endif } @@ -1220,8 +1220,8 @@ void ivas_omasa_dirac_rend_jbm_fx( { for ( int16_t ch = 0; ch < 2; ch++ ) { - //v_multc( output_f[ch], st_ivas->hMasaIsmData->gain_masa_edited, output_f[ch], *nSamplesRendered ); - assert( 00 && "Insert proper basop code here!"); + // v_multc( output_f[ch], st_ivas->hMasaIsmData->gain_masa_edited, output_f[ch], *nSamplesRendered ); + assert( 00 && "Insert proper basop code here!" ); } } #endif diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index ff10ddda1..be45fb8d1 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -987,11 +987,11 @@ typedef struct ivas_masa_ism_data_structure #ifdef OMASA_OBJECT_EDITING UWord16 objectsEdited; - Word32 preprocEneTarget_fx[MASA_FREQUENCY_BANDS]; /*Q-19*/ - Word32 preprocEneRealized_fx[MASA_FREQUENCY_BANDS]; /*Q-19*/ - Word32 ismPreprocMatrix_fx[2][2][MASA_FREQUENCY_BANDS]; /*Q-15*/ - Word32 eneMoveIIR_fx[2][MASA_FREQUENCY_BANDS]; /*Q-22*/ - Word32 enePreserveIIR_fx[2][MASA_FREQUENCY_BANDS]; /*Q-22*/ + Word32 preprocEneTarget_fx[MASA_FREQUENCY_BANDS]; /*Q-19*/ + Word32 preprocEneRealized_fx[MASA_FREQUENCY_BANDS]; /*Q-19*/ + Word32 ismPreprocMatrix_fx[2][2][MASA_FREQUENCY_BANDS]; /*Q-15*/ + Word32 eneMoveIIR_fx[2][MASA_FREQUENCY_BANDS]; /*Q-22*/ + Word32 enePreserveIIR_fx[2][MASA_FREQUENCY_BANDS]; /*Q-22*/ Word32 eneOrigIIR_fx[MASA_FREQUENCY_BANDS]; Word16 bits_ism[MAX_NUM_OBJECTS]; #else diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 16e362072..10e2fd9f8 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -3937,7 +3937,7 @@ ivas_error IVAS_DEC_GetSamplesDecoder( IF( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) { #ifdef OMASA_OBJECT_EDITING - IF ( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + IF( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) #else IF( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) #endif @@ -3989,8 +3989,7 @@ ivas_error IVAS_DEC_GetSamplesDecoder( ivas_error IVAS_DEC_GetEditableParameters( IVAS_DEC_HANDLE hIvasDec, - IVAS_EDITABLE_PARAMETERS *hIvasEditableParameters -) + IVAS_EDITABLE_PARAMETERS *hIvasEditableParameters ) { ivas_error error; #ifdef OMASA_OBJECT_EDITING @@ -4103,7 +4102,7 @@ ivas_error IVAS_DEC_GetEditableParameters( hIvasEditableParameters->ism_metadata[obj].radius_fx = hIvasDec->st_ivas->hIsmMetaData[obj]->radius_fx; /* reset the otherwise unused "gain" field for the object */ - hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain_fx = ONE_IN_Q31; //TODO: check Q value + hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain_fx = ONE_IN_Q31; // TODO: check Q value hIvasEditableParameters->ism_metadata[obj].gain_fx = hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain_fx; hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = hIvasDec->st_ivas->hIsmMetaData[obj]->non_diegetic_flag; } @@ -4158,16 +4157,16 @@ ivas_error IVAS_DEC_SetEditableParameters( #endif - IF ( !( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || - ( hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT && hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) || - ( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT && ( hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) ) || - hIvasDec->st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + IF( !( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || + ( hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT && hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) || + ( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT && ( hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) ) || + hIvasDec->st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Object editing no supported in this operation mode." ); } test(); - IF ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } @@ -4183,13 +4182,13 @@ ivas_error IVAS_DEC_SetEditableParameters( #endif test(); - IF ( EQ_16(hIvasDec->st_ivas->ivas_format, ISM_FORMAT) || EQ_16( hIvasDec->st_ivas->ivas_format, SBA_ISM_FORMAT ) ) + IF( EQ_16( hIvasDec->st_ivas->ivas_format, ISM_FORMAT ) || EQ_16( hIvasDec->st_ivas->ivas_format, SBA_ISM_FORMAT ) ) { test(); - IF ( EQ_16( hIvasDec->st_ivas->ism_mode, ISM_MODE_DISC ) || EQ_16( hIvasDec->st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) + IF( EQ_16( hIvasDec->st_ivas->ism_mode, ISM_MODE_DISC ) || EQ_16( hIvasDec->st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) { Word16 obj; - FOR ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) + FOR( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) { hIvasDec->st_ivas->hIsmMetaData[obj]->edited_azimuth_fx = hIvasEditableParameters.ism_metadata[obj].azimuth_fx; hIvasDec->st_ivas->hIsmMetaData[obj]->edited_elevation_fx = hIvasEditableParameters.ism_metadata[obj].elevation_fx; @@ -4203,15 +4202,15 @@ ivas_error IVAS_DEC_SetEditableParameters( hIvasDec->st_ivas->hIsmMetaData[obj]->non_diegetic_flag = hIvasEditableParameters.ism_metadata[obj].non_diegetic_flag; } - IF ( hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + IF( hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { hIvasDec->st_ivas->hSbaIsmData->gain_bed_fx = hIvasEditableParameters.gain_bed_fx; } } - ELSE IF ( EQ_16( hIvasDec->st_ivas->ism_mode, ISM_MODE_PARAM ) ) + ELSE IF( EQ_16( hIvasDec->st_ivas->ism_mode, ISM_MODE_PARAM ) ) { int16_t obj; - FOR ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) + FOR( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) { #ifdef OBJ_EDITING_PARAMISM_BIN hIvasDec->st_ivas->hParamIsmDec->edited_azimuth_values_fx[obj] = hIvasEditableParameters.ism_metadata[obj].azimuth; @@ -4219,8 +4218,8 @@ ivas_error IVAS_DEC_SetEditableParameters( hIvasDec->st_ivas->hMasaIsmData->gain_ism_edited_fx[obj] = hIvasEditableParameters.ism_metadata[obj].gain_fx; /* Detect direction editing in Param-ISM mode */ - IF ( GT_16( L_abs( L_sub( hIvasDec->st_ivas->hParamIsmDec->azimuth_values_fx[obj], hIvasEditableParameters.ism_metadata[obj].azimuth ) ), OMASA_AZI_EDIT_THR_FX ) || - GT_16( L_abs( L_sub( hIvasDec->st_ivas->hParamIsmDec->elevation_values_fx[obj], hIvasEditableParameters.ism_metadata[obj].elevation ) ), OMASA_ELE_EDIT_THR_FX ) ) + IF( GT_16( L_abs( L_sub( hIvasDec->st_ivas->hParamIsmDec->azimuth_values_fx[obj], hIvasEditableParameters.ism_metadata[obj].azimuth ) ), OMASA_AZI_EDIT_THR_FX ) || + GT_16( L_abs( L_sub( hIvasDec->st_ivas->hParamIsmDec->elevation_values_fx[obj], hIvasEditableParameters.ism_metadata[obj].elevation ) ), OMASA_ELE_EDIT_THR_FX ) ) { hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited[obj] = 1; } @@ -4230,7 +4229,7 @@ ivas_error IVAS_DEC_SetEditableParameters( } /* Detect gain editing in Param-ISM mode */ - IF (GT_32( L_abs( L_sub( ONE_IN_Q30, hIvasEditableParameters.ism_metadata[obj].gain_fx ) ), OMASA_GAIN_EDIT_THR_FX ) ) // TODO: check Q values + IF( GT_32( L_abs( L_sub( ONE_IN_Q30, hIvasEditableParameters.ism_metadata[obj].gain_fx ) ), OMASA_GAIN_EDIT_THR_FX ) ) // TODO: check Q values { hIvasDec->st_ivas->hMasaIsmData->ism_gain_is_edited[obj] = 1; } @@ -4251,20 +4250,20 @@ ivas_error IVAS_DEC_SetEditableParameters( } } #ifdef OMASA_OBJECT_EDITING - ELSE IF ( EQ_16(hIvasDec->st_ivas->ivas_format, MASA_ISM_FORMAT) && ( EQ_16( hIvasDec->st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) || EQ_16( hIvasDec->st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) ) + ELSE IF( EQ_16( hIvasDec->st_ivas->ivas_format, MASA_ISM_FORMAT ) && ( EQ_16( hIvasDec->st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) || EQ_16( hIvasDec->st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) ) { Word16 obj; Word32 id_th; Word32 threshold_azi, threshold_ele; - FOR ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) + FOR( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) { - IF ( hIvasDec->st_ivas->hMasaIsmData != NULL ) + IF( hIvasDec->st_ivas->hMasaIsmData != NULL ) { /* copy relevant fields also to OMASA structs, but only if the value has been changed. original values are in st_ivas->hIsmMetaData */ /* first, need to convert float values to ints used internally */ Word16 new_azi, new_ele; - IF ( hIvasEditableParameters.ism_metadata[obj].azimuth > 0.0f ) + IF( hIvasEditableParameters.ism_metadata[obj].azimuth > 0.0f ) { new_azi = (int16_t) ( hIvasEditableParameters.ism_metadata[obj].azimuth + 0.5f ); } @@ -4273,7 +4272,7 @@ ivas_error IVAS_DEC_SetEditableParameters( new_azi = (int16_t) ( hIvasEditableParameters.ism_metadata[obj].azimuth - 0.5f ); } - IF ( hIvasEditableParameters.ism_metadata[obj].elevation > 0.0f ) + IF( hIvasEditableParameters.ism_metadata[obj].elevation > 0.0f ) { new_ele = (int16_t) ( hIvasEditableParameters.ism_metadata[obj].elevation + 0.5f ); } @@ -4282,10 +4281,10 @@ ivas_error IVAS_DEC_SetEditableParameters( new_ele = (int16_t) ( hIvasEditableParameters.ism_metadata[obj].elevation - 0.5f ); } - IF ( EQ_16( hIvasDec->st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) + IF( EQ_16( hIvasDec->st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) { /* Handle MONO output */ - IF ( NE_16( hIvasDec->st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) ) + IF( NE_16( hIvasDec->st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) ) { dirac_read_idx = hIvasDec->st_ivas->hSpatParamRendCom->render_to_md_map[hIvasDec->st_ivas->hSpatParamRendCom->subframes_rendered]; } @@ -4299,15 +4298,14 @@ ivas_error IVAS_DEC_SetEditableParameters( * which in turn depends from the object priority and importance: * importance -> priority -> number of bits -> elevation resolution -> elevation ring index -> azimuth resolution. * leading to elevation_resolution -> elevation threshold and azimuth resolution -> azimuth threshold */ - //id_th = ( fabsf( (float) hIvasDec->st_ivas->hMasaIsmData->elevation_ism[obj][dirac_read_idx] ) / delta_theta_masa[hIvasDec->st_ivas->hMasaIsmData->bits_ism[obj] - 3] + 0.5f ); - assert(0 && "Insert proper basop code here!"); + // id_th = ( fabsf( (float) hIvasDec->st_ivas->hMasaIsmData->elevation_ism[obj][dirac_read_idx] ) / delta_theta_masa[hIvasDec->st_ivas->hMasaIsmData->bits_ism[obj] - 3] + 0.5f ); + assert( 0 && "Insert proper basop code here!" ); threshold_azi = 360.0f / (float) no_phi_masa[hIvasDec->st_ivas->hMasaIsmData->bits_ism[obj] - 1][id_th]; threshold_ele = delta_theta_masa_fx[hIvasDec->st_ivas->hMasaIsmData->bits_ism[obj] - 3]; test(); - IF ( ( GT_32( L_abs( L_sub(new_azi, hIvasDec->st_ivas->hMasaIsmData->azimuth_ism[obj][dirac_read_idx]) ), threshold_azi ) ) || - ( GT_32( L_abs( L_sub(new_ele, hIvasDec->st_ivas->hMasaIsmData->elevation_ism[obj][dirac_read_idx]) ), threshold_ele ) ) - ) + IF( ( GT_32( L_abs( L_sub( new_azi, hIvasDec->st_ivas->hMasaIsmData->azimuth_ism[obj][dirac_read_idx] ) ), threshold_azi ) ) || + ( GT_32( L_abs( L_sub( new_ele, hIvasDec->st_ivas->hMasaIsmData->elevation_ism[obj][dirac_read_idx] ) ), threshold_ele ) ) ) { /* at least one of the threshold is exceeded, so use new direction value and set editing detection flag */ hIvasDec->st_ivas->hMasaIsmData->azimuth_ism_edited[obj] = new_azi; @@ -4323,8 +4321,8 @@ ivas_error IVAS_DEC_SetEditableParameters( ELSE { /* detect editing in ISM_MASA_MODE_DISC. optionally, add quantization-resolution -based thresholds */ - IF ( GT_32( L_abs( L_sub( hIvasDec->st_ivas->hIsmMetaData[obj]->azimuth_fx, hIvasEditableParameters.ism_metadata[obj].azimuth_fx ) ), OMASA_AZI_EDIT_THR_FX ) || - GT_32( L_abs( L_sub( hIvasDec->st_ivas->hIsmMetaData[obj]->elevation_fx, hIvasEditableParameters.ism_metadata[obj].elevation_fx ) ), OMASA_ELE_EDIT_THR_FX ) ) + IF( GT_32( L_abs( L_sub( hIvasDec->st_ivas->hIsmMetaData[obj]->azimuth_fx, hIvasEditableParameters.ism_metadata[obj].azimuth_fx ) ), OMASA_AZI_EDIT_THR_FX ) || + GT_32( L_abs( L_sub( hIvasDec->st_ivas->hIsmMetaData[obj]->elevation_fx, hIvasEditableParameters.ism_metadata[obj].elevation_fx ) ), OMASA_ELE_EDIT_THR_FX ) ) { hIvasDec->st_ivas->hMasaIsmData->azimuth_ism_edited[obj] = new_azi; hIvasDec->st_ivas->hMasaIsmData->elevation_ism_edited[obj] = new_ele; @@ -4338,7 +4336,7 @@ ivas_error IVAS_DEC_SetEditableParameters( } /* compare pre-edit gain and the edited one to detect editing */ - IF ( L_abs( L_sub(hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain_fx, hIvasEditableParameters.ism_metadata[obj].gain_fx ) ) > OMASA_GAIN_EDIT_THR_FX ) + IF( L_abs( L_sub( hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain_fx, hIvasEditableParameters.ism_metadata[obj].gain_fx ) ) > OMASA_GAIN_EDIT_THR_FX ) { hIvasDec->st_ivas->hMasaIsmData->ism_gain_is_edited[obj] = 1u; hIvasDec->st_ivas->hMasaIsmData->gain_ism_edited_fx[obj] = hIvasEditableParameters.ism_metadata[obj].gain_fx; @@ -4350,7 +4348,7 @@ ivas_error IVAS_DEC_SetEditableParameters( } /* Copy edited values to hIsmMetaData struct */ - IF ( hIvasDec->st_ivas->hIsmMetaData[obj] != NULL ) + IF( hIvasDec->st_ivas->hIsmMetaData[obj] != NULL ) { hIvasDec->st_ivas->hIsmMetaData[obj]->azimuth_fx = hIvasEditableParameters.ism_metadata[obj].azimuth_fx; hIvasDec->st_ivas->hIsmMetaData[obj]->elevation_fx = hIvasEditableParameters.ism_metadata[obj].elevation_fx; @@ -4362,9 +4360,9 @@ ivas_error IVAS_DEC_SetEditableParameters( } } - IF ( GE_32( L_abs( L_sub(hIvasEditableParameters.gain_bed_fx, ONE_IN_Q30) ), OMASA_GAIN_EDIT_THR_FX ) ) //TODO: check Q value + IF( GE_32( L_abs( L_sub( hIvasEditableParameters.gain_bed_fx, ONE_IN_Q30 ) ), OMASA_GAIN_EDIT_THR_FX ) ) // TODO: check Q value { - hIvasDec->st_ivas->hMasaIsmData->gain_masa_edited_fx = hIvasEditableParameters.gain_bed_fx; //TODO: check type + hIvasDec->st_ivas->hMasaIsmData->gain_masa_edited_fx = hIvasEditableParameters.gain_bed_fx; // TODO: check type move32(); hIvasDec->st_ivas->hMasaIsmData->masa_gain_is_edited = 1u; } diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 977d5cdc7..6d741a31b 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -1338,7 +1338,7 @@ static void ivas_dirac_dec_decorrelate_slot_fx( #ifdef FIX_2049_DIFF_IN_DECORR_TAIL *q_out = q_decorrelatedFrameInterleaved; #else - // q_decorrelatedFrameInterleaved will be same as q_inp/q_protoFrame // + // q_decorrelatedFrameInterleaved will be same as q_inp/q_protoFrame // #endif return; } @@ -4995,8 +4995,7 @@ static void getDirectPartGains_fx( Word32 Rmat[3][3], /*Q30*/ PARAMBIN_HRTF_GAIN_CACHE *gainCache, const Word16 isHeadtracked, - HRTFS_PARAMBIN_HANDLE hHrtfParambin -) + HRTFS_PARAMBIN_HANDLE hHrtfParambin ) { // float aziRad, eleRad; Word32 y, mappedX; @@ -5014,15 +5013,15 @@ static void getDirectPartGains_fx( { #ifdef OMASA_OBJECT_EDITING - assert (0 && "Insert proper basop code here!)"); + assert( 0 && "Insert proper basop code here!)" ); //*lImagp = 0.0f; //*rImagp = 0.0f; - //if ( aziDeg == gainCache->azi && eleDeg == gainCache->ele ) + // if ( aziDeg == gainCache->azi && eleDeg == gainCache->ele ) //{ // *lRealp = gainCache->shVec[0]; /* Reused memory */ // *rRealp = gainCache->shVec[1]; /* Reused memory */ //} - //else + // else //{ // /* Convert azi and ele to an azi value of the cone of confusion */ // aziRad = (float) aziDeg * PI_OVER_180; @@ -5364,8 +5363,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( Word32 inIm_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word16 *cldfb_buf_q, const Word16 nBins, - const Word16 subframe -) + const Word16 subframe ) { int16_t bin, ch, inCh, outCh, ismDirIndex, slot, band_idx, bin_lo, bin_hi, max_band, n_ism; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; @@ -5462,37 +5460,37 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( /* OMASA gaining for discrete OMASA mode with stereo_param/bin_room_param renderer */ if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { - assert (0 && "Insert proper basop code here!"); + assert( 0 && "Insert proper basop code here!" ); ///* ///* ISM gaining */ - //for ( ch = 0; ch < n_ism; ch++ ) + // for ( ch = 0; ch < n_ism; ch++ ) //{ - // if ( st_ivas->hMasaIsmData->ism_gain_is_edited[ch] ) - // { - // for ( slot = 0; slot < hSpatParamRendCom->subframe_nbslots[subframe]; slot++ ) - // { - // float gain; - // gain = st_ivas->hMasaIsmData->gain_ism_edited_fx[ch]; - // v_multc( inRe[ch + 2][slot], gain, inRe[ch + 2][slot], nBins ); - // v_multc( inIm[ch + 2][slot], gain, inIm[ch + 2][slot], nBins ); - // } - // } - //} + // if ( st_ivas->hMasaIsmData->ism_gain_is_edited[ch] ) + // { + // for ( slot = 0; slot < hSpatParamRendCom->subframe_nbslots[subframe]; slot++ ) + // { + // float gain; + // gain = st_ivas->hMasaIsmData->gain_ism_edited_fx[ch]; + // v_multc( inRe[ch + 2][slot], gain, inRe[ch + 2][slot], nBins ); + // v_multc( inIm[ch + 2][slot], gain, inIm[ch + 2][slot], nBins ); + // } + // } + // } ///* MASA gaining */ - //for ( ch = 0; ch < 2; ch++ ) + // for ( ch = 0; ch < 2; ch++ ) //{ - // if ( masaGainEdited ) - // { - // for ( slot = 0; slot < hSpatParamRendCom->subframe_nbslots[subframe]; slot++ ) - // { - // float gain_masa; - // gain_masa = st_ivas->hMasaIsmData->gain_masa_edited_fx; - // v_multc( inRe[ch][slot], gain_masa, inRe[ch][slot], nBins ); - // v_multc( inIm[ch][slot], gain_masa, inIm[ch][slot], nBins ); - // } - // } - //} + // if ( masaGainEdited ) + // { + // for ( slot = 0; slot < hSpatParamRendCom->subframe_nbslots[subframe]; slot++ ) + // { + // float gain_masa; + // gain_masa = st_ivas->hMasaIsmData->gain_masa_edited_fx; + // v_multc( inRe[ch][slot], gain_masa, inRe[ch][slot], nBins ); + // v_multc( inIm[ch][slot], gain_masa, inIm[ch][slot], nBins ); + // } + // } + // } } #ifdef OBJ_EDITING_PARAMISM_BIN else if ( st_ivas->ivas_format == ISM_FORMAT && st_ivas->hISMDTX.dtx_flag ) /* If dtx on, perform just the smoothing of the processing gains */ @@ -5655,14 +5653,14 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( { /* Get input and output panning gains */ ivas_get_stereo_panning_gains_fx( hMasaIsmData->azimuth_ism[ismDirIndex][dirac_read_idx], - hMasaIsmData->elevation_ism[ismDirIndex][dirac_read_idx], - panGainsIn[ismDirIndex] ); + hMasaIsmData->elevation_ism[ismDirIndex][dirac_read_idx], + panGainsIn[ismDirIndex] ); if ( ismDirEdited[ismDirIndex] ) { ivas_get_stereo_panning_gains_fx( hMasaIsmData->azimuth_ism_edited[ismDirIndex], - hMasaIsmData->elevation_ism_edited[ismDirIndex], - panGainsOut[ismDirIndex] ); + hMasaIsmData->elevation_ism_edited[ismDirIndex], + panGainsOut[ismDirIndex] ); } else { diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index e7bf22110..13331d2c6 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -2854,7 +2854,7 @@ void ivas_dirac_dec_compute_directional_responses_fx( FOR( dir = 0; dir < hSpatParamRendCom->numIsmDirections; dir++ ) { #ifdef OMASA_OBJECT_EDITING - IF ( hMasaIsm->ism_dir_is_edited[dir] ) + IF( hMasaIsm->ism_dir_is_edited[dir] ) { ivas_dirac_dec_get_response_fx( hMasaIsm->azimuth_ism_edited[dir], hMasaIsm->elevation_ism_edited[dir], direct_response_temp_fx, hDirACRend->hOutSetup.ambisonics_order, Q29 ); } @@ -3112,7 +3112,7 @@ void ivas_dirac_dec_compute_directional_responses_fx( FOR( dir = 0; dir < hSpatParamRendCom->numIsmDirections; dir++ ) { #ifdef OMASA_OBJECT_EDITING - IF ( hMasaIsm->ism_dir_is_edited[dir] ) + IF( hMasaIsm->ism_dir_is_edited[dir] ) { vbap_determine_gains_fx( hVBAPdata, direct_response_temp_fx, hMasaIsm->azimuth_ism_edited[dir], hMasaIsm->elevation_ism_edited[dir], 1 ); } diff --git a/lib_rend/ivas_objectRenderer_fx.c b/lib_rend/ivas_objectRenderer_fx.c index 4d92fd819..3d5818325 100644 --- a/lib_rend/ivas_objectRenderer_fx.c +++ b/lib_rend/ivas_objectRenderer_fx.c @@ -962,7 +962,7 @@ ivas_error ivas_td_binaural_renderer_ext_fx( hIsmMetaData[0]->radius_fx = currentPos->radius_fx; move32(); #ifdef OBJ_EDITING_INTERFACE - hIsmMetaData[0]->gain = ONE_IN_Q30; //TODO: check Q value + hIsmMetaData[0]->gain = ONE_IN_Q30; // TODO: check Q value #endif hIsmMetaData[0]->non_diegetic_flag = currentPos->non_diegetic_flag; move16(); -- GitLab From cdee87c5bab1d305a8eca381a4a1517ec9a16ffc Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 14 Oct 2025 13:58:54 +0200 Subject: [PATCH 06/31] temporarily remove float code --- .../ivas_dirac_dec_binaural_functions_fx.c | 425 +----------------- 1 file changed, 1 insertion(+), 424 deletions(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 6d741a31b..a07ed0050 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -5603,430 +5603,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( #endif else /* Other processing modes */ { - float subframeEne; - float subframeEneCh[2]; - float normEnes[2]; - float ratioAccOrig; - float ratioAccNew; - float ratio; - float ismEneThis; - float ismTargetEneThis; - float ismTargetEneThisCh[2]; - float totalTargetEneCh[2]; - float totalTargetEne; - float masaTargetEneThisCh[2]; - float ismPreprocMtxNew[2][2]; - float ismPreprocMtxIncrement[2][2]; - float eneMove[2]; - float enePreserve[2]; - float ismRatioAcc; - float remainderNormEne; - float centeringFactor; - float eneMoveThis; - float enePreserveThis; - float normVal; - float eqVal; - float outSlotRe[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; - float outSlotIm[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; - float newRatios[6]; - float gainIsmThis; - float gainMasaPow2; - float nSlotDiv; - float tempDivisor; - float masaEneThisCh[2]; - float ratioAccNewDivisor; - - - gainMasaPow2 = 1.0f; - if ( masaGainEdited ) - { - gainMasaPow2 = hMasaIsmData->gain_masa_edited_fx; - gainMasaPow2 *= gainMasaPow2; - } - - nSlots = hSpatParamRendCom->subframe_nbslots[subframe]; - dirac_read_idx = hSpatParamRendCom->render_to_md_map[subframe]; - nSlotDiv = 1.0f / ( (float) nSlots ); - - /* Determine panning gains and energies for each object */ - for ( ismDirIndex = 0; ismDirIndex < n_ism; ismDirIndex++ ) - { - /* Get input and output panning gains */ - ivas_get_stereo_panning_gains_fx( hMasaIsmData->azimuth_ism[ismDirIndex][dirac_read_idx], - hMasaIsmData->elevation_ism[ismDirIndex][dirac_read_idx], - panGainsIn[ismDirIndex] ); - - if ( ismDirEdited[ismDirIndex] ) - { - ivas_get_stereo_panning_gains_fx( hMasaIsmData->azimuth_ism_edited[ismDirIndex], - hMasaIsmData->elevation_ism_edited[ismDirIndex], - panGainsOut[ismDirIndex] ); - } - else - { - /* When not edited, input and output pan gains are the same */ - for ( ch = 0; ch < 2; ch++ ) - { - panGainsOut[ismDirIndex][ch] = panGainsIn[ismDirIndex][ch]; - } - } - /* Determine pan enes */ - for ( ch = 0; ch < 2; ch++ ) - { - panEnesOut[ismDirIndex][ch] = panGainsOut[ismDirIndex][ch] * panGainsOut[ismDirIndex][ch]; - panEnesIn[ismDirIndex][ch] = panGainsIn[ismDirIndex][ch] * panGainsIn[ismDirIndex][ch]; - } - } - - /* Determine the highest band */ - max_band = 0; -#ifdef OBJ_EDITING_PARAMISM_BIN - if ( masaIsmMode ) - { -#endif - while ( max_band < MASA_FREQUENCY_BANDS && MASA_band_grouping_24[max_band] < nBins ) - { - max_band++; - } -#ifdef OBJ_EDITING_PARAMISM_BIN - } - else - { - while ( max_band < MAX_PARAM_ISM_NBANDS && hParamIsmDec->hParamIsm->band_grouping[max_band] < nBins ) - { - max_band++; - } - } -#endif - - /* Init out array */ - for ( int k = 0; k < nSlots; k++ ) - { - for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - set_zero( outSlotRe[ch][k], CLDFB_NO_CHANNELS_MAX ); - set_zero( outSlotIm[ch][k], CLDFB_NO_CHANNELS_MAX ); - } - } - - /* Perform the processing in frequency bands */ - for ( band_idx = 0; band_idx < max_band; band_idx++ ) - { - ratioAccOrig = 0.0f; - ratioAccNew = 0.0f; - ismRatioAcc = 0.0f; - - set_zero( subframeEneCh, 2 ); - set_zero( ismPreprocMtxNew[0], 2 ); - set_zero( ismPreprocMtxNew[1], 2 ); - set_zero( eneMove, 2 ); - set_zero( enePreserve, 2 ); -#ifdef OBJ_EDITING_PARAMISM_BIN - if ( masaIsmMode ) - { -#endif - bin_lo = MASA_band_grouping_24[band_idx]; - bin_hi = min( MASA_band_grouping_24[band_idx + 1], nBins ); -#ifdef OBJ_EDITING_PARAMISM_BIN - } - else - { - bin_lo = hParamIsmDec->hParamIsm->band_grouping[band_idx]; - bin_hi = min( hParamIsmDec->hParamIsm->band_grouping[band_idx + 1], nBins ); - } -#endif - - /* Determine transport normalized energies and subframe energy */ - for ( slot = 0; slot < nSlots; slot++ ) - { - for ( ch = 0; ch < 2; ch++ ) - { - for ( bin = bin_lo; bin < bin_hi; bin++ ) - { - subframeEneCh[ch] += inRe_fx[ch][slot][bin] * inRe_fx[ch][slot][bin]; - subframeEneCh[ch] += inIm_fx[ch][slot][bin] * inIm_fx[ch][slot][bin]; - } - } - } - subframeEne = subframeEneCh[0] + subframeEneCh[1]; - totalTargetEneCh[0] = subframeEneCh[0]; - totalTargetEneCh[1] = subframeEneCh[1]; - masaEneThisCh[0] = subframeEneCh[0]; - masaEneThisCh[1] = subframeEneCh[1]; - - /* Gain editing */ - /* For each object, estimate new target energy per channel based on the applied gain */ - for ( ismDirIndex = 0; ismDirIndex < n_ism; ismDirIndex++ ) - { - ratio = hMasaIsmData->energy_ratio_ism_fx[ismDirIndex][dirac_read_idx][bin_lo]; - ratioAccOrig += ratio; - - /* Calculate MASA energy as a residual of original channel energies subtracted with ISM energies */ - for ( ch = 0; ch < 2; ch++ ) - { - masaEneThisCh[ch] -= panEnesIn[ismDirIndex][ch] * ratio * subframeEne; - } - - /* Calculate target energy, gained ratio for accumulation, and transports gains, if ism gain is edited */ - if ( ismGainEdited[ismDirIndex] ) - { - gainIsmThis = hMasaIsmData->gain_ism_edited_fx[ismDirIndex]; - /* ISM original energy */ - ismEneThis = ratio * subframeEne; - - /* ISM target energy */ - ismTargetEneThis = ( gainIsmThis * gainIsmThis ) * ismEneThis; - - ratio *= gainIsmThis * gainIsmThis; - - /* Determine panning energies and channel target energies */ - for ( ch = 0; ch < 2; ch++ ) - { - ismTargetEneThisCh[ch] = panEnesIn[ismDirIndex][ch] * ismTargetEneThis; /* Ism target energy per channel */ - totalTargetEneCh[ch] -= panEnesIn[ismDirIndex][ch] * ismEneThis; /* Reduce original ism energy */ - totalTargetEneCh[ch] += ismTargetEneThisCh[ch]; /* Add ism target energy per channel */ - } - - /* If separated ism edited, apply gain directly to the separated ism */ - if ( ismDirIndex == hMasaIsmData->idx_separated_ism ) - { - /* Separated object gaining is done elsewhere with DIRAC renderer */ - if ( st_ivas->renderer_type != RENDERER_DIRAC ) - { - /* Gain transport channel of separated ism */ - for ( slot = 0; slot < nSlots; slot++ ) - { - for ( bin = bin_lo; bin < bin_hi; bin++ ) - { - inRe_fx[2][slot][bin] = gainIsmThis * inRe_fx[2][slot][bin]; - inIm_fx[2][slot][bin] = gainIsmThis * inIm_fx[2][slot][bin]; - } - } - } - } - } - ratioAccNew += ratio; - } - -#ifdef OBJ_EDITING_PARAMISM_BIN - if ( masaIsmMode ) - { -#endif - /* MASA original ratios */ - ratio = hSpatParamRendCom->energy_ratio1_fx[dirac_read_idx][bin_lo] + hSpatParamRendCom->energy_ratio2_fx[dirac_read_idx][bin_lo]; - ratioAccOrig += ratio; - - /* Estimate MASA original energies and determine adjusted target energies and gained ratio for accumulation, if a gain is applied to MASA */ - if ( masaGainEdited ) - { - /* Gained MASA ratio */ - ratio *= gainMasaPow2; - - /* Calculate MASA target energies and add to total target energy estimation */ - for ( ch = 0; ch < 2; ch++ ) - { - masaEneThisCh[ch] = fmaxf( masaEneThisCh[ch], 0.0f ); /* MASA original energy per channel */ - masaTargetEneThisCh[ch] = gainMasaPow2 * masaEneThisCh[ch]; /* MASA target energy per channel */ - totalTargetEneCh[ch] -= masaEneThisCh[ch]; /* Reduce original energy per channel */ - totalTargetEneCh[ch] += masaTargetEneThisCh[ch]; /* Add target energy per channel */ - } - } - - ratioAccNew += ratio; -#ifdef OBJ_EDITING_PARAMISM_BIN - } -#endif - - /* Limit target energies to non-negative values */ - for ( ch = 0; ch < 2; ch++ ) - { - totalTargetEneCh[ch] = max( totalTargetEneCh[ch], 0.0f ); - } - - /* Diffuse ratio accumulation based on gaining */ - if ( masaGainEdited ) - { - ratioAccNew += gainMasaPow2 * ( 1 - ratioAccOrig ); - } - else - { - ratioAccNew += ( 1.0f - ratioAccOrig ); - } - - ratioAccNewDivisor = 1.0f / fmaxf( 1e-12f, ratioAccNew ); /* New target total energy ratio divider */ - - /* Determine and process object energy ratios based on gaining */ - for ( ismDirIndex = 0; ismDirIndex < n_ism; ismDirIndex++ ) - { - newRatios[ismDirIndex + 2] = hMasaIsmData->energy_ratio_ism_fx[ismDirIndex][dirac_read_idx][bin_lo]; /* Determine original object energy ratio */ - if ( ismGainEdited[ismDirIndex] ) - { - gainIsmThis = hMasaIsmData->gain_ism_edited_fx[ismDirIndex]; - newRatios[ismDirIndex + 2] *= ( gainIsmThis * gainIsmThis ); /* Gain original object energy ratio, if edited */ - } - newRatios[ismDirIndex + 2] *= ratioAccNewDivisor; /* Divide with new target total ratio */ - } - - /* Determine and process MASA energy ratios based on gaining */ - newRatios[0] = hSpatParamRendCom->energy_ratio1_fx[dirac_read_idx][bin_lo]; - newRatios[1] = hSpatParamRendCom->energy_ratio2_fx[dirac_read_idx][bin_lo]; - if ( masaGainEdited ) - { - newRatios[0] *= gainMasaPow2; - newRatios[1] *= gainMasaPow2; - } - newRatios[0] *= ratioAccNewDivisor; - newRatios[1] *= ratioAccNewDivisor; - - /* Set adjusted energy ratios */ - for ( bin = bin_lo; bin < bin_hi; bin++ ) - { - for ( ismDirIndex = 0; ismDirIndex < n_ism; ismDirIndex++ ) - { - hMasaIsmData->energy_ratio_ism_fx[ismDirIndex][dirac_read_idx][bin] = newRatios[ismDirIndex + 2]; - } - hSpatParamRendCom->energy_ratio1_fx[dirac_read_idx][bin] = newRatios[0]; - hSpatParamRendCom->energy_ratio2_fx[dirac_read_idx][bin] = newRatios[1]; - } - - /* Direction editing */ - /* Determine new energetic values after gaining */ - totalTargetEne = totalTargetEneCh[0] + totalTargetEneCh[1]; - tempDivisor = 1.0f / fmaxf( 1e-12f, totalTargetEne ); - normEnes[0] = totalTargetEneCh[0] * tempDivisor; - normEnes[1] = totalTargetEneCh[1] * tempDivisor; - - /* For each ismDir, determine moved and preserve energy ratio per channel */ - for ( ismDirIndex = 0; ismDirIndex < n_ism; ismDirIndex++ ) - { - ratio = hMasaIsmData->energy_ratio_ism_fx[ismDirIndex][dirac_read_idx][bin_lo]; - - ismRatioAcc += ratio; - - if ( enableCentering ) - { - centeringFactor = fmaxf( 0.0f, 2.0f * fabsf( panEnesIn[ismDirIndex][0] - panEnesOut[ismDirIndex][0] ) - 1.0f ); - for ( ch = 0; ch < 2; ch++ ) - { - panEnesOut[ismDirIndex][ch] *= ( 1.0f - centeringFactor ); - panEnesOut[ismDirIndex][ch] += 0.5f * centeringFactor; - } - } - - for ( ch = 0; ch < 2; ch++ ) - { - eneMoveThis = fmaxf( 0.0f, panEnesIn[ismDirIndex][ch] - panEnesOut[ismDirIndex][ch] ); - enePreserveThis = panEnesIn[ismDirIndex][ch] - eneMoveThis; - - eneMove[ch] += ratio * eneMoveThis; - enePreserve[ch] += ratio * enePreserveThis; - - /* Subtract object parts from normEnes */ - normEnes[ch] -= panEnesIn[ismDirIndex][ch] * ratio; - } - } - - /* Any remaining (non-object) energy is set to be preserved at both channels */ - remainderNormEne = fmaxf( 0.0f, ( 1.0f - ismRatioAcc ) - normEnes[0] - normEnes[1] ); - - /* Normalize */ - for ( ch = 0; ch < 2; ch++ ) - { - enePreserve[ch] += fmaxf( 0.0f, normEnes[ch] + remainderNormEne / 2.0f ); - normVal = 1.0f / fmaxf( EPSILON, eneMove[ch] + enePreserve[ch] ); - normVal *= fminf( 10.0f, totalTargetEneCh[ch] / fmaxf( EPSILON, subframeEneCh[ch] ) ); - eneMove[ch] *= normVal; - enePreserve[ch] *= normVal; - } - - /* Temporally average target energy */ - hMasaIsmData->eneOrigIIR_fx[band_idx] *= STEREO_PREPROCESS_IIR_FACTOR; - hMasaIsmData->eneOrigIIR_fx[band_idx] += totalTargetEne; - - /* Temporally average energy moving and preserving, and generate the transport signal preprocessing matrix for - * gaining objects and moving objects between left and right */ - for ( ch = 0; ch < 2; ch++ ) - { - hMasaIsmData->eneMoveIIR_fx[ch][band_idx] *= STEREO_PREPROCESS_IIR_FACTOR; - hMasaIsmData->eneMoveIIR_fx[ch][band_idx] += eneMove[ch] * totalTargetEne; - hMasaIsmData->enePreserveIIR_fx[ch][band_idx] *= STEREO_PREPROCESS_IIR_FACTOR; - hMasaIsmData->enePreserveIIR_fx[ch][band_idx] += enePreserve[ch] * totalTargetEne; - normVal = 1.0f / fmaxf( EPSILON, hMasaIsmData->eneOrigIIR_fx[band_idx] ); - ismPreprocMtxNew[ch][ch] = fminf( 4.0f, sqrtf( hMasaIsmData->enePreserveIIR_fx[ch][band_idx] * normVal ) ); - ismPreprocMtxNew[1 - ch][ch] = fminf( 4.0f, sqrtf( hMasaIsmData->eneMoveIIR_fx[ch][band_idx] * normVal ) ); - } - - /* Get increment value for temporal interpolation */ - for ( inCh = 0; inCh < 2; inCh++ ) - { - for ( outCh = 0; outCh < 2; outCh++ ) - { - ismPreprocMtxIncrement[outCh][inCh] = ( ismPreprocMtxNew[outCh][inCh] - hMasaIsmData->ismPreprocMatrix_fx[outCh][inCh][band_idx] ) * nSlotDiv; - } - } - - /* Mix signals */ - hMasaIsmData->preprocEneTarget_fx[band_idx] *= STEREO_PREPROCESS_IIR_FACTOR; - hMasaIsmData->preprocEneRealized_fx[band_idx] *= STEREO_PREPROCESS_IIR_FACTOR; - hMasaIsmData->preprocEneTarget_fx[band_idx] += totalTargetEne; - - for ( outCh = 0; outCh < 2; outCh++ ) - { - for ( slot = 0; slot < nSlots; slot++ ) - { - for ( inCh = 0; inCh < 2; inCh++ ) - { - hMasaIsmData->ismPreprocMatrix_fx[outCh][inCh][band_idx] += ismPreprocMtxIncrement[outCh][inCh]; - for ( bin = bin_lo; bin < bin_hi; bin++ ) - { - outSlotRe[outCh][slot][bin] += inRe_fx[inCh][slot][bin] * hMasaIsmData->ismPreprocMatrix_fx[outCh][inCh][band_idx]; - outSlotIm[outCh][slot][bin] += inIm_fx[inCh][slot][bin] * hMasaIsmData->ismPreprocMatrix_fx[outCh][inCh][band_idx]; - } - } - - for ( bin = bin_lo; bin < bin_hi; bin++ ) - { - hMasaIsmData->preprocEneRealized_fx[band_idx] += ( outSlotRe[outCh][slot][bin] * outSlotRe[outCh][slot][bin] ) + ( outSlotIm[outCh][slot][bin] * outSlotIm[outCh][slot][bin] ); - } - } - } - - eqVal = fminf( 4.0f, sqrtf( hMasaIsmData->preprocEneTarget_fx[band_idx] / fmaxf( 1e-12f, hMasaIsmData->preprocEneRealized_fx[band_idx] ) ) ); - - for ( ch = 0; ch < 2; ch++ ) - { - for ( slot = 0; slot < nSlots; slot++ ) - { - for ( bin = bin_lo; bin < bin_hi; bin++ ) - { - inRe_fx[ch][slot][bin] = outSlotRe[ch][slot][bin] * eqVal; - inIm_fx[ch][slot][bin] = outSlotIm[ch][slot][bin] * eqVal; - } - } - } - } - -#ifdef OBJ_EDITING_PARAMISM_BIN - if ( !masaIsmMode ) - { - int16_t obj_idx1, obj_idx2; - - for ( band_idx = 0; band_idx < hParamIsmDec->hParamIsm->nbands; band_idx++ ) - { - bin_lo = hParamIsmDec->hParamIsm->band_grouping[band_idx]; - bin_hi = hParamIsmDec->hParamIsm->band_grouping[band_idx + 1]; - - obj_idx1 = hParamIsmDec->hParamIsm->obj_indices[band_idx][0][0]; - obj_idx2 = hParamIsmDec->hParamIsm->obj_indices[band_idx][0][1]; - - for ( bin = bin_lo; bin < bin_hi; bin++ ) - { - hSpatParamRendCom->energy_ratio1_fx[dirac_read_idx][bin] = hMasaIsmData->energy_ratio_ism_fx[obj_idx1][dirac_read_idx][bin]; - hSpatParamRendCom->energy_ratio2_fx[dirac_read_idx][bin] = hMasaIsmData->energy_ratio_ism_fx[obj_idx2][dirac_read_idx][bin]; - } - } - } -#endif + assert( 0 && "Insert proper basop code here!" ); } return; -- GitLab From b019f8ef4507a45841b03a5c7c493b3e744c6357 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 14 Oct 2025 14:00:19 +0200 Subject: [PATCH 07/31] disable some changes for now --- lib_rend/ivas_dirac_dec_binaural_functions_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index a07ed0050..cec23aee8 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -5381,13 +5381,13 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( uint8_t ismGainEdited[4]; uint8_t ismDirEdited[4]; uint8_t masaGainEdited; -#ifdef OBJ_EDITING_PARAMISM_BIN +#if 0 uint8_t masaIsmMode; #endif hSpatParamRendCom = st_ivas->hSpatParamRendCom; hMasaIsmData = st_ivas->hMasaIsmData; -#ifdef OBJ_EDITING_PARAMISM_BIN +#if 0 hParamIsmDec = st_ivas->hParamIsmDec; if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) -- GitLab From 341fb63a80ac9566c45bb78213523907041a29fa Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 14 Oct 2025 14:02:36 +0200 Subject: [PATCH 08/31] disable some changes for now --- lib_dec/ivas_ism_param_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 2a144880d..7802e1d7b 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -2128,7 +2128,7 @@ void ivas_param_ism_params_to_masa_param_mapping_fx( } } -#ifdef OBJ_EDITING_PARAMISM_BIN +#if 0 for ( obj = 0; obj < st_ivas->nchan_ism; obj++ ) { for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) -- GitLab From 18ce0a33c0ed3529861505e22dab400b52f4e273 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 14 Oct 2025 14:06:26 +0200 Subject: [PATCH 09/31] disable some changes for now --- lib_dec/ivas_ism_param_dec_fx.c | 4 ++-- lib_dec/ivas_jbm_dec_fx.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 7802e1d7b..cd68891b1 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -1984,7 +1984,7 @@ void ivas_param_ism_params_to_masa_param_mapping_fx( Word16 azimuth[2]; Word16 elevation[2]; Word16 power_ratio_fx[2]; /* Q15 */ -#ifdef OBJ_EDITING_PARAMISM_BIN +#if 0 MASA_ISM_DATA_HANDLE hMasaIsmData; int16_t obj; int16_t obj_idx; @@ -2000,7 +2000,7 @@ void ivas_param_ism_params_to_masa_param_mapping_fx( move16(); nBins = hSpatParamRendCom->num_freq_bands; move16(); -#ifdef OBJ_EDITING_PARAMISM_BIN +#if 0 hMasaIsmData = st_ivas->hMasaIsmData; move16(); #endif diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index beec45804..a950c3020 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -4701,8 +4701,8 @@ void ivas_jbm_dec_prepare_renderer( #ifdef OMASA_OBJECT_EDITING IF( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) { - Word16 tcBufferSize; - tcBufferSize = st_ivas->hSpatParamRendCom->num_slots * st_ivas->hSpatParamRendCom->slot_size; + //Word16 tcBufferSize; + //tcBufferSize = st_ivas->hSpatParamRendCom->num_slots * st_ivas->hSpatParamRendCom->slot_size; IF( st_ivas->hMasaIsmData->masa_gain_is_edited ) { -- GitLab From 3c7c6c378ad4eb8aff29b324410b504a680e0a9e Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 14 Oct 2025 15:43:19 +0200 Subject: [PATCH 10/31] fix formatting --- lib_dec/ivas_jbm_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index a950c3020..5d9d43a3f 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -4701,8 +4701,8 @@ void ivas_jbm_dec_prepare_renderer( #ifdef OMASA_OBJECT_EDITING IF( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) { - //Word16 tcBufferSize; - //tcBufferSize = st_ivas->hSpatParamRendCom->num_slots * st_ivas->hSpatParamRendCom->slot_size; + // Word16 tcBufferSize; + // tcBufferSize = st_ivas->hSpatParamRendCom->num_slots * st_ivas->hSpatParamRendCom->slot_size; IF( st_ivas->hMasaIsmData->masa_gain_is_edited ) { -- GitLab From 0a1a5d2c8dab672a950ccf6b833f7eeccd48f7ea Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 14 Oct 2025 15:51:13 +0200 Subject: [PATCH 11/31] fix compile errors --- lib_rend/ivas_dirac_dec_binaural_functions_fx.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index cec23aee8..047ea6bc2 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -4998,6 +4998,7 @@ static void getDirectPartGains_fx( HRTFS_PARAMBIN_HANDLE hHrtfParambin ) { // float aziRad, eleRad; +#if 0 Word32 y, mappedX; Word16 aziRadMapped, A, A2, A3; const Word16 LsAngleRad = 17157; // Q15 @@ -5008,6 +5009,7 @@ static void getDirectPartGains_fx( ptr_sin = &sine_table_Q31[180]; // sin[x] = sine_table_Q31[180 + x] ptr_cos = cosine_table_Q31; +#endif IF( renderStereoOutputInsteadOfBinaural ) /* In stereo (i.e. non-binaural) rendering mode */ { @@ -5368,23 +5370,23 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( int16_t bin, ch, inCh, outCh, ismDirIndex, slot, band_idx, bin_lo, bin_hi, max_band, n_ism; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; MASA_ISM_DATA_HANDLE hMasaIsmData; -#ifdef OBJ_EDITING_PARAMISM_BIN - PARAM_ISM_DEC_HANDLE hParamIsmDec; -#endif + PARAM_ISM_DEC_HANDLE hParamIsmDec = 0; + int16_t nSlots; +#if 0 uint8_t enableCentering; int16_t dirac_read_idx; - int16_t nSlots; float panGainsOut[4][2]; float panGainsIn[4][2]; float panEnesOut[4][2]; float panEnesIn[4][2]; +#endif uint8_t ismGainEdited[4]; uint8_t ismDirEdited[4]; uint8_t masaGainEdited; #if 0 uint8_t masaIsmMode; #endif - + *cldfb_buf_q = 0; hSpatParamRendCom = st_ivas->hSpatParamRendCom; hMasaIsmData = st_ivas->hMasaIsmData; #if 0 @@ -5398,7 +5400,6 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( { masaIsmMode = 0u; } -#endif if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_FOA || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA2 || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA3 ) { @@ -5408,6 +5409,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( { enableCentering = 1; } +#endif #ifdef OBJ_EDITING_PARAMISM_BIN if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC || st_ivas->ivas_format == ISM_FORMAT ) -- GitLab From 5748d3c253a4aad2dc7ca1599c55d30f68562185 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 14 Oct 2025 15:54:23 +0200 Subject: [PATCH 12/31] fix compile warnings --- lib_dec/lib_dec_fx.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 6253a4d30..6df308149 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -4000,7 +4000,9 @@ ivas_error IVAS_DEC_GetEditableParameters( IVAS_DEC_HANDLE hIvasDec, IVAS_EDITABLE_PARAMETERS *hIvasEditableParameters ) { +#if 0 ivas_error error; +#endif #ifdef OMASA_OBJECT_EDITING int16_t dirac_read_idx; #endif @@ -4160,7 +4162,9 @@ ivas_error IVAS_DEC_SetEditableParameters( IVAS_DEC_HANDLE hIvasDec, IVAS_EDITABLE_PARAMETERS hIvasEditableParameters ) { +#if 0 ivas_error error; +#endif #ifdef OMASA_OBJECT_EDITING Word16 dirac_read_idx; #endif -- GitLab From 9692da1e3b76538d5f3bf44039f8b37c0cd8d99e Mon Sep 17 00:00:00 2001 From: lintervo Date: Thu, 16 Oct 2025 10:48:04 +0300 Subject: [PATCH 13/31] Merge 1680_basop_port_object_editing_implementation_nokia_changes into 1680_basop_port_object_editing_implementation --- apps/decoder.c | 82 + lib_com/common_api_types.h | 14 +- lib_com/ivas_cnst.h | 7 +- lib_com/ivas_prot_fx.h | 2 +- lib_com/ivas_rom_com.h | 3 + lib_com/ivas_rom_com_fx.c | 7 + lib_com/options.h | 6 + lib_dec/ivas_dirac_dec_fx.c | 58 +- lib_dec/ivas_init_dec_fx.c | 4 +- lib_dec/ivas_ism_dec_fx.c | 7 +- lib_dec/ivas_ism_param_dec_fx.c | 43 +- lib_dec/ivas_ism_renderer_fx.c | 25 +- lib_dec/ivas_jbm_dec_fx.c | 26 +- lib_dec/ivas_masa_dec_fx.c | 5 +- lib_dec/ivas_objectRenderer_internal_fx.c | 2 +- lib_dec/ivas_omasa_dec_fx.c | 70 +- lib_dec/ivas_stat_dec.h | 52 +- lib_dec/lib_dec.h | 6 +- lib_dec/lib_dec_fx.c | 151 +- .../ivas_dirac_dec_binaural_functions_fx.c | 1530 ++++++++++++++--- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 8 +- lib_rend/ivas_objectRenderer_fx.c | 4 +- lib_rend/ivas_objectRenderer_sources_fx.c | 10 +- lib_rend/ivas_prot_rend_fx.h | 11 +- lib_util/ism_file_reader.c | 2 +- lib_util/ism_file_writer.c | 2 +- 26 files changed, 1647 insertions(+), 490 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 36ed7a94a..7bb54c6de 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -51,6 +51,11 @@ #include "wmc_auto.h" #include "options.h" #include "stl.h" +#ifdef OBJ_EDITING_API +#ifdef OBJ_EDITING_EXAMPLE +#include +#endif +#endif #define WMC_TOOL_SKIP @@ -135,6 +140,9 @@ typedef struct AcousticEnvironmentSequence aeSequence; bool dpidEnabled; uint16_t directivityPatternId[IVAS_MAX_NUM_OBJECTS]; +#ifdef OBJ_EDITING_EXAMPLE + bool objEditEnabled; +#endif } DecArguments; @@ -1008,6 +1016,9 @@ static bool parseCmdlIVAS_dec( { arg->directivityPatternId[i] = 65535; } +#ifdef OBJ_EDITING_EXAMPLE + arg->objEditEnabled = false; +#endif /*-----------------------------------------------------------------* * Initialization @@ -1459,6 +1470,13 @@ static bool parseCmdlIVAS_dec( i += tmp; } +#ifdef OBJ_EDITING_EXAMPLE + else if ( strcmp( argv_to_upper, "-OBJ_EDIT" ) == 0 ) + { + arg->objEditEnabled = true; + i++; + } +#endif /*-----------------------------------------------------------------* * Option not recognized @@ -1997,6 +2015,11 @@ static ivas_error decodeG192( int16_t isSplitRend, isSplitCoded; IVAS_RENDER_CONFIG_DATA renderConfig; RenderConfigReader *renderConfigReader = NULL; +#ifdef OBJ_EDITING_API +#ifdef OBJ_EDITING_EXAMPLE + IVAS_EDITABLE_PARAMETERS editableParameters; +#endif +#endif if ( ( error = IVAS_DEC_is_split_rendering_enabled( hIvasDec, &isSplitRend ) ) != IVAS_ERR_OK ) { @@ -2275,6 +2298,65 @@ static ivas_error decodeG192( #endif #ifdef OBJ_EDITING_API +#ifdef OBJ_EDITING_EXAMPLE + if ( arg.objEditEnabled ) + { + + /* Do object info editing here */ + /* get object parameters */ + if ( ( error = IVAS_DEC_GetEditableParameters( hIvasDec, &editableParameters ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError: could not get the editable parameters: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + + /* edit object parameters...*/ + + /* put the objects equally spaced at the horizontal plane */ + /* and play a little bit with the gains... */ + // int16_t obj_idx, non_diegetic_obj_idx; + // int16_t num_nondiegetic_objects; + // + // num_nondiegetic_objects = 0; + // for ( obj_idx = 0; obj_idx < editableParameters.num_obj; obj_idx++ ) + // { + // if ( !editableParameters.ism_metadata[obj_idx].non_diegetic_flag ) + // { + // num_nondiegetic_objects++; + // } + // } + // if ( num_nondiegetic_objects ) + // { + // float start_angle, angle_inc; + // angle_inc = 360.0f / (float) num_nondiegetic_objects; + // start_angle = angle_inc / 2.0f; + // for ( obj_idx = 0, non_diegetic_obj_idx = 0; obj_idx < editableParameters.num_obj; obj_idx++ ) + // { + // if ( !editableParameters.ism_metadata[obj_idx].non_diegetic_flag ) + // { + // editableParameters.ism_metadata[obj_idx].elevation = 0.0f; + // editableParameters.ism_metadata[obj_idx].azimuth = start_angle + (float) non_diegetic_obj_idx * angle_inc; + // non_diegetic_obj_idx++; + // } + // } + // } + // + // /* breakover object gains */ + // for ( obj_idx = 0; obj_idx < editableParameters.num_obj; obj_idx++ ) + // { + // editableParameters.ism_metadata[obj_idx].gain = 0.5f + (float) ( ( frame + obj_idx * 50 ) % 250 ) / 250.0f; + // } + // + // editableParameters.gain_bed = 0.5f; + + /* set new object parameters*/ + if ( ( error = IVAS_DEC_SetEditableParameters( hIvasDec, editableParameters ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError: could not set the editable parameters: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + } +#endif /* Do the final preparations needed for rendering */ if ( ( error = IVAS_DEC_PrepareRenderer( hIvasDec ) ) != IVAS_ERR_OK ) { diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index d8ccd49d9..863d0ccfb 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -122,13 +122,13 @@ typedef struct _IVAS_ENC_CHANNEL_AWARE_CONFIG typedef struct _IVAS_ISM_METADATA { - Word32 azimuth_fx; /* Q22 */ - Word32 elevation_fx; /* Q22 */ - Word16 radius_fx; /* Q9 */ - Word32 spread_fx; /* Q22 */ - Word32 gainFactor_fx; /* Q31 */ - Word32 yaw_fx; /* Q22 */ - Word32 pitch_fx; /* Q22 */ + Word32 azimuth_fx; /* Q22 */ + Word32 elevation_fx; /* Q22 */ + Word16 radius_fx; /* Q9 */ + Word32 spread_fx; /* Q22 */ + Word32 gainFactor_fx; /* Q31 */ // TODO: Gain factor can't be Q31, due to the gain editing + Word32 yaw_fx; /* Q22 */ + Word32 pitch_fx; /* Q22 */ float azimuth; float elevation; float radius; diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 547bd374f..b412ba3d0 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1328,14 +1328,13 @@ enum #define OMASA_TDREND_MATCHING_GAIN_FX 26026 //TODO: insert proper Q representations #ifdef OMASA_OBJECT_EDITING -#define OMASA_GAIN_EDIT_THR_FX 0 /* OMASA gain change threshold */ -#define OMASA_AZI_EDIT_THR_FX 1 /* OMASA-DISC azimuth change threshold */ -#define OMASA_ELE_EDIT_THR_FX 2 /* OMASA-DISC elevation change threshold */ +#define OMASA_GAIN_EDIT_THR_FX 246 /* OMASA gain change threshold, 0.06f in Q12 */ +#define OMASA_AZI_EDIT_THR_FX ONE_IN_Q22 /* OMASA-DISC azimuth change threshold, 1.0f in Q22 */ +#define OMASA_ELE_EDIT_THR_FX ONE_IN_Q23 /* OMASA-DISC elevation change threshold, 2.0f in Q22 */ #endif #define MASA_INV_ANGLE_AT_EQUATOR_DEG_Q30 (1453366656l) - #define MASA_JBM_RINGBUFFER_FRAMES 3 #define TOLERANCE_360_Q22 1510033326 /* 360 in Q22 + 0.02 in Q22*/ #define MINUS_TOLERANCE_360_Q22 -1510033326 /* - (360 in Q22 + 0.02 in Q22) */ diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 80155e5a6..a00109ac0 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -3947,7 +3947,7 @@ void ivas_omasa_preProcessStereoTransportsForMovedObjects_fx( Word32 inIm_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /*cldfb_buf_q*/ Word16 *cldfb_buf_q, const Word16 nBins, - const Word16 subframe + const Word16 subframe ); diff --git a/lib_com/ivas_rom_com.h b/lib_com/ivas_rom_com.h index 3c24b6823..5072e385f 100644 --- a/lib_com/ivas_rom_com.h +++ b/lib_com/ivas_rom_com.h @@ -294,6 +294,9 @@ extern const Word32 diffuseness_thresholds_hr_fx[HR_MASA_ER_LEVELS + 1]; extern const Word32 no_phi_masa_inv_fx[NO_SPHERICAL_GRIDS][MAX_NO_THETA]; extern const Word32 azimuth_cb_fx[8]; extern const Word32 delta_theta_masa_fx[NO_SPHERICAL_GRIDS - 2]; +#ifdef OBJ_EDIT_BASOP +extern const Word32 delta_theta_masa_inv_fx[NO_SPHERICAL_GRIDS - 2]; +#endif extern const Word16 coherence_cb0_masa_Q14[DIRAC_DIFFUSE_LEVELS * 2 * MASA_NO_CV_COH]; extern const Word32 coherence_cb0_masa_fx[DIRAC_DIFFUSE_LEVELS * 2 * MASA_NO_CV_COH]; extern const Word16 coherence_cb1_masa_Q15[MASA_NO_CV_COH1 * MASA_MAXIMUM_CODING_SUBBANDS]; /* 25 */ diff --git a/lib_com/ivas_rom_com_fx.c b/lib_com/ivas_rom_com_fx.c index 395a3c08f..4b14f6d5a 100644 --- a/lib_com/ivas_rom_com_fx.c +++ b/lib_com/ivas_rom_com_fx.c @@ -4406,6 +4406,13 @@ const Word32 delta_theta_masa_fx[NO_SPHERICAL_GRIDS - 2] = { 188743680, 188743680, 150994944, 106954752, 83886080, 62914560, 45214596, 28101836, 20971520 }; +#ifdef OBJ_EDIT_BASOP +// Q31 +const Word32 delta_theta_masa_inv_fx[NO_SPHERICAL_GRIDS - 2] = { + 47721859, 47721859, 59652324, 84215045, 107374182, 143165577, 199209986, 320519947, 429496730 +}; +#endif + // q = 14 const Word16 coherence_cb0_masa_Q14[DIRAC_DIFFUSE_LEVELS * 2 * MASA_NO_CV_COH] = { 783, 4173, 9036, 16163, 22238, 27587, 32234, 0, diff --git a/lib_com/options.h b/lib_com/options.h index b2ece6346..1a7fcf650 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -162,6 +162,7 @@ #define NONBE_FIX_1297_SPAR_JBM_MEM_SAN /* Dolby: issue 1297, SPAR + JBM + BR switch memory sanitizer */ // object-editing feature porting +#define OBJ_EDITING_INTERFACE /* Interface for object editing */ #define OBJ_EDITING_API /* object editing changes related to the API */ #ifdef OBJ_EDITING_API #define FIX_HRTF_LOAD_API // solves API conflicts between HRTF and object-editing features @@ -169,9 +170,14 @@ #define TMP_FIX_OMASA_SR_BE // temporary fix to keep OMASA split-rendering BE #define OBJ_EDITING_EXAMPLE /* obj editing example code in decoder.c */ #define OMASA_OBJECT_EDITING /* Nokia: object editing interface for OMASA */ +#ifdef OMASA_OBJECT_EDITING +#define NONBE_1399_1400_FIX_OBJ_EDIT_ISSUES // Nokia: Fix 1399_1400 issue in float, this is essential for the BASOP porting +#endif #define OBJ_EDITING_PARAMISM_BIN /* Nokia: object editing for ParamISM to binaural */ +#define OBJ_EDIT_BASOP #endif + /* #################### End BASOP porting switches ############################ */ #endif diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index a4c7df45e..b39acf657 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -2882,25 +2882,15 @@ void ivas_dirac_dec_render_sf_fx( } #ifdef OMASA_OBJECT_EDITING - if ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) + IF( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) { #ifdef FIX_1319_STACK_SBA_DECODER ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( st_ivas, Cldfb_RealBuffer_Binaural_fx[0], Cldfb_ImagBuffer_Binaural_fx[0], &cldfb_buf_q, hSpatParamRendCom->num_freq_bands, subframe_idx ); #else ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( st_ivas, Cldfb_RealBuffer_Temp_fx, Cldfb_ImagBuffer_Temp_fx, &cldfb_buf_q, hSpatParamRendCom->num_freq_bands, subframe_idx ); #endif - } -#else - test(); - IF( ( NE_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && NE_16( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) ) - { -#ifdef FIX_1319_STACK_SBA_DECODER - ivas_omasa_preProcessStereoTransportsForMovedObjects_fx( st_ivas, Cldfb_RealBuffer_Binaural_fx[0], Cldfb_ImagBuffer_Binaural_fx[0], &cldfb_buf_q, hSpatParamRendCom->num_freq_bands, subframe_idx ); -#else - ivas_omasa_preProcessStereoTransportsForMovedObjects_fx( st_ivas, Cldfb_RealBuffer_Temp_fx, Cldfb_ImagBuffer_Temp_fx, &cldfb_buf_q, hSpatParamRendCom->num_freq_bands, subframe_idx ); #endif } -#endif } FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) @@ -2936,8 +2926,8 @@ void ivas_dirac_dec_render_sf_fx( Copy32( Cldfb_RealBuffer_Binaural_fx[0][ch][slot_idx], Cldfb_RealBuffer_fx[ch][0], hSpatParamRendCom->num_freq_bands ); Copy32( Cldfb_ImagBuffer_Binaural_fx[0][ch][slot_idx], Cldfb_ImagBuffer_fx[ch][0], hSpatParamRendCom->num_freq_bands ); #else - Copy32( Cldfb_RealBuffer_Temp_fx[ch][slot_idx], Cldfb_RealBuffer_fx[ch][0], hSpatParamRendCom->num_freq_bands ); - Copy32( Cldfb_ImagBuffer_Temp_fx[ch][slot_idx], Cldfb_ImagBuffer_fx[ch][0], hSpatParamRendCom->num_freq_bands ); + Copy32( Cldfb_RealBuffer_Temp_fx[ch][slot_idx], Cldfb_RealBuffer_fx[ch][0], hSpatParamRendCom->num_freq_bands ); + Copy32( Cldfb_ImagBuffer_Temp_fx[ch][slot_idx], Cldfb_ImagBuffer_fx[ch][0], hSpatParamRendCom->num_freq_bands ); #endif } } @@ -3929,30 +3919,30 @@ void ivas_dirac_dec_render_sf_fx( Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx ); } #else - IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + IF( st_ivas->hSplitBinRend->hCldfbDataOut != NULL ) { - IF( st_ivas->hSplitBinRend->hCldfbDataOut != NULL ) + FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) { - FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) + FOR( ch = 0; ch < st_ivas->hBinRenderer->nInChannels; ch++ ) { - FOR( ch = 0; ch < st_ivas->hBinRenderer->nInChannels; ch++ ) - { - Copy32( Cldfb_RealBuffer_fx[ch][slot_idx], st_ivas->hSplitBinRend->hCldfbDataOut->Cldfb_RealBuffer_fx[ch][add( slot_idx_start, slot_idx )], hSpatParamRendCom->num_freq_bands ); - Copy32( Cldfb_ImagBuffer_fx[ch][slot_idx], st_ivas->hSplitBinRend->hCldfbDataOut->Cldfb_ImagBuffer_fx[ch][add( slot_idx_start, slot_idx )], hSpatParamRendCom->num_freq_bands ); - } + Copy32( Cldfb_RealBuffer_fx[ch][slot_idx], st_ivas->hSplitBinRend->hCldfbDataOut->Cldfb_RealBuffer_fx[ch][add( slot_idx_start, slot_idx )], hSpatParamRendCom->num_freq_bands ); + Copy32( Cldfb_ImagBuffer_fx[ch][slot_idx], st_ivas->hSplitBinRend->hCldfbDataOut->Cldfb_ImagBuffer_fx[ch][add( slot_idx_start, slot_idx )], hSpatParamRendCom->num_freq_bands ); } - st_ivas->hSplitBinRend->hCldfbDataOut->config = st_ivas->hIntSetup.output_config; - move16(); } + st_ivas->hSplitBinRend->hCldfbDataOut->config = st_ivas->hIntSetup.output_config; + move16(); } + } - /*Binaural output in Q6 format*/ - ivas_binRenderer_fx( st_ivas->hBinRenderer, - ( st_ivas->hSplitBinRend == NULL ) ? NULL : &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, - st_ivas->hCombinedOrientationData, - hSpatParamRendCom->subframe_nbslots[subframe_idx], - Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, - Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, &input_q ); + /*Binaural output in Q6 format*/ + ivas_binRenderer_fx( st_ivas->hBinRenderer, + ( st_ivas->hSplitBinRend == NULL ) ? NULL : &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, + st_ivas->hCombinedOrientationData, + hSpatParamRendCom->subframe_nbslots[subframe_idx], + Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, + Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, &input_q ); #endif /* Inverse CLDFB*/ @@ -3964,8 +3954,8 @@ void ivas_dirac_dec_render_sf_fx( Word32 *RealBuffer_fx[CLDFB_SLOTS_PER_SUBFRAME]; Word32 *ImagBuffer_fx[CLDFB_SLOTS_PER_SUBFRAME]; #else - Word32 *RealBuffer_fx[MAX_PARAM_SPATIAL_SUBFRAMES]; - Word32 *ImagBuffer_fx[MAX_PARAM_SPATIAL_SUBFRAMES]; + Word32 *RealBuffer_fx[MAX_PARAM_SPATIAL_SUBFRAMES]; + Word32 *ImagBuffer_fx[MAX_PARAM_SPATIAL_SUBFRAMES]; #endif FOR( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ ) { @@ -4016,8 +4006,8 @@ void ivas_dirac_dec_render_sf_fx( Word32 *RealBuffer_fx[CLDFB_SLOTS_PER_SUBFRAME]; Word32 *ImagBuffer_fx[CLDFB_SLOTS_PER_SUBFRAME]; #else - Word32 *RealBuffer_fx[MAX_PARAM_SPATIAL_SUBFRAMES]; - Word32 *ImagBuffer_fx[MAX_PARAM_SPATIAL_SUBFRAMES]; + Word32 *RealBuffer_fx[MAX_PARAM_SPATIAL_SUBFRAMES]; + Word32 *ImagBuffer_fx[MAX_PARAM_SPATIAL_SUBFRAMES]; #endif Word16 outchannels; diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 540e98522..472167cee 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -1885,10 +1885,10 @@ ivas_error ivas_init_decoder_fx( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed2 = st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed3; move16(); #ifdef OBJ_EDITING_PARAMISM_BIN - if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) { /* reusing OMASA function for allocating and initializing MASA_ISM rendering handle (even though not in OMASA) */ - if ( ( error = ivas_omasa_data_open_fx( st_ivas ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_omasa_data_open_fx( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_dec/ivas_ism_dec_fx.c b/lib_dec/ivas_ism_dec_fx.c index 1ae90aa15..7ea9d1f54 100644 --- a/lib_dec/ivas_ism_dec_fx.c +++ b/lib_dec/ivas_ism_dec_fx.c @@ -269,6 +269,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( /* close the parametric binaural renderer */ ivas_dirac_dec_close_binaural_data_fx( st_ivas->hDiracDecBin ); + #ifdef OBJ_EDITING_PARAMISM_BIN /* Close omasa data struct (used for object editing) */ ivas_omasa_data_close_fx( &st_ivas->hMasaIsmData ); @@ -309,10 +310,9 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( { return error; } - #ifdef OBJ_EDITING_PARAMISM_BIN /* Open omasa data struct (used for object editing) */ - if ( ( error = ivas_omasa_data_open_fx( st_ivas ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_omasa_data_open_fx( st_ivas ) ) != IVAS_ERR_OK ) { return error; } @@ -347,12 +347,11 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( #ifdef OBJ_EDITING_PARAMISM_BIN /* Open omasa data struct (used for object editing) */ - if ( ( error = ivas_omasa_data_open_fx( st_ivas ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_omasa_data_open_fx( st_ivas ) ) != IVAS_ERR_OK ) { return error; } #endif - /* close the crend binaural renderer */ #ifdef FIX_CREND_SIMPLIFY_CODE ivas_rend_closeCrend_fx( &( st_ivas->hCrendWrapper ) ); diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index cd68891b1..c62e7a783 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -1984,10 +1984,10 @@ void ivas_param_ism_params_to_masa_param_mapping_fx( Word16 azimuth[2]; Word16 elevation[2]; Word16 power_ratio_fx[2]; /* Q15 */ -#if 0 +#ifdef OBJ_EDITING_PARAMISM_BIN MASA_ISM_DATA_HANDLE hMasaIsmData; - int16_t obj; - int16_t obj_idx; + Word16 obj; + Word16 obj_idx; #endif #ifndef OBJ_EDITING_API Word32 ivas_total_brate; @@ -1998,12 +1998,11 @@ void ivas_param_ism_params_to_masa_param_mapping_fx( move16(); hSpatParamRendCom = st_ivas->hSpatParamRendCom; move16(); - nBins = hSpatParamRendCom->num_freq_bands; - move16(); -#if 0 +#ifdef OBJ_EDITING_PARAMISM_BIN hMasaIsmData = st_ivas->hMasaIsmData; - move16(); #endif + nBins = hSpatParamRendCom->num_freq_bands; + move16(); #ifndef OBJ_EDITING_API ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; move32(); @@ -2128,39 +2127,39 @@ void ivas_param_ism_params_to_masa_param_mapping_fx( } } -#if 0 - for ( obj = 0; obj < st_ivas->nchan_ism; obj++ ) +#ifdef OBJ_EDITING_PARAMISM_BIN + FOR( obj = 0; obj < st_ivas->nchan_ism; obj++ ) { - for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) + FOR( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) { - hMasaIsmData->azimuth_ism[obj][sf_idx] = (int16_t) roundf( hParamIsmDec->azimuth_values_fx[obj] ); - hMasaIsmData->elevation_ism[obj][sf_idx] = (int16_t) roundf( hParamIsmDec->elevation_values_fx[obj] ); + hMasaIsmData->azimuth_ism[obj][sf_idx] = extract_l( L_shr( ( L_add( hParamIsmDec->azimuth_values_fx[obj], ( 1 << 21 ) ) ), 22 ) ); // Q0 + hMasaIsmData->elevation_ism[obj][sf_idx] = extract_l( L_shr_r( L_add( hParamIsmDec->elevation_values_fx[obj], ( 1 << 21 ) ), 22 ) ); // Scale to Q0 } - hMasaIsmData->azimuth_ism_edited[obj] = (int16_t) roundf( hParamIsmDec->edited_azimuth_values_fx[obj] ); - hMasaIsmData->elevation_ism_edited[obj] = (int16_t) roundf( hParamIsmDec->edited_elevation_values_fx[obj] ); + hMasaIsmData->azimuth_ism_edited_fx[obj] = extract_l( L_shr( ( L_add( hParamIsmDec->edited_azimuth_values_fx[obj], ( 1 << 21 ) ) ), 22 ) ); + hMasaIsmData->elevation_ism_edited_fx[obj] = extract_l( L_shr( ( L_add( hParamIsmDec->edited_azimuth_values_fx[obj], ( 1 << 21 ) ) ), 22 ) ); - for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) + FOR( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) { - set_zero( hMasaIsmData->energy_ratio_ism_fx[obj][sf_idx], CLDFB_NO_CHANNELS_MAX ); + set_zero_fx( hMasaIsmData->energy_ratio_ism_fx[obj][sf_idx], CLDFB_NO_CHANNELS_MAX ); } } - for ( obj = 0; obj < MAX_PARAM_ISM_WAVE; obj++ ) + FOR( obj = 0; obj < MAX_PARAM_ISM_WAVE; obj++ ) { - for ( band_idx = 0; band_idx < hParamIsmDec->hParamIsm->nbands; band_idx++ ) + FOR( band_idx = 0; band_idx < hParamIsmDec->hParamIsm->nbands; band_idx++ ) { brange[0] = hParamIsmDec->hParamIsm->band_grouping[band_idx]; brange[1] = hParamIsmDec->hParamIsm->band_grouping[band_idx + 1]; obj_idx = hParamIsmDec->hParamIsm->obj_indices[band_idx][0][obj]; - power_ratio_fx[obj] = hParamIsmDec->power_ratios_fx[band_idx][0][obj]; + power_ratio_fx[obj] = hParamIsmDec->power_ratios_fx[band_idx][0][obj]; // Q15 - for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) + FOR( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) { - for ( bin_idx = brange[0]; bin_idx < brange[1]; bin_idx++ ) + FOR( bin_idx = brange[0]; bin_idx < brange[1]; bin_idx++ ) { - hMasaIsmData->energy_ratio_ism_fx[obj_idx][sf_idx][bin_idx] = power_ratio_fx[obj]; + hMasaIsmData->energy_ratio_ism_fx[obj_idx][sf_idx][bin_idx] = L_shl( power_ratio_fx[obj], 15 ); // Q15 -> Q30 } } } diff --git a/lib_dec/ivas_ism_renderer_fx.c b/lib_dec/ivas_ism_renderer_fx.c index 66e47ad6d..7680af47a 100644 --- a/lib_dec/ivas_ism_renderer_fx.c +++ b/lib_dec/ivas_ism_renderer_fx.c @@ -623,15 +623,20 @@ void ivas_omasa_separate_object_render_jbm_fx( IF( single_separated ) { #ifdef OMASA_OBJECT_EDITING - if ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ && st_ivas->hMasaIsmData->ism_dir_is_edited[st_ivas->hMasaIsmData->idx_separated_ism] ) + test(); + IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) && st_ivas->hMasaIsmData->ism_dir_is_edited_fx[st_ivas->hMasaIsmData->idx_separated_ism] ) { - azimuth = st_ivas->hMasaIsmData->azimuth_ism_edited[st_ivas->hMasaIsmData->idx_separated_ism]; - elevation = st_ivas->hMasaIsmData->elevation_ism_edited[st_ivas->hMasaIsmData->idx_separated_ism]; + azimuth = st_ivas->hMasaIsmData->azimuth_ism_edited_fx[st_ivas->hMasaIsmData->idx_separated_ism]; + move16(); + elevation = st_ivas->hMasaIsmData->elevation_ism_edited_fx[st_ivas->hMasaIsmData->idx_separated_ism]; + move16(); } - else + ELSE { azimuth = st_ivas->hMasaIsmData->azimuth_separated_ism[md_idx]; + move16(); elevation = st_ivas->hMasaIsmData->elevation_separated_ism[md_idx]; + move16(); } #else azimuth = st_ivas->hMasaIsmData->azimuth_separated_ism[md_idx]; @@ -643,15 +648,19 @@ void ivas_omasa_separate_object_render_jbm_fx( ELSE { #ifdef OMASA_OBJECT_EDITING - if ( st_ivas->hMasaIsmData->ism_dir_is_edited[obj] ) + IF( st_ivas->hMasaIsmData->ism_dir_is_edited_fx[obj] ) { - azimuth = st_ivas->hMasaIsmData->azimuth_ism_edited[obj]; - elevation = st_ivas->hMasaIsmData->elevation_ism_edited[obj]; + azimuth = st_ivas->hMasaIsmData->azimuth_ism_edited_fx[obj]; + move16(); + elevation = st_ivas->hMasaIsmData->elevation_ism_edited_fx[obj]; + move16(); } - else + ELSE { azimuth = st_ivas->hMasaIsmData->azimuth_ism[obj][md_idx]; + move16(); elevation = st_ivas->hMasaIsmData->elevation_ism[obj][md_idx]; + move16(); } #else azimuth = st_ivas->hMasaIsmData->azimuth_ism[obj][md_idx]; diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 5d9d43a3f..a39f47619 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -4681,16 +4681,14 @@ void ivas_jbm_dec_prepare_renderer( IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) ) { #ifdef OMASA_OBJECT_EDITING - Word32 gainIsm; - gainIsm = OMASA_TDREND_MATCHING_GAIN_FX; - IF( st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) + v_multc_fixed_16( st_ivas->hTcBuffer->tc_fx[CPE_CHANNELS + n], OMASA_TDREND_MATCHING_GAIN_FX, st_ivas->hTcBuffer->tc_fx[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available ); + + IF( st_ivas->hMasaIsmData->ism_gain_is_edited_fx[n] ) { - // gainIsm *= st_ivas->hMasaIsmData->gain_ism_edited[n]; - assert( 0 && "Insert actual basop code here!" ); + v_multc_fixed_16( st_ivas->hTcBuffer->tc_fx[CPE_CHANNELS + n], st_ivas->hMasaIsmData->gain_ism_edited_fx[n], st_ivas->hTcBuffer->tc_fx[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available ); + Scale_sig32( st_ivas->hTcBuffer->tc_fx[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available, Q3 ); // Q8 -> Q11 } - - v_multc_fixed_16( st_ivas->hTcBuffer->tc_fx[CPE_CHANNELS + n], gainIsm, st_ivas->hTcBuffer->tc_fx[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available ); #else v_multc_fixed_16( st_ivas->hTcBuffer->tc_fx[CPE_CHANNELS + n], OMASA_TDREND_MATCHING_GAIN_FX, st_ivas->hTcBuffer->tc_fx[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available ); #endif @@ -4699,17 +4697,15 @@ void ivas_jbm_dec_prepare_renderer( // TODO: check if tis is a bug in main already } #ifdef OMASA_OBJECT_EDITING - IF( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) + test(); + IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) ) { - // Word16 tcBufferSize; - // tcBufferSize = st_ivas->hSpatParamRendCom->num_slots * st_ivas->hSpatParamRendCom->slot_size; - - IF( st_ivas->hMasaIsmData->masa_gain_is_edited ) + IF( st_ivas->hMasaIsmData->masa_gain_is_edited_fx ) { - FOR( Word16 ch = 0; ch < 2; ch++ ) + FOR( n = 0; n < 2; n++ ) { - // v_multc_fixed_16( st_ivas->hTcBuffer->tc_fx[ch], st_ivas->hMasaIsmData->gain_masa_edited, st_ivas->hTcBuffer->tc_fx[ch], tcBufferSize ); - assert( 0 && "Insert actual basop code here!" ); + v_multc_fixed_16( st_ivas->hTcBuffer->tc_fx[n], st_ivas->hMasaIsmData->gain_masa_edited_fx, st_ivas->hTcBuffer->tc_fx[n], st_ivas->hTcBuffer->n_samples_available ); // Q8 + Scale_sig32( st_ivas->hTcBuffer->tc_fx[n], st_ivas->hTcBuffer->n_samples_available, Q3 ); // Q8 -> Q11 } } } diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c index 50dbc022b..fc02e649a 100644 --- a/lib_dec/ivas_masa_dec_fx.c +++ b/lib_dec/ivas_masa_dec_fx.c @@ -837,9 +837,10 @@ ivas_error ivas_masa_dec_open_fx( move32(); /* ISM metadata */ + #ifdef OMASA_OBJECT_EDITING test(); - IF( EQ_16( st_ivas->ivas_format, MASA_FORMAT ) && st_ivas->hIsmMetaData[0] == NULL ) + IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && st_ivas->hIsmMetaData[0] != NULL ) #else test(); test(); @@ -3365,7 +3366,7 @@ static Word16 ivas_decode_masaism_metadata_fx( FOR( obj = 0; obj < nchan_ism; obj++ ) { #ifdef OMASA_OBJECT_EDITING - hMasaIsmData->bits_ism[obj] = bits_ism[obj]; + hMasaIsmData->bits_ism_fx[obj] = bits_ism[obj]; #endif index = 0; move16(); diff --git a/lib_dec/ivas_objectRenderer_internal_fx.c b/lib_dec/ivas_objectRenderer_internal_fx.c index a97567c19..3c9caf731 100644 --- a/lib_dec/ivas_objectRenderer_internal_fx.c +++ b/lib_dec/ivas_objectRenderer_internal_fx.c @@ -240,7 +240,7 @@ ivas_error ivas_td_binaural_renderer_sf_fx( return error; } } - else + ELSE #endif { IF( NE_16( error = TDREND_Update_object_positions_fx( st_ivas->hBinRendererTd, nchan_ism, st_ivas->ivas_format, st_ivas->hIsmMetaData ), IVAS_ERR_OK ) ) diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index 2f628ac40..c0dd1f28b 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -328,25 +328,26 @@ ivas_error ivas_omasa_data_open_fx( } #ifdef OMASA_OBJECT_EDITING - FOR( Word16 band_idx = 0; band_idx < MASA_FREQUENCY_BANDS; band_idx++ ) + FOR( int16_t band_idx = 0; band_idx < MASA_FREQUENCY_BANDS; band_idx++ ) { FOR( ch = 0; ch < 2; ch++ ) { - hMasaIsmData->ismPreprocMatrix_fx[ch][ch][band_idx] = 32767; /* 1.0f in Q15 */ - move16(); - hMasaIsmData->ismPreprocMatrix_fx[1 - ch][ch][band_idx] = 0; // Q15 - move16(); - hMasaIsmData->eneMoveIIR_fx[ch][band_idx] = 0; // Q22 - move32(); - hMasaIsmData->enePreserveIIR_fx[ch][band_idx] = 0; // Q22 - move32(); + + hMasaIsmData->ismPreprocMatrix_fx[ch][ch][band_idx] = ONE_IN_Q28; + hMasaIsmData->ismPreprocMatrix_fx[1 - ch][ch][band_idx] = 0; + hMasaIsmData->eneMoveIIR_fx[ch][band_idx] = 0; + hMasaIsmData->eneMoveIIR_e[ch][band_idx] = 0; + hMasaIsmData->enePreserveIIR_fx[ch][band_idx] = 0; + hMasaIsmData->enePreserveIIR_e[ch][band_idx] = 0; } - hMasaIsmData->eneOrigIIR_fx[band_idx] = 0; // TODO: check Q - hMasaIsmData->preprocEneTarget_fx[band_idx] = 0; // Q19 - hMasaIsmData->preprocEneRealized_fx[band_idx] = 0; // Q19 + + hMasaIsmData->eneOrigIIR_fx[band_idx] = 0; + hMasaIsmData->eneOrigIIR_e[band_idx] = 0; + hMasaIsmData->preprocEneTarget_fx[band_idx] = 0; + hMasaIsmData->preprocEneRealized_fx[band_idx] = 0; } - hMasaIsmData->objectsEdited = 0; + hMasaIsmData->objectsEdited_fx = 0; #else FOR( bin = 0; bin < CLDFB_NO_CHANNELS_MAX; bin++ ) { @@ -376,19 +377,20 @@ ivas_error ivas_omasa_data_open_fx( FOR( ch = 0; ch < MAX_NUM_OBJECTS; ch++ ) { #ifdef OMASA_OBJECT_EDITING - hMasaIsmData->ism_dir_is_edited[ch] = 0; - hMasaIsmData->ism_gain_is_edited[ch] = 0; + hMasaIsmData->ism_dir_is_edited_fx[ch] = 0; + hMasaIsmData->ism_gain_is_edited_fx[ch] = 0; #else hMasaIsmData->ism_is_edited[ch] = 0; -#endif move16(); +#endif hMasaIsmData->q_elevation_old_fx[ch] = 0; // Q22 move32(); hMasaIsmData->q_azimuth_old_fx[ch] = 0; // Q22 move32(); } + #ifdef OMASA_OBJECT_EDITING - hMasaIsmData->masa_gain_is_edited = 0; + hMasaIsmData->masa_gain_is_edited_fx = 0; hMasaIsmData->idx_separated_ism = -1; #endif @@ -515,7 +517,6 @@ ivas_error ivas_omasa_dec_config_fx( #endif ) { - #ifdef OMASA_OBJECT_EDITING Word16 k, sce_id, nSCE_old, nchan_hp20_old, numCldfbAnalyses_old, numCldfbSyntheses_old; #else @@ -651,16 +652,16 @@ ivas_error ivas_omasa_dec_config_fx( { /* ISM MD reconfig. */ #ifdef OMASA_OBJECT_EDITING - if ( st_ivas->hIsmMetaData[0] == NULL ) + IF( st_ivas->hIsmMetaData[0] == NULL ) { - if ( ( error = ivas_ism_metadata_dec_create_fx( st_ivas, st_ivas->nchan_ism, NULL ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_ism_metadata_dec_create_fx( st_ivas, st_ivas->nchan_ism, NULL ) ) != IVAS_ERR_OK ) { return error; } } - else + ELSE { - for ( k = 0; k < st_ivas->nchan_ism; k++ ) + FOR( k = 0; k < st_ivas->nchan_ism; k++ ) { ivas_ism_reset_metadata_handle_dec_fx( st_ivas->hIsmMetaData[k] ); } @@ -724,9 +725,9 @@ ivas_error ivas_omasa_dec_config_fx( ivas_ism_metadata_close( st_ivas->hIsmMetaData, n_MD ); } +#endif st_ivas->hCPE[0]->element_brate = L_sub( ivas_total_brate, ism_total_brate ); -#endif /*-----------------------------------------------------------------* * Renderer selection @@ -1184,22 +1185,21 @@ void ivas_omasa_dirac_rend_jbm_fx( { Copy32( &output_f[CPE_CHANNELS][st_ivas->hTcBuffer->n_samples_rendered], data_separated_objects[0], *nSamplesRendered ); #ifdef OMASA_OBJECT_EDITING - IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) + IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) { /* Gain separated object, if edited */ FOR( n = 0; n < st_ivas->nchan_ism; n++ ) { test(); - IF( st_ivas->hMasaIsmData->ism_gain_is_edited[n] && EQ_16( st_ivas->hMasaIsmData->idx_separated_ism, n ) ) + IF( st_ivas->hMasaIsmData->ism_gain_is_edited_fx[n] && EQ_16( st_ivas->hMasaIsmData->idx_separated_ism, n ) ) { - // v_multc( data_separated_objects[0], st_ivas->hMasaIsmData->gain_ism_edited[n], data_separated_objects[0], *nSamplesRendered ); - assert( 0 && "Insert proper basop code here!" ); + v_multc_fixed_16( data_separated_objects[0], st_ivas->hMasaIsmData->gain_ism_edited_fx[n], data_separated_objects[0], *nSamplesRendered ); // Q = 8 + Scale_sig32( data_separated_objects[0], *nSamplesRendered, Q3 ); // Q = 11 } } } #endif } - ELSE { FOR( n = 0; n < st_ivas->nchan_ism; n++ ) @@ -1207,21 +1207,21 @@ void ivas_omasa_dirac_rend_jbm_fx( Copy32( &output_f[n + CPE_CHANNELS][st_ivas->hTcBuffer->n_samples_rendered], data_separated_objects[n], *nSamplesRendered ); #ifdef OMASA_OBJECT_EDITING /* Gain discrete objects, if edited */ - IF( st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) + IF( st_ivas->hMasaIsmData->ism_gain_is_edited_fx[n] ) { - // v_multc( data_separated_objects[n], st_ivas->hMasaIsmData->gain_ism_edited[n], data_separated_objects[n], *nSamplesRendered ); - assert( 00 && "Insert proper basop code here!" ); + v_multc_fixed_16( data_separated_objects[n], st_ivas->hMasaIsmData->gain_ism_edited_fx[n], data_separated_objects[n], *nSamplesRendered ); // Q = 8 + Scale_sig32( data_separated_objects[n], *nSamplesRendered, Q3 ); // Q = 11 } #endif } #ifdef OMASA_OBJECT_EDITING /* Gain MASA part, if edited */ - if ( st_ivas->hMasaIsmData->masa_gain_is_edited ) + IF( st_ivas->hMasaIsmData->masa_gain_is_edited_fx ) { - for ( int16_t ch = 0; ch < 2; ch++ ) + FOR( n = 0; n < 2; n++ ) { - // v_multc( output_f[ch], st_ivas->hMasaIsmData->gain_masa_edited, output_f[ch], *nSamplesRendered ); - assert( 00 && "Insert proper basop code here!" ); + v_multc_fixed_16( output_f[n], st_ivas->hMasaIsmData->gain_masa_edited_fx, output_f[n], *nSamplesRendered ); // Q = 8 + Scale_sig32( output_f[n], *nSamplesRendered, Q3 ); // Q = 11 } } #endif diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index be45fb8d1..29da074c3 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -464,8 +464,8 @@ typedef struct ivas_param_ism_dec_data_structure Word16 power_ratios_fx[MAX_PARAM_ISM_NBANDS][MAX_PARAM_ISM_NBLOCKS][MAX_PARAM_ISM_WAVE]; /* Q15 */ #ifdef OBJ_EDITING_API - Word32 edited_azimuth_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES * IVAS_MAX_NUM_BANDS]; - Word32 edited_elevation_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES * IVAS_MAX_NUM_BANDS]; + Word32 edited_azimuth_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES * IVAS_MAX_NUM_BANDS]; // Q22 + Word32 edited_elevation_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES * IVAS_MAX_NUM_BANDS]; // Q22 #endif /*sub-modules*/ @@ -955,29 +955,35 @@ typedef struct ivas_masa_ism_ext_data_structure /* Data structure for MASA_ISM rendering */ typedef struct ivas_masa_ism_data_structure { - Word16 azimuth_ism[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; - Word16 elevation_ism[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; + Word16 azimuth_ism[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; // Q0 + Word16 elevation_ism[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; // Q0 Word32 energy_ratio_ism_fx[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR][CLDFB_NO_CHANNELS_MAX]; /* Q30 */ Word32 masa_to_total_energy_ratio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; /* Q30 */ - Word16 azimuth_ism_edited[MAX_NUM_OBJECTS]; - Word16 elevation_ism_edited[MAX_NUM_OBJECTS]; + Word16 azimuth_ism_edited_fx[MAX_NUM_OBJECTS]; // Q0 + Word16 elevation_ism_edited_fx[MAX_NUM_OBJECTS]; // Q0 + #ifdef OMASA_OBJECT_EDITING - UWord16 ism_dir_is_edited[MAX_NUM_OBJECTS]; + UWord8 ism_dir_is_edited_fx[MAX_NUM_OBJECTS]; #else UWord8 ism_is_edited[MAX_NUM_OBJECTS]; #endif #ifdef OBJ_EDITING_API - Word32 gain_ism_fx[MAX_NUM_OBJECTS]; - Word32 gain_masa; + Word16 gain_ism_fx[MAX_NUM_OBJECTS]; + Word16 gain_masa_fx; #endif #ifdef OMASA_OBJECT_EDITING - Word32 gain_ism_edited_fx[MAX_NUM_OBJECTS]; - UWord8 ism_gain_is_edited[MAX_NUM_OBJECTS]; - UWord32 gain_masa_edited_fx; - UWord8 masa_gain_is_edited; + Word16 gain_ism_edited_fx[MAX_NUM_OBJECTS]; // Q12 + UWord8 ism_gain_is_edited_fx[MAX_NUM_OBJECTS]; + Word16 gain_masa_edited_fx; // Q12 + UWord8 masa_gain_is_edited_fx; +#else + Word16 azimuth_ism_edited[MAX_NUM_OBJECTS]; + Word16 elevation_ism_edited[MAX_NUM_OBJECTS]; + UWord8 ism_is_edited[MAX_NUM_OBJECTS]; #endif + Word16 idx_separated_ism; Word16 azimuth_separated_ism[MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; Word16 elevation_separated_ism[MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; @@ -986,14 +992,20 @@ typedef struct ivas_masa_ism_data_structure Word32 q_elevation_old_fx[MAX_NUM_OBJECTS]; /* Q22 */ #ifdef OMASA_OBJECT_EDITING - UWord16 objectsEdited; - Word32 preprocEneTarget_fx[MASA_FREQUENCY_BANDS]; /*Q-19*/ - Word32 preprocEneRealized_fx[MASA_FREQUENCY_BANDS]; /*Q-19*/ - Word32 ismPreprocMatrix_fx[2][2][MASA_FREQUENCY_BANDS]; /*Q-15*/ - Word32 eneMoveIIR_fx[2][MASA_FREQUENCY_BANDS]; /*Q-22*/ - Word32 enePreserveIIR_fx[2][MASA_FREQUENCY_BANDS]; /*Q-22*/ + UWord8 objectsEdited_fx; + Word32 preprocEneTarget_fx[MASA_FREQUENCY_BANDS]; + Word16 preprocEneTarget_e[MASA_FREQUENCY_BANDS]; + Word32 preprocEneRealized_fx[MASA_FREQUENCY_BANDS]; + Word16 preprocEneRealized_e[MASA_FREQUENCY_BANDS]; + Word32 ismPreprocMatrix_fx[2][2][MASA_FREQUENCY_BANDS]; // Q28? + // Word16 ismPreprocMatrix_e[2][2][MASA_FREQUENCY_BANDS]; // Not needed? + Word32 eneMoveIIR_fx[2][MASA_FREQUENCY_BANDS]; + Word16 eneMoveIIR_e[2][MASA_FREQUENCY_BANDS]; + Word32 enePreserveIIR_fx[2][MASA_FREQUENCY_BANDS]; + Word16 enePreserveIIR_e[2][MASA_FREQUENCY_BANDS]; Word32 eneOrigIIR_fx[MASA_FREQUENCY_BANDS]; - Word16 bits_ism[MAX_NUM_OBJECTS]; + Word16 eneOrigIIR_e[MASA_FREQUENCY_BANDS]; + Word16 bits_ism_fx[MAX_NUM_OBJECTS]; #else Word16 ismPreprocMatrix_fx[2][2][CLDFB_NO_CHANNELS_MAX]; /* Q15 */ UWord8 objectsMoved; diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index dc95fe00e..030d340ab 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -172,16 +172,16 @@ ivas_error IVAS_DEC_GetSamples( #ifdef OBJ_EDITING_API ivas_error IVAS_DEC_GetEditableParameters( IVAS_DEC_HANDLE hIvasDec, - IVAS_EDITABLE_PARAMETERS *hIvasEditableParameters + IVAS_EDITABLE_PARAMETERS *hIvasEditableParameters ); ivas_error IVAS_DEC_SetEditableParameters( IVAS_DEC_HANDLE hIvasDec, - IVAS_EDITABLE_PARAMETERS hIvasEditableParameters + IVAS_EDITABLE_PARAMETERS hIvasEditableParameters ); ivas_error IVAS_DEC_PrepareRenderer( - IVAS_DEC_HANDLE hIvasDec + IVAS_DEC_HANDLE hIvasDec ); #endif diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 6df308149..8f2bde1ee 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1,4 +1,4 @@ -/****************************************************************************************************** +/****************************************************************************************************** (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., @@ -3946,7 +3946,10 @@ ivas_error IVAS_DEC_GetSamplesDecoder( IF( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) { #ifdef OMASA_OBJECT_EDITING - IF( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + test(); + test(); + test(); + IF( EQ_32( hIvasDec->st_ivas->ism_mode, ISM_MODE_DISC ) || EQ_32( hIvasDec->st_ivas->ism_mode, ISM_MASA_MODE_DISC ) || EQ_32( hIvasDec->st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) || EQ_32( hIvasDec->st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) #else IF( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) #endif @@ -3960,12 +3963,12 @@ ivas_error IVAS_DEC_GetSamplesDecoder( hIsmMetaData[obj]->edited_yaw_fx = hIsmMetaData[obj]->yaw_fx; hIsmMetaData[obj]->edited_pitch_fx = hIsmMetaData[obj]->pitch_fx; hIsmMetaData[obj]->edited_radius_fx = hIsmMetaData[obj]->radius_fx; - hIsmMetaData[obj]->edited_gain_fx = ONE_IN_Q31; + hIsmMetaData[obj]->edited_gain_fx = ONE_IN_Q31; // TODO: Check Q value } IF( hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { - hIvasDec->st_ivas->hSbaIsmData->gain_bed_fx = ONE_IN_Q31; + hIvasDec->st_ivas->hSbaIsmData->gain_bed_fx = ONE_IN_Q31; // TODO: Check Q value } } } @@ -4012,9 +4015,9 @@ ivas_error IVAS_DEC_GetEditableParameters( test(); test(); test(); - IF( !( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || - ( hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT && hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) || - ( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT && ( hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) ) ) + if ( !( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || + ( hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT && hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) || + ( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT && ( hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) ) ) { return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Object editing no supported in this operation mode." ); } @@ -4042,12 +4045,12 @@ ivas_error IVAS_DEC_GetEditableParameters( move16(); test(); test(); - if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) + IF( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) { - if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + IF( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { Word16 obj; - for ( obj = 0; obj < hIvasEditableParameters->num_obj; obj++ ) + FOR( obj = 0; obj < hIvasEditableParameters->num_obj; obj++ ) { hIvasEditableParameters->ism_metadata[obj].azimuth_fx = hIvasDec->st_ivas->hIsmMetaData[obj]->azimuth_fx; move32(); @@ -4070,10 +4073,10 @@ ivas_error IVAS_DEC_GetEditableParameters( move32(); } } - else if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) + ELSE IF( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) { Word16 obj; - for ( obj = 0; obj < hIvasEditableParameters->num_obj; obj++ ) + FOR( obj = 0; obj < hIvasEditableParameters->num_obj; obj++ ) { hIvasEditableParameters->ism_metadata[obj].azimuth_fx = hIvasDec->st_ivas->hParamIsmDec->azimuth_values_fx[obj]; move32(); @@ -4085,26 +4088,26 @@ ivas_error IVAS_DEC_GetEditableParameters( move32(); hIvasEditableParameters->ism_metadata[obj].radius_fx = 0; move16(); - hIvasEditableParameters->ism_metadata[obj].gain_fx = ONE_IN_Q31; + hIvasEditableParameters->ism_metadata[obj].gain_fx = ONE_IN_Q31; // TODO check Q-value move32(); hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = 0; move16(); } } - else + ELSE { assert( 0 && "This should never happen!" ); } } #ifdef OMASA_OBJECT_EDITING - else if ( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT && ( hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) + ELSE IF( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT && ( hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) { /* object editing possible only in two highest OMASA modes */ - int16_t obj; + Word16 obj; - if ( hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + IF( hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { - for ( obj = 0; obj < hIvasEditableParameters->num_obj; obj++ ) + FOR( obj = 0; obj < hIvasEditableParameters->num_obj; obj++ ) { hIvasEditableParameters->ism_metadata[obj].azimuth_fx = hIvasDec->st_ivas->hIsmMetaData[obj]->azimuth_fx; hIvasEditableParameters->ism_metadata[obj].elevation_fx = hIvasDec->st_ivas->hIsmMetaData[obj]->elevation_fx; @@ -4113,34 +4116,34 @@ ivas_error IVAS_DEC_GetEditableParameters( hIvasEditableParameters->ism_metadata[obj].radius_fx = hIvasDec->st_ivas->hIsmMetaData[obj]->radius_fx; /* reset the otherwise unused "gain" field for the object */ - hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain_fx = ONE_IN_Q31; // TODO: check Q value + hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain_fx = ONE_IN_Q12; hIvasEditableParameters->ism_metadata[obj].gain_fx = hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain_fx; hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = hIvasDec->st_ivas->hIsmMetaData[obj]->non_diegetic_flag; } } - else + ELSE { /* Handle MONO output */ - if ( hIvasDec->st_ivas->renderer_type != RENDERER_MONO_DOWNMIX ) + IF( hIvasDec->st_ivas->renderer_type != RENDERER_MONO_DOWNMIX ) { dirac_read_idx = hIvasDec->st_ivas->hSpatParamRendCom->render_to_md_map[hIvasDec->st_ivas->hSpatParamRendCom->subframes_rendered]; } - else + ELSE { dirac_read_idx = 0; } - for ( obj = 0; obj < hIvasEditableParameters->num_obj; obj++ ) + FOR( obj = 0; obj < hIvasEditableParameters->num_obj; obj++ ) { - hIvasEditableParameters->ism_metadata[obj].azimuth = hIvasDec->st_ivas->hMasaIsmData->azimuth_ism[obj][dirac_read_idx]; - hIvasEditableParameters->ism_metadata[obj].elevation = hIvasDec->st_ivas->hMasaIsmData->elevation_ism[obj][dirac_read_idx]; + hIvasEditableParameters->ism_metadata[obj].azimuth_fx = L_shl( L_deposit_l( hIvasDec->st_ivas->hMasaIsmData->azimuth_ism[obj][dirac_read_idx] ), Q22 ); + hIvasEditableParameters->ism_metadata[obj].elevation_fx = L_shl( L_deposit_l( hIvasDec->st_ivas->hMasaIsmData->elevation_ism[obj][dirac_read_idx] ), Q22 ); hIvasEditableParameters->ism_metadata[obj].yaw_fx = hIvasDec->st_ivas->hIsmMetaData[obj]->yaw_fx; hIvasEditableParameters->ism_metadata[obj].pitch_fx = hIvasDec->st_ivas->hIsmMetaData[obj]->pitch_fx; hIvasEditableParameters->ism_metadata[obj].radius_fx = hIvasDec->st_ivas->hIsmMetaData[obj]->radius_fx; /* reset the otherwise unused "gain" field for the object */ - hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain_fx = ONE_IN_Q31; + hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain_fx = ONE_IN_Q12; hIvasEditableParameters->ism_metadata[obj].gain_fx = hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain_fx; hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = hIvasDec->st_ivas->hIsmMetaData[obj]->non_diegetic_flag; } @@ -4194,6 +4197,8 @@ ivas_error IVAS_DEC_SetEditableParameters( assert( hIvasEditableParameters.num_obj == hIvasDec->st_ivas->nchan_ism ); #endif + test(); + test(); test(); IF( EQ_16( hIvasDec->st_ivas->ivas_format, ISM_FORMAT ) || EQ_16( hIvasDec->st_ivas->ivas_format, SBA_ISM_FORMAT ) ) { @@ -4222,42 +4227,42 @@ ivas_error IVAS_DEC_SetEditableParameters( } ELSE IF( EQ_16( hIvasDec->st_ivas->ism_mode, ISM_MODE_PARAM ) ) { - int16_t obj; + Word16 obj; FOR( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) { #ifdef OBJ_EDITING_PARAMISM_BIN - hIvasDec->st_ivas->hParamIsmDec->edited_azimuth_values_fx[obj] = hIvasEditableParameters.ism_metadata[obj].azimuth; - hIvasDec->st_ivas->hParamIsmDec->edited_elevation_values_fx[obj] = hIvasEditableParameters.ism_metadata[obj].elevation; - hIvasDec->st_ivas->hMasaIsmData->gain_ism_edited_fx[obj] = hIvasEditableParameters.ism_metadata[obj].gain_fx; + hIvasDec->st_ivas->hParamIsmDec->edited_azimuth_values_fx[obj] = hIvasEditableParameters.ism_metadata[obj].azimuth_fx; + hIvasDec->st_ivas->hParamIsmDec->edited_elevation_values_fx[obj] = hIvasEditableParameters.ism_metadata[obj].elevation_fx; + hIvasDec->st_ivas->hMasaIsmData->gain_ism_edited_fx[obj] = extract_l( hIvasEditableParameters.ism_metadata[obj].gain_fx ); // TODO: Check incoming Q-value /* Detect direction editing in Param-ISM mode */ - IF( GT_16( L_abs( L_sub( hIvasDec->st_ivas->hParamIsmDec->azimuth_values_fx[obj], hIvasEditableParameters.ism_metadata[obj].azimuth ) ), OMASA_AZI_EDIT_THR_FX ) || - GT_16( L_abs( L_sub( hIvasDec->st_ivas->hParamIsmDec->elevation_values_fx[obj], hIvasEditableParameters.ism_metadata[obj].elevation ) ), OMASA_ELE_EDIT_THR_FX ) ) + IF( GT_32( L_abs( L_sub( hIvasDec->st_ivas->hParamIsmDec->azimuth_values_fx[obj], hIvasEditableParameters.ism_metadata[obj].azimuth_fx ) ), OMASA_AZI_EDIT_THR_FX ) || + GT_32( L_abs( L_sub( hIvasDec->st_ivas->hParamIsmDec->elevation_values_fx[obj], hIvasEditableParameters.ism_metadata[obj].elevation_fx ) ), OMASA_ELE_EDIT_THR_FX ) ) { - hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited[obj] = 1; + hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited_fx[obj] = 1; } ELSE { - hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited[obj] = 0; + hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited_fx[obj] = 0; } /* Detect gain editing in Param-ISM mode */ - IF( GT_32( L_abs( L_sub( ONE_IN_Q30, hIvasEditableParameters.ism_metadata[obj].gain_fx ) ), OMASA_GAIN_EDIT_THR_FX ) ) // TODO: check Q values + IF( GT_32( L_abs( sub( ONE_IN_Q12, extract_l( hIvasEditableParameters.ism_metadata[obj].gain_fx ) ) ), OMASA_GAIN_EDIT_THR_FX ) ) // TODO: check Q values { - hIvasDec->st_ivas->hMasaIsmData->ism_gain_is_edited[obj] = 1; + hIvasDec->st_ivas->hMasaIsmData->ism_gain_is_edited_fx[obj] = 1; } ELSE { - hIvasDec->st_ivas->hMasaIsmData->ism_gain_is_edited[obj] = 0; + hIvasDec->st_ivas->hMasaIsmData->ism_gain_is_edited_fx[obj] = 0; } #endif } #ifdef OBJ_EDITING_PARAMISM_BIN /* MASA is not present with the ISM format */ - hIvasDec->st_ivas->hMasaIsmData->masa_gain_is_edited = 0u; + hIvasDec->st_ivas->hMasaIsmData->masa_gain_is_edited_fx = 0; #endif } - else + ELSE { assert( 0 && "This should never happen!" ); } @@ -4276,22 +4281,16 @@ ivas_error IVAS_DEC_SetEditableParameters( /* copy relevant fields also to OMASA structs, but only if the value has been changed. original values are in st_ivas->hIsmMetaData */ /* first, need to convert float values to ints used internally */ Word16 new_azi, new_ele; - IF( hIvasEditableParameters.ism_metadata[obj].azimuth > 0.0f ) - { - new_azi = (int16_t) ( hIvasEditableParameters.ism_metadata[obj].azimuth + 0.5f ); - } - ELSE + new_azi = extract_l( L_shr( L_add( L_abs( hIvasEditableParameters.ism_metadata[obj].azimuth_fx ), 2097152 ), Q22 ) ); // Q22->Q0 + if ( hIvasEditableParameters.ism_metadata[obj].azimuth_fx < 0 ) { - new_azi = (int16_t) ( hIvasEditableParameters.ism_metadata[obj].azimuth - 0.5f ); + new_azi = negate( new_azi ); } - IF( hIvasEditableParameters.ism_metadata[obj].elevation > 0.0f ) - { - new_ele = (int16_t) ( hIvasEditableParameters.ism_metadata[obj].elevation + 0.5f ); - } - ELSE + new_ele = extract_l( L_shr( L_add( L_abs( hIvasEditableParameters.ism_metadata[obj].elevation_fx ), 2097152 ), Q22 ) ); // Q22->Q0 + if ( hIvasEditableParameters.ism_metadata[obj].elevation_fx < 0 ) { - new_ele = (int16_t) ( hIvasEditableParameters.ism_metadata[obj].elevation - 0.5f ); + new_ele = negate( new_ele ); } IF( EQ_16( hIvasDec->st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) @@ -4311,52 +4310,52 @@ ivas_error IVAS_DEC_SetEditableParameters( * which in turn depends from the object priority and importance: * importance -> priority -> number of bits -> elevation resolution -> elevation ring index -> azimuth resolution. * leading to elevation_resolution -> elevation threshold and azimuth resolution -> azimuth threshold */ - // id_th = ( fabsf( (float) hIvasDec->st_ivas->hMasaIsmData->elevation_ism[obj][dirac_read_idx] ) / delta_theta_masa[hIvasDec->st_ivas->hMasaIsmData->bits_ism[obj] - 3] + 0.5f ); - assert( 0 && "Insert proper basop code here!" ); - threshold_azi = 360.0f / (float) no_phi_masa[hIvasDec->st_ivas->hMasaIsmData->bits_ism[obj] - 1][id_th]; - threshold_ele = delta_theta_masa_fx[hIvasDec->st_ivas->hMasaIsmData->bits_ism[obj] - 3]; + id_th = extract_l( L_shr( L_add( Mpy_32_16_1( delta_theta_masa_inv_fx[hIvasDec->st_ivas->hMasaIsmData->bits_ism_fx[obj] - 3], abs_s( hIvasDec->st_ivas->hMasaIsmData->elevation_ism[obj][dirac_read_idx] ) ), 32768 ), 16 ) ); // + 0.5f in Q16 + threshold_azi = Mpy_32_32( 1509949440, no_phi_masa_inv_fx[hIvasDec->st_ivas->hMasaIsmData->bits_ism_fx[obj] - 1][id_th] ); // Q = 22; + threshold_ele = delta_theta_masa_fx[hIvasDec->st_ivas->hMasaIsmData->bits_ism_fx[obj] - 3]; test(); - IF( ( GT_32( L_abs( L_sub( new_azi, hIvasDec->st_ivas->hMasaIsmData->azimuth_ism[obj][dirac_read_idx] ) ), threshold_azi ) ) || - ( GT_32( L_abs( L_sub( new_ele, hIvasDec->st_ivas->hMasaIsmData->elevation_ism[obj][dirac_read_idx] ) ), threshold_ele ) ) ) + IF( ( GT_32( L_shl( abs_s( sub( new_azi, hIvasDec->st_ivas->hMasaIsmData->azimuth_ism[obj][dirac_read_idx] ) ), 22 ), threshold_azi ) ) || + ( GT_32( L_shl( abs_s( sub( new_ele, hIvasDec->st_ivas->hMasaIsmData->elevation_ism[obj][dirac_read_idx] ) ), 22 ), threshold_ele ) ) ) { /* at least one of the threshold is exceeded, so use new direction value and set editing detection flag */ - hIvasDec->st_ivas->hMasaIsmData->azimuth_ism_edited[obj] = new_azi; - hIvasDec->st_ivas->hMasaIsmData->elevation_ism_edited[obj] = new_ele; + hIvasDec->st_ivas->hMasaIsmData->azimuth_ism_edited_fx[obj] = new_azi; + hIvasDec->st_ivas->hMasaIsmData->elevation_ism_edited_fx[obj] = new_ele; - hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited[obj] = 1u; + hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited_fx[obj] = 1; } ELSE { - hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited[obj] = 0u; + hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited_fx[obj] = 0; } } ELSE { /* detect editing in ISM_MASA_MODE_DISC. optionally, add quantization-resolution -based thresholds */ - IF( GT_32( L_abs( L_sub( hIvasDec->st_ivas->hIsmMetaData[obj]->azimuth_fx, hIvasEditableParameters.ism_metadata[obj].azimuth_fx ) ), OMASA_AZI_EDIT_THR_FX ) || - GT_32( L_abs( L_sub( hIvasDec->st_ivas->hIsmMetaData[obj]->elevation_fx, hIvasEditableParameters.ism_metadata[obj].elevation_fx ) ), OMASA_ELE_EDIT_THR_FX ) ) + test(); + IF( L_abs( L_sub( hIvasDec->st_ivas->hIsmMetaData[obj]->azimuth_fx, hIvasEditableParameters.ism_metadata[obj].azimuth_fx ) ) > OMASA_AZI_EDIT_THR_FX || + L_abs( L_sub( hIvasDec->st_ivas->hIsmMetaData[obj]->elevation_fx, hIvasEditableParameters.ism_metadata[obj].elevation_fx ) ) > OMASA_ELE_EDIT_THR_FX ) { - hIvasDec->st_ivas->hMasaIsmData->azimuth_ism_edited[obj] = new_azi; - hIvasDec->st_ivas->hMasaIsmData->elevation_ism_edited[obj] = new_ele; + hIvasDec->st_ivas->hMasaIsmData->azimuth_ism_edited_fx[obj] = new_azi; + hIvasDec->st_ivas->hMasaIsmData->elevation_ism_edited_fx[obj] = new_ele; - hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited[obj] = 1u; + hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited_fx[obj] = 1; } ELSE { - hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited[obj] = 0u; + hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited_fx[obj] = 0; } } /* compare pre-edit gain and the edited one to detect editing */ - IF( L_abs( L_sub( hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain_fx, hIvasEditableParameters.ism_metadata[obj].gain_fx ) ) > OMASA_GAIN_EDIT_THR_FX ) + IF( GT_16( abs_s( sub( extract_l( hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain_fx ), extract_l( hIvasEditableParameters.ism_metadata[obj].gain_fx ) ) ), OMASA_GAIN_EDIT_THR_FX ) ) // TODO: check incoming Q value { - hIvasDec->st_ivas->hMasaIsmData->ism_gain_is_edited[obj] = 1u; - hIvasDec->st_ivas->hMasaIsmData->gain_ism_edited_fx[obj] = hIvasEditableParameters.ism_metadata[obj].gain_fx; + hIvasDec->st_ivas->hMasaIsmData->ism_gain_is_edited_fx[obj] = 1; + hIvasDec->st_ivas->hMasaIsmData->gain_ism_edited_fx[obj] = extract_l( hIvasEditableParameters.ism_metadata[obj].gain_fx ); } ELSE { - hIvasDec->st_ivas->hMasaIsmData->ism_gain_is_edited[obj] = 0u; + hIvasDec->st_ivas->hMasaIsmData->ism_gain_is_edited_fx[obj] = 0u; } } @@ -4368,20 +4367,20 @@ ivas_error IVAS_DEC_SetEditableParameters( hIvasDec->st_ivas->hIsmMetaData[obj]->yaw_fx = hIvasEditableParameters.ism_metadata[obj].yaw_fx; hIvasDec->st_ivas->hIsmMetaData[obj]->pitch_fx = hIvasEditableParameters.ism_metadata[obj].pitch_fx; hIvasDec->st_ivas->hIsmMetaData[obj]->radius_fx = hIvasEditableParameters.ism_metadata[obj].radius_fx; - hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain_fx = hIvasEditableParameters.ism_metadata[obj].gain_fx; + hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain_fx = hIvasEditableParameters.ism_metadata[obj].gain_fx; // TODO: check incoming Q value hIvasDec->st_ivas->hIsmMetaData[obj]->non_diegetic_flag = hIvasEditableParameters.ism_metadata[obj].non_diegetic_flag; } } - IF( GE_32( L_abs( L_sub( hIvasEditableParameters.gain_bed_fx, ONE_IN_Q30 ) ), OMASA_GAIN_EDIT_THR_FX ) ) // TODO: check Q value + IF( GT_16( abs_s( sub( extract_l( hIvasEditableParameters.gain_bed_fx ), ONE_IN_Q12 ) ), OMASA_GAIN_EDIT_THR_FX ) ) // TODO: check Q value { - hIvasDec->st_ivas->hMasaIsmData->gain_masa_edited_fx = hIvasEditableParameters.gain_bed_fx; // TODO: check type + hIvasDec->st_ivas->hMasaIsmData->gain_masa_edited_fx = extract_l( hIvasEditableParameters.gain_bed_fx ); // TODO: check type move32(); - hIvasDec->st_ivas->hMasaIsmData->masa_gain_is_edited = 1u; + hIvasDec->st_ivas->hMasaIsmData->masa_gain_is_edited_fx = 1; } ELSE { - hIvasDec->st_ivas->hMasaIsmData->masa_gain_is_edited = 0u; + hIvasDec->st_ivas->hMasaIsmData->masa_gain_is_edited_fx = 0; } } #endif diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 047ea6bc2..f050d5e98 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -987,13 +987,17 @@ static void ivas_dirac_dec_binaural_internal_fx( test(); #ifdef OMASA_OBJECT_EDITING #ifdef OBJ_EDITING_PARAMISM_BIN - if ( ( st_ivas->ivas_format == MASA_ISM_FORMAT && ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) ) ) ) || st_ivas->ivas_format == ISM_FORMAT ) + test(); + test(); + IF( ( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && ( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) || ( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) ) ) ) || EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) #else - if ( st_ivas->ivas_format == MASA_ISM_FORMAT && ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) ) ) ) + test(); + IF( st_ivas->ivas_format == MASA_ISM_FORMAT && ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) ) ) ) #endif { ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( st_ivas, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, &q_inp, nBins, subframe ); } + #else IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_16( nchan_transport, 2 ) && NE_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && NE_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) { @@ -1749,10 +1753,12 @@ static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices_fx( ismDirIndex = sub( dirIndex, hSpatParamRendCom->numParametricDirections ); assert( hMasaIsmData != NULL && "hMasaIsmData should not be NULL if we use it" ); #ifdef OMASA_OBJECT_EDITING - if ( hMasaIsmData->ism_dir_is_edited[ismDirIndex] ) + IF( hMasaIsmData->ism_dir_is_edited_fx[ismDirIndex] ) { - aziDeg = hMasaIsmData->azimuth_ism_edited[ismDirIndex]; - eleDeg = hMasaIsmData->elevation_ism_edited[ismDirIndex]; + aziDeg = hMasaIsmData->azimuth_ism_edited_fx[ismDirIndex]; + move16(); + eleDeg = hMasaIsmData->elevation_ism_edited_fx[ismDirIndex]; + move16(); } #else IF( hMasaIsmData->ism_is_edited[ismDirIndex] ) @@ -2618,14 +2624,14 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( IF( EQ_16( ism_mode, ISM_MASA_MODE_DISC ) ) { #ifdef OMASA_OBJECT_EDITING - if ( hMasaIsmData->ism_dir_is_edited[chB] ) + IF( hMasaIsmData->ism_dir_is_edited_fx[chB] ) { - aziDeg = hMasaIsmData->azimuth_ism_edited[chB]; + aziDeg = hMasaIsmData->azimuth_ism_edited_fx[chB]; move16(); - eleDeg = hMasaIsmData->elevation_ism_edited[chB]; + eleDeg = hMasaIsmData->elevation_ism_edited_fx[chB]; move16(); } - else + ELSE { aziDeg = hMasaIsmData->azimuth_ism[chB][dirac_read_idx]; move16(); @@ -2642,14 +2648,15 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( ELSE { #ifdef OMASA_OBJECT_EDITING - if ( ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ && hMasaIsmData->ism_dir_is_edited[hMasaIsmData->idx_separated_ism] ) + test(); + IF( ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ && hMasaIsmData->ism_dir_is_edited_fx[hMasaIsmData->idx_separated_ism] ) { - aziDeg = hMasaIsmData->azimuth_ism_edited[hMasaIsmData->idx_separated_ism]; + aziDeg = hMasaIsmData->azimuth_ism_edited_fx[hMasaIsmData->idx_separated_ism]; move16(); - eleDeg = hMasaIsmData->elevation_ism_edited[hMasaIsmData->idx_separated_ism]; + eleDeg = hMasaIsmData->elevation_ism_edited_fx[hMasaIsmData->idx_separated_ism]; move16(); } - else + ELSE { aziDeg = hMasaIsmData->azimuth_separated_ism[dirac_read_idx]; move16(); @@ -4998,7 +5005,6 @@ static void getDirectPartGains_fx( HRTFS_PARAMBIN_HANDLE hHrtfParambin ) { // float aziRad, eleRad; -#if 0 Word32 y, mappedX; Word16 aziRadMapped, A, A2, A3; const Word16 LsAngleRad = 17157; // Q15 @@ -5009,58 +5015,141 @@ static void getDirectPartGains_fx( ptr_sin = &sine_table_Q31[180]; // sin[x] = sine_table_Q31[180 + x] ptr_cos = cosine_table_Q31; -#endif IF( renderStereoOutputInsteadOfBinaural ) /* In stereo (i.e. non-binaural) rendering mode */ { #ifdef OMASA_OBJECT_EDITING + *lImagp = 0; + *rImagp = 0; + move32(); + move32(); + + test(); + IF( EQ_16( aziDeg, gainCache->azi ) && EQ_16( eleDeg, gainCache->ele ) ) + { + *lRealp = gainCache->shVec_fx[0]; /* Reused memory */ + *rRealp = gainCache->shVec_fx[1]; /* Reused memory */ + move32(); + move32(); + } + ELSE + { + /* Convert azi and ele to an azi value of the cone of confusion */ + + // y = ( sinf( aziRad ) * cosf( eleRad ) ); + + IF( GT_16( abs_s( eleDeg ), 180 ) ) + { + // cos(180 + x) = -cos(x) + cos_val = -ptr_cos[sub( abs_s( eleDeg ), 180 )]; // Q31 + } + ELSE + { + cos_val = ptr_cos[abs_s( eleDeg )]; // Q31 + } + move32(); + + IF( GT_16( aziDeg, 180 ) ) + { + // sin(180 + x) = -sin(x) + sin_val = -ptr_sin[sub( aziDeg, 180 )]; // Q31 + } + ELSE IF( LT_16( aziDeg, -180 ) ) + { + // sin(-(180 + x)) = sin(180 + x) = sinx + sin_val = ptr_sin[sub( abs_s( aziDeg ), 180 )]; // Q31 + } + ELSE + { + sin_val = ptr_sin[aziDeg]; // Q31 + } + move32(); + + y = Mpy_32_32( sin_val, cos_val ); // Q31 + e_mappedX = 0; + move16(); + mappedX = Sqrt32( L_max( 0, L_sub( ONE_IN_Q31, Mpy_32_32( y, y ) ) ), &e_mappedX ); + + aziRadMapped = BASOP_util_atan2( y, mappedX, negate( e_mappedX ) ); // Q13 + + /* Determine the real valued amplitude panning gains */ + move32(); + move32(); + IF( GE_16( aziRadMapped, shr( LsAngleRad, 2 ) ) ) + { /* Left side */ + *lRealp = ONE_IN_Q31; + *rRealp = 0; + move32(); + move32(); + } + ELSE IF( LE_16( aziRadMapped, negate( shr( LsAngleRad, 2 ) ) ) ) + { /* Right side */ + *lRealp = 0; + *rRealp = ONE_IN_Q31; + move32(); + move32(); + } + ELSE /* Tangent panning law */ + { + Word16 e_div, div, e_a, e_a3, temp_16_1, temp_16_2, e_num, e_den; + div = BASOP_Util_Divide3232_Scale( y, mappedX, &e_div ); + e_div = sub( e_div, e_mappedX ); + + A = mult( div, INV_TAN30_FX ); + e_a = add( e_div, 1 ); + + e_num = BASOP_Util_Add_MantExp( A, e_a, -32767, 0, &temp_16_1 ); + e_den = BASOP_Util_Add_MantExp( A, e_a, 32767, 0, &temp_16_2 ); + IF( temp_16_2 <= 0 ) + { + temp_16_2 = 32; + e_den = 0; + move16(); + move16(); + } + A2 = BASOP_Util_Divide1616_Scale( temp_16_1, temp_16_2, &e_div ); + e_div = add( e_div, sub( e_num, e_den ) ); + + e_den = BASOP_Util_Add_MantExp( mult( A2, A2 ), add( e_div, e_div ), 32767, 0, &temp_16_2 ); + A3 = BASOP_Util_Divide1616_Scale( 32767, temp_16_2, &e_a3 ); + e_a3 = sub( e_a3, e_den ); + // A3 = 1.0f / ( A2 * A2 + 1.0f ); // Q15 + Word32 temp_32 = L_shr( L_deposit_h( A3 ), sub( 0, e_a3 ) ); + Word16 temp_e = 0; + e_a3 = 0; + move16(); + move16(); + *lRealp = Sqrt32( temp_32, &e_a3 ); + *rRealp = Sqrt32( L_sub( ONE_IN_Q31, temp_32 ), &temp_e ); + *lRealp = L_shr( *lRealp, sub( 0, e_a3 ) ); // Q31 + *rRealp = L_shr( *rRealp, sub( 0, temp_e ) ); // Q31 + move32(); + move32(); + move32(); + move32(); + } + + /* Scaling to have the same expected gain as for the HRTF rendering */ + *lRealp = Mpy_32_32( *lRealp, SQRT2_FIXED ); // Q30 + *rRealp = Mpy_32_32( *rRealp, SQRT2_FIXED ); // Q30 + + *lRealp = L_shr( *lRealp, 2 ); // Q28 + *rRealp = L_shr( *rRealp, 2 ); // Q28 + move32(); + move32(); + move32(); + move32(); - assert( 0 && "Insert proper basop code here!)" ); - //*lImagp = 0.0f; - //*rImagp = 0.0f; - // if ( aziDeg == gainCache->azi && eleDeg == gainCache->ele ) - //{ - // *lRealp = gainCache->shVec[0]; /* Reused memory */ - // *rRealp = gainCache->shVec[1]; /* Reused memory */ - //} - // else - //{ - // /* Convert azi and ele to an azi value of the cone of confusion */ - // aziRad = (float) aziDeg * PI_OVER_180; - // eleRad = (float) eleDeg * PI_OVER_180; - // y = ( sinf( aziRad ) * cosf( eleRad ) ); - // mappedX = sqrtf( max( 0.0f, 1.0f - ( y * y ) ) ); - // aziRadMapped = atan2f( y, mappedX ); - - // /* Determine the real valued amplitude panning gains */ - // if ( aziRadMapped >= LsAngleRad ) - // { /* Left side */ - // *lRealp = 1.0f; - // *rRealp = 0.0f; - // } - // else if ( aziRadMapped <= -LsAngleRad ) - // { /* Right side */ - // *lRealp = 0.0f; - // *rRealp = 1.0f; - // } - // else /* Tangent panning law */ - // { - // A = tanf( aziRadMapped ) / tanf( LsAngleRad ); - // A2 = ( A - 1.0f ) / max( 0.001f, A + 1.0f ); - // A3 = 1.0f / ( A2 * A2 + 1.0f ); - // *lRealp = sqrtf( A3 ); - // *rRealp = sqrtf( 1.0f - A3 ); - // } - // /* Scaling to have the same expected gain as for the HRTF rendering */ - // *lRealp *= SQRT2; - // *rRealp *= SQRT2; - - // /* Store to gain cache */ - // gainCache->azi = aziDeg; - // gainCache->ele = eleDeg; - // gainCache->shVec[0] = *lRealp; /* Reuse memory */ - // gainCache->shVec[1] = *rRealp; /* Reuse memory */ - //} + /* Store to gain cache */ + gainCache->azi = aziDeg; + gainCache->ele = eleDeg; + gainCache->shVec_fx[0] = *lRealp; /* Reuse memory */ + gainCache->shVec_fx[1] = *rRealp; /* Reuse memory */ + move16(); + move16(); + move32(); + move32(); + } #else /* Convert azi and ele to an azi value of the cone of confusion */ @@ -5351,7 +5440,6 @@ Word16 configure_reqularization_factor_fx( return reqularizationFactor; } - #ifdef OMASA_OBJECT_EDITING /*-------------------------------------------------------------------* * ivas_omasa_preProcessStereoTransportsForEditedObjects() @@ -5367,92 +5455,107 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( const Word16 nBins, const Word16 subframe ) { - int16_t bin, ch, inCh, outCh, ismDirIndex, slot, band_idx, bin_lo, bin_hi, max_band, n_ism; + Word16 bin, ch, inCh, outCh, ismDirIndex, slot, band_idx, bin_lo, bin_hi, max_band, n_ism; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; MASA_ISM_DATA_HANDLE hMasaIsmData; - PARAM_ISM_DEC_HANDLE hParamIsmDec = 0; - int16_t nSlots; -#if 0 - uint8_t enableCentering; - int16_t dirac_read_idx; - float panGainsOut[4][2]; - float panGainsIn[4][2]; - float panEnesOut[4][2]; - float panEnesIn[4][2]; +#ifdef OBJ_EDITING_PARAMISM_BIN + PARAM_ISM_DEC_HANDLE hParamIsmDec; #endif - uint8_t ismGainEdited[4]; - uint8_t ismDirEdited[4]; - uint8_t masaGainEdited; -#if 0 - uint8_t masaIsmMode; + UWord8 enableCentering; + Word16 dirac_read_idx; + Word16 nSlots; + Word16 panGainsOut[4][2]; + Word16 panGainsIn[4][2]; + Word16 panEnesOut[4][2]; + Word16 panEnesIn[4][2]; + UWord8 ismGainEdited[4]; + UWord8 ismDirEdited[4]; + UWord8 masaGainEdited; +#ifdef OBJ_EDITING_PARAMISM_BIN + UWord8 masaIsmMode; #endif - *cldfb_buf_q = 0; + hSpatParamRendCom = st_ivas->hSpatParamRendCom; hMasaIsmData = st_ivas->hMasaIsmData; -#if 0 +#ifdef OBJ_EDITING_PARAMISM_BIN hParamIsmDec = st_ivas->hParamIsmDec; - if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) + IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) { - masaIsmMode = 1u; + masaIsmMode = 1; + move16(); } - else + ELSE { - masaIsmMode = 0u; + masaIsmMode = 0; + move16(); } +#endif - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_FOA || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA2 || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA3 ) + test(); + test(); + IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) || EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA2 ) || EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA3 ) ) { enableCentering = 0; + move16(); } - else + ELSE { enableCentering = 1; + move16(); } -#endif #ifdef OBJ_EDITING_PARAMISM_BIN - if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC || st_ivas->ivas_format == ISM_FORMAT ) + test(); + IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) || EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) #else - if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) #endif { n_ism = st_ivas->nchan_ism; + move16(); } - else + ELSE { n_ism = hSpatParamRendCom->numIsmDirections; + move16(); } - for ( ismDirIndex = 0; ismDirIndex < n_ism; ismDirIndex++ ) + FOR( ismDirIndex = 0; ismDirIndex < n_ism; ismDirIndex++ ) { - ismGainEdited[ismDirIndex] = hMasaIsmData->ism_gain_is_edited[ismDirIndex]; - ismDirEdited[ismDirIndex] = hMasaIsmData->ism_dir_is_edited[ismDirIndex]; + ismGainEdited[ismDirIndex] = hMasaIsmData->ism_gain_is_edited_fx[ismDirIndex]; + move16(); + ismDirEdited[ismDirIndex] = hMasaIsmData->ism_dir_is_edited_fx[ismDirIndex]; + move16(); } - masaGainEdited = hMasaIsmData->masa_gain_is_edited; + masaGainEdited = hMasaIsmData->masa_gain_is_edited_fx; + move16(); /* Bypass processing until first object is moved or gained */ - if ( hMasaIsmData->objectsEdited == 0 ) + IF( hMasaIsmData->objectsEdited_fx == 0 ) { - for ( ismDirIndex = 0; ismDirIndex < n_ism; ismDirIndex++ ) + FOR( ismDirIndex = 0; ismDirIndex < n_ism; ismDirIndex++ ) { - if ( ismDirEdited[ismDirIndex] ) + IF( ismDirEdited[ismDirIndex] ) { - hMasaIsmData->objectsEdited = 1; + hMasaIsmData->objectsEdited_fx = 1; + move16(); } - if ( ismGainEdited[ismDirIndex] ) + IF( ismGainEdited[ismDirIndex] ) { - hMasaIsmData->objectsEdited = 1; + hMasaIsmData->objectsEdited_fx = 1; + move16(); } } - if ( masaGainEdited ) + IF( masaGainEdited ) { - hMasaIsmData->objectsEdited = 1; + hMasaIsmData->objectsEdited_fx = 1; + move16(); } - if ( hMasaIsmData->objectsEdited == 0 ) + IF( hMasaIsmData->objectsEdited_fx == 0 ) { /* No objects have moved so far */ return; @@ -5460,214 +5563,1161 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( } /* OMASA gaining for discrete OMASA mode with stereo_param/bin_room_param renderer */ - if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) - { - assert( 0 && "Insert proper basop code here!" ); - ///* - ///* ISM gaining */ - // for ( ch = 0; ch < n_ism; ch++ ) - //{ - // if ( st_ivas->hMasaIsmData->ism_gain_is_edited[ch] ) - // { - // for ( slot = 0; slot < hSpatParamRendCom->subframe_nbslots[subframe]; slot++ ) - // { - // float gain; - // gain = st_ivas->hMasaIsmData->gain_ism_edited_fx[ch]; - // v_multc( inRe[ch + 2][slot], gain, inRe[ch + 2][slot], nBins ); - // v_multc( inIm[ch + 2][slot], gain, inIm[ch + 2][slot], nBins ); - // } - // } - // } - - ///* MASA gaining */ - // for ( ch = 0; ch < 2; ch++ ) - //{ - // if ( masaGainEdited ) - // { - // for ( slot = 0; slot < hSpatParamRendCom->subframe_nbslots[subframe]; slot++ ) - // { - // float gain_masa; - // gain_masa = st_ivas->hMasaIsmData->gain_masa_edited_fx; - // v_multc( inRe[ch][slot], gain_masa, inRe[ch][slot], nBins ); - // v_multc( inIm[ch][slot], gain_masa, inIm[ch][slot], nBins ); - // } - // } - // } + test(); + test(); + test(); + IF( ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) + { + /* ISM gaining */ + FOR( ch = 0; ch < n_ism; ch++ ) + { + IF( st_ivas->hMasaIsmData->ism_gain_is_edited_fx[ch] ) + { + FOR( slot = 0; slot < hSpatParamRendCom->subframe_nbslots[subframe]; slot++ ) + { + Word16 gain; + gain = st_ivas->hMasaIsmData->gain_ism_edited_fx[ch]; + move32(); + + v_multc_fixed_16( inRe_fx[ch + 2][slot], gain, inRe_fx[ch + 2][slot], nBins ); // Q = *cldfb_buf_q - 3 + Scale_sig32( inRe_fx[ch + 2][slot], nBins, Q3 ); // Q = *cldfb_buf_q + + v_multc_fixed_16( inIm_fx[ch + 2][slot], gain, inIm_fx[ch + 2][slot], nBins ); // Q = *cldfb_buf_q - 3 + Scale_sig32( inIm_fx[ch + 2][slot], nBins, Q3 ); // Q = *cldfb_buf_q + } + } + } + + /* MASA gaining */ + FOR( ch = 0; ch < 2; ch++ ) + { + IF( masaGainEdited ) + { + FOR( slot = 0; slot < hSpatParamRendCom->subframe_nbslots[subframe]; slot++ ) + { + Word16 gain_masa; + gain_masa = st_ivas->hMasaIsmData->gain_masa_edited_fx; + move32(); + + v_multc_fixed_16( inRe_fx[ch][slot], gain_masa, inRe_fx[ch][slot], nBins ); // Q = *cldfb_buf_q - 3 + Scale_sig32( inRe_fx[ch][slot], nBins, Q3 ); // Q = *cldfb_buf_q + + v_multc_fixed_16( inIm_fx[ch][slot], gain_masa, inIm_fx[ch][slot], nBins ); // Q = *cldfb_buf_q - 3 + Scale_sig32( inIm_fx[ch][slot], nBins, Q3 ); // Q = *cldfb_buf_q + } + } + } } #ifdef OBJ_EDITING_PARAMISM_BIN - else if ( st_ivas->ivas_format == ISM_FORMAT && st_ivas->hISMDTX.dtx_flag ) /* If dtx on, perform just the smoothing of the processing gains */ - { - float totalTargetEne; - float ismPreprocMtxNew[2][2]; - float ismPreprocMtxIncrement[2][2]; - float nSlotDiv; - float outSlotRe[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; - float outSlotIm[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; - float eqVal; + ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) && st_ivas->hISMDTX.dtx_flag ) /* If dtx on, perform just the smoothing of the processing gains */ + { + Word32 totalTargetEne; + Word32 ismPreprocMtxNew[2][2]; + Word32 ismPreprocMtxIncrement[2][2]; + Word32 outSlotRe[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + Word32 outSlotIm[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + Word32 eqVal; + Word32 temp; + Word16 temp_q; + Word64 temp64; + Word16 exp1; + Word16 totalTargetEne_e; nSlots = hSpatParamRendCom->subframe_nbslots[subframe]; - nSlotDiv = 1.0f / ( (float) nSlots ); + move16(); /* Use diagonal mixing matrix as the instant mixing matrix, to slowly fade away the editing during dtx */ - for ( ch = 0; ch < 2; ch++ ) + FOR( ch = 0; ch < 2; ch++ ) { - ismPreprocMtxNew[ch][ch] = 1.0f; - ismPreprocMtxNew[1 - ch][ch] = 0.0f; + ismPreprocMtxNew[ch][ch] = ONE_IN_Q28; + move32(); + ismPreprocMtxNew[1 - ch][ch] = 0; + move32(); } /* Determine the highest band */ max_band = 0; - while ( max_band < MAX_PARAM_ISM_NBANDS && hParamIsmDec->hParamIsm->band_grouping[max_band] < nBins ) + move16(); + WHILE( sub( MAX_PARAM_ISM_NBANDS, max_band ) > 0 && sub( nBins, hParamIsmDec->hParamIsm->band_grouping[max_band] ) > 0 ) { max_band++; } /* Init out array */ - for ( int k = 0; k < nSlots; k++ ) + FOR( Word16 k = 0; k < nSlots; k++ ) { - for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { - set_zero( outSlotRe[ch][k], CLDFB_NO_CHANNELS_MAX ); - set_zero( outSlotIm[ch][k], CLDFB_NO_CHANNELS_MAX ); + set32_fx( outSlotRe[ch][k], 0, CLDFB_NO_CHANNELS_MAX ); + set32_fx( outSlotIm[ch][k], 0, CLDFB_NO_CHANNELS_MAX ); } } - /* Perform the processing in frequency bands */ - for ( band_idx = 0; band_idx < max_band; band_idx++ ) + // /* Perform the processing in frequency bands */ + FOR( band_idx = 0; band_idx < max_band; band_idx++ ) { bin_lo = hParamIsmDec->hParamIsm->band_grouping[band_idx]; - bin_hi = min( hParamIsmDec->hParamIsm->band_grouping[band_idx + 1], nBins ); + bin_hi = s_min( hParamIsmDec->hParamIsm->band_grouping[band_idx + 1], nBins ); + move16(); + move16(); /* Determine transport energies */ - totalTargetEne = 0.0f; - for ( slot = 0; slot < nSlots; slot++ ) + totalTargetEne = 0; + totalTargetEne_e = 0; + move32(); + move16(); + FOR( slot = 0; slot < nSlots; slot++ ) { - for ( ch = 0; ch < 2; ch++ ) + FOR( ch = 0; ch < 2; ch++ ) { - for ( bin = bin_lo; bin < bin_hi; bin++ ) + FOR( bin = bin_lo; bin < bin_hi; bin++ ) { - totalTargetEne += inRe_fx[ch][slot][bin] * inRe_fx[ch][slot][bin]; - totalTargetEne += inIm_fx[ch][slot][bin] * inIm_fx[ch][slot][bin]; + + Word32 instEne_fx; + temp64 = W_mult0_32_32( inRe_fx[ch][slot][bin], inRe_fx[ch][slot][bin] ); // 2q-3 + temp64 = W_add( temp64, W_mult0_32_32( inIm_fx[ch][slot][bin], inIm_fx[ch][slot][bin] ) ); // 2q-3 + exp1 = W_norm( temp64 ); + instEne_fx = W_extract_h( W_shl( temp64, exp1 ) ); // 2*cldfb_buf_q - 32 + exp1 + exp1 = 31 - ( 2 * ( *cldfb_buf_q ) - 32 + exp1 ); + move16(); + + BASOP_Util_Add_Mant32Exp( totalTargetEne, totalTargetEne_e, instEne_fx, exp1, &totalTargetEne_e ); } } } /* Get increment value for temporal interpolation */ - for ( inCh = 0; inCh < 2; inCh++ ) + FOR( inCh = 0; inCh < 2; inCh++ ) { - for ( outCh = 0; outCh < 2; outCh++ ) + FOR( outCh = 0; outCh < 2; outCh++ ) { - ismPreprocMtxIncrement[outCh][inCh] = ( ismPreprocMtxNew[outCh][inCh] - hMasaIsmData->ismPreprocMatrix_fx[outCh][inCh][band_idx] ) * nSlotDiv; + temp = L_sub( ismPreprocMtxNew[outCh][inCh], hMasaIsmData->ismPreprocMatrix_fx[outCh][inCh][band_idx] ); // Q28 + ismPreprocMtxIncrement[outCh][inCh] = L_shr( temp, 2 ); // Divide by 4 + move32(); } } /* Mix signals */ - hMasaIsmData->preprocEneTarget_fx[band_idx] *= STEREO_PREPROCESS_IIR_FACTOR; - hMasaIsmData->preprocEneRealized_fx[band_idx] *= STEREO_PREPROCESS_IIR_FACTOR; - hMasaIsmData->preprocEneTarget_fx[band_idx] += totalTargetEne; + hMasaIsmData->preprocEneTarget_fx[band_idx] = Mpy_32_16_1( hMasaIsmData->preprocEneTarget_fx[band_idx], STEREO_PREPROCESS_IIR_FACTOR_Q15 ); // Q = preprocEneTarget_e + move32(); + + hMasaIsmData->preprocEneRealized_fx[band_idx] = Mpy_32_16_1( hMasaIsmData->preprocEneRealized_fx[band_idx], STEREO_PREPROCESS_IIR_FACTOR_Q15 ); // Q = preprocEneRealized_e + move32(); + + hMasaIsmData->preprocEneTarget_fx[band_idx] = BASOP_Util_Add_Mant32Exp( hMasaIsmData->preprocEneTarget_fx[band_idx], hMasaIsmData->preprocEneTarget_e[band_idx], totalTargetEne, totalTargetEne_e, &hMasaIsmData->preprocEneTarget_e[band_idx] ); // Q = 31-preprocEneTarget_e + move32(); - for ( outCh = 0; outCh < 2; outCh++ ) + FOR( outCh = 0; outCh < 2; outCh++ ) { - for ( slot = 0; slot < nSlots; slot++ ) + FOR( slot = 0; slot < nSlots; slot++ ) { - for ( inCh = 0; inCh < 2; inCh++ ) + FOR( inCh = 0; inCh < 2; inCh++ ) { - hMasaIsmData->ismPreprocMatrix_fx[outCh][inCh][band_idx] += ismPreprocMtxIncrement[outCh][inCh]; - for ( bin = bin_lo; bin < bin_hi; bin++ ) + hMasaIsmData->ismPreprocMatrix_fx[outCh][inCh][band_idx] = L_add( hMasaIsmData->ismPreprocMatrix_fx[outCh][inCh][band_idx], ismPreprocMtxIncrement[outCh][inCh] ); // Q28 + + FOR( bin = bin_lo; bin < bin_hi; bin++ ) { - outSlotRe[outCh][slot][bin] += inRe_fx[inCh][slot][bin] * hMasaIsmData->ismPreprocMatrix_fx[outCh][inCh][band_idx]; - outSlotIm[outCh][slot][bin] += inIm_fx[inCh][slot][bin] * hMasaIsmData->ismPreprocMatrix_fx[outCh][inCh][band_idx]; + temp = Mpy_32_32( inRe_fx[inCh][slot][bin], hMasaIsmData->ismPreprocMatrix_fx[outCh][inCh][band_idx] ); // Q = q_cldfb* + 28 - 31 = q_cldfb - 3 + outSlotRe[outCh][slot][bin] = L_add( outSlotRe[outCh][slot][bin], L_shl( temp, 3 ) ); // Q = q_cldfb* + move32(); + + temp = Mpy_32_32( inIm_fx[inCh][slot][bin], hMasaIsmData->ismPreprocMatrix_fx[outCh][inCh][band_idx] ); // Q = q_cldfb* + 28 - 31 = q_cldfb*-3 + outSlotIm[outCh][slot][bin] = L_add( outSlotIm[outCh][slot][bin], L_shl( temp, 3 ) ); // Q = q_cldfb* + move32(); } } - for ( bin = bin_lo; bin < bin_hi; bin++ ) + FOR( bin = bin_lo; bin < bin_hi; bin++ ) { - hMasaIsmData->preprocEneRealized_fx[band_idx] += ( outSlotRe[outCh][slot][bin] * outSlotRe[outCh][slot][bin] ) + ( outSlotIm[outCh][slot][bin] * outSlotIm[outCh][slot][bin] ); + Word32 instEne_fx; + temp64 = W_mult0_32_32( outSlotRe[outCh][slot][bin], outSlotRe[outCh][slot][bin] ); // 2q-3 + temp64 = W_add( temp64, W_mult0_32_32( outSlotIm[outCh][slot][bin], outSlotIm[outCh][slot][bin] ) ); // 2q-3 + exp1 = W_norm( temp64 ); + instEne_fx = W_extract_h( W_shl( temp64, exp1 ) ); // 2*cldfb_buf_q - 32 + exp1 + exp1 = 31 - ( 2 * ( *cldfb_buf_q ) - 32 + exp1 ); + move16(); + + hMasaIsmData->preprocEneRealized_fx[band_idx] = BASOP_Util_Add_Mant32Exp( hMasaIsmData->preprocEneRealized_fx[band_idx], hMasaIsmData->preprocEneRealized_e[band_idx], instEne_fx, exp1, &hMasaIsmData->preprocEneRealized_e[band_idx] ); // Q= *cldfb_buf_q + *cldfb_buf_q - 31 = Q-19); + move32(); } } } - eqVal = fminf( 4.0f, sqrtf( hMasaIsmData->preprocEneTarget_fx[band_idx] / fmaxf( 1e-12f, hMasaIsmData->preprocEneRealized_fx[band_idx] ) ) ); + test(); + IF( hMasaIsmData->preprocEneTarget_fx[band_idx] > 0 && hMasaIsmData->preprocEneRealized_fx[band_idx] > 0 ) + { + temp = BASOP_Util_Divide3232_Scale_newton( hMasaIsmData->preprocEneTarget_fx[band_idx], L_max( 1, hMasaIsmData->preprocEneRealized_fx[band_idx] ), &temp_q ); + temp_q = sub( Q31, sub( sub( Q31, temp_q ), sub( hMasaIsmData->preprocEneTarget_e[band_idx], hMasaIsmData->preprocEneRealized_e[band_idx] ) ) ); + temp = Sqrt32( temp, &temp_q ); // Q: 31-temp_q + temp = L_shl( temp, sub( temp_q, 3 ) ); // Q28 + temp_q = Q28; + move32(); + } + ELSE + { + temp = 0; + } + + IF( GT_32( ONE_IN_Q30, temp ) ) + { + eqVal = temp; + } + ELSE + { + eqVal = ONE_IN_Q30; // 4 in Q28 + } - for ( ch = 0; ch < 2; ch++ ) + FOR( ch = 0; ch < 2; ch++ ) { - for ( slot = 0; slot < nSlots; slot++ ) + FOR( slot = 0; slot < nSlots; slot++ ) { - for ( bin = bin_lo; bin < bin_hi; bin++ ) + FOR( bin = bin_lo; bin < bin_hi; bin++ ) { - inRe_fx[ch][slot][bin] = outSlotRe[ch][slot][bin] * eqVal; - inIm_fx[ch][slot][bin] = outSlotIm[ch][slot][bin] * eqVal; + temp = Mpy_32_32( outSlotRe[ch][slot][bin], eqVal ); // Q = (cldfb_q) + 28 -31 = cldfb_q - 3 + inRe_fx[ch][slot][bin] = L_shl( temp, 3 ); + move32(); + + temp = Mpy_32_32( outSlotIm[ch][slot][bin], eqVal ); // Q = (cldfb_q) + 28 -31 = cldfb_q - 3 + inIm_fx[ch][slot][bin] = L_shl( temp, 3 ); + move32(); } } } } } #endif - else /* Other processing modes */ - { - assert( 0 && "Insert proper basop code here!" ); - } - - return; -} -#else - - -/*-------------------------------------------------------------------* - * ivas_omasa_preProcessStereoTransportsForMovedObjects_fx() - * - * - *-------------------------------------------------------------------*/ + ELSE /* Other processing modes */ + { + Word32 subframeEne; + Word32 subframeEneCh[2]; + Word32 normEnes[2]; + Word32 ratioAccOrig; + Word32 ratioAccNew; + Word32 ratio; + Word32 ismEneThis; + Word32 ismTargetEneThis; + Word32 ismTargetEneThisCh[2]; + Word32 totalTargetEneCh[2]; + Word32 totalTargetEne; + Word32 masaTargetEneThisCh[2]; + Word32 ismPreprocMtxNew[2][2]; + Word16 ismPreprocMtxNew_e[2][2]; + Word32 ismPreprocMtxIncrement[2][2]; + Word16 ismPreprocMtxIncrement_e[2][2]; + Word32 eneMove[2]; + Word32 enePreserve[2]; + Word32 ismRatioAcc; + Word32 remainderNormEne; + Word16 centeringFactor; + Word16 eneMoveThis; + Word16 enePreserveThis; + Word32 normVal; + Word32 eqVal; + Word32 outSlotRe[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + Word32 outSlotIm[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + Word32 newRatios[6]; + Word16 gainIsmThis; + Word16 gainMasaPow2; + Word32 tempDivisor; + Word32 masaEneThisCh[2]; + Word32 ratioAccNewDivisor; + Word32 temp; + Word16 temp_q = 0; + Word16 temp1; + Word64 temp64; + Word16 norm, shift = 31; + Word16 exp, exp1; + Word16 subframeEneCh_e[2]; + Word16 subframeEneCh_Q[2]; + Word16 subQ = 0; + move16(); + move16(); + move16(); -void ivas_omasa_preProcessStereoTransportsForMovedObjects_fx( - Decoder_Struct *st_ivas, - Word32 inRe_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /*cldfb_buf_q*/ - Word32 inIm_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /*cldfb_buf_q*/ - Word16 *cldfb_buf_q, - const Word16 nBins, - const Word16 subframe ) -{ - Word16 bin, ch, inCh, outCh, ismDirIndex, slot; - SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; - MASA_ISM_DATA_HANDLE hMasaIsmData; - UWord8 enableCentering; - Word16 dirac_read_idx; - Word16 nSlots; + set16_fx( subframeEneCh_e, 0, 2 ); + temp = 0; + move32(); - hSpatParamRendCom = st_ivas->hSpatParamRendCom; - hMasaIsmData = st_ivas->hMasaIsmData; + gainMasaPow2 = 0; + move16(); + IF( masaGainEdited ) + { + gainMasaPow2 = hMasaIsmData->gain_masa_edited_fx; // Q12 + move16(); + gainMasaPow2 = mult( gainMasaPow2, gainMasaPow2 ); // Q = 12 + 12 - 15 = 9 + move16(); + } - test(); - test(); - IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) || EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA2 ) || EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA3 ) ) - { - enableCentering = 0; + nSlots = hSpatParamRendCom->subframe_nbslots[subframe]; move16(); - } - ELSE - { - enableCentering = 1; + dirac_read_idx = hSpatParamRendCom->render_to_md_map[subframe]; move16(); - } - /* Bypass processing until first object is moved */ - IF( hMasaIsmData->objectsMoved == 0 ) - { - FOR( ismDirIndex = 0; ismDirIndex < hSpatParamRendCom->numIsmDirections; ismDirIndex++ ) + /* Determine panning gains and energies for each object */ + FOR( ismDirIndex = 0; ismDirIndex < n_ism; ismDirIndex++ ) { - if ( hMasaIsmData->ism_is_edited[ismDirIndex] ) + /* Get input and output panning gains */ + ivas_get_stereo_panning_gains_fx( hMasaIsmData->azimuth_ism[ismDirIndex][dirac_read_idx], + hMasaIsmData->elevation_ism[ismDirIndex][dirac_read_idx], + panGainsIn[ismDirIndex] ); // Q15 + + IF( ismDirEdited[ismDirIndex] ) { - hMasaIsmData->objectsMoved = 1; - move16(); + ivas_get_stereo_panning_gains_fx( hMasaIsmData->azimuth_ism_edited_fx[ismDirIndex], + hMasaIsmData->elevation_ism_edited_fx[ismDirIndex], + panGainsOut[ismDirIndex] ); // Q15 } - } - IF( hMasaIsmData->objectsMoved == 0 ) - { - /* No objects have moved so far */ - return; - } - } - + ELSE + { + /* When not edited, input and output pan gains are the same */ + FOR( ch = 0; ch < 2; ch++ ) + { + panGainsOut[ismDirIndex][ch] = panGainsIn[ismDirIndex][ch]; + move16(); + } + } + + /* Determine pan enes */ + FOR( ch = 0; ch < 2; ch++ ) + { + panEnesOut[ismDirIndex][ch] = mult( panGainsOut[ismDirIndex][ch], panGainsOut[ismDirIndex][ch] ); // Q15 + move16(); + panEnesIn[ismDirIndex][ch] = mult( panGainsIn[ismDirIndex][ch], panGainsIn[ismDirIndex][ch] ); // Q15 + move16(); + } + } + + /* Determine the highest band */ + max_band = 0; + move16(); +#ifdef OBJ_EDITING_PARAMISM_BIN + IF( masaIsmMode ) + { +#endif + test(); + WHILE( ( sub( MASA_FREQUENCY_BANDS, max_band ) > 0 ) && ( sub( nBins, MASA_band_grouping_24[max_band] ) > 0 ) ) + { + max_band++; + } +#ifdef OBJ_EDITING_PARAMISM_BIN + } + ELSE + { + test(); + WHILE( ( sub( MAX_PARAM_ISM_NBANDS, max_band ) > 0 ) && ( sub( nBins, hParamIsmDec->hParamIsm->band_grouping[max_band] ) > 0 ) ) + { + max_band++; + } + } +#endif + + /* Init out array */ + FOR( Word16 k = 0; k < nSlots; k++ ) + { + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + set_zero_fx( outSlotRe[ch][k], CLDFB_NO_CHANNELS_MAX ); + set_zero_fx( outSlotIm[ch][k], CLDFB_NO_CHANNELS_MAX ); + + norm = s_min( L_norm_arr( inRe_fx[ch][k], nBins ), L_norm_arr( inIm_fx[ch][k], nBins ) ); + shift = s_min( norm, shift ); + } + } + + + /* Perform the processing in frequency bands */ + FOR( band_idx = 0; band_idx < max_band; band_idx++ ) + { + ratioAccOrig = 0; + move32(); + ratioAccNew = 0; + move32(); + ismRatioAcc = 0; + move32(); + + set32_fx( eneMove, 0, 2 ); + set32_fx( enePreserve, 0, 2 ); + set32_fx( subframeEneCh, 0, 2 ); + set32_fx( normEnes, 0, 2 ); + set32_fx( ismTargetEneThisCh, 0, 2 ); + set32_fx( totalTargetEneCh, 0, 2 ); + set32_fx( masaTargetEneThisCh, 0, 2 ); + set32_fx( ismPreprocMtxNew[0], 0, 2 ); + set32_fx( ismPreprocMtxNew[1], 0, 2 ); + set16_fx( ismPreprocMtxNew_e[0], 0, 2 ); + set16_fx( ismPreprocMtxNew_e[1], 0, 2 ); + set32_fx( ismPreprocMtxIncrement[0], 0, 2 ); + set32_fx( ismPreprocMtxIncrement[1], 0, 2 ); + set16_fx( ismPreprocMtxIncrement_e[1], 0, 2 ); + set16_fx( ismPreprocMtxIncrement_e[1], 0, 2 ); + +#ifdef OBJ_EDITING_PARAMISM_BIN + IF( masaIsmMode ) + { +#endif + bin_lo = MASA_band_grouping_24[band_idx]; + move16(); + bin_hi = s_min( MASA_band_grouping_24[band_idx + 1], nBins ); + move16(); +#ifdef OBJ_EDITING_PARAMISM_BIN + } + ELSE + { + bin_lo = hParamIsmDec->hParamIsm->band_grouping[band_idx]; + move16(); + bin_hi = s_min( hParamIsmDec->hParamIsm->band_grouping[band_idx + 1], nBins ); + move16(); + } +#endif + + exp = sub( 63, shl( *cldfb_buf_q, 1 ) ); + Word16 guardBits = 5; + move16(); + + /* Determine transport normalized energies and subframe energy */ + FOR( ch = 0; ch < 2; ch++ ) + { + FOR( slot = 0; slot < nSlots; slot++ ) + { + FOR( bin = bin_lo; bin < bin_hi; bin++ ) + { + + Word32 instEne_fx; + temp64 = W_mult0_32_32( inRe_fx[ch][slot][bin], inRe_fx[ch][slot][bin] ); // 2q + temp64 = W_add( temp64, W_mult0_32_32( inIm_fx[ch][slot][bin], inIm_fx[ch][slot][bin] ) ); // 2q + exp1 = W_norm( temp64 ); + instEne_fx = W_extract_h( W_shl( temp64, exp1 ) ); // 2*cldfb_buf_q - 32 + exp1 + /* exp of instEne_fx = 31 - (2q -32 + exp1) = 63 - 2q - exp1 = exp - exp1*/ + + subframeEneCh[ch] = BASOP_Util_Add_Mant32Exp( subframeEneCh[ch], subframeEneCh_e[ch], instEne_fx, sub( exp, exp1 ), &subframeEneCh_e[ch] ); + subframeEneCh_Q[ch] = 31 - subframeEneCh_e[ch]; + move32(); + move32(); + } + } + } + + // Align subframeEneCh Q values, shift 1 bit right to avoid overflow from sum + IF( EQ_32( subframeEneCh_Q[0], subframeEneCh_Q[1] ) ) + { + subframeEneCh[0] = L_shr( subframeEneCh[0], 1 ); + subframeEneCh[1] = L_shr( subframeEneCh[1], 1 ); + subframeEne = L_add( subframeEneCh[0], subframeEneCh[1] ); // subQ + subframeEneCh_Q[1] = sub( subframeEneCh_Q[1], 1 ); + subframeEneCh_Q[0] = sub( subframeEneCh_Q[0], 1 ); + subQ = subframeEneCh_Q[0]; + + move16(); + move16(); + move16(); + move16(); + move16(); + } + ELSE + { + IF( GT_32( subframeEneCh_Q[0], subframeEneCh_Q[1] ) ) + { + temp1 = sub( subframeEneCh_Q[0], subframeEneCh_Q[1] ); + subframeEneCh[0] = L_shr( subframeEneCh[0], temp1 ); + subframeEneCh[0] = L_shr( subframeEneCh[0], 1 ); + subframeEneCh[1] = L_shr( subframeEneCh[1], 1 ); + subframeEne = L_add( subframeEneCh[0], subframeEneCh[1] ); // subQ + subframeEneCh_Q[0] = sub( subframeEneCh_Q[1], 1 ); + subframeEneCh_Q[1] = sub( subframeEneCh_Q[1], 1 ); + subQ = subframeEneCh_Q[1]; + + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + } + ELSE + { + temp1 = sub( subframeEneCh_Q[1], subframeEneCh_Q[0] ); + subframeEneCh[1] = L_shr( subframeEneCh[1], temp1 ); + subframeEneCh[0] = L_shr( subframeEneCh[0], 1 ); + subframeEneCh[1] = L_shr( subframeEneCh[1], 1 ); + + subframeEne = L_add( subframeEneCh[0], subframeEneCh[1] ); + subframeEneCh_Q[1] = sub( subframeEneCh_Q[0], 1 ); + subframeEneCh_Q[0] = sub( subframeEneCh_Q[0], 1 ); + subQ = subframeEneCh_Q[0]; + + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + } + } + + /* Shift subframeEnes right by the number of guard bits to avoid overflow */ + subframeEne = L_shr( subframeEne, guardBits ); + subframeEneCh[0] = L_shr( subframeEneCh[0], guardBits ); + subframeEneCh[1] = L_shr( subframeEneCh[1], guardBits ); + + subQ = sub( subQ, guardBits ); + subframeEneCh_Q[0] = sub( subframeEneCh_Q[0], guardBits ); + subframeEneCh_Q[1] = sub( subframeEneCh_Q[1], guardBits ); + + move16(); + move16(); + move16(); + move16(); + + /* Zero check */ + IF( GT_32( subframeEne, 0 ) ) + { + totalTargetEneCh[0] = subframeEneCh[0]; // subQch[0] + move32(); + totalTargetEneCh[1] = subframeEneCh[1]; // subQch[1] + move32(); + masaEneThisCh[0] = subframeEneCh[0]; // subQch[0] + move32(); + masaEneThisCh[1] = subframeEneCh[1]; // subQch[1] + move32(); + } + + /* Gain editing */ + /* For each object, estimate new target energy per channel based on the applied gain */ + FOR( ismDirIndex = 0; ismDirIndex < n_ism; ismDirIndex++ ) + { + ratio = hMasaIsmData->energy_ratio_ism_fx[ismDirIndex][dirac_read_idx][bin_lo]; // Q30 + move32(); + + ratioAccOrig = L_add( ratioAccOrig, ratio ); // Q30 + + /* Calculate MASA energy as a residual of original channel energies subtracted with ISM energies */ + FOR( ch = 0; ch < 2; ch++ ) + { + temp = Mpy_32_32( ratio, subframeEne ); // Q = 30 + subEneQ - 31 = subEneQ-1 + temp = Mpy_32_16_1( temp, panEnesIn[ismDirIndex][ch] ); // Q = subEneQ-1 + + temp_q = sub( subframeEneCh_Q[ch], sub( subQ, 1 ) ); + masaEneThisCh[ch] = L_sub( masaEneThisCh[ch], L_shl( temp, temp_q ) ); // Q = subframeEneCh_Q + move32(); + } + + /* Calculate target energy, gained ratio for accumulation, and transports gains, if ism gain is edited */ + IF( ismGainEdited[ismDirIndex] ) + { + gainIsmThis = hMasaIsmData->gain_ism_edited_fx[ismDirIndex]; // Q12 + move16(); + + /* ISM original energy */ + ismEneThis = Mpy_32_32( ratio, subframeEne ); // Q = 30 + subEneQ - 31 = subQ-1 + move32(); + + /* ISM target energy */ + temp1 = shl_sat( mult( gainIsmThis, gainIsmThis ), 2 ); // Q = 12 + 12 - 15 + 2 = 11 + ismTargetEneThis = Mpy_32_16_1( ismEneThis, temp1 ); // Q = (subQ-1) + 11 - 15 = subQ-5 + move32(); + + ratio = L_shl( Mpy_32_16_1( ratio, temp1 ), 1 ); // Q = 30 + 11 - 15 + 1 = 27 + move32(); + + + /* Determine panning energies and channel target energies */ + FOR( ch = 0; ch < 2; ch++ ) + { + /* Ism target energy per channel */ + ismTargetEneThisCh[ch] = Mpy_32_16_1( ismTargetEneThis, panEnesIn[ismDirIndex][ch] ); // Q = subQ-5 + 15 + 1 - 16 = subQ-5 + move32(); + + /* Reduce original ism energy */ + temp = Mpy_32_16_1( ismEneThis, panEnesIn[ismDirIndex][ch] ); // subEneQ-1 + 15 + 1 - 16 = subQ-1 + totalTargetEneCh[ch] = L_sub( totalTargetEneCh[ch], L_shl( temp, 1 ) ); // subEneQ + move32(); + + /* Add ism target energy per channel */ + totalTargetEneCh[ch] = L_add( totalTargetEneCh[ch], L_shl( ismTargetEneThisCh[ch], 5 ) ); // SubQ + move32(); + } + + + /* If separated ism edited, apply gain directly to the separated ism */ + IF( EQ_16( ismDirIndex, hMasaIsmData->idx_separated_ism ) ) + { + /* Separated object gaining is done elsewhere with DIRAC renderer */ + IF( NE_32( st_ivas->renderer_type, RENDERER_DIRAC ) ) + { + /* Gain transport channel of separated ism */ + FOR( slot = 0; slot < nSlots; slot++ ) + { + FOR( bin = bin_lo; bin < bin_hi; bin++ ) + { + temp = Mpy_32_16_1( inRe_fx[2][slot][bin], gainIsmThis ); // Q = *cldfb_buf_q + 12 + 1 - 16 = *cldfb_buf_q - 3 + inRe_fx[2][slot][bin] = L_shl( temp, Q3 ); + move32(); + + temp = Mpy_32_16_1( inIm_fx[2][slot][bin], gainIsmThis ); // Q = *cldfb_buf_q + 12 + 1 - 16 = *cldfb_buf_q - 3 + inIm_fx[2][slot][bin] = L_shl( temp, Q3 ); + move32(); + } + } + } + } + ratioAccNew = L_add( ratioAccNew, ratio ); // Q27 + move32(); + } + ELSE + { + ratioAccNew = L_add( ratioAccNew, L_shr( ratio, 3 ) ); // Q27 + move32(); + } + } + +#ifdef OBJ_EDITING_PARAMISM_BIN + IF( masaIsmMode ) + { +#endif + /* MASA original ratios */ + ratio = L_add( hSpatParamRendCom->energy_ratio1_fx[dirac_read_idx][bin_lo], hSpatParamRendCom->energy_ratio2_fx[dirac_read_idx][bin_lo] ); // Q30 + move32(); + ratioAccOrig = L_add( ratioAccOrig, ratio ); // Q30 + move32(); + + /* Estimate MASA original energies and determine adjusted target energies and gained ratio for accumulation, if a gain is applied to MASA */ + IF( masaGainEdited ) + { + /* Gained MASA ratio */ + ratio = L_shl( Mpy_32_16_1( ratio, gainMasaPow2 ), 3 ); // Q = 30 + 9 - 15 + 3 = 27 + move32(); + + + /* Calculate MASA target energies and add to total target energy estimation */ + FOR( ch = 0; ch < 2; ch++ ) + { + /* MASA original energy per channel */ + masaEneThisCh[ch] = L_max( masaEneThisCh[ch], 0 ); // Q5 + move32(); + + /* MASA target energy per channel */ + temp = Mpy_32_16_1( masaEneThisCh[ch], shl( gainMasaPow2, 2 ) ); // Q = SubQ + 11 + 1 - 16 = SubQ-4 + masaTargetEneThisCh[ch] = L_shl( temp, 4 ); // SubQ + move32(); + + /* Reduce original energy per channel */ + totalTargetEneCh[ch] = L_sub( totalTargetEneCh[ch], masaEneThisCh[ch] ); // SubQ + move32(); + + /* Add target energy per channel */ + totalTargetEneCh[ch] = L_add( totalTargetEneCh[ch], masaTargetEneThisCh[ch] ); // SubQ + move32(); + } + ratioAccNew = L_add( ratioAccNew, ratio ); // Q27 + } + ELSE + { + ratioAccNew = L_add( ratioAccNew, L_shr( ratio, 3 ) ); // Q27 + } + +#ifdef OBJ_EDITING_PARAMISM_BIN + } +#endif + + +#ifdef NONBE_1399_1400_FIX_OBJ_EDIT_ISSUES + /* Limit target energies to non-negative values */ + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + totalTargetEneCh[ch] = L_max( 0, totalTargetEneCh[ch] ); + } +#endif + + /* due to rounding, the sum may exceed 1.0f ever so slightly, so clip it */ + ratioAccOrig = L_min( ratioAccOrig, ONE_IN_Q30 ); + move32(); + IF( masaGainEdited ) + { + temp = Mpy_32_16_1( L_sub( ONE_IN_Q30, ratioAccOrig ), gainMasaPow2 ); // Q = 30 + 9 + 1 - 16 = 24 + ratioAccNew = L_add_sat( ratioAccNew, L_shl_sat( temp, 3 ) ); // Q27 + move32(); + } + ELSE + { + ratioAccNew = L_add( ratioAccNew, L_shr( L_sub( ONE_IN_Q30, ratioAccOrig ), 3 ) ); // Q27 + move32(); + } + + + /* New target total energy ratio divider */ + IF( ratioAccNew > 0 ) + { + ratioAccNewDivisor = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q27, ratioAccNew, &temp_q ); + ratioAccNewDivisor = L_shl_sat( ratioAccNewDivisor, sub( temp_q, 4 ) ); // Q27, saturate to 16 in Q27 + + /* Determine and process object energy ratios based on gaining */ + FOR( ismDirIndex = 0; ismDirIndex < n_ism; ismDirIndex++ ) + { + newRatios[ismDirIndex + 2] = hMasaIsmData->energy_ratio_ism_fx[ismDirIndex][dirac_read_idx][bin_lo]; // Q30 + move32(); + + IF( ismGainEdited[ismDirIndex] ) + { + gainIsmThis = hMasaIsmData->gain_ism_edited_fx[ismDirIndex]; + move16(); + + /* Gain original object energy ratio, if edited */ + temp1 = mult( gainIsmThis, gainIsmThis ); // Q = 12 + 12 - 15 = 9 + newRatios[ismDirIndex + 2] = Mpy_32_16_1( newRatios[ismDirIndex + 2], temp1 ); // Q = 30 + 9 + 1 - 16 = 24 + move32(); + } + ELSE + { + newRatios[ismDirIndex + 2] = L_shr( newRatios[ismDirIndex + 2], 6 ); + move32(); + } + /* Divide with new target total ratio */ + newRatios[ismDirIndex + 2] = Mpy_32_32( newRatios[ismDirIndex + 2], ratioAccNewDivisor ); // Q = 24 + 27 - 31 = 20 + move32(); + } + + /* Determine and process MASA energy ratios based on gaining */ + newRatios[0] = hSpatParamRendCom->energy_ratio1_fx[dirac_read_idx][bin_lo]; // Q30 + newRatios[1] = hSpatParamRendCom->energy_ratio2_fx[dirac_read_idx][bin_lo]; // Q30 + move32(); + move32(); + + IF( masaGainEdited ) + { + newRatios[0] = Mpy_32_16_1( newRatios[0], gainMasaPow2 ); // Q = 30 + 9 + 1 - 16 = 24 + newRatios[1] = Mpy_32_16_1( newRatios[1], gainMasaPow2 ); // Q = 30 + 9 + 1 - 16 = 24 + move32(); + move32(); + } + ELSE + { + newRatios[0] = L_shr( newRatios[0], 6 ); // Q = 30 + 9 + 1 - 16 = 24 + newRatios[1] = L_shr( newRatios[0], 6 ); + move32(); + move32(); + } + newRatios[0] = Mpy_32_32( newRatios[0], ratioAccNewDivisor ); // Q = 24 + 27 - 31 = 20 + newRatios[1] = Mpy_32_32( newRatios[1], ratioAccNewDivisor ); // Q = 24 + 27 - 31 = 20 + move32(); + move32(); + + /* Set adjusted energy ratios */ + FOR( bin = bin_lo; bin < bin_hi; bin++ ) + { + FOR( ismDirIndex = 0; ismDirIndex < n_ism; ismDirIndex++ ) + { + hMasaIsmData->energy_ratio_ism_fx[ismDirIndex][dirac_read_idx][bin] = L_shl( newRatios[ismDirIndex + 2], 10 ); // Q30 + move32(); + } + + IF( masaIsmMode ) + { + hSpatParamRendCom->energy_ratio1_fx[dirac_read_idx][bin] = L_shl( newRatios[0], 10 ); + hSpatParamRendCom->energy_ratio2_fx[dirac_read_idx][bin] = L_shl( newRatios[1], 10 ); + move32(); + move32(); + } + } + } + + + /* Direction editing */ + /* Determine new energetic values after gaining */ + totalTargetEne = L_add( totalTargetEneCh[0], totalTargetEneCh[1] ); // SubQ + + IF( totalTargetEne > 0 ) + { + tempDivisor = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q28, max( EPSILON_FX, totalTargetEne ), &temp_q ); + + temp_q = sub( sub( Q31, temp_q ), sub( sub( Q31, Q28 ), sub( Q31, subQ ) ) ); + + normEnes[0] = Mpy_32_32( totalTargetEneCh[0], tempDivisor ); // Q = 25 + normEnes[1] = Mpy_32_32( totalTargetEneCh[1], tempDivisor ); // Q = 25 + temp_q = sub( add( subQ, temp_q ), Q31 ); + normEnes[0] = L_shl( normEnes[0], sub( Q25, temp_q ) ); + normEnes[1] = L_shl( normEnes[1], sub( Q25, temp_q ) ); + move32(); + move32(); + move32(); + move32(); + } + ELSE + { + normEnes[0] = 0; + normEnes[1] = 0; + move32(); + move32(); + } + + /* For each ismDir, determine moved and preserve energy ratio per channel */ + FOR( ismDirIndex = 0; ismDirIndex < n_ism; ismDirIndex++ ) + { + ratio = hMasaIsmData->energy_ratio_ism_fx[ismDirIndex][dirac_read_idx][bin_lo]; // Q30 + move32(); + + ismRatioAcc = L_add( ismRatioAcc, ratio ); // Q30 + + IF( enableCentering ) + { + temp1 = abs_s( sub( panEnesIn[ismDirIndex][0], panEnesOut[ismDirIndex][0] ) ); // 2*sub(enes) -> Q14 + centeringFactor = max( 0, sub( temp1, ONE_IN_Q14 ) ); // Q14 + + FOR( ch = 0; ch < 2; ch++ ) + { + temp1 = sub( ONE_IN_Q14, centeringFactor ); + panEnesOut[ismDirIndex][ch] = mult( panEnesOut[ismDirIndex][ch], temp1 ); // Q = 15 + 14 - 15 = 14 + move16(); + + temp1 = shr( centeringFactor, 1 ); // * 0.5f = Divide by 2 + panEnesOut[ismDirIndex][ch] = add( panEnesOut[ismDirIndex][ch], temp1 ); // Q14 + panEnesOut[ismDirIndex][ch] = shl( panEnesOut[ismDirIndex][ch], 1 ); // Q15 + move16(); + move16(); + } + } + + FOR( ch = 0; ch < 2; ch++ ) + { + eneMoveThis = s_max( 0, sub( panEnesIn[ismDirIndex][ch], panEnesOut[ismDirIndex][ch] ) ); // Q15 + move16(); + + enePreserveThis = sub( panEnesIn[ismDirIndex][ch], eneMoveThis ); // Q15 + move16(); + + temp = Mpy_32_16_1( ratio, eneMoveThis ); // Q = 30 + 15 + 1 - 16 = 30 + eneMove[ch] = L_add( eneMove[ch], temp ); // Q30 + move32(); + + temp = Mpy_32_16_1( ratio, enePreserveThis ); // Q = 30 + 15 + 1 - 16 = 30 + enePreserve[ch] = L_add( enePreserve[ch], temp ); // 30 + move32(); + + /* Subtract object parts from normEnes */ + temp = Mpy_32_16_1( L_shr( ratio, 5 ), panEnesIn[ismDirIndex][ch] ); // Q = 25 + 15 + 1 = 16 = 25; + normEnes[ch] = L_sub( normEnes[ch], temp ); // Q25 + move32(); + } + } + + /* Any remaining (non-object) energy is set to be preserved at both channels */ + temp = L_sub( ONE_IN_Q25, L_shr( ismRatioAcc, 5 ) ); + temp = L_sub( temp, normEnes[0] ); + temp = L_sub( temp, normEnes[1] ); + remainderNormEne = L_max( 0, temp ); // Q25 + + /* Normalize */ + FOR( ch = 0; ch < 2; ch++ ) + { + temp = L_shr( remainderNormEne, 1 ); // Division by 2, Q25 + temp = L_add( normEnes[ch], temp ); // Q25 + enePreserve[ch] = L_add( L_shr( enePreserve[ch], 5 ), L_max( 0, temp ) ); // Q25 + + temp = L_add( L_shr( eneMove[ch], 5 ), enePreserve[ch] ); // Q25 + temp = L_max( EPSILON_FX, temp ); + normVal = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q25, temp, &temp_q ); + normVal = L_shl_sat( normVal, sub( temp_q, 6 ) ); // Q25 + + temp = L_max( EPSILON_FX, subframeEneCh[ch] ); // SubQ + temp = BASOP_Util_Divide3232_Scale_newton( totalTargetEneCh[ch], temp, &temp_q ); + temp = L_shl_sat( temp, sub( temp_q, 6 ) ); // Q25 + normVal = Mpy_32_32( normVal, L_min( 335544320, temp ) ); // Q = 25 + 25 + 1 - 32 = 19 + + eneMove[ch] = Mpy_32_32( eneMove[ch], normVal ); // Q = 30 + 19 + 1 - 32 = 18 + move32(); + + enePreserve[ch] = Mpy_32_32( L_shl_sat( enePreserve[ch], 5 ), normVal ); // Q = 30 + 19 + 1 - 32 = 18 + move32(); + + enePreserve[ch] = L_shl_sat( enePreserve[ch], 8 ); // Q26 + eneMove[ch] = L_shl_sat( eneMove[ch], 8 ); // Q26 + move32(); + move32(); + } + + /* Temporally average target energy */ + hMasaIsmData->eneOrigIIR_fx[band_idx] = Mpy_32_16_1( hMasaIsmData->eneOrigIIR_fx[band_idx], STEREO_PREPROCESS_IIR_FACTOR_Q15 ); // Q = origIIR_Q + 15 + 1 - 16 = origIIR_Q + hMasaIsmData->eneOrigIIR_fx[band_idx] = BASOP_Util_Add_Mant32Exp( hMasaIsmData->eneOrigIIR_fx[band_idx], hMasaIsmData->eneOrigIIR_e[band_idx], totalTargetEne, sub( Q31, subQ ), &hMasaIsmData->eneOrigIIR_e[band_idx] ); + move32(); + move32(); + + /* Temporally average energy moving and preserving, and generate the transport signal preprocessing matrix for + * gaining objects and moving objects between left and right */ + FOR( ch = 0; ch < 2; ch++ ) + { + hMasaIsmData->eneMoveIIR_fx[ch][band_idx] = Mpy_32_16_1( hMasaIsmData->eneMoveIIR_fx[ch][band_idx], STEREO_PREPROCESS_IIR_FACTOR_Q15 ); // Q = Enemove_Q + 15 + 1 -16 = Enemove_Q + move32(); + + temp = Mpy_32_32( totalTargetEne, eneMove[ch] ); // Q = SubQ + 26 + 1 - 32 = SubQ-5 + shift = norm_l( temp ); + temp = L_shl( temp, shift ); // Q = subQ-5+shift + hMasaIsmData->eneMoveIIR_fx[ch][band_idx] = BASOP_Util_Add_Mant32Exp( hMasaIsmData->eneMoveIIR_fx[ch][band_idx], hMasaIsmData->eneMoveIIR_e[ch][band_idx], temp, sub( Q31, add( sub( subQ, 5 ), shift ) ), &hMasaIsmData->eneMoveIIR_e[ch][band_idx] ); + move32(); + + hMasaIsmData->enePreserveIIR_fx[ch][band_idx] = Mpy_32_16_1( hMasaIsmData->enePreserveIIR_fx[ch][band_idx], STEREO_PREPROCESS_IIR_FACTOR_Q15 ); // Q = enePreserve_Q + 15 + 1 - 16 = enePreserve_Q = 31- enePreserve_e + move32(); + + temp = Mpy_32_32( totalTargetEne, enePreserve[ch] ); // Q = subQ + 26 + 1 - 32 = subQ-5 + shift = norm_l( temp ); + temp = L_shl( temp, shift ); // Q = subQ-5+shift + hMasaIsmData->enePreserveIIR_fx[ch][band_idx] = BASOP_Util_Add_Mant32Exp( hMasaIsmData->enePreserveIIR_fx[ch][band_idx], hMasaIsmData->enePreserveIIR_e[ch][band_idx], temp, sub( Q31, add( sub( subQ, 5 ), shift ) ), &hMasaIsmData->enePreserveIIR_e[ch][band_idx] ); + move32(); + + temp_q = norm_l( hMasaIsmData->enePreserveIIR_fx[ch][band_idx] ); + hMasaIsmData->enePreserveIIR_fx[ch][band_idx] = L_shl( hMasaIsmData->enePreserveIIR_fx[ch][band_idx], temp_q ); + hMasaIsmData->enePreserveIIR_e[ch][band_idx] = sub( hMasaIsmData->enePreserveIIR_e[ch][band_idx], temp_q ); + move32(); + move32(); + + IF( hMasaIsmData->enePreserveIIR_fx[ch][band_idx] > 0 ) + { + temp = BASOP_Util_Divide3232_Scale_newton( hMasaIsmData->enePreserveIIR_fx[ch][band_idx], L_max( 1, hMasaIsmData->eneOrigIIR_fx[band_idx] ), &temp_q ); + temp_q = sub( Q31, sub( sub( Q31, temp_q ), sub( hMasaIsmData->enePreserveIIR_e[ch][band_idx], hMasaIsmData->eneOrigIIR_e[band_idx] ) ) ); + temp = Sqrt32( temp, &temp_q ); // Q = 31-temp_q + temp = L_shl_sat( temp, sub( temp_q, 3 ) ); // Q28 + } + ELSE + { + temp = 0; + move32(); + } + + IF( GT_32( ONE_IN_Q30, temp ) ) + { + ismPreprocMtxNew[ch][ch] = temp; + move32(); + } + ELSE + { + ismPreprocMtxNew[ch][ch] = ONE_IN_Q30; // 4 in Q28 + move32(); + } + + ismPreprocMtxNew_e[ch][ch] = Q28; + move32(); + + temp_q = norm_l( hMasaIsmData->eneMoveIIR_fx[ch][band_idx] ); + hMasaIsmData->eneMoveIIR_fx[ch][band_idx] = L_shl( hMasaIsmData->eneMoveIIR_fx[ch][band_idx], temp_q ); + hMasaIsmData->eneMoveIIR_e[ch][band_idx] = sub( hMasaIsmData->eneMoveIIR_e[ch][band_idx], temp_q ); + move32(); + move16(); + + IF( hMasaIsmData->eneMoveIIR_fx[ch][band_idx] > 0 ) + { + temp = BASOP_Util_Divide3232_Scale_newton( hMasaIsmData->eneMoveIIR_fx[ch][band_idx], L_max( 1, hMasaIsmData->eneOrigIIR_fx[band_idx] ), &temp_q ); + temp_q = sub( Q31, sub( sub( Q31, temp_q ), sub( hMasaIsmData->eneMoveIIR_e[ch][band_idx], hMasaIsmData->eneOrigIIR_e[band_idx] ) ) ); + temp = Sqrt32( temp, &temp_q ); + temp = L_shl_sat( temp, sub( temp_q, 3 ) ); // Q28 + } + ELSE + { + temp = 0; + move32(); + } + + IF( GT_32( ONE_IN_Q30, temp ) ) + { + ismPreprocMtxNew[1 - ch][ch] = temp; + move32(); + } + ELSE + { + ismPreprocMtxNew[1 - ch][ch] = ONE_IN_Q30; // 4 in Q28 + move32(); + } + ismPreprocMtxNew_e[1 - ch][ch] = Q28; // This may be removed + move32(); + } + + /* Get increment value for temporal interpolation */ + FOR( inCh = 0; inCh < 2; inCh++ ) + { + FOR( outCh = 0; outCh < 2; outCh++ ) + { + temp = L_sub( ismPreprocMtxNew[outCh][inCh], hMasaIsmData->ismPreprocMatrix_fx[outCh][inCh][band_idx] ); // Q28 + ismPreprocMtxIncrement[outCh][inCh] = L_shr( temp, 2 ); // Divide by 4 + move32(); + } + } + + /* Mix signals */ + hMasaIsmData->preprocEneTarget_fx[band_idx] = Mpy_32_16_1( hMasaIsmData->preprocEneTarget_fx[band_idx], STEREO_PREPROCESS_IIR_FACTOR_Q15 ); // Q = preprocEneTarget_e + move32(); + + hMasaIsmData->preprocEneRealized_fx[band_idx] = Mpy_32_16_1( hMasaIsmData->preprocEneRealized_fx[band_idx], STEREO_PREPROCESS_IIR_FACTOR_Q15 ); // Q = preprocEneRealized_e + move32(); + + hMasaIsmData->preprocEneTarget_fx[band_idx] = BASOP_Util_Add_Mant32Exp( hMasaIsmData->preprocEneTarget_fx[band_idx], hMasaIsmData->preprocEneTarget_e[band_idx], totalTargetEne, sub( Q31, subQ ), &hMasaIsmData->preprocEneTarget_e[band_idx] ); // Q = 31-preprocEneTarget_e + move32(); + + FOR( outCh = 0; outCh < 2; outCh++ ) + { + FOR( slot = 0; slot < nSlots; slot++ ) + { + FOR( inCh = 0; inCh < 2; inCh++ ) + { + hMasaIsmData->ismPreprocMatrix_fx[outCh][inCh][band_idx] = L_add( hMasaIsmData->ismPreprocMatrix_fx[outCh][inCh][band_idx], ismPreprocMtxIncrement[outCh][inCh] ); // Q28 + move32(); + + FOR( bin = bin_lo; bin < bin_hi; bin++ ) + { + temp = Mpy_32_32( inRe_fx[inCh][slot][bin], hMasaIsmData->ismPreprocMatrix_fx[outCh][inCh][band_idx] ); // Q = q_cldfb* + 28 - 31 = q_cldfb - 3 + outSlotRe[outCh][slot][bin] = L_add( outSlotRe[outCh][slot][bin], L_shl( temp, 3 ) ); // Q = q_cldfb* + move32(); + + temp = Mpy_32_32( inIm_fx[inCh][slot][bin], hMasaIsmData->ismPreprocMatrix_fx[outCh][inCh][band_idx] ); // Q = q_cldfb* + 28 - 31 = q_cldfb*-3 + outSlotIm[outCh][slot][bin] = L_add( outSlotIm[outCh][slot][bin], L_shl( temp, 3 ) ); // Q = q_cldfb* + move32(); + } + } + + FOR( bin = bin_lo; bin < bin_hi; bin++ ) + { + Word32 instEne_fx; + temp64 = W_mult0_32_32( outSlotRe[outCh][slot][bin], outSlotRe[outCh][slot][bin] ); // 2q-3 + temp64 = W_add( temp64, W_mult0_32_32( outSlotIm[outCh][slot][bin], outSlotIm[outCh][slot][bin] ) ); // 2q-3 + exp1 = W_norm( temp64 ); + instEne_fx = W_extract_h( W_shl( temp64, exp1 ) ); // 2*cldfb_buf_q - 32 + exp1 + exp1 = 31 - ( 2 * ( *cldfb_buf_q ) - 32 + exp1 ); + + hMasaIsmData->preprocEneRealized_fx[band_idx] = BASOP_Util_Add_Mant32Exp( hMasaIsmData->preprocEneRealized_fx[band_idx], hMasaIsmData->preprocEneRealized_e[band_idx], instEne_fx, exp1, &hMasaIsmData->preprocEneRealized_e[band_idx] ); // Q= *cldfb_buf_q + *cldfb_buf_q - 31 = Q-19); + move32(); + } + } + } + + + test(); + IF( hMasaIsmData->preprocEneTarget_fx[band_idx] > 0 && hMasaIsmData->preprocEneRealized_fx[band_idx] > 0 ) + { + temp = BASOP_Util_Divide3232_Scale_newton( hMasaIsmData->preprocEneTarget_fx[band_idx], L_max( 1, hMasaIsmData->preprocEneRealized_fx[band_idx] ), &temp_q ); + temp_q = sub( Q31, sub( sub( Q31, temp_q ), sub( hMasaIsmData->preprocEneTarget_e[band_idx], hMasaIsmData->preprocEneRealized_e[band_idx] ) ) ); + temp = Sqrt32( temp, &temp_q ); // Q: 31-temp_q + temp = L_shl( temp, sub( temp_q, 3 ) ); // Q28 + temp_q = Q28; + move16(); + } + ELSE + { + temp = 0; + move32(); + } + + IF( GT_32( ONE_IN_Q30, temp ) ) + { + eqVal = temp; + move32(); + } + ELSE + { + eqVal = ONE_IN_Q30; // 4 in Q28 + move32(); + } + + FOR( ch = 0; ch < 2; ch++ ) + { + FOR( slot = 0; slot < nSlots; slot++ ) + { + FOR( bin = bin_lo; bin < bin_hi; bin++ ) + { + temp = Mpy_32_32( outSlotRe[ch][slot][bin], eqVal ); // Q = (cldfb_q) + 28 -31 = cldfb_q - 3 + inRe_fx[ch][slot][bin] = L_shl_sat( temp, 3 ); + move32(); + + temp = Mpy_32_32( outSlotIm[ch][slot][bin], eqVal ); // Q = (cldfb_q) + 28 -31 = cldfb_q - 3 + inIm_fx[ch][slot][bin] = L_shl_sat( temp, 3 ); + move32(); + } + } + } + } + +#ifdef OBJ_EDITING_PARAMISM_BIN + IF( !masaIsmMode ) + { + Word16 obj_idx1, obj_idx2; + + FOR( band_idx = 0; band_idx < hParamIsmDec->hParamIsm->nbands; band_idx++ ) + { + bin_lo = hParamIsmDec->hParamIsm->band_grouping[band_idx]; + bin_hi = hParamIsmDec->hParamIsm->band_grouping[band_idx + 1]; + move16(); + move16(); + + obj_idx1 = hParamIsmDec->hParamIsm->obj_indices[band_idx][0][0]; + obj_idx2 = hParamIsmDec->hParamIsm->obj_indices[band_idx][0][1]; + move16(); + move16(); + + FOR( bin = bin_lo; bin < bin_hi; bin++ ) + { + hSpatParamRendCom->energy_ratio1_fx[dirac_read_idx][bin] = hMasaIsmData->energy_ratio_ism_fx[obj_idx1][dirac_read_idx][bin]; + hSpatParamRendCom->energy_ratio2_fx[dirac_read_idx][bin] = hMasaIsmData->energy_ratio_ism_fx[obj_idx2][dirac_read_idx][bin]; + move32(); + move32(); + } + } + } +#endif + } + + return; +} +#else +/*-------------------------------------------------------------------* + * ivas_omasa_preProcessStereoTransportsForMovedObjects_fx() + * + * + *-------------------------------------------------------------------*/ + +void ivas_omasa_preProcessStereoTransportsForMovedObjects_fx( + Decoder_Struct *st_ivas, + Word32 inRe_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /*cldfb_buf_q*/ + Word32 inIm_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /*cldfb_buf_q*/ + Word16 *cldfb_buf_q, + const Word16 nBins, + const Word16 subframe ) +{ + Word16 bin, ch, inCh, outCh, ismDirIndex, slot; + SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; + MASA_ISM_DATA_HANDLE hMasaIsmData; + UWord8 enableCentering; + Word16 dirac_read_idx; + Word16 nSlots; + + hSpatParamRendCom = st_ivas->hSpatParamRendCom; + hMasaIsmData = st_ivas->hMasaIsmData; + + test(); + test(); + IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) || EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA2 ) || EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA3 ) ) + { + enableCentering = 0; + move16(); + } + ELSE + { + enableCentering = 1; + move16(); + } + + /* Bypass processing until first object is moved */ + IF( hMasaIsmData->objectsMoved == 0 ) + { + FOR( ismDirIndex = 0; ismDirIndex < hSpatParamRendCom->numIsmDirections; ismDirIndex++ ) + { + if ( hMasaIsmData->ism_is_edited[ismDirIndex] ) + { + hMasaIsmData->objectsMoved = 1; + move16(); + } + } + IF( hMasaIsmData->objectsMoved == 0 ) + { + /* No objects have moved so far */ + return; + } + } + /* Perform object-movement based processing */ nSlots = hSpatParamRendCom->subframe_nbslots[subframe]; move16(); @@ -5954,7 +7004,6 @@ void ivas_omasa_preProcessStereoTransportsForMovedObjects_fx( } #endif - static void ivas_masa_ext_rend_parambin_internal_fx( MASA_EXT_REND_HANDLE hMasaExtRend, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, @@ -6319,7 +7368,6 @@ static void ivas_masa_ext_rend_parambin_internal_fx( return; } - void ivas_masa_ext_rend_parambin_render_fx( MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA ext rend structure */ COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index 13331d2c6..d56a9ef44 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -2854,9 +2854,9 @@ void ivas_dirac_dec_compute_directional_responses_fx( FOR( dir = 0; dir < hSpatParamRendCom->numIsmDirections; dir++ ) { #ifdef OMASA_OBJECT_EDITING - IF( hMasaIsm->ism_dir_is_edited[dir] ) + IF( hMasaIsm->ism_dir_is_edited_fx[dir] ) { - ivas_dirac_dec_get_response_fx( hMasaIsm->azimuth_ism_edited[dir], hMasaIsm->elevation_ism_edited[dir], direct_response_temp_fx, hDirACRend->hOutSetup.ambisonics_order, Q29 ); + ivas_dirac_dec_get_response_fx( hMasaIsm->azimuth_ism_edited_fx[dir], hMasaIsm->elevation_ism_edited_fx[dir], direct_response_temp_fx, hDirACRend->hOutSetup.ambisonics_order, Q29 ); } #else IF( hMasaIsm->ism_is_edited[dir] ) @@ -3112,9 +3112,9 @@ void ivas_dirac_dec_compute_directional_responses_fx( FOR( dir = 0; dir < hSpatParamRendCom->numIsmDirections; dir++ ) { #ifdef OMASA_OBJECT_EDITING - IF( hMasaIsm->ism_dir_is_edited[dir] ) + IF( hMasaIsm->ism_dir_is_edited_fx[dir] ) { - vbap_determine_gains_fx( hVBAPdata, direct_response_temp_fx, hMasaIsm->azimuth_ism_edited[dir], hMasaIsm->elevation_ism_edited[dir], 1 ); + vbap_determine_gains_fx( hVBAPdata, direct_response_temp_fx, hMasaIsm->azimuth_ism_edited_fx[dir], hMasaIsm->elevation_ism_edited_fx[dir], 1 ); } #else IF( hMasaIsm->ism_is_edited[dir] ) diff --git a/lib_rend/ivas_objectRenderer_fx.c b/lib_rend/ivas_objectRenderer_fx.c index 3d5818325..7dac50d18 100644 --- a/lib_rend/ivas_objectRenderer_fx.c +++ b/lib_rend/ivas_objectRenderer_fx.c @@ -650,7 +650,7 @@ ivas_error TDREND_Update_object_positions_fx( } #endif #ifdef OBJ_EDITING_INTERFACE - if ( ( error = TDREND_MIX_SRC_SetGain( hBinRendererTd, nS, hIsmMetaData[nS]->gain ) ) != IVAS_ERR_OK ) + if ( ( error = TDREND_MIX_SRC_SetGain( hBinRendererTd, nS, hIsmMetaData[nS]->gain_fx ) ) != IVAS_ERR_OK ) // TODO: Check Gain has correct Q-value { return error; } @@ -962,7 +962,7 @@ ivas_error ivas_td_binaural_renderer_ext_fx( hIsmMetaData[0]->radius_fx = currentPos->radius_fx; move32(); #ifdef OBJ_EDITING_INTERFACE - hIsmMetaData[0]->gain = ONE_IN_Q30; // TODO: check Q value + hIsmMetaData[0]->gain_fx = ONE_IN_Q30; // TODO: check Q value #endif hIsmMetaData[0]->non_diegetic_flag = currentPos->non_diegetic_flag; move16(); diff --git a/lib_rend/ivas_objectRenderer_sources_fx.c b/lib_rend/ivas_objectRenderer_sources_fx.c index bce7ce409..138453e88 100644 --- a/lib_rend/ivas_objectRenderer_sources_fx.c +++ b/lib_rend/ivas_objectRenderer_sources_fx.c @@ -50,7 +50,7 @@ static Word16 TDREND_SRC_SPATIAL_GetDistGain_fx( const TDREND_DistAtten_t *DistA static void TDREND_SRC_SPATIAL_SetDirAtten_fx( TDREND_SRC_SPATIAL_t *SrcSpatial_p, const TDREND_DirAtten_t *DirAtten_p ); static void TDREND_SRC_SPATIAL_SetDistAtten( TDREND_SRC_SPATIAL_t *SrcSpatial_p, const TDREND_DistAtten_t *DistAtten_p ); #ifdef OBJ_EDITING_INTERFACE -static void TDREND_SRC_SPATIAL_SetGain( const TDREND_SRC_t *Src_p, const float Gain ); +static void TDREND_SRC_SPATIAL_SetGain( const TDREND_SRC_t *Src_p, const Word32 Gain ); #endif static ivas_error TDREND_SRC_REND_Alloc( TDREND_SRC_REND_t **SrcRend_pp ); static void TDREND_SRC_SPATIAL_Dealloc( TDREND_SRC_SPATIAL_t *SrcSpatial_p ); @@ -141,8 +141,8 @@ ivas_error TDREND_MIX_SRC_SetDir_fx( ivas_error TDREND_MIX_SRC_SetGain( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - const int16_t SrcInd, /* i : Source index */ - const float Gain /* i : Gain */ + const Word16 SrcInd, /* i : Source index */ + const Word32 Gain /* i : Gain */ ) { TDREND_SRC_SPATIAL_SetGain( hBinRendererTd->Sources[SrcInd], Gain ); @@ -710,10 +710,10 @@ static void TDREND_SRC_SPATIAL_SetDistAtten( static void TDREND_SRC_SPATIAL_SetGain( const TDREND_SRC_t *Src_p, /* i : Directional attenuation specification */ - const float Gain /* i : Front-pointing vector */ + const Word32 Gain /* i : Front-pointing vector */ ) { - Src_p->SrcRend_p->SrcGain_p[0] = Gain; + Src_p->SrcRend_p->SrcGain_p_fx[0] = extract_h( Gain ); // Check incoming Q-value } #endif diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index 97772fc78..ebb8cc715 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -781,8 +781,8 @@ ivas_error TDREND_MIX_SRC_SetDir_fx( #ifdef OBJ_EDITING_INTERFACE ivas_error TDREND_MIX_SRC_SetGain( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - const int16_t SrcInd, /* i : Source index */ - const float Gain /* i : Gain */ + const Word16 SrcInd, + const Word32 Gain /* i : Gain */ ); #endif @@ -804,6 +804,13 @@ ivas_error TDREND_MIX_SRC_SetPlayState( const TDREND_PlayStatus_t PlayStatus /* i : Play state */ ); +#ifdef OBJ_EDITING_API +// ivas_error TDREND_SRC_SPATIAL_SetGain( +// BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ +// const Word32 SrcGain_p /* i : Source gain */ +// ); +#endif + void TDREND_SRC_REND_UpdateFiltersFromSpatialParams_fx( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ TDREND_SRC_REND_t *SrcRend_p, /* i/o: Source object */ diff --git a/lib_util/ism_file_reader.c b/lib_util/ism_file_reader.c index f3d782aeb..f27e34634 100644 --- a/lib_util/ism_file_reader.c +++ b/lib_util/ism_file_reader.c @@ -160,7 +160,7 @@ ivas_error IsmFileReader_readNextFrame( ismMetadata->elevation_fx = floatToFixed( meta_prm[1], Q22 ); ismMetadata->radius_fx = (Word16) floatToFixed( meta_prm[2], Q9 ); ismMetadata->spread_fx = floatToFixed( meta_prm[3], Q22 ); - ismMetadata->gainFactor_fx = floatToFixed( meta_prm[4], Q31 ); + ismMetadata->gainFactor_fx = floatToFixed( meta_prm[4], Q31 ); // TODO: Check correct Q value ismMetadata->yaw_fx = floatToFixed( meta_prm[5], Q22 ); ismMetadata->pitch_fx = floatToFixed( meta_prm[6], Q22 ); diff --git a/lib_util/ism_file_writer.c b/lib_util/ism_file_writer.c index 94bab6dd2..10c4332ea 100644 --- a/lib_util/ism_file_writer.c +++ b/lib_util/ism_file_writer.c @@ -118,7 +118,7 @@ ivas_error IsmFileWriter_writeFrame( ismMetadata.elevation = fixedToFloat( ismMetadata.elevation_fx, Q22 ); ismMetadata.radius = fix16_to_float( ismMetadata.radius_fx, Q9 ); ismMetadata.spread = fixedToFloat( ismMetadata.spread_fx, Q22 ); - ismMetadata.gainFactor = fixedToFloat( ismMetadata.gainFactor_fx, Q31 ); + ismMetadata.gainFactor = fixedToFloat( ismMetadata.gainFactor_fx, Q31 ); // TODO: Change to Q28 or Q12? ismMetadata.yaw = fixedToFloat( ismMetadata.yaw_fx, Q22 ); ismMetadata.pitch = fixedToFloat( ismMetadata.pitch_fx, Q22 ); -- GitLab From ae4d78ba080dc2c3bab3a395550e3e6fe83b7acb Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 16 Oct 2025 10:21:28 +0200 Subject: [PATCH 14/31] apply missing renames fixed -> fx --- lib_dec/ivas_ism_param_dec_fx.c | 2 +- lib_dec/ivas_omasa_dec_fx.c | 6 +++--- lib_dec/lib_dec_fx.c | 2 +- lib_rend/ivas_dirac_dec_binaural_functions_fx.c | 12 ++++++------ 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index f9b9cf183..6a6173c3c 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -1050,7 +1050,7 @@ void ivas_ism_dec_digest_tc_fx( efap_determine_gains_fx( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains_fx[i], azimuth_fx, elevation_fx, EFAP_MODE_EFAP ); #ifdef OBJ_EDITING_API // TODO: align Q values properly - v_multc_fixed( st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIsmMetaData[i]->edited_gain_fx, st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hEFAPdata->numSpk ); + v_multc_fx( st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIsmMetaData[i]->edited_gain_fx, st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hEFAPdata->numSpk ); #endif } } diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index 358efb5d9..fbd7f3a37 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -1181,7 +1181,7 @@ void ivas_omasa_dirac_rend_jbm_fx( test(); IF( st_ivas->hMasaIsmData->ism_gain_is_edited_fx[n] && EQ_16( st_ivas->hMasaIsmData->idx_separated_ism, n ) ) { - v_multc_fixed_16( data_separated_objects[0], st_ivas->hMasaIsmData->gain_ism_edited_fx[n], data_separated_objects[0], *nSamplesRendered ); // Q = 8 + v_multc_fx_16( data_separated_objects[0], st_ivas->hMasaIsmData->gain_ism_edited_fx[n], data_separated_objects[0], *nSamplesRendered ); // Q = 8 Scale_sig32( data_separated_objects[0], *nSamplesRendered, Q3 ); // Q = 11 } } @@ -1197,7 +1197,7 @@ void ivas_omasa_dirac_rend_jbm_fx( /* Gain discrete objects, if edited */ IF( st_ivas->hMasaIsmData->ism_gain_is_edited_fx[n] ) { - v_multc_fixed_16( data_separated_objects[n], st_ivas->hMasaIsmData->gain_ism_edited_fx[n], data_separated_objects[n], *nSamplesRendered ); // Q = 8 + v_multc_fx_16( data_separated_objects[n], st_ivas->hMasaIsmData->gain_ism_edited_fx[n], data_separated_objects[n], *nSamplesRendered ); // Q = 8 Scale_sig32( data_separated_objects[n], *nSamplesRendered, Q3 ); // Q = 11 } #endif @@ -1208,7 +1208,7 @@ void ivas_omasa_dirac_rend_jbm_fx( { FOR( n = 0; n < 2; n++ ) { - v_multc_fixed_16( output_f[n], st_ivas->hMasaIsmData->gain_masa_edited_fx, output_f[n], *nSamplesRendered ); // Q = 8 + v_multc_fx_16( output_f[n], st_ivas->hMasaIsmData->gain_masa_edited_fx, output_f[n], *nSamplesRendered ); // Q = 8 Scale_sig32( output_f[n], *nSamplesRendered, Q3 ); // Q = 11 } } diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 7866e329d..0d0177379 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -3975,7 +3975,7 @@ ivas_error IVAS_DEC_GetEditableParameters( IVAS_DEC_HANDLE hIvasDec, IVAS_EDITABLE_PARAMETERS *hIvasEditableParameters ) { - Word16 obj; + Word16 obj, dirac_read_idx; Decoder_Struct *st_ivas; ISM_MODE ism_mode; diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index ba21791b4..8777df227 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -5071,8 +5071,8 @@ static void getDirectPartGains_fx( } /* Scaling to have the same expected gain as for the HRTF rendering */ - *lRealp = Mpy_32_32( *lRealp, SQRT2_FIXED ); // Q30 - *rRealp = Mpy_32_32( *rRealp, SQRT2_FIXED ); // Q30 + *lRealp = Mpy_32_32( *lRealp, SQRT2_FX ); // Q30 + *rRealp = Mpy_32_32( *rRealp, SQRT2_FX ); // Q30 *lRealp = L_shr( *lRealp, 2 ); // Q28 *rRealp = L_shr( *rRealp, 2 ); // Q28 @@ -5518,10 +5518,10 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( gain = st_ivas->hMasaIsmData->gain_ism_edited_fx[ch]; move32(); - v_multc_fixed_16( inRe_fx[ch + 2][slot], gain, inRe_fx[ch + 2][slot], nBins ); // Q = *cldfb_buf_q - 3 + v_multc_fx_16( inRe_fx[ch + 2][slot], gain, inRe_fx[ch + 2][slot], nBins ); // Q = *cldfb_buf_q - 3 Scale_sig32( inRe_fx[ch + 2][slot], nBins, Q3 ); // Q = *cldfb_buf_q - v_multc_fixed_16( inIm_fx[ch + 2][slot], gain, inIm_fx[ch + 2][slot], nBins ); // Q = *cldfb_buf_q - 3 + v_multc_fx_16( inIm_fx[ch + 2][slot], gain, inIm_fx[ch + 2][slot], nBins ); // Q = *cldfb_buf_q - 3 Scale_sig32( inIm_fx[ch + 2][slot], nBins, Q3 ); // Q = *cldfb_buf_q } } @@ -5538,10 +5538,10 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( gain_masa = st_ivas->hMasaIsmData->gain_masa_edited_fx; move32(); - v_multc_fixed_16( inRe_fx[ch][slot], gain_masa, inRe_fx[ch][slot], nBins ); // Q = *cldfb_buf_q - 3 + v_multc_fx_16( inRe_fx[ch][slot], gain_masa, inRe_fx[ch][slot], nBins ); // Q = *cldfb_buf_q - 3 Scale_sig32( inRe_fx[ch][slot], nBins, Q3 ); // Q = *cldfb_buf_q - v_multc_fixed_16( inIm_fx[ch][slot], gain_masa, inIm_fx[ch][slot], nBins ); // Q = *cldfb_buf_q - 3 + v_multc_fx_16( inIm_fx[ch][slot], gain_masa, inIm_fx[ch][slot], nBins ); // Q = *cldfb_buf_q - 3 Scale_sig32( inIm_fx[ch][slot], nBins, Q3 ); // Q = *cldfb_buf_q } } -- GitLab From f135f2809a95f308d3b5a2d81447b66fd76770b5 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 16 Oct 2025 10:48:36 +0200 Subject: [PATCH 15/31] fix formatting --- lib_dec/ivas_jbm_dec_fx.c | 2 +- lib_dec/ivas_omasa_dec_fx.c | 6 +++--- lib_rend/ivas_dirac_dec_binaural_functions_fx.c | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 56287fe85..4c48ac4e8 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -4703,7 +4703,7 @@ void ivas_jbm_dec_prepare_renderer( FOR( n = 0; n < 2; n++ ) { v_multc_fx_16( st_ivas->hTcBuffer->tc_fx[n], st_ivas->hMasaIsmData->gain_masa_edited_fx, st_ivas->hTcBuffer->tc_fx[n], st_ivas->hTcBuffer->n_samples_available ); // Q8 - Scale_sig32( st_ivas->hTcBuffer->tc_fx[n], st_ivas->hTcBuffer->n_samples_available, Q3 ); // Q8 -> Q11 + Scale_sig32( st_ivas->hTcBuffer->tc_fx[n], st_ivas->hTcBuffer->n_samples_available, Q3 ); // Q8 -> Q11 } } } diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index fbd7f3a37..52e818926 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -1182,7 +1182,7 @@ void ivas_omasa_dirac_rend_jbm_fx( IF( st_ivas->hMasaIsmData->ism_gain_is_edited_fx[n] && EQ_16( st_ivas->hMasaIsmData->idx_separated_ism, n ) ) { v_multc_fx_16( data_separated_objects[0], st_ivas->hMasaIsmData->gain_ism_edited_fx[n], data_separated_objects[0], *nSamplesRendered ); // Q = 8 - Scale_sig32( data_separated_objects[0], *nSamplesRendered, Q3 ); // Q = 11 + Scale_sig32( data_separated_objects[0], *nSamplesRendered, Q3 ); // Q = 11 } } } @@ -1198,7 +1198,7 @@ void ivas_omasa_dirac_rend_jbm_fx( IF( st_ivas->hMasaIsmData->ism_gain_is_edited_fx[n] ) { v_multc_fx_16( data_separated_objects[n], st_ivas->hMasaIsmData->gain_ism_edited_fx[n], data_separated_objects[n], *nSamplesRendered ); // Q = 8 - Scale_sig32( data_separated_objects[n], *nSamplesRendered, Q3 ); // Q = 11 + Scale_sig32( data_separated_objects[n], *nSamplesRendered, Q3 ); // Q = 11 } #endif } @@ -1209,7 +1209,7 @@ void ivas_omasa_dirac_rend_jbm_fx( FOR( n = 0; n < 2; n++ ) { v_multc_fx_16( output_f[n], st_ivas->hMasaIsmData->gain_masa_edited_fx, output_f[n], *nSamplesRendered ); // Q = 8 - Scale_sig32( output_f[n], *nSamplesRendered, Q3 ); // Q = 11 + Scale_sig32( output_f[n], *nSamplesRendered, Q3 ); // Q = 11 } } #endif diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 8777df227..a0bf43d0b 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -5519,10 +5519,10 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( move32(); v_multc_fx_16( inRe_fx[ch + 2][slot], gain, inRe_fx[ch + 2][slot], nBins ); // Q = *cldfb_buf_q - 3 - Scale_sig32( inRe_fx[ch + 2][slot], nBins, Q3 ); // Q = *cldfb_buf_q + Scale_sig32( inRe_fx[ch + 2][slot], nBins, Q3 ); // Q = *cldfb_buf_q v_multc_fx_16( inIm_fx[ch + 2][slot], gain, inIm_fx[ch + 2][slot], nBins ); // Q = *cldfb_buf_q - 3 - Scale_sig32( inIm_fx[ch + 2][slot], nBins, Q3 ); // Q = *cldfb_buf_q + Scale_sig32( inIm_fx[ch + 2][slot], nBins, Q3 ); // Q = *cldfb_buf_q } } } @@ -5539,10 +5539,10 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( move32(); v_multc_fx_16( inRe_fx[ch][slot], gain_masa, inRe_fx[ch][slot], nBins ); // Q = *cldfb_buf_q - 3 - Scale_sig32( inRe_fx[ch][slot], nBins, Q3 ); // Q = *cldfb_buf_q + Scale_sig32( inRe_fx[ch][slot], nBins, Q3 ); // Q = *cldfb_buf_q v_multc_fx_16( inIm_fx[ch][slot], gain_masa, inIm_fx[ch][slot], nBins ); // Q = *cldfb_buf_q - 3 - Scale_sig32( inIm_fx[ch][slot], nBins, Q3 ); // Q = *cldfb_buf_q + Scale_sig32( inIm_fx[ch][slot], nBins, Q3 ); // Q = *cldfb_buf_q } } } -- GitLab From 2e2bdc86ccd5c6878496fcb793f5c4d519779cd2 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 16 Oct 2025 10:54:04 +0200 Subject: [PATCH 16/31] fix windows build errors --- lib_dec/lib_dec_fx.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 0d0177379..99878ab51 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -4076,8 +4076,6 @@ ivas_error IVAS_DEC_GetEditableParameters( ELSE IF( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT && ( hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) { /* object editing possible only in two highest OMASA modes */ - Word16 obj; - IF( hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { FOR( obj = 0; obj < hIvasEditableParameters->num_obj; obj++ ) @@ -4251,7 +4249,6 @@ ivas_error IVAS_DEC_SetEditableParameters( #ifdef OMASA_OBJECT_EDITING ELSE IF( EQ_16( hIvasDec->st_ivas->ivas_format, MASA_ISM_FORMAT ) && ( EQ_16( hIvasDec->st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) || EQ_16( hIvasDec->st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) ) { - Word16 obj; Word32 id_th; Word32 threshold_azi, threshold_ele; -- GitLab From 8c68d5543451135cb3ce4d4f53f663f3372054ad Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 16 Oct 2025 13:53:58 +0200 Subject: [PATCH 17/31] change Q of edited_gain_fx to 31 --- lib_com/ivas_ism_com_fx.c | 2 +- lib_com/ivas_stat_com.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/ivas_ism_com_fx.c b/lib_com/ivas_ism_com_fx.c index 30cd2f29e..f383831aa 100644 --- a/lib_com/ivas_ism_com_fx.c +++ b/lib_com/ivas_ism_com_fx.c @@ -471,7 +471,7 @@ void ivas_ism_reset_metadata( move16(); #ifdef OBJ_EDITING_API - hIsmMeta->edited_gain_fx = ONE_IN_Q31; + hIsmMeta->edited_gain_fx = ONE_IN_Q30; hIsmMeta->edited_azimuth_fx = 0; hIsmMeta->edited_elevation_fx = 0; hIsmMeta->edited_pitch_fx = 0; diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 1f7ea778d..b43c90eba 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -74,7 +74,7 @@ typedef struct Word32 edited_yaw_fx; /* Q22 */ Word32 edited_pitch_fx; /* Q22 */ - Word32 edited_gain_fx; /* Q31 */ + Word32 edited_gain_fx; /* Q30 */ #endif Word16 non_diegetic_flag; /* Non-diegetic (non-headtracked) object flag */ -- GitLab From a7e291ad03916df5e1c1911d5d2c9c241abd0b5f Mon Sep 17 00:00:00 2001 From: lintervo Date: Thu, 16 Oct 2025 15:40:45 +0300 Subject: [PATCH 18/31] Fix gaining feature --- lib_com/ivas_stat_com.h | 2 +- lib_dec/ivas_dirac_dec_fx.c | 7 +++++-- lib_dec/ivas_ism_param_dec_fx.c | 20 +++++++++++++++----- lib_dec/ivas_ism_renderer_fx.c | 7 +++++-- lib_rend/ivas_objectRenderer_sources_fx.c | 2 +- 5 files changed, 27 insertions(+), 11 deletions(-) diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index b43c90eba..1f7ea778d 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -74,7 +74,7 @@ typedef struct Word32 edited_yaw_fx; /* Q22 */ Word32 edited_pitch_fx; /* Q22 */ - Word32 edited_gain_fx; /* Q30 */ + Word32 edited_gain_fx; /* Q31 */ #endif Word16 non_diegetic_flag; /* Non-diegetic (non-headtracked) object flag */ diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index d29c65764..33bf0ad94 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -3768,8 +3768,11 @@ void ivas_dirac_dec_render_sf_fx( const Word32 ele_fx = L_shl( el1_32, Q22 - Q16 ); // Q16 -> Q22 efap_determine_gains_fx( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains_fx[i], azi_fx, ele_fx, EFAP_MODE_EFAP ); #ifdef OBJ_EDITING_API - // TODO: Enable gain editing feature - // v_multc_fixed( st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIsmMetaData[i]->edited_gain_fx, st_ivas->hIsmRendererData->gains_fx[i], nchan_out_woLFE ); // Q30, Q30 --> Q30 + // TODO: Align Q-values + IF( NE_32( st_ivas->hIsmMetaData[i]->edited_gain_fx, ONE_IN_Q31 ) ) + { + v_multc_fx( st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIsmMetaData[i]->edited_gain_fx, st_ivas->hIsmRendererData->gains_fx[i], nchan_out_woLFE ); // Q30, Q30 --> Q30 + } #endif } } diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 6a6173c3c..88efd4f63 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -1000,8 +1000,12 @@ void ivas_ism_dec_digest_tc_fx( move32(); st_ivas->hIsmRendererData->gains_fx[i][1] = L_shr( L_deposit_h( gains_fx[1] ), 1 ); // Q31 -> Q30 move32(); - // TODO: Enable gain editing feature - // v_multc_fixed( st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIsmMetaData[i]->edited_gain_fx, st_ivas->hIsmRendererData->gains_fx[i], CPE_CHANNELS ); // Q30, Q30 --> Q30 + // TODO: Align Q values + IF ( NE_32( st_ivas->hIsmMetaData[i]->edited_gain_fx, ONE_IN_Q31 ) ) + { + v_multc_fx( st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIsmMetaData[i]->edited_gain_fx, st_ivas->hIsmRendererData->gains_fx[i], CPE_CHANNELS ); // Q30, Q30 --> Q30 + } + #else Word16 gains_fx[2]; ivas_ism_get_stereo_gains_fx( (Word16) L_shr( st_ivas->hIsmMetaData[i]->azimuth_fx, 22 ), (Word16) L_shr( st_ivas->hIsmMetaData[i]->elevation_fx, 22 ), &gains_fx[0], &gains_fx[1] ); @@ -1050,7 +1054,10 @@ void ivas_ism_dec_digest_tc_fx( efap_determine_gains_fx( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains_fx[i], azimuth_fx, elevation_fx, EFAP_MODE_EFAP ); #ifdef OBJ_EDITING_API // TODO: align Q values properly - v_multc_fx( st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIsmMetaData[i]->edited_gain_fx, st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hEFAPdata->numSpk ); + IF( NE_32( st_ivas->hIsmMetaData[i]->edited_gain_fx, ONE_IN_Q31 ) ) + { + v_multc_fx( st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIsmMetaData[i]->edited_gain_fx, st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hEFAPdata->numSpk ); + } #endif } } @@ -1063,8 +1070,11 @@ void ivas_ism_dec_digest_tc_fx( Word16 ele = shr( extract_h( st_ivas->hIsmMetaData[i]->elevation_fx ), 22 - 16 ); // Q0 ivas_dirac_dec_get_response_fx( azi, ele, st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIntSetup.ambisonics_order, Q30 ); #ifdef OBJ_EDITING_API - // TODO: Enable gain editing feature - // v_multc_fixed( st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIsmMetaData[i]->edited_gain_fx, st_ivas->hIsmRendererData->gains_fx[i], ivas_sba_get_nchan_fx( st_ivas->hIntSetup.ambisonics_order, 0 ) ); // Q30, Q30 --> Q30 + // TODO: Align Q-values + IF( NE_32( st_ivas->hIsmMetaData[i]->edited_gain_fx, ONE_IN_Q31 ) ) + { + v_multc_fx( st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIsmMetaData[i]->edited_gain_fx, st_ivas->hIsmRendererData->gains_fx[i], ivas_sba_get_nchan_fx( st_ivas->hIntSetup.ambisonics_order, 0 ) ); // Q30, Q30 --> Q30 + } #endif } } diff --git a/lib_dec/ivas_ism_renderer_fx.c b/lib_dec/ivas_ism_renderer_fx.c index 2747ad284..efa8bd360 100644 --- a/lib_dec/ivas_ism_renderer_fx.c +++ b/lib_dec/ivas_ism_renderer_fx.c @@ -279,8 +279,11 @@ void ivas_ism_render_sf_fx( { efap_determine_gains_fx( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains_fx[i], L_shl( azimuth, 22 ), L_shl( elevation, 22 ), EFAP_MODE_EFAP ); #ifdef OBJ_EDITING_API - // TODO: Enable gain editing feature - // v_multc_fixed( st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIsmMetaData[i]->edited_gain_fx, st_ivas->hIsmRendererData->gains_fx[i], nchan_out_woLFE ); // Q30, Q30 --> Q30 + // TODO: Align Q-values + IF( NE_32( st_ivas->hIsmMetaData[i]->edited_gain_fx, ONE_IN_Q31 ) ) + { + v_multc_fx( st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIsmMetaData[i]->edited_gain_fx, st_ivas->hIsmRendererData->gains_fx[i], nchan_out_woLFE ); // Q30, Q30 --> Q30 + } #endif } } diff --git a/lib_rend/ivas_objectRenderer_sources_fx.c b/lib_rend/ivas_objectRenderer_sources_fx.c index ab653abf2..03c74b20e 100644 --- a/lib_rend/ivas_objectRenderer_sources_fx.c +++ b/lib_rend/ivas_objectRenderer_sources_fx.c @@ -704,7 +704,7 @@ static void TDREND_SRC_SPATIAL_SetGain( const Word32 Gain /* i : Front-pointing vector */ ) { - Src_p->SrcRend_p->SrcGain_p_fx[0] = extract_h( Gain ); // Check incoming Q-value + Src_p->SrcRend_p->SrcGain_p_fx[0] = add( extract_h( L_shr( Gain, Q1 ) ), 1 ); // TODO: Check incoming Q-value and fix this } #endif -- GitLab From f8df8efddcc4052874f6ff9f3bcc8d41429b1048 Mon Sep 17 00:00:00 2001 From: lintervo Date: Thu, 16 Oct 2025 15:42:33 +0300 Subject: [PATCH 19/31] Fix formatting --- lib_dec/ivas_ism_param_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 88efd4f63..75794b157 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -1001,7 +1001,7 @@ void ivas_ism_dec_digest_tc_fx( st_ivas->hIsmRendererData->gains_fx[i][1] = L_shr( L_deposit_h( gains_fx[1] ), 1 ); // Q31 -> Q30 move32(); // TODO: Align Q values - IF ( NE_32( st_ivas->hIsmMetaData[i]->edited_gain_fx, ONE_IN_Q31 ) ) + IF( NE_32( st_ivas->hIsmMetaData[i]->edited_gain_fx, ONE_IN_Q31 ) ) { v_multc_fx( st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIsmMetaData[i]->edited_gain_fx, st_ivas->hIsmRendererData->gains_fx[i], CPE_CHANNELS ); // Q30, Q30 --> Q30 } -- GitLab From 99164aae390d3369bd64a08bb391645026deed09 Mon Sep 17 00:00:00 2001 From: lintervo Date: Thu, 16 Oct 2025 15:46:03 +0300 Subject: [PATCH 20/31] Revert edited_gain_fx to Q31 --- lib_com/ivas_ism_com_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/ivas_ism_com_fx.c b/lib_com/ivas_ism_com_fx.c index f383831aa..30cd2f29e 100644 --- a/lib_com/ivas_ism_com_fx.c +++ b/lib_com/ivas_ism_com_fx.c @@ -471,7 +471,7 @@ void ivas_ism_reset_metadata( move16(); #ifdef OBJ_EDITING_API - hIsmMeta->edited_gain_fx = ONE_IN_Q30; + hIsmMeta->edited_gain_fx = ONE_IN_Q31; hIsmMeta->edited_azimuth_fx = 0; hIsmMeta->edited_elevation_fx = 0; hIsmMeta->edited_pitch_fx = 0; -- GitLab From 49876f5d67a67cec525b2e60f99fb6bb2771d359 Mon Sep 17 00:00:00 2001 From: lintervo Date: Thu, 16 Oct 2025 16:29:29 +0300 Subject: [PATCH 21/31] Align gain Q-values in IVAS_rend --- lib_rend/ivas_objectRenderer_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/ivas_objectRenderer_fx.c b/lib_rend/ivas_objectRenderer_fx.c index 0662d29ae..23f6881ab 100644 --- a/lib_rend/ivas_objectRenderer_fx.c +++ b/lib_rend/ivas_objectRenderer_fx.c @@ -962,7 +962,7 @@ ivas_error ivas_td_binaural_renderer_ext_fx( hIsmMetaData[0]->radius_fx = currentPos->radius_fx; move32(); #ifdef OBJ_EDITING_INTERFACE - hIsmMetaData[0]->gain_fx = ONE_IN_Q30; // TODO: check Q value + hIsmMetaData[0]->gain_fx = ONE_IN_Q31; // TODO: check Q value #endif hIsmMetaData[0]->non_diegetic_flag = currentPos->non_diegetic_flag; move16(); -- GitLab From 265942f241941d3de4cb9c7e0242d77a543d5c5c Mon Sep 17 00:00:00 2001 From: lintervo Date: Fri, 17 Oct 2025 09:05:51 +0300 Subject: [PATCH 22/31] Address comments --- lib_dec/ivas_dirac_dec_fx.c | 12 +++++++++++- lib_dec/ivas_omasa_dec_fx.c | 16 ++++++++++++++-- lib_dec/ivas_stat_dec.h | 2 +- .../ivas_dirac_dec_binaural_functions_fx.c | 18 +++++++++++------- 4 files changed, 37 insertions(+), 11 deletions(-) diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index 33bf0ad94..435204f1a 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -2808,15 +2808,25 @@ void ivas_dirac_dec_render_sf_fx( } #ifdef OMASA_OBJECT_EDITING - IF( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) + IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) { #ifdef FIX_1319_STACK_SBA_DECODER ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( st_ivas, Cldfb_RealBuffer_Binaural_fx[0], Cldfb_ImagBuffer_Binaural_fx[0], &cldfb_buf_q, hSpatParamRendCom->num_freq_bands, subframe_idx ); #else ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( st_ivas, Cldfb_RealBuffer_Temp_fx, Cldfb_ImagBuffer_Temp_fx, &cldfb_buf_q, hSpatParamRendCom->num_freq_bands, subframe_idx ); #endif + } +#else + test(); + IF( ( NE_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && NE_16( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) ) + { +#ifdef FIX_1319_STACK_SBA_DECODER + ivas_omasa_preProcessStereoTransportsForMovedObjects_fx( st_ivas, Cldfb_RealBuffer_Binaural_fx[0], Cldfb_ImagBuffer_Binaural_fx[0], &cldfb_buf_q, hSpatParamRendCom->num_freq_bands, subframe_idx ); +#else + ivas_omasa_preProcessStereoTransportsForMovedObjects_fx( st_ivas, Cldfb_RealBuffer_Temp_fx, Cldfb_ImagBuffer_Temp_fx, &cldfb_buf_q, hSpatParamRendCom->num_freq_bands, subframe_idx ); #endif } +#endif } FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index 52e818926..2a6e60f8f 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -328,26 +328,37 @@ ivas_error ivas_omasa_data_open_fx( } #ifdef OMASA_OBJECT_EDITING - FOR( int16_t band_idx = 0; band_idx < MASA_FREQUENCY_BANDS; band_idx++ ) + FOR( Word16 band_idx = 0; band_idx < MASA_FREQUENCY_BANDS; band_idx++ ) { FOR( ch = 0; ch < 2; ch++ ) { hMasaIsmData->ismPreprocMatrix_fx[ch][ch][band_idx] = ONE_IN_Q28; - hMasaIsmData->ismPreprocMatrix_fx[1 - ch][ch][band_idx] = 0; + move32(); + hMasaIsmData->ismPreprocMatrix_fx[sub(1, ch)][ch][band_idx] = 0; + move32(); hMasaIsmData->eneMoveIIR_fx[ch][band_idx] = 0; + move32(); hMasaIsmData->eneMoveIIR_e[ch][band_idx] = 0; + move16(); hMasaIsmData->enePreserveIIR_fx[ch][band_idx] = 0; + move32(); hMasaIsmData->enePreserveIIR_e[ch][band_idx] = 0; + move16(); } hMasaIsmData->eneOrigIIR_fx[band_idx] = 0; + move32(); hMasaIsmData->eneOrigIIR_e[band_idx] = 0; + move16(); hMasaIsmData->preprocEneTarget_fx[band_idx] = 0; + move32(); hMasaIsmData->preprocEneRealized_fx[band_idx] = 0; + move32(); } hMasaIsmData->objectsEdited_fx = 0; + move32(); #else FOR( bin = 0; bin < CLDFB_NO_CHANNELS_MAX; bin++ ) { @@ -392,6 +403,7 @@ ivas_error ivas_omasa_data_open_fx( #ifdef OMASA_OBJECT_EDITING hMasaIsmData->masa_gain_is_edited_fx = 0; hMasaIsmData->idx_separated_ism = -1; + move16(); #endif FOR( obj_idx = 0; obj_idx < MAX_NUM_OBJECTS; obj_idx++ ) diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index c8f3d2dc7..282dbd0a8 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -981,7 +981,7 @@ typedef struct ivas_masa_ism_data_structure #else Word16 azimuth_ism_edited[MAX_NUM_OBJECTS]; Word16 elevation_ism_edited[MAX_NUM_OBJECTS]; - UWord8 ism_is_edited[MAX_NUM_OBJECTS]; + // UWord8 ism_is_edited[MAX_NUM_OBJECTS]; #endif Word16 idx_separated_ism; diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index a0bf43d0b..20dda6420 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -5471,7 +5471,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( move16(); /* Bypass processing until first object is moved or gained */ - IF( hMasaIsmData->objectsEdited_fx == 0 ) + IF( EQ_32( hMasaIsmData->objectsEdited_fx, 0 ) ) { FOR( ismDirIndex = 0; ismDirIndex < n_ism; ismDirIndex++ ) { @@ -5494,7 +5494,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( move16(); } - IF( hMasaIsmData->objectsEdited_fx == 0 ) + IF( EQ_32( hMasaIsmData->objectsEdited_fx, 0 ) ) { /* No objects have moved so far */ return; @@ -5570,25 +5570,26 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( { ismPreprocMtxNew[ch][ch] = ONE_IN_Q28; move32(); - ismPreprocMtxNew[1 - ch][ch] = 0; + ismPreprocMtxNew[sub( 1, ch )][ch] = 0; move32(); } /* Determine the highest band */ max_band = 0; move16(); + test(); WHILE( sub( MAX_PARAM_ISM_NBANDS, max_band ) > 0 && sub( nBins, hParamIsmDec->hParamIsm->band_grouping[max_band] ) > 0 ) { max_band++; } /* Init out array */ - FOR( Word16 k = 0; k < nSlots; k++ ) + FOR( slot = 0; slot < nSlots; slot++ ) { FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { - set32_fx( outSlotRe[ch][k], 0, CLDFB_NO_CHANNELS_MAX ); - set32_fx( outSlotIm[ch][k], 0, CLDFB_NO_CHANNELS_MAX ); + set32_fx( outSlotRe[ch][slot], 0, CLDFB_NO_CHANNELS_MAX ); + set32_fx( outSlotIm[ch][slot], 0, CLDFB_NO_CHANNELS_MAX ); } } @@ -5695,15 +5696,18 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( ELSE { temp = 0; + move32(); } IF( GT_32( ONE_IN_Q30, temp ) ) { eqVal = temp; + move32(); } ELSE { eqVal = ONE_IN_Q30; // 4 in Q28 + move32(); } FOR( ch = 0; ch < 2; ch++ ) @@ -5777,7 +5781,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( temp = 0; move32(); - gainMasaPow2 = 0; + gainMasaPow2 = ONE_IN_Q9; move16(); IF( masaGainEdited ) { -- GitLab From e8a4f5acb6c474056114c79e1c7039175a2c808d Mon Sep 17 00:00:00 2001 From: lintervo Date: Fri, 17 Oct 2025 09:08:21 +0300 Subject: [PATCH 23/31] Fix formatting --- lib_dec/ivas_dirac_dec_fx.c | 46 ++++++++++++++++++------------------- lib_dec/ivas_omasa_dec_fx.c | 2 +- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index 435204f1a..cceb58840 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -2862,8 +2862,8 @@ void ivas_dirac_dec_render_sf_fx( Copy32( Cldfb_RealBuffer_Binaural_fx[0][ch][slot_idx], Cldfb_RealBuffer_fx[ch][0], hSpatParamRendCom->num_freq_bands ); Copy32( Cldfb_ImagBuffer_Binaural_fx[0][ch][slot_idx], Cldfb_ImagBuffer_fx[ch][0], hSpatParamRendCom->num_freq_bands ); #else - Copy32( Cldfb_RealBuffer_Temp_fx[ch][slot_idx], Cldfb_RealBuffer_fx[ch][0], hSpatParamRendCom->num_freq_bands ); - Copy32( Cldfb_ImagBuffer_Temp_fx[ch][slot_idx], Cldfb_ImagBuffer_fx[ch][0], hSpatParamRendCom->num_freq_bands ); + Copy32( Cldfb_RealBuffer_Temp_fx[ch][slot_idx], Cldfb_RealBuffer_fx[ch][0], hSpatParamRendCom->num_freq_bands ); + Copy32( Cldfb_ImagBuffer_Temp_fx[ch][slot_idx], Cldfb_ImagBuffer_fx[ch][0], hSpatParamRendCom->num_freq_bands ); #endif } } @@ -3861,30 +3861,30 @@ void ivas_dirac_dec_render_sf_fx( Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx ); } #else - IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) - { - IF( st_ivas->hSplitBinRend->hCldfbDataOut != NULL ) + IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { - FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) + IF( st_ivas->hSplitBinRend->hCldfbDataOut != NULL ) { - FOR( ch = 0; ch < st_ivas->hBinRenderer->nInChannels; ch++ ) + FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) { - Copy32( Cldfb_RealBuffer_fx[ch][slot_idx], st_ivas->hSplitBinRend->hCldfbDataOut->Cldfb_RealBuffer_fx[ch][add( slot_idx_start, slot_idx )], hSpatParamRendCom->num_freq_bands ); - Copy32( Cldfb_ImagBuffer_fx[ch][slot_idx], st_ivas->hSplitBinRend->hCldfbDataOut->Cldfb_ImagBuffer_fx[ch][add( slot_idx_start, slot_idx )], hSpatParamRendCom->num_freq_bands ); + FOR( ch = 0; ch < st_ivas->hBinRenderer->nInChannels; ch++ ) + { + Copy32( Cldfb_RealBuffer_fx[ch][slot_idx], st_ivas->hSplitBinRend->hCldfbDataOut->Cldfb_RealBuffer_fx[ch][add( slot_idx_start, slot_idx )], hSpatParamRendCom->num_freq_bands ); + Copy32( Cldfb_ImagBuffer_fx[ch][slot_idx], st_ivas->hSplitBinRend->hCldfbDataOut->Cldfb_ImagBuffer_fx[ch][add( slot_idx_start, slot_idx )], hSpatParamRendCom->num_freq_bands ); + } } + st_ivas->hSplitBinRend->hCldfbDataOut->config = st_ivas->hIntSetup.output_config; + move16(); } - st_ivas->hSplitBinRend->hCldfbDataOut->config = st_ivas->hIntSetup.output_config; - move16(); } - } - /*Binaural output in Q6 format*/ - ivas_binRenderer_fx( st_ivas->hBinRenderer, - ( st_ivas->hSplitBinRend == NULL ) ? NULL : &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, - st_ivas->hCombinedOrientationData, - hSpatParamRendCom->subframe_nbslots[subframe_idx], - Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, - Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, &input_q ); + /*Binaural output in Q6 format*/ + ivas_binRenderer_fx( st_ivas->hBinRenderer, + ( st_ivas->hSplitBinRend == NULL ) ? NULL : &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, + st_ivas->hCombinedOrientationData, + hSpatParamRendCom->subframe_nbslots[subframe_idx], + Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, + Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, &input_q ); #endif /* Inverse CLDFB*/ @@ -3896,8 +3896,8 @@ void ivas_dirac_dec_render_sf_fx( Word32 *RealBuffer_fx[CLDFB_SLOTS_PER_SUBFRAME]; Word32 *ImagBuffer_fx[CLDFB_SLOTS_PER_SUBFRAME]; #else - Word32 *RealBuffer_fx[MAX_PARAM_SPATIAL_SUBFRAMES]; - Word32 *ImagBuffer_fx[MAX_PARAM_SPATIAL_SUBFRAMES]; + Word32 *RealBuffer_fx[MAX_PARAM_SPATIAL_SUBFRAMES]; + Word32 *ImagBuffer_fx[MAX_PARAM_SPATIAL_SUBFRAMES]; #endif FOR( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ ) { @@ -3948,8 +3948,8 @@ void ivas_dirac_dec_render_sf_fx( Word32 *RealBuffer_fx[CLDFB_SLOTS_PER_SUBFRAME]; Word32 *ImagBuffer_fx[CLDFB_SLOTS_PER_SUBFRAME]; #else - Word32 *RealBuffer_fx[MAX_PARAM_SPATIAL_SUBFRAMES]; - Word32 *ImagBuffer_fx[MAX_PARAM_SPATIAL_SUBFRAMES]; + Word32 *RealBuffer_fx[MAX_PARAM_SPATIAL_SUBFRAMES]; + Word32 *ImagBuffer_fx[MAX_PARAM_SPATIAL_SUBFRAMES]; #endif Word16 outchannels; diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index 2a6e60f8f..cdc2615b8 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -335,7 +335,7 @@ ivas_error ivas_omasa_data_open_fx( hMasaIsmData->ismPreprocMatrix_fx[ch][ch][band_idx] = ONE_IN_Q28; move32(); - hMasaIsmData->ismPreprocMatrix_fx[sub(1, ch)][ch][band_idx] = 0; + hMasaIsmData->ismPreprocMatrix_fx[sub( 1, ch )][ch][band_idx] = 0; move32(); hMasaIsmData->eneMoveIIR_fx[ch][band_idx] = 0; move32(); -- GitLab From 7e8341b4efc333aab0310581b9122e1409463ffc Mon Sep 17 00:00:00 2001 From: lintervo Date: Fri, 17 Oct 2025 10:02:42 +0300 Subject: [PATCH 24/31] Harmonize gain editing to Q29 --- lib_com/common_api_types.h | 6 ++--- lib_com/ivas_ism_com_fx.c | 4 +-- lib_com/ivas_stat_com.h | 4 +-- lib_dec/ivas_dirac_dec_fx.c | 5 ++-- lib_dec/ivas_ism_param_dec_fx.c | 15 ++++++----- lib_dec/ivas_ism_renderer_fx.c | 5 ++-- lib_dec/ivas_jbm_dec_fx.c | 4 +-- lib_dec/ivas_stat_dec.h | 2 +- lib_dec/lib_dec_fx.c | 32 +++++++++++------------ lib_rend/ivas_objectRenderer_fx.c | 2 +- lib_rend/ivas_objectRenderer_sources_fx.c | 2 +- lib_util/ism_file_writer.c | 2 +- 12 files changed, 44 insertions(+), 39 deletions(-) diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index c798596b7..41ab8e759 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -126,7 +126,7 @@ typedef struct _IVAS_ISM_METADATA Word32 elevation_fx; /* Q22 */ Word16 radius_fx; /* Q9 */ Word32 spread_fx; /* Q22 */ - Word32 gainFactor_fx; /* Q31 */ // TODO: Gain factor can't be Q31, due to the gain editing + Word32 gainFactor_fx; /* Q29 */ Word32 yaw_fx; /* Q22 */ Word32 pitch_fx; /* Q22 */ float azimuth; @@ -138,7 +138,7 @@ typedef struct _IVAS_ISM_METADATA float pitch; Word16 non_diegetic_flag; #ifdef OBJ_EDITING_API - Word32 gain_fx; + Word32 gain_fx; // Q29 #endif } IVAS_ISM_METADATA; @@ -148,7 +148,7 @@ typedef struct _IVAS_EDITABLE_PARAMETERS { Word16 num_obj; IVAS_ISM_METADATA ism_metadata[IVAS_MAX_NUM_OBJECTS]; - Word32 gain_bed_fx; + Word32 gain_bed_fx; // Q29 } IVAS_EDITABLE_PARAMETERS; #endif diff --git a/lib_com/ivas_ism_com_fx.c b/lib_com/ivas_ism_com_fx.c index 30cd2f29e..8514fb9c2 100644 --- a/lib_com/ivas_ism_com_fx.c +++ b/lib_com/ivas_ism_com_fx.c @@ -471,13 +471,13 @@ void ivas_ism_reset_metadata( move16(); #ifdef OBJ_EDITING_API - hIsmMeta->edited_gain_fx = ONE_IN_Q31; + hIsmMeta->edited_gain_fx = ONE_IN_Q29; hIsmMeta->edited_azimuth_fx = 0; hIsmMeta->edited_elevation_fx = 0; hIsmMeta->edited_pitch_fx = 0; hIsmMeta->edited_yaw_fx = 0; hIsmMeta->edited_radius_fx = ONE_IN_Q9; - hIsmMeta->gain_fx = ONE_IN_Q31; + hIsmMeta->gain_fx = ONE_IN_Q29; hIsmMeta->non_diegetic_flag = 0; #endif diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 1f7ea778d..db2c6ca69 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -66,7 +66,7 @@ typedef struct Word32 pitch_fx; /* pitch value read from the input metadata file */ /* Q22 */ #ifdef OBJ_EDITING_API - Word32 gain_fx; /* Q31 */ + Word32 gain_fx; /* Q29 */ Word32 edited_azimuth_fx; /* Q22 */ Word32 edited_elevation_fx; /* Q22 */ @@ -74,7 +74,7 @@ typedef struct Word32 edited_yaw_fx; /* Q22 */ Word32 edited_pitch_fx; /* Q22 */ - Word32 edited_gain_fx; /* Q31 */ + Word32 edited_gain_fx; /* Q29 */ #endif Word16 non_diegetic_flag; /* Non-diegetic (non-headtracked) object flag */ diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index cceb58840..1c20d23a8 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -3779,9 +3779,10 @@ void ivas_dirac_dec_render_sf_fx( efap_determine_gains_fx( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains_fx[i], azi_fx, ele_fx, EFAP_MODE_EFAP ); #ifdef OBJ_EDITING_API // TODO: Align Q-values - IF( NE_32( st_ivas->hIsmMetaData[i]->edited_gain_fx, ONE_IN_Q31 ) ) + IF( NE_32( st_ivas->hIsmMetaData[i]->edited_gain_fx, ONE_IN_Q29 ) ) { - v_multc_fx( st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIsmMetaData[i]->edited_gain_fx, st_ivas->hIsmRendererData->gains_fx[i], nchan_out_woLFE ); // Q30, Q30 --> Q30 + v_multc_fx( st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIsmMetaData[i]->edited_gain_fx, st_ivas->hIsmRendererData->gains_fx[i], nchan_out_woLFE ); // Q30, Q29 --> Q28 + Scale_sig32( st_ivas->hIsmRendererData->gains_fx[i], nchan_out_woLFE, Q2 ); // Q28 --> Q30 } #endif } diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 75794b157..db97c98d6 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -1001,9 +1001,10 @@ void ivas_ism_dec_digest_tc_fx( st_ivas->hIsmRendererData->gains_fx[i][1] = L_shr( L_deposit_h( gains_fx[1] ), 1 ); // Q31 -> Q30 move32(); // TODO: Align Q values - IF( NE_32( st_ivas->hIsmMetaData[i]->edited_gain_fx, ONE_IN_Q31 ) ) + IF( NE_32( st_ivas->hIsmMetaData[i]->edited_gain_fx, ONE_IN_Q29 ) ) { - v_multc_fx( st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIsmMetaData[i]->edited_gain_fx, st_ivas->hIsmRendererData->gains_fx[i], CPE_CHANNELS ); // Q30, Q30 --> Q30 + v_multc_fx( st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIsmMetaData[i]->edited_gain_fx, st_ivas->hIsmRendererData->gains_fx[i], CPE_CHANNELS ); // Q30, Q29 --> Q28 + Scale_sig32( st_ivas->hIsmRendererData->gains_fx[i], CPE_CHANNELS, Q2 ); // Q28 --> Q30 } #else @@ -1054,9 +1055,10 @@ void ivas_ism_dec_digest_tc_fx( efap_determine_gains_fx( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains_fx[i], azimuth_fx, elevation_fx, EFAP_MODE_EFAP ); #ifdef OBJ_EDITING_API // TODO: align Q values properly - IF( NE_32( st_ivas->hIsmMetaData[i]->edited_gain_fx, ONE_IN_Q31 ) ) + IF( NE_32( st_ivas->hIsmMetaData[i]->edited_gain_fx, ONE_IN_Q29 ) ) { - v_multc_fx( st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIsmMetaData[i]->edited_gain_fx, st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hEFAPdata->numSpk ); + v_multc_fx( st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIsmMetaData[i]->edited_gain_fx, st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hEFAPdata->numSpk ); // Q30, Q29 --> Q28 + Scale_sig32( st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hEFAPdata->numSpk, Q2 ); // Q28 --> Q30 } #endif } @@ -1071,9 +1073,10 @@ void ivas_ism_dec_digest_tc_fx( ivas_dirac_dec_get_response_fx( azi, ele, st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIntSetup.ambisonics_order, Q30 ); #ifdef OBJ_EDITING_API // TODO: Align Q-values - IF( NE_32( st_ivas->hIsmMetaData[i]->edited_gain_fx, ONE_IN_Q31 ) ) + IF( NE_32( st_ivas->hIsmMetaData[i]->edited_gain_fx, ONE_IN_Q29 ) ) { - v_multc_fx( st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIsmMetaData[i]->edited_gain_fx, st_ivas->hIsmRendererData->gains_fx[i], ivas_sba_get_nchan_fx( st_ivas->hIntSetup.ambisonics_order, 0 ) ); // Q30, Q30 --> Q30 + v_multc_fx( st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIsmMetaData[i]->edited_gain_fx, st_ivas->hIsmRendererData->gains_fx[i], ivas_sba_get_nchan_fx( st_ivas->hIntSetup.ambisonics_order, 0 ) ); // Q30, Q29 --> Q28 + Scale_sig32( st_ivas->hIsmRendererData->gains_fx[i], ivas_sba_get_nchan_fx( st_ivas->hIntSetup.ambisonics_order, 0 ), Q2 ); // Q28 --> 30 } #endif } diff --git a/lib_dec/ivas_ism_renderer_fx.c b/lib_dec/ivas_ism_renderer_fx.c index efa8bd360..1fdedfcb6 100644 --- a/lib_dec/ivas_ism_renderer_fx.c +++ b/lib_dec/ivas_ism_renderer_fx.c @@ -280,9 +280,10 @@ void ivas_ism_render_sf_fx( efap_determine_gains_fx( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains_fx[i], L_shl( azimuth, 22 ), L_shl( elevation, 22 ), EFAP_MODE_EFAP ); #ifdef OBJ_EDITING_API // TODO: Align Q-values - IF( NE_32( st_ivas->hIsmMetaData[i]->edited_gain_fx, ONE_IN_Q31 ) ) + IF( NE_32( st_ivas->hIsmMetaData[i]->edited_gain_fx, ONE_IN_Q29 ) ) { - v_multc_fx( st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIsmMetaData[i]->edited_gain_fx, st_ivas->hIsmRendererData->gains_fx[i], nchan_out_woLFE ); // Q30, Q30 --> Q30 + v_multc_fx( st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIsmMetaData[i]->edited_gain_fx, st_ivas->hIsmRendererData->gains_fx[i], nchan_out_woLFE ); // Q30, Q29 --> Q28 + Scale_sig32( st_ivas->hIsmRendererData->gains_fx[i], nchan_out_woLFE, Q2 ); // Q28 --> Q30 } #endif } diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index cd908078e..5f30937e9 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2229,13 +2229,13 @@ ivas_error ivas_jbm_dec_render_fx( Word32 gain = st_ivas->hSbaIsmData->gain_bed_fx; test(); // TODO: Enable gain editing feature (NE_32 ( gain, ONE_IN_Q_gain ) ) - IF( NE_32( gain, ONE_IN_Q31 ) && GT_32( gain, 0 ) ) + IF( NE_32( gain, ONE_IN_Q29 ) && GT_32( gain, 0 ) ) { FOR( n = 0; n < nchan_out; n++ ) { FOR( i = 0; i < *nSamplesRendered; i++ ) { - Word32 tmp1 = Mpy_32_32( p_tc_fx[n + st_ivas->nchan_ism][i], gain ); // Q11 + Q30 - 32 = Q9 + Word32 tmp1 = Mpy_32_32( p_tc_fx[n + st_ivas->nchan_ism][i], gain ); // Q11 + Q29 - 31 = Q9 tmp1 = L_shl( tmp1, 2 ); // Q9 --> Q11 p_output_fx[n][i] = L_add_sat( p_output_fx[n][i], tmp1 ); // Q11 } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 282dbd0a8..3de03cec6 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -721,7 +721,7 @@ typedef struct ivas_osba_data Word16 delayBuffer_nchan; #ifdef OBJ_EDITING_API - Word32 gain_bed_fx; + Word32 gain_bed_fx; // Q29 #endif } SBA_ISM_DATA, *SBA_ISM_DATA_HANDLE; diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index e5f31a8d7..d45e226d2 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -2290,7 +2290,7 @@ ivas_error IVAS_DEC_GetObjectMetadata( metadata->yaw_fx = 0; // Q22 metadata->pitch_fx = 0; // Q22 metadata->spread_fx = 0; // Q22 - metadata->gainFactor_fx = ONE_IN_Q31; // Q31 + metadata->gainFactor_fx = ONE_IN_Q29; // Q31 metadata->non_diegetic_flag = 0; } ELSE @@ -2317,7 +2317,7 @@ ivas_error IVAS_DEC_GetObjectMetadata( metadata->yaw_fx = hIsmMeta->yaw_fx; metadata->pitch_fx = hIsmMeta->pitch_fx; metadata->spread_fx = 0; - metadata->gainFactor_fx = ONE_IN_Q31; + metadata->gainFactor_fx = ONE_IN_Q29; metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; } ELSE IF( EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) || EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) @@ -2340,7 +2340,7 @@ ivas_error IVAS_DEC_GetObjectMetadata( metadata->yaw_fx = hIsmMeta->yaw_fx; // Q22 metadata->pitch_fx = hIsmMeta->pitch_fx; // Q22 metadata->spread_fx = 0; // Q22 - metadata->gainFactor_fx = ONE_IN_Q31; + metadata->gainFactor_fx = ONE_IN_Q29; metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; } } @@ -3945,12 +3945,12 @@ ivas_error IVAS_DEC_GetSamplesDecoder( hIsmMetaData[obj]->edited_yaw_fx = hIsmMetaData[obj]->yaw_fx; hIsmMetaData[obj]->edited_pitch_fx = hIsmMetaData[obj]->pitch_fx; hIsmMetaData[obj]->edited_radius_fx = hIsmMetaData[obj]->radius_fx; - hIsmMetaData[obj]->edited_gain_fx = ONE_IN_Q31; // TODO: Check Q value + hIsmMetaData[obj]->edited_gain_fx = ONE_IN_Q29; // TODO: Check Q value } IF( hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { - hIvasDec->st_ivas->hSbaIsmData->gain_bed_fx = ONE_IN_Q31; // TODO: Check Q value + hIvasDec->st_ivas->hSbaIsmData->gain_bed_fx = ONE_IN_Q29; // TODO: Check Q value } } } @@ -4021,7 +4021,7 @@ ivas_error IVAS_DEC_GetEditableParameters( } #endif - hIvasEditableParameters->gain_bed_fx = ONE_IN_Q30; + hIvasEditableParameters->gain_bed_fx = ONE_IN_Q29; move32(); hIvasEditableParameters->num_obj = st_ivas->nchan_ism; move16(); @@ -4053,7 +4053,7 @@ ivas_error IVAS_DEC_GetEditableParameters( IF( EQ_32( ism_mode, ISM_SBA_MODE_DISC ) ) { - hIvasEditableParameters->gain_bed_fx = ONE_IN_Q30; + hIvasEditableParameters->gain_bed_fx = ONE_IN_Q29; move32(); } } @@ -4071,7 +4071,7 @@ ivas_error IVAS_DEC_GetEditableParameters( move32(); hIvasEditableParameters->ism_metadata[obj].radius_fx = 0; move16(); - hIvasEditableParameters->ism_metadata[obj].gain_fx = ONE_IN_Q31; // TODO check Q-value + hIvasEditableParameters->ism_metadata[obj].gain_fx = ONE_IN_Q29; // TODO check Q-value move32(); hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = 0; move16(); @@ -4097,7 +4097,7 @@ ivas_error IVAS_DEC_GetEditableParameters( hIvasEditableParameters->ism_metadata[obj].radius_fx = hIvasDec->st_ivas->hIsmMetaData[obj]->radius_fx; /* reset the otherwise unused "gain" field for the object */ - hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain_fx = ONE_IN_Q12; + hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain_fx = ONE_IN_Q29; hIvasEditableParameters->ism_metadata[obj].gain_fx = hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain_fx; hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = hIvasDec->st_ivas->hIsmMetaData[obj]->non_diegetic_flag; } @@ -4124,7 +4124,7 @@ ivas_error IVAS_DEC_GetEditableParameters( hIvasEditableParameters->ism_metadata[obj].radius_fx = hIvasDec->st_ivas->hIsmMetaData[obj]->radius_fx; /* reset the otherwise unused "gain" field for the object */ - hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain_fx = ONE_IN_Q12; + hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain_fx = ONE_IN_Q29; hIvasEditableParameters->ism_metadata[obj].gain_fx = hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain_fx; hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = hIvasDec->st_ivas->hIsmMetaData[obj]->non_diegetic_flag; } @@ -4222,7 +4222,7 @@ ivas_error IVAS_DEC_SetEditableParameters( #ifdef OBJ_EDITING_PARAMISM_BIN hIvasDec->st_ivas->hParamIsmDec->edited_azimuth_values_fx[obj] = hIvasEditableParameters.ism_metadata[obj].azimuth_fx; hIvasDec->st_ivas->hParamIsmDec->edited_elevation_values_fx[obj] = hIvasEditableParameters.ism_metadata[obj].elevation_fx; - hIvasDec->st_ivas->hMasaIsmData->gain_ism_edited_fx[obj] = extract_l( hIvasEditableParameters.ism_metadata[obj].gain_fx ); // TODO: Check incoming Q-value + hIvasDec->st_ivas->hMasaIsmData->gain_ism_edited_fx[obj] = shr( extract_h( hIvasEditableParameters.ism_metadata[obj].gain_fx ), Q1 ); // Q29 -> Q12 /* Detect direction editing in Param-ISM mode */ IF( GT_32( L_abs( L_sub( hIvasDec->st_ivas->hParamIsmDec->azimuth_values_fx[obj], hIvasEditableParameters.ism_metadata[obj].azimuth_fx ) ), OMASA_AZI_EDIT_THR_FX ) || @@ -4236,7 +4236,7 @@ ivas_error IVAS_DEC_SetEditableParameters( } /* Detect gain editing in Param-ISM mode */ - IF( GT_32( L_abs( sub( ONE_IN_Q12, extract_l( hIvasEditableParameters.ism_metadata[obj].gain_fx ) ) ), OMASA_GAIN_EDIT_THR_FX ) ) // TODO: check Q values + IF( GT_16( abs( sub( ONE_IN_Q12, shr( extract_h( hIvasEditableParameters.ism_metadata[obj].gain_fx ), Q1 ) ) ), OMASA_GAIN_EDIT_THR_FX ) ) // TODO: check Q values { hIvasDec->st_ivas->hMasaIsmData->ism_gain_is_edited_fx[obj] = 1; } @@ -4336,10 +4336,10 @@ ivas_error IVAS_DEC_SetEditableParameters( } /* compare pre-edit gain and the edited one to detect editing */ - IF( GT_16( abs_s( sub( extract_l( hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain_fx ), extract_l( hIvasEditableParameters.ism_metadata[obj].gain_fx ) ) ), OMASA_GAIN_EDIT_THR_FX ) ) // TODO: check incoming Q value + IF( GT_16( abs_s( sub( shr( extract_h( hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain_fx ), Q1 ), shr( extract_h( hIvasEditableParameters.ism_metadata[obj].gain_fx ), Q1 ) ) ), OMASA_GAIN_EDIT_THR_FX ) ) // TODO: check incoming Q value { hIvasDec->st_ivas->hMasaIsmData->ism_gain_is_edited_fx[obj] = 1; - hIvasDec->st_ivas->hMasaIsmData->gain_ism_edited_fx[obj] = extract_l( hIvasEditableParameters.ism_metadata[obj].gain_fx ); + hIvasDec->st_ivas->hMasaIsmData->gain_ism_edited_fx[obj] = shr( extract_h( hIvasEditableParameters.ism_metadata[obj].gain_fx ), Q1 ); // Q29 --> Q12 } ELSE { @@ -4360,9 +4360,9 @@ ivas_error IVAS_DEC_SetEditableParameters( } } - IF( GT_16( abs_s( sub( extract_l( hIvasEditableParameters.gain_bed_fx ), ONE_IN_Q12 ) ), OMASA_GAIN_EDIT_THR_FX ) ) // TODO: check Q value + IF( GT_16( abs_s( sub( shr( extract_h( hIvasEditableParameters.gain_bed_fx ), Q1 ), ONE_IN_Q12 ) ), OMASA_GAIN_EDIT_THR_FX ) ) // TODO: check Q value { - hIvasDec->st_ivas->hMasaIsmData->gain_masa_edited_fx = extract_l( hIvasEditableParameters.gain_bed_fx ); // TODO: check type + hIvasDec->st_ivas->hMasaIsmData->gain_masa_edited_fx = shr( extract_h( hIvasEditableParameters.gain_bed_fx ), Q1 ); // TODO: check type move32(); hIvasDec->st_ivas->hMasaIsmData->masa_gain_is_edited_fx = 1; } diff --git a/lib_rend/ivas_objectRenderer_fx.c b/lib_rend/ivas_objectRenderer_fx.c index 23f6881ab..0b1e221cc 100644 --- a/lib_rend/ivas_objectRenderer_fx.c +++ b/lib_rend/ivas_objectRenderer_fx.c @@ -962,7 +962,7 @@ ivas_error ivas_td_binaural_renderer_ext_fx( hIsmMetaData[0]->radius_fx = currentPos->radius_fx; move32(); #ifdef OBJ_EDITING_INTERFACE - hIsmMetaData[0]->gain_fx = ONE_IN_Q31; // TODO: check Q value + hIsmMetaData[0]->gain_fx = ONE_IN_Q29; // TODO: check Q value #endif hIsmMetaData[0]->non_diegetic_flag = currentPos->non_diegetic_flag; move16(); diff --git a/lib_rend/ivas_objectRenderer_sources_fx.c b/lib_rend/ivas_objectRenderer_sources_fx.c index 03c74b20e..e7ad3bdc1 100644 --- a/lib_rend/ivas_objectRenderer_sources_fx.c +++ b/lib_rend/ivas_objectRenderer_sources_fx.c @@ -704,7 +704,7 @@ static void TDREND_SRC_SPATIAL_SetGain( const Word32 Gain /* i : Front-pointing vector */ ) { - Src_p->SrcRend_p->SrcGain_p_fx[0] = add( extract_h( L_shr( Gain, Q1 ) ), 1 ); // TODO: Check incoming Q-value and fix this + Src_p->SrcRend_p->SrcGain_p_fx[0] = add( shl_sat( extract_h( Gain ), Q1 ), 1 ); // TODO: Check incoming Q-value and fix this } #endif diff --git a/lib_util/ism_file_writer.c b/lib_util/ism_file_writer.c index 10c4332ea..34fb9ae8d 100644 --- a/lib_util/ism_file_writer.c +++ b/lib_util/ism_file_writer.c @@ -118,7 +118,7 @@ ivas_error IsmFileWriter_writeFrame( ismMetadata.elevation = fixedToFloat( ismMetadata.elevation_fx, Q22 ); ismMetadata.radius = fix16_to_float( ismMetadata.radius_fx, Q9 ); ismMetadata.spread = fixedToFloat( ismMetadata.spread_fx, Q22 ); - ismMetadata.gainFactor = fixedToFloat( ismMetadata.gainFactor_fx, Q31 ); // TODO: Change to Q28 or Q12? + ismMetadata.gainFactor = fixedToFloat( ismMetadata.gainFactor_fx, Q29 ); // TODO: Change to Q28 or Q12? ismMetadata.yaw = fixedToFloat( ismMetadata.yaw_fx, Q22 ); ismMetadata.pitch = fixedToFloat( ismMetadata.pitch_fx, Q22 ); -- GitLab From c66f7186c714918d619d78679e0da3a8165b77e5 Mon Sep 17 00:00:00 2001 From: lintervo Date: Fri, 17 Oct 2025 10:06:34 +0300 Subject: [PATCH 25/31] Fix formatting --- lib_com/common_api_types.h | 18 +++++++++--------- lib_dec/ivas_ism_renderer_fx.c | 2 +- lib_dec/ivas_stat_dec.h | 2 +- lib_dec/lib_dec_fx.c | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 41ab8e759..bb0f92445 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -122,13 +122,13 @@ typedef struct _IVAS_ENC_CHANNEL_AWARE_CONFIG typedef struct _IVAS_ISM_METADATA { - Word32 azimuth_fx; /* Q22 */ - Word32 elevation_fx; /* Q22 */ - Word16 radius_fx; /* Q9 */ - Word32 spread_fx; /* Q22 */ - Word32 gainFactor_fx; /* Q29 */ - Word32 yaw_fx; /* Q22 */ - Word32 pitch_fx; /* Q22 */ + Word32 azimuth_fx; /* Q22 */ + Word32 elevation_fx; /* Q22 */ + Word16 radius_fx; /* Q9 */ + Word32 spread_fx; /* Q22 */ + Word32 gainFactor_fx; /* Q29 */ + Word32 yaw_fx; /* Q22 */ + Word32 pitch_fx; /* Q22 */ float azimuth; float elevation; float radius; @@ -138,7 +138,7 @@ typedef struct _IVAS_ISM_METADATA float pitch; Word16 non_diegetic_flag; #ifdef OBJ_EDITING_API - Word32 gain_fx; // Q29 + Word32 gain_fx; // Q29 #endif } IVAS_ISM_METADATA; @@ -148,7 +148,7 @@ typedef struct _IVAS_EDITABLE_PARAMETERS { Word16 num_obj; IVAS_ISM_METADATA ism_metadata[IVAS_MAX_NUM_OBJECTS]; - Word32 gain_bed_fx; // Q29 + Word32 gain_bed_fx; // Q29 } IVAS_EDITABLE_PARAMETERS; #endif diff --git a/lib_dec/ivas_ism_renderer_fx.c b/lib_dec/ivas_ism_renderer_fx.c index 1fdedfcb6..3b64ee536 100644 --- a/lib_dec/ivas_ism_renderer_fx.c +++ b/lib_dec/ivas_ism_renderer_fx.c @@ -283,7 +283,7 @@ void ivas_ism_render_sf_fx( IF( NE_32( st_ivas->hIsmMetaData[i]->edited_gain_fx, ONE_IN_Q29 ) ) { v_multc_fx( st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIsmMetaData[i]->edited_gain_fx, st_ivas->hIsmRendererData->gains_fx[i], nchan_out_woLFE ); // Q30, Q29 --> Q28 - Scale_sig32( st_ivas->hIsmRendererData->gains_fx[i], nchan_out_woLFE, Q2 ); // Q28 --> Q30 + Scale_sig32( st_ivas->hIsmRendererData->gains_fx[i], nchan_out_woLFE, Q2 ); // Q28 --> Q30 } #endif } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 3de03cec6..67db903d8 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -721,7 +721,7 @@ typedef struct ivas_osba_data Word16 delayBuffer_nchan; #ifdef OBJ_EDITING_API - Word32 gain_bed_fx; // Q29 + Word32 gain_bed_fx; // Q29 #endif } SBA_ISM_DATA, *SBA_ISM_DATA_HANDLE; diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index d45e226d2..bc8ee493e 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -4360,7 +4360,7 @@ ivas_error IVAS_DEC_SetEditableParameters( } } - IF( GT_16( abs_s( sub( shr( extract_h( hIvasEditableParameters.gain_bed_fx ), Q1 ), ONE_IN_Q12 ) ), OMASA_GAIN_EDIT_THR_FX ) ) // TODO: check Q value + IF( GT_16( abs_s( sub( shr( extract_h( hIvasEditableParameters.gain_bed_fx ), Q1 ), ONE_IN_Q12 ) ), OMASA_GAIN_EDIT_THR_FX ) ) // TODO: check Q value { hIvasDec->st_ivas->hMasaIsmData->gain_masa_edited_fx = shr( extract_h( hIvasEditableParameters.gain_bed_fx ), Q1 ); // TODO: check type move32(); -- GitLab From a7cf377d40470722be4dcd2f621c6f23685eec42 Mon Sep 17 00:00:00 2001 From: lintervo Date: Fri, 17 Oct 2025 10:26:58 +0300 Subject: [PATCH 26/31] Fix issues --- lib_dec/lib_dec_fx.c | 2 +- lib_rend/ivas_objectRenderer_sources_fx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index bc8ee493e..be15cf579 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -4236,7 +4236,7 @@ ivas_error IVAS_DEC_SetEditableParameters( } /* Detect gain editing in Param-ISM mode */ - IF( GT_16( abs( sub( ONE_IN_Q12, shr( extract_h( hIvasEditableParameters.ism_metadata[obj].gain_fx ), Q1 ) ) ), OMASA_GAIN_EDIT_THR_FX ) ) // TODO: check Q values + IF( GT_16( abs_s( sub( ONE_IN_Q12, shr( extract_h( hIvasEditableParameters.ism_metadata[obj].gain_fx ), Q1 ) ) ), OMASA_GAIN_EDIT_THR_FX ) ) // TODO: check Q values { hIvasDec->st_ivas->hMasaIsmData->ism_gain_is_edited_fx[obj] = 1; } diff --git a/lib_rend/ivas_objectRenderer_sources_fx.c b/lib_rend/ivas_objectRenderer_sources_fx.c index e7ad3bdc1..781fe52ce 100644 --- a/lib_rend/ivas_objectRenderer_sources_fx.c +++ b/lib_rend/ivas_objectRenderer_sources_fx.c @@ -704,7 +704,7 @@ static void TDREND_SRC_SPATIAL_SetGain( const Word32 Gain /* i : Front-pointing vector */ ) { - Src_p->SrcRend_p->SrcGain_p_fx[0] = add( shl_sat( extract_h( Gain ), Q1 ), 1 ); // TODO: Check incoming Q-value and fix this + Src_p->SrcRend_p->SrcGain_p_fx[0] = shl_sat( extract_h( Gain ), Q1 ); // TODO: Check incoming Q-value and fix this } #endif -- GitLab From 89291396513546df4bc32d0e7faa35f589cc032e Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 17 Oct 2025 11:50:40 +0200 Subject: [PATCH 27/31] enable experimental object-editing example --- apps/decoder.c | 68 +++++++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index ed7fd576f..2b9a37c85 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -2159,40 +2159,40 @@ static ivas_error decodeG192( /* put the objects equally spaced at the horizontal plane */ /* and play a little bit with the gains... */ - // int16_t obj_idx, non_diegetic_obj_idx; - // int16_t num_nondiegetic_objects; - // - // num_nondiegetic_objects = 0; - // for ( obj_idx = 0; obj_idx < editableParameters.num_obj; obj_idx++ ) - // { - // if ( !editableParameters.ism_metadata[obj_idx].non_diegetic_flag ) - // { - // num_nondiegetic_objects++; - // } - // } - // if ( num_nondiegetic_objects ) - // { - // float start_angle, angle_inc; - // angle_inc = 360.0f / (float) num_nondiegetic_objects; - // start_angle = angle_inc / 2.0f; - // for ( obj_idx = 0, non_diegetic_obj_idx = 0; obj_idx < editableParameters.num_obj; obj_idx++ ) - // { - // if ( !editableParameters.ism_metadata[obj_idx].non_diegetic_flag ) - // { - // editableParameters.ism_metadata[obj_idx].elevation = 0.0f; - // editableParameters.ism_metadata[obj_idx].azimuth = start_angle + (float) non_diegetic_obj_idx * angle_inc; - // non_diegetic_obj_idx++; - // } - // } - // } - // - // /* breakover object gains */ - // for ( obj_idx = 0; obj_idx < editableParameters.num_obj; obj_idx++ ) - // { - // editableParameters.ism_metadata[obj_idx].gain = 0.5f + (float) ( ( frame + obj_idx * 50 ) % 250 ) / 250.0f; - // } - // - // editableParameters.gain_bed = 0.5f; + Word16 obj_idx, non_diegetic_obj_idx; + Word16 num_nondiegetic_objects; + + num_nondiegetic_objects = 0; + for ( obj_idx = 0; obj_idx < editableParameters.num_obj; obj_idx++ ) + { + if ( !editableParameters.ism_metadata[obj_idx].non_diegetic_flag ) + { + num_nondiegetic_objects++; + } + } + if ( num_nondiegetic_objects ) + { + float start_angle, angle_inc; + angle_inc = 360.0f / (float) num_nondiegetic_objects; + start_angle = angle_inc / 2.0f; + for ( obj_idx = 0, non_diegetic_obj_idx = 0; obj_idx < editableParameters.num_obj; obj_idx++ ) + { + if ( !editableParameters.ism_metadata[obj_idx].non_diegetic_flag ) + { + editableParameters.ism_metadata[obj_idx].elevation_fx = 0; + editableParameters.ism_metadata[obj_idx].azimuth_fx = (Word32) ( (start_angle + (float) non_diegetic_obj_idx * angle_inc) * powf(2.0f, 22.0f) ); + non_diegetic_obj_idx++; + } + } + } + + /* breakover object gains */ + for ( obj_idx = 0; obj_idx < editableParameters.num_obj; obj_idx++ ) + { + editableParameters.ism_metadata[obj_idx].gain_fx = (Word32) ( ( 0.5f + (float) ( ( frame + obj_idx * 50 ) % 250 ) / 250.0f ) * powf(2.0f, 29.0f) ); + } + + editableParameters.gain_bed_fx = (1 << 28); // 0.5 in Q29 /* set new object parameters*/ if ( ( error = IVAS_DEC_SetEditableParameters( hIvasDec, editableParameters ) ) != IVAS_ERR_OK ) -- GitLab From d0705dc6cc68df851a3cdbc4e1f9a1c419a9d310 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 17 Oct 2025 11:53:41 +0200 Subject: [PATCH 28/31] fix formatting --- apps/decoder.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 2b9a37c85..0bb428c49 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -2180,7 +2180,7 @@ static ivas_error decodeG192( if ( !editableParameters.ism_metadata[obj_idx].non_diegetic_flag ) { editableParameters.ism_metadata[obj_idx].elevation_fx = 0; - editableParameters.ism_metadata[obj_idx].azimuth_fx = (Word32) ( (start_angle + (float) non_diegetic_obj_idx * angle_inc) * powf(2.0f, 22.0f) ); + editableParameters.ism_metadata[obj_idx].azimuth_fx = (Word32) ( ( start_angle + (float) non_diegetic_obj_idx * angle_inc ) * powf( 2.0f, 22.0f ) ); non_diegetic_obj_idx++; } } @@ -2189,10 +2189,10 @@ static ivas_error decodeG192( /* breakover object gains */ for ( obj_idx = 0; obj_idx < editableParameters.num_obj; obj_idx++ ) { - editableParameters.ism_metadata[obj_idx].gain_fx = (Word32) ( ( 0.5f + (float) ( ( frame + obj_idx * 50 ) % 250 ) / 250.0f ) * powf(2.0f, 29.0f) ); + editableParameters.ism_metadata[obj_idx].gain_fx = (Word32) ( ( 0.5f + (float) ( ( frame + obj_idx * 50 ) % 250 ) / 250.0f ) * powf( 2.0f, 29.0f ) ); } - editableParameters.gain_bed_fx = (1 << 28); // 0.5 in Q29 + editableParameters.gain_bed_fx = ( 1 << 28 ); // 0.5 in Q29 /* set new object parameters*/ if ( ( error = IVAS_DEC_SetEditableParameters( hIvasDec, editableParameters ) ) != IVAS_ERR_OK ) -- GitLab From 12a07ec0582e37491401bd465c2056b2c8ed3bbf Mon Sep 17 00:00:00 2001 From: lintervo Date: Fri, 17 Oct 2025 15:56:04 +0300 Subject: [PATCH 29/31] Address comments --- lib_dec/lib_dec_fx.c | 7 ++----- .../ivas_dirac_dec_binaural_functions_fx.c | 18 +++++++++--------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index be15cf579..c801aef5b 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -4146,9 +4146,6 @@ ivas_error IVAS_DEC_SetEditableParameters( IVAS_DEC_HANDLE hIvasDec, IVAS_EDITABLE_PARAMETERS hIvasEditableParameters ) { -#if 0 - ivas_error error; -#endif #ifdef OMASA_OBJECT_EDITING Word16 dirac_read_idx; #endif @@ -4270,13 +4267,13 @@ ivas_error IVAS_DEC_SetEditableParameters( /* first, need to convert float values to ints used internally */ Word16 new_azi, new_ele; new_azi = extract_l( L_shr( L_add( L_abs( hIvasEditableParameters.ism_metadata[obj].azimuth_fx ), 2097152 ), Q22 ) ); // Q22->Q0 - if ( hIvasEditableParameters.ism_metadata[obj].azimuth_fx < 0 ) + IF( LT_32( hIvasEditableParameters.ism_metadata[obj].azimuth_fx, 0 ) ) { new_azi = negate( new_azi ); } new_ele = extract_l( L_shr( L_add( L_abs( hIvasEditableParameters.ism_metadata[obj].elevation_fx ), 2097152 ), Q22 ) ); // Q22->Q0 - if ( hIvasEditableParameters.ism_metadata[obj].elevation_fx < 0 ) + IF( LT_32( hIvasEditableParameters.ism_metadata[obj].elevation_fx, 0 ) ) { new_ele = negate( new_ele ); } diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 20dda6420..891ade369 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -5578,7 +5578,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( max_band = 0; move16(); test(); - WHILE( sub( MAX_PARAM_ISM_NBANDS, max_band ) > 0 && sub( nBins, hParamIsmDec->hParamIsm->band_grouping[max_band] ) > 0 ) + WHILE( GT_16( sub( MAX_PARAM_ISM_NBANDS, max_band ), 0 ) && GT_16( sub( nBins, hParamIsmDec->hParamIsm->band_grouping[max_band] ), 0 ) ) { max_band++; } @@ -5838,7 +5838,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( { #endif test(); - WHILE( ( sub( MASA_FREQUENCY_BANDS, max_band ) > 0 ) && ( sub( nBins, MASA_band_grouping_24[max_band] ) > 0 ) ) + WHILE( GT_16( sub( MASA_FREQUENCY_BANDS, max_band ), 0 ) && GT_16( sub( nBins, MASA_band_grouping_24[max_band] ), 0 ) ) { max_band++; } @@ -5847,7 +5847,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( ELSE { test(); - WHILE( ( sub( MAX_PARAM_ISM_NBANDS, max_band ) > 0 ) && ( sub( nBins, hParamIsmDec->hParamIsm->band_grouping[max_band] ) > 0 ) ) + WHILE( GT_16( sub( MAX_PARAM_ISM_NBANDS, max_band ), 0 ) && GT_16( sub( nBins, hParamIsmDec->hParamIsm->band_grouping[max_band] ), 0 ) ) { max_band++; } @@ -6268,7 +6268,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( /* Determine new energetic values after gaining */ totalTargetEne = L_add( totalTargetEneCh[0], totalTargetEneCh[1] ); // SubQ - IF( totalTargetEne > 0 ) + IF( GT_32( totalTargetEne, 0 ) ) { tempDivisor = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q28, max( EPSILON_FX, totalTargetEne ), &temp_q ); @@ -6411,7 +6411,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( move32(); move32(); - IF( hMasaIsmData->enePreserveIIR_fx[ch][band_idx] > 0 ) + IF( GT_32( hMasaIsmData->enePreserveIIR_fx[ch][band_idx], 0 ) ) { temp = BASOP_Util_Divide3232_Scale_newton( hMasaIsmData->enePreserveIIR_fx[ch][band_idx], L_max( 1, hMasaIsmData->eneOrigIIR_fx[band_idx] ), &temp_q ); temp_q = sub( Q31, sub( sub( Q31, temp_q ), sub( hMasaIsmData->enePreserveIIR_e[ch][band_idx], hMasaIsmData->eneOrigIIR_e[band_idx] ) ) ); @@ -6444,7 +6444,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( move32(); move16(); - IF( hMasaIsmData->eneMoveIIR_fx[ch][band_idx] > 0 ) + IF( GT_32( hMasaIsmData->eneMoveIIR_fx[ch][band_idx], 0 ) ) { temp = BASOP_Util_Divide3232_Scale_newton( hMasaIsmData->eneMoveIIR_fx[ch][band_idx], L_max( 1, hMasaIsmData->eneOrigIIR_fx[band_idx] ), &temp_q ); temp_q = sub( Q31, sub( sub( Q31, temp_q ), sub( hMasaIsmData->eneMoveIIR_e[ch][band_idx], hMasaIsmData->eneOrigIIR_e[band_idx] ) ) ); @@ -6644,7 +6644,7 @@ void ivas_omasa_preProcessStereoTransportsForMovedObjects_fx( } /* Bypass processing until first object is moved */ - IF( hMasaIsmData->objectsMoved == 0 ) + IF( EQ_16( hMasaIsmData->objectsMoved, 0 ) ) { FOR( ismDirIndex = 0; ismDirIndex < hSpatParamRendCom->numIsmDirections; ismDirIndex++ ) { @@ -6654,7 +6654,7 @@ void ivas_omasa_preProcessStereoTransportsForMovedObjects_fx( move16(); } } - IF( hMasaIsmData->objectsMoved == 0 ) + IF( EQ_16( hMasaIsmData->objectsMoved, 0 ) ) { /* No objects have moved so far */ return; @@ -6711,7 +6711,7 @@ void ivas_omasa_preProcessStereoTransportsForMovedObjects_fx( subframeEne_fx = L_add( Enes_fx[0], Enes_fx[1] ); // Q = *cldfb_buf_q + *cldfb_buf_q - 31 = Q-19 - IF( subframeEne_fx != 0 ) + IF( NE_32( subframeEne_fx, 0 ) ) { normEnes_fx[0] = BASOP_Util_Divide3232_Scale( Enes_fx[0], subframeEne_fx, &temp_q ); move32(); -- GitLab From 8bd6dcf17505a8f164660baadb3346f4b414b06f Mon Sep 17 00:00:00 2001 From: lintervo Date: Fri, 17 Oct 2025 16:00:11 +0300 Subject: [PATCH 30/31] Harmonize hMasaIsm struct members --- lib_dec/ivas_ism_param_dec_fx.c | 4 +- lib_dec/ivas_ism_renderer_fx.c | 12 ++--- lib_dec/ivas_jbm_dec_fx.c | 4 +- lib_dec/ivas_masa_dec_fx.c | 10 ++-- lib_dec/ivas_omasa_dec_fx.c | 54 +++++++++---------- lib_dec/ivas_stat_dec.h | 18 +++---- lib_dec/lib_dec_fx.c | 40 +++++++------- .../ivas_dirac_dec_binaural_functions_fx.c | 40 +++++++------- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 8 +-- 9 files changed, 95 insertions(+), 95 deletions(-) diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index db97c98d6..7e25eeb09 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -2159,8 +2159,8 @@ void ivas_param_ism_params_to_masa_param_mapping_fx( { FOR( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) { - hMasaIsmData->azimuth_ism[obj][sf_idx] = extract_l( L_shr( ( L_add( hParamIsmDec->azimuth_values_fx[obj], ( 1 << 21 ) ) ), 22 ) ); // Q0 - hMasaIsmData->elevation_ism[obj][sf_idx] = extract_l( L_shr_r( L_add( hParamIsmDec->elevation_values_fx[obj], ( 1 << 21 ) ), 22 ) ); // Scale to Q0 + hMasaIsmData->azimuth_ism_fx[obj][sf_idx] = extract_l( L_shr( ( L_add( hParamIsmDec->azimuth_values_fx[obj], ( 1 << 21 ) ) ), 22 ) ); // Q0 + hMasaIsmData->elevation_ism_fx[obj][sf_idx] = extract_l( L_shr_r( L_add( hParamIsmDec->elevation_values_fx[obj], ( 1 << 21 ) ), 22 ) ); // Scale to Q0 } hMasaIsmData->azimuth_ism_edited_fx[obj] = extract_l( L_shr( ( L_add( hParamIsmDec->edited_azimuth_values_fx[obj], ( 1 << 21 ) ) ), 22 ) ); diff --git a/lib_dec/ivas_ism_renderer_fx.c b/lib_dec/ivas_ism_renderer_fx.c index 3b64ee536..e9edd161c 100644 --- a/lib_dec/ivas_ism_renderer_fx.c +++ b/lib_dec/ivas_ism_renderer_fx.c @@ -630,7 +630,7 @@ void ivas_omasa_separate_object_render_jbm_fx( { #ifdef OMASA_OBJECT_EDITING test(); - IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) && st_ivas->hMasaIsmData->ism_dir_is_edited_fx[st_ivas->hMasaIsmData->idx_separated_ism] ) + IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) && st_ivas->hMasaIsmData->ism_dir_is_edited[st_ivas->hMasaIsmData->idx_separated_ism] ) { azimuth = st_ivas->hMasaIsmData->azimuth_ism_edited_fx[st_ivas->hMasaIsmData->idx_separated_ism]; move16(); @@ -639,9 +639,9 @@ void ivas_omasa_separate_object_render_jbm_fx( } ELSE { - azimuth = st_ivas->hMasaIsmData->azimuth_separated_ism[md_idx]; + azimuth = st_ivas->hMasaIsmData->azimuth_separated_ism_fx[md_idx]; move16(); - elevation = st_ivas->hMasaIsmData->elevation_separated_ism[md_idx]; + elevation = st_ivas->hMasaIsmData->elevation_separated_ism_fx[md_idx]; move16(); } #else @@ -654,7 +654,7 @@ void ivas_omasa_separate_object_render_jbm_fx( ELSE { #ifdef OMASA_OBJECT_EDITING - IF( st_ivas->hMasaIsmData->ism_dir_is_edited_fx[obj] ) + IF( st_ivas->hMasaIsmData->ism_dir_is_edited[obj] ) { azimuth = st_ivas->hMasaIsmData->azimuth_ism_edited_fx[obj]; move16(); @@ -663,9 +663,9 @@ void ivas_omasa_separate_object_render_jbm_fx( } ELSE { - azimuth = st_ivas->hMasaIsmData->azimuth_ism[obj][md_idx]; + azimuth = st_ivas->hMasaIsmData->azimuth_ism_fx[obj][md_idx]; move16(); - elevation = st_ivas->hMasaIsmData->elevation_ism[obj][md_idx]; + elevation = st_ivas->hMasaIsmData->elevation_ism_fx[obj][md_idx]; move16(); } #else diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 5f30937e9..086102fdc 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -4723,7 +4723,7 @@ void ivas_jbm_dec_prepare_renderer( v_multc_fx_16( st_ivas->hTcBuffer->tc_fx[CPE_CHANNELS + n], OMASA_TDREND_MATCHING_GAIN_FX, st_ivas->hTcBuffer->tc_fx[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available ); - IF( st_ivas->hMasaIsmData->ism_gain_is_edited_fx[n] ) + IF( st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) { v_multc_fx_16( st_ivas->hTcBuffer->tc_fx[CPE_CHANNELS + n], st_ivas->hMasaIsmData->gain_ism_edited_fx[n], st_ivas->hTcBuffer->tc_fx[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available ); Scale_sig32( st_ivas->hTcBuffer->tc_fx[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available, Q3 ); // Q8 -> Q11 @@ -4739,7 +4739,7 @@ void ivas_jbm_dec_prepare_renderer( test(); IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) ) { - IF( st_ivas->hMasaIsmData->masa_gain_is_edited_fx ) + IF( st_ivas->hMasaIsmData->masa_gain_is_edited ) { FOR( n = 0; n < 2; n++ ) { diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c index e9404ef41..1938761f2 100644 --- a/lib_dec/ivas_masa_dec_fx.c +++ b/lib_dec/ivas_masa_dec_fx.c @@ -501,9 +501,9 @@ ivas_error ivas_masa_decode_fx( FOR( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) { meta_write_index = add( st_ivas->hSpatParamRendCom->dirac_bs_md_write_idx, sf ) % st_ivas->hSpatParamRendCom->dirac_md_buffer_length; - st_ivas->hMasaIsmData->azimuth_separated_ism[meta_write_index] = st_ivas->hMasaIsmData->azimuth_ism[obj][meta_write_index]; + st_ivas->hMasaIsmData->azimuth_separated_ism_fx[meta_write_index] = st_ivas->hMasaIsmData->azimuth_ism_fx[obj][meta_write_index]; move16(); - st_ivas->hMasaIsmData->elevation_separated_ism[meta_write_index] = st_ivas->hMasaIsmData->elevation_ism[obj][meta_write_index]; + st_ivas->hMasaIsmData->elevation_separated_ism_fx[meta_write_index] = st_ivas->hMasaIsmData->elevation_ism_fx[obj][meta_write_index]; move16(); } } @@ -3359,7 +3359,7 @@ static Word16 ivas_decode_masaism_metadata_fx( FOR( obj = 0; obj < nchan_ism; obj++ ) { #ifdef OMASA_OBJECT_EDITING - hMasaIsmData->bits_ism_fx[obj] = bits_ism[obj]; + hMasaIsmData->bits_ism[obj] = bits_ism[obj]; #endif index = 0; move16(); @@ -3437,9 +3437,9 @@ static Word16 ivas_decode_masaism_metadata_fx( Word16 int_azi = rint_fx( L_shr( azimuth, Q22 - 16 ) ); // Q0, extra -16 is added as int_azi is W16 and azimuth is W32 Word16 int_ele = rint_fx( L_shr( elevation, Q22 - 16 ) ); // Q0 - hMasaIsmData->azimuth_ism[obj][meta_write_index] = int_azi; // Q0 + hMasaIsmData->azimuth_ism_fx[obj][meta_write_index] = int_azi; // Q0 move16(); - hMasaIsmData->elevation_ism[obj][meta_write_index] = int_ele; // Q0 + hMasaIsmData->elevation_ism_fx[obj][meta_write_index] = int_ele; // Q0 move16(); } } diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index cdc2615b8..bc822cd71 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -357,7 +357,7 @@ ivas_error ivas_omasa_data_open_fx( move32(); } - hMasaIsmData->objectsEdited_fx = 0; + hMasaIsmData->objectsEdited = 0; move32(); #else FOR( bin = 0; bin < CLDFB_NO_CHANNELS_MAX; bin++ ) @@ -388,8 +388,8 @@ ivas_error ivas_omasa_data_open_fx( FOR( ch = 0; ch < MAX_NUM_OBJECTS; ch++ ) { #ifdef OMASA_OBJECT_EDITING - hMasaIsmData->ism_dir_is_edited_fx[ch] = 0; - hMasaIsmData->ism_gain_is_edited_fx[ch] = 0; + hMasaIsmData->ism_dir_is_edited[ch] = 0; + hMasaIsmData->ism_gain_is_edited[ch] = 0; #else hMasaIsmData->ism_is_edited[ch] = 0; move16(); @@ -401,22 +401,22 @@ ivas_error ivas_omasa_data_open_fx( } #ifdef OMASA_OBJECT_EDITING - hMasaIsmData->masa_gain_is_edited_fx = 0; + hMasaIsmData->masa_gain_is_edited = 0; hMasaIsmData->idx_separated_ism = -1; move16(); #endif FOR( obj_idx = 0; obj_idx < MAX_NUM_OBJECTS; obj_idx++ ) { - set16_fx( hMasaIsmData->azimuth_ism[obj_idx], 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR ); - set16_fx( hMasaIsmData->elevation_ism[obj_idx], 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR ); + set16_fx( hMasaIsmData->azimuth_ism_fx[obj_idx], 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR ); + set16_fx( hMasaIsmData->elevation_ism_fx[obj_idx], 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR ); FOR( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR; sf++ ) { set32_fx( hMasaIsmData->energy_ratio_ism_fx[obj_idx][sf], 0, CLDFB_NO_CHANNELS_MAX ); } } - set16_fx( hMasaIsmData->azimuth_separated_ism, 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR ); - set16_fx( hMasaIsmData->elevation_separated_ism, 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR ); + set16_fx( hMasaIsmData->azimuth_separated_ism_fx, 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR ); + set16_fx( hMasaIsmData->elevation_separated_ism_fx, 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR ); hMasaIsmData->hExtData = NULL; move32(); @@ -1090,9 +1090,9 @@ ivas_error ivas_omasa_ism_metadata_dec_fx( { meta_write_index = ( add( dirac_bs_md_write_idx, block ) ) % st_ivas->hSpatParamRendCom->dirac_md_buffer_length; move16(); - st_ivas->hMasaIsmData->azimuth_ism[n][meta_write_index] = azimuth_ism; + st_ivas->hMasaIsmData->azimuth_ism_fx[n][meta_write_index] = azimuth_ism; move16(); - st_ivas->hMasaIsmData->elevation_ism[n][meta_write_index] = elevation_ism; + st_ivas->hMasaIsmData->elevation_ism_fx[n][meta_write_index] = elevation_ism; move16(); } } @@ -1114,9 +1114,9 @@ ivas_error ivas_omasa_ism_metadata_dec_fx( { meta_write_index = ( add( dirac_bs_md_write_idx, block ) ) % st_ivas->hSpatParamRendCom->dirac_md_buffer_length; move16(); - st_ivas->hMasaIsmData->azimuth_separated_ism[meta_write_index] = azimuth_ism; + st_ivas->hMasaIsmData->azimuth_separated_ism_fx[meta_write_index] = azimuth_ism; move16(); - st_ivas->hMasaIsmData->elevation_separated_ism[meta_write_index] = elevation_ism; + st_ivas->hMasaIsmData->elevation_separated_ism_fx[meta_write_index] = elevation_ism; move16(); } } @@ -1136,15 +1136,15 @@ ivas_error ivas_omasa_ism_metadata_dec_fx( FOR( block = 0; block < 2; block++ ) { - st_ivas->hMasaIsmData->azimuth_separated_ism[block] = st_ivas->hMasaIsmData->azimuth_separated_ism[add( block, 2 )]; - st_ivas->hMasaIsmData->elevation_separated_ism[block] = st_ivas->hMasaIsmData->elevation_separated_ism[add( block, 2 )]; + st_ivas->hMasaIsmData->azimuth_separated_ism_fx[block] = st_ivas->hMasaIsmData->azimuth_separated_ism_fx[add( block, 2 )]; + st_ivas->hMasaIsmData->elevation_separated_ism_fx[block] = st_ivas->hMasaIsmData->elevation_separated_ism_fx[add( block, 2 )]; move16(); move16(); } FOR( block = 2; block < MAX_PARAM_SPATIAL_SUBFRAMES; block++ ) { - st_ivas->hMasaIsmData->azimuth_separated_ism[block] = azimuth_ism; - st_ivas->hMasaIsmData->elevation_separated_ism[block] = elevation_ism; + st_ivas->hMasaIsmData->azimuth_separated_ism_fx[block] = azimuth_ism; + st_ivas->hMasaIsmData->elevation_separated_ism_fx[block] = elevation_ism; move16(); move16(); } @@ -1191,7 +1191,7 @@ void ivas_omasa_dirac_rend_jbm_fx( FOR( n = 0; n < st_ivas->nchan_ism; n++ ) { test(); - IF( st_ivas->hMasaIsmData->ism_gain_is_edited_fx[n] && EQ_16( st_ivas->hMasaIsmData->idx_separated_ism, n ) ) + IF( st_ivas->hMasaIsmData->ism_gain_is_edited[n] && EQ_16( st_ivas->hMasaIsmData->idx_separated_ism, n ) ) { v_multc_fx_16( data_separated_objects[0], st_ivas->hMasaIsmData->gain_ism_edited_fx[n], data_separated_objects[0], *nSamplesRendered ); // Q = 8 Scale_sig32( data_separated_objects[0], *nSamplesRendered, Q3 ); // Q = 11 @@ -1207,7 +1207,7 @@ void ivas_omasa_dirac_rend_jbm_fx( Copy32( &output_f[n + CPE_CHANNELS][st_ivas->hTcBuffer->n_samples_rendered], data_separated_objects[n], *nSamplesRendered ); #ifdef OMASA_OBJECT_EDITING /* Gain discrete objects, if edited */ - IF( st_ivas->hMasaIsmData->ism_gain_is_edited_fx[n] ) + IF( st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) { v_multc_fx_16( data_separated_objects[n], st_ivas->hMasaIsmData->gain_ism_edited_fx[n], data_separated_objects[n], *nSamplesRendered ); // Q = 8 Scale_sig32( data_separated_objects[n], *nSamplesRendered, Q3 ); // Q = 11 @@ -1216,7 +1216,7 @@ void ivas_omasa_dirac_rend_jbm_fx( } #ifdef OMASA_OBJECT_EDITING /* Gain MASA part, if edited */ - IF( st_ivas->hMasaIsmData->masa_gain_is_edited_fx ) + IF( st_ivas->hMasaIsmData->masa_gain_is_edited ) { FOR( n = 0; n < 2; n++ ) { @@ -1598,8 +1598,8 @@ void ivas_omasa_combine_separate_ism_with_masa_fx( { Word32 ele, azi; - ele = st_ivas->hMasaIsmData->elevation_separated_ism[sf]; - azi = st_ivas->hMasaIsmData->azimuth_separated_ism[sf]; + ele = st_ivas->hMasaIsmData->elevation_separated_ism_fx[sf]; + azi = st_ivas->hMasaIsmData->azimuth_separated_ism_fx[sf]; directionIndex = index_theta_phi_16_fx( &ele, &azi, st_ivas->hMasa->data.sph_grid16 ); @@ -1625,10 +1625,10 @@ void ivas_omasa_combine_separate_ism_with_masa_fx( eneIsm_frac, eneIsm_exp ); /* Mix the separated object audio signal to the MASA audio signals */ - ivas_get_stereo_panning_gains_fx( st_ivas->hMasaIsmData->azimuth_separated_ism[0], - st_ivas->hMasaIsmData->elevation_separated_ism[0], old_panning_gains_q15_fx ); - ivas_get_stereo_panning_gains_fx( st_ivas->hMasaIsmData->azimuth_separated_ism[2], - st_ivas->hMasaIsmData->elevation_separated_ism[2], new_panning_gains_q15_fx ); + ivas_get_stereo_panning_gains_fx( st_ivas->hMasaIsmData->azimuth_separated_ism_fx[0], + st_ivas->hMasaIsmData->elevation_separated_ism_fx[0], old_panning_gains_q15_fx ); + ivas_get_stereo_panning_gains_fx( st_ivas->hMasaIsmData->azimuth_separated_ism_fx[2], + st_ivas->hMasaIsmData->elevation_separated_ism_fx[2], new_panning_gains_q15_fx ); /* Subsequent processing in Q31 format */ FOR( n = 0; n < MASA_MAX_TRANSPORT_CHANNELS; n++ ) @@ -1847,8 +1847,8 @@ void ivas_omasa_render_objects_from_mix_fx( FOR( n = 0; n < nchan_ism; n++ ) { // Q0 -> Q22 - Word32 azi = L_shl( st_ivas->hMasaIsmData->azimuth_ism[n][st_ivas->hSpatParamRendCom->dirac_read_idx], Q22 ); - Word32 ele = L_shl( st_ivas->hMasaIsmData->elevation_ism[n][st_ivas->hSpatParamRendCom->dirac_read_idx], Q22 ); + Word32 azi = L_shl( st_ivas->hMasaIsmData->azimuth_ism_fx[n][st_ivas->hSpatParamRendCom->dirac_read_idx], Q22 ); + Word32 ele = L_shl( st_ivas->hMasaIsmData->elevation_ism_fx[n][st_ivas->hSpatParamRendCom->dirac_read_idx], Q22 ); st_ivas->hIsmMetaData[n]->azimuth_fx = azi; st_ivas->hIsmMetaData[n]->elevation_fx = ele; diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 67db903d8..64657a00d 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -955,8 +955,8 @@ typedef struct ivas_masa_ism_ext_data_structure /* Data structure for MASA_ISM rendering */ typedef struct ivas_masa_ism_data_structure { - Word16 azimuth_ism[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; // Q0 - Word16 elevation_ism[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; // Q0 + Word16 azimuth_ism_fx[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; // Q0 + Word16 elevation_ism_fx[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; // Q0 Word32 energy_ratio_ism_fx[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR][CLDFB_NO_CHANNELS_MAX]; /* Q30 */ Word32 masa_to_total_energy_ratio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; /* Q30 */ @@ -964,7 +964,7 @@ typedef struct ivas_masa_ism_data_structure Word16 elevation_ism_edited_fx[MAX_NUM_OBJECTS]; // Q0 #ifdef OMASA_OBJECT_EDITING - UWord8 ism_dir_is_edited_fx[MAX_NUM_OBJECTS]; + UWord8 ism_dir_is_edited[MAX_NUM_OBJECTS]; #else UWord8 ism_is_edited[MAX_NUM_OBJECTS]; #endif @@ -975,9 +975,9 @@ typedef struct ivas_masa_ism_data_structure #ifdef OMASA_OBJECT_EDITING Word16 gain_ism_edited_fx[MAX_NUM_OBJECTS]; // Q12 - UWord8 ism_gain_is_edited_fx[MAX_NUM_OBJECTS]; + UWord8 ism_gain_is_edited[MAX_NUM_OBJECTS]; Word16 gain_masa_edited_fx; // Q12 - UWord8 masa_gain_is_edited_fx; + UWord8 masa_gain_is_edited; #else Word16 azimuth_ism_edited[MAX_NUM_OBJECTS]; Word16 elevation_ism_edited[MAX_NUM_OBJECTS]; @@ -985,14 +985,14 @@ typedef struct ivas_masa_ism_data_structure #endif Word16 idx_separated_ism; - Word16 azimuth_separated_ism[MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; - Word16 elevation_separated_ism[MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; + Word16 azimuth_separated_ism_fx[MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; + Word16 elevation_separated_ism_fx[MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; Word32 q_azimuth_old_fx[MAX_NUM_OBJECTS]; /* Q22 */ Word32 q_elevation_old_fx[MAX_NUM_OBJECTS]; /* Q22 */ #ifdef OMASA_OBJECT_EDITING - UWord8 objectsEdited_fx; + UWord8 objectsEdited; Word32 preprocEneTarget_fx[MASA_FREQUENCY_BANDS]; Word16 preprocEneTarget_e[MASA_FREQUENCY_BANDS]; Word32 preprocEneRealized_fx[MASA_FREQUENCY_BANDS]; @@ -1005,7 +1005,7 @@ typedef struct ivas_masa_ism_data_structure Word16 enePreserveIIR_e[2][MASA_FREQUENCY_BANDS]; Word32 eneOrigIIR_fx[MASA_FREQUENCY_BANDS]; Word16 eneOrigIIR_e[MASA_FREQUENCY_BANDS]; - Word16 bits_ism_fx[MAX_NUM_OBJECTS]; + Word16 bits_ism[MAX_NUM_OBJECTS]; #else Word16 ismPreprocMatrix_fx[2][2][CLDFB_NO_CHANNELS_MAX]; /* Q15 */ UWord8 objectsMoved; diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index c801aef5b..34ebf27f4 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -4116,8 +4116,8 @@ ivas_error IVAS_DEC_GetEditableParameters( FOR( obj = 0; obj < hIvasEditableParameters->num_obj; obj++ ) { - hIvasEditableParameters->ism_metadata[obj].azimuth_fx = L_shl( L_deposit_l( hIvasDec->st_ivas->hMasaIsmData->azimuth_ism[obj][dirac_read_idx] ), Q22 ); - hIvasEditableParameters->ism_metadata[obj].elevation_fx = L_shl( L_deposit_l( hIvasDec->st_ivas->hMasaIsmData->elevation_ism[obj][dirac_read_idx] ), Q22 ); + hIvasEditableParameters->ism_metadata[obj].azimuth_fx = L_shl( L_deposit_l( hIvasDec->st_ivas->hMasaIsmData->azimuth_ism_fx[obj][dirac_read_idx] ), Q22 ); + hIvasEditableParameters->ism_metadata[obj].elevation_fx = L_shl( L_deposit_l( hIvasDec->st_ivas->hMasaIsmData->elevation_ism_fx[obj][dirac_read_idx] ), Q22 ); hIvasEditableParameters->ism_metadata[obj].yaw_fx = hIvasDec->st_ivas->hIsmMetaData[obj]->yaw_fx; hIvasEditableParameters->ism_metadata[obj].pitch_fx = hIvasDec->st_ivas->hIsmMetaData[obj]->pitch_fx; @@ -4225,27 +4225,27 @@ ivas_error IVAS_DEC_SetEditableParameters( IF( GT_32( L_abs( L_sub( hIvasDec->st_ivas->hParamIsmDec->azimuth_values_fx[obj], hIvasEditableParameters.ism_metadata[obj].azimuth_fx ) ), OMASA_AZI_EDIT_THR_FX ) || GT_32( L_abs( L_sub( hIvasDec->st_ivas->hParamIsmDec->elevation_values_fx[obj], hIvasEditableParameters.ism_metadata[obj].elevation_fx ) ), OMASA_ELE_EDIT_THR_FX ) ) { - hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited_fx[obj] = 1; + hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited[obj] = 1; } ELSE { - hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited_fx[obj] = 0; + hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited[obj] = 0; } /* Detect gain editing in Param-ISM mode */ IF( GT_16( abs_s( sub( ONE_IN_Q12, shr( extract_h( hIvasEditableParameters.ism_metadata[obj].gain_fx ), Q1 ) ) ), OMASA_GAIN_EDIT_THR_FX ) ) // TODO: check Q values { - hIvasDec->st_ivas->hMasaIsmData->ism_gain_is_edited_fx[obj] = 1; + hIvasDec->st_ivas->hMasaIsmData->ism_gain_is_edited[obj] = 1; } ELSE { - hIvasDec->st_ivas->hMasaIsmData->ism_gain_is_edited_fx[obj] = 0; + hIvasDec->st_ivas->hMasaIsmData->ism_gain_is_edited[obj] = 0; } #endif } #ifdef OBJ_EDITING_PARAMISM_BIN /* MASA is not present with the ISM format */ - hIvasDec->st_ivas->hMasaIsmData->masa_gain_is_edited_fx = 0; + hIvasDec->st_ivas->hMasaIsmData->masa_gain_is_edited = 0; #endif } ELSE @@ -4295,23 +4295,23 @@ ivas_error IVAS_DEC_SetEditableParameters( * which in turn depends from the object priority and importance: * importance -> priority -> number of bits -> elevation resolution -> elevation ring index -> azimuth resolution. * leading to elevation_resolution -> elevation threshold and azimuth resolution -> azimuth threshold */ - id_th = extract_l( L_shr( L_add( Mpy_32_16_1( delta_theta_masa_inv_fx[hIvasDec->st_ivas->hMasaIsmData->bits_ism_fx[obj] - 3], abs_s( hIvasDec->st_ivas->hMasaIsmData->elevation_ism[obj][dirac_read_idx] ) ), 32768 ), 16 ) ); // + 0.5f in Q16 - threshold_azi = Mpy_32_32( 1509949440, no_phi_masa_inv_fx[hIvasDec->st_ivas->hMasaIsmData->bits_ism_fx[obj] - 1][id_th] ); // Q = 22; - threshold_ele = delta_theta_masa_fx[hIvasDec->st_ivas->hMasaIsmData->bits_ism_fx[obj] - 3]; + id_th = extract_l( L_shr( L_add( Mpy_32_16_1( delta_theta_masa_inv_fx[hIvasDec->st_ivas->hMasaIsmData->bits_ism[obj] - 3], abs_s( hIvasDec->st_ivas->hMasaIsmData->elevation_ism_fx[obj][dirac_read_idx] ) ), 32768 ), 16 ) ); // + 0.5f in Q16 + threshold_azi = Mpy_32_32( 1509949440, no_phi_masa_inv_fx[hIvasDec->st_ivas->hMasaIsmData->bits_ism[obj] - 1][id_th] ); // Q = 22; + threshold_ele = delta_theta_masa_fx[hIvasDec->st_ivas->hMasaIsmData->bits_ism[obj] - 3]; test(); - IF( ( GT_32( L_shl( abs_s( sub( new_azi, hIvasDec->st_ivas->hMasaIsmData->azimuth_ism[obj][dirac_read_idx] ) ), 22 ), threshold_azi ) ) || - ( GT_32( L_shl( abs_s( sub( new_ele, hIvasDec->st_ivas->hMasaIsmData->elevation_ism[obj][dirac_read_idx] ) ), 22 ), threshold_ele ) ) ) + IF( ( GT_32( L_shl( abs_s( sub( new_azi, hIvasDec->st_ivas->hMasaIsmData->azimuth_ism_fx[obj][dirac_read_idx] ) ), 22 ), threshold_azi ) ) || + ( GT_32( L_shl( abs_s( sub( new_ele, hIvasDec->st_ivas->hMasaIsmData->elevation_ism_fx[obj][dirac_read_idx] ) ), 22 ), threshold_ele ) ) ) { /* at least one of the threshold is exceeded, so use new direction value and set editing detection flag */ hIvasDec->st_ivas->hMasaIsmData->azimuth_ism_edited_fx[obj] = new_azi; hIvasDec->st_ivas->hMasaIsmData->elevation_ism_edited_fx[obj] = new_ele; - hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited_fx[obj] = 1; + hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited[obj] = 1; } ELSE { - hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited_fx[obj] = 0; + hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited[obj] = 0; } } ELSE @@ -4324,23 +4324,23 @@ ivas_error IVAS_DEC_SetEditableParameters( hIvasDec->st_ivas->hMasaIsmData->azimuth_ism_edited_fx[obj] = new_azi; hIvasDec->st_ivas->hMasaIsmData->elevation_ism_edited_fx[obj] = new_ele; - hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited_fx[obj] = 1; + hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited[obj] = 1; } ELSE { - hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited_fx[obj] = 0; + hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited[obj] = 0; } } /* compare pre-edit gain and the edited one to detect editing */ IF( GT_16( abs_s( sub( shr( extract_h( hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain_fx ), Q1 ), shr( extract_h( hIvasEditableParameters.ism_metadata[obj].gain_fx ), Q1 ) ) ), OMASA_GAIN_EDIT_THR_FX ) ) // TODO: check incoming Q value { - hIvasDec->st_ivas->hMasaIsmData->ism_gain_is_edited_fx[obj] = 1; + hIvasDec->st_ivas->hMasaIsmData->ism_gain_is_edited[obj] = 1; hIvasDec->st_ivas->hMasaIsmData->gain_ism_edited_fx[obj] = shr( extract_h( hIvasEditableParameters.ism_metadata[obj].gain_fx ), Q1 ); // Q29 --> Q12 } ELSE { - hIvasDec->st_ivas->hMasaIsmData->ism_gain_is_edited_fx[obj] = 0u; + hIvasDec->st_ivas->hMasaIsmData->ism_gain_is_edited[obj] = 0u; } } @@ -4361,11 +4361,11 @@ ivas_error IVAS_DEC_SetEditableParameters( { hIvasDec->st_ivas->hMasaIsmData->gain_masa_edited_fx = shr( extract_h( hIvasEditableParameters.gain_bed_fx ), Q1 ); // TODO: check type move32(); - hIvasDec->st_ivas->hMasaIsmData->masa_gain_is_edited_fx = 1; + hIvasDec->st_ivas->hMasaIsmData->masa_gain_is_edited = 1; } ELSE { - hIvasDec->st_ivas->hMasaIsmData->masa_gain_is_edited_fx = 0; + hIvasDec->st_ivas->hMasaIsmData->masa_gain_is_edited = 0; } } #endif diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 891ade369..e6c8df704 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -1722,7 +1722,7 @@ static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices_fx( ismDirIndex = sub( dirIndex, hSpatParamRendCom->numParametricDirections ); assert( hMasaIsmData != NULL && "hMasaIsmData should not be NULL if we use it" ); #ifdef OMASA_OBJECT_EDITING - IF( hMasaIsmData->ism_dir_is_edited_fx[ismDirIndex] ) + IF( hMasaIsmData->ism_dir_is_edited[ismDirIndex] ) { aziDeg = hMasaIsmData->azimuth_ism_edited_fx[ismDirIndex]; move16(); @@ -1740,9 +1740,9 @@ static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices_fx( #endif ELSE { - aziDeg = hMasaIsmData->azimuth_ism[ismDirIndex][dirac_read_idx]; + aziDeg = hMasaIsmData->azimuth_ism_fx[ismDirIndex][dirac_read_idx]; move16(); - eleDeg = hMasaIsmData->elevation_ism[ismDirIndex][dirac_read_idx]; + eleDeg = hMasaIsmData->elevation_ism_fx[ismDirIndex][dirac_read_idx]; move16(); } ratio_fx = hMasaIsmData->energy_ratio_ism_fx[ismDirIndex][dirac_read_idx][bin]; @@ -2593,7 +2593,7 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( IF( EQ_16( ism_mode, ISM_MASA_MODE_DISC ) ) { #ifdef OMASA_OBJECT_EDITING - IF( hMasaIsmData->ism_dir_is_edited_fx[chB] ) + IF( hMasaIsmData->ism_dir_is_edited[chB] ) { aziDeg = hMasaIsmData->azimuth_ism_edited_fx[chB]; move16(); @@ -2602,9 +2602,9 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( } ELSE { - aziDeg = hMasaIsmData->azimuth_ism[chB][dirac_read_idx]; + aziDeg = hMasaIsmData->azimuth_ism_fx[chB][dirac_read_idx]; move16(); - eleDeg = hMasaIsmData->elevation_ism[chB][dirac_read_idx]; + eleDeg = hMasaIsmData->elevation_ism_fx[chB][dirac_read_idx]; move16(); } #else @@ -2618,7 +2618,7 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( { #ifdef OMASA_OBJECT_EDITING test(); - IF( ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ && hMasaIsmData->ism_dir_is_edited_fx[hMasaIsmData->idx_separated_ism] ) + IF( ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ && hMasaIsmData->ism_dir_is_edited[hMasaIsmData->idx_separated_ism] ) { aziDeg = hMasaIsmData->azimuth_ism_edited_fx[hMasaIsmData->idx_separated_ism]; move16(); @@ -2627,9 +2627,9 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( } ELSE { - aziDeg = hMasaIsmData->azimuth_separated_ism[dirac_read_idx]; + aziDeg = hMasaIsmData->azimuth_separated_ism_fx[dirac_read_idx]; move16(); - eleDeg = hMasaIsmData->elevation_separated_ism[dirac_read_idx]; + eleDeg = hMasaIsmData->elevation_separated_ism_fx[dirac_read_idx]; move16(); } #else @@ -5462,39 +5462,39 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( FOR( ismDirIndex = 0; ismDirIndex < n_ism; ismDirIndex++ ) { - ismGainEdited[ismDirIndex] = hMasaIsmData->ism_gain_is_edited_fx[ismDirIndex]; + ismGainEdited[ismDirIndex] = hMasaIsmData->ism_gain_is_edited[ismDirIndex]; move16(); - ismDirEdited[ismDirIndex] = hMasaIsmData->ism_dir_is_edited_fx[ismDirIndex]; + ismDirEdited[ismDirIndex] = hMasaIsmData->ism_dir_is_edited[ismDirIndex]; move16(); } - masaGainEdited = hMasaIsmData->masa_gain_is_edited_fx; + masaGainEdited = hMasaIsmData->masa_gain_is_edited; move16(); /* Bypass processing until first object is moved or gained */ - IF( EQ_32( hMasaIsmData->objectsEdited_fx, 0 ) ) + IF( EQ_32( hMasaIsmData->objectsEdited, 0 ) ) { FOR( ismDirIndex = 0; ismDirIndex < n_ism; ismDirIndex++ ) { IF( ismDirEdited[ismDirIndex] ) { - hMasaIsmData->objectsEdited_fx = 1; + hMasaIsmData->objectsEdited = 1; move16(); } IF( ismGainEdited[ismDirIndex] ) { - hMasaIsmData->objectsEdited_fx = 1; + hMasaIsmData->objectsEdited = 1; move16(); } } IF( masaGainEdited ) { - hMasaIsmData->objectsEdited_fx = 1; + hMasaIsmData->objectsEdited = 1; move16(); } - IF( EQ_32( hMasaIsmData->objectsEdited_fx, 0 ) ) + IF( EQ_32( hMasaIsmData->objectsEdited, 0 ) ) { /* No objects have moved so far */ return; @@ -5510,7 +5510,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( /* ISM gaining */ FOR( ch = 0; ch < n_ism; ch++ ) { - IF( st_ivas->hMasaIsmData->ism_gain_is_edited_fx[ch] ) + IF( st_ivas->hMasaIsmData->ism_gain_is_edited[ch] ) { FOR( slot = 0; slot < hSpatParamRendCom->subframe_nbslots[subframe]; slot++ ) { @@ -5800,8 +5800,8 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( FOR( ismDirIndex = 0; ismDirIndex < n_ism; ismDirIndex++ ) { /* Get input and output panning gains */ - ivas_get_stereo_panning_gains_fx( hMasaIsmData->azimuth_ism[ismDirIndex][dirac_read_idx], - hMasaIsmData->elevation_ism[ismDirIndex][dirac_read_idx], + ivas_get_stereo_panning_gains_fx( hMasaIsmData->azimuth_ism_fx[ismDirIndex][dirac_read_idx], + hMasaIsmData->elevation_ism_fx[ismDirIndex][dirac_read_idx], panGainsIn[ismDirIndex] ); // Q15 IF( ismDirEdited[ismDirIndex] ) diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index d7d26707b..e79973c77 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -2854,7 +2854,7 @@ void ivas_dirac_dec_compute_directional_responses_fx( FOR( dir = 0; dir < hSpatParamRendCom->numIsmDirections; dir++ ) { #ifdef OMASA_OBJECT_EDITING - IF( hMasaIsm->ism_dir_is_edited_fx[dir] ) + IF( hMasaIsm->ism_dir_is_edited[dir] ) { ivas_dirac_dec_get_response_fx( hMasaIsm->azimuth_ism_edited_fx[dir], hMasaIsm->elevation_ism_edited_fx[dir], direct_response_temp_fx, hDirACRend->hOutSetup.ambisonics_order, Q29 ); } @@ -2866,7 +2866,7 @@ void ivas_dirac_dec_compute_directional_responses_fx( #endif ELSE { - ivas_dirac_dec_get_response_fx( hMasaIsm->azimuth_ism[dir][md_idx], hMasaIsm->elevation_ism[dir][md_idx], direct_response_temp_fx, hDirACRend->hOutSetup.ambisonics_order, Q29 ); + ivas_dirac_dec_get_response_fx( hMasaIsm->azimuth_ism_fx[dir][md_idx], hMasaIsm->elevation_ism_fx[dir][md_idx], direct_response_temp_fx, hDirACRend->hOutSetup.ambisonics_order, Q29 ); } exp_direct_response_temp = 2; move16(); @@ -3112,7 +3112,7 @@ void ivas_dirac_dec_compute_directional_responses_fx( FOR( dir = 0; dir < hSpatParamRendCom->numIsmDirections; dir++ ) { #ifdef OMASA_OBJECT_EDITING - IF( hMasaIsm->ism_dir_is_edited_fx[dir] ) + IF( hMasaIsm->ism_dir_is_edited[dir] ) { vbap_determine_gains_fx( hVBAPdata, direct_response_temp_fx, hMasaIsm->azimuth_ism_edited_fx[dir], hMasaIsm->elevation_ism_edited_fx[dir], 1 ); } @@ -3124,7 +3124,7 @@ void ivas_dirac_dec_compute_directional_responses_fx( #endif ELSE { - vbap_determine_gains_fx( hVBAPdata, direct_response_temp_fx, hMasaIsm->azimuth_ism[dir][md_idx], hMasaIsm->elevation_ism[dir][md_idx], 1 ); + vbap_determine_gains_fx( hVBAPdata, direct_response_temp_fx, hMasaIsm->azimuth_ism_fx[dir][md_idx], hMasaIsm->elevation_ism_fx[dir][md_idx], 1 ); } Word32 tmp = 0; move32(); -- GitLab From 9f9d95601b084f9f02c00d5c44b8b614c75689a0 Mon Sep 17 00:00:00 2001 From: lintervo Date: Fri, 17 Oct 2025 16:02:45 +0300 Subject: [PATCH 31/31] Fix formatting --- lib_dec/ivas_stat_dec.h | 4 ++-- lib_dec/lib_dec_fx.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 64657a00d..68188621f 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -955,8 +955,8 @@ typedef struct ivas_masa_ism_ext_data_structure /* Data structure for MASA_ISM rendering */ typedef struct ivas_masa_ism_data_structure { - Word16 azimuth_ism_fx[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; // Q0 - Word16 elevation_ism_fx[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; // Q0 + Word16 azimuth_ism_fx[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; // Q0 + Word16 elevation_ism_fx[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; // Q0 Word32 energy_ratio_ism_fx[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR][CLDFB_NO_CHANNELS_MAX]; /* Q30 */ Word32 masa_to_total_energy_ratio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; /* Q30 */ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 34ebf27f4..3d1c4366e 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -4296,7 +4296,7 @@ ivas_error IVAS_DEC_SetEditableParameters( * importance -> priority -> number of bits -> elevation resolution -> elevation ring index -> azimuth resolution. * leading to elevation_resolution -> elevation threshold and azimuth resolution -> azimuth threshold */ id_th = extract_l( L_shr( L_add( Mpy_32_16_1( delta_theta_masa_inv_fx[hIvasDec->st_ivas->hMasaIsmData->bits_ism[obj] - 3], abs_s( hIvasDec->st_ivas->hMasaIsmData->elevation_ism_fx[obj][dirac_read_idx] ) ), 32768 ), 16 ) ); // + 0.5f in Q16 - threshold_azi = Mpy_32_32( 1509949440, no_phi_masa_inv_fx[hIvasDec->st_ivas->hMasaIsmData->bits_ism[obj] - 1][id_th] ); // Q = 22; + threshold_azi = Mpy_32_32( 1509949440, no_phi_masa_inv_fx[hIvasDec->st_ivas->hMasaIsmData->bits_ism[obj] - 1][id_th] ); // Q = 22; threshold_ele = delta_theta_masa_fx[hIvasDec->st_ivas->hMasaIsmData->bits_ism[obj] - 3]; test(); -- GitLab