Skip to content
......@@ -262,7 +262,11 @@ void hq_lr_dec(
frac1 = L_Extract_lc( L_tmp, &exp ); /* Extract exponent of L_tmp */
L_tmp = Pow2( 30, frac1 );
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 ) );
}
......
......@@ -293,8 +293,7 @@ ivas_error init_decoder(
st->last_vad = 0;
st->last_active_brate = ACELP_7k20;
st->last_CNG_L_frame = L_FRAME;
st->active_cnt = 20;
st->active_cnt = CNG_TYPE_HO;
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(
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;
if ( ( error = ivas_binaural_reverb_init( &( hBinRenderer->hReverb ),
st_ivas->hHrtfStatistics,
hBinRenderer->conv_band,
......@@ -1007,7 +1008,8 @@ ivas_error ivas_binRenderer_open(
st_ivas->hDecoderConfig->output_Fs,
st_ivas->hHrtfFastConv->fastconvReverberationTimes,
st_ivas->hHrtfFastConv->fastconvReverberationEneCorrections,
hBinRenderer->earlyPartEneCorrection ) ) != IVAS_ERR_OK )
NULL ) ) != IVAS_ERR_OK )
{
return error;
}
......
......@@ -75,7 +75,8 @@ ivas_error ivas_core_dec(
float synth[CPE_CHANNELS][L_FRAME48k];
float tmp_buffer[L_FRAME48k];
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];
int16_t core_switching_flag[CPE_CHANNELS];
float old_syn_12k8_16k[CPE_CHANNELS][L_FRAME16k];
......@@ -84,7 +85,7 @@ ivas_error ivas_core_dec(
int16_t unbits[CPE_CHANNELS];
int16_t sid_bw[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;
int32_t element_brate, output_Fs;
int32_t last_element_brate;
......@@ -200,6 +201,7 @@ ivas_error ivas_core_dec(
set_f( voice_factors[n], 0.f, NB_SUBFR16k );
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)
......@@ -348,7 +350,8 @@ ivas_error ivas_core_dec(
if ( st->core == ACELP_CORE )
{
/* 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;
}
......@@ -372,7 +375,7 @@ ivas_error ivas_core_dec(
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 */
......@@ -510,6 +513,8 @@ ivas_error ivas_core_dec(
* 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 ) )
{
/* SWB TBE decoder */
......@@ -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 );
}
}
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_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)
*---------------------------------------------------------------------*/
......@@ -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 );
}
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
*----------------------------------------------------------------*/
......@@ -589,18 +583,10 @@ ivas_error ivas_core_dec(
tmps = NS2SA( output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_12k8_NS );
}
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 */
tmps = NS2SA( output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_16k_NS );
}
}
/* 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 ) &&
......@@ -733,11 +719,9 @@ ivas_error ivas_core_dec(
} /* n_channels loop */
#ifdef DEBUG_MODE_INFO
output_debug_mode_info_dec( sts, n_channels, output_frame, pitch_buf );
#endif
pop_wmops();
return error;
}
......
......@@ -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 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()
......@@ -74,7 +76,7 @@ ivas_error ivas_cpe_dec(
int16_t last_bwidth;
int16_t tdm_ratio_idx;
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;
Decoder_State **sts;
STEREO_DFT_CONFIG_DATA_HANDLE hConfigDft;
......@@ -265,6 +267,8 @@ ivas_error ivas_cpe_dec(
}
else
{
res_buf = outputHB[0]; /* note: temporarily reused buffer */
if ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT )
{
nb_bits -= nb_bits_metadata;
......@@ -382,13 +386,17 @@ ivas_error ivas_cpe_dec(
if ( sts[1] != NULL )
{
sts[1]->active_cnt = 0;
if ( sts[1]->ini_frame == 0 )
{
sts[1]->active_cnt = CNG_TYPE_HO;
}
}
}
else
{
sts[n]->VAD = 1;
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 */
......@@ -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 ) )
{
float DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX];
/* core decoder */
if ( ( error = ivas_core_dec( NULL, NULL, hCPE, st_ivas->hMCT, n_channels, output, outputHB, DFT, 0 ) ) != IVAS_ERR_OK )
if ( ( error = stereo_dft_dec_main( hCPE, ivas_total_brate, n_channels, res_buf, output, outputHB, output_frame ) ) != IVAS_ERR_OK )
{
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 )
{
......@@ -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()
*
......
......@@ -1554,7 +1554,8 @@ void ivas_dirac_dec_render(
uint16_t slot_size, n_samples_sf, ch, nchan_intern;
SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom;
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;
......@@ -1565,7 +1566,7 @@ void ivas_dirac_dec_render(
for ( ch = 0; ch < nchan_intern; 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 );
......@@ -1587,22 +1588,22 @@ void ivas_dirac_dec_render(
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 );
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 */
ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf );
}
n_samples_sf = hSpatParamRendCom->subframe_nbslots[subframe_idx] * hSpatParamRendCom->slot_size;
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 ) ) )
{
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 )
......@@ -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()
*
......@@ -1633,8 +1708,8 @@ void ivas_dirac_dec_render_sf(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */
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_im[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX] )
float *pppQMfFrame_ts_re[HOA3_CHANNELS][CLDFB_NO_COL_MAX],
float *pppQMfFrame_ts_im[HOA3_CHANNELS][CLDFB_NO_COL_MAX] )
{
int16_t i, ch, idx_in, idx_lfe;
DIRAC_DEC_HANDLE hDirAC;
......@@ -1648,13 +1723,11 @@ void ivas_dirac_dec_render_sf(
float *p_Rmat;
int16_t slot_idx_start, slot_idx_start_cldfb_synth, md_idx;
/*CLDFB: last output channels reserved to LFT for CICPx*/
float Cldfb_RealBuffer[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX];
float Cldfb_ImagBuffer[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX];
float Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX];
float Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][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];
/*CLDFB: last output channels reserved to LFE for CICPx*/
float Cldfb_RealBuffer[MAX_OUTPUT_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX];
float Cldfb_ImagBuffer[MAX_OUTPUT_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX];
float Cldfb_RealBuffer_Binaural[1][BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX];
float Cldfb_ImagBuffer_Binaural[1][BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX];
int16_t index, num_freq_bands;
/* local copies of azi, ele, diffuseness */
......@@ -1832,8 +1905,8 @@ void ivas_dirac_dec_render_sf(
for ( ch = 0; ch < nchan_transport; ch++ )
{
cldfbAnalysis_ts( &( st_ivas->hTcBuffer->tc[hDirACRend->sba_map_tc[ch]][hSpatParamRendCom->num_freq_bands * index_slot] ),
Cldfb_RealBuffer_Temp[ch][slot_idx],
Cldfb_ImagBuffer_Temp[ch][slot_idx],
Cldfb_RealBuffer_Binaural[0][ch][slot_idx], /* note: it is a tmp. buffer at this point */
Cldfb_ImagBuffer_Binaural[0][ch][slot_idx], /* note: it is a tmp. buffer at this point */
hSpatParamRendCom->num_freq_bands,
st_ivas->cldfbAnaDec[ch] );
}
......@@ -1841,7 +1914,7 @@ void ivas_dirac_dec_render_sf(
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(
{
for ( ch = 0; ch < nchan_transport; ch++ )
{
mvr2r( Cldfb_RealBuffer_Temp[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_RealBuffer_Binaural[0][ch][slot_idx], Cldfb_RealBuffer[ch][0], hSpatParamRendCom->num_freq_bands );
mvr2r( Cldfb_ImagBuffer_Binaural[0][ch][slot_idx], Cldfb_ImagBuffer[ch][0], hSpatParamRendCom->num_freq_bands );
}
}
else
......@@ -2313,34 +2386,23 @@ void ivas_dirac_dec_render_sf(
}
/* 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 )
{
int16_t pos_idx;
for ( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ )
{
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 );
}
}
binRenderer_split( st_ivas->hBinRenderer, st_ivas->hSplitBinRend, st_ivas->hCombinedOrientationData, hSpatParamRendCom->subframe_nbslots[subframe_idx],
Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer, slot_idx_start, hSpatParamRendCom->num_freq_bands, st_ivas->hDecoderConfig->nchan_out );
}
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*/
for ( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ )
{
/* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */
float *RealBuffer[MAX_PARAM_SPATIAL_SUBFRAMES];
float *ImagBuffer[MAX_PARAM_SPATIAL_SUBFRAMES];
float *RealBuffer[CLDFB_SLOTS_PER_SUBFRAME];
float *ImagBuffer[CLDFB_SLOTS_PER_SUBFRAME];
for ( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ )
{
......@@ -2364,8 +2426,8 @@ void ivas_dirac_dec_render_sf(
}
else
{
float *RealBuffer[MAX_PARAM_SPATIAL_SUBFRAMES];
float *ImagBuffer[MAX_PARAM_SPATIAL_SUBFRAMES];
float *RealBuffer[CLDFB_SLOTS_PER_SUBFRAME];
float *ImagBuffer[CLDFB_SLOTS_PER_SUBFRAME];
int16_t outchannels;
idx_in = 0;
......@@ -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 */
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 );
}
for ( ch = 0; ch < outchannels; ch++ )
{
......
......@@ -380,25 +380,25 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot(
)
{
int16_t param_band_idx, band, ch_idx;
float mixing_matrix_smooth[MAX_CICP_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS];
float mixing_matrix_res_smooth[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS];
float mixing_matrix_buffer[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS];
float mixing_matrix_smooth[MAX_LS_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS];
float mixing_matrix_res_smooth[MAX_LS_CHANNELS * MAX_LS_CHANNELS];
float mixing_matrix_buffer[MAX_LS_CHANNELS * MAX_LS_CHANNELS];
int16_t have_residual;
float input_f_real[PARAM_MC_MAX_TRANSPORT_CHANS];
float input_f_imag[PARAM_MC_MAX_TRANSPORT_CHANS];
float output_f_real[MAX_CICP_CHANNELS];
float output_f_imag[MAX_CICP_CHANNELS];
float diff_f_real[MAX_CICP_CHANNELS];
float diff_f_imag[MAX_CICP_CHANNELS];
float output_f_real[MAX_LS_CHANNELS];
float output_f_imag[MAX_LS_CHANNELS];
float diff_f_real[MAX_LS_CHANNELS];
float diff_f_imag[MAX_LS_CHANNELS];
int16_t brange[2];
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_imag, PARAM_MC_MAX_TRANSPORT_CHANS );
set_zero( output_f_real, MAX_CICP_CHANNELS );
set_zero( output_f_imag, MAX_CICP_CHANNELS );
set_zero( diff_f_real, MAX_CICP_CHANNELS );
set_zero( diff_f_imag, MAX_CICP_CHANNELS );
set_zero( output_f_real, MAX_LS_CHANNELS );
set_zero( output_f_imag, MAX_LS_CHANNELS );
set_zero( diff_f_real, MAX_LS_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++ )
{
......
......@@ -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 )
......@@ -1252,6 +1252,7 @@ ivas_error ivas_init_decoder(
int16_t sce_id, cpe_id;
int16_t numCldfbAnalyses, numCldfbSyntheses;
int16_t granularity, n_channels_transport_jbm;
int16_t nchan_out_buff;
int32_t output_Fs, ivas_total_brate;
int32_t delay_ns;
AUDIO_CONFIG output_config;
......@@ -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->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 )
......@@ -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 )
{
......@@ -2378,22 +2387,13 @@ ivas_error ivas_init_decoder(
* 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 */
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 error;
}
return error;
return IVAS_ERR_OK;
}
......@@ -2781,7 +2781,7 @@ void ivas_destroy_dec(
ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin );
/* 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 */
ivas_reverb_close( &st_ivas->hReverb );
......@@ -2848,12 +2848,14 @@ void ivas_destroy_dec(
/* Limiter struct */
ivas_limiter_close( &( st_ivas->hLimiter ) );
/* Decoder configuration structure */
if ( st_ivas->hDecoderConfig != NULL )
{
free( st_ivas->hDecoderConfig );
st_ivas->hDecoderConfig = NULL;
}
/* JBM TC buffer structure */
ivas_jbm_dec_tc_buffer_close( &st_ivas->hTcBuffer );
if ( st_ivas->hJbmMetadata != NULL )
......@@ -2865,12 +2867,8 @@ void ivas_destroy_dec(
/* floating-point output audio buffers */
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;
}
}
/* main IVAS handle */
free( st_ivas );
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -380,7 +380,7 @@ ivas_error ivas_create_lfe_dec(
LFE_DEC_HANDLE hLFE;
float lfe_addl_delay_s;
int16_t i, j;
int16_t add_delay_sa;
float lfe_block_delay_s;
low_pass_delay_dec_out = 0;
block_offset_s = 0;
......@@ -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;
/* 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;
filt_order = 0;
......@@ -426,21 +426,21 @@ ivas_error ivas_create_lfe_dec(
if ( ( delay_ns / 1000000000.f ) > ivas_lfe_lpf_delay[IVAS_FILTER_ORDER_4 - 3] )
{
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 );
}
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->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 );
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 ) + add_delay_sa;
hLFE->lfe_block_delay_s += lfe_addl_delay_s + add_delay_sa / output_Fs;
hLFE->lfe_addl_delay = (int16_t) ( lfe_addl_delay_s * output_Fs );
hLFE->delay_ns = delay_ns;
if ( hLFE->lfe_addl_delay > 0 )
{
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.