From aead89f8e4d38ff30dac841d52a73bc65167251f Mon Sep 17 00:00:00 2001 From: marc emerit Date: Wed, 9 Jul 2025 14:35:33 +0200 Subject: [PATCH] initial version --- lib_com/options.h | 2 + lib_dec/ivas_jbm_dec_fx.c | 80 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 81 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 7a8ea4d33..57c5016b8 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -116,6 +116,8 @@ #define NONBE_FIX_991_PARAMBIN_BINARY_HRTF /* Nokia: issue #991: fix using of binary file HRTF in ParamBin (to activate when USE_NEW_HRTF_BINARY_FILE_FORMAT and FIX_777_COMBI_RENDER_CONFIG_FILE are on ) */ +#define NONBE_FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT /* fix 1070 USAN: nullptr-with-offset and Segfaults in 7_1_4 to BINAURAL and BINAURAL_ROOM_REVERB decoding with bitrate switching and head rotation*/ + #define FIX_1741_REVERB_TIMES_Q_FORMAT /* Philips: reverberation times in Q26 format instead of Q31 */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 324c099b6..437003e3b 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2701,6 +2701,23 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( { IF( EQ_16( mc_mode_old, MC_MODE_MCT ) ) { +#ifdef NONBE_FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT + int16_t crendInPlaceRotation = FALSE; + + test(); + test(); + test(); + IF( NE_16( st_ivas->transport_config, intern_config_old ) && ( EQ_16( intern_config_old, IVAS_AUDIO_CONFIG_FOA ) || EQ_16( intern_config_old, IVAS_AUDIO_CONFIG_HOA2 ) || EQ_16( intern_config_old, IVAS_AUDIO_CONFIG_HOA3 ) ) ) + { + IF( GT_16( sub( add( hIntSetupOld->nchan_out_woLFE, hIntSetupOld->num_lfe ), add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ) ), 0 ) ) + { + crendInPlaceRotation = TRUE; + move16(); + ivas_mc2sba_fx( st_ivas->hTransSetup, hTcBuffer->tc_fx, p_output_fx, hTcBuffer->n_samples_granularity, hIntSetupOld->ambisonics_order, GAIN_LFE_FX ); + } + } +#endif + test(); IF( EQ_16( renderer_type_old, RENDERER_BINAURAL_MIXER_CONV ) || EQ_16( renderer_type_old, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) { @@ -2716,10 +2733,15 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( } *st_ivas->hCrendWrapper->p_io_qfactor = 11; move16(); - +#ifdef NONBE_FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT + IF( NE_32( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, + hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output_fx : st_ivas->hTcBuffer->tc_fx, p_output_fx, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs, 0 ), + IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, hTcBuffer->tc_fx, p_output_fx, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs, 0 ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -3431,7 +3453,11 @@ ivas_error ivas_jbm_dec_tc_buffer_open_fx( const Word16 n_samples_granularity /* i : granularity of the renderer/buffer */ ) { +#ifdef NONBE_FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT + Word32 nsamp_to_allocate; +#else Word16 nsamp_to_allocate; +#endif DECODER_TC_BUFFER_HANDLE hTcBuffer; Word16 nMaxSlotsPerSubframe; Word16 nchan_residual; @@ -3476,7 +3502,11 @@ ivas_error ivas_jbm_dec_tc_buffer_open_fx( hTcBuffer->nb_subframes = MAX_PARAM_SPATIAL_SUBFRAMES; move16(); nsamp_to_allocate = 0; +#ifdef NONBE_FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT + move32(); +#else move16(); +#endif tmp32 = L_mult0( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES, hTcBuffer->n_samples_granularity ); // Q0 tmp = BASOP_Util_Divide3232_Scale( st_ivas->hDecoderConfig->output_Fs, tmp32, &tmp_e ); @@ -3514,8 +3544,13 @@ ivas_error ivas_jbm_dec_tc_buffer_open_fx( move16(); } +#ifdef NONBE_FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT + nsamp_to_allocate = L_mult0( hTcBuffer->nchan_buffer_full, n_samp_full ); + nsamp_to_allocate = L_add( nsamp_to_allocate, L_mult0( nchan_residual, n_samp_residual ) ); +#else nsamp_to_allocate = mult0( hTcBuffer->nchan_buffer_full, n_samp_full ); nsamp_to_allocate = add( nsamp_to_allocate, mult0( nchan_residual, n_samp_residual ) ); +#endif IF( nsamp_to_allocate == 0 ) { @@ -3534,7 +3569,11 @@ ivas_error ivas_jbm_dec_tc_buffer_open_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); } +#ifdef NONBE_FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT + set_zero2_fx( hTcBuffer->tc_buffer_fx, nsamp_to_allocate ); +#else set32_fx( hTcBuffer->tc_buffer_fx, 0, nsamp_to_allocate ); +#endif offset = 0; move16(); @@ -3582,7 +3621,12 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx( const Word16 n_samples_granularity /* i : new granularity of the renderer/buffer */ ) { +#ifdef NONBE_FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT + Word32 nsamp_to_allocate, offset; + Word16 n_samp_full, n_samp_residual, nchan_residual; +#else Word16 nsamp_to_allocate, n_samp_full, n_samp_residual, offset, nchan_residual; +#endif Word16 ch_idx; DECODER_TC_BUFFER_HANDLE hTcBuffer; @@ -3642,8 +3686,14 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx( n_samp_residual = 0; move16(); } + +#ifdef NONBE_FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT + nsamp_to_allocate = L_mult0( hTcBuffer->nchan_buffer_full, n_samp_full ); + nsamp_to_allocate = L_add( nsamp_to_allocate, L_mult0( nchan_residual, n_samp_residual ) ); +#else nsamp_to_allocate = imult1616( hTcBuffer->nchan_buffer_full, n_samp_full ); nsamp_to_allocate = add( nsamp_to_allocate, imult1616( nchan_residual, n_samp_residual ) ); +#endif IF( nsamp_to_allocate == 0 ) { @@ -3662,19 +3712,35 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory FOR JBM TC Buffer\n" ) ); } +#ifdef NONBE_FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT + set_zero2_fx( hTcBuffer->tc_buffer_fx, nsamp_to_allocate ); +#else set32_fx( hTcBuffer->tc_buffer_fx, 0, nsamp_to_allocate ); +#endif offset = 0; +#ifdef NONBE_FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT + move32(); +#else move16(); +#endif FOR( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) { hTcBuffer->tc_fx[ch_idx] = &hTcBuffer->tc_buffer_fx[offset]; +#ifdef NONBE_FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT + offset = L_add( offset, n_samp_full ); +#else offset = add( offset, n_samp_full ); +#endif } FOR( ; ch_idx < hTcBuffer->nchan_transport_internal; ch_idx++ ) { hTcBuffer->tc_fx[ch_idx] = &hTcBuffer->tc_buffer_fx[offset]; +#ifdef NONBE_FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT + offset = L_add( offset, n_samp_residual ); +#else offset = add( offset, n_samp_residual ); +#endif } FOR( ; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) { @@ -3685,14 +3751,26 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx( move16(); offset = 0; +#ifdef NONBE_FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT + move32(); +#else move16(); +#endif FOR( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) { +#ifdef NONBE_FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT + offset = L_add( offset, n_samp_full ); +#else offset = add( offset, n_samp_full ); +#endif } FOR( ; ch_idx < hTcBuffer->nchan_transport_internal; ch_idx++ ) { +#ifdef NONBE_FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT + offset = L_add( offset, n_samp_residual ); +#else offset = add( offset, n_samp_residual ); +#endif } } ELSE -- GitLab