diff --git a/lib_com/options.h b/lib_com/options.h index b9856194fba6cd198459766d51baf05a1cd9d080..c4d0aebd2b5dbe6d2294e089956833c2025eddd6 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -158,6 +158,7 @@ #define NOKIA_ADAPTIVE_BINAURAL_PROTOS_OPT /* Nokia: enable adaptive binaural prototype complexity optimizations */ #define FIX_389_EXT_REND_PCM_SR /* Nokia: Issue 389: Fix assignment of sample rate with PCM input. */ +#define FIX_390_EXT_REND_MASA_META_COPY /* Nokia: Issue 390: Fixes MASA metadata copying to renderer. */ /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index e97ae461cf2556999539d0c138614b011e642dea..5a4d31d313fd11e55e25ddab82af1d40ff23109d 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -2222,6 +2222,9 @@ static ivas_error initMasaDummyDecForMcOut( { return error; } +#ifdef FIX_390_EXT_REND_MASA_META_COPY + decDummy->hDirAC->dirac_bs_md_write_idx = 0; +#endif if ( decDummy->renderer_type == RENDERER_STEREO_PARAMETRIC ) { @@ -2298,6 +2301,9 @@ static ivas_error initMasaDummyDecForSbaOut( { return error; } +#ifdef FIX_390_EXT_REND_MASA_META_COPY + decDummy->hDirAC->dirac_bs_md_write_idx = 0; +#endif numCldfbAnalyses = decDummy->nchan_transport; numCldfbSyntheses = decDummy->hDecoderConfig->nchan_out; @@ -2366,6 +2372,9 @@ static ivas_error initMasaDummyDecForBinauralOut( { return error; } +#ifdef FIX_390_EXT_REND_MASA_META_COPY + decDummy->hDirAC->dirac_bs_md_write_idx = 0; +#endif if ( ( error = ivas_dirac_dec_binaural_copy_hrtfs( &decDummy->hHrtfParambin ) ) != IVAS_ERR_OK ) { @@ -5287,33 +5296,61 @@ static void copyMasaMetadataToDiracRenderer( DIRAC_DEC_HANDLE hDirAC ) { int16_t band, sf, bin; +#ifdef FIX_390_EXT_REND_MASA_META_COPY + int16_t meta_write_index; +#endif hDirAC->numSimultaneousDirections = meta->descriptive_meta.numberOfDirections + 1; for ( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) { +#ifdef FIX_390_EXT_REND_MASA_META_COPY + meta_write_index = ( hDirAC->dirac_bs_md_write_idx + sf ) % hDirAC->dirac_md_buffer_length; +#endif + for ( band = 0; band < MASA_MAXIMUM_CODING_SUBBANDS; band++ ) { for ( bin = MASA_band_grouping_24[band]; bin < MASA_band_grouping_24[band + 1]; bin++ ) { +#ifdef FIX_390_EXT_REND_MASA_META_COPY + hDirAC->azimuth[meta_write_index][bin] = (int16_t) meta->directional_meta[0].azimuth[sf][band]; + hDirAC->elevation[meta_write_index][bin] = (int16_t) meta->directional_meta[0].elevation[sf][band]; + hDirAC->energy_ratio1[meta_write_index][bin] = meta->directional_meta[0].energy_ratio[sf][band]; + hDirAC->diffuseness_vector[meta_write_index][bin] = 1.0f - meta->directional_meta[0].energy_ratio[sf][band]; + hDirAC->spreadCoherence[meta_write_index][bin] = meta->directional_meta[0].spread_coherence[sf][band]; + hDirAC->surroundingCoherence[meta_write_index][bin] = meta->common_meta.surround_coherence[sf][band]; +#else hDirAC->azimuth[sf][bin] = (int16_t) meta->directional_meta[0].azimuth[sf][band]; hDirAC->elevation[sf][bin] = (int16_t) meta->directional_meta[0].elevation[sf][band]; hDirAC->energy_ratio1[sf][bin] = meta->directional_meta[0].energy_ratio[sf][band]; hDirAC->diffuseness_vector[sf][bin] = 1.0f - meta->directional_meta[0].energy_ratio[sf][band]; hDirAC->spreadCoherence[sf][bin] = meta->directional_meta[0].spread_coherence[sf][band]; hDirAC->surroundingCoherence[sf][bin] = meta->common_meta.surround_coherence[sf][band]; +#endif if ( hDirAC->numSimultaneousDirections == 2 ) { +#ifdef FIX_390_EXT_REND_MASA_META_COPY + hDirAC->azimuth2[meta_write_index][bin] = (int16_t) meta->directional_meta[1].azimuth[sf][band]; + hDirAC->elevation2[meta_write_index][bin] = (int16_t) meta->directional_meta[1].elevation[sf][band]; + hDirAC->energy_ratio2[meta_write_index][bin] = meta->directional_meta[1].energy_ratio[sf][band]; + hDirAC->diffuseness_vector[meta_write_index][bin] -= meta->directional_meta[1].energy_ratio[sf][band]; + hDirAC->spreadCoherence2[meta_write_index][bin] = meta->directional_meta[1].spread_coherence[sf][band]; +#else hDirAC->azimuth2[sf][bin] = (int16_t) meta->directional_meta[1].azimuth[sf][band]; hDirAC->elevation2[sf][bin] = (int16_t) meta->directional_meta[1].elevation[sf][band]; hDirAC->energy_ratio2[sf][bin] = meta->directional_meta[1].energy_ratio[sf][band]; hDirAC->diffuseness_vector[sf][bin] -= meta->directional_meta[1].energy_ratio[sf][band]; hDirAC->spreadCoherence2[sf][bin] = meta->directional_meta[1].spread_coherence[sf][band]; +#endif } } } } +#ifdef FIX_390_EXT_REND_MASA_META_COPY + + hDirAC->dirac_bs_md_write_idx = ( hDirAC->dirac_bs_md_write_idx + MAX_PARAM_SPATIAL_SUBFRAMES ) % hDirAC->dirac_md_buffer_length; +#endif return; }