diff --git a/lib_com/options.h b/lib_com/options.h index 2b5fe5729be45e2792a16589add08d1176b07490..d54af21f35dfb2f3a1c1fdf5de3444e675213c0b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -133,6 +133,7 @@ #define FIX_1330_JBM_MEMORY /* VA: issue 1330: memory savings in the JBM decoder */ #define FIX_1411_IGF_CRASH_BW_SWITCHING /* FhG: Fix for issue 1411: fixes crash that can happen for IGF with BW switching and DTX*/ #define NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG /* FhG: Fix MDCT-Stereo comfort noise for certain noise types */ +#define NONBE_1344_REND_MASA_LOW_FS /* Nokia: Issue 1344: Fix sanitizer errors when using IVAS_rend to render MASA with lower sampling rates */ // object-editing feature porting #define TMP_FIX_SPLIT_REND // temporary fix to split-rendering (it follows the later state of the framework but it is needed now because of current test-conditions) diff --git a/lib_rend/ivas_dirac_ana_fx.c b/lib_rend/ivas_dirac_ana_fx.c index 502f4f5ae81acc7af1caa8d4935f9c1089f9923f..37150a6da69944f8f5e14d50816bcb9ca0bf8ffc 100644 --- a/lib_rend/ivas_dirac_ana_fx.c +++ b/lib_rend/ivas_dirac_ana_fx.c @@ -250,16 +250,24 @@ void ivas_dirac_ana_fx( const Word16 nchan_transport, /* i : Number of transport channels */ const Word16 data_q ) { - Word32 elevation_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - Word32 azimuth_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - Word32 energyRatio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - Word32 spreadCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - Word32 surroundingCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + Word32 elevation_m_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + Word32 azimuth_m_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + Word32 energyRatio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + Word32 spreadCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + Word32 surroundingCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; /* Estimate MASA parameters from the SBA signals */ - ivas_dirac_param_est_ana_fx( hDirAC, data_fx, elevation_m_values, azimuth_m_values, energyRatio, spreadCoherence, surroundingCoherence, input_frame, data_q ); - /* Create MASA metadata buffer from the estimated values */ + ivas_dirac_param_est_ana_fx( hDirAC, data_fx, elevation_m_values_fx, azimuth_m_values_fx, energyRatio_fx, spreadCoherence_fx, surroundingCoherence_fx, input_frame, data_q ); - ivas_create_masa_out_meta_fx( hDirAC->hMasaOut, hDirAC->sph_grid16, nchan_transport, elevation_m_values, azimuth_m_values, energyRatio, spreadCoherence, surroundingCoherence, Q31, Q31, Q31 ); +#ifdef NONBE_1344_REND_MASA_LOW_FS + /* Add zeros to higher bands in case of lower sampling rates */ + IF( LT_16( hDirAC->nbands, MASA_FREQUENCY_BANDS ) ) + { + ivas_masa_zero_high_bands_fx( hDirAC->nbands, elevation_m_values_fx, azimuth_m_values_fx, energyRatio_fx, spreadCoherence_fx, surroundingCoherence_fx ); + } +#endif + + /* Create MASA metadata buffer from the estimated values */ + ivas_create_masa_out_meta_fx( hDirAC->hMasaOut, hDirAC->sph_grid16, nchan_transport, elevation_m_values_fx, azimuth_m_values_fx, energyRatio_fx, spreadCoherence_fx, surroundingCoherence_fx, Q31, Q31, Q31 ); /* Downmix */ ivas_dirac_dmx_fx( data_fx, input_frame, nchan_transport ); // output Q of data_fx is same as that of input diff --git a/lib_rend/ivas_masa_merge_fx.c b/lib_rend/ivas_masa_merge_fx.c index 432ed8253dfc04c8f6fe00202f0ce3edd02849ff..144953e2672c93f199b87325e32c35ab7e9f3065 100644 --- a/lib_rend/ivas_masa_merge_fx.c +++ b/lib_rend/ivas_masa_merge_fx.c @@ -37,6 +37,9 @@ #include "ivas_cnst.h" #include "prot_fx.h" #include "wmc_auto.h" +#ifdef NONBE_1344_REND_MASA_LOW_FS +#include "ivas_rom_com.h" +#endif #include "ivas_prot_fx.h" #define INV_UINT8_MAX 8421505 /* 1/UINT8_MAX in Q31 */ @@ -487,6 +490,9 @@ ivas_error masaPrerendOpen_fx( { MASA_PREREND_HANDLE hMasaPrerend; Word16 i; +#ifdef NONBE_1344_REND_MASA_LOW_FS + Word16 maxBin; +#endif ivas_error error; error = IVAS_ERR_OK; @@ -498,6 +504,26 @@ ivas_error masaPrerendOpen_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MASA prerenderer\n" ) ); } +#ifdef NONBE_1344_REND_MASA_LOW_FS + /* Determine the number of bands and band grouping */ + hMasaPrerend->nbands = MASA_FREQUENCY_BANDS; + move16(); + mvs2s( MASA_band_grouping_24, hMasaPrerend->band_grouping, MASA_FREQUENCY_BANDS + 1 ); + + maxBin = extract_l( Mpy_32_32( input_Fs, INV_CLDFB_BANDWIDTH_Q31 ) ); /* Q0 */ + FOR( i = 1; i < hMasaPrerend->nbands + 1; i++ ) + { + IF( GE_16( hMasaPrerend->band_grouping[i], maxBin ) ) + { + hMasaPrerend->band_grouping[i] = maxBin; + move16(); + hMasaPrerend->nbands = i; + move16(); + break; + } + } +#endif + hMasaPrerend->num_Cldfb_instances = numTransports; move16(); FOR( i = 0; i < hMasaPrerend->num_Cldfb_instances; i++ ) diff --git a/lib_rend/ivas_mcmasa_ana_fx.c b/lib_rend/ivas_mcmasa_ana_fx.c index ab41810b84403df5e460a5117aa7c44afa546c3f..2f607a7b33a956353a3d89d8ef82ede82edd84c7 100644 --- a/lib_rend/ivas_mcmasa_ana_fx.c +++ b/lib_rend/ivas_mcmasa_ana_fx.c @@ -486,6 +486,14 @@ void ivas_mcmasa_ana_fx( /* Analysis */ ivas_mcmasa_param_est_ana_fx( hMcMasa, data, elevation_m_values_fx, azimuth_m_values_fx, energyRatio_fx, spreadCoherence_fx, surroundingCoherence_fx, q_data, input_frame, nchan_inp ); +#ifdef NONBE_1344_REND_MASA_LOW_FS + /* Add zeros to higher bands in case of lower sampling rates */ + IF( LT_16( hMcMasa->nbands, MASA_FREQUENCY_BANDS ) ) + { + ivas_masa_zero_high_bands_fx( hMcMasa->nbands, elevation_m_values_fx, azimuth_m_values_fx, energyRatio_fx, spreadCoherence_fx, surroundingCoherence_fx ); + } +#endif + /* Create MASA metadata buffer from the estimated values */ ivas_create_masa_out_meta_fx( hMcMasa->hMasaOut, hMcMasa->sph_grid16, nchan_transport, elevation_m_values_fx, azimuth_m_values_fx, energyRatio_fx, spreadCoherence_fx, surroundingCoherence_fx, Q31, Q31, Q31 ); @@ -1703,3 +1711,43 @@ void ivas_create_masa_out_meta_fx( return; } + + +#ifdef NONBE_1344_REND_MASA_LOW_FS +/*------------------------------------------------------------------------- + * ivas_masa_zero_high_bands() + * + * + *------------------------------------------------------------------------*/ + +void ivas_masa_zero_high_bands_fx( + const Word16 nbands, /* i : Number of frequency bands with estimated values */ + Word32 elevation_m_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o : Estimated elevation */ + Word32 azimuth_m_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o : Estimated azimuth */ + Word32 energyRatio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o : Estimated direct-to-total ratio */ + Word32 spreadCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o : Estimated spread coherence */ + Word32 surroundingCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i/o : Estimated surround coherence */ +) +{ + Word16 sf, band; + + FOR( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) + { + FOR( band = nbands; band < MASA_FREQUENCY_BANDS; band++ ) + { + elevation_m_values_fx[sf][band] = 0; + move32(); + azimuth_m_values_fx[sf][band] = 0; + move32(); + energyRatio_fx[sf][band] = 0; + move32(); + spreadCoherence_fx[sf][band] = 0; + move32(); + surroundingCoherence_fx[sf][band] = 0; + move32(); + } + } + + return; +} +#endif diff --git a/lib_rend/ivas_omasa_ana_fx.c b/lib_rend/ivas_omasa_ana_fx.c index 310addb66fbb4efe0fdbcb863346f05a3de5c620..7e73a0f605b4759938ed3c7ff8b892239a3d4497 100644 --- a/lib_rend/ivas_omasa_ana_fx.c +++ b/lib_rend/ivas_omasa_ana_fx.c @@ -318,6 +318,14 @@ void ivas_omasa_ana_fx( /* Estimate MASA parameters from the objects */ ivas_omasa_param_est_ana_fx( hOMasa, data_in_f_fx, *data_in_q, elevation_m_values_fx, azimuth_m_values_fx, energyRatio_fx, &energyRatio_q, spreadCoherence_fx, &spreadCoherence_q, surroundingCoherence_fx, &sorroundingCoherence_q, input_frame, nchan_ism ); +#ifdef NONBE_1344_REND_MASA_LOW_FS + /* Add zeros to higher bands in case of lower sampling rates */ + IF( LT_16( hOMasa->nbands, MASA_FREQUENCY_BANDS ) ) + { + ivas_masa_zero_high_bands_fx( hOMasa->nbands, elevation_m_values_fx, azimuth_m_values_fx, energyRatio_fx, spreadCoherence_fx, surroundingCoherence_fx ); + } +#endif + /* Create MASA metadata buffer from the estimated values */ ivas_create_masa_out_meta_fx( hOMasa->hMasaOut, hOMasa->sph_grid16, nchan_transport, elevation_m_values_fx, azimuth_m_values_fx, energyRatio_fx, spreadCoherence_fx, surroundingCoherence_fx, Q31, Q31, Q31 ); diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index c2274202ead7c90cf4c6c736bb14d1bc16c929aa..86586520ea539a9b028d6f0873fa06af1d96e54c 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -1489,6 +1489,17 @@ void ivas_create_masa_out_meta_fx( Word16 surroundingCoherence_q ); +#ifdef NONBE_1344_REND_MASA_LOW_FS +void ivas_masa_zero_high_bands_fx( + const Word16 nbands, /* i : Number of frequency bands with estimated values */ + Word32 elevation_m_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o : Estimated elevation */ + Word32 azimuth_m_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o : Estimated azimuth */ + Word32 energyRatio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o : Estimated direct-to-total ratio */ + Word32 spreadCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o : Estimated spread coherence */ + Word32 surroundingCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i/o : Estimated surround coherence */ +); +#endif + ivas_error ivas_dirac_ana_open_fx( DIRAC_ANA_HANDLE *hDirACPtr, /* i/o: DIRAC data handle pointer */ Word32 input_Fs diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 3f6ac811b28dd7b1344d7fb2397a353b2d772596..b0a1f27be03c5d34442683aed2879e5ce2003e6e 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1697,6 +1697,11 @@ typedef struct ivas_dirac_ana_data_structure typedef struct ivas_masa_prerend_data_structure { +#ifdef NONBE_1344_REND_MASA_LOW_FS + Word16 nbands; + Word16 band_grouping[MASA_FREQUENCY_BANDS + 1]; +#endif + /* CLDFB analysis */ Word16 num_Cldfb_instances; HANDLE_CLDFB_FILTER_BANK cldfbAnaEnc[MASA_MAX_TRANSPORT_CHANNELS]; diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 9a7a38809212ba51694ac0f1f55e25377652f284..b8e282d914658b815285586bea091ffa972bfe0d 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -8649,12 +8649,23 @@ static void renderMasaToMasa( Word16 q_add = sub( 31, add( scale_factor, q_cldfb_out ) ); /* Compute channel energy for metadata processing */ +#ifdef NONBE_1344_REND_MASA_LOW_FS + FOR( band_m_idx = 0; band_m_idx < masaInput->hMasaPrerend->nbands; band_m_idx++ ) +#else FOR( band_m_idx = 0; band_m_idx < MASA_FREQUENCY_BANDS; band_m_idx++ ) +#endif { +#ifdef NONBE_1344_REND_MASA_LOW_FS + brange[0] = masaInput->hMasaPrerend->band_grouping[band_m_idx]; + move16(); + brange[1] = masaInput->hMasaPrerend->band_grouping[band_m_idx + 1]; + move16(); +#else brange[0] = MASA_band_grouping_24[band_m_idx]; move16(); brange[1] = MASA_band_grouping_24[band_m_idx + 1]; move16(); +#endif FOR( j = brange[0]; j < brange[1]; j++ ) { FOR( i = 0; i < numAnalysisChannels; i++ )