diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index a1716d0741016248b0733042a630799631912714..905972e44e06524a0efb6bd23432d3d343822332 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -942,6 +942,9 @@ typedef enum #ifdef FIX_350_MASA_DELAY_COMP #define DELAY_MASA_PARAM_DEC_SFR 2 /* Delay to be compensation for MASA parameters in the decoder (subframes) */ +#ifdef FIX_373_MASA_DELAY_COMP_MSAN +#define SPH_IDX_FRONT ( MASA_NO_POINTS_EQUATOR / 2 ) /* Spherical index corresponding to front direction for setting as default value */ +#endif #endif #define DIRAC_SLOT_NS 1250000L /* time duration of a time slot, 1.25ms (==DELAY_RENERER_NS/MAX_PARAM_SPATIAL_SUBFRAMES) */ diff --git a/lib_com/ivas_masa_com.c b/lib_com/ivas_masa_com.c index 86f76763780c18891f261df2d28b033dc4a6927a..bd0336ad432f868ea1b25942446abd122217eb76 100644 --- a/lib_com/ivas_masa_com.c +++ b/lib_com/ivas_masa_com.c @@ -314,6 +314,10 @@ void masa_sample_rate_band_correction( int16_t *band_mapping, /* i/o: Band mapping used and modified */ IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: QMetadata structure for modification */ const int32_t sampling_rate /* i : Sampling rate */ +#ifdef FIX_373_MASA_DELAY_COMP_MSAN + , + MASA_DECODER_EXT_OUT_META_HANDLE hExtOutMeta /* i/o: MASA decoder metadata ext out buffer */ +#endif ) { uint8_t band, sf; @@ -386,6 +390,28 @@ void masa_sample_rate_band_correction( hQMetaData->twoDirBands[band] = 0; } } +#ifdef FIX_373_MASA_DELAY_COMP_MSAN + if ( hExtOutMeta != NULL ) + { + /* in decoder, zero the EXT out MASA meta buffer */ + for ( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) + { + for ( band = config->numCodingBands; band < MASA_FREQUENCY_BANDS; band++ ) + { + hExtOutMeta->directionIndex[0][sf][band] = SPH_IDX_FRONT; + hExtOutMeta->directToTotalRatio[0][sf][band] = 0u; + hExtOutMeta->spreadCoherence[0][sf][band] = 0u; + + hExtOutMeta->directionIndex[1][sf][band] = SPH_IDX_FRONT; + hExtOutMeta->directToTotalRatio[1][sf][band] = 0u; + hExtOutMeta->spreadCoherence[1][sf][band] = 0u; + + hExtOutMeta->surroundCoherence[sf][band] = 0u; + hExtOutMeta->diffuseToTotalRatio[sf][band] = UINT8_MAX; + } + } + } +#endif return; } diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index a0506e7473af7485cc2b837f1de4bb2e6954e632..dccf26abd2616bde9c93e59b057f02a252556143 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -4534,6 +4534,9 @@ void masa_sample_rate_band_correction( int16_t *band_mapping, /* i/o: Band mapping used and modified */ IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: QMetadata structure for modification */ const int32_t sampling_rate /* i : sampling rate */ +#ifdef FIX_373_MASA_DELAY_COMP_MSAN + , MASA_DECODER_EXT_OUT_META_HANDLE hExtOutMeta /* i/o: MASA decoder metadata ext out buffer */ +#endif ); void invdct4_transform( diff --git a/lib_com/options.h b/lib_com/options.h index 8f87cd3fd2caaa76b1c7840740f4a2bf2488da47..219f2c193569041b3fad00c91b9fda4bde384579 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -152,6 +152,7 @@ #define TD5 /* Eri: Contribution 17: Extended metadata for 6 DoF rendering in TD renderer */ #define TD5_FIX_INVALID_MEMORY_ACCESS /* FhG: Resolves segfault in case IVAS_REND_InitConfig gets initialized with rendererConfigEnabled:=false && ISM are being rendered */ #define FIX_371_DELAY_REPORT /* Issue 371: div. by zero with -no_delay_cmp */ +#define FIX_373_MASA_DELAY_COMP_MSAN /* Nokia: Issue 373: MASA audio/meta delay compensation. MSAN bugfix */ #ifdef FIX_I109_ORIENTATION_TRACKING #define OTR_REFERENCE_VECTOR_TRACKING /* FhG: enables the reference position orientation tracking mode */ diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index b8b7b74ffc51647d6d466e68ea325f111014fd4b..0f134a581a80782f52e6eb359047618600253483 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -492,7 +492,19 @@ static ivas_error ivas_masa_dec_config( ivas_set_qmetadata_maxbit_req( st_ivas->hQMetaData, st_ivas->ivas_format ); +#ifdef FIX_373_MASA_DELAY_COMP_MSAN + if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_EXTERNAL ) + { + /* need to apply the sampling rate correction also for the EXT output MASA meta buffer */ + masa_sample_rate_band_correction( &( hMasa->config ), hMasa->data.band_mapping, st_ivas->hQMetaData, st_ivas->hDecoderConfig->output_Fs, hMasa->data.extOutMeta ); + } + else + { + masa_sample_rate_band_correction( &( hMasa->config ), hMasa->data.band_mapping, st_ivas->hQMetaData, st_ivas->hDecoderConfig->output_Fs, NULL ); + } +#else masa_sample_rate_band_correction( &( hMasa->config ), hMasa->data.band_mapping, st_ivas->hQMetaData, st_ivas->hDecoderConfig->output_Fs ); +#endif return error; } diff --git a/lib_enc/ivas_masa_enc.c b/lib_enc/ivas_masa_enc.c index dca9be401092af394f7a1b08ee95fd50100726cb..67f74fec63cb692fa9502465ab0586229b6f35cc 100644 --- a/lib_enc/ivas_masa_enc.c +++ b/lib_enc/ivas_masa_enc.c @@ -589,7 +589,11 @@ ivas_error ivas_masa_enc_config( ivas_set_qmetadata_maxbit_req( hQMetaData, ivas_format ); +#ifdef FIX_373_MASA_DELAY_COMP_MSAN + masa_sample_rate_band_correction( &( hMasa->config ), hMasa->data.band_mapping, hQMetaData, st_ivas->hEncoderConfig->input_Fs, NULL ); +#else masa_sample_rate_band_correction( &( hMasa->config ), hMasa->data.band_mapping, hQMetaData, st_ivas->hEncoderConfig->input_Fs ); +#endif /* Transmit stereo signals using a mono downmix at lowest bitrates */ if ( ivas_format == MASA_FORMAT && st_ivas->nCPE == 1 && st_ivas->hCPE[0]->hStereoDft != NULL && st_ivas->hCPE[0]->hStereoDft->hConfig != NULL ) diff --git a/lib_util/masa_file_writer.c b/lib_util/masa_file_writer.c index 5667968ece8b39c4a1a8ecc783a9efcea63b2011..74429f9185c07ad0367325e2377112850389ac2b 100644 --- a/lib_util/masa_file_writer.c +++ b/lib_util/masa_file_writer.c @@ -67,8 +67,10 @@ struct MasaFileWriter *-----------------------------------------------------------------------*/ #ifndef FIX_350_MASA_DELAY_COMP +#ifndef FIX_373_MASA_DELAY_COMP_MSAN #define SPH_IDX_FRONT ( MASA_NO_POINTS_EQUATOR / 2 ) /* Spherical index corresponding to front direction for setting as default value */ #endif +#endif /*-----------------------------------------------------------------------* * Local functions