diff --git a/lib_com/options.h b/lib_com/options.h old mode 100644 new mode 100755 index 587daf7b995530424d11b7713e094e2076308371..00e65c268106d9d554ad2b6a92220bea91cc415c --- a/lib_com/options.h +++ b/lib_com/options.h @@ -190,6 +190,7 @@ #define NONBE_FIX_931_IGF_STEREO_DEC_NOISE /* FhG: issue #931: fix noise substitution in the stereo IGF decoder */ #define FIX_CRASH_LONG_BRIR /* Orange : port 1202 Fix crash when long BRIR is set */ #define NONBE_FIX_943_RECONFIG_IGF_AFTER_SETTING_BW /* FhG: issue 943: fix crash in BW switchin from WB in MDCT-Stereo core encoder */ +#define FIX_911_REMOVE_CREND_DUPLICATION /* VA: issue 911: resolve duplication of CRend binaural external renderer function */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_rend/ivas_crend_fx.c b/lib_rend/ivas_crend_fx.c index 6e4247bc978f4f997c8da4c18ffa2d716e76efab..a00bccf2129daf8729e09ab34ae35ca696880376 100644 --- a/lib_rend/ivas_crend_fx.c +++ b/lib_rend/ivas_crend_fx.c @@ -1426,6 +1426,11 @@ ivas_error ivas_rend_initCrendWrapper( ( *pCrend )->binaural_latency_ns = 0; move32(); ( *pCrend )->hHrtfCrend = NULL; +#ifdef FIX_911_REMOVE_CREND_DUPLICATION + ( *pCrend )->io_qfactor = 0; + move16(); + ( *pCrend )->p_io_qfactor = &( *pCrend )->io_qfactor; +#endif #ifdef SPLIT_REND_WITH_HEAD_ROT FOR( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) @@ -2109,6 +2114,7 @@ static ivas_error ivas_rend_crendConvolver( return IVAS_ERR_OK; } +#ifndef FIX_911_REMOVE_CREND_DUPLICATION /*-----------------------------------------------------------------------------------------* * Function ivas_rend_crend_Process() * @@ -2278,6 +2284,7 @@ ivas_error ivas_rend_crendProcess( pop_wmops(); return IVAS_ERR_OK; } +#endif /*-----------------------------------------------------------------------------------------* * Function ivas_rend_crendProcessSubframe() @@ -2351,24 +2358,74 @@ ivas_error ivas_rend_crendProcessSubframe( { p_pcm_tmp_fx[ch] = pcm_tmp_fx[ch]; } - slot_size = hTcBuffer->n_samples_granularity; - move16(); - /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ - slots_to_render = s_min( sub( hTcBuffer->num_slots, hTcBuffer->slots_rendered ), idiv1616( n_samples_to_render, slot_size ) ); - first_sf = hTcBuffer->subframes_rendered; - move16(); - last_sf = first_sf; - move16(); +#ifdef FIX_911_REMOVE_CREND_DUPLICATION + IF( hTcBuffer != NULL ) + { +#endif + slot_size = hTcBuffer->n_samples_granularity; + move16(); - WHILE( slots_to_render > 0 ) + /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ + slots_to_render = s_min( sub( hTcBuffer->num_slots, hTcBuffer->slots_rendered ), idiv1616( n_samples_to_render, slot_size ) ); + first_sf = hTcBuffer->subframes_rendered; + move16(); + last_sf = first_sf; + move16(); + + WHILE( slots_to_render > 0 ) + { + slots_to_render = sub( slots_to_render, hTcBuffer->subframe_nbslots[last_sf] ); + last_sf = add( last_sf, 1 ); + } + +#ifdef FIX_911_REMOVE_CREND_DUPLICATION + subframe_len = -1; /* will be set later */ + move16(); + } + ELSE { - slots_to_render = sub( slots_to_render, hTcBuffer->subframe_nbslots[last_sf] ); - last_sf = add( last_sf, 1 ); + Word16 n_den, den, last_sf_tmp; + + SWITCH( output_Fs ) + { + case 48000: + subframe_len = L_SUBFRAME_48k; + move16(); + BREAK; + case 32000: + subframe_len = L_SUBFRAME_32k; + move16(); + BREAK; + case 16000: + default: + subframe_len = L_SUBFRAME_16k; + move16(); + BREAK; + } + + first_sf = 0; + move16(); + last_sf = idiv1616( n_samples_to_render, subframe_len ); + + n_den = norm_s( subframe_len ); + den = shl( subframe_len, n_den ); + last_sf_tmp = div_s( n_samples_to_render, den ); + last_sf = shr( last_sf_tmp, sub( 15, n_den ) ); } +#endif + FOR( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) { - subframe_len = imult1616( hTcBuffer->subframe_nbslots[subframe_idx], hTcBuffer->n_samples_granularity ); +#ifdef FIX_911_REMOVE_CREND_DUPLICATION + if ( hTcBuffer != NULL ) + { +#endif + subframe_len = imult1616( hTcBuffer->subframe_nbslots[subframe_idx], hTcBuffer->n_samples_granularity ); +#ifdef FIX_911_REMOVE_CREND_DUPLICATION + } +#endif + /* Early Reflections */ IF( hCrend->reflections != NULL ) { @@ -2432,6 +2489,7 @@ ivas_error ivas_rend_crendProcessSubframe( } } #endif + FOR( ch = 0; ch < nchan_in; ch++ ) { tc_local_fx[ch] += subframe_len; @@ -2440,13 +2498,22 @@ ivas_error ivas_rend_crendProcessSubframe( { p_pcm_tmp_fx[ch] += subframe_len; } - hTcBuffer->slots_rendered = add( hTcBuffer->subframe_nbslots[subframe_idx], hTcBuffer->slots_rendered ); - move16(); + +#ifdef FIX_911_REMOVE_CREND_DUPLICATION + if ( hTcBuffer != NULL ) + { +#endif + hTcBuffer->slots_rendered = add( hTcBuffer->subframe_nbslots[subframe_idx], hTcBuffer->slots_rendered ); + move16(); +#ifdef FIX_911_REMOVE_CREND_DUPLICATION + } +#endif } ELSE { return IVAS_ERR_INVALID_INPUT_FORMAT; } + /* update combined orientation access index */ ivas_combined_orientation_update_index( hCombinedOrientationData, subframe_len ); } @@ -2468,14 +2535,23 @@ ivas_error ivas_rend_crendProcessSubframe( } } } + /* move to output */ FOR( ch = 0; ch < nchan_out; ch++ ) { MVR2R_WORD32( pcm_tmp_fx[ch], output[ch], n_samples_to_render ); // Qx } - hTcBuffer->subframes_rendered = last_sf; - move16(); +#ifdef FIX_911_REMOVE_CREND_DUPLICATION + if ( hTcBuffer != NULL ) + { +#endif + hTcBuffer->subframes_rendered = last_sf; + move16(); +#ifdef FIX_911_REMOVE_CREND_DUPLICATION + } +#endif + pop_wmops(); return IVAS_ERR_OK; diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index e44e81d05cc062c17cf19e3f16a851f9934eac44..b365aa7672b1cab749b56f8ccfb24751dc394115 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -892,6 +892,8 @@ ivas_error ivas_rend_initCrendWrapper( CREND_WRAPPER_HANDLE *pCrend #endif ); + +#ifndef FIX_911_REMOVE_CREND_DUPLICATION ivas_error ivas_rend_crendProcess( const CREND_WRAPPER *pCrend, const AUDIO_CONFIG inConfig, @@ -909,6 +911,7 @@ ivas_error ivas_rend_crendProcess( const Word16 num_subframes /* i : number of subframes to render */ #endif ); +#endif ivas_error ivas_rend_crendProcessSubframe( const CREND_WRAPPER *pCrend, /* i/o: Crend wrapper handle */ const AUDIO_CONFIG inConfig, /* i : input audio configuration */ diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 0dbbef51712484f5af76415e6cabe0502eb9c09c..5babc6af9419079b537d723dff2cd171bd81a4d2 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -5982,10 +5982,14 @@ static ivas_error renderIsmToBinauralRoom( #ifdef SPLIT_REND_WITH_HEAD_ROT /* render 7_1_4 with BRIRs */ +#ifdef FIX_911_REMOVE_CREND_DUPLICATION + IF( NE_32( ( error = ivas_rend_crendProcessSubframe( ismInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, NULL, NULL, NULL, NULL, NULL, p_tmpRendBuffer, p_tmpRendBuffer, ismInput->base.inputBuffer.config.numSamplesPerChannel, *ismInput->base.ctx.pOutSampleRate, 0 ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_rend_crendProcess( ismInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, NULL, NULL, NULL, NULL, p_tmpRendBuffer, *ismInput->base.ctx.pOutSampleRate, getNumSubframesInBuffer( &outAudio, *ismInput->base.ctx.pOutSampleRate ), 0 ) ), IVAS_ERR_OK ) ) +#endif #else /* render 7_1_4 with BRIRs */ IF( NE_32( ( error = ivas_rend_crendProcess( ismInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, @@ -6802,9 +6806,13 @@ static ivas_error renderMcToBinaural( /* call CREND */ #ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef FIX_911_REMOVE_CREND_DUPLICATION + IF( NE_32( ( error = ivas_rend_crendProcessSubframe( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, NULL, p_tmpRendBuffer_fx, p_tmpRendBuffer_fx, mcInput->base.inputBuffer.config.numSamplesPerChannel, *mcInput->base.ctx.pOutSampleRate, 0 ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, p_tmpRendBuffer_fx, *mcInput->base.ctx.pOutSampleRate, getNumSubframesInBuffer( &outAudio, *mcInput->base.ctx.pOutSampleRate ), 0 ) ), IVAS_ERR_OK ) ) +#endif #else IF( NE_32( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, p_tmpRendBuffer_fx, *mcInput->base.ctx.pOutSampleRate, getNumSubframesInBuffer( &outAudio, *mcInput->base.ctx.pOutSampleRate ) ) ), @@ -6813,6 +6821,7 @@ static ivas_error renderMcToBinaural( { return error; } + IF( hCrend->hReverb != NULL ) { exp = sub( exp, 2 ); @@ -6948,9 +6957,13 @@ static ivas_error renderMcToBinauralRoom( /* call CREND */ #ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef FIX_911_REMOVE_CREND_DUPLICATION + IF( NE_32( ( error = ivas_rend_crendProcessSubframe( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, NULL, p_tmpRendBuffer, p_tmpRendBuffer, mcInput->base.inputBuffer.config.numSamplesPerChannel, *mcInput->base.ctx.pOutSampleRate, 0 ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, p_tmpRendBuffer, *mcInput->base.ctx.pOutSampleRate, getNumSubframesInBuffer( &outAudio, *mcInput->base.ctx.pOutSampleRate ), 0 ) ), IVAS_ERR_OK ) ) +#endif #else IF( NE_32( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, p_tmpRendBuffer, *mcInput->base.ctx.pOutSampleRate, getNumSubframesInBuffer( &outAudio, *mcInput->base.ctx.pOutSampleRate ) ) ), @@ -6959,6 +6972,7 @@ static ivas_error renderMcToBinauralRoom( { return error; } + IF( hCrend->hReverb != NULL ) { exp = sub( exp, Q2 ); @@ -7079,11 +7093,16 @@ static ivas_error renderMcCustomLsToBinauralRoom( #else hCrend = mcInput->crendWrapper->hCrend; #endif + /* call CREND */ #ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef FIX_911_REMOVE_CREND_DUPLICATION + IF( NE_32( ( error = ivas_rend_crendProcessSubframe( mcInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, NULL, NULL, NULL, p_tmpCrendBuffer, p_tmpCrendBuffer, mcInput->base.inputBuffer.config.numSamplesPerChannel, *mcInput->base.ctx.pOutSampleRate, 0 ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, NULL, NULL, p_tmpCrendBuffer, *mcInput->base.ctx.pOutSampleRate, getNumSubframesInBuffer( &outAudio, *mcInput->base.ctx.pOutSampleRate ), 0 ) ), IVAS_ERR_OK ) ) +#endif #else IF( NE_32( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, NULL, NULL, p_tmpCrendBuffer, *mcInput->base.ctx.pOutSampleRate, getNumSubframesInBuffer( &outAudio, *mcInput->base.ctx.pOutSampleRate ) ) ), @@ -7092,6 +7111,7 @@ static ivas_error renderMcCustomLsToBinauralRoom( { return error; } + IF( hCrend->hReverb != NULL ) { exp = sub( exp, 2 ); @@ -7338,9 +7358,16 @@ static ivas_error renderMcToSplitBinaural( copyBufferTo2dArray_fx( tmpRotBuffer, tmpRendBuffer ); /* call CREND (rotation already performed) */ +#ifdef FIX_911_REMOVE_CREND_DUPLICATION + IF( NE_32( ( error = ivas_rend_crendProcessSubframe( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, NULL, p_tmpRendBuffer, p_tmpRendBuffer, mcInput->base.inputBuffer.config.numSamplesPerChannel, *mcInput->base.ctx.pOutSampleRate, pos_idx ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, p_tmpRendBuffer, *mcInput->base.ctx.pOutSampleRate, getNumSubframesInBuffer( &tmpRotBuffer, *mcInput->base.ctx.pOutSampleRate ), pos_idx ) ), IVAS_ERR_OK ) ) +#endif + { + return error; + } IF( EQ_16( pos_idx, 0 ) ) { @@ -7611,9 +7638,13 @@ static ivas_error renderSbaToMultiBinaural( assert( sbaInput->crendWrapper->hCrend[0]->hReverb == NULL ); /* call CREND */ +#ifdef FIX_911_REMOVE_CREND_DUPLICATION + IF( NE_32( ( error = ivas_rend_crendProcessSubframe( sbaInput->crendWrapper, sbaInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, NULL, p_tmpCrendBuffer, p_tmpCrendBuffer, sbaInput->base.inputBuffer.config.numSamplesPerChannel, *sbaInput->base.ctx.pOutSampleRate, pos_idx ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_rend_crendProcess( sbaInput->crendWrapper, sbaInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, p_tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate, getNumSubframesInBuffer( &tmpRotBuffer, *sbaInput->base.ctx.pOutSampleRate ), pos_idx ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -7803,9 +7834,13 @@ static ivas_error renderSbaToBinaural( /* call CREND */ #ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef FIX_911_REMOVE_CREND_DUPLICATION + IF( NE_32( ( error = ivas_rend_crendProcessSubframe( sbaInput->crendWrapper, sbaInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, NULL, output_fx, output_fx, sbaInput->base.inputBuffer.config.numSamplesPerChannel, *sbaInput->base.ctx.pOutSampleRate, 0 ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_rend_crendProcess( sbaInput->crendWrapper, sbaInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, output_fx, *sbaInput->base.ctx.pOutSampleRate, getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ), 0 ) ), IVAS_ERR_OK ) ) +#endif #else IF( NE_32( ( error = ivas_rend_crendProcess( sbaInput->crendWrapper, sbaInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, output_fx, *sbaInput->base.ctx.pOutSampleRate, getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ) ) ), @@ -7814,6 +7849,7 @@ static ivas_error renderSbaToBinaural( { return error; } + IF( hCrend->hReverb != NULL ) { *outAudio.pq_fact = sub( *outAudio.pq_fact, Q2 ); @@ -7935,10 +7971,14 @@ static ivas_error renderSbaToBinauralRoom( /* call CREND */ #ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef FIX_911_REMOVE_CREND_DUPLICATION + IF( NE_32( ( error = ivas_rend_crendProcessSubframe( sbaInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, NULL, NULL, NULL, p_tmpCrendBuffer, p_tmpCrendBuffer, sbaInput->base.inputBuffer.config.numSamplesPerChannel, *sbaInput->base.ctx.pOutSampleRate, 0 ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_rend_crendProcess( sbaInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, NULL, NULL, p_tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate, getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ), 0 ) ), IVAS_ERR_OK ) ) +#endif #else IF( NE_32( ( error = ivas_rend_crendProcess( sbaInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, NULL, NULL, p_tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate, @@ -7948,6 +7988,7 @@ static ivas_error renderSbaToBinauralRoom( { return error; } + IF( hCrend->hReverb != NULL ) { *outAudio.pq_fact = sub( *outAudio.pq_fact, 2 );