Loading lib_com/options.h +2 −0 Original line number Diff line number Diff line Loading @@ -151,6 +151,8 @@ #define FIX_382_MASA_META_FRAMING_ASYNC /* Nokia: Issue 382: detect potential MASA metadata framing offset */ #define SBA_PARABIN_FOAMODE /* Nokia: FOAmode for parametric binauralizer for making FOA-sounding output */ /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ #endif lib_dec/ivas_dec.c +13 −1 Original line number Diff line number Diff line Loading @@ -389,8 +389,20 @@ ivas_error ivas_dec( } else if ( st_ivas->ivas_format == SBA_FORMAT && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) { float gain = 0.8414f; /* Todo: Temporary gain for roughly matching the loudness. To be tuned later together with other outputs. */ #ifdef SBA_PARABIN_FOAMODE float gain; if ( nchan_remapped == 1 ) { gain = 1.4454f; } else { gain = 1.3657f; } #else float gain = 0.8414f; /* Todo: Temporary gain for roughly matching the loudness. To be tuned later together with other outputs. */ #endif for ( n = 0; n < nchan_remapped; n++ ) { v_multc( output[n], gain, output[n], output_frame ); Loading lib_rend/ivas_dirac_dec_binaural_functions.c +74 −8 Original line number Diff line number Diff line Loading @@ -72,9 +72,15 @@ static void ivas_dirac_dec_binaural_check_and_switch_transports_headtracked( HEA 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 ); #ifdef SBA_PARABIN_FOAMODE static void hrtfShGetHrtf( const int16_t bin, const int16_t aziDeg, const int16_t eleDeg, float *lRealp, float *lImagp, float *rRealp, float *rImagp, uint8_t foamode ); static void getDirectPartGains( const int16_t bin, int16_t aziDeg, int16_t eleDeg, float *lRealp, float *lImagp, float *rRealp, float *rImagp, const uint8_t stereoMode, float Rmat[3][3], uint8_t foamode ); #else static void hrtfShGetHrtf( const int16_t bin, const int16_t aziDeg, const int16_t eleDeg, float *lRealp, float *lImagp, float *rRealp, float *rImagp ); static void getDirectPartGains( const int16_t bin, int16_t aziDeg, int16_t eleDeg, float *lRealp, float *lImagp, float *rRealp, float *rImagp, const uint8_t stereoMode, float Rmat[3][3] ); #endif static void matrixMul( float Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Aim[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Bre[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Bim[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float outRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float outIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS] ); Loading Loading @@ -170,6 +176,12 @@ ivas_error ivas_dirac_dec_init_binaural_data( /* These formulas and values are from Christian Borss's publication for binaural diffuse field coherence */ tmpFloat = max( 0.0f, 1.0f - binCenterFreq / 2700.0f ); hBinaural->diffuseFieldCoherence[bin] = tmpFloat * sinf( binCenterFreq * EVS_PI / 550.0f ) / ( binCenterFreq * EVS_PI / 550.0f ); #ifdef SBA_PARABIN_FOAMODE if ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->sba_order == 1 && st_ivas->transport_config == AUDIO_CONFIG_FOA ) { hBinaural->diffuseFieldCoherence[bin] = max( hBinaural->diffuseFieldCoherence[bin], 0.3f ) ; /* For FOA input, render output with FOA-like spatial impression */ } #endif } for ( bin = 0; bin < BINAURAL_COHERENCE_DIFFERENCE_BINS; bin++ ) Loading Loading @@ -647,11 +659,21 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric float lowBitRateEQ[CLDFB_NO_CHANNELS_MAX]; uint8_t applyLowBitRateEQ; int16_t dirac_read_idx; #ifdef SBA_PARABIN_FOAMODE uint8_t foamode; #endif hDirAC = st_ivas->hDirAC; h = st_ivas->hDiracDecBin; separateCenterChannelRendering = st_ivas->hOutSetup.separateChannelEnabled; nBins = hDirAC->num_freq_bands; /* Actually bins */ #ifdef SBA_PARABIN_FOAMODE foamode = 0; if ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->sba_order == 1 && st_ivas->transport_config == AUDIO_CONFIG_FOA ) { foamode = 1; /* For FOA input, render output with FOA-like spatial impression */ } #endif set_zero( h->ChCrossRe, nBins ); set_zero( h->ChCrossIm, nBins ); Loading Loading @@ -804,9 +826,11 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric altSpreadCoh = 1.0f - ( spatialAngleDeg / 30.0f ); spreadCoh = max( spreadCoh, altSpreadCoh ); } #ifdef SBA_PARABIN_FOAMODE getDirectPartGains( bin, aziDeg, eleDeg, &lRealp, &lImagp, &rRealp, &rImagp, h->renderStereoOutputInsteadOfBinaural, Rmat, foamode ); #else getDirectPartGains( bin, aziDeg, eleDeg, &lRealp, &lImagp, &rRealp, &rImagp, h->renderStereoOutputInsteadOfBinaural, Rmat ); #endif if ( h->renderStereoOutputInsteadOfBinaural ) { /* Synthesizing spread coherence is not needed for stereo loudspeaker output, Loading Loading @@ -848,8 +872,11 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric rImagp *= centerMul; /* Apply the gain for the left source of the three coherent sources */ #ifdef SBA_PARABIN_FOAMODE getDirectPartGains( bin, aziDeg + 30, eleDeg, &lRealpTmp, &lImagpTmp, &rRealpTmp, &rImagpTmp, h->renderStereoOutputInsteadOfBinaural, Rmat, 0 ); #else getDirectPartGains( bin, aziDeg + 30, eleDeg, &lRealpTmp, &lImagpTmp, &rRealpTmp, &rImagpTmp, h->renderStereoOutputInsteadOfBinaural, Rmat ); #endif hrtfEneSides = ( lRealpTmp * lRealpTmp ) + ( lImagpTmp * lImagpTmp ) + ( rRealpTmp * rRealpTmp ) + ( rImagpTmp * rImagpTmp ); lRealp += sidesMul * lRealpTmp; lImagp += sidesMul * lImagpTmp; Loading @@ -858,8 +885,11 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric /* Apply the gain for the right source of the three coherent sources. * -30 degrees to 330 wrapping due to internal functions. */ #ifdef SBA_PARABIN_FOAMODE getDirectPartGains( bin, aziDeg + 330, eleDeg, &lRealpTmp, &lImagpTmp, &rRealpTmp, &rImagpTmp, h->renderStereoOutputInsteadOfBinaural, Rmat, 0 ); #else getDirectPartGains( bin, aziDeg + 330, eleDeg, &lRealpTmp, &lImagpTmp, &rRealpTmp, &rImagpTmp, h->renderStereoOutputInsteadOfBinaural, Rmat ); #endif hrtfEneSides += ( lRealpTmp * lRealpTmp ) + ( lImagpTmp * lImagpTmp ) + ( rRealpTmp * rRealpTmp ) + ( rImagpTmp * rImagpTmp ); lRealp += sidesMul * lRealpTmp; lImagp += sidesMul * lImagpTmp; Loading Loading @@ -1192,8 +1222,11 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices( h->processMtxImPrev[chA][2][bin] = h->processMtxIm[chA][2][bin]; } #ifdef SBA_PARABIN_FOAMODE getDirectPartGains( bin, aziDeg, eleDeg, &lRealp, &lImagp, &rRealp, &rImagp, h->renderStereoOutputInsteadOfBinaural, Rmat, 0 ); #else getDirectPartGains( bin, aziDeg, eleDeg, &lRealp, &lImagp, &rRealp, &rImagp, h->renderStereoOutputInsteadOfBinaural, Rmat ); #endif h->processMtxRe[0][2][bin] = lRealp * gainFactor; h->processMtxIm[0][2][bin] = lImagp * gainFactor; h->processMtxRe[1][2][bin] = rRealp * gainFactor; Loading Loading @@ -1772,7 +1805,11 @@ static void getDirectPartGains( float *rRealp, float *rImagp, const uint8_t renderStereoOutputInsteadOfBinaural, float Rmat[3][3] ) float Rmat[3][3] #ifdef SBA_PARABIN_FOAMODE , uint8_t foamode #endif ) { float aziRad, eleRad; float y, mappedX, aziRadMapped, A, A2, A3; Loading Loading @@ -1816,7 +1853,11 @@ static void getDirectPartGains( else /* In regular binaural rendering mode */ { rotateAziEle( (float) aziDeg, (float) eleDeg, &aziDeg, &eleDeg, Rmat, 0 ); #ifdef SBA_PARABIN_FOAMODE hrtfShGetHrtf( bin, aziDeg, eleDeg, lRealp, lImagp, rRealp, rImagp, foamode ); #else hrtfShGetHrtf( bin, aziDeg, eleDeg, lRealp, lImagp, rRealp, rImagp ); #endif } return; Loading @@ -1830,21 +1871,46 @@ static void hrtfShGetHrtf( float *lRealp, float *lImagp, float *rRealp, float *rImagp ) float *rImagp #ifdef SBA_PARABIN_FOAMODE , uint8_t foamode #endif ) { int16_t k; float shVec[HRTF_SH_CHANNELS]; #ifdef SBA_PARABIN_FOAMODE int16_t sh_order; int16_t sh_channels; if ( foamode ) { sh_order = 2; sh_channels = 9; } else { sh_order = HRTF_SH_ORDER; sh_channels = HRTF_SH_CHANNELS; } #endif ivas_dirac_dec_get_response( aziDeg, eleDeg, shVec, #ifdef SBA_PARABIN_FOAMODE sh_order ); #else HRTF_SH_ORDER ); #endif *lRealp = 0.0f; *lImagp = 0.0f; *rRealp = 0.0f; *rImagp = 0.0f; #ifdef SBA_PARABIN_FOAMODE for ( k = 0; k < sh_channels; k++ ) #else for ( k = 0; k < HRTF_SH_CHANNELS; k++ ) #endif { *lRealp += hrtfShCoeffsRe[0][k][bin] * shVec[k]; *lImagp += hrtfShCoeffsIm[0][k][bin] * shVec[k]; Loading Loading
lib_com/options.h +2 −0 Original line number Diff line number Diff line Loading @@ -151,6 +151,8 @@ #define FIX_382_MASA_META_FRAMING_ASYNC /* Nokia: Issue 382: detect potential MASA metadata framing offset */ #define SBA_PARABIN_FOAMODE /* Nokia: FOAmode for parametric binauralizer for making FOA-sounding output */ /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ #endif
lib_dec/ivas_dec.c +13 −1 Original line number Diff line number Diff line Loading @@ -389,8 +389,20 @@ ivas_error ivas_dec( } else if ( st_ivas->ivas_format == SBA_FORMAT && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) { float gain = 0.8414f; /* Todo: Temporary gain for roughly matching the loudness. To be tuned later together with other outputs. */ #ifdef SBA_PARABIN_FOAMODE float gain; if ( nchan_remapped == 1 ) { gain = 1.4454f; } else { gain = 1.3657f; } #else float gain = 0.8414f; /* Todo: Temporary gain for roughly matching the loudness. To be tuned later together with other outputs. */ #endif for ( n = 0; n < nchan_remapped; n++ ) { v_multc( output[n], gain, output[n], output_frame ); Loading
lib_rend/ivas_dirac_dec_binaural_functions.c +74 −8 Original line number Diff line number Diff line Loading @@ -72,9 +72,15 @@ static void ivas_dirac_dec_binaural_check_and_switch_transports_headtracked( HEA 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 ); #ifdef SBA_PARABIN_FOAMODE static void hrtfShGetHrtf( const int16_t bin, const int16_t aziDeg, const int16_t eleDeg, float *lRealp, float *lImagp, float *rRealp, float *rImagp, uint8_t foamode ); static void getDirectPartGains( const int16_t bin, int16_t aziDeg, int16_t eleDeg, float *lRealp, float *lImagp, float *rRealp, float *rImagp, const uint8_t stereoMode, float Rmat[3][3], uint8_t foamode ); #else static void hrtfShGetHrtf( const int16_t bin, const int16_t aziDeg, const int16_t eleDeg, float *lRealp, float *lImagp, float *rRealp, float *rImagp ); static void getDirectPartGains( const int16_t bin, int16_t aziDeg, int16_t eleDeg, float *lRealp, float *lImagp, float *rRealp, float *rImagp, const uint8_t stereoMode, float Rmat[3][3] ); #endif static void matrixMul( float Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Aim[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Bre[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Bim[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float outRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float outIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS] ); Loading Loading @@ -170,6 +176,12 @@ ivas_error ivas_dirac_dec_init_binaural_data( /* These formulas and values are from Christian Borss's publication for binaural diffuse field coherence */ tmpFloat = max( 0.0f, 1.0f - binCenterFreq / 2700.0f ); hBinaural->diffuseFieldCoherence[bin] = tmpFloat * sinf( binCenterFreq * EVS_PI / 550.0f ) / ( binCenterFreq * EVS_PI / 550.0f ); #ifdef SBA_PARABIN_FOAMODE if ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->sba_order == 1 && st_ivas->transport_config == AUDIO_CONFIG_FOA ) { hBinaural->diffuseFieldCoherence[bin] = max( hBinaural->diffuseFieldCoherence[bin], 0.3f ) ; /* For FOA input, render output with FOA-like spatial impression */ } #endif } for ( bin = 0; bin < BINAURAL_COHERENCE_DIFFERENCE_BINS; bin++ ) Loading Loading @@ -647,11 +659,21 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric float lowBitRateEQ[CLDFB_NO_CHANNELS_MAX]; uint8_t applyLowBitRateEQ; int16_t dirac_read_idx; #ifdef SBA_PARABIN_FOAMODE uint8_t foamode; #endif hDirAC = st_ivas->hDirAC; h = st_ivas->hDiracDecBin; separateCenterChannelRendering = st_ivas->hOutSetup.separateChannelEnabled; nBins = hDirAC->num_freq_bands; /* Actually bins */ #ifdef SBA_PARABIN_FOAMODE foamode = 0; if ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->sba_order == 1 && st_ivas->transport_config == AUDIO_CONFIG_FOA ) { foamode = 1; /* For FOA input, render output with FOA-like spatial impression */ } #endif set_zero( h->ChCrossRe, nBins ); set_zero( h->ChCrossIm, nBins ); Loading Loading @@ -804,9 +826,11 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric altSpreadCoh = 1.0f - ( spatialAngleDeg / 30.0f ); spreadCoh = max( spreadCoh, altSpreadCoh ); } #ifdef SBA_PARABIN_FOAMODE getDirectPartGains( bin, aziDeg, eleDeg, &lRealp, &lImagp, &rRealp, &rImagp, h->renderStereoOutputInsteadOfBinaural, Rmat, foamode ); #else getDirectPartGains( bin, aziDeg, eleDeg, &lRealp, &lImagp, &rRealp, &rImagp, h->renderStereoOutputInsteadOfBinaural, Rmat ); #endif if ( h->renderStereoOutputInsteadOfBinaural ) { /* Synthesizing spread coherence is not needed for stereo loudspeaker output, Loading Loading @@ -848,8 +872,11 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric rImagp *= centerMul; /* Apply the gain for the left source of the three coherent sources */ #ifdef SBA_PARABIN_FOAMODE getDirectPartGains( bin, aziDeg + 30, eleDeg, &lRealpTmp, &lImagpTmp, &rRealpTmp, &rImagpTmp, h->renderStereoOutputInsteadOfBinaural, Rmat, 0 ); #else getDirectPartGains( bin, aziDeg + 30, eleDeg, &lRealpTmp, &lImagpTmp, &rRealpTmp, &rImagpTmp, h->renderStereoOutputInsteadOfBinaural, Rmat ); #endif hrtfEneSides = ( lRealpTmp * lRealpTmp ) + ( lImagpTmp * lImagpTmp ) + ( rRealpTmp * rRealpTmp ) + ( rImagpTmp * rImagpTmp ); lRealp += sidesMul * lRealpTmp; lImagp += sidesMul * lImagpTmp; Loading @@ -858,8 +885,11 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric /* Apply the gain for the right source of the three coherent sources. * -30 degrees to 330 wrapping due to internal functions. */ #ifdef SBA_PARABIN_FOAMODE getDirectPartGains( bin, aziDeg + 330, eleDeg, &lRealpTmp, &lImagpTmp, &rRealpTmp, &rImagpTmp, h->renderStereoOutputInsteadOfBinaural, Rmat, 0 ); #else getDirectPartGains( bin, aziDeg + 330, eleDeg, &lRealpTmp, &lImagpTmp, &rRealpTmp, &rImagpTmp, h->renderStereoOutputInsteadOfBinaural, Rmat ); #endif hrtfEneSides += ( lRealpTmp * lRealpTmp ) + ( lImagpTmp * lImagpTmp ) + ( rRealpTmp * rRealpTmp ) + ( rImagpTmp * rImagpTmp ); lRealp += sidesMul * lRealpTmp; lImagp += sidesMul * lImagpTmp; Loading Loading @@ -1192,8 +1222,11 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices( h->processMtxImPrev[chA][2][bin] = h->processMtxIm[chA][2][bin]; } #ifdef SBA_PARABIN_FOAMODE getDirectPartGains( bin, aziDeg, eleDeg, &lRealp, &lImagp, &rRealp, &rImagp, h->renderStereoOutputInsteadOfBinaural, Rmat, 0 ); #else getDirectPartGains( bin, aziDeg, eleDeg, &lRealp, &lImagp, &rRealp, &rImagp, h->renderStereoOutputInsteadOfBinaural, Rmat ); #endif h->processMtxRe[0][2][bin] = lRealp * gainFactor; h->processMtxIm[0][2][bin] = lImagp * gainFactor; h->processMtxRe[1][2][bin] = rRealp * gainFactor; Loading Loading @@ -1772,7 +1805,11 @@ static void getDirectPartGains( float *rRealp, float *rImagp, const uint8_t renderStereoOutputInsteadOfBinaural, float Rmat[3][3] ) float Rmat[3][3] #ifdef SBA_PARABIN_FOAMODE , uint8_t foamode #endif ) { float aziRad, eleRad; float y, mappedX, aziRadMapped, A, A2, A3; Loading Loading @@ -1816,7 +1853,11 @@ static void getDirectPartGains( else /* In regular binaural rendering mode */ { rotateAziEle( (float) aziDeg, (float) eleDeg, &aziDeg, &eleDeg, Rmat, 0 ); #ifdef SBA_PARABIN_FOAMODE hrtfShGetHrtf( bin, aziDeg, eleDeg, lRealp, lImagp, rRealp, rImagp, foamode ); #else hrtfShGetHrtf( bin, aziDeg, eleDeg, lRealp, lImagp, rRealp, rImagp ); #endif } return; Loading @@ -1830,21 +1871,46 @@ static void hrtfShGetHrtf( float *lRealp, float *lImagp, float *rRealp, float *rImagp ) float *rImagp #ifdef SBA_PARABIN_FOAMODE , uint8_t foamode #endif ) { int16_t k; float shVec[HRTF_SH_CHANNELS]; #ifdef SBA_PARABIN_FOAMODE int16_t sh_order; int16_t sh_channels; if ( foamode ) { sh_order = 2; sh_channels = 9; } else { sh_order = HRTF_SH_ORDER; sh_channels = HRTF_SH_CHANNELS; } #endif ivas_dirac_dec_get_response( aziDeg, eleDeg, shVec, #ifdef SBA_PARABIN_FOAMODE sh_order ); #else HRTF_SH_ORDER ); #endif *lRealp = 0.0f; *lImagp = 0.0f; *rRealp = 0.0f; *rImagp = 0.0f; #ifdef SBA_PARABIN_FOAMODE for ( k = 0; k < sh_channels; k++ ) #else for ( k = 0; k < HRTF_SH_CHANNELS; k++ ) #endif { *lRealp += hrtfShCoeffsRe[0][k][bin] * shVec[k]; *lImagp += hrtfShCoeffsIm[0][k][bin] * shVec[k]; Loading