Skip to content
...@@ -262,7 +262,11 @@ void hq_lr_dec( ...@@ -262,7 +262,11 @@ void hq_lr_dec(
frac1 = L_Extract_lc( L_tmp, &exp ); /* Extract exponent of L_tmp */ frac1 = L_Extract_lc( L_tmp, &exp ); /* Extract exponent of L_tmp */
L_tmp = Pow2( 30, frac1 ); L_tmp = Pow2( 30, frac1 );
exp = sub( exp, 30 ); exp = sub( exp, 30 );
Ep_fx[i] = L_shl( L_tmp, sub( exp, 6 ) ); /* Q -6 */ #ifdef BASOP_NOGLOB
Ep_fx[i] = L_shl_o( L_tmp, s_max( sub( exp, 6 ), -31 ), &Overflow ); /* Q -6 */
#else
Ep_fx[i] = L_shl( L_tmp, s_max( sub( exp, 6 ), -31 ) ); /* Q -6 */
#endif
Ep[i] = (float) ( Ep_fx[i] / pow( 2.0, -6 ) ); Ep[i] = (float) ( Ep_fx[i] / pow( 2.0, -6 ) );
} }
......
...@@ -293,8 +293,7 @@ ivas_error init_decoder( ...@@ -293,8 +293,7 @@ ivas_error init_decoder(
st->last_vad = 0; st->last_vad = 0;
st->last_active_brate = ACELP_7k20; st->last_active_brate = ACELP_7k20;
st->last_CNG_L_frame = L_FRAME; st->last_CNG_L_frame = L_FRAME;
st->active_cnt = CNG_TYPE_HO;
st->active_cnt = 20;
if ( idchan == 0 && ( st->element_mode == EVS_MONO || st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD ) ) if ( idchan == 0 && ( st->element_mode == EVS_MONO || st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD ) )
{ {
......
...@@ -999,6 +999,7 @@ ivas_error ivas_binRenderer_open( ...@@ -999,6 +999,7 @@ ivas_error ivas_binRenderer_open(
if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
{ {
pRoomAcoustics = ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ? &( st_ivas->hRenderConfig->roomAcoustics ) : NULL; pRoomAcoustics = ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ? &( st_ivas->hRenderConfig->roomAcoustics ) : NULL;
if ( ( error = ivas_binaural_reverb_init( &( hBinRenderer->hReverb ), if ( ( error = ivas_binaural_reverb_init( &( hBinRenderer->hReverb ),
st_ivas->hHrtfStatistics, st_ivas->hHrtfStatistics,
hBinRenderer->conv_band, hBinRenderer->conv_band,
...@@ -1007,7 +1008,8 @@ ivas_error ivas_binRenderer_open( ...@@ -1007,7 +1008,8 @@ ivas_error ivas_binRenderer_open(
st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->output_Fs,
st_ivas->hHrtfFastConv->fastconvReverberationTimes, st_ivas->hHrtfFastConv->fastconvReverberationTimes,
st_ivas->hHrtfFastConv->fastconvReverberationEneCorrections, st_ivas->hHrtfFastConv->fastconvReverberationEneCorrections,
hBinRenderer->earlyPartEneCorrection ) ) != IVAS_ERR_OK ) NULL ) ) != IVAS_ERR_OK )
{ {
return error; return error;
} }
......
...@@ -75,7 +75,8 @@ ivas_error ivas_core_dec( ...@@ -75,7 +75,8 @@ ivas_error ivas_core_dec(
float synth[CPE_CHANNELS][L_FRAME48k]; float synth[CPE_CHANNELS][L_FRAME48k];
float tmp_buffer[L_FRAME48k]; float tmp_buffer[L_FRAME48k];
int16_t tmps, incr; int16_t tmps, incr;
float bwe_exc_extended[CPE_CHANNELS][L_FRAME32k + NL_BUFF_OFFSET]; float *bwe_exc_extended[CPE_CHANNELS] = { NULL, NULL };
int16_t flag_bwe_bws;
float voice_factors[CPE_CHANNELS][NB_SUBFR16k]; float voice_factors[CPE_CHANNELS][NB_SUBFR16k];
int16_t core_switching_flag[CPE_CHANNELS]; int16_t core_switching_flag[CPE_CHANNELS];
float old_syn_12k8_16k[CPE_CHANNELS][L_FRAME16k]; float old_syn_12k8_16k[CPE_CHANNELS][L_FRAME16k];
...@@ -84,7 +85,7 @@ ivas_error ivas_core_dec( ...@@ -84,7 +85,7 @@ ivas_error ivas_core_dec(
int16_t unbits[CPE_CHANNELS]; int16_t unbits[CPE_CHANNELS];
int16_t sid_bw[CPE_CHANNELS]; int16_t sid_bw[CPE_CHANNELS];
FRAME_MODE frameMode[CPE_CHANNELS]; FRAME_MODE frameMode[CPE_CHANNELS];
float tdm_lspQ_PCh[M], tdm_lsfQ_PCh[M]; float tdm_lsfQ_PCh[M];
int16_t tdm_LRTD_flag; int16_t tdm_LRTD_flag;
int32_t element_brate, output_Fs; int32_t element_brate, output_Fs;
int32_t last_element_brate; int32_t last_element_brate;
...@@ -200,6 +201,7 @@ ivas_error ivas_core_dec( ...@@ -200,6 +201,7 @@ ivas_error ivas_core_dec(
set_f( voice_factors[n], 0.f, NB_SUBFR16k ); set_f( voice_factors[n], 0.f, NB_SUBFR16k );
set_f( hb_synth[n], 0.0f, L_FRAME48k ); set_f( hb_synth[n], 0.0f, L_FRAME48k );
bwe_exc_extended[n] = hb_synth[n]; /* note: reuse the buffer */
/*------------------------------------------------------------------* /*------------------------------------------------------------------*
* Decision matrix (selection of technologies) * Decision matrix (selection of technologies)
...@@ -348,7 +350,8 @@ ivas_error ivas_core_dec( ...@@ -348,7 +350,8 @@ ivas_error ivas_core_dec(
if ( st->core == ACELP_CORE ) if ( st->core == ACELP_CORE )
{ {
/* ACELP core decoder */ /* ACELP core decoder */
if ( ( error = acelp_core_dec( st, output[n], synth[n], save_hb_synth, bwe_exc_extended[n], voice_factors[n], old_syn_12k8_16k[n], sharpFlag[n], pitch_buf[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lspQ_PCh, tdm_lsfQ_PCh, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hStereoCng, read_sid_info ) ) != IVAS_ERR_OK ) if ( ( error = acelp_core_dec( st, output[n], synth[n], save_hb_synth, bwe_exc_extended[n], voice_factors[n], old_syn_12k8_16k[n], sharpFlag[n], pitch_buf[n], &unbits[n], &sid_bw[n], hStereoTD,
tdm_lsfQ_PCh, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hStereoCng, read_sid_info ) ) != IVAS_ERR_OK )
{ {
return error; return error;
} }
...@@ -372,7 +375,7 @@ ivas_error ivas_core_dec( ...@@ -372,7 +375,7 @@ ivas_error ivas_core_dec(
if ( st->element_mode == IVAS_CPE_TD && n == 0 ) if ( st->element_mode == IVAS_CPE_TD && n == 0 )
{ {
td_stereo_param_updt( st->lsp_old, st->lsf_old, st->old_pitch_buf + st->nb_subfr, tdm_lspQ_PCh, tdm_lsfQ_PCh, hStereoTD->tdm_Pri_pitch_buf, st->flag_ACELP16k, hStereoTD->tdm_use_IAWB_Ave_lpc ); td_stereo_param_updt( st->lsp_old, st->lsf_old, st->old_pitch_buf + st->nb_subfr, tdm_lsfQ_PCh, hStereoTD->tdm_Pri_pitch_buf, st->flag_ACELP16k, hStereoTD->tdm_use_IAWB_Ave_lpc );
} }
} /* n_channels loop */ } /* n_channels loop */
...@@ -510,6 +513,8 @@ ivas_error ivas_core_dec( ...@@ -510,6 +513,8 @@ ivas_error ivas_core_dec(
* SWB(FB) BWE decoding * SWB(FB) BWE decoding
*---------------------------------------------------------------------*/ *---------------------------------------------------------------------*/
flag_bwe_bws = ( output_Fs >= 32000 && st->core == ACELP_CORE && st->bwidth > NB && st->bws_cnt > 0 && st->bfi == 0 );
if ( st->extl == SWB_TBE || st->extl == FB_TBE || ( st->coder_type != AUDIO && st->coder_type != INACTIVE && st->core_brate >= SID_2k40 && st->core == ACELP_CORE && !st->con_tcx && output_Fs >= 32000 && st->bwidth > NB && st->bws_cnt > 0 ) ) if ( st->extl == SWB_TBE || st->extl == FB_TBE || ( st->coder_type != AUDIO && st->coder_type != INACTIVE && st->core_brate >= SID_2k40 && st->core == ACELP_CORE && !st->con_tcx && output_Fs >= 32000 && st->bwidth > NB && st->bws_cnt > 0 ) )
{ {
/* SWB TBE decoder */ /* SWB TBE decoder */
...@@ -521,12 +526,17 @@ ivas_error ivas_core_dec( ...@@ -521,12 +526,17 @@ ivas_error ivas_core_dec(
fb_tbe_dec( st, tmp_buffer /*fb_exc*/, hb_synth[n], tmp_buffer /*fb_synth_ref*/, output_frame ); fb_tbe_dec( st, tmp_buffer /*fb_exc*/, hb_synth[n], tmp_buffer /*fb_synth_ref*/, output_frame );
} }
} }
else if ( st->extl == SWB_BWE || st->extl == FB_BWE || ( output_Fs >= 32000 && st->core == ACELP_CORE && st->bwidth > NB && st->bws_cnt > 0 && !st->ppp_mode_dec && !( st->nelp_mode_dec == 1 && st->bfi == 1 ) ) ) else if ( st->extl == SWB_BWE || st->extl == FB_BWE || flag_bwe_bws )
{ {
/* SWB BWE decoder */ /* SWB BWE decoder */
swb_bwe_dec( st, output[n], synth[n], hb_synth[n], use_cldfb_for_dft, output_frame ); swb_bwe_dec( st, output[n], synth[n], hb_synth[n], use_cldfb_for_dft, output_frame );
} }
if ( ( st->core == ACELP_CORE && ( st->extl == -1 || st->extl == SWB_CNG ) ) && flag_bwe_bws == 0 )
{
set_f( hb_synth[n], 0.0f, L_FRAME48k );
}
/*---------------------------------------------------------------------* /*---------------------------------------------------------------------*
* FEC - recovery after lost HQ core (smoothing of the BWE component) * FEC - recovery after lost HQ core (smoothing of the BWE component)
*---------------------------------------------------------------------*/ *---------------------------------------------------------------------*/
...@@ -560,22 +570,6 @@ ivas_error ivas_core_dec( ...@@ -560,22 +570,6 @@ ivas_error ivas_core_dec(
stereo_icBWE_dec( hCPE, hb_synth[0], hb_synth[1], tmp_buffer /*fb_synth_ref*/, voice_factors[0], output_frame ); stereo_icBWE_dec( hCPE, hb_synth[0], hb_synth[1], tmp_buffer /*fb_synth_ref*/, voice_factors[0], output_frame );
} }
if ( st->element_mode == EVS_MONO )
{
/*----------------------------------------------------------------*
* BFI waveform adjustment
*----------------------------------------------------------------*/
if ( st->core == ACELP_CORE && !st->bfi && st->prev_bfi && st->last_total_brate >= HQ_48k && st->last_codec_mode == MODE2 && ( st->last_core_bfi == TCX_20_CORE || st->last_core_bfi == TCX_10_CORE ) && st->hPlcInfo->concealment_method == TCX_NONTONAL && st->hPlcInfo->nbLostCmpt < 4 )
{
tmps = NS2SA( output_Fs, DELAY_CLDFB_NS );
waveform_adj2( st->hPlcInfo, st->hTonalMDCTConc->secondLastPcmOut, synth[n] + tmps, tmps, st->hPlcInfo->nbLostCmpt + 1, st->bfi );
st->hPlcInfo->Pitch = 0;
}
}
/*----------------------------------------------------------------* /*----------------------------------------------------------------*
* Transition and synchronization of BWE components * Transition and synchronization of BWE components
*----------------------------------------------------------------*/ *----------------------------------------------------------------*/
...@@ -589,18 +583,10 @@ ivas_error ivas_core_dec( ...@@ -589,18 +583,10 @@ ivas_error ivas_core_dec(
tmps = NS2SA( output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_12k8_NS ); tmps = NS2SA( output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_12k8_NS );
} }
else else
{
if ( st->extl == SWB_BWE_HIGHRATE || st->extl == FB_BWE_HIGHRATE )
{
/* HR SWB BWE on top of ACELP@16kHz */
tmps = NS2SA( output_Fs, DELAY_BWE_TOTAL_NS );
}
else
{ {
/* TBE on top of ACELP@16kHz */ /* TBE on top of ACELP@16kHz */
tmps = NS2SA( output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_16k_NS ); tmps = NS2SA( output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_16k_NS );
} }
}
/* Smooth transitions when switching between different technologies */ /* Smooth transitions when switching between different technologies */
if ( !( ( st->core == TCX_20_CORE || st->core == TCX_10_CORE || st->core == HQ_CORE ) && st->last_core == ACELP_CORE ) && if ( !( ( st->core == TCX_20_CORE || st->core == TCX_10_CORE || st->core == HQ_CORE ) && st->last_core == ACELP_CORE ) &&
...@@ -733,11 +719,9 @@ ivas_error ivas_core_dec( ...@@ -733,11 +719,9 @@ ivas_error ivas_core_dec(
} /* n_channels loop */ } /* n_channels loop */
#ifdef DEBUG_MODE_INFO #ifdef DEBUG_MODE_INFO
output_debug_mode_info_dec( sts, n_channels, output_frame, pitch_buf ); output_debug_mode_info_dec( sts, n_channels, output_frame, pitch_buf );
#endif #endif
pop_wmops(); pop_wmops();
return error; return error;
} }
......
...@@ -54,6 +54,8 @@ static void read_stereo_mode_and_bwidth( CPE_DEC_HANDLE hCPE, const Decoder_Stru ...@@ -54,6 +54,8 @@ static void read_stereo_mode_and_bwidth( CPE_DEC_HANDLE hCPE, const Decoder_Stru
static void stereo_mode_combined_format_dec( const Decoder_Struct *st_ivas, CPE_DEC_HANDLE hCPE ); static void stereo_mode_combined_format_dec( const Decoder_Struct *st_ivas, CPE_DEC_HANDLE hCPE );
static ivas_error stereo_dft_dec_main( CPE_DEC_HANDLE hCPE, const int32_t ivas_total_brate, const int16_t n_channels, float *p_res_buf, float *output[], float outputHB[][L_FRAME48k], const int16_t output_frame );
/*--------------------------------------------------------------------------* /*--------------------------------------------------------------------------*
* ivas_cpe_dec() * ivas_cpe_dec()
...@@ -74,7 +76,7 @@ ivas_error ivas_cpe_dec( ...@@ -74,7 +76,7 @@ ivas_error ivas_cpe_dec(
int16_t last_bwidth; int16_t last_bwidth;
int16_t tdm_ratio_idx; int16_t tdm_ratio_idx;
float outputHB[CPE_CHANNELS][L_FRAME48k]; /* 'float' buffer for output HB synthesis, both channels */ float outputHB[CPE_CHANNELS][L_FRAME48k]; /* 'float' buffer for output HB synthesis, both channels */
float res_buf[STEREO_DFT_N_8k]; float *res_buf = NULL;
CPE_DEC_HANDLE hCPE; CPE_DEC_HANDLE hCPE;
Decoder_State **sts; Decoder_State **sts;
STEREO_DFT_CONFIG_DATA_HANDLE hConfigDft; STEREO_DFT_CONFIG_DATA_HANDLE hConfigDft;
...@@ -265,6 +267,8 @@ ivas_error ivas_cpe_dec( ...@@ -265,6 +267,8 @@ ivas_error ivas_cpe_dec(
} }
else else
{ {
res_buf = outputHB[0]; /* note: temporarily reused buffer */
if ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) if ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT )
{ {
nb_bits -= nb_bits_metadata; nb_bits -= nb_bits_metadata;
...@@ -382,13 +386,17 @@ ivas_error ivas_cpe_dec( ...@@ -382,13 +386,17 @@ ivas_error ivas_cpe_dec(
if ( sts[1] != NULL ) if ( sts[1] != NULL )
{ {
sts[1]->active_cnt = 0; sts[1]->active_cnt = 0;
if ( sts[1]->ini_frame == 0 )
{
sts[1]->active_cnt = CNG_TYPE_HO;
}
} }
} }
else else
{ {
sts[n]->VAD = 1; sts[n]->VAD = 1;
sts[n]->active_cnt++; sts[n]->active_cnt++;
sts[n]->active_cnt = min( sts[n]->active_cnt, 100 ); sts[n]->active_cnt = min( sts[n]->active_cnt, 200 );
} }
/* set CNA flag */ /* set CNA flag */
...@@ -443,40 +451,10 @@ ivas_error ivas_cpe_dec( ...@@ -443,40 +451,10 @@ ivas_error ivas_cpe_dec(
if ( hCPE->element_mode == IVAS_CPE_DFT && !( hCPE->nchan_out == 1 && hConfigDft->res_cod_mode == STEREO_DFT_RES_COD_OFF ) ) if ( hCPE->element_mode == IVAS_CPE_DFT && !( hCPE->nchan_out == 1 && hConfigDft->res_cod_mode == STEREO_DFT_RES_COD_OFF ) )
{ {
float DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX]; if ( ( error = stereo_dft_dec_main( hCPE, ivas_total_brate, n_channels, res_buf, output, outputHB, output_frame ) ) != IVAS_ERR_OK )
/* core decoder */
if ( ( error = ivas_core_dec( NULL, NULL, hCPE, st_ivas->hMCT, n_channels, output, outputHB, DFT, 0 ) ) != IVAS_ERR_OK )
{ {
return error; return error;
} }
/* DFT Stereo residual decoding */
if ( hCPE->hStereoDft->res_cod_band_max > 0 && !st_ivas->bfi )
{
stereo_dft_dec_res( hCPE, res_buf, output[1] );
stereo_dft_dec_analyze( hCPE, output[1], DFT, 1, L_FRAME8k, output_frame, DFT_STEREO_DEC_ANA_LB, 0, 0 );
}
/* DFT stereo CNG */
stereo_dtf_cng( hCPE, ivas_total_brate, DFT, output_frame );
/* decoding */
if ( hCPE->nchan_out == 1 )
{
stereo_dft_unify_dmx( hCPE->hStereoDft, sts[0], DFT, hCPE->input_mem[1], hCPE->hStereoCng->prev_sid_nodata );
}
else
{
stereo_dft_dec( hCPE->hStereoDft, sts[0], DFT, hCPE->input_mem[1], hCPE->hStereoCng, 0, 0, 0, 0, 0, 0, MAX_PARAM_SPATIAL_SUBFRAMES );
}
/* synthesis iFFT */
for ( n = 0; n < hCPE->nchan_out; n++ )
{
stereo_dft_dec_synthesize( hCPE, DFT, n, output[n], output_frame );
}
} }
else if ( hCPE->element_mode == IVAS_CPE_TD ) else if ( hCPE->element_mode == IVAS_CPE_TD )
{ {
...@@ -602,6 +580,72 @@ ivas_error ivas_cpe_dec( ...@@ -602,6 +580,72 @@ ivas_error ivas_cpe_dec(
} }
/*-------------------------------------------------------------------------
* stereo_dft_dec_main()
*
* DFT decoder main function
*-------------------------------------------------------------------------*/
static ivas_error stereo_dft_dec_main(
CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
const int32_t ivas_total_brate, /* i : IVAS total bitrate */
const int16_t n_channels, /* i : number of channels to be decoded */
float *p_res_buf, /* i : DFT stereo residual S signal */
float *output[], /* o : output synthesis signal */
float outputHB[][L_FRAME48k], /* o : output HB synthesis signal */
const int16_t output_frame /* i : output frame length per channel */
)
{
float DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX];
int16_t n;
Decoder_State *st0;
ivas_error error;
st0 = hCPE->hCoreCoder[0];
/* copy from temporary buffer */
if ( hCPE->hStereoDft->res_cod_band_max > 0 && !st0->bfi )
{
mvr2r( p_res_buf, DFT[1], STEREO_DFT_N_8k );
}
/* core decoder */
if ( ( error = ivas_core_dec( NULL, NULL, hCPE, NULL, n_channels, output, outputHB, DFT, 0 ) ) != IVAS_ERR_OK )
{
return error;
}
/* DFT Stereo residual decoding */
if ( hCPE->hStereoDft->res_cod_band_max > 0 && !st0->bfi )
{
stereo_dft_dec_res( hCPE, DFT[1] /*res_buf*/, output[1] );
stereo_dft_dec_analyze( hCPE, output[1], DFT, 1, L_FRAME8k, output_frame, DFT_STEREO_DEC_ANA_LB, 0, 0 );
}
/* DFT stereo CNG */
stereo_dtf_cng( hCPE, ivas_total_brate, DFT, output_frame );
/* decoding */
if ( hCPE->nchan_out == 1 )
{
stereo_dft_unify_dmx( hCPE->hStereoDft, st0, DFT, hCPE->input_mem[1], hCPE->hStereoCng->prev_sid_nodata );
}
else
{
stereo_dft_dec( hCPE->hStereoDft, st0, DFT, hCPE->input_mem[1], hCPE->hStereoCng, 0, 0, 0, 0, 0, 0, MAX_PARAM_SPATIAL_SUBFRAMES );
}
/* synthesis iFFT */
for ( n = 0; n < hCPE->nchan_out; n++ )
{
stereo_dft_dec_synthesize( hCPE, DFT, n, output[n], output_frame );
}
return IVAS_ERR_OK;
}
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
* create_cpe_dec() * create_cpe_dec()
* *
......
...@@ -1554,7 +1554,8 @@ void ivas_dirac_dec_render( ...@@ -1554,7 +1554,8 @@ void ivas_dirac_dec_render(
uint16_t slot_size, n_samples_sf, ch, nchan_intern; uint16_t slot_size, n_samples_sf, ch, nchan_intern;
SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom;
float *output_f_local[MAX_OUTPUT_CHANNELS]; float *output_f_local[MAX_OUTPUT_CHANNELS];
float output_f_local_buff[MAX_OUTPUT_CHANNELS][L_FRAME48k]; float *p_output_f[MAX_OUTPUT_CHANNELS];
float output_f_local_buff[MAX_OUTPUT_CHANNELS][L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES];
hSpatParamRendCom = st_ivas->hSpatParamRendCom; hSpatParamRendCom = st_ivas->hSpatParamRendCom;
...@@ -1565,7 +1566,7 @@ void ivas_dirac_dec_render( ...@@ -1565,7 +1566,7 @@ void ivas_dirac_dec_render(
for ( ch = 0; ch < nchan_intern; ch++ ) for ( ch = 0; ch < nchan_intern; ch++ )
{ {
output_f_local[ch] = output_f_local_buff[ch]; output_f_local[ch] = output_f_local_buff[ch];
set_zero( output_f_local_buff[ch], nSamplesAsked ); p_output_f[ch] = output_f[ch];
} }
slot_size = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); slot_size = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS );
...@@ -1587,22 +1588,22 @@ void ivas_dirac_dec_render( ...@@ -1587,22 +1588,22 @@ void ivas_dirac_dec_render(
for ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) for ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ )
{ {
ivas_dirac_dec_render_sf( st_ivas, output_f_local, nchan_transport, NULL, NULL ); ivas_dirac_dec_render_sf( st_ivas, output_f_local, nchan_transport, NULL, NULL );
n_samples_sf = hSpatParamRendCom->subframe_nbslots[subframe_idx] * hSpatParamRendCom->slot_size;
for ( ch = 0; ch < nchan_intern; ch++ )
{
output_f_local[ch] += n_samples_sf;
}
/* update combined orientation access index */ n_samples_sf = hSpatParamRendCom->subframe_nbslots[subframe_idx] * hSpatParamRendCom->slot_size;
ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf );
}
for ( ch = 0; ch < nchan_intern; ch++ ) for ( ch = 0; ch < nchan_intern; ch++ )
{ {
/* move to output */
if ( !( ( st_ivas->hDirACRend->hOutSetup.separateChannelEnabled ) && ( st_ivas->hDirACRend->hOutSetup.separateChannelIndex == ch || st_ivas->hDirACRend->hOutSetup.separateChannelIndex + 1 == ch ) ) ) if ( !( ( st_ivas->hDirACRend->hOutSetup.separateChannelEnabled ) && ( st_ivas->hDirACRend->hOutSetup.separateChannelIndex == ch || st_ivas->hDirACRend->hOutSetup.separateChannelIndex + 1 == ch ) ) )
{ {
mvr2r( output_f_local_buff[ch], output_f[ch], *nSamplesRendered ); mvr2r( output_f_local_buff[ch], p_output_f[ch], n_samples_sf );
} }
p_output_f[ch] += n_samples_sf;
}
/* update combined orientation access index */
ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf );
} }
if ( hSpatParamRendCom->slots_rendered == hSpatParamRendCom->num_slots ) if ( hSpatParamRendCom->slots_rendered == hSpatParamRendCom->num_slots )
...@@ -1623,6 +1624,80 @@ void ivas_dirac_dec_render( ...@@ -1623,6 +1624,80 @@ void ivas_dirac_dec_render(
} }
/*-------------------------------------------------------------------------
* Local functions to perform binaural rendering with optimized stack
*------------------------------------------------------------------------*/
static void binRenderer_split(
BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: binaural renderer handle */
ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE hSplitBinRend, /* i/o: ISAR split binaural rendering handle */
COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle */
const int16_t numTimeSlots, /* i : number of time slots to render */
float Cldfb_RealBuffer_Binaural[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */
float Cldfb_ImagBuffer_Binaural[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */
float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals */
float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals */
const int16_t slot_idx_start,
const int16_t num_freq_bands,
const int16_t nchan_out )
{
int16_t pos_idx, slot_idx, ch;
float Cldfb_RealBuffer_Binaural_loc[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX];
float Cldfb_ImagBuffer_Binaural_loc[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX];
/* Perform binaural rendering */
ivas_binRenderer( hBinRenderer, &hSplitBinRend->splitrend.multiBinPoseData, hCombinedOrientationData, numTimeSlots,
#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG
NULL,
#endif
Cldfb_RealBuffer_Binaural_loc, Cldfb_ImagBuffer_Binaural_loc, RealBuffer, ImagBuffer );
for ( slot_idx = 0; slot_idx < numTimeSlots; slot_idx++ )
{
for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
{
mvr2r( Cldfb_RealBuffer_Binaural_loc[0][ch][slot_idx], Cldfb_RealBuffer_Binaural[0][ch][slot_idx], num_freq_bands );
mvr2r( Cldfb_ImagBuffer_Binaural_loc[0][ch][slot_idx], Cldfb_ImagBuffer_Binaural[0][ch][slot_idx], num_freq_bands );
}
}
for ( pos_idx = 0; pos_idx < hBinRenderer->numPoses; pos_idx++ )
{
for ( slot_idx = 0; slot_idx < numTimeSlots; slot_idx++ )
{
for ( ch = 0; ch < nchan_out; ch++ )
{
mvr2r( Cldfb_RealBuffer_Binaural_loc[pos_idx][ch][slot_idx], hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[( pos_idx * BINAURAL_CHANNELS ) + ch][slot_idx_start + slot_idx], num_freq_bands );
mvr2r( Cldfb_ImagBuffer_Binaural_loc[pos_idx][ch][slot_idx], hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[( pos_idx * BINAURAL_CHANNELS ) + ch][slot_idx_start + slot_idx], num_freq_bands );
}
}
}
return;
}
static void binRenderer(
BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: binaural renderer handle */
COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle */
const int16_t numTimeSlots, /* i : number of time slots to render */
float Cldfb_RealBuffer_Binaural[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */
float Cldfb_ImagBuffer_Binaural[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */
float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals */
float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX] /* i : LS signals */
)
{
/* Perform binaural rendering */
ivas_binRenderer( hBinRenderer, NULL, hCombinedOrientationData, numTimeSlots,
#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG
NULL,
#endif
Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, RealBuffer, ImagBuffer );
return;
}
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
* ivas_dirac_dec_render_sf() * ivas_dirac_dec_render_sf()
* *
...@@ -1633,8 +1708,8 @@ void ivas_dirac_dec_render_sf( ...@@ -1633,8 +1708,8 @@ void ivas_dirac_dec_render_sf(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */
const int16_t nchan_transport, /* i : number of transport channels */ const int16_t nchan_transport, /* i : number of transport channels */
float *pppQMfFrame_ts_re[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX], float *pppQMfFrame_ts_re[HOA3_CHANNELS][CLDFB_NO_COL_MAX],
float *pppQMfFrame_ts_im[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX] ) float *pppQMfFrame_ts_im[HOA3_CHANNELS][CLDFB_NO_COL_MAX] )
{ {
int16_t i, ch, idx_in, idx_lfe; int16_t i, ch, idx_in, idx_lfe;
DIRAC_DEC_HANDLE hDirAC; DIRAC_DEC_HANDLE hDirAC;
...@@ -1648,13 +1723,11 @@ void ivas_dirac_dec_render_sf( ...@@ -1648,13 +1723,11 @@ void ivas_dirac_dec_render_sf(
float *p_Rmat; float *p_Rmat;
int16_t slot_idx_start, slot_idx_start_cldfb_synth, md_idx; int16_t slot_idx_start, slot_idx_start_cldfb_synth, md_idx;
/*CLDFB: last output channels reserved to LFT for CICPx*/ /*CLDFB: last output channels reserved to LFE for CICPx*/
float Cldfb_RealBuffer[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; float Cldfb_RealBuffer[MAX_OUTPUT_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX];
float Cldfb_ImagBuffer[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; float Cldfb_ImagBuffer[MAX_OUTPUT_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX];
float Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; float Cldfb_RealBuffer_Binaural[1][BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX];
float Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; float Cldfb_ImagBuffer_Binaural[1][BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX];
float Cldfb_RealBuffer_Temp[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX];
float Cldfb_ImagBuffer_Temp[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX];
int16_t index, num_freq_bands; int16_t index, num_freq_bands;
/* local copies of azi, ele, diffuseness */ /* local copies of azi, ele, diffuseness */
...@@ -1832,8 +1905,8 @@ void ivas_dirac_dec_render_sf( ...@@ -1832,8 +1905,8 @@ void ivas_dirac_dec_render_sf(
for ( ch = 0; ch < nchan_transport; ch++ ) for ( ch = 0; ch < nchan_transport; ch++ )
{ {
cldfbAnalysis_ts( &( st_ivas->hTcBuffer->tc[hDirACRend->sba_map_tc[ch]][hSpatParamRendCom->num_freq_bands * index_slot] ), cldfbAnalysis_ts( &( st_ivas->hTcBuffer->tc[hDirACRend->sba_map_tc[ch]][hSpatParamRendCom->num_freq_bands * index_slot] ),
Cldfb_RealBuffer_Temp[ch][slot_idx], Cldfb_RealBuffer_Binaural[0][ch][slot_idx], /* note: it is a tmp. buffer at this point */
Cldfb_ImagBuffer_Temp[ch][slot_idx], Cldfb_ImagBuffer_Binaural[0][ch][slot_idx], /* note: it is a tmp. buffer at this point */
hSpatParamRendCom->num_freq_bands, hSpatParamRendCom->num_freq_bands,
st_ivas->cldfbAnaDec[ch] ); st_ivas->cldfbAnaDec[ch] );
} }
...@@ -1841,7 +1914,7 @@ void ivas_dirac_dec_render_sf( ...@@ -1841,7 +1914,7 @@ void ivas_dirac_dec_render_sf(
if ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) if ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ )
{ {
ivas_omasa_preProcessStereoTransportsForEditedObjects( st_ivas, Cldfb_RealBuffer_Temp, Cldfb_ImagBuffer_Temp, hSpatParamRendCom->num_freq_bands, subframe_idx ); ivas_omasa_preProcessStereoTransportsForEditedObjects( st_ivas, Cldfb_RealBuffer_Binaural[0], Cldfb_ImagBuffer_Binaural[0], hSpatParamRendCom->num_freq_bands, subframe_idx );
} }
} }
...@@ -1868,8 +1941,8 @@ void ivas_dirac_dec_render_sf( ...@@ -1868,8 +1941,8 @@ void ivas_dirac_dec_render_sf(
{ {
for ( ch = 0; ch < nchan_transport; ch++ ) for ( ch = 0; ch < nchan_transport; ch++ )
{ {
mvr2r( Cldfb_RealBuffer_Temp[ch][slot_idx], Cldfb_RealBuffer[ch][0], hSpatParamRendCom->num_freq_bands ); mvr2r( Cldfb_RealBuffer_Binaural[0][ch][slot_idx], Cldfb_RealBuffer[ch][0], hSpatParamRendCom->num_freq_bands );
mvr2r( Cldfb_ImagBuffer_Temp[ch][slot_idx], Cldfb_ImagBuffer[ch][0], hSpatParamRendCom->num_freq_bands ); mvr2r( Cldfb_ImagBuffer_Binaural[0][ch][slot_idx], Cldfb_ImagBuffer[ch][0], hSpatParamRendCom->num_freq_bands );
} }
} }
else else
...@@ -2313,34 +2386,23 @@ void ivas_dirac_dec_render_sf( ...@@ -2313,34 +2386,23 @@ void ivas_dirac_dec_render_sf(
} }
/* Perform binaural rendering */ /* Perform binaural rendering */
ivas_binRenderer( st_ivas->hBinRenderer, ( st_ivas->hSplitBinRend == NULL ) ? NULL : &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, st_ivas->hCombinedOrientationData, hSpatParamRendCom->subframe_nbslots[subframe_idx],
#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG
NULL,
#endif
Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer );
if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
{ {
int16_t pos_idx; binRenderer_split( st_ivas->hBinRenderer, st_ivas->hSplitBinRend, st_ivas->hCombinedOrientationData, hSpatParamRendCom->subframe_nbslots[subframe_idx],
for ( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer, slot_idx_start, hSpatParamRendCom->num_freq_bands, st_ivas->hDecoderConfig->nchan_out );
{
for ( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ )
{
for ( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ )
{
mvr2r( Cldfb_RealBuffer_Binaural[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[( pos_idx * BINAURAL_CHANNELS ) + ch][slot_idx_start + slot_idx], hSpatParamRendCom->num_freq_bands );
mvr2r( Cldfb_ImagBuffer_Binaural[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[( pos_idx * BINAURAL_CHANNELS ) + ch][slot_idx_start + slot_idx], hSpatParamRendCom->num_freq_bands );
}
}
} }
else
{
binRenderer( st_ivas->hBinRenderer, st_ivas->hCombinedOrientationData, hSpatParamRendCom->subframe_nbslots[subframe_idx],
Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer );
} }
/* Inverse CLDFB*/ /* Inverse CLDFB*/
for ( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) for ( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ )
{ {
/* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */ /* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */
float *RealBuffer[MAX_PARAM_SPATIAL_SUBFRAMES]; float *RealBuffer[CLDFB_SLOTS_PER_SUBFRAME];
float *ImagBuffer[MAX_PARAM_SPATIAL_SUBFRAMES]; float *ImagBuffer[CLDFB_SLOTS_PER_SUBFRAME];
for ( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ ) for ( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ )
{ {
...@@ -2364,8 +2426,8 @@ void ivas_dirac_dec_render_sf( ...@@ -2364,8 +2426,8 @@ void ivas_dirac_dec_render_sf(
} }
else else
{ {
float *RealBuffer[MAX_PARAM_SPATIAL_SUBFRAMES]; float *RealBuffer[CLDFB_SLOTS_PER_SUBFRAME];
float *ImagBuffer[MAX_PARAM_SPATIAL_SUBFRAMES]; float *ImagBuffer[CLDFB_SLOTS_PER_SUBFRAME];
int16_t outchannels; int16_t outchannels;
idx_in = 0; idx_in = 0;
...@@ -2391,7 +2453,10 @@ void ivas_dirac_dec_render_sf( ...@@ -2391,7 +2453,10 @@ void ivas_dirac_dec_render_sf(
/* Move the separated and the LFE channels to temporary variables as spatial synthesis may overwrite current channels */ /* Move the separated and the LFE channels to temporary variables as spatial synthesis may overwrite current channels */
mvr2r( &( output_f[st_ivas->hOutSetup.separateChannelIndex][subframe_start_sample] ), tmp_separated, num_samples_subframe ); mvr2r( &( output_f[st_ivas->hOutSetup.separateChannelIndex][subframe_start_sample] ), tmp_separated, num_samples_subframe );
if ( hDirACRend->hOutSetup.num_lfe > 0 )
{
mvr2r( &( output_f[LFE_CHANNEL][subframe_start_sample] ), tmp_lfe, num_samples_subframe ); mvr2r( &( output_f[LFE_CHANNEL][subframe_start_sample] ), tmp_lfe, num_samples_subframe );
}
for ( ch = 0; ch < outchannels; ch++ ) for ( ch = 0; ch < outchannels; ch++ )
{ {
......
...@@ -380,25 +380,25 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot( ...@@ -380,25 +380,25 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot(
) )
{ {
int16_t param_band_idx, band, ch_idx; int16_t param_band_idx, band, ch_idx;
float mixing_matrix_smooth[MAX_CICP_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS]; float mixing_matrix_smooth[MAX_LS_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS];
float mixing_matrix_res_smooth[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; float mixing_matrix_res_smooth[MAX_LS_CHANNELS * MAX_LS_CHANNELS];
float mixing_matrix_buffer[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; float mixing_matrix_buffer[MAX_LS_CHANNELS * MAX_LS_CHANNELS];
int16_t have_residual; int16_t have_residual;
float input_f_real[PARAM_MC_MAX_TRANSPORT_CHANS]; float input_f_real[PARAM_MC_MAX_TRANSPORT_CHANS];
float input_f_imag[PARAM_MC_MAX_TRANSPORT_CHANS]; float input_f_imag[PARAM_MC_MAX_TRANSPORT_CHANS];
float output_f_real[MAX_CICP_CHANNELS]; float output_f_real[MAX_LS_CHANNELS];
float output_f_imag[MAX_CICP_CHANNELS]; float output_f_imag[MAX_LS_CHANNELS];
float diff_f_real[MAX_CICP_CHANNELS]; float diff_f_real[MAX_LS_CHANNELS];
float diff_f_imag[MAX_CICP_CHANNELS]; float diff_f_imag[MAX_LS_CHANNELS];
int16_t brange[2]; int16_t brange[2];
DIRAC_OUTPUT_SYNTHESIS_COV_STATE h_synthesis_state = hParamMC->h_output_synthesis_cov_state; DIRAC_OUTPUT_SYNTHESIS_COV_STATE h_synthesis_state = hParamMC->h_output_synthesis_cov_state;
set_zero( input_f_real, PARAM_MC_MAX_TRANSPORT_CHANS ); set_zero( input_f_real, PARAM_MC_MAX_TRANSPORT_CHANS );
set_zero( input_f_imag, PARAM_MC_MAX_TRANSPORT_CHANS ); set_zero( input_f_imag, PARAM_MC_MAX_TRANSPORT_CHANS );
set_zero( output_f_real, MAX_CICP_CHANNELS ); set_zero( output_f_real, MAX_LS_CHANNELS );
set_zero( output_f_imag, MAX_CICP_CHANNELS ); set_zero( output_f_imag, MAX_LS_CHANNELS );
set_zero( diff_f_real, MAX_CICP_CHANNELS ); set_zero( diff_f_real, MAX_LS_CHANNELS );
set_zero( diff_f_imag, MAX_CICP_CHANNELS ); set_zero( diff_f_imag, MAX_LS_CHANNELS );
for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx++ ) for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx++ )
{ {
......
...@@ -487,7 +487,7 @@ ivas_error ivas_dec_setup( ...@@ -487,7 +487,7 @@ ivas_error ivas_dec_setup(
} }
/*-------------------------------------------------------------------* /*-------------------------------------------------------------------*
* Read other signling (ISM/MC mode, number of channels, etc.) * Read other signaling (ISM/MC mode, number of channels, etc.)
*-------------------------------------------------------------------*/ *-------------------------------------------------------------------*/
if ( is_DTXrate( ivas_total_brate ) == 0 ) if ( is_DTXrate( ivas_total_brate ) == 0 )
...@@ -1252,6 +1252,7 @@ ivas_error ivas_init_decoder( ...@@ -1252,6 +1252,7 @@ ivas_error ivas_init_decoder(
int16_t sce_id, cpe_id; int16_t sce_id, cpe_id;
int16_t numCldfbAnalyses, numCldfbSyntheses; int16_t numCldfbAnalyses, numCldfbSyntheses;
int16_t granularity, n_channels_transport_jbm; int16_t granularity, n_channels_transport_jbm;
int16_t nchan_out_buff;
int32_t output_Fs, ivas_total_brate; int32_t output_Fs, ivas_total_brate;
int32_t delay_ns; int32_t delay_ns;
AUDIO_CONFIG output_config; AUDIO_CONFIG output_config;
...@@ -2304,8 +2305,16 @@ ivas_error ivas_init_decoder( ...@@ -2304,8 +2305,16 @@ ivas_error ivas_init_decoder(
*-----------------------------------------------------------------*/ *-----------------------------------------------------------------*/
if ( st_ivas->mc_mode == MC_MODE_MCT || st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) if ( st_ivas->mc_mode == MC_MODE_MCT || st_ivas->mc_mode == MC_MODE_PARAMUPMIX )
{
if ( st_ivas->hIntSetup.index_lfe[0] != -1 )
{ {
delay_ns = st_ivas->binaural_latency_ns; delay_ns = st_ivas->binaural_latency_ns;
}
else
{
delay_ns = 0;
}
if ( st_ivas->hBinRenderer != NULL ) if ( st_ivas->hBinRenderer != NULL )
{ {
if ( st_ivas->hBinRenderer->render_lfe ) if ( st_ivas->hBinRenderer->render_lfe )
...@@ -2363,7 +2372,7 @@ ivas_error ivas_init_decoder( ...@@ -2363,7 +2372,7 @@ ivas_error ivas_init_decoder(
} }
} }
if ( ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) && st_ivas->hDecoderConfig->Opt_tsm ) if ( ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) && hDecoderConfig->Opt_tsm )
{ {
if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL )
{ {
...@@ -2378,22 +2387,13 @@ ivas_error ivas_init_decoder( ...@@ -2378,22 +2387,13 @@ ivas_error ivas_init_decoder(
* Allocate floating-point output audio buffers * Allocate floating-point output audio buffers
*-----------------------------------------------------------------*/ *-----------------------------------------------------------------*/
for ( n = 0; n < ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); n++ ) nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, ivas_total_brate );
if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff, hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK )
{ {
/* note: these are intra-frame heap memories */ return error;
if ( ( st_ivas->p_output_f[n] = (float *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) );
}
}
for ( ; n < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; n++ )
{
st_ivas->p_output_f[n] = NULL;
} }
return IVAS_ERR_OK;
return error;
} }
...@@ -2781,7 +2781,7 @@ void ivas_destroy_dec( ...@@ -2781,7 +2781,7 @@ void ivas_destroy_dec(
ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin ); ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin );
/* Crend handle */ /* Crend handle */
ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ), ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ); ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) );
/* Reverb handle */ /* Reverb handle */
ivas_reverb_close( &st_ivas->hReverb ); ivas_reverb_close( &st_ivas->hReverb );
...@@ -2848,12 +2848,14 @@ void ivas_destroy_dec( ...@@ -2848,12 +2848,14 @@ void ivas_destroy_dec(
/* Limiter struct */ /* Limiter struct */
ivas_limiter_close( &( st_ivas->hLimiter ) ); ivas_limiter_close( &( st_ivas->hLimiter ) );
/* Decoder configuration structure */
if ( st_ivas->hDecoderConfig != NULL ) if ( st_ivas->hDecoderConfig != NULL )
{ {
free( st_ivas->hDecoderConfig ); free( st_ivas->hDecoderConfig );
st_ivas->hDecoderConfig = NULL; st_ivas->hDecoderConfig = NULL;
} }
/* JBM TC buffer structure */
ivas_jbm_dec_tc_buffer_close( &st_ivas->hTcBuffer ); ivas_jbm_dec_tc_buffer_close( &st_ivas->hTcBuffer );
if ( st_ivas->hJbmMetadata != NULL ) if ( st_ivas->hJbmMetadata != NULL )
...@@ -2865,12 +2867,8 @@ void ivas_destroy_dec( ...@@ -2865,12 +2867,8 @@ void ivas_destroy_dec(
/* floating-point output audio buffers */ /* floating-point output audio buffers */
for ( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ ) for ( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ )
{ {
if ( st_ivas->p_output_f[i] != NULL )
{
free( st_ivas->p_output_f[i] );
st_ivas->p_output_f[i] = NULL; st_ivas->p_output_f[i] = NULL;
} }
}
/* main IVAS handle */ /* main IVAS handle */
free( st_ivas ); free( st_ivas );
......
...@@ -60,7 +60,7 @@ static ivas_error ivas_ism_bitrate_switching_dec( ...@@ -60,7 +60,7 @@ static ivas_error ivas_ism_bitrate_switching_dec(
int16_t tc_nchan_tc_new; int16_t tc_nchan_tc_new;
int16_t tc_nchan_allocate_new; int16_t tc_nchan_allocate_new;
int16_t tc_granularity_new; int16_t tc_granularity_new;
int16_t nchan_out_buff, nchan_out_buff_old; int16_t nchan_out_buff;
nCPE_old = st_ivas->nCPE; nCPE_old = st_ivas->nCPE;
nSCE_old = st_ivas->nSCE; nSCE_old = st_ivas->nSCE;
...@@ -70,7 +70,6 @@ static ivas_error ivas_ism_bitrate_switching_dec( ...@@ -70,7 +70,6 @@ static ivas_error ivas_ism_bitrate_switching_dec(
st_ivas->ism_mode = last_ism_mode; st_ivas->ism_mode = last_ism_mode;
ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old );
st_ivas->ism_mode = ism_mode; st_ivas->ism_mode = ism_mode;
nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 );
if ( ( error = ivas_ism_config( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->nchan_ism, NULL, 0, NULL, NULL, element_brate_tmp, NULL, NULL, 0 ) ) != IVAS_ERR_OK ) if ( ( error = ivas_ism_config( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->nchan_ism, NULL, 0, NULL, NULL, element_brate_tmp, NULL, NULL, 0 ) ) != IVAS_ERR_OK )
{ {
...@@ -122,6 +121,25 @@ static ivas_error ivas_ism_bitrate_switching_dec( ...@@ -122,6 +121,25 @@ static ivas_error ivas_ism_bitrate_switching_dec(
mvs2s( st_ivas->hSpatParamRendCom->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); mvs2s( st_ivas->hSpatParamRendCom->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
} }
#ifdef NONBE_1321_JBM_ASSERT_BITRATE_SWITCHING
/* JBM: when granularity goes down (e.g. Discrete ISM with TD Obj Renderer -> ParamISM with binaural fastconv
render what still fits in the new granularity */
tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs );
if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity )
{
/* flush already done in IVAS_DEC_ReadFormat() */
}
/* JBM: when granularity goes up set samples to discard at the beginning of the frame */
else if ( tc_granularity_new > st_ivas->hTcBuffer->n_samples_granularity )
{
if ( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
}
#endif
if ( st_ivas->ism_mode != last_ism_mode ) if ( st_ivas->ism_mode != last_ism_mode )
{ {
/* EFAP handle */ /* EFAP handle */
...@@ -253,7 +271,7 @@ static ivas_error ivas_ism_bitrate_switching_dec( ...@@ -253,7 +271,7 @@ static ivas_error ivas_ism_bitrate_switching_dec(
} }
/* close the crend binaural renderer */ /* close the crend binaural renderer */
ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ), ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ); ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) );
} }
} }
...@@ -266,17 +284,6 @@ static ivas_error ivas_ism_bitrate_switching_dec( ...@@ -266,17 +284,6 @@ static ivas_error ivas_ism_bitrate_switching_dec(
return error; return error;
} }
/*-----------------------------------------------------------------*
* floating-point output audio buffers
*-----------------------------------------------------------------*/
nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 );
if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK )
{
return error;
}
/*-----------------------------------------------------------------* /*-----------------------------------------------------------------*
* JBM TC buffers * JBM TC buffers
*-----------------------------------------------------------------*/ *-----------------------------------------------------------------*/
...@@ -289,7 +296,9 @@ static ivas_error ivas_ism_bitrate_switching_dec( ...@@ -289,7 +296,9 @@ static ivas_error ivas_ism_bitrate_switching_dec(
tc_nchan_tc_new = ivas_jbm_dec_get_num_tc_channels( st_ivas ); tc_nchan_tc_new = ivas_jbm_dec_get_num_tc_channels( st_ivas );
tc_nchan_allocate_new = tc_nchan_tc_new; tc_nchan_allocate_new = tc_nchan_tc_new;
tc_nchan_full_new = tc_nchan_tc_new; tc_nchan_full_new = tc_nchan_tc_new;
#ifndef NONBE_1321_JBM_ASSERT_BITRATE_SWITCHING
tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs ); tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs );
#endif
if ( st_ivas->ism_mode == ISM_MODE_PARAM && ( st_ivas->renderer_type != RENDERER_MONO_DOWNMIX && st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) if ( st_ivas->ism_mode == ISM_MODE_PARAM && ( st_ivas->renderer_type != RENDERER_MONO_DOWNMIX && st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM ) )
{ {
...@@ -317,6 +326,16 @@ static ivas_error ivas_ism_bitrate_switching_dec( ...@@ -317,6 +326,16 @@ static ivas_error ivas_ism_bitrate_switching_dec(
mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
} }
/*-----------------------------------------------------------------*
* floating-point output audio buffers
*-----------------------------------------------------------------*/
nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 );
if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff, st_ivas->hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK )
{
return error;
}
return IVAS_ERR_OK; return IVAS_ERR_OK;
} }
......
...@@ -193,21 +193,11 @@ void ivas_ism_render_sf( ...@@ -193,21 +193,11 @@ void ivas_ism_render_sf(
ism_md_subframe_update_jbm = st_ivas->hTcBuffer->nb_subframes - 2; ism_md_subframe_update_jbm = st_ivas->hTcBuffer->nb_subframes - 2;
} }
if ( st_ivas->hDecoderConfig->Opt_tsm )
{
for ( i = 0; i < num_objects; i++ )
{
p_tc[i] = &st_ivas->hTcBuffer->tc[i][tc_offset];
}
}
else
{
for ( i = 0; i < num_objects; i++ ) for ( i = 0; i < num_objects; i++ )
{ {
mvr2r( &output_f[i][tc_offset], tc_local[i], n_samples_to_render ); mvr2r( &output_f[i][tc_offset], tc_local[i], n_samples_to_render );
p_tc[i] = tc_local[i]; p_tc[i] = tc_local[i];
} }
}
for ( i = 0; i < nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; i++ ) for ( i = 0; i < nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; i++ )
{ {
...@@ -432,8 +422,7 @@ void ivas_omasa_separate_object_render_jbm( ...@@ -432,8 +422,7 @@ void ivas_omasa_separate_object_render_jbm(
const uint16_t nSamplesRendered, /* i : number of samples rendered */ const uint16_t nSamplesRendered, /* i : number of samples rendered */
float input_f_in[][L_FRAME48k], /* i : separated object signal */ float input_f_in[][L_FRAME48k], /* i : separated object signal */
float *output_f[], /* o : rendered time signal */ float *output_f[], /* o : rendered time signal */
const int16_t subframes_rendered, /* i : number of subframes rendered */ const int16_t subframes_rendered /* i : number of subframes rendered */
const int16_t slots_rendered /* i : number of CLDFB slots rendered */
) )
{ {
VBAP_HANDLE hVBAPdata; VBAP_HANDLE hVBAPdata;
...@@ -474,27 +463,15 @@ void ivas_omasa_separate_object_render_jbm( ...@@ -474,27 +463,15 @@ void ivas_omasa_separate_object_render_jbm(
num_objects = st_ivas->nchan_ism; num_objects = st_ivas->nchan_ism;
} }
offsetSamples = slots_rendered * hSpatParamRendCom->slot_size;
for ( j = 0; j < nchan_out_woLFE + num_lfe; j++ ) for ( j = 0; j < nchan_out_woLFE + num_lfe; j++ )
{ {
output_f_local[j] = output_f[j]; output_f_local[j] = output_f[j];
} }
if ( st_ivas->hDecoderConfig->Opt_tsm )
{
for ( obj = 0; obj < num_objects; obj++ )
{
input_f[obj] = &st_ivas->hTcBuffer->tc[obj + 2][offsetSamples];
}
}
else
{
for ( obj = 0; obj < num_objects; obj++ ) for ( obj = 0; obj < num_objects; obj++ )
{ {
input_f[obj] = input_f_in[obj]; input_f[obj] = input_f_in[obj];
} }
}
slots_to_render = nSamplesRendered / hSpatParamRendCom->slot_size; slots_to_render = nSamplesRendered / hSpatParamRendCom->slot_size;
first_sf = subframes_rendered; first_sf = subframes_rendered;
......
...@@ -757,14 +757,13 @@ ivas_error ivas_jbm_dec_tc( ...@@ -757,14 +757,13 @@ ivas_error ivas_jbm_dec_tc(
void ivas_jbm_dec_feed_tc_to_renderer( void ivas_jbm_dec_feed_tc_to_renderer(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
const int16_t nSamplesForRendering, /* i : number of TC samples available for rendering */ const int16_t nSamplesForRendering, /* i : number of TC samples available for rendering */
int16_t *nSamplesResidual, /* o : number of samples not fitting into the renderer grid and buffer for the next call*/ int16_t *nSamplesResidual /* o : number of samples not fitting into the renderer grid and buffer for the next call*/
float *data /* i : transport channels */
) )
{ {
float data_f[MAX_CLDFB_DIGEST_CHANNELS][MAX_JBM_L_FRAME48k]; /* 'float' buffer for transport channels that will be directly converted with the CLDFB */ float tmp_buf[MAX_JBM_L_FRAME48k];
float *p_data_f[MAX_CLDFB_DIGEST_CHANNELS]; float *p_data_f[FOA_CHANNELS + MAX_NUM_OBJECTS];
int16_t n, n_render_timeslots, n_ch_cldfb; int16_t n, n_render_timeslots, n_ch_cldfb;
int16_t ch; int16_t ch, offset, len_offset;
DECODER_TC_BUFFER_HANDLE hTcBuffer; DECODER_TC_BUFFER_HANDLE hTcBuffer;
hTcBuffer = st_ivas->hTcBuffer; hTcBuffer = st_ivas->hTcBuffer;
...@@ -772,14 +771,8 @@ void ivas_jbm_dec_feed_tc_to_renderer( ...@@ -772,14 +771,8 @@ void ivas_jbm_dec_feed_tc_to_renderer(
if ( st_ivas->hDecoderConfig->Opt_tsm ) if ( st_ivas->hDecoderConfig->Opt_tsm )
{ {
int16_t n_samples_still_available, m; int16_t n_samples_still_available;
int16_t n_ch_full_copy; int16_t n_ch_full_copy, n_ch_res_copy;
int16_t n_ch_res_copy;
for ( n = 0; n < n_ch_cldfb; n++ )
{
p_data_f[n] = &data_f[n][0];
}
n_samples_still_available = hTcBuffer->n_samples_buffered - hTcBuffer->n_samples_rendered; n_samples_still_available = hTcBuffer->n_samples_buffered - hTcBuffer->n_samples_rendered;
hTcBuffer->n_samples_buffered = n_samples_still_available + nSamplesForRendering + hTcBuffer->n_samples_discard; hTcBuffer->n_samples_buffered = n_samples_still_available + nSamplesForRendering + hTcBuffer->n_samples_discard;
...@@ -788,27 +781,38 @@ void ivas_jbm_dec_feed_tc_to_renderer( ...@@ -788,27 +781,38 @@ void ivas_jbm_dec_feed_tc_to_renderer(
n_ch_full_copy = min( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); n_ch_full_copy = min( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full );
n_ch_res_copy = hTcBuffer->nchan_transport_jbm - hTcBuffer->nchan_buffer_full; n_ch_res_copy = hTcBuffer->nchan_transport_jbm - hTcBuffer->nchan_buffer_full;
for ( ch = 0; ch < n_ch_full_copy; ch++ ) /* buffers are shared between 'hTcBuffer->tc[]' and 'p_output_f[]':
in case of 'length(hTcBuffer->tc[]) < length(p_output_f[])', reset of TC buffers
pointers is needed after ivas_buffer_interleaved_to_deinterleaved() */
len_offset = NS2SA( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS );
if ( len_offset < L_FRAME48k )
{ {
set_zero( hTcBuffer->tc[ch], hTcBuffer->n_samples_discard ); offset = 0;
mvr2r( hTcBuffer->tc[ch] + hTcBuffer->n_samples_rendered, hTcBuffer->tc[ch] + hTcBuffer->n_samples_discard, n_samples_still_available ); for ( ch = 0; ch < max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); ch++ )
for ( m = 0; m < nSamplesForRendering; m++ )
{ {
hTcBuffer->tc[ch][n_samples_still_available + hTcBuffer->n_samples_discard + m] = data[m * hTcBuffer->nchan_transport_jbm + ch]; hTcBuffer->tc[ch] = &hTcBuffer->tc_buffer[offset];
offset += len_offset;
} }
} }
for ( ch = 0; ch < n_ch_full_copy; ch++ )
{
mvr2r( hTcBuffer->tc[ch], tmp_buf, nSamplesForRendering );
set_zero( hTcBuffer->tc[ch], hTcBuffer->n_samples_discard );
mvr2r( hTcBuffer->tc_buffer_old[ch], hTcBuffer->tc[ch] + hTcBuffer->n_samples_discard, n_samples_still_available );
mvr2r( tmp_buf, hTcBuffer->tc[ch] + n_samples_still_available + hTcBuffer->n_samples_discard, nSamplesForRendering - *nSamplesResidual );
mvr2r( tmp_buf + nSamplesForRendering - *nSamplesResidual, hTcBuffer->tc_buffer_old[ch], *nSamplesResidual );
}
if ( n_ch_res_copy > 0 ) if ( n_ch_res_copy > 0 )
{ {
for ( ; ch < hTcBuffer->nchan_transport_jbm; ch++ ) for ( ; ch < hTcBuffer->nchan_transport_jbm; ch++ )
{ {
mvr2r( hTcBuffer->tc[ch], p_data_f[ch], n_samples_still_available ); p_data_f[ch] = hTcBuffer->tc[ch];
mvr2r( hTcBuffer->tc[ch], tmp_buf, nSamplesForRendering );
for ( m = 0; m < nSamplesForRendering; m++ ) mvr2r( hTcBuffer->tc_buffer_old[ch], p_data_f[ch], n_samples_still_available );
{ mvr2r( tmp_buf, p_data_f[ch] + n_samples_still_available, nSamplesForRendering - *nSamplesResidual );
p_data_f[ch][n_samples_still_available + m] = data[m * hTcBuffer->nchan_transport_jbm + ch]; mvr2r( tmp_buf + nSamplesForRendering - *nSamplesResidual, hTcBuffer->tc_buffer_old[ch], *nSamplesResidual );
}
mvr2r( p_data_f[ch] + hTcBuffer->n_samples_available, hTcBuffer->tc[ch], *nSamplesResidual );
} }
} }
...@@ -821,7 +825,8 @@ void ivas_jbm_dec_feed_tc_to_renderer( ...@@ -821,7 +825,8 @@ void ivas_jbm_dec_feed_tc_to_renderer(
p_data_f[n] = &st_ivas->p_output_f[n][0]; p_data_f[n] = &st_ivas->p_output_f[n][0];
} }
for ( n = 0; n < ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); n++ ) ch = max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full );
for ( n = 0; n < ch; n++ )
{ {
hTcBuffer->tc[n] = st_ivas->p_output_f[n]; /* note: buffers needed in the TD decorellator */ hTcBuffer->tc[n] = st_ivas->p_output_f[n]; /* note: buffers needed in the TD decorellator */
} }
...@@ -894,7 +899,7 @@ ivas_error ivas_jbm_dec_render( ...@@ -894,7 +899,7 @@ ivas_error ivas_jbm_dec_render(
if ( !st_ivas->hDecoderConfig->Opt_tsm ) if ( !st_ivas->hDecoderConfig->Opt_tsm )
{ {
for ( n = 0; n < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; n++ ) for ( n = 0; n < MAX_INTERN_CHANNELS; n++ )
{ {
st_ivas->hTcBuffer->tc[n] = p_output[n]; st_ivas->hTcBuffer->tc[n] = p_output[n];
} }
...@@ -1131,6 +1136,10 @@ ivas_error ivas_jbm_dec_render( ...@@ -1131,6 +1136,10 @@ ivas_error ivas_jbm_dec_render(
else if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) else if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM )
{ {
ivas_dirac_dec_binaural_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output ); ivas_dirac_dec_binaural_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output );
for ( n = 0; n < st_ivas->hDecoderConfig->nchan_out; n++ )
{
v_multc( p_output[n], 2.0f, p_output[n], *nSamplesRendered );
}
} }
else else
{ {
...@@ -1153,6 +1162,10 @@ ivas_error ivas_jbm_dec_render( ...@@ -1153,6 +1162,10 @@ ivas_error ivas_jbm_dec_render(
set_zero( p_output[n], *nSamplesRendered ); set_zero( p_output[n], *nSamplesRendered );
} }
} }
for ( n = 0; n < st_ivas->hDecoderConfig->nchan_out; n++ )
{
v_multc( p_output[n], 2.0f, p_output[n], *nSamplesRendered );
}
} }
} }
else if ( st_ivas->ivas_format == MC_FORMAT ) else if ( st_ivas->ivas_format == MC_FORMAT )
...@@ -1347,7 +1360,7 @@ ivas_error ivas_jbm_dec_render( ...@@ -1347,7 +1360,7 @@ ivas_error ivas_jbm_dec_render(
break; break;
case PCM_FLOAT32: case PCM_FLOAT32:
ivas_syn_output_f( p_output, *nSamplesRendered, nchan_out_syn_output, (float *) data ); ivas_buffer_deinterleaved_to_interleaved( p_output, nchan_out_syn_output, *nSamplesRendered, (float *) data );
break; break;
default: default:
error = IVAS_ERR_UNKNOWN; error = IVAS_ERR_UNKNOWN;
...@@ -1385,7 +1398,7 @@ ivas_error ivas_jbm_dec_flush_renderer( ...@@ -1385,7 +1398,7 @@ ivas_error ivas_jbm_dec_flush_renderer(
int16_t n_slots_still_available; int16_t n_slots_still_available;
int16_t n_samples_to_render; int16_t n_samples_to_render;
DECODER_TC_BUFFER_HANDLE hTcBuffer; DECODER_TC_BUFFER_HANDLE hTcBuffer;
float *p_output[MAX_CICP_CHANNELS + MAX_NUM_OBJECTS]; float *p_output[MAX_LS_CHANNELS + MAX_NUM_OBJECTS];
if ( !st_ivas->hDecoderConfig->Opt_tsm ) if ( !st_ivas->hDecoderConfig->Opt_tsm )
{ {
...@@ -1410,13 +1423,12 @@ ivas_error ivas_jbm_dec_flush_renderer( ...@@ -1410,13 +1423,12 @@ ivas_error ivas_jbm_dec_flush_renderer(
{ {
int16_t ch_idx; int16_t ch_idx;
/* render what is still there with zero padding */ /* render available full slots (with new lower granularity) */
for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) for ( ch_idx = 0; ch_idx < max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); ch_idx++ )
{ {
/* move it at the beginning of the TC buffer with zero padding */ /* move it at the beginning of the TC buffer with zero padding */
mvr2r( hTcBuffer->tc[ch_idx] + hTcBuffer->n_samples_rendered, hTcBuffer->tc[ch_idx], n_samples_to_render ); mvr2r( hTcBuffer->tc_buffer_old[ch_idx], hTcBuffer->tc[ch_idx], n_samples_to_render );
set_zero( hTcBuffer->tc[ch_idx] + n_samples_to_render, hTcBuffer->n_samples_granularity - n_samples_to_render ); set_zero( hTcBuffer->tc[ch_idx] + n_samples_to_render, hTcBuffer->n_samples_granularity - n_samples_to_render );
mvr2r( hTcBuffer->tc[ch_idx] + hTcBuffer->n_samples_rendered + n_samples_to_render, hTcBuffer->tc[ch_idx] + hTcBuffer->n_samples_granularity, n_samples_still_available );
} }
/* simple change of the slot info */ /* simple change of the slot info */
...@@ -1514,17 +1526,45 @@ ivas_error ivas_jbm_dec_flush_renderer( ...@@ -1514,17 +1526,45 @@ ivas_error ivas_jbm_dec_flush_renderer(
if ( ism_mode_old == ISM_MASA_MODE_DISC ) if ( ism_mode_old == ISM_MASA_MODE_DISC )
{ {
float *tc_local[MAX_NUM_OBJECTS]; float *tc_local[MAX_NUM_OBJECTS];
int16_t last_dirac_md_idx;
uint16_t nSamplesAvailableNext;
ISM_MODE ism_mode_orig;
RENDERER_TYPE renderer_type_orig;
int32_t ivas_total_brate;
/* copy from ISM delay buffer to the correct place in TCs */
for ( ch_idx = 0; ch_idx < st_ivas->nchan_ism; ch_idx++ ) for ( ch_idx = 0; ch_idx < st_ivas->nchan_ism; ch_idx++ )
{ {
tc_local[ch_idx] = &st_ivas->hTcBuffer->tc[ch_idx + 2][hTcBuffer->n_samples_rendered]; tc_local[ch_idx] = &st_ivas->hTcBuffer->tc[ch_idx + 2][hTcBuffer->n_samples_rendered];
mvr2r( st_ivas->hMasaIsmData->delayBuffer[ch_idx], tc_local[ch_idx], st_ivas->hMasaIsmData->delayBuffer_size ); mvr2r( st_ivas->hMasaIsmData->delayBuffer[ch_idx], tc_local[ch_idx], st_ivas->hMasaIsmData->delayBuffer_size );
} }
if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_output, hTcBuffer->n_samples_granularity ) ) != IVAS_ERR_OK ) /* to render flushed samples, use configuration from the last received frame */
ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
renderer_type_orig = st_ivas->renderer_type;
ism_mode_orig = st_ivas->ism_mode;
st_ivas->ism_mode = ism_mode_old;
st_ivas->renderer_type = renderer_type_old;
st_ivas->hDecoderConfig->ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate;
last_dirac_md_idx = st_ivas->hSpatParamRendCom->render_to_md_map[st_ivas->hSpatParamRendCom->slots_rendered - 1];
/* transfer adapted sf info from hTcBuffer to DirAC */
st_ivas->hSpatParamRendCom->nb_subframes = 1;
st_ivas->hSpatParamRendCom->subframes_rendered = 0;
st_ivas->hSpatParamRendCom->subframe_nbslots[0] = JBM_CLDFB_SLOTS_IN_SUBFRAME;
st_ivas->hSpatParamRendCom->slots_rendered = 0;
st_ivas->hSpatParamRendCom->num_slots = JBM_CLDFB_SLOTS_IN_SUBFRAME;
set_s( st_ivas->hSpatParamRendCom->render_to_md_map, last_dirac_md_idx, n_slots_still_available );
if ( ( error = ivas_omasa_dirac_td_binaural_jbm( st_ivas, (uint16_t) hTcBuffer->n_samples_granularity, nSamplesRendered, &nSamplesAvailableNext, CPE_CHANNELS, p_output ) ) != IVAS_ERR_OK )
{ {
return error; return error;
} }
/* restore original configuration */
st_ivas->ism_mode = ism_mode_orig;
st_ivas->renderer_type = renderer_type_orig;
st_ivas->hDecoderConfig->ivas_total_brate = ivas_total_brate;
} }
} }
else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) else if ( st_ivas->ivas_format == SBA_ISM_FORMAT )
...@@ -1539,20 +1579,20 @@ ivas_error ivas_jbm_dec_flush_renderer( ...@@ -1539,20 +1579,20 @@ ivas_error ivas_jbm_dec_flush_renderer(
RENDERER_TYPE renderer_type_orig; RENDERER_TYPE renderer_type_orig;
int32_t ivas_total_brate; int32_t ivas_total_brate;
/* to render flushed samples, use configuration from the last received frame */
ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
renderer_type_orig = st_ivas->renderer_type; renderer_type_orig = st_ivas->renderer_type;
ism_mode_orig = st_ivas->ism_mode; ism_mode_orig = st_ivas->ism_mode;
st_ivas->ism_mode = ism_mode_old; st_ivas->ism_mode = ism_mode_old;
st_ivas->renderer_type = renderer_type_old; st_ivas->renderer_type = renderer_type_old;
st_ivas->hDecoderConfig->ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate; st_ivas->hDecoderConfig->ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate;
last_spar_md_idx = st_ivas->hSpar->render_to_md_map[st_ivas->hSpar->slots_rendered - 1]; last_spar_md_idx = st_ivas->hSpar->render_to_md_map[st_ivas->hSpar->slots_rendered - 1];
last_dirac_md_idx = st_ivas->hSpatParamRendCom->render_to_md_map[st_ivas->hSpatParamRendCom->slots_rendered - 1]; last_dirac_md_idx = st_ivas->hSpatParamRendCom->render_to_md_map[st_ivas->hSpatParamRendCom->slots_rendered - 1];
#ifdef DEBUGGING #ifdef DEBUGGING
assert( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ); assert( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV );
#endif #endif
/* copy from ISM delay buffer to the correct place in tcs */ /* copy from ISM delay buffer to the correct place in TCs */
for ( ch_idx = 0; ch_idx < st_ivas->nchan_ism; ch_idx++ ) for ( ch_idx = 0; ch_idx < st_ivas->nchan_ism; ch_idx++ )
{ {
tc_local[ch_idx] = &st_ivas->hTcBuffer->tc[ch_idx][hTcBuffer->n_samples_rendered]; tc_local[ch_idx] = &st_ivas->hTcBuffer->tc[ch_idx][hTcBuffer->n_samples_rendered];
...@@ -1581,6 +1621,7 @@ ivas_error ivas_jbm_dec_flush_renderer( ...@@ -1581,6 +1621,7 @@ ivas_error ivas_jbm_dec_flush_renderer(
return error; return error;
} }
/* restore original configuration */
st_ivas->ism_mode = ism_mode_orig; st_ivas->ism_mode = ism_mode_orig;
st_ivas->renderer_type = renderer_type_orig; st_ivas->renderer_type = renderer_type_orig;
st_ivas->hDecoderConfig->ivas_total_brate = ivas_total_brate; st_ivas->hDecoderConfig->ivas_total_brate = ivas_total_brate;
...@@ -1619,7 +1660,7 @@ ivas_error ivas_jbm_dec_flush_renderer( ...@@ -1619,7 +1660,7 @@ ivas_error ivas_jbm_dec_flush_renderer(
ivas_syn_output( p_output, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, (int16_t *) data ); ivas_syn_output( p_output, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, (int16_t *) data );
break; break;
case PCM_FLOAT32: case PCM_FLOAT32:
ivas_syn_output_f( p_output, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, (float *) data ); ivas_buffer_deinterleaved_to_interleaved( p_output, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, (float *) data );
break; break;
default: default:
error = IVAS_ERR_UNKNOWN; error = IVAS_ERR_UNKNOWN;
...@@ -2041,6 +2082,135 @@ int16_t ivas_jbm_dec_get_render_granularity( ...@@ -2041,6 +2082,135 @@ int16_t ivas_jbm_dec_get_render_granularity(
} }
/*--------------------------------------------------------------------------*
* ivas_jbm_dec_tc_audio_allocate()
*
* allocate and initialize TC audio buffer
*--------------------------------------------------------------------------*/
static ivas_error ivas_jbm_dec_tc_audio_allocate(
DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: JBM TSM buffer handle */
const int32_t output_Fs, /* i : output sampling rate */
const int16_t Opt_tsm /* i : TSM option flag */
)
{
int16_t nsamp_to_allocate;
int16_t ch_idx, n_samp_full, n_samp_residual, offset;
if ( Opt_tsm )
{
n_samp_full = ( NS2SA( output_Fs, MAX_JBM_L_FRAME_NS ) );
n_samp_full = max( n_samp_full, L_FRAME48k ); /* buffers are shared between 'hTcBuffer->tc[]' and 'p_output_f[]': ensure minimal length */
n_samp_residual = hTcBuffer->n_samples_granularity - 1;
}
else
{
n_samp_full = (int16_t) ( output_Fs / FRAMES_PER_SEC );
n_samp_residual = 0;
}
nsamp_to_allocate = max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ) * n_samp_full;
if ( Opt_tsm )
{
/* note: this is stack memory buffer for time-scale modified audio signals */
if ( ( hTcBuffer->tc_buffer = (float *) malloc( nsamp_to_allocate * sizeof( float ) ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) );
}
set_zero( hTcBuffer->tc_buffer, nsamp_to_allocate );
offset = 0;
for ( ch_idx = 0; ch_idx < max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); ch_idx++ )
{
hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset];
offset += n_samp_full;
}
for ( ; ch_idx < MAX_INTERN_CHANNELS; ch_idx++ )
{
hTcBuffer->tc[ch_idx] = NULL;
}
/* memory buffer for TC audio samples not rendered in the previous frame */
for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_transport_internal; ch_idx++ )
{
if ( ( hTcBuffer->tc_buffer_old[ch_idx] = (float *) malloc( n_samp_residual * sizeof( float ) ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) );
}
set_zero( hTcBuffer->tc_buffer_old[ch_idx], n_samp_residual );
}
for ( ; ch_idx < MAX_INTERN_CHANNELS; ch_idx++ )
{
hTcBuffer->tc_buffer_old[ch_idx] = NULL;
}
}
else
{
hTcBuffer->tc_buffer = NULL;
for ( ch_idx = 0; ch_idx < MAX_INTERN_CHANNELS; ch_idx++ )
{
hTcBuffer->tc[ch_idx] = NULL;
}
for ( ch_idx = 0; ch_idx < MAX_INTERN_CHANNELS; ch_idx++ )
{
hTcBuffer->tc_buffer_old[ch_idx] = NULL;
}
}
hTcBuffer->tc_buffer2 = NULL;
return IVAS_ERR_OK;
}
/*--------------------------------------------------------------------------*
* ivas_jbm_dec_tc_audio_deallocate()
*
* deallocate TC audio buffer
*--------------------------------------------------------------------------*/
static void ivas_jbm_dec_tc_audio_deallocate(
DECODER_TC_BUFFER_HANDLE hTcBuffer /* i/o: JBM TSM buffer handle */
)
{
int16_t ch_idx;
if ( hTcBuffer != NULL )
{
if ( hTcBuffer->tc_buffer != NULL )
{
for ( ch_idx = 0; ch_idx < MAX_INTERN_CHANNELS; ch_idx++ )
{
hTcBuffer->tc[ch_idx] = NULL;
}
free( hTcBuffer->tc_buffer );
hTcBuffer->tc_buffer = NULL;
}
for ( ch_idx = 0; ch_idx < MAX_INTERN_CHANNELS; ch_idx++ )
{
if ( hTcBuffer->tc_buffer_old[ch_idx] != NULL )
{
free( hTcBuffer->tc_buffer_old[ch_idx] );
hTcBuffer->tc_buffer_old[ch_idx] = NULL;
}
}
if ( hTcBuffer->tc_buffer2 != NULL )
{
free( hTcBuffer->tc_buffer2 );
hTcBuffer->tc_buffer2 = NULL;
}
}
return;
}
/*--------------------------------------------------------------------------* /*--------------------------------------------------------------------------*
* ivas_jbm_dec_tc_buffer_open() * ivas_jbm_dec_tc_buffer_open()
* *
...@@ -2056,11 +2226,9 @@ ivas_error ivas_jbm_dec_tc_buffer_open( ...@@ -2056,11 +2226,9 @@ ivas_error ivas_jbm_dec_tc_buffer_open(
const int16_t n_samples_granularity /* i : granularity of the renderer/buffer */ const int16_t n_samples_granularity /* i : granularity of the renderer/buffer */
) )
{ {
int16_t nsamp_to_allocate;
DECODER_TC_BUFFER_HANDLE hTcBuffer; DECODER_TC_BUFFER_HANDLE hTcBuffer;
int16_t nMaxSlotsPerSubframe; int16_t nMaxSlotsPerSubframe;
int16_t nchan_residual; ivas_error error;
int16_t ch_idx;
/*-----------------------------------------------------------------* /*-----------------------------------------------------------------*
* prepare library opening * prepare library opening
...@@ -2075,7 +2243,6 @@ ivas_error ivas_jbm_dec_tc_buffer_open( ...@@ -2075,7 +2243,6 @@ ivas_error ivas_jbm_dec_tc_buffer_open(
hTcBuffer->nchan_transport_jbm = nchan_transport_jbm; hTcBuffer->nchan_transport_jbm = nchan_transport_jbm;
hTcBuffer->nchan_transport_internal = nchan_transport_internal; hTcBuffer->nchan_transport_internal = nchan_transport_internal;
hTcBuffer->nchan_buffer_full = nchan_full; hTcBuffer->nchan_buffer_full = nchan_full;
nchan_residual = nchan_transport_internal - nchan_full;
hTcBuffer->n_samples_granularity = n_samples_granularity; hTcBuffer->n_samples_granularity = n_samples_granularity;
hTcBuffer->n_samples_available = 0; hTcBuffer->n_samples_available = 0;
hTcBuffer->n_samples_buffered = 0; hTcBuffer->n_samples_buffered = 0;
...@@ -2085,70 +2252,15 @@ ivas_error ivas_jbm_dec_tc_buffer_open( ...@@ -2085,70 +2252,15 @@ ivas_error ivas_jbm_dec_tc_buffer_open(
hTcBuffer->n_samples_discard = 0; hTcBuffer->n_samples_discard = 0;
hTcBuffer->n_samples_flushed = 0; hTcBuffer->n_samples_flushed = 0;
hTcBuffer->nb_subframes = MAX_PARAM_SPATIAL_SUBFRAMES; hTcBuffer->nb_subframes = MAX_PARAM_SPATIAL_SUBFRAMES;
nsamp_to_allocate = 0;
nMaxSlotsPerSubframe = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / hTcBuffer->n_samples_granularity; nMaxSlotsPerSubframe = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / hTcBuffer->n_samples_granularity;
hTcBuffer->num_slots = nMaxSlotsPerSubframe * MAX_PARAM_SPATIAL_SUBFRAMES; hTcBuffer->num_slots = nMaxSlotsPerSubframe * MAX_PARAM_SPATIAL_SUBFRAMES;
set_s( hTcBuffer->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); set_s( hTcBuffer->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS );
set_s( hTcBuffer->subframe_nbslots, nMaxSlotsPerSubframe, MAX_PARAM_SPATIAL_SUBFRAMES ); set_s( hTcBuffer->subframe_nbslots, nMaxSlotsPerSubframe, MAX_PARAM_SPATIAL_SUBFRAMES );
if ( ( error = ivas_jbm_dec_tc_audio_allocate( hTcBuffer, st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->Opt_tsm ) ) != IVAS_ERR_OK )
{ {
int16_t n_samp_full, n_samp_residual; return error;
int32_t offset;
if ( st_ivas->hDecoderConfig->Opt_tsm )
{
n_samp_full = ( NS2SA( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ) + hTcBuffer->n_samples_granularity - 1 );
n_samp_residual = hTcBuffer->n_samples_granularity - 1;
}
else
{
n_samp_full = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC );
n_samp_residual = 0;
}
nsamp_to_allocate = hTcBuffer->nchan_buffer_full * n_samp_full;
nsamp_to_allocate += nchan_residual * n_samp_residual;
if ( nsamp_to_allocate == 0 )
{
hTcBuffer->tc_buffer = NULL;
for ( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ )
{
hTcBuffer->tc[ch_idx] = NULL;
}
}
else
{
if ( st_ivas->hDecoderConfig->Opt_tsm )
{
/* note: the maximum buffer length is for OSBA DISC mode with ISMs -> 15*(1920+239)=32385 samples */
if ( ( hTcBuffer->tc_buffer = (float *) malloc( nsamp_to_allocate * sizeof( float ) ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) );
}
set_zero( hTcBuffer->tc_buffer, nsamp_to_allocate );
offset = 0;
for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ )
{
hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset];
offset += n_samp_full;
}
for ( ; ch_idx < hTcBuffer->nchan_transport_internal; ch_idx++ )
{
hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset];
offset += n_samp_residual;
}
for ( ; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ )
{
hTcBuffer->tc[ch_idx] = NULL;
}
}
else
{
hTcBuffer->tc_buffer = NULL;
}
}
} }
st_ivas->hTcBuffer = hTcBuffer; st_ivas->hTcBuffer = hTcBuffer;
...@@ -2172,12 +2284,30 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( ...@@ -2172,12 +2284,30 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure(
const int16_t n_samples_granularity /* i : new granularity of the renderer/buffer */ const int16_t n_samples_granularity /* i : new granularity of the renderer/buffer */
) )
{ {
int16_t nsamp_to_allocate, n_samp_full, n_samp_residual, offset, nchan_residual; int16_t ch_idx, num_tc_buffer_mem, n_samples_still_available;
int16_t ch_idx; float tc_buffer_mem[MAX_INTERN_CHANNELS][L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES - 1];
ivas_error error;
DECODER_TC_BUFFER_HANDLE hTcBuffer; DECODER_TC_BUFFER_HANDLE hTcBuffer;
hTcBuffer = st_ivas->hTcBuffer; hTcBuffer = st_ivas->hTcBuffer;
num_tc_buffer_mem = 0;
n_samples_still_available = 0;
if ( st_ivas->hDecoderConfig->Opt_tsm )
{
/* save samples of the TC buffer from the previous frame */
num_tc_buffer_mem = min( hTcBuffer->nchan_transport_internal, nchan_transport_internal );
n_samples_still_available = hTcBuffer->n_samples_buffered - hTcBuffer->n_samples_rendered;
/* what is remaining from last frame needs always be smaller than the new granularity */
assert( n_samples_still_available < n_samples_granularity );
for ( ch_idx = 0; ch_idx < num_tc_buffer_mem; ch_idx++ )
{
mvr2r( hTcBuffer->tc_buffer_old[ch_idx] + hTcBuffer->n_samples_flushed, tc_buffer_mem[ch_idx], n_samples_still_available );
}
}
/* if granularity changes, adapt subframe_nb_slots */ /* if granularity changes, adapt subframe_nb_slots */
if ( n_samples_granularity != hTcBuffer->n_samples_granularity ) if ( n_samples_granularity != hTcBuffer->n_samples_granularity )
...@@ -2216,71 +2346,21 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( ...@@ -2216,71 +2346,21 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure(
hTcBuffer->nchan_transport_jbm = nchan_transport_jbm; hTcBuffer->nchan_transport_jbm = nchan_transport_jbm;
hTcBuffer->nchan_transport_internal = nchan_transport_internal; hTcBuffer->nchan_transport_internal = nchan_transport_internal;
hTcBuffer->nchan_buffer_full = nchan_full; hTcBuffer->nchan_buffer_full = nchan_full;
nchan_residual = nchan_transport_internal - nchan_full;
hTcBuffer->n_samples_granularity = n_samples_granularity; hTcBuffer->n_samples_granularity = n_samples_granularity;
#ifdef DEBUGGING /* reallocate TC audio buffers */
/* what is remaining from last frames needs always be smaller than n_samples_granularity */
assert( ( hTcBuffer->n_samples_buffered - hTcBuffer->n_samples_rendered ) < n_samples_granularity );
#endif
/* realloc buffers */
if ( hTcBuffer->tc_buffer != NULL )
{
free( hTcBuffer->tc_buffer );
hTcBuffer->tc_buffer = NULL;
}
if ( st_ivas->hDecoderConfig->Opt_tsm ) ivas_jbm_dec_tc_audio_deallocate( hTcBuffer );
{
n_samp_full = ( NS2SA( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ) + hTcBuffer->n_samples_granularity - 1 );
n_samp_residual = hTcBuffer->n_samples_granularity - 1;
}
else
{
n_samp_full = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC );
n_samp_residual = 0;
}
nsamp_to_allocate = hTcBuffer->nchan_buffer_full * n_samp_full;
nsamp_to_allocate += nchan_residual * n_samp_residual;
if ( nsamp_to_allocate == 0 ) if ( ( error = ivas_jbm_dec_tc_audio_allocate( hTcBuffer, st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->Opt_tsm ) ) != IVAS_ERR_OK )
{
hTcBuffer->tc_buffer = NULL;
for ( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ )
{ {
hTcBuffer->tc[ch_idx] = NULL; return error;
}
}
else
{
if ( st_ivas->hDecoderConfig->Opt_tsm )
{
if ( ( hTcBuffer->tc_buffer = (float *) malloc( nsamp_to_allocate * sizeof( float ) ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) );
} }
set_zero( hTcBuffer->tc_buffer, nsamp_to_allocate );
offset = 0; /* propagate samples of the TC buffer from the previous frame */
for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) for ( ch_idx = 0; ch_idx < num_tc_buffer_mem; ch_idx++ )
{
hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset];
offset += n_samp_full;
}
for ( ; ch_idx < hTcBuffer->nchan_transport_internal; ch_idx++ )
{
hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset];
offset += n_samp_residual;
}
for ( ; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ )
{
hTcBuffer->tc[ch_idx] = NULL;
}
}
else
{ {
hTcBuffer->tc_buffer = NULL; mvr2r( tc_buffer_mem[ch_idx], hTcBuffer->tc_buffer_old[ch_idx], n_samples_still_available );
}
} }
return IVAS_ERR_OK; return IVAS_ERR_OK;
...@@ -2321,7 +2401,7 @@ static void ivas_jbm_dec_tc_buffer_playout( ...@@ -2321,7 +2401,7 @@ static void ivas_jbm_dec_tc_buffer_playout(
for ( ch_idx = 0; ch_idx < st_ivas->hTcBuffer->nchan_transport_jbm; ch_idx++ ) for ( ch_idx = 0; ch_idx < st_ivas->hTcBuffer->nchan_transport_jbm; ch_idx++ )
{ {
mvr2r( st_ivas->hTcBuffer->tc[ch_idx] + st_ivas->hTcBuffer->n_samples_rendered, output[ch_idx], *nSamplesRendered ); output[ch_idx] = st_ivas->hTcBuffer->tc[ch_idx] + st_ivas->hTcBuffer->n_samples_rendered;
} }
st_ivas->hTcBuffer->subframes_rendered = last_sf; st_ivas->hTcBuffer->subframes_rendered = last_sf;
...@@ -2340,20 +2420,9 @@ void ivas_jbm_dec_tc_buffer_close( ...@@ -2340,20 +2420,9 @@ void ivas_jbm_dec_tc_buffer_close(
DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */ DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */
) )
{ {
int16_t i;
if ( *phTcBuffer != NULL ) if ( *phTcBuffer != NULL )
{ {
for ( i = 0; i < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; i++ ) ivas_jbm_dec_tc_audio_deallocate( *phTcBuffer );
{
( *phTcBuffer )->tc[i] = NULL;
}
if ( ( *phTcBuffer )->tc_buffer != NULL )
{
free( ( *phTcBuffer )->tc_buffer );
( *phTcBuffer )->tc_buffer = NULL;
}
free( *phTcBuffer ); free( *phTcBuffer );
*phTcBuffer = NULL; *phTcBuffer = NULL;
......
...@@ -380,7 +380,7 @@ ivas_error ivas_create_lfe_dec( ...@@ -380,7 +380,7 @@ ivas_error ivas_create_lfe_dec(
LFE_DEC_HANDLE hLFE; LFE_DEC_HANDLE hLFE;
float lfe_addl_delay_s; float lfe_addl_delay_s;
int16_t i, j; int16_t i, j;
int16_t add_delay_sa; float lfe_block_delay_s;
low_pass_delay_dec_out = 0; low_pass_delay_dec_out = 0;
block_offset_s = 0; block_offset_s = 0;
...@@ -418,7 +418,7 @@ ivas_error ivas_create_lfe_dec( ...@@ -418,7 +418,7 @@ ivas_error ivas_create_lfe_dec(
hLFE->cum_freq_models[1][3] = &ivas_str_lfe_freq_models.entropy_coder_model_coarse_sg4; hLFE->cum_freq_models[1][3] = &ivas_str_lfe_freq_models.entropy_coder_model_coarse_sg4;
/* delay calculation */ /* delay calculation */
hLFE->lfe_block_delay_s = ( IVAS_LFE_FADE_NS / 1000000000.f ) + ivas_lfe_lpf_delay[IVAS_FILTER_ORDER_4 - 3]; lfe_block_delay_s = ( IVAS_LFE_FADE_NS / 1000000000.f ) + ivas_lfe_lpf_delay[IVAS_FILTER_ORDER_4 - 3];
block_offset_s = BLOCK_OFFSET_MS * 0.001f; block_offset_s = BLOCK_OFFSET_MS * 0.001f;
filt_order = 0; filt_order = 0;
...@@ -426,21 +426,21 @@ ivas_error ivas_create_lfe_dec( ...@@ -426,21 +426,21 @@ ivas_error ivas_create_lfe_dec(
if ( ( delay_ns / 1000000000.f ) > ivas_lfe_lpf_delay[IVAS_FILTER_ORDER_4 - 3] ) if ( ( delay_ns / 1000000000.f ) > ivas_lfe_lpf_delay[IVAS_FILTER_ORDER_4 - 3] )
{ {
filt_order = 4; filt_order = 4;
low_pass_delay_dec_out = ivas_lfe_lpf_delay[IVAS_FILTER_ORDER_4 - 3] * 1000000000.f; low_pass_delay_dec_out = ivas_lfe_lpf_delay[IVAS_FILTER_ORDER_4 - 3];
ivas_create_lfe_lpf_dec( &( hLFE->filter_state ), output_Fs ); ivas_create_lfe_lpf_dec( &( hLFE->filter_state ), output_Fs );
} }
hLFE->filter_state.order = filt_order; hLFE->filter_state.order = filt_order;
hLFE->lfe_block_delay_s = hLFE->lfe_block_delay_s + low_pass_delay_dec_out; lfe_block_delay_s = lfe_block_delay_s + low_pass_delay_dec_out;
hLFE->lfe_prior_buf_len = NS2SA( output_Fs, IVAS_LFE_FADE_NS ); hLFE->lfe_prior_buf_len = NS2SA( output_Fs, IVAS_LFE_FADE_NS );
hLFE->bfi_count = 0; hLFE->bfi_count = 0;
block_offset_s += delay_ns / 1000000000.f;
lfe_addl_delay_s = block_offset_s - lfe_block_delay_s;
lfe_addl_delay_s = block_offset_s - hLFE->lfe_block_delay_s;
lfe_addl_delay_s = max( 0.0f, lfe_addl_delay_s ); lfe_addl_delay_s = max( 0.0f, lfe_addl_delay_s );
add_delay_sa = (int16_t) roundf( (float) delay_ns * output_Fs / 1000000000.f ); hLFE->lfe_addl_delay = (int16_t) ( lfe_addl_delay_s * output_Fs );
hLFE->lfe_addl_delay = (int16_t) ( lfe_addl_delay_s * output_Fs ) + add_delay_sa; hLFE->delay_ns = delay_ns;
hLFE->lfe_block_delay_s += lfe_addl_delay_s + add_delay_sa / output_Fs;
if ( hLFE->lfe_addl_delay > 0 ) if ( hLFE->lfe_addl_delay > 0 )
{ {
......
...@@ -1320,6 +1320,7 @@ ivas_error ivas_masa_dec_reconfigure( ...@@ -1320,6 +1320,7 @@ ivas_error ivas_masa_dec_reconfigure(
Decoder_State **sts; Decoder_State **sts;
int32_t ivas_total_brate, last_ivas_total_brate; int32_t ivas_total_brate, last_ivas_total_brate;
int16_t numCldfbAnalyses_old, numCldfbSyntheses_old; int16_t numCldfbAnalyses_old, numCldfbSyntheses_old;
int16_t nchan_out_buff;
ivas_error error; ivas_error error;
int16_t pos_idx; int16_t pos_idx;
int32_t ism_total_brate; int32_t ism_total_brate;
...@@ -1471,6 +1472,10 @@ ivas_error ivas_masa_dec_reconfigure( ...@@ -1471,6 +1472,10 @@ ivas_error ivas_masa_dec_reconfigure(
ivas_masa_set_elements( ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, st_ivas->hQMetaData, &tmp, &tmp, &tmp, st_ivas->ivas_format, st_ivas->ism_mode, ism_total_brate ); ivas_masa_set_elements( ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, st_ivas->hQMetaData, &tmp, &tmp, &tmp, st_ivas->ivas_format, st_ivas->ism_mode, ism_total_brate );
/*-----------------------------------------------------------------*
* JBM TC buffers
*-----------------------------------------------------------------*/
{ {
int16_t tc_nchan_to_allocate; int16_t tc_nchan_to_allocate;
int16_t tc_nchan_transport; int16_t tc_nchan_transport;
...@@ -1489,10 +1494,33 @@ ivas_error ivas_masa_dec_reconfigure( ...@@ -1489,10 +1494,33 @@ ivas_error ivas_masa_dec_reconfigure(
tc_nchan_to_allocate = BINAURAL_CHANNELS + st_ivas->nchan_ism; tc_nchan_to_allocate = BINAURAL_CHANNELS + st_ivas->nchan_ism;
} }
else else
{
tc_nchan_to_allocate = BINAURAL_CHANNELS;
if ( st_ivas->hDiracDecBin[0] != NULL && st_ivas->hDiracDecBin[0]->useTdDecorr )
{ {
tc_nchan_to_allocate = 2 * BINAURAL_CHANNELS; tc_nchan_to_allocate = 2 * BINAURAL_CHANNELS;
} }
} }
#ifdef NONBE_1321_JBM_ASSERT_BITRATE_SWITCHING
if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC )
{
if ( n_samples_granularity > st_ivas->hTcBuffer->n_samples_granularity )
{
if ( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
}
}
else if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode != ISM_MASA_MODE_DISC )
{
if ( n_samples_granularity < st_ivas->hTcBuffer->n_samples_granularity )
{
/* flush already done in IVAS_DEC_ReadFormat() */
}
}
#endif
}
else if ( st_ivas->nchan_transport == 1 && ( st_ivas->renderer_type == RENDERER_DIRAC && st_ivas->hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) ) else if ( st_ivas->nchan_transport == 1 && ( st_ivas->renderer_type == RENDERER_DIRAC && st_ivas->hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) )
{ {
/* addtl channel for CNG */ /* addtl channel for CNG */
...@@ -1530,6 +1558,19 @@ ivas_error ivas_masa_dec_reconfigure( ...@@ -1530,6 +1558,19 @@ ivas_error ivas_masa_dec_reconfigure(
} }
} }
/*-----------------------------------------------------------------*
* floating-point output audio buffers
*-----------------------------------------------------------------*/
if ( st_ivas->ivas_format == MASA_FORMAT && st_ivas->last_ivas_format == MASA_FORMAT ) /* note: switching with OMASA is addressed in ivas_omasa_dec_config() */
{
nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 );
if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff, st_ivas->hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK )
{
return error;
}
}
return IVAS_ERR_OK; return IVAS_ERR_OK;
} }
......
...@@ -78,7 +78,7 @@ static void ivas_param_mc_dec_init( PARAM_MC_DEC_HANDLE hParamMC, const int16_t ...@@ -78,7 +78,7 @@ static void ivas_param_mc_dec_init( PARAM_MC_DEC_HANDLE hParamMC, const int16_t
static void param_mc_protoSignalComputation( float *RealBuffer, float *ImagBuffer, float *proto_frame_f, const PARAM_MC_DIFF_PROTO_INFO *diff_proto_info, const int16_t num_freq_bands ); static void param_mc_protoSignalComputation( float *RealBuffer, float *ImagBuffer, float *proto_frame_f, const PARAM_MC_DIFF_PROTO_INFO *diff_proto_info, const int16_t num_freq_bands );
static void ivas_param_mc_dec_copy_diffuse_proto( PARAM_MC_DEC_HANDLE hParamMC, float Cldfb_buffer_real[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float Cldfb_buffer_imag[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const int16_t nY, const int16_t slot_idx ); static void ivas_param_mc_dec_copy_diffuse_proto( PARAM_MC_DEC_HANDLE hParamMC, float Cldfb_buffer_real[MAX_LS_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float Cldfb_buffer_imag[MAX_LS_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const int16_t nY, const int16_t slot_idx );
static int16_t ivas_param_mc_range_decoder_LC( uint16_t *bit_buffer, int16_t *x, int16_t *BER_detect, const int16_t sz_seq, const int16_t sz_alphabet, const uint16_t *cft, const uint16_t *sft, const int16_t tot_shift, const int16_t nbbits ); static int16_t ivas_param_mc_range_decoder_LC( uint16_t *bit_buffer, int16_t *x, int16_t *BER_detect, const int16_t sz_seq, const int16_t sz_alphabet, const uint16_t *cft, const uint16_t *sft, const int16_t tot_shift, const int16_t nbbits );
...@@ -114,7 +114,7 @@ ivas_error ivas_param_mc_dec_open( ...@@ -114,7 +114,7 @@ ivas_error ivas_param_mc_dec_open(
PARAM_MC_DEC_HANDLE hParamMC; PARAM_MC_DEC_HANDLE hParamMC;
int16_t nchan_out_transport; int16_t nchan_out_transport;
int16_t nchan_out_cov; int16_t nchan_out_cov;
float proto_matrix[MAX_CICP_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS]; float proto_matrix[MAX_LS_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS];
float proto_mtx_norm; float proto_mtx_norm;
int16_t max_param_band_residual; int16_t max_param_band_residual;
uint16_t config_index; uint16_t config_index;
...@@ -552,7 +552,7 @@ ivas_error ivas_param_mc_dec_reconfig( ...@@ -552,7 +552,7 @@ ivas_error ivas_param_mc_dec_reconfig(
PARAM_MC_DEC_HANDLE hParamMC; PARAM_MC_DEC_HANDLE hParamMC;
int16_t nchan_out_transport; int16_t nchan_out_transport;
int16_t nchan_out_cov; int16_t nchan_out_cov;
float proto_matrix[MAX_CICP_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS]; float proto_matrix[MAX_LS_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS];
float proto_mtx_norm; float proto_mtx_norm;
int16_t max_param_band_residual; int16_t max_param_band_residual;
uint16_t config_index; uint16_t config_index;
...@@ -888,9 +888,9 @@ ivas_error ivas_param_mc_dec_reconfig( ...@@ -888,9 +888,9 @@ ivas_error ivas_param_mc_dec_reconfig(
{ {
DIRAC_OUTPUT_SYNTHESIS_COV_STATE cov_state_old = hParamMC->h_output_synthesis_cov_state; DIRAC_OUTPUT_SYNTHESIS_COV_STATE cov_state_old = hParamMC->h_output_synthesis_cov_state;
DIRAC_OUTPUT_SYNTHESIS_PARAMS params_old = hParamMC->h_output_synthesis_params; DIRAC_OUTPUT_SYNTHESIS_PARAMS params_old = hParamMC->h_output_synthesis_params;
float tmp_buf[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; float tmp_buf[MAX_LS_CHANNELS * MAX_LS_CHANNELS];
set_zero( tmp_buf, MAX_CICP_CHANNELS * MAX_CICP_CHANNELS ); set_zero( tmp_buf, MAX_LS_CHANNELS * MAX_LS_CHANNELS );
/* output synthesis */ /* output synthesis */
if ( ( error = ivas_dirac_dec_output_synthesis_cov_open( &( hParamMC->h_output_synthesis_params ), &( hParamMC->h_output_synthesis_cov_state ), hParamMC->max_band_decorr, PARAM_MC_MAX_NSLOTS, if ( ( error = ivas_dirac_dec_output_synthesis_cov_open( &( hParamMC->h_output_synthesis_params ), &( hParamMC->h_output_synthesis_cov_state ), hParamMC->max_band_decorr, PARAM_MC_MAX_NSLOTS,
...@@ -1389,7 +1389,7 @@ void ivas_param_mc_dec_prepare_renderer( ...@@ -1389,7 +1389,7 @@ void ivas_param_mc_dec_prepare_renderer(
push_wmops( "param_mc_dec_digest_tc" ); push_wmops( "param_mc_dec_digest_tc" );
set_s( channel_active, 0, MAX_CICP_CHANNELS ); set_s( channel_active, 0, MAX_LS_CHANNELS );
nchan_transport = st_ivas->nchan_transport; nchan_transport = st_ivas->nchan_transport;
nchan_out_transport = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; nchan_out_transport = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe;
...@@ -1558,7 +1558,7 @@ void ivas_param_mc_dec_render( ...@@ -1558,7 +1558,7 @@ void ivas_param_mc_dec_render(
float Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; float Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX];
float Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; float Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX];
/*Decorrelator*/ /*Decorrelator*/
float onset_filter[MAX_CICP_CHANNELS * CLDFB_NO_CHANNELS_MAX]; float onset_filter[MAX_LS_CHANNELS * CLDFB_NO_CHANNELS_MAX];
/* format converter */ /* format converter */
int16_t channel_active[MAX_OUTPUT_CHANNELS]; int16_t channel_active[MAX_OUTPUT_CHANNELS];
uint16_t nband_synth, nbands_to_zero; uint16_t nband_synth, nbands_to_zero;
...@@ -1570,7 +1570,7 @@ void ivas_param_mc_dec_render( ...@@ -1570,7 +1570,7 @@ void ivas_param_mc_dec_render(
push_wmops( "param_mc_dec_render" ); push_wmops( "param_mc_dec_render" );
set_s( channel_active, 0, MAX_CICP_CHANNELS ); set_s( channel_active, 0, MAX_LS_CHANNELS );
nchan_transport = st_ivas->nchan_transport; nchan_transport = st_ivas->nchan_transport;
nchan_out_transport = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; nchan_out_transport = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe;
nchan_out_init = nchan_out_transport; nchan_out_init = nchan_out_transport;
...@@ -1977,8 +1977,8 @@ static void param_mc_protoSignalComputation( ...@@ -1977,8 +1977,8 @@ static void param_mc_protoSignalComputation(
static void ivas_param_mc_dec_copy_diffuse_proto( static void ivas_param_mc_dec_copy_diffuse_proto(
PARAM_MC_DEC_HANDLE hParamMC, /* i : Parametric MC handle */ PARAM_MC_DEC_HANDLE hParamMC, /* i : Parametric MC handle */
float Cldfb_buffer_real[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* o : CLDFB buffer used in the final synthesis (real part) */ float Cldfb_buffer_real[MAX_LS_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* o : CLDFB buffer used in the final synthesis (real part) */
float Cldfb_buffer_imag[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* o : CLDFB buffer used in the final synthesis (imaginary part) */ float Cldfb_buffer_imag[MAX_LS_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* o : CLDFB buffer used in the final synthesis (imaginary part) */
const int16_t nY, /* i : number of decorrelated channels */ const int16_t nY, /* i : number of decorrelated channels */
const int16_t slot_idx /* i : current time slot index */ const int16_t slot_idx /* i : current time slot index */
) )
...@@ -2219,18 +2219,18 @@ static void ivas_param_mc_get_mixing_matrices( ...@@ -2219,18 +2219,18 @@ static void ivas_param_mc_get_mixing_matrices(
) )
{ {
float Cx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; float Cx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS];
float Cy[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; float Cy[MAX_LS_CHANNELS * MAX_LS_CHANNELS];
float Cy_diag[MAX_CICP_CHANNELS]; float Cy_diag[MAX_LS_CHANNELS];
float Cr[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; float Cr[MAX_LS_CHANNELS * MAX_LS_CHANNELS];
float Cproto_diag[MAX_CICP_CHANNELS]; float Cproto_diag[MAX_LS_CHANNELS];
float Cproto[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; float Cproto[MAX_LS_CHANNELS * MAX_LS_CHANNELS];
float mat_mult_buffer1[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; float mat_mult_buffer1[MAX_LS_CHANNELS * MAX_LS_CHANNELS];
float *Cx_state; float *Cx_state;
float *Cx_old_state; float *Cx_old_state;
float Cy_state[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; float Cy_state[MAX_LS_CHANNELS * MAX_LS_CHANNELS];
float *Cy_old_state; float *Cy_old_state;
int16_t nY_band; int16_t nY_band;
float proto_matrix_noLFE[PARAM_MC_MAX_TRANSPORT_CHANS * MAX_CICP_CHANNELS]; float proto_matrix_noLFE[PARAM_MC_MAX_TRANSPORT_CHANS * MAX_LS_CHANNELS];
float *proto_matrix_ptr; float *proto_matrix_ptr;
int16_t num_lfe_bands; int16_t num_lfe_bands;
int16_t brange[2]; int16_t brange[2];
...@@ -2238,15 +2238,15 @@ static void ivas_param_mc_get_mixing_matrices( ...@@ -2238,15 +2238,15 @@ static void ivas_param_mc_get_mixing_matrices(
int16_t ch_idx1, ch_idx2, lfe_idx1, lfe_idx2; int16_t ch_idx1, ch_idx2, lfe_idx1, lfe_idx2;
float *ptrMM; float *ptrMM;
float *ptrMM_out; float *ptrMM_out;
float Cy_full[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; float Cy_full[MAX_LS_CHANNELS * MAX_LS_CHANNELS];
float mixing_matrix_local[MAX_CICP_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS]; float mixing_matrix_local[MAX_LS_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS];
float mixing_matrix_res_local[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; float mixing_matrix_res_local[MAX_LS_CHANNELS * MAX_LS_CHANNELS];
int16_t remove_lfe; int16_t remove_lfe;
int16_t lfe_indices[PARAM_MC_LOCAL_SZ_LFE_MAP]; int16_t lfe_indices[PARAM_MC_LOCAL_SZ_LFE_MAP];
set_zero( Cproto, MAX_CICP_CHANNELS * MAX_CICP_CHANNELS ); set_zero( Cproto, MAX_LS_CHANNELS * MAX_LS_CHANNELS );
set_zero( mat_mult_buffer1, MAX_CICP_CHANNELS * MAX_CICP_CHANNELS ); set_zero( mat_mult_buffer1, MAX_LS_CHANNELS * MAX_LS_CHANNELS );
set_zero( proto_matrix_noLFE, PARAM_MC_MAX_TRANSPORT_CHANS * MAX_CICP_CHANNELS ); set_zero( proto_matrix_noLFE, PARAM_MC_MAX_TRANSPORT_CHANS * MAX_LS_CHANNELS );
nY_band = nY_cov; nY_band = nY_cov;
num_lfe_bands = 0; num_lfe_bands = 0;
...@@ -2266,7 +2266,7 @@ static void ivas_param_mc_get_mixing_matrices( ...@@ -2266,7 +2266,7 @@ static void ivas_param_mc_get_mixing_matrices(
lfe_indices[hSynthesisOutputSetup->num_lfe + 1] = nY_cov; lfe_indices[hSynthesisOutputSetup->num_lfe + 1] = nY_cov;
proto_matrix_ptr = &proto_matrix_noLFE[0]; proto_matrix_ptr = &proto_matrix_noLFE[0];
proto_matrix_ptr_in = &hParamMC->h_output_synthesis_params.proto_matrix[0]; proto_matrix_ptr_in = &hParamMC->h_output_synthesis_params.proto_matrix[0];
set_zero( proto_matrix_noLFE, PARAM_MC_MAX_TRANSPORT_CHANS * MAX_CICP_CHANNELS ); set_zero( proto_matrix_noLFE, PARAM_MC_MAX_TRANSPORT_CHANS * MAX_LS_CHANNELS );
for ( ch_idx1 = 0; ch_idx1 < nX; ch_idx1++ ) for ( ch_idx1 = 0; ch_idx1 < nX; ch_idx1++ )
{ {
...@@ -2589,12 +2589,12 @@ static void ivas_param_mc_dequantize_cov( ...@@ -2589,12 +2589,12 @@ static void ivas_param_mc_dequantize_cov(
if ( synth_conf == PARAM_MC_SYNTH_LS_CONV_COV ) if ( synth_conf == PARAM_MC_SYNTH_LS_CONV_COV )
{ {
/* Cy = dmx*Cy*dmx' */ /* Cy = dmx*Cy*dmx' */
float mat_mult_buffer1[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; float mat_mult_buffer1[MAX_LS_CHANNELS * MAX_LS_CHANNELS];
float target_ch_ener[MAX_CICP_CHANNELS]; float target_ch_ener[MAX_LS_CHANNELS];
float dmx_ch_ener[MAX_CICP_CHANNELS]; float dmx_ch_ener[MAX_LS_CHANNELS];
set_zero( target_ch_ener, MAX_CICP_CHANNELS ); set_zero( target_ch_ener, MAX_LS_CHANNELS );
set_zero( dmx_ch_ener, MAX_CICP_CHANNELS ); set_zero( dmx_ch_ener, MAX_LS_CHANNELS );
matrix_product( hParamMC->ls_conv_dmx_matrix, nY_cov, nY_int, 0, matrix_product( hParamMC->ls_conv_dmx_matrix, nY_cov, nY_int, 0,
Cy_state_int, nY_int, nY_int, 0, Cy_state_int, nY_int, nY_int, 0,
...@@ -2705,7 +2705,7 @@ static ivas_error param_mc_get_diff_proto_info( ...@@ -2705,7 +2705,7 @@ static ivas_error param_mc_get_diff_proto_info(
PARAM_MC_DIFF_PROTO_INFO *p_diff_proto_info /* o : generated diffuse prototype info */ PARAM_MC_DIFF_PROTO_INFO *p_diff_proto_info /* o : generated diffuse prototype info */
) )
{ {
float proto_fac[MAX_CICP_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS]; float proto_fac[MAX_LS_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS];
uint16_t cur_out_ch; uint16_t cur_out_ch;
uint16_t cur_diff_proto; uint16_t cur_diff_proto;
uint16_t cur_transport_ch; uint16_t cur_transport_ch;
...@@ -2713,7 +2713,7 @@ static ivas_error param_mc_get_diff_proto_info( ...@@ -2713,7 +2713,7 @@ static ivas_error param_mc_get_diff_proto_info(
/* Initializations */ /* Initializations */
max_num_src_chan = 0; max_num_src_chan = 0;
set_zero( proto_fac, MAX_CICP_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS ); set_zero( proto_fac, MAX_LS_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS );
if ( ( p_diff_proto_info->proto_index_diff = (int16_t *) malloc( nchan_out_cov * sizeof( int16_t ) ) ) == NULL ) if ( ( p_diff_proto_info->proto_index_diff = (int16_t *) malloc( nchan_out_cov * sizeof( int16_t ) ) ) == NULL )
{ {
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) );
......
...@@ -679,6 +679,7 @@ static void ivas_mc_paramupmix_dec_sf( ...@@ -679,6 +679,7 @@ static void ivas_mc_paramupmix_dec_sf(
cldfbAnalysis_ts( &( pPcm_temp[ch][hMCParamUpmix->num_freq_bands * slot_idx] ), Cldfb_RealBuffer[ch][slot_idx], Cldfb_ImagBuffer[ch][slot_idx], hMCParamUpmix->num_freq_bands, st_ivas->cldfbAnaDec[ch] ); cldfbAnalysis_ts( &( pPcm_temp[ch][hMCParamUpmix->num_freq_bands * slot_idx] ), Cldfb_RealBuffer[ch][slot_idx], Cldfb_ImagBuffer[ch][slot_idx], hMCParamUpmix->num_freq_bands, st_ivas->cldfbAnaDec[ch] );
} }
} }
for ( ch = 0; ch < MC_PARAMUPMIX_COMBINATIONS; ch++ ) for ( ch = 0; ch < MC_PARAMUPMIX_COMBINATIONS; ch++ )
{ {
ps_pred_process_sf( hMCParamUpmix, ps_pred_process_sf( hMCParamUpmix,
...@@ -837,12 +838,16 @@ static void ivas_mc_paramupmix_dec_sf( ...@@ -837,12 +838,16 @@ static void ivas_mc_paramupmix_dec_sf(
hMCParamUpmix->num_freq_bands, st_ivas->cldfbSynDec[ch] ); hMCParamUpmix->num_freq_bands, st_ivas->cldfbSynDec[ch] );
} }
} }
/* adjust delay of other channels */ /* adjust delay of other channels */
noparamupmix_delay = NS2SA( st_ivas->hDecoderConfig->output_Fs, IVAS_FB_DEC_DELAY_NS ); noparamupmix_delay = NS2SA( st_ivas->hDecoderConfig->output_Fs, IVAS_FB_DEC_DELAY_NS );
n_samples_rendered = st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->subframes_rendered] * hMCParamUpmix->num_freq_bands; n_samples_rendered = st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->subframes_rendered] * hMCParamUpmix->num_freq_bands;
if ( n_samples_rendered > noparamupmix_delay ) if ( n_samples_rendered > noparamupmix_delay )
{ {
for ( ch = 0; ch < MC_PARAMUPMIX_COMBINATIONS; ch++ ) for ( ch = 0; ch < MC_PARAMUPMIX_COMBINATIONS; ch++ )
{
/*delay is handled within LFE decoder*/
if ( st_ivas->hIntSetup.index_lfe[0] != ch )
{ {
float tmp_buf[L_SUBFRAME5MS_48k]; float tmp_buf[L_SUBFRAME5MS_48k];
mvr2r( &output_f[ch][n_samples_rendered - noparamupmix_delay], tmp_buf, noparamupmix_delay ); mvr2r( &output_f[ch][n_samples_rendered - noparamupmix_delay], tmp_buf, noparamupmix_delay );
...@@ -851,9 +856,12 @@ static void ivas_mc_paramupmix_dec_sf( ...@@ -851,9 +856,12 @@ static void ivas_mc_paramupmix_dec_sf(
mvr2r( tmp_buf, hMCParamUpmix->pcm_delay[ch], noparamupmix_delay ); mvr2r( tmp_buf, hMCParamUpmix->pcm_delay[ch], noparamupmix_delay );
} }
} }
}
else else
{ {
for ( ch = 0; ch < MC_PARAMUPMIX_COMBINATIONS; ch++ ) for ( ch = 0; ch < MC_PARAMUPMIX_COMBINATIONS; ch++ )
{
if ( st_ivas->hIntSetup.index_lfe[0] != ch )
{ {
float tmp_buf[L_SUBFRAME5MS_48k]; float tmp_buf[L_SUBFRAME5MS_48k];
mvr2r( &output_f[ch][0], tmp_buf, n_samples_rendered ); mvr2r( &output_f[ch][0], tmp_buf, n_samples_rendered );
...@@ -863,6 +871,7 @@ static void ivas_mc_paramupmix_dec_sf( ...@@ -863,6 +871,7 @@ static void ivas_mc_paramupmix_dec_sf(
} }
} }
} }
}
st_ivas->hTcBuffer->slots_rendered += st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->subframes_rendered]; st_ivas->hTcBuffer->slots_rendered += st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->subframes_rendered];
st_ivas->hTcBuffer->subframes_rendered++; st_ivas->hTcBuffer->subframes_rendered++;
......
...@@ -212,7 +212,7 @@ ivas_error ivas_mct_dec( ...@@ -212,7 +212,7 @@ ivas_error ivas_mct_dec(
else if ( st_ivas->renderer_type == RENDERER_MC_PARAMMC && ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO ) ) else if ( st_ivas->renderer_type == RENDERER_MC_PARAMMC && ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO ) )
{ {
float *x_all[MAX_CICP_CHANNELS][NB_DIV]; float *x_all[MAX_LS_CHANNELS][NB_DIV];
for ( cpe_id = 0; cpe_id < nCPE; cpe_id++ ) for ( cpe_id = 0; cpe_id < nCPE; cpe_id++ )
{ {
...@@ -732,11 +732,10 @@ static ivas_error ivas_mc_dec_reconfig( ...@@ -732,11 +732,10 @@ static ivas_error ivas_mc_dec_reconfig(
int16_t tc_nchan_tc_new; int16_t tc_nchan_tc_new;
int16_t tc_nchan_allocate_new; int16_t tc_nchan_allocate_new;
int16_t tc_granularity_new; int16_t tc_granularity_new;
int16_t nchan_out_buff_old, nchan_out_buff; int16_t nchan_out_buff;
ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
nchan_transport_old = st_ivas->nchan_transport; nchan_transport_old = st_ivas->nchan_transport;
nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 );
last_mc_mode = ivas_mc_mode_select( ivas_mc_map_output_config_to_mc_ls_setup( st_ivas->transport_config ), st_ivas->hDecoderConfig->last_ivas_total_brate ); /* NB: this assumes that LS config remains the same between frames */ last_mc_mode = ivas_mc_mode_select( ivas_mc_map_output_config_to_mc_ls_setup( st_ivas->transport_config ), st_ivas->hDecoderConfig->last_ivas_total_brate ); /* NB: this assumes that LS config remains the same between frames */
/* temporally set the current mc_mode back to the previous one to make sure the following call to /* temporally set the current mc_mode back to the previous one to make sure the following call to
...@@ -789,6 +788,25 @@ static ivas_error ivas_mc_dec_reconfig( ...@@ -789,6 +788,25 @@ static ivas_error ivas_mc_dec_reconfig(
} }
} }
#ifdef NONBE_1321_JBM_ASSERT_BITRATE_SWITCHING
/* JBM: when granularity goes down (e.g. MCT with CREND -> ParamMC with binaural fastconv
render what still fits in the new granularity */
tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs );
if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity )
{
/* flush already done in IVAS_DEC_ReadFormat() */
}
/* JBM: when granularity goes up set samples to discard at the beginning of the frame */
else if ( tc_granularity_new > st_ivas->hTcBuffer->n_samples_granularity )
{
if ( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
}
#endif
if ( st_ivas->mc_mode == MC_MODE_MCT ) if ( st_ivas->mc_mode == MC_MODE_MCT )
{ {
st_ivas->nchan_transport = ivas_mc_ls_setup_get_num_channels( ivas_mc_map_output_config_to_mc_ls_setup( st_ivas->transport_config ) ); st_ivas->nchan_transport = ivas_mc_ls_setup_get_num_channels( ivas_mc_map_output_config_to_mc_ls_setup( st_ivas->transport_config ) );
...@@ -1077,42 +1095,6 @@ static ivas_error ivas_mc_dec_reconfig( ...@@ -1077,42 +1095,6 @@ static ivas_error ivas_mc_dec_reconfig(
return error; return error;
} }
/*-----------------------------------------------------------------*
* Allocate the LFE handle that is coded separately after the allocation of the core coders
*-----------------------------------------------------------------*/
if ( ( st_ivas->mc_mode == MC_MODE_MCT || st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) && st_ivas->hLFE == NULL )
{
int32_t delay_ns = st_ivas->binaural_latency_ns;
if ( st_ivas->hBinRenderer != NULL )
{
if ( st_ivas->hBinRenderer->render_lfe )
{
/* Account for filterbank delay */
delay_ns += IVAS_FB_DEC_DELAY_NS;
}
else
{
delay_ns = 0;
}
}
else
{
if ( ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) && ( st_ivas->cldfbSynDec[0] != NULL ) )
{
delay_ns += IVAS_FB_DEC_DELAY_NS;
}
}
if ( ( error = ivas_create_lfe_dec( &st_ivas->hLFE, st_ivas->hDecoderConfig->output_Fs, delay_ns ) ) != IVAS_ERR_OK )
{
return error;
}
set_zero( st_ivas->hLFE->prevsynth_buf, LFE_PLC_BUFLEN );
set_zero( st_ivas->hLFE->prior_out_buffer, L_FRAME48k );
}
/*-----------------------------------------------------------------* /*-----------------------------------------------------------------*
* Reconfigure renderers * Reconfigure renderers
*-----------------------------------------------------------------*/ *-----------------------------------------------------------------*/
...@@ -1161,6 +1143,7 @@ static ivas_error ivas_mc_dec_reconfig( ...@@ -1161,6 +1143,7 @@ static ivas_error ivas_mc_dec_reconfig(
if ( st_ivas->hBinRenderer != NULL && ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV && st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM ) ) if ( st_ivas->hBinRenderer != NULL && ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV && st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM ) )
{ {
ivas_binRenderer_close( &st_ivas->hBinRenderer ); ivas_binRenderer_close( &st_ivas->hBinRenderer );
if ( ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) ) if ( ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) )
{ {
efap_free_data( &st_ivas->hEFAPdata ); efap_free_data( &st_ivas->hEFAPdata );
...@@ -1169,7 +1152,7 @@ static ivas_error ivas_mc_dec_reconfig( ...@@ -1169,7 +1152,7 @@ static ivas_error ivas_mc_dec_reconfig(
if ( ( st_ivas->hCrendWrapper != NULL ) && ( st_ivas->hCrendWrapper->hCrend[0] != NULL ) && ( st_ivas->renderer_type != RENDERER_BINAURAL_MIXER_CONV && st_ivas->renderer_type != RENDERER_BINAURAL_MIXER_CONV_ROOM && ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD || st_ivas->hIntSetup.output_config != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) if ( ( st_ivas->hCrendWrapper != NULL ) && ( st_ivas->hCrendWrapper->hCrend[0] != NULL ) && ( st_ivas->renderer_type != RENDERER_BINAURAL_MIXER_CONV && st_ivas->renderer_type != RENDERER_BINAURAL_MIXER_CONV_ROOM && ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD || st_ivas->hIntSetup.output_config != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) )
{ {
ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ), ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ); ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) );
} }
if ( st_ivas->hBinRendererTd != NULL && ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD ) ) if ( st_ivas->hBinRendererTd != NULL && ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD ) )
...@@ -1263,6 +1246,63 @@ static ivas_error ivas_mc_dec_reconfig( ...@@ -1263,6 +1246,63 @@ static ivas_error ivas_mc_dec_reconfig(
return error; return error;
} }
/*-----------------------------------------------------------------*
* Allocate the LFE handle that is coded separately after the allocation of the core coders
*-----------------------------------------------------------------*/
if ( ( st_ivas->mc_mode == MC_MODE_MCT || st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) )
{
int32_t delay_ns;
if ( st_ivas->hIntSetup.index_lfe[0] != -1 )
{
delay_ns = st_ivas->binaural_latency_ns;
}
else
{
delay_ns = 0;
}
if ( st_ivas->hBinRenderer != NULL )
{
if ( st_ivas->hBinRenderer->render_lfe )
{
/* Account for filterbank delay */
delay_ns += IVAS_FB_DEC_DELAY_NS;
}
else
{
delay_ns = 0;
}
}
else
{
if ( ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) && ( st_ivas->cldfbSynDec[0] != NULL ) )
{
delay_ns += IVAS_FB_DEC_DELAY_NS;
}
}
if ( st_ivas->hLFE != NULL )
{
if ( st_ivas->hLFE->delay_ns != delay_ns )
{
ivas_lfe_dec_close( &( st_ivas->hLFE ) );
}
}
if ( st_ivas->hLFE == NULL )
{
if ( ( error = ivas_create_lfe_dec( &st_ivas->hLFE, st_ivas->hDecoderConfig->output_Fs, delay_ns ) ) != IVAS_ERR_OK )
{
return error;
}
set_zero( st_ivas->hLFE->prevsynth_buf, LFE_PLC_BUFLEN );
set_zero( st_ivas->hLFE->prior_out_buffer, L_FRAME48k );
}
}
/*-----------------------------------------------------------------* /*-----------------------------------------------------------------*
* JBM TC buffers * JBM TC buffers
*-----------------------------------------------------------------*/ *-----------------------------------------------------------------*/
...@@ -1275,11 +1315,22 @@ static ivas_error ivas_mc_dec_reconfig( ...@@ -1275,11 +1315,22 @@ static ivas_error ivas_mc_dec_reconfig(
tc_nchan_tc_new = ivas_jbm_dec_get_num_tc_channels( st_ivas ); tc_nchan_tc_new = ivas_jbm_dec_get_num_tc_channels( st_ivas );
tc_nchan_allocate_new = tc_nchan_tc_new; tc_nchan_allocate_new = tc_nchan_tc_new;
tc_nchan_full_new = tc_nchan_tc_new; tc_nchan_full_new = tc_nchan_tc_new;
#ifndef NONBE_1321_JBM_ASSERT_BITRATE_SWITCHING
tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs ); tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs );
#endif
if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC )
{
tc_nchan_allocate_new = BINAURAL_CHANNELS;
if ( st_ivas->hDiracDecBin[0] != NULL && st_ivas->hDiracDecBin[0]->useTdDecorr )
{ {
tc_nchan_allocate_new = 2 * BINAURAL_CHANNELS; tc_nchan_allocate_new = 2 * BINAURAL_CHANNELS;
}
else if ( st_ivas->hOutSetup.separateChannelEnabled )
{
tc_nchan_allocate_new++;
}
tc_nchan_full_new = tc_nchan_allocate_new; tc_nchan_full_new = tc_nchan_allocate_new;
} }
...@@ -1310,6 +1361,7 @@ static ivas_error ivas_mc_dec_reconfig( ...@@ -1310,6 +1361,7 @@ static ivas_error ivas_mc_dec_reconfig(
return error; return error;
} }
} }
/* transfer subframe info from central tc buffer to ParamMC or McMASA (DirAC) */ /* transfer subframe info from central tc buffer to ParamMC or McMASA (DirAC) */
if ( st_ivas->hSpatParamRendCom != NULL ) if ( st_ivas->hSpatParamRendCom != NULL )
{ {
...@@ -1334,8 +1386,7 @@ static ivas_error ivas_mc_dec_reconfig( ...@@ -1334,8 +1386,7 @@ static ivas_error ivas_mc_dec_reconfig(
*-----------------------------------------------------------------*/ *-----------------------------------------------------------------*/
nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ); nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 );
if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff, st_ivas->hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK )
if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK )
{ {
return error; return error;
} }
......
...@@ -804,7 +804,7 @@ void ivas_mdct_core_reconstruct( ...@@ -804,7 +804,7 @@ void ivas_mdct_core_reconstruct(
int16_t L_frame[CPE_CHANNELS], L_frameTCX[CPE_CHANNELS], nSubframes[CPE_CHANNELS]; int16_t L_frame[CPE_CHANNELS], L_frameTCX[CPE_CHANNELS], nSubframes[CPE_CHANNELS];
int16_t L_frame_global[CPE_CHANNELS], L_frame_globalTCX[CPE_CHANNELS]; int16_t L_frame_global[CPE_CHANNELS], L_frame_globalTCX[CPE_CHANNELS];
/* Synth */ /* Synth */
float synth_buf[OLD_SYNTH_SIZE_DEC + L_FRAME_PLUS + M]; float synth_buf[OLD_SYNTH_INTERNAL_DEC + L_FRAME_PLUS_INTERNAL + M];
float *synth; float *synth;
float synth_bufFB[OLD_SYNTH_SIZE_DEC + L_FRAME_PLUS + M]; float synth_bufFB[OLD_SYNTH_SIZE_DEC + L_FRAME_PLUS + M];
float *synthFB; float *synthFB;
...@@ -841,7 +841,7 @@ void ivas_mdct_core_reconstruct( ...@@ -841,7 +841,7 @@ void ivas_mdct_core_reconstruct(
synthFB = synth_bufFB + st->hTcxDec->old_synth_lenFB; synthFB = synth_bufFB + st->hTcxDec->old_synth_lenFB;
mvr2r( st->hTcxDec->old_synth, synth_buf, st->hTcxDec->old_synth_len ); mvr2r( st->hTcxDec->old_synth, synth_buf, st->hTcxDec->old_synth_len );
mvr2r( st->hTcxDec->old_synthFB, synth_bufFB, st->hTcxDec->old_synth_lenFB ); mvr2r( st->hTcxDec->old_synthFB, synth_bufFB, st->hTcxDec->old_synth_lenFB );
set_zero( synth, L_FRAME_PLUS + M ); set_zero( synth, L_FRAME_PLUS_INTERNAL + M );
set_zero( synthFB, L_FRAME_PLUS + M ); set_zero( synthFB, L_FRAME_PLUS + M );
if ( st->core != ACELP_CORE ) if ( st->core != ACELP_CORE )
...@@ -943,11 +943,7 @@ void ivas_mdct_core_reconstruct( ...@@ -943,11 +943,7 @@ void ivas_mdct_core_reconstruct(
/* Postfiltering */ /* Postfiltering */
post_decoder( st, synth_buf, pit_gain[ch], pitch[ch], x[ch][0], st->p_bpf_noise_buf ); post_decoder( st, synth_buf, pit_gain[ch], pitch[ch], x[ch][0], st->p_bpf_noise_buf );
if ( signal_outFB[ch] )
{
mvr2r( synthFB, signal_outFB[ch], st->hTcxDec->L_frameTCX ); mvr2r( synthFB, signal_outFB[ch], st->hTcxDec->L_frameTCX );
}
#ifdef DEBUG_PLC_INFO #ifdef DEBUG_PLC_INFO
{ {
int16_t i; int16_t i;
......
...@@ -200,7 +200,7 @@ ivas_error ivas_omasa_dec_config( ...@@ -200,7 +200,7 @@ ivas_error ivas_omasa_dec_config(
int32_t ivas_total_brate, ism_total_brate, cpe_brate; int32_t ivas_total_brate, ism_total_brate, cpe_brate;
ISM_MODE ism_mode_old; ISM_MODE ism_mode_old;
IVAS_FORMAT ivas_format_orig; IVAS_FORMAT ivas_format_orig;
int16_t nchan_out_buff, nchan_out_buff_old; int16_t nchan_out_buff;
ivas_error error; ivas_error error;
RENDERER_TYPE old_renderer_type; RENDERER_TYPE old_renderer_type;
...@@ -215,8 +215,6 @@ ivas_error ivas_omasa_dec_config( ...@@ -215,8 +215,6 @@ ivas_error ivas_omasa_dec_config(
ivas_format_orig = st_ivas->ivas_format; ivas_format_orig = st_ivas->ivas_format;
st_ivas->ivas_format = st_ivas->last_ivas_format; st_ivas->ivas_format = st_ivas->last_ivas_format;
ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old );
nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 );
st_ivas->ivas_format = ivas_format_orig; st_ivas->ivas_format = ivas_format_orig;
nSCE_old = st_ivas->nSCE; nSCE_old = st_ivas->nSCE;
...@@ -470,7 +468,7 @@ ivas_error ivas_omasa_dec_config( ...@@ -470,7 +468,7 @@ ivas_error ivas_omasa_dec_config(
*-----------------------------------------------------------------*/ *-----------------------------------------------------------------*/
nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ); nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 );
if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK ) if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff, st_ivas->hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK )
{ {
return error; return error;
} }
...@@ -673,19 +671,16 @@ void ivas_omasa_dirac_rend_jbm( ...@@ -673,19 +671,16 @@ void ivas_omasa_dirac_rend_jbm(
) )
{ {
int16_t subframes_rendered; int16_t subframes_rendered;
int16_t slots_rendered;
int16_t n; int16_t n;
float data_separated_objects[MAX_NUM_OBJECTS][L_FRAME48k]; float data_separated_objects[MAX_NUM_OBJECTS][L_FRAME48k];
if ( !st_ivas->hDecoderConfig->Opt_tsm )
{
*nSamplesRendered = min( nSamplesAsked, st_ivas->hTcBuffer->n_samples_available ); *nSamplesRendered = min( nSamplesAsked, st_ivas->hTcBuffer->n_samples_available );
if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ )
{ {
mvr2r( &output_f[CPE_CHANNELS][st_ivas->hTcBuffer->n_samples_rendered], data_separated_objects[0], *nSamplesRendered ); mvr2r( &output_f[CPE_CHANNELS][st_ivas->hTcBuffer->n_samples_rendered], data_separated_objects[0], *nSamplesRendered );
if ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) if ( !st_ivas->hDecoderConfig->Opt_tsm && st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ )
{ {
/* Gain separated object, if edited */ /* Gain separated object, if edited */
for ( n = 0; n < st_ivas->nchan_ism; n++ ) for ( n = 0; n < st_ivas->nchan_ism; n++ )
...@@ -704,14 +699,14 @@ void ivas_omasa_dirac_rend_jbm( ...@@ -704,14 +699,14 @@ void ivas_omasa_dirac_rend_jbm(
mvr2r( &output_f[n + CPE_CHANNELS][st_ivas->hTcBuffer->n_samples_rendered], data_separated_objects[n], *nSamplesRendered ); mvr2r( &output_f[n + CPE_CHANNELS][st_ivas->hTcBuffer->n_samples_rendered], data_separated_objects[n], *nSamplesRendered );
/* Gain discrete objects, if edited */ /* Gain discrete objects, if edited */
if ( st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) if ( !st_ivas->hDecoderConfig->Opt_tsm && st_ivas->hMasaIsmData->ism_gain_is_edited[n] )
{ {
v_multc( data_separated_objects[n], st_ivas->hMasaIsmData->gain_ism_edited[n], data_separated_objects[n], *nSamplesRendered ); v_multc( data_separated_objects[n], st_ivas->hMasaIsmData->gain_ism_edited[n], data_separated_objects[n], *nSamplesRendered );
} }
} }
/* Gain MASA part, if edited */ /* Gain MASA part, if edited */
if ( st_ivas->hMasaIsmData->masa_gain_is_edited ) if ( !st_ivas->hDecoderConfig->Opt_tsm && st_ivas->hMasaIsmData->masa_gain_is_edited )
{ {
for ( int16_t ch = 0; ch < 2; ch++ ) for ( int16_t ch = 0; ch < 2; ch++ )
{ {
...@@ -719,14 +714,12 @@ void ivas_omasa_dirac_rend_jbm( ...@@ -719,14 +714,12 @@ void ivas_omasa_dirac_rend_jbm(
} }
} }
} }
}
subframes_rendered = st_ivas->hSpatParamRendCom->subframes_rendered; subframes_rendered = st_ivas->hSpatParamRendCom->subframes_rendered;
slots_rendered = st_ivas->hSpatParamRendCom->slots_rendered;
ivas_dirac_dec_render( st_ivas, nchan_transport, nSamplesAsked, nSamplesRendered, nSamplesAvailable, output_f ); ivas_dirac_dec_render( st_ivas, nchan_transport, nSamplesAsked, nSamplesRendered, nSamplesAvailable, output_f );
ivas_omasa_separate_object_render_jbm( st_ivas, *nSamplesRendered, data_separated_objects, output_f, subframes_rendered, slots_rendered ); ivas_omasa_separate_object_render_jbm( st_ivas, *nSamplesRendered, data_separated_objects, output_f, subframes_rendered );
return; return;
} }
......
...@@ -183,12 +183,11 @@ ivas_error ivas_osba_dirac_td_binaural_jbm( ...@@ -183,12 +183,11 @@ ivas_error ivas_osba_dirac_td_binaural_jbm(
for ( b = 0; b < num_cldfb_bands; b++ ) for ( b = 0; b < num_cldfb_bands; b++ )
{ {
st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[n][slot_idx_start + slot_idx][b] = st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[n][slot_idx_start + slot_idx][b] =
( 0.5f * st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[n][slot_idx_start + slot_idx][b] ) + st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[n][slot_idx_start + slot_idx][b] +
( 0.5f * Cldfb_RealBuffer[b] ); Cldfb_RealBuffer[b];
st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[n][slot_idx_start + slot_idx][b] = st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[n][slot_idx_start + slot_idx][b] =
( 0.5f * st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[n][slot_idx_start + slot_idx][b] ) + st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[n][slot_idx_start + slot_idx][b] +
( 0.5f * Cldfb_ImagBuffer[b] ); Cldfb_ImagBuffer[b];
} }
} }
} }
...@@ -205,7 +204,7 @@ ivas_error ivas_osba_dirac_td_binaural_jbm( ...@@ -205,7 +204,7 @@ ivas_error ivas_osba_dirac_td_binaural_jbm(
int16_t i; int16_t i;
for ( i = 0; i < nSamplesAsked; i++ ) for ( i = 0; i < nSamplesAsked; i++ )
{ {
output_f[n][i] = 0.5f * output_f[channel_offset + n][i] + 0.5f * p_sepobj[n][i]; output_f[n][i] = output_f[channel_offset + n][i] + p_sepobj[n][i];
} }
} }
} }
...@@ -259,43 +258,35 @@ ivas_error ivas_osba_render_sf( ...@@ -259,43 +258,35 @@ ivas_error ivas_osba_render_sf(
) )
{ {
int16_t n; int16_t n;
float output_ism[MAX_OUTPUT_CHANNELS][L_FRAME48k]; float output_sba[MAX_OUTPUT_CHANNELS][L_FRAME48k];
float *p_output_ism[MAX_OUTPUT_CHANNELS]; float *p_output_sba[MAX_OUTPUT_CHANNELS];
ivas_error error; ivas_error error;
for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ )
{ {
p_output_ism[n] = &output_ism[n][0]; p_output_sba[n] = output_sba[n];
} }
if ( !st_ivas->hDecoderConfig->Opt_tsm ) if ( ( error = ivas_sba_dec_render( st_ivas, nSamplesAsked, nSamplesRendered, nSamplesAvailableNext, p_output_sba ) ) != IVAS_ERR_OK )
{
int16_t tc_offset;
tc_offset = st_ivas->hTcBuffer->n_samples_rendered;
for ( n = 0; n < st_ivas->nchan_ism; n++ )
{
mvr2r( &p_output[n][tc_offset], &output_ism[n][tc_offset], nSamplesAsked );
}
}
if ( ( error = ivas_sba_dec_render( st_ivas, nSamplesAsked, nSamplesRendered, nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK )
{ {
return error; return error;
} }
if ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM ) if ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM )
{ {
ivas_ism_render_sf( st_ivas, st_ivas->renderer_type, p_output_ism, *nSamplesRendered ); ivas_ism_render_sf( st_ivas, st_ivas->renderer_type, p_output, *nSamplesRendered );
} }
for ( n = 0; n < st_ivas->hDecoderConfig->nchan_out; n++ ) for ( n = 0; n < st_ivas->hDecoderConfig->nchan_out; n++ )
{ {
if ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM ) if ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM )
{ {
v_add( p_output[n], p_output_ism[n], p_output[n], *nSamplesRendered ); v_add( p_output[n], p_output_sba[n], p_output[n], *nSamplesRendered );
}
else
{
mvr2r( p_output_sba[n], p_output[n], *nSamplesRendered );
} }
v_multc( p_output[n], 0.5f, p_output[n], *nSamplesRendered );
} }
return IVAS_ERR_OK; return IVAS_ERR_OK;
...@@ -338,10 +329,6 @@ void ivas_osba_stereo_add_channels( ...@@ -338,10 +329,6 @@ void ivas_osba_stereo_add_channels(
} }
} }
for ( n = 0; n < nchan_out; n++ )
{
v_multc( output_f[n], 0.5f, output_f[n], n_samples_to_render );
}
return; return;
} }
...@@ -309,9 +309,7 @@ ivas_error ivas_ls_setup_conversion_open( ...@@ -309,9 +309,7 @@ ivas_error ivas_ls_setup_conversion_open(
int16_t output_frame; int16_t output_frame;
int32_t output_Fs; int32_t output_Fs;
int16_t paramUpmixMonoStereo; int16_t paramUpmixMonoStereo;
#ifdef FIX_1314_STEREO_TO_EXT
ivas_error error; ivas_error error;
#endif
if ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_PARAMUPMIX && ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO ) ) if ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_PARAMUPMIX && ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO ) )
{ {
...@@ -350,7 +348,7 @@ ivas_error ivas_ls_setup_conversion_open( ...@@ -350,7 +348,7 @@ ivas_error ivas_ls_setup_conversion_open(
set_f( hLsSetUpConversion->targetEnergyPrev[chIdx], 0.0f, hLsSetUpConversion->sfbCnt ); set_f( hLsSetUpConversion->targetEnergyPrev[chIdx], 0.0f, hLsSetUpConversion->sfbCnt );
set_f( hLsSetUpConversion->dmxEnergyPrev[chIdx], 0.0f, hLsSetUpConversion->sfbCnt ); set_f( hLsSetUpConversion->dmxEnergyPrev[chIdx], 0.0f, hLsSetUpConversion->sfbCnt );
} }
for ( ; chIdx < MAX_CICP_CHANNELS; chIdx++ ) for ( ; chIdx < MAX_LS_CHANNELS; chIdx++ )
{ {
hLsSetUpConversion->targetEnergyPrev[chIdx] = NULL; hLsSetUpConversion->targetEnergyPrev[chIdx] = NULL;
hLsSetUpConversion->dmxEnergyPrev[chIdx] = NULL; hLsSetUpConversion->dmxEnergyPrev[chIdx] = NULL;
...@@ -385,7 +383,7 @@ ivas_error ivas_ls_setup_conversion_open( ...@@ -385,7 +383,7 @@ ivas_error ivas_ls_setup_conversion_open(
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LS configuration Conversion Handle \n" ) ); return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LS configuration Conversion Handle \n" ) );
} }
for ( chIdx = 1; chIdx < MAX_CICP_CHANNELS; chIdx++ ) for ( chIdx = 1; chIdx < MAX_LS_CHANNELS; chIdx++ )
{ {
hLsSetUpConversion->targetEnergyPrev[chIdx] = NULL; hLsSetUpConversion->targetEnergyPrev[chIdx] = NULL;
hLsSetUpConversion->dmxEnergyPrev[chIdx] = NULL; hLsSetUpConversion->dmxEnergyPrev[chIdx] = NULL;
...@@ -406,7 +404,7 @@ ivas_error ivas_ls_setup_conversion_open( ...@@ -406,7 +404,7 @@ ivas_error ivas_ls_setup_conversion_open(
set_zero( hLsSetUpConversion->dmxMtx[chIdx], outChannels ); set_zero( hLsSetUpConversion->dmxMtx[chIdx], outChannels );
} }
for ( ; chIdx < MAX_CICP_CHANNELS; chIdx++ ) for ( ; chIdx < MAX_LS_CHANNELS; chIdx++ )
{ {
hLsSetUpConversion->dmxMtx[chIdx] = NULL; hLsSetUpConversion->dmxMtx[chIdx] = NULL;
} }
...@@ -421,37 +419,25 @@ ivas_error ivas_ls_setup_conversion_open( ...@@ -421,37 +419,25 @@ ivas_error ivas_ls_setup_conversion_open(
{ {
if ( paramUpmixMonoStereo == TRUE ) if ( paramUpmixMonoStereo == TRUE )
{ {
#ifdef FIX_1314_STEREO_TO_EXT
if ( ( error = get_ls_conversion_matrix( hLsSetUpConversion, IVAS_AUDIO_CONFIG_5_1_2, st_ivas->hDecoderConfig->output_config ) ) != IVAS_ERR_OK ) if ( ( error = get_ls_conversion_matrix( hLsSetUpConversion, IVAS_AUDIO_CONFIG_5_1_2, st_ivas->hDecoderConfig->output_config ) ) != IVAS_ERR_OK )
{ {
return error; return error;
} }
#else
get_ls_conversion_matrix( hLsSetUpConversion, IVAS_AUDIO_CONFIG_5_1_2, st_ivas->hDecoderConfig->output_config );
#endif
} }
else else
{ {
#ifdef FIX_1314_STEREO_TO_EXT
if ( ( error = get_ls_conversion_matrix( hLsSetUpConversion, st_ivas->transport_config, st_ivas->hDecoderConfig->output_config ) ) != IVAS_ERR_OK ) if ( ( error = get_ls_conversion_matrix( hLsSetUpConversion, st_ivas->transport_config, st_ivas->hDecoderConfig->output_config ) ) != IVAS_ERR_OK )
{ {
return error; return error;
} }
#else
get_ls_conversion_matrix( hLsSetUpConversion, st_ivas->transport_config, st_ivas->hDecoderConfig->output_config );
#endif
} }
} }
else else
{ {
#ifdef FIX_1314_STEREO_TO_EXT
if ( ( error = get_ls_conversion_matrix( hLsSetUpConversion, st_ivas->intern_config, st_ivas->hDecoderConfig->output_config ) ) != IVAS_ERR_OK ) if ( ( error = get_ls_conversion_matrix( hLsSetUpConversion, st_ivas->intern_config, st_ivas->hDecoderConfig->output_config ) ) != IVAS_ERR_OK )
{ {
return error; return error;
} }
#else
get_ls_conversion_matrix( hLsSetUpConversion, st_ivas->intern_config, st_ivas->hDecoderConfig->output_config );
#endif
} }
} }
...@@ -478,7 +464,7 @@ void ivas_ls_setup_conversion_close( ...@@ -478,7 +464,7 @@ void ivas_ls_setup_conversion_close(
return; return;
} }
for ( idx = 0; idx < MAX_CICP_CHANNELS; idx++ ) for ( idx = 0; idx < MAX_LS_CHANNELS; idx++ )
{ {
if ( ( *hLsSetUpConversion )->dmxMtx[idx] != NULL ) if ( ( *hLsSetUpConversion )->dmxMtx[idx] != NULL )
{ {
...@@ -585,17 +571,17 @@ void ivas_ls_setup_conversion_process_mdct( ...@@ -585,17 +571,17 @@ void ivas_ls_setup_conversion_process_mdct(
/* Declaration of all required variables */ /* Declaration of all required variables */
int16_t i, bandIdx, chInIdx, chOutIdx, cpe_idx, subFrameIdx, binIdx, idx; int16_t i, bandIdx, chInIdx, chOutIdx, cpe_idx, subFrameIdx, binIdx, idx;
int16_t inChannels, outChannels, num_CPE; int16_t inChannels, outChannels, num_CPE;
int16_t transform_type[MAX_CICP_CHANNELS][2]; int16_t transform_type[MAX_LS_CHANNELS][2];
int16_t frameSize; int16_t frameSize;
float targetEnergy[MAX_SFB + 2], dmxEnergy[MAX_SFB + 2]; float targetEnergy[MAX_SFB + 2], dmxEnergy[MAX_SFB + 2];
float dmxCoeff; float dmxCoeff;
float dmxSignalReal[L_FRAME48k], dmxSignalImag[L_FRAME48k]; float dmxSignalReal[L_FRAME48k], dmxSignalImag[L_FRAME48k];
float eqGain; float eqGain;
float *sig[NB_DIV], *pTmp[NB_DIV], *x[MAX_CICP_CHANNELS][NB_DIV]; float *sig[NB_DIV], *pTmp[NB_DIV], *x[MAX_LS_CHANNELS][NB_DIV];
float mdst[L_FRAME48k]; float mdst[L_FRAME48k];
float convertRes[L_FRAME48k]; float convertRes[L_FRAME48k];
int16_t start, stop, start_tcx5, stop_tcx5; int16_t start, stop, start_tcx5, stop_tcx5;
int16_t mct_chan_mode[MAX_CICP_CHANNELS]; int16_t mct_chan_mode[MAX_LS_CHANNELS];
/* Declare all handles */ /* Declare all handles */
LSSETUP_CONVERSION_HANDLE hLsSetUpConversion; LSSETUP_CONVERSION_HANDLE hLsSetUpConversion;
...@@ -826,20 +812,20 @@ void ivas_ls_setup_conversion_process_mdct_param_mc( ...@@ -826,20 +812,20 @@ void ivas_ls_setup_conversion_process_mdct_param_mc(
int16_t band, bandIdx, num_bands; int16_t band, bandIdx, num_bands;
int16_t num_CPE; int16_t num_CPE;
int16_t transform_type[MAX_CICP_CHANNELS][2]; int16_t transform_type[MAX_LS_CHANNELS][2];
int16_t frameSize; int16_t frameSize;
float targetEnergy[MAX_SFB + 2], dmxEnergy[MAX_SFB + 2]; float targetEnergy[MAX_SFB + 2], dmxEnergy[MAX_SFB + 2];
float eqGain; float eqGain;
float *sig[MAX_CICP_CHANNELS][NB_DIV], *pTmp[NB_DIV]; float *sig[MAX_LS_CHANNELS][NB_DIV], *pTmp[NB_DIV];
float mdst[MAX_CICP_CHANNELS][L_FRAME48k]; float mdst[MAX_LS_CHANNELS][L_FRAME48k];
float convertRes[MAX_CICP_CHANNELS][L_FRAME48k]; float convertRes[MAX_LS_CHANNELS][L_FRAME48k];
int16_t start, stop, start_tcx5, stop_tcx5; int16_t start, stop, start_tcx5, stop_tcx5;
int16_t mct_chan_mode[MAX_CICP_CHANNELS]; int16_t mct_chan_mode[MAX_LS_CHANNELS];
float cx[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; float cx[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS];
float cx_imag[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; float cx_imag[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS];
float cy[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; float cy[MAX_LS_CHANNELS * MAX_LS_CHANNELS];
float real_in_buffer[PARAM_MC_MAX_BANDS_IN_PARAMETER_BAND * PARAM_MC_BAND_TO_MDCT_BAND_RATIO * MAX_TRANSPORT_CHANNELS]; float real_in_buffer[PARAM_MC_MAX_BANDS_IN_PARAMETER_BAND * PARAM_MC_BAND_TO_MDCT_BAND_RATIO * MAX_TRANSPORT_CHANNELS];
float imag_in_buffer[PARAM_MC_MAX_BANDS_IN_PARAMETER_BAND * PARAM_MC_BAND_TO_MDCT_BAND_RATIO * MAX_TRANSPORT_CHANNELS]; float imag_in_buffer[PARAM_MC_MAX_BANDS_IN_PARAMETER_BAND * PARAM_MC_BAND_TO_MDCT_BAND_RATIO * MAX_TRANSPORT_CHANNELS];
float real_buffer[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; float real_buffer[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS];
...@@ -984,7 +970,7 @@ void ivas_ls_setup_conversion_process_mdct_param_mc( ...@@ -984,7 +970,7 @@ void ivas_ls_setup_conversion_process_mdct_param_mc(
for ( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ ) for ( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ )
{ {
DMXEne = 0.0f; DMXEne = 0.0f;
set_zero( cy, MAX_CICP_CHANNELS * MAX_CICP_CHANNELS ); set_zero( cy, MAX_LS_CHANNELS * MAX_LS_CHANNELS );
set_zero( Nrqq, MAX_OUTPUT_CHANNELS ); set_zero( Nrqq, MAX_OUTPUT_CHANNELS );
set_zero( target_ch_ener, MAX_OUTPUT_CHANNELS ); set_zero( target_ch_ener, MAX_OUTPUT_CHANNELS );
...@@ -1149,19 +1135,19 @@ void ivas_ls_setup_conversion_process_mdct_param_mc( ...@@ -1149,19 +1135,19 @@ void ivas_ls_setup_conversion_process_mdct_param_mc(
void ivas_lssetupconversion_process_param_mc( void ivas_lssetupconversion_process_param_mc(
Decoder_Struct *st_ivas, /* i/o: LS setup conversion renderer handle */ Decoder_Struct *st_ivas, /* i/o: LS setup conversion renderer handle */
const int16_t num_timeslots, const int16_t num_timeslots,
float Cldfb_RealBuffer_InOut[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i/o: LS signals */ float Cldfb_RealBuffer_InOut[MAX_LS_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i/o: LS signals */
float Cldfb_ImagBuffer_InOut[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i/o: LS signals */ float Cldfb_ImagBuffer_InOut[MAX_LS_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i/o: LS signals */
int16_t channel_active[MAX_CICP_CHANNELS] /* i : bitmap indicating which output channels are active */ int16_t channel_active[MAX_LS_CHANNELS] /* i : bitmap indicating which output channels are active */
) )
{ {
int16_t slotIdx, chOutIdx, chInIdx, bandIdx; int16_t slotIdx, chOutIdx, chInIdx, bandIdx;
int16_t inChannels, outChannels; int16_t inChannels, outChannels;
float targetEnergy[MAX_CICP_CHANNELS][CLDFB_NO_CHANNELS_MAX]; float targetEnergy[MAX_LS_CHANNELS][CLDFB_NO_CHANNELS_MAX];
float dmxEnergy[MAX_CICP_CHANNELS][CLDFB_NO_CHANNELS_MAX]; float dmxEnergy[MAX_LS_CHANNELS][CLDFB_NO_CHANNELS_MAX];
float tmpDMXSig, dmxCoeff, tmpReal, tmpImag; float tmpDMXSig, dmxCoeff, tmpReal, tmpImag;
float EQ; float EQ;
float Cldfb_RealBuffer_tmp[MAX_CICP_CHANNELS][CLDFB_NO_CHANNELS_MAX]; float Cldfb_RealBuffer_tmp[MAX_LS_CHANNELS][CLDFB_NO_CHANNELS_MAX];
float Cldfb_ImagBuffer_tmp[MAX_CICP_CHANNELS][CLDFB_NO_CHANNELS_MAX]; float Cldfb_ImagBuffer_tmp[MAX_LS_CHANNELS][CLDFB_NO_CHANNELS_MAX];
LSSETUP_CONVERSION_HANDLE hLsSetUpConversion; LSSETUP_CONVERSION_HANDLE hLsSetUpConversion;
push_wmops( "LS_Renderer_Process_Param_MC" ); push_wmops( "LS_Renderer_Process_Param_MC" );
......