From b696a87b58f75fb87539ccf2fc14d7a86e93714d Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Fri, 5 May 2023 14:49:32 +0300 Subject: [PATCH 1/2] Fix rest of issue 355 by refactoring parametric binauralizer to 5ms subframe resolution. --- lib_com/ivas_cnst.h | 3 + lib_com/ivas_prot.h | 10 +- lib_com/options.h | 2 + lib_dec/ivas_binRenderer_internal.c | 22 +- lib_dec/ivas_masa_dec.c | 207 ++++ lib_rend/ivas_dirac_dec_binaural_functions.c | 985 ++++++++++++++++++- lib_rend/ivas_prot_rend.h | 21 +- lib_rend/ivas_reverb.c | 46 + lib_rend/ivas_sba_rendering.c | 89 +- 9 files changed, 1336 insertions(+), 49 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 781e35878f..263c5992b0 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -864,6 +864,9 @@ typedef enum { // VE: this should be renamed to e.g. N_SPATIAL_SUBFRAMES #define MAX_PARAM_SPATIAL_SUBFRAMES 4 /* Maximum number of subframes for parameteric spatial coding */ #define L_SPATIAL_SUBFR_48k (L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES) +#ifdef FIX_355_REFACTOR_PARAMBIN_TO_5MS +#define CLDFB_SLOTS_PER_SUBFRAME ( CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES ) /* Number of CLDFB slots per subframe */ +#endif /*----------------------------------------------------------------------------------* diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 16d475ab09..9138455fe7 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -4691,13 +4691,21 @@ void ivas_masa_prerender( const int16_t output_frame /* i : output frame length per channel */ ); +#ifdef FIX_355_REFACTOR_PARAMBIN_TO_5MS +void ivas_spar_param_to_masa_param_mapping( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ + float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, real */ + float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, imag */ + const int16_t subframe /* i : Subframe to map */ +); +#else void ivas_spar_param_to_masa_param_mapping( Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ float inRe[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, real */ float inIm[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, imag */ const int16_t firstSubframe, /* i : First subframe to map */ const int16_t nSubframes /* i : Number of subframes to map */ -); +#endif /*---------------------------------------------------------------------------------* diff --git a/lib_com/options.h b/lib_com/options.h index cc884679fc..c896d8271b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -169,6 +169,8 @@ #define EUALER2QUAT_FIX /*Dlb :fix for issue 430 issue in euler2quat, sign of quat y is inverted*/ #define HR_METADATA /* Nok: encode directional MASA metadata with more bits at 384k and 512k */ +#define FIX_355_REFACTOR_PARAMBIN_TO_5MS /* Nokia: Fixes issue 355 by refactoring parametric binauralizer code to 5 ms mode */ + /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ #endif diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 2db5602519..63372cd5ba 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -426,6 +426,15 @@ static ivas_error ivas_binaural_hrtf_open( * *-------------------------------------------------------------------------*/ +#ifdef FIX_355_REFACTOR_PARAMBIN_TO_5MS +static void ivas_binaural_obtain_DMX( + const int16_t numTimeSlots, + BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: fastconv binaural renderer handle */ + float RealBuffer[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Contains the LS signals */ + float ImagBuffer[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Contains the LS signals */ + float realDMX[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + float imagDMX[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] ) +#else static void ivas_binaural_obtain_DMX( const int16_t numTimeSlots, BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: fastconv binaural renderer handle */ @@ -433,6 +442,7 @@ static void ivas_binaural_obtain_DMX( float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : Contains the LS signals */ float realDMX[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], float imagDMX[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] ) +#endif { int16_t chIdx, bandIdx, k; @@ -1029,11 +1039,17 @@ void ivas_binRenderer( /* Obtain the binaural dmx and compute the reverb */ if ( hBinRenderer->hReverb != NULL ) { +#ifdef FIX_355_REFACTOR_PARAMBIN_TO_5MS + float reverbRe[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + float reverbIm[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + float inRe[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + float inIm[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; +#else float reverbRe[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; float reverbIm[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; float inRe[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; float inIm[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - +#endif ivas_binaural_obtain_DMX( numTimeSlots, hBinRenderer, RealBuffer, ImagBuffer, inRe, inIm ); for ( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) @@ -1045,7 +1061,11 @@ void ivas_binRenderer( } } +#ifdef FIX_355_REFACTOR_PARAMBIN_TO_5MS + ivas_binaural_reverb_processSubframe( hBinRenderer->hReverb, BINAURAL_CHANNELS, inRe, inIm, reverbRe, reverbIm ); +#else ivas_binaural_reverb_processFrame( hBinRenderer->hReverb, BINAURAL_CHANNELS, inRe, inIm, reverbRe, reverbIm, 0u ); +#endif /* Add the conv module and reverb module output */ for ( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index e13cf41046..eead759257 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -1244,6 +1244,212 @@ ivas_error ivas_masa_dec_reconfigure( * Determine MASA metadata from the SPAR metadata *-------------------------------------------------------------------*/ +#ifdef FIX_355_REFACTOR_PARAMBIN_TO_5MS +void ivas_spar_param_to_masa_param_mapping( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ + float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, real */ + float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, imag */ + const int16_t subframe /* i : Subframe to map */ +) +{ + int16_t i, j, band, bin, slot, ch, nBins, nchan_transport; + int16_t mixer_mat_index; + int16_t dirac_write_idx; + DIRAC_DEC_HANDLE hDirAC; + DIFFUSE_DISTRIBUTION_HANDLE hDiffuseDist; + float mixer_mat_sf_bands_real[MAX_PARAM_SPATIAL_SUBFRAMES][SPAR_DIRAC_SPLIT_START_BAND][FOA_CHANNELS][FOA_CHANNELS]; + float mixer_mat_sf_bins_real[MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX][FOA_CHANNELS][FOA_CHANNELS]; + int16_t *band_grouping; + int16_t band_start, band_end; + float transportSignalEnergies[2][CLDFB_NO_CHANNELS_MAX]; + float transportSignalCrossCorrelation[CLDFB_NO_CHANNELS_MAX]; + float instEne; + float inCovarianceMtx[FOA_CHANNELS][FOA_CHANNELS]; + float foaCovarianceMtx[FOA_CHANNELS][FOA_CHANNELS]; + float Iy, Iz, Ix, E, azi, ele, I, ratio; + float diffuseGainX, diffuseGainY, diffuseGainZ, diffuseGainSum; + + /* Set values */ + hDirAC = st_ivas->hDirAC; + hDirAC->numSimultaneousDirections = 1; + hDiffuseDist = st_ivas->hDirAC->hDiffuseDist; + nchan_transport = st_ivas->nchan_transport; + band_grouping = hDirAC->band_grouping; + dirac_write_idx = hDirAC->dirac_read_idx; /* Mixing matrices, from which MASA meta is determined, already have the delay compensation */ + + /* Init arrays */ + for ( i = 0; i < FOA_CHANNELS; i++ ) + { + set_zero( inCovarianceMtx[i], FOA_CHANNELS ); + } + + /* Delay the SPAR mixing matrices to have them synced with the audio */ + if ( subframe < SPAR_META_DELAY_SUBFRAMES ) + { + mixer_mat_index = subframe + MAX_PARAM_SPATIAL_SUBFRAMES - SPAR_META_DELAY_SUBFRAMES + 1; + for ( band = 0; band < SPAR_DIRAC_SPLIT_START_BAND; band++ ) + { + for ( i = 0; i < FOA_CHANNELS; i++ ) + { + for ( j = 0; j < FOA_CHANNELS; j++ ) + { + mixer_mat_sf_bands_real[subframe][band][i][j] = st_ivas->hSpar->hMdDec->mixer_mat_prev[mixer_mat_index][i][j][band]; + } + } + } + } + else + { + mixer_mat_index = subframe - SPAR_META_DELAY_SUBFRAMES; + for ( band = 0; band < SPAR_DIRAC_SPLIT_START_BAND; band++ ) + { + for ( i = 0; i < FOA_CHANNELS; i++ ) + { + for ( j = 0; j < FOA_CHANNELS; j++ ) + { + mixer_mat_sf_bands_real[subframe][band][i][j] = st_ivas->hSpar->hMdDec->mixer_mat[i][j][band + mixer_mat_index * IVAS_MAX_NUM_BANDS]; + } + } + } + } + + /* Map the mixing matrices from the frequency bands to frequency bins */ + bin = 0; + for ( band = 0; band < SPAR_DIRAC_SPLIT_START_BAND; band++ ) + { + band_start = band_grouping[band]; + band_end = band_grouping[band + 1]; + for ( bin = band_start; bin < band_end; bin++ ) + { + for ( i = 0; i < FOA_CHANNELS; i++ ) + { + for ( j = 0; j < FOA_CHANNELS; j++ ) + { + mixer_mat_sf_bins_real[subframe][bin][i][j] = mixer_mat_sf_bands_real[subframe][band][i][j]; + } + } + } + } + nBins = bin; + + /* Determine MASA metadata */ + /* Determine transport signal energies and cross correlations when more than 1 TC */ + if ( nchan_transport == 2 ) + { + set_zero( transportSignalEnergies[0], nBins ); + set_zero( transportSignalEnergies[1], nBins ); + set_zero( transportSignalCrossCorrelation, nBins ); + + for ( slot = 0; slot < hDirAC->subframe_nbslots; slot++ ) + { + for ( bin = 0; bin < nBins; bin++ ) + { + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + instEne = ( inRe[ch][slot][bin] * inRe[ch][slot][bin] ); + instEne += ( inIm[ch][slot][bin] * inIm[ch][slot][bin] ); + transportSignalEnergies[ch][bin] += instEne; + } + transportSignalCrossCorrelation[bin] += inRe[0][slot][bin] * inRe[1][slot][bin]; + transportSignalCrossCorrelation[bin] += inIm[0][slot][bin] * inIm[1][slot][bin]; + } + } + } + + if ( hDiffuseDist != NULL ) + { + set_zero( hDiffuseDist->diffuseRatioX[subframe], CLDFB_NO_CHANNELS_MAX ); + set_zero( hDiffuseDist->diffuseRatioY[subframe], CLDFB_NO_CHANNELS_MAX ); + set_zero( hDiffuseDist->diffuseRatioZ[subframe], CLDFB_NO_CHANNELS_MAX ); + } + + for ( bin = 0; bin < nBins; bin++ ) + { + /* Set the energy of the first transport signal */ + if ( nchan_transport == 1 ) + { + inCovarianceMtx[0][0] = 1.0f; /* In case of 1TC, fixed value can be used */ + } + else + { + inCovarianceMtx[0][0] = transportSignalEnergies[0][bin]; /* In case of 2TC, use actual energies */ + } + /* Decorrelated channels assumed to have the same energy as the source channel */ + inCovarianceMtx[1][1] = inCovarianceMtx[0][0]; + inCovarianceMtx[2][2] = inCovarianceMtx[0][0]; + inCovarianceMtx[3][3] = inCovarianceMtx[0][0]; + + /* In case residuals were transmitted, use their actual energies and cross correlations */ + if ( nchan_transport == 2 ) + { + inCovarianceMtx[1][1] = transportSignalEnergies[1][bin]; + inCovarianceMtx[0][1] = transportSignalCrossCorrelation[bin]; + inCovarianceMtx[1][0] = inCovarianceMtx[0][1]; + } + + compute_foa_cov_matrix( foaCovarianceMtx, inCovarianceMtx, mixer_mat_sf_bins_real[subframe][bin] ); + + /* Estimate MASA metadata */ + Iy = foaCovarianceMtx[0][1]; /* Intensity in Y direction */ + Iz = foaCovarianceMtx[0][2]; /* Intensity in Z direction */ + Ix = foaCovarianceMtx[0][3]; /* Intensity in X direction */ + I = sqrtf( Ix * Ix + Iy * Iy + Iz * Iz ); /* Intensity vector length */ + E = ( foaCovarianceMtx[0][0] + foaCovarianceMtx[1][1] + foaCovarianceMtx[2][2] + foaCovarianceMtx[3][3] ) / 2.0f; /* Overall energy */ + azi = atan2f( Iy, Ix ); /* Azimuth */ + ele = atan2f( Iz, sqrtf( Ix * Ix + Iy * Iy ) ); /* Elevation */ + ratio = I / fmaxf( 1e-12f, E ); /* Energy ratio */ + ratio = fmaxf( 0.0f, fminf( 1.0f, ratio ) ); + + hDirAC->azimuth[dirac_write_idx][bin] = (int16_t) roundf( azi / PI_OVER_180 ); + hDirAC->elevation[dirac_write_idx][bin] = (int16_t) roundf( ele / PI_OVER_180 ); + hDirAC->energy_ratio1[dirac_write_idx][bin] = ratio; + hDirAC->diffuseness_vector[dirac_write_idx][bin] = 1.0f - ratio; + + hDirAC->spreadCoherence[dirac_write_idx][bin] = 0.0f; + hDirAC->surroundingCoherence[dirac_write_idx][bin] = 0.0f; + + /* Determine directional distribution of the indirect audio based on the SPAR mixing matrices (and the transport audio signals when 2 TC) */ + if ( hDiffuseDist != NULL ) + { + if ( nchan_transport == 1 ) + { + diffuseGainY = fabsf( mixer_mat_sf_bins_real[subframe][bin][1][1] ); + diffuseGainX = fabsf( mixer_mat_sf_bins_real[subframe][bin][3][2] ); + diffuseGainZ = fabsf( mixer_mat_sf_bins_real[subframe][bin][2][3] ); + } + else if ( nchan_transport == 2 ) + { + diffuseGainY = fabsf( mixer_mat_sf_bins_real[subframe][bin][1][1] * transportSignalEnergies[1][bin] ); + diffuseGainX = fabsf( mixer_mat_sf_bins_real[subframe][bin][3][2] * transportSignalEnergies[0][bin] ) + fabsf( mixer_mat_sf_bins_real[subframe][bin][3][1] * transportSignalEnergies[1][bin] ); + diffuseGainZ = fabsf( mixer_mat_sf_bins_real[subframe][bin][2][3] * transportSignalEnergies[0][bin] ) + fabsf( mixer_mat_sf_bins_real[subframe][bin][2][1] * transportSignalEnergies[1][bin] ); + } + else + { + diffuseGainY = 1.0f; + diffuseGainX = 1.0f; + diffuseGainZ = 1.0f; + } + + diffuseGainSum = diffuseGainY + diffuseGainX + diffuseGainZ; + + if ( diffuseGainSum == 0.0f ) + { + hDiffuseDist->diffuseRatioX[subframe][bin] = 1.0f / 3.0f; + hDiffuseDist->diffuseRatioY[subframe][bin] = 1.0f / 3.0f; + hDiffuseDist->diffuseRatioZ[subframe][bin] = 1.0f / 3.0f; + } + else + { + hDiffuseDist->diffuseRatioX[subframe][bin] = diffuseGainX / ( diffuseGainSum + EPSILON ); + hDiffuseDist->diffuseRatioY[subframe][bin] = diffuseGainY / ( diffuseGainSum + EPSILON ); + hDiffuseDist->diffuseRatioZ[subframe][bin] = diffuseGainZ / ( diffuseGainSum + EPSILON ); + } + } + } + + return; +} +#else void ivas_spar_param_to_masa_param_mapping( Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ float inRe[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, real */ @@ -1462,6 +1668,7 @@ void ivas_spar_param_to_masa_param_mapping( return; } +#endif /* Estimate FOA properties: foaCov = mixMtx * inCov * mixMtx' */ diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 1fbcad6f68..035036bad3 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -70,20 +70,37 @@ * Local function prototypes *------------------------------------------------------------------------*/ +#ifdef FIX_355_REFACTOR_PARAMBIN_TO_5MS +static void ivas_dirac_dec_binaural_internal( Decoder_Struct *st_ivas, float output_f[][L_FRAME48k], const int16_t nchan_transport, const int16_t subframe ); + +static void ivas_dirac_dec_decorrelate_slot( DIRAC_DEC_HANDLE hDirAC, const int16_t slot, float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float decRe[][CLDFB_NO_CHANNELS_MAX], float decIm[][CLDFB_NO_CHANNELS_MAX] ); + +static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices( Decoder_Struct *st_ivas, float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float Rmat[3][3], const int16_t subframe ); +#else static void ivas_dirac_dec_binaural_internal( Decoder_Struct *st_ivas, float output_f[][L_FRAME48k], const int16_t nchan_transport, const uint8_t firstSubframe, const uint8_t nSubframes ); static void ivas_dirac_dec_decorrelate_slot( DIRAC_DEC_HANDLE hDirAC, const int8_t slot, float inRe[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], float decRe[][CLDFB_NO_CHANNELS_MAX], float decIm[][CLDFB_NO_CHANNELS_MAX] ); static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices( Decoder_Struct *st_ivas, float inRe[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], float Rmat[3][3], const uint8_t firstSubframe, const uint8_t nSubFrames ); +#endif static void ivas_dirac_dec_binaural_determine_processing_matrices( Decoder_Struct *st_ivas, const int16_t max_band_decorr, float Rmat[3][3] ); +#ifdef FIX_355_REFACTOR_PARAMBIN_TO_5MS +static void ivas_dirac_dec_binaural_process_output( Decoder_Struct *st_ivas, float output_f[][L_FRAME48k], float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const int16_t max_band_decorr, const int16_t numInChannels, const int16_t subframe ); + +static void adaptTransportSignalsHeadtracked( HEAD_TRACK_DATA_HANDLE hHeadTrackData, float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const int16_t nBins, float Rmat[3][3] ); + +static void ivas_dirac_dec_binaural_check_and_switch_transports_headtracked( HEAD_TRACK_DATA_HANDLE hHeadTrackData, float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const int16_t nBins, float Rmat[3][3] ); +#else static void ivas_dirac_dec_binaural_process_output( Decoder_Struct *st_ivas, float output_f[][L_FRAME48k], float inRe[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], const int16_t max_band_decorr, const uint8_t numInputChannels, const uint8_t firstSlot, const uint8_t slotEnd ); static void adaptTransportSignalsHeadtracked( HEAD_TRACK_DATA_HANDLE hHeadTrackData, float inIm[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], float inRe[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], const uint8_t firstSlot, const uint8_t slotEnd, const uint8_t nBins, float Rmat[3][3] ); static void ivas_dirac_dec_binaural_check_and_switch_transports_headtracked( HEAD_TRACK_DATA_HANDLE hHeadTrackData, float inIm[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], float inRe[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], const uint8_t firstSlot, const uint8_t slotEnd, const uint8_t nBins, float Rmat[3][3] ); +#endif + static void formulate2x2MixingMatrix( float Ein1, float Ein2, float CinRe, float CinIm, float Eout1, float Eout2, float CoutRe, float CoutIm, float Q[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Mre[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Mim[BINAURAL_CHANNELS][BINAURAL_CHANNELS], const float regularizationFactor ); static void hrtfShGetHrtf( const int16_t bin, const int16_t aziDeg, const int16_t eleDeg, float *lRealp, float *lImagp, float *rRealp, float *rImagp ); @@ -156,7 +173,9 @@ ivas_error ivas_dirac_dec_init_binaural_data( set_zero( hBinaural->ChCrossImOutPrev, nBins ); hBinaural->renderStereoOutputInsteadOfBinaural = 0; +#ifndef FIX_355_REFACTOR_PARAMBIN_TO_5MS hBinaural->useSubframeMode = 1; +#endif #ifndef FIX_417_TD_DECORR_BRATE_SW hBinaural->useTdDecorr = 0; @@ -208,6 +227,28 @@ ivas_error ivas_dirac_dec_init_binaural_data( mvr2r( hHrtfParambin->parametricEarlyPartEneCorrection, hBinaural->earlyPartEneCorrection, nBins ); /* reconfiguration needed when Reverb. parameters are changed -> close and open the handle again */ +#ifdef FIX_355_REFACTOR_PARAMBIN_TO_5MS + if ( hBinaural->hReverb != NULL && ( ( hBinaural->hReverb->numBins != nBins ) || + ( hBinaural->hReverb->blockSize != CLDFB_SLOTS_PER_SUBFRAME ) ) ) + { + ivas_binaural_reverb_close( &( hBinaural->hReverb ) ); + } + + if ( hBinaural->hReverb == NULL ) + { + if ( ( error = ivas_binaural_reverb_open( &hBinaural->hReverb, + nBins, + CLDFB_SLOTS_PER_SUBFRAME, NULL, + st_ivas->hIntSetup.output_config, + output_Fs, + RENDERER_BINAURAL_PARAMETRIC_ROOM, + st_ivas->hHrtfFastConv, + st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#else if ( hBinaural->hReverb != NULL && ( ( hBinaural->hReverb->numBins != nBins ) || ( hBinaural->useSubframeMode && hBinaural->hReverb->blockSize != CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES ) || ( !hBinaural->useSubframeMode && hBinaural->hReverb->blockSize != CLDFB_NO_COL_MAX ) ) ) @@ -247,6 +288,7 @@ ivas_error ivas_dirac_dec_init_binaural_data( } } } +#endif } else if ( renderer_type == RENDERER_STEREO_PARAMETRIC ) { @@ -393,6 +435,10 @@ void ivas_dirac_dec_binaural( const int16_t nchan_transport /* i : number of transport channels */ ) { +#ifdef FIX_355_REFACTOR_PARAMBIN_TO_5MS + int16_t subframe; + +#endif if ( st_ivas->hDiracDecBin->useTdDecorr ) { float *decorr_signal[BINAURAL_CHANNELS]; @@ -408,6 +454,12 @@ void ivas_dirac_dec_binaural( ivas_td_decorr_process( st_ivas->hDiracDecBin->hTdDecorr, output_f, decorr_signal, output_frame ); } +#ifdef FIX_355_REFACTOR_PARAMBIN_TO_5MS + for ( subframe = 0; subframe < MAX_PARAM_SPATIAL_SUBFRAMES; subframe++ ) + { + ivas_dirac_dec_binaural_internal( st_ivas, output_f, nchan_transport, subframe ); + } +#else if ( st_ivas->hDiracDecBin->useSubframeMode ) { uint8_t subframe; @@ -420,6 +472,7 @@ void ivas_dirac_dec_binaural( { ivas_dirac_dec_binaural_internal( st_ivas, output_f, nchan_transport, 0u, (uint8_t) MAX_PARAM_SPATIAL_SUBFRAMES ); } +#endif return; } @@ -429,6 +482,188 @@ void ivas_dirac_dec_binaural( * Local functions *------------------------------------------------------------------------*/ +#ifdef FIX_355_REFACTOR_PARAMBIN_TO_5MS +static void ivas_dirac_dec_binaural_internal( + Decoder_Struct *st_ivas, + float output_f[][L_FRAME48k], + const int16_t nchan_transport, + const int16_t subframe ) +{ + DIRAC_DEC_HANDLE hDirAC; + int16_t slot, ch, numInChannels; + float Cldfb_RealBuffer_in[4][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer_in[4][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + float Rmat[3][3]; + int16_t max_band_decorr; + DIFFUSE_DISTRIBUTION_DATA diffuseDistData; + int16_t nBins, offsetSamples; + + hDirAC = st_ivas->hDirAC; + nBins = hDirAC->num_freq_bands; + offsetSamples = subframe * CLDFB_SLOTS_PER_SUBFRAME * nBins; + + /* The input channel number at this processing function (not nchan_transport) */ + numInChannels = BINAURAL_CHANNELS; + if ( st_ivas->hOutSetup.separateChannelEnabled ) + { + numInChannels++; + } + + Rmat[0][0] = 1.0f; + Rmat[0][1] = 0.0f; + Rmat[0][2] = 0.0f; + + Rmat[1][0] = 0.0f; + Rmat[1][1] = 1.0f; + Rmat[1][2] = 0.0f; + + Rmat[2][0] = 0.0f; + Rmat[2][1] = 0.0f; + Rmat[2][2] = 1.0f; + + /* CLDFB Analysis of input */ + for ( slot = 0; slot < CLDFB_SLOTS_PER_SUBFRAME; slot++ ) + { + for ( ch = 0; ch < numInChannels; ch++ ) + { + if ( ch == 0 || nchan_transport == 2 ) + { + cldfbAnalysis_ts( &( output_f[ch][nBins * slot + offsetSamples] ), + Cldfb_RealBuffer_in[ch][slot], + Cldfb_ImagBuffer_in[ch][slot], + nBins, st_ivas->cldfbAnaDec[ch] ); + } + else if ( st_ivas->nchan_transport == 2 ) /* Stereo signal transmitted as mono with DFT stereo */ + { + /* At mono input duplicate the channel to dual-mono */ + mvr2r( Cldfb_RealBuffer_in[0][slot], Cldfb_RealBuffer_in[1][slot], nBins ); + mvr2r( Cldfb_ImagBuffer_in[0][slot], Cldfb_ImagBuffer_in[1][slot], nBins ); + } + else /* when nchan_transport == 1 and ch == 1 */ + { + /* CNA and HB FD-CNG*/ + if ( st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag ) + { + int16_t numCoreBands, b; + int16_t slotInFrame; + + numCoreBands = st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->numCoreBands; + slotInFrame = subframe * CLDFB_SLOTS_PER_SUBFRAME + slot; + + generate_masking_noise_dirac( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom, + st_ivas->cldfbAnaDec[1], + &( output_f[1][L_FRAME48k - L_FRAME16k] ), /*used as temporary static buffer for the whole frame*/ + Cldfb_RealBuffer_in[2][slot], Cldfb_ImagBuffer_in[2][slot], + slotInFrame, + st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag && st_ivas->hSCE[0]->hCoreCoder[0]->flag_cna, + ( st_ivas->hSCE[0]->hCoreCoder[0]->core_brate == FRAME_NO_DATA || st_ivas->hSCE[0]->hCoreCoder[0]->core_brate == SID_2k40 ) && ( st_ivas->hSCE[0]->hCoreCoder[0]->cng_type == FD_CNG ) && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag ); + + generate_masking_noise_dirac( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom, + st_ivas->cldfbAnaDec[1], /*nothing will be analyzed, just get cnst*/ + NULL, + Cldfb_RealBuffer_in[1][slot], Cldfb_ImagBuffer_in[1][slot], + slotInFrame, + st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag && st_ivas->hSCE[0]->hCoreCoder[0]->flag_cna, + ( st_ivas->hSCE[0]->hCoreCoder[0]->core_brate == FRAME_NO_DATA || st_ivas->hSCE[0]->hCoreCoder[0]->core_brate == SID_2k40 ) && ( st_ivas->hSCE[0]->hCoreCoder[0]->cng_type == FD_CNG ) && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag ); + + /* LB: Copy first channel + LB-CNG to first and second channels with same scaling (dual-mono)*/ + for ( b = 0; b < numCoreBands; b++ ) + { + Cldfb_RealBuffer_in[0][slot][b] = INV_SQRT2 * ( Cldfb_RealBuffer_in[0][slot][b] + Cldfb_RealBuffer_in[2][slot][b] ); + Cldfb_RealBuffer_in[1][slot][b] = Cldfb_RealBuffer_in[0][slot][b]; + Cldfb_ImagBuffer_in[0][slot][b] = INV_SQRT2 * ( Cldfb_ImagBuffer_in[0][slot][b] + Cldfb_ImagBuffer_in[2][slot][b] ); + Cldfb_ImagBuffer_in[1][slot][b] = Cldfb_ImagBuffer_in[0][slot][b]; + } + + /* HB: Copy first channel to second channel and add HB-CNGs with different scalings*/ + for ( ; b < nBins; b++ ) + { + Cldfb_RealBuffer_in[0][slot][b] *= INV_SQRT2; + Cldfb_RealBuffer_in[1][slot][b] = Cldfb_RealBuffer_in[0][slot][b] + 0.5f * Cldfb_RealBuffer_in[1][slot][b] + Cldfb_RealBuffer_in[0][slot][b]; + Cldfb_RealBuffer_in[0][slot][b] += 0.5f * Cldfb_RealBuffer_in[2][slot][b]; + + Cldfb_ImagBuffer_in[0][slot][b] *= INV_SQRT2; + Cldfb_ImagBuffer_in[1][slot][b] = Cldfb_ImagBuffer_in[0][slot][b] + 0.5f * Cldfb_ImagBuffer_in[1][slot][b]; + Cldfb_ImagBuffer_in[0][slot][b] += 0.5f * Cldfb_ImagBuffer_in[2][slot][b]; + } + } + else + { + /* At mono input duplicate the channel to dual-mono, and apply gain + correction to ensure same overall level as in stereo mode */ + v_multc( Cldfb_RealBuffer_in[0][slot], INV_SQRT_2, Cldfb_RealBuffer_in[0][slot], nBins ); + v_multc( Cldfb_ImagBuffer_in[0][slot], INV_SQRT_2, Cldfb_ImagBuffer_in[0][slot], nBins ); + + mvr2r( Cldfb_RealBuffer_in[0][slot], Cldfb_RealBuffer_in[1][slot], nBins ); + mvr2r( Cldfb_ImagBuffer_in[0][slot], Cldfb_ImagBuffer_in[1][slot], nBins ); + } + } + } + + if ( st_ivas->hDiracDecBin->useTdDecorr ) + { + for ( ch = BINAURAL_CHANNELS; ch < ( 2 * BINAURAL_CHANNELS ); ch++ ) + { + cldfbAnalysis_ts( &( output_f[ch][nBins * slot + offsetSamples] ), + Cldfb_RealBuffer_in[ch][slot], + Cldfb_ImagBuffer_in[ch][slot], + nBins, st_ivas->cldfbAnaDec[ch] ); + + if ( st_ivas->nchan_transport == 1 && st_ivas->ivas_format == SBA_FORMAT ) + { + v_multc( Cldfb_RealBuffer_in[ch][slot], INV_SQRT_2, Cldfb_RealBuffer_in[ch][slot], nBins ); + v_multc( Cldfb_ImagBuffer_in[ch][slot], INV_SQRT_2, Cldfb_ImagBuffer_in[ch][slot], nBins ); + } + } + } + } + + if ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->sba_mode == SBA_MODE_SPAR ) + { + st_ivas->hDirAC->hDiffuseDist = &diffuseDistData; + + ivas_spar_param_to_masa_param_mapping( st_ivas, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, subframe ); + + ivas_sba_prototype_renderer( st_ivas, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, subframe ); + } + + if ( st_ivas->hHeadTrackData && st_ivas->hHeadTrackData->num_quaternions >= 0 ) + { + QuatToRotMat( st_ivas->hHeadTrackData->Quaternions[subframe], Rmat ); + + if ( nchan_transport == 2 ) + { + adaptTransportSignalsHeadtracked( st_ivas->hHeadTrackData, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, nBins, Rmat ); + + ivas_dirac_dec_binaural_check_and_switch_transports_headtracked( st_ivas->hHeadTrackData, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, nBins, Rmat ); + } + } + + ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices( st_ivas, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, Rmat, subframe ); + + if ( st_ivas->ivas_format == ISM_FORMAT ) + { + max_band_decorr = 0; + } + else if ( st_ivas->hDiracDecBin->useTdDecorr ) + { + max_band_decorr = CLDFB_NO_CHANNELS_MAX; + } + else + { + max_band_decorr = st_ivas->hDirAC->h_freq_domain_decorr_ap_params->max_band_decorr; + } + + ivas_dirac_dec_binaural_determine_processing_matrices( st_ivas, max_band_decorr, Rmat ); + + ivas_dirac_dec_binaural_process_output( st_ivas, output_f, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, max_band_decorr, numInChannels, subframe ); + + st_ivas->hDirAC->hDiffuseDist = NULL; + hDirAC->dirac_read_idx = ( hDirAC->dirac_read_idx + 1 ) % hDirAC->dirac_md_buffer_length; + + return; +} +#else static void ivas_dirac_dec_binaural_internal( Decoder_Struct *st_ivas, float output_f[][L_FRAME48k], @@ -605,64 +840,473 @@ static void ivas_dirac_dec_binaural_internal( ivas_dirac_dec_binaural_process_output( st_ivas, output_f, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, max_band_decorr, numInChannels, firstSlot, slotEnd ); - st_ivas->hDirAC->hDiffuseDist = NULL; + st_ivas->hDirAC->hDiffuseDist = NULL; + + return; +} +#endif + + +#ifdef FIX_355_REFACTOR_PARAMBIN_TO_5MS +static void ivas_dirac_dec_decorrelate_slot( + DIRAC_DEC_HANDLE hDirAC, + const int16_t slot, + float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + float decRe[][CLDFB_NO_CHANNELS_MAX], + float decIm[][CLDFB_NO_CHANNELS_MAX] ) +#else +static void ivas_dirac_dec_decorrelate_slot( + DIRAC_DEC_HANDLE hDirAC, + const int8_t slot, + float inRe[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + float inIm[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + float decRe[][CLDFB_NO_CHANNELS_MAX], + float decIm[][CLDFB_NO_CHANNELS_MAX] ) +#endif +{ + int16_t offset, ch, bin; + float onset_filter[BINAURAL_CHANNELS * CLDFB_NO_CHANNELS_MAX]; /* 2 ch, 60 bins */ + float decorrelatedFrameInterleaved[2 * BINAURAL_CHANNELS * CLDFB_NO_CHANNELS_MAX]; /* 2 ch, real + imag, 60 bins */ + + /* Decorrelation needs interleaved data. Copy left and right signals to proto_frame_f */ + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + offset = hDirAC->num_freq_bands * BINAURAL_CHANNELS * ch; + for ( bin = 0; bin < hDirAC->num_freq_bands; bin++ ) + { + hDirAC->proto_frame_f[( bin * BINAURAL_CHANNELS ) + offset] = inRe[ch][slot][bin]; + hDirAC->proto_frame_f[( bin * BINAURAL_CHANNELS ) + offset + 1] = inIm[ch][slot][bin]; + } + } + + /* Decorrelate proto signal to decorrelatedFrameInterleaved */ + ivas_dirac_dec_decorr_process( hDirAC->num_freq_bands, + hDirAC->num_outputs_diff, + hDirAC->num_protos_diff, + hDirAC->synthesisConf, + BINAURAL_CHANNELS, + hDirAC->proto_frame_f, + hDirAC->num_protos_diff, + hDirAC->proto_index_diff, + decorrelatedFrameInterleaved, + onset_filter, + hDirAC->h_freq_domain_decorr_ap_params, + hDirAC->h_freq_domain_decorr_ap_state ); + + /* De-interleave decorrelated signals*/ + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + offset = hDirAC->num_freq_bands * BINAURAL_CHANNELS * ch; + for ( bin = 0; bin < hDirAC->num_freq_bands; bin++ ) + { + decRe[ch][bin] = decorrelatedFrameInterleaved[( bin * BINAURAL_CHANNELS ) + offset]; + decIm[ch][bin] = decorrelatedFrameInterleaved[( bin * BINAURAL_CHANNELS ) + offset + 1]; + } + } + + return; +} + + +#ifdef FIX_355_REFACTOR_PARAMBIN_TO_5MS +static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices( + Decoder_Struct *st_ivas, + float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + float Rmat[3][3], + const int16_t subframe ) +{ + int16_t ch, slot, bin; + uint8_t separateCenterChannelRendering; + int16_t nBins, idx; + float frameMeanDiffusenessEneWeight[CLDFB_NO_CHANNELS_MAX]; + DIRAC_DEC_HANDLE hDirAC; + DIRAC_DEC_BIN_HANDLE h; + float IIReneLimiterFactor; + float qualityBasedSmFactor; + float lowBitRateEQ[CLDFB_NO_CHANNELS_MAX]; + uint8_t applyLowBitRateEQ; + int16_t dirac_read_idx; + float subFrameTotalEne[CLDFB_NO_CHANNELS_MAX]; + + hDirAC = st_ivas->hDirAC; + h = st_ivas->hDiracDecBin; + separateCenterChannelRendering = st_ivas->hOutSetup.separateChannelEnabled; + nBins = hDirAC->num_freq_bands; /* Actually bins */ + + set_zero( h->ChCrossRe, nBins ); + set_zero( h->ChCrossIm, nBins ); + set_zero( h->ChCrossReOut, nBins ); + set_zero( h->ChCrossImOut, nBins ); + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + set_zero( h->ChEne[ch], nBins ); + set_zero( h->ChEneOut[ch], nBins ); + } + set_zero( h->frameMeanDiffuseness, nBins ); + + set_zero( frameMeanDiffusenessEneWeight, CLDFB_NO_CHANNELS_MAX ); + + /* Determine EQ for low bit rates (13.2 and 16.4 kbps) */ + applyLowBitRateEQ = 0; + if ( ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MC_FORMAT ) && st_ivas->hDecoderConfig->ivas_total_brate < MASA_STEREO_MIN_BITRATE ) + { + applyLowBitRateEQ = 1; + if ( st_ivas->hDecoderConfig->ivas_total_brate == IVAS_16k4 ) + { + for ( bin = 0; bin < LOW_BIT_RATE_BINAURAL_EQ_BINS; bin++ ) + { + lowBitRateEQ[bin + LOW_BIT_RATE_BINAURAL_EQ_OFFSET] = lowBitRateBinauralEQ[bin] * 0.5f + 0.5f; + } + } + else + { + for ( bin = 0; bin < LOW_BIT_RATE_BINAURAL_EQ_BINS; bin++ ) + { + lowBitRateEQ[bin + LOW_BIT_RATE_BINAURAL_EQ_OFFSET] = lowBitRateBinauralEQ[bin]; + } + } + } + + /* Formulate input and target covariance matrices for this subframe */ + set_zero( subFrameTotalEne, CLDFB_NO_CHANNELS_MAX ); + dirac_read_idx = hDirAC->dirac_read_idx; + + /* Calculate input covariance matrix */ + for ( slot = 0; slot < hDirAC->subframe_nbslots; slot++ ) + { + for ( bin = 0; bin < nBins; bin++ ) + { + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + float instEne; + + instEne = ( inRe[ch][slot][bin] * inRe[ch][slot][bin] ); + instEne += ( inIm[ch][slot][bin] * inIm[ch][slot][bin] ); + h->ChEne[ch][bin] += instEne; + subFrameTotalEne[bin] += instEne; + } + h->ChCrossRe[bin] += inRe[0][slot][bin] * inRe[1][slot][bin]; + h->ChCrossRe[bin] += inIm[0][slot][bin] * inIm[1][slot][bin]; + h->ChCrossIm[bin] += inRe[0][slot][bin] * inIm[1][slot][bin]; + h->ChCrossIm[bin] -= inIm[0][slot][bin] * inRe[1][slot][bin]; + } + } + + /* Apply EQ at low bit rates */ + if ( applyLowBitRateEQ ) + { + int16_t lastEqBin = LOW_BIT_RATE_BINAURAL_EQ_OFFSET + LOW_BIT_RATE_BINAURAL_EQ_BINS - 1; + + for ( bin = LOW_BIT_RATE_BINAURAL_EQ_OFFSET; bin < lastEqBin; bin++ ) + { + subFrameTotalEne[bin] *= lowBitRateEQ[bin]; + } + for ( ; bin < nBins; bin++ ) + { + subFrameTotalEne[bin] *= lowBitRateEQ[lastEqBin]; + } + } + + if ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->nchan_transport == 2 ) + { + float tempRe, tempIm; + + set_zero( subFrameTotalEne, CLDFB_NO_CHANNELS_MAX ); + + for ( slot = 0; slot < hDirAC->subframe_nbslots; slot++ ) + { + for ( bin = 0; bin < nBins; bin++ ) + { + tempRe = inRe[0][slot][bin] + inRe[1][slot][bin]; + tempIm = inIm[0][slot][bin] + inIm[1][slot][bin]; + subFrameTotalEne[bin] += tempRe * tempRe + tempIm * tempIm; + } + } + } + + /* Determine target covariance matrix containing target binaural properties */ + for ( bin = 0; bin < nBins; bin++ ) + { + float diffuseness = 1.0f; /* ratio1 and ratio2 are subtracted from diffuseness further below */ + float surCoh = 0.0f, spreadCoh = 0.0f; /* Default values if spreadSurroundCoherenceApplied == false */ + float diffEne, dirEne, meanEnePerCh; + int16_t dirIndex; + + /* When BINAURAL_ROOM is not indicated, hBinaural->earlyPartEneCorrection[bin] values are all 1.0f. + * When BINAURAL_ROOM is indicated, the binaural audio output is based on combined use of the + * HRTF data set and a BRIR-based data set. The HRTF data set is spectrally corrected to match + * the early spectrum of the BRIR data, using the spectral correction data in + * hBinaural->earlyPartEneCorrection[bin], based on the BRIR set. */ + meanEnePerCh = h->earlyPartEneCorrection[bin] * subFrameTotalEne[bin] / 2.0f; + + /* Determine direct part target covariance matrix (for 1 or 2 directions) */ + for ( dirIndex = 0; dirIndex < hDirAC->numSimultaneousDirections; dirIndex++ ) + { + int16_t aziDeg, eleDeg; + float lRealp, lImagp, rRealp, rImagp; + float lRealpTmp, lImagpTmp, rRealpTmp, rImagpTmp; + float hrtfEne[BINAURAL_CHANNELS], hrtfCrossRe, hrtfCrossIm, ratio; + + if ( dirIndex == 0 ) /* For first of the two simultaneous directions */ + { + aziDeg = hDirAC->azimuth[dirac_read_idx][bin]; + eleDeg = hDirAC->elevation[dirac_read_idx][bin]; + ratio = hDirAC->energy_ratio1[dirac_read_idx][bin]; + spreadCoh = hDirAC->spreadCoherence[dirac_read_idx][bin]; + } + else /* For second of the two simultaneous directions */ + { + aziDeg = hDirAC->azimuth2[dirac_read_idx][bin]; + eleDeg = hDirAC->elevation2[dirac_read_idx][bin]; + ratio = hDirAC->energy_ratio2[dirac_read_idx][bin]; + spreadCoh = hDirAC->spreadCoherence2[dirac_read_idx][bin]; + } + diffuseness -= ratio; /* diffuseness = 1 - ratio1 - ratio2 */ + + if ( separateCenterChannelRendering ) + { + /* In masa + mono rendering mode, the center directions originate from phantom sources, so the + * spread coherence is increased */ + float aziRad, eleRad, doaVectorX, spatialAngleDeg, altSpreadCoh; + + aziRad = (float) aziDeg * PI_OVER_180; + eleRad = (float) eleDeg * PI_OVER_180; + doaVectorX = cosf( aziRad ) * cosf( eleRad ); + spatialAngleDeg = acosf( doaVectorX ) * _180_OVER_PI; + altSpreadCoh = 1.0f - ( spatialAngleDeg / 30.0f ); + spreadCoh = max( spreadCoh, altSpreadCoh ); + } + + getDirectPartGains( bin, aziDeg, eleDeg, &lRealp, &lImagp, &rRealp, &rImagp, h->renderStereoOutputInsteadOfBinaural, Rmat ); + + if ( h->renderStereoOutputInsteadOfBinaural ) + { + /* Synthesizing spread coherence is not needed for stereo loudspeaker output, + * as directional sound is reproduced with two loudspeakers in any case */ + spreadCoh = 0.0f; + } + + if ( spreadCoh > 0.0f ) + { + float centerMul, sidesMul; + float hrtfEneCenter, hrtfEneSides, hrtfEneRealized, eneCorrectionFactor; + float w1, w2, w3, eq; + + hrtfEneCenter = ( lRealp * lRealp ) + ( lImagp * lImagp ) + ( rRealp * rRealp ) + ( rImagp * rImagp ); + + /* Spread coherence is synthesized as coherent sources at 30 degree horizontal spacing. + * The following formulas determine the gains for these sources. + * spreadCoh = 0: Only panning + * spreadCoh = 0.5: Three sources coherent panning (e.g. 30 0 -30 deg azi) + * spreadCoh = 1.0: Two sources coherent panning with gap (as above, but center is silent) */ + if ( spreadCoh < 0.5f ) + { + /* 0.0f < spreadCoh < 0.5f */ + sidesMul = 0.5774f * spreadCoh * 2.0f; /* sqrt(1/3) = 0.5774f */ + centerMul = 1.0f - ( spreadCoh * 2.0f ) + sidesMul; + } + else + { + /* 0.5f <= spreadCoh < 1.0f */ + centerMul = 2.0f - ( 2.0f * spreadCoh ); + sidesMul = inv_sqrt( centerMul + 2.0f ); + centerMul *= sidesMul; + } + + /* Apply the gain for the center source of the three coherent sources */ + lRealp *= centerMul; + lImagp *= centerMul; + rRealp *= centerMul; + rImagp *= centerMul; + + /* Apply the gain for the left source of the three coherent sources */ + getDirectPartGains( bin, aziDeg + 30, eleDeg, &lRealpTmp, &lImagpTmp, &rRealpTmp, &rImagpTmp, h->renderStereoOutputInsteadOfBinaural, Rmat ); + + hrtfEneSides = ( lRealpTmp * lRealpTmp ) + ( lImagpTmp * lImagpTmp ) + ( rRealpTmp * rRealpTmp ) + ( rImagpTmp * rImagpTmp ); + lRealp += sidesMul * lRealpTmp; + lImagp += sidesMul * lImagpTmp; + rRealp += sidesMul * rRealpTmp; + rImagp += sidesMul * rImagpTmp; + + /* Apply the gain for the right source of the three coherent sources. + * -30 degrees to 330 wrapping due to internal functions. */ + getDirectPartGains( bin, aziDeg + 330, eleDeg, &lRealpTmp, &lImagpTmp, &rRealpTmp, &rImagpTmp, h->renderStereoOutputInsteadOfBinaural, Rmat ); + + hrtfEneSides += ( lRealpTmp * lRealpTmp ) + ( lImagpTmp * lImagpTmp ) + ( rRealpTmp * rRealpTmp ) + ( rImagpTmp * rImagpTmp ); + lRealp += sidesMul * lRealpTmp; + lImagp += sidesMul * lImagpTmp; + rRealp += sidesMul * rRealpTmp; + rImagp += sidesMul * rImagpTmp; + + /* Formulate an eneCorrectionFactor that compensates for the coherent summation of the HRTFs */ + hrtfEneRealized = ( lRealp * lRealp ) + ( lImagp * lImagp ) + ( rRealp * rRealp ) + ( rImagp * rImagp ); + eneCorrectionFactor = ( ( hrtfEneSides * sidesMul * sidesMul ) + + ( hrtfEneCenter * centerMul * centerMul ) ) / + max( 1e-12f, hrtfEneRealized ); + + /* Weighting factors to determine appropriate target spectrum for spread coherent sound */ + if ( spreadCoh < 0.5 ) + { + w1 = 1.0f - 2.0f * spreadCoh; + w2 = 2.0f * spreadCoh; + w3 = 0.0f; + } + else + { + w1 = 0.0f; + w2 = 2.0f - 2.0f * spreadCoh; + w3 = 2.0f * spreadCoh - 1.0f; + } + + if ( ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCMASA ) ) + { + idx = min( bin, MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS - 1 ); + + /* Apply the target spectrum to the eneCorrectionFactor */ + if ( separateCenterChannelRendering ) /* spreadCoh mostly originates from phantom sources in separate channel rendering mode */ + { + eneCorrectionFactor *= w1 * 1.0f + ( w2 + w3 ) * spreadCohEne1[idx]; + } + else + { + eneCorrectionFactor *= w1 * 1.0f + w2 * spreadCohEne05[idx] + w3 * spreadCohEne1[idx]; + } + } + + /* Equalize the spread coherent combined HRTFs */ + eq = min( 4.0f, sqrtf( eneCorrectionFactor ) ); + lRealp *= eq; + lImagp *= eq; + rRealp *= eq; + rImagp *= eq; + } + + hrtfEne[0] = ( lRealp * lRealp ) + ( lImagp * lImagp ); + hrtfEne[1] = ( rRealp * rRealp ) + ( rImagp * rImagp ); + hrtfCrossRe = ( lRealp * rRealp ) + ( lImagp * rImagp ); + hrtfCrossIm = ( -lImagp * rRealp ) + ( lRealp * rImagp ); + + /* Add direct part (1 or 2) covariance matrix */ + dirEne = ratio * meanEnePerCh; + h->ChEneOut[0][bin] += dirEne * hrtfEne[0]; /* Dir ene part*/ + h->ChEneOut[1][bin] += dirEne * hrtfEne[1]; + h->ChCrossReOut[bin] += dirEne * hrtfCrossRe; /* Dir cross re */ + h->ChCrossImOut[bin] += dirEne * hrtfCrossIm; /* Dir cross im */ + } + + /* Add diffuse / ambient part covariance matrix */ + diffuseness = max( 0.0f, diffuseness ); + diffEne = diffuseness * meanEnePerCh; + surCoh = hDirAC->surroundingCoherence[dirac_read_idx][bin]; + if ( ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCMASA ) ) + { + if ( !h->renderStereoOutputInsteadOfBinaural ) + { + idx = min( bin, MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS - 1 ); + /* Apply target spectrum that emphasizes low frequencies when the sound is surround coherent */ + diffEne *= ( 1.0f - surCoh ) + surCoh * surCohEne[idx]; + } + } + h->ChEneOut[0][bin] += diffEne; /* Diff ene part*/ + h->ChEneOut[1][bin] += diffEne; + + if ( h->renderStereoOutputInsteadOfBinaural ) + { + /* When rendering stereo, ambience (except for surround coherent sound) has zero ICC. */ + h->ChCrossReOut[bin] += surCoh * diffEne; + } + else /* When rendering binaural, ambience has frequency dependent ICC. */ + { + if ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->sba_mode == SBA_MODE_SPAR && bin < BINAURAL_COHERENCE_DIFFERENCE_BINS ) + { + float diffuseFieldCoherence; + diffuseFieldCoherence = hDirAC->hDiffuseDist->diffuseRatioX[subframe][bin] * h->diffuseFieldCoherenceX[bin] + hDirAC->hDiffuseDist->diffuseRatioY[subframe][bin] * h->diffuseFieldCoherenceY[bin] + hDirAC->hDiffuseDist->diffuseRatioZ[subframe][bin] * h->diffuseFieldCoherenceZ[bin]; + h->ChCrossReOut[bin] += ( ( 1.0f - surCoh ) * diffuseFieldCoherence + surCoh ) * diffEne; + } + else + { + h->ChCrossReOut[bin] += ( ( 1.0f - surCoh ) * h->diffuseFieldCoherence[bin] + surCoh ) * diffEne; + } + } + + /* Store parameters for formulating average diffuseness over frame */ + h->frameMeanDiffuseness[bin] += diffEne; + frameMeanDiffusenessEneWeight[bin] += meanEnePerCh; + } + + /* Formulate average diffuseness over frame */ + for ( bin = 0; bin < nBins; bin++ ) + { + h->frameMeanDiffuseness[bin] /= fmaxf( 1e-12f, frameMeanDiffusenessEneWeight[bin] ); + } + + /* Determine encoding quality based additional smoothing factor */ + qualityBasedSmFactor = 1.0f; + if ( st_ivas->hMasa != NULL ) + { + qualityBasedSmFactor = st_ivas->hMasa->data.dir_decode_quality; + qualityBasedSmFactor *= qualityBasedSmFactor; + } + + /* Temporal IIR-type smoothing of covariance matrices */ + if ( st_ivas->ivas_format == MASA_FORMAT && st_ivas->hDecoderConfig->ivas_total_brate < MASA_STEREO_MIN_BITRATE ) + { + IIReneLimiterFactor = 16.0f + ( 1.0f - qualityBasedSmFactor ); + } + else + { + IIReneLimiterFactor = 8.0f + ( 1.0f - qualityBasedSmFactor ); + } + for ( bin = 0; bin < nBins; bin++ ) + { + float eneRatio, IIReneLimiter; + + /* Temporally smooth cov mtx estimates for resulting mixing matrix stability. The design principle is that + * the energy history (IIR) must not be more than double of the current frame energy. This provides more + * robust performance at energy offsets when compared to typical IIR averaging. */ + eneRatio = ( h->ChEne[0][bin] + h->ChEne[1][bin] ) / fmaxf( 1e-12f, ( h->ChEnePrev[0][bin] + h->ChEnePrev[1][bin] ) ); + IIReneLimiter = fminf( 1.0f, eneRatio * IIReneLimiterFactor ); - return; -} + h->ChCrossRe[bin] *= qualityBasedSmFactor; + h->ChCrossIm[bin] *= qualityBasedSmFactor; + h->ChCrossReOut[bin] *= qualityBasedSmFactor; + h->ChCrossImOut[bin] *= qualityBasedSmFactor; + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + h->ChEne[ch][bin] *= qualityBasedSmFactor; + h->ChEneOut[ch][bin] *= qualityBasedSmFactor; + } -static void ivas_dirac_dec_decorrelate_slot( - DIRAC_DEC_HANDLE hDirAC, - const int8_t slot, - float inRe[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - float inIm[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - float decRe[][CLDFB_NO_CHANNELS_MAX], - float decIm[][CLDFB_NO_CHANNELS_MAX] ) -{ - int16_t offset, ch, bin; - float onset_filter[BINAURAL_CHANNELS * CLDFB_NO_CHANNELS_MAX]; /* 2 ch, 60 bins */ - float decorrelatedFrameInterleaved[2 * BINAURAL_CHANNELS * CLDFB_NO_CHANNELS_MAX]; /* 2 ch, real + imag, 60 bins */ + h->ChCrossRe[bin] += IIReneLimiter * h->ChCrossRePrev[bin]; + h->ChCrossIm[bin] += IIReneLimiter * h->ChCrossImPrev[bin]; + h->ChCrossReOut[bin] += IIReneLimiter * h->ChCrossReOutPrev[bin]; + h->ChCrossImOut[bin] += IIReneLimiter * h->ChCrossImOutPrev[bin]; - /* Decorrelation needs interleaved data. Copy left and right signals to proto_frame_f */ - for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - offset = hDirAC->num_freq_bands * BINAURAL_CHANNELS * ch; - for ( bin = 0; bin < hDirAC->num_freq_bands; bin++ ) + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { - hDirAC->proto_frame_f[( bin * BINAURAL_CHANNELS ) + offset] = inRe[ch][slot][bin]; - hDirAC->proto_frame_f[( bin * BINAURAL_CHANNELS ) + offset + 1] = inIm[ch][slot][bin]; + h->ChEne[ch][bin] += IIReneLimiter * h->ChEnePrev[ch][bin]; + h->ChEneOut[ch][bin] += IIReneLimiter * h->ChEneOutPrev[ch][bin]; } - } - /* Decorrelate proto signal to decorrelatedFrameInterleaved */ - ivas_dirac_dec_decorr_process( hDirAC->num_freq_bands, - hDirAC->num_outputs_diff, - hDirAC->num_protos_diff, - hDirAC->synthesisConf, - BINAURAL_CHANNELS, - hDirAC->proto_frame_f, - hDirAC->num_protos_diff, - hDirAC->proto_index_diff, - decorrelatedFrameInterleaved, - onset_filter, - hDirAC->h_freq_domain_decorr_ap_params, - hDirAC->h_freq_domain_decorr_ap_state ); + /* Store energy values and coefficients for next round */ + h->ChCrossRePrev[bin] = h->ChCrossRe[bin]; + h->ChCrossImPrev[bin] = h->ChCrossIm[bin]; + h->ChCrossReOutPrev[bin] = h->ChCrossReOut[bin]; + h->ChCrossImOutPrev[bin] = h->ChCrossImOut[bin]; - /* De-interleave decorrelated signals*/ - for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - offset = hDirAC->num_freq_bands * BINAURAL_CHANNELS * ch; - for ( bin = 0; bin < hDirAC->num_freq_bands; bin++ ) + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { - decRe[ch][bin] = decorrelatedFrameInterleaved[( bin * BINAURAL_CHANNELS ) + offset]; - decIm[ch][bin] = decorrelatedFrameInterleaved[( bin * BINAURAL_CHANNELS ) + offset + 1]; + h->ChEnePrev[ch][bin] = h->ChEne[ch][bin]; + h->ChEneOutPrev[ch][bin] = h->ChEneOut[ch][bin]; } } return; } - - +#else static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices( Decoder_Struct *st_ivas, float inRe[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], @@ -1070,6 +1714,7 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric return; } +#endif static void ivas_dirac_dec_binaural_determine_processing_matrices( @@ -1077,7 +1722,11 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices( const int16_t max_band_decorr, float Rmat[3][3] ) { +#ifdef FIX_355_REFACTOR_PARAMBIN_TO_5MS + int16_t chA, chB, bin; +#else uint8_t chA, chB, bin; +#endif uint8_t separateCenterChannelRendering; int16_t nBins; DIRAC_DEC_BIN_HANDLE h; @@ -1240,6 +1889,117 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices( } +#ifdef FIX_355_REFACTOR_PARAMBIN_TO_5MS +static void ivas_dirac_dec_binaural_process_output( + Decoder_Struct *st_ivas, + float output_f[][L_FRAME48k], + float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + const int16_t max_band_decorr, + const int16_t numInChannels, + const int16_t subframe ) +{ + int16_t slot, bin, chA, chB; + int16_t nBins; + float outSlotRe[CLDFB_NO_CHANNELS_MAX], outSlotIm[CLDFB_NO_CHANNELS_MAX]; + float decSlotRe[BINAURAL_CHANNELS][CLDFB_NO_CHANNELS_MAX], decSlotIm[BINAURAL_CHANNELS][CLDFB_NO_CHANNELS_MAX]; + float reverbRe[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + float reverbIm[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + DIRAC_DEC_BIN_HANDLE h; + float interpVal; + float *decSlotRePointer; + float *decSlotImPointer; + int16_t offsetSamples; + + h = st_ivas->hDiracDecBin; + nBins = st_ivas->hDirAC->num_freq_bands; + offsetSamples = subframe * CLDFB_SLOTS_PER_SUBFRAME * nBins; + + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + { + /* Process second / room effect part of binaural output when needed */ + ivas_binaural_reverb_processSubframe( st_ivas->hDiracDecBin->hReverb, numInChannels, inRe, inIm, reverbRe, reverbIm ); + } + + interpVal = 0.0f; + for ( slot = 0; slot < CLDFB_SLOTS_PER_SUBFRAME; slot++ ) + { + interpVal += 1.0f / ( (float) CLDFB_SLOTS_PER_SUBFRAME ); + if ( !st_ivas->hDiracDecBin->useTdDecorr && max_band_decorr > 0 ) + { + ivas_dirac_dec_decorrelate_slot( st_ivas->hDirAC, slot, inRe, inIm, decSlotRe, decSlotIm ); + } + + for ( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) + { + float *outSlotRePr, *outSlotImPr; /* Pointers needed for function call compatibility */ + + set_zero( outSlotRe, CLDFB_NO_CHANNELS_MAX ); + set_zero( outSlotIm, CLDFB_NO_CHANNELS_MAX ); + + /* Processing of the first / HRTF part of the binaural output. */ + for ( chB = 0; chB < numInChannels; chB++ ) + { + if ( st_ivas->hDiracDecBin->useTdDecorr ) + { + decSlotRePointer = inRe[chB + 2][slot]; + decSlotImPointer = inIm[chB + 2][slot]; + } + else + { + decSlotRePointer = decSlotRe[chB]; + decSlotImPointer = decSlotIm[chB]; + } + + for ( bin = 0; bin < nBins; bin++ ) + { + float gain; + + /* Mixing using the formulated processing matrix M */ + gain = ( 1.0f - interpVal ) * h->processMtxRePrev[chA][chB][bin] + + interpVal * h->processMtxRe[chA][chB][bin]; + outSlotRe[bin] += gain * inRe[chB][slot][bin]; + outSlotIm[bin] += gain * inIm[chB][slot][bin]; + + gain = ( 1.0f - interpVal ) * h->processMtxImPrev[chA][chB][bin] + + interpVal * h->processMtxIm[chA][chB][bin]; + outSlotRe[bin] -= gain * inIm[chB][slot][bin]; + outSlotIm[bin] += gain * inRe[chB][slot][bin]; + + /* Mixing decorrelated signals using the formulated residual processing matrix Mdec */ + if ( bin < max_band_decorr && chB < 2 ) + { + gain = ( 1.0f - interpVal ) * h->processMtxDecRePrev[chA][chB][bin] + + interpVal * h->processMtxDecRe[chA][chB][bin]; + outSlotRe[bin] += gain * decSlotRePointer[bin]; + outSlotIm[bin] += gain * decSlotImPointer[bin]; + + gain = ( 1.0f - interpVal ) * h->processMtxDecImPrev[chA][chB][bin] + + interpVal * h->processMtxDecIm[chA][chB][bin]; + outSlotRe[bin] -= gain * decSlotImPointer[bin]; + outSlotIm[bin] += gain * decSlotRePointer[bin]; + } + } + } + + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + { + /* Combine second (reverb) part with the first (HRTF) part to obtain binaural output signal with room effect */ + v_add( outSlotRe, reverbRe[chA][slot], outSlotRe, CLDFB_NO_CHANNELS_MAX ); + v_add( outSlotIm, reverbIm[chA][slot], outSlotIm, CLDFB_NO_CHANNELS_MAX ); + } + + outSlotRePr = &( outSlotRe[0] ); + outSlotImPr = &( outSlotIm[0] ); + + /* Inverse filter bank */ + cldfbSynthesis( &outSlotRePr, &outSlotImPr, &( output_f[chA][nBins * slot + offsetSamples] ), nBins, st_ivas->cldfbSynDec[chA] ); + } + } + + return; +} +#else static void ivas_dirac_dec_binaural_process_output( Decoder_Struct *st_ivas, float output_f[][L_FRAME48k], @@ -1350,8 +2110,124 @@ static void ivas_dirac_dec_binaural_process_output( return; } +#endif + + +#ifdef FIX_355_REFACTOR_PARAMBIN_TO_5MS +static void adaptTransportSignalsHeadtracked( + HEAD_TRACK_DATA_HANDLE hHeadTrackData, + float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + const int16_t nBins, + float Rmat[3][3] ) +{ + int16_t slot, ch, bin, louderCh; + float ILD, mono_factor_ILD, mono_factor_rotation, mono_factor, y_val, ene_proc, ene_target; + int16_t max_band; + float eqVal; + int16_t band_idx, bin_lo, bin_hi; + + /* Determine head-orientation-based mono factor. + Rmat[1][1] entry informs how close the ears are aligned according to transport signals. */ + y_val = 1.0f - fabsf( Rmat[1][1] ); + mono_factor_rotation = ( y_val - ADAPT_HTPROTO_ROT_LIM_0 ) / ( ADAPT_HTPROTO_ROT_LIM_1 - ADAPT_HTPROTO_ROT_LIM_0 ); + mono_factor_rotation = fmaxf( 0.0f, fminf( 1.0f, mono_factor_rotation ) ); + + /* Adapt transport signals in frequency bands */ + /* optimization grouping CLDFB bins into MASA bands (they are readily available in ROM and suitable for the task) AND group CLDFB slots into sub-frames */ + + max_band = 0; + while ( max_band < MASA_FREQUENCY_BANDS && MASA_band_grouping_24[max_band] < nBins ) + { + max_band++; + } + + for ( band_idx = 0; band_idx < max_band; band_idx++ ) + { + float ch_nrg[2]; /* storage for input signal channel energies */ + bin_lo = MASA_band_grouping_24[band_idx]; + bin_hi = min( MASA_band_grouping_24[band_idx + 1], (int16_t) nBins ); + for ( ch = 0; ch < 2; ch++ ) + { + ch_nrg[ch] = 0.0f; + for ( slot = 0; slot < CLDFB_SLOTS_PER_SUBFRAME; slot++ ) + { + for ( bin = bin_lo; bin < bin_hi; bin++ ) + { + ch_nrg[ch] += ( inRe[ch][slot][bin] * inRe[ch][slot][bin] ) + ( inIm[ch][slot][bin] * inIm[ch][slot][bin] ); + } + } + hHeadTrackData->chEneIIR[ch][band_idx] *= ADAPT_HTPROTO_IIR_FAC; + hHeadTrackData->chEneIIR[ch][band_idx] += ( 1.0f - ADAPT_HTPROTO_IIR_FAC ) * ch_nrg[ch]; + } + + /* Determine ILD */ + ILD = fabsf( 10.0f * log10f( fmaxf( 1e-12f, hHeadTrackData->chEneIIR[0][band_idx] ) / fmaxf( 1e-12f, hHeadTrackData->chEneIIR[1][band_idx] ) ) ); + if ( hHeadTrackData->chEneIIR[1][band_idx] > hHeadTrackData->chEneIIR[0][band_idx] ) + { + louderCh = 1; + } + else + { + louderCh = 0; + } + + /* Determine ILD-based mono factor */ + mono_factor_ILD = ( ILD - ADAPT_HTPROTO_ILD_LIM_DB0 ) / ( ADAPT_HTPROTO_ILD_LIM_DB1 - ADAPT_HTPROTO_ILD_LIM_DB0 ); + mono_factor_ILD = fmaxf( 0.0f, fminf( 1.0f, mono_factor_ILD ) ); + + /* Combine mono factors */ + mono_factor = mono_factor_ILD * mono_factor_rotation; + + /* Mix original audio and sum signal according to determined mono factor */ + for ( ch = 0; ch < 2; ch++ ) + { + if ( ch != louderCh ) + { + float band_nrg = 0.0f; + + for ( slot = 0; slot < CLDFB_SLOTS_PER_SUBFRAME; slot++ ) + { + for ( bin = bin_lo; bin < bin_hi; bin++ ) + { + /* mono sum signal with the computed weight + rest from the original channel */ + inRe[ch][slot][bin] = mono_factor * ( inRe[0][slot][bin] + inRe[1][slot][bin] ) + ( 1.0f - mono_factor ) * inRe[ch][slot][bin]; + inIm[ch][slot][bin] = mono_factor * ( inIm[0][slot][bin] + inIm[1][slot][bin] ) + ( 1.0f - mono_factor ) * inIm[ch][slot][bin]; + band_nrg += ( inRe[ch][slot][bin] * inRe[ch][slot][bin] ) + ( inIm[ch][slot][bin] * inIm[ch][slot][bin] ); + } + } + hHeadTrackData->procChEneIIR[ch][band_idx] *= ADAPT_HTPROTO_IIR_FAC; + hHeadTrackData->procChEneIIR[ch][band_idx] += ( 1.0f - ADAPT_HTPROTO_IIR_FAC ) * band_nrg; + } + else + { + /* processed signal is input. use the original channel, so no need to compute new signals or signal energy */ + hHeadTrackData->procChEneIIR[ch][band_idx] *= ADAPT_HTPROTO_IIR_FAC; + hHeadTrackData->procChEneIIR[ch][band_idx] += ( 1.0f - ADAPT_HTPROTO_IIR_FAC ) * ch_nrg[ch]; + } + } + /* Equalize */ + ene_target = hHeadTrackData->chEneIIR[0][band_idx] + hHeadTrackData->chEneIIR[1][band_idx]; + ene_proc = hHeadTrackData->procChEneIIR[0][band_idx] + hHeadTrackData->procChEneIIR[1][band_idx]; + eqVal = fminf( 4.0f, sqrtf( ene_target / fmaxf( 1e-12f, ene_proc ) ) ); + + for ( slot = 0; slot < CLDFB_SLOTS_PER_SUBFRAME; slot++ ) + { + for ( ch = 0; ch < 2; ch++ ) + { + for ( bin = bin_lo; bin < bin_hi; bin++ ) + { + inRe[ch][slot][bin] *= eqVal; + inIm[ch][slot][bin] *= eqVal; + } + } + } + } + return; +} +#else static void adaptTransportSignalsHeadtracked( HEAD_TRACK_DATA_HANDLE hHeadTrackData, float inIm[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], @@ -1478,8 +2354,18 @@ static void adaptTransportSignalsHeadtracked( return; } +#endif - +#ifdef FIX_355_REFACTOR_PARAMBIN_TO_5MS +static void ivas_dirac_dec_binaural_check_and_switch_transports_headtracked( + HEAD_TRACK_DATA_HANDLE hHeadTrackData, + float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + const int16_t nBins, + float Rmat[3][3] ) +{ + int16_t slot, bin, ch; +#else static void ivas_dirac_dec_binaural_check_and_switch_transports_headtracked( HEAD_TRACK_DATA_HANDLE hHeadTrackData, float inIm[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], @@ -1490,6 +2376,7 @@ static void ivas_dirac_dec_binaural_check_and_switch_transports_headtracked( float Rmat[3][3] ) { uint8_t slot, bin, ch; +#endif float tmpVal; /* When not currently in prototype signal left-right switching procedure, check if such switching is needed */ @@ -1509,7 +2396,11 @@ static void ivas_dirac_dec_binaural_check_and_switch_transports_headtracked( /* When currently in interpolation */ if ( hHeadTrackData->lrSwitchedNext != hHeadTrackData->lrSwitchedCurrent ) { +#ifdef FIX_355_REFACTOR_PARAMBIN_TO_5MS + for ( slot = 0; slot < CLDFB_SLOTS_PER_SUBFRAME; slot++ ) +#else for ( slot = firstSlot; slot < slotEnd; slot++ ) +#endif { float switchOrderFactor, origOrderFactor; @@ -1565,7 +2456,11 @@ static void ivas_dirac_dec_binaural_check_and_switch_transports_headtracked( /* If not in interpolation, but in switched prototype situation, then switch left and right channels */ if ( hHeadTrackData->lrSwitchedCurrent == 1 ) { +#ifdef FIX_355_REFACTOR_PARAMBIN_TO_5MS + for ( slot = 0; slot < CLDFB_SLOTS_PER_SUBFRAME; slot++ ) +#else for ( slot = firstSlot; slot < slotEnd; slot++ ) +#endif { for ( bin = 0; bin < nBins; bin++ ) { diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 7713dbe1a3..36e0c04fee 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -136,6 +136,14 @@ void efap_determine_gains( * SBA rendering *----------------------------------------------------------------------------------*/ +#ifdef FIX_355_REFACTOR_PARAMBIN_TO_5MS +void ivas_sba_prototype_renderer( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ + float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, real */ + float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, imag */ + const int16_t subframe /* i : Subframe to render */ +); +#else void ivas_sba_prototype_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ float inRe[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, real */ @@ -143,6 +151,7 @@ void ivas_sba_prototype_renderer( const int16_t firstSubframe, /* i : First subframe to map */ const int16_t nSubframes /* i : Number of subframes to map */ ); +#endif ivas_error ivas_sba_get_hoa_dec_matrix( const IVAS_OUTPUT_SETUP hOutSetup, /* i : target output setup */ @@ -542,6 +551,16 @@ void ivas_binaural_reverb_close( REVERB_STRUCT_HANDLE *hReverb /* i/o: binaural reverb handle */ ); +#ifdef FIX_355_REFACTOR_PARAMBIN_TO_5MS +void ivas_binaural_reverb_processSubframe( + REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */ + const int16_t numInChannels, /* i : num input channels to be processed */ + float inReal[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : input CLDFB data real */ + float inImag[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : input CLDFB data imag */ + float outReal[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* o : output CLDFB data real */ + float outImag[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /* o : output CLDFB data imag */ +); +#else void ivas_binaural_reverb_processFrame( REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */ const int16_t numInChannels, /* i : num input channels to be processed */ @@ -550,7 +569,7 @@ void ivas_binaural_reverb_processFrame( float outReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : output CLDFB data real */ float outImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : output CLDFB data imag */ const uint8_t offsetSamplesIO /* i : number of offset samples */ -); +#endif ivas_error ivas_reverb_open( REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */ diff --git a/lib_rend/ivas_reverb.c b/lib_rend/ivas_reverb.c index 65a7c60ed9..af2717cc11 100644 --- a/lib_rend/ivas_reverb.c +++ b/lib_rend/ivas_reverb.c @@ -1616,6 +1616,16 @@ ivas_error ivas_reverb_process( * Compute the reverberation - room effect *------------------------------------------------------------------------*/ +#ifdef FIX_355_REFACTOR_PARAMBIN_TO_5MS +void ivas_binaural_reverb_processSubframe( + REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */ + const int16_t numInChannels, /* i : num inputs to be processed */ + float inReal[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : input CLDFB data real, Comment: This change swaps two first dimensions as first dimension is not constant. */ + float inImag[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : input CLDFB data imag */ + float outReal[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* o : output CLDFB data real */ + float outImag[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /* o : output CLDFB data imag */ +) +#else void ivas_binaural_reverb_processFrame( REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */ const int16_t numInChannels, /* i : num inputs to be processed */ @@ -1625,6 +1635,7 @@ void ivas_binaural_reverb_processFrame( float outImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : output CLDFB data imag */ const uint8_t offsetSamplesIO /* i : number of offset samples */ ) +#endif { /* Declare the required variables */ int16_t idx, bin, ch, sample, invertSampleIndex, tapIdx, *phaseShiftTypePr; @@ -1650,8 +1661,10 @@ void ivas_binaural_reverb_processFrame( idx = hReverb->preDelayBufferIndex; for ( sample = 0; sample < hReverb->blockSize; sample++ ) { +#ifndef FIX_355_REFACTOR_PARAMBIN_TO_5MS uint16_t sampleWithOffset; sampleWithOffset = sample + offsetSamplesIO; +#endif invertSampleIndex = hReverb->blockSize - sample - 1; for ( bin = 0; bin < hReverb->numBins; bin++ ) { @@ -1665,6 +1678,23 @@ void ivas_binaural_reverb_processFrame( /* Add every second input channel as is to the pre-delay buffer, and every second input channel with * 90 degrees phase shift to reduce energy imbalances between coherent and incoherent sounds */ +#ifdef FIX_355_REFACTOR_PARAMBIN_TO_5MS + for ( ch = 0; ch < numInChannels; ch++ ) + { + if ( ch % 2 ) + { + v_add( hReverb->preDelayBufferReal[idx], inReal[ch][sample], hReverb->preDelayBufferReal[idx], hReverb->numBins ); + v_add( hReverb->preDelayBufferImag[idx], inImag[ch][sample], hReverb->preDelayBufferImag[idx], hReverb->numBins ); + } + else + { + v_sub( hReverb->preDelayBufferReal[idx], inImag[ch][sample], hReverb->preDelayBufferReal[idx], hReverb->numBins ); + v_add( hReverb->preDelayBufferImag[idx], inReal[ch][sample], hReverb->preDelayBufferImag[idx], hReverb->numBins ); + } + } + idx = ( idx + 1 ) % hReverb->preDelayBufferLength; + } +#else for ( ch = 0; ch < numInChannels; ch++ ) { if ( ch % 2 ) @@ -1680,6 +1710,7 @@ void ivas_binaural_reverb_processFrame( } idx = ( idx + 1 ) % hReverb->preDelayBufferLength; } +#endif hReverb->preDelayBufferIndex = idx; /* 3) Perform the filtering/decorrelating, using complex and sparse FIR filtering */ @@ -1749,12 +1780,26 @@ void ivas_binaural_reverb_processFrame( { for ( sample = 0; sample < hReverb->blockSize; sample++ ) { +#ifndef FIX_355_REFACTOR_PARAMBIN_TO_5MS uint16_t sampleWithOffset; sampleWithOffset = sample + offsetSamplesIO; +#endif /* Audio was in the temporally inverted order for convolution, re-invert audio to output */ invertSampleIndex = hReverb->blockSize - sample - 1; +#ifdef FIX_355_REFACTOR_PARAMBIN_TO_5MS + for ( bin = 0; bin < hReverb->numBins; bin++ ) + { + outReal[ch][sample][bin] = hReverb->outputBufferReal[bin][ch][invertSampleIndex]; + outImag[ch][sample][bin] = hReverb->outputBufferImag[bin][ch][invertSampleIndex]; + } + for ( ; bin < CLDFB_NO_CHANNELS_MAX; bin++ ) + { + outReal[ch][sample][bin] = 0.0f; + outImag[ch][sample][bin] = 0.0f; + } +#else for ( bin = 0; bin < hReverb->numBins; bin++ ) { outReal[ch][sampleWithOffset][bin] = hReverb->outputBufferReal[bin][ch][invertSampleIndex]; @@ -1765,6 +1810,7 @@ void ivas_binaural_reverb_processFrame( outReal[ch][sampleWithOffset][bin] = 0.0f; outImag[ch][sampleWithOffset][bin] = 0.0f; } +#endif } } diff --git a/lib_rend/ivas_sba_rendering.c b/lib_rend/ivas_sba_rendering.c index 8fd10d83ba..f59df117b4 100644 --- a/lib_rend/ivas_sba_rendering.c +++ b/lib_rend/ivas_sba_rendering.c @@ -50,6 +50,14 @@ * Render prototype audio signals using SBA mixing matrices *-------------------------------------------------------------------*/ +#ifdef FIX_355_REFACTOR_PARAMBIN_TO_5MS +void ivas_sba_prototype_renderer( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ + float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, real */ + float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, imag */ + const int16_t subframe /* i : Subframe to render */ +) +#else void ivas_sba_prototype_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ float inRe[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, real */ @@ -57,6 +65,7 @@ void ivas_sba_prototype_renderer( const int16_t firstSubframe, /* i : First subframe to map */ const int16_t nSubframes /* i : Number of subframes to map */ ) +#endif { float mixer_mat[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS]; SPAR_DEC_HANDLE hSpar; @@ -66,8 +75,12 @@ void ivas_sba_prototype_renderer( int16_t num_cldfb_bands, numch_in, numch_out; int16_t cldfb_band; int16_t out_ch, in_ch; +#ifdef FIX_355_REFACTOR_PARAMBIN_TO_5MS + int16_t firstInCh, inChEnd, firstOutCh, outChEnd; +#else int16_t firstSlot, slotEnd, firstInCh, inChEnd, firstOutCh, outChEnd; int16_t sf_idx; +#endif push_wmops( "ivas_sba_prototype_renderer" ); @@ -75,9 +88,10 @@ void ivas_sba_prototype_renderer( hDecoderConfig = st_ivas->hDecoderConfig; num_spar_bands = hSpar->hFbMixer->pFb->filterbank_num_bands; +#ifndef FIX_355_REFACTOR_PARAMBIN_TO_5MS firstSlot = firstSubframe * ( CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES ); slotEnd = ( firstSubframe + nSubframes ) * ( CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES ); - +#endif num_cldfb_bands = hSpar->hFbMixer->pFb->fb_bin_to_band.num_cldfb_bands; numch_in = hSpar->hFbMixer->fb_cfg->num_in_chans; numch_out = hSpar->hFbMixer->fb_cfg->num_out_chans; @@ -98,6 +112,74 @@ void ivas_sba_prototype_renderer( } /* Apply mixing matrix */ +#ifdef FIX_355_REFACTOR_PARAMBIN_TO_5MS + for ( ts = 0; ts < CLDFB_SLOTS_PER_SUBFRAME; ts++ ) + { + /* determine SPAR parameters for this time slot */ + ivas_spar_get_parameters( hSpar, hDecoderConfig, ts + subframe * CLDFB_SLOTS_PER_SUBFRAME, numch_out, numch_in, num_spar_bands, mixer_mat ); + + for ( cldfb_band = 0; cldfb_band < num_cldfb_bands; cldfb_band++ ) + { + float out_re[IVAS_SPAR_MAX_CH]; + float out_im[IVAS_SPAR_MAX_CH]; + float cldfb_par; + ivas_fb_bin_to_band_data_t *bin2band = &hSpar->hFbMixer->pFb->fb_bin_to_band; + + for ( out_ch = firstOutCh; out_ch < outChEnd; out_ch++ ) + { + out_re[out_ch] = 0.0f; + out_im[out_ch] = 0.0f; + + for ( in_ch = firstInCh; in_ch < inChEnd; in_ch++ ) + { + if ( cldfb_band < CLDFB_PAR_WEIGHT_START_BAND ) /* tuning parameter, depends on how much SPAR Filters overlap for the CLDFB bands */ + { + spar_band = bin2band->p_cldfb_map_to_spar_band[cldfb_band]; + cldfb_par = mixer_mat[out_ch][in_ch][spar_band]; + } + else + { + cldfb_par = 0.0f; + for ( spar_band = bin2band->p_spar_start_bands[cldfb_band]; spar_band < num_spar_bands; spar_band++ ) + { + /* accumulate contributions from all SPAR bands */ + cldfb_par += mixer_mat[out_ch][in_ch][spar_band] * bin2band->pp_cldfb_weights_per_spar_band[cldfb_band][spar_band]; + } + } + + out_re[out_ch] += inRe[in_ch][ts][cldfb_band] * cldfb_par; + out_im[out_ch] += inIm[in_ch][ts][cldfb_band] * cldfb_par; + } + } + + /*update CLDFB data with the parameter-modified data*/ + for ( out_ch = firstOutCh; out_ch < outChEnd; out_ch++ ) + { + inRe[out_ch][ts][cldfb_band] = out_re[out_ch]; + inIm[out_ch][ts][cldfb_band] = out_im[out_ch]; + } + } + } + + /* Update mixing matrices */ + hSpar->i_subframe++; + hSpar->i_subframe = min( hSpar->i_subframe, MAX_PARAM_SPATIAL_SUBFRAMES ); + mvr2r( hSpar->hMdDec->mixer_mat_prev[1][0][0], hSpar->hMdDec->mixer_mat_prev[0][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); + mvr2r( hSpar->hMdDec->mixer_mat_prev[2][0][0], hSpar->hMdDec->mixer_mat_prev[1][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); + mvr2r( hSpar->hMdDec->mixer_mat_prev[3][0][0], hSpar->hMdDec->mixer_mat_prev[2][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); + mvr2r( hSpar->hMdDec->mixer_mat_prev[4][0][0], hSpar->hMdDec->mixer_mat_prev[3][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); + + for ( out_ch = 0; out_ch < numch_out; out_ch++ ) + { + for ( in_ch = 0; in_ch < numch_in; in_ch++ ) + { + for ( b = 0; b < num_spar_bands; b++ ) + { + hSpar->hMdDec->mixer_mat_prev[4][out_ch][in_ch][b] = hSpar->hMdDec->mixer_mat[out_ch][in_ch][b + subframe * IVAS_MAX_NUM_BANDS]; + } + } + } +#else for ( ts = firstSlot; ts < slotEnd; ts++ ) { /* determine SPAR parameters for this time slot */ @@ -168,11 +250,16 @@ void ivas_sba_prototype_renderer( } } } +#endif /* Create prototypes */ if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) { +#ifdef FIX_355_REFACTOR_PARAMBIN_TO_5MS + for ( ts = 0; ts < CLDFB_SLOTS_PER_SUBFRAME; ts++ ) +#else for ( ts = firstSlot; ts < slotEnd; ts++ ) +#endif { if ( st_ivas->nchan_transport == 1 ) /* Dual mono */ { -- GitLab From 4d1a4ca725920b6c4d276a1cab98e0d16e30b7b7 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Mon, 8 May 2023 10:57:35 +0200 Subject: [PATCH 2/2] [fix] compilation with switch disabled --- lib_com/ivas_prot.h | 1 + lib_rend/ivas_prot_rend.h | 1 + 2 files changed, 2 insertions(+) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 9138455fe7..370d440f08 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -4705,6 +4705,7 @@ void ivas_spar_param_to_masa_param_mapping( float inIm[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, imag */ const int16_t firstSubframe, /* i : First subframe to map */ const int16_t nSubframes /* i : Number of subframes to map */ +); #endif diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 36e0c04fee..efa2111243 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -569,6 +569,7 @@ void ivas_binaural_reverb_processFrame( float outReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : output CLDFB data real */ float outImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : output CLDFB data imag */ const uint8_t offsetSamplesIO /* i : number of offset samples */ +); #endif ivas_error ivas_reverb_open( -- GitLab