diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index cc0b2de7b354c695c4b0f1490bb6d91cb3375c81..b83057ede4a5b4e5cbb95178777fd3d2b241b730 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -195,11 +195,19 @@ ivas_error ivas_dirac_config( if ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) { +#ifdef NONBE_FIX_907_VLBR_DIRAC_BAND_MAPPING + ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( Fs * INV_CLDFB_BANDWIDTH + 0.5f ), dirac_to_spar_md_bands, hQMetaData->useLowerBandRes, hConfig->enc_param_start_band, hFbMdft, 1 ); +#else ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( Fs * INV_CLDFB_BANDWIDTH + 0.5f ), dirac_to_spar_md_bands, hQMetaData->useLowerBandRes, hConfig->enc_param_start_band, hFbMdft ); +#endif } else { +#ifdef NONBE_FIX_907_VLBR_DIRAC_BAND_MAPPING + ivas_dirac_config_bands( band_grouping, hConfig->nbands, (int16_t) ( Fs * INV_CLDFB_BANDWIDTH + 0.5f ), NULL, 0, 0, hFbMdft, 1 ); +#else ivas_dirac_config_bands( band_grouping, hConfig->nbands, (int16_t) ( Fs * INV_CLDFB_BANDWIDTH + 0.5f ), NULL, 0, 0, hFbMdft ); +#endif } return error; @@ -207,11 +215,22 @@ ivas_error ivas_dirac_config( /*------------------------------------------------------------------------- - * ivas_dirac_sba_config_bands() + * ivas_dirac_config_bands() * * DirAC Configuration freq. band function; used also in MASA decoder *------------------------------------------------------------------------*/ +#ifdef NONBE_FIX_907_VLBR_DIRAC_BAND_MAPPING +void ivas_dirac_config_bands( + int16_t *band_grouping, /* o : band grouping */ + const int16_t nbands, /* i : number of bands */ + const int16_t max_band, /* i : maximal band index +1 */ + int16_t *dirac_to_spar_md_bands, + const int8_t useLowerBandRes, + const int16_t enc_param_start_band, + IVAS_FB_MIXER_HANDLE hFbMdft, + const int8_t BandGroupLowRes ) +#else void ivas_dirac_config_bands( int16_t *band_grouping, /* o : band grouping */ const int16_t nbands, /* i : number of bands */ @@ -220,6 +239,7 @@ void ivas_dirac_config_bands( const int8_t useLowerBandRes, const int16_t enc_param_start_band, IVAS_FB_MIXER_HANDLE hFbMdft ) +#endif { int16_t i; { @@ -270,14 +290,20 @@ void ivas_dirac_config_bands( { int16_t step = DIRAC_LOW_BANDRES_STEP; int16_t reduced_band; - for ( band = enc_param_start_band + 2, reduced_band = enc_param_start_band + 1; band <= DIRAC_MAX_NBANDS; band += step, reduced_band++ ) +#ifdef NONBE_FIX_907_VLBR_DIRAC_BAND_MAPPING + if ( BandGroupLowRes ) +#endif { - band_grouping[reduced_band] = band_grouping[band]; - } - for ( ; reduced_band <= DIRAC_MAX_NBANDS; reduced_band++ ) - { - band_grouping[reduced_band] = max_band; + for ( band = enc_param_start_band + 2, reduced_band = enc_param_start_band + 1; band <= DIRAC_MAX_NBANDS; band += step, reduced_band++ ) + { + band_grouping[reduced_band] = band_grouping[band]; + } + for ( ; reduced_band <= DIRAC_MAX_NBANDS; reduced_band++ ) + { + band_grouping[reduced_band] = max_band; + } } + for ( band = enc_param_start_band + ( DIRAC_MAX_NBANDS - enc_param_start_band ) / 2 - 1, reduced_band = DIRAC_MAX_NBANDS - 1; band >= enc_param_start_band; band--, reduced_band -= step ) { dirac_to_spar_md_bands[reduced_band] = dirac_to_spar_md_bands[band]; diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 217d3cb6cf9ce24556871a13e2423c74b3babdab..4fd60152bc7eff4529fe336b32f0540084baec83 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3662,6 +3662,18 @@ ivas_error ivas_dirac_config( const int16_t enc_dec /* i : encoder or decoder flag */ ); +#ifdef NONBE_FIX_907_VLBR_DIRAC_BAND_MAPPING +void ivas_dirac_config_bands( + int16_t *band_grouping, /* o : band grouping */ + const int16_t nbands, /* i : number of bands */ + const int16_t max_band, /* i : maximal band index +1 */ + int16_t *dirac_to_spar_md_bands, /* o : mapping of DirAC parameter band index to SPAR FB band index */ + const int8_t useLowerBandRes, /* i : flag indicating lower band resolution for DirAC */ + const int16_t enc_param_start_band, /* i : band index of first DirAC parameter band */ + IVAS_FB_MIXER_HANDLE hFbMdft, /* i : MDFT filterbank handle */ + const int8_t BandGroupLowRes /* i : flag indicating lower band grouping resolution for DirAC */ +); +#else void ivas_dirac_config_bands( int16_t *band_grouping, /* o : band grouping */ const int16_t nbands, /* i : number of bands */ @@ -3671,6 +3683,7 @@ void ivas_dirac_config_bands( const int16_t enc_param_start_band, /* i : band index of first DirAC parameter band */ IVAS_FB_MIXER_HANDLE hFbMdft ); +#endif void ivas_get_dirac_sba_max_md_bits( const int32_t sba_total_brate, diff --git a/lib_com/options.h b/lib_com/options.h index ee26612dbebbcc60438b9e207dece73159ffd22e..9ea2d3709856d316595bee9faff6748417538268 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -204,6 +204,7 @@ #define FIX_929_RENDERER_CMDL /* Nokia: issue #929: renderer command line option */ #define NONBE_FIX_BINAURAL_ROOM_IR_REVERBERATOR /* FhG: re-enable acidentially disabled reverberator for BINAURAL_ROOM_IR */ #define NONBE_FIX_1058_DECODER_ERROR_WITH_REVERB_ROOM /* FhG: issue 1058: do not initialize EFAP when IntSetup is HOA3 */ +#define NONBE_FIX_907_VLBR_DIRAC_BAND_MAPPING /* Dlb: issue 907: fix for band mapping at VLBR */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index c429686f7bf685d79e4a0862e2739c6f2dae4b86..da04827dea0bc6a6e2d688aad43c54837fd43cf3 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -1287,7 +1287,11 @@ void ivas_qmetadata_to_dirac( /* SID/zero-frame: 1 direction, 5 bands, nblocks re-generated out of SID decoder*/ start_band = 0; hDirAC->hConfig->nbands = 5; +#ifdef NONBE_FIX_907_VLBR_DIRAC_BAND_MAPPING + ivas_dirac_config_bands( hDirAC->band_grouping, hDirAC->hConfig->nbands, nbands, NULL, 0, 0, NULL, 1 ); +#else ivas_dirac_config_bands( hDirAC->band_grouping, hDirAC->hConfig->nbands, nbands, NULL, 0, 0, NULL ); +#endif nbands = 5; } else @@ -1302,7 +1306,11 @@ void ivas_qmetadata_to_dirac( hDirAC->hConfig->nbands = q_direction->cfg.nbands; } +#ifdef NONBE_FIX_907_VLBR_DIRAC_BAND_MAPPING + ivas_dirac_config_bands( hDirAC->band_grouping, hDirAC->hConfig->nbands, nbands, dirac_to_spar_md_bands, hQMetaData->useLowerBandRes, hDirAC->hConfig->enc_param_start_band, hDirAC->hFbMdft, 0 ); +#else ivas_dirac_config_bands( hDirAC->band_grouping, hDirAC->hConfig->nbands, nbands, dirac_to_spar_md_bands, hQMetaData->useLowerBandRes, hDirAC->hConfig->enc_param_start_band, hDirAC->hFbMdft ); +#endif nbands = hDirAC->hConfig->nbands; if ( hQMetaData->q_direction[0].cfg.nblocks == 0 ) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 839a16a69b12619ef9eb803cf6d5a17d949d176d..e9fd70202ba11b9f0310ce99a97233d3a2cf9e92 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1356,8 +1356,14 @@ ivas_error ivas_init_decoder( st_ivas->hQMetaData->numTwoDirBands = (uint8_t) st_ivas->hQMetaData->q_direction[0].cfg.nbands; } + +#ifdef NONBE_FIX_907_VLBR_DIRAC_BAND_MAPPING + ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), + st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0, 1 ); +#else ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0 ); +#endif } st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); @@ -1510,8 +1516,13 @@ ivas_error ivas_init_decoder( st_ivas->hQMetaData->numTwoDirBands = (uint8_t) st_ivas->hQMetaData->q_direction[0].cfg.nbands; } +#ifdef NONBE_FIX_907_VLBR_DIRAC_BAND_MAPPING + ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), + st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0, 1 ); +#else ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0 ); +#endif } for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index da3f566beafed3acfac423d7885008a93d517d87..4218ff9f06c80d8e57f7efa2bac257a6b7b8da0c 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -427,8 +427,14 @@ ivas_error ivas_sba_dec_reconfigure( st_ivas->hQMetaData->numTwoDirBands = (uint8_t) st_ivas->hQMetaData->q_direction[0].cfg.nbands; } + +#ifdef NONBE_FIX_907_VLBR_DIRAC_BAND_MAPPING + ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), + st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0, 1 ); +#else ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0 ); +#endif if ( st_ivas->hDirAC ) { diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc.c index 682c5d52e0217358853e421abc39065058aa9818..be984bb404b69fd1c4f5364c1d165342726efa28 100644 --- a/lib_enc/ivas_spar_md_enc.c +++ b/lib_enc/ivas_spar_md_enc.c @@ -492,6 +492,9 @@ ivas_error ivas_spar_md_enc_process( int16_t md_indices_allocated; int16_t max_num_indices_tmp; float Wscale[IVAS_MAX_NUM_BANDS]; +#ifdef NONBE_FIX_907_VLBR_DIRAC_BAND_MAPPING + float P_quant_re_prior[SPAR_DIRAC_SPLIT_START_BAND][FOA_CHANNELS - 1]; +#endif /*extra 16 bits for arithmetic coder as overshoot check is after a symbol is written*/ md_indices_allocated = hMdEnc->spar_md_cfg.max_bits_per_blk + IVAS_SPAR_ARITH_OVERSHOOT_BITS; @@ -588,6 +591,16 @@ ivas_error ivas_spar_md_enc_process( } } +#ifdef NONBE_FIX_907_VLBR_DIRAC_BAND_MAPPING + if ( hEncoderConfig->ivas_total_brate < IVAS_24k4 ) + { + for ( b = 0; b < num_bands * bands_bw; b++ ) + { + mvr2r( hMdEnc->spar_md.band_coeffs[b].P_quant_re, P_quant_re_prior[b], FOA_CHANNELS - 1 ); + } + } +#endif + ivas_compute_spar_params( cov_real, dm_fv_re, 0, hMdEnc->mixer_mat, 0, nB, dtx_vad, num_ch, bands_bw, active_w, active_w_vlbr, &hMdEnc->spar_md_cfg, &hMdEnc->spar_md, Wscale, 0, dyn_active_w_flag ); if ( dirac_mono_flag ) @@ -854,6 +867,19 @@ ivas_error ivas_spar_md_enc_process( #endif /* Reuse mixer matrix values for unsent bands */ +#ifdef NONBE_FIX_907_VLBR_DIRAC_BAND_MAPPING + if ( hEncoderConfig->ivas_total_brate < IVAS_24k4 ) + { + for ( k = num_bands - 1; k >= 0; k-- ) + { + for ( b = bands_bw - 1; b >= 0; b-- ) + { + mvr2r( hMdEnc->spar_md.band_coeffs[k].P_quant_re, hMdEnc->spar_md.band_coeffs[bands_bw * k + b].P_quant_re, FOA_CHANNELS - 1 ); + } + } + } +#endif + if ( ( hEncoderConfig->ivas_total_brate < IVAS_24k4 ) && ( code_strat > 3 ) ) { for ( b = 0; b < num_bands * bands_bw; b += 2 * bands_bw ) @@ -870,6 +896,10 @@ ivas_error ivas_spar_md_enc_process( hMdEnc->mixer_mat[i][j][b + 1] = prior_mixer[i][j][b + 1]; } } +#ifdef NONBE_FIX_907_VLBR_DIRAC_BAND_MAPPING + mvr2r( P_quant_re_prior[b], hMdEnc->spar_md.band_coeffs[b].P_quant_re, FOA_CHANNELS - 1 ); + mvr2r( P_quant_re_prior[b + 1], hMdEnc->spar_md.band_coeffs[b + 1].P_quant_re, FOA_CHANNELS - 1 ); +#endif } } #ifdef DEBUG_LBR_SBA