From db0cb169ab65b15539233812465f6d140fc43692 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Mon, 13 Oct 2025 18:26:41 +0200 Subject: [PATCH 01/40] Port some formatting and documentation changes that were omitted in port 171 of float MR 1527 Not all changes from the original MR were ported, which makes porting following MRs more difficult than it should be. This commit ports some of the missing changes in preparation for work on port 391: https://forge.3gpp.org/rep/sa4/audio/ivas-basop/-/issues/2102 Original float MR: https://forge.3gpp.org/rep/ivas-codec-pc/ivas-codec/-/merge_requests/1527 Incomplete port to BASOP main: https://forge.3gpp.org/rep/sa4/audio/ivas-basop/-/merge_requests/1977 --- lib_isar/isar_prot.h | 320 +++++++++++++++++++++++-------------------- 1 file changed, 168 insertions(+), 152 deletions(-) diff --git a/lib_isar/isar_prot.h b/lib_isar/isar_prot.h index d2db09359..ca02665b4 100644 --- a/lib_isar/isar_prot.h +++ b/lib_isar/isar_prot.h @@ -33,7 +33,6 @@ #ifndef ISAR_PROT_H #define ISAR_PROT_H - #include "isar_stat.h" #include #include "options.h" @@ -42,19 +41,59 @@ #include "enh64.h" /* clang-format off */ +/*----------------------------------------------------------------------------------* + * General ISAR prototypes + *----------------------------------------------------------------------------------*/ + +ivas_error isar_splitBinPreRendOpen( + ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend, /* i/o: binaural pre-renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData /* i/o: pose correction data handle */ +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + , + const Word32 output_Fs +#endif +); + +ivas_error split_renderer_open_lc3plus( + SPLIT_REND_WRAPPER *hSplitRendWrapper, /* i/o: Split renderer pre-renderer handle */ + const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, /* i : Split renderer pre-renderer config */ + const Word32 output_Fs, /* i : output sampling rate */ + const IVAS_RENDER_FRAMESIZE ivas_frame_size /* i : IVAS frame size */ +); + +void isar_splitBinPreRendClose( + ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend /* i/o: binaural pre-renderer handle */ +); + +void lc3plusTimeAlignCldfbPoseCorr( + SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renderer handle */ + Word32 Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: Binaural signals, real part */ + Word32 Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: Binaural signals, imag. part */ + Word16 *Q_in +); + +ivas_error splitRendLc3plusEncodeAndWrite( + SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renderer handle */ + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + const Word32 available_bits, /* i : available bit-budget */ + Word32 *in[], /* i/o: PCM in/out buffer */ + Word16 Q_sig +); +/*! r: parameter value */ Word32 ISAR_SPLIT_REND_BITStream_read_int32( - ISAR_SPLIT_REND_BITS_HANDLE pBits, - const Word32 bits ); + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + const Word32 bits /* i : number of bits to be read */ +); void ISAR_SPLIT_REND_BITStream_write_int32( - ISAR_SPLIT_REND_BITS_HANDLE pBits, - const Word32 val, - const Word32 bits + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + const Word32 val, /* i : parameter value */ + const Word32 bits /* i : number of bits to be written */ ); ivas_error isar_splitBinLCLDEncOpen( - ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE *hSplitBinLCLDEnc, + ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE *hSplitBinLCLDEnc, /* o : ISAR LCLD encoder handle */ const Word32 iSampleRate, const Word16 iChannels, const Word32 iDataRate, @@ -63,15 +102,16 @@ ivas_error isar_splitBinLCLDEncOpen( ); ivas_error isar_splitBinRendPLCOpen( - ISAR_SPLIT_REND_PLC_HANDLE *phSplitRendPLC, - const Word16 iNumSubSets ); + ISAR_SPLIT_REND_PLC_HANDLE *phSplitRendPLC, /* i/o: ISAR PLC handle */ + const Word16 iNumSubSets +); void isar_splitBinRendPLCClose( - ISAR_SPLIT_REND_PLC_HANDLE *phSplitRendPLC + ISAR_SPLIT_REND_PLC_HANDLE *phSplitRendPLC /* i/o: ISAR PLC handle */ ); ivas_error isar_splitBinLCLDDecOpen( - ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE *hSplitBinLCLDDec, + ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE *hSplitBinLCLDDec, /* i/o: ISAR LCLD decoder handle */ const Word32 iSampleRate, const Word16 iChannels, const Word16 iNumBlocks, @@ -79,7 +119,7 @@ ivas_error isar_splitBinLCLDDecOpen( ); void isar_splitBinLCLDDecClose( - ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE *hSplitBinLCLDDec + ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE *hSplitBinLCLDDec /* o : ISAR LCLD decoder handle */ ); void isar_splitBinRendPLCsaveState( @@ -126,47 +166,38 @@ void isar_log_cldfb2wav_data( const Word16 md_band_idx, const char *filename ); -#endif - -void isar_SplitRenderer_PostRenderer( - ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinPostRenderer, /* i/o: binaural renderer handle */ - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - Word32 Cldfb_RealBuffer_Ref_Binaural_fx[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o : Reference/out Binaural signals */ - Word32 Cldfb_ImagBuffer_Ref_Binaural_fx[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o : Reference/out Binaural signals */ - const IVAS_QUATERNION Quaternion_act, - Word16 *Q_in -); +#endif void isar_splitBinLCLDDecProcess( - ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE hSplitBinLCLDDec, - ISAR_SPLIT_REND_BITS_HANDLE pBits, - Word32 Cldfb_Out_Real_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word32 Cldfb_Out_Imag_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE hSplitBinLCLDDec, /* i/o: ISAR LCLD decoder handle */ + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + Word32 Cldfb_Out_Real_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : Binaural signals, real part */ + Word32 Cldfb_Out_Imag_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : Binaural signals, imag. part */ Word16 *Q_cldfb_final, - const Word16 bfi + const Word16 bfi /* i : BFI flag */ ); void set_fix_rotation_mat_fx( Word32 fix_pos_rot_mat[][BINAURAL_CHANNELS][BINAURAL_CHANNELS], - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData /* i/o: pose correction data handle */ ); void isar_splitBinLCLDEncClose( - ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE *hSplitBinLCLDEnc + ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE *hSplitBinLCLDEnc /* i/o: ISAR LCLD encoder handle */ ); void isar_splitBinLCLDEncProcess( - ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE hSplitBinLCLDEnc, + ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE hSplitBinLCLDEnc, /* i/o: ISAR LCLD encoder handle */ Word32 Cldfb_In_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], Word32 Cldfb_In_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], const Word32 available_bits, - ISAR_SPLIT_REND_BITS_HANDLE pBits, + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ Word16 *q_final ); void set_pose_types_fx( - ISAR_SPLIT_REND_POSE_TYPE pose_type[MAX_HEAD_ROT_POSES - 1], - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData + ISAR_SPLIT_REND_POSE_TYPE pose_type[MAX_HEAD_ROT_POSES - 1],/* o : ISAR pose type */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData /* i/o: pose correction data handle */ ); void isar_split_rend_init_huff_cfg( @@ -174,13 +205,13 @@ void isar_split_rend_init_huff_cfg( ); ivas_error isar_splitBinPostRendOpen( - ISAR_BIN_HR_SPLIT_POST_REND_HANDLE *hBinHrSplitPostRend, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - const Word32 output_Fs + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE *hBinHrSplitPostRend, /* i/o: binaural post-renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ + const Word32 output_Fs /* i : output sampling rate */ ); void isar_splitBinPostRendClose( - ISAR_BIN_HR_SPLIT_POST_REND_HANDLE *hBinHrSplitPostRend + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE *hBinHrSplitPostRend /* i/o: binaural post-renderer handle */ ); void isar_SplitRenderer_getdiagdiff( @@ -191,18 +222,6 @@ void isar_SplitRenderer_getdiagdiff( const Word16 max_val ); -void isar_renderSplitGetMultiBinPoseData_fx( - const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - const ISAR_SPLIT_REND_ROT_AXIS rot_axis -); - -void isar_renderSplitGetMultiBinPoseData( - const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - const ISAR_SPLIT_REND_ROT_AXIS rot_axis -); - void isar_split_rend_get_quant_params_fx( const Word16 num_md_bands, Word16 pred_real_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], @@ -219,20 +238,20 @@ void isar_split_rend_get_quant_params_fx( ); void isar_splitBinPostRendMdDec_fx( - ISAR_SPLIT_REND_BITS_HANDLE pBits, - ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, /* i/o: binaural post-renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData /* i/o: pose correction data handle */ #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG , - BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend + BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend /* i/o: binaural pre-renderer handle */ #endif ); void Quat2EulerDegree( - const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ - float *yaw, /* o : yaw */ - float *pitch, /* o : pitch */ - float *roll /* o : roll */ + const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ + float *yaw, /* o : yaw */ + float *pitch, /* o : pitch */ + float *roll /* o : roll */ ); void isar_mat_mult_2by2_complex_fx( @@ -251,8 +270,8 @@ void isar_mat_mult_2by2_complex_fx( ); void isar_rend_CldfbSplitPostRendProcess( - ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, /* i/o: binaural post-renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ const IVAS_QUATERNION QuaternionPost, Word32 Cldfb_RealBuffer_Binaural_fx[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], Word32 Cldfb_ImagBuffer_Binaural_fx[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], @@ -262,14 +281,6 @@ void isar_rend_CldfbSplitPostRendProcess( const Word16 cldfb_in_flag ); -void isar_init_multi_bin_pose_data_fx( - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ); - -/* Copy for encoder, to be removed */ -void isar_init_multi_bin_pose_data_fx_enc( - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData -); - void isar_rend_CldfbSplitPreRendProcess( const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, const IVAS_QUATERNION headPosition, @@ -284,6 +295,32 @@ void isar_rend_CldfbSplitPreRendProcess( const Word16 ro_md_flag ); +ivas_error isar_renderMultiTDBinToSplitBinaural( + SPLIT_REND_WRAPPER *hSplitBin, + const IVAS_QUATERNION headPosition, + const Word32 SplitRendBitRate, + const Word16 isar_frame_size_ms, + const Word16 codec_frame_size_ms, + ISAR_SPLIT_REND_BITS_HANDLE pBits, + const Word16 max_bands, + // float *in[], + Word32 *in_fx[], // Q11 + Word16 Q_sig, + const Word16 low_res_pre_rend_rot, + const Word16 pcm_out_flag, + const Word16 ro_md_flag +); + +void isar_init_multi_bin_pose_data_fx( + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData /* i/o: pose correction data handle */ +); + +void isar_renderSplitGetMultiBinPoseData_fx( + const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, /* i : Split renderer pre-renderer config */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ + const ISAR_SPLIT_REND_ROT_AXIS rot_axis /* i : external control for rotation axis for split rendering */ +); + Word16 isar_renderSplitGetRot_axisNumBits( const Word16 dof ); @@ -300,86 +337,56 @@ Word16 isar_renderSplitGetCodeFromRot_axis( ); void isar_init_split_post_rend_handles( - ISAR_SPLIT_POST_REND_WRAPPER *hSplitRendWrapper ); - -ivas_error isar_splitBinPreRendOpen( - ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend, -#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - const Word32 output_Fs -#else - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData -#endif -); - -void isar_splitBinPreRendClose( - ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend + ISAR_SPLIT_POST_REND_WRAPPER *hSplitRendWrapper /* i/o: Split renderer post-renderer handle */ ); void isar_set_split_rend_ht_setup_fx( - SPLIT_REND_WRAPPER *hSplitrend, - IVAS_QUATERNION Quaternions[MAX_PARAM_SPATIAL_SUBFRAMES], - Word32 Rmat_fx[MAX_PARAM_SPATIAL_SUBFRAMES][3][3] + SPLIT_REND_WRAPPER *hSplitrend, /* i/o: Split renderer pre-renderer handle */ + IVAS_QUATERNION Quaternions[MAX_PARAM_SPATIAL_SUBFRAMES], /* i/o: External orientation in quaternions */ + Word32 Rmat_fx[MAX_PARAM_SPATIAL_SUBFRAMES][3][3] /* o : real-space rotation matrix */ ); Word32 isar_get_lc3plus_bitrate( - const Word32 SplitRendBitRate, - const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, - const Word32 nChannels, - const Word32 codecFrameDurationUs ); + const Word32 SplitRendBitRate, /* i : ISAR bitrate */ + const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, /* i : ISAR pose correction mode */ + const Word32 nChannels, /* i : number of channels */ + const Word32 lc3plus_frame_duration_us /* i : ISAR frame length in us */ +); ivas_error isar_split_rend_validate_config( - const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, - const Word16 is_pcm_out + const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, /* i : Split renderer pre-renderer config */ + const Word16 is_pcm_out /* i : flag to indicate PCM output */ ); +/*! r: LCLD codec bitrate */ Word32 isar_get_lcld_bitrate( - const Word32 SplitRendBitRate, - const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode + const Word32 SplitRendBitRate, /* i : ISAR bitrate */ + const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode /* i : ISAR pose correction mode */ ); -ivas_error splitRendLc3plusEncodeAndWrite( - SPLIT_REND_WRAPPER *hSplitBin, - ISAR_SPLIT_REND_BITS_HANDLE pBits, - const Word32 available_bits, - Word32 *in[], - Word16 Q_sig +/*! r: ISAR MD bitrate */ +Word32 isar_get_split_rend_md_target_brate( + const Word32 SplitRendBitRate, /* i : ISAR bitrate */ + const Word16 pcm_out_flag /* i : flag to indicate PCM output */ ); ivas_error isar_framesize_to_ms( - const IVAS_RENDER_FRAMESIZE frame_size, /* i : frame size enum */ - Word16 *ms /* o : frame size in ms */ -); - -Word32 isar_get_split_rend_md_target_brate( - const Word32 SplitRendBitRate, - const Word16 pcm_out_flag + const IVAS_RENDER_FRAMESIZE frame_size, /* i : frame size enum */ + Word16 *ms /* o : frame size in ms */ ); ivas_error isar_split_rend_choose_default_codec( - ISAR_SPLIT_REND_CODEC *pCodec, /* i/o: pointer to codec setting */ - Word16 *pIsar_frame_size_ms, /* i/o: pointer to ISAR frame size setting */ - Word16 *pCodec_frame_size_ms, /* i/o: pointer to codec frame size setting */ - const Word16 cldfb_in_flag, /* i : flag indicating rendering in TD */ - const Word16 pcm_out_flag, /* i : flag to indicate PCM output */ - const Word16 num_subframes /* i : number of subframes */ -); - -void ISAR_SPLIT_REND_BITStream_init( - ISAR_SPLIT_REND_BITS_HANDLE pBits, - const Word32 buf_len_bytes, - UWord8 *pbuf -); - -Word16 wrap_a( - Word16 val, - const Word16 min_val, - const Word16 max_val + ISAR_SPLIT_REND_CODEC *pCodec, /* i/o: pointer to codec setting */ + Word16 *pIsar_frame_size_ms, /* i/o: pointer to ISAR frame size setting */ + Word16 *pCodec_frame_size_ms, /* i/o: pointer to codec frame size setting */ + const Word16 cldfb_in_flag, /* i : flag indicating rendering in TD */ + const Word16 pcm_out_flag, /* i : flag to indicate PCM output */ + const Word16 num_subframes /* i : number of subframes */ ); void isar_renderSplitUpdateNoCorrectionPoseData( - const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData + const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, /* i : Split renderer pre-renderer config */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData /* i/o: pose correction data handle */ ); Word32 get_bit( @@ -387,44 +394,53 @@ Word32 get_bit( const Word32 bit_id ); -ivas_error split_renderer_open_lc3plus( - SPLIT_REND_WRAPPER *hSplitRendWrapper, - const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, - const Word32 OutSampleRate, - const IVAS_RENDER_FRAMESIZE ivas_frame_size -); - +/*! r: ISAR audio type */ ISAR_POST_REND_AudioConfigType isar_getAudioConfigType( - const IVAS_AUDIO_CONFIG config + const IVAS_AUDIO_CONFIG config /* i : audio configuration */ ); void isar_init_split_rend_handles( - SPLIT_REND_WRAPPER *hSplitRendWrapper + SPLIT_REND_WRAPPER *hSplitRendWrapper /* i/o: Split renderer pre-renderer handle */ ); -ivas_error isar_renderMultiTDBinToSplitBinaural( - SPLIT_REND_WRAPPER *hSplitBin, - const IVAS_QUATERNION headPosition, - const Word32 SplitRendBitRate, - const Word16 isar_frame_size_ms, - const Word16 codec_frame_size_ms, +// UNUSED +void ISAR_SPLIT_REND_BITStream_init( ISAR_SPLIT_REND_BITS_HANDLE pBits, - const Word16 max_bands, - // float *in[], - Word32 *in_fx[], // Q11 - Word16 Q_sig, - const Word16 low_res_pre_rend_rot, - const Word16 pcm_out_flag, - const Word16 ro_md_flag + const Word32 buf_len_bytes, + UWord8 *pbuf ); -void lc3plusTimeAlignCldfbPoseCorr( - SPLIT_REND_WRAPPER *hSplitBin, - Word32 Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word32 Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word16 *Q_in +/*----------------------------------------------------------------------------------* + * BASOP-only + *----------------------------------------------------------------------------------*/ + +/* Copy for encoder, to be removed */ +void isar_init_multi_bin_pose_data_fx_enc( + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData +); + + +Word16 wrap_a( + Word16 val, + const Word16 min_val, + const Word16 max_val ); +void isar_renderSplitGetMultiBinPoseData( + const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const ISAR_SPLIT_REND_ROT_AXIS rot_axis +); + + +void isar_SplitRenderer_PostRenderer( + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinPostRenderer, /* i/o: binaural renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + Word32 Cldfb_RealBuffer_Ref_Binaural_fx[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o : Reference/out Binaural signals */ + Word32 Cldfb_ImagBuffer_Ref_Binaural_fx[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o : Reference/out Binaural signals */ + const IVAS_QUATERNION Quaternion_act, + Word16 *Q_in +); void ivas_cmult_fix( Word32 in1_re_fx, -- GitLab From 9f8fb15fc4f67c95c90fda23a2e6a1540af1c8ee Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Wed, 22 Oct 2025 12:58:34 +0200 Subject: [PATCH 02/40] [WIP] Port split rendering support in VoIP mode --- Workspace_msvc/lib_rend.vcxproj | 1 + Workspace_msvc/lib_rend.vcxproj.filters | 3 + apps/decoder.c | 129 ++- apps/isar_post_rend.c | 13 + lib_com/ivas_prot_fx.h | 38 + lib_com/options.h | 4 +- lib_dec/ivas_dirac_dec_fx.c | 16 +- lib_dec/ivas_init_dec_fx.c | 5 + lib_dec/ivas_jbm_dec_fx.c | 17 + lib_dec/ivas_mc_param_dec_fx.c | 8 + lib_dec/ivas_mc_paramupmix_dec_fx.c | 8 + lib_dec/ivas_omasa_dec_fx.c | 11 + lib_dec/ivas_osba_dec_fx.c | 16 +- lib_dec/ivas_output_config_fx.c | 12 + lib_dec/ivas_stat_dec.h | 18 +- lib_dec/lib_dec.h | 20 + lib_dec/lib_dec_fx.c | 740 +++++++++++++++++- lib_isar/isar_prot.h | 34 +- lib_isar/isar_splitRend_lcld_enc.c | 9 +- lib_isar/isar_splitRendererPre.c | 137 +++- lib_isar/isar_stat.h | 12 + lib_isar/lib_isar_pre_rend.c | 55 +- lib_isar/lib_isar_pre_rend.h | 5 + lib_rend/ivas_cldfb_ring_buffer.c | 321 ++++++++ .../ivas_dirac_dec_binaural_functions_fx.c | 16 + lib_rend/ivas_prot_rend_fx.h | 62 ++ lib_rend/ivas_stat_rend.h | 16 + lib_rend/ivas_td_ring_buffer.c | 448 +++++++++++ lib_rend/lib_rend_fx.c | 27 +- 29 files changed, 2121 insertions(+), 80 deletions(-) create mode 100644 lib_rend/ivas_cldfb_ring_buffer.c create mode 100644 lib_rend/ivas_td_ring_buffer.c diff --git a/Workspace_msvc/lib_rend.vcxproj b/Workspace_msvc/lib_rend.vcxproj index c39806d47..db791e067 100644 --- a/Workspace_msvc/lib_rend.vcxproj +++ b/Workspace_msvc/lib_rend.vcxproj @@ -138,6 +138,7 @@ + diff --git a/Workspace_msvc/lib_rend.vcxproj.filters b/Workspace_msvc/lib_rend.vcxproj.filters index 2494e2ee2..0892a4dcb 100644 --- a/Workspace_msvc/lib_rend.vcxproj.filters +++ b/Workspace_msvc/lib_rend.vcxproj.filters @@ -109,6 +109,9 @@ rend_c + + rend_c + rend_c diff --git a/apps/decoder.c b/apps/decoder.c index dfebd7392..a04eb819d 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -163,7 +163,11 @@ static bool parseCmdlIVAS_dec( int16_t argc, char **argv, DecArguments *arg ); static void usage_dec( void ); #ifdef FIX_1217_OBJECT_EDIT_FILE_INTERFACE static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ObjectEditFileReader *objectEditFileReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); +#ifdef FIX_1119_SPLIT_RENDERING_VOIP +static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtf, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ObjectEditFileReader *objectEditFileReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); +#else static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ObjectEditFileReader *objectEditFileReader, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); +#endif #else static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); @@ -655,7 +659,11 @@ int main( if ( arg.voipMode ) { #ifdef FIX_1217_OBJECT_EDIT_FILE_INTERFACE +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, &splitRendBits, hIvasDec, pcmBuf ); +#else error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, hIvasDec, pcmBuf ); +#endif #else error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, hIvasDec, pcmBuf ); #endif @@ -1755,7 +1763,11 @@ static ivas_error initOnFirstGoodFrame( for ( int16_t i = 0; i < numInitialBadFrames; ++i ) { +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + if ( isSplitRend ) +#else if ( *splitRendWriter != NULL ) +#endif { ISAR_SPLIT_REND_BITS_DATA splitRendBitsZero; splitRendBitsZero.bits_buf = NULL; @@ -1773,7 +1785,12 @@ static ivas_error initOnFirstGoodFrame( return error; } } + +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + if ( !isSplitCoded ) +#else else +#endif { if ( *pRemainingDelayNumSamples < *numOutSamples ) { @@ -1984,6 +2001,14 @@ static ivas_error decodeG192( return error; } +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + if ( !isSplitRend ) + { + /* Ensure split rendering output struct is not used when not outputting to a split rendering output configuration */ + splitRendBits = NULL; + } +#endif + if ( ( error = IVAS_DEC_is_split_rendering_coded_out( hIvasDec, &isSplitCoded ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_is_split_rendering_coded_out, code: %d\n", error ); @@ -2245,7 +2270,11 @@ static ivas_error decodeG192( } /* decode transport channels, do TSM and feed to renderer */ +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + if ( ( error = IVAS_DEC_GetSamplesDecoder( hIvasDec, splitRendBits ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_DEC_GetSamplesDecoder( hIvasDec, isSplitRend, splitRendBits ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -2700,6 +2729,9 @@ static ivas_error decodeVoIP( Vector3PairFileReader *referenceVectorReader, #ifdef FIX_1217_OBJECT_EDIT_FILE_INTERFACE ObjectEditFileReader *objectEditFileReader, +#endif +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + ISAR_SPLIT_REND_BITS_DATA *splitRendBits, #endif IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ) @@ -2750,6 +2782,29 @@ static ivas_error decodeVoIP( bool parametersAvailableForEditing = false; uint16_t nSamplesRendered; +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + SplitFileReadWrite *splitRendWriter = NULL; + int16_t isSplitRend, isSplitCoded; + + if ( ( error = IVAS_DEC_is_split_rendering_enabled( hIvasDec, &isSplitRend ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError in IVAS_DEC_is_split_rendering_enabled, code: %d\n", error ); + return error; + } + + if ( !isSplitRend ) + { + /* Ensure split rendering output struct is not used when not outputting to a split rendering format */ + splitRendBits = NULL; + } + + if ( ( error = IVAS_DEC_is_split_rendering_coded_out( hIvasDec, &isSplitCoded ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError in IVAS_DEC_is_split_rendering_coded_out, code: %d\n", error ); + return error; + } +#endif + vec_pos_update = 0; if ( ( error = IVAS_DEC_GetRenderFramesizeMs( hIvasDec, &systemTimeInc_ms ) ) != IVAS_ERR_OK ) { @@ -3047,6 +3102,22 @@ static ivas_error decodeVoIP( /* decode and get samples */ while ( nSamplesRendered < nOutSamples ) { +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + if ( isSplitRend ) + { +#ifdef SUPPORT_JBM_TRACEFILE + if ( ( error = IVAS_DEC_VoIP_GetSplitBinauralBitstream( hIvasDec, (void *) pcmBuf, splitRendBits, writeJbmTraceFileFrameWrapper, jbmTraceWriter, &bitstreamReadDone, &nSamplesRendered, ¶metersAvailableForEditing, systemTime_ms ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_DEC_VoIP_GetSplitBinauralBitstream( hIvasDec, (void *) pcmBuf, splitRendBits, &bitstreamReadDone, &nSamplesRendered, ¶metersAvailableForEditing, systemTime_ms ) ) != IVAS_ERR_OK ) +#endif + { + fprintf( stderr, "\nError in IVAS_DEC_VoIP_GetSplitBinauralBitstream: %s\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + } + else + { +#endif #ifdef SUPPORT_JBM_TRACEFILE if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, (void *) pcmBuf, writeJbmTraceFileFrameWrapper, jbmTraceWriter, &bitstreamReadDone, &nSamplesRendered, ¶metersAvailableForEditing, systemTime_ms ) ) != IVAS_ERR_OK ) #else @@ -3056,6 +3127,9 @@ static ivas_error decodeVoIP( fprintf( stderr, "\nError in IVAS_DEC_VoIP_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + } +#endif if ( bitstreamReadDone == true ) { @@ -3143,9 +3217,15 @@ static ivas_error decodeVoIP( /* Once good frame decoded, catch up */ if ( decodedGoodFrame ) { +#ifndef FIX_1119_SPLIT_RENDERING_VOIP SplitFileReadWrite *splitRendWriter = NULL; +#endif +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + if ( ( error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, &nOutSamples, &vec_pos_len, delayNumSamples_orig, &delayNumSamples, &delayTimeScale, +#else if ( ( error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, &nOutSamples, NULL, delayNumSamples_orig, &delayNumSamples, &delayTimeScale, +#endif &bsFormat, &afWriter, &masaWriter, ismWriters, &nOutChannels, &numObj, &splitRendWriter ) ) != IVAS_ERR_OK ) { goto cleanup; @@ -3160,19 +3240,35 @@ static ivas_error decodeVoIP( /* Write current frame */ if ( decodedGoodFrame ) { - if ( delayNumSamples < nOutSamples ) +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + if ( isSplitRend ) { - if ( ( error = AudioFileWriter_write( afWriter, &pcmBuf[delayNumSamples * nOutChannels], nOutSamples * nOutChannels - ( delayNumSamples * nOutChannels ) ) ) != IVAS_ERR_OK ) + if ( split_rend_write_bitstream_to_file( splitRendWriter, splitRendBits->bits_buf, &splitRendBits->bits_read, &splitRendBits->bits_written ) != IVAS_ERR_OK ) { - fprintf( stderr, "\nOutput audio file writer error\n" ); + fprintf( stderr, "\nUnable to write to bitstream file!\n" ); goto cleanup; } - delayNumSamples = 0; } - else + + if ( !isSplitCoded ) { - delayNumSamples -= nOutSamples; +#endif + if ( delayNumSamples < nOutSamples ) + { + if ( ( error = AudioFileWriter_write( afWriter, &pcmBuf[delayNumSamples * nOutChannels], nOutSamples * nOutChannels - ( delayNumSamples * nOutChannels ) ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nOutput audio file writer error\n" ); + goto cleanup; + } + delayNumSamples = 0; + } + else + { + delayNumSamples -= nOutSamples; + } +#ifdef FIX_1119_SPLIT_RENDERING_VOIP } +#endif /* Write ISM metadata to external file(s) */ if ( decodedGoodFrame && arg.outputConfig == IVAS_AUDIO_CONFIG_EXTERNAL ) @@ -3272,7 +3368,11 @@ static ivas_error decodeVoIP( goto cleanup; } +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + if ( nSamplesFlushed && !isSplitCoded ) +#else if ( nSamplesFlushed ) +#endif { /* Write current frame */ if ( ( error = AudioFileWriter_write( afWriter, pcmBuf, nSamplesFlushed * nOutChannels ) ) != IVAS_ERR_OK ) @@ -3343,11 +3443,19 @@ static ivas_error decodeVoIP( *------------------------------------------------------------------------------------------*/ memset( pcmBuf, 0, delayNumSamples_orig[0] * nOutChannels * sizeof( int16_t ) ); - if ( ( error = AudioFileWriter_write( afWriter, pcmBuf, delayNumSamples_orig[0] * nOutChannels ) ) != IVAS_ERR_OK ) + +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + if ( afWriter != NULL ) { - fprintf( stderr, "\nError writing output file: %s\n", ivas_error_to_string( error ) ); - goto cleanup; +#endif + if ( ( error = AudioFileWriter_write( afWriter, pcmBuf, delayNumSamples_orig[0] * nOutChannels ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError writing output file: %s\n", ivas_error_to_string( error ) ); + goto cleanup; + } +#ifdef FIX_1119_SPLIT_RENDERING_VOIP } +#endif /*------------------------------------------------------------------------------------------* * Printouts after decoding has finished @@ -3392,6 +3500,9 @@ cleanup: EVS_RTPDUMP_DEPACKER_close( &rtpdumpDepacker ); AudioFileWriter_close( &afWriter ); +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + split_rend_reader_writer_close( &splitRendWriter ); +#endif JbmOffsetFileWriter_close( &jbmOffsetWriter ); #ifdef SUPPORT_JBM_TRACEFILE JbmTraceFileWriter_close( &jbmTraceWriter ); diff --git a/apps/isar_post_rend.c b/apps/isar_post_rend.c index 53417cf15..e56ef760c 100644 --- a/apps/isar_post_rend.c +++ b/apps/isar_post_rend.c @@ -1127,6 +1127,19 @@ int main( fprintf( stderr, "\nISAR_POST_REND_FeedSplitBinauralBitstream failed: %s\n", ivas_error_to_string( error ) ); goto cleanup; } + +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + /* Set BFI if frame is empty */ + int16_t frameEmpty = (int16_t) ( bitsBuffer.config.bitsWritten == 0 ); + if ( frameEmpty ) + { + if ( ( error = ISAR_POST_REND_SetSplitRendBFI( hIsarPostRend, 1 ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error in ISAR_POST_REND_SetSplitRendBFI(): %s\n", ivas_error_to_string( error ) ); + goto cleanup; + } + } +#endif } } diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 08e5694d6..9ea4526be 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -6733,6 +6733,44 @@ void ivas_binaural_hrtf_close_fx( HRTFS_FASTCONV_HANDLE *hHrtfFastConv /* i/o: decoder binaural hrtf handle */ ); +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + +/*---------------------------------------------------------------------------------* + * Multi-pose ring buffer Prototypes +*-----------------------------------------------------------------------------------*/ + +ivas_error ivas_CLDFB_RINGBUF_Open( + ISAR_CLDFB_RINGBUF_HANDLE *ph, + const Word16 capacity_columns +); + +void ivas_CLDFB_RINGBUF_Close( + ISAR_CLDFB_RINGBUF_HANDLE *ph +); + +void ivas_CLDFB_RINGBUF_Push( + ISAR_CLDFB_RINGBUF_HANDLE h, + const Word32 *real, + const Word32 *imag, + const Word16 num_bands +); + +void ivas_CLDFB_RINGBUF_Pop( + ISAR_CLDFB_RINGBUF_HANDLE h, + Word32 *real, + Word32 *imag, + const Word16 num_bands +); + +void ivas_CLDFB_RINGBUF_GetByIdx( + ISAR_CLDFB_RINGBUF_HANDLE h, + Word32 **p_real, + Word32 **p_imag, + const Word16 idx +); + +#endif + /*----------------------------------------------------------------------------------* * renderer prototypes *----------------------------------------------------------------------------------*/ diff --git a/lib_com/options.h b/lib_com/options.h index 0e364d2b8..8ca21eb97 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -95,7 +95,6 @@ #define NONBE_1377_REND_DIRATT_CONF /* Eri: Issue 1377: Error in directivity attenuation configuration for both IVAS_dec and IVAS_rend */ #define FIX_1377_HANDLE_ERROR_CODE /* Eri: Add missing error code handling from IVAS_REND_SetObjectIDs */ #define FIX_1053_REVERB_RECONFIGURATION -#define TMP_FIX_1119_SPLIT_RENDERING_VOIP /* FhG: Add error check for unsupported config: split rendering with VoIP mode */ #define FIX_1113_EXTREND_ISAR /* FhG: issue 1113: fix external renderer asserts for FOA/HOA2 and CLDFB config */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_938_COMPILER_WARNING /* FhG: Fix compiler warning in ivas_mdct_core_reconstruct() */ @@ -132,6 +131,9 @@ #define NONBE_FIX_1305_OMASA_OBJ_EDIT_EXT /* Nokia: issue 1305: Fix OMASA ext output in case of object editing */ #define NONBE_FIX_1172_OBJ_EDIT_JBM /* VA: issue 1172: fix OMASA object editing in JBM */ +#define FIX_1119_SPLIT_RENDERING_VOIP /* FhG: Add split rendering support to decoder in VoIP mode */ +#define FIX_1119_SPLIT_RENDERING_VOIP_TD_RINGBUF // TODO(sgi): align with port 369, which actually adds the TD ringbuf: https://forge.3gpp.org/rep/sa4/audio/ivas-basop/-/merge_requests/2412/diffs#d6d51ef63eb9458b72d78958dfd5b73ac4bae1de +#define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ /* #################### End BASOP porting switches ############################ */ #endif diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index 6e30bc084..c9d9b2c38 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -2189,7 +2189,9 @@ static void binRenderer_split_fx( Word32 Cldfb_ImagBuffer_Binaural_fx[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals */ Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals */ +#ifndef FIX_1119_SPLIT_RENDERING_VOIP const Word16 slot_idx_start, +#endif const Word16 num_freq_bands, const Word16 nchan_out ) { @@ -2222,8 +2224,16 @@ static void binRenderer_split_fx( { FOR( ch = 0; ch < nchan_out; ch++ ) { +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + ivas_CLDFB_RINGBUF_Push( + hSplitBinRend->hMultiBinCldfbData[pos_idx * BINAURAL_CHANNELS + ch], + Cldfb_RealBuffer_Binaural_loc[pos_idx][ch][slot_idx], + Cldfb_ImagBuffer_Binaural_loc[pos_idx][ch][slot_idx], + num_freq_bands ); +#else Copy32( Cldfb_RealBuffer_Binaural_loc[pos_idx][ch][slot_idx], hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural_fx[( pos_idx * BINAURAL_CHANNELS ) + ch][slot_idx_start + slot_idx], num_freq_bands ); Copy32( Cldfb_ImagBuffer_Binaural_loc[pos_idx][ch][slot_idx], hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural_fx[( pos_idx * BINAURAL_CHANNELS ) + ch][slot_idx_start + slot_idx], num_freq_bands ); +#endif } } } @@ -3867,7 +3877,11 @@ void ivas_dirac_dec_render_sf_fx( } binRenderer_split_fx( st_ivas->hBinRenderer, st_ivas->hSplitBinRend, st_ivas->hCombinedOrientationData, hSpatParamRendCom->subframe_nbslots[subframe_idx], - Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, slot_idx_start, hSpatParamRendCom->num_freq_bands, st_ivas->hDecoderConfig->nchan_out ); + Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, +#ifndef FIX_1119_SPLIT_RENDERING_VOIP + slot_idx_start, +#endif + hSpatParamRendCom->num_freq_bands, st_ivas->hDecoderConfig->nchan_out ); } ELSE { diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 00179537e..3f9b7d13f 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -1476,6 +1476,11 @@ ivas_error ivas_init_decoder_front( } } +#ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR + st_ivas->flushing = 0; + move16(); +#endif + return error; } diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 62a5b5490..fa4c0a919 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2580,13 +2580,30 @@ ivas_error ivas_jbm_dec_render_fx( IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { +#ifdef FIX_1119_SPLIT_RENDERING_VOIP /* NOTE(sgi): BASOP special - not in float version */ + nchan_out_syn_output = BINAURAL_CHANNELS * st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; +#ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR // TODO(sgi): verify if this is needed in BASOP + if ( st_ivas->flushing ) + { + nchan_out_syn_output = BINAURAL_CHANNELS; + } +#endif +#else FOR( i = 0; i < st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses * BINAURAL_CHANNELS; i++ ) { Copy32( p_output_fx[i], st_ivas->hSplitBinRend->hMultiBinCldfbData->output_fx[i], *nSamplesRendered ); } +#endif } +#ifdef FIX_1119_SPLIT_RENDERING_VOIP /* NOTE(sgi): BASOP special - not in float version */ + ELSE + { +#endif nchan_out_syn_output = nchan_out; move16(); +#ifdef FIX_1119_SPLIT_RENDERING_VOIP /* NOTE(sgi): BASOP special - not in float version */ + } +#endif IF( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) == 0 ) { diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index 2a5b0020e..156d3ef2e 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -2252,8 +2252,16 @@ void ivas_param_mc_dec_render_fx( { FOR( ch = 0; ch < nchan_out_cldfb; ch++ ) { +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + ivas_CLDFB_RINGBUF_Push( + st_ivas->hSplitBinRend->hMultiBinCldfbData[pos_idx * BINAURAL_CHANNELS + ch], + Cldfb_RealBuffer_Binaural_fx[pos_idx][ch][slot_idx], + Cldfb_ImagBuffer_Binaural_fx[pos_idx][ch][slot_idx], + hParamMC->num_freq_bands ); +#else Copy32( Cldfb_RealBuffer_Binaural_fx[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural_fx[add( i_mult( pos_idx, BINAURAL_CHANNELS ), ch )][add( slot_idx_start, slot_idx )], hParamMC->num_freq_bands ); Copy32( Cldfb_ImagBuffer_Binaural_fx[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural_fx[add( i_mult( pos_idx, BINAURAL_CHANNELS ), ch )][add( slot_idx_start, slot_idx )], hParamMC->num_freq_bands ); +#endif } } } diff --git a/lib_dec/ivas_mc_paramupmix_dec_fx.c b/lib_dec/ivas_mc_paramupmix_dec_fx.c index d28ba8328..cd789dad1 100644 --- a/lib_dec/ivas_mc_paramupmix_dec_fx.c +++ b/lib_dec/ivas_mc_paramupmix_dec_fx.c @@ -907,8 +907,16 @@ static void ivas_mc_paramupmix_dec_sf( { FOR( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) { +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + ivas_CLDFB_RINGBUF_Push( + st_ivas->hSplitBinRend->hMultiBinCldfbData[pos_idx * BINAURAL_CHANNELS + ch], + Cldfb_RealBuffer_Binaural_fx[pos_idx][ch][slot_idx], + Cldfb_ImagBuffer_Binaural_fx[pos_idx][ch][slot_idx], + maxBand ); +#else Copy32( Cldfb_RealBuffer_Binaural_fx[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural_fx[add( i_mult( pos_idx, BINAURAL_CHANNELS ), ch )][add( slot_index_start, slot_idx )], maxBand ); Copy32( Cldfb_ImagBuffer_Binaural_fx[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural_fx[add( i_mult( pos_idx, BINAURAL_CHANNELS ), ch )][add( slot_index_start, slot_idx )], maxBand ); +#endif } } } diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index 4749fc22d..49317590e 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -1184,10 +1184,14 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm_fx( ivas_error error; Word32 *p_sepobj_fx[BINAURAL_CHANNELS]; // Q11 Word32 data_separated_objects_fx[BINAURAL_CHANNELS][L_FRAME48k]; +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + Word32 *re, *im; +#else Word16 slot_idx_start; slot_idx_start = st_ivas->hSpatParamRendCom->slots_rendered; move16(); +#endif FOR( n = 0; n < BINAURAL_CHANNELS; n++ ) { @@ -1246,9 +1250,16 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm_fx( Scale_sig32( Cldfb_RealBuffer, num_cldfb_bands, sub( Q6, q_cldfb ) ); Scale_sig32( Cldfb_ImagBuffer, num_cldfb_bands, sub( Q6, q_cldfb ) ); + +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + ivas_CLDFB_RINGBUF_GetByIdx( st_ivas->hSplitBinRend->hMultiBinCldfbData[n], &re, &im, slot_idx - cldfb_slots ); + v_add_fx( re, Cldfb_RealBuffer, re, num_cldfb_bands ); + v_add_fx( im, Cldfb_ImagBuffer, im, num_cldfb_bands ); +#else /* note: this intentionally differs from OSBA by: no scaling by 0.5 */ v_add_fx( st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural_fx[n][slot_idx_start + slot_idx], Cldfb_RealBuffer, st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural_fx[n][slot_idx_start + slot_idx], num_cldfb_bands ); v_add_fx( st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural_fx[n][slot_idx_start + slot_idx], Cldfb_ImagBuffer, st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural_fx[n][slot_idx_start + slot_idx], num_cldfb_bands ); +#endif } } } diff --git a/lib_dec/ivas_osba_dec_fx.c b/lib_dec/ivas_osba_dec_fx.c index 67908e996..728fdfdb2 100644 --- a/lib_dec/ivas_osba_dec_fx.c +++ b/lib_dec/ivas_osba_dec_fx.c @@ -137,10 +137,14 @@ ivas_error ivas_osba_dirac_td_binaural_jbm_fx( Word32 output_separated_objects_fx[BINAURAL_CHANNELS][L_FRAME48k]; Word32 *p_sepobj_fx[BINAURAL_CHANNELS]; Word16 channel_offset; +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + Word32 *re, *im; +#else Word16 slot_idx_start; slot_idx_start = st_ivas->hSpatParamRendCom->slots_rendered; move16(); +#endif FOR( Word16 i = 0; i < BINAURAL_CHANNELS; i++ ) { @@ -163,7 +167,10 @@ ivas_error ivas_osba_dirac_td_binaural_jbm_fx( ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData ); IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { - Word16 slot_idx, num_cldfb_bands, b, nchan_transport_orig; + Word16 slot_idx, num_cldfb_bands, nchan_transport_orig; +#ifndef FIX_1119_SPLIT_RENDERING_VOIP + Word16 b; +#endif Word16 cldfb_slots; Word32 Cldfb_RealBuffer[CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer[CLDFB_NO_CHANNELS_MAX]; @@ -198,6 +205,12 @@ ivas_error ivas_osba_dirac_td_binaural_jbm_fx( Scale_sig32( Cldfb_RealBuffer, num_cldfb_bands, sub( Q6, q_cldfb ) ); Scale_sig32( Cldfb_ImagBuffer, num_cldfb_bands, sub( Q6, q_cldfb ) ); + +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + ivas_CLDFB_RINGBUF_GetByIdx( st_ivas->hSplitBinRend->hMultiBinCldfbData[n], &re, &im, slot_idx - cldfb_slots ); + v_add_fx( re, Cldfb_RealBuffer, re, num_cldfb_bands ); + v_add_fx( im, Cldfb_ImagBuffer, im, num_cldfb_bands ); +#else FOR( b = 0; b < num_cldfb_bands; b++ ) { st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural_fx[n][slot_idx_start + slot_idx][b] = @@ -208,6 +221,7 @@ ivas_error ivas_osba_dirac_td_binaural_jbm_fx( L_add( st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural_fx[n][add( slot_idx_start, slot_idx )][b], Cldfb_ImagBuffer[b] ); move32(); } +#endif } } } diff --git a/lib_dec/ivas_output_config_fx.c b/lib_dec/ivas_output_config_fx.c index 284bd0859..53573c7ee 100644 --- a/lib_dec/ivas_output_config_fx.c +++ b/lib_dec/ivas_output_config_fx.c @@ -626,12 +626,24 @@ RENDERER_TYPE ivas_renderer_secondary_select_fx( test(); test(); +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + test(); + test(); + IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && + ( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + ) +#else IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) ) +#endif { renderer_type = RENDERER_BINAURAL_OBJECTS_TD; move32(); } +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) && ( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) ) +#else ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) && ( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) +#endif { renderer_type = RENDERER_BINAURAL_OBJECTS_TD; move32(); diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 289b91b77..ad180e6e8 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -870,6 +870,7 @@ typedef struct renderer_struct * IVAS decoder specific ISAR wrapper structures *----------------------------------------------------------------------------------*/ +#ifndef FIX_1119_SPLIT_RENDERING_VOIP typedef struct { Word32 Cldfb_RealBuffer_Binaural_fx[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; @@ -878,18 +879,29 @@ typedef struct } ISAR_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA, *ISAR_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA_HANDLE; +#endif typedef struct { +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + Word32 Cldfb_RealBuffer_fx[MAX_OUTPUT_CHANNELS][2 * CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; /* Double space to account for TSM */ + Word32 Cldfb_ImagBuffer_fx[MAX_OUTPUT_CHANNELS][2 * CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; +#else Word32 Cldfb_RealBuffer_fx[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_fx[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; +#endif IVAS_AUDIO_CONFIG config; } ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA, *ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE; typedef struct { +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + TD_RINGBUF_HANDLE hMultiBinTdData; + ISAR_CLDFB_RINGBUF_HANDLE hMultiBinCldfbData[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS]; +#else ISAR_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA_HANDLE hMultiBinCldfbData; /*scratch buffer for frame by frame processing*/ - ISAR_SPLIT_REND_BITS_HANDLE hSplitRendBits; /*scratch buffer for frame by frame processing*/ +#endif + ISAR_SPLIT_REND_BITS_HANDLE hSplitRendBits; /*scratch buffer for frame by frame processing*/ SPLIT_REND_WRAPPER splitrend; ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE hCldfbDataOut; /*buffer to store cldfb data before binauralization*/ Word16 numTdSamplesPerChannelCached; @@ -1189,6 +1201,10 @@ typedef struct Decoder_Struct Word16 ism_extmeta_active; /* Extended metadata active in decoder */ Word16 ism_extmeta_cnt; /* Change frame counter for extended metadata */ +#ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR + int16_t flushing; +#endif + } Decoder_Struct; /* clang-format on */ diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 51c359227..006a7487d 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -153,7 +153,9 @@ ivas_error IVAS_DEC_ReadFormat( ivas_error IVAS_DEC_GetSamplesDecoder( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ +#ifndef FIX_1119_SPLIT_RENDERING_VOIP const Word16 isSplitRend, /* i : split rendering enabled flag */ +#endif ISAR_SPLIT_REND_BITS_DATA *splitRendBits /* o : output split rendering bits */ ); @@ -314,6 +316,24 @@ ivas_error IVAS_DEC_VoIP_GetSamples( const UWord32 systemTimestamp_ms /* i : current system timestamp */ ); +#ifdef FIX_1119_SPLIT_RENDERING_VOIP +/*! r: error code */ +ivas_error IVAS_DEC_VoIP_GetSplitBinauralBitstream( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + /* const IVAS_DEC_PCM_TYPE pcmType, */ /* i : type for the decoded PCM resolution */ + Word16 *pcmBuf, /* o : output synthesis signal */ + ISAR_SPLIT_REND_BITS_DATA *splitRendBits, /* o : output split rendering bits */ +#ifdef SUPPORT_JBM_TRACEFILE + JbmTraceFileWriterFn jbmWriterFn, + void* jbmWriter, +#endif + bool *bitstreamReadDone, /* o : flag indicating that bitstream was read */ + UWord16 *nSamplesRendered, /* o : number of samples rendered */ + bool *parametersAvailableForEditing, /* o : indicates whether objects editing is available */ + const UWord32 systemTimestamp_ms /* i : current system timestamp */ +); +#endif + ivas_error IVAS_DEC_Flush( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const Word16 nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index be60b0580..109863787 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -129,7 +129,11 @@ static ivas_error evs_dec_main_fx( Decoder_Struct *st_ivas, const Word16 nOutSam static ivas_error input_format_API_to_internal( IVAS_DEC_INPUT_FORMAT input_format, Word16 *bitstream_format_internal, Word16 *sdp_hf_only, const bool is_voip_enabled ); static void init_decoder_config( DECODER_CONFIG_HANDLE hDecoderConfig ); #ifdef LIB_DEC_REVISION +#ifdef FIX_1119_SPLIT_RENDERING_VOIP +static ivas_error ivas_dec_setup_all( IVAS_DEC_HANDLE hIvasDec, UWord8 *nTransportChannels, ISAR_SPLIT_REND_BITS_DATA *splitRendBits ); +#else static ivas_error ivas_dec_setup_all( IVAS_DEC_HANDLE hIvasDec, UWord8 *nTransportChannels, const Word16 isSplitRend, ISAR_SPLIT_REND_BITS_DATA *splitRendBits ); +#endif static ivas_error apa_setup( IVAS_DEC_HANDLE hIvasDec, const bool isInitialized_voip, const UWord16 nTransportChannels ); #else static ivas_error IVAS_DEC_VoIP_reconfigure( IVAS_DEC_HANDLE hIvasDec, const UWord16 nTransportChannels, const UWord16 l_ts ); @@ -140,6 +144,10 @@ static ivas_error IVAS_DEC_GetRenderedSamples( IVAS_DEC_HANDLE hIvasDec, const U static ivas_error IVAS_DEC_GetBufferedNumberOfSamples( IVAS_DEC_HANDLE hIvasDec, Word16 *nSamplesBuffered ); #endif static Word16 get_render_frame_size_ms( IVAS_RENDER_FRAMESIZE render_framesize ); +#ifdef FIX_1119_SPLIT_RENDERING_VOIP +static Word16 get_render_frame_size_samples( const DECODER_CONFIG_HANDLE hDecoderConfig ); +static Word16 ivas_dec_split_rend_cldfb_in( const RENDERER_TYPE renderer_type ); +#endif static void update_voip_rendered20ms( IVAS_DEC_HANDLE hIvasDec, const Word16 nSamplesRendered ); static ivas_error isar_set_split_rend_setup( ISAR_DEC_SPLIT_REND_WRAPPER *hSplitBinRend, const ISAR_SPLIT_REND_CONFIG_DATA *hSplitBinConfig, const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, ISAR_SPLIT_REND_BITS_DATA *splitRendBits ); static ivas_error ivas_dec_reconfig_split_rend( Decoder_Struct *st_ivas ); @@ -818,6 +826,41 @@ ivas_error IVAS_DEC_GetRenderFramesize( } +#ifdef FIX_1119_SPLIT_RENDERING_VOIP +/*---------------------------------------------------------------------* + * get_render_frame_size_samples( ) + * + * + *---------------------------------------------------------------------*/ + +static int16_t get_render_frame_size_samples( + const DECODER_CONFIG_HANDLE hDecoderConfig /* i : configuration structure */ +) +{ + Word16 tmp; + tmp = (Word16) Mpy_32_16_1( hDecoderConfig->output_Fs, INV_FR_P_S_MX_PRM_SPL_SBFR_Q15 ); + + /* NOTE(sgi): BASOP special - not in float version */ + IF( EQ_16( hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_5MS ) ) + { + /* correct value already in tmp */ + } + ELSE IF( EQ_16( hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_10MS ) ) + { + tmp = shl( tmp, 1 ); + } + ELSE IF( EQ_16( hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_20MS ) ) + { + tmp = shl( tmp, 2 ); + } + ELSE + { + tmp = 0; + } + return tmp; +} +#endif + /*---------------------------------------------------------------------* * IVAS_DEC_GetGetRenderFramesizeSamples( ) * @@ -829,7 +872,9 @@ ivas_error IVAS_DEC_GetRenderFramesizeSamples( Word16 *render_framesize /* o : render framesize in samples Q0 */ ) { +#ifndef FIX_1119_SPLIT_RENDERING_VOIP /* NOTE(sgi): BASOP special - not in float version */ Word16 tmp; +#endif test(); test(); @@ -838,6 +883,9 @@ ivas_error IVAS_DEC_GetRenderFramesizeSamples( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + *render_framesize = get_render_frame_size_samples( hIvasDec->st_ivas->hDecoderConfig ); +#else tmp = (Word16) Mpy_32_16_1( hIvasDec->st_ivas->hDecoderConfig->output_Fs, INV_FR_P_S_MX_PRM_SPL_SBFR_Q15 ); IF( EQ_16( hIvasDec->st_ivas->hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_5MS ) ) @@ -856,6 +904,7 @@ ivas_error IVAS_DEC_GetRenderFramesizeSamples( { *render_framesize = 0; } +#endif move16(); return IVAS_ERR_OK; @@ -1193,6 +1242,299 @@ ivas_error IVAS_DEC_FeedFrame_Serial( return IVAS_ERR_OK; } +#ifdef FIX_1119_SPLIT_RENDERING_VOIP +/*---------------------------------------------------------------------* + * isar_get_frame_size( ) + * + * + *---------------------------------------------------------------------*/ + +static Word16 isar_get_frame_size( + Decoder_Struct *st_ivas /* i : IVAS decoder handle */ +) +{ + Word32 output_Fs; + Word16 nSamplesPerChannel; + + output_Fs = st_ivas->hDecoderConfig->output_Fs; + + if ( st_ivas->hDecoderConfig->render_framesize != IVAS_RENDER_FRAMESIZE_20MS && + ( st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE || + st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) + { +#if 0 // NOTE(sgi2det): the divide function includes a right shift so the result ends up 2x too small here + nSamplesPerChannel = divide3216( output_Fs, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ); + nSamplesPerChannel = imult1616( nSamplesPerChannel, st_ivas->hDecoderConfig->render_framesize ); +#else + nSamplesPerChannel = (int16_t) ( output_Fs / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ); + nSamplesPerChannel *= (int16_t) st_ivas->hDecoderConfig->render_framesize; +#endif + } + else + { +#if 0 // NOTE(sgi2det): the divide function includes a right shift so the result ends up 2x too small here + nSamplesPerChannel = divide3216( output_Fs, FRAMES_PER_SEC ); +#else + nSamplesPerChannel = output_Fs / FRAMES_PER_SEC; +#endif + } + + return nSamplesPerChannel; +} + + +/*---------------------------------------------------------------------* + * isar_render_poses( ) + * + * + *---------------------------------------------------------------------*/ + +static ivas_error isar_render_poses( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const Word16 nSamplesAsked, /* i : number of samples wanted by the caller */ + Word16 *nOutSamples, /* o : number of samples per channel written to output buffer */ + bool *needNewFrame /* o : indication that the decoder needs a new frame */ +) +{ + // NOTE(sgi2det): Code in this function was moved and adapted from IVAS_DEC_GetSplitBinauralBitstream, + // see #else branch of FIX_1119_SPLIT_RENDERING_VOIP there for reference + Word16 pcmBuf[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES * L_FRAME48k]; + Decoder_Struct *st_ivas; + ivas_error error; + Word16 numPoses; + + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + *needNewFrame = false; + + st_ivas = hIvasDec->st_ivas; + + numPoses = st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; + + /* init flush buffer for rate switch if not already initizalized */ + if ( hIvasDec->flushbuffer == NULL ) + { +#if 1 // NOTE(sgi2det): I copied this from previously ported version of IVAS_DEC_GetSplitBinauralBitstream. + // Generally I've seen arithmetic within calls to malloc() not ported, so maybe this is ok. + 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 ); +#else // NOTE(sgi): originally from det + Word32 tmp; + /* numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( Word16 ) */ + tmp = imult3216( L_deposit_l( numPoses ), hIvasDec->nSamplesFrame ); + /* BINAURAL_CHANNELS=2, IVAS_MAX_PARAM_SPATIAL_SUBFRAMES=4, sizeof (Word16)=2. */ + /* BINAURAL_CHANNELS * sizeof(Word16)/ IVAS_MAX_PARAM_SPATIAL_SUBFRAMES = 4/4 = 1 */ + hIvasDec->flushbuffer = (void *) malloc( tmp ); + if ( hIvasDec->flushbuffer == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate flush buffer" ); + } + hIvasDec->pcmType = IVAS_DEC_PCM_FLOAT; // NOTE(sgi2det): the BASOP version of this struct has no pcmType member - only 16 bit PCM is supported. + /* hIvasDec->flushbuffer, numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES = tmp/2 */ + tmp = L_shr( tmp, 1); + set_zero( (Word16 *) hIvasDec->flushbuffer, tmp ); +#endif + } + + /* render */ +#ifdef LIB_DEC_REVISION + IF ( ( error = IVAS_DEC_GetSamplesRenderer( hIvasDec, nSamplesAsked, pcmBuf, nOutSamples, needNewFrame ) ) != IVAS_ERR_OK ) +#else + IF ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesAsked, pcmBuf, nOutSamples, needNewFrame ) ) != IVAS_ERR_OK ) +#endif + { + return error; + } + +#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST + IF ( !hIvasDec->hasBeenFedFirstGoodFrame ) + { + return IVAS_ERR_OK; + } +#endif + + IF ( !ivas_dec_split_rend_cldfb_in( st_ivas->renderer_type ) ) + { +#if 1 /* NOTE(sgi): Workaround for bit width mismatch */ + Word32 pcmBuf32[960 * 16]; + + for (int i = 0; i < *nOutSamples * hIvasDec->st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses * BINAURAL_CHANNELS; ++i) + { + // NOTE(sgi2det): Is this even correct or do we need to adjust the Q-format? + pcmBuf32[i] = pcmBuf[i]; + } +#endif + + // NOTE(sgi2det): We need signal in 32 bit here, but get only 16 bit from IVAS_DEC_GetSamplesRenderer... + // The float version of that function has switchable output format (int16 or float) but not in BASOP. + // Any ideas for a better solution than this pcmBuf32? + ivas_TD_RINGBUF_PushInterleaved( st_ivas->hSplitBinRend->hMultiBinTdData, pcmBuf32, *nOutSamples ); + } + + return error; +} + + +/*---------------------------------------------------------------------* + * isar_generate_metadata_and_bitstream( ) + * + * + *---------------------------------------------------------------------*/ + +static ivas_error isar_generate_metadata_and_bitstream( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + Word32 **p_head_pose_buf, /* i/o: PCM buffer with head-pose data */ + Word16 nSamples, /* i : duration of audio (in samples per channel) for which metadata should be generated */ + ISAR_SPLIT_REND_BITS_DATA *splitRendBits /* o : output split rendering bits */ +) +{ + // NOTE(sgi2det): Code in this function was moved and adapted from IVAS_DEC_GetSplitBinauralBitstream, + // see #else branch of FIX_1119_SPLIT_RENDERING_VOIP there for reference + ivas_error error; + ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE hSplitBinRend; + Word16 max_band; + Word16 pcm_out_flag; + Word16 cldfb_in_flag; + Word16 ro_md_flag; + IVAS_QUATERNION Quaternion; + Word16 i, j, num_poses, num_cldfb_slots, n_samples_in_cldfb_slot; + Word32 *p_Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX]; + Word32 *p_Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX]; + + hSplitBinRend = st_ivas->hSplitBinRend; + +#if 1 // NOTE(sgi2det): The divide function includes a right shift so the result ends up 2x too small here. + // I copied this from previously ported version of IVAS_DEC_GetSplitBinauralBitstream. Maybe this can just stay here. + max_band = (Word16) ( ( BINAURAL_MAXBANDS * st_ivas->hDecoderConfig->output_Fs ) / 48000 ); // TODO remove division +#else // NOTE(sgi): originally from det + // NOTE(sgi): warning: implicit conversion from 'int' to 'Word16' (aka 'short') changes value from 48000 to -17536 [-Wconstant-conversion] + max_band = divide3216( imult3216( BINAURAL_MAXBANDS, st_ivas->hDecoderConfig->output_Fs ), 48000 ); +#endif + pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; + cldfb_in_flag = ivas_dec_split_rend_cldfb_in( st_ivas->renderer_type ); + + // NOTE(sgi): BASOP special - not in float version + n_samples_in_cldfb_slot = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + assert( nSamples % n_samples_in_cldfb_slot == 0 ); +#if 0 // NOTE(sgi2det): the divide function includes a right shift so the result ends up 2x too small here + num_cldfb_slots = extract_l( divide3216( L_deposit_l( nSamples ), n_samples_in_cldfb_slot ) ); +#else + num_cldfb_slots = nSamples / n_samples_in_cldfb_slot; +#endif + + num_poses = hSplitBinRend->splitrend.multiBinPoseData.num_poses; + + IF( cldfb_in_flag ) + { + FOR( i = 0; i < imult1616( BINAURAL_CHANNELS, num_poses); ++i ) + { + FOR( j = 0; j < num_cldfb_slots; ++j ) + { + /* Save pointers to first CLDFB column in the ring buffer. Allows us to save + * significant amounts of memory by not copying CLDFB values into a separate buffer. */ + ivas_CLDFB_RINGBUF_GetByIdx( hSplitBinRend->hMultiBinCldfbData[i], &p_Cldfb_RealBuffer_Binaural[i][j], &p_Cldfb_ImagBuffer_Binaural[i][j], 0 ); + + /* Pop the CLDFB column we just saved pointers to. This is fine as long as we use + * the saved columns only before any new columns are pushed to the buffer - the new + * columns could potentially overwrite the old columns we wanted to use. + * This requirement is fulfilled in this case. */ + ivas_CLDFB_RINGBUF_Pop( hSplitBinRend->hMultiBinCldfbData[i], NULL, NULL, CLDFB_NO_CHANNELS_MAX ); + } + } + } + ELSE + { + ivas_TD_RINGBUF_PopChannels( st_ivas->hSplitBinRend->hMultiBinTdData, p_head_pose_buf, nSamples ); + } + + + IF ( st_ivas->hBinRendererTd != NULL ) + { + ro_md_flag = 1; + } + ELSE + { + ro_md_flag = 0; + } + + IF( st_ivas->hHeadTrackData != NULL ) + { + Quaternion = st_ivas->hHeadTrackData->Quaternions[0]; + } + ELSE + { + Quaternion.w_fx = -12582912; + Quaternion.x_fx = 0; + Quaternion.y_fx = 0; + Quaternion.z_fx = 0; + } + // NOTE(sgi): BASOP special - not in float version + Word16 q1 = 31, q2 = 31, Q_buff = 31; + Word16 Q_out[CLDFB_NO_COL_MAX]; // NOTE(sgi): Seems unnecessarily large. Only indices 0 and 1 are used, value at index 1 is writen but never read. + Q_out[0] = 31; + + IF( EQ_16( cldfb_in_flag, 1 ) ) + { + FOR( i = 0; i < i_mult( BINAURAL_CHANNELS, num_poses ); i++ ) + { + FOR( j = 0; j < num_cldfb_slots; j++ ) + { + q1 = s_min( q1, L_norm_arr( p_Cldfb_RealBuffer_Binaural[i][j], CLDFB_NO_CHANNELS_MAX ) ); + q2 = s_min( q2, L_norm_arr( p_Cldfb_ImagBuffer_Binaural[i][j], CLDFB_NO_CHANNELS_MAX ) ); + } + } + Q_buff = s_min( q1, q2 ); + FOR( i = 0; i < i_mult( BINAURAL_CHANNELS, num_poses ); i++ ) + { + FOR( j = 0; j < num_cldfb_slots; j++ ) + { + scale_sig32( p_Cldfb_RealBuffer_Binaural[i][j], CLDFB_NO_CHANNELS_MAX, Q_buff ); + scale_sig32( p_Cldfb_ImagBuffer_Binaural[i][j], CLDFB_NO_CHANNELS_MAX, Q_buff ); + } + } + Q_buff = add( Q_buff, Q6 ); + } + ELSE + { + /*TD input*/ + /*if CLDFB handles have been allocated then assume valid multi binaural input in out[][] buffer and perform CLDFB analysis*/ + /* local float2fix, to be removed */ + num_poses = hSplitBinRend->splitrend.multiBinPoseData.num_poses; + + FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; ++i ) + { + Q_out[0] = s_min( Q_out[0], L_norm_arr( p_head_pose_buf[i], L_FRAME48k ) ); + } + + FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; ++i ) + { + scale_sig32( p_head_pose_buf[i], L_FRAME48k, Q_out[0] ); + } + Q_out[0] = add( Q_out[0], Q11 ); + Q_out[1] = Q_out[0]; + } + + IF( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( &hSplitBinRend->splitrend, + Quaternion, + st_ivas->hRenderConfig->split_rend_config.splitRendBitRate, + st_ivas->hRenderConfig->split_rend_config.codec, + st_ivas->hRenderConfig->split_rend_config.isar_frame_size_ms, + st_ivas->hRenderConfig->split_rend_config.codec_frame_size_ms, + splitRendBits, + p_Cldfb_RealBuffer_Binaural, + p_Cldfb_ImagBuffer_Binaural, + max_band, p_head_pose_buf, 1, cldfb_in_flag, pcm_out_flag, ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) + { + return error; + } + + return IVAS_ERR_OK; +} +#endif /* FIX_1119_SPLIT_RENDERING_VOIP */ + /*---------------------------------------------------------------------* * IVAS_DEC_GetSamplesRenderer( ) @@ -1401,6 +1743,70 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( bool *needNewFrame /* o : indication that the decoder needs a new frame */ ) { +#ifdef FIX_1119_SPLIT_RENDERING_VOIP // NOTE(sgi2det): this function still needs to be ported to BASOP + Decoder_Struct *st_ivas; + ivas_error error; + Word32 head_pose_buf[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES][L_FRAME48k]; + Word32 *p_head_pose_buf[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES]; + Word16 i; + Word16 pcm_out_flag; + Word16 numSamplesPerChannelToOutput; + + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + st_ivas = hIvasDec->st_ivas; + + if ( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) == 0 ) + { + return IVAS_ERR_WRONG_PARAMS; + } + + pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; + numSamplesPerChannelToOutput = isar_get_frame_size( st_ivas ); + + if ( ( error = isar_render_poses( hIvasDec, numSamplesPerChannelToOutput, nOutSamples, needNewFrame ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( !hIvasDec->hasBeenFedFirstGoodFrame ) + { + return IVAS_ERR_OK; + } + + for ( i = 0; i < BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES; ++i ) + { + p_head_pose_buf[i] = head_pose_buf[i]; + } + + if ( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nOutSamples, splitRendBits ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* convert to int16 with limiting for BINAURAL_SPLIT_PCM */ + if ( pcm_out_flag ) + { + if ( st_ivas->hDecoderConfig->render_framesize == IVAS_RENDER_FRAMESIZE_5MS ) + { +#ifndef DISABLE_LIMITER + ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToOutput, st_ivas->BER_detect, Q11 ); +#endif + } + else + { + ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToOutput, st_ivas->BER_detect, Q11 ); + } + +#ifdef DEBUGGING + st_ivas->noClipping += +#endif + ivas_syn_output_fx( p_head_pose_buf, Q11, numSamplesPerChannelToOutput, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf_out ); + } +#else Decoder_Struct *st_ivas; AUDIO_CONFIG output_config; Word32 output_Fs; @@ -1657,8 +2063,9 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( ivas_syn_output_fx( pOutput, Q11, numSamplesPerChannelToDecode, st_ivas->hDecoderConfig->nchan_out, (Word16 *) pcmBuf_out ); } -#ifndef TMP_FIX_SPLIT_REND +#ifndef TMP_FIX_SPLIT_REND // TODO(sgi): need to port? free( st_ivas->hSplitBinRend->hMultiBinCldfbData ); +#endif #endif return IVAS_ERR_OK; @@ -1673,9 +2080,11 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( *---------------------------------------------------------------------*/ static ivas_error ivas_dec_setup_all( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - UWord8 *nTransportChannels, /* o : number of decoded transport PCM channels */ - const Word16 isSplitRend, /* i : split rendering enabled flag */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + UWord8 *nTransportChannels, /* o : number of decoded transport PCM channels */ +#ifndef FIX_1119_SPLIT_RENDERING_VOIP + const Word16 isSplitRend, /* i : split rendering enabled flag */ +#endif ISAR_SPLIT_REND_BITS_DATA *splitRendBits /* o : output split rendering bits */ ) #else @@ -1714,7 +2123,11 @@ static ivas_error IVAS_DEC_Setup( #ifdef LIB_DEC_REVISION /* Setup IVAS split rendering */ +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + IF( splitRendBits != NULL ) +#else IF( isSplitRend ) +#endif { IF( ( error = isar_set_split_rend_setup( st_ivas->hSplitBinRend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hCombinedOrientationData, splitRendBits ) ) != IVAS_ERR_OK ) { @@ -1755,7 +2168,11 @@ static ivas_error IVAS_DEC_Setup( test(); #ifdef LIB_DEC_REVISION +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + IF( st_ivas->ini_frame == 0 && splitRendBits != NULL ) +#else IF( st_ivas->ini_frame == 0 && isSplitRend ) +#endif #else IF( st_ivas->ini_frame == 0 && ( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) ) ) #endif @@ -3848,8 +4265,10 @@ ivas_error IVAS_DEC_ReadFormat( *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetSamplesDecoder( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const Word16 isSplitRend, /* i : split rendering enabled flag */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ +#ifndef FIX_1119_SPLIT_RENDERING_VOIP + const Word16 isSplitRend, /* i : split rendering enabled flag */ +#endif ISAR_SPLIT_REND_BITS_DATA *splitRendBits /* o : output split rendering bits */ ) { @@ -3889,7 +4308,11 @@ ivas_error IVAS_DEC_GetSamplesDecoder( * Setup all decoder parts (IVAS decoder, ISAR) *-----------------------------------------------------------------*/ +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + IF( ( error = ivas_dec_setup_all( hIvasDec, &nTransportChannels, splitRendBits ) ) != IVAS_ERR_OK ) +#else IF( ( error = ivas_dec_setup_all( hIvasDec, &nTransportChannels, isSplitRend, splitRendBits ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -4662,19 +5085,37 @@ ivas_error IVAS_DEC_PrepareRenderer( } +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + +/*---------------------------------------------------------------------* + * ivas_dec_voip_get_samples_common( ) + * + * Main function to output one frame in VoIP. Holds common code for + * regular output configs and split rendering configs. + *---------------------------------------------------------------------*/ + +static ivas_error ivas_dec_voip_get_samples_common + +#else /*---------------------------------------------------------------------* * IVAS_DEC_VoIP_GetSamples( ) * * Main function to decode one frame in VoIP *---------------------------------------------------------------------*/ - -ivas_error IVAS_DEC_VoIP_GetSamples( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - UWord16 nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ - Word16 *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels Q0 */ +ivas_error IVAS_DEC_VoIP_GetSamples +#endif + ( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + UWord16 nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ + /* const IVAS_DEC_PCM_TYPE pcmType, */ /* i : type for the decoded PCM resolution */ + Word16 *pcmBuf, /* o : output synthesis signal */ +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + ISAR_SPLIT_REND_BITS_DATA *splitRendBits, /* o : output split rendering bits */ + Word32 **p_head_pose_buf, /* i : PCM buffer with head-pose data */ +#endif #ifdef SUPPORT_JBM_TRACEFILE - JbmTraceFileWriterFn jbmWriterFn, - void *jbmWriter, + JbmTraceFileWriterFn jbmWriterFn, + void *jbmWriter, #endif bool *bitstreamReadDone, /* o : flag indicating that bitstream was read */ UWord16 *nSamplesRendered, /* o : number of samples rendered */ @@ -4713,12 +5154,14 @@ ivas_error IVAS_DEC_VoIP_GetSamples( return IVAS_ERR_WRONG_PARAMS; } -#ifdef TMP_FIX_1119_SPLIT_RENDERING_VOIP +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + test(); test(); - IF( EQ_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || - EQ_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) + IF( ( EQ_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || + EQ_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) && + splitRendBits == NULL ) { - return IVAS_ERROR( IVAS_ERR_NOT_IMPLEMENTED, "Split rendering is not integrated with VoIP mode" ); + return IVAS_ERR_UNEXPECTED_NULL_POINTER; // NOTE(sgi): BASOP special - not in float version } #endif @@ -4922,7 +5365,12 @@ ivas_error IVAS_DEC_VoIP_GetSamples( #ifndef LIB_DEC_REVISION uint16_t nSamplesFlushed_ref = hIvasDec->nSamplesFlushed; #endif - IF( ( error = IVAS_DEC_GetSamplesDecoder( hIvasDec, 0, 0 ) ) != IVAS_ERR_OK ) + +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + IF ( ( error = IVAS_DEC_GetSamplesDecoder( hIvasDec, splitRendBits ) ) != IVAS_ERR_OK ) +#else + IF ( ( error = IVAS_DEC_GetSamplesDecoder( hIvasDec, 0, 0 ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -4952,24 +5400,169 @@ ivas_error IVAS_DEC_VoIP_GetSamples( } } - /* render IVAS frames directly to the output buffer */ +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + IF( splitRendBits != NULL ) + { + /* Render head poses from time-scaled transport channels */ + IF( ( error = isar_render_poses( hIvasDec, nSamplesToRender, &nSamplesRendered_loop, &tmp ) ) != IVAS_ERR_OK ) + { + return error; + } + } + ELSE + { +#endif + /* render IVAS frames directly to the output buffer */ #ifdef LIB_DEC_REVISION - IF( NE_32( ( error = IVAS_DEC_GetSamplesRenderer( hIvasDec, nSamplesToRender, pcmBuf + imult1616( *nSamplesRendered, nOutChannels ), &nSamplesRendered_loop, &tmp ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = IVAS_DEC_GetSamplesRenderer( hIvasDec, nSamplesToRender, pcmBuf + imult1616( *nSamplesRendered, nOutChannels ), &nSamplesRendered_loop, &tmp ) ), IVAS_ERR_OK ) ) #else - IF( NE_32( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, pcmBuf + imult1616( *nSamplesRendered, nOutChannels ), &nSamplesRendered_loop, &tmp ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, pcmBuf + imult1616( *nSamplesRendered, nOutChannels ), &nSamplesRendered_loop, &tmp ) ), IVAS_ERR_OK ) ) #endif - { - return error; + { + return error; + } +#ifdef FIX_1119_SPLIT_RENDERING_VOIP } +#endif *nSamplesRendered = add( *nSamplesRendered, nSamplesRendered_loop ); update_voip_rendered20ms( hIvasDec, nSamplesRendered_loop ); } } +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + IF( hIvasDec->hasDecodedFirstGoodFrame && splitRendBits != NULL ) + { + /* Analyse head poses over entire frame, generate ISAR metadata and maybe encode if split coded */ + IF( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nSamplesRendered, splitRendBits ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* Synthesise PCM output if split PCM */ + IF( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + IF( st_ivas->hDecoderConfig->render_framesize == IVAS_RENDER_FRAMESIZE_5MS ) + { +#ifndef DISABLE_LIMITER + ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, Q11 ); +#endif + } + ELSE + { + ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, Q11 ); + } + +#ifdef DEBUGGING + st_ivas->noClipping += +#endif + ivas_syn_output_fx( p_head_pose_buf, Q11, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf ); + } + } +#endif + return IVAS_ERR_OK; } +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + +/*---------------------------------------------------------------------* + * IVAS_DEC_VoIP_GetSamples( ) + * + * Main function to decode one frame in VoIP + *---------------------------------------------------------------------*/ + +ivas_error IVAS_DEC_VoIP_GetSamples( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + UWord16 nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ + /* const IVAS_DEC_PCM_TYPE pcmType, */ /* i : type for the decoded PCM resolution */ + Word16 *pcmBuf, /* o : output synthesis signal */ +#ifdef SUPPORT_JBM_TRACEFILE + JbmTraceFileWriterFn jbmWriterFn, + void *jbmWriter, +#endif + bool *bitstreamReadDone, /* o : flag indicating that bitstream was read */ + UWord16 *nSamplesRendered, /* o : number of samples rendered */ + bool *parametersAvailableForEditing, /* o : indicates whether objects editing is available */ + const UWord32 systemTimestamp_ms /* i : current system timestamp */ +) +{ + return ivas_dec_voip_get_samples_common( + hIvasDec, + nSamplesPerChannel, + /* pcmType, */ + pcmBuf, + NULL, + NULL, +#ifdef SUPPORT_JBM_TRACEFILE + jbmWriterFn, + jbmWriter, +#endif + bitstreamReadDone, + nSamplesRendered, + parametersAvailableForEditing, + systemTimestamp_ms ); +} + + +/*---------------------------------------------------------------------* + * IVAS_DEC_VoIP_GetSplitBinauralBitstream( ) + * + * Main function to decode one split-rendering frame in VoIP + *---------------------------------------------------------------------*/ + +/*! r: error code */ +ivas_error IVAS_DEC_VoIP_GetSplitBinauralBitstream( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + /* const IVAS_DEC_PCM_TYPE pcmType, */ /* i : type for the decoded PCM resolution */ + Word16 *pcmBuf, /* o : output synthesis signal */ + ISAR_SPLIT_REND_BITS_DATA *splitRendBits, /* o : output split rendering bits */ +#ifdef SUPPORT_JBM_TRACEFILE + JbmTraceFileWriterFn jbmWriterFn, + void *jbmWriter, +#endif + bool *bitstreamReadDone, /* o : flag indicating that bitstream was read */ + UWord16 *nSamplesRendered, /* o : number of samples rendered */ + bool *parametersAvailableForEditing, /* o : indicates whether objects editing is available */ + const UWord32 systemTimestamp_ms /* i : current system timestamp */ +) +{ + Word16 i; + Word32 head_pose_buf[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES][L_FRAME48k]; + Word32 *pp_head_pose_buf[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES]; + ivas_error error = IVAS_ERR_UNKNOWN; + Word16 nSamplesPerChannel = 0; + + IF( ( error = IVAS_DEC_GetRenderFramesizeSamples( hIvasDec, &nSamplesPerChannel ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* Set pointers to beginning of head pose buffers */ + FOR( i = 0; i < BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES; ++i ) + { + pp_head_pose_buf[i] = head_pose_buf[i]; + } + + return ivas_dec_voip_get_samples_common( + hIvasDec, + nSamplesPerChannel, + /* IVAS_DEC_PCM_INT16, */ + pcmBuf, + splitRendBits, + pp_head_pose_buf, +#ifdef SUPPORT_JBM_TRACEFILE + jbmWriterFn, + jbmWriter, +#endif + bitstreamReadDone, + nSamplesRendered, + parametersAvailableForEditing, + systemTimestamp_ms ); +} +#endif + + /*---------------------------------------------------------------------* * update_voip_rendered20ms( ) @@ -5040,6 +5633,10 @@ ivas_error IVAS_DEC_Flush( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } +#ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR + hIvasDec->st_ivas->flushing = 1; +#endif + *nSamplesFlushed = s_min( nSamplesPerChannel, hIvasDec->nSamplesAvailableNext ); move16(); @@ -5064,6 +5661,10 @@ ivas_error IVAS_DEC_Flush( *nSamplesFlushed = 0; move16(); } +#ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR + hIvasDec->st_ivas->flushing = 0; +#endif + return error; } @@ -5925,6 +6526,9 @@ static ivas_error ivas_create_handle_isar( ) { ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE hSplitBinRend; +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + Word16 i; +#endif IF( ( hSplitBinRend = (ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE) malloc( sizeof( ISAR_DEC_SPLIT_REND_WRAPPER ) ) ) == NULL ) { @@ -5933,7 +6537,15 @@ static ivas_error ivas_create_handle_isar( isar_init_split_rend_handles( &hSplitBinRend->splitrend ); +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + hSplitBinRend->hMultiBinTdData = NULL; + FOR( i = 0; i < MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; ++i ) + { + hSplitBinRend->hMultiBinCldfbData[i] = NULL; + } +#else hSplitBinRend->hMultiBinCldfbData = NULL; +#endif hSplitBinRend->hCldfbDataOut = NULL; hSplitBinRend->numTdSamplesPerChannelCached = 0; @@ -5953,13 +6565,31 @@ static void ivas_destroy_handle_isar( ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE *hSplitBinRend /* i/o: ISAR split binaural rendering handle */ ) { +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + Word16 i; +#endif + IF( *hSplitBinRend != NULL ) { +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + IF( ( *hSplitBinRend )->hMultiBinTdData != NULL ) + { + ivas_TD_RINGBUF_Close( &( *hSplitBinRend )->hMultiBinTdData ); + } + FOR( i = 0; i < MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; ++i ) + { + IF( ( *hSplitBinRend )->hMultiBinCldfbData[i] != NULL ) + { + ivas_CLDFB_RINGBUF_Close( &( *hSplitBinRend )->hMultiBinCldfbData[i] ); + } + } +#else #ifdef TMP_FIX_SPLIT_REND free( ( *hSplitBinRend )->hMultiBinCldfbData ); ( *hSplitBinRend )->hMultiBinCldfbData = NULL; - #endif +#endif + ISAR_PRE_REND_close( &( *hSplitBinRend )->splitrend, NULL ); IF( ( *hSplitBinRend )->hCldfbDataOut != NULL ) @@ -6152,6 +6782,33 @@ static ivas_error ivas_dec_reconfig_split_rend( } +#ifdef FIX_1119_SPLIT_RENDERING_VOIP +/*-------------------------------------------------------------------* + * ivas_dec_split_rend_cldfb_in() + * + * + *-------------------------------------------------------------------*/ + +static Word16 ivas_dec_split_rend_cldfb_in( + const RENDERER_TYPE renderer_type /* i : renderer type */ +) +{ + if ( renderer_type == RENDERER_BINAURAL_FASTCONV || + renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || + renderer_type == RENDERER_BINAURAL_PARAMETRIC || + renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + { + return 1; + } + else + { + return 0; + } +} +#endif + + + /*-------------------------------------------------------------------* * ivas_dec_init_split_rend() * @@ -6165,11 +6822,18 @@ static ivas_error ivas_dec_init_split_rend( ivas_error error; Word16 cldfb_in_flag, pcm_out_flag; Word16 mixed_td_cldfb_flag; +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + Word16 i, num_poses; +#endif pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; cldfb_in_flag = 0; move16(); +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + cldfb_in_flag = ivas_dec_split_rend_cldfb_in( st_ivas->renderer_type ); +#else + #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 ) @@ -6186,9 +6850,37 @@ static ivas_error ivas_dec_init_split_rend( cldfb_in_flag = 1; move16(); } +#endif +#ifdef FIX_1119_SPLIT_RENDERING_VOIP ISAR_PRE_REND_GetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->sr_pose_pred_axis : DEFAULT_AXIS ); + num_poses = st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; + assert( num_poses <= MAX_HEAD_ROT_POSES ); + + IF( cldfb_in_flag ) + { + FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; ++i ) + { + /* note: this is intra-frame heap memory */ + IF( ( error = ivas_CLDFB_RINGBUF_Open( &st_ivas->hSplitBinRend->hMultiBinCldfbData[i], CLDFB_NO_COL_MAX ) ) != IVAS_ERR_OK ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for split rendering structure" ); + } + } + } + ELSE + { + IF( ( error = ivas_TD_RINGBUF_Open( &st_ivas->hSplitBinRend->hMultiBinTdData, get_render_frame_size_samples( st_ivas->hDecoderConfig ), num_poses * BINAURAL_CHANNELS ) ) != IVAS_ERR_OK ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for split rendering structure" ); + } + } +#else + + ISAR_PRE_REND_GetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->sr_pose_pred_axis : DEFAULT_AXIS ); +#endif + IF( EQ_16( cldfb_in_flag, 1 ) && ( EQ_16( st_ivas->hSplitBinRend->splitrend.multiBinPoseData.poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) ) ) { IF( ( st_ivas->hSplitBinRend->hCldfbDataOut = (ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE) malloc( sizeof( ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA ) ) ) == NULL ) diff --git a/lib_isar/isar_prot.h b/lib_isar/isar_prot.h index ca02665b4..7d7b16f67 100644 --- a/lib_isar/isar_prot.h +++ b/lib_isar/isar_prot.h @@ -67,8 +67,13 @@ void isar_splitBinPreRendClose( void lc3plusTimeAlignCldfbPoseCorr( SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renderer handle */ - Word32 Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: Binaural signals, real part */ - Word32 Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: Binaural signals, imag. part */ +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + Word32 *Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX], /* i/o: Binaural signals, real part */ + Word32 *Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX], /* i/o: Binaural signals, imag. part */ +#else + Word32 Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], +#endif Word16 *Q_in ); @@ -187,11 +192,16 @@ void isar_splitBinLCLDEncClose( ); void isar_splitBinLCLDEncProcess( - ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE hSplitBinLCLDEnc, /* i/o: ISAR LCLD encoder handle */ + ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE hSplitBinLCLDEnc, /* i/o: ISAR LCLD encoder handle */ +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + Word32 *Cldfb_In_Real_fx[][CLDFB_NO_COL_MAX], /* i/o: Binaural signals, real part */ + Word32 *Cldfb_In_Imag_fx[][CLDFB_NO_COL_MAX], /* i/o: Binaural signals, imag. part */ +#else Word32 Cldfb_In_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], Word32 Cldfb_In_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - const Word32 available_bits, - ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ +#endif + const Word32 available_bits, /* i : available bit-budget */ + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ Word16 *q_final ); @@ -282,12 +292,20 @@ void isar_rend_CldfbSplitPostRendProcess( ); void isar_rend_CldfbSplitPreRendProcess( - const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, - const IVAS_QUATERNION headPosition, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, /* i : binaural pre-renderer handle */ + const IVAS_QUATERNION headPosition, /* i : head rotation QUATERNION */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + Word32* Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX], /* i : Binaural signals, real part */ +#else Word32 Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], +#endif Word16 exp_cldfb_re, +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + Word32* Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX], /* i : Binaural signals, imag. part */ +#else Word32 Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], +#endif Word16 exp_cldfb_im, ISAR_SPLIT_REND_BITS_HANDLE pBits, const Word32 target_md_bits, diff --git a/lib_isar/isar_splitRend_lcld_enc.c b/lib_isar/isar_splitRend_lcld_enc.c index e6efe1ff2..b1249653f 100644 --- a/lib_isar/isar_splitRend_lcld_enc.c +++ b/lib_isar/isar_splitRend_lcld_enc.c @@ -152,10 +152,15 @@ void isar_splitBinLCLDEncClose( *------------------------------------------------------------------------*/ void isar_splitBinLCLDEncProcess( ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE hSplitBinLCLDEnc, +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + Word32 *Cldfb_In_Real_fx[][CLDFB_NO_COL_MAX], /* i/o: Binaural signals, real part */ + Word32 *Cldfb_In_Imag_fx[][CLDFB_NO_COL_MAX], /* i/o: Binaural signals, imag part */ +#else Word32 Cldfb_In_Real_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], Word32 Cldfb_In_Imag_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - const Word32 available_bits, - ISAR_SPLIT_REND_BITS_HANDLE pBits, +#endif + const Word32 available_bits, /* i : available bit-budget */ + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ Word16 *q_final ) { Word32 iBitsWritten, itr, available_bits_itr, rem_itr, available_bits_local; diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c index 71e285a9c..ebb07b720 100644 --- a/lib_isar/isar_splitRendererPre.c +++ b/lib_isar/isar_splitRendererPre.c @@ -50,6 +50,25 @@ #endif #include "basop_util.h" +/*---------------------------------------------------------------------* + * Local function declarations + *---------------------------------------------------------------------*/ + +static void isar_SplitRenderer_GetRotMd_fx( ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + Word32 *Cldfb_RealBuffer_Ref_Binaural_fx[][CLDFB_NO_COL_MAX], + Word16 exp_cldfb_re, + Word32 *Cldfb_ImagBuffer_Ref_Binaural_fx[][CLDFB_NO_COL_MAX], + Word16 exp_cldfb_im, +#else + Word32 Cldfb_RealBuffer_Ref_Binaural_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word16 exp_cldfb_re, + Word32 Cldfb_ImagBuffer_Ref_Binaural_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word16 exp_cldfb_im, +#endif + const Word16 low_res, + const Word16 ro_md_flag ); /*------------------------------------------------------------------------- * Local functions @@ -505,15 +524,29 @@ static void ComputePostPredCov_fx( static void ComputeBandedCrossCov_fx( +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + Word32 *Cldfb_RealBuffer1_fx[][CLDFB_NO_COL_MAX], + Word16 exp_cldfb_re_1, + Word32 *Cldfb_ImagBuffer1_fx[][CLDFB_NO_COL_MAX], + Word16 exp_cldfb_im_1, +#else Word32 Cldfb_RealBuffer1_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], Word16 exp_cldfb_re_1, Word32 Cldfb_ImagBuffer1_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], Word16 exp_cldfb_im_1, +#endif const Word16 ch_start_idx1, +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + Word32 *Cldfb_RealBuffer2_fx[][CLDFB_NO_COL_MAX], + Word16 exp_cldfb_re_2, + Word32 *Cldfb_ImagBuffer2_fx[][CLDFB_NO_COL_MAX], + Word16 exp_cldfb_im_2, +#else Word32 Cldfb_RealBuffer2_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], Word16 exp_cldfb_re_2, Word32 Cldfb_ImagBuffer2_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], Word16 exp_cldfb_im_2, +#endif const Word16 ch_start_idx2, Word32 out_cov_re_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word16 *exp_out_cov_re, @@ -646,10 +679,17 @@ static void ComputeBandedCrossCov_fx( static void ComputeBandedCov_fx( +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + Word32 *Cldfb_RealBuffer_fx[][CLDFB_NO_COL_MAX], + Word16 exp_cldfb_re, + Word32 *Cldfb_ImagBuffer_fx[][CLDFB_NO_COL_MAX], + Word16 exp_cldfb_im, +#else Word32 Cldfb_RealBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], Word16 exp_cldfb_re, Word32 Cldfb_ImagBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], Word16 exp_cldfb_im, +#endif const Word16 ch_start_idx, Word32 out_cov_re_fx[][BINAURAL_CHANNELS], Word16 *exp_cov_re, @@ -2142,14 +2182,20 @@ static void isar_SplitRenderer_quant_code( * * *------------------------------------------------------------------------*/ - static void isar_SplitRenderer_GetRotMd_fx( ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, /* i/o: binaural renderer handle */ - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + Word32 *Cldfb_RealBuffer_Ref_Binaural_fx[][CLDFB_NO_COL_MAX], /* o : Reference Binaural signals */ + Word16 exp_cldfb_re, + Word32 *Cldfb_ImagBuffer_Ref_Binaural_fx[][CLDFB_NO_COL_MAX], /* o : Reference Binaural signals */ + Word16 exp_cldfb_im, +#else Word32 Cldfb_RealBuffer_Ref_Binaural_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : Reference Binaural signals */ Word16 exp_cldfb_re, Word32 Cldfb_ImagBuffer_Ref_Binaural_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : Reference Binaural signals */ Word16 exp_cldfb_im, +#endif const Word16 low_res, const Word16 ro_md_flag ) { @@ -2245,17 +2291,25 @@ static void isar_SplitRenderer_GetRotMd_fx( *------------------------------------------------------------------------*/ void isar_rend_CldfbSplitPreRendProcess( - const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, - const IVAS_QUATERNION headPosition, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, /* i : binaural pre-renderer handle */ + const IVAS_QUATERNION headPosition, /* i : head rotation QUATERNION */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + Word32 *Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX], /* i : Binaural signals, real part */ + Word16 exp_cldfb_re, + Word32 *Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX], + Word16 exp_cldfb_im, +#else Word32 Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], Word16 exp_cldfb_re, Word32 Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], Word16 exp_cldfb_im, - ISAR_SPLIT_REND_BITS_HANDLE pBits, - const Word32 target_md_bits, - const Word16 low_res_pre_rend_rot, - const Word16 ro_md_flag ) +#endif + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + const Word32 target_md_bits, /* i : ISAR MD bitrate */ + const Word16 low_res_pre_rend_rot, /* i : low time resolution pre-renderer flag */ + const Word16 ro_md_flag /* i : real only metadata for yaw flag */ +) { push_wmops( "isar_rend_CldfbSplitPreRendProcess" ); @@ -2860,6 +2914,11 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( UWord8 useLc3plus; Word32 *in_delayed_fx[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS]; Word16 i; +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + int16_t j; + Word32 *p_Cldfb_In_BinReal[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX]; + Word32 *p_Cldfb_In_BinImag[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX]; +#endif Word32 num_slots; push_wmops( "isar_renderMultiTDBinToSplitBinaural" ); @@ -2869,6 +2928,17 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( useLc3plus = hSplitBin->hLc3plusEnc != NULL; +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + for ( i = 0; i < MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; ++i ) + { + for ( j = 0; j < CLDFB_NO_COL_MAX; ++j ) + { + p_Cldfb_In_BinReal[i][j] = Cldfb_In_BinReal_fx[i][j]; + p_Cldfb_In_BinImag[i][j] = Cldfb_In_BinImag_fx[i][j]; + } + } +#endif + IF( useLc3plus ) { /*this should always have the time resolution of pose correction MD. Note that this does not change frame size of LC3plus*/ @@ -2989,7 +3059,25 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( q_final = add( q_final, scale_factor ); Word16 exp_cldfb_re = sub( 31, q_final ); Word16 exp_cldfb_im = sub( 31, q_final ); - isar_rend_CldfbSplitPreRendProcess( hSplitBin->hBinHrSplitPreRend, headPosition, &hSplitBin->multiBinPoseData, Cldfb_In_BinReal_fx, exp_cldfb_re, Cldfb_In_BinImag_fx, exp_cldfb_im, pBits, target_md_bits, low_res_pre_rend_rot, ro_md_flag ); + isar_rend_CldfbSplitPreRendProcess( + hSplitBin->hBinHrSplitPreRend, + headPosition, + &hSplitBin->multiBinPoseData, +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + p_Cldfb_In_BinReal, + exp_cldfb_re, + p_Cldfb_In_BinImag, + exp_cldfb_im, +#else + Cldfb_In_BinReal_fx, + exp_cldfb_re, + Cldfb_In_BinImag_fx, + exp_cldfb_im, +#endif + pBits, + target_md_bits, + low_res_pre_rend_rot, + ro_md_flag ); } IF( EQ_16( pcm_out_flag, 0 ) ) @@ -3009,7 +3097,18 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( move16(); pBits->isar_frame_size_ms = isar_frame_size_ms; move16(); - isar_splitBinLCLDEncProcess( hSplitBin->hSplitBinLCLDEnc, Cldfb_In_BinReal_fx, Cldfb_In_BinImag_fx, available_bits, pBits, &q_final ); + isar_splitBinLCLDEncProcess( + hSplitBin->hSplitBinLCLDEnc, +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + p_Cldfb_In_BinReal, + p_Cldfb_In_BinImag, +#else + Cldfb_In_BinReal_fx, + Cldfb_In_BinImag_fx, +#endif + available_bits, + pBits, + &q_final ); } ELSE { @@ -3085,9 +3184,14 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( *------------------------------------------------------------------------*/ void lc3plusTimeAlignCldfbPoseCorr( - SPLIT_REND_WRAPPER *hSplitBin, - Word32 Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word32 Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renderer handle */ +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + Word32 *Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX], /* i/o: Binaural signals, real part */ + Word32 *Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX], /* i/o: Binaural signals, imag. part */ +#else + Word32 Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: Binaural signals, real part */ + Word32 Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: Binaural signals, imag. part */ +#endif Word16 *Q_in ) { Word32 Cldfb_In_BinReal_tmp_fx[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][2][CLDFB_NO_CHANNELS_MAX]; @@ -3107,7 +3211,12 @@ void lc3plusTimeAlignCldfbPoseCorr( } ELSE { +#ifdef FIX_1119_SPLIT_RENDERING_VOIP // NOTE(sgi): BASOP special - not in float version + FOR( Word16 i = 0; i < i_mult( hSplitBin->multiBinPoseData.num_poses, BINAURAL_CHANNELS ); i++ ) +#else FOR( Word16 i = 0; i < CLDFB_NO_COL_MAX; i++ ) +#endif + { for ( Word16 j = 0; j < CLDFB_NO_COL_MAX; j++ ) { diff --git a/lib_isar/isar_stat.h b/lib_isar/isar_stat.h index 351cb4525..4576e7c1d 100644 --- a/lib_isar/isar_stat.h +++ b/lib_isar/isar_stat.h @@ -256,5 +256,17 @@ typedef struct Word32 lc3plusDelaySamples; } SPLIT_REND_WRAPPER; +#ifdef FIX_1119_SPLIT_RENDERING_VOIP +typedef struct +{ + Word32 *real; + Word32 *imag; + Word16 capacity; + Word16 write_pos; + Word16 read_pos; + Word16 is_full; + +} ISAR_CLDFB_RINGBUF, *ISAR_CLDFB_RINGBUF_HANDLE; +#endif #endif /* ISAR_STAT_H */ diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index 1ba5cafc4..20cfc9f4d 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -278,21 +278,26 @@ void ISAR_PRE_REND_GetMultiBinPoseData( *------------------------------------------------------------------------*/ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( - SPLIT_REND_WRAPPER *hSplitBin, - const IVAS_QUATERNION headPosition, - const Word32 SplitRendBitRate, - ISAR_SPLIT_REND_CODEC splitCodec, - const Word16 isar_frame_size_ms, /* i: ISAR framesize */ - Word16 codec_frame_size_ms, + SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renerer handle */ + const IVAS_QUATERNION headPosition, /* i : head rotation QUATERNION */ + const Word32 SplitRendBitRate, /* i : Split renderer bitrate */ + ISAR_SPLIT_REND_CODEC splitCodec, /* i/o: Split renderer codec */ + const Word16 isar_frame_size_ms, /* i : ISAR framesize */ + Word16 codec_frame_size_ms, /* i/o: ISAR transport codec framesize */ ISAR_SPLIT_REND_BITS_HANDLE pBits, +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + Word32 *Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX], /* i/o: CLDFB real buffer */ + Word32 *Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX], /* i/o: CLDFB imag buffer */ +#else Word32 Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], Word32 Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - const Word16 max_bands, - Word32 *pOutput_fx[], - const Word16 low_res_pre_rend_rot, - const Word16 cldfb_in_flag, - const Word16 pcm_out_flag, - const Word16 ro_md_flag, +#endif + const Word16 max_bands, /* i : CLDFB bands */ + Word32 *pOutput_fx[], /* i/o: PCM in/out buffer */ + const Word16 low_res_pre_rend_rot, /* i : low time resolution pre-renderer flag */ + const Word16 cldfb_in_flag, /* i : Flag to indicate CLDFB or time domain input */ + const Word16 pcm_out_flag, /* i : Flag to indicate PCM output */ + const Word16 ro_md_flag, /* i : Flag to indicate real only metadata for yaw */ Word16 Q_buff, Word16 *Q_out ) { @@ -405,7 +410,7 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( tmp_e = 0; tmp = BASOP_Util_Divide3232_Scale( L_mult0( CLDFB_NO_COL_MAX, ivas_fs ), 20, &tmp_e ); - num_slots = shr( tmp, sub( 15, tmp_e ) ); // Q0 + num_slots = shr( tmp, sub( 15, tmp_e ) ); // Q0 // NOTE(sgi): this could be a macro constant? // num_slots = (Word16) CLDFB_NO_COL_MAX * ivas_fs / 20; /* CLDFB synthesis of main pose */ { @@ -415,7 +420,11 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( move16(); FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { +#ifdef FIX_1119_SPLIT_RENDERING_VOIP /* NOTE(sgi): BASOP special - not in float version */ + FOR( j = 0; j < num_slots; j++ ) +#else FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) +#endif { q1 = s_min( getScaleFactor32( Cldfb_In_BinReal_fx[ch][j], CLDFB_NO_CHANNELS_MAX ), q1 ); q2 = s_min( getScaleFactor32( Cldfb_In_BinImag_fx[ch][j], CLDFB_NO_CHANNELS_MAX ), q2 ); @@ -429,7 +438,11 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { +#ifdef FIX_1119_SPLIT_RENDERING_VOIP /* NOTE(sgi): BASOP special - not in float version */ + FOR( j = 0; j < num_slots; j++ ) +#else FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) +#endif { Scale_sig32( Cldfb_In_BinReal_fx[ch][j], CLDFB_NO_CHANNELS_MAX, sub( q_final, Q_buff_re ) ); Scale_sig32( Cldfb_In_BinImag_fx[ch][j], CLDFB_NO_CHANNELS_MAX, sub( q_final, Q_buff_im ) ); @@ -480,7 +493,13 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( } ELSE { - Word16 ch, slot_idx; + Word16 ch, slot_idx, num_slots; +#if 0 // NOTE(sgi2det): This shift left here doesn't correspond to what the original code does. + num_slots = shl( isar_frame_size_ms, 3); /* ( isar_frame_size_ms * 1000000 / CLDFB_SLOT_NS ); */ +#else + num_slots = isar_frame_size_ms * 1000000 / CLDFB_SLOT_NS; +#endif + /* CLDFB synthesis of main pose */ FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { @@ -490,7 +509,7 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( move16(); q2 = 31; move16(); - FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) + FOR( j = 0; j < num_slots; j++ ) // NOTE(sgi): BASOP special - not in float version { q1 = s_min( getScaleFactor32( Cldfb_In_BinReal_fx[ch][j], CLDFB_NO_CHANNELS_MAX ), q1 ); q2 = s_min( getScaleFactor32( Cldfb_In_BinImag_fx[ch][j], CLDFB_NO_CHANNELS_MAX ), q2 ); @@ -499,13 +518,13 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( q_final = s_min( add( Q_buff_re, q_final ), add( Q_buff_im, q_final ) ); q_final = sub( q_final, 6 ); // guard bits q_final = s_min( q_final, Q25 ); - FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) + FOR( j = 0; j < num_slots; j++ ) // NOTE(sgi): BASOP special - not in float version { Scale_sig32( Cldfb_In_BinReal_fx[ch][j], CLDFB_NO_CHANNELS_MAX, sub( q_final, Q_buff_re ) ); Scale_sig32( Cldfb_In_BinImag_fx[ch][j], CLDFB_NO_CHANNELS_MAX, sub( q_final, Q_buff_im ) ); } - FOR( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX; slot_idx++ ) + FOR( slot_idx = 0; slot_idx < num_slots; slot_idx++ ) { Cldfb_In_BinReal_p_fx[slot_idx] = Cldfb_In_BinReal_fx[ch][slot_idx]; move32(); @@ -516,7 +535,7 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( Q_cldfb = q_final; move16(); Scale_sig32( hSplitBin->hCldfbHandles->cldfbSyn[ch]->cldfb_state_fx, hSplitBin->hCldfbHandles->cldfbSyn[ch]->p_filter_length, sub( sub( Q_cldfb, 1 ), hSplitBin->hCldfbHandles->cldfbSyn[ch]->Q_cldfb_state ) ); - cldfbSynthesis_ivas_fx( Cldfb_In_BinReal_p_fx, Cldfb_In_BinImag_p_fx, pOutput_fx[ch], hSplitBin->hCldfbHandles->cldfbSyn[0]->no_channels * CLDFB_NO_COL_MAX, 0, 0, hSplitBin->hCldfbHandles->cldfbSyn[ch] ); // Q_cldfb - 1 + cldfbSynthesis_ivas_fx( Cldfb_In_BinReal_p_fx, Cldfb_In_BinImag_p_fx, pOutput_fx[ch], hSplitBin->hCldfbHandles->cldfbSyn[0]->no_channels * num_slots, 0, 0, hSplitBin->hCldfbHandles->cldfbSyn[ch] ); // Q_cldfb - 1 Q_out[ch] = sub( Q_cldfb, 1 ); move16(); hSplitBin->hCldfbHandles->cldfbSyn[ch]->Q_cldfb_state = Q_out[ch]; diff --git a/lib_isar/lib_isar_pre_rend.h b/lib_isar/lib_isar_pre_rend.h index 772637db9..9ee1aae86 100644 --- a/lib_isar/lib_isar_pre_rend.h +++ b/lib_isar/lib_isar_pre_rend.h @@ -70,8 +70,13 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( const Word16 isar_frame_size_ms, /* i : ISAR framesize */ Word16 codec_frame_size_ms, /* i/o: Split renderer codec framesize */ ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: Split renderer bitstream handle */ +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + Word32* Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX], /* i/o: CLDFB real buffer */ + Word32* Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX], /* i/o: CLDFB imag buffer */ +#else Word32 Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: CLDFB real buffer */ Word32 Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: CLDFB imag buffer */ +#endif const Word16 max_bands, /* i : CLDFB bands */ Word32 *pOutput_fx[], /* i : low time resolution pre-renderer flag */ const Word16 low_res_pre_rend_rot, /* i : low time resolution pre-renderer flag */ diff --git a/lib_rend/ivas_cldfb_ring_buffer.c b/lib_rend/ivas_cldfb_ring_buffer.c new file mode 100644 index 000000000..eacf7f3fe --- /dev/null +++ b/lib_rend/ivas_cldfb_ring_buffer.c @@ -0,0 +1,321 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#include "cnst.h" +#include "prot_fx.h" +#include "ivas_prot_fx.h" +#include +#ifdef DEBUGGING +#include "debug.h" +#endif +#include "wmc_auto.h" + +#ifdef FIX_1119_SPLIT_RENDERING_VOIP +/*---------------------------------------------------------------------* + * CLDFB ring-buffer functions needed in split-rendering outputs + *---------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------* + * ivas_cldfb_ringbuf_IsEmpty() + * + * Returns 1 if the ring buffer is empty, or 0 otherwise. + *---------------------------------------------------------------------*/ + +static Word16 ivas_cldfb_ringbuf_IsEmpty( + ISAR_CLDFB_RINGBUF_HANDLE h ) +{ + test(); + return EQ_16( h->read_pos, h->write_pos ) && !h->is_full; +} + + +/*---------------------------------------------------------------------* + * ivas_cldfb_ringbuf_IsFull() + * + * Returns 1 if the ring buffer is full, or 0 otherwise. + *---------------------------------------------------------------------*/ + +static Word32 ivas_cldfb_ringbuf_IsFull( + ISAR_CLDFB_RINGBUF_HANDLE h ) +{ + return h->is_full; +} + + +/*---------------------------------------------------------------------* + * ivas_CLDFB_RINGBUF_Open() + * + * Allocate a ring buffer for CLDFB data with the given capacity of CLDFB columns. + * Each column is expected to contain at most CLDFB_NO_CHANNELS_MAX frequency bands. + * + * May return IVAS_ERR_FAILED_ALLOC on failed allocation, or IVAS_ERR_OK otherwise. + *---------------------------------------------------------------------*/ + +ivas_error ivas_CLDFB_RINGBUF_Open( + ISAR_CLDFB_RINGBUF_HANDLE *ph, + const Word16 capacity_columns ) +{ + ISAR_CLDFB_RINGBUF_HANDLE h; + Word16 capacity; + + capacity = i_mult( capacity_columns, CLDFB_NO_CHANNELS_MAX ); + move16(); + + IF ( ( h = malloc( sizeof( ISAR_CLDFB_RINGBUF ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for CLDFB ring buffer\n" ); + } + h->real = NULL; + h->imag = NULL; + h->capacity = 0; + move16(); + h->write_pos = 0; + move16(); + h->read_pos = 0; + move16(); + h->is_full = 0; + move16(); + *ph = h; + + IF ( ( h->real = malloc( capacity * sizeof( Word32 ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for CLDFB ring buffer\n" ); + } + IF ( ( h->imag = malloc( capacity * sizeof( Word32 ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for CLDFB ring buffer\n" ); + } + h->capacity = capacity; + move16(); + + return IVAS_ERR_OK; +} + + +/*---------------------------------------------------------------------* + * ivas_CLDFB_RINGBUF_Close() + * + * Dellocate CLDFB ring buffer. The given handle will be set to NULL. + *---------------------------------------------------------------------*/ + +void ivas_CLDFB_RINGBUF_Close( + ISAR_CLDFB_RINGBUF_HANDLE *ph ) +{ + ISAR_CLDFB_RINGBUF_HANDLE h; + + IF ( ph == NULL ) + { + return; + } + h = *ph; + + IF ( h == NULL ) + { + return; + } + + IF ( h->real != NULL ) + { + free( h->real ); + } + IF ( h->imag != NULL ) + { + free( h->imag ); + } + + free( h ); + *ph = NULL; + + return; +} + + +/*---------------------------------------------------------------------* + * ivas_CLDFB_RINGBUF_Push() + * + * Push a single column onto the back of the CLDFB ring buffer from real and imag arrays. + *---------------------------------------------------------------------*/ + +void ivas_CLDFB_RINGBUF_Push( + ISAR_CLDFB_RINGBUF_HANDLE h, + const Word32 *real, + const Word32 *imag, + const Word16 num_bands ) +{ + assert( num_bands <= CLDFB_NO_CHANNELS_MAX ); + assert( !ivas_cldfb_ringbuf_IsFull( h ) ); + + Copy32( real, &h->real[h->write_pos], num_bands ); + Copy32( imag, &h->imag[h->write_pos], num_bands ); + + h->write_pos = add( h->write_pos, CLDFB_NO_CHANNELS_MAX ); + move16(); + if ( EQ_16( h->write_pos, h->capacity ) ) + { + h->write_pos = 0; + move16(); + } + + if ( EQ_16( h->read_pos, h->write_pos ) ) + { + h->is_full = 1; + move16(); + } + + return; +} + + +/*---------------------------------------------------------------------* + * ivas_CLDFB_RINGBUF_Pop() + * + * Pop a single column from the front of the CLDFB ring buffer into real and imag arrays. + *---------------------------------------------------------------------*/ + +void ivas_CLDFB_RINGBUF_Pop( + ISAR_CLDFB_RINGBUF_HANDLE h, + Word32 *real, + Word32 *imag, + const Word16 num_bands ) +{ + assert( num_bands <= CLDFB_NO_CHANNELS_MAX ); + assert( !ivas_cldfb_ringbuf_IsEmpty( h ) ); + + IF ( real != NULL ) + { + Copy32( &h->real[h->read_pos], real, num_bands ); + } + IF ( imag != NULL ) + { + Copy32( &h->imag[h->read_pos], imag, num_bands ); + } + + h->read_pos = add( h->read_pos, CLDFB_NO_CHANNELS_MAX ); + move16(); + IF ( EQ_16( h->read_pos, h->capacity ) ) + { + h->read_pos = 0; + move16(); + } + + h->is_full = 0; + move16(); + + return; +} + + +/*---------------------------------------------------------------------* + * ivas_cldfb_ringbuf_total_size() + * + * Returns total number of buffered samples (including number of channels) + *---------------------------------------------------------------------*/ + +static uint32_t ivas_cldfb_ringbuf_total_size( + ISAR_CLDFB_RINGBUF_HANDLE h ) +{ + IF ( ivas_cldfb_ringbuf_IsFull( h ) ) + { + return h->capacity; + } + + IF ( LE_16( h->read_pos, h->write_pos ) ) + { + return sub( h->write_pos, h->read_pos ); + } + + /* else wrap around */ + return add( h->write_pos, sub( h->capacity, h->read_pos ) ); +} + + +/*---------------------------------------------------------------------* + * ivas_CLDFB_RINGBUF_GetByIdx() + * + * Get pointers into a specific column in the CLDFB ring buffer based on given index. + * Non-negative indices access from the front of the ring buffer, negative indexes access + * from the back, similar to Python arrays. For example: + * + * - index 0 accesses the front of the buffer, i.e. the oldest CLDFB column in the queue. + * - index -1 accesses the back of the buffer, i.e. the newest (last pushed) CLDFB column in the queue. + *---------------------------------------------------------------------*/ + +void ivas_CLDFB_RINGBUF_GetByIdx( + ISAR_CLDFB_RINGBUF_HANDLE h, + Word32 **p_real, + Word32 **p_imag, + const Word16 col_idx ) +{ + Word16 idx = i_mult( col_idx, CLDFB_NO_CHANNELS_MAX ); + move16(); + Word16 num_floats = ivas_cldfb_ringbuf_total_size( h ); + move16(); + Word16 offset /*, uidx */; // uidx unused in FX code + + assert( -num_floats <= idx && idx <= num_floats ); + + IF ( GE_16( idx, 0 ) ) + { + offset = add( h->read_pos, idx ); + move16(); + if ( LE_16( h->capacity, offset ) ) + { + offset = sub( offset, h->capacity ); + move16(); + } + } + ELSE + { + idx = negate( idx ); + move16(); + IF ( LE_16 ( idx, h->write_pos ) ) + { + offset = sub( h->write_pos, idx ); + move16(); + } + ELSE + { + offset = add( h->write_pos, sub( h->capacity, idx ) ); + move16(); + } + } + + *p_real = &h->real[offset]; + move16(); + *p_imag = &h->imag[offset]; + move16(); + + return; +} +#endif diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 0539b7b85..dae32647a 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -1111,8 +1111,12 @@ static void ivas_dirac_dec_binaural_internal_fx( { FOR( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe]; i++ ) { +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + ivas_CLDFB_RINGBUF_Push( st_ivas->hSplitBinRend->hMultiBinCldfbData[ch], tmp_Cldfb_out_re[ch][i], tmp_Cldfb_out_im[ch][i], CLDFB_NO_CHANNELS_MAX ); +#else Copy32( tmp_Cldfb_out_re[ch][i], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural_fx[ch][hSpatParamRendCom->slots_rendered + i], CLDFB_NO_CHANNELS_MAX ); Copy32( tmp_Cldfb_out_im[ch][i], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural_fx[ch][hSpatParamRendCom->slots_rendered + i], CLDFB_NO_CHANNELS_MAX ); +#endif } } } @@ -1172,11 +1176,19 @@ static void ivas_dirac_dec_binaural_internal_fx( Copy( st_ivas->hDiracDecBin[0]->ChCrossIm_e, hDiracDecBin->ChCrossIm_e, hSpatParamRendCom->num_freq_bands ); ivas_dirac_dec_binaural_formulate_target_covariance_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, Rmat_local, subframe, +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, +#else hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, +#endif subFrameTotalEne_fx, subFrameTotalEne_e, IIReneLimiter_fx, st_ivas->hMasaIsmData ); ivas_dirac_dec_binaural_determine_processing_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, max_band_decorr, Rmat_local, subframe, +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, +#else hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, +#endif nchanSeparateChannels, st_ivas->hMasaIsmData ); q_mat = hDiracDecBin->q_processMtx; @@ -1224,8 +1236,12 @@ static void ivas_dirac_dec_binaural_internal_fx( { FOR( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe]; i++ ) { +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + ivas_CLDFB_RINGBUF_Push( st_ivas->hSplitBinRend->hMultiBinCldfbData[pos_idx * BINAURAL_CHANNELS + ch], tmp_Cldfb_out_re[ch][i], tmp_Cldfb_out_im[ch][i], CLDFB_NO_CHANNELS_MAX ); +#else Copy32( tmp_Cldfb_out_re[ch][i], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural_fx[pos_idx * BINAURAL_CHANNELS + ch][hSpatParamRendCom->slots_rendered + i], CLDFB_NO_CHANNELS_MAX ); Copy32( tmp_Cldfb_out_im[ch][i], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural_fx[pos_idx * BINAURAL_CHANNELS + ch][hSpatParamRendCom->slots_rendered + i], CLDFB_NO_CHANNELS_MAX ); +#endif } } diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index 250fea751..d978d9034 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -1594,6 +1594,68 @@ void ivas_rend_closeCldfbRend( CLDFB_REND_WRAPPER *pCldfbRend ); +#ifdef FIX_1119_SPLIT_RENDERING_VOIP_TD_RINGBUF +/*----------------------------------------------------------------------------------* + * Time domain ring buffer prototypes + *----------------------------------------------------------------------------------*/ + +ivas_error ivas_TD_RINGBUF_Open( + TD_RINGBUF_HANDLE *ph, /* i/o: Ring buffer handle */ + const Word16 capacity_per_channel, /* i : Number of samples stored per channel */ + const Word16 num_channels /* i : Number of channels */ +); + +void ivas_TD_RINGBUF_Close( + TD_RINGBUF_HANDLE *ph /* i/o: Ring buffer handle */ +); + +#ifdef FIX_1119_SPLIT_RENDERING_VOIP +void ivas_TD_RINGBUF_PushInterleaved( + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + const Word32 *data, /* i : Input audio in interleaved channels layout */ + const Word16 num_samples_per_channel /* i : Number of samples per channel to push */ +); + +void ivas_TD_RINGBUF_PushChannels( + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + const Word32 *p_channels[], /* i : Array of pointers to each input channel */ + const Word16 num_samples_per_channel /* i : Number of samples per channel to store */ +); + +void ivas_TD_RINGBUF_PushConstant( + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + const Word32 value, /* i : Value to push */ + const Word16 num_samples_per_channel /* i : Number of samples per channel to push */ +); + +void ivas_TD_RINGBUF_PopChannels( + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + Word32 *p_channels[], /* i : Array of pointers to each output channel */ + const Word16 num_samples_per_channel /* i : Number of samples per channel to pop */ +); +#else +void ivas_TD_RINGBUF_Push( + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + const Word32 *data, /* i : Input data */ + const Word16 num_samples_per_channel /* i : Number of samples per channel to store */ +); + +void ivas_TD_RINGBUF_PushZeros( + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + const Word16 num_samples_per_channel /* i : Number of zeros per channel to store */ +); + +void ivas_TD_RINGBUF_Pop( + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + Word32 *data, /* i : Output data */ + const Word16 num_samples_per_channel /* i : Number of samples per channel to retrieve*/ +); +#endif + +Word16 ivas_TD_RINGBUF_Size( // bit width? + const TD_RINGBUF_HANDLE h /* i : Ring buffer handle */ +); +#endif /* clang-format on */ diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index aec8eb3b9..23489353f 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1432,6 +1432,22 @@ typedef struct } CLDFB_REND_WRAPPER; +#ifdef FIX_1119_SPLIT_RENDERING_VOIP_TD_RINGBUF +/*----------------------------------------------------------------------------------* + * Time domain ring buffer structure + *----------------------------------------------------------------------------------*/ + +typedef struct +{ + Word32 *data; /* samples in interleaved layout */ + Word32 capacity; + Word16 num_channels; + Word32 write_pos; + Word32 read_pos; + Word16 is_full; + +} TD_RINGBUF_DATA, *TD_RINGBUF_HANDLE; +#endif /*----------------------------------------------------------------------------------* * Limiter structure diff --git a/lib_rend/ivas_td_ring_buffer.c b/lib_rend/ivas_td_ring_buffer.c new file mode 100644 index 000000000..a79d7b0c7 --- /dev/null +++ b/lib_rend/ivas_td_ring_buffer.c @@ -0,0 +1,448 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include +#include "ivas_error_utils.h" +#include "ivas_prot_rend_fx.h" +#include "options.h" +#include "wmc_auto.h" + + +#ifdef FIX_1119_SPLIT_RENDERING_VOIP_TD_RINGBUF + +/*-----------------------------------------------------------------------* + * Local function prototypes + *-----------------------------------------------------------------------*/ + +static Word32 ivas_td_ringbuf_total_size( + TD_RINGBUF_HANDLE h ) +{ + if ( h->is_full ) + { + return h->capacity; + } + + if ( LE_32( h->read_pos, h->write_pos ) ) + { + return L_sub( h->write_pos, h->read_pos ); + } + /* else wrap around */ + return L_add( h->write_pos, L_sub( h->capacity, h->read_pos ) ); +} + + +static Word16 ivas_td_ringbuf_has_space_for_num_samples( + TD_RINGBUF_HANDLE h, + const Word32 num_samples ) +{ + return LE_32( L_add( ivas_td_ringbuf_total_size( h ), num_samples ), h->capacity ); +} + + +#ifdef FIX_1119_SPLIT_RENDERING_VOIP +static void ivas_td_ringbuf_push_interleaved( + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + const Word32 *data, /* i : Input audio in interleaved channels layout */ + const Word16 num_samples_per_channel, /* i : Number of samples per channel to push */ + const Word16 read_stride /* i: : 1 for normal operation, 0 for reading from a single input value */ +) +{ + Word32 s, read_s; + + assert( h != NULL ); + assert( data != NULL ); + assert( read_stride == 0 || read_stride == 1 ); + assert( ivas_td_ringbuf_has_space_for_num_samples( h, num_samples_per_channel * h->num_channels ) ); + + read_s = 0; + move32(); + FOR ( s = 0; s < L_mult0( num_samples_per_channel, h->num_channels); ++s ) + { + h->data[h->write_pos] = data[read_s]; + move32(); + ++h->write_pos; + + if ( EQ_32( h->write_pos, h->capacity ) ) + { + h->write_pos = 0; + } + read_s = L_add( read_s, L_deposit_l( read_stride ) ); + move32(); + } + + if ( EQ_32( h->read_pos, h->write_pos ) ) + { + h->is_full = 1; + move16(); + } + + return; +} +#endif + + +/*-----------------------------------------------------------------------* + * Global function definitions + *-----------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------* + * ivas_TD_RINGBUF_Open() + * + * Allocate a ring buffer for TD data with the given capacity of TD samples per channel. + * + * May return IVAS_ERR_FAILED_ALLOC on failed allocation, or IVAS_ERR_OK otherwise. + *---------------------------------------------------------------------*/ + +ivas_error ivas_TD_RINGBUF_Open( + TD_RINGBUF_HANDLE *ph, /* i/o: Ring buffer handle */ + const Word16 capacity_per_channel, /* i : Number of samples stored per channel */ + const Word16 num_channels /* i : Number of channels */ +) +{ + TD_RINGBUF_HANDLE h; + Word32 capacity; + + capacity = L_mult0( capacity_per_channel, num_channels ); + move32(); + + h = malloc( sizeof( TD_RINGBUF_DATA ) ); + IF ( h == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for TD ring buffer\n" ); + } + h->data = NULL; + h->capacity = 0; + move32(); + h->num_channels = num_channels; + move16(); + h->write_pos = 0; + move32(); + h->read_pos = 0; + move32(); + h->is_full = 0; + move16(); + *ph = h; + + h->data = malloc( capacity * sizeof( Word32 ) ); + if ( h->data == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for TD ring buffer\n" ); + } + h->capacity = capacity; + move32(); + + return IVAS_ERR_OK; +} + + +/*---------------------------------------------------------------------* + * ivas_TD_RINGBUF_Close() + * + * Dellocate TD ring buffer. The given handle will be set to NULL. + + *---------------------------------------------------------------------*/ + +void ivas_TD_RINGBUF_Close( + TD_RINGBUF_HANDLE *ph /* i/o: Ring buffer handle */ +) +{ + TD_RINGBUF_HANDLE h; + + IF ( ph == NULL ) + { + return; + } + h = *ph; + + IF ( h == NULL ) + { + return; + } + + IF ( h->data != NULL ) + { + free( h->data ); + } + + free( h ); + *ph = NULL; + + return; +} + + +#ifdef FIX_1119_SPLIT_RENDERING_VOIP +/*---------------------------------------------------------------------* + * ivas_TD_RINGBUF_PushInterleaved() + * + * Push samples from a buffer with interleaved channel layout onto the back of the TD ring buffer. + *---------------------------------------------------------------------*/ + +void ivas_TD_RINGBUF_PushInterleaved( + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + const Word32 *data, /* i : Input audio in interleaved channels layout */ + const Word16 num_samples_per_channel /* i : Number of samples per channel to push */ +) +{ + ivas_td_ringbuf_push_interleaved( h, data, num_samples_per_channel, 1 ); + + return; +} + + +/*---------------------------------------------------------------------* + * ivas_TD_RINGBUF_PushChannels() + * + * Push samples from channel pointers onto the back of the TD ring buffer. + *---------------------------------------------------------------------*/ + +void ivas_TD_RINGBUF_PushChannels( + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + const Word32 *p_channels[], /* i : Array of pointers to each input channel */ + const Word16 num_samples_per_channel /* i : Number of samples per channel to push */ +) +#else +/*---------------------------------------------------------------------* + * ivas_TD_RINGBUF_Push() + * + * Push samples onto the back of the TD ring buffer. + * Returns total number of buffered samples (includes number of channels) + *---------------------------------------------------------------------*/ + +void ivas_TD_RINGBUF_Push( + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + const Word32 *data, /* i : Input data */ + const Word16 num_samples_per_channel /* i : Number of samples per channel to store */ +) +#endif +{ + Word32 s; + Word16 c; + +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + assert( h != NULL ); + assert( p_channels != NULL ); + for ( c = 0; c < h->num_channels; ++c ) /* Not using BASOP FOR because this loops only does assertions */ + { + assert( p_channels[c] != NULL ); + } +#endif + assert( ivas_td_ringbuf_has_space_for_num_samples( h, num_samples_per_channel * h->num_channels ) ); + + FOR ( s = 0; s < num_samples_per_channel; ++s ) + { + FOR ( c = 0; c < h->num_channels; ++c ) + { +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + h->data[h->write_pos] = p_channels[c][s]; + move32(); +#else + h->data[h->write_pos] = data[L_add( L_mult0( c, num_samples_per_channel ), s )]; + move32(); +#endif + ++h->write_pos; + + if ( EQ_32( h->write_pos, h->capacity ) ) + { + h->write_pos = 0; + move32(); + } + } + } + + if ( EQ_32( h->read_pos, h->write_pos ) ) + { + h->is_full = 1; + move16(); + } + + return; +} + + +#ifdef FIX_1119_SPLIT_RENDERING_VOIP +/*---------------------------------------------------------------------* + * ivas_TD_RINGBUF_PushConstant() + * + * Push samples with a constant value onto the back of the TD ring buffer. + *---------------------------------------------------------------------*/ + +void ivas_TD_RINGBUF_PushConstant( + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + const Word32 value, /* i : Value to push */ + const Word16 num_samples_per_channel /* i : Number of samples per channel to push */ +) +{ + ivas_td_ringbuf_push_interleaved( h, &value, num_samples_per_channel, 0 ); + + return; +} +#else +/*---------------------------------------------------------------------* + * ivas_TD_RINGBUF_PushZeros() + * + * Push zero samples onto the back of the TD ring buffer. + *---------------------------------------------------------------------*/ + +void ivas_TD_RINGBUF_PushZeros( + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + const Word16 num_samples_per_channel /* i : Number of zeros per channel to store */ +) +{ + Word32 s; + Word16 c; + + assert( ivas_td_ringbuf_has_space_for_num_samples( h, num_samples_per_channel * h->num_channels ) ); + if ( !num_samples_per_channel ) + { + return; + } + + FOR ( s = 0; s < num_samples_per_channel; ++s ) + { + FOR ( c = 0; c < h->num_channels; ++c ) + { + h->data[h->write_pos] = 0.f; + move32(); + ++h->write_pos; + + if ( EQ_32 ( h->write_pos == h->capacity ) ) + { + h->write_pos = 0; + move32(); + } + } + } + + if ( EQ_32( h->read_pos == h->write_pos ) ) + { + h->is_full = 1; + move16(); + } + + return; +} +#endif + + +#ifdef FIX_1119_SPLIT_RENDERING_VOIP +/*---------------------------------------------------------------------* + * ivas_TD_RINGBUF_PopChannels() + * + * Pop samples from the front of the TD ring buffer to an array of channel pointers. + *---------------------------------------------------------------------*/ + +void ivas_TD_RINGBUF_PopChannels( + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + Word32 *p_channels[], /* i : Array of pointers to each output channel */ + const Word16 num_samples_per_channel /* i : Number of samples per channel to pop */ +) +#else +/*---------------------------------------------------------------------* + * ivas_TD_RINGBUF_Pop() + * + * Pop samples from the front of the TD ring buffer. + *---------------------------------------------------------------------*/ + +void ivas_TD_RINGBUF_Pop( + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + Word32 *data, /* i : Output data */ + const Word16 num_samples_per_channel /* i : Number of samples per channel to retrieve */ +) +#endif +{ + Word32 s; + Word16 c; + +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + assert( h != NULL ); + assert( p_channels != NULL ); + for ( c = 0; c < h->num_channels; ++c ) /* Not using BASOP FOR because this loops only does assertions */ + { + assert( p_channels[c] != NULL ); + } +#endif + assert( ivas_td_ringbuf_total_size( h ) >= num_samples_per_channel * h->num_channels ); + + FOR ( s = 0; s < num_samples_per_channel; ++s ) + { + FOR ( c = 0; c < h->num_channels; ++c ) + { +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + p_channels[c][s] = h->data[h->read_pos]; + move32(); +#else + data[L_add( L_mult0( c, num_samples_per_channel ), s )) = h->data[h->read_pos]; + move32(); +#endif + ++h->read_pos; + + IF ( EQ_32( h->read_pos, h->capacity ) ) + { + h->read_pos = 0; + move32(); + } + } + } + +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + if ( NE_16( num_samples_per_channel, 0 ) ) + { + h->is_full = 0; + move16(); + } +#else + if ( h->is_full ) + { + h->is_full = 0; + move16(); + } +#endif + + return; +} + + +/*---------------------------------------------------------------------* + * ivas_TD_RINGBUF_Size() + * + * Returns number of buffered samples per channel. + *---------------------------------------------------------------------*/ + +Word16 ivas_TD_RINGBUF_Size( + const TD_RINGBUF_HANDLE h /* i : Ring buffer handle */ +) +{ + return ivas_td_ringbuf_total_size( h ) / (uint32_t) h->num_channels; // TODO(sgi): port division +} +#endif diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 5827cc275..52eba4dd1 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -8888,6 +8888,20 @@ static ivas_error getSamplesInternal( } Word32 *tmpBinaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS], tmpBinaural_buff[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][L_FRAME48k]; +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + // TODO(sgi): This doesn't match the original MR. BASOP main too far behind. Port later. + Word32 *p_Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX]; + Word32 *p_Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX]; + + for ( i = 0; i < BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES; ++i ) + { + for ( j = 0; j < CLDFB_NO_COL_MAX; ++j ) + { + p_Cldfb_RealBuffer_Binaural[i][j] = Cldfb_RealBuffer_Binaural[i][j]; + p_Cldfb_ImagBuffer_Binaural[i][j] = Cldfb_ImagBuffer_Binaural[i][j]; + } + } +#endif FOR( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) { @@ -8965,10 +8979,21 @@ static ivas_error getSamplesInternal( Q_out[0] = Q_out[0] + *outAudio.pq_fact; } +#ifdef FIX_1119_SPLIT_RENDERING_VOIP /* NOTE(sgi): BASOP special - not in float version */ 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, extract_l( Mpy_32_32( hIvasRend->sampleRateOut, 2684355 /*(BINAURAL_MAXBANDS / 48000) in Q31*/ ) ), 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, + p_Cldfb_RealBuffer_Binaural, p_Cldfb_ImagBuffer_Binaural, + extract_l( Mpy_32_32( hIvasRend->sampleRateOut, 2684355 /*(BINAURAL_MAXBANDS / 48000) in Q31*/ ) ), 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 ) +#else + 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, + extract_l( Mpy_32_32( hIvasRend->sampleRateOut, 2684355 /*(BINAURAL_MAXBANDS / 48000) in Q31*/ ) ), 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 ) +#endif { return error; } -- GitLab From 3812c58083641d8b1c66d4ff46687eacea396ca1 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Wed, 29 Oct 2025 16:50:21 +0100 Subject: [PATCH 03/40] Fixed scaling issues when outputting to SPLIT_BINAURAL_PCM from CLDFB split rendering --- lib_dec/lib_dec_fx.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 109863787..900c386e7 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1388,7 +1388,8 @@ static ivas_error isar_generate_metadata_and_bitstream( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ Word32 **p_head_pose_buf, /* i/o: PCM buffer with head-pose data */ Word16 nSamples, /* i : duration of audio (in samples per channel) for which metadata should be generated */ - ISAR_SPLIT_REND_BITS_DATA *splitRendBits /* o : output split rendering bits */ + ISAR_SPLIT_REND_BITS_DATA *splitRendBits,/* o : output split rendering bits */ + Word16* td_q /* o : Q-format of the TD output if rendering from CLDFB */ ) { // NOTE(sgi2det): Code in this function was moved and adapted from IVAS_DEC_GetSplitBinauralBitstream, @@ -1473,7 +1474,7 @@ static ivas_error isar_generate_metadata_and_bitstream( } // NOTE(sgi): BASOP special - not in float version Word16 q1 = 31, q2 = 31, Q_buff = 31; - Word16 Q_out[CLDFB_NO_COL_MAX]; // NOTE(sgi): Seems unnecessarily large. Only indices 0 and 1 are used, value at index 1 is writen but never read. + Word16 Q_out[CLDFB_NO_COL_MAX]; Q_out[0] = 31; IF( EQ_16( cldfb_in_flag, 1 ) ) @@ -1530,6 +1531,7 @@ static ivas_error isar_generate_metadata_and_bitstream( { return error; } + *td_q = Q_out[0]; return IVAS_ERR_OK; } @@ -1751,6 +1753,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( Word16 i; Word16 pcm_out_flag; Word16 numSamplesPerChannelToOutput; + Word16 td_q; if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { @@ -1782,7 +1785,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( p_head_pose_buf[i] = head_pose_buf[i]; } - if ( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nOutSamples, splitRendBits ) ) != IVAS_ERR_OK ) + if ( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nOutSamples, splitRendBits, &td_q ) ) != IVAS_ERR_OK ) { return error; } @@ -1804,7 +1807,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( #ifdef DEBUGGING st_ivas->noClipping += #endif - ivas_syn_output_fx( p_head_pose_buf, Q11, numSamplesPerChannelToOutput, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf_out ); + ivas_syn_output_fx( p_head_pose_buf, td_q, numSamplesPerChannelToOutput, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf_out ); } #else Decoder_Struct *st_ivas; @@ -5433,8 +5436,10 @@ ivas_error IVAS_DEC_VoIP_GetSamples #ifdef FIX_1119_SPLIT_RENDERING_VOIP IF( hIvasDec->hasDecodedFirstGoodFrame && splitRendBits != NULL ) { + Word16 td_q; + /* Analyse head poses over entire frame, generate ISAR metadata and maybe encode if split coded */ - IF( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nSamplesRendered, splitRendBits ) ) != IVAS_ERR_OK ) + IF( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nSamplesRendered, splitRendBits, &td_q ) ) != IVAS_ERR_OK ) { return error; } @@ -5456,7 +5461,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples #ifdef DEBUGGING st_ivas->noClipping += #endif - ivas_syn_output_fx( p_head_pose_buf, Q11, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf ); + ivas_syn_output_fx( p_head_pose_buf, td_q, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf ); } } #endif -- GitLab From 8c67d5ab8974352bc2d70e0ee3fe06106aa368c6 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Wed, 29 Oct 2025 17:07:46 +0100 Subject: [PATCH 04/40] Fix Q-factor for TD signal synthesis --- lib_dec/lib_dec_fx.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 900c386e7..babd4f715 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1531,7 +1531,11 @@ static ivas_error isar_generate_metadata_and_bitstream( { return error; } - *td_q = Q_out[0]; + + IF( EQ_16( cldfb_in_flag, 1 ) ) + { + *td_q = Q_out[0]; + } return IVAS_ERR_OK; } @@ -1753,7 +1757,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( Word16 i; Word16 pcm_out_flag; Word16 numSamplesPerChannelToOutput; - Word16 td_q; + Word16 td_q = 11; if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { @@ -5436,7 +5440,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples #ifdef FIX_1119_SPLIT_RENDERING_VOIP IF( hIvasDec->hasDecodedFirstGoodFrame && splitRendBits != NULL ) { - Word16 td_q; + Word16 td_q = 11;; /* Analyse head poses over entire frame, generate ISAR metadata and maybe encode if split coded */ IF( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nSamplesRendered, splitRendBits, &td_q ) ) != IVAS_ERR_OK ) -- GitLab From 1ca09d327c98bc28d47775faba80b42b375c47f8 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Thu, 30 Oct 2025 12:34:07 +0100 Subject: [PATCH 05/40] Add missing manual instrumentation --- lib_dec/lib_dec_fx.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index babd4f715..a4bd04aa8 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1455,10 +1455,12 @@ static ivas_error isar_generate_metadata_and_bitstream( IF ( st_ivas->hBinRendererTd != NULL ) { ro_md_flag = 1; + move16(); } ELSE { ro_md_flag = 0; + move16(); } IF( st_ivas->hHeadTrackData != NULL ) @@ -1759,6 +1761,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( Word16 numSamplesPerChannelToOutput; Word16 td_q = 11; + test(); if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; -- GitLab From 9f39d1a808cb535677d23c960c34b4a3f7e0ff5c Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Thu, 30 Oct 2025 10:26:13 +0100 Subject: [PATCH 06/40] Fix TD processing in split rendering --- lib_dec/ivas_jbm_dec_fx.c | 13 +++++++++ lib_dec/lib_dec_fx.c | 60 ++++++++++++++++----------------------- 2 files changed, 38 insertions(+), 35 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index fa4c0a919..c0c129f13 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2581,7 +2581,20 @@ ivas_error ivas_jbm_dec_render_fx( IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { #ifdef FIX_1119_SPLIT_RENDERING_VOIP /* NOTE(sgi): BASOP special - not in float version */ + const Word32* p_output_fx_const[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; + nchan_out_syn_output = BINAURAL_CHANNELS * st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; + + /* Save TD signals for pose correction if they are to be used */ + if ( st_ivas->hSplitBinRend->hMultiBinTdData != NULL ) + { + FOR( i = 0; i < nchan_out_syn_output; i++ ) + { + p_output_fx_const[i] = p_output_fx[i]; + } + ivas_TD_RINGBUF_PushChannels( st_ivas->hSplitBinRend->hMultiBinTdData, p_output_fx_const, *nSamplesRendered ); // TODO(sgi): change num_samples_per_channel to unsigned + } + #ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR // TODO(sgi): verify if this is needed in BASOP if ( st_ivas->flushing ) { diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index a4bd04aa8..4c4d959ef 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1356,23 +1356,8 @@ static ivas_error isar_render_poses( } #endif - IF ( !ivas_dec_split_rend_cldfb_in( st_ivas->renderer_type ) ) - { -#if 1 /* NOTE(sgi): Workaround for bit width mismatch */ - Word32 pcmBuf32[960 * 16]; - - for (int i = 0; i < *nOutSamples * hIvasDec->st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses * BINAURAL_CHANNELS; ++i) - { - // NOTE(sgi2det): Is this even correct or do we need to adjust the Q-format? - pcmBuf32[i] = pcmBuf[i]; - } -#endif - - // NOTE(sgi2det): We need signal in 32 bit here, but get only 16 bit from IVAS_DEC_GetSamplesRenderer... - // The float version of that function has switchable output format (int16 or float) but not in BASOP. - // Any ideas for a better solution than this pcmBuf32? - ivas_TD_RINGBUF_PushInterleaved( st_ivas->hSplitBinRend->hMultiBinTdData, pcmBuf32, *nOutSamples ); - } +// NOTE: Here BASOP differs from float version. In float, we push samples to TD ring buffer here. In BASOP, TD signals are only available in 16 bit here. +// To save TD signals in 32-bit precision, samples are pushed via ivas_TD_RINGBUF_PushChannels in ivas_jbm_dec_render_fx within IVAS_DEC_GetSamplesRenderer. return error; } @@ -1385,11 +1370,11 @@ static ivas_error isar_render_poses( *---------------------------------------------------------------------*/ static ivas_error isar_generate_metadata_and_bitstream( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - Word32 **p_head_pose_buf, /* i/o: PCM buffer with head-pose data */ - Word16 nSamples, /* i : duration of audio (in samples per channel) for which metadata should be generated */ - ISAR_SPLIT_REND_BITS_DATA *splitRendBits,/* o : output split rendering bits */ - Word16* td_q /* o : Q-format of the TD output if rendering from CLDFB */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + Word32 **p_head_pose_buf, /* i/o: PCM buffer with head-pose data */ + Word16 nSamples, /* i : duration of audio (in samples per channel) for which metadata should be generated */ + ISAR_SPLIT_REND_BITS_DATA *splitRendBits, /* o : output split rendering bits */ + Word16 Q_out[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS] /* o : Q-format of each channel of p_head_pose_buf */ ) { // NOTE(sgi2det): Code in this function was moved and adapted from IVAS_DEC_GetSplitBinauralBitstream, @@ -1475,8 +1460,7 @@ static ivas_error isar_generate_metadata_and_bitstream( Quaternion.z_fx = 0; } // NOTE(sgi): BASOP special - not in float version - Word16 q1 = 31, q2 = 31, Q_buff = 31; - Word16 Q_out[CLDFB_NO_COL_MAX]; + Word16 q1 = 31, q2 = 31, Q_buff; Q_out[0] = 31; IF( EQ_16( cldfb_in_flag, 1 ) ) @@ -1518,6 +1502,7 @@ static ivas_error isar_generate_metadata_and_bitstream( } Q_out[0] = add( Q_out[0], Q11 ); Q_out[1] = Q_out[0]; + Q_buff = Q31 + Q6; // TODO(sgi): likely unneeded } IF( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( &hSplitBinRend->splitrend, @@ -1534,11 +1519,6 @@ static ivas_error isar_generate_metadata_and_bitstream( return error; } - IF( EQ_16( cldfb_in_flag, 1 ) ) - { - *td_q = Q_out[0]; - } - return IVAS_ERR_OK; } #endif /* FIX_1119_SPLIT_RENDERING_VOIP */ @@ -1759,7 +1739,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( Word16 i; Word16 pcm_out_flag; Word16 numSamplesPerChannelToOutput; - Word16 td_q = 11; + Word16 Q_out[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS]; test(); if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) @@ -1792,7 +1772,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( p_head_pose_buf[i] = head_pose_buf[i]; } - if ( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nOutSamples, splitRendBits, &td_q ) ) != IVAS_ERR_OK ) + if ( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nOutSamples, splitRendBits, Q_out ) ) != IVAS_ERR_OK ) { return error; } @@ -1800,6 +1780,10 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( /* convert to int16 with limiting for BINAURAL_SPLIT_PCM */ if ( pcm_out_flag ) { + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + scale_sig32( p_head_pose_buf[i], numSamplesPerChannelToOutput, sub( Q11, Q_out[i] ) ); // Q11 + } if ( st_ivas->hDecoderConfig->render_framesize == IVAS_RENDER_FRAMESIZE_5MS ) { #ifndef DISABLE_LIMITER @@ -1814,7 +1798,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( #ifdef DEBUGGING st_ivas->noClipping += #endif - ivas_syn_output_fx( p_head_pose_buf, td_q, numSamplesPerChannelToOutput, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf_out ); + ivas_syn_output_fx( p_head_pose_buf, Q11, numSamplesPerChannelToOutput, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf_out ); } #else Decoder_Struct *st_ivas; @@ -5443,10 +5427,11 @@ ivas_error IVAS_DEC_VoIP_GetSamples #ifdef FIX_1119_SPLIT_RENDERING_VOIP IF( hIvasDec->hasDecodedFirstGoodFrame && splitRendBits != NULL ) { - Word16 td_q = 11;; + Word16 Q_out[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS]; + Word16 i; /* Analyse head poses over entire frame, generate ISAR metadata and maybe encode if split coded */ - IF( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nSamplesRendered, splitRendBits, &td_q ) ) != IVAS_ERR_OK ) + IF( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nSamplesRendered, splitRendBits, Q_out ) ) != IVAS_ERR_OK ) { return error; } @@ -5454,6 +5439,11 @@ ivas_error IVAS_DEC_VoIP_GetSamples /* Synthesise PCM output if split PCM */ IF( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + scale_sig32( p_head_pose_buf[i], *nSamplesRendered, sub( Q11, Q_out[i] ) ); // Q11 + } + IF( st_ivas->hDecoderConfig->render_framesize == IVAS_RENDER_FRAMESIZE_5MS ) { #ifndef DISABLE_LIMITER @@ -5468,7 +5458,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples #ifdef DEBUGGING st_ivas->noClipping += #endif - ivas_syn_output_fx( p_head_pose_buf, td_q, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf ); + ivas_syn_output_fx( p_head_pose_buf, Q11, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf ); } } #endif -- GitLab From 1d9b752a270b61353216b8e59f40512acc48cb22 Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Thu, 30 Oct 2025 13:56:49 +0100 Subject: [PATCH 07/40] lib_isar_pre_rend.c and lib_dec_fx.c called the wrong functions for divisons. --- lib_dec/lib_dec_fx.c | 20 +++++++++++--------- lib_isar/lib_isar_pre_rend.c | 4 ++-- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index babd4f715..b874f0e48 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1262,8 +1262,8 @@ static Word16 isar_get_frame_size( ( st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE || st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) { -#if 0 // NOTE(sgi2det): the divide function includes a right shift so the result ends up 2x too small here - nSamplesPerChannel = divide3216( output_Fs, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ); +#if 1 // NOTE(sgi2det): the divide function includes a right shift so the result ends up 2x too small here // NOTE(det2sgi): ar_div() is a better fit than divide3216 + nSamplesPerChannel = ar_div( output_Fs, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ); nSamplesPerChannel = imult1616( nSamplesPerChannel, st_ivas->hDecoderConfig->render_framesize ); #else nSamplesPerChannel = (int16_t) ( output_Fs / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ); @@ -1272,8 +1272,8 @@ static Word16 isar_get_frame_size( } else { -#if 0 // NOTE(sgi2det): the divide function includes a right shift so the result ends up 2x too small here - nSamplesPerChannel = divide3216( output_Fs, FRAMES_PER_SEC ); +#if 1 // NOTE(sgi2det): the divide function includes a right shift so the result ends up 2x too small here // NOTE(det2sgi): ar_div() is a better fit than divide3216 + nSamplesPerChannel = ar_div( output_Fs, FRAMES_PER_SEC ); #else nSamplesPerChannel = output_Fs / FRAMES_PER_SEC; #endif @@ -1319,7 +1319,8 @@ static ivas_error isar_render_poses( { #if 1 // NOTE(sgi2det): I copied this from previously ported version of IVAS_DEC_GetSplitBinauralBitstream. // Generally I've seen arithmetic within calls to malloc() not ported, so maybe this is ok. - hIvasDec->flushbuffer = (void *) malloc( numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( float ) ); + // NOTE(det2sgi): D'accord. But was the sizeof(float) correct? + hIvasDec->flushbuffer = (void *) malloc( sizeof( Word16) * 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 ); #else // NOTE(sgi): originally from det Word32 tmp; @@ -1371,6 +1372,7 @@ static ivas_error isar_render_poses( // NOTE(sgi2det): We need signal in 32 bit here, but get only 16 bit from IVAS_DEC_GetSamplesRenderer... // The float version of that function has switchable output format (int16 or float) but not in BASOP. // Any ideas for a better solution than this pcmBuf32? + // NOTE(det2sgi): Was the requirement for the TD_Ringbuf a 32 Bit Datatype? A 16 Bit would make more sense. ivas_TD_RINGBUF_PushInterleaved( st_ivas->hSplitBinRend->hMultiBinTdData, pcmBuf32, *nOutSamples ); } @@ -1407,9 +1409,9 @@ static ivas_error isar_generate_metadata_and_bitstream( hSplitBinRend = st_ivas->hSplitBinRend; -#if 1 // NOTE(sgi2det): The divide function includes a right shift so the result ends up 2x too small here. +#if 1 // NOTE(sgi2det): The divide function includes a right shift so the result ends up 2x too small here.// NOTE(det2sgi): ar_div() is a better fit than divide3216 // I copied this from previously ported version of IVAS_DEC_GetSplitBinauralBitstream. Maybe this can just stay here. - max_band = (Word16) ( ( BINAURAL_MAXBANDS * st_ivas->hDecoderConfig->output_Fs ) / 48000 ); // TODO remove division + max_band = (Word16)ar_div( BINAURAL_MAXBANDS * st_ivas->hDecoderConfig->output_Fs, 48000 ); // TODO remove division #else // NOTE(sgi): originally from det // NOTE(sgi): warning: implicit conversion from 'int' to 'Word16' (aka 'short') changes value from 48000 to -17536 [-Wconstant-conversion] max_band = divide3216( imult3216( BINAURAL_MAXBANDS, st_ivas->hDecoderConfig->output_Fs ), 48000 ); @@ -1420,8 +1422,8 @@ static ivas_error isar_generate_metadata_and_bitstream( // NOTE(sgi): BASOP special - not in float version n_samples_in_cldfb_slot = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); assert( nSamples % n_samples_in_cldfb_slot == 0 ); -#if 0 // NOTE(sgi2det): the divide function includes a right shift so the result ends up 2x too small here - num_cldfb_slots = extract_l( divide3216( L_deposit_l( nSamples ), n_samples_in_cldfb_slot ) ); +#if 1 // NOTE(sgi2det): the divide function includes a right shift so the result ends up 2x too small here// NOTE(det2sgi): int_div_s_x() is a better fit for a 16x16->16 bit division + num_cldfb_slots = int_div_s_x( nSamples , n_samples_in_cldfb_slot ); #else num_cldfb_slots = nSamples / n_samples_in_cldfb_slot; #endif diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index 20cfc9f4d..f5b2a800b 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -494,8 +494,8 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( ELSE { Word16 ch, slot_idx, num_slots; -#if 0 // NOTE(sgi2det): This shift left here doesn't correspond to what the original code does. - num_slots = shl( isar_frame_size_ms, 3); /* ( isar_frame_size_ms * 1000000 / CLDFB_SLOT_NS ); */ +#if 1 // NOTE(sgi2det): This shift left here doesn't correspond to what the original code does.// NOTE(det2sgi): Missing Division by 10 added + num_slots = int_div_s_x( shl( isar_frame_size_ms, 3), 10); /* ( isar_frame_size_ms * 1000000 / CLDFB_SLOT_NS ); */ #else num_slots = isar_frame_size_ms * 1000000 / CLDFB_SLOT_NS; #endif -- GitLab From fe0e9ff93068c8f89c8992a12c70fa088f87b15d Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Thu, 30 Oct 2025 21:43:44 +0100 Subject: [PATCH 08/40] Remove unused function ISAR_SPLIT_REND_BITStream_init --- lib_isar/isar_prot.h | 7 ------ lib_isar/isar_splitRenderer_utils.c | 23 ------------------- ...ring_buffer.c => ivas_td_ring_buffer_fx.c} | 0 3 files changed, 30 deletions(-) rename lib_rend/{ivas_td_ring_buffer.c => ivas_td_ring_buffer_fx.c} (100%) diff --git a/lib_isar/isar_prot.h b/lib_isar/isar_prot.h index 7d7b16f67..e1b173e02 100644 --- a/lib_isar/isar_prot.h +++ b/lib_isar/isar_prot.h @@ -421,13 +421,6 @@ void isar_init_split_rend_handles( SPLIT_REND_WRAPPER *hSplitRendWrapper /* i/o: Split renderer pre-renderer handle */ ); -// UNUSED -void ISAR_SPLIT_REND_BITStream_init( - ISAR_SPLIT_REND_BITS_HANDLE pBits, - const Word32 buf_len_bytes, - UWord8 *pbuf -); - /*----------------------------------------------------------------------------------* * BASOP-only *----------------------------------------------------------------------------------*/ diff --git a/lib_isar/isar_splitRenderer_utils.c b/lib_isar/isar_splitRenderer_utils.c index 54e0ec79c..6f72ce651 100644 --- a/lib_isar/isar_splitRenderer_utils.c +++ b/lib_isar/isar_splitRenderer_utils.c @@ -212,29 +212,6 @@ void isar_mat_mult_2by2_complex_fx( } -/*------------------------------------------------------------------------- - * Function ISAR_SPLIT_REND_BITStream_init() - * - * - *------------------------------------------------------------------------*/ - -void ISAR_SPLIT_REND_BITStream_init( - ISAR_SPLIT_REND_BITS_HANDLE pBits, - const Word32 buf_len_bytes, - UWord8 *pbuf ) -{ - pBits->bits_buf = pbuf; - pBits->buf_len = buf_len_bytes; - move32(); - pBits->bits_read = 0; - move32(); - pBits->bits_written = 0; - move32(); - - return; -} - - /*------------------------------------------------------------------------- * Function isar_split_rend_huffman_dec_init_min_max_len() * diff --git a/lib_rend/ivas_td_ring_buffer.c b/lib_rend/ivas_td_ring_buffer_fx.c similarity index 100% rename from lib_rend/ivas_td_ring_buffer.c rename to lib_rend/ivas_td_ring_buffer_fx.c -- GitLab From 1c468f073062fc44a4c70a465cae01bcb65d6bd3 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 00:12:23 +0100 Subject: [PATCH 09/40] Remove leftover switch --- lib_dec/lib_dec_fx.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index f0d71f3a9..214f65d02 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1271,12 +1271,10 @@ static ivas_error isar_render_poses( return error; } -#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST IF ( !hIvasDec->hasBeenFedFirstGoodFrame ) { return IVAS_ERR_OK; } -#endif IF ( !ivas_dec_split_rend_cldfb_in( st_ivas->renderer_type ) ) -- GitLab From ac1f33955f435f795f80ee908666babd286aabfe Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 00:12:54 +0100 Subject: [PATCH 10/40] Fix incorrect conflict resolution --- lib_dec/lib_dec_fx.c | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 214f65d02..a5e6bdc4f 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1276,25 +1276,6 @@ static ivas_error isar_render_poses( return IVAS_ERR_OK; } - - IF ( !ivas_dec_split_rend_cldfb_in( st_ivas->renderer_type ) ) - { -#if 1 /* NOTE(sgi): Workaround for bit width mismatch */ - Word32 pcmBuf32[960 * 16]; - - for (int i = 0; i < *nOutSamples * hIvasDec->st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses * BINAURAL_CHANNELS; ++i) - { - // NOTE(sgi2det): Is this even correct or do we need to adjust the Q-format? - pcmBuf32[i] = pcmBuf[i]; - } -#endif - - // NOTE(sgi2det): We need signal in 32 bit here, but get only 16 bit from IVAS_DEC_GetSamplesRenderer... - // The float version of that function has switchable output format (int16 or float) but not in BASOP. - // Any ideas for a better solution than this pcmBuf32? - // NOTE(det2sgi): Was the requirement for the TD_Ringbuf a 32 Bit Datatype? A 16 Bit would make more sense. - ivas_TD_RINGBUF_PushInterleaved( st_ivas->hSplitBinRend->hMultiBinTdData, pcmBuf32, *nOutSamples ); - } // NOTE: Here BASOP differs from float version. In float, we push samples to TD ring buffer here. In BASOP, TD signals are only available in 16 bit here. // To save TD signals in 32-bit precision, samples are pushed via ivas_TD_RINGBUF_PushChannels in ivas_jbm_dec_render_fx within IVAS_DEC_GetSamplesRenderer. -- GitLab From 9dad84917b1aeff512122206f88a37613bf86973 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 00:35:15 +0100 Subject: [PATCH 11/40] Update with changes from the float branch --- Workspace_msvc/lib_rend.vcxproj | 3 ++- lib_com/options.h | 1 - lib_rend/ivas_cldfb_ring_buffer.c | 12 ++++++------ lib_rend/ivas_prot_rend_fx.h | 24 +++++++++++------------- lib_rend/ivas_stat_rend.h | 7 +++---- lib_rend/ivas_td_ring_buffer_fx.c | 13 ++++++++----- lib_rend/lib_rend_fx.c | 19 +++++++++---------- 7 files changed, 39 insertions(+), 40 deletions(-) diff --git a/Workspace_msvc/lib_rend.vcxproj b/Workspace_msvc/lib_rend.vcxproj index db791e067..b76f3211c 100644 --- a/Workspace_msvc/lib_rend.vcxproj +++ b/Workspace_msvc/lib_rend.vcxproj @@ -176,6 +176,7 @@ + @@ -210,4 +211,4 @@ - \ No newline at end of file + diff --git a/lib_com/options.h b/lib_com/options.h index bf6ed9456..c2c673ca5 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -100,7 +100,6 @@ #define FIX_1377_HANDLE_ERROR_CODE /* Eri: Add missing error code handling from IVAS_REND_SetObjectIDs */ #define FIX_1053_REVERB_RECONFIGURATION #define FIX_1119_SPLIT_RENDERING_VOIP /* FhG: Add split rendering support to decoder in VoIP mode */ -#define FIX_1119_SPLIT_RENDERING_VOIP_TD_RINGBUF // TODO(sgi): align with port 369, which actually adds the TD ringbuf: https://forge.3gpp.org/rep/sa4/audio/ivas-basop/-/merge_requests/2412/diffs#d6d51ef63eb9458b72d78958dfd5b73ac4bae1de #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_938_COMPILER_WARNING /* FhG: Fix compiler warning in ivas_mdct_core_reconstruct() */ diff --git a/lib_rend/ivas_cldfb_ring_buffer.c b/lib_rend/ivas_cldfb_ring_buffer.c index eacf7f3fe..d5a78ef68 100644 --- a/lib_rend/ivas_cldfb_ring_buffer.c +++ b/lib_rend/ivas_cldfb_ring_buffer.c @@ -66,7 +66,7 @@ static Word16 ivas_cldfb_ringbuf_IsEmpty( * Returns 1 if the ring buffer is full, or 0 otherwise. *---------------------------------------------------------------------*/ -static Word32 ivas_cldfb_ringbuf_IsFull( +static Word16 ivas_cldfb_ringbuf_IsFull( ISAR_CLDFB_RINGBUF_HANDLE h ) { return h->is_full; @@ -76,7 +76,7 @@ static Word32 ivas_cldfb_ringbuf_IsFull( /*---------------------------------------------------------------------* * ivas_CLDFB_RINGBUF_Open() * - * Allocate a ring buffer for CLDFB data with the given capacity of CLDFB columns. + * Allocates a ring buffer for CLDFB data with the given capacity of CLDFB columns. * Each column is expected to contain at most CLDFB_NO_CHANNELS_MAX frequency bands. * * May return IVAS_ERR_FAILED_ALLOC on failed allocation, or IVAS_ERR_OK otherwise. @@ -126,7 +126,7 @@ ivas_error ivas_CLDFB_RINGBUF_Open( /*---------------------------------------------------------------------* * ivas_CLDFB_RINGBUF_Close() * - * Dellocate CLDFB ring buffer. The given handle will be set to NULL. + * Dellocates CLDFB ring buffer. The given handle will be set to NULL. *---------------------------------------------------------------------*/ void ivas_CLDFB_RINGBUF_Close( @@ -164,7 +164,7 @@ void ivas_CLDFB_RINGBUF_Close( /*---------------------------------------------------------------------* * ivas_CLDFB_RINGBUF_Push() * - * Push a single column onto the back of the CLDFB ring buffer from real and imag arrays. + * Pushes a single column onto the back of the CLDFB ring buffer from real and imag arrays. *---------------------------------------------------------------------*/ void ivas_CLDFB_RINGBUF_Push( @@ -200,7 +200,7 @@ void ivas_CLDFB_RINGBUF_Push( /*---------------------------------------------------------------------* * ivas_CLDFB_RINGBUF_Pop() * - * Pop a single column from the front of the CLDFB ring buffer into real and imag arrays. + * Pops a single column from the front of the CLDFB ring buffer into real and imag arrays. *---------------------------------------------------------------------*/ void ivas_CLDFB_RINGBUF_Pop( @@ -263,7 +263,7 @@ static uint32_t ivas_cldfb_ringbuf_total_size( /*---------------------------------------------------------------------* * ivas_CLDFB_RINGBUF_GetByIdx() * - * Get pointers into a specific column in the CLDFB ring buffer based on given index. + * Gets pointers into a specific column in the CLDFB ring buffer based on given index. * Non-negative indices access from the front of the ring buffer, negative indexes access * from the back, similar to Python arrays. For example: * diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index d978d9034..c2274202e 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -1594,15 +1594,14 @@ void ivas_rend_closeCldfbRend( CLDFB_REND_WRAPPER *pCldfbRend ); -#ifdef FIX_1119_SPLIT_RENDERING_VOIP_TD_RINGBUF /*----------------------------------------------------------------------------------* * Time domain ring buffer prototypes *----------------------------------------------------------------------------------*/ ivas_error ivas_TD_RINGBUF_Open( TD_RINGBUF_HANDLE *ph, /* i/o: Ring buffer handle */ - const Word16 capacity_per_channel, /* i : Number of samples stored per channel */ - const Word16 num_channels /* i : Number of channels */ + const Word16 capacity_per_channel, /* i : Number of samples stored per channel */ + const Word16 num_channels /* i : Number of channels */ ); void ivas_TD_RINGBUF_Close( @@ -1612,26 +1611,26 @@ void ivas_TD_RINGBUF_Close( #ifdef FIX_1119_SPLIT_RENDERING_VOIP void ivas_TD_RINGBUF_PushInterleaved( TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ - const Word32 *data, /* i : Input audio in interleaved channels layout */ - const Word16 num_samples_per_channel /* i : Number of samples per channel to push */ + const Word32 *data, /* i : Input audio in interleaved channels layout */ + const Word16 num_samples_per_channel /* i : Number of samples per channel to push */ ); void ivas_TD_RINGBUF_PushChannels( TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ - const Word32 *p_channels[], /* i : Array of pointers to each input channel */ - const Word16 num_samples_per_channel /* i : Number of samples per channel to store */ + const Word32 *p_channels[], /* i : Array of pointers to each input channel */ + const Word16 num_samples_per_channel /* i : Number of samples per channel to store */ ); void ivas_TD_RINGBUF_PushConstant( TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ - const Word32 value, /* i : Value to push */ - const Word16 num_samples_per_channel /* i : Number of samples per channel to push */ + const Word32 value, /* i : Value to push */ + const Word16 num_samples_per_channel /* i : Number of samples per channel to push */ ); void ivas_TD_RINGBUF_PopChannels( TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ - Word32 *p_channels[], /* i : Array of pointers to each output channel */ - const Word16 num_samples_per_channel /* i : Number of samples per channel to pop */ + Word32 *p_channels[], /* i : Array of pointers to each output channel */ + const Word16 num_samples_per_channel /* i : Number of samples per channel to pop */ ); #else void ivas_TD_RINGBUF_Push( @@ -1652,10 +1651,9 @@ void ivas_TD_RINGBUF_Pop( ); #endif -Word16 ivas_TD_RINGBUF_Size( // bit width? +Word16 ivas_TD_RINGBUF_Size( const TD_RINGBUF_HANDLE h /* i : Ring buffer handle */ ); -#endif /* clang-format on */ diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 23489353f..398d28350 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1432,22 +1432,21 @@ typedef struct } CLDFB_REND_WRAPPER; -#ifdef FIX_1119_SPLIT_RENDERING_VOIP_TD_RINGBUF + /*----------------------------------------------------------------------------------* * Time domain ring buffer structure *----------------------------------------------------------------------------------*/ typedef struct { - Word32 *data; /* samples in interleaved layout */ - Word32 capacity; + Word32 *data; /* samples in interleaved layout, e.g. for channels A, B, C, samples are stored: A1, B1, C1, A2, B2, C2, ... */ + Word32 capacity; /* max number of Word32 values that can be stored */ Word16 num_channels; Word32 write_pos; Word32 read_pos; Word16 is_full; } TD_RINGBUF_DATA, *TD_RINGBUF_HANDLE; -#endif /*----------------------------------------------------------------------------------* * Limiter structure diff --git a/lib_rend/ivas_td_ring_buffer_fx.c b/lib_rend/ivas_td_ring_buffer_fx.c index a79d7b0c7..497bed224 100644 --- a/lib_rend/ivas_td_ring_buffer_fx.c +++ b/lib_rend/ivas_td_ring_buffer_fx.c @@ -38,21 +38,25 @@ #include "wmc_auto.h" -#ifdef FIX_1119_SPLIT_RENDERING_VOIP_TD_RINGBUF - /*-----------------------------------------------------------------------* * Local function prototypes *-----------------------------------------------------------------------*/ +/*---------------------------------------------------------------------* + * ivas_td_ringbuf_total_size() + * + * Returns total number of buffered samples (including number of channels) + *---------------------------------------------------------------------*/ + static Word32 ivas_td_ringbuf_total_size( TD_RINGBUF_HANDLE h ) { - if ( h->is_full ) + IF( h->is_full ) { return h->capacity; } - if ( LE_32( h->read_pos, h->write_pos ) ) + IF ( LE_32( h->read_pos, h->write_pos ) ) { return L_sub( h->write_pos, h->read_pos ); } @@ -445,4 +449,3 @@ Word16 ivas_TD_RINGBUF_Size( { return ivas_td_ringbuf_total_size( h ) / (uint32_t) h->num_channels; // TODO(sgi): port division } -#endif diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 80d87712a..f9765c821 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -8952,19 +8952,18 @@ static ivas_error getSamplesInternal( } Word32 *tmpBinaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS], tmpBinaural_buff[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][L_FRAME48k]; -#ifdef FIX_1119_SPLIT_RENDERING_VOIP - // TODO(sgi): This doesn't match the original MR. BASOP main too far behind. Port later. - Word32 *p_Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX]; - Word32 *p_Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX]; +#ifdef FIX_1119_SPLIT_RENDERING_VOIP /* Temporary fix. Proper implementation of port 391 can only be added once port 369 is complete. */ + Word32 *p_Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX]; + Word32 *p_Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX]; - for ( i = 0; i < BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES; ++i ) - { - for ( j = 0; j < CLDFB_NO_COL_MAX; ++j ) + for ( i = 0; i < BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES; ++i ) { - p_Cldfb_RealBuffer_Binaural[i][j] = Cldfb_RealBuffer_Binaural[i][j]; - p_Cldfb_ImagBuffer_Binaural[i][j] = Cldfb_ImagBuffer_Binaural[i][j]; + for ( j = 0; j < CLDFB_NO_COL_MAX; ++j ) + { + p_Cldfb_RealBuffer_Binaural[i][j] = Cldfb_RealBuffer_Binaural[i][j]; + p_Cldfb_ImagBuffer_Binaural[i][j] = Cldfb_ImagBuffer_Binaural[i][j]; + } } - } #endif FOR( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) -- GitLab From 87bf98647c9f4b4bbf620c385d92f6050565ff5d Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 00:53:43 +0100 Subject: [PATCH 12/40] Clean up TODO and NOTE comments --- lib_dec/ivas_jbm_dec_fx.c | 2 +- lib_dec/lib_dec_fx.c | 62 +++++++------------------------ lib_isar/lib_isar_pre_rend.c | 20 ++++++---- lib_rend/ivas_td_ring_buffer_fx.c | 3 +- 4 files changed, 29 insertions(+), 58 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 3a43d4181..363283022 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2472,7 +2472,7 @@ ivas_error ivas_jbm_dec_render_fx( { p_output_fx_const[i] = p_output_fx[i]; } - ivas_TD_RINGBUF_PushChannels( st_ivas->hSplitBinRend->hMultiBinTdData, p_output_fx_const, *nSamplesRendered ); // TODO(sgi): change num_samples_per_channel to unsigned + ivas_TD_RINGBUF_PushChannels( st_ivas->hSplitBinRend->hMultiBinTdData, p_output_fx_const, *nSamplesRendered ); } #ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR // TODO(sgi): verify if this is needed in BASOP diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index a5e6bdc4f..af4368e32 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1187,21 +1187,12 @@ static Word16 isar_get_frame_size( ( st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE || st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) { -#if 1 // NOTE(sgi2det): the divide function includes a right shift so the result ends up 2x too small here // NOTE(det2sgi): ar_div() is a better fit than divide3216 nSamplesPerChannel = ar_div( output_Fs, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ); nSamplesPerChannel = imult1616( nSamplesPerChannel, st_ivas->hDecoderConfig->render_framesize ); -#else - nSamplesPerChannel = (int16_t) ( output_Fs / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ); - nSamplesPerChannel *= (int16_t) st_ivas->hDecoderConfig->render_framesize; -#endif } else { -#if 1 // NOTE(sgi2det): the divide function includes a right shift so the result ends up 2x too small here // NOTE(det2sgi): ar_div() is a better fit than divide3216 nSamplesPerChannel = ar_div( output_Fs, FRAMES_PER_SEC ); -#else - nSamplesPerChannel = output_Fs / FRAMES_PER_SEC; -#endif } return nSamplesPerChannel; @@ -1221,8 +1212,10 @@ static ivas_error isar_render_poses( bool *needNewFrame /* o : indication that the decoder needs a new frame */ ) { - // NOTE(sgi2det): Code in this function was moved and adapted from IVAS_DEC_GetSplitBinauralBitstream, - // see #else branch of FIX_1119_SPLIT_RENDERING_VOIP there for reference +#ifndef FIX_1119_SPLIT_RENDERING_VOIP + // Note for reviewers: Code in this function was moved and adapted from IVAS_DEC_GetSplitBinauralBitstream, + // see #else branch of FIX_1119_SPLIT_RENDERING_VOIP there for reference +#endif Word16 pcmBuf[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES * L_FRAME48k]; Decoder_Struct *st_ivas; ivas_error error; @@ -1242,27 +1235,8 @@ static ivas_error isar_render_poses( /* init flush buffer for rate switch if not already initizalized */ if ( hIvasDec->flushbuffer == NULL ) { -#if 1 // NOTE(sgi2det): I copied this from previously ported version of IVAS_DEC_GetSplitBinauralBitstream. - // Generally I've seen arithmetic within calls to malloc() not ported, so maybe this is ok. - // NOTE(det2sgi): D'accord. But was the sizeof(float) correct? - hIvasDec->flushbuffer = (void *) malloc( sizeof( Word16) * numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); + hIvasDec->flushbuffer = (void *) malloc( sizeof( Word16 ) * 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 ); -#else // NOTE(sgi): originally from det - Word32 tmp; - /* numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( Word16 ) */ - tmp = imult3216( L_deposit_l( numPoses ), hIvasDec->nSamplesFrame ); - /* BINAURAL_CHANNELS=2, IVAS_MAX_PARAM_SPATIAL_SUBFRAMES=4, sizeof (Word16)=2. */ - /* BINAURAL_CHANNELS * sizeof(Word16)/ IVAS_MAX_PARAM_SPATIAL_SUBFRAMES = 4/4 = 1 */ - hIvasDec->flushbuffer = (void *) malloc( tmp ); - if ( hIvasDec->flushbuffer == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate flush buffer" ); - } - hIvasDec->pcmType = IVAS_DEC_PCM_FLOAT; // NOTE(sgi2det): the BASOP version of this struct has no pcmType member - only 16 bit PCM is supported. - /* hIvasDec->flushbuffer, numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES = tmp/2 */ - tmp = L_shr( tmp, 1); - set_zero( (Word16 *) hIvasDec->flushbuffer, tmp ); -#endif } /* render */ @@ -1297,8 +1271,10 @@ static ivas_error isar_generate_metadata_and_bitstream( Word16 Q_out[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS] /* o : Q-format of each channel of p_head_pose_buf */ ) { - // NOTE(sgi2det): Code in this function was moved and adapted from IVAS_DEC_GetSplitBinauralBitstream, - // see #else branch of FIX_1119_SPLIT_RENDERING_VOIP there for reference +#ifndef FIX_1119_SPLIT_RENDERING_VOIP + // Note for reviewers: Code in this function was moved and adapted from IVAS_DEC_GetSplitBinauralBitstream, + // see #else branch of FIX_1119_SPLIT_RENDERING_VOIP there for reference +#endif ivas_error error; ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE hSplitBinRend; Word16 max_band; @@ -1312,24 +1288,14 @@ static ivas_error isar_generate_metadata_and_bitstream( hSplitBinRend = st_ivas->hSplitBinRend; -#if 1 // NOTE(sgi2det): The divide function includes a right shift so the result ends up 2x too small here.// NOTE(det2sgi): ar_div() is a better fit than divide3216 - // I copied this from previously ported version of IVAS_DEC_GetSplitBinauralBitstream. Maybe this can just stay here. - max_band = (Word16)ar_div( BINAURAL_MAXBANDS * st_ivas->hDecoderConfig->output_Fs, 48000 ); // TODO remove division -#else // NOTE(sgi): originally from det - // NOTE(sgi): warning: implicit conversion from 'int' to 'Word16' (aka 'short') changes value from 48000 to -17536 [-Wconstant-conversion] - max_band = divide3216( imult3216( BINAURAL_MAXBANDS, st_ivas->hDecoderConfig->output_Fs ), 48000 ); -#endif + max_band = (Word16)ar_div( BINAURAL_MAXBANDS * st_ivas->hDecoderConfig->output_Fs, 48000 ); pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; cldfb_in_flag = ivas_dec_split_rend_cldfb_in( st_ivas->renderer_type ); // NOTE(sgi): BASOP special - not in float version n_samples_in_cldfb_slot = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); assert( nSamples % n_samples_in_cldfb_slot == 0 ); -#if 1 // NOTE(sgi2det): the divide function includes a right shift so the result ends up 2x too small here// NOTE(det2sgi): int_div_s_x() is a better fit for a 16x16->16 bit division - num_cldfb_slots = int_div_s_x( nSamples , n_samples_in_cldfb_slot ); -#else - num_cldfb_slots = nSamples / n_samples_in_cldfb_slot; -#endif + num_cldfb_slots = int_div_s_x( nSamples, n_samples_in_cldfb_slot ); num_poses = hSplitBinRend->splitrend.multiBinPoseData.num_poses; @@ -1422,7 +1388,7 @@ static ivas_error isar_generate_metadata_and_bitstream( } Q_out[0] = add( Q_out[0], Q11 ); Q_out[1] = Q_out[0]; - Q_buff = Q31 + Q6; // TODO(sgi): likely unneeded + Q_buff = Q31 + Q6; // likely unneeded } IF( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( &hSplitBinRend->splitrend, @@ -1596,7 +1562,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( bool *needNewFrame /* o : indication that the decoder needs a new frame */ ) { -#ifdef FIX_1119_SPLIT_RENDERING_VOIP // NOTE(sgi2det): this function still needs to be ported to BASOP +#ifdef FIX_1119_SPLIT_RENDERING_VOIP // TODO(sgi): this function still needs to be ported to BASOP Decoder_Struct *st_ivas; ivas_error error; Word32 head_pose_buf[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES][L_FRAME48k]; @@ -1916,7 +1882,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( ivas_syn_output_fx( pOutput, Q11, numSamplesPerChannelToDecode, st_ivas->hDecoderConfig->nchan_out, (Word16 *) pcmBuf_out ); } -#ifndef TMP_FIX_SPLIT_REND // TODO(sgi): need to port? +#ifndef TMP_FIX_SPLIT_REND free( st_ivas->hSplitBinRend->hMultiBinCldfbData ); #endif #endif diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index f5b2a800b..82077791a 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -410,7 +410,7 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( tmp_e = 0; tmp = BASOP_Util_Divide3232_Scale( L_mult0( CLDFB_NO_COL_MAX, ivas_fs ), 20, &tmp_e ); - num_slots = shr( tmp, sub( 15, tmp_e ) ); // Q0 // NOTE(sgi): this could be a macro constant? + num_slots = shr( tmp, sub( 15, tmp_e ) ); // Q0 // num_slots = (Word16) CLDFB_NO_COL_MAX * ivas_fs / 20; /* CLDFB synthesis of main pose */ { @@ -494,11 +494,7 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( ELSE { Word16 ch, slot_idx, num_slots; -#if 1 // NOTE(sgi2det): This shift left here doesn't correspond to what the original code does.// NOTE(det2sgi): Missing Division by 10 added - num_slots = int_div_s_x( shl( isar_frame_size_ms, 3), 10); /* ( isar_frame_size_ms * 1000000 / CLDFB_SLOT_NS ); */ -#else - num_slots = isar_frame_size_ms * 1000000 / CLDFB_SLOT_NS; -#endif + num_slots = int_div_s_x( shl( isar_frame_size_ms, 3), 10); /* CLDFB synthesis of main pose */ FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) @@ -509,7 +505,11 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( move16(); q2 = 31; move16(); - FOR( j = 0; j < num_slots; j++ ) // NOTE(sgi): BASOP special - not in float version +#ifdef FIX_1119_SPLIT_RENDERING_VOIP // NOTE(sgi): BASOP special - not in float version + FOR( j = 0; j < num_slots; j++ ) +#else + FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) +#endif { q1 = s_min( getScaleFactor32( Cldfb_In_BinReal_fx[ch][j], CLDFB_NO_CHANNELS_MAX ), q1 ); q2 = s_min( getScaleFactor32( Cldfb_In_BinImag_fx[ch][j], CLDFB_NO_CHANNELS_MAX ), q2 ); @@ -518,7 +518,11 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( q_final = s_min( add( Q_buff_re, q_final ), add( Q_buff_im, q_final ) ); q_final = sub( q_final, 6 ); // guard bits q_final = s_min( q_final, Q25 ); - FOR( j = 0; j < num_slots; j++ ) // NOTE(sgi): BASOP special - not in float version +#ifdef FIX_1119_SPLIT_RENDERING_VOIP // NOTE(sgi): BASOP special - not in float version + FOR( j = 0; j < num_slots; j++ ) +#else + FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) +#endif { Scale_sig32( Cldfb_In_BinReal_fx[ch][j], CLDFB_NO_CHANNELS_MAX, sub( q_final, Q_buff_re ) ); Scale_sig32( Cldfb_In_BinImag_fx[ch][j], CLDFB_NO_CHANNELS_MAX, sub( q_final, Q_buff_im ) ); diff --git a/lib_rend/ivas_td_ring_buffer_fx.c b/lib_rend/ivas_td_ring_buffer_fx.c index 497bed224..0f1a72c47 100644 --- a/lib_rend/ivas_td_ring_buffer_fx.c +++ b/lib_rend/ivas_td_ring_buffer_fx.c @@ -36,6 +36,7 @@ #include "ivas_prot_rend_fx.h" #include "options.h" #include "wmc_auto.h" +#include "prot_fx.h" /*-----------------------------------------------------------------------* @@ -447,5 +448,5 @@ Word16 ivas_TD_RINGBUF_Size( const TD_RINGBUF_HANDLE h /* i : Ring buffer handle */ ) { - return ivas_td_ringbuf_total_size( h ) / (uint32_t) h->num_channels; // TODO(sgi): port division + return extract_l( ar_div( ivas_td_ringbuf_total_size( h ), L_deposit_l( h->num_channels ) ) ); } -- GitLab From 1ab8a5a1169c49f095f7869c9b2ad6cda2ab1966 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 00:56:57 +0100 Subject: [PATCH 13/40] Fix formatting --- apps/decoder.c | 10 ++-- lib_dec/ivas_jbm_dec_fx.c | 8 +-- lib_dec/ivas_output_config_fx.c | 3 +- lib_dec/ivas_stat_dec.h | 2 +- lib_dec/lib_dec_fx.c | 84 +++++++++++++++---------------- lib_isar/lib_isar_pre_rend.c | 2 +- lib_rend/ivas_cldfb_ring_buffer.c | 34 ++++++------- lib_rend/ivas_stat_rend.h | 4 +- lib_rend/ivas_td_ring_buffer_fx.c | 64 +++++++++++------------ lib_rend/lib_rend_fx.c | 4 +- 10 files changed, 106 insertions(+), 109 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index e0c0ad73e..03f09be6d 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -3034,14 +3034,14 @@ static ivas_error decodeVoIP( { #endif #ifdef SUPPORT_JBM_TRACEFILE - if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, (void *) pcmBuf, writeJbmTraceFileFrameWrapper, jbmTraceWriter, &bitstreamReadDone, &nSamplesRendered, ¶metersAvailableForEditing, systemTime_ms ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, (void *) pcmBuf, writeJbmTraceFileFrameWrapper, jbmTraceWriter, &bitstreamReadDone, &nSamplesRendered, ¶metersAvailableForEditing, systemTime_ms ) ) != IVAS_ERR_OK ) #else if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, (void *) pcmBuf, &bitstreamReadDone, ¶metersAvailableForEditing, systemTime_ms ) ) != IVAS_ERR_OK ) #endif - { - fprintf( stderr, "\nError in IVAS_DEC_VoIP_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); - goto cleanup; - } + { + fprintf( stderr, "\nError in IVAS_DEC_VoIP_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } #ifdef FIX_1119_SPLIT_RENDERING_VOIP } #endif diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 363283022..81bd0ea6d 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2461,7 +2461,7 @@ ivas_error ivas_jbm_dec_render_fx( IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { #ifdef FIX_1119_SPLIT_RENDERING_VOIP /* NOTE(sgi): BASOP special - not in float version */ - const Word32* p_output_fx_const[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; + const Word32 *p_output_fx_const[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; nchan_out_syn_output = BINAURAL_CHANNELS * st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; @@ -2475,7 +2475,7 @@ ivas_error ivas_jbm_dec_render_fx( ivas_TD_RINGBUF_PushChannels( st_ivas->hSplitBinRend->hMultiBinTdData, p_output_fx_const, *nSamplesRendered ); } -#ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR // TODO(sgi): verify if this is needed in BASOP +#ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR // TODO(sgi): verify if this is needed in BASOP if ( st_ivas->flushing ) { nchan_out_syn_output = BINAURAL_CHANNELS; @@ -2492,8 +2492,8 @@ ivas_error ivas_jbm_dec_render_fx( ELSE { #endif - nchan_out_syn_output = nchan_out; - move16(); + nchan_out_syn_output = nchan_out; + move16(); #ifdef FIX_1119_SPLIT_RENDERING_VOIP /* NOTE(sgi): BASOP special - not in float version */ } #endif diff --git a/lib_dec/ivas_output_config_fx.c b/lib_dec/ivas_output_config_fx.c index 53573c7ee..c71431e5c 100644 --- a/lib_dec/ivas_output_config_fx.c +++ b/lib_dec/ivas_output_config_fx.c @@ -630,8 +630,7 @@ RENDERER_TYPE ivas_renderer_secondary_select_fx( test(); test(); IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && - ( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) - ) + ( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) ) #else IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) ) #endif diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 46c1710c1..53d73c7c9 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1024,7 +1024,7 @@ typedef struct decoder_tc_buffer_structure #ifdef JBM_MEMORY_OPT Word32 *tc_fx[MAX_INTERN_CHANNELS]; /* pointers into the buffer to the beginning of each tc */ #else - Word32 *tc_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; /* pointers into the buffer to the beginning of each tc Q11 for ivas */ + Word32 *tc_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; /* pointers into the buffer to the beginning of each tc Q11 for ivas */ #endif Word16 no_channels; /*Stores no of channels in tc_fx with values*/ Word16 q_tc_fx; diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index af4368e32..fef1711e6 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -783,7 +783,7 @@ static int16_t get_render_frame_size_samples( Word16 tmp; tmp = (Word16) Mpy_32_16_1( hDecoderConfig->output_Fs, INV_FR_P_S_MX_PRM_SPL_SBFR_Q15 ); - /* NOTE(sgi): BASOP special - not in float version */ + /* NOTE(sgi): BASOP special - not in float version */ IF( EQ_16( hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_5MS ) ) { /* correct value already in tmp */ @@ -1206,10 +1206,10 @@ static Word16 isar_get_frame_size( *---------------------------------------------------------------------*/ static ivas_error isar_render_poses( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const Word16 nSamplesAsked, /* i : number of samples wanted by the caller */ - Word16 *nOutSamples, /* o : number of samples per channel written to output buffer */ - bool *needNewFrame /* o : indication that the decoder needs a new frame */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const Word16 nSamplesAsked, /* i : number of samples wanted by the caller */ + Word16 *nOutSamples, /* o : number of samples per channel written to output buffer */ + bool *needNewFrame /* o : indication that the decoder needs a new frame */ ) { #ifndef FIX_1119_SPLIT_RENDERING_VOIP @@ -1240,18 +1240,18 @@ static ivas_error isar_render_poses( } /* render */ - IF ( ( error = IVAS_DEC_GetSamplesRenderer( hIvasDec, nSamplesAsked, pcmBuf, nOutSamples, needNewFrame ) ) != IVAS_ERR_OK ) + IF( ( error = IVAS_DEC_GetSamplesRenderer( hIvasDec, nSamplesAsked, pcmBuf, nOutSamples, needNewFrame ) ) != IVAS_ERR_OK ) { return error; } - IF ( !hIvasDec->hasBeenFedFirstGoodFrame ) + IF( !hIvasDec->hasBeenFedFirstGoodFrame ) { return IVAS_ERR_OK; } -// NOTE: Here BASOP differs from float version. In float, we push samples to TD ring buffer here. In BASOP, TD signals are only available in 16 bit here. -// To save TD signals in 32-bit precision, samples are pushed via ivas_TD_RINGBUF_PushChannels in ivas_jbm_dec_render_fx within IVAS_DEC_GetSamplesRenderer. + // NOTE: Here BASOP differs from float version. In float, we push samples to TD ring buffer here. In BASOP, TD signals are only available in 16 bit here. + // To save TD signals in 32-bit precision, samples are pushed via ivas_TD_RINGBUF_PushChannels in ivas_jbm_dec_render_fx within IVAS_DEC_GetSamplesRenderer. return error; } @@ -1264,11 +1264,11 @@ static ivas_error isar_render_poses( *---------------------------------------------------------------------*/ static ivas_error isar_generate_metadata_and_bitstream( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - Word32 **p_head_pose_buf, /* i/o: PCM buffer with head-pose data */ - Word16 nSamples, /* i : duration of audio (in samples per channel) for which metadata should be generated */ - ISAR_SPLIT_REND_BITS_DATA *splitRendBits, /* o : output split rendering bits */ - Word16 Q_out[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS] /* o : Q-format of each channel of p_head_pose_buf */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + Word32 **p_head_pose_buf, /* i/o: PCM buffer with head-pose data */ + Word16 nSamples, /* i : duration of audio (in samples per channel) for which metadata should be generated */ + ISAR_SPLIT_REND_BITS_DATA *splitRendBits, /* o : output split rendering bits */ + Word16 Q_out[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS] /* o : Q-format of each channel of p_head_pose_buf */ ) { #ifndef FIX_1119_SPLIT_RENDERING_VOIP @@ -1288,7 +1288,7 @@ static ivas_error isar_generate_metadata_and_bitstream( hSplitBinRend = st_ivas->hSplitBinRend; - max_band = (Word16)ar_div( BINAURAL_MAXBANDS * st_ivas->hDecoderConfig->output_Fs, 48000 ); + max_band = (Word16) ar_div( BINAURAL_MAXBANDS * st_ivas->hDecoderConfig->output_Fs, 48000 ); pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; cldfb_in_flag = ivas_dec_split_rend_cldfb_in( st_ivas->renderer_type ); @@ -1301,7 +1301,7 @@ static ivas_error isar_generate_metadata_and_bitstream( IF( cldfb_in_flag ) { - FOR( i = 0; i < imult1616( BINAURAL_CHANNELS, num_poses); ++i ) + FOR( i = 0; i < imult1616( BINAURAL_CHANNELS, num_poses ); ++i ) { FOR( j = 0; j < num_cldfb_slots; ++j ) { @@ -1323,7 +1323,7 @@ static ivas_error isar_generate_metadata_and_bitstream( } - IF ( st_ivas->hBinRendererTd != NULL ) + IF( st_ivas->hBinRendererTd != NULL ) { ro_md_flag = 1; move16(); @@ -1392,15 +1392,15 @@ static ivas_error isar_generate_metadata_and_bitstream( } IF( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( &hSplitBinRend->splitrend, - Quaternion, - st_ivas->hRenderConfig->split_rend_config.splitRendBitRate, - st_ivas->hRenderConfig->split_rend_config.codec, - st_ivas->hRenderConfig->split_rend_config.isar_frame_size_ms, - st_ivas->hRenderConfig->split_rend_config.codec_frame_size_ms, - splitRendBits, - p_Cldfb_RealBuffer_Binaural, - p_Cldfb_ImagBuffer_Binaural, - max_band, p_head_pose_buf, 1, cldfb_in_flag, pcm_out_flag, ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) + Quaternion, + st_ivas->hRenderConfig->split_rend_config.splitRendBitRate, + st_ivas->hRenderConfig->split_rend_config.codec, + st_ivas->hRenderConfig->split_rend_config.isar_frame_size_ms, + st_ivas->hRenderConfig->split_rend_config.codec_frame_size_ms, + splitRendBits, + p_Cldfb_RealBuffer_Binaural, + p_Cldfb_ImagBuffer_Binaural, + max_band, p_head_pose_buf, 1, cldfb_in_flag, pcm_out_flag, ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) { return error; } @@ -4549,23 +4549,23 @@ static ivas_error ivas_dec_voip_get_samples_common ivas_error IVAS_DEC_VoIP_GetSamples #endif ( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - UWord16 nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ - /* const IVAS_DEC_PCM_TYPE pcmType, */ /* i : type for the decoded PCM resolution */ - Word16 *pcmBuf, /* o : output synthesis signal */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + UWord16 nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ + /* const IVAS_DEC_PCM_TYPE pcmType, */ /* i : type for the decoded PCM resolution */ + Word16 *pcmBuf, /* o : output synthesis signal */ #ifdef FIX_1119_SPLIT_RENDERING_VOIP ISAR_SPLIT_REND_BITS_DATA *splitRendBits, /* o : output split rendering bits */ - Word32 **p_head_pose_buf, /* i : PCM buffer with head-pose data */ + Word32 **p_head_pose_buf, /* i : PCM buffer with head-pose data */ #endif #ifdef SUPPORT_JBM_TRACEFILE JbmTraceFileWriterFn jbmWriterFn, void *jbmWriter, #endif - bool *bitstreamReadDone, /* o : flag indicating that bitstream was read */ - UWord16 *nSamplesRendered, /* o : number of samples rendered */ - bool *parametersAvailableForEditing, /* o : indicates whether objects editing is available */ - const UWord32 systemTimestamp_ms /* i : current system timestamp */ -) + bool *bitstreamReadDone, /* o : flag indicating that bitstream was read */ + UWord16 *nSamplesRendered, /* o : number of samples rendered */ + bool *parametersAvailableForEditing, /* o : indicates whether objects editing is available */ + const UWord32 systemTimestamp_ms /* i : current system timestamp */ + ) { Decoder_Struct *st_ivas; DECODER_CONFIG_HANDLE hDecoderConfig; @@ -4603,7 +4603,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples test(); IF( ( EQ_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || EQ_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) && - splitRendBits == NULL ) + splitRendBits == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; // NOTE(sgi): BASOP special - not in float version } @@ -4885,10 +4885,10 @@ ivas_error IVAS_DEC_VoIP_GetSamples *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_VoIP_GetSamples( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - UWord16 nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ - /* const IVAS_DEC_PCM_TYPE pcmType, */ /* i : type for the decoded PCM resolution */ - Word16 *pcmBuf, /* o : output synthesis signal */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + UWord16 nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ + /* const IVAS_DEC_PCM_TYPE pcmType, */ /* i : type for the decoded PCM resolution */ + Word16 *pcmBuf, /* o : output synthesis signal */ #ifdef SUPPORT_JBM_TRACEFILE JbmTraceFileWriterFn jbmWriterFn, void *jbmWriter, @@ -4975,7 +4975,6 @@ ivas_error IVAS_DEC_VoIP_GetSplitBinauralBitstream( #endif - /*---------------------------------------------------------------------* * update_voip_rendered20ms( ) * @@ -6134,7 +6133,6 @@ static Word16 ivas_dec_split_rend_cldfb_in( #endif - /*-------------------------------------------------------------------* * ivas_dec_init_split_rend() * diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index 82077791a..2b1220154 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -494,7 +494,7 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( ELSE { Word16 ch, slot_idx, num_slots; - num_slots = int_div_s_x( shl( isar_frame_size_ms, 3), 10); + num_slots = int_div_s_x( shl( isar_frame_size_ms, 3 ), 10 ); /* CLDFB synthesis of main pose */ FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) diff --git a/lib_rend/ivas_cldfb_ring_buffer.c b/lib_rend/ivas_cldfb_ring_buffer.c index d5a78ef68..d23490255 100644 --- a/lib_rend/ivas_cldfb_ring_buffer.c +++ b/lib_rend/ivas_cldfb_ring_buffer.c @@ -56,7 +56,7 @@ static Word16 ivas_cldfb_ringbuf_IsEmpty( ISAR_CLDFB_RINGBUF_HANDLE h ) { test(); - return EQ_16( h->read_pos, h->write_pos ) && !h->is_full; + return EQ_16( h->read_pos, h->write_pos ) && !h->is_full; } @@ -92,7 +92,7 @@ ivas_error ivas_CLDFB_RINGBUF_Open( capacity = i_mult( capacity_columns, CLDFB_NO_CHANNELS_MAX ); move16(); - IF ( ( h = malloc( sizeof( ISAR_CLDFB_RINGBUF ) ) ) == NULL ) + IF( ( h = malloc( sizeof( ISAR_CLDFB_RINGBUF ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for CLDFB ring buffer\n" ); } @@ -108,11 +108,11 @@ ivas_error ivas_CLDFB_RINGBUF_Open( move16(); *ph = h; - IF ( ( h->real = malloc( capacity * sizeof( Word32 ) ) ) == NULL ) + IF( ( h->real = malloc( capacity * sizeof( Word32 ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for CLDFB ring buffer\n" ); } - IF ( ( h->imag = malloc( capacity * sizeof( Word32 ) ) ) == NULL ) + IF( ( h->imag = malloc( capacity * sizeof( Word32 ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for CLDFB ring buffer\n" ); } @@ -134,22 +134,22 @@ void ivas_CLDFB_RINGBUF_Close( { ISAR_CLDFB_RINGBUF_HANDLE h; - IF ( ph == NULL ) + IF( ph == NULL ) { return; } h = *ph; - IF ( h == NULL ) + IF( h == NULL ) { return; } - IF ( h->real != NULL ) + IF( h->real != NULL ) { free( h->real ); } - IF ( h->imag != NULL ) + IF( h->imag != NULL ) { free( h->imag ); } @@ -181,13 +181,13 @@ void ivas_CLDFB_RINGBUF_Push( h->write_pos = add( h->write_pos, CLDFB_NO_CHANNELS_MAX ); move16(); - if ( EQ_16( h->write_pos, h->capacity ) ) + if ( EQ_16( h->write_pos, h->capacity ) ) { h->write_pos = 0; move16(); } - if ( EQ_16( h->read_pos, h->write_pos ) ) + if ( EQ_16( h->read_pos, h->write_pos ) ) { h->is_full = 1; move16(); @@ -212,18 +212,18 @@ void ivas_CLDFB_RINGBUF_Pop( assert( num_bands <= CLDFB_NO_CHANNELS_MAX ); assert( !ivas_cldfb_ringbuf_IsEmpty( h ) ); - IF ( real != NULL ) + IF( real != NULL ) { Copy32( &h->real[h->read_pos], real, num_bands ); } - IF ( imag != NULL ) + IF( imag != NULL ) { Copy32( &h->imag[h->read_pos], imag, num_bands ); } h->read_pos = add( h->read_pos, CLDFB_NO_CHANNELS_MAX ); move16(); - IF ( EQ_16( h->read_pos, h->capacity ) ) + IF( EQ_16( h->read_pos, h->capacity ) ) { h->read_pos = 0; move16(); @@ -245,12 +245,12 @@ void ivas_CLDFB_RINGBUF_Pop( static uint32_t ivas_cldfb_ringbuf_total_size( ISAR_CLDFB_RINGBUF_HANDLE h ) { - IF ( ivas_cldfb_ringbuf_IsFull( h ) ) + IF( ivas_cldfb_ringbuf_IsFull( h ) ) { return h->capacity; } - IF ( LE_16( h->read_pos, h->write_pos ) ) + IF( LE_16( h->read_pos, h->write_pos ) ) { return sub( h->write_pos, h->read_pos ); } @@ -285,7 +285,7 @@ void ivas_CLDFB_RINGBUF_GetByIdx( assert( -num_floats <= idx && idx <= num_floats ); - IF ( GE_16( idx, 0 ) ) + IF( GE_16( idx, 0 ) ) { offset = add( h->read_pos, idx ); move16(); @@ -299,7 +299,7 @@ void ivas_CLDFB_RINGBUF_GetByIdx( { idx = negate( idx ); move16(); - IF ( LE_16 ( idx, h->write_pos ) ) + IF( LE_16( idx, h->write_pos ) ) { offset = sub( h->write_pos, idx ); move16(); diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 398d28350..7fe2f3af7 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1439,8 +1439,8 @@ typedef struct typedef struct { - Word32 *data; /* samples in interleaved layout, e.g. for channels A, B, C, samples are stored: A1, B1, C1, A2, B2, C2, ... */ - Word32 capacity; /* max number of Word32 values that can be stored */ + Word32 *data; /* samples in interleaved layout, e.g. for channels A, B, C, samples are stored: A1, B1, C1, A2, B2, C2, ... */ + Word32 capacity; /* max number of Word32 values that can be stored */ Word16 num_channels; Word32 write_pos; Word32 read_pos; diff --git a/lib_rend/ivas_td_ring_buffer_fx.c b/lib_rend/ivas_td_ring_buffer_fx.c index 0f1a72c47..9d26bbd2d 100644 --- a/lib_rend/ivas_td_ring_buffer_fx.c +++ b/lib_rend/ivas_td_ring_buffer_fx.c @@ -57,7 +57,7 @@ static Word32 ivas_td_ringbuf_total_size( return h->capacity; } - IF ( LE_32( h->read_pos, h->write_pos ) ) + IF( LE_32( h->read_pos, h->write_pos ) ) { return L_sub( h->write_pos, h->read_pos ); } @@ -70,14 +70,14 @@ static Word16 ivas_td_ringbuf_has_space_for_num_samples( TD_RINGBUF_HANDLE h, const Word32 num_samples ) { - return LE_32( L_add( ivas_td_ringbuf_total_size( h ), num_samples ), h->capacity ); + return LE_32( L_add( ivas_td_ringbuf_total_size( h ), num_samples ), h->capacity ); } #ifdef FIX_1119_SPLIT_RENDERING_VOIP static void ivas_td_ringbuf_push_interleaved( - TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ - const Word32 *data, /* i : Input audio in interleaved channels layout */ + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + const Word32 *data, /* i : Input audio in interleaved channels layout */ const Word16 num_samples_per_channel, /* i : Number of samples per channel to push */ const Word16 read_stride /* i: : 1 for normal operation, 0 for reading from a single input value */ ) @@ -91,7 +91,7 @@ static void ivas_td_ringbuf_push_interleaved( read_s = 0; move32(); - FOR ( s = 0; s < L_mult0( num_samples_per_channel, h->num_channels); ++s ) + FOR( s = 0; s < L_mult0( num_samples_per_channel, h->num_channels ); ++s ) { h->data[h->write_pos] = data[read_s]; move32(); @@ -105,7 +105,7 @@ static void ivas_td_ringbuf_push_interleaved( move32(); } - if ( EQ_32( h->read_pos, h->write_pos ) ) + if ( EQ_32( h->read_pos, h->write_pos ) ) { h->is_full = 1; move16(); @@ -129,7 +129,7 @@ static void ivas_td_ringbuf_push_interleaved( *---------------------------------------------------------------------*/ ivas_error ivas_TD_RINGBUF_Open( - TD_RINGBUF_HANDLE *ph, /* i/o: Ring buffer handle */ + TD_RINGBUF_HANDLE *ph, /* i/o: Ring buffer handle */ const Word16 capacity_per_channel, /* i : Number of samples stored per channel */ const Word16 num_channels /* i : Number of channels */ ) @@ -141,7 +141,7 @@ ivas_error ivas_TD_RINGBUF_Open( move32(); h = malloc( sizeof( TD_RINGBUF_DATA ) ); - IF ( h == NULL ) + IF( h == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for TD ring buffer\n" ); } @@ -183,18 +183,18 @@ void ivas_TD_RINGBUF_Close( { TD_RINGBUF_HANDLE h; - IF ( ph == NULL ) + IF( ph == NULL ) { return; } h = *ph; - IF ( h == NULL ) + IF( h == NULL ) { return; } - IF ( h->data != NULL ) + IF( h->data != NULL ) { free( h->data ); } @@ -214,8 +214,8 @@ void ivas_TD_RINGBUF_Close( *---------------------------------------------------------------------*/ void ivas_TD_RINGBUF_PushInterleaved( - TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ - const Word32 *data, /* i : Input audio in interleaved channels layout */ + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + const Word32 *data, /* i : Input audio in interleaved channels layout */ const Word16 num_samples_per_channel /* i : Number of samples per channel to push */ ) { @@ -232,8 +232,8 @@ void ivas_TD_RINGBUF_PushInterleaved( *---------------------------------------------------------------------*/ void ivas_TD_RINGBUF_PushChannels( - TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ - const Word32 *p_channels[], /* i : Array of pointers to each input channel */ + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + const Word32 *p_channels[], /* i : Array of pointers to each input channel */ const Word16 num_samples_per_channel /* i : Number of samples per channel to push */ ) #else @@ -245,8 +245,8 @@ void ivas_TD_RINGBUF_PushChannels( *---------------------------------------------------------------------*/ void ivas_TD_RINGBUF_Push( - TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ - const Word32 *data, /* i : Input data */ + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + const Word32 *data, /* i : Input data */ const Word16 num_samples_per_channel /* i : Number of samples per channel to store */ ) #endif @@ -264,9 +264,9 @@ void ivas_TD_RINGBUF_Push( #endif assert( ivas_td_ringbuf_has_space_for_num_samples( h, num_samples_per_channel * h->num_channels ) ); - FOR ( s = 0; s < num_samples_per_channel; ++s ) + FOR( s = 0; s < num_samples_per_channel; ++s ) { - FOR ( c = 0; c < h->num_channels; ++c ) + FOR( c = 0; c < h->num_channels; ++c ) { #ifdef FIX_1119_SPLIT_RENDERING_VOIP h->data[h->write_pos] = p_channels[c][s]; @@ -303,8 +303,8 @@ void ivas_TD_RINGBUF_Push( *---------------------------------------------------------------------*/ void ivas_TD_RINGBUF_PushConstant( - TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ - const Word32 value, /* i : Value to push */ + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + const Word32 value, /* i : Value to push */ const Word16 num_samples_per_channel /* i : Number of samples per channel to push */ ) { @@ -320,7 +320,7 @@ void ivas_TD_RINGBUF_PushConstant( *---------------------------------------------------------------------*/ void ivas_TD_RINGBUF_PushZeros( - TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ const Word16 num_samples_per_channel /* i : Number of zeros per channel to store */ ) { @@ -333,15 +333,15 @@ void ivas_TD_RINGBUF_PushZeros( return; } - FOR ( s = 0; s < num_samples_per_channel; ++s ) + FOR( s = 0; s < num_samples_per_channel; ++s ) { - FOR ( c = 0; c < h->num_channels; ++c ) + FOR( c = 0; c < h->num_channels; ++c ) { h->data[h->write_pos] = 0.f; move32(); ++h->write_pos; - if ( EQ_32 ( h->write_pos == h->capacity ) ) + if ( EQ_32( h->write_pos == h->capacity ) ) { h->write_pos = 0; move32(); @@ -368,8 +368,8 @@ void ivas_TD_RINGBUF_PushZeros( *---------------------------------------------------------------------*/ void ivas_TD_RINGBUF_PopChannels( - TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ - Word32 *p_channels[], /* i : Array of pointers to each output channel */ + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + Word32 *p_channels[], /* i : Array of pointers to each output channel */ const Word16 num_samples_per_channel /* i : Number of samples per channel to pop */ ) #else @@ -380,8 +380,8 @@ void ivas_TD_RINGBUF_PopChannels( *---------------------------------------------------------------------*/ void ivas_TD_RINGBUF_Pop( - TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ - Word32 *data, /* i : Output data */ + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + Word32 *data, /* i : Output data */ const Word16 num_samples_per_channel /* i : Number of samples per channel to retrieve */ ) #endif @@ -399,9 +399,9 @@ void ivas_TD_RINGBUF_Pop( #endif assert( ivas_td_ringbuf_total_size( h ) >= num_samples_per_channel * h->num_channels ); - FOR ( s = 0; s < num_samples_per_channel; ++s ) + FOR( s = 0; s < num_samples_per_channel; ++s ) { - FOR ( c = 0; c < h->num_channels; ++c ) + FOR( c = 0; c < h->num_channels; ++c ) { #ifdef FIX_1119_SPLIT_RENDERING_VOIP p_channels[c][s] = h->data[h->read_pos]; @@ -412,7 +412,7 @@ void ivas_TD_RINGBUF_Pop( #endif ++h->read_pos; - IF ( EQ_32( h->read_pos, h->capacity ) ) + IF( EQ_32( h->read_pos, h->capacity ) ) { h->read_pos = 0; move32(); diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index f9765c821..e01a93347 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -9047,14 +9047,14 @@ static ivas_error getSamplesInternal( hIvasRend->hRendererConfig->split_rend_config.isar_frame_size_ms, hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, &bits, - p_Cldfb_RealBuffer_Binaural, p_Cldfb_ImagBuffer_Binaural, + p_Cldfb_RealBuffer_Binaural, p_Cldfb_ImagBuffer_Binaural, extract_l( Mpy_32_32( hIvasRend->sampleRateOut, 2684355 /*(BINAURAL_MAXBANDS / 48000) in Q31*/ ) ), 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 ) #else 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, + Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, extract_l( Mpy_32_32( hIvasRend->sampleRateOut, 2684355 /*(BINAURAL_MAXBANDS / 48000) in Q31*/ ) ), 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 ) #endif { -- GitLab From 183b90372a173f19f60718498ff89a584ddd801a Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 00:59:44 +0100 Subject: [PATCH 14/40] Fix build with DEBUGGING enabled --- lib_dec/lib_dec_fx.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index fef1711e6..4882dd11d 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1626,10 +1626,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToOutput, st_ivas->BER_detect, Q11 ); } -#ifdef DEBUGGING - st_ivas->noClipping += -#endif - ivas_syn_output_fx( p_head_pose_buf, Q11, numSamplesPerChannelToOutput, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf_out ); + ivas_syn_output_fx( p_head_pose_buf, Q11, numSamplesPerChannelToOutput, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf_out ); } #else Decoder_Struct *st_ivas; @@ -4865,10 +4862,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, Q11 ); } -#ifdef DEBUGGING - st_ivas->noClipping += -#endif - ivas_syn_output_fx( p_head_pose_buf, Q11, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf ); + ivas_syn_output_fx( p_head_pose_buf, Q11, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf ); } } #endif -- GitLab From 012af922bb678cefd064e59c40f0f688e6a99fb4 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 01:04:54 +0100 Subject: [PATCH 15/40] Fix MSVC warnings --- lib_rend/ivas_cldfb_ring_buffer.c | 4 ++-- lib_rend/ivas_td_ring_buffer_fx.c | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib_rend/ivas_cldfb_ring_buffer.c b/lib_rend/ivas_cldfb_ring_buffer.c index d23490255..93f3d9927 100644 --- a/lib_rend/ivas_cldfb_ring_buffer.c +++ b/lib_rend/ivas_cldfb_ring_buffer.c @@ -242,7 +242,7 @@ void ivas_CLDFB_RINGBUF_Pop( * Returns total number of buffered samples (including number of channels) *---------------------------------------------------------------------*/ -static uint32_t ivas_cldfb_ringbuf_total_size( +static Word32 ivas_cldfb_ringbuf_total_size( ISAR_CLDFB_RINGBUF_HANDLE h ) { IF( ivas_cldfb_ringbuf_IsFull( h ) ) @@ -279,7 +279,7 @@ void ivas_CLDFB_RINGBUF_GetByIdx( { Word16 idx = i_mult( col_idx, CLDFB_NO_CHANNELS_MAX ); move16(); - Word16 num_floats = ivas_cldfb_ringbuf_total_size( h ); + Word16 num_floats = extract_l( ivas_cldfb_ringbuf_total_size( h ) ); move16(); Word16 offset /*, uidx */; // uidx unused in FX code diff --git a/lib_rend/ivas_td_ring_buffer_fx.c b/lib_rend/ivas_td_ring_buffer_fx.c index 9d26bbd2d..e8ce8bd2e 100644 --- a/lib_rend/ivas_td_ring_buffer_fx.c +++ b/lib_rend/ivas_td_ring_buffer_fx.c @@ -70,7 +70,11 @@ static Word16 ivas_td_ringbuf_has_space_for_num_samples( TD_RINGBUF_HANDLE h, const Word32 num_samples ) { - return LE_32( L_add( ivas_td_ringbuf_total_size( h ), num_samples ), h->capacity ); + if ( LE_32( L_add( ivas_td_ringbuf_total_size( h ), num_samples ), h->capacity ) ) + { + return 1; + } + return 0; } -- GitLab From 18bfc9c9f21dc6e9dd5bc9bbd454f40ca38bf29a Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 01:07:52 +0100 Subject: [PATCH 16/40] Fix more MSVC warnigs --- lib_dec/lib_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 4882dd11d..3cf66caec 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1187,12 +1187,12 @@ static Word16 isar_get_frame_size( ( st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE || st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) { - nSamplesPerChannel = ar_div( output_Fs, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ); + nSamplesPerChannel = extract_l( ar_div( output_Fs, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ); nSamplesPerChannel = imult1616( nSamplesPerChannel, st_ivas->hDecoderConfig->render_framesize ); } else { - nSamplesPerChannel = ar_div( output_Fs, FRAMES_PER_SEC ); + nSamplesPerChannel = extract_l( ar_div( output_Fs, FRAMES_PER_SEC ) ); } return nSamplesPerChannel; -- GitLab From ada2ff18338fcf9d019d900346cda318fd9f7fad Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 01:46:18 +0100 Subject: [PATCH 17/40] Fix missing bits of porting --- lib_dec/ivas_jbm_dec_fx.c | 4 ++-- lib_dec/lib_dec_fx.c | 37 ++++++++++++++++++------------- lib_isar/isar_splitRendererPre.c | 4 ++-- lib_rend/ivas_cldfb_ring_buffer.c | 6 ++--- lib_rend/ivas_td_ring_buffer_fx.c | 26 +++++++++++----------- lib_rend/lib_rend_fx.c | 4 ++-- 6 files changed, 44 insertions(+), 37 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 81bd0ea6d..e68fe934b 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2466,7 +2466,7 @@ ivas_error ivas_jbm_dec_render_fx( nchan_out_syn_output = BINAURAL_CHANNELS * st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; /* Save TD signals for pose correction if they are to be used */ - if ( st_ivas->hSplitBinRend->hMultiBinTdData != NULL ) + IF ( st_ivas->hSplitBinRend->hMultiBinTdData != NULL ) { FOR( i = 0; i < nchan_out_syn_output; i++ ) { @@ -2476,7 +2476,7 @@ ivas_error ivas_jbm_dec_render_fx( } #ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR // TODO(sgi): verify if this is needed in BASOP - if ( st_ivas->flushing ) + IF ( st_ivas->flushing ) { nchan_out_syn_output = BINAURAL_CHANNELS; } diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 3cf66caec..2ba0d3e26 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1183,14 +1183,16 @@ static Word16 isar_get_frame_size( output_Fs = st_ivas->hDecoderConfig->output_Fs; - if ( st_ivas->hDecoderConfig->render_framesize != IVAS_RENDER_FRAMESIZE_20MS && + test(); + test(); + IF ( st_ivas->hDecoderConfig->render_framesize != IVAS_RENDER_FRAMESIZE_20MS && ( st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE || st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) { nSamplesPerChannel = extract_l( ar_div( output_Fs, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ); nSamplesPerChannel = imult1616( nSamplesPerChannel, st_ivas->hDecoderConfig->render_framesize ); } - else + ELSE { nSamplesPerChannel = extract_l( ar_div( output_Fs, FRAMES_PER_SEC ) ); } @@ -1221,7 +1223,7 @@ static ivas_error isar_render_poses( ivas_error error; Word16 numPoses; - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + IF ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } @@ -1233,7 +1235,7 @@ static ivas_error isar_render_poses( numPoses = st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; /* init flush buffer for rate switch if not already initizalized */ - if ( hIvasDec->flushbuffer == NULL ) + IF ( hIvasDec->flushbuffer == NULL ) { hIvasDec->flushbuffer = (void *) malloc( sizeof( Word16 ) * 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 ); @@ -1562,7 +1564,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( bool *needNewFrame /* o : indication that the decoder needs a new frame */ ) { -#ifdef FIX_1119_SPLIT_RENDERING_VOIP // TODO(sgi): this function still needs to be ported to BASOP +#ifdef FIX_1119_SPLIT_RENDERING_VOIP Decoder_Struct *st_ivas; ivas_error error; Word32 head_pose_buf[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES][L_FRAME48k]; @@ -1573,49 +1575,51 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( Word16 Q_out[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS]; test(); - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + IF ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } st_ivas = hIvasDec->st_ivas; - if ( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) == 0 ) + IF ( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) == 0 ) { return IVAS_ERR_WRONG_PARAMS; } pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; + move16(); numSamplesPerChannelToOutput = isar_get_frame_size( st_ivas ); + move16(); - if ( ( error = isar_render_poses( hIvasDec, numSamplesPerChannelToOutput, nOutSamples, needNewFrame ) ) != IVAS_ERR_OK ) + IF ( ( error = isar_render_poses( hIvasDec, numSamplesPerChannelToOutput, nOutSamples, needNewFrame ) ) != IVAS_ERR_OK ) { return error; } - if ( !hIvasDec->hasBeenFedFirstGoodFrame ) + IF ( !hIvasDec->hasBeenFedFirstGoodFrame ) { return IVAS_ERR_OK; } - for ( i = 0; i < BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES; ++i ) + FOR ( i = 0; i < BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES; ++i ) { p_head_pose_buf[i] = head_pose_buf[i]; } - if ( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nOutSamples, splitRendBits, Q_out ) ) != IVAS_ERR_OK ) + IF ( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nOutSamples, splitRendBits, Q_out ) ) != IVAS_ERR_OK ) { return error; } /* convert to int16 with limiting for BINAURAL_SPLIT_PCM */ - if ( pcm_out_flag ) + IF ( pcm_out_flag ) { FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) { scale_sig32( p_head_pose_buf[i], numSamplesPerChannelToOutput, sub( Q11, Q_out[i] ) ); // Q11 } - if ( st_ivas->hDecoderConfig->render_framesize == IVAS_RENDER_FRAMESIZE_5MS ) + IF ( st_ivas->hDecoderConfig->render_framesize == IVAS_RENDER_FRAMESIZE_5MS ) { #ifndef DISABLE_LIMITER ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToOutput, st_ivas->BER_detect, Q11 ); @@ -6112,14 +6116,17 @@ static Word16 ivas_dec_split_rend_cldfb_in( const RENDERER_TYPE renderer_type /* i : renderer type */ ) { - if ( renderer_type == RENDERER_BINAURAL_FASTCONV || + test(); + test(); + test(); + IF ( renderer_type == RENDERER_BINAURAL_FASTCONV || renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || renderer_type == RENDERER_BINAURAL_PARAMETRIC || renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) { return 1; } - else + ELSE { return 0; } diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c index ebb07b720..455eeff3f 100644 --- a/lib_isar/isar_splitRendererPre.c +++ b/lib_isar/isar_splitRendererPre.c @@ -2929,9 +2929,9 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( useLc3plus = hSplitBin->hLc3plusEnc != NULL; #ifdef FIX_1119_SPLIT_RENDERING_VOIP - for ( i = 0; i < MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; ++i ) + FOR ( i = 0; i < MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; ++i ) { - for ( j = 0; j < CLDFB_NO_COL_MAX; ++j ) + FOR ( j = 0; j < CLDFB_NO_COL_MAX; ++j ) { p_Cldfb_In_BinReal[i][j] = Cldfb_In_BinReal_fx[i][j]; p_Cldfb_In_BinImag[i][j] = Cldfb_In_BinImag_fx[i][j]; diff --git a/lib_rend/ivas_cldfb_ring_buffer.c b/lib_rend/ivas_cldfb_ring_buffer.c index 93f3d9927..87929a0b5 100644 --- a/lib_rend/ivas_cldfb_ring_buffer.c +++ b/lib_rend/ivas_cldfb_ring_buffer.c @@ -181,13 +181,13 @@ void ivas_CLDFB_RINGBUF_Push( h->write_pos = add( h->write_pos, CLDFB_NO_CHANNELS_MAX ); move16(); - if ( EQ_16( h->write_pos, h->capacity ) ) + IF ( EQ_16( h->write_pos, h->capacity ) ) { h->write_pos = 0; move16(); } - if ( EQ_16( h->read_pos, h->write_pos ) ) + IF ( EQ_16( h->read_pos, h->write_pos ) ) { h->is_full = 1; move16(); @@ -289,7 +289,7 @@ void ivas_CLDFB_RINGBUF_GetByIdx( { offset = add( h->read_pos, idx ); move16(); - if ( LE_16( h->capacity, offset ) ) + IF ( LE_16( h->capacity, offset ) ) { offset = sub( offset, h->capacity ); move16(); diff --git a/lib_rend/ivas_td_ring_buffer_fx.c b/lib_rend/ivas_td_ring_buffer_fx.c index e8ce8bd2e..215500d37 100644 --- a/lib_rend/ivas_td_ring_buffer_fx.c +++ b/lib_rend/ivas_td_ring_buffer_fx.c @@ -70,7 +70,7 @@ static Word16 ivas_td_ringbuf_has_space_for_num_samples( TD_RINGBUF_HANDLE h, const Word32 num_samples ) { - if ( LE_32( L_add( ivas_td_ringbuf_total_size( h ), num_samples ), h->capacity ) ) + IF ( LE_32( L_add( ivas_td_ringbuf_total_size( h ), num_samples ), h->capacity ) ) { return 1; } @@ -101,7 +101,7 @@ static void ivas_td_ringbuf_push_interleaved( move32(); ++h->write_pos; - if ( EQ_32( h->write_pos, h->capacity ) ) + IF ( EQ_32( h->write_pos, h->capacity ) ) { h->write_pos = 0; } @@ -109,7 +109,7 @@ static void ivas_td_ringbuf_push_interleaved( move32(); } - if ( EQ_32( h->read_pos, h->write_pos ) ) + IF ( EQ_32( h->read_pos, h->write_pos ) ) { h->is_full = 1; move16(); @@ -163,7 +163,7 @@ ivas_error ivas_TD_RINGBUF_Open( *ph = h; h->data = malloc( capacity * sizeof( Word32 ) ); - if ( h->data == NULL ) + IF ( h->data == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for TD ring buffer\n" ); } @@ -261,7 +261,7 @@ void ivas_TD_RINGBUF_Push( #ifdef FIX_1119_SPLIT_RENDERING_VOIP assert( h != NULL ); assert( p_channels != NULL ); - for ( c = 0; c < h->num_channels; ++c ) /* Not using BASOP FOR because this loops only does assertions */ + FOR ( c = 0; c < h->num_channels; ++c ) /* Not using BASOP FOR because this loops only does assertions */ { assert( p_channels[c] != NULL ); } @@ -281,7 +281,7 @@ void ivas_TD_RINGBUF_Push( #endif ++h->write_pos; - if ( EQ_32( h->write_pos, h->capacity ) ) + IF ( EQ_32( h->write_pos, h->capacity ) ) { h->write_pos = 0; move32(); @@ -289,7 +289,7 @@ void ivas_TD_RINGBUF_Push( } } - if ( EQ_32( h->read_pos, h->write_pos ) ) + IF ( EQ_32( h->read_pos, h->write_pos ) ) { h->is_full = 1; move16(); @@ -332,7 +332,7 @@ void ivas_TD_RINGBUF_PushZeros( Word16 c; assert( ivas_td_ringbuf_has_space_for_num_samples( h, num_samples_per_channel * h->num_channels ) ); - if ( !num_samples_per_channel ) + IF ( !num_samples_per_channel ) { return; } @@ -345,7 +345,7 @@ void ivas_TD_RINGBUF_PushZeros( move32(); ++h->write_pos; - if ( EQ_32( h->write_pos == h->capacity ) ) + IF ( EQ_32( h->write_pos == h->capacity ) ) { h->write_pos = 0; move32(); @@ -353,7 +353,7 @@ void ivas_TD_RINGBUF_PushZeros( } } - if ( EQ_32( h->read_pos == h->write_pos ) ) + IF ( EQ_32( h->read_pos == h->write_pos ) ) { h->is_full = 1; move16(); @@ -396,7 +396,7 @@ void ivas_TD_RINGBUF_Pop( #ifdef FIX_1119_SPLIT_RENDERING_VOIP assert( h != NULL ); assert( p_channels != NULL ); - for ( c = 0; c < h->num_channels; ++c ) /* Not using BASOP FOR because this loops only does assertions */ + FOR ( c = 0; c < h->num_channels; ++c ) /* Not using BASOP FOR because this loops only does assertions */ { assert( p_channels[c] != NULL ); } @@ -425,13 +425,13 @@ void ivas_TD_RINGBUF_Pop( } #ifdef FIX_1119_SPLIT_RENDERING_VOIP - if ( NE_16( num_samples_per_channel, 0 ) ) + IF ( NE_16( num_samples_per_channel, 0 ) ) { h->is_full = 0; move16(); } #else - if ( h->is_full ) + IF ( h->is_full ) { h->is_full = 0; move16(); diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index e01a93347..76ecb0c87 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -8956,9 +8956,9 @@ static ivas_error getSamplesInternal( Word32 *p_Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX]; Word32 *p_Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX]; - for ( i = 0; i < BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES; ++i ) + FOR ( i = 0; i < BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES; ++i ) { - for ( j = 0; j < CLDFB_NO_COL_MAX; ++j ) + FOR ( j = 0; j < CLDFB_NO_COL_MAX; ++j ) { p_Cldfb_RealBuffer_Binaural[i][j] = Cldfb_RealBuffer_Binaural[i][j]; p_Cldfb_ImagBuffer_Binaural[i][j] = Cldfb_ImagBuffer_Binaural[i][j]; -- GitLab From cbe5b09535fea0eac37fd6e74cbb20a4817d9719 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 01:52:15 +0100 Subject: [PATCH 18/40] Remove NOTE comments --- lib_dec/ivas_jbm_dec_fx.c | 8 ++++---- lib_dec/lib_dec_fx.c | 9 +++------ lib_isar/isar_splitRendererPre.c | 2 +- lib_isar/lib_isar_pre_rend.c | 8 ++++---- lib_rend/lib_rend_fx.c | 2 +- 5 files changed, 13 insertions(+), 16 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index e68fe934b..56dcc3dfe 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2460,7 +2460,7 @@ ivas_error ivas_jbm_dec_render_fx( IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { -#ifdef FIX_1119_SPLIT_RENDERING_VOIP /* NOTE(sgi): BASOP special - not in float version */ +#ifdef FIX_1119_SPLIT_RENDERING_VOIP const Word32 *p_output_fx_const[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; nchan_out_syn_output = BINAURAL_CHANNELS * st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; @@ -2475,7 +2475,7 @@ ivas_error ivas_jbm_dec_render_fx( ivas_TD_RINGBUF_PushChannels( st_ivas->hSplitBinRend->hMultiBinTdData, p_output_fx_const, *nSamplesRendered ); } -#ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR // TODO(sgi): verify if this is needed in BASOP +#ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR IF ( st_ivas->flushing ) { nchan_out_syn_output = BINAURAL_CHANNELS; @@ -2488,13 +2488,13 @@ ivas_error ivas_jbm_dec_render_fx( } #endif } -#ifdef FIX_1119_SPLIT_RENDERING_VOIP /* NOTE(sgi): BASOP special - not in float version */ +#ifdef FIX_1119_SPLIT_RENDERING_VOIP ELSE { #endif nchan_out_syn_output = nchan_out; move16(); -#ifdef FIX_1119_SPLIT_RENDERING_VOIP /* NOTE(sgi): BASOP special - not in float version */ +#ifdef FIX_1119_SPLIT_RENDERING_VOIP } #endif diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 2ba0d3e26..a4b595e55 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -783,7 +783,6 @@ static int16_t get_render_frame_size_samples( Word16 tmp; tmp = (Word16) Mpy_32_16_1( hDecoderConfig->output_Fs, INV_FR_P_S_MX_PRM_SPL_SBFR_Q15 ); - /* NOTE(sgi): BASOP special - not in float version */ IF( EQ_16( hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_5MS ) ) { /* correct value already in tmp */ @@ -815,7 +814,7 @@ ivas_error IVAS_DEC_GetRenderFramesizeSamples( Word16 *render_framesize /* o : render framesize in samples Q0 */ ) { -#ifndef FIX_1119_SPLIT_RENDERING_VOIP /* NOTE(sgi): BASOP special - not in float version */ +#ifndef FIX_1119_SPLIT_RENDERING_VOIP Word16 tmp; #endif @@ -1294,7 +1293,6 @@ static ivas_error isar_generate_metadata_and_bitstream( pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; cldfb_in_flag = ivas_dec_split_rend_cldfb_in( st_ivas->renderer_type ); - // NOTE(sgi): BASOP special - not in float version n_samples_in_cldfb_slot = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); assert( nSamples % n_samples_in_cldfb_slot == 0 ); num_cldfb_slots = int_div_s_x( nSamples, n_samples_in_cldfb_slot ); @@ -1347,7 +1345,6 @@ static ivas_error isar_generate_metadata_and_bitstream( Quaternion.y_fx = 0; Quaternion.z_fx = 0; } - // NOTE(sgi): BASOP special - not in float version Word16 q1 = 31, q2 = 31, Q_buff; Q_out[0] = 31; @@ -1625,7 +1622,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToOutput, st_ivas->BER_detect, Q11 ); #endif } - else + ELSE { ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToOutput, st_ivas->BER_detect, Q11 ); } @@ -4606,7 +4603,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples EQ_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) && splitRendBits == NULL ) { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; // NOTE(sgi): BASOP special - not in float version + return IVAS_ERR_UNEXPECTED_NULL_POINTER; } #endif diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c index 455eeff3f..d08d69221 100644 --- a/lib_isar/isar_splitRendererPre.c +++ b/lib_isar/isar_splitRendererPre.c @@ -3211,7 +3211,7 @@ void lc3plusTimeAlignCldfbPoseCorr( } ELSE { -#ifdef FIX_1119_SPLIT_RENDERING_VOIP // NOTE(sgi): BASOP special - not in float version +#ifdef FIX_1119_SPLIT_RENDERING_VOIP FOR( Word16 i = 0; i < i_mult( hSplitBin->multiBinPoseData.num_poses, BINAURAL_CHANNELS ); i++ ) #else FOR( Word16 i = 0; i < CLDFB_NO_COL_MAX; i++ ) diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index 2b1220154..5a6668b2e 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -420,7 +420,7 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( move16(); FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { -#ifdef FIX_1119_SPLIT_RENDERING_VOIP /* NOTE(sgi): BASOP special - not in float version */ +#ifdef FIX_1119_SPLIT_RENDERING_VOIP FOR( j = 0; j < num_slots; j++ ) #else FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) @@ -438,7 +438,7 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { -#ifdef FIX_1119_SPLIT_RENDERING_VOIP /* NOTE(sgi): BASOP special - not in float version */ +#ifdef FIX_1119_SPLIT_RENDERING_VOIP FOR( j = 0; j < num_slots; j++ ) #else FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) @@ -505,7 +505,7 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( move16(); q2 = 31; move16(); -#ifdef FIX_1119_SPLIT_RENDERING_VOIP // NOTE(sgi): BASOP special - not in float version +#ifdef FIX_1119_SPLIT_RENDERING_VOIP FOR( j = 0; j < num_slots; j++ ) #else FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) @@ -518,7 +518,7 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( q_final = s_min( add( Q_buff_re, q_final ), add( Q_buff_im, q_final ) ); q_final = sub( q_final, 6 ); // guard bits q_final = s_min( q_final, Q25 ); -#ifdef FIX_1119_SPLIT_RENDERING_VOIP // NOTE(sgi): BASOP special - not in float version +#ifdef FIX_1119_SPLIT_RENDERING_VOIP FOR( j = 0; j < num_slots; j++ ) #else FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 76ecb0c87..230652e41 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -9042,7 +9042,7 @@ static ivas_error getSamplesInternal( Q_out[0] = Q_out[0] + *outAudio.pq_fact; } -#ifdef FIX_1119_SPLIT_RENDERING_VOIP /* NOTE(sgi): BASOP special - not in float version */ +#ifdef FIX_1119_SPLIT_RENDERING_VOIP 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, -- GitLab From 3658bd6d60e368618a49a06cc65e45090882ded8 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 09:37:11 +0100 Subject: [PATCH 19/40] Fix build with switch FIX_1119_SPLIT_RENDERING_VOIP disabled --- lib_rend/ivas_td_ring_buffer_fx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_rend/ivas_td_ring_buffer_fx.c b/lib_rend/ivas_td_ring_buffer_fx.c index 215500d37..3f56b0b9e 100644 --- a/lib_rend/ivas_td_ring_buffer_fx.c +++ b/lib_rend/ivas_td_ring_buffer_fx.c @@ -345,7 +345,7 @@ void ivas_TD_RINGBUF_PushZeros( move32(); ++h->write_pos; - IF ( EQ_32( h->write_pos == h->capacity ) ) + IF ( EQ_32( h->write_pos, h->capacity ) ) { h->write_pos = 0; move32(); @@ -353,7 +353,7 @@ void ivas_TD_RINGBUF_PushZeros( } } - IF ( EQ_32( h->read_pos == h->write_pos ) ) + IF ( EQ_32( h->read_pos, h->write_pos ) ) { h->is_full = 1; move16(); @@ -411,7 +411,7 @@ void ivas_TD_RINGBUF_Pop( p_channels[c][s] = h->data[h->read_pos]; move32(); #else - data[L_add( L_mult0( c, num_samples_per_channel ), s )) = h->data[h->read_pos]; + data[L_add( L_mult0( c, num_samples_per_channel ), s ) ] = h->data[h->read_pos]; move32(); #endif ++h->read_pos; -- GitLab From 42b0cc5acaacef8875487590a56967d3c210cb15 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 09:48:25 +0100 Subject: [PATCH 20/40] Fix formatting --- lib_dec/ivas_jbm_dec_fx.c | 4 ++-- lib_dec/lib_dec_fx.c | 34 +++++++++++++++---------------- lib_isar/isar_splitRendererPre.c | 4 ++-- lib_rend/ivas_cldfb_ring_buffer.c | 6 +++--- lib_rend/ivas_td_ring_buffer_fx.c | 28 ++++++++++++------------- lib_rend/lib_rend_fx.c | 4 ++-- 6 files changed, 40 insertions(+), 40 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 56dcc3dfe..162be9100 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2466,7 +2466,7 @@ ivas_error ivas_jbm_dec_render_fx( nchan_out_syn_output = BINAURAL_CHANNELS * st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; /* Save TD signals for pose correction if they are to be used */ - IF ( st_ivas->hSplitBinRend->hMultiBinTdData != NULL ) + IF( st_ivas->hSplitBinRend->hMultiBinTdData != NULL ) { FOR( i = 0; i < nchan_out_syn_output; i++ ) { @@ -2476,7 +2476,7 @@ ivas_error ivas_jbm_dec_render_fx( } #ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR - IF ( st_ivas->flushing ) + IF( st_ivas->flushing ) { nchan_out_syn_output = BINAURAL_CHANNELS; } diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index a4b595e55..12abb15ec 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1184,9 +1184,9 @@ static Word16 isar_get_frame_size( test(); test(); - IF ( st_ivas->hDecoderConfig->render_framesize != IVAS_RENDER_FRAMESIZE_20MS && - ( st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE || - st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) + IF( st_ivas->hDecoderConfig->render_framesize != IVAS_RENDER_FRAMESIZE_20MS && + ( st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE || + st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) { nSamplesPerChannel = extract_l( ar_div( output_Fs, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ); nSamplesPerChannel = imult1616( nSamplesPerChannel, st_ivas->hDecoderConfig->render_framesize ); @@ -1222,7 +1222,7 @@ static ivas_error isar_render_poses( ivas_error error; Word16 numPoses; - IF ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } @@ -1234,7 +1234,7 @@ static ivas_error isar_render_poses( numPoses = st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; /* init flush buffer for rate switch if not already initizalized */ - IF ( hIvasDec->flushbuffer == NULL ) + IF( hIvasDec->flushbuffer == NULL ) { hIvasDec->flushbuffer = (void *) malloc( sizeof( Word16 ) * 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 ); @@ -1572,14 +1572,14 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( Word16 Q_out[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS]; test(); - IF ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } st_ivas = hIvasDec->st_ivas; - IF ( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) == 0 ) + IF( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) == 0 ) { return IVAS_ERR_WRONG_PARAMS; } @@ -1589,34 +1589,34 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( numSamplesPerChannelToOutput = isar_get_frame_size( st_ivas ); move16(); - IF ( ( error = isar_render_poses( hIvasDec, numSamplesPerChannelToOutput, nOutSamples, needNewFrame ) ) != IVAS_ERR_OK ) + IF( ( error = isar_render_poses( hIvasDec, numSamplesPerChannelToOutput, nOutSamples, needNewFrame ) ) != IVAS_ERR_OK ) { return error; } - IF ( !hIvasDec->hasBeenFedFirstGoodFrame ) + IF( !hIvasDec->hasBeenFedFirstGoodFrame ) { return IVAS_ERR_OK; } - FOR ( i = 0; i < BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES; ++i ) + FOR( i = 0; i < BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES; ++i ) { p_head_pose_buf[i] = head_pose_buf[i]; } - IF ( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nOutSamples, splitRendBits, Q_out ) ) != IVAS_ERR_OK ) + IF( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nOutSamples, splitRendBits, Q_out ) ) != IVAS_ERR_OK ) { return error; } /* convert to int16 with limiting for BINAURAL_SPLIT_PCM */ - IF ( pcm_out_flag ) + IF( pcm_out_flag ) { FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) { scale_sig32( p_head_pose_buf[i], numSamplesPerChannelToOutput, sub( Q11, Q_out[i] ) ); // Q11 } - IF ( st_ivas->hDecoderConfig->render_framesize == IVAS_RENDER_FRAMESIZE_5MS ) + IF( st_ivas->hDecoderConfig->render_framesize == IVAS_RENDER_FRAMESIZE_5MS ) { #ifndef DISABLE_LIMITER ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToOutput, st_ivas->BER_detect, Q11 ); @@ -6116,10 +6116,10 @@ static Word16 ivas_dec_split_rend_cldfb_in( test(); test(); test(); - IF ( renderer_type == RENDERER_BINAURAL_FASTCONV || - renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || - renderer_type == RENDERER_BINAURAL_PARAMETRIC || - renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + IF( renderer_type == RENDERER_BINAURAL_FASTCONV || + renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || + renderer_type == RENDERER_BINAURAL_PARAMETRIC || + renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) { return 1; } diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c index d08d69221..fe4965993 100644 --- a/lib_isar/isar_splitRendererPre.c +++ b/lib_isar/isar_splitRendererPre.c @@ -2929,9 +2929,9 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( useLc3plus = hSplitBin->hLc3plusEnc != NULL; #ifdef FIX_1119_SPLIT_RENDERING_VOIP - FOR ( i = 0; i < MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; ++i ) + FOR( i = 0; i < MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; ++i ) { - FOR ( j = 0; j < CLDFB_NO_COL_MAX; ++j ) + FOR( j = 0; j < CLDFB_NO_COL_MAX; ++j ) { p_Cldfb_In_BinReal[i][j] = Cldfb_In_BinReal_fx[i][j]; p_Cldfb_In_BinImag[i][j] = Cldfb_In_BinImag_fx[i][j]; diff --git a/lib_rend/ivas_cldfb_ring_buffer.c b/lib_rend/ivas_cldfb_ring_buffer.c index 87929a0b5..49d88e8f3 100644 --- a/lib_rend/ivas_cldfb_ring_buffer.c +++ b/lib_rend/ivas_cldfb_ring_buffer.c @@ -181,13 +181,13 @@ void ivas_CLDFB_RINGBUF_Push( h->write_pos = add( h->write_pos, CLDFB_NO_CHANNELS_MAX ); move16(); - IF ( EQ_16( h->write_pos, h->capacity ) ) + IF( EQ_16( h->write_pos, h->capacity ) ) { h->write_pos = 0; move16(); } - IF ( EQ_16( h->read_pos, h->write_pos ) ) + IF( EQ_16( h->read_pos, h->write_pos ) ) { h->is_full = 1; move16(); @@ -289,7 +289,7 @@ void ivas_CLDFB_RINGBUF_GetByIdx( { offset = add( h->read_pos, idx ); move16(); - IF ( LE_16( h->capacity, offset ) ) + IF( LE_16( h->capacity, offset ) ) { offset = sub( offset, h->capacity ); move16(); diff --git a/lib_rend/ivas_td_ring_buffer_fx.c b/lib_rend/ivas_td_ring_buffer_fx.c index 3f56b0b9e..4036e6011 100644 --- a/lib_rend/ivas_td_ring_buffer_fx.c +++ b/lib_rend/ivas_td_ring_buffer_fx.c @@ -70,7 +70,7 @@ static Word16 ivas_td_ringbuf_has_space_for_num_samples( TD_RINGBUF_HANDLE h, const Word32 num_samples ) { - IF ( LE_32( L_add( ivas_td_ringbuf_total_size( h ), num_samples ), h->capacity ) ) + IF( LE_32( L_add( ivas_td_ringbuf_total_size( h ), num_samples ), h->capacity ) ) { return 1; } @@ -101,7 +101,7 @@ static void ivas_td_ringbuf_push_interleaved( move32(); ++h->write_pos; - IF ( EQ_32( h->write_pos, h->capacity ) ) + IF( EQ_32( h->write_pos, h->capacity ) ) { h->write_pos = 0; } @@ -109,7 +109,7 @@ static void ivas_td_ringbuf_push_interleaved( move32(); } - IF ( EQ_32( h->read_pos, h->write_pos ) ) + IF( EQ_32( h->read_pos, h->write_pos ) ) { h->is_full = 1; move16(); @@ -163,7 +163,7 @@ ivas_error ivas_TD_RINGBUF_Open( *ph = h; h->data = malloc( capacity * sizeof( Word32 ) ); - IF ( h->data == NULL ) + IF( h->data == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for TD ring buffer\n" ); } @@ -261,7 +261,7 @@ void ivas_TD_RINGBUF_Push( #ifdef FIX_1119_SPLIT_RENDERING_VOIP assert( h != NULL ); assert( p_channels != NULL ); - FOR ( c = 0; c < h->num_channels; ++c ) /* Not using BASOP FOR because this loops only does assertions */ + FOR( c = 0; c < h->num_channels; ++c ) /* Not using BASOP FOR because this loops only does assertions */ { assert( p_channels[c] != NULL ); } @@ -281,7 +281,7 @@ void ivas_TD_RINGBUF_Push( #endif ++h->write_pos; - IF ( EQ_32( h->write_pos, h->capacity ) ) + IF( EQ_32( h->write_pos, h->capacity ) ) { h->write_pos = 0; move32(); @@ -289,7 +289,7 @@ void ivas_TD_RINGBUF_Push( } } - IF ( EQ_32( h->read_pos, h->write_pos ) ) + IF( EQ_32( h->read_pos, h->write_pos ) ) { h->is_full = 1; move16(); @@ -332,7 +332,7 @@ void ivas_TD_RINGBUF_PushZeros( Word16 c; assert( ivas_td_ringbuf_has_space_for_num_samples( h, num_samples_per_channel * h->num_channels ) ); - IF ( !num_samples_per_channel ) + IF( !num_samples_per_channel ) { return; } @@ -345,7 +345,7 @@ void ivas_TD_RINGBUF_PushZeros( move32(); ++h->write_pos; - IF ( EQ_32( h->write_pos, h->capacity ) ) + IF( EQ_32( h->write_pos, h->capacity ) ) { h->write_pos = 0; move32(); @@ -353,7 +353,7 @@ void ivas_TD_RINGBUF_PushZeros( } } - IF ( EQ_32( h->read_pos, h->write_pos ) ) + IF( EQ_32( h->read_pos, h->write_pos ) ) { h->is_full = 1; move16(); @@ -396,7 +396,7 @@ void ivas_TD_RINGBUF_Pop( #ifdef FIX_1119_SPLIT_RENDERING_VOIP assert( h != NULL ); assert( p_channels != NULL ); - FOR ( c = 0; c < h->num_channels; ++c ) /* Not using BASOP FOR because this loops only does assertions */ + FOR( c = 0; c < h->num_channels; ++c ) /* Not using BASOP FOR because this loops only does assertions */ { assert( p_channels[c] != NULL ); } @@ -411,7 +411,7 @@ void ivas_TD_RINGBUF_Pop( p_channels[c][s] = h->data[h->read_pos]; move32(); #else - data[L_add( L_mult0( c, num_samples_per_channel ), s ) ] = h->data[h->read_pos]; + data[L_add( L_mult0( c, num_samples_per_channel ), s )] = h->data[h->read_pos]; move32(); #endif ++h->read_pos; @@ -425,13 +425,13 @@ void ivas_TD_RINGBUF_Pop( } #ifdef FIX_1119_SPLIT_RENDERING_VOIP - IF ( NE_16( num_samples_per_channel, 0 ) ) + IF( NE_16( num_samples_per_channel, 0 ) ) { h->is_full = 0; move16(); } #else - IF ( h->is_full ) + IF( h->is_full ) { h->is_full = 0; move16(); diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 230652e41..f32dee8b8 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -8956,9 +8956,9 @@ static ivas_error getSamplesInternal( Word32 *p_Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX]; Word32 *p_Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX]; - FOR ( i = 0; i < BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES; ++i ) + FOR( i = 0; i < BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES; ++i ) { - FOR ( j = 0; j < CLDFB_NO_COL_MAX; ++j ) + FOR( j = 0; j < CLDFB_NO_COL_MAX; ++j ) { p_Cldfb_RealBuffer_Binaural[i][j] = Cldfb_RealBuffer_Binaural[i][j]; p_Cldfb_ImagBuffer_Binaural[i][j] = Cldfb_ImagBuffer_Binaural[i][j]; -- GitLab From 4eea9cefa605d8d6d6ad26c58ef026ece83c982c Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 13:49:24 +0100 Subject: [PATCH 21/40] Apply review suggestions - batch 1 --- lib_dec/ivas_jbm_dec_fx.c | 5 +++-- lib_dec/ivas_omasa_dec_fx.c | 2 +- lib_dec/ivas_osba_dec_fx.c | 2 +- lib_dec/ivas_output_config_fx.c | 5 +++++ lib_dec/ivas_stat_dec.h | 2 +- lib_dec/lib_dec.h | 16 +++++++------- lib_dec/lib_dec_fx.c | 35 +++++++++++++++++++++++-------- lib_isar/isar_splitRendererPre.c | 2 +- lib_isar/lib_isar_pre_rend.c | 2 +- lib_rend/ivas_td_ring_buffer_fx.c | 17 ++++++++------- 10 files changed, 56 insertions(+), 32 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 162be9100..0e25388f2 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2463,7 +2463,7 @@ ivas_error ivas_jbm_dec_render_fx( #ifdef FIX_1119_SPLIT_RENDERING_VOIP const Word32 *p_output_fx_const[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; - nchan_out_syn_output = BINAURAL_CHANNELS * st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; + nchan_out_syn_output = i_mult( BINAURAL_CHANNELS, st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ); /* Save TD signals for pose correction if they are to be used */ IF( st_ivas->hSplitBinRend->hMultiBinTdData != NULL ) @@ -2476,9 +2476,10 @@ ivas_error ivas_jbm_dec_render_fx( } #ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR - IF( st_ivas->flushing ) + if( st_ivas->flushing ) { nchan_out_syn_output = BINAURAL_CHANNELS; + move16(); } #endif #else diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index af2b33158..1f3eb6314 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -1250,7 +1250,7 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm_fx( Scale_sig32( Cldfb_ImagBuffer, num_cldfb_bands, sub( Q6, q_cldfb ) ); #ifdef FIX_1119_SPLIT_RENDERING_VOIP - ivas_CLDFB_RINGBUF_GetByIdx( st_ivas->hSplitBinRend->hMultiBinCldfbData[n], &re, &im, slot_idx - cldfb_slots ); + ivas_CLDFB_RINGBUF_GetByIdx( st_ivas->hSplitBinRend->hMultiBinCldfbData[n], &re, &im, sub( slot_idx, cldfb_slots ) ); v_add_fx( re, Cldfb_RealBuffer, re, num_cldfb_bands ); v_add_fx( im, Cldfb_ImagBuffer, im, num_cldfb_bands ); #else diff --git a/lib_dec/ivas_osba_dec_fx.c b/lib_dec/ivas_osba_dec_fx.c index 5f174034c..c4e0fc8a7 100644 --- a/lib_dec/ivas_osba_dec_fx.c +++ b/lib_dec/ivas_osba_dec_fx.c @@ -207,7 +207,7 @@ ivas_error ivas_osba_dirac_td_binaural_jbm_fx( Scale_sig32( Cldfb_ImagBuffer, num_cldfb_bands, sub( Q6, q_cldfb ) ); #ifdef FIX_1119_SPLIT_RENDERING_VOIP - ivas_CLDFB_RINGBUF_GetByIdx( st_ivas->hSplitBinRend->hMultiBinCldfbData[n], &re, &im, slot_idx - cldfb_slots ); + ivas_CLDFB_RINGBUF_GetByIdx( st_ivas->hSplitBinRend->hMultiBinCldfbData[n], &re, &im, sub( slot_idx, cldfb_slots ) ); v_add_fx( re, Cldfb_RealBuffer, re, num_cldfb_bands ); v_add_fx( im, Cldfb_ImagBuffer, im, num_cldfb_bands ); #else diff --git a/lib_dec/ivas_output_config_fx.c b/lib_dec/ivas_output_config_fx.c index c71431e5c..1958cea41 100644 --- a/lib_dec/ivas_output_config_fx.c +++ b/lib_dec/ivas_output_config_fx.c @@ -626,7 +626,12 @@ RENDERER_TYPE ivas_renderer_secondary_select_fx( test(); test(); + test(); + test(); + test(); #ifdef FIX_1119_SPLIT_RENDERING_VOIP + test(); + test(); test(); test(); IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 53d73c7c9..16354439e 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1209,7 +1209,7 @@ typedef struct Decoder_Struct Word16 ism_extmeta_cnt; /* Change frame counter for extended metadata */ #ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR - int16_t flushing; + Word16 flushing; #endif } Decoder_Struct; diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 945e0526f..e911a5fca 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -310,18 +310,18 @@ ivas_error IVAS_DEC_VoIP_GetSamples( #ifdef FIX_1119_SPLIT_RENDERING_VOIP /*! r: error code */ ivas_error IVAS_DEC_VoIP_GetSplitBinauralBitstream( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - /* const IVAS_DEC_PCM_TYPE pcmType, */ /* i : type for the decoded PCM resolution */ - Word16 *pcmBuf, /* o : output synthesis signal */ - ISAR_SPLIT_REND_BITS_DATA *splitRendBits, /* o : output split rendering bits */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + /* const IVAS_DEC_PCM_TYPE pcmType, */ /* i : type for the decoded PCM resolution */ + Word16 *pcmBuf, /* o : output synthesis signal */ + ISAR_SPLIT_REND_BITS_DATA *splitRendBits, /* o : output split rendering bits */ #ifdef SUPPORT_JBM_TRACEFILE JbmTraceFileWriterFn jbmWriterFn, void* jbmWriter, #endif - bool *bitstreamReadDone, /* o : flag indicating that bitstream was read */ - UWord16 *nSamplesRendered, /* o : number of samples rendered */ - bool *parametersAvailableForEditing, /* o : indicates whether objects editing is available */ - const UWord32 systemTimestamp_ms /* i : current system timestamp */ + bool *bitstreamReadDone, /* o : flag indicating that bitstream was read */ + UWord16 *nSamplesRendered, /* o : number of samples rendered */ + bool *parametersAvailableForEditing, /* o : indicates whether objects editing is available */ + const UWord32 systemTimestamp_ms /* i : current system timestamp */ ); #endif diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 12abb15ec..8184452e7 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -776,7 +776,7 @@ ivas_error IVAS_DEC_GetRenderFramesize( * *---------------------------------------------------------------------*/ -static int16_t get_render_frame_size_samples( +static Word16 get_render_frame_size_samples( const DECODER_CONFIG_HANDLE hDecoderConfig /* i : configuration structure */ ) { @@ -1184,9 +1184,9 @@ static Word16 isar_get_frame_size( test(); test(); - IF( st_ivas->hDecoderConfig->render_framesize != IVAS_RENDER_FRAMESIZE_20MS && - ( st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE || - st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) + IF( NE_32( st_ivas->hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_20MS ) && + ( EQ_32( st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) || + EQ_32( st_ivas->hRenderConfig->split_rend_config.dof, 0 ) ) ) { nSamplesPerChannel = extract_l( ar_div( output_Fs, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ); nSamplesPerChannel = imult1616( nSamplesPerChannel, st_ivas->hDecoderConfig->render_framesize ); @@ -1222,16 +1222,19 @@ static ivas_error isar_render_poses( ivas_error error; Word16 numPoses; + test(); IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } *needNewFrame = false; + move16(); st_ivas = hIvasDec->st_ivas; numPoses = st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; + move16(); /* init flush buffer for rate switch if not already initizalized */ IF( hIvasDec->flushbuffer == NULL ) @@ -1298,6 +1301,7 @@ static ivas_error isar_generate_metadata_and_bitstream( num_cldfb_slots = int_div_s_x( nSamples, n_samples_in_cldfb_slot ); num_poses = hSplitBinRend->splitrend.multiBinPoseData.num_poses; + move16(); IF( cldfb_in_flag ) { @@ -1341,12 +1345,19 @@ static ivas_error isar_generate_metadata_and_bitstream( ELSE { Quaternion.w_fx = -12582912; + move32(); Quaternion.x_fx = 0; + move32(); Quaternion.y_fx = 0; + move32(); Quaternion.z_fx = 0; + move32(); } Word16 q1 = 31, q2 = 31, Q_buff; + move32(); + move32(); Q_out[0] = 31; + move32(); IF( EQ_16( cldfb_in_flag, 1 ) ) { @@ -1375,6 +1386,7 @@ static ivas_error isar_generate_metadata_and_bitstream( /*if CLDFB handles have been allocated then assume valid multi binaural input in out[][] buffer and perform CLDFB analysis*/ /* local float2fix, to be removed */ num_poses = hSplitBinRend->splitrend.multiBinPoseData.num_poses; + move16(); FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; ++i ) { @@ -1387,7 +1399,9 @@ static ivas_error isar_generate_metadata_and_bitstream( } Q_out[0] = add( Q_out[0], Q11 ); Q_out[1] = Q_out[0]; + move16(); Q_buff = Q31 + Q6; // likely unneeded + move16(); } IF( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( &hSplitBinRend->splitrend, @@ -5029,6 +5043,7 @@ ivas_error IVAS_DEC_Flush( #ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR hIvasDec->st_ivas->flushing = 1; + move16(); #endif *nSamplesFlushed = s_min( nSamplesPerChannel, hIvasDec->nSamplesAvailableNext ); @@ -5053,6 +5068,7 @@ ivas_error IVAS_DEC_Flush( } #ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR hIvasDec->st_ivas->flushing = 0; + move16(); #endif @@ -6116,10 +6132,10 @@ static Word16 ivas_dec_split_rend_cldfb_in( test(); test(); test(); - IF( renderer_type == RENDERER_BINAURAL_FASTCONV || - renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || - renderer_type == RENDERER_BINAURAL_PARAMETRIC || - renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + IF( EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV ) || + EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || + EQ_32( renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || + EQ_32( renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) { return 1; } @@ -6178,6 +6194,7 @@ static ivas_error ivas_dec_init_split_rend( ISAR_PRE_REND_GetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->sr_pose_pred_axis : DEFAULT_AXIS ); num_poses = st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; + move16(); assert( num_poses <= MAX_HEAD_ROT_POSES ); IF( cldfb_in_flag ) @@ -6193,7 +6210,7 @@ static ivas_error ivas_dec_init_split_rend( } ELSE { - IF( ( error = ivas_TD_RINGBUF_Open( &st_ivas->hSplitBinRend->hMultiBinTdData, get_render_frame_size_samples( st_ivas->hDecoderConfig ), num_poses * BINAURAL_CHANNELS ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_TD_RINGBUF_Open( &st_ivas->hSplitBinRend->hMultiBinTdData, get_render_frame_size_samples( st_ivas->hDecoderConfig ), i_mult( num_poses, BINAURAL_CHANNELS ) ) ) != IVAS_ERR_OK ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for split rendering structure" ); } diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c index fe4965993..dacb1777f 100644 --- a/lib_isar/isar_splitRendererPre.c +++ b/lib_isar/isar_splitRendererPre.c @@ -2915,7 +2915,7 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( Word32 *in_delayed_fx[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS]; Word16 i; #ifdef FIX_1119_SPLIT_RENDERING_VOIP - int16_t j; + Word16 j; Word32 *p_Cldfb_In_BinReal[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX]; Word32 *p_Cldfb_In_BinImag[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX]; #endif diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index 5a6668b2e..49f2f4964 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -539,7 +539,7 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( Q_cldfb = q_final; move16(); Scale_sig32( hSplitBin->hCldfbHandles->cldfbSyn[ch]->cldfb_state_fx, hSplitBin->hCldfbHandles->cldfbSyn[ch]->p_filter_length, sub( sub( Q_cldfb, 1 ), hSplitBin->hCldfbHandles->cldfbSyn[ch]->Q_cldfb_state ) ); - cldfbSynthesis_ivas_fx( Cldfb_In_BinReal_p_fx, Cldfb_In_BinImag_p_fx, pOutput_fx[ch], hSplitBin->hCldfbHandles->cldfbSyn[0]->no_channels * num_slots, 0, 0, hSplitBin->hCldfbHandles->cldfbSyn[ch] ); // Q_cldfb - 1 + cldfbSynthesis_ivas_fx( Cldfb_In_BinReal_p_fx, Cldfb_In_BinImag_p_fx, pOutput_fx[ch], i_mult( hSplitBin->hCldfbHandles->cldfbSyn[0]->no_channels, num_slots ), 0, 0, hSplitBin->hCldfbHandles->cldfbSyn[ch] ); // Q_cldfb - 1 Q_out[ch] = sub( Q_cldfb, 1 ); move16(); hSplitBin->hCldfbHandles->cldfbSyn[ch]->Q_cldfb_state = Q_out[ch]; diff --git a/lib_rend/ivas_td_ring_buffer_fx.c b/lib_rend/ivas_td_ring_buffer_fx.c index 4036e6011..a67143dbb 100644 --- a/lib_rend/ivas_td_ring_buffer_fx.c +++ b/lib_rend/ivas_td_ring_buffer_fx.c @@ -99,17 +99,18 @@ static void ivas_td_ringbuf_push_interleaved( { h->data[h->write_pos] = data[read_s]; move32(); - ++h->write_pos; + h->write_pos = L_add( h->write_pos, 1 ); - IF( EQ_32( h->write_pos, h->capacity ) ) + if ( EQ_32( h->write_pos, h->capacity ) ) { h->write_pos = 0; + move16(); } read_s = L_add( read_s, L_deposit_l( read_stride ) ); move32(); } - IF( EQ_32( h->read_pos, h->write_pos ) ) + if ( EQ_32( h->read_pos, h->write_pos ) ) { h->is_full = 1; move16(); @@ -279,9 +280,9 @@ void ivas_TD_RINGBUF_Push( h->data[h->write_pos] = data[L_add( L_mult0( c, num_samples_per_channel ), s )]; move32(); #endif - ++h->write_pos; + h->write_pos = L_add( h->write_pos, 1 ); - IF( EQ_32( h->write_pos, h->capacity ) ) + if ( EQ_32( h->write_pos, h->capacity ) ) { h->write_pos = 0; move32(); @@ -289,7 +290,7 @@ void ivas_TD_RINGBUF_Push( } } - IF( EQ_32( h->read_pos, h->write_pos ) ) + if ( EQ_32( h->read_pos, h->write_pos ) ) { h->is_full = 1; move16(); @@ -343,7 +344,7 @@ void ivas_TD_RINGBUF_PushZeros( { h->data[h->write_pos] = 0.f; move32(); - ++h->write_pos; + h->write_pos = L_add( h->write_pos, 1 ); IF( EQ_32( h->write_pos, h->capacity ) ) { @@ -353,7 +354,7 @@ void ivas_TD_RINGBUF_PushZeros( } } - IF( EQ_32( h->read_pos, h->write_pos ) ) + if ( EQ_32( h->read_pos, h->write_pos ) ) { h->is_full = 1; move16(); -- GitLab From 93085e53af8ae561a62f29ccd55f73fa43bd6927 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 14:00:41 +0100 Subject: [PATCH 22/40] 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 0e25388f2..92b65f7a7 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2476,7 +2476,7 @@ ivas_error ivas_jbm_dec_render_fx( } #ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR - if( st_ivas->flushing ) + if ( st_ivas->flushing ) { nchan_out_syn_output = BINAURAL_CHANNELS; move16(); -- GitLab From ed749e0bf79ceaba3f67f7f8a26830daa5e711e9 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 14:31:41 +0100 Subject: [PATCH 23/40] Fix missing BASOPs part 1 --- lib_dec/lib_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 8184452e7..c0d3b4344 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1292,7 +1292,7 @@ static ivas_error isar_generate_metadata_and_bitstream( hSplitBinRend = st_ivas->hSplitBinRend; - max_band = (Word16) ar_div( BINAURAL_MAXBANDS * st_ivas->hDecoderConfig->output_Fs, 48000 ); + max_band = extract_l( ar_div( imult3216( st_ivas->hDecoderConfig->output_Fs, BINAURAL_MAXBANDS ), 48000 ) ); pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; cldfb_in_flag = ivas_dec_split_rend_cldfb_in( st_ivas->renderer_type ); -- GitLab From 941443a00281aaa57b1f6c823cb81400b6e37521 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 14:36:53 +0100 Subject: [PATCH 24/40] Improve comments about differences between BASOP and float versions --- lib_dec/ivas_jbm_dec_fx.c | 4 +++- lib_dec/lib_dec_fx.c | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 92b65f7a7..097027872 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2465,7 +2465,9 @@ ivas_error ivas_jbm_dec_render_fx( nchan_out_syn_output = i_mult( BINAURAL_CHANNELS, st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ); - /* Save TD signals for pose correction if they are to be used */ + /* Save TD signals for pose correction if they are to be used. + * + * NOTE: Here BASOP differs from the float version. In float, we push samples to TD ring buffer in lib_dec.c function isar_render_poses. */ IF( st_ivas->hSplitBinRend->hMultiBinTdData != NULL ) { FOR( i = 0; i < nchan_out_syn_output; i++ ) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index c0d3b4344..9ff0c9e50 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1254,8 +1254,8 @@ static ivas_error isar_render_poses( return IVAS_ERR_OK; } - // NOTE: Here BASOP differs from float version. In float, we push samples to TD ring buffer here. In BASOP, TD signals are only available in 16 bit here. - // To save TD signals in 32-bit precision, samples are pushed via ivas_TD_RINGBUF_PushChannels in ivas_jbm_dec_render_fx within IVAS_DEC_GetSamplesRenderer. + /* NOTE: Here BASOP differs from the float version. In float, we push samples to TD ring buffer here. In BASOP, TD signals are only available in 16 bit here. + * To save TD signals in 32-bit precision, samples are pushed via ivas_TD_RINGBUF_PushChannels in ivas_jbm_dec_render_fx within IVAS_DEC_GetSamplesRenderer. */ return error; } -- GitLab From dc89328bcd8bdb905b002d419215afea5e46c28a Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 15:01:00 +0100 Subject: [PATCH 25/40] Fix missing BASOPs part 2 --- lib_dec/lib_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 9ff0c9e50..aa0a9d721 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1293,7 +1293,7 @@ static ivas_error isar_generate_metadata_and_bitstream( hSplitBinRend = st_ivas->hSplitBinRend; max_band = extract_l( ar_div( imult3216( st_ivas->hDecoderConfig->output_Fs, BINAURAL_MAXBANDS ), 48000 ) ); - pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; + pcm_out_flag = EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ); cldfb_in_flag = ivas_dec_split_rend_cldfb_in( st_ivas->renderer_type ); n_samples_in_cldfb_slot = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); -- GitLab From 86a28a5d6e93adf9dab8ddc877b4c442d6a481fa Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 15:02:08 +0100 Subject: [PATCH 26/40] Fix missing BASOPs part 3 --- lib_dec/lib_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index aa0a9d721..9bca6d7d0 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1296,7 +1296,7 @@ static ivas_error isar_generate_metadata_and_bitstream( pcm_out_flag = EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ); cldfb_in_flag = ivas_dec_split_rend_cldfb_in( st_ivas->renderer_type ); - n_samples_in_cldfb_slot = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + n_samples_in_cldfb_slot = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); assert( nSamples % n_samples_in_cldfb_slot == 0 ); num_cldfb_slots = int_div_s_x( nSamples, n_samples_in_cldfb_slot ); -- GitLab From d0233ecac8fed33e02ada2bbcc4f698b2b96f777 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 15:05:20 +0100 Subject: [PATCH 27/40] Fix missing BASOPs part 4 --- lib_dec/lib_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 9bca6d7d0..ea65c382a 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1598,7 +1598,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( return IVAS_ERR_WRONG_PARAMS; } - pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; + pcm_out_flag = EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ); move16(); numSamplesPerChannelToOutput = isar_get_frame_size( st_ivas ); move16(); -- GitLab From 4020bf719a6c3c2546ca11db206fe5b3576b48c9 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 15:11:06 +0100 Subject: [PATCH 28/40] Fix BASOPs part 5 --- 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 f32dee8b8..dcdea6dca 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -9048,7 +9048,7 @@ static ivas_error getSamplesInternal( hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, &bits, p_Cldfb_RealBuffer_Binaural, p_Cldfb_ImagBuffer_Binaural, - extract_l( Mpy_32_32( hIvasRend->sampleRateOut, 2684355 /*(BINAURAL_MAXBANDS / 48000) in Q31*/ ) ), 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 ) + extract_l( Mpy_32_32( hIvasRend->sampleRateOut, 2684355 /*(BINAURAL_MAXBANDS / 48000) in Q31*/ ) ), tmpBinaural, 1, cldfb_in_flag, EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ), ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) #else 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, -- GitLab From 70582ac193b6c5418beb282dff2b78363e9f9a23 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 15:22:05 +0100 Subject: [PATCH 29/40] Fix MSVC warning --- 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 dcdea6dca..431e4d693 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -9048,7 +9048,7 @@ static ivas_error getSamplesInternal( hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, &bits, p_Cldfb_RealBuffer_Binaural, p_Cldfb_ImagBuffer_Binaural, - extract_l( Mpy_32_32( hIvasRend->sampleRateOut, 2684355 /*(BINAURAL_MAXBANDS / 48000) in Q31*/ ) ), tmpBinaural, 1, cldfb_in_flag, EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ), ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) + extract_l( Mpy_32_32( hIvasRend->sampleRateOut, 2684355 /*(BINAURAL_MAXBANDS / 48000) in Q31*/ ) ), tmpBinaural, 1, cldfb_in_flag, extract_l( EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ), ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) #else 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, -- GitLab From 41aaabf7b244e38e788df96d342a8798a5b3500a Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 15:27:01 +0100 Subject: [PATCH 30/40] Fix more conversion errors --- lib_dec/lib_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index ea65c382a..e942efd7f 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1293,7 +1293,7 @@ static ivas_error isar_generate_metadata_and_bitstream( hSplitBinRend = st_ivas->hSplitBinRend; max_band = extract_l( ar_div( imult3216( st_ivas->hDecoderConfig->output_Fs, BINAURAL_MAXBANDS ), 48000 ) ); - pcm_out_flag = EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ); + pcm_out_flag = extract_l( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ); cldfb_in_flag = ivas_dec_split_rend_cldfb_in( st_ivas->renderer_type ); n_samples_in_cldfb_slot = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); @@ -1598,7 +1598,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( return IVAS_ERR_WRONG_PARAMS; } - pcm_out_flag = EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ); + pcm_out_flag = extract_l( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ); move16(); numSamplesPerChannelToOutput = isar_get_frame_size( st_ivas ); move16(); -- GitLab From 65607ba9cf8d5dfac035f00df04910465439b738 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 17:00:04 +0100 Subject: [PATCH 31/40] Trigger CI -- GitLab From 6c090f8b69d891344bb0e7d5106750ecd71036e8 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Mon, 3 Nov 2025 11:19:04 +0100 Subject: [PATCH 32/40] Use BASOPs for computing allocation size --- lib_dec/lib_dec_fx.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index e942efd7f..f42e83633 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1239,8 +1239,12 @@ static ivas_error isar_render_poses( /* init flush buffer for rate switch if not already initizalized */ IF( hIvasDec->flushbuffer == NULL ) { - hIvasDec->flushbuffer = (void *) malloc( sizeof( Word16 ) * 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 ); + /* hIvasDec->flushbuffer = (void *) malloc( sizeof( Word16 ) * 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 ); */ + Word32 size; + size = L_mult0( mult0( sizeof( Word16 ), mult0( numPoses, BINAURAL_CHANNELS ) ), shl( div_l( hIvasDec->nSamplesFrame, IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ), 1 ) ); + hIvasDec->flushbuffer = (void *) malloc( size ); + set16_fx( (Word16 *) hIvasDec->flushbuffer, 0, size ); } /* render */ -- GitLab From 0ce0cbe1ba3b4c3890a3521cfc9eaaa6670aea8b Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Mon, 3 Nov 2025 11:23:17 +0100 Subject: [PATCH 33/40] Initialise flags using if statements --- lib_dec/lib_dec_fx.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index f42e83633..81f765506 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1297,8 +1297,16 @@ static ivas_error isar_generate_metadata_and_bitstream( hSplitBinRend = st_ivas->hSplitBinRend; max_band = extract_l( ar_div( imult3216( st_ivas->hDecoderConfig->output_Fs, BINAURAL_MAXBANDS ), 48000 ) ); - pcm_out_flag = extract_l( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ); + move16(); cldfb_in_flag = ivas_dec_split_rend_cldfb_in( st_ivas->renderer_type ); + move16(); + pcm_out_flag = 0; + move16(); + if( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + pcm_out_flag = 1; + move16(); + } n_samples_in_cldfb_slot = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); assert( nSamples % n_samples_in_cldfb_slot == 0 ); @@ -1602,10 +1610,15 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( return IVAS_ERR_WRONG_PARAMS; } - pcm_out_flag = extract_l( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ); - move16(); numSamplesPerChannelToOutput = isar_get_frame_size( st_ivas ); move16(); + pcm_out_flag = 0; + move16(); + if( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + pcm_out_flag = 1; + move16(); + } IF( ( error = isar_render_poses( hIvasDec, numSamplesPerChannelToOutput, nOutSamples, needNewFrame ) ) != IVAS_ERR_OK ) { -- GitLab From 953487ed26ac1f599519a8d38e954944429c7241 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Mon, 3 Nov 2025 11:25:13 +0100 Subject: [PATCH 34/40] Instrument copy of a struct --- lib_dec/lib_dec_fx.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 81f765506..d0e43b16e 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1353,6 +1353,12 @@ static ivas_error isar_generate_metadata_and_bitstream( IF( st_ivas->hHeadTrackData != NULL ) { Quaternion = st_ivas->hHeadTrackData->Quaternions[0]; + /* Copy of a struct: 4x Word32 and 1x Word32 */ + move32(); + move32(); + move32(); + move32(); + move16(); } ELSE { -- GitLab From 038bbadbb39d855d22cbd6fc1602475512a0e948 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Mon, 3 Nov 2025 11:53:02 +0100 Subject: [PATCH 35/40] Replace leftover == and != with EQ and NE macros --- lib_dec/lib_dec_fx.c | 44 +++++++++++++++++++++++++----------------- lib_rend/lib_rend_fx.c | 8 +++----- 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index d0e43b16e..2b92f2b09 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1248,7 +1248,7 @@ static ivas_error isar_render_poses( } /* render */ - IF( ( error = IVAS_DEC_GetSamplesRenderer( hIvasDec, nSamplesAsked, pcmBuf, nOutSamples, needNewFrame ) ) != IVAS_ERR_OK ) + IF( NE_32 ( ( error = IVAS_DEC_GetSamplesRenderer( hIvasDec, nSamplesAsked, pcmBuf, nOutSamples, needNewFrame ) ), IVAS_ERR_OK ) ) { return error; } @@ -1422,7 +1422,7 @@ static ivas_error isar_generate_metadata_and_bitstream( move16(); } - IF( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( &hSplitBinRend->splitrend, + IF( NE_32( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( &hSplitBinRend->splitrend, Quaternion, st_ivas->hRenderConfig->split_rend_config.splitRendBitRate, st_ivas->hRenderConfig->split_rend_config.codec, @@ -1431,7 +1431,7 @@ static ivas_error isar_generate_metadata_and_bitstream( splitRendBits, p_Cldfb_RealBuffer_Binaural, p_Cldfb_ImagBuffer_Binaural, - max_band, p_head_pose_buf, 1, cldfb_in_flag, pcm_out_flag, ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) + max_band, p_head_pose_buf, 1, cldfb_in_flag, pcm_out_flag, ro_md_flag, Q_buff, &Q_out[0] ) ), IVAS_ERR_OK ) ) { return error; } @@ -1611,7 +1611,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( st_ivas = hIvasDec->st_ivas; - IF( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) == 0 ) + IF( EQ_16( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ), 0 ) ) { return IVAS_ERR_WRONG_PARAMS; } @@ -1626,7 +1626,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( move16(); } - IF( ( error = isar_render_poses( hIvasDec, numSamplesPerChannelToOutput, nOutSamples, needNewFrame ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = isar_render_poses( hIvasDec, numSamplesPerChannelToOutput, nOutSamples, needNewFrame ) ), IVAS_ERR_OK ) ) { return error; } @@ -1641,7 +1641,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( p_head_pose_buf[i] = head_pose_buf[i]; } - IF( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nOutSamples, splitRendBits, Q_out ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nOutSamples, splitRendBits, Q_out ) ), IVAS_ERR_OK ) ) { return error; } @@ -1653,7 +1653,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( { scale_sig32( p_head_pose_buf[i], numSamplesPerChannelToOutput, sub( Q11, Q_out[i] ) ); // Q11 } - IF( st_ivas->hDecoderConfig->render_framesize == IVAS_RENDER_FRAMESIZE_5MS ) + IF( EQ_32( st_ivas->hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_5MS ) ) { #ifndef DISABLE_LIMITER ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToOutput, st_ivas->BER_detect, Q11 ); @@ -2002,7 +2002,7 @@ static ivas_error ivas_dec_setup_all( test(); #ifdef FIX_1119_SPLIT_RENDERING_VOIP - IF( st_ivas->ini_frame == 0 && splitRendBits != NULL ) + IF( EQ_16( st_ivas->ini_frame, 0 ) && splitRendBits != NULL ) #else IF( st_ivas->ini_frame == 0 && isSplitRend ) #endif @@ -3851,7 +3851,7 @@ ivas_error IVAS_DEC_GetSamplesDecoder( *-----------------------------------------------------------------*/ #ifdef FIX_1119_SPLIT_RENDERING_VOIP - IF( ( error = ivas_dec_setup_all( hIvasDec, &nTransportChannels, splitRendBits ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_dec_setup_all( hIvasDec, &nTransportChannels, splitRendBits ) ), IVAS_ERR_OK ) ) #else IF( ( error = ivas_dec_setup_all( hIvasDec, &nTransportChannels, isSplitRend, splitRendBits ) ) != IVAS_ERR_OK ) #endif @@ -4816,7 +4816,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples IF( hIvasDec->nSamplesAvailableNext == 0 || EQ_16( hIvasDec->nSamplesAvailableNext, hIvasDec->nSamplesFrame ) ) { #ifdef FIX_1119_SPLIT_RENDERING_VOIP - IF( ( error = IVAS_DEC_GetSamplesDecoder( hIvasDec, splitRendBits ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = IVAS_DEC_GetSamplesDecoder( hIvasDec, splitRendBits ) ), IVAS_ERR_OK ) ) #else IF( ( error = IVAS_DEC_GetSamplesDecoder( hIvasDec, 0, 0 ) ) != IVAS_ERR_OK ) #endif @@ -4847,7 +4847,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples IF( splitRendBits != NULL ) { /* Render head poses from time-scaled transport channels */ - IF( ( error = isar_render_poses( hIvasDec, nSamplesToRender, &nSamplesRendered_loop, &tmp ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = isar_render_poses( hIvasDec, nSamplesToRender, &nSamplesRendered_loop, &tmp ) ), IVAS_ERR_OK ) ) { return error; } @@ -4876,20 +4876,20 @@ ivas_error IVAS_DEC_VoIP_GetSamples Word16 i; /* Analyse head poses over entire frame, generate ISAR metadata and maybe encode if split coded */ - IF( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nSamplesRendered, splitRendBits, Q_out ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nSamplesRendered, splitRendBits, Q_out ) ), IVAS_ERR_OK ) ) { return error; } /* Synthesise PCM output if split PCM */ - IF( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) { scale_sig32( p_head_pose_buf[i], *nSamplesRendered, sub( Q11, Q_out[i] ) ); // Q11 } - IF( st_ivas->hDecoderConfig->render_framesize == IVAS_RENDER_FRAMESIZE_5MS ) + IF( EQ_32( st_ivas->hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_5MS ) ) { #ifndef DISABLE_LIMITER ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, Q11 ); @@ -4977,7 +4977,7 @@ ivas_error IVAS_DEC_VoIP_GetSplitBinauralBitstream( ivas_error error = IVAS_ERR_UNKNOWN; Word16 nSamplesPerChannel = 0; - IF( ( error = IVAS_DEC_GetRenderFramesizeSamples( hIvasDec, &nSamplesPerChannel ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = IVAS_DEC_GetRenderFramesizeSamples( hIvasDec, &nSamplesPerChannel ) ), IVAS_ERR_OK ) ) { return error; } @@ -6185,6 +6185,7 @@ static ivas_error ivas_dec_init_split_rend( Word16 mixed_td_cldfb_flag; #ifdef FIX_1119_SPLIT_RENDERING_VOIP Word16 i, num_poses; + ISAR_SPLIT_REND_ROT_AXIS head_rot_axis; #endif pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; @@ -6214,7 +6215,14 @@ static ivas_error ivas_dec_init_split_rend( #endif #ifdef FIX_1119_SPLIT_RENDERING_VOIP - ISAR_PRE_REND_GetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->sr_pose_pred_axis : DEFAULT_AXIS ); + head_rot_axis = DEFAULT_AXIS; + move32(); + if ( st_ivas->hHeadTrackData != NULL ) + { + head_rot_axis = st_ivas->hHeadTrackData->sr_pose_pred_axis; + move32(); + } + ISAR_PRE_REND_GetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, head_rot_axis ); num_poses = st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; move16(); @@ -6225,7 +6233,7 @@ static ivas_error ivas_dec_init_split_rend( FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; ++i ) { /* note: this is intra-frame heap memory */ - IF( ( error = ivas_CLDFB_RINGBUF_Open( &st_ivas->hSplitBinRend->hMultiBinCldfbData[i], CLDFB_NO_COL_MAX ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_CLDFB_RINGBUF_Open( &st_ivas->hSplitBinRend->hMultiBinCldfbData[i], CLDFB_NO_COL_MAX ) ), IVAS_ERR_OK ) ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for split rendering structure" ); } @@ -6233,7 +6241,7 @@ static ivas_error ivas_dec_init_split_rend( } ELSE { - IF( ( error = ivas_TD_RINGBUF_Open( &st_ivas->hSplitBinRend->hMultiBinTdData, get_render_frame_size_samples( st_ivas->hDecoderConfig ), i_mult( num_poses, BINAURAL_CHANNELS ) ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_TD_RINGBUF_Open( &st_ivas->hSplitBinRend->hMultiBinTdData, get_render_frame_size_samples( st_ivas->hDecoderConfig ), i_mult( num_poses, BINAURAL_CHANNELS ) ) ), IVAS_ERR_OK ) ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for split rendering structure" ); } diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 431e4d693..ac350a2eb 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -9043,19 +9043,17 @@ static ivas_error getSamplesInternal( } #ifdef FIX_1119_SPLIT_RENDERING_VOIP - IF( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( hIvasRend->splitRendWrapper, hIvasRend->headRotData.headPositions[0], hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, hIvasRend->hRendererConfig->split_rend_config.codec, + IF( NE_32( ( 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, p_Cldfb_RealBuffer_Binaural, p_Cldfb_ImagBuffer_Binaural, - extract_l( Mpy_32_32( hIvasRend->sampleRateOut, 2684355 /*(BINAURAL_MAXBANDS / 48000) in Q31*/ ) ), tmpBinaural, 1, cldfb_in_flag, extract_l( EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ), ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) + extract_l( Mpy_32_32( hIvasRend->sampleRateOut, 2684355 /*(BINAURAL_MAXBANDS / 48000) in Q31*/ ) ), tmpBinaural, 1, cldfb_in_flag, extract_l( EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ), ro_md_flag, Q_buff, &Q_out[0] ) ), IVAS_ERR_OK ) ) #else 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, - extract_l( Mpy_32_32( hIvasRend->sampleRateOut, 2684355 /*(BINAURAL_MAXBANDS / 48000) in Q31*/ ) ), 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, extract_l( Mpy_32_32( hIvasRend->sampleRateOut, 2684355 /*(BINAURAL_MAXBANDS / 48000) in Q31*/ ) ), 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 ) #endif { return error; -- GitLab From 0ccced8119c65b8f83e8d770fd6899a2bfe2a8f5 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Mon, 3 Nov 2025 12:01:59 +0100 Subject: [PATCH 36/40] Fix formatting --- lib_dec/lib_dec_fx.c | 25 +++++++++++++------------ lib_rend/lib_rend_fx.c | 11 ++++++----- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 2b92f2b09..c3ac98c47 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1248,7 +1248,7 @@ static ivas_error isar_render_poses( } /* render */ - IF( NE_32 ( ( error = IVAS_DEC_GetSamplesRenderer( hIvasDec, nSamplesAsked, pcmBuf, nOutSamples, needNewFrame ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = IVAS_DEC_GetSamplesRenderer( hIvasDec, nSamplesAsked, pcmBuf, nOutSamples, needNewFrame ) ), IVAS_ERR_OK ) ) { return error; } @@ -1302,7 +1302,7 @@ static ivas_error isar_generate_metadata_and_bitstream( move16(); pcm_out_flag = 0; move16(); - if( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + if ( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { pcm_out_flag = 1; move16(); @@ -1423,15 +1423,16 @@ static ivas_error isar_generate_metadata_and_bitstream( } IF( NE_32( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( &hSplitBinRend->splitrend, - Quaternion, - st_ivas->hRenderConfig->split_rend_config.splitRendBitRate, - st_ivas->hRenderConfig->split_rend_config.codec, - st_ivas->hRenderConfig->split_rend_config.isar_frame_size_ms, - st_ivas->hRenderConfig->split_rend_config.codec_frame_size_ms, - splitRendBits, - p_Cldfb_RealBuffer_Binaural, - p_Cldfb_ImagBuffer_Binaural, - max_band, p_head_pose_buf, 1, cldfb_in_flag, pcm_out_flag, ro_md_flag, Q_buff, &Q_out[0] ) ), IVAS_ERR_OK ) ) + Quaternion, + st_ivas->hRenderConfig->split_rend_config.splitRendBitRate, + st_ivas->hRenderConfig->split_rend_config.codec, + st_ivas->hRenderConfig->split_rend_config.isar_frame_size_ms, + st_ivas->hRenderConfig->split_rend_config.codec_frame_size_ms, + splitRendBits, + p_Cldfb_RealBuffer_Binaural, + p_Cldfb_ImagBuffer_Binaural, + max_band, p_head_pose_buf, 1, cldfb_in_flag, pcm_out_flag, ro_md_flag, Q_buff, &Q_out[0] ) ), + IVAS_ERR_OK ) ) { return error; } @@ -1620,7 +1621,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( move16(); pcm_out_flag = 0; move16(); - if( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + if ( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { pcm_out_flag = 1; move16(); diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index ac350a2eb..3a7718724 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -9044,11 +9044,12 @@ static ivas_error getSamplesInternal( #ifdef FIX_1119_SPLIT_RENDERING_VOIP IF( NE_32( ( 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, - p_Cldfb_RealBuffer_Binaural, p_Cldfb_ImagBuffer_Binaural, - extract_l( Mpy_32_32( hIvasRend->sampleRateOut, 2684355 /*(BINAURAL_MAXBANDS / 48000) in Q31*/ ) ), tmpBinaural, 1, cldfb_in_flag, extract_l( EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ), ro_md_flag, Q_buff, &Q_out[0] ) ), IVAS_ERR_OK ) ) + hIvasRend->hRendererConfig->split_rend_config.isar_frame_size_ms, + hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, + &bits, + p_Cldfb_RealBuffer_Binaural, p_Cldfb_ImagBuffer_Binaural, + extract_l( Mpy_32_32( hIvasRend->sampleRateOut, 2684355 /*(BINAURAL_MAXBANDS / 48000) in Q31*/ ) ), tmpBinaural, 1, cldfb_in_flag, extract_l( EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ), ro_md_flag, Q_buff, &Q_out[0] ) ), + IVAS_ERR_OK ) ) #else 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, -- GitLab From 165ee5a97d235ee1246305e8eac7df7364d5b13f Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Mon, 3 Nov 2025 12:09:58 +0100 Subject: [PATCH 37/40] Fix incorrect allocation size --- 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 bbe309720..7d3ee4ffd 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1241,10 +1241,10 @@ static ivas_error isar_render_poses( { /* hIvasDec->flushbuffer = (void *) malloc( sizeof( Word16 ) * 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 ); */ - Word32 size; - size = L_mult0( mult0( sizeof( Word16 ), mult0( numPoses, BINAURAL_CHANNELS ) ), shl( div_l( hIvasDec->nSamplesFrame, IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ), 1 ) ); - hIvasDec->flushbuffer = (void *) malloc( size ); - set16_fx( (Word16 *) hIvasDec->flushbuffer, 0, size ); + Word16 num_samples_flushbuffer; + num_samples_flushbuffer = mult0( mult0( numPoses, BINAURAL_CHANNELS ), shl( div_l( hIvasDec->nSamplesFrame, IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ), 1 ) ); + hIvasDec->flushbuffer = (void *) malloc( L_mult0( sizeof( Word16 ), num_samples_flushbuffer ) ); + set16_fx( (Word16 *) hIvasDec->flushbuffer, 0, num_samples_flushbuffer ); } /* render */ -- GitLab From 729f2a1640b3700c3b472f2076d78d3633c67a78 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Mon, 3 Nov 2025 15:09:30 +0100 Subject: [PATCH 38/40] Align with port 369 branch --- lib_rend/ivas_td_ring_buffer_fx.c | 46 +++++++++++++++---------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/lib_rend/ivas_td_ring_buffer_fx.c b/lib_rend/ivas_td_ring_buffer_fx.c index a67143dbb..cb066b544 100644 --- a/lib_rend/ivas_td_ring_buffer_fx.c +++ b/lib_rend/ivas_td_ring_buffer_fx.c @@ -52,12 +52,12 @@ static Word32 ivas_td_ringbuf_total_size( TD_RINGBUF_HANDLE h ) { - IF( h->is_full ) + IF ( h->is_full ) { return h->capacity; } - IF( LE_32( h->read_pos, h->write_pos ) ) + IF ( LE_32( h->read_pos, h->write_pos ) ) { return L_sub( h->write_pos, h->read_pos ); } @@ -70,7 +70,7 @@ static Word16 ivas_td_ringbuf_has_space_for_num_samples( TD_RINGBUF_HANDLE h, const Word32 num_samples ) { - IF( LE_32( L_add( ivas_td_ringbuf_total_size( h ), num_samples ), h->capacity ) ) + IF ( LE_32( L_add( ivas_td_ringbuf_total_size( h ), num_samples ), h->capacity ) ) { return 1; } @@ -95,7 +95,7 @@ static void ivas_td_ringbuf_push_interleaved( read_s = 0; move32(); - FOR( s = 0; s < L_mult0( num_samples_per_channel, h->num_channels ); ++s ) + FOR ( s = 0; s < L_mult0( num_samples_per_channel, h->num_channels ); ++s ) { h->data[h->write_pos] = data[read_s]; move32(); @@ -146,7 +146,7 @@ ivas_error ivas_TD_RINGBUF_Open( move32(); h = malloc( sizeof( TD_RINGBUF_DATA ) ); - IF( h == NULL ) + IF ( h == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for TD ring buffer\n" ); } @@ -164,7 +164,7 @@ ivas_error ivas_TD_RINGBUF_Open( *ph = h; h->data = malloc( capacity * sizeof( Word32 ) ); - IF( h->data == NULL ) + IF ( h->data == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for TD ring buffer\n" ); } @@ -188,18 +188,18 @@ void ivas_TD_RINGBUF_Close( { TD_RINGBUF_HANDLE h; - IF( ph == NULL ) + IF ( ph == NULL ) { return; } h = *ph; - IF( h == NULL ) + IF ( h == NULL ) { return; } - IF( h->data != NULL ) + IF ( h->data != NULL ) { free( h->data ); } @@ -262,16 +262,16 @@ void ivas_TD_RINGBUF_Push( #ifdef FIX_1119_SPLIT_RENDERING_VOIP assert( h != NULL ); assert( p_channels != NULL ); - FOR( c = 0; c < h->num_channels; ++c ) /* Not using BASOP FOR because this loops only does assertions */ + for ( c = 0; c < h->num_channels; ++c ) /* Not using BASOP FOR because this loops only does assertions */ { assert( p_channels[c] != NULL ); } #endif assert( ivas_td_ringbuf_has_space_for_num_samples( h, num_samples_per_channel * h->num_channels ) ); - FOR( s = 0; s < num_samples_per_channel; ++s ) + FOR ( s = 0; s < num_samples_per_channel; ++s ) { - FOR( c = 0; c < h->num_channels; ++c ) + FOR ( c = 0; c < h->num_channels; ++c ) { #ifdef FIX_1119_SPLIT_RENDERING_VOIP h->data[h->write_pos] = p_channels[c][s]; @@ -333,20 +333,20 @@ void ivas_TD_RINGBUF_PushZeros( Word16 c; assert( ivas_td_ringbuf_has_space_for_num_samples( h, num_samples_per_channel * h->num_channels ) ); - IF( !num_samples_per_channel ) + IF ( !num_samples_per_channel ) { return; } - FOR( s = 0; s < num_samples_per_channel; ++s ) + FOR ( s = 0; s < num_samples_per_channel; ++s ) { - FOR( c = 0; c < h->num_channels; ++c ) + FOR ( c = 0; c < h->num_channels; ++c ) { - h->data[h->write_pos] = 0.f; + h->data[h->write_pos] = 0; move32(); h->write_pos = L_add( h->write_pos, 1 ); - IF( EQ_32( h->write_pos, h->capacity ) ) + IF ( EQ_32( h->write_pos, h->capacity ) ) { h->write_pos = 0; move32(); @@ -397,16 +397,16 @@ void ivas_TD_RINGBUF_Pop( #ifdef FIX_1119_SPLIT_RENDERING_VOIP assert( h != NULL ); assert( p_channels != NULL ); - FOR( c = 0; c < h->num_channels; ++c ) /* Not using BASOP FOR because this loops only does assertions */ + for ( c = 0; c < h->num_channels; ++c ) /* Not using BASOP FOR because this loops only does assertions */ { assert( p_channels[c] != NULL ); } #endif assert( ivas_td_ringbuf_total_size( h ) >= num_samples_per_channel * h->num_channels ); - FOR( s = 0; s < num_samples_per_channel; ++s ) + FOR ( s = 0; s < num_samples_per_channel; ++s ) { - FOR( c = 0; c < h->num_channels; ++c ) + FOR ( c = 0; c < h->num_channels; ++c ) { #ifdef FIX_1119_SPLIT_RENDERING_VOIP p_channels[c][s] = h->data[h->read_pos]; @@ -417,7 +417,7 @@ void ivas_TD_RINGBUF_Pop( #endif ++h->read_pos; - IF( EQ_32( h->read_pos, h->capacity ) ) + IF ( EQ_32( h->read_pos, h->capacity ) ) { h->read_pos = 0; move32(); @@ -426,13 +426,13 @@ void ivas_TD_RINGBUF_Pop( } #ifdef FIX_1119_SPLIT_RENDERING_VOIP - IF( NE_16( num_samples_per_channel, 0 ) ) + IF ( NE_16( num_samples_per_channel, 0 ) ) { h->is_full = 0; move16(); } #else - IF( h->is_full ) + IF ( h->is_full ) { h->is_full = 0; move16(); -- GitLab From 8a93dcbefb1eb32b3005a93d454d0c80fab91e63 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Mon, 3 Nov 2025 15:46:18 +0100 Subject: [PATCH 39/40] Fix formatting --- lib_rend/ivas_td_ring_buffer_fx.c | 40 +++++++++++++++---------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/lib_rend/ivas_td_ring_buffer_fx.c b/lib_rend/ivas_td_ring_buffer_fx.c index cb066b544..2bd4f35a7 100644 --- a/lib_rend/ivas_td_ring_buffer_fx.c +++ b/lib_rend/ivas_td_ring_buffer_fx.c @@ -52,12 +52,12 @@ static Word32 ivas_td_ringbuf_total_size( TD_RINGBUF_HANDLE h ) { - IF ( h->is_full ) + IF( h->is_full ) { return h->capacity; } - IF ( LE_32( h->read_pos, h->write_pos ) ) + IF( LE_32( h->read_pos, h->write_pos ) ) { return L_sub( h->write_pos, h->read_pos ); } @@ -70,7 +70,7 @@ static Word16 ivas_td_ringbuf_has_space_for_num_samples( TD_RINGBUF_HANDLE h, const Word32 num_samples ) { - IF ( LE_32( L_add( ivas_td_ringbuf_total_size( h ), num_samples ), h->capacity ) ) + IF( LE_32( L_add( ivas_td_ringbuf_total_size( h ), num_samples ), h->capacity ) ) { return 1; } @@ -95,7 +95,7 @@ static void ivas_td_ringbuf_push_interleaved( read_s = 0; move32(); - FOR ( s = 0; s < L_mult0( num_samples_per_channel, h->num_channels ); ++s ) + FOR( s = 0; s < L_mult0( num_samples_per_channel, h->num_channels ); ++s ) { h->data[h->write_pos] = data[read_s]; move32(); @@ -146,7 +146,7 @@ ivas_error ivas_TD_RINGBUF_Open( move32(); h = malloc( sizeof( TD_RINGBUF_DATA ) ); - IF ( h == NULL ) + IF( h == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for TD ring buffer\n" ); } @@ -164,7 +164,7 @@ ivas_error ivas_TD_RINGBUF_Open( *ph = h; h->data = malloc( capacity * sizeof( Word32 ) ); - IF ( h->data == NULL ) + IF( h->data == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for TD ring buffer\n" ); } @@ -188,18 +188,18 @@ void ivas_TD_RINGBUF_Close( { TD_RINGBUF_HANDLE h; - IF ( ph == NULL ) + IF( ph == NULL ) { return; } h = *ph; - IF ( h == NULL ) + IF( h == NULL ) { return; } - IF ( h->data != NULL ) + IF( h->data != NULL ) { free( h->data ); } @@ -269,9 +269,9 @@ void ivas_TD_RINGBUF_Push( #endif assert( ivas_td_ringbuf_has_space_for_num_samples( h, num_samples_per_channel * h->num_channels ) ); - FOR ( s = 0; s < num_samples_per_channel; ++s ) + FOR( s = 0; s < num_samples_per_channel; ++s ) { - FOR ( c = 0; c < h->num_channels; ++c ) + FOR( c = 0; c < h->num_channels; ++c ) { #ifdef FIX_1119_SPLIT_RENDERING_VOIP h->data[h->write_pos] = p_channels[c][s]; @@ -333,20 +333,20 @@ void ivas_TD_RINGBUF_PushZeros( Word16 c; assert( ivas_td_ringbuf_has_space_for_num_samples( h, num_samples_per_channel * h->num_channels ) ); - IF ( !num_samples_per_channel ) + IF( !num_samples_per_channel ) { return; } - FOR ( s = 0; s < num_samples_per_channel; ++s ) + FOR( s = 0; s < num_samples_per_channel; ++s ) { - FOR ( c = 0; c < h->num_channels; ++c ) + FOR( c = 0; c < h->num_channels; ++c ) { h->data[h->write_pos] = 0; move32(); h->write_pos = L_add( h->write_pos, 1 ); - IF ( EQ_32( h->write_pos, h->capacity ) ) + IF( EQ_32( h->write_pos, h->capacity ) ) { h->write_pos = 0; move32(); @@ -404,9 +404,9 @@ void ivas_TD_RINGBUF_Pop( #endif assert( ivas_td_ringbuf_total_size( h ) >= num_samples_per_channel * h->num_channels ); - FOR ( s = 0; s < num_samples_per_channel; ++s ) + FOR( s = 0; s < num_samples_per_channel; ++s ) { - FOR ( c = 0; c < h->num_channels; ++c ) + FOR( c = 0; c < h->num_channels; ++c ) { #ifdef FIX_1119_SPLIT_RENDERING_VOIP p_channels[c][s] = h->data[h->read_pos]; @@ -417,7 +417,7 @@ void ivas_TD_RINGBUF_Pop( #endif ++h->read_pos; - IF ( EQ_32( h->read_pos, h->capacity ) ) + IF( EQ_32( h->read_pos, h->capacity ) ) { h->read_pos = 0; move32(); @@ -426,13 +426,13 @@ void ivas_TD_RINGBUF_Pop( } #ifdef FIX_1119_SPLIT_RENDERING_VOIP - IF ( NE_16( num_samples_per_channel, 0 ) ) + IF( NE_16( num_samples_per_channel, 0 ) ) { h->is_full = 0; move16(); } #else - IF ( h->is_full ) + IF( h->is_full ) { h->is_full = 0; move16(); -- GitLab From 6cbfcd50ce8a7593092f8c7aed677708b966f41f Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Mon, 3 Nov 2025 16:08:43 +0100 Subject: [PATCH 40/40] Align one more thing with port 369 --- lib_rend/ivas_td_ring_buffer_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_rend/ivas_td_ring_buffer_fx.c b/lib_rend/ivas_td_ring_buffer_fx.c index 2bd4f35a7..5866c31ad 100644 --- a/lib_rend/ivas_td_ring_buffer_fx.c +++ b/lib_rend/ivas_td_ring_buffer_fx.c @@ -277,7 +277,7 @@ void ivas_TD_RINGBUF_Push( h->data[h->write_pos] = p_channels[c][s]; move32(); #else - h->data[h->write_pos] = data[L_add( L_mult0( c, num_samples_per_channel ), s )]; + h->data[h->write_pos] = data[L_mac0( s, c, num_samples_per_channel )]; move32(); #endif h->write_pos = L_add( h->write_pos, 1 ); @@ -412,7 +412,7 @@ void ivas_TD_RINGBUF_Pop( p_channels[c][s] = h->data[h->read_pos]; move32(); #else - data[L_add( L_mult0( c, num_samples_per_channel ), s )] = h->data[h->read_pos]; + data[L_mac0( s, c, num_samples_per_channel )] = h->data[h->read_pos]; move32(); #endif ++h->read_pos; -- GitLab