From f98e6425a345a2b4acfa95cb265b10cdbb27bf9f Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 8 Oct 2025 12:12:38 +0200 Subject: [PATCH 01/46] port changes from the float branches here --- apps/decoder.c | 37 +- lib_com/common_api_types.h | 12 + lib_com/ivas_ism_com_fx.c | 11 + lib_com/ivas_prot_fx.h | 31 + lib_com/ivas_stat_com.h | 12 + lib_com/options.h | 8 + lib_dec/ivas_dirac_dec_fx.c | 3 + lib_dec/ivas_ism_param_dec_fx.c | 205 +++++- lib_dec/ivas_ism_renderer_fx.c | 11 + lib_dec/ivas_jbm_dec_fx.c | 229 ++++++- lib_dec/ivas_mc_param_dec_fx.c | 201 +++++- lib_dec/ivas_objectRenderer_internal_fx.c | 24 + lib_dec/ivas_stat_dec.h | 13 + lib_dec/lib_dec.h | 28 + lib_dec/lib_dec_fx.c | 730 +++++++++++++++++++--- lib_rend/ivas_objectRenderer_fx.c | 3 + lib_rend/ivas_objectRenderer_sources_fx.c | 4 + 17 files changed, 1449 insertions(+), 113 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index deb97aeff..83c5dfbf2 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -2265,6 +2265,24 @@ static ivas_error decodeG192( } } #endif + +#ifdef FIX_HRTF_LOAD_API + /* decode transport channels, do TSM and feed to renderer */ + if ( ( error = IVAS_DEC_GetSamplesDecoder( hIvasDec, isSplitRend, splitRendBits ) ) != IVAS_ERR_OK ) + { + return error; + } + +#endif +#ifdef OBJ_EDITING_API + /* Do the final preparations needed for rendering */ + if ( ( error = IVAS_DEC_PrepareRenderer( hIvasDec ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError: could not prepare the renderer: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } +#endif + } if ( isSplitRend ) @@ -2714,6 +2732,9 @@ static ivas_error decodeVoIP( int16_t nOutSamples = 0; #ifdef FIX_CREND_SIMPLIFY_CODE bool bitstreamReadDone = false; +#ifdef OBJ_EDITING_API + bool parametersAvailableForEditing = false; +#endif uint16_t nSamplesRendered; #endif @@ -3005,13 +3026,21 @@ static ivas_error decodeVoIP( #endif #ifdef SUPPORT_JBM_TRACEFILE #ifdef FIX_CREND_SIMPLIFY_CODE +#ifdef OBJ_EDITING_API + if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, (void *) pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter, &bitstreamReadDone, &nSamplesRendered, ¶metersAvailableForEditing ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, (void *) pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter, &bitstreamReadDone, &nSamplesRendered ) ) != IVAS_ERR_OK ) +#endif #else if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter ) ) != IVAS_ERR_OK ) #endif #else #ifdef FIX_CREND_SIMPLIFY_CODE +#ifdef OBJ_EDITING_API + if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, (void *) pcmBuf, systemTime_ms, &bitstreamReadDone, ¶metersAvailableForEditing ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, (void *) pcmBuf, systemTime_ms, &bitstreamReadDone ) ) != IVAS_ERR_OK ) +#endif #else if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, pcmBuf, systemTime_ms ) ) != IVAS_ERR_OK ) #endif @@ -3046,8 +3075,14 @@ static ivas_error decodeVoIP( } } #endif +#ifdef OBJ_EDITING_API + if ( parametersAvailableForEditing == true ) + { + /* do the object editing here */ + } +#endif #ifdef FIX_HRTF_LOAD - } + } /* while ( nSamplesRendered < nOutSamples ) */ #endif /* write JBM Offset file entry */ diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 112d82607..948ce1ff7 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -137,9 +137,21 @@ typedef struct _IVAS_ISM_METADATA float yaw; float pitch; Word16 non_diegetic_flag; +#ifdef OBJ_EDITING_API + float gain; +#endif } IVAS_ISM_METADATA; +#ifdef OBJ_EDITING_API +typedef struct _IVAS_EDITABLE_PARAMETERS +{ + int16_t num_obj; + IVAS_ISM_METADATA ism_metadata[IVAS_MAX_NUM_OBJECTS]; + float gain_bed; +} IVAS_EDITABLE_PARAMETERS; +#endif + typedef struct { // float w, x, y, z; diff --git a/lib_com/ivas_ism_com_fx.c b/lib_com/ivas_ism_com_fx.c index 7e9ab34cc..3e0d938c4 100644 --- a/lib_com/ivas_ism_com_fx.c +++ b/lib_com/ivas_ism_com_fx.c @@ -470,6 +470,17 @@ void ivas_ism_reset_metadata( hIsmMeta->non_diegetic_flag = 0; move16(); +#ifdef OBJ_EDITING_API + hIsmMeta->edited_gain = 1.0f; + hIsmMeta->edited_azimuth = 0.0f; + hIsmMeta->edited_elevation = 0.0f; + hIsmMeta->edited_pitch = 0.0f; + hIsmMeta->edited_yaw = 0.0f; + hIsmMeta->edited_radius = 1.0f; + hIsmMeta->gain = 1.0f; + hIsmMeta->non_diegetic_flag = 0; +#endif + return; } diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 7c3354dba..9eb954046 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -777,6 +777,12 @@ ivas_error ivas_ism_metadata_dec_fx( DEC_CORE_HANDLE st0 /* i : core-coder handle */ ); +#ifdef OBJ_EDITING_API +void ivas_ism_renderer_update_md( + Decoder_Struct *st_ivas /* i/o: main IVAS decoder handle */ +); +#endif + void ivas_get_ism_sid_quan_bitbudget_fx( const Word16 nchan_ism, /* i : number of objects */ Word16 *nBits_azimuth, /* o : number of Q bits for azimuth */ @@ -4225,6 +4231,12 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( Word32 *data /* i/o: transport channels/output synthesis signal */ ); +#ifdef OBJ_EDITING_API +void ivas_jbm_dec_prepare_renderer( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); +#endif + void ivas_jbm_dec_get_adapted_subframes( const Word16 nCldfbTs, /* i : number of time slots in the current frame */ Word16 *subframe_nbslots, /* i/o: subframe grid */ @@ -4320,6 +4332,18 @@ void ivas_param_ism_dec_digest_tc_fx( Word32 *transport_channels[], /* i : synthesized core-coder transport channels/DirAC output */ Word16 q_tc_in ); + +#ifdef OBJ_EDITING_API +void ivas_param_ism_dec_dequant_md( + Decoder_Struct *st_ivas +); + +void ivas_param_ism_dec_prepare_renderer( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nCldfbSlots /* i : number of CLFBS slots in the transport channels */ +); +#endif + void ivas_param_ism_dec_render_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested */ @@ -5163,6 +5187,13 @@ void ivas_param_mc_dec_digest_tc_fx( Word32 *transport_channels_f_fx[], Word16 transport_f_e ); +#ifdef OBJ_EDITING_API +void ivas_param_mc_dec_prepare_renderer( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint8_t nCldfbSlots /* i : number of CLFBS slots in the transport channels */ +); +#endif + void ivas_param_mc_dec_render_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested */ diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 847442c35..1f13c30be 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -65,6 +65,18 @@ typedef struct Word32 yaw_fx; /* yaw value read from the input metadata file */ /* Q22 */ Word32 pitch_fx; /* pitch value read from the input metadata file */ /* Q22 */ +#ifdef OBJ_EDITING_API + float gain; + + float edited_azimuth; + float edited_elevation; + float edited_radius; + + float edited_yaw; + float edited_pitch; + float edited_gain; +#endif + Word16 non_diegetic_flag; /* Non-diegetic (non-headtracked) object flag */ ISM_METADATA_ANGLE position_angle; /* Angle structs for azimuth and elevation */ diff --git a/lib_com/options.h b/lib_com/options.h index ef687f30e..b961f38ba 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -147,6 +147,14 @@ #define FIX_1387_INIT_PRM_SQQ /* FhG: initialize pointer prm_sqQ, which might be uninitialized in case of bfi == 1 */ #define NONBE_1296_TDREND_ITD_OUT_OF_BOUNDS_ACCESS /* Eri: issue 1296: ITD resampling can occasionally read out of bounds, especially when the requested subframes are short (1.25 ms). Seen for headtracking+JBM. */ +// object-editing feature porting +#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 +#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 +#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 a2b3096a9..8d2ecc08d 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -3837,6 +3837,9 @@ void ivas_dirac_dec_render_sf_fx( const Word32 azi_fx = L_shl( az1_32, Q22 - Q16 ); // Q16 -> Q22 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 + v_multc( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmMetaData[i]->edited_gain, st_ivas->hIsmRendererData->gains[i], nchan_out_woLFE ); +#endif } } diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 53c25b4d5..2a2ff6c18 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -979,18 +979,28 @@ void ivas_ism_dec_digest_tc_fx( IF( EQ_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_STEREO ) ) { +#ifdef OBJ_EDITING_API + ivas_ism_get_stereo_gains( st_ivas->hIsmMetaData[i]->edited_azimuth, st_ivas->hIsmMetaData[i]->edited_elevation, &st_ivas->hIsmRendererData->gains[i][0], &st_ivas->hIsmRendererData->gains[i][1] ); + v_multc( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmMetaData[i]->edited_gain, st_ivas->hIsmRendererData->gains[i], CPE_CHANNELS ); +#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] ); st_ivas->hIsmRendererData->gains_fx[i][0] = L_shr( L_deposit_h( gains_fx[0] ), 1 ); // Q31 -> Q30 move32(); st_ivas->hIsmRendererData->gains_fx[i][1] = L_shr( L_deposit_h( gains_fx[1] ), 1 ); // Q31 -> Q30 move32(); +#endif } ELSE { // TODO tmu review when #215 is resolved +#ifdef OBJ_EDITING_API + azimuth = (int16_t) floorf( st_ivas->hIsmMetaData[i]->edited_azimuth + 0.5f ); + elevation = (int16_t) floorf( st_ivas->hIsmMetaData[i]->edited_elevation + 0.5f ); +#else azimuth_fx = L_shr( L_add( st_ivas->hIsmMetaData[i]->azimuth_fx, 2097152 ), Q22 ); // Q0 ,2097152 = .5f in Q22 elevation_fx = L_shr( L_add( st_ivas->hIsmMetaData[i]->elevation_fx, 2097152 ), Q22 ); // Q0 ,2097152 = .5f in Q22 +#endif test(); test(); @@ -1018,6 +1028,9 @@ void ivas_ism_dec_digest_tc_fx( azimuth_fx = L_shl( azimuth_fx, Q22 ); // Q22 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 + v_multc( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmMetaData[i]->edited_gain, st_ivas->hIsmRendererData->gains[i], st_ivas->hEFAPdata->numSpk ); +#endif } } ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) || @@ -1028,6 +1041,9 @@ void ivas_ism_dec_digest_tc_fx( Word16 azi = shr( extract_h( st_ivas->hIsmMetaData[i]->azimuth_fx ), 22 - 16 ); // Q0 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 + v_multc( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmMetaData[i]->edited_gain, st_ivas->hIsmRendererData->gains[i], ivas_sba_get_nchan( st_ivas->hIntSetup.ambisonics_order, 0 ) ); +#endif } } } @@ -1052,17 +1068,27 @@ void ivas_param_ism_dec_digest_tc_fx( move16(); move16(); move16(); +#ifndef OBJ_EDITING_API Word32 cx_diag_fx[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX]; Word16 exp_cx_diag[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX]; +#endif Word16 q_tc = q_tc_in; move16(); +#ifndef OBJ_EDITING_API Word16 ch, nchan_transport, nchan_out, nchan_out_woLFE, i; Word16 slot_idx, bin_idx; Word32 ivas_total_brate; +#else + Word16 ch, nchan_transport; + Word16 slot_idx; +#endif + Word16 output_frame; +#ifndef OBJ_EDITING_API /* Direct Response/EFAP Gains */ Word32 direct_response_fx[MAX_NUM_OBJECTS][PARAM_ISM_MAX_CHAN]; +#endif PARAM_ISM_DEC_HANDLE hParamIsmDec; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; Word16 fade_len; @@ -1076,6 +1102,7 @@ void ivas_param_ism_dec_digest_tc_fx( output_frame = imult1616( nCldfbSlots, hSpatParamRendCom->num_freq_bands ); fade_len = shr( output_frame, 1 ); +#ifndef OBJ_EDITING_API nchan_transport = st_ivas->nchan_transport; move16(); ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; @@ -1100,9 +1127,11 @@ void ivas_param_ism_dec_digest_tc_fx( nchan_out_woLFE = st_ivas->hIntSetup.nchan_out_woLFE; move16(); } +#endif push_wmops( "ivas_param_ism_dec" ); +#ifndef OBJ_EDITING_API /* general setup */ ivas_jbm_dec_get_adapted_linear_interpolator_fx( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbSlots, hParamIsmDec->hParamIsmRendering->interpolator_fx ); @@ -1185,6 +1214,7 @@ void ivas_param_ism_dec_digest_tc_fx( } } } +#endif IF( st_ivas->hDecoderConfig->Opt_tsm ) { @@ -1220,6 +1250,7 @@ void ivas_param_ism_dec_digest_tc_fx( hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_exp = sub( 31, q_tc ); move16(); } + Word16 scale_factor_real, scale_factor_imag; Word16 current_idx; exp_real_tmp = hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_exp; @@ -1233,6 +1264,7 @@ void ivas_param_ism_dec_digest_tc_fx( scale_sig32( &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[current_idx], hSpatParamRendCom->num_freq_bands, scale_factor_imag ); // Q(31-(exp_imag_tmp-scale_factor_imag)) exp_real_tmp = sub( exp_real_tmp, scale_factor_real ); exp_imag_tmp = sub( exp_imag_tmp, scale_factor_imag ); +#ifndef OBJ_EDITING_API ivas_param_ism_collect_slot_fx( hParamIsmDec, &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx[current_idx], exp_real_tmp, @@ -1240,6 +1272,7 @@ void ivas_param_ism_dec_digest_tc_fx( exp_imag_tmp, ch, cx_diag_fx, exp_cx_diag ); +#endif exp_real_tmp = add( exp_real_tmp, scale_factor_real ); exp_imag_tmp = add( exp_imag_tmp, scale_factor_imag ); @@ -1247,6 +1280,8 @@ void ivas_param_ism_dec_digest_tc_fx( scale_sig32( &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[current_idx], hSpatParamRendCom->num_freq_bands, -scale_factor_imag ); // Q(31-(exp_imag_tmp)) } } + +#ifndef OBJ_EDITING_API /* Obtain Mixing Matrix on a frame-level */ FOR( bin_idx = 0; bin_idx < CLDFB_NO_CHANNELS_MAX; bin_idx++ ) { @@ -1257,12 +1292,142 @@ void ivas_param_ism_dec_digest_tc_fx( ivas_param_ism_compute_mixing_matrix_fx( st_ivas->nchan_ism, hParamIsmDec, st_ivas->hISMDTX, direct_response_fx, nchan_transport, nchan_out_woLFE, cx_diag_fx, exp_cx_diag, hParamIsmDec->hParamIsmRendering->mixing_matrix_lin_fx, hParamIsmDec->hParamIsmRendering->exp_mixing_matrix_lin_fx ); +#endif pop_wmops(); return; } +#ifdef OBJ_EDITING_API +/*-------------------------------------------------------------------------* + * ivas_param_ism_dec_prepare_renderer() + * + * + *-------------------------------------------------------------------------*/ + +void ivas_param_ism_dec_prepare_renderer( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nCldfbSlots /* i : number of CLFBS slots in the transport channels */ +) +{ + int16_t ch, nchan_transport, nchan_out, nchan_out_woLFE, i; + int16_t slot_idx, bin_idx; + float ref_power[CLDFB_NO_CHANNELS_MAX]; + float cx_diag[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX]; + /* Direct Response/EFAP Gains */ + float direct_response[MAX_NUM_OBJECTS][PARAM_ISM_MAX_CHAN]; + PARAM_ISM_DEC_HANDLE hParamIsmDec; + SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; + + /* Initialization */ + hParamIsmDec = st_ivas->hParamIsmDec; + assert( hParamIsmDec ); + hSpatParamRendCom = st_ivas->hSpatParamRendCom; + assert( hSpatParamRendCom ); + + nchan_transport = st_ivas->nchan_transport; + + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + { + nchan_out = st_ivas->nchan_ism; + nchan_out_woLFE = nchan_out; + st_ivas->hDecoderConfig->nchan_out = nchan_out; + } + else + { + nchan_out = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; + nchan_out_woLFE = st_ivas->hIntSetup.nchan_out_woLFE; + } + + push_wmops( "ivas_param_ism_dec_digest_tc" ); + + /* general setup */ + ivas_jbm_dec_get_adapted_linear_interpolator( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbSlots, hParamIsmDec->hParamIsmRendering->interpolator ); + + ivas_dirac_dec_set_md_map( st_ivas, nCldfbSlots ); + + /* set buffers to zero */ + for ( bin_idx = 0; bin_idx < CLDFB_NO_CHANNELS_MAX; bin_idx++ ) + { + set_zero( cx_diag[bin_idx], PARAM_ISM_MAX_DMX ); + } + set_zero( ref_power, CLDFB_NO_CHANNELS_MAX ); + + /* obtain the direct response using EFAP */ + if ( !( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) ) + { + for ( i = 0; i < st_ivas->nchan_ism; i++ ) + { + efap_determine_gains( st_ivas->hEFAPdata, direct_response[i], hParamIsmDec->edited_azimuth_values[i], hParamIsmDec->edited_elevation_values[i], EFAP_MODE_EFAP ); + } + } + else + { + int16_t j; + + for ( i = 0; i < st_ivas->nchan_ism; i++ ) + { + for ( j = 0; j < nchan_out_woLFE; j++ ) + { + if ( i == j ) + { + direct_response[i][j] = 1.0f; + } + else + { + direct_response[i][j] = 0.0f; + } + } + } + + for ( j = 0; j < nchan_out_woLFE; j++ ) + { + if ( hParamIsmDec->azimuth_values[j] > 0.0f ) + { + hParamIsmDec->hParamIsmRendering->proto_matrix[j] = 1.0f; + hParamIsmDec->hParamIsmRendering->proto_matrix[nchan_out_woLFE + j] = 0.0f; + } + else + { + if ( hParamIsmDec->azimuth_values[j] < 0.0f ) + { + hParamIsmDec->hParamIsmRendering->proto_matrix[j] = 0.0f; + hParamIsmDec->hParamIsmRendering->proto_matrix[nchan_out_woLFE + j] = 1.0f; + } + else /* == 0.0f */ + { + hParamIsmDec->hParamIsmRendering->proto_matrix[j] = 0.5f; + hParamIsmDec->hParamIsmRendering->proto_matrix[nchan_out_woLFE + j] = 0.5f; + } + } + } + } + + for ( ch = 0; ch < nchan_transport; ch++ ) + { + /* CLDFB Analysis */ + for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) + { + ivas_param_ism_collect_slot( hParamIsmDec, &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], ch, ref_power, cx_diag ); + } + } + + /* Obtain Mixing Matrix on a frame-level */ + for ( bin_idx = 0; bin_idx < hSpatParamRendCom->num_freq_bands; bin_idx++ ) + { + set_f( hParamIsmDec->hParamIsmRendering->mixing_matrix_lin[bin_idx], 0.0f, nchan_transport * nchan_out_woLFE ); + } + + /* Compute mixing matrix */ + ivas_param_ism_compute_mixing_matrix( st_ivas->nchan_ism, hParamIsmDec, st_ivas->hISMDTX, direct_response, nchan_transport, nchan_out_woLFE, cx_diag, ref_power, hParamIsmDec->hParamIsmRendering->mixing_matrix_lin ); + + pop_wmops(); + + return; +} +#endif + /*-------------------------------------------------------------------------* * ivas_ism_param_dec_tc_gain_ajust() * @@ -1666,6 +1831,17 @@ void ivas_param_ism_dec_render_fx( /* store MetaData parameters */ FOR( ch = 0; ch < st_ivas->nchan_ism; ch++ ) { +#ifdef OBJ_EDITING_API + if ( st_ivas->hParamIsmDec->azimuth_values_fx[ch] > 180.0f ) + { + st_ivas->hIsmMetaData[ch]->azimuth_fx = st_ivas->hParamIsmDec->edited_azimuth_values_fx[ch] - 360.0f; + } + else + { + st_ivas->hIsmMetaData[ch]->azimuth_fx = st_ivas->hParamIsmDec->edited_azimuth_values_fx[ch]; + } + st_ivas->hIsmMetaData[ch]->elevation_fx = st_ivas->hParamIsmDec->edited_elevation_values_fx[ch]; +#else IF( GT_32( st_ivas->hParamIsmDec->azimuth_values_fx[ch], 754974720 ) /*180.f in Q22*/ ) { st_ivas->hIsmMetaData[ch]->azimuth_fx = L_sub( st_ivas->hParamIsmDec->azimuth_values_fx[ch], 1509949440 ) /*360.0F in Q22*/; @@ -1676,6 +1852,7 @@ void ivas_param_ism_dec_render_fx( st_ivas->hIsmMetaData[ch]->azimuth_fx = st_ivas->hParamIsmDec->azimuth_values_fx[ch]; move32(); } +#endif st_ivas->hIsmMetaData[ch]->elevation_fx = st_ivas->hParamIsmDec->elevation_values_fx[ch]; move32(); @@ -1705,10 +1882,15 @@ void ivas_param_ism_params_to_masa_param_mapping_fx( Word16 azimuth[2]; Word16 elevation[2]; Word16 power_ratio_fx[2]; /* Q15 */ +#ifndef OBJ_EDITING_API Word32 ivas_total_brate; +#endif + + hParamIsmDec = st_ivas->hParamIsmDec; hSpatParamRendCom = st_ivas->hSpatParamRendCom; +#ifndef OBJ_EDITING_API nBins = hSpatParamRendCom->num_freq_bands; move16(); ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; @@ -1724,8 +1906,11 @@ void ivas_param_ism_params_to_masa_param_mapping_fx( } ELSE { - st_ivas->hISMDTX.dtx_flag = 1; - move16(); + +#endif + st_ivas->hISMDTX.dtx_flag = 1; + + move16(); } IF( GT_16( st_ivas->nchan_ism, 1 ) ) @@ -1766,20 +1951,30 @@ void ivas_param_ism_params_to_masa_param_mapping_fx( FOR( band_idx = 0; band_idx < hParamIsmDec->hParamIsm->nbands; band_idx++ ) { brange[0] = hParamIsmDec->hParamIsm->band_grouping[band_idx]; +#ifdef OBJ_EDITING_API + azimuth[0] = (int16_t) roundf( hParamIsmDec->edited_azimuth_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][0]] ); + elevation[0] = (int16_t) roundf( hParamIsmDec->edited_elevation_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][0]] ); +#else 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 +#endif + power_ratio_fx[0] = hParamIsmDec->power_ratios_fx[band_idx][0][0];lues_fx[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][0]], ( 1 << 21 ) ), 22 ) ); // Q0 move16(); power_ratio_fx[0] = hParamIsmDec->power_ratios_fx[band_idx][0][0]; move16(); + +#ifdef OBJ_EDITING_API + azimuth[1] = (int16_t) roundf( hParamIsmDec->edited_azimuth_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][1]] ); + elevation[1] = (int16_t) roundf( hParamIsmDec->edited_elevation_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][1]] ); +#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(); +#endif + power_ratio_fx[1] = hParamIsmDec->power_ratios_fx[band_idx][0][1]; move16(); diff --git a/lib_dec/ivas_ism_renderer_fx.c b/lib_dec/ivas_ism_renderer_fx.c index 11a06abd4..0d79e8807 100644 --- a/lib_dec/ivas_ism_renderer_fx.c +++ b/lib_dec/ivas_ism_renderer_fx.c @@ -259,16 +259,27 @@ void ivas_ism_render_sf_fx( { if ( GE_16( subframe_idx, ism_md_subframe_update_jbm ) ) { +#ifdef OBJ_EDITING_API + rotateAziEle( st_ivas->hIsmMetaData[i]->edited_azimuth, st_ivas->hIsmMetaData[i]->edited_elevation, &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); +#else rotateAziEle_fx( extract_l( L_shr( st_ivas->hIsmMetaData[i]->azimuth_fx, 22 ) ), extract_l( L_shr( st_ivas->hIsmMetaData[i]->elevation_fx, 22 ) ), &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat_fx[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); +#endif } else { +#ifdef OBJ_EDITING_API + rotateAziEle( st_ivas->hIsmMetaData[i]->edited_azimuth, st_ivas->hIsmMetaData[i]->edited_elevation, &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); +#else rotateAziEle_fx( extract_l( L_shr( st_ivas->hIsmMetaData[i]->last_azimuth_fx, 22 ) ), extract_l( L_shr( st_ivas->hIsmMetaData[i]->last_elevation_fx, 22 ) ), &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat_fx[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); +#endif } IF( st_ivas->hEFAPdata != NULL ) { 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 + v_multc( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmMetaData[i]->edited_gain, st_ivas->hIsmRendererData->gains[i], nchan_out_woLFE ); +#endif } } diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index a1988168c..8e6e5fcf3 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -194,6 +194,9 @@ ivas_error ivas_jbm_dec_tc_fx( } } ivas_ism_dtx_limit_noise_energy_for_near_silence_fx( st_ivas->hSCE, st_ivas->hISMDTX.sce_id_dtx, st_ivas->nchan_transport, Q_cngNoiseLevel ); +#ifdef OBJ_EDITING_API + ivas_param_ism_dec_dequant_md_fx( st_ivas ); +#endif } ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) ) { @@ -201,6 +204,9 @@ ivas_error ivas_jbm_dec_tc_fx( { return error; } +#ifdef OBJ_EDITING_API + ivas_param_ism_dec_dequant_md_fx( st_ivas ); +#endif } ELSE /* ISM_MODE_DISC */ { @@ -1581,6 +1587,7 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( } n_render_timeslots = idiv1616( st_ivas->hTcBuffer->n_samples_available, st_ivas->hTcBuffer->n_samples_granularity ); +#ifndef OBJ_EDITING_API test(); IF( EQ_16( st_ivas->hTcBuffer->tc_buffer_mode, TC_BUFFER_MODE_BUFFER ) ) { @@ -1598,12 +1605,15 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( { ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); } - ELSE IF( EQ_16( st_ivas->ivas_format, ISM_FORMAT ) ) + ELSE +#endif + IF( EQ_16( st_ivas->ivas_format, ISM_FORMAT ) ) { /* Rendering */ IF( EQ_16( st_ivas->ism_mode, ISM_MODE_PARAM ) ) { test(); +#ifndef OBJ_EDITING_API test(); test(); IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_16( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) @@ -1612,17 +1622,22 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( ivas_param_ism_params_to_masa_param_mapping_fx( st_ivas ); } - ELSE IF( EQ_16( st_ivas->renderer_type, RENDERER_PARAM_ISM ) || EQ_16( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) + ELSE +#endif + IF( EQ_16( st_ivas->renderer_type, RENDERER_PARAM_ISM ) || EQ_16( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) { ivas_param_ism_dec_digest_tc_fx( st_ivas, n_render_timeslots, p_data_f_fx, Q11 ); } } +#ifndef OBJ_EDITING_API ELSE /* ISM_MODE_DISC */ { ivas_ism_dec_digest_tc_fx( st_ivas ); } +#endif } +#ifndef OBJ_EDITING_API ELSE IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) || EQ_16( st_ivas->ivas_format, MASA_FORMAT ) ) { IF( st_ivas->hSCE[0] ) @@ -1849,6 +1864,15 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); } } +#else + else if ( st_ivas->ivas_format == MC_FORMAT ) + { + if ( st_ivas->mc_mode == MC_MODE_PARAMMC && st_ivas->hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_RENDERER ) + { + ivas_param_mc_dec_digest_tc_fx( st_ivas, (uint8_t) n_render_timeslots, p_data_f ); + } + } +#endif pop_wmops(); return; @@ -2195,7 +2219,35 @@ ivas_error ivas_jbm_dec_render_fx( ivas_ism_render_sf_fx( st_ivas, st_ivas->renderer_type, p_output_fx, *nSamplesRendered ); /* add already rendered SBA part */ - ivas_osba_stereo_add_channels_fx( p_tc_fx, p_output_fx, ONE_IN_Q11, nchan_out, st_ivas->nchan_ism, *nSamplesRendered ); +#ifdef OBJ_EDITING_API + if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + float gain = st_ivas->hSbaIsmData->gain_bed; + if ( gain != 1.0f && gain >= 0.0f ) + { + int16_t i; + for ( n = 0; n < nchan_out; n++ ) + { + for ( i = 0; i < *nSamplesRendered; i++ ) + { + p_output[n][i] += p_tc[n + st_ivas->nchan_ism][i] * gain; + } + } + } + else + { + for ( n = 0; n < nchan_out; n++ ) + { + v_add( p_output[n], p_tc[n + st_ivas->nchan_ism], p_output[n], *nSamplesRendered ); + } + } + } + else +#else + { + ivas_osba_stereo_add_channels_fx( p_tc_fx, p_output_fx, ONE_IN_Q11, nchan_out, st_ivas->nchan_ism, *nSamplesRendered ); + } +#endif } ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_OSBA_AMBI ) || EQ_32( st_ivas->renderer_type, RENDERER_OSBA_LS ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { @@ -4351,3 +4403,174 @@ void ivas_jbm_masa_sf_to_sf_map( return; } + +#ifdef OBJ_EDITING_API +/*--------------------------------------------------------------------------* + * ivas_jbm_dec_prepare_renderer() + * + * prepare IVAS JBM renderer routine + *--------------------------------------------------------------------------*/ + +void ivas_jbm_dec_prepare_renderer( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +) +{ + int16_t n, n_render_timeslots; + + push_wmops( "ivas_jbm_dec_feed_tc_to_rendererer" ); + + n_render_timeslots = st_ivas->hTcBuffer->n_samples_available / st_ivas->hTcBuffer->n_samples_granularity; + + if ( st_ivas->hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_BUFFER ) + { + ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); + + if ( ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) && st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL && st_ivas->hDecoderConfig->Opt_tsm ) + { + ivas_jbm_masa_sf_to_slot_map( st_ivas, n_render_timeslots ); + } + } + else if ( st_ivas->ivas_format == STEREO_FORMAT ) + { + ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); + } + else if ( st_ivas->ivas_format == ISM_FORMAT ) + { + /* Rendering */ + if ( st_ivas->ism_mode == ISM_MODE_PARAM ) + { + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) + { + ivas_dirac_dec_set_md_map( st_ivas, n_render_timeslots ); + ivas_param_ism_params_to_masa_param_mapping( st_ivas ); + } + else if ( st_ivas->renderer_type == RENDERER_PARAM_ISM || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) + { + ivas_param_ism_dec_prepare_renderer( st_ivas, n_render_timeslots ); + } + } + else /* ISM_MODE_DISC */ + { + ivas_ism_dec_digest_tc( st_ivas ); + } + } + else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) + { + ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + } + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + ivas_ism_dec_digest_tc( st_ivas ); + + /* delay the objects here for all renderers where it is needed */ + if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || + st_ivas->renderer_type == RENDERER_OSBA_AMBI || + st_ivas->renderer_type == RENDERER_OSBA_LS || + st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) && + ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + for ( n = 0; n < st_ivas->nchan_ism; n++ ) + { + delay_signal( st_ivas->hTcBuffer->tc[n], st_ivas->hTcBuffer->n_samples_available, st_ivas->hSbaIsmData->delayBuffer[n], st_ivas->hSbaIsmData->delayBuffer_size ); + } + } + + if ( !st_ivas->sba_dirac_stereo_flag ) + { + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) + { + n_render_timeslots *= ( st_ivas->hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size ); + } + + ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + } + } + else + { + ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); + + ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + } + } + else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) + { + if ( st_ivas->renderer_type == RENDERER_OMASA_MIX_EXT || st_ivas->renderer_type == RENDERER_OMASA_OBJECT_EXT ) + { + ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); + + if ( st_ivas->hDecoderConfig->Opt_tsm ) + { + ivas_jbm_masa_sf_to_slot_map( st_ivas, n_render_timeslots ); + } + } + else + { + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + { + n_render_timeslots *= ( st_ivas->hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size ); + } + + ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + + if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + { + ivas_ism_dec_digest_tc( st_ivas ); + } + + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_DIRAC ) + { + int16_t num_objects; + /* Delay the signal to match CLDFB delay. Delay the whole buffer. */ + num_objects = 0; + if ( ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC ) + { + num_objects = 1; + } + else if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + { + num_objects = st_ivas->nchan_ism; + } + for ( n = 0; n < num_objects; n++ ) + { + if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) + { + v_multc( st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], OMASA_TDREND_MATCHING_GAIN, st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available ); + } +#ifndef TMP_FIX_OMASA_SR_BE + if ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#endif + { + delay_signal( st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); + } + } + } + } + } + else if ( st_ivas->ivas_format == MC_FORMAT ) + { + if ( st_ivas->mc_mode == MC_MODE_MCT ) + { + ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); + } + else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) + { + ivas_mc_paramupmix_dec_digest_tc( st_ivas, (uint8_t) n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + } + else if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) + { + ivas_param_mc_dec_prepare_renderer( st_ivas, (uint8_t) n_render_timeslots ); + } + else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) + { + ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + } + } + + pop_wmops(); + return; +} +#endif \ No newline at end of file diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index 243377a49..1be8b3a69 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -1519,11 +1519,16 @@ void ivas_param_mc_dec_digest_tc_fx( Word16 transport_f_e ) { PARAM_MC_DEC_HANDLE hParamMC; +#ifdef OBJ_EDITING_API + Word16 ch, slot_idx; + Word16 nchan_transport +#else Word16 i, ch; Word16 is_next_band, skip_next_band; Word16 slot_idx, param_band_idx; Word16 nchan_transport, nchan_out_transport, nchan_out_cldfb; Word16 nchan_out_cov; +#endif /*CLDFB*/ /* format converter */ Word16 channel_active[MAX_OUTPUT_CHANNELS]; @@ -1531,11 +1536,14 @@ void ivas_param_mc_dec_digest_tc_fx( hParamMC = st_ivas->hParamMC; assert( hParamMC ); + +#ifndef OBJ_EDITING_API Word32 *pCx, *pCx_imag; Word32 cx_fx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; // Q(31 - cx_e) Word32 cx_imag_fx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; // Q(31 - cx_imag_e) Word32 cx_next_band_fx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; // Q(31 - cx_next_band_e) Word32 cx_imag_next_band_fx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; // Q(31 - cx_imag_next_band_e) + Word32 real_part_fx, imag_part_fx, L_tmp1, L_tmp2; Word16 cx_buff_e[2][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; Word16 cx_e; @@ -1543,16 +1551,20 @@ void ivas_param_mc_dec_digest_tc_fx( Word16 cx_imag_next_band_e, cx_next_band_e; Word16 qout = 0; move16(); +#endif - Word32 real_part_fx, imag_part_fx, L_tmp1, L_tmp2; Word16 max_e; push_wmops( "param_mc_dec_digest_tc" ); +#ifndef OBJ_EDITING_API set16_fx( channel_active, 0, MAX_CICP_CHANNELS ); +#endif nchan_transport = st_ivas->nchan_transport; move16(); + +#ifndef OBJ_EDITINGA_API nchan_out_transport = add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ); test(); @@ -1629,13 +1641,17 @@ void ivas_param_mc_dec_digest_tc_fx( move16(); cx_imag_next_band_e = 0; move16(); +#endif + /* slot loop for gathering the input data */ FOR( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) { IF( st_ivas->hDecoderConfig->Opt_tsm ) { +#ifndef OBJ_EDITING_API IF( param_band_idx == 0 ) /* only run cldfbAna once */ { +#endif Word32 RealBuffer_fx[CLDFB_NO_CHANNELS_MAX]; Word32 ImagBuffer_fx[CLDFB_NO_CHANNELS_MAX]; @@ -1652,8 +1668,11 @@ void ivas_param_mc_dec_digest_tc_fx( hParamMC->Cldfb_ImagBuffer_tc_e = qout; move16(); +#ifndef OBJ_EDITING_API } +#endif } +#ifndef OBJ_EDITING_API IF( GE_16( slot_idx, shl( hParamMC->hMetadataPMC->attackIndex, 1 ) ) ) { FOR( is_next_band = 0; is_next_band < 2; is_next_band++ ) @@ -1693,8 +1712,10 @@ void ivas_param_mc_dec_digest_tc_fx( } } } +#endif } +#ifdef OBJ_EDITING_API Word16 tmp_cx_e, tmp_cx_imag_e; /* map from complex input covariance to real values */ FOR( is_next_band = 0; is_next_band < 2; is_next_band++ ) @@ -1826,11 +1847,189 @@ void ivas_param_mc_dec_digest_tc_fx( } } } +#endif pop_wmops(); return; } +#ifdef OBJ_EDITING_API +/*------------------------------------------------------------------------- + * ivas_param_mc_dec_prepare_renderer() + * + * + *------------------------------------------------------------------------*/ + +void ivas_param_mc_dec_prepare_renderer( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint8_t nCldfbSlots /* i : number of CLFBS slots in the transport channels */ +) +{ + PARAM_MC_DEC_HANDLE hParamMC; + int16_t i; + int16_t is_next_band, skip_next_band; + int16_t slot_idx, param_band_idx; + int16_t nchan_transport, nchan_out_transport, nchan_out_cldfb; + int16_t nchan_out_cov; + /*CLDFB*/ + float *pCx, *pCx_imag; + float cx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; + float cx_imag[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; + float cx_next_band[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; + float cx_imag_next_band[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; + float real_part, imag_part; + /* format converter */ + int16_t channel_active[MAX_OUTPUT_CHANNELS]; + IVAS_OUTPUT_SETUP *hSynthesisOutputSetup; + + hParamMC = st_ivas->hParamMC; + assert( hParamMC ); + + push_wmops( "param_mc_dec_digest_tc" ); + + set_s( channel_active, 0, MAX_CICP_CHANNELS ); + nchan_transport = st_ivas->nchan_transport; + nchan_out_transport = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; + + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) + { + nchan_out_cldfb = BINAURAL_CHANNELS; + set_s( channel_active, 1, nchan_out_cldfb ); + nchan_out_cov = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; + hSynthesisOutputSetup = &st_ivas->hTransSetup; + } + else if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_CLDFB ) + { + nchan_out_cov = nchan_out_transport; + nchan_out_cldfb = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; + hSynthesisOutputSetup = &st_ivas->hTransSetup; + } + else if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) + { + nchan_out_cov = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; + nchan_out_cldfb = nchan_out_cov; + set_s( channel_active, 1, nchan_out_cov ); + hSynthesisOutputSetup = &st_ivas->hOutSetup; + } + else + { + nchan_out_cov = nchan_out_transport; + nchan_out_cldfb = nchan_out_transport; + set_s( channel_active, 1, nchan_out_cov ); + hSynthesisOutputSetup = &st_ivas->hTransSetup; + } + + /* adapt transient position */ + if ( hParamMC->hMetadataPMC->bAttackPresent ) + { + hParamMC->hMetadataPMC->attackIndex = (int16_t) max( 0, hParamMC->hMetadataPMC->attackIndex + ( ( nCldfbSlots - DEFAULT_JBM_CLDFB_TIMESLOTS ) / 2 ) ); + } + /* adapt subframes */ + hParamMC->num_slots = nCldfbSlots; + hParamMC->slots_rendered = 0; + hParamMC->subframes_rendered = 0; + ivas_jbm_dec_get_adapted_subframes( nCldfbSlots, hParamMC->subframe_nbslots, &hParamMC->nb_subframes ); + st_ivas->hTcBuffer->nb_subframes = hParamMC->nb_subframes; + mvs2s( hParamMC->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, hParamMC->nb_subframes ); + + ivas_param_mc_dec_compute_interpolator( hParamMC->hMetadataPMC->bAttackPresent, hParamMC->hMetadataPMC->attackIndex, nCldfbSlots, hParamMC->h_output_synthesis_params.interpolator ); + + /* loop over two bands at a time */ + for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx += 2 ) + { + /* don't process next band if it exceeds the limit */ + skip_next_band = ( ( param_band_idx + 1 ) == hParamMC->num_param_bands_synth ) ? 1 : 0; + + set_zero( cx, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); + set_zero( cx_imag, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); + set_zero( cx_next_band, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); + set_zero( cx_imag_next_band, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); + + /* slot loop for gathering the input data */ + for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) + { + if ( slot_idx >= 2 * hParamMC->hMetadataPMC->attackIndex ) + { + for ( is_next_band = 0; is_next_band < 2; is_next_band++ ) + { + if ( is_next_band && skip_next_band ) + { + continue; + } + + ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot( &hParamMC->Cldfb_RealBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], + &hParamMC->Cldfb_ImagBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], + is_next_band ? cx_next_band : cx, + is_next_band ? cx_imag_next_band : cx_imag, + param_band_idx + is_next_band, + hParamMC, + nchan_transport ); + } + } + } + + /* map from complex input covariance to real values */ + for ( is_next_band = 0; is_next_band < 2; is_next_band++ ) + { + if ( is_next_band && skip_next_band ) + { + continue; + } + + /* Cx for transport channels */ + pCx = is_next_band ? &cx_next_band[0] : &cx[0]; + pCx_imag = is_next_band ? &cx_imag_next_band[0] : &cx_imag[0]; + + for ( i = 0; i < nchan_transport * nchan_transport; i++ ) + { + real_part = pCx[i]; + imag_part = pCx_imag[i]; + + /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ + if ( param_band_idx < hParamMC->max_param_band_abs_cov ) + { + pCx[i] = sqrtf( real_part * real_part + imag_part * imag_part ); + } + else + { + pCx[i] = real_part; + } + } + } + + /* we have to do it similar to the encoder in case of attacks (i.e. accumulate two bands) to ensure correct DMX of the target covariance*/ + if ( hParamMC->hMetadataPMC->bAttackPresent && ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) ) + { + v_add( cx, cx_next_band, cx, nchan_transport * nchan_transport ); + mvr2r( cx, cx_next_band, nchan_transport * nchan_transport ); + } + + for ( is_next_band = 0; is_next_band < 2; is_next_band++ ) + { + if ( is_next_band && skip_next_band ) + { + continue; + } + + /* generate mixing matrices */ + ivas_param_mc_get_mixing_matrices( hParamMC, + hSynthesisOutputSetup, + is_next_band ? cx_next_band : cx, + param_band_idx + is_next_band, + hParamMC->h_output_synthesis_cov_state.mixing_matrix, + hParamMC->h_output_synthesis_cov_state.mixing_matrix_res, + nchan_out_transport, + hParamMC->synthesis_conf, + nchan_transport, + nchan_out_cov ); + } + } + + pop_wmops(); + + return; +} +#endif /*------------------------------------------------------------------------- * ivas_param_mc_dec() diff --git a/lib_dec/ivas_objectRenderer_internal_fx.c b/lib_dec/ivas_objectRenderer_internal_fx.c index 5e898d236..db2d83853 100644 --- a/lib_dec/ivas_objectRenderer_internal_fx.c +++ b/lib_dec/ivas_objectRenderer_internal_fx.c @@ -210,6 +210,30 @@ ivas_error ivas_td_binaural_renderer_sf_fx( IF( EQ_16( subframe_idx, ism_md_subframe_update_jbm ) ) { +#ifdef OBJ_EDITING_API + if ( st_ivas->ivas_format == ISM_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + ISM_METADATA_FRAME ismMetaData[MAX_NUM_OBJECTS]; + ISM_METADATA_HANDLE hIsmMetaData[MAX_NUM_OBJECTS]; + for ( nS = 0; nS < nchan_ism; nS++ ) + { + ismMetaData[nS].azimuth = st_ivas->hIsmMetaData[nS]->edited_azimuth; + ismMetaData[nS].elevation = st_ivas->hIsmMetaData[nS]->edited_elevation; + ismMetaData[nS].radius = st_ivas->hIsmMetaData[nS]->edited_radius; + ismMetaData[nS].yaw = st_ivas->hIsmMetaData[nS]->edited_yaw; + ismMetaData[nS].pitch = st_ivas->hIsmMetaData[nS]->edited_pitch; + ismMetaData[nS].non_diegetic_flag = st_ivas->hIsmMetaData[nS]->non_diegetic_flag; + ismMetaData[nS].gain = st_ivas->hIsmMetaData[nS]->edited_gain; + hIsmMetaData[nS] = &ismMetaData[nS]; + } + + if ( ( error = TDREND_Update_object_positions_fx( st_ivas->hBinRendererTd, nchan_ism, st_ivas->ivas_format, hIsmMetaData ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else +#endif IF( ( error = TDREND_Update_object_positions_fx( st_ivas->hBinRendererTd, nchan_ism, st_ivas->ivas_format, st_ivas->hIsmMetaData ) ) != IVAS_ERR_OK ) { return error; diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index a4d03c644..464ef3dcf 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -463,6 +463,11 @@ typedef struct ivas_param_ism_dec_data_structure Word32 elevation_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES * IVAS_MAX_NUM_BANDS]; /* Q22 */ Word16 power_ratios_fx[MAX_PARAM_ISM_NBANDS][MAX_PARAM_ISM_NBLOCKS][MAX_PARAM_ISM_WAVE]; /* Q15 */ +#ifdef OBJ_EDITING_API + float edited_azimuth_values[MAX_PARAM_SPATIAL_SUBFRAMES * IVAS_MAX_NUM_BANDS]; + float edited_elevation_values[MAX_PARAM_SPATIAL_SUBFRAMES * IVAS_MAX_NUM_BANDS]; +#endif + /*sub-modules*/ PARAM_ISM_CONFIG_HANDLE hParamIsm; /* Parametric ISM common handle */ PARAM_ISM_RENDERING_HANDLE hParamIsmRendering; /* ParamISM rendering handle */ @@ -715,6 +720,10 @@ typedef struct ivas_osba_data Word16 delayBuffer_size; Word16 delayBuffer_nchan; +#ifdef OBJ_EDITING_API + float gain_bed; +#endif + } SBA_ISM_DATA, *SBA_ISM_DATA_HANDLE; @@ -954,6 +963,10 @@ typedef struct ivas_masa_ism_data_structure Word16 azimuth_ism_edited[MAX_NUM_OBJECTS]; Word16 elevation_ism_edited[MAX_NUM_OBJECTS]; UWord8 ism_is_edited[MAX_NUM_OBJECTS]; +#ifdef OBJ_EDITING_API + float gain_ism[MAX_NUM_OBJECTS]; + float gain_masa; +#endif Word16 idx_separated_ism; Word16 azimuth_separated_ism[MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index c87b4292c..dc95fe00e 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -150,6 +150,14 @@ ivas_error IVAS_DEC_ReadFormat( IVAS_BIN_RENDERER_TYPE *binaural_renderer_sec, /* o : secondary binaural renderer type */ IVAS_AUDIO_CONFIG *hrtf_set_audio_cfg /* o : HRTF set audio config. */ ); + +#ifdef FIX_HRTF_LOAD_API +ivas_error IVAS_DEC_GetSamplesDecoder( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const int16_t isSplitRend, /* i : split rendering enabled flag */ + ISAR_SPLIT_REND_BITS_DATA *splitRendBits /* o : output split rendering bits */ +); +#endif #endif /*! r: decoder error code */ @@ -161,6 +169,22 @@ ivas_error IVAS_DEC_GetSamples( bool *needNewFrame /* o : indication that the decoder needs a new frame */ ); +#ifdef OBJ_EDITING_API +ivas_error IVAS_DEC_GetEditableParameters( + IVAS_DEC_HANDLE hIvasDec, + IVAS_EDITABLE_PARAMETERS *hIvasEditableParameters +); + +ivas_error IVAS_DEC_SetEditableParameters( + IVAS_DEC_HANDLE hIvasDec, + IVAS_EDITABLE_PARAMETERS hIvasEditableParameters +); + +ivas_error IVAS_DEC_PrepareRenderer( + IVAS_DEC_HANDLE hIvasDec +); +#endif + ivas_error IVAS_DEC_GetSplitBinauralBitstream( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ Word16 *pcmBuf_out, /* o : output synthesis signal for BINAURAL_SPLIT_PCM */ @@ -287,6 +311,10 @@ ivas_error IVAS_DEC_VoIP_GetSamples( void* jbmWriter #endif #endif +#ifdef OBJ_EDITING_API + , + bool *parametersAvailableForEditing +#endif ); ivas_error IVAS_DEC_Flush( diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 4a929f97e..e492820fd 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -99,9 +99,18 @@ struct IVAS_DEC #ifdef FIX_HRTF_LOAD UWord16 nSamplesFlushed; +#ifdef FIX_HRTF_LOAD_API + Word16 *flushbuffer; +#else Word16 flushbuffer[20 * 960 / 4]; // temp. hack +#endif +#ifdef OBJ_EDITING_API + bool hasEditableParameters; + bool enableParameterEditing; +#endif bool hasBeenPreparedRendering; #endif + }; /*---------------------------------------------------------------------* @@ -195,7 +204,16 @@ ivas_error IVAS_DEC_Open( move16(); move16(); #ifdef FIX_HRTF_LOAD +#ifdef OBJ_EDITING_API + hIvasDec->flushbuffer = NULL; +#else + // hIvasDec->flushbuffer = NULL; +#endif hIvasDec->nSamplesFlushed = 0; +#ifdef OBJ_EDITING_API + hIvasDec->hasEditableParameters = false; + hIvasDec->enableParameterEditing = false; +#endif hIvasDec->hasBeenPreparedRendering = false; #endif @@ -320,10 +338,12 @@ static ivas_error isar_set_split_rend_setup( splitRendBits->isar_frame_size_ms = 0; splitRendBits->lc3plus_highres = 0; +#ifndef TMP_FIX_SPLIT_REND if ( ( hSplitBinRend->hMultiBinCldfbData = (ISAR_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA_HANDLE) malloc( sizeof( ISAR_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for split rendering structure" ); } +#endif ISAR_PRE_REND_GetMultiBinPoseData( hSplitBinConfig, &hSplitBinRend->splitrend.multiBinPoseData, ( hCombinedOrientationData != NULL ) ? hCombinedOrientationData->sr_pose_pred_axis : DEFAULT_AXIS ); @@ -418,6 +438,12 @@ void IVAS_DEC_Close( { free( ( *phIvasDec )->apaExecBuffer_fx ); } +#ifdef OBJ_EDITING_API + if ( ( *phIvasDec )->flushbuffer != NULL ) + { + free( ( *phIvasDec )->flushbuffer ); + } +#endif free( *phIvasDec ); *phIvasDec = NULL; phIvasDec = NULL; @@ -621,6 +647,16 @@ ivas_error IVAS_DEC_Configure( move16(); move16(); +#ifdef OBJ_EDITING_API + /* init flush buffer if necessary (only needed for binaural)*/ + if ( tsmEnabled && ( outputConfig == IVAS_AUDIO_CONFIG_BINAURAL || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) + { + hIvasDec->flushbuffer = (void *) malloc( CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( int16_t ) ); + hIvasDec->pcmType = IVAS_DEC_PCM_INT16; + set_s( (int16_t *) hIvasDec->flushbuffer, 0, CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); + } +#endif + return IVAS_ERR_OK; } @@ -949,6 +985,7 @@ ivas_error IVAS_DEC_EnableVoIP( } #endif + return IVAS_ERR_OK; } @@ -1092,17 +1129,26 @@ ivas_error IVAS_DEC_GetSamples( ) { ivas_error error; +#ifdef OBJ_EDITING_API + Word16 nSamplesToRender; + UWord16 nSamplesRendered, nSamplesRendered_loop; + UWord16 nOutChannels; +#else Word16 nOutSamplesElse, nSamplesToRender; UWord16 nSamplesRendered, nSamplesRendered_loop, l_ts, nTimeScalerOutSamples; UWord8 nTransportChannels, nOutChannels; +#endif nSamplesRendered = 0; nOutChannels = 0; nSamplesRendered_loop = 0; +#ifndef OBJ_EDITING_API l_ts = 0; nTransportChannels = 0; +#endif move16(); move16(); + move16(); move16(); move16(); @@ -1112,6 +1158,13 @@ ivas_error IVAS_DEC_GetSamples( { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } +#ifdef OBJ_EDITING_API + /* the rendering needs to be prepared at this point */ + if ( hIvasDec->hasBeenPreparedRendering == false ) + { + return IVAS_ERR_UNKNOWN; + } +#endif IF( hIvasDec->updateOrientation ) { @@ -1176,138 +1229,171 @@ ivas_error IVAS_DEC_GetSamples( } ELSE { +#ifndef OBJ_EDITING_API /* check if we need to run the setup function */ test(); - IF( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ){ + IF( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) + { /* setup */ #ifdef FIX_HRTF_LOAD IF( NE_32( ( error = IVAS_DEC_Setup( hIvasDec, &l_ts, &nTransportChannels ) ), IVAS_ERR_OK ) ) #else IF( NE_32( ( error = IVAS_DEC_Setup( hIvasDec, &l_ts, &nTransportChannels, &nOutChannels, &nSamplesRendered_loop, pcmBuf + imult3216( nSamplesRendered, nOutChannels ) ) ), IVAS_ERR_OK ) ) #endif - { - return error; - } -} -{ - /* check if we need to run the setup function, tc decoding and feeding the renderer */ - test(); - IF( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) - { - Word16 nResidualSamples, nSamplesTcsScaled; - nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop ); - - test(); - IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm && NE_16( (Word16) nTransportChannels, hIvasDec->nTransportChannelsOld ) ) - { - IF( NE_32( ( error = IVAS_DEC_VoIP_reconfigure( hIvasDec, nTransportChannels, l_ts ) ), IVAS_ERR_OK ) ) { return error; } } - - /* IVAS decoder */ - IF( NE_32( ( error = IVAS_DEC_GetTcSamples( hIvasDec, hIvasDec->apaExecBuffer_fx, &nOutSamplesElse ) ), IVAS_ERR_OK ) ) - { - return error; - } - - /* JBM */ - IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) +#endif { - IF( apa_set_scale_fx( hIvasDec->hTimeScaler, hIvasDec->tsm_scale ) != 0 ) +#ifndef OBJ_EDITING_API + /* check if we need to run the setup function, tc decoding and feeding the renderer */ + test(); + IF( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) { - return IVAS_ERR_UNKNOWN; - } + Word16 nResidualSamples, nSamplesTcsScaled; + nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop ); - // tmp apaExecBuffer - IF( EQ_16( (Word16) hIvasDec->mode, IVAS_DEC_MODE_EVS ) ) - { - Word16 tmp_apaExecBuffer[APA_BUF]; - FOR( Word32 i = 0; i < APA_BUF_PER_CHANNEL * nTransportChannels; ++i ) + test(); + IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm && NE_16( (Word16) nTransportChannels, hIvasDec->nTransportChannelsOld ) ) { - tmp_apaExecBuffer[i] = extract_l( L_shr( hIvasDec->apaExecBuffer_fx[i], Q11 ) ); // Q0 + IF( NE_32( ( error = IVAS_DEC_VoIP_reconfigure( hIvasDec, nTransportChannels, l_ts ) ), IVAS_ERR_OK ) ) + { + return error; + } } - IF( apa_exec_fx( hIvasDec->hTimeScaler, tmp_apaExecBuffer, (UWord16) imult3216( hIvasDec->nSamplesFrame, nTransportChannels ), (UWord16) hIvasDec->tsm_max_scaling, tmp_apaExecBuffer, &nTimeScalerOutSamples ) != 0 ) + + /* IVAS decoder */ + IF( NE_32( ( error = IVAS_DEC_GetTcSamples( hIvasDec, hIvasDec->apaExecBuffer_fx, &nOutSamplesElse ) ), IVAS_ERR_OK ) ) { - return IVAS_ERR_UNKNOWN; + return error; } - FOR( Word32 i = 0; i < APA_BUF_PER_CHANNEL * nTransportChannels; ++i ) + + /* JBM */ + IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) { - hIvasDec->apaExecBuffer_fx[i] = L_shl( tmp_apaExecBuffer[i], Q11 ); // Q11 + IF( apa_set_scale_fx( hIvasDec->hTimeScaler, hIvasDec->tsm_scale ) != 0 ) + { + return IVAS_ERR_UNKNOWN; + } + + // tmp apaExecBuffer + IF( EQ_16( (Word16) hIvasDec->mode, IVAS_DEC_MODE_EVS ) ) + { + Word16 tmp_apaExecBuffer[APA_BUF]; + FOR( Word32 i = 0; i < APA_BUF_PER_CHANNEL * nTransportChannels; ++i ) + { + tmp_apaExecBuffer[i] = extract_l( L_shr( hIvasDec->apaExecBuffer_fx[i], Q11 ) ); // Q0 + } + IF( apa_exec_fx( hIvasDec->hTimeScaler, tmp_apaExecBuffer, (UWord16) imult3216( hIvasDec->nSamplesFrame, nTransportChannels ), (UWord16) hIvasDec->tsm_max_scaling, tmp_apaExecBuffer, &nTimeScalerOutSamples ) != 0 ) + { + return IVAS_ERR_UNKNOWN; + } + FOR( Word32 i = 0; i < APA_BUF_PER_CHANNEL * nTransportChannels; ++i ) + { + hIvasDec->apaExecBuffer_fx[i] = L_shl( tmp_apaExecBuffer[i], Q11 ); // Q11 + } + } + ELSE + { + IF( apa_exec_ivas_fx( hIvasDec->hTimeScaler, hIvasDec->apaExecBuffer_fx, (UWord16) imult3216( hIvasDec->nSamplesFrame, nTransportChannels ), (UWord16) hIvasDec->tsm_max_scaling, hIvasDec->apaExecBuffer_fx, &nTimeScalerOutSamples ) != 0 ) + { + return IVAS_ERR_UNKNOWN; + } + } + assert( LE_32( (Word32) nTimeScalerOutSamples, APA_BUF ) ); + nSamplesTcsScaled = idiv1616U( extract_l( nTimeScalerOutSamples ), nTransportChannels ); + hIvasDec->timeScalingDone = 1; + move16(); } - } - ELSE - { - IF( apa_exec_ivas_fx( hIvasDec->hTimeScaler, hIvasDec->apaExecBuffer_fx, (UWord16) imult3216( hIvasDec->nSamplesFrame, nTransportChannels ), (UWord16) hIvasDec->tsm_max_scaling, hIvasDec->apaExecBuffer_fx, &nTimeScalerOutSamples ) != 0 ) + ELSE { - return IVAS_ERR_UNKNOWN; + nSamplesTcsScaled = hIvasDec->nSamplesFrame; + move16(); } - } - assert( LE_32( (Word32) nTimeScalerOutSamples, APA_BUF ) ); - nSamplesTcsScaled = idiv1616U( extract_l( nTimeScalerOutSamples ), nTransportChannels ); - hIvasDec->timeScalingDone = 1; - move16(); - } - ELSE - { - nSamplesTcsScaled = hIvasDec->nSamplesFrame; - move16(); - } #ifdef DEBUG_MODE_JBM - dbgwrite( &nTimeScalerOutSamples, sizeof( uint16_t ), 1, 1, "./res/JBM_nTimeScaleOutSamples.dat" ); + dbgwrite( &nTimeScalerOutSamples, sizeof( uint16_t ), 1, 1, "./res/JBM_nTimeScaleOutSamples.dat" ); #endif - /* Feed decoded transport channels samples to the renderer */ - IF( NE_32( ( error = IVAS_DEC_RendererFeedTcSamples( hIvasDec, nSamplesTcsScaled, &nResidualSamples, hIvasDec->apaExecBuffer_fx ) ), IVAS_ERR_OK ) ) - { - return error; - } + /* Feed decoded transport channels samples to the renderer */ + IF( NE_32( ( error = IVAS_DEC_RendererFeedTcSamples( hIvasDec, nSamplesTcsScaled, &nResidualSamples, hIvasDec->apaExecBuffer_fx ) ), IVAS_ERR_OK ) ) + { + return error; + } #ifdef DEBUG_MODE_JBM - dbgwrite( &nResidualSamples, sizeof( int16_t ), 1, 1, "./res/JBM_nResidualSamples.dat" ); + dbgwrite( &nResidualSamples, sizeof( int16_t ), 1, 1, "./res/JBM_nResidualSamples.dat" ); #endif - IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) - { - /* feed residual samples to TSM for the next call */ - IF( apa_set_renderer_residual_samples( hIvasDec->hTimeScaler, (UWord16) nResidualSamples ) != 0 ) + IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) + { + /* feed residual samples to TSM for the next call */ + IF( apa_set_renderer_residual_samples( hIvasDec->hTimeScaler, (UWord16) nResidualSamples ) != 0 ) + { + return IVAS_ERR_UNKNOWN; + } + } + hIvasDec->hasBeenFedFrame = false; + move16(); + } +#else + nOutChannels = (uint8_t) hIvasDec->st_ivas->hDecoderConfig->nchan_out; + hIvasDec->hasBeenFedFrame = false; + /* check for possible flushed samples from a rate switch */ + if ( hIvasDec->nSamplesFlushed > 0 ) { - return IVAS_ERR_UNKNOWN; + void *pPcmBuffer; +#ifdef DEBUGGING + assert( hIvasDec->pcmType == pcmType ); +#endif + pPcmBuffer = pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ); + if ( pcmType == IVAS_DEC_PCM_INT16 ) + { + mvs2s( (int16_t *) hIvasDec->flushbuffer, pPcmBuffer, hIvasDec->nSamplesFlushed * nOutChannels ); + } + else if ( pcmType == IVAS_DEC_PCM_FLOAT ) + { + mvr2r( (float *) hIvasDec->flushbuffer, pPcmBuffer, hIvasDec->nSamplesFlushed * nOutChannels ); + } +#ifdef DEBUGGING + else + { + assert( 0 && "wrong PCM type for the flush buffer!" ); + } +#endif + nSamplesRendered += hIvasDec->nSamplesFlushed; + hIvasDec->nSamplesFlushed = 0; } - } - hIvasDec->hasBeenFedFrame = false; - move16(); - } +#endif - /* render IVAS frames directly to the output buffer */ - nSamplesToRender = sub( nSamplesAsked, nSamplesRendered ); - IF( NE_32( ( error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesRendered_loop, &hIvasDec->nSamplesAvailableNext, pcmBuf + imult3216( nSamplesRendered, nOutChannels ) ) ), IVAS_ERR_OK ) ) - { - return error; - } + /* render IVAS frames directly to the output buffer */ + nSamplesToRender = sub( nSamplesAsked, nSamplesRendered ); + IF( NE_32( ( error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesRendered_loop, &hIvasDec->nSamplesAvailableNext, pcmBuf + imult3216( nSamplesRendered, nOutChannels ) ) ), IVAS_ERR_OK ) ) + { + return error; + } - nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop ); - nSamplesToRender = sub( nSamplesToRender, nSamplesRendered_loop ); - IF( hIvasDec->nSamplesAvailableNext == 0 ) - { - *needNewFrame = true; - hIvasDec->needNewFrame = true; - move16(); - move16(); - } - ELSE - { - *needNewFrame = false; - move16(); + nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop ); + nSamplesToRender = sub( nSamplesToRender, nSamplesRendered_loop ); + IF( hIvasDec->nSamplesAvailableNext == 0 ) + { + *needNewFrame = true; + hIvasDec->needNewFrame = true; + move16(); + move16(); + } + ELSE + { + *needNewFrame = false; + move16(); + } + } } -} -} -*nOutSamples = nSamplesRendered; -move16(); + *nOutSamples = nSamplesRendered; + move16(); -return IVAS_ERR_OK; + return IVAS_ERR_OK; } @@ -1357,10 +1443,12 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( *needNewFrame = false; hSplitBinRend = st_ivas->hSplitBinRend; +#ifndef OBJ_EDITING_API IF( ( error = isar_set_split_rend_setup( hSplitBinRend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hCombinedOrientationData, splitRendBits ) ) != IVAS_ERR_OK ) { return error; } +#endif FOR( i = 0; i < MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; i++ ) { @@ -1388,6 +1476,16 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( numPoses = hSplitBinRend->splitrend.multiBinPoseData.num_poses; move16(); +#ifdef OBJ_EDITING_API + /* init flush buffer for rate switch if not already initizalized */ + if ( hIvasDec->flushbuffer == NULL ) + { + hIvasDec->flushbuffer = (void *) malloc( numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( float ) ); + hIvasDec->pcmType = IVAS_DEC_PCM_FLOAT; + set_zero( (float *) hIvasDec->flushbuffer, numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); + } +#endif + IF( NE_32( st_ivas->hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_20MS ) && ( EQ_32( hIvasDec->st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) || EQ_16( hIvasDec->st_ivas->hRenderConfig->split_rend_config.dof, 0 ) ) ) @@ -1568,7 +1666,9 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( ivas_syn_output_fx( pOutput, Q11, numSamplesPerChannelToDecode, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf_out ); } +#ifndef TMP_FIX_SPLIT_REND free( st_ivas->hSplitBinRend->hMultiBinCldfbData ); +#endif return IVAS_ERR_OK; } @@ -2197,14 +2297,54 @@ ivas_error IVAS_DEC_GetObjectMetadata( } ELSE { - metadata->azimuth_fx = hIsmMeta->azimuth_fx; // Q22 - metadata->elevation_fx = hIsmMeta->elevation_fx; // Q22 - metadata->radius_fx = hIsmMeta->radius_fx; // Q9 - 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->non_diegetic_flag = hIsmMeta->non_diegetic_flag; +#ifdef OBJ_EDITING_API + if ( st_ivas->ism_mode == ISM_MODE_DISC ) + { + metadata->azimuth = hIsmMeta->edited_azimuth; + metadata->elevation = hIsmMeta->edited_elevation; + metadata->radius = hIsmMeta->edited_radius; + + metadata->yaw = hIsmMeta->edited_yaw; + metadata->pitch = hIsmMeta->edited_pitch; + metadata->spread = 0.f; + + metadata->gainFactor = hIsmMeta->edited_gain; + metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; + } + else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) + { + metadata->azimuth = st_ivas->hParamIsmDec->edited_azimuth_values[objectIdx]; + metadata->elevation = st_ivas->hParamIsmDec->edited_elevation_values[objectIdx]; + metadata->radius = hIsmMeta->radius; + metadata->yaw = hIsmMeta->yaw; + metadata->pitch = hIsmMeta->pitch; + metadata->spread = 0.f; + metadata->gainFactor = 1.f; + metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; + } + else if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC || st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + { + metadata->azimuth = st_ivas->hIsmMetaData[objectIdx]->edited_azimuth; + metadata->elevation = st_ivas->hIsmMetaData[objectIdx]->edited_elevation; + metadata->radius = st_ivas->hIsmMetaData[objectIdx]->edited_radius; + metadata->yaw = st_ivas->hIsmMetaData[objectIdx]->edited_yaw; + metadata->pitch = st_ivas->hIsmMetaData[objectIdx]->edited_pitch; + metadata->spread = 0.f; + metadata->gainFactor = st_ivas->hIsmMetaData[objectIdx]->edited_gain; + metadata->non_diegetic_flag = st_ivas->hIsmMetaData[objectIdx]->non_diegetic_flag; + } + ELSE +#endif + { + metadata->azimuth_fx = hIsmMeta->azimuth_fx; // Q22 + metadata->elevation_fx = hIsmMeta->elevation_fx; // Q22 + metadata->radius_fx = hIsmMeta->radius_fx; // Q9 + 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->non_diegetic_flag = hIsmMeta->non_diegetic_flag; + } } move32(); @@ -3622,6 +3762,325 @@ ivas_error IVAS_DEC_ReadFormat( } #endif +#ifdef FIX_HRTF_LOAD_API +/*---------------------------------------------------------------------* + * IVAS_DEC_GetSamplesDecoder( ) + * + * Main function to decode transport channels, do TSM and feed to renderer. + *---------------------------------------------------------------------*/ + +ivas_error IVAS_DEC_GetSamplesDecoder( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const int16_t isSplitRend, /* i : split rendering enabled flag */ + ISAR_SPLIT_REND_BITS_DATA *splitRendBits /* o : output split rendering bits */ +) +{ + ivas_error error; + + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + /* If TSM is generally enabled, we have to wait for the first good frame. + Otherwise, we directly decode the first frame in any case. */ +#ifdef FIX_HRTF_LOAD + if ( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) +#else + if ( ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm && hIvasDec->hasBeenFedFirstGoodFrame ) || !hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) +#endif + { + uint16_t l_ts, nTimeScalerOutSamples; +#ifdef FIX_HRTF_LOAD + uint8_t nTransportChannels; +#else + uint8_t nTransportChannels, nOutChannels; +#endif + int16_t nResidualSamples, nSamplesTcsScaled, nOutSamplesElse; + + if ( isSplitRend ) + { + if ( ( error = isar_set_split_rend_setup( hIvasDec->st_ivas->hSplitBinRend, &hIvasDec->st_ivas->hRenderConfig->split_rend_config, hIvasDec->st_ivas->hCombinedOrientationData, splitRendBits ) ) != IVAS_ERR_OK ) + { + return error; + } + } + +#ifdef FIX_HRTF_LOAD + if ( ( error = IVAS_DEC_Setup( hIvasDec, &l_ts, &nTransportChannels ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_DEC_Setup( hIvasDec, &l_ts, &nTransportChannels, &nOutChannels, &hIvasDec->nSamplesFlushed, hIvasDec->pcmType, hIvasDec->flushbuffer ) ) != IVAS_ERR_OK ) +#endif + { + return error; + } + + if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm && nTransportChannels != hIvasDec->nTransportChannelsOld ) + { + if ( ( error = IVAS_DEC_VoIP_reconfigure( hIvasDec, nTransportChannels, l_ts ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + /* IVAS TC decoder */ + if ( ( error = IVAS_DEC_GetTcSamples( hIvasDec, hIvasDec->apaExecBuffer, &nOutSamplesElse ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* JBM */ + if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) + { + if ( apa_set_scale( hIvasDec->hTimeScaler, hIvasDec->tsm_scale ) != 0 ) + { + return IVAS_ERR_UNKNOWN; + } + + if ( apa_exec( hIvasDec->hTimeScaler, hIvasDec->apaExecBuffer, hIvasDec->nSamplesFrame * nTransportChannels, (uint16_t) hIvasDec->tsm_max_scaling, hIvasDec->apaExecBuffer, &nTimeScalerOutSamples ) != 0 ) + { + return IVAS_ERR_UNKNOWN; + } + + assert( nTimeScalerOutSamples <= APA_BUF ); + nSamplesTcsScaled = nTimeScalerOutSamples / nTransportChannels; + hIvasDec->timeScalingDone = 1; + } + else + { + nSamplesTcsScaled = hIvasDec->nSamplesFrame; + } + + /* Feed decoded transport channels samples to the renderer */ + if ( ( error = IVAS_DEC_RendererFeedTcSamples( hIvasDec, nSamplesTcsScaled, &nResidualSamples, hIvasDec->apaExecBuffer ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) + { + /* feed residual samples to TSM for the next call */ + if ( apa_set_renderer_residual_samples( hIvasDec->hTimeScaler, (uint16_t) nResidualSamples ) != 0 ) + { + return IVAS_ERR_UNKNOWN; + } + } + hIvasDec->hasBeenFedFrame = false; + } + hIvasDec->hasBeenPreparedRendering = false; + + if ( hIvasDec->st_ivas->hIsmMetaData[0] ) + { + if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == MASA_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_MASA_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + int16_t obj; + ISM_METADATA_HANDLE *hIsmMetaData = hIvasDec->st_ivas->hIsmMetaData; + for ( obj = 0; obj < hIvasDec->st_ivas->nchan_ism; obj++ ) + { + hIsmMetaData[obj]->edited_azimuth = hIsmMetaData[obj]->azimuth; + hIsmMetaData[obj]->edited_elevation = hIsmMetaData[obj]->elevation; + hIsmMetaData[obj]->edited_yaw = hIsmMetaData[obj]->yaw; + hIsmMetaData[obj]->edited_pitch = hIsmMetaData[obj]->pitch; + hIsmMetaData[obj]->edited_radius = hIsmMetaData[obj]->radius; + hIsmMetaData[obj]->edited_gain = 1.0f; + } + + if ( hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + hIvasDec->st_ivas->hSbaIsmData->gain_bed = 1.0f; + } + } + } + } + + if ( hIvasDec->st_ivas->hParamIsmDec != NULL ) + { + if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) + { + int16_t obj = 0; + PARAM_ISM_DEC_HANDLE hParamIsmDec = hIvasDec->st_ivas->hParamIsmDec; + for ( obj = 0; obj < hIvasDec->st_ivas->nchan_ism; obj++ ) + { + hParamIsmDec->edited_azimuth_values[obj] = hParamIsmDec->azimuth_values[obj]; + hParamIsmDec->edited_elevation_values[obj] = hParamIsmDec->elevation_values[obj]; + } + } + } + + return IVAS_ERR_OK; +} +#endif + +#ifdef OBJ_EDITING_API +/*---------------------------------------------------------------------* + * IVAS_DEC_GetEditableParameters( ) + * + * + *---------------------------------------------------------------------*/ + +ivas_error IVAS_DEC_GetEditableParameters( + IVAS_DEC_HANDLE hIvasDec, + IVAS_EDITABLE_PARAMETERS *hIvasEditableParameters ) +{ + ivas_error error; + + 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." ); + } + + if ( hIvasEditableParameters == NULL || hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + hIvasEditableParameters->gain_bed = 1.0f; + hIvasEditableParameters->num_obj = hIvasDec->st_ivas->nchan_ism; + 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 ) + { + int16_t obj; + for ( obj = 0; obj < hIvasEditableParameters->num_obj; obj++ ) + { + hIvasEditableParameters->ism_metadata[obj].azimuth = hIvasDec->st_ivas->hIsmMetaData[obj]->azimuth; + hIvasEditableParameters->ism_metadata[obj].elevation = hIvasDec->st_ivas->hIsmMetaData[obj]->elevation; + hIvasEditableParameters->ism_metadata[obj].yaw = hIvasDec->st_ivas->hIsmMetaData[obj]->yaw; + hIvasEditableParameters->ism_metadata[obj].pitch = hIvasDec->st_ivas->hIsmMetaData[obj]->pitch; + hIvasEditableParameters->ism_metadata[obj].radius = hIvasDec->st_ivas->hIsmMetaData[obj]->radius; + 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; + } + if ( hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + hIvasEditableParameters->gain_bed = 1.0f; + } + } + else if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) + { + int16_t obj; + for ( obj = 0; obj < hIvasEditableParameters->num_obj; obj++ ) + { + hIvasEditableParameters->ism_metadata[obj].azimuth = hIvasDec->st_ivas->hParamIsmDec->azimuth_values[obj]; + hIvasEditableParameters->ism_metadata[obj].elevation = hIvasDec->st_ivas->hParamIsmDec->elevation_values[obj]; + hIvasEditableParameters->ism_metadata[obj].yaw = 0.0f; + hIvasEditableParameters->ism_metadata[obj].pitch = 0.0f; + hIvasEditableParameters->ism_metadata[obj].radius = 0.0f; + hIvasEditableParameters->ism_metadata[obj].gain = 1.0f; + hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = 0; + } + } + else + { + assert( 0 && "This should never happen!" ); + } + } + + error = IVAS_ERR_OK; + + return error; +} + + +/*---------------------------------------------------------------------* + * IVAS_DEC_SetEditableParameters( ) + * + * Main function to decode to PCM data + *---------------------------------------------------------------------*/ + +ivas_error IVAS_DEC_SetEditableParameters( + IVAS_DEC_HANDLE hIvasDec, + IVAS_EDITABLE_PARAMETERS hIvasEditableParameters ) +{ + ivas_error error; + + 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." ); + } + + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + error = IVAS_ERR_OK; + +#ifdef DEBUGGING + 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 ) + { + if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + int16_t obj; + for ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) + { + hIvasDec->st_ivas->hIsmMetaData[obj]->edited_azimuth = hIvasEditableParameters.ism_metadata[obj].azimuth; + hIvasDec->st_ivas->hIsmMetaData[obj]->edited_elevation = hIvasEditableParameters.ism_metadata[obj].elevation; + hIvasDec->st_ivas->hIsmMetaData[obj]->edited_radius = hIvasEditableParameters.ism_metadata[obj].radius; + + hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain = hIvasEditableParameters.ism_metadata[obj].gain; + + hIvasDec->st_ivas->hIsmMetaData[obj]->edited_yaw = hIvasEditableParameters.ism_metadata[obj].yaw; + hIvasDec->st_ivas->hIsmMetaData[obj]->edited_pitch = hIvasEditableParameters.ism_metadata[obj].pitch; + + 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 ) + { + hIvasDec->st_ivas->hSbaIsmData->gain_bed = hIvasEditableParameters.gain_bed; + } + } + else if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) + { + int16_t obj; + for ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) + { + } + } + else + { + assert( 0 && "This should never happen!" ); + } + } + + return error; +} + + +/*---------------------------------------------------------------------* + * IVAS_DEC_PrepareRenderer( ) + * + * Main function to decode to PCM data + *---------------------------------------------------------------------*/ + +ivas_error IVAS_DEC_PrepareRenderer( + IVAS_DEC_HANDLE hIvasDec ) +{ + ivas_error error; + + error = IVAS_ERR_OK; + + if ( hIvasDec == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + ivas_jbm_dec_prepare_renderer( hIvasDec->st_ivas ); + hIvasDec->hasBeenPreparedRendering = true; + return error; +} +#endif /*---------------------------------------------------------------------* * IVAS_DEC_VoIP_GetSamples( ) @@ -3647,6 +4106,10 @@ ivas_error IVAS_DEC_VoIP_GetSamples( void *jbmWriter #endif #endif +#ifdef OBJ_EDITING_API + , + bool *parametersAvailableForEditing, +#endif ) { Decoder_Struct *st_ivas; @@ -3660,6 +4123,10 @@ ivas_error IVAS_DEC_VoIP_GetSamples( #ifndef FIX_CREND_SIMPLIFY_CODE Word16 nSamplesRendered; #endif +#ifdef OBJ_EDITING_API + *parametersAvailableForEditing = false; +#endif + UWord8 nOutChannels; test(); @@ -3844,6 +4311,15 @@ ivas_error IVAS_DEC_VoIP_GetSamples( move16(); move16(); } + +#ifdef OBJ_EDITING_API + /* :TODO: only return here if we really have editing initialized */ + if ( hIvasDec->hasBeenFedFirstGoodFrame && hIvasDec->hasEditableParameters == true && hIvasDec->enableParameterEditing == true ) + { + *parametersAvailableForEditing = true; + return IVAS_ERR_OK; + } +#endif } /* decode */ @@ -3869,12 +4345,44 @@ ivas_error IVAS_DEC_VoIP_GetSamples( { Word16 nSamplesToRender, nSamplesRendered_loop; bool tmp; + +#ifdef FIX_HRTF_LOAD_API + if ( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) + { + if ( hIvasDec->nSamplesAvailableNext == 0 || hIvasDec->nSamplesAvailableNext == hIvasDec->nSamplesFrame ) + { + uint16_t nSamplesFlushed_ref = hIvasDec->nSamplesFlushed; + + if ( ( error = IVAS_DEC_GetSamplesDecoder( hIvasDec, 0, 0 ) ) != IVAS_ERR_OK ) + { + return error; + } + + hIvasDec->nSamplesFlushed = nSamplesFlushed_ref; + + *bitstreamReadDone = false; + } + } +#endif + #ifdef FIX_CREND_SIMPLIFY_CODE nSamplesToRender = sub( nSamplesPerChannel, *nSamplesRendered ); #else nSamplesToRender = sub( nSamplesPerChannel, nSamplesRendered ); #endif +#ifdef OBJ_EDITING_API + /* check if we still need to prepare the renderer */ + if ( hIvasDec->hasBeenPreparedRendering == false ) + { + + if ( ( error = IVAS_DEC_PrepareRenderer( hIvasDec ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#endif + /* render IVAS frames directly to the output buffer */ #ifdef FIX_CREND_SIMPLIFY_CODE IF( NE_32( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, pcmBuf + imult1616( *nSamplesRendered, nOutChannels ), &nSamplesRendered_loop, &tmp ) ), IVAS_ERR_OK ) ) @@ -3885,9 +4393,12 @@ ivas_error IVAS_DEC_VoIP_GetSamples( return error; } +#ifndef FIX_HRTF_LOAD_API #ifdef FIX_HRTF_LOAD *bitstreamReadDone = false; // temp hack until JBM API is reworked #endif +#endif + #ifdef FIX_CREND_SIMPLIFY_CODE *nSamplesRendered = add( *nSamplesRendered, nSamplesRendered_loop ); #else @@ -4804,6 +5315,11 @@ static void ivas_destroy_handle_isar( { IF( *hSplitBinRend != NULL ) { +#ifdef TMP_FIX_SPLIT_REND + free( ( *hSplitBinRend )->hMultiBinCldfbData ); + ( *hSplitBinRend )->hMultiBinCldfbData = NULL; + +#endif ISAR_PRE_REND_close( &( *hSplitBinRend )->splitrend, NULL ); IF( ( *hSplitBinRend )->hCldfbDataOut != NULL ) @@ -5014,6 +5530,14 @@ static ivas_error ivas_dec_init_split_rend( cldfb_in_flag = 0; move16(); +#ifdef TMP_FIX_SPLIT_REND + /* note: this is intra-frame heap memory */ + if ( ( st_ivas->hSplitBinRend->hMultiBinCldfbData = (ISAR_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA_HANDLE) malloc( sizeof( ISAR_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for split rendering structure" ); + } +#endif + IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || diff --git a/lib_rend/ivas_objectRenderer_fx.c b/lib_rend/ivas_objectRenderer_fx.c index 024f5b6ac..42f6d94c7 100644 --- a/lib_rend/ivas_objectRenderer_fx.c +++ b/lib_rend/ivas_objectRenderer_fx.c @@ -586,6 +586,9 @@ static void TDREND_Clear_Update_flags_fx( { hBinRendererTd->Sources[i]->SrcSpatial_p->Updated = FALSE; move16(); +#ifdef OBJ_EDITING_API + hBinRendererTd->Sources[i]->SrcRend_p->SrcGainUpdated = FALSE; +#endif } return; diff --git a/lib_rend/ivas_objectRenderer_sources_fx.c b/lib_rend/ivas_objectRenderer_sources_fx.c index 5b18e8a43..90ac586ee 100644 --- a/lib_rend/ivas_objectRenderer_sources_fx.c +++ b/lib_rend/ivas_objectRenderer_sources_fx.c @@ -254,7 +254,11 @@ static void TDREND_SRC_REND_Init_fx( move16(); SrcRend_p->SrcGain_p_fx[nC] = ONE_IN_Q14; // Q14 move16(); +#ifdef OBJ_EDITING_API + SrcRend_p->SrcGainMax_p_fx[nC] = 32767; // TODO: make it 2, this is one in Q15, i thinki, need to change Q for that +#else SrcRend_p->SrcGainMax_p_fx[nC] = 32767; /* Q15 */ +#endif move16(); } SrcRend_p->SrcGainUpdated = FALSE; -- GitLab From 89c92ac838638d95fc84a873a3e8a5841027b95e Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 8 Oct 2025 17:05:14 +0200 Subject: [PATCH 02/46] convert data types and set preliminary Q values --- lib_com/ivas_stat_com.h | 14 +++++++------- lib_dec/ivas_dirac_dec_fx.c | 2 +- lib_dec/ivas_ism_param_dec_fx.c | 12 +++++------- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 1f13c30be..891515997 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -66,15 +66,15 @@ typedef struct Word32 pitch_fx; /* pitch value read from the input metadata file */ /* Q22 */ #ifdef OBJ_EDITING_API - float gain; + Word16 gain /* Q30 */; - float edited_azimuth; - float edited_elevation; - float edited_radius; + Word32 edited_azimuth; /* Q22 */ + Word32 edited_elevation; /* Q22 */ + Word16 edited_radius; /* Q9 */ - float edited_yaw; - float edited_pitch; - float edited_gain; + Word32 edited_yaw; /* Q22 */ + Word32 edited_pitch; /* Q22 */ + Word16 edited_gain; /* Q30 */ #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 8d2ecc08d..ba48ee141 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -3838,7 +3838,7 @@ 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 - v_multc( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmMetaData[i]->edited_gain, st_ivas->hIsmRendererData->gains[i], nchan_out_woLFE ); + v_multc_fixed( st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIsmMetaData[i]->edited_gain, 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 2a2ff6c18..7afa55844 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -1906,11 +1906,8 @@ void ivas_param_ism_params_to_masa_param_mapping_fx( } ELSE { - -#endif - st_ivas->hISMDTX.dtx_flag = 1; - - move16(); + st_ivas->hISMDTX.dtx_flag = 1; + move16(); } IF( GT_16( st_ivas->nchan_ism, 1 ) ) @@ -1958,9 +1955,10 @@ void ivas_param_ism_params_to_masa_param_mapping_fx( 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(); -#endif - power_ratio_fx[0] = hParamIsmDec->power_ratios_fx[band_idx][0][0];lues_fx[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][0]], ( 1 << 21 ) ), 22 ) ); // Q0 + 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(); power_ratio_fx[0] = hParamIsmDec->power_ratios_fx[band_idx][0][0]; move16(); -- GitLab From 5e278c127a7433af7ca8ce7a6c6956bd07be118b Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 9 Oct 2025 09:46:36 +0200 Subject: [PATCH 03/46] convert OE code to BASOP --- lib_com/ivas_ism_com_fx.c | 14 +-- lib_com/ivas_prot_fx.h | 2 +- lib_com/ivas_stat_com.h | 14 +-- lib_dec/ivas_dirac_dec_fx.c | 2 +- lib_dec/ivas_ism_param_dec_fx.c | 196 ++++++++++++++++++++++---------- lib_dec/ivas_ism_renderer_fx.c | 6 +- lib_dec/ivas_jbm_dec_fx.c | 2 +- lib_dec/ivas_stat_dec.h | 4 +- 8 files changed, 156 insertions(+), 84 deletions(-) diff --git a/lib_com/ivas_ism_com_fx.c b/lib_com/ivas_ism_com_fx.c index 3e0d938c4..cbb66246c 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 = 1.0f; - hIsmMeta->edited_azimuth = 0.0f; - hIsmMeta->edited_elevation = 0.0f; - hIsmMeta->edited_pitch = 0.0f; - hIsmMeta->edited_yaw = 0.0f; - hIsmMeta->edited_radius = 1.0f; - hIsmMeta->gain = 1.0f; + hIsmMeta->edited_gain_fx = ONE_IN_Q30; + 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_Q30; + hIsmMeta->gain_fx = ONE_IN_Q30; hIsmMeta->non_diegetic_flag = 0; #endif diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 9eb954046..0d46e2a62 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -4334,7 +4334,7 @@ void ivas_param_ism_dec_digest_tc_fx( #ifdef OBJ_EDITING_API -void ivas_param_ism_dec_dequant_md( +void ivas_param_ism_dec_dequant_md_fx( Decoder_Struct *st_ivas ); diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 891515997..567c2ec64 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -66,15 +66,15 @@ typedef struct Word32 pitch_fx; /* pitch value read from the input metadata file */ /* Q22 */ #ifdef OBJ_EDITING_API - Word16 gain /* Q30 */; + Word32 gain_fx; /* Q30 */ - Word32 edited_azimuth; /* Q22 */ - Word32 edited_elevation; /* Q22 */ - Word16 edited_radius; /* Q9 */ + Word32 edited_azimuth_fx; /* Q22 */ + Word32 edited_elevation_fx; /* Q22 */ + Word32 edited_radius_fx; /* Q9 */ - Word32 edited_yaw; /* Q22 */ - Word32 edited_pitch; /* Q22 */ - Word16 edited_gain; /* Q30 */ + Word32 edited_yaw_fx; /* Q22 */ + Word32 edited_pitch_fx; /* Q22 */ + Word32 edited_gain_fx; /* Q30 */ #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 ba48ee141..770b6fb36 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -3838,7 +3838,7 @@ 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 - v_multc_fixed( st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIsmMetaData[i]->edited_gain, st_ivas->hIsmRendererData->gains_fx[i], nchan_out_woLFE ); // Q30, Q30 --> Q30 + 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 #endif } } diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 7afa55844..bb2c9546f 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -980,8 +980,13 @@ void ivas_ism_dec_digest_tc_fx( IF( EQ_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_STEREO ) ) { #ifdef OBJ_EDITING_API - ivas_ism_get_stereo_gains( st_ivas->hIsmMetaData[i]->edited_azimuth, st_ivas->hIsmMetaData[i]->edited_elevation, &st_ivas->hIsmRendererData->gains[i][0], &st_ivas->hIsmRendererData->gains[i][1] ); - v_multc( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmMetaData[i]->edited_gain, st_ivas->hIsmRendererData->gains[i], CPE_CHANNELS ); + 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] ); + st_ivas->hIsmRendererData->gains_fx[i][0] = L_shr( L_deposit_h( gains_fx[0] ), 1 ); // Q31 -> Q30 + move32(); + st_ivas->hIsmRendererData->gains_fx[i][1] = L_shr( L_deposit_h( gains_fx[1] ), 1 ); // Q31 -> Q30 + move32(); + 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 #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] ); @@ -995,8 +1000,8 @@ void ivas_ism_dec_digest_tc_fx( { // TODO tmu review when #215 is resolved #ifdef OBJ_EDITING_API - azimuth = (int16_t) floorf( st_ivas->hIsmMetaData[i]->edited_azimuth + 0.5f ); - elevation = (int16_t) floorf( st_ivas->hIsmMetaData[i]->edited_elevation + 0.5f ); + azimuth_fx = L_shr( L_add( st_ivas->hIsmMetaData[i]->edited_azimuth_fx, 2097152 ), Q22 ); // Q0 ,2097152 = .5f in Q22 + elevation_fx = L_shr( L_add( st_ivas->hIsmMetaData[i]->edited_elevation_fx, 2097152 ), Q22 ); // Q0 ,2097152 = .5f in Q22 #else azimuth_fx = L_shr( L_add( st_ivas->hIsmMetaData[i]->azimuth_fx, 2097152 ), Q22 ); // Q0 ,2097152 = .5f in Q22 elevation_fx = L_shr( L_add( st_ivas->hIsmMetaData[i]->elevation_fx, 2097152 ), Q22 ); // Q0 ,2097152 = .5f in Q22 @@ -1029,7 +1034,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 - v_multc( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmMetaData[i]->edited_gain, st_ivas->hIsmRendererData->gains[i], st_ivas->hEFAPdata->numSpk ); + 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 } } @@ -1042,7 +1047,7 @@ 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 - v_multc( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmMetaData[i]->edited_gain, st_ivas->hIsmRendererData->gains[i], ivas_sba_get_nchan( st_ivas->hIntSetup.ambisonics_order, 0 ) ); + 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 #endif } } @@ -1063,7 +1068,6 @@ void ivas_param_ism_dec_digest_tc_fx( Word32 *transport_channels[], /* i : synthesized core-coder transport channels/DirAC output q_tc_in*/ Word16 q_tc_in ) { - Word16 exp_real_tmp = 0, exp_imag_tmp = 0; move16(); move16(); move16(); @@ -1071,6 +1075,7 @@ void ivas_param_ism_dec_digest_tc_fx( #ifndef OBJ_EDITING_API Word32 cx_diag_fx[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX]; Word16 exp_cx_diag[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX]; + Word16 exp_real_tmp = 0, exp_imag_tmp = 0; #endif Word16 q_tc = q_tc_in; @@ -1080,7 +1085,7 @@ void ivas_param_ism_dec_digest_tc_fx( Word16 slot_idx, bin_idx; Word32 ivas_total_brate; #else - Word16 ch, nchan_transport; + Word16 ch, nchan_transport, i; Word16 slot_idx; #endif @@ -1094,7 +1099,9 @@ void ivas_param_ism_dec_digest_tc_fx( Word16 fade_len; /* Initialization */ +#ifndef OBJ_EDITING_API set32_fx( &direct_response_fx[0][0], 0, MAX_NUM_OBJECTS * PARAM_ISM_MAX_CHAN ); +#endif hParamIsmDec = st_ivas->hParamIsmDec; assert( hParamIsmDec ); hSpatParamRendCom = st_ivas->hSpatParamRendCom; @@ -1251,6 +1258,7 @@ void ivas_param_ism_dec_digest_tc_fx( move16(); } +#ifndef OBJ_EDITING_API Word16 scale_factor_real, scale_factor_imag; Word16 current_idx; exp_real_tmp = hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_exp; @@ -1264,7 +1272,6 @@ void ivas_param_ism_dec_digest_tc_fx( scale_sig32( &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[current_idx], hSpatParamRendCom->num_freq_bands, scale_factor_imag ); // Q(31-(exp_imag_tmp-scale_factor_imag)) exp_real_tmp = sub( exp_real_tmp, scale_factor_real ); exp_imag_tmp = sub( exp_imag_tmp, scale_factor_imag ); -#ifndef OBJ_EDITING_API ivas_param_ism_collect_slot_fx( hParamIsmDec, &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx[current_idx], exp_real_tmp, @@ -1272,12 +1279,12 @@ void ivas_param_ism_dec_digest_tc_fx( exp_imag_tmp, ch, cx_diag_fx, exp_cx_diag ); -#endif exp_real_tmp = add( exp_real_tmp, scale_factor_real ); exp_imag_tmp = add( exp_imag_tmp, scale_factor_imag ); scale_sig32( &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx[current_idx], hSpatParamRendCom->num_freq_bands, -scale_factor_real ); // Q(31-(exp_real_tmp)) scale_sig32( &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[current_idx], hSpatParamRendCom->num_freq_bands, -scale_factor_imag ); // Q(31-(exp_imag_tmp)) +#endif } } @@ -1306,121 +1313,177 @@ void ivas_param_ism_dec_digest_tc_fx( * *-------------------------------------------------------------------------*/ -void ivas_param_ism_dec_prepare_renderer( +void ivas_param_ism_dec_prepare_renderer_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nCldfbSlots /* i : number of CLFBS slots in the transport channels */ + const Word16 nCldfbSlots /* i : number of CLFBS slots in the transport channels */ ) { int16_t ch, nchan_transport, nchan_out, nchan_out_woLFE, i; int16_t slot_idx, bin_idx; - float ref_power[CLDFB_NO_CHANNELS_MAX]; - float cx_diag[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX]; + Word32 ref_powe_fx[CLDFB_NO_CHANNELS_MAX]; + Word32 cx_diag_fx[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX]; + Word16 exp_cx_diag[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX]; + Word16 exp_real_tmp = 0, exp_imag_tmp = 0; + Word32 ivas_total_brate; /* Direct Response/EFAP Gains */ - float direct_response[MAX_NUM_OBJECTS][PARAM_ISM_MAX_CHAN]; + Word32 direct_response_fx[MAX_NUM_OBJECTS][PARAM_ISM_MAX_CHAN]; PARAM_ISM_DEC_HANDLE hParamIsmDec; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; /* Initialization */ hParamIsmDec = st_ivas->hParamIsmDec; - assert( hParamIsmDec ); - hSpatParamRendCom = st_ivas->hSpatParamRendCom; - assert( hSpatParamRendCom ); - nchan_transport = st_ivas->nchan_transport; + move16(); + ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; + move32(); - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_exp = 25; + move16(); + hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_exp = 25; + move16(); + IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) { nchan_out = st_ivas->nchan_ism; + move16(); nchan_out_woLFE = nchan_out; + move16(); st_ivas->hDecoderConfig->nchan_out = nchan_out; + move16(); } - else + ELSE { - nchan_out = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; + nchan_out = add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe ); nchan_out_woLFE = st_ivas->hIntSetup.nchan_out_woLFE; + move16(); } - push_wmops( "ivas_param_ism_dec_digest_tc" ); /* general setup */ - ivas_jbm_dec_get_adapted_linear_interpolator( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbSlots, hParamIsmDec->hParamIsmRendering->interpolator ); - - ivas_dirac_dec_set_md_map( st_ivas, nCldfbSlots ); + ivas_jbm_dec_get_adapted_linear_interpolator_fx( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbSlots, hParamIsmDec->hParamIsmRendering->interpolator_fx ); + ivas_dirac_dec_set_md_map_fx( st_ivas, nCldfbSlots ); /* set buffers to zero */ - for ( bin_idx = 0; bin_idx < CLDFB_NO_CHANNELS_MAX; bin_idx++ ) + + set_zero_fx( &cx_diag_fx[0][0], CLDFB_NO_CHANNELS_MAX * PARAM_ISM_MAX_DMX ); + set16_zero_fx( &exp_cx_diag[0][0], CLDFB_NO_CHANNELS_MAX * PARAM_ISM_MAX_DMX ); + + /* Frame-level Processing */ + /* De-quantization */ + test(); + IF( !( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) || EQ_32( ivas_total_brate, FRAME_NO_DATA ) ) ) { - set_zero( cx_diag[bin_idx], PARAM_ISM_MAX_DMX ); + ivas_param_ism_dec_dequant_DOA_fx( hParamIsmDec, st_ivas->nchan_ism ); + ivas_param_ism_dec_dequant_powrat_fx( hParamIsmDec ); + st_ivas->hISMDTX.dtx_flag = 0; + move16(); + } + ELSE + { + st_ivas->hISMDTX.dtx_flag = 1; + move16(); } - set_zero( ref_power, CLDFB_NO_CHANNELS_MAX ); /* obtain the direct response using EFAP */ - if ( !( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) ) + IF( !( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) ) { - for ( i = 0; i < st_ivas->nchan_ism; i++ ) + FOR( i = 0; i < st_ivas->nchan_ism; i++ ) { - efap_determine_gains( st_ivas->hEFAPdata, direct_response[i], hParamIsmDec->edited_azimuth_values[i], hParamIsmDec->edited_elevation_values[i], EFAP_MODE_EFAP ); + efap_determine_gains_fx( st_ivas->hEFAPdata, direct_response_fx[i], hParamIsmDec->azimuth_values_fx[i], hParamIsmDec->elevation_values_fx[i], EFAP_MODE_EFAP ); } } - else + ELSE { - int16_t j; + Word16 j; - for ( i = 0; i < st_ivas->nchan_ism; i++ ) + FOR( i = 0; i < st_ivas->nchan_ism; i++ ) { - for ( j = 0; j < nchan_out_woLFE; j++ ) + FOR( j = 0; j < nchan_out_woLFE; j++ ) { - if ( i == j ) + IF( EQ_16( i, j ) ) { - direct_response[i][j] = 1.0f; + direct_response_fx[i][j] = ONE_IN_Q30; + move32(); } - else + ELSE { - direct_response[i][j] = 0.0f; + direct_response_fx[i][j] = 0; + move32(); } } } - for ( j = 0; j < nchan_out_woLFE; j++ ) + FOR( j = 0; j < nchan_out_woLFE; j++ ) { - if ( hParamIsmDec->azimuth_values[j] > 0.0f ) + IF( hParamIsmDec->azimuth_values_fx[j] > 0 ) { - hParamIsmDec->hParamIsmRendering->proto_matrix[j] = 1.0f; - hParamIsmDec->hParamIsmRendering->proto_matrix[nchan_out_woLFE + j] = 0.0f; + hParamIsmDec->hParamIsmRendering->proto_matrix_fx[j] = 32767; // (1.0f in Q15) - 1 + move16(); + hParamIsmDec->hParamIsmRendering->proto_matrix_fx[nchan_out_woLFE + j] = 0; + move16(); } - else + ELSE { - if ( hParamIsmDec->azimuth_values[j] < 0.0f ) + IF( hParamIsmDec->azimuth_values_fx[j] < 0 ) { - hParamIsmDec->hParamIsmRendering->proto_matrix[j] = 0.0f; - hParamIsmDec->hParamIsmRendering->proto_matrix[nchan_out_woLFE + j] = 1.0f; + hParamIsmDec->hParamIsmRendering->proto_matrix_fx[j] = 0; + move16(); + hParamIsmDec->hParamIsmRendering->proto_matrix_fx[nchan_out_woLFE + j] = 32767; // (1.0f in Q15) - 1 + move16(); } - else /* == 0.0f */ + ELSE /* == 0.0f */ { - hParamIsmDec->hParamIsmRendering->proto_matrix[j] = 0.5f; - hParamIsmDec->hParamIsmRendering->proto_matrix[nchan_out_woLFE + j] = 0.5f; + hParamIsmDec->hParamIsmRendering->proto_matrix_fx[j] = ONE_IN_Q14; // Q15 + move16(); + hParamIsmDec->hParamIsmRendering->proto_matrix_fx[nchan_out_woLFE + j] = ONE_IN_Q14; // Q15 + move16(); } } } } - for ( ch = 0; ch < nchan_transport; ch++ ) + FOR( ch = 0; ch < nchan_transport; ch++ ) { /* CLDFB Analysis */ - for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) + FOR( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) { - ivas_param_ism_collect_slot( hParamIsmDec, &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], ch, ref_power, cx_diag ); + Word16 scale_factor_real, scale_factor_imag; + Word16 current_idx; + exp_real_tmp = hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_exp; + move16(); + exp_imag_tmp = hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_exp; + move16(); + current_idx = add( imult1616( imult1616( slot_idx, hSpatParamRendCom->num_freq_bands ), nchan_transport ), imult1616( ch, hSpatParamRendCom->num_freq_bands ) ); + scale_factor_real = getScaleFactor32( &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx[current_idx], hSpatParamRendCom->num_freq_bands ); + scale_factor_imag = getScaleFactor32( &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[current_idx], hSpatParamRendCom->num_freq_bands ); + scale_sig32( &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx[current_idx], hSpatParamRendCom->num_freq_bands, scale_factor_real ); // Q(31-(exp_real_tmp-scale_factor_real)) + scale_sig32( &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[current_idx], hSpatParamRendCom->num_freq_bands, scale_factor_imag ); // Q(31-(exp_imag_tmp-scale_factor_imag)) + exp_real_tmp = sub( exp_real_tmp, scale_factor_real ); + exp_imag_tmp = sub( exp_imag_tmp, scale_factor_imag ); + ivas_param_ism_collect_slot_fx( hParamIsmDec, + &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx[current_idx], + exp_real_tmp, + &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[current_idx], + exp_imag_tmp, + ch, + cx_diag_fx, exp_cx_diag ); + + exp_real_tmp = add( exp_real_tmp, scale_factor_real ); + exp_imag_tmp = add( exp_imag_tmp, scale_factor_imag ); + scale_sig32( &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx[current_idx], hSpatParamRendCom->num_freq_bands, -scale_factor_real ); // Q(31-(exp_real_tmp)) + scale_sig32( &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[current_idx], hSpatParamRendCom->num_freq_bands, -scale_factor_imag ); // Q(31-(exp_imag_tmp)) } } /* Obtain Mixing Matrix on a frame-level */ - for ( bin_idx = 0; bin_idx < hSpatParamRendCom->num_freq_bands; bin_idx++ ) + FOR( bin_idx = 0; bin_idx < CLDFB_NO_CHANNELS_MAX; bin_idx++ ) { - set_f( hParamIsmDec->hParamIsmRendering->mixing_matrix_lin[bin_idx], 0.0f, nchan_transport * nchan_out_woLFE ); + set32_fx( hParamIsmDec->hParamIsmRendering->mixing_matrix_lin_fx[bin_idx], 0, PARAM_ISM_MAX_CHAN * PARAM_ISM_MAX_DMX ); } /* Compute mixing matrix */ - ivas_param_ism_compute_mixing_matrix( st_ivas->nchan_ism, hParamIsmDec, st_ivas->hISMDTX, direct_response, nchan_transport, nchan_out_woLFE, cx_diag, ref_power, hParamIsmDec->hParamIsmRendering->mixing_matrix_lin ); + ivas_param_ism_compute_mixing_matrix_fx( st_ivas->nchan_ism, hParamIsmDec, st_ivas->hISMDTX, direct_response_fx, nchan_transport, nchan_out_woLFE, cx_diag_fx, exp_cx_diag, + hParamIsmDec->hParamIsmRendering->mixing_matrix_lin_fx, hParamIsmDec->hParamIsmRendering->exp_mixing_matrix_lin_fx ); + pop_wmops(); @@ -1909,6 +1972,7 @@ void ivas_param_ism_params_to_masa_param_mapping_fx( st_ivas->hISMDTX.dtx_flag = 1; move16(); } +#endif IF( GT_16( st_ivas->nchan_ism, 1 ) ) { @@ -1949,8 +2013,14 @@ void ivas_param_ism_params_to_masa_param_mapping_fx( { brange[0] = hParamIsmDec->hParamIsm->band_grouping[band_idx]; #ifdef OBJ_EDITING_API - azimuth[0] = (int16_t) roundf( hParamIsmDec->edited_azimuth_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][0]] ); - elevation[0] = (int16_t) roundf( hParamIsmDec->edited_elevation_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][0]] ); + 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(); #else move16(); brange[1] = hParamIsmDec->hParamIsm->band_grouping[band_idx + 1]; @@ -1960,19 +2030,21 @@ void ivas_param_ism_params_to_masa_param_mapping_fx( 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(); #ifdef OBJ_EDITING_API - azimuth[1] = (int16_t) roundf( hParamIsmDec->edited_azimuth_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][1]] ); - elevation[1] = (int16_t) roundf( hParamIsmDec->edited_elevation_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][1]] ); + 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(); #endif - power_ratio_fx[1] = hParamIsmDec->power_ratios_fx[band_idx][0][1]; move16(); diff --git a/lib_dec/ivas_ism_renderer_fx.c b/lib_dec/ivas_ism_renderer_fx.c index 0d79e8807..ef16c3aa3 100644 --- a/lib_dec/ivas_ism_renderer_fx.c +++ b/lib_dec/ivas_ism_renderer_fx.c @@ -260,7 +260,7 @@ void ivas_ism_render_sf_fx( if ( GE_16( subframe_idx, ism_md_subframe_update_jbm ) ) { #ifdef OBJ_EDITING_API - rotateAziEle( st_ivas->hIsmMetaData[i]->edited_azimuth, st_ivas->hIsmMetaData[i]->edited_elevation, &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); + rotateAziEle_fx( extract_l( L_shr( st_ivas->hIsmMetaData[i]->edited_azimuth_fx, 22 ) ), extract_l( L_shr( st_ivas->hIsmMetaData[i]->edited_elevation_fx, 22 ) ), &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat_fx[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); #else rotateAziEle_fx( extract_l( L_shr( st_ivas->hIsmMetaData[i]->azimuth_fx, 22 ) ), extract_l( L_shr( st_ivas->hIsmMetaData[i]->elevation_fx, 22 ) ), &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat_fx[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); #endif @@ -268,7 +268,7 @@ void ivas_ism_render_sf_fx( else { #ifdef OBJ_EDITING_API - rotateAziEle( st_ivas->hIsmMetaData[i]->edited_azimuth, st_ivas->hIsmMetaData[i]->edited_elevation, &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); + rotateAziEle_fx( extract_l( L_shr( st_ivas->hIsmMetaData[i]->edited_azimuth_fx, 22 ) ), extract_l( L_shr( st_ivas->hIsmMetaData[i]->edited_elevation_fx, 22 ) ), &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat_fx[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); #else rotateAziEle_fx( extract_l( L_shr( st_ivas->hIsmMetaData[i]->last_azimuth_fx, 22 ) ), extract_l( L_shr( st_ivas->hIsmMetaData[i]->last_elevation_fx, 22 ) ), &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat_fx[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); #endif @@ -278,7 +278,7 @@ 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 - v_multc( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmMetaData[i]->edited_gain, st_ivas->hIsmRendererData->gains[i], nchan_out_woLFE ); + 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 #endif } } diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 8e6e5fcf3..409817907 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -1869,7 +1869,7 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( { if ( st_ivas->mc_mode == MC_MODE_PARAMMC && st_ivas->hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_RENDERER ) { - ivas_param_mc_dec_digest_tc_fx( st_ivas, (uint8_t) n_render_timeslots, p_data_f ); + ivas_param_mc_dec_digest_tc_fx( st_ivas, (UWord8) n_render_timeslots, (Word32 **) p_data_f_fx, Q11 ); } } #endif diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 464ef3dcf..fc4fc4365 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 - float edited_azimuth_values[MAX_PARAM_SPATIAL_SUBFRAMES * IVAS_MAX_NUM_BANDS]; - float edited_elevation_values[MAX_PARAM_SPATIAL_SUBFRAMES * IVAS_MAX_NUM_BANDS]; + 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]; #endif /*sub-modules*/ -- GitLab From 05b535ce08dc5f336f1c4a9540c30a628d759b64 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 9 Oct 2025 13:33:15 +0200 Subject: [PATCH 04/46] convert more code to BASOP --- lib_com/common_api_types.h | 4 +- lib_com/ivas_prot_fx.h | 2 +- lib_dec/ivas_ism_param_dec_fx.c | 28 +- lib_dec/ivas_jbm_dec_fx.c | 225 +++++++---- lib_dec/ivas_mc_param_dec_fx.c | 439 +++++++++++----------- lib_dec/ivas_objectRenderer_internal_fx.c | 12 +- lib_dec/ivas_stat_dec.h | 2 +- lib_dec/lib_dec_fx.c | 175 ++++----- 8 files changed, 481 insertions(+), 406 deletions(-) diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 948ce1ff7..5c006f8c1 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -138,7 +138,7 @@ typedef struct _IVAS_ISM_METADATA float pitch; Word16 non_diegetic_flag; #ifdef OBJ_EDITING_API - float gain; + Word32 gain_fx; #endif } IVAS_ISM_METADATA; @@ -148,7 +148,7 @@ typedef struct _IVAS_EDITABLE_PARAMETERS { int16_t num_obj; IVAS_ISM_METADATA ism_metadata[IVAS_MAX_NUM_OBJECTS]; - float gain_bed; + Word32 gain_bed_fx; } IVAS_EDITABLE_PARAMETERS; #endif diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 0d46e2a62..f78513fd6 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -5190,7 +5190,7 @@ void ivas_param_mc_dec_digest_tc_fx( #ifdef OBJ_EDITING_API void ivas_param_mc_dec_prepare_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint8_t nCldfbSlots /* i : number of CLFBS slots in the transport channels */ + const UWord16 nCldfbSlots /* i : number of CLFBS slots in the transport channels */ ); #endif diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index bb2c9546f..841b1a6d8 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -1307,8 +1307,34 @@ void ivas_param_ism_dec_digest_tc_fx( #ifdef OBJ_EDITING_API + + +/*-------------------------------------------------------------------------* + * ivas_param_ism_dec_prepare_renderer_fx() + * + * + *-------------------------------------------------------------------------*/ + +void ivas_param_ism_dec_dequant_md_fx( + Decoder_Struct *st_ivas ) +{ + /* De-quantization */ + if ( !( st_ivas->hDecoderConfig->ivas_total_brate == IVAS_SID_5k2 || st_ivas->hDecoderConfig->ivas_total_brate == FRAME_NO_DATA ) ) + { + ivas_param_ism_dec_dequant_DOA_fx( st_ivas->hParamIsmDec, st_ivas->nchan_ism ); + ivas_param_ism_dec_dequant_powrat_fx( st_ivas->hParamIsmDec ); + st_ivas->hISMDTX.dtx_flag = 0; + } + else + { + st_ivas->hISMDTX.dtx_flag = 1; + } + + return; +} + /*-------------------------------------------------------------------------* - * ivas_param_ism_dec_prepare_renderer() + * ivas_param_ism_dec_prepare_renderer_fx() * * *-------------------------------------------------------------------------*/ diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 409817907..71db4c1e6 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2222,7 +2222,7 @@ ivas_error ivas_jbm_dec_render_fx( #ifdef OBJ_EDITING_API if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { - float gain = st_ivas->hSbaIsmData->gain_bed; + Word32 gain = st_ivas->hSbaIsmData->gain_bed_fx; if ( gain != 1.0f && gain >= 0.0f ) { int16_t i; @@ -2230,7 +2230,7 @@ ivas_error ivas_jbm_dec_render_fx( { for ( i = 0; i < *nSamplesRendered; i++ ) { - p_output[n][i] += p_tc[n + st_ivas->nchan_ism][i] * gain; + assert ( 0 && "This is yet to be implemented"); } } } @@ -2238,16 +2238,15 @@ ivas_error ivas_jbm_dec_render_fx( { for ( n = 0; n < nchan_out; n++ ) { - v_add( p_output[n], p_tc[n + st_ivas->nchan_ism], p_output[n], *nSamplesRendered ); + assert ( 0 && "This is yet to be implemented"); } } } else -#else +#endif { ivas_osba_stereo_add_channels_fx( p_tc_fx, p_output_fx, ONE_IN_Q11, nchan_out, st_ivas->nchan_ism, *nSamplesRendered ); } -#endif } ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_OSBA_AMBI ) || EQ_32( st_ivas->renderer_type, RENDERER_OSBA_LS ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { @@ -4421,152 +4420,220 @@ void ivas_jbm_dec_prepare_renderer( n_render_timeslots = st_ivas->hTcBuffer->n_samples_available / st_ivas->hTcBuffer->n_samples_granularity; - if ( st_ivas->hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_BUFFER ) + + IF( EQ_16( st_ivas->hTcBuffer->tc_buffer_mode, TC_BUFFER_MODE_BUFFER ) ) { ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); - if ( ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) && st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL && st_ivas->hDecoderConfig->Opt_tsm ) + test(); + test(); + test(); + IF( ( EQ_16( st_ivas->ivas_format, MASA_FORMAT ) || EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) && EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) && st_ivas->hDecoderConfig->Opt_tsm ) { ivas_jbm_masa_sf_to_slot_map( st_ivas, n_render_timeslots ); } } - else if ( st_ivas->ivas_format == STEREO_FORMAT ) + ELSE IF( EQ_16( st_ivas->ivas_format, STEREO_FORMAT ) ) { ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); } - else if ( st_ivas->ivas_format == ISM_FORMAT ) + ELSE IF( EQ_16( st_ivas->ivas_format, ISM_FORMAT ) ) { /* Rendering */ - if ( st_ivas->ism_mode == ISM_MODE_PARAM ) + IF( EQ_16( st_ivas->ism_mode, ISM_MODE_PARAM ) ) { - if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) - { - ivas_dirac_dec_set_md_map( st_ivas, n_render_timeslots ); - ivas_param_ism_params_to_masa_param_mapping( st_ivas ); - } - else if ( st_ivas->renderer_type == RENDERER_PARAM_ISM || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) + test(); + test(); + IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_16( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) { - ivas_param_ism_dec_prepare_renderer( st_ivas, n_render_timeslots ); + ivas_dirac_dec_set_md_map_fx( st_ivas, n_render_timeslots ); + + ivas_param_ism_params_to_masa_param_mapping_fx( st_ivas ); } } - else /* ISM_MODE_DISC */ + ELSE /* ISM_MODE_DISC */ { - ivas_ism_dec_digest_tc( st_ivas ); + ivas_ism_dec_digest_tc_fx( st_ivas ); } } - else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) + ELSE IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) || EQ_16( st_ivas->ivas_format, MASA_FORMAT ) ) { - ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + IF( st_ivas->hSCE[0] ) + { + Word16 shift = getScaleFactor32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN ); + IF( LT_16( sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ), 4 ) ) + { + shift = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 4 ); + } + scale_sig32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift ); // Q(31-cngNoiseLevelExp+shift) + st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ); + } + ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); } - else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + ELSE IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) { - if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + IF( EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) { - ivas_ism_dec_digest_tc( st_ivas ); + ivas_ism_dec_digest_tc_fx( st_ivas ); + test(); + test(); + test(); + test(); /* delay the objects here for all renderers where it is needed */ - if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || - st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || - st_ivas->renderer_type == RENDERER_OSBA_AMBI || - st_ivas->renderer_type == RENDERER_OSBA_LS || - st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) && - ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + IF( + ( + EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || + EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || + EQ_16( st_ivas->renderer_type, RENDERER_OSBA_AMBI ) || + EQ_16( st_ivas->renderer_type, RENDERER_OSBA_LS ) || + EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) && + ( NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) ) { - for ( n = 0; n < st_ivas->nchan_ism; n++ ) + FOR( n = 0; n < st_ivas->nchan_ism; n++ ) { - delay_signal( st_ivas->hTcBuffer->tc[n], st_ivas->hTcBuffer->n_samples_available, st_ivas->hSbaIsmData->delayBuffer[n], st_ivas->hSbaIsmData->delayBuffer_size ); + delay_signal32_fx( st_ivas->hTcBuffer->tc_fx[n], st_ivas->hTcBuffer->n_samples_available, st_ivas->hSbaIsmData->delayBuffer_fx[n], st_ivas->hSbaIsmData->delayBuffer_size ); } } - if ( !st_ivas->sba_dirac_stereo_flag ) + IF( !st_ivas->sba_dirac_stereo_flag ) { - if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) + IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ) { - n_render_timeslots *= ( st_ivas->hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size ); + Word16 temp, temp_e; + temp = BASOP_Util_Divide1616_Scale( st_ivas->hTcBuffer->n_samples_granularity, st_ivas->hSpatParamRendCom->slot_size, &temp_e ); + n_render_timeslots = extract_l( L_shr( L_mult0( n_render_timeslots, temp ), sub( 15, temp_e ) ) ); } - ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + IF( st_ivas->hSCE[0] ) + { + Word16 shift = getScaleFactor32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN ); + if ( LT_16( sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ), 4 ) ) + { + shift = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 4 ); + } + scale_sig32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift ); // Q(31-cngNoiseLevelExp+shift) + st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ); + } + ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); } } - else + ELSE { ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); - ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + IF( st_ivas->hSCE[0] ) + { + Word16 shift = getScaleFactor32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN ); + if ( LT_16( sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ), 4 ) ) + { + shift = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 4 ); + } + scale_sig32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift ); // Q(31-cngNoiseLevelExp+shift) + st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ); + } + ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); } } - else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) + ELSE IF( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) { - if ( st_ivas->renderer_type == RENDERER_OMASA_MIX_EXT || st_ivas->renderer_type == RENDERER_OMASA_OBJECT_EXT ) + test(); + IF( EQ_32( st_ivas->renderer_type, RENDERER_OMASA_MIX_EXT ) || EQ_32( st_ivas->renderer_type, RENDERER_OMASA_OBJECT_EXT ) ) { ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); - - if ( st_ivas->hDecoderConfig->Opt_tsm ) + IF( st_ivas->hDecoderConfig->Opt_tsm ) { ivas_jbm_masa_sf_to_slot_map( st_ivas, n_render_timeslots ); } } - else + ELSE { - if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + test(); + IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) { - n_render_timeslots *= ( st_ivas->hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size ); + n_render_timeslots = i_mult( n_render_timeslots, idiv1616( st_ivas->hTcBuffer->n_samples_granularity, st_ivas->hSpatParamRendCom->slot_size ) ); } - ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + IF( st_ivas->hSCE[0] ) + { + Word16 shift = getScaleFactor32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN ); + if ( LT_16( sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ), 4 ) ) + { + shift = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 4 ); + } + scale_sig32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift ); // Q(31- (st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp - shift) + st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ); + move16(); + } + ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); - if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) { - ivas_ism_dec_digest_tc( st_ivas ); + ivas_ism_dec_digest_tc_fx( st_ivas ); } + } + + test(); + IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_DIRAC ) ) + { + Word16 num_objects; - if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_DIRAC ) + /* Delay the signal to match CLDFB delay. Delay the whole buffer. */ + num_objects = 0; + move16(); + + test(); + test(); + IF( ( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) || EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) && NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) ) { - int16_t num_objects; - /* Delay the signal to match CLDFB delay. Delay the whole buffer. */ - num_objects = 0; - if ( ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC ) - { - num_objects = 1; - } - else if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) - { - num_objects = st_ivas->nchan_ism; - } - for ( n = 0; n < num_objects; n++ ) + num_objects = 1; + move16(); + } + ELSE IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) + { + num_objects = st_ivas->nchan_ism; + move16(); + } + FOR( n = 0; n < num_objects; n++ ) + { + test(); + IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) ) { - if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) - { - v_multc( st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], OMASA_TDREND_MATCHING_GAIN, st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available ); - } -#ifndef TMP_FIX_OMASA_SR_BE - if ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) -#endif - { - delay_signal( st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); - } + 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 ); } + 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 ); } } } - else if ( st_ivas->ivas_format == MC_FORMAT ) + ELSE IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) ) { - if ( st_ivas->mc_mode == MC_MODE_MCT ) + IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCT ) ) { ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); } - else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) + ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) { - ivas_mc_paramupmix_dec_digest_tc( st_ivas, (uint8_t) n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + ivas_mc_paramupmix_dec_digest_tc( st_ivas, (UWord8) n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); } - else if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) + ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMMC ) ) { - ivas_param_mc_dec_prepare_renderer( st_ivas, (uint8_t) n_render_timeslots ); + ivas_param_mc_dec_prepare_renderer( st_ivas, (UWord16) n_render_timeslots ); } - else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) + ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) ) { - ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + IF( st_ivas->hSCE[0] ) + { + Word16 shift = getScaleFactor32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN ); + if ( LT_16( sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ), 4 ) ) + { + shift = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 4 ); + } + scale_sig32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift ); // Q(31-cngNoiseLevelExp+shift) + st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ); + move16(); + } + ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); } } diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index 1be8b3a69..faa2a4ee9 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -1521,7 +1521,7 @@ void ivas_param_mc_dec_digest_tc_fx( PARAM_MC_DEC_HANDLE hParamMC; #ifdef OBJ_EDITING_API Word16 ch, slot_idx; - Word16 nchan_transport + Word16 nchan_transport; #else Word16 i, ch; Word16 is_next_band, skip_next_band; @@ -1530,9 +1530,6 @@ void ivas_param_mc_dec_digest_tc_fx( Word16 nchan_out_cov; #endif /*CLDFB*/ - /* format converter */ - Word16 channel_active[MAX_OUTPUT_CHANNELS]; - IVAS_OUTPUT_SETUP *hSynthesisOutputSetup; hParamMC = st_ivas->hParamMC; assert( hParamMC ); @@ -1549,12 +1546,17 @@ void ivas_param_mc_dec_digest_tc_fx( Word16 cx_e; Word16 cx_imag_e, tmp_e; Word16 cx_imag_next_band_e, cx_next_band_e; + + Word16 max_e; + + /* format converter */ + Word16 channel_active[MAX_OUTPUT_CHANNELS]; + IVAS_OUTPUT_SETUP *hSynthesisOutputSetup; +#endif Word16 qout = 0; move16(); -#endif - Word16 max_e; push_wmops( "param_mc_dec_digest_tc" ); @@ -1564,7 +1566,7 @@ void ivas_param_mc_dec_digest_tc_fx( nchan_transport = st_ivas->nchan_transport; move16(); -#ifndef OBJ_EDITINGA_API +#ifndef OBJ_EDITING_API nchan_out_transport = add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ); test(); @@ -1715,139 +1717,6 @@ void ivas_param_mc_dec_digest_tc_fx( #endif } -#ifdef OBJ_EDITING_API - Word16 tmp_cx_e, tmp_cx_imag_e; - /* map from complex input covariance to real values */ - FOR( is_next_band = 0; is_next_band < 2; is_next_band++ ) - { - test(); - IF( is_next_band && skip_next_band ) - { - CONTINUE; - } - /* Cx for transport channels */ - IF( is_next_band ) - { - pCx = &cx_next_band_fx[0]; - pCx_imag = &cx_imag_next_band_fx[0]; - tmp_cx_e = cx_next_band_e; - tmp_cx_imag_e = cx_imag_next_band_e; - } - ELSE - { - pCx = &cx_fx[0]; - pCx_imag = &cx_imag_fx[0]; - tmp_cx_e = cx_e; - tmp_cx_imag_e = cx_imag_e; - } - - FOR( i = 0; i < nchan_transport * nchan_transport; i++ ) - { - real_part_fx = pCx[i]; // Q(31 - cx_buff_e) - imag_part_fx = pCx_imag[i]; - move32(); - move32(); - cx_buff_e[is_next_band][i] = tmp_cx_e; - move16(); - /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ - IF( LT_16( param_band_idx, hParamMC->max_param_band_abs_cov ) ) - { - L_tmp1 = Mpy_32_32( real_part_fx, real_part_fx ); - L_tmp2 = Mpy_32_32( imag_part_fx, imag_part_fx ); - L_tmp1 = BASOP_Util_Add_Mant32Exp( L_tmp1, add( tmp_cx_e, tmp_cx_e ), L_tmp2, add( tmp_cx_imag_e, tmp_cx_imag_e ), &tmp_e ); - pCx[i] = Sqrt32( L_tmp1, &tmp_e ); - move32(); - cx_buff_e[is_next_band][i] = tmp_e; - move16(); - } - ELSE - { - pCx[i] = real_part_fx; - move32(); - cx_buff_e[is_next_band][i] = tmp_cx_e; - move16(); - } - } - } - - max_e = cx_buff_e[0][0]; - move16(); - - /* Cx for transport channels */ - FOR( is_next_band = 0; is_next_band < 2; is_next_band++ ) - { - FOR( i = 0; i < imult1616( nchan_transport, nchan_transport ); i++ ) - { - - IF( LT_16( max_e, cx_buff_e[is_next_band][i] ) ) - { - max_e = cx_buff_e[is_next_band][i]; - } - } - } - /* Cx for transport channels */ - FOR( is_next_band = 0; is_next_band < 2; is_next_band++ ) - { - FOR( i = 0; i < imult1616( nchan_transport, nchan_transport ); i++ ) - { - if ( is_next_band == 0 ) - { - cx_fx[i] = L_shr( cx_fx[i], sub( max_e, cx_buff_e[is_next_band][i] ) ); - } - else - { - cx_next_band_fx[i] = L_shr( cx_next_band_fx[i], sub( max_e, cx_buff_e[is_next_band][i] ) ); - } - move32(); - } - } - cx_e = max_e; - move16(); - - - /* we have to do it similar to the encoder in case of attacks (i.e. accumulate two bands) to ensure correct DMX of the target covariance*/ - - test(); - test(); - IF( hParamMC->hMetadataPMC->bAttackPresent && ( EQ_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_LS_CONV_COV ) || EQ_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) ) - { - Word16 len = imult1616( nchan_transport, nchan_transport ); - Word16 sc = s_min( getScaleFactor32( cx_fx, len ), getScaleFactor32( cx_next_band_fx, len ) ); - IF( EQ_16( sc, 0 ) ) - { - Scale_sig32( cx_fx, len, -Q1 ); // add one bit head room - Scale_sig32( cx_next_band_fx, len, -Q1 ); // add one bit head room - cx_e = add( cx_e, Q1 ); - cx_next_band_e = add( cx_e, Q1 ); - } - v_add_fx( cx_fx, cx_next_band_fx, cx_fx, len ); - Copy32( cx_fx, cx_next_band_fx, len ); - } - - FOR( is_next_band = 0; is_next_band < 2; is_next_band++ ) - { - test(); - IF( is_next_band && skip_next_band ) - { - CONTINUE; - } - - IF( NE_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) - { - IF( is_next_band ) - { - - ivas_param_mc_get_mixing_matrices_fx( hParamMC, hSynthesisOutputSetup, cx_next_band_fx, cx_e, add( param_band_idx, is_next_band ), hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp, nchan_out_transport, hParamMC->synthesis_conf, nchan_transport, nchan_out_cov ); - } - ELSE - { - - ivas_param_mc_get_mixing_matrices_fx( hParamMC, hSynthesisOutputSetup, cx_fx, cx_e, add( param_band_idx, is_next_band ), hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp, nchan_out_transport, hParamMC->synthesis_conf, nchan_transport, nchan_out_cov ); - } - } - } - } -#endif pop_wmops(); return; @@ -1862,7 +1731,7 @@ void ivas_param_mc_dec_digest_tc_fx( void ivas_param_mc_dec_prepare_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint8_t nCldfbSlots /* i : number of CLFBS slots in the transport channels */ + const UWord16 nCldfbSlots /* i : number of CLFBS slots in the transport channels */ ) { PARAM_MC_DEC_HANDLE hParamMC; @@ -1872,12 +1741,20 @@ void ivas_param_mc_dec_prepare_renderer( int16_t nchan_transport, nchan_out_transport, nchan_out_cldfb; int16_t nchan_out_cov; /*CLDFB*/ - float *pCx, *pCx_imag; - float cx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; - float cx_imag[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; - float cx_next_band[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; - float cx_imag_next_band[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; - float real_part, imag_part; + Word32 *pCx, *pCx_imag; + Word32 cx_fx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; // Q(31 - cx_e) + Word32 cx_imag_fx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; // Q(31 - cx_imag_e) + Word32 cx_next_band_fx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; // Q(31 - cx_next_band_e) + Word32 cx_imag_next_band_fx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; // Q(31 - cx_imag_next_band_e) + Word32 real_part_fx, imag_part_fx, L_tmp1, L_tmp2; + + Word16 cx_buff_e[2][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; + Word16 cx_e; + Word16 cx_imag_e, tmp_e; + Word16 cx_imag_next_band_e, cx_next_band_e; + + Word16 max_e; + /* format converter */ int16_t channel_active[MAX_OUTPUT_CHANNELS]; IVAS_OUTPUT_SETUP *hSynthesisOutputSetup; @@ -1887,141 +1764,259 @@ void ivas_param_mc_dec_prepare_renderer( push_wmops( "param_mc_dec_digest_tc" ); - set_s( channel_active, 0, MAX_CICP_CHANNELS ); nchan_transport = st_ivas->nchan_transport; - nchan_out_transport = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; + move16(); + + nchan_out_transport = add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ); - if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) + test(); + test(); + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { nchan_out_cldfb = BINAURAL_CHANNELS; - set_s( channel_active, 1, nchan_out_cldfb ); - nchan_out_cov = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; + move16(); + set16_fx( channel_active, 1, nchan_out_cldfb ); + nchan_out_cov = add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ); hSynthesisOutputSetup = &st_ivas->hTransSetup; } - else if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_CLDFB ) + ELSE IF( EQ_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_LS_CONV_CLDFB ) ) { nchan_out_cov = nchan_out_transport; - nchan_out_cldfb = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; + move16(); + nchan_out_cldfb = add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ); hSynthesisOutputSetup = &st_ivas->hTransSetup; } - else if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) + ELSE IF( EQ_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_LS_CONV_COV ) || EQ_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) { - nchan_out_cov = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; + nchan_out_cov = add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ); nchan_out_cldfb = nchan_out_cov; - set_s( channel_active, 1, nchan_out_cov ); + move16(); + set16_fx( channel_active, 1, nchan_out_cov ); hSynthesisOutputSetup = &st_ivas->hOutSetup; } - else + ELSE { nchan_out_cov = nchan_out_transport; + move16(); nchan_out_cldfb = nchan_out_transport; - set_s( channel_active, 1, nchan_out_cov ); + move16(); + set16_fx( channel_active, 1, nchan_out_cov ); hSynthesisOutputSetup = &st_ivas->hTransSetup; } /* adapt transient position */ - if ( hParamMC->hMetadataPMC->bAttackPresent ) + IF( hParamMC->hMetadataPMC->bAttackPresent ) { - hParamMC->hMetadataPMC->attackIndex = (int16_t) max( 0, hParamMC->hMetadataPMC->attackIndex + ( ( nCldfbSlots - DEFAULT_JBM_CLDFB_TIMESLOTS ) / 2 ) ); + hParamMC->hMetadataPMC->attackIndex = s_max( 0, add( hParamMC->hMetadataPMC->attackIndex, shr( sub( nCldfbSlots, DEFAULT_JBM_CLDFB_TIMESLOTS ), 1 ) ) ); + move16(); } /* adapt subframes */ hParamMC->num_slots = nCldfbSlots; + move16(); hParamMC->slots_rendered = 0; + move16(); hParamMC->subframes_rendered = 0; + move16(); ivas_jbm_dec_get_adapted_subframes( nCldfbSlots, hParamMC->subframe_nbslots, &hParamMC->nb_subframes ); st_ivas->hTcBuffer->nb_subframes = hParamMC->nb_subframes; - mvs2s( hParamMC->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, hParamMC->nb_subframes ); + move16(); + Copy( hParamMC->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, hParamMC->nb_subframes ); - ivas_param_mc_dec_compute_interpolator( hParamMC->hMetadataPMC->bAttackPresent, hParamMC->hMetadataPMC->attackIndex, nCldfbSlots, hParamMC->h_output_synthesis_params.interpolator ); + ivas_param_mc_dec_compute_interpolator_fx( hParamMC->hMetadataPMC->bAttackPresent, hParamMC->hMetadataPMC->attackIndex, nCldfbSlots, hParamMC->h_output_synthesis_params.interpolator_fx ); /* loop over two bands at a time */ - for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx += 2 ) + FOR( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx += 2 ) { /* don't process next band if it exceeds the limit */ skip_next_band = ( ( param_band_idx + 1 ) == hParamMC->num_param_bands_synth ) ? 1 : 0; - set_zero( cx, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); - set_zero( cx_imag, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); - set_zero( cx_next_band, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); - set_zero( cx_imag_next_band, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); + set_zero_fx( cx_fx, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); + set_zero_fx( cx_imag_fx, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); + set_zero_fx( cx_next_band_fx, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); + set_zero_fx( cx_imag_next_band_fx, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); - /* slot loop for gathering the input data */ - for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) + cx_e = 0; + move16(); + cx_imag_e = 0; + move16(); + cx_next_band_e = 0; + move16(); + cx_imag_next_band_e = 0; + move16(); + + FOR( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) { - if ( slot_idx >= 2 * hParamMC->hMetadataPMC->attackIndex ) + /* slot loop for gathering the input data */ + IF( GE_16( slot_idx, shl( hParamMC->hMetadataPMC->attackIndex, 1 ) ) ) { - for ( is_next_band = 0; is_next_band < 2; is_next_band++ ) + FOR( is_next_band = 0; is_next_band < 2; is_next_band++ ) { - if ( is_next_band && skip_next_band ) + test(); + IF( is_next_band && skip_next_band ) { - continue; + CONTINUE; + } + IF( is_next_band ) + { + ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot_fx( &hParamMC->Cldfb_RealBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport], + /*hParamMC->Cldfb_RealBuffer_tc_e*/ Q31 - Q6, + &hParamMC->Cldfb_ImagBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport], + /*hParamMC->Cldfb_ImagBuffer_tc_e*/ Q31 - Q6, + cx_next_band_fx, + &cx_next_band_e, + cx_imag_next_band_fx, + &cx_imag_next_band_e, + hParamMC, + add( param_band_idx, is_next_band ), + nchan_transport ); + } + ELSE + { + ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot_fx( &hParamMC->Cldfb_RealBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport], + /*hParamMC->Cldfb_RealBuffer_tc_e*/ Q31 - Q6, + &hParamMC->Cldfb_ImagBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport], + /*hParamMC->Cldfb_ImagBuffer_tc_e*/ Q31 - Q6, + cx_fx, + &cx_e, + cx_imag_fx, + &cx_imag_e, + hParamMC, + add( param_band_idx, is_next_band ), + nchan_transport ); } - - ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot( &hParamMC->Cldfb_RealBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], - &hParamMC->Cldfb_ImagBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], - is_next_band ? cx_next_band : cx, - is_next_band ? cx_imag_next_band : cx_imag, - param_band_idx + is_next_band, - hParamMC, - nchan_transport ); } } - } - /* map from complex input covariance to real values */ - for ( is_next_band = 0; is_next_band < 2; is_next_band++ ) - { - if ( is_next_band && skip_next_band ) + Word16 tmp_cx_e, tmp_cx_imag_e; + /* map from complex input covariance to real values */ + FOR( is_next_band = 0; is_next_band < 2; is_next_band++ ) { - continue; + test(); + IF( is_next_band && skip_next_band ) + { + CONTINUE; + } + /* Cx for transport channels */ + IF( is_next_band ) + { + pCx = &cx_next_band_fx[0]; + pCx_imag = &cx_imag_next_band_fx[0]; + tmp_cx_e = cx_next_band_e; + tmp_cx_imag_e = cx_imag_next_band_e; + } + ELSE + { + pCx = &cx_fx[0]; + pCx_imag = &cx_imag_fx[0]; + tmp_cx_e = cx_e; + tmp_cx_imag_e = cx_imag_e; + } + + FOR( i = 0; i < nchan_transport * nchan_transport; i++ ) + { + real_part_fx = pCx[i]; // Q(31 - cx_buff_e) + imag_part_fx = pCx_imag[i]; + move32(); + move32(); + cx_buff_e[is_next_band][i] = tmp_cx_e; + move16(); + /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ + IF( LT_16( param_band_idx, hParamMC->max_param_band_abs_cov ) ) + { + L_tmp1 = Mpy_32_32( real_part_fx, real_part_fx ); + L_tmp2 = Mpy_32_32( imag_part_fx, imag_part_fx ); + L_tmp1 = BASOP_Util_Add_Mant32Exp( L_tmp1, add( tmp_cx_e, tmp_cx_e ), L_tmp2, add( tmp_cx_imag_e, tmp_cx_imag_e ), &tmp_e ); + pCx[i] = Sqrt32( L_tmp1, &tmp_e ); + move32(); + cx_buff_e[is_next_band][i] = tmp_e; + move16(); + } + ELSE + { + pCx[i] = real_part_fx; + move32(); + cx_buff_e[is_next_band][i] = tmp_cx_e; + move16(); + } + } } - /* Cx for transport channels */ - pCx = is_next_band ? &cx_next_band[0] : &cx[0]; - pCx_imag = is_next_band ? &cx_imag_next_band[0] : &cx_imag[0]; + max_e = cx_buff_e[0][0]; + move16(); - for ( i = 0; i < nchan_transport * nchan_transport; i++ ) + /* Cx for transport channels */ + FOR( is_next_band = 0; is_next_band < 2; is_next_band++ ) { - real_part = pCx[i]; - imag_part = pCx_imag[i]; - - /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ - if ( param_band_idx < hParamMC->max_param_band_abs_cov ) + FOR( i = 0; i < imult1616( nchan_transport, nchan_transport ); i++ ) { - pCx[i] = sqrtf( real_part * real_part + imag_part * imag_part ); + + IF( LT_16( max_e, cx_buff_e[is_next_band][i] ) ) + { + max_e = cx_buff_e[is_next_band][i]; + } } - else + } + /* Cx for transport channels */ + FOR( is_next_band = 0; is_next_band < 2; is_next_band++ ) + { + FOR( i = 0; i < imult1616( nchan_transport, nchan_transport ); i++ ) { - pCx[i] = real_part; + if ( is_next_band == 0 ) + { + cx_fx[i] = L_shr( cx_fx[i], sub( max_e, cx_buff_e[is_next_band][i] ) ); + } + else + { + cx_next_band_fx[i] = L_shr( cx_next_band_fx[i], sub( max_e, cx_buff_e[is_next_band][i] ) ); + } + move32(); } } - } + cx_e = max_e; + move16(); - /* we have to do it similar to the encoder in case of attacks (i.e. accumulate two bands) to ensure correct DMX of the target covariance*/ - if ( hParamMC->hMetadataPMC->bAttackPresent && ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) ) - { - v_add( cx, cx_next_band, cx, nchan_transport * nchan_transport ); - mvr2r( cx, cx_next_band, nchan_transport * nchan_transport ); - } - for ( is_next_band = 0; is_next_band < 2; is_next_band++ ) - { - if ( is_next_band && skip_next_band ) + /* we have to do it similar to the encoder in case of attacks (i.e. accumulate two bands) to ensure correct DMX of the target covariance*/ + + test(); + test(); + IF( hParamMC->hMetadataPMC->bAttackPresent && ( EQ_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_LS_CONV_COV ) || EQ_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) ) { - continue; + Word16 len = imult1616( nchan_transport, nchan_transport ); + Word16 sc = s_min( getScaleFactor32( cx_fx, len ), getScaleFactor32( cx_next_band_fx, len ) ); + IF( EQ_16( sc, 0 ) ) + { + Scale_sig32( cx_fx, len, -Q1 ); // add one bit head room + Scale_sig32( cx_next_band_fx, len, -Q1 ); // add one bit head room + cx_e = add( cx_e, Q1 ); + cx_next_band_e = add( cx_e, Q1 ); + } + v_add_fx( cx_fx, cx_next_band_fx, cx_fx, len ); + Copy32( cx_fx, cx_next_band_fx, len ); } - /* generate mixing matrices */ - ivas_param_mc_get_mixing_matrices( hParamMC, - hSynthesisOutputSetup, - is_next_band ? cx_next_band : cx, - param_band_idx + is_next_band, - hParamMC->h_output_synthesis_cov_state.mixing_matrix, - hParamMC->h_output_synthesis_cov_state.mixing_matrix_res, - nchan_out_transport, - hParamMC->synthesis_conf, - nchan_transport, - nchan_out_cov ); + FOR( is_next_band = 0; is_next_band < 2; is_next_band++ ) + { + test(); + IF( is_next_band && skip_next_band ) + { + CONTINUE; + } + + IF( NE_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) + { + IF( is_next_band ) + { + + ivas_param_mc_get_mixing_matrices_fx( hParamMC, hSynthesisOutputSetup, cx_next_band_fx, cx_e, add( param_band_idx, is_next_band ), hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp, nchan_out_transport, hParamMC->synthesis_conf, nchan_transport, nchan_out_cov ); + } + ELSE + { + + ivas_param_mc_get_mixing_matrices_fx( hParamMC, hSynthesisOutputSetup, cx_fx, cx_e, add( param_band_idx, is_next_band ), hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp, nchan_out_transport, hParamMC->synthesis_conf, nchan_transport, nchan_out_cov ); + } + } + } } } diff --git a/lib_dec/ivas_objectRenderer_internal_fx.c b/lib_dec/ivas_objectRenderer_internal_fx.c index db2d83853..d058a3af0 100644 --- a/lib_dec/ivas_objectRenderer_internal_fx.c +++ b/lib_dec/ivas_objectRenderer_internal_fx.c @@ -217,13 +217,13 @@ ivas_error ivas_td_binaural_renderer_sf_fx( ISM_METADATA_HANDLE hIsmMetaData[MAX_NUM_OBJECTS]; for ( nS = 0; nS < nchan_ism; nS++ ) { - ismMetaData[nS].azimuth = st_ivas->hIsmMetaData[nS]->edited_azimuth; - ismMetaData[nS].elevation = st_ivas->hIsmMetaData[nS]->edited_elevation; - ismMetaData[nS].radius = st_ivas->hIsmMetaData[nS]->edited_radius; - ismMetaData[nS].yaw = st_ivas->hIsmMetaData[nS]->edited_yaw; - ismMetaData[nS].pitch = st_ivas->hIsmMetaData[nS]->edited_pitch; + ismMetaData[nS].azimuth_fx = st_ivas->hIsmMetaData[nS]->edited_azimuth_fx; + ismMetaData[nS].elevation_fx = st_ivas->hIsmMetaData[nS]->edited_elevation_fx; + ismMetaData[nS].radius_fx = st_ivas->hIsmMetaData[nS]->edited_radius_fx; + ismMetaData[nS].yaw_fx = st_ivas->hIsmMetaData[nS]->edited_yaw_fx; + ismMetaData[nS].pitch_fx = st_ivas->hIsmMetaData[nS]->edited_pitch_fx; ismMetaData[nS].non_diegetic_flag = st_ivas->hIsmMetaData[nS]->non_diegetic_flag; - ismMetaData[nS].gain = st_ivas->hIsmMetaData[nS]->edited_gain; + ismMetaData[nS].gain_fx = st_ivas->hIsmMetaData[nS]->edited_gain_fx; hIsmMetaData[nS] = &ismMetaData[nS]; } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index fc4fc4365..1d628578f 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 - float gain_bed; + Word32 gain_bed_fx; #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 e492820fd..74f07912e 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -651,9 +651,8 @@ ivas_error IVAS_DEC_Configure( /* init flush buffer if necessary (only needed for binaural)*/ if ( tsmEnabled && ( outputConfig == IVAS_AUDIO_CONFIG_BINAURAL || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { - hIvasDec->flushbuffer = (void *) malloc( CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( int16_t ) ); - hIvasDec->pcmType = IVAS_DEC_PCM_INT16; - set_s( (int16_t *) hIvasDec->flushbuffer, 0, CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); + hIvasDec->flushbuffer = (void *) malloc( CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( Word16 ) ); + set16_fx( (Word16 *) hIvasDec->flushbuffer, 0, CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); } #endif @@ -1342,27 +1341,13 @@ ivas_error IVAS_DEC_GetSamples( /* check for possible flushed samples from a rate switch */ if ( hIvasDec->nSamplesFlushed > 0 ) { - void *pPcmBuffer; -#ifdef DEBUGGING - assert( hIvasDec->pcmType == pcmType ); -#endif - pPcmBuffer = pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ); - if ( pcmType == IVAS_DEC_PCM_INT16 ) - { - mvs2s( (int16_t *) hIvasDec->flushbuffer, pPcmBuffer, hIvasDec->nSamplesFlushed * nOutChannels ); - } - else if ( pcmType == IVAS_DEC_PCM_FLOAT ) - { - mvr2r( (float *) hIvasDec->flushbuffer, pPcmBuffer, hIvasDec->nSamplesFlushed * nOutChannels ); - } -#ifdef DEBUGGING - else - { - assert( 0 && "wrong PCM type for the flush buffer!" ); - } -#endif - nSamplesRendered += hIvasDec->nSamplesFlushed; + /* note: offset (rendered samples) is always 0 */ + Copy( hIvasDec->flushbuffer, pcmBuf, hIvasDec->nSamplesFlushed * nOutChannels ); + + hIvasDec->nSamplesRendered = hIvasDec->nSamplesFlushed; hIvasDec->nSamplesFlushed = 0; + move16(); + move16(); } #endif @@ -1481,8 +1466,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( if ( hIvasDec->flushbuffer == NULL ) { hIvasDec->flushbuffer = (void *) malloc( numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( float ) ); - hIvasDec->pcmType = IVAS_DEC_PCM_FLOAT; - set_zero( (float *) hIvasDec->flushbuffer, numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); + set16_fx( (Word16 *) hIvasDec->flushbuffer, 0, numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); } #endif @@ -2300,37 +2284,37 @@ ivas_error IVAS_DEC_GetObjectMetadata( #ifdef OBJ_EDITING_API if ( st_ivas->ism_mode == ISM_MODE_DISC ) { - metadata->azimuth = hIsmMeta->edited_azimuth; - metadata->elevation = hIsmMeta->edited_elevation; - metadata->radius = hIsmMeta->edited_radius; + metadata->azimuth_fx = hIsmMeta->edited_azimuth_fx; + metadata->elevation_fx = hIsmMeta->edited_elevation_fx; + metadata->radius_fx = hIsmMeta->edited_radius_fx; - metadata->yaw = hIsmMeta->edited_yaw; - metadata->pitch = hIsmMeta->edited_pitch; - metadata->spread = 0.f; + metadata->yaw_fx = hIsmMeta->edited_yaw_fx; + metadata->pitch_fx = hIsmMeta->edited_pitch_fx; + metadata->spread = 0; - metadata->gainFactor = hIsmMeta->edited_gain; + metadata->gainFactor_fx = hIsmMeta->edited_gain_fx; metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; } else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { - metadata->azimuth = st_ivas->hParamIsmDec->edited_azimuth_values[objectIdx]; - metadata->elevation = st_ivas->hParamIsmDec->edited_elevation_values[objectIdx]; - metadata->radius = hIsmMeta->radius; - metadata->yaw = hIsmMeta->yaw; - metadata->pitch = hIsmMeta->pitch; - metadata->spread = 0.f; - metadata->gainFactor = 1.f; + metadata->azimuth_fx = st_ivas->hParamIsmDec->edited_azimuth_values_fx[objectIdx]; + metadata->elevation_fx = st_ivas->hParamIsmDec->edited_elevation_values_fx[objectIdx]; + metadata->radius_fx = hIsmMeta->radius_fx; + metadata->yaw_fx = hIsmMeta->yaw_fx; + metadata->pitch_fx = hIsmMeta->pitch_fx; + metadata->spread_fx = 0; + metadata->gainFactor_fx = ONE_IN_Q31; metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; } else if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC || st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { - metadata->azimuth = st_ivas->hIsmMetaData[objectIdx]->edited_azimuth; - metadata->elevation = st_ivas->hIsmMetaData[objectIdx]->edited_elevation; - metadata->radius = st_ivas->hIsmMetaData[objectIdx]->edited_radius; - metadata->yaw = st_ivas->hIsmMetaData[objectIdx]->edited_yaw; - metadata->pitch = st_ivas->hIsmMetaData[objectIdx]->edited_pitch; - metadata->spread = 0.f; - metadata->gainFactor = st_ivas->hIsmMetaData[objectIdx]->edited_gain; + metadata->azimuth_fx = st_ivas->hIsmMetaData[objectIdx]->edited_azimuth_fx; + metadata->elevation_fx = st_ivas->hIsmMetaData[objectIdx]->edited_elevation_fx; + metadata->radius_fx = st_ivas->hIsmMetaData[objectIdx]->edited_radius_fx; + metadata->yaw_fx = st_ivas->hIsmMetaData[objectIdx]->edited_yaw_fx; + metadata->pitch_fx = st_ivas->hIsmMetaData[objectIdx]->edited_pitch_fx; + metadata->spread_fx = 0.f; + metadata->gainFactor_fx = st_ivas->hIsmMetaData[objectIdx]->edited_gain_fx; metadata->non_diegetic_flag = st_ivas->hIsmMetaData[objectIdx]->non_diegetic_flag; } ELSE @@ -3763,6 +3747,7 @@ ivas_error IVAS_DEC_ReadFormat( #endif #ifdef FIX_HRTF_LOAD_API + /*---------------------------------------------------------------------* * IVAS_DEC_GetSamplesDecoder( ) * @@ -3775,6 +3760,7 @@ ivas_error IVAS_DEC_GetSamplesDecoder( ISAR_SPLIT_REND_BITS_DATA *splitRendBits /* o : output split rendering bits */ ) { + ivas_error error; if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) @@ -3790,17 +3776,18 @@ ivas_error IVAS_DEC_GetSamplesDecoder( if ( ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm && hIvasDec->hasBeenFedFirstGoodFrame ) || !hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) #endif { - uint16_t l_ts, nTimeScalerOutSamples; + + UWord16 l_ts, nTimeScalerOutSamples; #ifdef FIX_HRTF_LOAD - uint8_t nTransportChannels; + UWord8 nTransportChannels; #else - uint8_t nTransportChannels, nOutChannels; + UWord8 nTransportChannels, nOutChannels; #endif - int16_t nResidualSamples, nSamplesTcsScaled, nOutSamplesElse; + Word16 nResidualSamples, nSamplesTcsScaled, nOutSamplesElse; if ( isSplitRend ) { - if ( ( error = isar_set_split_rend_setup( hIvasDec->st_ivas->hSplitBinRend, &hIvasDec->st_ivas->hRenderConfig->split_rend_config, hIvasDec->st_ivas->hCombinedOrientationData, splitRendBits ) ) != IVAS_ERR_OK ) + IF ( ( error = isar_set_split_rend_setup( hIvasDec->st_ivas->hSplitBinRend, &hIvasDec->st_ivas->hRenderConfig->split_rend_config, hIvasDec->st_ivas->hCombinedOrientationData, splitRendBits ) ) != IVAS_ERR_OK ) { return error; } @@ -3824,7 +3811,7 @@ ivas_error IVAS_DEC_GetSamplesDecoder( } /* IVAS TC decoder */ - if ( ( error = IVAS_DEC_GetTcSamples( hIvasDec, hIvasDec->apaExecBuffer, &nOutSamplesElse ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_GetTcSamples( hIvasDec, hIvasDec->apaExecBuffer_fx, &nOutSamplesElse ) ) != IVAS_ERR_OK ) { return error; } @@ -3832,12 +3819,12 @@ ivas_error IVAS_DEC_GetSamplesDecoder( /* JBM */ if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) { - if ( apa_set_scale( hIvasDec->hTimeScaler, hIvasDec->tsm_scale ) != 0 ) + if ( apa_set_scale_fx( hIvasDec->hTimeScaler, hIvasDec->tsm_scale ) != 0 ) { return IVAS_ERR_UNKNOWN; } - if ( apa_exec( hIvasDec->hTimeScaler, hIvasDec->apaExecBuffer, hIvasDec->nSamplesFrame * nTransportChannels, (uint16_t) hIvasDec->tsm_max_scaling, hIvasDec->apaExecBuffer, &nTimeScalerOutSamples ) != 0 ) + if ( apa_exec_fx( hIvasDec->hTimeScaler, hIvasDec->apaExecBuffer_fx, hIvasDec->nSamplesFrame * nTransportChannels, (UWord16) hIvasDec->tsm_max_scaling, hIvasDec->apaExecBuffer_fx, &nTimeScalerOutSamples ) != 0 ) { return IVAS_ERR_UNKNOWN; } @@ -3852,7 +3839,7 @@ ivas_error IVAS_DEC_GetSamplesDecoder( } /* Feed decoded transport channels samples to the renderer */ - if ( ( error = IVAS_DEC_RendererFeedTcSamples( hIvasDec, nSamplesTcsScaled, &nResidualSamples, hIvasDec->apaExecBuffer ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_RendererFeedTcSamples( hIvasDec, nSamplesTcsScaled, &nResidualSamples, hIvasDec->apaExecBuffer_fx ) ) != IVAS_ERR_OK ) { return error; } @@ -3869,42 +3856,42 @@ ivas_error IVAS_DEC_GetSamplesDecoder( } hIvasDec->hasBeenPreparedRendering = false; - if ( hIvasDec->st_ivas->hIsmMetaData[0] ) + IF ( hIvasDec->st_ivas->hIsmMetaData[0] ) { - if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) + IF ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == MASA_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_MASA_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_MASA_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { - int16_t obj; + Word16 obj; ISM_METADATA_HANDLE *hIsmMetaData = hIvasDec->st_ivas->hIsmMetaData; - for ( obj = 0; obj < hIvasDec->st_ivas->nchan_ism; obj++ ) + FOR ( obj = 0; obj < hIvasDec->st_ivas->nchan_ism; obj++ ) { - hIsmMetaData[obj]->edited_azimuth = hIsmMetaData[obj]->azimuth; - hIsmMetaData[obj]->edited_elevation = hIsmMetaData[obj]->elevation; - hIsmMetaData[obj]->edited_yaw = hIsmMetaData[obj]->yaw; - hIsmMetaData[obj]->edited_pitch = hIsmMetaData[obj]->pitch; - hIsmMetaData[obj]->edited_radius = hIsmMetaData[obj]->radius; - hIsmMetaData[obj]->edited_gain = 1.0f; + hIsmMetaData[obj]->edited_azimuth_fx = hIsmMetaData[obj]->azimuth_fx; + hIsmMetaData[obj]->edited_elevation_fx = hIsmMetaData[obj]->elevation_fx; + 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 = 1.0f; } - 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 = 1.0f; + hIvasDec->st_ivas->hSbaIsmData->gain_bed_fx = ONE_IN_Q30; } } } } - if ( hIvasDec->st_ivas->hParamIsmDec != NULL ) + IF ( hIvasDec->st_ivas->hParamIsmDec != NULL ) { - if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) + IF ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) { - int16_t obj = 0; + Word16 obj = 0; PARAM_ISM_DEC_HANDLE hParamIsmDec = hIvasDec->st_ivas->hParamIsmDec; for ( obj = 0; obj < hIvasDec->st_ivas->nchan_ism; obj++ ) { - hParamIsmDec->edited_azimuth_values[obj] = hParamIsmDec->azimuth_values[obj]; - hParamIsmDec->edited_elevation_values[obj] = hParamIsmDec->elevation_values[obj]; + hParamIsmDec->edited_azimuth_values_fx[obj] = hParamIsmDec->azimuth_values_fx[obj]; + hParamIsmDec->edited_elevation_values_fx[obj] = hParamIsmDec->elevation_values_fx[obj]; } } } @@ -3938,7 +3925,7 @@ ivas_error IVAS_DEC_GetEditableParameters( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - hIvasEditableParameters->gain_bed = 1.0f; + hIvasEditableParameters->gain_bed_fx = ONE_IN_Q30; hIvasEditableParameters->num_obj = hIvasDec->st_ivas->nchan_ism; if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) { @@ -3947,17 +3934,17 @@ ivas_error IVAS_DEC_GetEditableParameters( int16_t obj; for ( obj = 0; obj < hIvasEditableParameters->num_obj; obj++ ) { - hIvasEditableParameters->ism_metadata[obj].azimuth = hIvasDec->st_ivas->hIsmMetaData[obj]->azimuth; - hIvasEditableParameters->ism_metadata[obj].elevation = hIvasDec->st_ivas->hIsmMetaData[obj]->elevation; - hIvasEditableParameters->ism_metadata[obj].yaw = hIvasDec->st_ivas->hIsmMetaData[obj]->yaw; - hIvasEditableParameters->ism_metadata[obj].pitch = hIvasDec->st_ivas->hIsmMetaData[obj]->pitch; - hIvasEditableParameters->ism_metadata[obj].radius = hIvasDec->st_ivas->hIsmMetaData[obj]->radius; - hIvasEditableParameters->ism_metadata[obj].gain = hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain; + 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; + 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; } if ( hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { - hIvasEditableParameters->gain_bed = 1.0f; + hIvasEditableParameters->gain_bed_fx = ONE_IN_Q30; } } else if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) @@ -3965,12 +3952,12 @@ ivas_error IVAS_DEC_GetEditableParameters( int16_t obj; for ( obj = 0; obj < hIvasEditableParameters->num_obj; obj++ ) { - hIvasEditableParameters->ism_metadata[obj].azimuth = hIvasDec->st_ivas->hParamIsmDec->azimuth_values[obj]; - hIvasEditableParameters->ism_metadata[obj].elevation = hIvasDec->st_ivas->hParamIsmDec->elevation_values[obj]; + hIvasEditableParameters->ism_metadata[obj].azimuth_fx = hIvasDec->st_ivas->hParamIsmDec->azimuth_values_fx[obj]; + hIvasEditableParameters->ism_metadata[obj].elevation_fx = hIvasDec->st_ivas->hParamIsmDec->elevation_values_fx[obj]; hIvasEditableParameters->ism_metadata[obj].yaw = 0.0f; - hIvasEditableParameters->ism_metadata[obj].pitch = 0.0f; - hIvasEditableParameters->ism_metadata[obj].radius = 0.0f; - hIvasEditableParameters->ism_metadata[obj].gain = 1.0f; + hIvasEditableParameters->ism_metadata[obj].pitch_fx = 0.0f; + hIvasEditableParameters->ism_metadata[obj].radius_fx = 0.0f; + hIvasEditableParameters->ism_metadata[obj].gain_fx = 1.0f; hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = 0; } } @@ -4024,21 +4011,21 @@ ivas_error IVAS_DEC_SetEditableParameters( int16_t obj; for ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) { - hIvasDec->st_ivas->hIsmMetaData[obj]->edited_azimuth = hIvasEditableParameters.ism_metadata[obj].azimuth; - hIvasDec->st_ivas->hIsmMetaData[obj]->edited_elevation = hIvasEditableParameters.ism_metadata[obj].elevation; - hIvasDec->st_ivas->hIsmMetaData[obj]->edited_radius = hIvasEditableParameters.ism_metadata[obj].radius; + 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; + hIvasDec->st_ivas->hIsmMetaData[obj]->edited_radius_fx = hIvasEditableParameters.ism_metadata[obj].radius_fx; - hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain = 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_yaw = hIvasEditableParameters.ism_metadata[obj].yaw; - hIvasDec->st_ivas->hIsmMetaData[obj]->edited_pitch = hIvasEditableParameters.ism_metadata[obj].pitch; + hIvasDec->st_ivas->hIsmMetaData[obj]->edited_yaw_fx = hIvasEditableParameters.ism_metadata[obj].yaw_fx; + hIvasDec->st_ivas->hIsmMetaData[obj]->edited_pitch_fx = hIvasEditableParameters.ism_metadata[obj].pitch_fx; 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 ) { - hIvasDec->st_ivas->hSbaIsmData->gain_bed = hIvasEditableParameters.gain_bed; + hIvasDec->st_ivas->hSbaIsmData->gain_bed_fx = hIvasEditableParameters.gain_bed_fx; } } else if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) @@ -4108,7 +4095,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( #endif #ifdef OBJ_EDITING_API , - bool *parametersAvailableForEditing, + bool *parametersAvailableForEditing #endif ) { -- GitLab From fe4263811d340cdee9b01e3a3ccfcb10b4a2a014 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 9 Oct 2025 13:55:25 +0200 Subject: [PATCH 05/46] insert more proper BASOP code --- lib_com/ivas_prot_fx.h | 4 ++-- lib_dec/ivas_ism_param_dec_fx.c | 9 +++++++-- lib_dec/lib_dec_fx.c | 32 ++++++++++++++++++++++++++------ 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index f78513fd6..c76513697 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -4338,9 +4338,9 @@ void ivas_param_ism_dec_dequant_md_fx( Decoder_Struct *st_ivas ); -void ivas_param_ism_dec_prepare_renderer( +void ivas_param_ism_dec_prepare_renderer_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nCldfbSlots /* i : number of CLFBS slots in the transport channels */ + const Word16 nCldfbSlots /* i : number of CLFBS slots in the transport channels */ ); #endif diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 841b1a6d8..0ae5fdf33 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -1346,7 +1346,6 @@ void ivas_param_ism_dec_prepare_renderer_fx( { int16_t ch, nchan_transport, nchan_out, nchan_out_woLFE, i; int16_t slot_idx, bin_idx; - Word32 ref_powe_fx[CLDFB_NO_CHANNELS_MAX]; Word32 cx_diag_fx[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX]; Word16 exp_cx_diag[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX]; Word16 exp_real_tmp = 0, exp_imag_tmp = 0; @@ -1357,11 +1356,17 @@ void ivas_param_ism_dec_prepare_renderer_fx( SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; /* Initialization */ + hSpatParamRendCom = st_ivas->hSpatParamRendCom; + assert( hSpatParamRendCom ); + move32(); hParamIsmDec = st_ivas->hParamIsmDec; + assert( hParamIsmDec ); + move32(); nchan_transport = st_ivas->nchan_transport; move16(); ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; - move32(); + + /* Initialization */ hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_exp = 25; move16(); diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 74f07912e..e0bdee501 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -3819,19 +3819,39 @@ ivas_error IVAS_DEC_GetSamplesDecoder( /* JBM */ if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) { - if ( apa_set_scale_fx( hIvasDec->hTimeScaler, hIvasDec->tsm_scale ) != 0 ) + IF( apa_set_scale_fx( hIvasDec->hTimeScaler, hIvasDec->tsm_scale ) != 0 ) { return IVAS_ERR_UNKNOWN; } - if ( apa_exec_fx( hIvasDec->hTimeScaler, hIvasDec->apaExecBuffer_fx, hIvasDec->nSamplesFrame * nTransportChannels, (UWord16) hIvasDec->tsm_max_scaling, hIvasDec->apaExecBuffer_fx, &nTimeScalerOutSamples ) != 0 ) + // tmp apaExecBuffer + IF( EQ_16( (Word16) hIvasDec->mode, IVAS_DEC_MODE_EVS ) ) { - return IVAS_ERR_UNKNOWN; + Word16 tmp_apaExecBuffer[APA_BUF]; + FOR( Word32 i = 0; i < APA_BUF_PER_CHANNEL * nTransportChannels; ++i ) + { + tmp_apaExecBuffer[i] = extract_l( L_shr( hIvasDec->apaExecBuffer_fx[i], Q11 ) ); // Q0 + } + IF( apa_exec_fx( hIvasDec->hTimeScaler, tmp_apaExecBuffer, (UWord16) imult3216( hIvasDec->nSamplesFrame, nTransportChannels ), (UWord16) hIvasDec->tsm_max_scaling, tmp_apaExecBuffer, &nTimeScalerOutSamples ) != 0 ) + { + return IVAS_ERR_UNKNOWN; + } + FOR( Word32 i = 0; i < APA_BUF_PER_CHANNEL * nTransportChannels; ++i ) + { + hIvasDec->apaExecBuffer_fx[i] = L_shl( tmp_apaExecBuffer[i], Q11 ); // Q11 + } } - - assert( nTimeScalerOutSamples <= APA_BUF ); - nSamplesTcsScaled = nTimeScalerOutSamples / nTransportChannels; + ELSE + { + IF( apa_exec_ivas_fx( hIvasDec->hTimeScaler, hIvasDec->apaExecBuffer_fx, (UWord16) imult3216( hIvasDec->nSamplesFrame, nTransportChannels ), (UWord16) hIvasDec->tsm_max_scaling, hIvasDec->apaExecBuffer_fx, &nTimeScalerOutSamples ) != 0 ) + { + return IVAS_ERR_UNKNOWN; + } + } + assert( LE_32( (Word32) nTimeScalerOutSamples, APA_BUF ) ); + nSamplesTcsScaled = idiv1616U( extract_l( nTimeScalerOutSamples ), nTransportChannels ); hIvasDec->timeScalingDone = 1; + move16(); } else { -- GitLab From 96cbaa4ba36d535b0dc891e0451ecdc0cf954af8 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 9 Oct 2025 14:32:20 +0200 Subject: [PATCH 06/46] fix formatting --- apps/decoder.c | 1 - lib_com/ivas_stat_com.h | 14 +-- lib_dec/ivas_ism_param_dec_fx.c | 9 +- lib_dec/ivas_jbm_dec_fx.c | 14 +-- lib_dec/ivas_mc_param_dec_fx.c | 123 +++++++++++----------- lib_dec/ivas_objectRenderer_internal_fx.c | 8 +- lib_dec/lib_dec_fx.c | 27 +++-- 7 files changed, 95 insertions(+), 101 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 83c5dfbf2..36ed7a94a 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -2282,7 +2282,6 @@ static ivas_error decodeG192( goto cleanup; } #endif - } if ( isSplitRend ) diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 567c2ec64..2867cd906 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -66,15 +66,15 @@ typedef struct Word32 pitch_fx; /* pitch value read from the input metadata file */ /* Q22 */ #ifdef OBJ_EDITING_API - Word32 gain_fx; /* Q30 */ + Word32 gain_fx; /* Q30 */ - Word32 edited_azimuth_fx; /* Q22 */ - Word32 edited_elevation_fx; /* Q22 */ - Word32 edited_radius_fx; /* Q9 */ + Word32 edited_azimuth_fx; /* Q22 */ + Word32 edited_elevation_fx; /* Q22 */ + Word32 edited_radius_fx; /* Q9 */ - Word32 edited_yaw_fx; /* Q22 */ - Word32 edited_pitch_fx; /* Q22 */ - Word32 edited_gain_fx; /* Q30 */ + Word32 edited_yaw_fx; /* Q22 */ + Word32 edited_pitch_fx; /* Q22 */ + Word32 edited_gain_fx; /* Q30 */ #endif Word16 non_diegetic_flag; /* Non-diegetic (non-headtracked) object flag */ diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 0ae5fdf33..4d02fe136 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -1109,9 +1109,9 @@ void ivas_param_ism_dec_digest_tc_fx( output_frame = imult1616( nCldfbSlots, hSpatParamRendCom->num_freq_bands ); fade_len = shr( output_frame, 1 ); -#ifndef OBJ_EDITING_API nchan_transport = st_ivas->nchan_transport; move16(); +#ifndef OBJ_EDITING_API ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; move32(); @@ -1257,7 +1257,7 @@ void ivas_param_ism_dec_digest_tc_fx( hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_exp = sub( 31, q_tc ); move16(); } - + #ifndef OBJ_EDITING_API Word16 scale_factor_real, scale_factor_imag; Word16 current_idx; @@ -1340,7 +1340,7 @@ void ivas_param_ism_dec_dequant_md_fx( *-------------------------------------------------------------------------*/ void ivas_param_ism_dec_prepare_renderer_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const Word16 nCldfbSlots /* i : number of CLFBS slots in the transport channels */ ) { @@ -1981,12 +1981,11 @@ void ivas_param_ism_params_to_masa_param_mapping_fx( #endif - hParamIsmDec = st_ivas->hParamIsmDec; hSpatParamRendCom = st_ivas->hSpatParamRendCom; -#ifndef OBJ_EDITING_API nBins = hSpatParamRendCom->num_freq_bands; move16(); +#ifndef OBJ_EDITING_API ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; move32(); diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 71db4c1e6..32e1610ae 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -1605,8 +1605,8 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( { ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); } - ELSE -#endif + ELSE +#endif IF( EQ_16( st_ivas->ivas_format, ISM_FORMAT ) ) { /* Rendering */ @@ -1622,8 +1622,8 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( ivas_param_ism_params_to_masa_param_mapping_fx( st_ivas ); } - ELSE -#endif + ELSE +#endif IF( EQ_16( st_ivas->renderer_type, RENDERER_PARAM_ISM ) || EQ_16( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) { @@ -2230,7 +2230,7 @@ ivas_error ivas_jbm_dec_render_fx( { for ( i = 0; i < *nSamplesRendered; i++ ) { - assert ( 0 && "This is yet to be implemented"); + assert( 0 && "This is yet to be implemented" ); } } } @@ -2238,7 +2238,7 @@ ivas_error ivas_jbm_dec_render_fx( { for ( n = 0; n < nchan_out; n++ ) { - assert ( 0 && "This is yet to be implemented"); + assert( 0 && "This is yet to be implemented" ); } } } @@ -4640,4 +4640,4 @@ void ivas_jbm_dec_prepare_renderer( pop_wmops(); return; } -#endif \ No newline at end of file +#endif diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index faa2a4ee9..7c30bdffa 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -1557,7 +1557,6 @@ void ivas_param_mc_dec_digest_tc_fx( move16(); - push_wmops( "param_mc_dec_digest_tc" ); #ifndef OBJ_EDITING_API @@ -1646,80 +1645,78 @@ void ivas_param_mc_dec_digest_tc_fx( #endif /* slot loop for gathering the input data */ - FOR( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) - { - IF( st_ivas->hDecoderConfig->Opt_tsm ) - { + FOR( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ){ + IF( st_ivas->hDecoderConfig->Opt_tsm ){ #ifndef OBJ_EDITING_API IF( param_band_idx == 0 ) /* only run cldfbAna once */ { #endif Word32 RealBuffer_fx[CLDFB_NO_CHANNELS_MAX]; - Word32 ImagBuffer_fx[CLDFB_NO_CHANNELS_MAX]; + Word32 ImagBuffer_fx[CLDFB_NO_CHANNELS_MAX]; - /* CLDFB Analysis*/ - FOR( ch = 0; ch < nchan_transport; ch++ ) - { - qout = transport_f_e; - move16(); - cldfbAnalysis_ts_fx_fixed_q( &( transport_channels_f_fx[ch][hParamMC->num_freq_bands * slot_idx] ), RealBuffer_fx, ImagBuffer_fx, hParamMC->num_freq_bands, st_ivas->cldfbAnaDec[ch], &qout ); + /* CLDFB Analysis*/ + FOR( ch = 0; ch < nchan_transport; ch++ ) + { + qout = transport_f_e; + move16(); + cldfbAnalysis_ts_fx_fixed_q( &( transport_channels_f_fx[ch][hParamMC->num_freq_bands * slot_idx] ), RealBuffer_fx, ImagBuffer_fx, hParamMC->num_freq_bands, st_ivas->cldfbAnaDec[ch], &qout ); - Copy32( RealBuffer_fx, &hParamMC->Cldfb_RealBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport + ch * hParamMC->num_freq_bands], hParamMC->num_freq_bands ); - Copy32( ImagBuffer_fx, &hParamMC->Cldfb_ImagBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport + ch * hParamMC->num_freq_bands], hParamMC->num_freq_bands ); - } + Copy32( RealBuffer_fx, &hParamMC->Cldfb_RealBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport + ch * hParamMC->num_freq_bands], hParamMC->num_freq_bands ); + Copy32( ImagBuffer_fx, &hParamMC->Cldfb_ImagBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport + ch * hParamMC->num_freq_bands], hParamMC->num_freq_bands ); + } - hParamMC->Cldfb_ImagBuffer_tc_e = qout; - move16(); + hParamMC->Cldfb_ImagBuffer_tc_e = qout; + move16(); #ifndef OBJ_EDITING_API - } + } #endif - } +} #ifndef OBJ_EDITING_API - IF( GE_16( slot_idx, shl( hParamMC->hMetadataPMC->attackIndex, 1 ) ) ) - { - FOR( is_next_band = 0; is_next_band < 2; is_next_band++ ) - { - test(); - IF( is_next_band && skip_next_band ) - { - CONTINUE; - } - IF( is_next_band ) - { - ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot_fx( &hParamMC->Cldfb_RealBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport], - /*hParamMC->Cldfb_RealBuffer_tc_e*/ Q31 - Q6, - &hParamMC->Cldfb_ImagBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport], - /*hParamMC->Cldfb_ImagBuffer_tc_e*/ Q31 - Q6, - cx_next_band_fx, - &cx_next_band_e, - cx_imag_next_band_fx, - &cx_imag_next_band_e, - hParamMC, - add( param_band_idx, is_next_band ), - nchan_transport ); - } - ELSE - { - ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot_fx( &hParamMC->Cldfb_RealBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport], - /*hParamMC->Cldfb_RealBuffer_tc_e*/ Q31 - Q6, - &hParamMC->Cldfb_ImagBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport], - /*hParamMC->Cldfb_ImagBuffer_tc_e*/ Q31 - Q6, - cx_fx, - &cx_e, - cx_imag_fx, - &cx_imag_e, - hParamMC, - add( param_band_idx, is_next_band ), - nchan_transport ); - } - } - } -#endif +IF( GE_16( slot_idx, shl( hParamMC->hMetadataPMC->attackIndex, 1 ) ) ) +{ + FOR( is_next_band = 0; is_next_band < 2; is_next_band++ ) + { + test(); + IF( is_next_band && skip_next_band ) + { + CONTINUE; + } + IF( is_next_band ) + { + ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot_fx( &hParamMC->Cldfb_RealBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport], + /*hParamMC->Cldfb_RealBuffer_tc_e*/ Q31 - Q6, + &hParamMC->Cldfb_ImagBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport], + /*hParamMC->Cldfb_ImagBuffer_tc_e*/ Q31 - Q6, + cx_next_band_fx, + &cx_next_band_e, + cx_imag_next_band_fx, + &cx_imag_next_band_e, + hParamMC, + add( param_band_idx, is_next_band ), + nchan_transport ); + } + ELSE + { + ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot_fx( &hParamMC->Cldfb_RealBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport], + /*hParamMC->Cldfb_RealBuffer_tc_e*/ Q31 - Q6, + &hParamMC->Cldfb_ImagBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport], + /*hParamMC->Cldfb_ImagBuffer_tc_e*/ Q31 - Q6, + cx_fx, + &cx_e, + cx_imag_fx, + &cx_imag_e, + hParamMC, + add( param_band_idx, is_next_band ), + nchan_transport ); } + } +} +#endif +} - pop_wmops(); +pop_wmops(); - return; +return; } #ifdef OBJ_EDITING_API @@ -1752,7 +1749,7 @@ void ivas_param_mc_dec_prepare_renderer( Word16 cx_e; Word16 cx_imag_e, tmp_e; Word16 cx_imag_next_band_e, cx_next_band_e; - + Word16 max_e; /* format converter */ @@ -1843,7 +1840,7 @@ void ivas_param_mc_dec_prepare_renderer( move16(); cx_imag_next_band_e = 0; move16(); - + FOR( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) { /* slot loop for gathering the input data */ diff --git a/lib_dec/ivas_objectRenderer_internal_fx.c b/lib_dec/ivas_objectRenderer_internal_fx.c index d058a3af0..fec2462fd 100644 --- a/lib_dec/ivas_objectRenderer_internal_fx.c +++ b/lib_dec/ivas_objectRenderer_internal_fx.c @@ -234,10 +234,10 @@ ivas_error ivas_td_binaural_renderer_sf_fx( } else #endif - IF( ( error = TDREND_Update_object_positions_fx( st_ivas->hBinRendererTd, nchan_ism, st_ivas->ivas_format, st_ivas->hIsmMetaData ) ) != IVAS_ERR_OK ) - { - return error; - } + IF( ( error = TDREND_Update_object_positions_fx( st_ivas->hBinRendererTd, nchan_ism, st_ivas->ivas_format, st_ivas->hIsmMetaData ) ) != IVAS_ERR_OK ) + { + return error; + } } /* Update the listener's location/orientation */ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index e0bdee501..ead29e828 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -110,7 +110,6 @@ struct IVAS_DEC #endif bool hasBeenPreparedRendering; #endif - }; /*---------------------------------------------------------------------* @@ -207,7 +206,7 @@ ivas_error IVAS_DEC_Open( #ifdef OBJ_EDITING_API hIvasDec->flushbuffer = NULL; #else - // hIvasDec->flushbuffer = NULL; + // hIvasDec->flushbuffer = NULL; #endif hIvasDec->nSamplesFlushed = 0; #ifdef OBJ_EDITING_API @@ -1130,7 +1129,7 @@ ivas_error IVAS_DEC_GetSamples( ivas_error error; #ifdef OBJ_EDITING_API Word16 nSamplesToRender; - UWord16 nSamplesRendered, nSamplesRendered_loop; + UWord16 nSamplesRendered, nSamplesRendered_loop; UWord16 nOutChannels; #else Word16 nOutSamplesElse, nSamplesToRender; @@ -1233,7 +1232,7 @@ ivas_error IVAS_DEC_GetSamples( test(); IF( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) { - /* setup */ + /* setup */ #ifdef FIX_HRTF_LOAD IF( NE_32( ( error = IVAS_DEC_Setup( hIvasDec, &l_ts, &nTransportChannels ) ), IVAS_ERR_OK ) ) #else @@ -1343,7 +1342,7 @@ ivas_error IVAS_DEC_GetSamples( { /* note: offset (rendered samples) is always 0 */ Copy( hIvasDec->flushbuffer, pcmBuf, hIvasDec->nSamplesFlushed * nOutChannels ); - + hIvasDec->nSamplesRendered = hIvasDec->nSamplesFlushed; hIvasDec->nSamplesFlushed = 0; move16(); @@ -3787,7 +3786,7 @@ ivas_error IVAS_DEC_GetSamplesDecoder( if ( isSplitRend ) { - IF ( ( error = isar_set_split_rend_setup( hIvasDec->st_ivas->hSplitBinRend, &hIvasDec->st_ivas->hRenderConfig->split_rend_config, hIvasDec->st_ivas->hCombinedOrientationData, splitRendBits ) ) != IVAS_ERR_OK ) + IF( ( error = isar_set_split_rend_setup( hIvasDec->st_ivas->hSplitBinRend, &hIvasDec->st_ivas->hRenderConfig->split_rend_config, hIvasDec->st_ivas->hCombinedOrientationData, splitRendBits ) ) != IVAS_ERR_OK ) { return error; } @@ -3876,15 +3875,15 @@ ivas_error IVAS_DEC_GetSamplesDecoder( } hIvasDec->hasBeenPreparedRendering = false; - IF ( hIvasDec->st_ivas->hIsmMetaData[0] ) + IF( hIvasDec->st_ivas->hIsmMetaData[0] ) { - IF ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) + IF( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == MASA_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_MASA_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_MASA_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { Word16 obj; ISM_METADATA_HANDLE *hIsmMetaData = hIvasDec->st_ivas->hIsmMetaData; - FOR ( obj = 0; obj < hIvasDec->st_ivas->nchan_ism; obj++ ) + FOR( obj = 0; obj < hIvasDec->st_ivas->nchan_ism; obj++ ) { hIsmMetaData[obj]->edited_azimuth_fx = hIsmMetaData[obj]->azimuth_fx; hIsmMetaData[obj]->edited_elevation_fx = hIsmMetaData[obj]->elevation_fx; @@ -3894,7 +3893,7 @@ ivas_error IVAS_DEC_GetSamplesDecoder( hIsmMetaData[obj]->edited_gain_fx = 1.0f; } - 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 = ONE_IN_Q30; } @@ -3902,9 +3901,9 @@ ivas_error IVAS_DEC_GetSamplesDecoder( } } - IF ( hIvasDec->st_ivas->hParamIsmDec != NULL ) + IF( hIvasDec->st_ivas->hParamIsmDec != NULL ) { - IF ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) + IF( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) { Word16 obj = 0; PARAM_ISM_DEC_HANDLE hParamIsmDec = hIvasDec->st_ivas->hParamIsmDec; @@ -4400,7 +4399,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( return error; } -#ifndef FIX_HRTF_LOAD_API +#ifndef FIX_HRTF_LOAD_API #ifdef FIX_HRTF_LOAD *bitstreamReadDone = false; // temp hack until JBM API is reworked #endif -- GitLab From 2ac6c8f648bfde43f5564da152641d2a67700251 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 9 Oct 2025 15:18:33 +0200 Subject: [PATCH 07/46] translate more float code to basop --- lib_dec/ivas_objectRenderer_internal_fx.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib_dec/ivas_objectRenderer_internal_fx.c b/lib_dec/ivas_objectRenderer_internal_fx.c index fec2462fd..dd3bf8b1f 100644 --- a/lib_dec/ivas_objectRenderer_internal_fx.c +++ b/lib_dec/ivas_objectRenderer_internal_fx.c @@ -211,11 +211,12 @@ ivas_error ivas_td_binaural_renderer_sf_fx( IF( EQ_16( subframe_idx, ism_md_subframe_update_jbm ) ) { #ifdef OBJ_EDITING_API - if ( st_ivas->ivas_format == ISM_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) + test(); + IF ( EQ_16(st_ivas->ivas_format, ISM_FORMAT) || EQ_16(st_ivas->ivas_format, SBA_ISM_FORMAT ) ) { ISM_METADATA_FRAME ismMetaData[MAX_NUM_OBJECTS]; ISM_METADATA_HANDLE hIsmMetaData[MAX_NUM_OBJECTS]; - for ( nS = 0; nS < nchan_ism; nS++ ) + FOR ( nS = 0; nS < nchan_ism; nS++ ) { ismMetaData[nS].azimuth_fx = st_ivas->hIsmMetaData[nS]->edited_azimuth_fx; ismMetaData[nS].elevation_fx = st_ivas->hIsmMetaData[nS]->edited_elevation_fx; @@ -227,14 +228,14 @@ ivas_error ivas_td_binaural_renderer_sf_fx( hIsmMetaData[nS] = &ismMetaData[nS]; } - if ( ( error = TDREND_Update_object_positions_fx( st_ivas->hBinRendererTd, nchan_ism, st_ivas->ivas_format, hIsmMetaData ) ) != IVAS_ERR_OK ) + IF ( NE_16 ( ( error = TDREND_Update_object_positions_fx( st_ivas->hBinRendererTd, nchan_ism, st_ivas->ivas_format, hIsmMetaData ) ), IVAS_ERR_OK ) ) { return error; } } else #endif - IF( ( error = TDREND_Update_object_positions_fx( st_ivas->hBinRendererTd, nchan_ism, st_ivas->ivas_format, st_ivas->hIsmMetaData ) ) != IVAS_ERR_OK ) + IF( NE_16( error = TDREND_Update_object_positions_fx( st_ivas->hBinRendererTd, nchan_ism, st_ivas->ivas_format, st_ivas->hIsmMetaData ) ), IVAS_ERR_OK ) ) { return error; } -- GitLab From 0494639fff673e3ff932d707b64240fbb1dc7d97 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 9 Oct 2025 15:21:45 +0200 Subject: [PATCH 08/46] add missing move32() --- lib_rend/ivas_objectRenderer_fx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib_rend/ivas_objectRenderer_fx.c b/lib_rend/ivas_objectRenderer_fx.c index 42f6d94c7..0cba73286 100644 --- a/lib_rend/ivas_objectRenderer_fx.c +++ b/lib_rend/ivas_objectRenderer_fx.c @@ -588,6 +588,7 @@ static void TDREND_Clear_Update_flags_fx( move16(); #ifdef OBJ_EDITING_API hBinRendererTd->Sources[i]->SrcRend_p->SrcGainUpdated = FALSE; + move32(); #endif } -- GitLab From ebed8f905f52c0150283a5a4e73f717935da454c Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 9 Oct 2025 15:23:08 +0200 Subject: [PATCH 09/46] fix compile error --- lib_dec/ivas_objectRenderer_internal_fx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_objectRenderer_internal_fx.c b/lib_dec/ivas_objectRenderer_internal_fx.c index dd3bf8b1f..ca228dd05 100644 --- a/lib_dec/ivas_objectRenderer_internal_fx.c +++ b/lib_dec/ivas_objectRenderer_internal_fx.c @@ -235,10 +235,12 @@ ivas_error ivas_td_binaural_renderer_sf_fx( } 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 ) ) + { + IF( NE_16( error = TDREND_Update_object_positions_fx( st_ivas->hBinRendererTd, nchan_ism, st_ivas->ivas_format, st_ivas->hIsmMetaData ) , IVAS_ERR_OK ) ) { return error; } + } } /* Update the listener's location/orientation */ -- GitLab From a437ef7c13bd34c87e69663f408c4fe76fb55b45 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 9 Oct 2025 15:24:30 +0200 Subject: [PATCH 10/46] replace a move32() by a move16() --- 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 0cba73286..463c03158 100644 --- a/lib_rend/ivas_objectRenderer_fx.c +++ b/lib_rend/ivas_objectRenderer_fx.c @@ -588,7 +588,7 @@ static void TDREND_Clear_Update_flags_fx( move16(); #ifdef OBJ_EDITING_API hBinRendererTd->Sources[i]->SrcRend_p->SrcGainUpdated = FALSE; - move32(); + move16(); #endif } -- GitLab From 4e77e4afa7dcaff00e44a0ab0950b1bada59b389 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 9 Oct 2025 15:29:37 +0200 Subject: [PATCH 11/46] insert proper BASOPs in ivas_jbm_dec_render_fx --- lib_dec/ivas_jbm_dec_fx.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 32e1610ae..c7e64fca4 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2220,29 +2220,31 @@ ivas_error ivas_jbm_dec_render_fx( /* add already rendered SBA part */ #ifdef OBJ_EDITING_API - if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + test(); + IF ( EQ_16(st_ivas->ivas_format, SBA_ISM_FORMAT) && EQ_16(st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) { Word32 gain = st_ivas->hSbaIsmData->gain_bed_fx; - if ( gain != 1.0f && gain >= 0.0f ) + test(); + IF ( NE_32(gain, ONE_IN_Q30) && GT_32( gain, 0 ) ) { - int16_t i; - for ( n = 0; n < nchan_out; n++ ) + Word16 i; + FOR ( n = 0; n < nchan_out; n++ ) { - for ( i = 0; i < *nSamplesRendered; i++ ) + FOR ( i = 0; i < *nSamplesRendered; i++ ) { assert( 0 && "This is yet to be implemented" ); } } } - else + ELSE { - for ( n = 0; n < nchan_out; n++ ) + FOR ( n = 0; n < nchan_out; n++ ) { assert( 0 && "This is yet to be implemented" ); } } } - else + ELSE #endif { ivas_osba_stereo_add_channels_fx( p_tc_fx, p_output_fx, ONE_IN_Q11, nchan_out, st_ivas->nchan_ism, *nSamplesRendered ); -- GitLab From 8edc724ba46d1090c304281b23e9e97721b82d28 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 9 Oct 2025 15:47:50 +0200 Subject: [PATCH 12/46] fix formatting --- lib_dec/ivas_jbm_dec_fx.c | 10 +++++----- lib_dec/ivas_objectRenderer_internal_fx.c | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index c7e64fca4..6284c3002 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2221,16 +2221,16 @@ ivas_error ivas_jbm_dec_render_fx( /* add already rendered SBA part */ #ifdef OBJ_EDITING_API test(); - IF ( EQ_16(st_ivas->ivas_format, SBA_ISM_FORMAT) && EQ_16(st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) + IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) { Word32 gain = st_ivas->hSbaIsmData->gain_bed_fx; test(); - IF ( NE_32(gain, ONE_IN_Q30) && GT_32( gain, 0 ) ) + IF( NE_32( gain, ONE_IN_Q30 ) && GT_32( gain, 0 ) ) { Word16 i; - FOR ( n = 0; n < nchan_out; n++ ) + FOR( n = 0; n < nchan_out; n++ ) { - FOR ( i = 0; i < *nSamplesRendered; i++ ) + FOR( i = 0; i < *nSamplesRendered; i++ ) { assert( 0 && "This is yet to be implemented" ); } @@ -2238,7 +2238,7 @@ ivas_error ivas_jbm_dec_render_fx( } ELSE { - FOR ( n = 0; n < nchan_out; n++ ) + FOR( n = 0; n < nchan_out; n++ ) { assert( 0 && "This is yet to be implemented" ); } diff --git a/lib_dec/ivas_objectRenderer_internal_fx.c b/lib_dec/ivas_objectRenderer_internal_fx.c index ca228dd05..ae35fa703 100644 --- a/lib_dec/ivas_objectRenderer_internal_fx.c +++ b/lib_dec/ivas_objectRenderer_internal_fx.c @@ -212,11 +212,11 @@ ivas_error ivas_td_binaural_renderer_sf_fx( { #ifdef OBJ_EDITING_API test(); - IF ( EQ_16(st_ivas->ivas_format, ISM_FORMAT) || EQ_16(st_ivas->ivas_format, SBA_ISM_FORMAT ) ) + IF( EQ_16( st_ivas->ivas_format, ISM_FORMAT ) || EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) { ISM_METADATA_FRAME ismMetaData[MAX_NUM_OBJECTS]; ISM_METADATA_HANDLE hIsmMetaData[MAX_NUM_OBJECTS]; - FOR ( nS = 0; nS < nchan_ism; nS++ ) + FOR( nS = 0; nS < nchan_ism; nS++ ) { ismMetaData[nS].azimuth_fx = st_ivas->hIsmMetaData[nS]->edited_azimuth_fx; ismMetaData[nS].elevation_fx = st_ivas->hIsmMetaData[nS]->edited_elevation_fx; @@ -228,7 +228,7 @@ ivas_error ivas_td_binaural_renderer_sf_fx( hIsmMetaData[nS] = &ismMetaData[nS]; } - IF ( NE_16 ( ( error = TDREND_Update_object_positions_fx( st_ivas->hBinRendererTd, nchan_ism, st_ivas->ivas_format, hIsmMetaData ) ), IVAS_ERR_OK ) ) + IF( NE_16( ( error = TDREND_Update_object_positions_fx( st_ivas->hBinRendererTd, nchan_ism, st_ivas->ivas_format, hIsmMetaData ) ), IVAS_ERR_OK ) ) { return error; } @@ -236,7 +236,7 @@ ivas_error ivas_td_binaural_renderer_sf_fx( 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 ) ) + IF( NE_16( error = TDREND_Update_object_positions_fx( st_ivas->hBinRendererTd, nchan_ism, st_ivas->ivas_format, st_ivas->hIsmMetaData ), IVAS_ERR_OK ) ) { return error; } -- GitLab From 4c17c0285583716f84dd21357f960e70661e23a9 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 9 Oct 2025 16:34:20 +0200 Subject: [PATCH 13/46] change the type of edited_radius_fx to Word16 --- lib_com/ivas_stat_com.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 2867cd906..985f6a52d 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -70,7 +70,7 @@ typedef struct Word32 edited_azimuth_fx; /* Q22 */ Word32 edited_elevation_fx; /* Q22 */ - Word32 edited_radius_fx; /* Q9 */ + Word16 edited_radius_fx; /* Q9 */ Word32 edited_yaw_fx; /* Q22 */ Word32 edited_pitch_fx; /* Q22 */ -- GitLab From e3cfe5b623af9261dc0b22523ad9bdead54aad0b Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 9 Oct 2025 16:47:27 +0200 Subject: [PATCH 14/46] fix compile error --- 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 cbb66246c..cce77af03 100644 --- a/lib_com/ivas_ism_com_fx.c +++ b/lib_com/ivas_ism_com_fx.c @@ -476,7 +476,7 @@ void ivas_ism_reset_metadata( hIsmMeta->edited_elevation_fx = 0; hIsmMeta->edited_pitch_fx = 0; hIsmMeta->edited_yaw_fx = 0; - hIsmMeta->edited_radius_fx = ONE_IN_Q30; + hIsmMeta->edited_radius_fx = ONE_IN_Q9; hIsmMeta->gain_fx = ONE_IN_Q30; hIsmMeta->non_diegetic_flag = 0; #endif -- GitLab From 6bd936640496e540df6253f2d399b976eeb9bde8 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 9 Oct 2025 17:39:18 +0200 Subject: [PATCH 15/46] implement ambisonics gain --- lib_dec/ivas_jbm_dec_fx.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 06a9d388f..a55958623 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2268,7 +2268,9 @@ ivas_error ivas_jbm_dec_render_fx( { FOR( i = 0; i < *nSamplesRendered; i++ ) { - assert( 0 && "This is yet to be implemented" ); + Word32 tmp1 = Mpy_32_32( p_tc_fx[n + st_ivas->nchan_ism][i], gain ); // Q11 + Q30 - 32 = Q9 + tmp1 = L_shl(tmp1, 2); // Q9 --> Q11 + p_output_fx[n][i] = L_add( p_output_fx[n][i], tmp1 ); // Q11 } } } @@ -2276,7 +2278,13 @@ ivas_error ivas_jbm_dec_render_fx( { FOR( n = 0; n < nchan_out; n++ ) { - assert( 0 && "This is yet to be implemented" ); + FOR( n = 0; n < nchan_out; n++ ) + { + FOR( i = 0; i < *nSamplesRendered; i++ ) + { + p_output_fx[n][i] = L_add( p_output_fx[n][i], p_tc_fx[n + st_ivas->nchan_ism][i] ); // Q11 + } + } } } } -- GitLab From d5db48979fb86237f29cb43bd0327082048f0f66 Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Thu, 9 Oct 2025 22:33:20 +0200 Subject: [PATCH 16/46] fix compiler warnings --- lib_dec/ivas_ism_param_dec_fx.c | 4 ++-- lib_dec/lib_dec_fx.c | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 4d02fe136..5698db516 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -1926,9 +1926,9 @@ void ivas_param_ism_dec_render_fx( FOR( ch = 0; ch < st_ivas->nchan_ism; ch++ ) { #ifdef OBJ_EDITING_API - if ( st_ivas->hParamIsmDec->azimuth_values_fx[ch] > 180.0f ) + if ( st_ivas->hParamIsmDec->azimuth_values_fx[ch] > 755827200 ) /*180 in Q22*/ { - st_ivas->hIsmMetaData[ch]->azimuth_fx = st_ivas->hParamIsmDec->edited_azimuth_values_fx[ch] - 360.0f; + st_ivas->hIsmMetaData[ch]->azimuth_fx = st_ivas->hParamIsmDec->edited_azimuth_values_fx[ch] - 1513500160; /* 360 in Q22 */ } else { diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index ead29e828..cb87a25c0 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -2312,7 +2312,7 @@ ivas_error IVAS_DEC_GetObjectMetadata( metadata->radius_fx = st_ivas->hIsmMetaData[objectIdx]->edited_radius_fx; metadata->yaw_fx = st_ivas->hIsmMetaData[objectIdx]->edited_yaw_fx; metadata->pitch_fx = st_ivas->hIsmMetaData[objectIdx]->edited_pitch_fx; - metadata->spread_fx = 0.f; + metadata->spread_fx = 0; metadata->gainFactor_fx = st_ivas->hIsmMetaData[objectIdx]->edited_gain_fx; metadata->non_diegetic_flag = st_ivas->hIsmMetaData[objectIdx]->non_diegetic_flag; } @@ -3890,7 +3890,7 @@ 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 = 1.0f; + hIsmMetaData[obj]->edited_gain_fx = ONE_IN_Q30; } IF( hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) @@ -3974,9 +3974,9 @@ ivas_error IVAS_DEC_GetEditableParameters( hIvasEditableParameters->ism_metadata[obj].azimuth_fx = hIvasDec->st_ivas->hParamIsmDec->azimuth_values_fx[obj]; hIvasEditableParameters->ism_metadata[obj].elevation_fx = hIvasDec->st_ivas->hParamIsmDec->elevation_values_fx[obj]; hIvasEditableParameters->ism_metadata[obj].yaw = 0.0f; - hIvasEditableParameters->ism_metadata[obj].pitch_fx = 0.0f; - hIvasEditableParameters->ism_metadata[obj].radius_fx = 0.0f; - hIvasEditableParameters->ism_metadata[obj].gain_fx = 1.0f; + hIvasEditableParameters->ism_metadata[obj].pitch_fx = 0; + hIvasEditableParameters->ism_metadata[obj].radius_fx = 0; + hIvasEditableParameters->ism_metadata[obj].gain_fx = ONE_IN_Q31; hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = 0; } } -- GitLab From 66ea2e939a996bd41e3c0eede042e7879f1d798a Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Thu, 9 Oct 2025 22:42:34 +0200 Subject: [PATCH 17/46] clang format --- lib_dec/ivas_jbm_dec_fx.c | 6 +++--- lib_dec/lib_dec_fx.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index a55958623..85999491a 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2268,9 +2268,9 @@ ivas_error ivas_jbm_dec_render_fx( { 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 - tmp1 = L_shl(tmp1, 2); // Q9 --> Q11 - p_output_fx[n][i] = L_add( p_output_fx[n][i], tmp1 ); // Q11 + Word32 tmp1 = Mpy_32_32( p_tc_fx[n + st_ivas->nchan_ism][i], gain ); // Q11 + Q30 - 32 = Q9 + tmp1 = L_shl( tmp1, 2 ); // Q9 --> Q11 + p_output_fx[n][i] = L_add( p_output_fx[n][i], tmp1 ); // Q11 } } } diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index cb87a25c0..af66ee371 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -3976,7 +3976,7 @@ ivas_error IVAS_DEC_GetEditableParameters( hIvasEditableParameters->ism_metadata[obj].yaw = 0.0f; hIvasEditableParameters->ism_metadata[obj].pitch_fx = 0; hIvasEditableParameters->ism_metadata[obj].radius_fx = 0; - hIvasEditableParameters->ism_metadata[obj].gain_fx = ONE_IN_Q31; + hIvasEditableParameters->ism_metadata[obj].gain_fx = ONE_IN_Q31; hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = 0; } } -- GitLab From c6187158134ab5d7cf63fbce3d0469e97f32de2d Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Thu, 9 Oct 2025 23:09:19 +0200 Subject: [PATCH 18/46] fix windows compilation warning --- lib_dec/ivas_jbm_dec_fx.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index a55958623..2090745a6 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2263,7 +2263,6 @@ ivas_error ivas_jbm_dec_render_fx( test(); IF( NE_32( gain, ONE_IN_Q30 ) && GT_32( gain, 0 ) ) { - Word16 i; FOR( n = 0; n < nchan_out; n++ ) { FOR( i = 0; i < *nSamplesRendered; i++ ) -- GitLab From 0863f79d95c14b4a57cb9f3af188f990e388f91c Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 10 Oct 2025 09:10:48 +0200 Subject: [PATCH 19/46] switch to saturating adds to add objects and ambisonics signals --- 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 49eb58788..00eb77a03 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2269,7 +2269,7 @@ ivas_error ivas_jbm_dec_render_fx( { Word32 tmp1 = Mpy_32_32( p_tc_fx[n + st_ivas->nchan_ism][i], gain ); // Q11 + Q30 - 32 = Q9 tmp1 = L_shl( tmp1, 2 ); // Q9 --> Q11 - p_output_fx[n][i] = L_add( p_output_fx[n][i], tmp1 ); // Q11 + p_output_fx[n][i] = L_add_sat( p_output_fx[n][i], tmp1 ); // Q11 } } } @@ -2281,7 +2281,7 @@ ivas_error ivas_jbm_dec_render_fx( { FOR( i = 0; i < *nSamplesRendered; i++ ) { - p_output_fx[n][i] = L_add( p_output_fx[n][i], p_tc_fx[n + st_ivas->nchan_ism][i] ); // Q11 + p_output_fx[n][i] = L_add_sat( p_output_fx[n][i], p_tc_fx[n + st_ivas->nchan_ism][i] ); // Q11 } } } -- GitLab From 9cdcea0e42d5aca2f76caef006953155c5bc518d Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 10 Oct 2025 09:14:27 +0200 Subject: [PATCH 20/46] fix formatting --- lib_dec/ivas_jbm_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 00eb77a03..497dbd1f9 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2269,7 +2269,7 @@ ivas_error ivas_jbm_dec_render_fx( { Word32 tmp1 = Mpy_32_32( p_tc_fx[n + st_ivas->nchan_ism][i], gain ); // Q11 + Q30 - 32 = Q9 tmp1 = L_shl( tmp1, 2 ); // Q9 --> Q11 - p_output_fx[n][i] = L_add_sat( p_output_fx[n][i], tmp1 ); // Q11 + p_output_fx[n][i] = L_add_sat( p_output_fx[n][i], tmp1 ); // Q11 } } } -- GitLab From 4a4dfb9e491a95c6d22f7f252b4cd76adfa286ee Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 10 Oct 2025 09:19:58 +0200 Subject: [PATCH 21/46] insert correct BASOPs in ivas_jbm_dec_feed_to_renderer_fx --- lib_dec/ivas_jbm_dec_fx.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 497dbd1f9..bc24490b9 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -1901,9 +1901,10 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( } } #else - else if ( st_ivas->ivas_format == MC_FORMAT ) + ELSE IF ( EQ_16(st_ivas->ivas_format, MC_FORMAT ) ) { - if ( st_ivas->mc_mode == MC_MODE_PARAMMC && st_ivas->hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_RENDERER ) + test(); + IF ( EQ_16(st_ivas->mc_mode, MC_MODE_PARAMMC) && EQ_16( st_ivas->hTcBuffer->tc_buffer_mode, TC_BUFFER_MODE_RENDERER ) ) { ivas_param_mc_dec_digest_tc_fx( st_ivas, (UWord8) n_render_timeslots, (Word32 **) p_data_f_fx, Q11 ); } -- GitLab From 1122a5b05d204b4cb3d455acb785797b9acd1690 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 10 Oct 2025 09:21:39 +0200 Subject: [PATCH 22/46] fix a variable type in struct _IVAS_EDITABLE_PARAMETERS --- lib_com/common_api_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 5c006f8c1..d8ccd49d9 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -146,7 +146,7 @@ typedef struct _IVAS_ISM_METADATA #ifdef OBJ_EDITING_API typedef struct _IVAS_EDITABLE_PARAMETERS { - int16_t num_obj; + Word16 num_obj; IVAS_ISM_METADATA ism_metadata[IVAS_MAX_NUM_OBJECTS]; Word32 gain_bed_fx; } IVAS_EDITABLE_PARAMETERS; -- GitLab From 0d203a2bf64f72112f8c8a09b9ef9fed9cad2674 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 10 Oct 2025 09:45:13 +0200 Subject: [PATCH 23/46] 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 bc24490b9..f83bea315 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -1901,10 +1901,10 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( } } #else - ELSE IF ( EQ_16(st_ivas->ivas_format, MC_FORMAT ) ) + ELSE IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) ) { test(); - IF ( EQ_16(st_ivas->mc_mode, MC_MODE_PARAMMC) && EQ_16( st_ivas->hTcBuffer->tc_buffer_mode, TC_BUFFER_MODE_RENDERER ) ) + IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMMC ) && EQ_16( st_ivas->hTcBuffer->tc_buffer_mode, TC_BUFFER_MODE_RENDERER ) ) { ivas_param_mc_dec_digest_tc_fx( st_ivas, (UWord8) n_render_timeslots, (Word32 **) p_data_f_fx, Q11 ); } -- GitLab From 56e68205b76e514c9cfd7fb6fca13704a75d39fa Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 10 Oct 2025 09:48:12 +0200 Subject: [PATCH 24/46] change variable types in ivas_param_mc_dec_prepare_renderer --- lib_dec/ivas_mc_param_dec_fx.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index 7c30bdffa..596ec9e70 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -1732,11 +1732,11 @@ void ivas_param_mc_dec_prepare_renderer( ) { PARAM_MC_DEC_HANDLE hParamMC; - int16_t i; - int16_t is_next_band, skip_next_band; - int16_t slot_idx, param_band_idx; - int16_t nchan_transport, nchan_out_transport, nchan_out_cldfb; - int16_t nchan_out_cov; + Word16 i; + Word16 is_next_band, skip_next_band; + Word16 slot_idx, param_band_idx; + Word16 nchan_transport, nchan_out_transport, nchan_out_cldfb; + Word16 nchan_out_cov; /*CLDFB*/ Word32 *pCx, *pCx_imag; Word32 cx_fx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; // Q(31 - cx_e) @@ -1753,7 +1753,7 @@ void ivas_param_mc_dec_prepare_renderer( Word16 max_e; /* format converter */ - int16_t channel_active[MAX_OUTPUT_CHANNELS]; + Word16 channel_active[MAX_OUTPUT_CHANNELS]; IVAS_OUTPUT_SETUP *hSynthesisOutputSetup; hParamMC = st_ivas->hParamMC; -- GitLab From b0e7b68204d4ed00bbf7d94d3ced7817111f7c6a Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Fri, 10 Oct 2025 11:07:33 +0200 Subject: [PATCH 25/46] correct constants add BASOP operators --- lib_dec/ivas_ism_param_dec_fx.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 5698db516..831ce431c 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -1926,15 +1926,18 @@ void ivas_param_ism_dec_render_fx( FOR( ch = 0; ch < st_ivas->nchan_ism; ch++ ) { #ifdef OBJ_EDITING_API - if ( st_ivas->hParamIsmDec->azimuth_values_fx[ch] > 755827200 ) /*180 in Q22*/ + IF( GT_32( st_ivas->hParamIsmDec->azimuth_values_fx[ch], 754974720 ) /*180.f in Q22*/ ) { - st_ivas->hIsmMetaData[ch]->azimuth_fx = st_ivas->hParamIsmDec->edited_azimuth_values_fx[ch] - 1513500160; /* 360 in Q22 */ + st_ivas->hIsmMetaData[ch]->azimuth_fx = L_sub( st_ivas->hParamIsmDec->edited_azimuth_values_fx[ch], 1509949440 ) /*360.0F in Q22*/; + move32(); } - else + ELSE { st_ivas->hIsmMetaData[ch]->azimuth_fx = st_ivas->hParamIsmDec->edited_azimuth_values_fx[ch]; + move32(); } st_ivas->hIsmMetaData[ch]->elevation_fx = st_ivas->hParamIsmDec->edited_elevation_values_fx[ch]; + move32(); #else IF( GT_32( st_ivas->hParamIsmDec->azimuth_values_fx[ch], 754974720 ) /*180.f in Q22*/ ) { -- GitLab From fa8f9ea6b5762b25b6f784115fefefab7da055be Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 10 Oct 2025 11:29:34 +0200 Subject: [PATCH 26/46] fix porting issues in ivas_param_mc_dec_prepare_renderer --- lib_com/ivas_prot_fx.h | 2 +- lib_dec/ivas_mc_param_dec_fx.c | 450 +++++++++++++++++++++------------ 2 files changed, 292 insertions(+), 160 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index c76513697..f226e5d95 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -5190,7 +5190,7 @@ void ivas_param_mc_dec_digest_tc_fx( #ifdef OBJ_EDITING_API void ivas_param_mc_dec_prepare_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const UWord16 nCldfbSlots /* i : number of CLFBS slots in the transport channels */ + const UWord8 nCldfbSlots /* i : number of CLFBS slots in the transport channels */ ); #endif diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index 596ec9e70..da511f1e8 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -1645,80 +1645,217 @@ void ivas_param_mc_dec_digest_tc_fx( #endif /* slot loop for gathering the input data */ - FOR( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ){ - IF( st_ivas->hDecoderConfig->Opt_tsm ){ + FOR( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) + { + IF( st_ivas->hDecoderConfig->Opt_tsm ) + { #ifndef OBJ_EDITING_API IF( param_band_idx == 0 ) /* only run cldfbAna once */ { #endif Word32 RealBuffer_fx[CLDFB_NO_CHANNELS_MAX]; - Word32 ImagBuffer_fx[CLDFB_NO_CHANNELS_MAX]; + Word32 ImagBuffer_fx[CLDFB_NO_CHANNELS_MAX]; - /* CLDFB Analysis*/ - FOR( ch = 0; ch < nchan_transport; ch++ ) - { - qout = transport_f_e; - move16(); - cldfbAnalysis_ts_fx_fixed_q( &( transport_channels_f_fx[ch][hParamMC->num_freq_bands * slot_idx] ), RealBuffer_fx, ImagBuffer_fx, hParamMC->num_freq_bands, st_ivas->cldfbAnaDec[ch], &qout ); + /* CLDFB Analysis*/ + FOR( ch = 0; ch < nchan_transport; ch++ ) + { + qout = transport_f_e; + move16(); + cldfbAnalysis_ts_fx_fixed_q( &( transport_channels_f_fx[ch][hParamMC->num_freq_bands * slot_idx] ), RealBuffer_fx, ImagBuffer_fx, hParamMC->num_freq_bands, st_ivas->cldfbAnaDec[ch], &qout ); - Copy32( RealBuffer_fx, &hParamMC->Cldfb_RealBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport + ch * hParamMC->num_freq_bands], hParamMC->num_freq_bands ); - Copy32( ImagBuffer_fx, &hParamMC->Cldfb_ImagBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport + ch * hParamMC->num_freq_bands], hParamMC->num_freq_bands ); - } + Copy32( RealBuffer_fx, &hParamMC->Cldfb_RealBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport + ch * hParamMC->num_freq_bands], hParamMC->num_freq_bands ); + Copy32( ImagBuffer_fx, &hParamMC->Cldfb_ImagBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport + ch * hParamMC->num_freq_bands], hParamMC->num_freq_bands ); + } - hParamMC->Cldfb_ImagBuffer_tc_e = qout; - move16(); + hParamMC->Cldfb_ImagBuffer_tc_e = qout; + move16(); #ifndef OBJ_EDITING_API - } + } #endif -} + } + #ifndef OBJ_EDITING_API -IF( GE_16( slot_idx, shl( hParamMC->hMetadataPMC->attackIndex, 1 ) ) ) -{ - FOR( is_next_band = 0; is_next_band < 2; is_next_band++ ) - { - test(); - IF( is_next_band && skip_next_band ) + IF( GE_16( slot_idx, shl( hParamMC->hMetadataPMC->attackIndex, 1 ) ) ) + { + FOR( is_next_band = 0; is_next_band < 2; is_next_band++ ) + { + test(); + IF( is_next_band && skip_next_band ) + { + CONTINUE; + } + IF( is_next_band ) + { + ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot_fx( &hParamMC->Cldfb_RealBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport], + /*hParamMC->Cldfb_RealBuffer_tc_e*/ Q31 - Q6, + &hParamMC->Cldfb_ImagBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport], + /*hParamMC->Cldfb_ImagBuffer_tc_e*/ Q31 - Q6, + cx_next_band_fx, + &cx_next_band_e, + cx_imag_next_band_fx, + &cx_imag_next_band_e, + hParamMC, + add( param_band_idx, is_next_band ), + nchan_transport ); + } + ELSE + { + ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot_fx( &hParamMC->Cldfb_RealBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport], + /*hParamMC->Cldfb_RealBuffer_tc_e*/ Q31 - Q6, + &hParamMC->Cldfb_ImagBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport], + /*hParamMC->Cldfb_ImagBuffer_tc_e*/ Q31 - Q6, + cx_fx, + &cx_e, + cx_imag_fx, + &cx_imag_e, + hParamMC, + add( param_band_idx, is_next_band ), + nchan_transport ); + } + } + } +#endif + } + +#ifndef OBJ_EDITING_API + Word16 tmp_cx_e, tmp_cx_imag_e; + /* map from complex input covariance to real values */ + FOR( is_next_band = 0; is_next_band < 2; is_next_band++ ) { - CONTINUE; + test(); + IF( is_next_band && skip_next_band ) + { + CONTINUE; + } + /* Cx for transport channels */ + IF( is_next_band ) + { + pCx = &cx_next_band_fx[0]; + pCx_imag = &cx_imag_next_band_fx[0]; + tmp_cx_e = cx_next_band_e; + tmp_cx_imag_e = cx_imag_next_band_e; + } + ELSE + { + pCx = &cx_fx[0]; + pCx_imag = &cx_imag_fx[0]; + tmp_cx_e = cx_e; + tmp_cx_imag_e = cx_imag_e; + } + + FOR( i = 0; i < nchan_transport * nchan_transport; i++ ) + { + real_part_fx = pCx[i]; // Q(31 - cx_buff_e) + imag_part_fx = pCx_imag[i]; + move32(); + move32(); + cx_buff_e[is_next_band][i] = tmp_cx_e; + move16(); + /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ + IF( LT_16( param_band_idx, hParamMC->max_param_band_abs_cov ) ) + { + L_tmp1 = Mpy_32_32( real_part_fx, real_part_fx ); + L_tmp2 = Mpy_32_32( imag_part_fx, imag_part_fx ); + L_tmp1 = BASOP_Util_Add_Mant32Exp( L_tmp1, add( tmp_cx_e, tmp_cx_e ), L_tmp2, add( tmp_cx_imag_e, tmp_cx_imag_e ), &tmp_e ); + pCx[i] = Sqrt32( L_tmp1, &tmp_e ); + move32(); + cx_buff_e[is_next_band][i] = tmp_e; + move16(); + } + ELSE + { + pCx[i] = real_part_fx; + move32(); + cx_buff_e[is_next_band][i] = tmp_cx_e; + move16(); + } + } } - IF( is_next_band ) + + max_e = cx_buff_e[0][0]; + move16(); + + /* Cx for transport channels */ + FOR( is_next_band = 0; is_next_band < 2; is_next_band++ ) { - ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot_fx( &hParamMC->Cldfb_RealBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport], - /*hParamMC->Cldfb_RealBuffer_tc_e*/ Q31 - Q6, - &hParamMC->Cldfb_ImagBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport], - /*hParamMC->Cldfb_ImagBuffer_tc_e*/ Q31 - Q6, - cx_next_band_fx, - &cx_next_band_e, - cx_imag_next_band_fx, - &cx_imag_next_band_e, - hParamMC, - add( param_band_idx, is_next_band ), - nchan_transport ); + FOR( i = 0; i < imult1616( nchan_transport, nchan_transport ); i++ ) + { + + IF( LT_16( max_e, cx_buff_e[is_next_band][i] ) ) + { + max_e = cx_buff_e[is_next_band][i]; + } + } } - ELSE + /* Cx for transport channels */ + FOR( is_next_band = 0; is_next_band < 2; is_next_band++ ) + { + FOR( i = 0; i < imult1616( nchan_transport, nchan_transport ); i++ ) + { + if ( is_next_band == 0 ) + { + cx_fx[i] = L_shr( cx_fx[i], sub( max_e, cx_buff_e[is_next_band][i] ) ); + } + else + { + cx_next_band_fx[i] = L_shr( cx_next_band_fx[i], sub( max_e, cx_buff_e[is_next_band][i] ) ); + } + move32(); + } + } + cx_e = max_e; + move16(); + + + /* we have to do it similar to the encoder in case of attacks (i.e. accumulate two bands) to ensure correct DMX of the target covariance*/ + + test(); + test(); + IF( hParamMC->hMetadataPMC->bAttackPresent && ( EQ_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_LS_CONV_COV ) || EQ_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) ) + { + Word16 len = imult1616( nchan_transport, nchan_transport ); + Word16 sc = s_min( getScaleFactor32( cx_fx, len ), getScaleFactor32( cx_next_band_fx, len ) ); + IF( EQ_16( sc, 0 ) ) + { + Scale_sig32( cx_fx, len, -Q1 ); // add one bit head room + Scale_sig32( cx_next_band_fx, len, -Q1 ); // add one bit head room + cx_e = add( cx_e, Q1 ); + cx_next_band_e = add( cx_e, Q1 ); + } + v_add_fx( cx_fx, cx_next_band_fx, cx_fx, len ); + Copy32( cx_fx, cx_next_band_fx, len ); + } + + FOR( is_next_band = 0; is_next_band < 2; is_next_band++ ) { - ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot_fx( &hParamMC->Cldfb_RealBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport], - /*hParamMC->Cldfb_RealBuffer_tc_e*/ Q31 - Q6, - &hParamMC->Cldfb_ImagBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport], - /*hParamMC->Cldfb_ImagBuffer_tc_e*/ Q31 - Q6, - cx_fx, - &cx_e, - cx_imag_fx, - &cx_imag_e, - hParamMC, - add( param_band_idx, is_next_band ), - nchan_transport ); + test(); + IF( is_next_band && skip_next_band ) + { + CONTINUE; + } + + IF( NE_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) + { + IF( is_next_band ) + { + + ivas_param_mc_get_mixing_matrices_fx( hParamMC, hSynthesisOutputSetup, cx_next_band_fx, cx_e, add( param_band_idx, is_next_band ), hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp, nchan_out_transport, hParamMC->synthesis_conf, nchan_transport, nchan_out_cov ); + } + ELSE + { + + ivas_param_mc_get_mixing_matrices_fx( hParamMC, hSynthesisOutputSetup, cx_fx, cx_e, add( param_band_idx, is_next_band ), hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp, nchan_out_transport, hParamMC->synthesis_conf, nchan_transport, nchan_out_cov ); + } + } } } -} #endif -} - -pop_wmops(); + pop_wmops(); -return; + return; } + #ifdef OBJ_EDITING_API /*------------------------------------------------------------------------- * ivas_param_mc_dec_prepare_renderer() @@ -1728,16 +1865,16 @@ return; void ivas_param_mc_dec_prepare_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const UWord16 nCldfbSlots /* i : number of CLFBS slots in the transport channels */ + const UWord8 nCldfbSlots /* i : number of CLFBS slots in the transport channels */ ) { - PARAM_MC_DEC_HANDLE hParamMC; Word16 i; Word16 is_next_band, skip_next_band; Word16 slot_idx, param_band_idx; Word16 nchan_transport, nchan_out_transport, nchan_out_cldfb; Word16 nchan_out_cov; - /*CLDFB*/ + PARAM_MC_DEC_HANDLE hParamMC; + Word32 *pCx, *pCx_imag; Word32 cx_fx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; // Q(31 - cx_e) Word32 cx_imag_fx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; // Q(31 - cx_imag_e) @@ -1759,7 +1896,7 @@ void ivas_param_mc_dec_prepare_renderer( hParamMC = st_ivas->hParamMC; assert( hParamMC ); - push_wmops( "param_mc_dec_digest_tc" ); + set16_fx( channel_active, 0, MAX_CICP_CHANNELS ); nchan_transport = st_ivas->nchan_transport; move16(); @@ -1840,11 +1977,11 @@ void ivas_param_mc_dec_prepare_renderer( move16(); cx_imag_next_band_e = 0; move16(); - + + /* slot loop for gathering the input data */ FOR( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) { - /* slot loop for gathering the input data */ - IF( GE_16( slot_idx, shl( hParamMC->hMetadataPMC->attackIndex, 1 ) ) ) + IF( GE_16( slot_idx, shl( hParamMC->hMetadataPMC->attackIndex, 1 ) ) ) { FOR( is_next_band = 0; is_next_band < 2; is_next_band++ ) { @@ -1883,143 +2020,138 @@ void ivas_param_mc_dec_prepare_renderer( } } } + } + Word16 tmp_cx_e, tmp_cx_imag_e; + /* map from complex input covariance to real values */ + FOR( is_next_band = 0; is_next_band < 2; is_next_band++ ) + { + test(); + IF( is_next_band && skip_next_band ) + { + CONTINUE; + } + /* Cx for transport channels */ + IF( is_next_band ) + { + pCx = &cx_next_band_fx[0]; + pCx_imag = &cx_imag_next_band_fx[0]; + tmp_cx_e = cx_next_band_e; + tmp_cx_imag_e = cx_imag_next_band_e; + } + ELSE + { + pCx = &cx_fx[0]; + pCx_imag = &cx_imag_fx[0]; + tmp_cx_e = cx_e; + tmp_cx_imag_e = cx_imag_e; + } - Word16 tmp_cx_e, tmp_cx_imag_e; - /* map from complex input covariance to real values */ - FOR( is_next_band = 0; is_next_band < 2; is_next_band++ ) + FOR( i = 0; i < nchan_transport * nchan_transport; i++ ) { - test(); - IF( is_next_band && skip_next_band ) - { - CONTINUE; - } - /* Cx for transport channels */ - IF( is_next_band ) + real_part_fx = pCx[i]; // Q(31 - cx_buff_e) + imag_part_fx = pCx_imag[i]; + move32(); + move32(); + cx_buff_e[is_next_band][i] = tmp_cx_e; + move16(); + /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ + IF( LT_16( param_band_idx, hParamMC->max_param_band_abs_cov ) ) { - pCx = &cx_next_band_fx[0]; - pCx_imag = &cx_imag_next_band_fx[0]; - tmp_cx_e = cx_next_band_e; - tmp_cx_imag_e = cx_imag_next_band_e; + L_tmp1 = Mpy_32_32( real_part_fx, real_part_fx ); + L_tmp2 = Mpy_32_32( imag_part_fx, imag_part_fx ); + L_tmp1 = BASOP_Util_Add_Mant32Exp( L_tmp1, add( tmp_cx_e, tmp_cx_e ), L_tmp2, add( tmp_cx_imag_e, tmp_cx_imag_e ), &tmp_e ); + pCx[i] = Sqrt32( L_tmp1, &tmp_e ); + move32(); + cx_buff_e[is_next_band][i] = tmp_e; + move16(); } ELSE { - pCx = &cx_fx[0]; - pCx_imag = &cx_imag_fx[0]; - tmp_cx_e = cx_e; - tmp_cx_imag_e = cx_imag_e; - } - - FOR( i = 0; i < nchan_transport * nchan_transport; i++ ) - { - real_part_fx = pCx[i]; // Q(31 - cx_buff_e) - imag_part_fx = pCx_imag[i]; - move32(); + pCx[i] = real_part_fx; move32(); cx_buff_e[is_next_band][i] = tmp_cx_e; move16(); - /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ - IF( LT_16( param_band_idx, hParamMC->max_param_band_abs_cov ) ) - { - L_tmp1 = Mpy_32_32( real_part_fx, real_part_fx ); - L_tmp2 = Mpy_32_32( imag_part_fx, imag_part_fx ); - L_tmp1 = BASOP_Util_Add_Mant32Exp( L_tmp1, add( tmp_cx_e, tmp_cx_e ), L_tmp2, add( tmp_cx_imag_e, tmp_cx_imag_e ), &tmp_e ); - pCx[i] = Sqrt32( L_tmp1, &tmp_e ); - move32(); - cx_buff_e[is_next_band][i] = tmp_e; - move16(); - } - ELSE - { - pCx[i] = real_part_fx; - move32(); - cx_buff_e[is_next_band][i] = tmp_cx_e; - move16(); - } } } + } - max_e = cx_buff_e[0][0]; - move16(); + max_e = cx_buff_e[0][0]; + move16(); - /* Cx for transport channels */ - FOR( is_next_band = 0; is_next_band < 2; is_next_band++ ) + /* Cx for transport channels */ + FOR( is_next_band = 0; is_next_band < 2; is_next_band++ ) + { + FOR( i = 0; i < imult1616( nchan_transport, nchan_transport ); i++ ) { - FOR( i = 0; i < imult1616( nchan_transport, nchan_transport ); i++ ) - { - IF( LT_16( max_e, cx_buff_e[is_next_band][i] ) ) - { - max_e = cx_buff_e[is_next_band][i]; - } + IF( LT_16( max_e, cx_buff_e[is_next_band][i] ) ) + { + max_e = cx_buff_e[is_next_band][i]; } } - /* Cx for transport channels */ - FOR( is_next_band = 0; is_next_band < 2; is_next_band++ ) + } + /* Cx for transport channels */ + FOR( is_next_band = 0; is_next_band < 2; is_next_band++ ) + { + FOR( i = 0; i < imult1616( nchan_transport, nchan_transport ); i++ ) { - FOR( i = 0; i < imult1616( nchan_transport, nchan_transport ); i++ ) + if ( is_next_band == 0 ) { - if ( is_next_band == 0 ) - { - cx_fx[i] = L_shr( cx_fx[i], sub( max_e, cx_buff_e[is_next_band][i] ) ); - } - else - { - cx_next_band_fx[i] = L_shr( cx_next_band_fx[i], sub( max_e, cx_buff_e[is_next_band][i] ) ); - } - move32(); + cx_fx[i] = L_shr( cx_fx[i], sub( max_e, cx_buff_e[is_next_band][i] ) ); + } + else + { + cx_next_band_fx[i] = L_shr( cx_next_band_fx[i], sub( max_e, cx_buff_e[is_next_band][i] ) ); } + move32(); } - cx_e = max_e; - move16(); + } + cx_e = max_e; + move16(); - /* we have to do it similar to the encoder in case of attacks (i.e. accumulate two bands) to ensure correct DMX of the target covariance*/ + /* we have to do it similar to the encoder in case of attacks (i.e. accumulate two bands) to ensure correct DMX of the target covariance*/ + test(); + test(); + IF( hParamMC->hMetadataPMC->bAttackPresent && ( EQ_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_LS_CONV_COV ) || EQ_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) ) + { + Word16 len = imult1616( nchan_transport, nchan_transport ); + Word16 sc = s_min( getScaleFactor32( cx_fx, len ), getScaleFactor32( cx_next_band_fx, len ) ); + IF( EQ_16( sc, 0 ) ) + { + Scale_sig32( cx_fx, len, -Q1 ); // add one bit head room + Scale_sig32( cx_next_band_fx, len, -Q1 ); // add one bit head room + cx_e = add( cx_e, Q1 ); + cx_next_band_e = add( cx_e, Q1 ); + } + v_add_fx( cx_fx, cx_next_band_fx, cx_fx, len ); + Copy32( cx_fx, cx_next_band_fx, len ); + } + + FOR( is_next_band = 0; is_next_band < 2; is_next_band++ ) + { test(); - test(); - IF( hParamMC->hMetadataPMC->bAttackPresent && ( EQ_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_LS_CONV_COV ) || EQ_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) ) + IF( is_next_band && skip_next_band ) { - Word16 len = imult1616( nchan_transport, nchan_transport ); - Word16 sc = s_min( getScaleFactor32( cx_fx, len ), getScaleFactor32( cx_next_band_fx, len ) ); - IF( EQ_16( sc, 0 ) ) - { - Scale_sig32( cx_fx, len, -Q1 ); // add one bit head room - Scale_sig32( cx_next_band_fx, len, -Q1 ); // add one bit head room - cx_e = add( cx_e, Q1 ); - cx_next_band_e = add( cx_e, Q1 ); - } - v_add_fx( cx_fx, cx_next_band_fx, cx_fx, len ); - Copy32( cx_fx, cx_next_band_fx, len ); + CONTINUE; } - FOR( is_next_band = 0; is_next_band < 2; is_next_band++ ) + IF( NE_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) { - test(); - IF( is_next_band && skip_next_band ) + IF( is_next_band ) { - CONTINUE; - } - IF( NE_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) + ivas_param_mc_get_mixing_matrices_fx( hParamMC, hSynthesisOutputSetup, cx_next_band_fx, cx_e, add( param_band_idx, is_next_band ), hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp, nchan_out_transport, hParamMC->synthesis_conf, nchan_transport, nchan_out_cov ); + } + ELSE { - IF( is_next_band ) - { - - ivas_param_mc_get_mixing_matrices_fx( hParamMC, hSynthesisOutputSetup, cx_next_band_fx, cx_e, add( param_band_idx, is_next_band ), hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp, nchan_out_transport, hParamMC->synthesis_conf, nchan_transport, nchan_out_cov ); - } - ELSE - { - ivas_param_mc_get_mixing_matrices_fx( hParamMC, hSynthesisOutputSetup, cx_fx, cx_e, add( param_band_idx, is_next_band ), hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp, nchan_out_transport, hParamMC->synthesis_conf, nchan_transport, nchan_out_cov ); - } + ivas_param_mc_get_mixing_matrices_fx( hParamMC, hSynthesisOutputSetup, cx_fx, cx_e, add( param_band_idx, is_next_band ), hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp, nchan_out_transport, hParamMC->synthesis_conf, nchan_transport, nchan_out_cov ); } } } } - - pop_wmops(); - - return; } #endif -- GitLab From 6976fcb6eed8a87ba638e3c878b421a7ae7f751d Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Fri, 10 Oct 2025 11:29:48 +0200 Subject: [PATCH 27/46] add BASOP operator --- lib_dec/ivas_jbm_dec_fx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index f83bea315..ae73f188c 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -4460,11 +4460,13 @@ void ivas_jbm_dec_prepare_renderer( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { - int16_t n, n_render_timeslots; + Word16 n, n_render_timeslots, tmp; push_wmops( "ivas_jbm_dec_feed_tc_to_rendererer" ); - n_render_timeslots = st_ivas->hTcBuffer->n_samples_available / st_ivas->hTcBuffer->n_samples_granularity; + /* n_render_timeslots = st_ivas->hTcBuffer->n_samples_available / st_ivas->hTcBuffer->n_samples_granularity; */ + tmp = BASOP_Util_Divide1616_Scale( st_ivas->hTcBuffer->n_samples_available, st_ivas->hTcBuffer->n_samples_granularity, &exp ); + n_render_timeslots = shr( tmp, sub( 15, exp ) ); // Q0 IF( EQ_16( st_ivas->hTcBuffer->tc_buffer_mode, TC_BUFFER_MODE_BUFFER ) ) -- GitLab From 89f737b7e937e2efd622d4ba99863bbeceb50853 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 10 Oct 2025 11:38:42 +0200 Subject: [PATCH 28/46] fix formatting --- lib_dec/ivas_mc_param_dec_fx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index da511f1e8..250b37675 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -1864,7 +1864,7 @@ void ivas_param_mc_dec_digest_tc_fx( *------------------------------------------------------------------------*/ void ivas_param_mc_dec_prepare_renderer( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const UWord8 nCldfbSlots /* i : number of CLFBS slots in the transport channels */ ) { @@ -1977,11 +1977,11 @@ void ivas_param_mc_dec_prepare_renderer( move16(); cx_imag_next_band_e = 0; move16(); - + /* slot loop for gathering the input data */ FOR( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) { - IF( GE_16( slot_idx, shl( hParamMC->hMetadataPMC->attackIndex, 1 ) ) ) + IF( GE_16( slot_idx, shl( hParamMC->hMetadataPMC->attackIndex, 1 ) ) ) { FOR( is_next_band = 0; is_next_band < 2; is_next_band++ ) { @@ -2020,7 +2020,7 @@ void ivas_param_mc_dec_prepare_renderer( } } } - } + } Word16 tmp_cx_e, tmp_cx_imag_e; /* map from complex input covariance to real values */ FOR( is_next_band = 0; is_next_band < 2; is_next_band++ ) -- GitLab From 567b3782a7e681d79cae38bb59d375d9e5fc3a10 Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Fri, 10 Oct 2025 11:45:05 +0200 Subject: [PATCH 29/46] define forgotten variable --- lib_dec/ivas_jbm_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index ae73f188c..6acac1029 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -4460,7 +4460,7 @@ void ivas_jbm_dec_prepare_renderer( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { - Word16 n, n_render_timeslots, tmp; + Word16 n, n_render_timeslots, tmp, exp; push_wmops( "ivas_jbm_dec_feed_tc_to_rendererer" ); -- GitLab From 63c3246ffa0ef5de1de6b579af00d06582121e08 Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Fri, 10 Oct 2025 12:28:13 +0200 Subject: [PATCH 30/46] fix windows warning --- lib_dec/ivas_jbm_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 6acac1029..f27a14d78 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -4666,7 +4666,7 @@ void ivas_jbm_dec_prepare_renderer( } ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMMC ) ) { - ivas_param_mc_dec_prepare_renderer( st_ivas, (UWord16) n_render_timeslots ); + ivas_param_mc_dec_prepare_renderer( st_ivas, (UWord8) n_render_timeslots ); } ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) ) { -- GitLab From f01cef708bf9c3f3b2109c4055ff0119936b9a64 Mon Sep 17 00:00:00 2001 From: lintervo Date: Fri, 10 Oct 2025 14:39:35 +0300 Subject: [PATCH 31/46] Fix scaling of proto_matrix_int_fx --- lib_dec/ivas_jbm_dec_fx.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index f27a14d78..3aefeb325 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -4666,7 +4666,13 @@ void ivas_jbm_dec_prepare_renderer( } ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMMC ) ) { + scale_sig32( st_ivas->hParamMC->proto_matrix_int_fx, st_ivas->hParamMC->proto_matrix_int_len, -1 ); // Q(31-1) + st_ivas->hParamMC->proto_matrix_int_e = 1; + move16(); + ivas_param_mc_dec_prepare_renderer( st_ivas, (UWord8) n_render_timeslots ); + + scale_sig32( st_ivas->hParamMC->proto_matrix_int_fx, st_ivas->hParamMC->proto_matrix_int_len, 1 ); // Q(31-1+1) } ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) ) { -- GitLab From 0c31b04c7a5dd146e85c0f846ffa3734888ab3f2 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 10 Oct 2025 16:08:23 +0200 Subject: [PATCH 32/46] insert missing call to ivas_param_ism_dec_prepare_renderer_fx --- lib_dec/ivas_jbm_dec_fx.c | 4 ++++ lib_dec/lib_dec_fx.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 3aefeb325..fbfa854dd 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -4498,6 +4498,10 @@ void ivas_jbm_dec_prepare_renderer( ivas_param_ism_params_to_masa_param_mapping_fx( st_ivas ); } + ELSE IF ( st_ivas->renderer_type == RENDERER_PARAM_ISM || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) + { + ivas_param_ism_dec_prepare_renderer_fx( st_ivas, n_render_timeslots ); + } } ELSE /* ISM_MODE_DISC */ { diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index af66ee371..68e2ff8b2 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1143,9 +1143,9 @@ ivas_error IVAS_DEC_GetSamples( #ifndef OBJ_EDITING_API l_ts = 0; nTransportChannels = 0; -#endif move16(); move16(); +#endif move16(); move16(); -- GitLab From b5ada7a12b603c8d0fcedcfbacbe22b9cf73c0e4 Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Fri, 10 Oct 2025 16:13:06 +0200 Subject: [PATCH 33/46] remaining float variables and missing instrumentation --- lib_dec/ivas_objectRenderer_internal_fx.c | 7 ++++ lib_dec/ivas_stat_dec.h | 4 +-- lib_dec/lib_dec_fx.c | 39 ++++++++++++++++++++--- 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/lib_dec/ivas_objectRenderer_internal_fx.c b/lib_dec/ivas_objectRenderer_internal_fx.c index ae35fa703..a97567c19 100644 --- a/lib_dec/ivas_objectRenderer_internal_fx.c +++ b/lib_dec/ivas_objectRenderer_internal_fx.c @@ -219,12 +219,19 @@ ivas_error ivas_td_binaural_renderer_sf_fx( FOR( nS = 0; nS < nchan_ism; nS++ ) { ismMetaData[nS].azimuth_fx = st_ivas->hIsmMetaData[nS]->edited_azimuth_fx; + move32(); ismMetaData[nS].elevation_fx = st_ivas->hIsmMetaData[nS]->edited_elevation_fx; + move32(); ismMetaData[nS].radius_fx = st_ivas->hIsmMetaData[nS]->edited_radius_fx; + move16(); ismMetaData[nS].yaw_fx = st_ivas->hIsmMetaData[nS]->edited_yaw_fx; + move32(); ismMetaData[nS].pitch_fx = st_ivas->hIsmMetaData[nS]->edited_pitch_fx; + move32(); ismMetaData[nS].non_diegetic_flag = st_ivas->hIsmMetaData[nS]->non_diegetic_flag; + move16(); ismMetaData[nS].gain_fx = st_ivas->hIsmMetaData[nS]->edited_gain_fx; + move32(); hIsmMetaData[nS] = &ismMetaData[nS]; } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 1d628578f..edf9729ce 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -964,8 +964,8 @@ typedef struct ivas_masa_ism_data_structure Word16 elevation_ism_edited[MAX_NUM_OBJECTS]; UWord8 ism_is_edited[MAX_NUM_OBJECTS]; #ifdef OBJ_EDITING_API - float gain_ism[MAX_NUM_OBJECTS]; - float gain_masa; + Word32 gain_ism[MAX_NUM_OBJECTS]; + Word32 gain_masa; #endif Word16 idx_separated_ism; diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 68e2ff8b2..31a2cb218 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -648,6 +648,11 @@ ivas_error IVAS_DEC_Configure( #ifdef OBJ_EDITING_API /* init flush buffer if necessary (only needed for binaural)*/ + test(); + test(); + test(); + test(); + test(); if ( tsmEnabled && ( outputConfig == IVAS_AUDIO_CONFIG_BINAURAL || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { hIvasDec->flushbuffer = (void *) malloc( CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( Word16 ) ); @@ -2289,7 +2294,7 @@ ivas_error IVAS_DEC_GetObjectMetadata( metadata->yaw_fx = hIsmMeta->edited_yaw_fx; metadata->pitch_fx = hIsmMeta->edited_pitch_fx; - metadata->spread = 0; + metadata->spread_fx = 0; metadata->gainFactor_fx = hIsmMeta->edited_gain_fx; metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; @@ -3932,6 +3937,11 @@ ivas_error IVAS_DEC_GetEditableParameters( { ivas_error error; + test(); + test(); + 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 ) ) ) ) @@ -3939,45 +3949,66 @@ ivas_error IVAS_DEC_GetEditableParameters( return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Object editing no supported in this operation mode." ); } + test(); + test(); if ( hIvasEditableParameters == NULL || hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } hIvasEditableParameters->gain_bed_fx = ONE_IN_Q30; + move32(); hIvasEditableParameters->num_obj = hIvasDec->st_ivas->nchan_ism; + move16(); + test(); + test(); 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 ) { - int16_t obj; + Word16 obj; for ( obj = 0; obj < hIvasEditableParameters->num_obj; obj++ ) { hIvasEditableParameters->ism_metadata[obj].azimuth_fx = hIvasDec->st_ivas->hIsmMetaData[obj]->azimuth_fx; + move32(); hIvasEditableParameters->ism_metadata[obj].elevation_fx = hIvasDec->st_ivas->hIsmMetaData[obj]->elevation_fx; + move32(); hIvasEditableParameters->ism_metadata[obj].yaw_fx = hIvasDec->st_ivas->hIsmMetaData[obj]->yaw_fx; + move32(); hIvasEditableParameters->ism_metadata[obj].pitch_fx = hIvasDec->st_ivas->hIsmMetaData[obj]->pitch_fx; + move32(); hIvasEditableParameters->ism_metadata[obj].radius_fx = hIvasDec->st_ivas->hIsmMetaData[obj]->radius_fx; + move16(); hIvasEditableParameters->ism_metadata[obj].gain_fx = hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain_fx; + move32(); hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = hIvasDec->st_ivas->hIsmMetaData[obj]->non_diegetic_flag; + move16(); } if ( hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { hIvasEditableParameters->gain_bed_fx = ONE_IN_Q30; + move32(); } } else if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) { - int16_t obj; + Word16 obj; for ( obj = 0; obj < hIvasEditableParameters->num_obj; obj++ ) { hIvasEditableParameters->ism_metadata[obj].azimuth_fx = hIvasDec->st_ivas->hParamIsmDec->azimuth_values_fx[obj]; + move32(); hIvasEditableParameters->ism_metadata[obj].elevation_fx = hIvasDec->st_ivas->hParamIsmDec->elevation_values_fx[obj]; - hIvasEditableParameters->ism_metadata[obj].yaw = 0.0f; + move32(); + hIvasEditableParameters->ism_metadata[obj].yaw_fx = 0; + move32(); hIvasEditableParameters->ism_metadata[obj].pitch_fx = 0; + move32(); hIvasEditableParameters->ism_metadata[obj].radius_fx = 0; + move16(); hIvasEditableParameters->ism_metadata[obj].gain_fx = ONE_IN_Q31; + move32(); hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = 0; + move16(); } } else -- GitLab From bb0d8bef87a8ae12f834facc4488ab71fe5a5255 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 10 Oct 2025 16:22:21 +0200 Subject: [PATCH 34/46] fix formatting --- lib_dec/ivas_jbm_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index fbfa854dd..261d95f93 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -4498,7 +4498,7 @@ void ivas_jbm_dec_prepare_renderer( ivas_param_ism_params_to_masa_param_mapping_fx( st_ivas ); } - ELSE IF ( st_ivas->renderer_type == RENDERER_PARAM_ISM || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) + ELSE IF( st_ivas->renderer_type == RENDERER_PARAM_ISM || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) { ivas_param_ism_dec_prepare_renderer_fx( st_ivas, n_render_timeslots ); } -- GitLab From e18faadfa3f3d5f1e82d06bb57921855c4f4e52f Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 10 Oct 2025 16:25:25 +0200 Subject: [PATCH 35/46] insert correct BASOP comparisons in ivas_jbm_dec_prepare_renderer --- lib_dec/ivas_jbm_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 261d95f93..b42217efd 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -4498,7 +4498,7 @@ void ivas_jbm_dec_prepare_renderer( ivas_param_ism_params_to_masa_param_mapping_fx( st_ivas ); } - ELSE IF( st_ivas->renderer_type == RENDERER_PARAM_ISM || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) + ELSE IF( EQ_16( st_ivas->renderer_type, RENDERER_PARAM_ISM ) || EQ_16( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) { ivas_param_ism_dec_prepare_renderer_fx( st_ivas, n_render_timeslots ); } -- GitLab From b6abe4e49a472debccff2a58e2ad45ee84293c7e Mon Sep 17 00:00:00 2001 From: naghibza Date: Fri, 10 Oct 2025 17:42:44 +0200 Subject: [PATCH 36/46] added the missing initialization of hIvasDec->flushBuffer --- lib_dec/lib_dec_fx.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 31a2cb218..117ea6041 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -988,6 +988,13 @@ ivas_error IVAS_DEC_EnableVoIP( } #endif +#ifdef OBJ_EDITING_API + if ( hIvasDec->flushbuffer == NULL && ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) + { + hIvasDec->flushbuffer = (void *) malloc( CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( Word16 ) ); + set16_fx( (Word16 *) hIvasDec->flushbuffer, 0, CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); + } +#endif return IVAS_ERR_OK; } -- GitLab From 6b8813b1e30bb1a931cec07538802bba11038758 Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Sat, 11 Oct 2025 21:12:42 +0200 Subject: [PATCH 37/46] change initialization of gains in metadata to Q31 --- lib_com/ivas_ism_com_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/ivas_ism_com_fx.c b/lib_com/ivas_ism_com_fx.c index cce77af03..30cd2f29e 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_Q30; + hIsmMeta->edited_gain_fx = ONE_IN_Q31; 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_Q30; + hIsmMeta->gain_fx = ONE_IN_Q31; hIsmMeta->non_diegetic_flag = 0; #endif -- GitLab From a37be589c06674d715e4a2b56257cef0020ca5f2 Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Sat, 11 Oct 2025 22:07:43 +0200 Subject: [PATCH 38/46] set edited_gain_fx to Q31 in IVAS_DEC_GetSamplesDecoder() --- lib_com/ivas_stat_com.h | 4 ++-- lib_dec/lib_dec_fx.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 985f6a52d..1f7ea778d 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; /* Q30 */ + Word32 gain_fx; /* Q31 */ 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; /* Q30 */ + Word32 edited_gain_fx; /* Q31 */ #endif Word16 non_diegetic_flag; /* Non-diegetic (non-headtracked) object flag */ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 117ea6041..c97c937b0 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -3902,12 +3902,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_Q30; + hIsmMetaData[obj]->edited_gain_fx = ONE_IN_Q31; } IF( hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { - hIvasDec->st_ivas->hSbaIsmData->gain_bed_fx = ONE_IN_Q30; + hIvasDec->st_ivas->hSbaIsmData->gain_bed_fx = ONE_IN_Q31; } } } -- GitLab From 2b8cc71f459d1f91e65f1aafe380f5010a4a8f6b Mon Sep 17 00:00:00 2001 From: lintervo Date: Sun, 12 Oct 2025 18:13:20 +0300 Subject: [PATCH 39/46] Disable gain editing related code due to the caused differences --- lib_dec/ivas_dirac_dec_fx.c | 3 ++- lib_dec/ivas_ism_param_dec_fx.c | 9 ++++++--- lib_dec/ivas_ism_renderer_fx.c | 3 ++- lib_dec/ivas_jbm_dec_fx.c | 3 ++- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index 770b6fb36..6d36b3429 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -3838,7 +3838,8 @@ 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 - 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: 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 #endif } } diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 831ce431c..c8b7038d7 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -986,7 +986,8 @@ 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(); - 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: 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 #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] ); @@ -1034,7 +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 - 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: 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 ); #endif } } @@ -1047,7 +1049,8 @@ 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 - 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: 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 #endif } } diff --git a/lib_dec/ivas_ism_renderer_fx.c b/lib_dec/ivas_ism_renderer_fx.c index ef16c3aa3..36234bf47 100644 --- a/lib_dec/ivas_ism_renderer_fx.c +++ b/lib_dec/ivas_ism_renderer_fx.c @@ -278,7 +278,8 @@ 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 - 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: 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 #endif } } diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index b42217efd..7e455dde5 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2262,7 +2262,8 @@ ivas_error ivas_jbm_dec_render_fx( { Word32 gain = st_ivas->hSbaIsmData->gain_bed_fx; test(); - IF( NE_32( gain, ONE_IN_Q30 ) && GT_32( gain, 0 ) ) + // TODO: Enable gain editing feature (NE_32 ( gain, ONE_IN_Q_gain ) ) + IF( NE_32( gain, ONE_IN_Q31 ) && GT_32( gain, 0 ) ) { FOR( n = 0; n < nchan_out; n++ ) { -- GitLab From a4107adc54a70fdc3846c5562b040e1daf56090c Mon Sep 17 00:00:00 2001 From: lintervo Date: Sun, 12 Oct 2025 18:16:53 +0300 Subject: [PATCH 40/46] Clang format --- 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 c8b7038d7..79a4fc4c9 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -987,7 +987,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: 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 + // 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 #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] ); -- GitLab From 85ec41dda22ff85990edb22e44796a16097db8e8 Mon Sep 17 00:00:00 2001 From: lintervo Date: Sun, 12 Oct 2025 20:06:57 +0300 Subject: [PATCH 41/46] Add forgotten code --- lib_dec/ivas_jbm_dec_fx.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 7e455dde5..767979d8a 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -4671,6 +4671,31 @@ void ivas_jbm_dec_prepare_renderer( } ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMMC ) ) { + Word16 nchan_transport = st_ivas->nchan_transport; + move16(); + Word16 nchan_out_transport = add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ); + Word16 nchan_out_cov; + test(); + test(); + IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + { + nchan_out_cov = add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ); + } + ELSE IF( EQ_16( st_ivas->hParamMC->synthesis_conf, PARAM_MC_SYNTH_LS_CONV_CLDFB ) ) + { + nchan_out_cov = nchan_out_transport; + move16(); + } + ELSE IF( EQ_16( st_ivas->hParamMC->synthesis_conf, PARAM_MC_SYNTH_LS_CONV_COV ) || EQ_16( st_ivas->hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) + { + nchan_out_cov = add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ); + } + ELSE + { + nchan_out_cov = nchan_out_transport; + move16(); + } + scale_sig32( st_ivas->hParamMC->proto_matrix_int_fx, st_ivas->hParamMC->proto_matrix_int_len, -1 ); // Q(31-1) st_ivas->hParamMC->proto_matrix_int_e = 1; move16(); @@ -4678,6 +4703,20 @@ void ivas_jbm_dec_prepare_renderer( ivas_param_mc_dec_prepare_renderer( st_ivas, (UWord8) n_render_timeslots ); scale_sig32( st_ivas->hParamMC->proto_matrix_int_fx, st_ivas->hParamMC->proto_matrix_int_len, 1 ); // Q(31-1+1) + + Word16 shift; + FOR( Word16 param_band_idx = 0; param_band_idx < st_ivas->hParamMC->num_param_bands_synth; param_band_idx++ ) + { + shift = getScaleFactor32( st_ivas->hParamMC->h_output_synthesis_cov_state.cx_old_fx[param_band_idx], s_min( st_ivas->hParamMC->h_output_synthesis_cov_state.cx_old_len, nchan_transport * nchan_transport ) ); + scale_sig32( st_ivas->hParamMC->h_output_synthesis_cov_state.cx_old_fx[param_band_idx], s_min( st_ivas->hParamMC->h_output_synthesis_cov_state.cx_old_len, i_mult( nchan_transport, nchan_transport ) ), shift ); // Q(31-cx_old_e+shift) + st_ivas->hParamMC->h_output_synthesis_cov_state.cx_old_e[param_band_idx] = sub( st_ivas->hParamMC->h_output_synthesis_cov_state.cx_old_e[param_band_idx], shift ); + move16(); + + shift = getScaleFactor32( st_ivas->hParamMC->h_output_synthesis_cov_state.cy_old_fx[param_band_idx], nchan_out_cov * nchan_out_cov ); + scale_sig32( st_ivas->hParamMC->h_output_synthesis_cov_state.cy_old_fx[param_band_idx], i_mult( nchan_out_cov, nchan_out_cov ), shift ); // Q(31-cy_old_e+shift) + st_ivas->hParamMC->h_output_synthesis_cov_state.cy_old_e[param_band_idx] = sub( st_ivas->hParamMC->h_output_synthesis_cov_state.cy_old_e[param_band_idx], shift ); + move16(); + } } ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) ) { -- GitLab From ed6a09a2393a97352ab2b0fac94b84765f21129c Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Sun, 12 Oct 2025 21:13:15 +0200 Subject: [PATCH 42/46] fix error from porting --- lib_dec/lib_dec_fx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index c97c937b0..f7af2932d 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1347,15 +1347,15 @@ ivas_error IVAS_DEC_GetSamples( move16(); } #else - nOutChannels = (uint8_t) hIvasDec->st_ivas->hDecoderConfig->nchan_out; + nOutChannels = (UWord8) hIvasDec->st_ivas->hDecoderConfig->nchan_out; hIvasDec->hasBeenFedFrame = false; /* check for possible flushed samples from a rate switch */ - if ( hIvasDec->nSamplesFlushed > 0 ) + IF( GE_16( hIvasDec->nSamplesFlushed, 0 ) ) { /* note: offset (rendered samples) is always 0 */ - Copy( hIvasDec->flushbuffer, pcmBuf, hIvasDec->nSamplesFlushed * nOutChannels ); + Copy( hIvasDec->flushbuffer, pcmBuf, imult1616( hIvasDec->nSamplesFlushed, nOutChannels ) ); - hIvasDec->nSamplesRendered = hIvasDec->nSamplesFlushed; + nSamplesRendered = add( nSamplesRendered, hIvasDec->nSamplesFlushed ); hIvasDec->nSamplesFlushed = 0; move16(); move16(); -- GitLab From 6feb2babed57dec774a78ad39943fc7dc37d7a0b Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 13 Oct 2025 10:52:56 +0200 Subject: [PATCH 43/46] insert correct BASOP instrumentation in ivas_param_ism_dec_dequant_md_fx --- lib_dec/ivas_ism_param_dec_fx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 79a4fc4c9..9ff239df5 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -1322,15 +1322,17 @@ void ivas_param_ism_dec_dequant_md_fx( Decoder_Struct *st_ivas ) { /* De-quantization */ - if ( !( st_ivas->hDecoderConfig->ivas_total_brate == IVAS_SID_5k2 || st_ivas->hDecoderConfig->ivas_total_brate == FRAME_NO_DATA ) ) + IF ( !( EQ_16(st_ivas->hDecoderConfig->ivas_total_brate, IVAS_SID_5k2) || EQ_16(st_ivas->hDecoderConfig->ivas_total_brate, FRAME_NO_DATA ) ) ) { ivas_param_ism_dec_dequant_DOA_fx( st_ivas->hParamIsmDec, st_ivas->nchan_ism ); ivas_param_ism_dec_dequant_powrat_fx( st_ivas->hParamIsmDec ); st_ivas->hISMDTX.dtx_flag = 0; + move16(); } - else + ELSE { st_ivas->hISMDTX.dtx_flag = 1; + move16(); } return; -- GitLab From f1d73141b1795102e1304eea8f03715bdd6bd680 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 13 Oct 2025 10:55:06 +0200 Subject: [PATCH 44/46] 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 9ff239df5..1aa56c078 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -1322,7 +1322,7 @@ void ivas_param_ism_dec_dequant_md_fx( Decoder_Struct *st_ivas ) { /* De-quantization */ - IF ( !( EQ_16(st_ivas->hDecoderConfig->ivas_total_brate, IVAS_SID_5k2) || EQ_16(st_ivas->hDecoderConfig->ivas_total_brate, FRAME_NO_DATA ) ) ) + IF( !( EQ_16( st_ivas->hDecoderConfig->ivas_total_brate, IVAS_SID_5k2 ) || EQ_16( st_ivas->hDecoderConfig->ivas_total_brate, FRAME_NO_DATA ) ) ) { ivas_param_ism_dec_dequant_DOA_fx( st_ivas->hParamIsmDec, st_ivas->nchan_ism ); ivas_param_ism_dec_dequant_powrat_fx( st_ivas->hParamIsmDec ); -- GitLab From 68019414ff96122a8f1c9e3c4beb3a4fa4ffd89d Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 13 Oct 2025 11:44:47 +0200 Subject: [PATCH 45/46] fix encapsulation in ivas_ism_param_dec_fx.c --- lib_dec/ivas_ism_param_dec_fx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 1aa56c078..8d076c7eb 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -2050,8 +2050,8 @@ void ivas_param_ism_params_to_masa_param_mapping_fx( FOR( band_idx = 0; band_idx < hParamIsmDec->hParamIsm->nbands; band_idx++ ) { brange[0] = hParamIsmDec->hParamIsm->band_grouping[band_idx]; -#ifdef OBJ_EDITING_API move16(); +#ifdef OBJ_EDITING_API brange[1] = hParamIsmDec->hParamIsm->band_grouping[band_idx + 1]; move16(); @@ -2060,7 +2060,6 @@ void ivas_param_ism_params_to_masa_param_mapping_fx( 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 - move16(); brange[1] = hParamIsmDec->hParamIsm->band_grouping[band_idx + 1]; move16(); -- GitLab From 2ba931fca4aa2d5de63136da0086a89754cc5c33 Mon Sep 17 00:00:00 2001 From: naghibza Date: Mon, 13 Oct 2025 11:45:25 +0200 Subject: [PATCH 46/46] change IF conditions to follow BASOP rules. --- lib_dec/ivas_ism_param_dec_fx.c | 2 +- lib_dec/lib_dec_fx.c | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 1aa56c078..d02e49aaa 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -1322,7 +1322,7 @@ void ivas_param_ism_dec_dequant_md_fx( Decoder_Struct *st_ivas ) { /* De-quantization */ - IF( !( EQ_16( st_ivas->hDecoderConfig->ivas_total_brate, IVAS_SID_5k2 ) || EQ_16( st_ivas->hDecoderConfig->ivas_total_brate, FRAME_NO_DATA ) ) ) + IF( !( EQ_32( st_ivas->hDecoderConfig->ivas_total_brate, IVAS_SID_5k2 ) || EQ_32( st_ivas->hDecoderConfig->ivas_total_brate, FRAME_NO_DATA ) ) ) { ivas_param_ism_dec_dequant_DOA_fx( st_ivas->hParamIsmDec, st_ivas->nchan_ism ); ivas_param_ism_dec_dequant_powrat_fx( st_ivas->hParamIsmDec ); diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index f7af2932d..051876ff9 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -438,7 +438,7 @@ void IVAS_DEC_Close( free( ( *phIvasDec )->apaExecBuffer_fx ); } #ifdef OBJ_EDITING_API - if ( ( *phIvasDec )->flushbuffer != NULL ) + IF( ( *phIvasDec )->flushbuffer != NULL ) { free( ( *phIvasDec )->flushbuffer ); } @@ -653,7 +653,7 @@ ivas_error IVAS_DEC_Configure( test(); test(); test(); - if ( tsmEnabled && ( outputConfig == IVAS_AUDIO_CONFIG_BINAURAL || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) + IF( tsmEnabled && ( EQ_32( outputConfig, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || EQ_32( outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) { hIvasDec->flushbuffer = (void *) malloc( CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( Word16 ) ); set16_fx( (Word16 *) hIvasDec->flushbuffer, 0, CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); @@ -989,7 +989,7 @@ ivas_error IVAS_DEC_EnableVoIP( #endif #ifdef OBJ_EDITING_API - if ( hIvasDec->flushbuffer == NULL && ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) + IF( hIvasDec->flushbuffer == NULL && ( EQ_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) { hIvasDec->flushbuffer = (void *) malloc( CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( Word16 ) ); set16_fx( (Word16 *) hIvasDec->flushbuffer, 0, CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); @@ -1474,7 +1474,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( #ifdef OBJ_EDITING_API /* init flush buffer for rate switch if not already initizalized */ - if ( hIvasDec->flushbuffer == NULL ) + IF( hIvasDec->flushbuffer == NULL ) { hIvasDec->flushbuffer = (void *) malloc( numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( float ) ); set16_fx( (Word16 *) hIvasDec->flushbuffer, 0, numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); @@ -2293,7 +2293,7 @@ ivas_error IVAS_DEC_GetObjectMetadata( ELSE { #ifdef OBJ_EDITING_API - if ( st_ivas->ism_mode == ISM_MODE_DISC ) + IF( EQ_32( st_ivas->ism_mode, ISM_MODE_DISC ) ) { metadata->azimuth_fx = hIsmMeta->edited_azimuth_fx; metadata->elevation_fx = hIsmMeta->edited_elevation_fx; @@ -2306,7 +2306,7 @@ ivas_error IVAS_DEC_GetObjectMetadata( metadata->gainFactor_fx = hIsmMeta->edited_gain_fx; metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; } - else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) + ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) ) { metadata->azimuth_fx = st_ivas->hParamIsmDec->edited_azimuth_values_fx[objectIdx]; metadata->elevation_fx = st_ivas->hParamIsmDec->edited_elevation_values_fx[objectIdx]; @@ -2317,7 +2317,7 @@ ivas_error IVAS_DEC_GetObjectMetadata( metadata->gainFactor_fx = ONE_IN_Q31; metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; } - else if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC || st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + ELSE IF( EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) || EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) { metadata->azimuth_fx = st_ivas->hIsmMetaData[objectIdx]->edited_azimuth_fx; metadata->elevation_fx = st_ivas->hIsmMetaData[objectIdx]->edited_elevation_fx; @@ -4417,10 +4417,10 @@ ivas_error IVAS_DEC_VoIP_GetSamples( #ifdef OBJ_EDITING_API /* check if we still need to prepare the renderer */ - if ( hIvasDec->hasBeenPreparedRendering == false ) + IF( hIvasDec->hasBeenPreparedRendering == false ) { - if ( ( error = IVAS_DEC_PrepareRenderer( hIvasDec ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = IVAS_DEC_PrepareRenderer( hIvasDec ) ), IVAS_ERR_OK ) ) { return error; } -- GitLab