diff --git a/lib_com/options.h b/lib_com/options.h index 2165b7e81837e2f3a1e4f09e14d0e8ee55cb1fab..7f31403c939b6f3e1722deab92545bdd7034d8c2 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -115,6 +115,7 @@ #define FIX_BASOP_2510_UNNECESSARY_ASSERT /* Nokia: BASOP issue 2510: Fix by removing assert */ #define FIX_2515_TDREND_PORT_ERROR_SCALING /* Nokia: BASOP issue 2515: Fix port error by changing to correct scaling */ #define FIX_BASOP_2522_MAP_PARAMS_DIRAC_STEREO /* FhG: BASOP issue 2522: Fix copy and paste error for side_gain calculation in map_params_dirac_to_stereo() */ +#define FIX_2505_IVAS_DEC_SEGFAULT /* FhG: BASOP #2505: Add headroom to input of ivas_rend_crendProcessSubframe_fx() for ivas_mdft_fx() calculation */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/ivas_dec_render_fx.c b/lib_dec/ivas_dec_render_fx.c index ec74f595e62761061cc6d4b72040b885e23ec26e..ee5105fdebb2c9d9ac44912ada0df77aec7fa0fb 100644 --- a/lib_dec/ivas_dec_render_fx.c +++ b/lib_dec/ivas_dec_render_fx.c @@ -1077,21 +1077,57 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( } ELSE IF( EQ_16( renderer_type_old, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) { +#ifdef FIX_2505_IVAS_DEC_SEGFAULT + Word16 subframe_len, guard_bits, q_shift_min; + +#endif /* Convert to CICPxx; used also for ISM->CICP19->binaural_room rendering */ set16_fx( st_ivas->hIsmRendererData->interpolator_fx, 32767, n_samples_granularity ); // 32767=1.0f in Q15 ivas_ism_render_sf_fx( st_ivas, renderer_type_old, p_output_fx, n_samples_granularity ); st_ivas->hCrendWrapper->p_io_qfactor = &st_ivas->hCrendWrapper->io_qfactor; +#ifdef FIX_2505_IVAS_DEC_SEGFAULT + + IF( NE_32( ( error = getAudioConfigNumChannels( IVAS_AUDIO_CONFIG_7_1_4, &nchan_in ) ), IVAS_ERR_OK ) ) + { + return error; + } + + subframe_len = imult1616( st_ivas->hTcBuffer->subframe_nbslots[0], n_samples_granularity ); + guard_bits = find_guarded_bits_fx( subframe_len ); + + q_shift_min = L_norm_arr( p_output_fx[0], subframe_len ); + FOR( Word16 i = 1; i < nchan_in; i++ ) + { + q_shift_min = s_min( q_shift_min, L_norm_arr( p_output_fx[i], subframe_len ) ); + } + q_shift_min = sub( q_shift_min, guard_bits ); + + FOR( Word16 i = 0; i < nchan_in; i++ ) + { + scale_sig32( p_output_fx[i], *nSamplesRendered, q_shift_min ); + } + *st_ivas->hCrendWrapper->p_io_qfactor = add( Q11, q_shift_min ); +#else *st_ivas->hCrendWrapper->p_io_qfactor = 11; move16(); +#endif IF( NE_32( ( error = ivas_rend_crendProcessSubframe_fx( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, NULL, NULL, st_ivas->hTcBuffer, p_output_fx, p_output_fx, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs, 0 ) ), IVAS_ERR_OK ) ) { return error; } +#ifdef FIX_2505_IVAS_DEC_SEGFAULT + FOR( Word16 i = 0; i < nchan_in; i++ ) + { + scale_sig32( p_output_fx[i], *nSamplesRendered, negate( q_shift_min ) ); // Q11 + } + *st_ivas->hCrendWrapper->p_io_qfactor = Q11; + move16(); +#endif } } ELSE diff --git a/lib_rend/ivas_crend_fx.c b/lib_rend/ivas_crend_fx.c index 989215e4fb1e4677408eed5bd1607018d49b94ee..5e41928918a7834cfefc0d26adc519e431ca8740 100644 --- a/lib_rend/ivas_crend_fx.c +++ b/lib_rend/ivas_crend_fx.c @@ -1923,8 +1923,11 @@ static ivas_error ivas_rend_crendConvolver_fx( } } } - +#ifdef FIX_2505_IVAS_DEC_SEGFAULT + ivas_mdft_fx( pIn, pFreq_buf_re, pFreq_buf_im, subframe_length, subframe_length ); // Input guard bits are added two functions up the call chain before ivas_rend_crendProcessSubframe_fx() is called +#else ivas_mdft_fx( pIn, pFreq_buf_re, pFreq_buf_im, subframe_length, subframe_length ); +#endif i = add( i, 1 ); } }