From 445cb5ec972413777b84a52fec3ef214a85c18de Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 15 Aug 2025 13:18:59 +0200 Subject: [PATCH 1/7] port CR --- apps/renderer.c | 28 +++++ lib_com/bitstream_fx.c | 2 - lib_com/ivas_prot_fx.h | 20 ++-- lib_com/options.h | 1 + lib_dec/ivas_init_dec_fx.c | 6 +- lib_dec/ivas_mct_dec_fx.c | 5 +- lib_dec/ivas_objectRenderer_internal_fx.c | 3 + lib_dec/ivas_stat_dec.h | 79 ++++++------ lib_dec/lib_dec_fx.c | 8 +- lib_rend/ivas_objectRenderer_fx.c | 5 +- lib_rend/ivas_prot_rend_fx.h | 50 ++++---- lib_rend/lib_rend.h | 18 +-- lib_rend/lib_rend_fx.c | 139 ++++++++++++++++------ 13 files changed, 240 insertions(+), 124 deletions(-) diff --git a/apps/renderer.c b/apps/renderer.c index f317178b9..1fdf465b8 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -174,6 +174,10 @@ typedef struct char customHrtfFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; char renderConfigFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; int8_t orientation_tracking; +#ifdef FIX_1135_EXT_RENDERER_HANDLES + int16_t Opt_Headrotation; + int16_t Opt_ExternalOrientation; +#endif int16_t nonDiegeticPan; float nonDiegeticPanGain; IVAS_REND_COMPLEXITY_LEVEL complexityLevel; @@ -979,7 +983,12 @@ int main( Word32 nonDiegeticPanGain_fx = ( args.nonDiegeticPanGain == 1.0f ) ? ONE_IN_Q31 : ( args.nonDiegeticPanGain == -1.0f ) ? L_negate( ONE_IN_Q31 ) : (Word32) ( args.nonDiegeticPanGain * ( 1LL << Q31 ) ); + +#ifdef FIX_1135_EXT_RENDERER_HANDLES + IF( ( error = IVAS_REND_Open( &hIvasRend, args.sampleRate, args.outConfig.audioConfig, !isEmptyString( args.customHrtfFilePath ), args.nonDiegeticPan, nonDiegeticPanGain_fx, args.Opt_Headrotation, args.Opt_ExternalOrientation, (int16_t) args.render_framesize ) ) != IVAS_ERR_OK ) +#else IF( ( error = IVAS_REND_Open( &hIvasRend, args.sampleRate, args.outConfig.audioConfig, !isEmptyString( args.customHrtfFilePath ), args.nonDiegeticPan, nonDiegeticPanGain_fx, (int16_t) args.render_framesize ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nError opening renderer handle: %s\n", ivas_error_to_string( error ) ); goto cleanup; @@ -2757,7 +2766,13 @@ static CmdlnArgs defaultArgs( clearString( args.renderConfigFilePath ); clearString( args.externalOrientationFilePath ); +#ifdef FIX_1135_EXT_RENDERER_HANDLES + args.Opt_Headrotation = 0; + args.Opt_ExternalOrientation = 0; +#endif + args.orientation_tracking = IVAS_HEAD_ORIENT_TRK_NONE; + args.nonDiegeticPan = 0; args.nonDiegeticPanGain = 0.f; @@ -2849,6 +2864,9 @@ static void parseOption( break; case CmdLnOptionId_trajFile: assert( numOptionValues == 1 ); +#ifdef FIX_1135_EXT_RENDERER_HANDLES + args->Opt_Headrotation = 1; +#endif strncpy( args->headRotationFilePath, optionValues[0], RENDERER_MAX_CLI_ARG_LENGTH - 1 ); break; case CmdLnOptionId_outputMetadata: @@ -2869,6 +2887,9 @@ static void parseOption( break; case CmdLnOptionId_exteriorOrientationFile: assert( numOptionValues == 1 ); +#ifdef FIX_1135_EXT_RENDERER_HANDLES + args->Opt_ExternalOrientation = 1; +#endif strncpy( args->externalOrientationFilePath, optionValues[0], RENDERER_MAX_CLI_ARG_LENGTH - 1 ); break; case CmdLnOptionId_customHrtfFile: @@ -3002,6 +3023,13 @@ static CmdlnArgs parseCmdlnArgs( exit( -1 ); /* Error printout handled by failing function */ } +#ifdef FIX_1135_EXT_RENDERER_HANDLES + if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + args.Opt_Headrotation = 1; + } +#endif + return args; } diff --git a/lib_com/bitstream_fx.c b/lib_com/bitstream_fx.c index 77ce24079..6b0883202 100644 --- a/lib_com/bitstream_fx.c +++ b/lib_com/bitstream_fx.c @@ -4461,8 +4461,6 @@ ivas_error read_indices_fx( st_ivas->BER_detect = 0; move16(); - st_ivas->num_bits = num_bits; - move16(); sts = reset_elements( st_ivas ); #ifdef DEBUGGING diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 337fb72a9..35122ea4f 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -4017,12 +4017,14 @@ void sns_avq_dec_stereo_fx( Word32 *SNS_Ql, /* o : Quantized SNS vectors (left channel) */ Word16 *q_l, Word32 *SNS_Qr, /* o : Quantized SNS vectors (right channe) */ - Word16 *q_r ); + Word16 *q_r +); void dequantize_sns_fx( Word16 indices[CPE_CHANNELS][NPRM_LPC_NEW], Word32 snsQ_out[CPE_CHANNELS][NB_DIV][M], - Decoder_State **sts ); + Decoder_State **sts +); void inverseMS_fx( const Word16 L_frame, /* i : frame length Q0*/ @@ -4038,7 +4040,6 @@ void ivas_syn_output_f_fx( Word32 *synth_out /* o : integer 16 bits synthesis signal */ ); - ivas_error ivas_init_encoder_fx( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ ); @@ -4134,7 +4135,8 @@ Word16 ivas_smc_gmm_fx( const Word16 flag_spitch, /* i : flag to indicate very short stable pitch */ Word16 Qfact_PS, Word16 Q_esp, - Word16 Qfact_PS_past ); + Word16 Qfact_PS_past +); void ivas_signaling_enc_fx( Encoder_State *st, /* i/o: encoder state structure */ @@ -4180,12 +4182,13 @@ void TonalMdctConceal_create_concealment_noise_ivas_fx( const Word16 subframe_idx, const Word16 core, const Word16 crossfade_gain, - const TONALMDCTCONC_NOISE_GEN_MODE noise_gen_mode ); - + const TONALMDCTCONC_NOISE_GEN_MODE noise_gen_mode +); Word16 rand_triangular_signed_fx( Word16 *seed, - Word16 *exp_fac ); + Word16 *exp_fac +); Word64 var_32_fx( const Word32 *x, /* i : input vector */ @@ -4195,7 +4198,8 @@ Word64 var_32_fx( ivas_error ivas_jbm_dec_tc_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - Word32 *data_fx ); + Word32 *data_fx +); ivas_error ivas_jbm_dec_flush_renderer_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ diff --git a/lib_com/options.h b/lib_com/options.h index 6857f4c95..7ce13b469 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -141,6 +141,7 @@ #define NONBE_1360_LFE_DELAY /* Dlb: LFE delay alignment when rendering in CLDFB domain*/ #define NONBE_1229_FIX_ISM1_DPID /* Eri: issue 1229: fix bug causing ISM 1 to use default -dpid instead of the specified one */ +#define FIX_1135_EXT_RENDERER_HANDLES /* VA: issue 1135: Memory usage reduction in external renderer: Allocate only handles that are really needed. */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 667b9dc32..3b01824e0 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -2732,8 +2732,7 @@ ivas_error ivas_init_decoder_fx( /*-----------------------------------------------------------------* * Allocate floating-point output audio buffers *-----------------------------------------------------------------*/ - st_ivas->p_out_len = ivas_get_nchan_buffers_dec_fx( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); - move16(); + FOR( n = 0; n < ivas_get_nchan_buffers_dec_fx( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); n++ ) { /* note: these are intra-frame heap memories */ @@ -2743,14 +2742,15 @@ ivas_error ivas_init_decoder_fx( } set32_fx( st_ivas->p_output_fx[n], 0, 48000 / FRAMES_PER_SEC ); } - FOR( ; n < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; n++ ) { st_ivas->p_output_fx[n] = NULL; } + return error; } + /*------------------------------------------------------------------------- * destroy_core_dec() * diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index cdb117820..af49f142a 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -1503,7 +1503,10 @@ static ivas_error ivas_mc_dec_reconfig_fx( } ELSE IF( st_ivas->hBinRendererTd == NULL && EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) ) { - IF( ( error = ivas_td_binaural_open_fx( st_ivas, &st_ivas->SrcInd[0], &st_ivas->num_src ) ) != IVAS_ERR_OK ) + Word16 num_src; + Word16 SrcInd[MAX_NUM_TDREND_CHANNELS]; + + IF( ( error = ivas_td_binaural_open_fx( st_ivas, SrcInd, &num_src ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_objectRenderer_internal_fx.c b/lib_dec/ivas_objectRenderer_internal_fx.c index e64e9d220..8f7b51a1c 100644 --- a/lib_dec/ivas_objectRenderer_internal_fx.c +++ b/lib_dec/ivas_objectRenderer_internal_fx.c @@ -46,6 +46,7 @@ * * Open and initialize TD Object binaural renderer *---------------------------------------------------------------------*/ + ivas_error ivas_td_binaural_open_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ Word16 *SrcInd, /*Temporarily used to store the updated value of SrcInd*/ @@ -53,12 +54,14 @@ ivas_error ivas_td_binaural_open_fx( { *num_src = st_ivas->nchan_transport; move16(); + test(); if ( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) || EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) { *num_src = st_ivas->nchan_ism; move16(); } + #ifdef CONF_DISTATT return ivas_td_binaural_open_unwrap_fx( &st_ivas->hHrtfTD, st_ivas->hDecoderConfig->output_Fs, *num_src, st_ivas->ivas_format, st_ivas->transport_config, st_ivas->hRenderConfig->directivity_fx, st_ivas->hRenderConfig->distAtt_fx, st_ivas->hTransSetup, &st_ivas->hBinRendererTd, &st_ivas->binaural_latency_ns, SrcInd ); #else diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 39d42ee86..6a105d622 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1038,23 +1038,23 @@ typedef struct jbm_metadata_structure typedef struct decoder_config_structure { - Word32 ivas_total_brate; /* IVAS total bitrate in bps */ - Word32 last_ivas_total_brate; /* last IVAS total bitrate in bps */ - Word32 output_Fs; /* output signal sampling frequency in Hz */ - Word16 nchan_out; /* number of output audio channels */ - AUDIO_CONFIG output_config; /* output audio configuration */ - Word16 Opt_LsCustom; /* indicates whether loudspeaker custom setup is used */ - Word16 Opt_HRTF_binary; /* indicates whether HRTF binary file is used */ - Word16 Opt_Headrotation; /* indicates whether head-rotation is used */ - Word16 Opt_RendConfigCustom; /* indicates whether Renderer configuration custom setup is used */ - IVAS_HEAD_ORIENT_TRK_T orientation_tracking; /* indicates orientation tracking type */ - Word16 Opt_non_diegetic_pan; /* indicates diegetic or not */ - Word16 non_diegetic_pan_gain_fx; /* non diegetic panning gain*/ /* Q15 */ - Word16 Opt_AMR_WB; /* flag indicating AMR-WB IO mode */ - Word16 Opt_ExternalOrientation; /* indiates whether external orientations are used */ - Word16 Opt_dpid_on; /* indicates whether Directivity pattern option is used */ - Word16 Opt_aeid_on; /* indicates whether Acoustic environment option is used */ - Word16 Opt_tsm; /* indicates whether time scaling modification is activated */ + Word32 ivas_total_brate; /* IVAS total bitrate in bps */ + Word32 last_ivas_total_brate; /* last IVAS total bitrate in bps */ + Word32 output_Fs; /* output signal sampling frequency in Hz */ + Word16 nchan_out; /* number of output audio channels */ + AUDIO_CONFIG output_config; /* output audio configuration */ + Word16 Opt_LsCustom; /* indicates whether loudspeaker custom setup is used */ + Word16 Opt_HRTF_binary; /* indicates whether HRTF binary file is used */ + Word16 Opt_Headrotation; /* indicates whether head-rotation is used */ + Word16 Opt_RendConfigCustom; /* indicates whether Renderer configuration custom setup is used */ + IVAS_HEAD_ORIENT_TRK_T orientation_tracking; /* indicates orientation tracking type */ + Word16 Opt_non_diegetic_pan; /* indicates diegetic or not */ + Word16 non_diegetic_pan_gain_fx; /* non diegetic panning gain, Q15 */ + Word16 Opt_AMR_WB; /* flag indicating AMR-WB IO mode */ + Word16 Opt_ExternalOrientation; /* indicates whether external orientations are used */ + Word16 Opt_dpid_on; /* indicates whether Directivity pattern option is used */ + Word16 Opt_aeid_on; /* indicates whether Acoustic environment option is used */ + Word16 Opt_tsm; /* indicates whether time scaling modification is activated */ IVAS_RENDER_FRAMESIZE render_framesize; Word16 Opt_delay_comp; /* flag indicating delay compensation active */ @@ -1075,8 +1075,8 @@ typedef struct Decoder_Struct IVAS_FORMAT ivas_format; /* IVAS format */ IVAS_FORMAT last_ivas_format; /* last frame IVAS format */ - Word16 sid_format; /* IVAS format indicator from SID frame */ - Word16 nchan_transport; /* number of transport channels */ + Word16 sid_format; /* IVAS format indicator from SID frame */ + Word16 nchan_transport; /* number of transport channels */ IVAS_OUTPUT_SETUP hOutSetup; /* output setup structure */ AUDIO_CONFIG intern_config; /* internal audio configuration */ IVAS_OUTPUT_SETUP hIntSetup; /* internal setup structure */ @@ -1084,24 +1084,26 @@ typedef struct Decoder_Struct AUDIO_CONFIG transport_config; /* transport audio configuration */ IVAS_OUTPUT_SETUP hTransSetup; /* transport setup structure */ - Word16 element_mode_init; /* element mode used at initialization */ - Word16 codec_mode; /* Mode 1 or 2 */ - Word16 ini_frame; /* initialization frames counter */ - Word16 ini_active_frame; /* initialization active frames counter */ + Word16 element_mode_init; /* element mode used at initialization */ + Word16 codec_mode; /* Mode 1 or 2 */ + Word16 ini_frame; /* initialization frames counter */ + Word16 ini_active_frame; /* initialization active frames counter */ - Word16 bfi; /* FEC - bad frame indicator */ - Word16 BER_detect; /* BER detect flag */ - Word16 num_bits; /* BER detect flag */ + Word16 bfi; /* FEC - bad frame indicator */ + Word16 BER_detect; /* BER detect flag */ - UWord16 *bit_stream; /* Pointer to bitstream buffer */ - Word16 writeFECoffset; /* parameter for debugging JBM stuff */ + UWord16 *bit_stream; /* Pointer to bitstream buffer */ + Word16 writeFECoffset; /* parameter for debugging JBM stuff */ + + Word32 **mem_hp20_out_fx; /* output signals HP filter memories */ IVAS_LIMITER_HANDLE hLimiter; /* Limiter handle */ + Word32 *p_output_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; /* Word32-output audio buffers */ /* core-decoder modules */ - Word16 nSCE; /* number of total SCEs */ - Word16 nCPE; /* number of total CPEs */ - Word16 nCPE_old; /* number of total CPEs available in the last frame before bitrate switching */ + Word16 nSCE; /* number of total SCEs */ + Word16 nCPE; /* number of total CPEs */ + Word16 nCPE_old; /* number of total CPEs available in the last frame before bitrate switching */ SCE_DEC_HANDLE hSCE[MAX_SCE]; /* SCE handles */ CPE_DEC_HANDLE hCPE[MCT_MAX_BLOCKS]; /* CPE handles */ @@ -1120,12 +1122,12 @@ typedef struct Decoder_Struct LFE_DEC_HANDLE hLFE; /* LFE handle */ ISM_MODE ism_mode; /* ISM format mode */ - Word16 nchan_ism; /* number of ISM channels */ + Word16 nchan_ism; /* number of ISM channels */ MC_MODE mc_mode; /* MC format mode */ - Word16 sba_order; /* Ambisonic (SBA) order */ - Word16 sba_planar; /* Ambisonic (SBA) planar flag */ - Word16 sba_analysis_order; /* Ambisonic (SBA) order used for analysis and coding */ - Word16 sba_dirac_stereo_flag; /* flag indicating stereo output for SBA DirAC modes with 1 TC */ + Word16 sba_order; /* Ambisonic (SBA) order */ + Word16 sba_planar; /* Ambisonic (SBA) planar flag */ + Word16 sba_analysis_order; /* Ambisonic (SBA) order used for analysis and coding */ + Word16 sba_dirac_stereo_flag; /* flag indicating stereo output for SBA DirAC modes with 1 TC */ /* rendering modules */ RENDERER_TYPE renderer_type; /* renderer type */ @@ -1169,11 +1171,6 @@ typedef struct Decoder_Struct Word32 last_active_ivas_total_brate; Word16 ism_extmeta_active; /* Extended metadata active in decoder */ Word16 ism_extmeta_cnt; /* Change frame counter for extended metadata */ - Word32 **mem_hp20_out_fx; - Word32 *p_output_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; /* Word32-output audio buffers */ - Word16 p_out_len; /*Stores the total no of channels for which memory is allocated to p_output_fx*/ - Word16 num_src; - Word16 SrcInd[MAX_NUM_TDREND_CHANNELS]; } Decoder_Struct; diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index ccd24ad4c..d031fb357 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -574,6 +574,7 @@ ivas_error IVAS_DEC_Configure( { return IVAS_ERR_WRONG_PARAMS; } + IF( EQ_16( outputConfig, IVAS_AUDIO_CONFIG_EXTERNAL ) ) { hDecoderConfig->render_framesize = IVAS_RENDER_FRAMESIZE_20MS; @@ -582,15 +583,15 @@ ivas_error IVAS_DEC_Configure( { hDecoderConfig->render_framesize = renderFramesize; } - move16(); +#ifndef FIX_1135_EXT_RENDERER_HANDLES IF( EQ_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { hDecoderConfig->Opt_Headrotation = TRUE; move16(); } - +#endif /* Set decoder parameters to initial values */ IF( NE_32( ( error = ivas_init_decoder_front( st_ivas ) ), IVAS_ERR_OK ) ) { @@ -3983,11 +3984,10 @@ static ivas_error evs_dec_main_fx( hCoreCoder = st_ivas->hSCE[0]->hCoreCoder; hCoreCoder[0]->total_brate = st_ivas->hDecoderConfig->ivas_total_brate; - hCoreCoder[0]->total_num_bits = st_ivas->num_bits; - move16(); move32(); hCoreCoder[0]->output_frame_fx = extract_l( Mult_32_16( hCoreCoder[0]->output_Fs, 0x0290 /*Q0*/ ) ); // Q0 move16(); + mdct_switching_dec_fx( hCoreCoder[0] ); FOR( ch = 0; ch < MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN; ch++ ) diff --git a/lib_rend/ivas_objectRenderer_fx.c b/lib_rend/ivas_objectRenderer_fx.c index bfd856656..210095dd8 100644 --- a/lib_rend/ivas_objectRenderer_fx.c +++ b/lib_rend/ivas_objectRenderer_fx.c @@ -794,6 +794,7 @@ ivas_error TDREND_Update_listener_orientation_fx( * * *---------------------------------------------------------------------*/ + ivas_error ivas_td_binaural_open_ext_fx( TDREND_WRAPPER *pTDRend, AUDIO_CONFIG inConfig, @@ -808,7 +809,6 @@ ivas_error ivas_td_binaural_open_ext_fx( IVAS_FORMAT ivas_format; IVAS_OUTPUT_SETUP hTransSetup; ivas_error error; - #ifdef CONF_DISTATT Word32 *distAtt_fx = NULL; #endif @@ -857,12 +857,15 @@ ivas_error ivas_td_binaural_open_ext_fx( distAtt_fx = hRendCfg->distAtt_fx; #endif } + #ifdef CONF_DISTATT return ivas_td_binaural_open_unwrap_fx( pTDRend->hHrtfTD, outFs, nchan_transport, ivas_format, transport_config, directivity_fx, distAtt_fx, hTransSetup, &pTDRend->hBinRendererTd, &pTDRend->binaural_latency_ns, SrcInd ); #else return ivas_td_binaural_open_unwrap_fx( pTDRend->hHrtfTD, outFs, nchan_transport, ivas_format, transport_config, directivity_fx, hTransSetup, &pTDRend->hBinRendererTd, &pTDRend->binaural_latency_ns, SrcInd ); #endif } + + /*---------------------------------------------------------------------* * ivas_td_binaural_renderer_ext() * diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index 566914f2f..ba15f73ed 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -746,16 +746,18 @@ ivas_error TDREND_MIX_SRC_SetPos_fx( ); ivas_error TDREND_MIX_SRC_SetDir_fx( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - const Word16 SrcInd, /* i : Source index */ - const Word32 *Vec_p, /* i : Direction vector */ - const Word16 Vec_p_q /* i : Direction vector q */ + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ + const Word16 SrcInd, /* i : Source index */ + const Word32 *Vec_p, /* i : Direction vector */ + const Word16 Vec_p_q /* i : Direction vector q */ ); + ivas_error TDREND_MIX_SRC_SetDirAtten_fx( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - const Word16 SrcInd, /* i : Source index */ + const Word16 SrcInd, /* i : Source index */ const TDREND_DirAtten_t *DirAtten_p /* i : Directional attenuation specifier */ ); + #ifdef CONF_DISTATT ivas_error TDREND_MIX_SRC_SetDistAtten( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ @@ -763,30 +765,32 @@ ivas_error TDREND_MIX_SRC_SetDistAtten( const TDREND_DistAtten_t *DistAtten_p /* i : Distance attenuation specifier */ ); #endif + ivas_error TDREND_MIX_SRC_SetPlayState( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - const Word16 SrcInd, /* i : Source index */ + const Word16 SrcInd, /* i : Source index */ const TDREND_PlayStatus_t PlayStatus /* i : Play state */ ); void TDREND_SRC_REND_UpdateFiltersFromSpatialParams_fx( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - TDREND_SRC_REND_t *SrcRend_p, /* i/o: Source object */ - TDREND_SRC_SPATIAL_t *SrcSpatial_p, /* i : Spatial aspects of source */ - Word32 *hrf_left_prev, /* i/o: Left filter */ - Word16 *hrf_left_prev_e, /* i/o: Left filter exponent */ - Word32 *hrf_right_prev, /* i/o: Right filter */ - Word16 *hrf_right_prev_e, /* i/o: Right filter exponent */ - Word32 *hrf_left_delta, /* o : Left filter interpolation delta */ - Word16 *hrf_left_delta_e, /* o : Left filter interpolation delta exponent */ - Word32 *hrf_right_delta, /* o : Right filter interpolation delta */ - Word16 *hrf_right_delta_e, /* o : Right filter interpolation delta exponent */ - Word16 *intp_count, /* o : Interpolation count */ - Word16 *filterlength, /* o : Length of filters */ - Word16 *itd, /* o : ITD value */ - Word32 *Gain, /* o : Gain value Q30 */ - TDREND_SRC_t *Src_p, /* i/o: Source pointer */ - const Word16 subframe_update_flag); + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ + TDREND_SRC_REND_t *SrcRend_p, /* i/o: Source object */ + TDREND_SRC_SPATIAL_t *SrcSpatial_p, /* i : Spatial aspects of source */ + Word32 *hrf_left_prev, /* i/o: Left filter */ + Word16 *hrf_left_prev_e, /* i/o: Left filter exponent */ + Word32 *hrf_right_prev, /* i/o: Right filter */ + Word16 *hrf_right_prev_e, /* i/o: Right filter exponent */ + Word32 *hrf_left_delta, /* o : Left filter interpolation delta */ + Word16 *hrf_left_delta_e, /* o : Left filter interpolation delta exponent */ + Word32 *hrf_right_delta, /* o : Right filter interpolation delta */ + Word16 *hrf_right_delta_e, /* o : Right filter interpolation delta exponent */ + Word16 *intp_count, /* o : Interpolation count */ + Word16 *filterlength, /* o : Length of filters */ + Word16 *itd, /* o : ITD value */ + Word32 *Gain, /* o : Gain value Q30 */ + TDREND_SRC_t *Src_p, /* i/o: Source pointer */ + const Word16 subframe_update_flag +); ivas_error TDREND_SRC_Alloc( TDREND_SRC_t **Src_pp /* i/o: Source */ diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 26318818a..810e53459 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -109,13 +109,17 @@ typedef enum _IVAS_REND_COMPLEXITY_LEVEL /* Functions to be called before rendering */ ivas_error IVAS_REND_Open( - IVAS_REND_HANDLE *phIvasRend, /* i/o: Pointer to renderer handle */ - const Word32 outputSampleRate, /* i : output sampling rate */ - const IVAS_AUDIO_CONFIG outConfig, /* i : output audio config */ - const bool asHrtfBinary, /* i : load hrtf binary file */ - const Word16 nonDiegeticPan, /* i : non-diegetic object flag */ - const Word32 nonDiegeticPanGain, /* i : non-diegetic panning gain Q31 */ - const Word16 num_subframes /* i : number of subframes */ + IVAS_REND_HANDLE *phIvasRend, /* i/o: Pointer to renderer handle */ + const Word32 outputSampleRate, /* i : output sampling rate */ + const IVAS_AUDIO_CONFIG outConfig, /* i : output audio config */ + const bool asHrtfBinary, /* i : load hrtf binary file */ + const Word16 nonDiegeticPan, /* i : non-diegetic object flag */ + const Word32 nonDiegeticPanGain, /* i : non-diegetic panning gain Q31*/ +#ifdef FIX_1135_EXT_RENDERER_HANDLES + const Word16 Opt_Headrotation, /* i : indicates whether head-rotation is used */ + const Word16 Opt_ExternalOrientation, /* i : indicates whether external orientations are used */ +#endif + const Word16 num_subframes /* i : number of subframes */ ); /* Note: this will reset custom LFE routings set for any MC input */ diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 389b6a5a7..6d7fa223c 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -3284,13 +3284,18 @@ static void clearInputMasa( *------------------------------------------------------------------------*/ ivas_error IVAS_REND_Open( - IVAS_REND_HANDLE *phIvasRend, - const Word32 outputSampleRate, - const AUDIO_CONFIG outConfig, - const bool asHrtfBinary, - const Word16 nonDiegeticPan, - const Word32 nonDiegeticPanGain, /* Q31 */ - const Word16 num_subframes ) + IVAS_REND_HANDLE *phIvasRend, /* i/o: Pointer to renderer handle */ + const Word32 outputSampleRate, /* i : output sampling rate */ + const IVAS_AUDIO_CONFIG outConfig, /* i : output audio config */ + const bool asHrtfBinary, /* i : load hrtf binary file */ + const Word16 nonDiegeticPan, /* i : non-diegetic object flag */ + const Word32 nonDiegeticPanGain, /* i : non-diegetic panning gain Q31*/ +#ifdef FIX_1135_EXT_RENDERER_HANDLES + const Word16 Opt_Headrotation, /* i : indicates whether head-rotation is used */ + const Word16 Opt_ExternalOrientation, /* i : indicates whether external orientations are used */ +#endif + const Word16 num_subframes /* i : number of subframes */ +) { Word16 i; Word16 j; @@ -3341,21 +3346,47 @@ ivas_error IVAS_REND_Open( } /* Initialize headrotation data */ - IF( NE_32( ( error = initHeadRotation_fx( hIvasRend ) ), IVAS_ERR_OK ) ) +#ifdef FIX_1135_EXT_RENDERER_HANDLES + hIvasRend->headRotData.headRotEnabled = 0; + IF( Opt_Headrotation ) { - return error; +#endif + IF( NE_32( ( error = initHeadRotation_fx( hIvasRend ) ), IVAS_ERR_OK ) ) + { + return error; + } +#ifdef FIX_1135_EXT_RENDERER_HANDLES } +#endif /* Initialize external orientation data */ - IF( NE_32( ( error = ivas_external_orientation_open( &( hIvasRend->hExternalOrientationData ), num_subframes ) ), IVAS_ERR_OK ) ) +#ifdef FIX_1135_EXT_RENDERER_HANDLES + hIvasRend->hExternalOrientationData = NULL; + IF( Opt_ExternalOrientation ) { - return error; +#endif + IF( NE_32( ( error = ivas_external_orientation_open( &( hIvasRend->hExternalOrientationData ), num_subframes ) ), IVAS_ERR_OK ) ) + { + return error; + } +#ifdef FIX_1135_EXT_RENDERER_HANDLES } +#endif + /* Initilize combined orientation data */ - IF( NE_32( ( error = ivas_combined_orientation_open( &( hIvasRend->hCombinedOrientationData ), outputSampleRate, num_subframes ) ), IVAS_ERR_OK ) ) +#ifdef FIX_1135_EXT_RENDERER_HANDLES + hIvasRend->hCombinedOrientationData = NULL; + IF( Opt_Headrotation || Opt_ExternalOrientation ) { - return error; +#endif + IF( NE_32( ( error = ivas_combined_orientation_open( &( hIvasRend->hCombinedOrientationData ), outputSampleRate, num_subframes ) ), IVAS_ERR_OK ) ) + { + return error; + } +#ifdef FIX_1135_EXT_RENDERER_HANDLES } +#endif + /* Initialize EFAP */ IF( NE_32( ( error = initEfap( &hIvasRend->efapOutWrapper, outConfig, &hIvasRend->customLsOut ) ), IVAS_ERR_OK ) ) { @@ -3466,14 +3497,23 @@ ivas_error IVAS_REND_Open( return error; } } - IF( NE_32( ( error = ivas_HRTF_statistics_init( &( hIvasRend->hHrtfs.hHrtfStatistics ), hIvasRend->sampleRateOut ) ), IVAS_ERR_OK ) ) + +#ifdef FIX_1135_EXT_RENDERER_HANDLES + IF( EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { - return error; +#endif + IF( NE_32( ( error = ivas_HRTF_statistics_init( &( hIvasRend->hHrtfs.hHrtfStatistics ), hIvasRend->sampleRateOut ) ), IVAS_ERR_OK ) ) + { + return error; + } +#ifdef FIX_1135_EXT_RENDERER_HANDLES } +#endif return IVAS_ERR_OK; } + static LSSETUP_CUSTOM_STRUCT makeCustomLsSetup( const IVAS_CUSTOM_LS_DATA rendCustomLsLayout ) { @@ -3813,11 +3853,11 @@ static ivas_error findFreeInputSlot_fx( Word32 *inputIndex ) { /* Using a void pointer and a separately provided size is a hack for this function - to be reusable for arrays of any input type (input_ism, input_mc, input_sba, input_masa). - Assumptions: - - input_base is always the first member in the input struct - - provided size is correct - */ + to be reusable for arrays of any input type (input_ism, input_mc, input_sba, input_masa). + Assumptions: + - input_base is always the first member in the input struct + - provided size is correct + */ Word32 i; bool canAddInput; @@ -5187,6 +5227,13 @@ ivas_error IVAS_REND_SetOrientationTrackingMode( const IVAS_HEAD_ORIENT_TRK_T orientation_tracking /* i : Head orientation tracking type */ ) { +#ifdef FIX_1135_EXT_RENDERER_HANDLES + if ( hIvasRend->headRotData.headRotEnabled == 0 ) + { + return IVAS_ERR_OK; + } +#endif + return ivas_orient_trk_SetTrackingType_fx( hIvasRend->headRotData.hOrientationTracker, orientation_tracking ); } @@ -5335,15 +5382,15 @@ ivas_error IVAS_REND_CombineHeadAndExternalOrientation( * Local functions *-------------------------------------------------------------------*/ /* Take one channel from input buffer and copy it to each channel - in output buffer, with different gain applied per output channel. - This function takes 2 gain vectors - one for the beginning and one - for the end of the buffer. Gain values are lineraly interpolated - for all samples in between. */ + in output buffer, with different gain applied per output channel. + This function takes 2 gain vectors - one for the beginning and one + for the end of the buffer. Gain values are lineraly interpolated + for all samples in between. */ /* Take one channel from input buffer and copy it to each channel - in output buffer, with different gain applied per output channel. - This function takes 2 gain vectors - one for the beginning and one - for the end of the buffer. Gain values are lineraly interpolated - for all samples in between. */ + in output buffer, with different gain applied per output channel. + This function takes 2 gain vectors - one for the beginning and one + for the end of the buffer. Gain values are lineraly interpolated + for all samples in between. */ static void renderBufferChannelLerp_fx( const IVAS_REND_AudioBuffer inAudio, const Word32 inChannelIdx, @@ -5500,7 +5547,7 @@ static void renderBufferChannelLerp_fx( /* Take one channel from input buffer and copy it to each channel - in output buffer, with different gain applied per output channel */ + in output buffer, with different gain applied per output channel */ static void renderBufferChannel_fx( const IVAS_REND_AudioBuffer inAudio, const Word32 inChannelIdx, @@ -5941,7 +5988,11 @@ static ivas_error renderIsmToBinauralRoom( hCombinedOrientationData = ismInput->base.ctx.pCombinedOrientationData; combinedOrientationEnabled = 0; move16(); +#ifdef FIX_1135_EXT_RENDERER_HANDLES + IF( *hCombinedOrientationData != NULL ) +#else IF( hCombinedOrientationData != NULL ) +#endif { FOR( subframe_idx = 0; subframe_idx < ( *hCombinedOrientationData )->num_subframes; subframe_idx++ ) { @@ -6084,8 +6135,6 @@ static ivas_error renderIsmToBinauralRoom( } } - move16(); - /* render 7_1_4 with BRIRs */ IF( NE_32( ( error = ivas_rend_crendProcessSubframe( ismInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, NULL, NULL, NULL, NULL, NULL, p_tmpRendBuffer, p_tmpRendBuffer, ismInput->base.inputBuffer.config.numSamplesPerChannel, *ismInput->base.ctx.pOutSampleRate, 0 ) ), IVAS_ERR_OK ) ) { @@ -6752,17 +6801,23 @@ static ivas_error renderMcToBinaural( Word16 i; Word16 exp = *outAudio.pq_fact; move16(); + FOR( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) { p_tmpRendBuffer_fx[i] = tmpRendBuffer_fx[i]; } push_wmops( "renderMcToBinaural" ); + inConfig = mcInput->base.inConfig; move32(); hCombinedOrientationData = mcInput->base.ctx.pCombinedOrientationData; combinedOrientationEnabled = 0; move16(); +#ifdef FIX_1135_EXT_RENDERER_HANDLES + IF( *hCombinedOrientationData != NULL ) +#else IF( hCombinedOrientationData != NULL ) +#endif { FOR( subframe_idx = 0; subframe_idx < ( *hCombinedOrientationData )->num_subframes; subframe_idx++ ) { @@ -6880,7 +6935,11 @@ static ivas_error renderMcToBinauralRoom( hCombinedOrientationData = mcInput->base.ctx.pCombinedOrientationData; combinedOrientationEnabled = 0; move16(); +#ifdef FIX_1135_EXT_RENDERER_HANDLES + IF( *hCombinedOrientationData != NULL ) +#else IF( hCombinedOrientationData != NULL ) +#endif { FOR( subframe_idx = 0; subframe_idx < ( *hCombinedOrientationData )->num_subframes; subframe_idx++ ) { @@ -7001,7 +7060,11 @@ static ivas_error renderMcCustomLsToBinauralRoom( hCombinedOrientationData = mcInput->base.ctx.pCombinedOrientationData; combinedOrientationEnabled = 0; move16(); +#ifdef FIX_1135_EXT_RENDERER_HANDLES + IF( *hCombinedOrientationData != NULL ) +#else IF( hCombinedOrientationData != NULL ) +#endif { FOR( subframe_idx = 0; subframe_idx < ( *hCombinedOrientationData )->num_subframes; subframe_idx++ ) { @@ -7688,7 +7751,6 @@ static ivas_error renderSbaToBinaural( } ELSE { - FOR( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) { output_fx[i] = output_buffer_fx[i]; @@ -7698,7 +7760,11 @@ static ivas_error renderSbaToBinaural( hCombinedOrientationData = sbaInput->base.ctx.pCombinedOrientationData; combinedOrientationEnabled = 0; move16(); +#ifdef FIX_1135_EXT_RENDERER_HANDLES + IF( *hCombinedOrientationData != NULL ) +#else IF( hCombinedOrientationData != NULL ) +#endif { FOR( subframe_idx = 0; subframe_idx < ( *hCombinedOrientationData )->num_subframes; subframe_idx++ ) { @@ -7710,6 +7776,7 @@ static ivas_error renderSbaToBinaural( } } } + /* apply rotation */ IF( combinedOrientationEnabled ) { @@ -7793,7 +7860,11 @@ static ivas_error renderSbaToBinauralRoom( hCombinedOrientationData = sbaInput->base.ctx.pCombinedOrientationData; combinedOrientationEnabled = 0; move16(); +#ifdef FIX_1135_EXT_RENDERER_HANDLES + IF( *hCombinedOrientationData != NULL ) +#else IF( hCombinedOrientationData != NULL ) +#endif { FOR( subframe_idx = 0; subframe_idx < ( *hCombinedOrientationData )->num_subframes; subframe_idx++ ) { @@ -8895,7 +8966,7 @@ static ivas_error getSamplesInternal( if ( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( hIvasRend->splitRendWrapper, hIvasRend->headRotData.headPositions[0], hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, hIvasRend->hRendererConfig->split_rend_config.codec, hIvasRend->hRendererConfig->split_rend_config.isar_frame_size_ms, hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, - &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, ( const Word16 )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) + &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, (const Word16) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) { return error; } @@ -8980,7 +9051,7 @@ ivas_error IVAS_REND_GetSplitBinauralBitstream( hIvasRend->splitRendEncBuffer.config.numSamplesPerChannel *= cldfb_in_flag ? 2 : 1; /* hIvasRend->splitRendEncBuffer used for BINAURAL_SPLIT_CODED output - outAudio used for BINAURAL_SPLIT_PCM output */ + outAudio used for BINAURAL_SPLIT_PCM output */ return getSamplesInternal( hIvasRend, outAudio, hBits ); } -- GitLab From 205739d546f2d317ce9b014c5b374b0902f6b488 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 15 Aug 2025 13:27:16 +0200 Subject: [PATCH 2/7] port CR --- lib_rend/lib_rend.h | 5 ----- lib_rend/lib_rend_fx.c | 38 +++++++++++++++++++++++++++----------- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 810e53459..fee0fac6b 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -185,11 +185,6 @@ ivas_error IVAS_REND_GetDelay_fx( Word16 *nSamples, /* o : Renderer delay in samples */ Word32 *timeScale /* o : Time scale of the delay, equal to renderer output sampling rate */ ); -ivas_error IVAS_REND_GetDelay( - IVAS_REND_CONST_HANDLE hIvasRend, /* i : Renderer handle */ - int16_t *nSamples, /* o : Renderer delay in samples */ - int32_t *timeScale /* o : Time scale of the delay, equal to renderer output sampling rate */ -); /*! r: error code */ ivas_error IVAS_REND_GetHrtfHandle( diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 6d7fa223c..a40254640 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -4428,11 +4428,13 @@ ivas_error IVAS_REND_GetNumAllObjects( return IVAS_ERR_OK; } + /*-------------------------------------------------------------------* * IVAS_REND_GetDelay() * * *-------------------------------------------------------------------*/ + ivas_error IVAS_REND_GetDelay_fx( IVAS_REND_CONST_HANDLE hIvasRend, /* i : Renderer state */ Word16 *nSamples, /* o : Renderer delay in samples */ @@ -4515,25 +4517,40 @@ ivas_error IVAS_REND_GetDelay_fx( { IF( NE_32( hIvasRend->inputsSba[i].base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) ) { - if ( hIvasRend->splitRendWrapper->hBinHrSplitPreRend != NULL ) +#ifdef FIX_1135_EXT_RENDERER_HANDLES + test(); + IF( hIvasRend->splitRendWrapper != NULL && hIvasRend->splitRendWrapper->hBinHrSplitPreRend != NULL ) +#else + IF( hIvasRend->splitRendWrapper->hBinHrSplitPreRend != NULL ) +#endif { - if ( hIvasRend->hRendererConfig->split_rend_config.rendererSelection == ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) + IF( hIvasRend->hRendererConfig->split_rend_config.rendererSelection == ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) { latency_ns = hIvasRend->inputsSba[i].cldfbRendWrapper.binaural_latency_ns; + move32(); } - else + ELSE { - latency_ns = ( hIvasRend->inputsSba[i].crendWrapper != NULL ) ? hIvasRend->inputsSba[i].crendWrapper->binaural_latency_ns : 0; + IF( ( hIvasRend->inputsSba[i].crendWrapper != NULL ) ) + { + latency_ns = hIvasRend->inputsSba[i].crendWrapper->binaural_latency_ns; + } + ELSE + { + latency_ns = 0; + } + move32(); } - max_latency_ns = max( max_latency_ns, latency_ns ); + max_latency_ns = L_max( max_latency_ns, latency_ns ); } - else if ( hIvasRend->inputsSba[i].cldfbRendWrapper.hCldfbRend != NULL ) + ELSE IF( hIvasRend->inputsSba[i].cldfbRendWrapper.hCldfbRend != NULL ) { latency_ns = hIvasRend->inputsSba[i].cldfbRendWrapper.binaural_latency_ns; - latency_ns += IVAS_FB_DEC_DELAY_NS; - max_latency_ns = max( max_latency_ns, latency_ns ); + move32(); + latency_ns = L_add( latency_ns, IVAS_FB_DEC_DELAY_NS ); + max_latency_ns = L_max( max_latency_ns, latency_ns ); } - else + ELSE { IF( hIvasRend->inputsSba[i].crendWrapper != NULL ) { @@ -4549,7 +4566,6 @@ ivas_error IVAS_REND_GetDelay_fx( } } - FOR( i = 0; i < RENDERER_MAX_MASA_INPUTS; i++ ) { IF( NE_32( hIvasRend->inputsMasa[i].base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) ) @@ -4560,7 +4576,6 @@ ivas_error IVAS_REND_GetDelay_fx( } } - //*nSamples = (Word16) roundf( (float) max_latency_ns * *timeScale / 1000000000.f ); Word32 temp = Mpy_32_32( *timeScale, 268436 ); // Q0 + Q31 - Q31 -> Q0, ( 1 / 8000 ) * 2 ^ 31 *nSamples = extract_l( Mpy_32_32_r( max_latency_ns, timescale_by_ns[temp] ) ); @@ -4569,6 +4584,7 @@ ivas_error IVAS_REND_GetDelay_fx( return IVAS_ERR_OK; } + /*-------------------------------------------------------------------* * IVAS_REND_FeedInputAudio() * -- GitLab From 5550a3ea56c376e5609a08e4d4e37f2fe57fcd2a Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 15 Aug 2025 13:43:42 +0200 Subject: [PATCH 3/7] clang-format --- lib_rend/lib_rend_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index a40254640..38c492d77 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -8982,7 +8982,7 @@ static ivas_error getSamplesInternal( if ( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( hIvasRend->splitRendWrapper, hIvasRend->headRotData.headPositions[0], hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, hIvasRend->hRendererConfig->split_rend_config.codec, hIvasRend->hRendererConfig->split_rend_config.isar_frame_size_ms, hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, - &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, (const Word16) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) + &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, ( const Word16 )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) { return error; } -- GitLab From bcc0a29311b1b459a03bdf22e47067a5a834bfcb Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 19 Aug 2025 16:56:39 +0200 Subject: [PATCH 4/7] fix merge --- lib_com/options.h | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index c7b47251e..281096886 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -126,7 +126,6 @@ #define NONBE_FIX_1141_OSBA_ROOM_RENDERING /* FhG: Fix for issue 1141: render objects in OSBA decoder with room effect */ #define NONBE_1360_LFE_DELAY /* Dlb: LFE delay alignment when rendering in CLDFB domain*/ #define NONBE_1229_FIX_ISM1_DPID /* Eri: issue 1229: fix bug causing ISM 1 to use default -dpid instead of the specified one */ -#define NONBE_SVD_OPTIMIZATION /* FhG: port-2211-svd-optimization */ #define FIX_1135_EXT_RENDERER_HANDLES /* VA: issue 1135: Memory usage reduction in external renderer: Allocate only handles that are really needed. */ #define NONBE_FIX_1176_OSBA_REVERB_JBM_ASAN_ERROR /* Ericsson: Issue 1176, fix in TDREND_firfilt for subframes shorter than the filter length */ #define NONBE_1131_ACELP_OOB /* VA: issue 1131: fix division-by-zero in acelp gain decoding caused by wrong length of buffer update when switching from HQ core to ACELP core */ -- GitLab From f6a4634a994d0ffad4676f38424fad70cc00e5ed Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 19 Aug 2025 21:23:01 +0200 Subject: [PATCH 5/7] fix --- lib_rend/ivas_objectRenderer_fx.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lib_rend/ivas_objectRenderer_fx.c b/lib_rend/ivas_objectRenderer_fx.c index 4bc79235f..d3c7b7002 100644 --- a/lib_rend/ivas_objectRenderer_fx.c +++ b/lib_rend/ivas_objectRenderer_fx.c @@ -422,13 +422,25 @@ ivas_error ivas_td_binaural_renderer_unwrap_fx( Word16 tmp_headRotEnabled; tmp_headRotEnabled = 0; move16(); - if ( enableCombinedOrientation != NULL ) +#ifdef FIX_1135_EXT_RENDERER_HANDLES + Word16 tmp_CombinedOrient_subframe_idx; + tmp_CombinedOrient_subframe_idx = 0; + move16(); +#endif + IF( enableCombinedOrientation != NULL ) { tmp_headRotEnabled = enableCombinedOrientation[hCombinedOrientationData->subframe_idx]; move16(); +#ifdef FIX_1135_EXT_RENDERER_HANDLES + tmp_CombinedOrient_subframe_idx = hCombinedOrientationData->subframe_idx; +#endif } +#ifdef FIX_1135_EXT_RENDERER_HANDLES + IF( NE_32( ( error = TDREND_Update_listener_orientation_fx( hBinRendererTd, tmp_headRotEnabled, &Quaternions[tmp_CombinedOrient_subframe_idx], &Pos[tmp_CombinedOrient_subframe_idx] ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = TDREND_Update_listener_orientation_fx( hBinRendererTd, tmp_headRotEnabled, &Quaternions[hCombinedOrientationData->subframe_idx], &Pos[hCombinedOrientationData->subframe_idx] ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -995,7 +1007,13 @@ ivas_error ivas_td_binaural_renderer_ext_fx( move16(); Word16 pos_q = Q25; move16(); + +#ifdef FIX_1135_EXT_RENDERER_HANDLES + test(); + IF( *hCombinedOrientationData != NULL && ( *hCombinedOrientationData )->listenerPos != NULL ) +#else IF( ( *hCombinedOrientationData )->listenerPos != NULL ) +#endif { ( *hCombinedOrientationData )->listenerPos[idx].x_fx = L_shr( ( *hCombinedOrientationData )->listenerPos[idx].x_fx, sub( ( *hCombinedOrientationData )->listenerPos[idx].q_fact, pos_q ) ); move32(); -- GitLab From 8faa9416967f3d45065ba7bf06edc08778fdcf7a Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 20 Aug 2025 10:29:38 +0200 Subject: [PATCH 6/7] fix: missing instance in porting --- lib_rend/lib_rend_fx.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index c3559c7ec..e1a677536 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -1210,7 +1210,12 @@ static void closeHeadRotation( IVAS_REND_HANDLE hIvasRend ) { test(); +#ifdef FIX_1135_EXT_RENDERER_HANDLES + test(); + IF( hIvasRend != NULL && hIvasRend->headRotData.headRotEnabled && hIvasRend->headRotData.hOrientationTracker != NULL ) +#else IF( ( hIvasRend != NULL ) && ( hIvasRend->headRotData.hOrientationTracker != NULL ) ) +#endif { free( hIvasRend->headRotData.hOrientationTracker ); } @@ -8976,7 +8981,7 @@ static ivas_error getSamplesInternal( if ( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( hIvasRend->splitRendWrapper, hIvasRend->headRotData.headPositions[0], hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, hIvasRend->hRendererConfig->split_rend_config.codec, hIvasRend->hRendererConfig->split_rend_config.isar_frame_size_ms, hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, - &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, ( const Word16 )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) + &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, (const Word16) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) { return error; } -- GitLab From dafd37f4e4bacd7bdf964d59a084e645f8b09760 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 20 Aug 2025 11:04:53 +0200 Subject: [PATCH 7/7] clang-format --- lib_rend/lib_rend_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index e1a677536..0565ede1b 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -8981,7 +8981,7 @@ static ivas_error getSamplesInternal( if ( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( hIvasRend->splitRendWrapper, hIvasRend->headRotData.headPositions[0], hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, hIvasRend->hRendererConfig->split_rend_config.codec, hIvasRend->hRendererConfig->split_rend_config.isar_frame_size_ms, hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, - &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, (const Word16) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) + &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, ( const Word16 )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) { return error; } -- GitLab