From bee11a909648b0fcf0d23951fe5565c6292ef939 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 3 Aug 2023 23:43:20 +0200 Subject: [PATCH 01/15] formal improvements --- lib_rend/lib_rend.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index e30368606a..11cf5d087a 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -4112,16 +4112,22 @@ static ivas_error findFreeInputSlot( } #ifdef SPLIT_REND_WITH_HEAD_ROT -static void closeSplitRend( SPLIT_REND_WRAPPER *pSplitRendWrapper, IVAS_REND_AudioBuffer *pSplitRendEncBuffer ) +static void closeSplitRend( + SPLIT_REND_WRAPPER *pSplitRendWrapper, + IVAS_REND_AudioBuffer *pSplitRendEncBuffer ) { ivas_split_renderer_close( pSplitRendWrapper ); + if ( pSplitRendEncBuffer->data != NULL ) { free( pSplitRendEncBuffer->data ); pSplitRendEncBuffer->data = NULL; } + pSplitRendEncBuffer->config.numChannels = 0; pSplitRendEncBuffer->config.numSamplesPerChannel = 0; + + return; } #endif @@ -8654,7 +8660,7 @@ ivas_error IVAS_REND_GetSamples( &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, - ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), + (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, td_input, -- GitLab From 9831500b50ae51b82e7cc64131d27c136a28392d Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 7 Sep 2023 09:13:31 +0200 Subject: [PATCH 02/15] fix build --- lib_rend/lib_rend.c | 335 +++++++++++++++++++++----------------------- 1 file changed, 156 insertions(+), 179 deletions(-) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 4a8b689db8..24d51a3d23 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -1421,7 +1421,7 @@ static ivas_error setRendInputActiveIsm( } if ( outConfig == AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) - { + { if ( ( error = ivas_reverb_open( &( inputIsm->hReverb ), outConfig, NULL, inputIsm->tdRendWrapper.hBinRendererTd->HrFiltSet_p->lr_energy_and_iac, hRendCfg, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) { return error; @@ -2683,13 +2683,13 @@ static ivas_error updateSbaPanGains( { if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, inConfig, outConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate #ifdef SPLIT_REND_WITH_HEAD_ROT - , - rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses + , + rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses #endif ) ) != IVAS_ERR_OK ) { return error; - } + } } break; case AUDIO_CONFIG_BINAURAL_ROOM_IR: @@ -2701,8 +2701,8 @@ static ivas_error updateSbaPanGains( if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate #ifdef SPLIT_REND_WITH_HEAD_ROT - , - rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses + , + rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses #endif ) ) != IVAS_ERR_OK ) { @@ -3441,7 +3441,7 @@ static void freeDecoderDummy( if ( pDecDummy->hHrtfParambin != NULL ) { #endif - free( pDecDummy->hHrtfParambin ); + free( pDecDummy->hHrtfParambin ); #ifdef LIB_REND_FIX_HRTFPARAMBIN_MEMLEAK pDecDummy->hHrtfParambin = NULL; } @@ -4162,9 +4162,9 @@ static void closeSplitRend( *-------------------------------------------------------------------*/ ivas_error IVAS_REND_AddInput( - IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ const AUDIO_CONFIG inConfig, /* i : audio config for a new input */ - IVAS_REND_InputId *inputId /* o : ID of the new input */ + IVAS_REND_InputId *inputId /* o : ID of the new input */ ) { ivas_error error; @@ -5149,12 +5149,7 @@ ivas_error IVAS_REND_FeedSplitBinauralBitstream( *-------------------------------------------------------------------*/ ivas_error IVAS_REND_SetHeadRotation( -<<<<<<< HEAD - IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ -#ifdef API_5MS -======= IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ ->>>>>>> a6c09e4c8d628f3c9736959442e9006de7e24052 const IVAS_QUATERNION headRot, /* i : head orientations for next rendering call */ const IVAS_VECTOR3 Pos /* i : listener positions for next rendering call */ #ifdef SPLIT_REND_WITH_HEAD_ROT @@ -5360,10 +5355,6 @@ ivas_error IVAS_REND_SetReferenceVector( ivas_error IVAS_REND_SetExternalOrientation( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ IVAS_QUATERNION *orientation, /* i : external orientation data */ -<<<<<<< HEAD -#ifdef API_5MS -======= ->>>>>>> a6c09e4c8d628f3c9736959442e9006de7e24052 int8_t enableHeadRotation, /* i : flag to enable head rotation for this frame */ int8_t enableExternalOrientation, /* i : flag to enable external orientation for this frame */ int8_t enableRotationInterpolation, /* i : flag to interpolate rotations from current and previous frames */ @@ -5544,15 +5535,7 @@ static ivas_error chooseCrossfade( const IVAS_REND_HeadRotData *headRotData, con static ivas_error rotateFrameMc( IVAS_REND_AudioBuffer inAudio, /* i : Input Audio buffer */ AUDIO_CONFIG inConfig, /* i : Input Audio config */ -<<<<<<< HEAD -#ifdef API_5MS - const LSSETUP_CUSTOM_STRUCT *pInCustomLs, /* i : Input Custom LS setup */ -#else - LSSETUP_CUSTOM_STRUCT inCustomLs, /* i : Input Custom LS setup */ -#endif -======= const LSSETUP_CUSTOM_STRUCT *pInCustomLs, /* i : Input Custom LS setup */ ->>>>>>> a6c09e4c8d628f3c9736959442e9006de7e24052 const IVAS_REND_HeadRotData *headRotData, /* i : Head rotation data */ const COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData, /* i : Combined head and external orientations */ rotation_gains gains_prev, /* i/o: Previous frame rotation gains */ @@ -5992,7 +5975,7 @@ static ivas_error renderIsmToBinauralRoom( NULL, NULL, NULL, NULL, p_tmpRendBuffer, *ismInput->base.ctx.pOutSampleRate, getNumSubframesInBuffer( &outAudio, *ismInput->base.ctx.pOutSampleRate ) #ifdef SPLIT_REND_WITH_HEAD_ROT - , + , 0 #endif ) ) != IVAS_ERR_OK ) @@ -6244,8 +6227,8 @@ static ivas_error renderIsmToSplitBinaural( tmpProcessing ); if ( error != IVAS_ERR_OK ) { - return error; - } + return error; + } /* Copy rendered audio to tmp storage buffer. Copying directly to output would * overwrite original audio, which is still needed for rendering next head pose. */ @@ -6566,7 +6549,7 @@ static ivas_error renderMcToBinaural( if ( ( 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 ) #ifdef SPLIT_REND_WITH_HEAD_ROT - , + , 0 #endif ) ) != IVAS_ERR_OK ) @@ -6680,7 +6663,7 @@ static ivas_error renderMcToBinauralRoom( if ( ( 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 ) #ifdef SPLIT_REND_WITH_HEAD_ROT - , + , 0 #endif ) ) != IVAS_ERR_OK ) @@ -6792,7 +6775,7 @@ static ivas_error renderMcCustomLsToBinauralRoom( p_tmpCrendBuffer, *mcInput->base.ctx.pOutSampleRate, getNumSubframesInBuffer( &outAudio, *mcInput->base.ctx.pOutSampleRate ) #ifdef SPLIT_REND_WITH_HEAD_ROT - , + , 0 #endif ) ) != IVAS_ERR_OK ) @@ -7313,15 +7296,15 @@ static ivas_error renderSplitBinauralWithPostRot( } else { - config.lc3plus_frame_duration_us = 5000; - config.ivas_frame_duration_us = 20000; + config.lc3plus_frame_duration_us = 5000; + config.ivas_frame_duration_us = 20000; } config.channels = BINAURAL_CHANNELS; config.samplerate = *splitBinInput->base.ctx.pOutSampleRate; if ( ( error = IVAS_LC3PLUS_DEC_Open( config, #ifdef LC3PLUS_DEC_ALLOW_DISABLE_CACHING - 0 /* caching disabled */, + 0 /* caching disabled */, #endif &splitBinInput->splitPostRendWrapper.hLc3plusDec ) ) != IVAS_ERR_OK ) { @@ -7349,8 +7332,8 @@ static ivas_error renderSplitBinauralWithPostRot( { ivas_splitBinPostRendMdDec( &bits, hSplitBin->hBinHrSplitPostRend, &hSplitBin->multiBinPoseData #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG - , - hSplitBin->hBinHrSplitPreRend + , + hSplitBin->hBinHrSplitPreRend #endif ); } @@ -7413,100 +7396,97 @@ static ivas_error renderSplitBinauralWithPostRot( } } } - else - { + else + { error = splitBinLc3plusDecode( hSplitBin, &bits, tmpCrendBuffer, bits.pose_correction ); if ( error != IVAS_ERR_OK ) <<<<<<< HEAD - { - return error; - } -#ifdef API_5MS -======= { return error; } +#ifdef API_5MS + == == == = { return error; + } >>>>>>> a6c09e4c8d628f3c9736959442e9006de7e24052 - /* cache the remaining 15ms */ - splitBinInput->numCachedSamples = numSamplesPerChannelCacheSize; - mvr2r( &tmpCrendBuffer[0][outBufNumSamplesPerChannel], - splitBinInput->bufferData, - numSamplesPerChannelCacheSize ); - mvr2r( &tmpCrendBuffer[1][outBufNumSamplesPerChannel], - splitBinInput->bufferData + numSamplesPerChannelCacheSize, - numSamplesPerChannelCacheSize ); + /* cache the remaining 15ms */ + splitBinInput->numCachedSamples = numSamplesPerChannelCacheSize; + mvr2r( &tmpCrendBuffer[0][outBufNumSamplesPerChannel], + splitBinInput->bufferData, + numSamplesPerChannelCacheSize ); + mvr2r( &tmpCrendBuffer[1][outBufNumSamplesPerChannel], + splitBinInput->bufferData + numSamplesPerChannelCacheSize, + numSamplesPerChannelCacheSize ); <<<<<<< HEAD #endif - } + } #ifdef API_5MS + } + else + { + == == == = + } } else { -======= - } - } - else - { >>>>>>> a6c09e4c8d628f3c9736959442e9006de7e24052 - /* copy from cache */ - if ( bits.codec == IVAS_SPLIT_REND_CODEC_LCLD ) - { - int16_t readOffset = ( numColPerChannelCacheSize - splitBinInput->numCachedSamples ); - readPtr = splitBinInput->bufferData; - isPostRendInputCldfb = 1; + /* copy from cache */ + if ( bits.codec == IVAS_SPLIT_REND_CODEC_LCLD ) + { + int16_t readOffset = ( numColPerChannelCacheSize - splitBinInput->numCachedSamples ); + readPtr = splitBinInput->bufferData; + isPostRendInputCldfb = 1; - readPtr += 2 * readOffset * CLDFB_NO_CHANNELS_MAX * BINAURAL_CHANNELS; - for ( slotIdx = 0; slotIdx < CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; ++slotIdx ) + readPtr += 2 * readOffset * CLDFB_NO_CHANNELS_MAX * BINAURAL_CHANNELS; + for ( slotIdx = 0; slotIdx < CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; ++slotIdx ) + { + for ( chnlIdx = 0; chnlIdx < BINAURAL_CHANNELS; ++chnlIdx ) + { + for ( smplIdx = 0; smplIdx < CLDFB_NO_CHANNELS_MAX; ++smplIdx ) { - for ( chnlIdx = 0; chnlIdx < BINAURAL_CHANNELS; ++chnlIdx ) - { - for ( smplIdx = 0; smplIdx < CLDFB_NO_CHANNELS_MAX; ++smplIdx ) - { - Cldfb_RealBuffer_Binaural_5ms[sf_idx][chnlIdx][slotIdx][smplIdx] = *readPtr++; - } - for ( smplIdx = 0; smplIdx < CLDFB_NO_CHANNELS_MAX; ++smplIdx ) - { - Cldfb_ImagBuffer_Binaural_5ms[sf_idx][chnlIdx][slotIdx][smplIdx] = *readPtr++; - } - } + Cldfb_RealBuffer_Binaural_5ms[sf_idx][chnlIdx][slotIdx][smplIdx] = *readPtr++; + } + for ( smplIdx = 0; smplIdx < CLDFB_NO_CHANNELS_MAX; ++smplIdx ) + { + Cldfb_ImagBuffer_Binaural_5ms[sf_idx][chnlIdx][slotIdx][smplIdx] = *readPtr++; } - - splitBinInput->numCachedSamples -= outBufNumColPerChannel; - } - else - { - int16_t readOffset = numSamplesPerChannelCacheSize - splitBinInput->numCachedSamples; - mvr2r( splitBinInput->bufferData + readOffset, - &tmpCrendBuffer[0][sf_idx * outBufNumSamplesPerChannel], - outBufNumSamplesPerChannel ); - mvr2r( splitBinInput->bufferData + readOffset + numSamplesPerChannelCacheSize, - &tmpCrendBuffer[1][sf_idx * outBufNumSamplesPerChannel], - outBufNumSamplesPerChannel ); - splitBinInput->numCachedSamples -= outBufNumSamplesPerChannel; } } + + splitBinInput->numCachedSamples -= outBufNumColPerChannel; + } + else + { + int16_t readOffset = numSamplesPerChannelCacheSize - splitBinInput->numCachedSamples; + mvr2r( splitBinInput->bufferData + readOffset, + &tmpCrendBuffer[0][sf_idx * outBufNumSamplesPerChannel], + outBufNumSamplesPerChannel ); + mvr2r( splitBinInput->bufferData + readOffset + numSamplesPerChannelCacheSize, + &tmpCrendBuffer[1][sf_idx * outBufNumSamplesPerChannel], + outBufNumSamplesPerChannel ); + splitBinInput->numCachedSamples -= outBufNumSamplesPerChannel; } } - else - { - copyBufferTo2dArray( splitBinInput->base.inputBuffer, tmpCrendBuffer ); - } + } +} +else +{ + copyBufferTo2dArray( splitBinInput->base.inputBuffer, tmpCrendBuffer ); +} - /* apply pose correction if enabled */ - for ( sf_idx = 0; sf_idx < pCombinedOrientationData->num_subframes; sf_idx++ ) - { +/* apply pose correction if enabled */ +for ( sf_idx = 0; sf_idx < pCombinedOrientationData->num_subframes; sf_idx++ ) +{ <<<<<<< HEAD -#endif - if ( bits.pose_correction == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_NONE && isPostRendInputCldfb ) - { - /* 0DOF with LCLD codec requires CLDFB synthesis */ - int16_t ch_idx, slot_idx; +#endif if ( bits.pose_correction == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_NONE && isPostRendInputCldfb ) + { + /* 0DOF with LCLD codec requires CLDFB synthesis */ + int16_t ch_idx, slot_idx; - for ( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) - { + for ( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) + { #ifdef API_5MS -======= - if ( bits.pose_correction == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_NONE && isPostRendInputCldfb ) + == == == = + if ( bits.pose_correction == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_NONE && isPostRendInputCldfb ) { /* 0DOF with LCLD codec requires CLDFB synthesis */ int16_t ch_idx, slot_idx; @@ -7519,37 +7499,34 @@ static ivas_error renderSplitBinauralWithPostRot( for ( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) <<<<<<< HEAD -#else - float *RealBuffer[CLDFB_NO_COL_MAX]; - float *ImagBuffer[CLDFB_NO_COL_MAX]; +#else float *RealBuffer[CLDFB_NO_COL_MAX]; + float *ImagBuffer[CLDFB_NO_COL_MAX]; - for ( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX; slot_idx++ ) + for ( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX; slot_idx++ ) #endif - { + { #ifdef API_5MS RealBuffer[slot_idx] = Cldfb_RealBuffer_Binaural_5ms[sf_idx][ch_idx][slot_idx]; ImagBuffer[slot_idx] = Cldfb_ImagBuffer_Binaural_5ms[sf_idx][ch_idx][slot_idx]; #else - RealBuffer[slot_idx] = Cldfb_RealBuffer_Binaural[ch_idx][slot_idx]; - ImagBuffer[slot_idx] = Cldfb_ImagBuffer_Binaural[ch_idx][slot_idx]; + RealBuffer[slot_idx] = Cldfb_RealBuffer_Binaural[ch_idx][slot_idx]; + ImagBuffer[slot_idx] = Cldfb_ImagBuffer_Binaural[ch_idx][slot_idx]; #endif - } -======= - { - RealBuffer[slot_idx] = Cldfb_RealBuffer_Binaural_5ms[sf_idx][ch_idx][slot_idx]; - ImagBuffer[slot_idx] = Cldfb_ImagBuffer_Binaural_5ms[sf_idx][ch_idx][slot_idx]; } + == == == = { RealBuffer[slot_idx] = Cldfb_RealBuffer_Binaural_5ms[sf_idx][ch_idx][slot_idx]; + ImagBuffer[slot_idx] = Cldfb_ImagBuffer_Binaural_5ms[sf_idx][ch_idx][slot_idx]; + } >>>>>>> a6c09e4c8d628f3c9736959442e9006de7e24052 cldfbSynthesis( RealBuffer, ImagBuffer, - &( tmpCrendBuffer[ch_idx][sf_idx * outBufNumSamplesPerChannel] ), + &( tmpCrendBuffer[ch_idx][sf_idx * outBufNumSamplesPerChannel] ), <<<<<<< HEAD - hSplitBin->hBinHrSplitPostRend->cldfbSyn[0]->no_channels * CLDFB_NO_COL_MAX + hSplitBin->hBinHrSplitPostRend->cldfbSyn[0]->no_channels * CLDFB_NO_COL_MAX #ifdef API_5MS - / MAX_PARAM_SPATIAL_SUBFRAMES + / MAX_PARAM_SPATIAL_SUBFRAMES #endif - , + , hSplitBin->hBinHrSplitPostRend->cldfbSyn[ch_idx] ); } } @@ -7559,65 +7536,65 @@ static ivas_error renderSplitBinauralWithPostRot( ======= hSplitBin->hBinHrSplitPostRend->cldfbSyn[0]->no_channels * CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, hSplitBin->hBinHrSplitPostRend->cldfbSyn[ch_idx] ); - } - } - else if ( bits.pose_correction == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) - { + } + } + else if ( bits.pose_correction == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) + { >>>>>>> a6c09e4c8d628f3c9736959442e9006de7e24052 - mvr2r( &tmpCrendBuffer[0][sf_idx * outBufNumSamplesPerChannel], - tmpCrendBuffer_sf[0], - outBufNumSamplesPerChannel ); - mvr2r( &tmpCrendBuffer[1][sf_idx * outBufNumSamplesPerChannel], - tmpCrendBuffer_sf[1], - outBufNumSamplesPerChannel ); - ivas_rend_CldfbSplitPostRendProcess( - hSplitBin->hBinHrSplitPostRend, - &hSplitBin->multiBinPoseData, - QuaternionsPost[sf_idx], - Cldfb_RealBuffer_Binaural_5ms[sf_idx], - Cldfb_ImagBuffer_Binaural_5ms[sf_idx], - tmpCrendBuffer_sf, - isPostRendInputCldfb ); - - mvr2r( tmpCrendBuffer_sf[0], - &tmpCrendBuffer[0][sf_idx * outBufNumSamplesPerChannel], - outBufNumSamplesPerChannel ); - mvr2r( tmpCrendBuffer_sf[1], - &tmpCrendBuffer[1][sf_idx * outBufNumSamplesPerChannel], - outBufNumSamplesPerChannel ); + mvr2r( &tmpCrendBuffer[0][sf_idx * outBufNumSamplesPerChannel], + tmpCrendBuffer_sf[0], + outBufNumSamplesPerChannel ); + mvr2r( &tmpCrendBuffer[1][sf_idx * outBufNumSamplesPerChannel], + tmpCrendBuffer_sf[1], + outBufNumSamplesPerChannel ); + ivas_rend_CldfbSplitPostRendProcess( + hSplitBin->hBinHrSplitPostRend, + &hSplitBin->multiBinPoseData, + QuaternionsPost[sf_idx], + Cldfb_RealBuffer_Binaural_5ms[sf_idx], + Cldfb_ImagBuffer_Binaural_5ms[sf_idx], + tmpCrendBuffer_sf, + isPostRendInputCldfb ); + + mvr2r( tmpCrendBuffer_sf[0], + &tmpCrendBuffer[0][sf_idx * outBufNumSamplesPerChannel], + outBufNumSamplesPerChannel ); + mvr2r( tmpCrendBuffer_sf[1], + &tmpCrendBuffer[1][sf_idx * outBufNumSamplesPerChannel], + outBufNumSamplesPerChannel ); <<<<<<< HEAD #endif - } -#ifdef API_5MS } +#ifdef API_5MS +} #endif -======= - } - } +== == == = +} +} >>>>>>> a6c09e4c8d628f3c9736959442e9006de7e24052 - } - else +} +else +{ + if ( splitBinInput->base.inConfig == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) { - if ( splitBinInput->base.inConfig == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) + int16_t ch_idx; + for ( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) { - int16_t ch_idx; - for ( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) - { - set_zero( tmpCrendBuffer[ch_idx], outAudio.config.numSamplesPerChannel ); - } - } - else - { - copyBufferTo2dArray( splitBinInput->base.inputBuffer, tmpCrendBuffer ); + set_zero( tmpCrendBuffer[ch_idx], outAudio.config.numSamplesPerChannel ); } } + else + { + copyBufferTo2dArray( splitBinInput->base.inputBuffer, tmpCrendBuffer ); + } +} - convertInternalBitsBuffToBitsBuffer( splitBinInput->hBits, bits ); - accumulate2dArrayToBuffer( tmpCrendBuffer, &outAudio ); +convertInternalBitsBuffToBitsBuffer( splitBinInput->hBits, bits ); +accumulate2dArrayToBuffer( tmpCrendBuffer, &outAudio ); - pop_wmops(); +pop_wmops(); - return error; +return error; } @@ -7858,7 +7835,7 @@ static ivas_error renderSbaToBinaural( #ifdef SPLIT_REND_WITH_HEAD_ROT sbaInput->rot_gains_prev[0], #else - sbaInput->rot_gains_prev, + sbaInput->rot_gains_prev, #endif tmpRotBuffer ) ) != IVAS_ERR_OK ) @@ -7879,7 +7856,7 @@ static ivas_error renderSbaToBinaural( NULL, NULL, NULL, NULL, p_tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate, getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ) #ifdef SPLIT_REND_WITH_HEAD_ROT - , + , 0 #endif ) ) != IVAS_ERR_OK ) @@ -7949,7 +7926,7 @@ static ivas_error renderSbaToBinauralRoom( #ifdef SPLIT_REND_WITH_HEAD_ROT sbaInput->rot_gains_prev[0], #else - sbaInput->rot_gains_prev, + sbaInput->rot_gains_prev, #endif tmpRotBuffer ) ) != IVAS_ERR_OK ) { @@ -7982,7 +7959,7 @@ static ivas_error renderSbaToBinauralRoom( NULL, NULL, NULL, NULL, p_tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate, getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ) #ifdef SPLIT_REND_WITH_HEAD_ROT - , + , 0 #endif ) ) != IVAS_ERR_OK ) @@ -8073,7 +8050,7 @@ static ivas_error renderInputSba( if ( ( sbaInput->base.numNewSamplesPerChannel * cldfb2tdSampleFact != outAudio.config.numSamplesPerChannel ) && ( outConfig != AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && ( outConfig != AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) #else - if ( sbaInput->base.numNewSamplesPerChannel != outAudio.config.numSamplesPerChannel ) + if ( sbaInput->base.numNewSamplesPerChannel != outAudio.config.numSamplesPerChannel ) #endif { return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "Mismatch between the number of input samples vs number of requested output samples - currently not allowed" ); @@ -8466,7 +8443,7 @@ static ivas_error renderInputMasa( if ( ( masaInput->base.numNewSamplesPerChannel * cldfb2tdSampleFact != outAudio.config.numSamplesPerChannel ) && ( outConfig != AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && ( outConfig != AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) #else - if ( masaInput->base.numNewSamplesPerChannel != outAudio.config.numSamplesPerChannel ) + if ( masaInput->base.numNewSamplesPerChannel != outAudio.config.numSamplesPerChannel ) #endif { return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "Mismatch between the number of input samples vs number of requested output samples - currently not allowed" ); @@ -8774,7 +8751,7 @@ static ivas_error getSamplesInternal( if ( outAudio.config.numSamplesPerChannel <= 0 || ( MAX_BUFFER_LENGTH_PER_CHANNEL < outAudio.config.numSamplesPerChannel && outAudio.config.is_cldfb == 0 ) || ( ( MAX_BUFFER_LENGTH_PER_CHANNEL * cldfb2tdSampleFact ) < outAudio.config.numSamplesPerChannel && outAudio.config.is_cldfb == 1 ) ) #else - if ( outAudio.config.numSamplesPerChannel <= 0 || MAX_BUFFER_LENGTH_PER_CHANNEL < outAudio.config.numSamplesPerChannel ) + if ( outAudio.config.numSamplesPerChannel <= 0 || MAX_BUFFER_LENGTH_PER_CHANNEL < outAudio.config.numSamplesPerChannel ) #endif { return IVAS_ERR_INVALID_BUFFER_SIZE; @@ -8791,8 +8768,8 @@ static ivas_error getSamplesInternal( hIvasRend->outputConfig != AUDIO_CONFIG_BINAURAL_SPLIT_PCM && ( outAudio.config.numSamplesPerChannel * 1000 / cldfb2tdSampleFact ) != ( hIvasRend->num_subframes * BINAURAL_RENDERING_FRAME_SIZE_MS ) * hIvasRend->sampleRateOut ) #else - if ( getAudioConfigType( hIvasRend->outputConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL && - outAudio.config.numSamplesPerChannel * 1000 != ( hIvasRend->num_subframes * BINAURAL_RENDERING_FRAME_SIZE_MS ) * hIvasRend->sampleRateOut ) + if ( getAudioConfigType( hIvasRend->outputConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL && + outAudio.config.numSamplesPerChannel * 1000 != ( hIvasRend->num_subframes * BINAURAL_RENDERING_FRAME_SIZE_MS ) * hIvasRend->sampleRateOut ) #endif { return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "Binaural rendering requires specific frame size" ); @@ -8903,9 +8880,9 @@ static ivas_error getSamplesInternal( #ifndef DISABLE_LIMITER #ifdef DEBUGGING - hIvasRend->numClipping += + hIvasRend->numClipping += #endif - limitRendererOutput( hIvasRend->hLimiter, outAudio.data, outAudio.config.numSamplesPerChannel, IVAS_LIMITER_THRESHOLD ); + limitRendererOutput( hIvasRend->hLimiter, outAudio.data, outAudio.config.numSamplesPerChannel, IVAS_LIMITER_THRESHOLD ); #endif #endif /* SPLIT_REND_WITH_HEAD_ROT */ -- GitLab From bb32c9a72c8bad5ed606b775ee3997735494dad7 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 16 Oct 2023 12:46:27 +0200 Subject: [PATCH 03/15] wrap set_f() into DEBUG_MODE_INFO --- lib_debug/snr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_debug/snr.c b/lib_debug/snr.c index 5efefe8737..3e817287c7 100644 --- a/lib_debug/snr.c +++ b/lib_debug/snr.c @@ -84,6 +84,7 @@ static float mem_synth_snr[MAX_INPUT_CHANNELS][M]; here we do not want to include prot.h due to its dependencies *--------------------------------------------------------------------*/ +#ifdef DEBUG_MODE_INFO static void set_f( float y[], /* i/o: Vector to set */ const float a, /* i : Value to set the vector to */ @@ -99,7 +100,7 @@ static void set_f( return; } - +#endif static float sum2_f( const float *vec, /* i : input vector */ -- GitLab From f8a4c5121b6a471fd079a59b2d62dfb2574b32a0 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 5 Mar 2024 15:28:02 +0100 Subject: [PATCH 04/15] sync --- lib_com/options.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 52901ec9c4..19651aa27a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -48,7 +48,7 @@ /* ################### Start DEBUGGING switches ########################### */ #ifndef RELEASE -/*#define DEBUGGING*/ /* Activate debugging part of the code */ +#define DEBUGGING /* Activate debugging part of the code */ #endif /*#define WMOPS*/ /* Activate complexity and memory counters */ /*#define WMOPS_PER_FRAME*/ /* Output per-frame complexity (writes one float value per frame to the file "wmops_analysis") */ @@ -57,7 +57,7 @@ /*#define MEM_COUNT_DETAILS*/ /* Output detailed memory analysis for the worst-case frame (writes to the file "mem_analysis.csv") */ #ifdef DEBUGGING -/*#define DEBUG_MODE_INFO*/ /* output most important parameters to the subdirectory "res/" */ +#define DEBUG_MODE_INFO /* output most important parameters to the subdirectory "res/" */ #ifdef DEBUG_MODE_INFO /*#define DEBUG_MODE_ACELP*/ /* output most important ACELP core parameters to the subdirectory "res/" */ /*#define DEBUG_MODE_TCX*/ /* output most important TCX core parameters to the subdirectory "res/" */ -- GitLab From 926c1538e4746038dc5bf74749bd1ea069ecf1f0 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 5 Mar 2024 15:29:25 +0100 Subject: [PATCH 05/15] fix sync --- lib_dec/ivas_sce_dec.c | 2 +- lib_enc/speech_music_classif.c | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_sce_dec.c b/lib_dec/ivas_sce_dec.c index 70903f2a0d..92a20ad0eb 100644 --- a/lib_dec/ivas_sce_dec.c +++ b/lib_dec/ivas_sce_dec.c @@ -300,7 +300,7 @@ ivas_error ivas_sce_dec( dbgwrite( &tmpF, sizeof( float ), 1, output_frame, fname( debug_dir, "element_brate", 0, sce_id, DEC ) ); dbgwrite( &st->element_mode, sizeof( int16_t ), 1, output_frame, fname( debug_dir, "element_mode", 0, sce_id, DEC ) ); - dbgwrite( output, sizeof( float ), output_frame, 1, fname( debug_dir, "output.sce", 0, sce_id, DEC ) ); + dbgwrite( output[0], sizeof( float ), output_frame, 1, fname( debug_dir, "output.sce", 0, sce_id, DEC ) ); if ( st_ivas->ivas_format != MASA_ISM_FORMAT ) { diff --git a/lib_enc/speech_music_classif.c b/lib_enc/speech_music_classif.c index 3d17233c40..94cf57fe42 100644 --- a/lib_enc/speech_music_classif.c +++ b/lib_enc/speech_music_classif.c @@ -1966,6 +1966,16 @@ void ivas_smc_mode_selection( *attack_flag = attack + 1; } + if ( st->localVAD == 1 && st->coder_type == UNVOICED && attack > 0 /*&& *attack_flag < 32*/ /*&& st->tc_cnt != 2*/ && !( st->sp_aud_decision2 == 1 && ton > 0.65f ) && st->flag_ACELP16k ) + { + /* change ACELP coder_type to TC if attack has been detected */ + st->sp_aud_decision1 = 0; + st->sp_aud_decision2 = 0; + + st->coder_type = TRANSITION; + *attack_flag = attack + 1; + } + #ifdef DEBUGGING if ( st->idchan == 0 && st->coder_type != INACTIVE ) { -- GitLab From 208c8ba6da5b600e261677b0a56f4d3038996d34 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 6 Mar 2024 12:06:00 +0100 Subject: [PATCH 06/15] remove ISM4 issue debugging code --- lib_enc/speech_music_classif.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/lib_enc/speech_music_classif.c b/lib_enc/speech_music_classif.c index 94cf57fe42..d05e066c75 100644 --- a/lib_enc/speech_music_classif.c +++ b/lib_enc/speech_music_classif.c @@ -1966,15 +1966,6 @@ void ivas_smc_mode_selection( *attack_flag = attack + 1; } - if ( st->localVAD == 1 && st->coder_type == UNVOICED && attack > 0 /*&& *attack_flag < 32*/ /*&& st->tc_cnt != 2*/ && !( st->sp_aud_decision2 == 1 && ton > 0.65f ) && st->flag_ACELP16k ) - { - /* change ACELP coder_type to TC if attack has been detected */ - st->sp_aud_decision1 = 0; - st->sp_aud_decision2 = 0; - - st->coder_type = TRANSITION; - *attack_flag = attack + 1; - } #ifdef DEBUGGING if ( st->idchan == 0 && st->coder_type != INACTIVE ) -- GitLab From dd5f97856a10208904741aa99abac2136bc3fcfc Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 7 Mar 2024 14:30:10 +0100 Subject: [PATCH 07/15] reintroduce testing of rotation in SHD --- scripts/config/self_test.prm | 4 ++++ scripts/config/self_test_ltv.prm | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/config/self_test.prm b/scripts/config/self_test.prm index 6a211e3c53..434fa282b5 100644 --- a/scripts/config/self_test.prm +++ b/scripts/config/self_test.prm @@ -1232,6 +1232,10 @@ eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g1 ../IVAS_cod -mc 7_1_4 160000 48 testv/stv714MC48c.wav bit ../IVAS_dec 7_1_4 48 bit testv/stv714MC48c.wav_MC714_160000_48-48_MC714.tst +// Multi-channel 7_1_4 at 512 kbps, 48kHz in, 48kHz out, BINAURAL out, HR +../IVAS_cod -mc 7_1_4 512000 48 testv/stv714MC48c.wav bit +../IVAS_dec -t testv/headrot.csv BINAURAL 48 bit testv/stv714MC48c.wav_MC714_512000_48-48_MC_binaural_hrot.tst + // Multi-channel 5_1_2 at 32 kbps, 48kHz in, 48kHz out, STEREO out, random FER at 5% ../IVAS_cod -mc 5_1_2 32000 48 testv/stv512MC48c.wav bit eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g192 bit_error diff --git a/scripts/config/self_test_ltv.prm b/scripts/config/self_test_ltv.prm index 5281b5edda..92e1f62f81 100644 --- a/scripts/config/self_test_ltv.prm +++ b/scripts/config/self_test_ltv.prm @@ -884,7 +884,6 @@ eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g1 - // MASA 1dir 1TC at 13.2 kbps, 48kHz in, 48kHz out, BINAURAL out, bandwidth switching ../IVAS_cod -max_band testv/ivas_bws_20fr_start_SWB.txt -masa 1 testv/ltv48_MASA1TC.met 13200 48 testv/ltv48_MASA1TC.wav bit ../IVAS_dec BINAURAL 48 bit testv/ltv48_MASA1TC.wav_13200_48-48_BINAURAL.tst @@ -1029,7 +1028,6 @@ eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g1 ../IVAS_cod -max_band testv/ivas_bws_20fr_start_WB.txt -masa 2 testv/ltv48_MASA2TC.met 384000 48 testv/ltv48_MASA2TC.wav bit ../IVAS_dec BINAURAL_ROOM_IR 48 bit testv/ltv48_MASA2TC.wav_384000_48-48_BinauralRoom.tst - // MASA 2dir 2TC at 512 kbps, 48kHz in, 48kHz out, 5_1 out ../IVAS_cod -masa 2 testv/ltv48_MASA2TC.met 512000 48 testv/ltv48_MASA2TC.wav bit ../IVAS_dec 5_1 48 bit testv/ltv48_MASA2TC.wav_512000_48-48_5_1.tst @@ -1230,6 +1228,10 @@ eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g1 ../IVAS_cod -max_band testv/ivas_bws_20fr_start_WB.txt -mc 7_1_4 160000 48 testv/ltv48_MC714.wav bit ../IVAS_dec BINAURAL 48 bit testv/ltv48_MC714.wav_MC714_160000_48-48_MC_binaural.tst +// Multi-channel 7_1_4 at 512 kbps, 48kHz in, 48kHz out, BINAURAL out, HR +../IVAS_cod -mc 7_1_4 512000 48 testv/ltv48_MC714.wav bit +../IVAS_dec -t testv/headrot.csv BINAURAL 48 bit testv/ltv48_MC714.wav_MC714_512000_48-48_MC_binaural_hrot.tst + // Multi-channel 7_1_4 at 160 kbps, 48kHz in, 48kHz out, 7_1_4 out ../IVAS_cod -mc 7_1_4 160000 48 testv/ltv48_MC714.wav bit ../IVAS_dec 7_1_4 48 bit testv/ltv48_MC714.wav_MC714_160000_48-48_MC714.tst @@ -1691,8 +1693,6 @@ eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g1 // eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_10pct.g192 bit_error // ../IVAS_dec STEREO 32 bit_error testv/ltv48_OSBA_3ISM_2OA.wav_STEREO_sw_48-32_FER10.tst - - // OSBA 3ISM 3OA at bitrate switching 13.2 to 512 kbps, 48kHz in, 32kHz out, BINAURAL ROOM REVERB out ../IVAS_cod -ism_sba 3 3 testv/ltvISM1.csv testv/ltvISM2.csv testv/ltvISM3.csv ../scripts/switchPaths/sw_13k2_512k.bin 48 testv/ltv48_OSBA_3ISM_HOA3.wav bit ../IVAS_dec BINAURAL_ROOM_REVERB 32 bit testv/ltv48_OSBA_3ISM_HOA3.wav_BINAURAL_ROOM_REVERB_sw_48-32.tst -- GitLab From d637882b13a843377aec66f88731d3ff0f2e7e41 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 17 Jun 2024 14:58:28 +0200 Subject: [PATCH 08/15] set output SBA order to the input order for OSBA EXT output --- lib_com/options.h | 2 ++ lib_dec/ivas_init_dec.c | 45 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 6a7b5fc981..4bb1a4730e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -174,6 +174,8 @@ #define REVERT_ZERO_FLUSH_TRESH /* FhG: issue 1069: revert threshold value introduced with !1518 due to significant complexity increase*/ #define NONBE_FIX_1097_SBA_DTX_BRATE_SWITCHING_ENC /* FhG: fix out-of-bound errors when switching from SID frame to active frame*/ +#define NONBE_FIX_1128_OSBA_EXT_OUTPUT_ORDER /* FhG: issue 1128: set output ambisonics order to input order for EXT output */ + /* ##################### End NON-BE switches ########################### */ /* ################## End DEVELOPMENT switches ######################### */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 64cddf0e12..b9f514f29b 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -940,7 +940,29 @@ ivas_error ivas_init_decoder( } else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { +#ifdef NONBE_FIX_1128_OSBA_EXT_OUTPUT_ORDER + + st_ivas->hOutSetup.ambisonics_order = st_ivas->sba_order; + switch (st_ivas->sba_order) + { + case 1: + hDecoderConfig->nchan_out = audioCfg2channels( IVAS_AUDIO_CONFIG_FOA ); + break; + + case 2: + hDecoderConfig->nchan_out = audioCfg2channels( IVAS_AUDIO_CONFIG_HOA2 ); + break; + + case 3: + hDecoderConfig->nchan_out = audioCfg2channels( IVAS_AUDIO_CONFIG_HOA3 ); + break; + + default: + assert(0 && "Invalid SBA order!"); + } +#else hDecoderConfig->nchan_out = audioCfg2channels( IVAS_AUDIO_CONFIG_HOA3 ); +#endif hDecoderConfig->nchan_out += st_ivas->nchan_ism; } else if ( st_ivas->ivas_format == MASA_ISM_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) @@ -981,10 +1003,33 @@ ivas_error ivas_init_decoder( if ( st_ivas->ivas_format == SBA_ISM_FORMAT && output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { +#ifdef NONBE_FIX_1128_OSBA_EXT_OUTPUT_ORDER + st_ivas->hOutSetup.ambisonics_order = st_ivas->sba_order; + switch ( st_ivas->sba_order ) + { + case 1: + st_ivas->intern_config = IVAS_AUDIO_CONFIG_FOA; + break; + + case 2: + st_ivas->intern_config = IVAS_AUDIO_CONFIG_HOA2; + break; + + case 3: + st_ivas->intern_config = IVAS_AUDIO_CONFIG_HOA3; + break; + + default: + assert( 0 && "Invalid SBA order!"); + } + st_ivas->hOutSetup.output_config = st_ivas->intern_config; + st_ivas->hOutSetup.nchan_out_woLFE = audioCfg2channels(st_ivas->intern_config); +#else st_ivas->hOutSetup.ambisonics_order = SBA_HOA3_ORDER; st_ivas->intern_config = IVAS_AUDIO_CONFIG_HOA3; st_ivas->hOutSetup.output_config = IVAS_AUDIO_CONFIG_HOA3; st_ivas->hOutSetup.nchan_out_woLFE = audioCfg2channels( IVAS_AUDIO_CONFIG_HOA3 ); +#endif } /* Only initialize transport setup if it is used */ -- GitLab From 867cb6c6e69c497ec195ee59d2fcd27c4bdd07e8 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 17 Jun 2024 14:59:46 +0200 Subject: [PATCH 09/15] fix formatting --- lib_dec/ivas_init_dec.c | 76 ++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index b9f514f29b..a24b0cf44d 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -942,24 +942,24 @@ ivas_error ivas_init_decoder( { #ifdef NONBE_FIX_1128_OSBA_EXT_OUTPUT_ORDER - st_ivas->hOutSetup.ambisonics_order = st_ivas->sba_order; - switch (st_ivas->sba_order) - { - case 1: - hDecoderConfig->nchan_out = audioCfg2channels( IVAS_AUDIO_CONFIG_FOA ); - break; - - case 2: - hDecoderConfig->nchan_out = audioCfg2channels( IVAS_AUDIO_CONFIG_HOA2 ); - break; - - case 3: - hDecoderConfig->nchan_out = audioCfg2channels( IVAS_AUDIO_CONFIG_HOA3 ); - break; - - default: - assert(0 && "Invalid SBA order!"); - } + st_ivas->hOutSetup.ambisonics_order = st_ivas->sba_order; + switch ( st_ivas->sba_order ) + { + case 1: + hDecoderConfig->nchan_out = audioCfg2channels( IVAS_AUDIO_CONFIG_FOA ); + break; + + case 2: + hDecoderConfig->nchan_out = audioCfg2channels( IVAS_AUDIO_CONFIG_HOA2 ); + break; + + case 3: + hDecoderConfig->nchan_out = audioCfg2channels( IVAS_AUDIO_CONFIG_HOA3 ); + break; + + default: + assert( 0 && "Invalid SBA order!" ); + } #else hDecoderConfig->nchan_out = audioCfg2channels( IVAS_AUDIO_CONFIG_HOA3 ); #endif @@ -1004,26 +1004,26 @@ ivas_error ivas_init_decoder( if ( st_ivas->ivas_format == SBA_ISM_FORMAT && output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { #ifdef NONBE_FIX_1128_OSBA_EXT_OUTPUT_ORDER - st_ivas->hOutSetup.ambisonics_order = st_ivas->sba_order; - switch ( st_ivas->sba_order ) - { - case 1: - st_ivas->intern_config = IVAS_AUDIO_CONFIG_FOA; - break; - - case 2: - st_ivas->intern_config = IVAS_AUDIO_CONFIG_HOA2; - break; - - case 3: - st_ivas->intern_config = IVAS_AUDIO_CONFIG_HOA3; - break; - - default: - assert( 0 && "Invalid SBA order!"); - } - st_ivas->hOutSetup.output_config = st_ivas->intern_config; - st_ivas->hOutSetup.nchan_out_woLFE = audioCfg2channels(st_ivas->intern_config); + st_ivas->hOutSetup.ambisonics_order = st_ivas->sba_order; + switch ( st_ivas->sba_order ) + { + case 1: + st_ivas->intern_config = IVAS_AUDIO_CONFIG_FOA; + break; + + case 2: + st_ivas->intern_config = IVAS_AUDIO_CONFIG_HOA2; + break; + + case 3: + st_ivas->intern_config = IVAS_AUDIO_CONFIG_HOA3; + break; + + default: + assert( 0 && "Invalid SBA order!" ); + } + st_ivas->hOutSetup.output_config = st_ivas->intern_config; + st_ivas->hOutSetup.nchan_out_woLFE = audioCfg2channels( st_ivas->intern_config ); #else st_ivas->hOutSetup.ambisonics_order = SBA_HOA3_ORDER; st_ivas->intern_config = IVAS_AUDIO_CONFIG_HOA3; -- GitLab From a6869b2ab34681e239adfc97b3e0c08a07d71d50 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 17 Jun 2024 16:38:08 +0200 Subject: [PATCH 10/15] fix OSBA EXT output config in ivas_renderer_select --- lib_dec/ivas_output_config.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index 7284155d9e..3fb23b3285 100644 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -327,7 +327,10 @@ void ivas_renderer_select( *internal_config = IVAS_AUDIO_CONFIG_FOA; } else - { +#ifdef NONBE_FIX_1128_OSBA_EXT_OUTPUT_ORDER + if ( output_config != IVAS_AUDIO_CONFIG_EXTERNAL ) +#endif + { *internal_config = IVAS_AUDIO_CONFIG_HOA3; } *renderer_type = RENDERER_SBA_LINEAR_DEC; -- GitLab From b723170163c08e05b07db035de044f9f74475c92 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 17 Jun 2024 20:47:15 +0200 Subject: [PATCH 11/15] updates --- lib_dec/ivas_init_dec.c | 83 ++++++++++++++++++------------------ lib_dec/ivas_output_config.c | 7 +-- 2 files changed, 45 insertions(+), 45 deletions(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index a24b0cf44d..3d5696dbd2 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -54,13 +54,29 @@ static ivas_error ivas_read_format( Decoder_Struct *st_ivas, int16_t *num_bits_r static ivas_error doSanityChecks_IVAS( Decoder_Struct *st_ivas ); + +#ifdef NONBE_FIX_1128_OSBA_EXT_OUTPUT_ORDER +/*-------------------------------------------------------------------* + * ivas_set_audio_config_from_sba_order() + * + * + *-------------------------------------------------------------------*/ + +/*! r: audio configuration */ +static AUDIO_CONFIG ivas_set_audio_config_from_sba_order( + const int16_t sba_order /* i : Ambisonic (SBA) order */ +) +#else static AUDIO_CONFIG ivas_set_output_config_from_sba_order( const int16_t sba_order ); static AUDIO_CONFIG ivas_set_output_config_from_sba_order( const int16_t sba_order ) +#endif { AUDIO_CONFIG output_config; + output_config = IVAS_AUDIO_CONFIG_HOA3; + switch ( sba_order ) { case SBA_FOA_ORDER: @@ -73,11 +89,18 @@ static AUDIO_CONFIG ivas_set_output_config_from_sba_order( const int16_t sba_ord output_config = IVAS_AUDIO_CONFIG_HOA3; break; default: +#ifdef NONBE_FIX_1128_OSBA_EXT_OUTPUT_ORDER + output_config = IVAS_AUDIO_CONFIG_INVALID; + break; +#else assert( 0 ); +#endif } + return output_config; } + /*-------------------------------------------------------------------* * ivas_dec_setup() * @@ -158,7 +181,11 @@ ivas_error ivas_dec_setup( st_ivas->sba_order += 2 * st_ivas->bit_stream[num_bits_read]; if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { +#ifdef NONBE_FIX_1128_OSBA_EXT_OUTPUT_ORDER + st_ivas->hDecoderConfig->output_config = ivas_set_audio_config_from_sba_order( st_ivas->sba_order ); +#else st_ivas->hDecoderConfig->output_config = ivas_set_output_config_from_sba_order( st_ivas->sba_order ); +#endif st_ivas->hDecoderConfig->nchan_out = audioCfg2channels( st_ivas->hDecoderConfig->output_config ); } @@ -402,7 +429,11 @@ ivas_error ivas_dec_setup( if ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { +#ifdef NONBE_FIX_1128_OSBA_EXT_OUTPUT_ORDER + st_ivas->hDecoderConfig->output_config = ivas_set_audio_config_from_sba_order( st_ivas->sba_order ); +#else st_ivas->hDecoderConfig->output_config = ivas_set_output_config_from_sba_order( st_ivas->sba_order ); +#endif st_ivas->hDecoderConfig->nchan_out = audioCfg2channels( st_ivas->hDecoderConfig->output_config ); } @@ -941,25 +972,7 @@ ivas_error ivas_init_decoder( else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { #ifdef NONBE_FIX_1128_OSBA_EXT_OUTPUT_ORDER - - st_ivas->hOutSetup.ambisonics_order = st_ivas->sba_order; - switch ( st_ivas->sba_order ) - { - case 1: - hDecoderConfig->nchan_out = audioCfg2channels( IVAS_AUDIO_CONFIG_FOA ); - break; - - case 2: - hDecoderConfig->nchan_out = audioCfg2channels( IVAS_AUDIO_CONFIG_HOA2 ); - break; - - case 3: - hDecoderConfig->nchan_out = audioCfg2channels( IVAS_AUDIO_CONFIG_HOA3 ); - break; - - default: - assert( 0 && "Invalid SBA order!" ); - } + hDecoderConfig->nchan_out = audioCfg2channels( ivas_set_audio_config_from_sba_order( st_ivas->sba_order ) ); #else hDecoderConfig->nchan_out = audioCfg2channels( IVAS_AUDIO_CONFIG_HOA3 ); #endif @@ -988,6 +1001,13 @@ ivas_error ivas_init_decoder( ivas_output_init( &( st_ivas->hOutSetup ), st_ivas->transport_config ); st_ivas->intern_config = st_ivas->transport_config; } +#ifdef NONBE_FIX_1128_OSBA_EXT_OUTPUT_ORDER + else if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL && st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + st_ivas->intern_config = ivas_set_audio_config_from_sba_order( st_ivas->sba_order ); + ivas_output_init( &( st_ivas->hOutSetup ), st_ivas->intern_config ); + } +#endif else { ivas_output_init( &( st_ivas->hOutSetup ), output_config ); @@ -1001,37 +1021,16 @@ ivas_error ivas_init_decoder( st_ivas->hOutSetup.nchan_out_woLFE = audioCfg2channels( st_ivas->intern_config ); } +#ifndef NONBE_FIX_1128_OSBA_EXT_OUTPUT_ORDER if ( st_ivas->ivas_format == SBA_ISM_FORMAT && output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { -#ifdef NONBE_FIX_1128_OSBA_EXT_OUTPUT_ORDER - st_ivas->hOutSetup.ambisonics_order = st_ivas->sba_order; - switch ( st_ivas->sba_order ) - { - case 1: - st_ivas->intern_config = IVAS_AUDIO_CONFIG_FOA; - break; - - case 2: - st_ivas->intern_config = IVAS_AUDIO_CONFIG_HOA2; - break; - - case 3: - st_ivas->intern_config = IVAS_AUDIO_CONFIG_HOA3; - break; - - default: - assert( 0 && "Invalid SBA order!" ); - } - st_ivas->hOutSetup.output_config = st_ivas->intern_config; - st_ivas->hOutSetup.nchan_out_woLFE = audioCfg2channels( st_ivas->intern_config ); -#else st_ivas->hOutSetup.ambisonics_order = SBA_HOA3_ORDER; st_ivas->intern_config = IVAS_AUDIO_CONFIG_HOA3; st_ivas->hOutSetup.output_config = IVAS_AUDIO_CONFIG_HOA3; st_ivas->hOutSetup.nchan_out_woLFE = audioCfg2channels( IVAS_AUDIO_CONFIG_HOA3 ); -#endif } +#endif /* Only initialize transport setup if it is used */ if ( st_ivas->transport_config != IVAS_AUDIO_CONFIG_INVALID ) { diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index 3fb23b3285..d221d11961 100644 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -326,11 +326,12 @@ void ivas_renderer_select( { *internal_config = IVAS_AUDIO_CONFIG_FOA; } - else #ifdef NONBE_FIX_1128_OSBA_EXT_OUTPUT_ORDER - if ( output_config != IVAS_AUDIO_CONFIG_EXTERNAL ) + else if ( output_config != IVAS_AUDIO_CONFIG_EXTERNAL ) +#else + if ( output_config != IVAS_AUDIO_CONFIG_EXTERNAL ) #endif - { + { *internal_config = IVAS_AUDIO_CONFIG_HOA3; } *renderer_type = RENDERER_SBA_LINEAR_DEC; -- GitLab From dbc693e91c4505ab2252680bfd47f94544aed0a9 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 17 Jun 2024 20:52:07 +0200 Subject: [PATCH 12/15] clang-format --- lib_dec/ivas_init_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 3d5696dbd2..8cffa9afcd 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -59,7 +59,7 @@ static ivas_error doSanityChecks_IVAS( Decoder_Struct *st_ivas ); /*-------------------------------------------------------------------* * ivas_set_audio_config_from_sba_order() * - * + * *-------------------------------------------------------------------*/ /*! r: audio configuration */ -- GitLab From bc431f3113b036515f5b7fad2b008a7d55e1420c Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 20 Jun 2024 14:59:57 +0200 Subject: [PATCH 13/15] revert unnecessary formatting changes --- lib_dec/ivas_sce_dec.c | 2 +- lib_enc/speech_music_classif.c | 1 - lib_rend/lib_rend.c | 18 +++++++++--------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/lib_dec/ivas_sce_dec.c b/lib_dec/ivas_sce_dec.c index 92a20ad0eb..70903f2a0d 100644 --- a/lib_dec/ivas_sce_dec.c +++ b/lib_dec/ivas_sce_dec.c @@ -300,7 +300,7 @@ ivas_error ivas_sce_dec( dbgwrite( &tmpF, sizeof( float ), 1, output_frame, fname( debug_dir, "element_brate", 0, sce_id, DEC ) ); dbgwrite( &st->element_mode, sizeof( int16_t ), 1, output_frame, fname( debug_dir, "element_mode", 0, sce_id, DEC ) ); - dbgwrite( output[0], sizeof( float ), output_frame, 1, fname( debug_dir, "output.sce", 0, sce_id, DEC ) ); + dbgwrite( output, sizeof( float ), output_frame, 1, fname( debug_dir, "output.sce", 0, sce_id, DEC ) ); if ( st_ivas->ivas_format != MASA_ISM_FORMAT ) { diff --git a/lib_enc/speech_music_classif.c b/lib_enc/speech_music_classif.c index d05e066c75..3d17233c40 100644 --- a/lib_enc/speech_music_classif.c +++ b/lib_enc/speech_music_classif.c @@ -1966,7 +1966,6 @@ void ivas_smc_mode_selection( *attack_flag = attack + 1; } - #ifdef DEBUGGING if ( st->idchan == 0 && st->coder_type != INACTIVE ) { diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 38efcef4ca..6e3257b6c8 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -3756,7 +3756,7 @@ ivas_error IVAS_REND_RemoveInput( *-------------------------------------------------------------------*/ ivas_error IVAS_REND_GetInputNumChannels( - IVAS_REND_CONST_HANDLE hIvasRend, /* i : Renderer handle */ + IVAS_REND_CONST_HANDLE hIvasRend, /* i : Renderer handle */ const IVAS_REND_InputId inputId, /* i : ID of the input */ int16_t *numChannels /* o : number of channels of the input */ ) @@ -3791,7 +3791,7 @@ ivas_error IVAS_REND_GetInputNumChannels( *-------------------------------------------------------------------*/ ivas_error IVAS_REND_GetNumAllObjects( - IVAS_REND_CONST_HANDLE hIvasRend, /* i : Renderer handle */ + IVAS_REND_CONST_HANDLE hIvasRend, /* i : Renderer handle */ int16_t *numChannels /* o : number of all objects */ ) { @@ -3816,9 +3816,9 @@ ivas_error IVAS_REND_GetNumAllObjects( *-------------------------------------------------------------------*/ ivas_error IVAS_REND_GetDelay( - IVAS_REND_CONST_HANDLE hIvasRend, /* i : Renderer state */ - int16_t *nSamples, /* o : Renderer delay in samples */ - int32_t *timeScale /* o : Time scale of the delay, equal to renderer output sampling rate */ + IVAS_REND_CONST_HANDLE hIvasRend, /* i : Renderer state */ + int16_t *nSamples, /* o : Renderer delay in samples */ + int32_t *timeScale /* o : Time scale of the delay, equal to renderer output sampling rate */ ) { /* TODO tmu : this function only returns the maximum delay across all inputs @@ -4093,7 +4093,7 @@ ivas_error IVAS_REND_FeedInputMasaMetadata( *-------------------------------------------------------------------*/ ivas_error IVAS_REND_InitConfig( - IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ const AUDIO_CONFIG outAudioConfig /* i : output audioConfig */ ) { @@ -4454,7 +4454,7 @@ ivas_error IVAS_REND_SetHeadRotation( *-------------------------------------------------------------------*/ ivas_error IVAS_REND_DisableHeadRotation( - IVAS_REND_HANDLE hIvasRend /* i/o: Renderer handle */ + IVAS_REND_HANDLE hIvasRend /* i/o: Renderer handle */ ) { int16_t i; @@ -4517,7 +4517,7 @@ ivas_error IVAS_REND_SetSplitRendBFI( *-------------------------------------------------------------------*/ ivas_error IVAS_REND_SetOrientationTrackingMode( - IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ const IVAS_HEAD_ORIENT_TRK_T orientation_tracking /* i : Head orientation tracking type */ ) { @@ -4676,7 +4676,7 @@ ivas_error IVAS_REND_SetExternalOrientation( *---------------------------------------------------------------------*/ ivas_error IVAS_REND_CombineHeadAndExternalOrientation( - IVAS_REND_HANDLE hIvasRend /* i/o: Renderer handle */ + IVAS_REND_HANDLE hIvasRend /* i/o: Renderer handle */ ) { if ( hIvasRend == NULL ) -- GitLab From 47e544e446348dc7d8ad026efe22152a8a9b07db Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 20 Jun 2024 15:01:21 +0200 Subject: [PATCH 14/15] disable DEBUG_MODE_INFO --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 195de220c0..55748e43b9 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -57,7 +57,7 @@ /*#define MEM_COUNT_DETAILS*/ /* Output detailed memory analysis for the worst-case frame (writes to the file "mem_analysis.csv") */ #ifdef DEBUGGING -#define DEBUG_MODE_INFO /* output most important parameters to the subdirectory "res/" */ +/*#define DEBUG_MODE_INFO*/ /* output most important parameters to the subdirectory "res/" */ #ifdef DEBUG_MODE_INFO /*#define DEBUG_MODE_ACELP*/ /* output most important ACELP core parameters to the subdirectory "res/" */ /*#define DEBUG_MODE_TCX*/ /* output most important TCX core parameters to the subdirectory "res/" */ -- GitLab From 09dfd6ab6426bbe66b22bdfced1da782b1acfaa5 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 20 Jun 2024 15:24:14 +0200 Subject: [PATCH 15/15] revert changes to config/self_test_ltv.prm --- scripts/config/self_test_ltv.prm | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/config/self_test_ltv.prm b/scripts/config/self_test_ltv.prm index 7969b99011..bb815be3ad 100644 --- a/scripts/config/self_test_ltv.prm +++ b/scripts/config/self_test_ltv.prm @@ -930,7 +930,6 @@ eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g1 eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g192 bit_error ../IVAS_dec EXT 48 bit_error testv/ltv48_HOA3.wav_sw_48-48_DTX_EXT_FER5.tst - // MASA 1dir 1TC at 13.2 kbps, 48kHz in, 48kHz out, BINAURAL out, bandwidth switching ../IVAS_cod -max_band testv/ivas_bws_20fr_start_SWB.txt -masa 1 testv/ltv48_MASA1TC.met 13200 48 testv/ltv48_MASA1TC.wav bit ../IVAS_dec BINAURAL 48 bit testv/ltv48_MASA1TC.wav_13200_48-48_BINAURAL.tst -- GitLab