Loading lib_com/options.h +1 −0 Original line number Diff line number Diff line Loading @@ -159,6 +159,7 @@ #endif #define NOKIA_ADAPTIVE_BINAURAL_PROTOS #define NOKIA_ADAPTIVE_BINAURAL_PROTOS_OPT /* enable adaptive binaural prototype complexity optimizations */ /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ Loading lib_rend/ivas_dirac_dec_binaural_functions.c +127 −2 Original line number Diff line number Diff line Loading @@ -40,6 +40,8 @@ #include "ivas_cnst.h" #include "ivas_rom_binauralRenderer.h" #include "ivas_rom_rend.h" #include "ivas_rom_com.h" #ifdef DEBUGGING #include "debug.h" #endif Loading @@ -55,7 +57,13 @@ #define IVAS_TDET_DUCK_MULT_FAC_PARA_BIN_LOW_BR ( 3.0f ) #ifdef NOKIA_ADAPTIVE_BINAURAL_PROTOS #ifdef NOKIA_ADAPTIVE_BINAURAL_PROTOS_OPT /* powf(0.95f, 4.0f) for sub-frame smoothing instead of CLDFB slot */ #define ADAPT_HTPROTO_IIR_FAC 0.81450625f #else #define ADAPT_HTPROTO_IIR_FAC 0.95f #endif #define ADAPT_HTPROTO_ILD_LIM_DB0 1.0f #define ADAPT_HTPROTO_ILD_LIM_DB1 4.0f #define ADAPT_HTPROTO_ROT_LIM_0 0.4f Loading @@ -77,8 +85,12 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices( Decoder_Struc 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 ); #ifdef NOKIA_ADAPTIVE_BINAURAL_PROTOS #ifdef NOKIA_ADAPTIVE_BINAURAL_PROTOS_OPT 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, float Rmat[3][3] ); #else 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] ); #endif #endif 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] ); Loading Loading @@ -575,7 +587,11 @@ static void ivas_dirac_dec_binaural_internal( if ( nchan_transport == 2 ) { #ifdef NOKIA_ADAPTIVE_BINAURAL_PROTOS #ifdef NOKIA_ADAPTIVE_BINAURAL_PROTOS_OPT adaptTransportSignalsHeadtracked( st_ivas->hHeadTrackData, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, firstSlot, slotEnd, Rmat ); #else adaptTransportSignalsHeadtracked( st_ivas->hHeadTrackData, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, firstSlot, slotEnd, nBins, Rmat ); #endif #endif ivas_dirac_dec_binaural_check_and_switch_transports_headtracked( st_ivas->hHeadTrackData, Cldfb_ImagBuffer_in, Cldfb_RealBuffer_in, firstSlot, slotEnd, nBins, Rmat ); Loading Loading @@ -1355,12 +1371,19 @@ static void adaptTransportSignalsHeadtracked( float inRe[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], const uint8_t firstSlot, const uint8_t slotEnd, #ifndef NOKIA_ADAPTIVE_BINAURAL_PROTOS_OPT const uint8_t nBins, #endif float Rmat[3][3] ) { int16_t slot, ch, bin, louderCh; #ifdef NOKIA_ADAPTIVE_BINAURAL_PROTOS_OPT float ILD, mono_factor_ILD, mono_factor_rotation, mono_factor, y_val, ene_proc, ene_target; uint8_t n_slots_per_sf, sf_idx, n_sf; #else float re[2], im[2], ILD, mono_factor_ILD, mono_factor_rotation, mono_factor, y_val; float proc_re[2], proc_im[2], sum_re, sum_im, ene_proc, ene_target, mf; #endif /* Determine head-orientation-based mono factor. Rmat[1][1] entry informs how close the ears are aligned according to transport signals. */ Loading @@ -1369,9 +1392,110 @@ static void adaptTransportSignalsHeadtracked( mono_factor_rotation = fmaxf( 0.0f, fminf( 1.0f, mono_factor_rotation ) ); /* Adapt transport signals in frequency bands */ #ifdef NOKIA_ADAPTIVE_BINAURAL_PROTOS_OPT /* 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 */ n_slots_per_sf = CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; n_sf = ( slotEnd - firstSlot ) / n_slots_per_sf; for ( sf_idx = 0; sf_idx < n_sf; sf_idx++ ) { float eqVal; uint8_t start_slot, stop_slot; int16_t band_idx, bin_lo, bin_hi; start_slot = firstSlot + sf_idx * n_slots_per_sf; stop_slot = start_slot + n_slots_per_sf; for ( band_idx = 0; band_idx < MASA_FREQUENCY_BANDS; band_idx++ ) { float ch_nrg[2]; /* storage for input signal channel energies */ bin_lo = MASA_band_grouping_24[band_idx]; bin_hi = MASA_band_grouping_24[band_idx + 1]; for ( ch = 0; ch < 2; ch++ ) { ch_nrg[ch] = 0.0f; for ( slot = start_slot; slot < stop_slot; 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 = start_slot; slot < stop_slot; 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 = start_slot; slot < stop_slot; 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; } } } } } #else /* original contribution */ for ( slot = firstSlot; slot < slotEnd; slot++ ) { float eqVal[60]; for ( bin = 0; bin < nBins; bin++ ) { /* Determine channel energies */ Loading Loading @@ -1421,6 +1545,7 @@ static void adaptTransportSignalsHeadtracked( } } } #endif return; } Loading lib_rend/ivas_stat_rend.h +5 −0 Original line number Diff line number Diff line Loading @@ -246,8 +246,13 @@ typedef struct ivas_binaural_head_track_struct float lrSwitchInterpVal; #ifdef NOKIA_ADAPTIVE_BINAURAL_PROTOS #ifdef NOKIA_ADAPTIVE_BINAURAL_PROTOS_OPT float chEneIIR[2][MASA_FREQUENCY_BANDS]; /* independent of the format. MASA bands are suitable for the task and readily available in ROM. */ float procChEneIIR[2][MASA_FREQUENCY_BANDS]; #else float chEneIIR[2][CLDFB_NO_CHANNELS_MAX]; float procChEneIIR[2][CLDFB_NO_CHANNELS_MAX]; #endif #endif int16_t shd_rot_max_order; Loading Loading
lib_com/options.h +1 −0 Original line number Diff line number Diff line Loading @@ -159,6 +159,7 @@ #endif #define NOKIA_ADAPTIVE_BINAURAL_PROTOS #define NOKIA_ADAPTIVE_BINAURAL_PROTOS_OPT /* enable adaptive binaural prototype complexity optimizations */ /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ Loading
lib_rend/ivas_dirac_dec_binaural_functions.c +127 −2 Original line number Diff line number Diff line Loading @@ -40,6 +40,8 @@ #include "ivas_cnst.h" #include "ivas_rom_binauralRenderer.h" #include "ivas_rom_rend.h" #include "ivas_rom_com.h" #ifdef DEBUGGING #include "debug.h" #endif Loading @@ -55,7 +57,13 @@ #define IVAS_TDET_DUCK_MULT_FAC_PARA_BIN_LOW_BR ( 3.0f ) #ifdef NOKIA_ADAPTIVE_BINAURAL_PROTOS #ifdef NOKIA_ADAPTIVE_BINAURAL_PROTOS_OPT /* powf(0.95f, 4.0f) for sub-frame smoothing instead of CLDFB slot */ #define ADAPT_HTPROTO_IIR_FAC 0.81450625f #else #define ADAPT_HTPROTO_IIR_FAC 0.95f #endif #define ADAPT_HTPROTO_ILD_LIM_DB0 1.0f #define ADAPT_HTPROTO_ILD_LIM_DB1 4.0f #define ADAPT_HTPROTO_ROT_LIM_0 0.4f Loading @@ -77,8 +85,12 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices( Decoder_Struc 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 ); #ifdef NOKIA_ADAPTIVE_BINAURAL_PROTOS #ifdef NOKIA_ADAPTIVE_BINAURAL_PROTOS_OPT 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, float Rmat[3][3] ); #else 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] ); #endif #endif 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] ); Loading Loading @@ -575,7 +587,11 @@ static void ivas_dirac_dec_binaural_internal( if ( nchan_transport == 2 ) { #ifdef NOKIA_ADAPTIVE_BINAURAL_PROTOS #ifdef NOKIA_ADAPTIVE_BINAURAL_PROTOS_OPT adaptTransportSignalsHeadtracked( st_ivas->hHeadTrackData, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, firstSlot, slotEnd, Rmat ); #else adaptTransportSignalsHeadtracked( st_ivas->hHeadTrackData, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, firstSlot, slotEnd, nBins, Rmat ); #endif #endif ivas_dirac_dec_binaural_check_and_switch_transports_headtracked( st_ivas->hHeadTrackData, Cldfb_ImagBuffer_in, Cldfb_RealBuffer_in, firstSlot, slotEnd, nBins, Rmat ); Loading Loading @@ -1355,12 +1371,19 @@ static void adaptTransportSignalsHeadtracked( float inRe[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], const uint8_t firstSlot, const uint8_t slotEnd, #ifndef NOKIA_ADAPTIVE_BINAURAL_PROTOS_OPT const uint8_t nBins, #endif float Rmat[3][3] ) { int16_t slot, ch, bin, louderCh; #ifdef NOKIA_ADAPTIVE_BINAURAL_PROTOS_OPT float ILD, mono_factor_ILD, mono_factor_rotation, mono_factor, y_val, ene_proc, ene_target; uint8_t n_slots_per_sf, sf_idx, n_sf; #else float re[2], im[2], ILD, mono_factor_ILD, mono_factor_rotation, mono_factor, y_val; float proc_re[2], proc_im[2], sum_re, sum_im, ene_proc, ene_target, mf; #endif /* Determine head-orientation-based mono factor. Rmat[1][1] entry informs how close the ears are aligned according to transport signals. */ Loading @@ -1369,9 +1392,110 @@ static void adaptTransportSignalsHeadtracked( mono_factor_rotation = fmaxf( 0.0f, fminf( 1.0f, mono_factor_rotation ) ); /* Adapt transport signals in frequency bands */ #ifdef NOKIA_ADAPTIVE_BINAURAL_PROTOS_OPT /* 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 */ n_slots_per_sf = CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; n_sf = ( slotEnd - firstSlot ) / n_slots_per_sf; for ( sf_idx = 0; sf_idx < n_sf; sf_idx++ ) { float eqVal; uint8_t start_slot, stop_slot; int16_t band_idx, bin_lo, bin_hi; start_slot = firstSlot + sf_idx * n_slots_per_sf; stop_slot = start_slot + n_slots_per_sf; for ( band_idx = 0; band_idx < MASA_FREQUENCY_BANDS; band_idx++ ) { float ch_nrg[2]; /* storage for input signal channel energies */ bin_lo = MASA_band_grouping_24[band_idx]; bin_hi = MASA_band_grouping_24[band_idx + 1]; for ( ch = 0; ch < 2; ch++ ) { ch_nrg[ch] = 0.0f; for ( slot = start_slot; slot < stop_slot; 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 = start_slot; slot < stop_slot; 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 = start_slot; slot < stop_slot; 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; } } } } } #else /* original contribution */ for ( slot = firstSlot; slot < slotEnd; slot++ ) { float eqVal[60]; for ( bin = 0; bin < nBins; bin++ ) { /* Determine channel energies */ Loading Loading @@ -1421,6 +1545,7 @@ static void adaptTransportSignalsHeadtracked( } } } #endif return; } Loading
lib_rend/ivas_stat_rend.h +5 −0 Original line number Diff line number Diff line Loading @@ -246,8 +246,13 @@ typedef struct ivas_binaural_head_track_struct float lrSwitchInterpVal; #ifdef NOKIA_ADAPTIVE_BINAURAL_PROTOS #ifdef NOKIA_ADAPTIVE_BINAURAL_PROTOS_OPT float chEneIIR[2][MASA_FREQUENCY_BANDS]; /* independent of the format. MASA bands are suitable for the task and readily available in ROM. */ float procChEneIIR[2][MASA_FREQUENCY_BANDS]; #else float chEneIIR[2][CLDFB_NO_CHANNELS_MAX]; float procChEneIIR[2][CLDFB_NO_CHANNELS_MAX]; #endif #endif int16_t shd_rot_max_order; Loading