Skip to content
......@@ -78,11 +78,7 @@ ivas_error ivas_ism_metadata_dec(
wmops_sub_start( "ism_meta_dec" );
#ifdef PARAM_ISM_DTX_CNG
if (ism_total_brate == IVAS_SID_5k || ism_total_brate == FRAME_NO_DATA)
#else
if ( ism_total_brate == IVAS_SID_4k4 || ism_total_brate == FRAME_NO_DATA )
#endif
if ( ism_total_brate == IVAS_SID_5k2 || ism_total_brate == FRAME_NO_DATA )
{
/* no metadata decoding in CNG */
for ( ch = 0; ch < *nchan_transport; ch++ )
......@@ -91,11 +87,7 @@ ivas_error ivas_ism_metadata_dec(
}
/* set padding bits as metadata bits to keep later bitrate checks valid */
#ifdef PARAM_ISM_DTX_CNG
nb_bits_metadata[0] = (IVAS_SID_5k - SID_2k40) / FRAMES_PER_SEC;
#else
nb_bits_metadata[0] = ( IVAS_SID_4k4 - SID_2k40 ) / FRAMES_PER_SEC;
#endif
nb_bits_metadata[0] = ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC;
#ifdef DEBUGGING
#ifndef PARAM_ISM_DTX_CNG
......
......@@ -1118,6 +1118,139 @@ void ivas_param_ism_params_to_masa_param_mapping(
return;
}
/*-------------------------------------------------------------------------*
* ivas_ism_bitrate_switching()
*
*
*-------------------------------------------------------------------------*/
static ivas_error ivas_ism_bitrate_switching(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
const int16_t nchan_transport_old, /* i : last number of transport channels */
const ISM_MODE last_ism_mode, /* i : last ISM mode */
const int16_t num_obj /* i : number of objects in the bitstream */
)
{
ivas_error error;
int32_t element_brate_tmp[MAX_NUM_OBJECTS];
error = IVAS_ERR_OK;
ivas_ism_config( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, num_obj, NULL, NULL, NULL, element_brate_tmp, NULL, NULL );
st_ivas->nSCE = st_ivas->nchan_transport;
ivas_corecoder_dec_reconfig( st_ivas, nchan_transport_old, 0, nchan_transport_old, 0 );
ivas_hp20_dec_reconfig( st_ivas, nchan_transport_old );
/* Initialize the needed renderer struct and destroy the unnecessary renderer struct */
/* select the renderer */
ivas_renderer_select( st_ivas );
ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->intern_config );
if ( ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) && ( st_ivas->ism_mode == ISM_MODE_DISC ) )
{
ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->hDecoderConfig->output_config );
}
if ( st_ivas->ism_mode != last_ism_mode )
{
/* EFAP handle */
efap_free_data( &st_ivas->hEFAPdata );
}
if ( st_ivas->ism_mode == ISM_MODE_DISC && last_ism_mode == ISM_MODE_PARAM )
{
/* switching from ParamISM to DiscISM */
/* Deallocate the ParamISM struct */
if ( st_ivas->hDirAC != NULL )
{
ivas_param_ism_dec_close( st_ivas->hDirAC, st_ivas->hDecoderConfig->output_config );
st_ivas->hDirAC = NULL;
}
if ( st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL )
{
/* close the parametric binaural renderer */
ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin );
/* Open the TD Binaural renderer */
ivas_td_binaural_open( st_ivas );
}
else
{
/* close the ISM renderer and reinitialize */
if ( st_ivas->hIsmRendererData != NULL )
{
count_free( st_ivas->hIsmRendererData );
st_ivas->hIsmRendererData = NULL;
}
ivas_ism_renderer_open( st_ivas );
}
if ( st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL_ROOM )
{
/* close the parametric binaural renderer */
ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin );
/* Open Crend Binaural renderer */
ivas_crend_open( st_ivas );
}
}
if ( st_ivas->ism_mode == ISM_MODE_PARAM && last_ism_mode == ISM_MODE_DISC )
{
/* switching from Discrete ISM to ParamISM */
/* Allocate and initialize the ParamISM struct */
ivas_param_ism_dec_open( st_ivas );
if ( st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL )
{
/* open the parametric binaural renderer */
ivas_dirac_dec_init_binaural_data( st_ivas );
/* Close the TD Binaural renderer */
if ( st_ivas->hBinRendererTd != NULL )
{
ivas_td_binaural_close( &st_ivas->hBinRendererTd );
}
if ( st_ivas->hHrtfTD != NULL )
{
st_ivas->hHrtfTD = NULL;
}
}
else
{
/* Close the ISM renderer */
if ( st_ivas->hIsmRendererData != NULL )
{
count_free( st_ivas->hIsmRendererData );
st_ivas->hIsmRendererData = NULL;
}
}
if ( st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL_ROOM )
{
/* open the parametric binaural renderer */
ivas_dirac_dec_init_binaural_data( st_ivas );
/* close the crend binaural renderer */
ivas_crend_close( st_ivas );
if ( st_ivas->hHrtf != NULL )
{
st_ivas->hHrtf = NULL;
}
}
}
return error;
}
/*-------------------------------------------------------------------------
* ivas_ism_dec_config()
*
......@@ -1134,6 +1267,7 @@ ivas_error ivas_ism_dec_config(
int32_t ivas_total_brate;
ISM_MODE last_ism_mode;
ivas_error error;
int16_t nchan_transport_old;
error = IVAS_ERR_OK;
......@@ -1141,12 +1275,14 @@ ivas_error ivas_ism_dec_config(
/* store last frame ISM mode */
last_ism_mode = st_ivas->ism_mode;
/* Assumes that num of input objects are constant */
nchan_transport_old = num_obj;
if ( last_ism_mode == ISM_MODE_PARAM )
{
nchan_transport_old = 2;
}
#ifdef PARAM_ISM_DTX_CNG
if (!st_ivas->bfi && ivas_total_brate != IVAS_SID_5k && ivas_total_brate != FRAME_NO_DATA)
#else
if ( !st_ivas->bfi && ivas_total_brate != IVAS_SID_4k4 && ivas_total_brate != FRAME_NO_DATA )
#endif
if ( !st_ivas->bfi && ivas_total_brate != IVAS_SID_5k2 && ivas_total_brate != FRAME_NO_DATA )
{
/* select ISM format mode */
st_ivas->ism_mode = ivas_ism_mode_select( num_obj, ivas_total_brate );
......@@ -1163,22 +1299,21 @@ ivas_error ivas_ism_dec_config(
if ( st_ivas->ini_active_frame != 0 )
{
/* ISM format switching */
if ( st_ivas->ism_mode != last_ism_mode )
/* ISM bit-rate switching */
if ( st_ivas->hDecoderConfig->last_ivas_total_brate != IVAS_SID_5k2 && st_ivas->hDecoderConfig->last_ivas_total_brate != FRAME_NO_DATA )
{
if ( ( st_ivas->ism_mode != last_ism_mode ) || ( st_ivas->hDecoderConfig->ivas_total_brate != st_ivas->hDecoderConfig->last_ivas_total_brate ) )
{
/*ivas_ism_dec_reconfigure( st_ivas );*/
return IVAS_ERROR( IVAS_ERR_RECONFIGURE_NOT_SUPPORTED, "\n\n!!! Error: ISM format switching not supported yet!!!\n\n" );
ivas_ism_bitrate_switching( st_ivas, nchan_transport_old, last_ism_mode, num_obj );
}
}
}
#ifdef PARAM_ISM_DTX_CNG
else if (!st_ivas->bfi && ivas_total_brate == IVAS_SID_5k)
#else
else if ( !st_ivas->bfi && ivas_total_brate == IVAS_SID_4k4 )
#endif
}
else if ( !st_ivas->bfi && ivas_total_brate == IVAS_SID_5k2 )
{
st_ivas->nchan_transport = num_obj;
}
switch ( num_obj )
{
case 1:
......
......@@ -29,7 +29,7 @@
the United Nations Convention on Contracts on the International Sales of Goods.
*******************************************************************************************************/
// VE2AT: move to lib_rend ?
#include <stdint.h>
#include "options.h"
#include "ivas_cnst.h"
......
......@@ -115,7 +115,7 @@ ivas_error ivas_masa_decode(
*nb_bits_read = 0;
next_bit_pos_orig = st->next_bit_pos;
if ( masa_brate == IVAS_SID_4k4 )
if ( masa_brate == IVAS_SID_5k2 )
{
st->next_bit_pos = (int16_t) ( ( masa_brate / FRAMES_PER_SEC ) - 1 - SID_FORMAT_NBITS );
}
......@@ -124,7 +124,7 @@ ivas_error ivas_masa_decode(
st->next_bit_pos = (int16_t) ( ( masa_brate / FRAMES_PER_SEC ) - 1 );
}
if ( !st->bfi && ivas_total_brate > IVAS_SID_4k4 )
if ( !st->bfi && ivas_total_brate > IVAS_SID_5k2 )
{
if ( !( ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCMASA ) )
{
......@@ -216,7 +216,7 @@ ivas_error ivas_masa_decode(
replicate_subframes( hQMetaData );
}
}
else if ( !st->bfi && ivas_format == MASA_FORMAT && ivas_total_brate == IVAS_SID_4k4 )
else if ( !st->bfi && ivas_format == MASA_FORMAT && ivas_total_brate == IVAS_SID_5k2 )
{
if ( hQMetaData->q_direction == NULL )
{
......@@ -229,7 +229,7 @@ ivas_error ivas_masa_decode(
ivas_masa_set_elements( ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport,
hQMetaData, &st_ivas->element_mode_init, &st_ivas->nSCE, &st_ivas->nCPE );
hQMetaData->metadata_max_bits = ( IVAS_SID_4k4 - SID_2k40 ) / FRAMES_PER_SEC;
hQMetaData->metadata_max_bits = ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC;
if ( ( error = ivas_qmetadata_allocate_memory( hQMetaData, 5, 1, 0 ) ) != IVAS_ERR_OK )
{
......@@ -285,7 +285,7 @@ ivas_error ivas_masa_decode(
{
st_ivas->hCPE[0]->hStereoDft->hConfig->force_mono_transmission = ivas_total_brate < MASA_STEREO_MIN_BITRATE ? 1 : 0;
if ( ivas_total_brate <= IVAS_SID_4k4 )
if ( ivas_total_brate <= IVAS_SID_5k2 )
{
st_ivas->hCPE[0]->hStereoDft->hConfig->force_mono_transmission = 0;
}
......@@ -295,11 +295,11 @@ ivas_error ivas_masa_decode(
{
st_ivas->hCPE[0]->hCoreCoder[0]->masa_sid_format = 0;
if ( st_ivas->hDecoderConfig->last_ivas_total_brate <= IVAS_SID_4k4 )
if ( st_ivas->hDecoderConfig->last_ivas_total_brate <= IVAS_SID_5k2 )
{
st_ivas->hCPE[0]->hCoreCoder[0]->masa_sid_format = 1;
if ( ivas_total_brate >= IVAS_SID_4k4 )
if ( ivas_total_brate >= IVAS_SID_5k2 )
{
st_ivas->hCPE[0]->element_brate = ivas_total_brate;
}
......@@ -479,7 +479,7 @@ void ivas_masa_prerender(
const int16_t output_frame /* i : output frame length per channel */
)
{
if ( st_ivas->ivas_format == MASA_FORMAT && st_ivas->nchan_transport == 2 && st_ivas->hDecoderConfig->ivas_total_brate < MASA_STEREO_MIN_BITRATE && st_ivas->hDecoderConfig->ivas_total_brate > IVAS_SID_4k4 )
if ( st_ivas->ivas_format == MASA_FORMAT && st_ivas->nchan_transport == 2 && st_ivas->hDecoderConfig->ivas_total_brate < MASA_STEREO_MIN_BITRATE && st_ivas->hDecoderConfig->ivas_total_brate > IVAS_SID_5k2 )
{
if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_EXTERNAL )
{
......
......@@ -250,6 +250,19 @@ ivas_error ivas_mct_dec(
#endif
}
#ifdef DEBUG_MODE_INFO
for ( cpe_id = 0; cpe_id < nCPE; cpe_id++ )
{
float tmpF = st_ivas->hCPE[cpe_id]->element_brate / 1000.0f;
dbgwrite( &tmpF, sizeof( float ), 1, output_frame, fname( debug_dir, "element_brate", 0, cpe_id, DEC ) );
dbgwrite( output[0], sizeof( float ), output_frame, 1, fname( debug_dir, "output.mct", 0, cpe_id, DEC ) );
tmpF = 0;
dbgwrite( &tmpF, sizeof( float ), 1, output_frame, fname( debug_dir, "output.sce", 0, cpe_id, DEC ) );
dbgwrite( &tmpF, sizeof( float ), 1, output_frame, fname( debug_dir, "output.cpe", 0, cpe_id, DEC ) );
}
#endif
wmops_sub_end();
return error;
}
......
......@@ -220,8 +220,7 @@ void apply_MCT_dec(
{
hBlock = hMCT->hBlockData[pair];
stereo_decoder_tcx( hBlock->hStereoMdct, hBlock->mask, &x[hBlock->ch2][0], &x[hBlock->ch1][0], &x[hBlock->ch2][0], hBlock->hStereoMdct->mdct_stereo_mode,
sts[hBlock->ch1]->core, sts[hBlock->ch2]->core, sts[0]->igf, sts[0]->hTcxDec->L_frameTCX, 1, TCX_20_CORE, TCX_20_CORE, 0 );
stereo_decoder_tcx( hBlock->hStereoMdct, hBlock->mask, &x[hBlock->ch2][0], &x[hBlock->ch1][0], &x[hBlock->ch2][0], hBlock->hStereoMdct->mdct_stereo_mode, sts[hBlock->ch1]->core, sts[hBlock->ch2]->core, sts[0]->igf, sts[0]->hTcxDec->L_frameTCX, sts[1]->hTcxDec->L_frameTCX, 1, TCX_20_CORE, TCX_20_CORE, 0 );
}
applyGlobalILD( sts, hMCT, x );
......@@ -283,7 +282,7 @@ void mctStereoIGF_dec(
/* stereo IGF decoding */
assert( ( sts[0]->core == sts[1]->core ) || ( hMCT->hBlockData[b]->hStereoMdct->mdct_stereo_mode[0] == SMDCT_DUAL_MONO ) );
decoder_tcx_IGF_stereo( sts, hMCT->hBlockData[b]->hStereoMdct, hMCT->hBlockData[b]->mask, p_x, L_frame[0], left_rect[0], k, bfi );
decoder_tcx_IGF_stereo( sts, hMCT->hBlockData[b]->hStereoMdct, hMCT->hBlockData[b]->mask, p_x, L_frame[0], left_rect[0], k, bfi, 1 /* MCT_flag */ );
}
else
{
......
......@@ -102,9 +102,7 @@ static void dec_prm_tcx_sidebits(
int16_t p_param[NB_DIV], /* o : pointer to parameters for next round of bs reading*/
int16_t nTnsBitsTCX10[NB_DIV], /* o : number of TNS bits per TCX10 subframe */
Decoder_State *st0, /* i/o: core decoder state handle - for bitstream */
#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT
const int16_t MCT_flag,
#endif
const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */
const int16_t ch /* i : channel */
)
{
......@@ -134,11 +132,7 @@ static void dec_prm_tcx_sidebits(
*--------------------------------------------------------------------------------*/
/* Modes (ACE_GC, ACE_UC, TCX20, TCX10...) */
#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT
getTCXMode( st, st0, MCT_flag );
#else
getTCXMode( st, st0 );
#endif
st->flagGuidedAcelp = 0;
......@@ -307,7 +301,7 @@ void ivas_mdct_dec_side_bits_frame_channel(
int16_t *LFE_off, /* o : flag if LFE has content */
int16_t nTnsBitsTCX10[CPE_CHANNELS][NB_DIV], /* o : number of bits for TNS */
int16_t param[CPE_CHANNELS][DEC_NPRM_DIV * NB_DIV], /* i/o: parameters buffer */
const int16_t MCT_flag, /* i : MCT tool active(1) or deactive(0) */
const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/
const int16_t odd_channel_cpe /* i : flag cpe with odd nb of tc channels */
)
{
......@@ -381,11 +375,7 @@ void ivas_mdct_dec_side_bits_frame_channel(
tmp = 3;
}
#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT
dec_prm_tcx_sidebits( param[ch], st, ( ( st->element_mode == IVAS_CPE_MDCT && !MCT_flag ) ? sts[0]->hTcxDec->tnsActive : NULL ), p_param[ch], nTnsBitsTCX10[ch], st0, MCT_flag, tmp );
#else
dec_prm_tcx_sidebits( param[ch], st, ( ( st->element_mode == IVAS_CPE_MDCT && !MCT_flag ) ? sts[0]->hTcxDec->tnsActive : NULL ), p_param[ch], nTnsBitsTCX10[ch], st0, tmp );
#endif
assert( st->BER_detect != 1 );
}
......@@ -455,7 +445,7 @@ void ivas_mdct_core_invQ(
float *x[CPE_CHANNELS][NB_DIV], /* i/o: signal buffer */
float Aq[CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )], /* i : LP coefficients */
int16_t ms_mask[NB_DIV][MAX_SFB], /* i : M/S mask */
const int16_t isMCT /* i : MCT flag */
const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */
)
{
int16_t ch, bfi, k;
......@@ -481,18 +471,14 @@ void ivas_mdct_core_invQ(
const int16_t *prm_sqQ;
int16_t L_frameTCX_global[CPE_CHANNELS];
float tmp_ms_sig[CPE_CHANNELS][N_MAX];
#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT
float concealment_noise[CPE_CHANNELS][L_FRAME48k];
TONALMDCTCONC_NOISE_GEN_MODE noise_gen_mode_bfi;
#endif
wmops_sub_start( "mdct_core_invQ" );
sts = hCPE->hCoreCoder;
bfi = sts[0]->bfi;
#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT
noise_gen_mode_bfi = -1;
#endif
set_f( xn_buf, 0, L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX );
set_s( total_nbbits, 0, CPE_CHANNELS );
......@@ -505,16 +491,15 @@ void ivas_mdct_core_invQ(
}
/* temporarily restore LR representation of previous frame for PLC mode decision (done on the individual channels) */
if ( bfi && !isMCT && ( hCPE->hStereoMdct->mdct_stereo_mode[0] > SMDCT_DUAL_MONO || hCPE->hStereoMdct->mdct_stereo_mode[1] > SMDCT_DUAL_MONO ) )
if ( bfi && !MCT_flag && ( hCPE->hStereoMdct->mdct_stereo_mode[0] > SMDCT_DUAL_MONO || hCPE->hStereoMdct->mdct_stereo_mode[1] > SMDCT_DUAL_MONO ) )
{
L_frameTCX[0] = sts[0]->L_frameTCX_past;
L_frameTCX[1] = sts[1]->L_frameTCX_past;
mvr2r( sts[0]->hTonalMDCTConc->lastBlockData.spectralData, tmp_ms_sig[0], L_frameTCX[0] );
mvr2r( sts[1]->hTonalMDCTConc->lastBlockData.spectralData, tmp_ms_sig[1], L_frameTCX[0] );
stereo_decoder_tcx( hCPE->hStereoMdct, ms_mask, x_0[1], &sts[0]->hTonalMDCTConc->lastBlockData.spectralData, &sts[1]->hTonalMDCTConc->lastBlockData.spectralData, &hCPE->hStereoMdct->mdct_stereo_mode[0],
sts[0]->core, sts[1]->core, sts[0]->igf, L_frameTCX[0], 0, sts[0]->last_core, sts[1]->last_core, 1 );
stereo_decoder_tcx( hCPE->hStereoMdct, ms_mask, x_0[1], &sts[0]->hTonalMDCTConc->lastBlockData.spectralData, &sts[1]->hTonalMDCTConc->lastBlockData.spectralData, &hCPE->hStereoMdct->mdct_stereo_mode[0], sts[0]->core, sts[1]->core, sts[0]->igf, L_frameTCX[0], L_frameTCX[1], 0, sts[0]->last_core, sts[1]->last_core, 1 );
}
#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT
if ( bfi )
{
if ( sts[0]->core == sts[1]->core )
......@@ -530,7 +515,6 @@ void ivas_mdct_core_invQ(
noise_gen_mode_bfi = TCX20_IN_0_TCX10_IN_1;
}
}
#endif
/* parameter decoding */
for ( ch = 0; ch < CPE_CHANNELS; ch++ )
......@@ -623,7 +607,7 @@ void ivas_mdct_core_invQ(
}
}
if ( bfi && !isMCT && ( hCPE->hStereoMdct->mdct_stereo_mode[0] > SMDCT_DUAL_MONO || hCPE->hStereoMdct->mdct_stereo_mode[1] > SMDCT_DUAL_MONO ) )
if ( bfi && !MCT_flag && ( hCPE->hStereoMdct->mdct_stereo_mode[0] > SMDCT_DUAL_MONO || hCPE->hStereoMdct->mdct_stereo_mode[1] > SMDCT_DUAL_MONO ) )
{
/* avoid using TD-PLC in only one channel when stereo mode isn't dual mono */
if ( sts[0]->core != sts[1]->core && ( sts[0]->core == ACELP_CORE || sts[1]->core == ACELP_CORE ) )
......@@ -728,23 +712,15 @@ void ivas_mdct_core_invQ(
}
nf_seed = 0;
#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT
decoder_tcx_invQ( st, prm[ch], Aq[ch], Aind[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], x[ch][k], NULL, xn_buf, &fUseTns[ch][k], &tnsData[ch][k], &gain_tcx, &prm_sqQ, &nf_seed, bfi, isMCT, k );
#else
decoder_tcx_invQ( st, prm[ch], Aq[ch], Aind[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], x[ch][k], NULL, xn_buf, &fUseTns[ch][k], &tnsData[ch][k], &gain_tcx, &prm_sqQ, &nf_seed, bfi, k );
#endif
mvr2r( x[ch][k], x_0[ch][k], L_frameTCX[ch] );
#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT
if ( bfi && !isMCT )
if ( bfi && !MCT_flag )
{
TonalMdctConceal_create_concealment_noise( concealment_noise[ch], hCPE, L_frameTCX[ch], L_frame[ch], ch, k, st->core, st->hTcxDec->cummulative_damping_tcx, noise_gen_mode_bfi );
}
decoder_tcx_noisefilling( st, concealment_noise[ch], Aq[ch], L_frameTCX_global[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], x[ch][k], NULL, &tmp_concealment_method, gain_tcx, prm_sqQ, nf_seed, bfi, isMCT, k );
#else
decoder_tcx_noisefilling( st, Aq[ch], L_frameTCX_global[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], x[ch][k], NULL, &tmp_concealment_method, gain_tcx, prm_sqQ, nf_seed, bfi, k );
#endif
decoder_tcx_noisefilling( st, concealment_noise[ch], Aq[ch], L_frameTCX_global[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], x[ch][k], NULL, &tmp_concealment_method, gain_tcx, prm_sqQ, nf_seed, bfi, MCT_flag, k );
decoder_tcx_noiseshaping_igf( st, L_spec[ch], L_frame[ch], L_frameTCX[ch], left_rect[ch], x[ch][k],
NULL, &tmp_concealment_method, bfi );
......@@ -775,7 +751,7 @@ void ivas_mdct_core_reconstruct(
float signal_outFB[CPE_CHANNELS][L_FRAME_PLUS], /* o : synthesis @output_FS */
const int16_t LFE_off, /* i : flag if LFE content */
int16_t fUseTns[CPE_CHANNELS][NB_DIV], /* i : flage TNS enabled */
const int16_t isMCT /* i : MCT flag */
const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0)*/
)
{
int16_t ch, k, bfi;
......@@ -861,31 +837,19 @@ void ivas_mdct_core_reconstruct(
TonalMDCTConceal_SaveTimeSignal( st->hTonalMDCTConc, synthFB, L_frameTCX[ch] );
}
#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT
decoder_tcx_post( st, synth, synthFB, NULL, bfi, isMCT );
#else
decoder_tcx_post( st, synth, synthFB, NULL, bfi );
#endif
decoder_tcx_post( st, synth, synthFB, NULL, bfi, MCT_flag );
}
else /*ACELP core for ACELP-PLC */
{
assert( st->bfi == 1 );
/* PLC: [TCX: TD PLC] */
if ( isMCT )
if ( MCT_flag )
{
#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT
con_tcx( st, &synthFB[0], -1.f, NULL, 0, NULL );
#else
con_tcx( st, &synthFB[0], -1.f, NULL, 0 );
#endif
}
else
{
#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT
con_tcx( st, &synthFB[0], hCPE->hStereoMdct->lastCoh, &sts[0]->seed_acelp, ( sts[1]->core != ACELP_CORE ) ? 1 : 0, &st->hFdCngDec->hFdCngCom->A_cng[0] );
#else
con_tcx( st, &synthFB[0], hCPE->hStereoMdct->lastCoh, &sts[0]->seed_acelp, ( sts[1]->core != ACELP_CORE ) ? 1 : 0 );
#endif
}
lerp( synthFB, synth, st->L_frame, st->hTcxDec->L_frameTCX );
......@@ -976,7 +940,7 @@ void ivas_mdct_core_reconstruct(
}
/* calculate coherence of signal needed when next frame is lost */
if ( !bfi && !isMCT && hCPE->element_mode == IVAS_CPE_MDCT )
if ( !bfi && !MCT_flag && hCPE->element_mode == IVAS_CPE_MDCT )
{
int16_t i;
......@@ -991,7 +955,7 @@ void ivas_mdct_core_reconstruct(
xcorr += signal_outFB[0][i] * signal_outFB[1][i];
}
hCPE->hStereoMdct->lastCoh = fabsf( xcorr ) / sqrtf( nrgL * nrgR );
hCPE->hStereoMdct->lastCoh = fabsf( xcorr ) * inv_sqrt( nrgL * nrgR );
hCPE->hStereoMdct->lastCoh = min( hCPE->hStereoMdct->lastCoh, 1.f );
}
......@@ -1012,7 +976,7 @@ void ivas_mdct_core_tns_ns(
STnsData tnsData[CPE_CHANNELS][NB_DIV], /* o : TNS parameter */
float *x[CPE_CHANNELS][NB_DIV], /* o : synthesis @internal_FS */
float Aq[CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )], /* o : LP coefficients */
const int16_t isMCT /* i : MCT flag */
const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */
)
{
int16_t ch, k, bfi;
......@@ -1064,54 +1028,26 @@ void ivas_mdct_core_tns_ns(
{
sns_interpolate_scalefactors( &sns_int_scf[0], &Aq[ch][k * M], DEC );
#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT
if ( isMCT && st->hTonalMDCTConc != NULL && ( ( k + 1 ) == nSubframes[ch] ) )
#else
if ( isMCT && st->hTonalMDCTConc != NULL )
#endif
{
#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT
int16_t infoIGFStartLine;
if ( st->igf == 0 )
if ( MCT_flag && st->hTonalMDCTConc != NULL && ( ( k + 1 ) == nSubframes[ch] ) )
{
if ( st->narrowBand == 0 )
{
/* minimum needed for output with sampling rates lower then the
nominal sampling rate */
infoIGFStartLine = min( L_frameTCX[ch], L_frame[ch] );
}
else
{
infoIGFStartLine = L_frameTCX[ch];
}
}
else
{
infoIGFStartLine = min( st->hIGFDec->infoIGFStartLine, L_frameTCX[ch] );
}
TonalMDCTConceal_SaveFreqSignal( st->hTonalMDCTConc, x[ch][k], L_frameTCX[ch], L_frame[ch], &sns_int_scf[0], infoIGFStartLine );
#else
TonalMDCTConceal_SaveFreqSignal( st->hTonalMDCTConc, x[ch][k], L_frameTCX[ch], L_frame[ch], &sns_int_scf[0] );
#endif
TonalMDCTConceal_SaveFreqSignal( st->hTonalMDCTConc, x[ch][k], L_frameTCX[ch], L_frame[ch], &sns_int_scf[0], get_igf_startline( st, L_frame[ch], L_frameTCX[ch] ) );
}
}
else
{
if ( st->hTonalMDCTConc != NULL )
{
#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT
if ( st->hTcxDec->cummulative_damping_tcx != 1.f )
if ( !MCT_flag && st->hTcxDec->cummulative_damping_tcx != 1.f )
{
float *scf_last;
float *scf_bg;
float fade_in;
float fade_out;
float *scf_last, *scf_bg;
float fade_in, fade_out;
scf_last = &st->hTonalMDCTConc->lastBlockData.scaleFactors[0];
scf_bg = &st->hTonalMDCTConc->scaleFactorsBackground[0];
fade_out = st->hTcxDec->cummulative_damping_tcx;
st->hTonalMDCTConc->scf_fadeout *= 0.95f;
fade_out = st->hTonalMDCTConc->scf_fadeout;
fade_in = 1 - fade_out;
for ( int16_t i = 0; i < st->hTonalMDCTConc->nScaleFactors; i++ )
......@@ -1121,11 +1057,9 @@ void ivas_mdct_core_tns_ns(
}
else
{
st->hTonalMDCTConc->scf_fadeout = 1.0f;
mvr2r( st->hTonalMDCTConc->lastBlockData.scaleFactors, &sns_int_scf[0], st->hTonalMDCTConc->nScaleFactors );
}
#else
mvr2r( st->hTonalMDCTConc->lastBlockData.scaleFactors, &sns_int_scf[0], st->hTonalMDCTConc->nScaleFactors );
#endif
}
}
......@@ -1144,7 +1078,7 @@ void ivas_mdct_core_tns_ns(
TonalMDCTConceal_Apply( st->hTonalMDCTConc, x[ch][0], st->hTcxCfg->psychParamsCurrent );
}
if ( ( bfi || isMCT ) && st->hTonalMDCTConc != NULL )
if ( ( bfi || MCT_flag ) && st->hTonalMDCTConc != NULL )
{
TonalMDCTConceal_UpdateState( st->hTonalMDCTConc, L_frameTCX[ch], ( st->hTcxDec->tcxltp_last_gain_unmodified > 0 ) ? st->old_fpitch : 0, bfi, bfi && st->tonal_mdct_plc_active );
}
......
......@@ -29,7 +29,7 @@
the United Nations Convention on Contracts on the International Sales of Goods.
*******************************************************************************************************/
// VE2AT: move to lib_rend ?
#include <stdint.h>
#include "options.h"
#include <math.h>
......
......@@ -29,7 +29,7 @@
the United Nations Convention on Contracts on the International Sales of Goods.
*******************************************************************************************************/
// VE2AT: move to lib_rend ?
#include <assert.h>
#include <stdint.h>
#include "options.h"
......
......@@ -478,7 +478,7 @@ void stereo_dft_dec_core_switching(
mvr2r( output, pAp_input, st->L_frame );
}
if ( st->last_core == ACELP_CORE && !( st->prev_bfi == 1 && st->last_core == ACELP_CORE && st->last_con_tcx == 1 ) ) /* ACELP -> TCX/HQ-Core */
if ( st->last_core == ACELP_CORE && !( st->prev_bfi == 1 && st->last_core == ACELP_CORE && st->last_con_tcx == 1 ) && !st->tcxonly ) /* ACELP -> TCX/HQ-Core */
{
mvr2r( tcx_core_buf, tmp_fade, ap_fade_len );
for ( i = 0; i < ap_fade_len; i++ )
......
......@@ -721,17 +721,20 @@ int16_t ivas_qmetadata_dec_sid_decode(
{
if ( sba_mode == SBA_MODE_SPAR )
{
metadata_sid_bits = (int16_t) ( IVAS_SID_5k - SID_2k40 ) / FRAMES_PER_SEC - ( SPAR_DTX_BANDS * 18 ) - 1; /* -1 for inactive mode header bit*/
/* TODO: still use old sid frame size to keep bitexactness */
metadata_sid_bits = (int16_t) ( 5000 /*IVAS_SID_5k2*/ - SID_2k40 ) / FRAMES_PER_SEC - ( SPAR_DTX_BANDS * 18 ) - 1; /* -1 for inactive mode header bit*/
}
else
{
/* keep 13.2 and 16.4 sid bitrate as 4.4 kbps for now*/
metadata_sid_bits = ( IVAS_SID_4k4 - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS;
/* TODO: still use old sid frame size to keep bitexactness */
metadata_sid_bits = ( 4400 /*IVAS_SID_5k2*/ - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS;
}
}
else
{
metadata_sid_bits = ( IVAS_SID_4k4 - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS;
/* TODO: still use old sid frame size to keep bitexactness */
metadata_sid_bits = ( 4400 /*IVAS_SID_5k2*/ - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS;
}
start_index = *index;
......@@ -850,6 +853,18 @@ int16_t ivas_qmetadata_dec_sid_decode(
}
}
}
/* TODO: temporary hack to keep BE */
if ( ivas_format == SBA_FORMAT )
{
if ( sba_mode != SBA_MODE_SPAR )
{
metadata_sid_bits = ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS - 1; /* -1 for spar/dirac indicator*/
}
}
else
{
metadata_sid_bits = ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS;
}
/*Read filling bits*/
while ( start_index - *index < metadata_sid_bits )
......
......@@ -512,393 +512,11 @@ const int16_t sba_map_tc[8] =
0, 1, 2, 3, 4, 8, 9, 15
};
/*----------------------------------------------------------------------------------*
* LS Renderer ROM tables
*----------------------------------------------------------------------------------*/
/* All matrices are stored with dimensions nchan_in x nchan_out */
/* Downmix matrices */
const float ls_conversion_cicpX_mono[12][1] =
{
{1.00000000f},
{1.00000000f},
{0.70710677f},
{0.70710677f},
{0.79999995f},
{0.79999995f},
{0.79999995f},
{0.79999995f},
{0.849999964f},
{0.849999964f},
{0.849999964f},
{0.849999964f}
};
const float ls_conversion_cicpX_stereo[12][2] =
{
{1.00000000f, 0.00000000f},
{0.00000000f, 1.00000000f},
{0.70710677f, 0.70710677f},
{0.70710677f, 0.70710677f},
{0.79999995f, 0.00000000f},
{0.00000000f, 0.79999995f},
{0.79999995f, 0.00000000f},
{0.00000000f, 0.79999995f},
{0.849999964f, 0.000000000f},
{0.000000000f, 0.849999964f},
{0.849999964f, 0.000000000f},
{0.000000000f, 0.849999964f}
};
const LS_CONVERSION_MATRIX ls_conversion_cicp12_cicp6[] =
{
/* First row indicates the number of non-zero elements */
{8, 0.0f},
/* Index of non-zero element, value of non-zero element*/
{0, 1.000000000f},
{7, 1.000000000f},
{14, 1.000000000f},
{21, 1.000000000f},
{28, 1.000000000f},
{35, 1.000000000f},
{40, 1.000000000f},
{47, 1.000000000f}
};
const LS_CONVERSION_MATRIX ls_conversion_cicp14_cicp6[] =
{
/* First row indicates the number of non-zero elements */
{8, 0.0f},
/* Index of non-zero element, value of non-zero element*/
{0, 1.000000000f},
{7, 1.000000000f},
{14, 1.000000000f},
{21, 1.000000000f},
{28, 1.000000000f},
{35, 1.000000000f},
{36, 0.849999964f},
{43, 0.849999964f}
};
const LS_CONVERSION_MATRIX ls_conversion_cicp14_cicp12[] =
{
/* First row indicates the number of non-zero elements */
{8, 0.0f},
/* Index of non-zero element, value of non-zero element*/
{0, 1.000000000f},
{9, 1.000000000f},
{18, 1.000000000f},
{27, 1.000000000f},
{36, 1.000000000f},
{45, 1.000000000f},
{48, 0.849999964f},
{57, 0.849999964f}
};
const LS_CONVERSION_MATRIX ls_conversion_cicp16_cicp6[] =
{
/* First row indicates the number of non-zero elements */
{10, 0.0f},
/* Index of non-zero element, value of non-zero element*/
{0, 1.000000000f},
{7, 1.000000000f},
{14, 1.000000000f},
{21, 1.000000000f},
{28, 1.000000000f},
{35, 1.000000000f},
{36, 0.849999964f},
{43, 0.849999964f},
{52, 0.849999964f},
{59, 0.849999964f}
};
const LS_CONVERSION_MATRIX ls_conversion_cicp16_cicp12[] =
{
/* First row indicates the number of non-zero elements */
{10, 0.0f},
/* Index of non-zero element, value of non-zero element*/
{0, 1.000000000f},
{9, 1.000000000f},
{18, 1.000000000f},
{27, 1.000000000f},
{36, 1.000000000f},
{45, 1.000000000f},
{48, 0.849999964f},
{57, 0.849999964f},
{68, 0.849999964f},
{77, 0.849999964f}
};
const LS_CONVERSION_MATRIX ls_conversion_cicp16_cicp14[] =
{
/* First row indicates the number of non-zero elements */
{10, 0.0f},
/* Index of non-zero element, value of non-zero element*/
{0, 1.000000000f},
{9, 1.000000000f},
{18, 1.000000000f},
{27, 1.000000000f},
{36, 1.000000000f},
{45, 1.000000000f},
{54, 1.000000000f},
{63, 1.000000000f},
{68, 0.849999964f},
{77, 0.849999964f},
};
const LS_CONVERSION_MATRIX ls_conversion_cicp19_cicp6[] =
{
/* First row indicates the number of non-zero elements */
{14, 0.0f},
/* Index of non-zero element, value of non-zero element*/
{0, 1.000000000f},
{7, 1.000000000f},
{14, 1.000000000f},
{21, 1.000000000f},
{28, 1.000000000f},
{35, 1.000000000f},
{36, 0.367322683f},
{40, 0.930093586f},
{43, 0.367322683f},
{47, 0.930093586f},
{48, 0.849999964f},
{55, 0.849999964f},
{64, 0.849999964f},
{71, 0.849999964f}
};
const LS_CONVERSION_MATRIX ls_conversion_cicp19_cicp12[] =
{
/* First row indicates the number of non-zero elements */
{14, 0.0f},
/* Index of non-zero element, value of non-zero element*/
{0, 1.000000000f},
{9, 1.000000000f},
{18, 1.000000000f},
{27, 1.000000000f},
{38, 1.000000000f},
{47, 1.000000000f},
{48, 0.367322683f},
{52, 0.930093586f},
{57, 0.367322683f},
{61, 0.930093586f},
{64, 0.849999964f},
{73, 0.849999964f},
{84, 0.849999964f},
{93, 0.849999964f}
};
const LS_CONVERSION_MATRIX ls_conversion_cicp19_cicp14[] =
{
/* First row indicates the number of non-zero elements */
{14, 0.0f},
/* Index of non-zero element, value of non-zero element*/
{0, 1.000000000f},
{9, 1.000000000f},
{18, 1.000000000f},
{27, 1.000000000f},
{36, 1.000000000f},
{45, 1.000000000f},
{48, 0.367322683f},
{52, 0.930093586f},
{57, 0.367322683f},
{61, 0.930093586f},
{70, 1.000000000f},
{79, 1.000000000f},
{84, 0.849999964f},
{93, 0.849999964f}
};
const LS_CONVERSION_MATRIX ls_conversion_cicp19_cicp16[] =
{
/* First row indicates the number of non-zero elements */
{14, 0.0f},
/* Index of non-zero element, value of non-zero element*/
{0, 1.000000000f},
{11, 1.000000000f},
{22, 1.000000000f},
{33, 1.000000000f},
{44, 1.000000000f},
{55, 1.000000000f},
{60, 0.367322683f},
{64, 0.930093586f},
{71, 0.367322683f},
{75, 0.930093586f},
{86, 1.000000000f},
{97, 1.000000000f},
{108, 1.000000000f},
{119, 1.000000000f}
};
/* Upmix matrices */
const LS_CONVERSION_MATRIX ls_conversion_cicp12_cicp14[] =
{
/* First row indicates the number of non-zero elements */
{8, 0.0f},
/* Index of non-zero element, value of non-zero element*/
{0, 1.0f},
{9, 1.0f},
{18, 1.0f},
{27, 1.0f},
{36, 1.0f},
{45, 1.0f},
{52, 1.0f},
{61, 1.0f}
};
const LS_CONVERSION_MATRIX ls_conversion_cicp12_cicp16[] =
{
/* First row indicates the number of non-zero elements */
{8, 0.0f},
/* Index of non-zero element, value of non-zero element*/
{0, 1.0f},
{11, 1.0f},
{22, 1.0f},
{33, 1.0f},
{44, 1.0f},
{55, 1.0f},
{64, 1.0f},
{75, 1.0f}
};
const LS_CONVERSION_MATRIX ls_conversion_cicp12_cicp19[] =
{
/* First row indicates the number of non-zero elements */
{8, 0.0f},
/* Index of non-zero element, value of non-zero element*/
{0, 1.0f},
{13, 1.0f},
{26, 1.0f},
{39, 1.0f},
{54, 1.0f},
{67, 1.0f},
{76, 1.0f},
{89, 1.0f}
};
const LS_CONVERSION_MATRIX ls_conversion_cicp14_cicp19[] =
{
/* First row indicates the number of non-zero elements */
{8, 0.0f},
/* Index of non-zero element, value of non-zero element*/
{0, 1.0f},
{13, 1.0f},
{26, 1.0f},
{39, 1.0f},
{52, 1.0f},
{65, 1.0f},
{80, 1.0f},
{93, 1.0f}
};
const LS_CONVERSION_MATRIX ls_conversion_cicp16_cicp19[] =
{
/* First row indicates the number of non-zero elements */
{10, 0.0f},
/* Index of non-zero element, value of non-zero element*/
{0, 1.0f},
{13, 1.0f},
{26, 1.0f},
{39, 1.0f},
{52, 1.0f},
{65, 1.0f},
{80, 1.0f},
{93, 1.0f},
{106, 1.0f},
{119, 1.0f}
};
/*
* Mapping table of input config : output config with corresponding matrix
* NULL indicates a 1:1 mapping of existing input channels to output channels ( used for upmix )
*/
const LS_CONVERSION_MAPPING ls_conversion_mapping[LS_SETUP_CONVERSION_NUM_MAPPINGS] =
{
/* Dowmix mappings - NULL is a special case for MONO / STEREO downmix */
{AUDIO_CONFIG_5_1, AUDIO_CONFIG_MONO, NULL},
{AUDIO_CONFIG_7_1, AUDIO_CONFIG_MONO, NULL},
{AUDIO_CONFIG_5_1_2, AUDIO_CONFIG_MONO, NULL},
{AUDIO_CONFIG_5_1_4, AUDIO_CONFIG_MONO, NULL},
{AUDIO_CONFIG_7_1_4, AUDIO_CONFIG_MONO, NULL},
{AUDIO_CONFIG_5_1, AUDIO_CONFIG_STEREO, NULL},
{AUDIO_CONFIG_7_1, AUDIO_CONFIG_STEREO, NULL},
{AUDIO_CONFIG_5_1_2, AUDIO_CONFIG_STEREO, NULL},
{AUDIO_CONFIG_5_1_4, AUDIO_CONFIG_STEREO, NULL},
{AUDIO_CONFIG_7_1_4, AUDIO_CONFIG_STEREO, NULL},
{AUDIO_CONFIG_7_1, AUDIO_CONFIG_5_1, ls_conversion_cicp12_cicp6},
{AUDIO_CONFIG_5_1_2, AUDIO_CONFIG_5_1, ls_conversion_cicp14_cicp6},
{AUDIO_CONFIG_5_1_2, AUDIO_CONFIG_7_1, ls_conversion_cicp14_cicp12},
{AUDIO_CONFIG_5_1_4, AUDIO_CONFIG_5_1, ls_conversion_cicp16_cicp6},
{AUDIO_CONFIG_5_1_4, AUDIO_CONFIG_7_1, ls_conversion_cicp16_cicp12},
{AUDIO_CONFIG_5_1_4, AUDIO_CONFIG_5_1_2, ls_conversion_cicp16_cicp14},
{AUDIO_CONFIG_7_1_4, AUDIO_CONFIG_5_1, ls_conversion_cicp19_cicp6},
{AUDIO_CONFIG_7_1_4, AUDIO_CONFIG_7_1, ls_conversion_cicp19_cicp12},
{AUDIO_CONFIG_7_1_4, AUDIO_CONFIG_5_1_2, ls_conversion_cicp19_cicp14},
{AUDIO_CONFIG_7_1_4, AUDIO_CONFIG_5_1_4, ls_conversion_cicp19_cicp16},
/* Upmix mappings - NULL implies a 1:1 upmix */
{AUDIO_CONFIG_STEREO, AUDIO_CONFIG_5_1, NULL},
{AUDIO_CONFIG_STEREO, AUDIO_CONFIG_7_1, NULL},
{AUDIO_CONFIG_STEREO, AUDIO_CONFIG_5_1_2, NULL},
{AUDIO_CONFIG_STEREO, AUDIO_CONFIG_5_1_4, NULL},
{AUDIO_CONFIG_STEREO, AUDIO_CONFIG_7_1_4, NULL},
{AUDIO_CONFIG_5_1, AUDIO_CONFIG_7_1, NULL},
{AUDIO_CONFIG_5_1, AUDIO_CONFIG_5_1_2, NULL},
{AUDIO_CONFIG_5_1, AUDIO_CONFIG_5_1_4, NULL},
{AUDIO_CONFIG_5_1, AUDIO_CONFIG_7_1_4, NULL},
{AUDIO_CONFIG_7_1, AUDIO_CONFIG_5_1_2, ls_conversion_cicp12_cicp14},
{AUDIO_CONFIG_7_1, AUDIO_CONFIG_5_1_4, ls_conversion_cicp12_cicp16},
{AUDIO_CONFIG_7_1, AUDIO_CONFIG_7_1_4, ls_conversion_cicp12_cicp19},
{AUDIO_CONFIG_5_1_2, AUDIO_CONFIG_5_1_4, NULL},
{AUDIO_CONFIG_5_1_2, AUDIO_CONFIG_7_1_4, ls_conversion_cicp14_cicp19},
{AUDIO_CONFIG_5_1_4, AUDIO_CONFIG_7_1_4, ls_conversion_cicp16_cicp19},
};
/*----------------------------------------------------------------------------------*
* FASTCONV and PARAMETRIC binaural renderer ROM tables
*----------------------------------------------------------------------------------*/
const float dmxmtx[BINAURAL_CHANNELS][11] =
{
{ 1.0f, 0.0f, 0.70709997f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f },
{ 0.0f, 1.0f, 0.70709997f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f },
};
/*
* 0 = 30,0
* 1 = -30,0
* 2 = 0,0
* 3 = 135,0
* 4 = -135,0
* 5 = 110,0
* 6 = -110,0
* 7 = 90,0
* 8 = -90,0
* 9 = 30,35
* 10 = -30,35
* 11 = 110,35
* 12 = -110,35
* 13 = 135, 35
* 14 = -135, 35
*/
const int16_t channelIndex_CICP6[5] = { 0, 1, 2, 5, 6 };
const int16_t channelIndex_CICP12[7] = { 0, 1, 2, 5, 6, 3, 4 };
const int16_t channelIndex_CICP14[7] = { 0, 1, 2, 5, 6, 9, 10 };
const int16_t channelIndex_CICP16[9] = { 0, 1, 2, 5, 6, 9, 10, 11, 12 };
const int16_t channelIndex_CICP19[11] = { 0, 1, 2, 3, 4, 7, 8, 9, 10, 13, 14 };
// VE2AT: move to in ivas_rom_dec ?
const float surCohEne[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS] =
{
3.0903f, 2.0053f, 1.0860f, 0.8072f, 0.7079f
......@@ -934,261 +552,4 @@ const float diffuseFieldCoherenceDifferenceZ[BINAURAL_COHERENCE_DIFFERENCE_BINS]
0.048207f, 0.10796f, 0.11845f, 0.047886f, 0.035917f, 0.045196f, 0.018863f, 0.015547f, 0.014157f
};
/*----------------------------------------------------------------------------------*
* TD ISm binaural renderer ROM tables
*----------------------------------------------------------------------------------*/
/* The maximum target times set to 100 msec. */
const int16_t TDREND_SRC_REND_MaxTargetTimes[IVAS_NUM_SUPPORTED_FS] =
{
1600, 3200, 4800 /* Corresponds to 16kHz, 32kHz, 48kHz */
};
/* The maximum lengths of the blocks internally in the effect. Corresponds to 6 msec. This means also that */
/* if the length of the input block is just above 6 msec, the block will be divided into two 3 msec blocks. */
const int16_t TDREND_SRC_REND_MaxBlockLengths[IVAS_NUM_SUPPORTED_FS] =
{
96, 192, 288 /* Corresponds to 16kHz, 32kHz, 48kHz */
};
const int16_t TDREND_MaxITD[IVAS_NUM_SUPPORTED_FS] =
{
111, 222, 333 /* Corresponds to 16kHz, 32kHz, 48kHz */
};
const float TDREND_MaxITD_Incr[IVAS_NUM_SUPPORTED_FS] =
{
0.0925f, 0.1850f, 0.2775f /* Corresponds to 16kHz, 32kHz, 48kHz, e.g. ( ( 2 * MaxITD ) / ( 0.05 * 48000 ) ) */
};
const int16_t HRTF_MODEL_N_CPTS_VAR[HRTF_MODEL_N_SECTIONS] =
{
13, 12, 11
};
const float SincTable[321] =
{
1.00000000f, 0.99957629f, 0.99830587f, 0.99619078f, 0.99323448f, 0.98944177f, 0.98481881f, 0.97937311f,
0.97311350f, 0.96605012f, 0.95819441f, 0.94955907f, 0.94015803f, 0.93000645f, 0.91912066f, 0.90751815f,
0.89521750f, 0.88223838f, 0.86860150f, 0.85432856f, 0.83944219f, 0.82396595f, 0.80792425f, 0.79134231f,
0.77424608f, 0.75666226f, 0.73861817f, 0.72014174f, 0.70126144f, 0.68200624f, 0.66240553f, 0.64248906f,
0.62228691f, 0.60182943f, 0.58114713f, 0.56027070f, 0.53923087f, 0.51805843f, 0.49678411f, 0.47543856f,
0.45405225f, 0.43265547f, 0.41127824f, 0.38995024f, 0.36870081f, 0.34755883f, 0.32655271f, 0.30571035f,
0.28505905f, 0.26462549f, 0.24443569f, 0.22451493f, 0.20488776f, 0.18557791f, 0.16660829f, 0.14800093f,
0.12977695f, 0.11195656f, 0.09455895f, 0.07760236f, 0.06110400f, 0.04508003f, 0.02954554f, 0.01451456f,
0.00000000f, -0.01398631f, -0.02743368f, -0.04033255f, -0.05267447f, -0.06445214f, -0.07565940f, -0.08629121f,
-0.09634367f, -0.10581400f, -0.11470052f, -0.12300268f, -0.13072098f, -0.13785702f, -0.14441345f, -0.15039394f,
-0.15580318f, -0.16064685f, -0.16493160f, -0.16866498f, -0.17185547f, -0.17451243f, -0.17664604f, -0.17826729f,
-0.17938796f, -0.18002054f, -0.18017822f, -0.17987486f, -0.17912493f, -0.17794347f, -0.17634608f, -0.17434883f,
-0.17196824f, -0.16922125f, -0.16612516f, -0.16269761f, -0.15895648f, -0.15491992f, -0.15060625f, -0.14603396f,
-0.14122162f, -0.13618787f, -0.13095139f, -0.12553081f, -0.11994473f, -0.11421163f, -0.10834984f, -0.10237755f,
-0.09631271f, -0.09017300f, -0.08397586f, -0.07773838f, -0.07147731f, -0.06520902f, -0.05894946f, -0.05271415f,
-0.04651815f, -0.04037601f, -0.03430179f, -0.02830902f, -0.02241063f, -0.01661904f, -0.01094605f, -0.00540284f,
-0.00000000f, 0.00525251f, 0.01034538f, 0.01526993f, 0.02001814f, 0.02458266f, 0.02895676f, 0.03313441f,
0.03711021f, 0.04087943f, 0.04443799f, 0.04778246f, 0.05091003f, 0.05381856f, 0.05650650f, 0.05897292f,
0.06121749f, 0.06324047f, 0.06504268f, 0.06662549f, 0.06799083f, 0.06914112f, 0.07007930f, 0.07080878f,
0.07133343f, 0.07165755f, 0.07178588f, 0.07172352f, 0.07147595f, 0.07104902f, 0.07044886f, 0.06968193f,
0.06875494f, 0.06767485f, 0.06644886f, 0.06508435f, 0.06358888f, 0.06197015f, 0.06023599f, 0.05839432f,
0.05645314f, 0.05442051f, 0.05230450f, 0.05011320f, 0.04785466f, 0.04553692f, 0.04316793f, 0.04075558f,
0.03830765f, 0.03583181f, 0.03333557f, 0.03082630f, 0.02831121f, 0.02579730f, 0.02329137f, 0.02080003f,
0.01832963f, 0.01588629f, 0.01347589f, 0.01110403f, 0.00877607f, 0.00649705f, 0.00427175f, 0.00210467f,
0.00000000f, -0.00203837f, -0.00400686f, -0.00590216f, -0.00772131f, -0.00946162f, -0.01112072f, -0.01269654f,
-0.01418731f, -0.01559156f, -0.01690810f, -0.01813605f, -0.01927478f, -0.02032396f, -0.02128352f, -0.02215366f,
-0.02293482f, -0.02362769f, -0.02423318f, -0.02475245f, -0.02518686f, -0.02553797f, -0.02580754f, -0.02599752f,
-0.02611000f, -0.02614728f, -0.02611175f, -0.02600597f, -0.02583262f, -0.02559449f, -0.02529446f, -0.02493550f,
-0.02452066f, -0.02405306f, -0.02353586f, -0.02297226f, -0.02236549f, -0.02171881f, -0.02103547f, -0.02031874f,
-0.01957185f, -0.01879802f, -0.01800043f, -0.01718225f, -0.01634655f, -0.01549638f, -0.01463471f, -0.01376443f,
-0.01288838f, -0.01200928f, -0.01112977f, -0.01025241f, -0.00937962f, -0.00851376f, -0.00765705f, -0.00681160f,
-0.00597942f, -0.00516238f, -0.00436225f, -0.00358068f, -0.00281917f, -0.00207914f, -0.00136185f, -0.00066846f,
-0.00000000f, 0.00064260f, 0.00125856f, 0.00184718f, 0.00240790f, 0.00294026f, 0.00344390f, 0.00391857f,
0.00436413f, 0.00478051f, 0.00516776f, 0.00552600f, 0.00585544f, 0.00615637f, 0.00642915f, 0.00667420f,
0.00689203f, 0.00708318f, 0.00724827f, 0.00738795f, 0.00750293f, 0.00759395f, 0.00766178f, 0.00770723f,
0.00773114f, 0.00773435f, 0.00771774f, 0.00768218f, 0.00762857f, 0.00755779f, 0.00747075f, 0.00736831f,
0.00725138f, 0.00712082f, 0.00697748f, 0.00682221f, 0.00665584f, 0.00647916f, 0.00629295f, 0.00609797f,
0.00589494f, 0.00568458f, 0.00546754f, 0.00524448f, 0.00501600f, 0.00478270f, 0.00454511f, 0.00430377f,
0.00405916f, 0.00381176f, 0.00356198f, 0.00331023f, 0.00305690f, 0.00280234f, 0.00254687f, 0.00229079f,
0.00203440f, 0.00177795f, 0.00152168f, 0.00126584f, 0.00101062f, 0.00075625f, 0.00050289f, 0.00025075f,
0.00000000f
};
const float orange53_left_avg_power[257] = /* 257 == IVAS_REVERB_FFT_SIZE_48K/2 + 1 */
{
0.999231100f, 0.992580175f, 0.969233215f, 0.925614893f, 0.871408045f, 0.826101780f, 0.803222895f, 0.800087631f, 0.802672029f,
0.801490188f, 0.796555817f, 0.790879488f, 0.784882724f, 0.777585745f, 0.769326210f, 0.761789441f, 0.756145239f, 0.752754092f,
0.751703024f, 0.752594173f, 0.754317880f, 0.755515277f, 0.754378498f, 0.748860359f, 0.738919020f, 0.727488697f, 0.718792558f,
0.714865267f, 0.713446736f, 0.711076498f, 0.706021905f, 0.697553098f, 0.684623063f, 0.667031527f, 0.647006035f, 0.627680719f,
0.609939933f, 0.592472672f, 0.574803054f, 0.558499217f, 0.544599831f, 0.532128096f, 0.520152628f, 0.509682238f, 0.501904130f,
0.496162385f, 0.491121918f, 0.486813396f, 0.483951330f, 0.482198298f, 0.480713189f, 0.479654074f, 0.479590476f, 0.479965866f,
0.479589254f, 0.478181243f, 0.476334095f, 0.474199444f, 0.471616089f, 0.469089746f, 0.467486322f, 0.466943622f, 0.467153549f,
0.468381166f, 0.470996737f, 0.474416614f, 0.477639019f, 0.480612457f, 0.483910263f, 0.487287015f, 0.489909321f, 0.491668850f,
0.493155539f, 0.494319856f, 0.494512051f, 0.493615031f, 0.492155492f, 0.490116775f, 0.486886710f, 0.482303619f, 0.476902038f,
0.470775038f, 0.463377595f, 0.454571068f, 0.445130944f, 0.435581058f, 0.425568998f, 0.414717495f, 0.403531373f, 0.392556936f,
0.381436378f, 0.369506508f, 0.357099295f, 0.345049500f, 0.333368897f, 0.321326375f, 0.308959186f, 0.297232091f, 0.286592871f,
0.276453108f, 0.266589880f, 0.257950366f, 0.251341701f, 0.246435612f, 0.242861211f, 0.241405189f, 0.242839754f, 0.246688128f,
0.252115428f, 0.259297341f, 0.268399984f, 0.278481483f, 0.288520366f, 0.298599035f, 0.308846802f, 0.318350822f, 0.326248646f,
0.332813978f, 0.338464528f, 0.342543274f, 0.344278336f, 0.344031811f, 0.342641503f, 0.339995682f, 0.335437506f, 0.329174429f,
0.322237372f, 0.315035462f, 0.306967229f, 0.297821850f, 0.288482070f, 0.279766560f, 0.271234214f, 0.262228251f, 0.253214896f,
0.245183259f, 0.237939596f, 0.230546176f, 0.223051578f, 0.216552779f, 0.211263061f, 0.206180066f, 0.200917527f, 0.196485907f,
0.193453044f, 0.190857053f, 0.187853232f, 0.185171053f, 0.183685005f, 0.182665780f, 0.180928215f, 0.178784713f, 0.177342966f,
0.176323384f, 0.174430951f, 0.171496049f, 0.168740034f, 0.166518897f, 0.163711995f, 0.159658119f, 0.155442193f, 0.152056932f,
0.148795277f, 0.144545168f, 0.139905334f, 0.136263832f, 0.133493021f, 0.130194828f, 0.126240104f, 0.123071767f, 0.121281922f,
0.119557180f, 0.117016964f, 0.114773229f, 0.114072219f, 0.114103459f, 0.113414355f, 0.112460621f, 0.112842396f, 0.114564091f,
0.115944758f, 0.116569765f, 0.117913686f, 0.120910525f, 0.124211200f, 0.126575813f, 0.128826424f, 0.132578567f, 0.137430578f,
0.141675219f, 0.144987956f, 0.148879051f, 0.154273912f, 0.159992099f, 0.164641231f, 0.168560207f, 0.173201621f, 0.178906262f,
0.184429348f, 0.188756809f, 0.192309171f, 0.196154252f, 0.200732291f, 0.205381230f, 0.209404662f, 0.212832779f, 0.216197237f,
0.220162451f, 0.225029215f, 0.230637416f, 0.236752108f, 0.243243530f, 0.249900997f, 0.256293535f, 0.261716694f, 0.265186161f,
0.265652657f, 0.262010813f, 0.253508776f, 0.243198514f, 0.244490802f, 0.255167097f, 0.258825988f, 0.257396817f, 0.256197631f,
0.256865948f, 0.258354962f, 0.259370565f, 0.259730458f, 0.259894609f, 0.260285556f, 0.260970831f, 0.261650831f, 0.262020200f,
0.262095064f, 0.262225062f, 0.262741268f, 0.263585031f, 0.264350951f, 0.264654577f, 0.264539272f, 0.264409125f, 0.264633715f,
0.265172601f, 0.265621960f, 0.265678704f, 0.265469313f, 0.265454412f, 0.265907466f, 0.266625792f, 0.267101586f, 0.266997635f,
0.266522497f, 0.266185820f, 0.266298562f, 0.266692907f, 0.266907692f
};
const float orange53_right_avg_power[257] =
{
0.999231100f, 0.992580175f, 0.969233215f, 0.925614893f, 0.871408045f, 0.826101780f, 0.803222895f, 0.800087631f, 0.802672029f,
0.801490188f, 0.796555817f, 0.790879488f, 0.784882724f, 0.777585745f, 0.769326210f, 0.761789441f, 0.756145239f, 0.752754092f,
0.751703024f, 0.752594173f, 0.754317880f, 0.755515277f, 0.754378498f, 0.748860359f, 0.738919020f, 0.727488697f, 0.718792558f,
0.714865267f, 0.713446736f, 0.711076498f, 0.706021905f, 0.697553098f, 0.684623063f, 0.667031527f, 0.647006035f, 0.627680719f,
0.609939933f, 0.592472672f, 0.574803054f, 0.558499217f, 0.544599831f, 0.532128096f, 0.520152628f, 0.509682238f, 0.501904130f,
0.496162385f, 0.491121918f, 0.486813396f, 0.483951330f, 0.482198298f, 0.480713189f, 0.479654074f, 0.479590476f, 0.479965866f,
0.479589254f, 0.478181243f, 0.476334095f, 0.474199444f, 0.471616089f, 0.469089746f, 0.467486322f, 0.466943622f, 0.467153549f,
0.468381166f, 0.470996737f, 0.474416614f, 0.477639019f, 0.480612457f, 0.483910263f, 0.487287015f, 0.489909321f, 0.491668850f,
0.493155539f, 0.494319856f, 0.494512051f, 0.493615031f, 0.492155492f, 0.490116775f, 0.486886710f, 0.482303619f, 0.476902038f,
0.470775038f, 0.463377595f, 0.454571068f, 0.445130944f, 0.435581058f, 0.425568998f, 0.414717495f, 0.403531373f, 0.392556936f,
0.381436378f, 0.369506508f, 0.357099295f, 0.345049500f, 0.333368897f, 0.321326375f, 0.308959186f, 0.297232091f, 0.286592871f,
0.276453108f, 0.266589880f, 0.257950366f, 0.251341701f, 0.246435612f, 0.242861211f, 0.241405189f, 0.242839754f, 0.246688128f,
0.252115428f, 0.259297341f, 0.268399984f, 0.278481483f, 0.288520366f, 0.298599035f, 0.308846802f, 0.318350822f, 0.326248646f,
0.332813978f, 0.338464528f, 0.342543274f, 0.344278336f, 0.344031811f, 0.342641503f, 0.339995682f, 0.335437506f, 0.329174429f,
0.322237372f, 0.315035462f, 0.306967229f, 0.297821850f, 0.288482070f, 0.279766560f, 0.271234214f, 0.262228251f, 0.253214896f,
0.245183259f, 0.237939596f, 0.230546176f, 0.223051578f, 0.216552779f, 0.211263061f, 0.206180066f, 0.200917527f, 0.196485907f,
0.193453044f, 0.190857053f, 0.187853232f, 0.185171053f, 0.183685005f, 0.182665780f, 0.180928215f, 0.178784713f, 0.177342966f,
0.176323384f, 0.174430951f, 0.171496049f, 0.168740034f, 0.166518897f, 0.163711995f, 0.159658119f, 0.155442193f, 0.152056932f,
0.148795277f, 0.144545168f, 0.139905334f, 0.136263832f, 0.133493021f, 0.130194828f, 0.126240104f, 0.123071767f, 0.121281922f,
0.119557180f, 0.117016964f, 0.114773229f, 0.114072219f, 0.114103459f, 0.113414355f, 0.112460621f, 0.112842396f, 0.114564091f,
0.115944758f, 0.116569765f, 0.117913686f, 0.120910525f, 0.124211200f, 0.126575813f, 0.128826424f, 0.132578567f, 0.137430578f,
0.141675219f, 0.144987956f, 0.148879051f, 0.154273912f, 0.159992099f, 0.164641231f, 0.168560207f, 0.173201621f, 0.178906262f,
0.184429348f, 0.188756809f, 0.192309171f, 0.196154252f, 0.200732291f, 0.205381230f, 0.209404662f, 0.212832779f, 0.216197237f,
0.220162451f, 0.225029215f, 0.230637416f, 0.236752108f, 0.243243530f, 0.249900997f, 0.256293535f, 0.261716694f, 0.265186161f,
0.265652657f, 0.262010813f, 0.253508776f, 0.243198514f, 0.244490802f, 0.255167097f, 0.258825988f, 0.257396817f, 0.256197631f,
0.256865948f, 0.258354962f, 0.259370565f, 0.259730458f, 0.259894609f, 0.260285556f, 0.260970831f, 0.261650831f, 0.262020200f,
0.262095064f, 0.262225062f, 0.262741268f, 0.263585031f, 0.264350951f, 0.264654577f, 0.264539272f, 0.264409125f, 0.264633715f,
0.265172601f, 0.265621960f, 0.265678704f, 0.265469313f, 0.265454412f, 0.265907466f, 0.266625792f, 0.267101586f, 0.266997635f,
0.266522497f, 0.266185820f, 0.266298562f, 0.266692907f, 0.266907692f
};
const float orange53_coherence[257] =
{
0.929530263f, 0.921171963f, 0.900268972f, 0.876067519f, 0.855227590f, 0.837884128f, 0.823401272f, 0.818804145f, 0.835025251f,
0.871971071f, 0.911253273f, 0.929330528f, 0.921199203f, 0.900894165f, 0.882577479f, 0.867001534f, 0.849280477f, 0.832460761f,
0.824062645f, 0.823441386f, 0.820908070f, 0.811902404f, 0.802339375f, 0.798648477f, 0.797345281f, 0.791158736f, 0.779512227f,
0.768243194f, 0.760565042f, 0.754912853f, 0.751044095f, 0.752276063f, 0.759258866f, 0.766927004f, 0.769716740f, 0.767338514f,
0.763358235f, 0.759508014f, 0.755201221f, 0.750362694f, 0.746060252f, 0.742611766f, 0.739434779f, 0.736354828f, 0.733443379f,
0.730109870f, 0.726028502f, 0.722365141f, 0.720153689f, 0.718220115f, 0.714793265f, 0.710619092f, 0.708084404f, 0.707218647f,
0.705624878f, 0.702472746f, 0.700073540f, 0.699947894f, 0.700519860f, 0.699934483f, 0.699344158f, 0.700895131f, 0.704551995f,
0.708814025f, 0.713567019f, 0.719995975f, 0.728467822f, 0.738399088f, 0.749545693f, 0.761859894f, 0.774593413f, 0.787218869f,
0.800481200f, 0.814727187f, 0.828367889f, 0.839860320f, 0.850490928f, 0.862034321f, 0.873037636f, 0.880097568f, 0.883217216f,
0.885473788f, 0.887664974f, 0.886511028f, 0.880120754f, 0.871120989f, 0.862524390f, 0.853262126f, 0.840783834f, 0.825854301f,
0.811407208f, 0.798167706f, 0.784307659f, 0.769172490f, 0.754072189f, 0.739893615f, 0.726129174f, 0.712544501f, 0.699519753f,
0.686980069f, 0.674778104f, 0.663931608f, 0.655511260f, 0.648816824f, 0.642671287f, 0.638217211f, 0.637585819f, 0.640332758f,
0.643755615f, 0.647433281f, 0.653589368f, 0.662824631f, 0.672268033f, 0.680022597f, 0.687623680f, 0.696763635f, 0.705829978f,
0.712574661f, 0.717432320f, 0.721986175f, 0.725707173f, 0.727064371f, 0.726255059f, 0.724350274f, 0.720927835f, 0.715189219f,
0.708206475f, 0.701428175f, 0.693923056f, 0.684313059f, 0.674107075f, 0.666009307f, 0.659245491f, 0.650998116f, 0.641600072f,
0.634524226f, 0.630267978f, 0.625348687f, 0.618164837f, 0.611785769f, 0.608430445f, 0.605561733f, 0.600407422f, 0.594782710f,
0.591767371f, 0.590365708f, 0.587845862f, 0.584915996f, 0.584355533f, 0.585834682f, 0.586913347f, 0.587935925f, 0.591403484f,
0.596784472f, 0.601111054f, 0.604539037f, 0.610374093f, 0.618451059f, 0.624519289f, 0.627448440f, 0.631859899f, 0.639748096f,
0.646256745f, 0.647378445f, 0.647664309f, 0.652599990f, 0.659044445f, 0.659743190f, 0.656243205f, 0.656651020f, 0.662200928f,
0.664544880f, 0.660030127f, 0.656303048f, 0.659881413f, 0.664978266f, 0.662953973f, 0.657274961f, 0.658065319f, 0.665406108f,
0.668446958f, 0.663809955f, 0.661349833f, 0.668595374f, 0.677367866f, 0.677208483f, 0.672289610f, 0.675831020f, 0.688208520f,
0.695776582f, 0.691749871f, 0.687812865f, 0.696674168f, 0.711764693f, 0.716045380f, 0.706839681f, 0.701565385f, 0.711955190f,
0.726487696f, 0.723370016f, 0.700417101f, 0.677427649f, 0.670733511f, 0.671355724f, 0.654210806f, 0.608316183f, 0.549225986f,
0.504217446f, 0.484227657f, 0.475346446f, 0.452598959f, 0.399407327f, 0.319485664f, 0.229244962f, 0.146649837f, 0.083417825f,
0.041744832f, 0.018142883f, 0.006854009f, 0.002511850f, 0.001177550f, 0.000840970f, 0.000701097f, 0.000571384f, 0.000458581f,
0.000376965f, 0.000320562f, 0.000278847f, 0.000245546f, 0.000218281f, 0.000195632f, 0.000176647f, 0.000160827f, 0.000147978f,
0.000137649f, 0.000129066f, 0.000121431f, 0.000114406f, 0.000108067f, 0.000102595f, 0.000097917f, 0.000093750f, 0.000089854f,
0.000086255f, 0.000083183f, 0.000080804f, 0.000079026f, 0.000077552f, 0.000076117f, 0.000074693f, 0.000073431f, 0.000072456f,
0.000071701f, 0.000071002f, 0.000070286f, 0.000069692f, 0.000069457f
};
/*----------------------------------------------------------------------------------*
* t-design and SN3D normalization table
*----------------------------------------------------------------------------------*/
/* SN3D norm */
const float norm_sn3d_hoa3[16] =
{
1.f, 1.7320508f, 1.7320508f, 1.7320508f, 2.2360680f, 2.2360680f, 2.2360680f, 2.2360680f,
2.2360680f, 2.6457512f, 2.6457512f, 2.6457512f, 2.6457512f, 2.6457512f, 2.6457512f, 2.6457512f
};
/* Order 11 t-design */
const float t_design_11_azimuth[SBA_T_DESIGN_11_SIZE] =
{
1.329273e+02f, -8.393495e+01f, 8.474100e+00f, -1.133408e+02f, -1.032659e+02f, -3.323704e+01f, 2.185643e+01f, -1.565395e+02f,
-6.426475e+01f, 1.657795e+02f, -2.520283e+01f, -9.700380e+01f, 2.785464e+01f, 1.532142e+02f, -1.550616e+02f, -1.184214e+01f,
8.053873e+01f, -4.205616e+01f, -3.122333e+01f, 3.883790e+01f, 9.376069e+01f, -8.475602e+01f, 7.755368e+00f, -1.222769e+02f,
4.680127e+01f, -2.476863e+01f, 9.989047e+01f, -1.347840e+02f, -8.308802e+01f, 6.012817e+01f, 1.526447e+02f, 2.975767e+01f,
4.077932e+01f, 1.101839e+02f, 1.656521e+02f, -1.299266e+01f, 7.973599e+01f, -5.052453e+01f, 1.189239e+02f, 4.722029e+01f,
1.719253e+02f, -6.251458e+01f, -1.111567e+01f, 1.320180e+02f, -1.353555e+02f, 1.023709e+02f, 1.127393e+02f, -1.783050e+02f,
-1.223199e+02f, 5.907635e+01f, 1.517042e+02f, 2.137634e+01f, -1.690055e+02f, 1.189808e+02f, -1.160893e+02f, 9.647679e+00f,
6.089332e+01f, -1.560215e+02f, -6.346030e+01f, 1.749298e+02f, -1.752888e+02f, -1.059519e+02f, -5.019283e+01f, 1.313583e+02f,
-1.362968e+02f, 9.356446e+01f, -9.708401e+01f, -1.691583e+02f, -4.413238e+01f, 8.147954e+01f
};
const float t_design_11_elevation[SBA_T_DESIGN_11_SIZE] =
{
7.692547e+00f, -2.373007e+01f, 2.351276e+01f, 7.042259e+01f, -9.896944e+00f, -7.075133e+01f, -2.646185e+01f, 4.777649e+01f,
-7.720470e+00f, 4.453436e+01f, 2.638979e+01f, -4.465789e+01f, 9.767035e+00f, -4.770533e+01f, 7.453029e+00f, -2.359012e+01f,
2.371945e+01f, 7.043827e+01f, -9.835416e+00f, -7.049808e+01f, -2.629492e+01f, 4.761480e+01f, -7.517185e+00f, 4.428623e+01f,
2.664426e+01f, -4.456937e+01f, 9.912719e+00f, -4.795996e+01f, 7.296799e+00f, -2.334460e+01f, 2.364153e+01f, 7.068431e+01f,
-9.581404e+00f, -7.039345e+01f, -2.642582e+01f, 4.775107e+01f, -7.308536e+00f, 4.426328e+01f, 2.671406e+01f, -4.431497e+01f,
9.758997e+00f, -4.803619e+01f, 7.439651e+00f, -2.333261e+01f, 2.338690e+01f, 7.082191e+01f, -9.485964e+00f, -7.058019e+01f,
-2.667403e+01f, 4.799784e+01f, -7.382762e+00f, 4.449706e+01f, 2.650250e+01f, -4.424619e+01f, 9.518451e+00f, -4.782814e+01f,
7.684274e+00f, -2.357068e+01f, 2.330745e+01f, 7.065865e+01f, -9.680889e+00f, -7.080268e+01f, -2.669635e+01f, 4.801363e+01f,
-7.637348e+00f, 4.466512e+01f, 2.630235e+01f, -4.445764e+01f, 9.523415e+00f, -4.762422e+01f
};
/*----------------------------------------------------------------------*
* Reverberator ROM tables
*-----------------------------------------------------------------------*/
const float ivas_reverb_default_fc[IVAS_REVERB_DEFAULT_N_BANDS] =
{
20.0f, 25.0f, 31.5f, 40.0f,
50.0f, 63.0f, 80.0f, 100.0f,
125.0f, 160.0f, 200.0f, 250.0f,
315.0f, 400.0f, 500.0f, 630.0f,
800.0f, 1000.0f, 1250.0f, 1600.0f,
2000.0f, 2500.0f, 3150.0f, 4000.0f,
5000.0f, 6300.0f, 8000.0f, 10000.0f,
12500.0f, 16000.0f, 20000.0f
};
const float ivas_reverb_default_RT60[IVAS_REVERB_DEFAULT_N_BANDS] =
{
1.3622f, 1.4486f, 1.3168f, 1.5787f,
1.4766f, 1.3954f, 1.2889f, 1.3462f,
1.0759f, 1.0401f, 1.097f, 1.085f,
1.091f, 1.0404f, 1.0499f, 1.0699f,
1.1028f, 1.1714f, 1.1027f, 1.0666f,
1.055f, 1.0553f, 1.0521f, 1.0569f,
1.0421f, 0.97822f, 0.80487f, 0.75944f,
0.71945f, 0.61682f, 0.60031f
};
const float ivas_reverb_default_DSR[IVAS_REVERB_DEFAULT_N_BANDS] =
{
1.8811e-08f, 2.1428e-08f, 1.3972e-08f, 1.51e-08f,
1.287e-08f, 1.8747e-08f, 2.413e-08f, 3.9927e-08f,
8.9719e-08f, 1.902e-07f, 3.702e-07f, 6.1341e-07f,
7.1432e-07f, 6.5331e-07f, 4.6094e-07f, 5.4683e-07f,
7.0134e-07f, 6.856e-07f, 7.114e-07f, 6.9604e-07f,
5.2939e-07f, 5.699e-07f, 6.1773e-07f, 5.7488e-07f,
4.7748e-07f, 2.7213e-07f, 1.3681e-07f, 1.0941e-07f,
6.2001e-08f, 2.8483e-08f, 2.6267e-08f
};
/* clang-format on */
......@@ -118,7 +118,6 @@ extern const int16_t sba_map_tc[8];
extern const float ls_conversion_cicpX_mono[12][1];
extern const float ls_conversion_cicpX_stereo[12][2];
extern const LS_CONVERSION_MATRIX ls_conversion_cicp12_cicp6[];
extern const LS_CONVERSION_MATRIX ls_conversion_cicp12_cicp6[];
extern const LS_CONVERSION_MATRIX ls_conversion_cicp14_cicp6[];
extern const LS_CONVERSION_MATRIX ls_conversion_cicp14_cicp12[];
extern const LS_CONVERSION_MATRIX ls_conversion_cicp16_cicp6[];
......@@ -143,13 +142,6 @@ extern const LS_CONVERSION_MAPPING ls_conversion_mapping[];
* FASTCONV and PARAMETRIC binaural renderer ROM tables
*----------------------------------------------------------------------------------*/
extern const float dmxmtx[BINAURAL_CHANNELS][11];
extern const int16_t channelIndex_CICP6[5];
extern const int16_t channelIndex_CICP12[7];
extern const int16_t channelIndex_CICP14[9];
extern const int16_t channelIndex_CICP16[9];
extern const int16_t channelIndex_CICP19[11];
/* These are equalization values for spread and surround coherent sounds, approximating the spectrum
* for such sounds at anechoic multichannel listening. */
extern const float surCohEne[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS];
......@@ -164,44 +156,4 @@ extern const float diffuseFieldCoherenceDifferenceX[BINAURAL_COHERENCE_DIFFERENC
extern const float diffuseFieldCoherenceDifferenceY[BINAURAL_COHERENCE_DIFFERENCE_BINS];
extern const float diffuseFieldCoherenceDifferenceZ[BINAURAL_COHERENCE_DIFFERENCE_BINS];
/*----------------------------------------------------------------------------------*
* TD ISM Object renderer
*----------------------------------------------------------------------------------*/
extern const int16_t TDREND_SRC_REND_MaxTargetTimes[IVAS_NUM_SUPPORTED_FS];
extern const int16_t TDREND_SRC_REND_MaxBlockLengths[IVAS_NUM_SUPPORTED_FS];
extern const int16_t TDREND_MaxITD[IVAS_NUM_SUPPORTED_FS];
extern const float TDREND_MaxITD_Incr[IVAS_NUM_SUPPORTED_FS];
extern const int16_t HRTF_MODEL_N_CPTS_VAR[HRTF_MODEL_N_SECTIONS];
extern const float SincTable[321];
extern const float orange53_left_avg_power[257];
extern const float orange53_right_avg_power[257];
extern const float orange53_coherence[257];
/*----------------------------------------------------------------------------------*
* t-design and SN3D normalization table
*----------------------------------------------------------------------------------*/
/* SN3D norm */
extern const float norm_sn3d_hoa3[16];
/* Order 11 t-design */
extern const uint16_t t_design_11_size;
extern const float t_design_11_azimuth[SBA_T_DESIGN_11_SIZE];
extern const float t_design_11_elevation[SBA_T_DESIGN_11_SIZE];
/*----------------------------------------------------------------------*
* Reverberator ROM tables
*-----------------------------------------------------------------------*/
extern const float ivas_reverb_default_fc[];
extern const float ivas_reverb_default_RT60[];
extern const float ivas_reverb_default_DSR[];
#endif
......@@ -38,408 +38,506 @@
#include "prot.h"
#include "ivas_prot.h"
#include "ivas_rom_dec.h"
#include <math.h>
#ifdef DEBUGGING
#include "debug.h"
#endif
#include "wmops.h"
/*-----------------------------------------------------------------------*
* Local function prototypes
*-----------------------------------------------------------------------*/
static void ivas_sba_dmx_dec( float sba_data[][L_FRAME48k], const int16_t nchan_transport, const int16_t output_frame );
#ifdef DEBUG_MODE_DIRAC
static void debug_mode_dirac( float output[MAX_OUTPUT_CHANNELS][L_FRAME48k], const int16_t nchan_transport, const int16_t output_frame );
#endif
/*-------------------------------------------------------------------------*
* ivas_mc2sba()
#ifdef SBA_BR_SWITCHING
/*-------------------------------------------------------------------*
* ivas_sba_dec_reinit()
*
* MC signals transformed into SBA in TD domain
*-------------------------------------------------------------------------*/
void ivas_mc2sba(
IVAS_OUTPUT_SETUP hIntSetup, /* i : Format of decoder output */
float buffer_td[][L_FRAME48k], /* i/o: MC signals (on input) and the HOA3 (on output) */
const int16_t output_frame, /* i : output frame length per channel */
const int16_t sba_order, /* i : Ambisonic (SBA) order */
const float gain_lfe /* i : gain for LFE, 0 = ignore LFE */
* Reinitialisation of IVAS SBA decoder
*-------------------------------------------------------------------*/
ivas_error ivas_sba_dec_reinit(
Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
)
{
int16_t i, j, k;
int16_t idx_lfe, idx_in;
float buffer_tmp[16][L_FRAME48k];
float gains[16];
int16_t azimuth, elevation;
int16_t sba_num_chans;
int16_t i, k, n;
int16_t sce_id, cpe_id;
int16_t numCldfbAnalyses;
int16_t numCldfbSyntheses;
int32_t output_Fs, ivas_total_brate;
AUDIO_CONFIG output_config;
DECODER_CONFIG_HANDLE hDecoderConfig;
ivas_error error;
error = IVAS_ERR_OK;
assert( ( sba_order <= 3 ) && "Only order up to 3 is supported!" );
output_Fs = st_ivas->hDecoderConfig->output_Fs;
hDecoderConfig = st_ivas->hDecoderConfig;
output_config = hDecoderConfig->output_config;
ivas_total_brate = hDecoderConfig->ivas_total_brate;
/* Init*/
sba_num_chans = ( sba_order + 1 ) * ( sba_order + 1 );
for ( j = 0; j < sba_num_chans; j++ )
hDecoderConfig->last_ivas_total_brate = ivas_total_brate;
/*------------------------------------------------------------------------------------------*
* Closing Decoder handles before Reinitialisation
*------------------------------------------------------------------------------------------*/
/* Qmetadata handle */
ivas_qmetadata_close( &st_ivas->hQMetaData );
/* DirAC handle */
if ( st_ivas->hDirAC != NULL )
{
if ( st_ivas->ivas_format == ISM_FORMAT )
{
set_zero( buffer_tmp[j], output_frame );
ivas_param_ism_dec_close( st_ivas->hDirAC, st_ivas->hDecoderConfig->output_config );
}
/* HOA encoding*/
idx_lfe = 0;
idx_in = 0;
for ( i = 0; i < hIntSetup.nchan_out_woLFE + hIntSetup.num_lfe; i++ )
else
{
if ( ( hIntSetup.num_lfe > 0 ) && ( i == hIntSetup.index_lfe[idx_lfe] ) )
ivas_dirac_dec_close( st_ivas->hDirAC );
}
st_ivas->hDirAC = NULL;
}
/* Spar handle */
if ( st_ivas->hSpar != NULL )
{
if ( gain_lfe > 0.f )
ivas_spar_dec_close( st_ivas->hSpar, st_ivas->hDecoderConfig->output_Fs );
st_ivas->hSpar = NULL;
}
/* SCE handles */
for ( i = 0; i < MAX_SCE; i++ )
{
/* Add LFE to omni W with gain*/
for ( k = 0; k < output_frame; k++ )
if ( st_ivas->hSCE[i] != NULL )
{
buffer_tmp[0][k] += gain_lfe * buffer_td[i][k];
destroy_sce_dec( st_ivas->hSCE[i] );
st_ivas->hSCE[i] = NULL;
}
}
if ( idx_lfe < ( hIntSetup.num_lfe - 1 ) )
/* CPE handles */
for ( i = 0; i < MAX_CPE; i++ )
{
idx_lfe++;
if ( st_ivas->hCPE[i] != NULL )
{
/* set pointer to NULL as core coder already deallocated in destroy_sce_dec() */
if ( st_ivas->sba_dirac_stereo_flag )
{
st_ivas->hCPE[i]->hCoreCoder[0] = NULL;
st_ivas->hCPE[i]->hCoreCoder[1] = NULL;
}
destroy_cpe_dec( st_ivas->hCPE[i] );
st_ivas->hCPE[i] = NULL;
}
}
else
{
azimuth = (int16_t) ( hIntSetup.ls_azimuth[idx_in] );
elevation = (int16_t) ( hIntSetup.ls_elevation[idx_in] );
idx_in++;
/* get HOA response for direction (ACN/SN3D)*/
ivas_dirac_dec_get_response(
azimuth,
elevation,
gains,
sba_order );
/* MCT handle */
ivas_mct_dec_close( &st_ivas->hMCT );
for ( j = 0; j < sba_num_chans; j++ )
/* HP20 filter handles */
if ( st_ivas->mem_hp20_out != NULL )
{
for ( k = 0; k < output_frame; k++ )
for ( i = 0; i < getNumChanSynthesis( st_ivas ); i++ )
{
buffer_tmp[j][k] += gains[j] * buffer_td[i][k];
}
}
count_free( st_ivas->mem_hp20_out[i] );
st_ivas->mem_hp20_out[i] = NULL;
}
count_free( st_ivas->mem_hp20_out );
st_ivas->mem_hp20_out = NULL;
}
for ( j = 0; j < sba_num_chans; j++ )
/* HOA decoder matrix */
if ( st_ivas->hoa_dec_mtx != NULL )
{
mvr2r( buffer_tmp[j], buffer_td[j], output_frame );
count_free( st_ivas->hoa_dec_mtx );
st_ivas->hoa_dec_mtx = NULL;
}
return;
}
/* Parametric MC handle */
ivas_param_mc_dec_close( &st_ivas->hParamMC );
/* EFAP handle */
efap_free_data( &st_ivas->hEFAPdata );
/*-------------------------------------------------------------------------*
* ivas_sba2MC_cldfb()
*
* SBA signals transformed into MC in CLDFB domain
*-------------------------------------------------------------------------*/
void ivas_sba2mc_cldfb(
IVAS_OUTPUT_SETUP hInSetup, /* i : Format of input layout */
float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: cldfb real part */
float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: cldfb imag part */
const int16_t nb_channels_out, /* i : nb of output channels */
const int16_t nb_bands, /* i : nb of CLDFB bands to process */
const float *hoa_dec_mtx /* i : HOA decoding mtx */
)
{
int16_t iBlock, iBand, n, m;
float realOut[16][MAX_PARAM_SPATIAL_SUBFRAMES * CLDFB_NO_CHANNELS_MAX], imagOut[16][MAX_PARAM_SPATIAL_SUBFRAMES * CLDFB_NO_CHANNELS_MAX];
float g;
float *p_real, *p_imag, *p_realOut, *p_imagOut;
int16_t nb_channels_in;
/* VBAP handle */
vbap_free_data( &( st_ivas->hVBAPdata ) );
/* Fastconv binaural renderer handle */
ivas_binRenderer_close( &st_ivas->hBinRenderer );
/* Parametric binaural renderer handle */
ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin );
wmops_sub_start( "ivas_sba2mc_cldfb" );
/* Crend handle */
ivas_crend_close( st_ivas );
nb_channels_in = hInSetup.nchan_out_woLFE;
assert( ( nb_channels_in == 16 ) && ( nb_channels_out == 11 ) && "ivas_sba2mc_cldfb; only HOA3 to CICP19 is for now supported!" );
/* LS config converter handle */
ivas_ls_setup_conversion_close( &st_ivas->hLsSetUpConversion );
for ( n = 0; n < nb_channels_out; n++ )
/* Custom LS configuration handle */
if ( st_ivas->hLsSetupCustom != NULL )
{
set_zero( realOut[n], MAX_PARAM_SPATIAL_SUBFRAMES * nb_bands );
set_zero( imagOut[n], MAX_PARAM_SPATIAL_SUBFRAMES * nb_bands );
count_free( st_ivas->hLsSetupCustom );
st_ivas->hLsSetupCustom = NULL;
}
for ( m = 0; m < nb_channels_in; m++ )
/* MASA decoder structure */
if ( st_ivas->hMasa != NULL )
{
g = hoa_dec_mtx[SBA_NHARM_HOA3 * n + m];
p_realOut = realOut[n];
p_imagOut = imagOut[n];
for ( iBlock = 0; iBlock < MAX_PARAM_SPATIAL_SUBFRAMES; iBlock++ )
ivas_masa_dec_close( st_ivas->hMasa );
st_ivas->hMasa = NULL;
}
/* Downmix structure */
if ( st_ivas->hMonoDmxRenderer != NULL )
{
p_real = RealBuffer[m][iBlock];
p_imag = ImagBuffer[m][iBlock];
for ( iBand = 0; iBand < nb_bands; iBand++ )
count_free( st_ivas->hMonoDmxRenderer );
st_ivas->hMonoDmxRenderer = NULL;
}
/* Head track data handle */
if ( st_ivas->hHeadTrackData != NULL )
{
*p_realOut = *p_realOut + g * *( p_real++ );
*p_imagOut = *p_imagOut + g * *( p_imag++ );
p_realOut++;
p_imagOut++;
count_free( st_ivas->hHeadTrackData );
st_ivas->hHeadTrackData = NULL;
}
/* Time Domain binaural renderer handle */
if ( st_ivas->hBinRendererTd != NULL )
{
ivas_td_binaural_close( &st_ivas->hBinRendererTd );
}
else if ( st_ivas->hHrtfTD != NULL )
{
/* Case when HRTF filter is mistakenly specified but TD renderer was not active */
if ( st_ivas->hHrtfTD->ModelParams.UseItdModel && !st_ivas->hHrtfTD->ModelParams.modelROM )
{
BSplineModelEvalITDDealloc( &st_ivas->hHrtfTD->ModelParamsITD );
}
BSplineModelEvalDealloc( &st_ivas->hHrtfTD->ModelParams, &st_ivas->hHrtfTD->ModelEval );
ivas_HRTF_binary_close( &st_ivas->hHrtfTD );
}
for ( n = 0; n < nb_channels_out; n++ )
{
p_realOut = realOut[n];
p_imagOut = imagOut[n];
for ( iBlock = 0; iBlock < MAX_PARAM_SPATIAL_SUBFRAMES; iBlock++ )
/* Config. Renderer */
ivas_render_config_close( &( st_ivas->hRenderConfig ) );
for ( i = 0; i < MAX_INTERN_CHANNELS; i++ )
{
p_real = RealBuffer[n][iBlock];
p_imag = ImagBuffer[n][iBlock];
for ( iBand = 0; iBand < nb_bands; iBand++ )
if ( st_ivas->cldfbAnaDec[i] != NULL )
{
*( p_real++ ) = *p_realOut++;
*( p_imag++ ) = *p_imagOut++;
}
deleteCldfb( &( st_ivas->cldfbAnaDec[i] ) );
st_ivas->cldfbAnaDec[i] = NULL;
}
}
wmops_sub_end();
return;
for ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ )
{
if ( st_ivas->cldfbSynDec[i] != NULL )
{
deleteCldfb( &( st_ivas->cldfbSynDec[i] ) );
st_ivas->cldfbSynDec[i] = NULL;
}
}
/*-------------------------------------------------------------------*
* ivas_sba_remapTCs()
*
* Get TCs from Ambisonics signal in ACN
*-------------------------------------------------------------------*/
/*------------------------------------------------------------------------------------------*
* Reopening Decoder handles for Reinitialisation
*------------------------------------------------------------------------------------------*/
int16_t ivas_sba_remapTCs(
float sba_data[][L_FRAME48k], /* i/o: SBA signals */
Decoder_Struct *st_ivas, /* i/o: decoder struct */
const int16_t output_frame /* i : frame length */
)
/* Allocate and initialize Custom loudspeaker layout handle */
if ( st_ivas->hDecoderConfig->Opt_LsCustom )
{
int16_t nchan_remapped;
if ( ( error = ivas_ls_custom_open( &( st_ivas->hLsSetupCustom ) ) ) != IVAS_ERR_OK )
{
return error;
}
}
#ifdef DEBUG_MODE_DIRAC
debug_mode_dirac( sba_data, st_ivas->nchan_transport, output_frame );
#endif
/* Allocate and initialize Head-Tracking handle */
if ( st_ivas->hDecoderConfig->Opt_Headrotation )
{
if ( ( error = ivas_headTrack_open( &( st_ivas->hHeadTrackData ) ) ) != IVAS_ERR_OK )
{
return error;
}
}
nchan_remapped = st_ivas->nchan_transport;
if ( ( st_ivas->sba_mode != SBA_MODE_SPAR && st_ivas->sba_planar && nchan_remapped >= 3 ) ||
( ( st_ivas->sba_mode == SBA_MODE_SPAR ) && nchan_remapped == 3 ) )
/* Allocate HRTF binary handle */
if ( st_ivas->hDecoderConfig->Opt_HRTF_binary )
{
if ( ( error = ivas_HRTF_binary_open( &( st_ivas->hHrtfTD ) ) ) != IVAS_ERR_OK )
{
return error;
}
}
nchan_remapped++;
if ( st_ivas->sba_mode != SBA_MODE_SPAR )
st_ivas->sba_dirac_stereo_flag = 0;
/*Reconfigure output paramaters*/
ivas_sba_config( ivas_total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init );
ivas_renderer_select( st_ivas );
ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->intern_config );
if ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK )
{
return error;
}
if ( st_ivas->sba_mode == SBA_MODE_SPAR )
{
if ( ( error = ivas_spar_dec_open( st_ivas ) ) != IVAS_ERR_OK )
{
assert( ( ( st_ivas->nchan_transport == 3 ) || ( st_ivas->nchan_transport == 5 ) || ( st_ivas->nchan_transport == 7 ) ) && "Number of channels must be odd for SBA planar!" );
return error;
}
if ( nchan_remapped == 4 )
if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC && st_ivas->hOutSetup.is_loudspeaker_setup )
{
if ( ( error = ivas_sba_get_hoa_dec_matrix( st_ivas->hOutSetup, &st_ivas->hoa_dec_mtx, st_ivas->hIntSetup.ambisonics_order ) ) != IVAS_ERR_OK )
{
/*For planar A-format channel 2 and 3 are identical -> Z=0*/
mvr2r( sba_data[2], sba_data[3], output_frame );
return error;
}
}
if ( st_ivas->sba_mode == SBA_MODE_SPAR )
if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, st_ivas->sba_mode, IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) ) != IVAS_ERR_OK )
{
int16_t i = 0;
float temp;
return error;
}
if ( st_ivas->nchan_transport >= 3 )
if ( hDecoderConfig->output_config != AUDIO_CONFIG_FOA )
{
/*convert WYXZ downmix to WYZX*/
for ( i = 0; i < output_frame; i++ )
if ( ( error = ivas_dirac_dec_open( st_ivas ) ) != IVAS_ERR_OK )
{
temp = sba_data[2][i];
sba_data[2][i] = sba_data[3][i];
sba_data[3][i] = temp;
if ( st_ivas->nchan_transport == 3 )
return error;
}
for ( k = 0; k < DIRAC_MAX_NBANDS; k++ )
{
sba_data[2][i] = 0;
st_ivas->hSpar->dirac_to_spar_md_bands[k] = st_ivas->hDirAC->dirac_to_spar_md_bands[k];
}
st_ivas->hSpar->enc_param_start_band = st_ivas->hDirAC->hConfig->enc_param_start_band;
}
else
{
int16_t band_grouping[IVAS_MAX_NUM_BANDS + 1];
st_ivas->hSpar->enc_param_start_band = min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND );
ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ),
st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0 );
}
}
else
{
ivas_sba_dmx_dec( sba_data, nchan_remapped, output_frame );
if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, st_ivas->sba_mode, -1 ) ) != IVAS_ERR_OK )
{
return error;
}
if ( st_ivas->sba_mode != SBA_MODE_SPAR )
st_ivas->sba_dirac_stereo_flag = ( st_ivas->nchan_transport == 1 && output_config == AUDIO_CONFIG_STEREO );
if ( ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC ) && st_ivas->hOutSetup.is_loudspeaker_setup )
{
int16_t ambisonics_order;
ambisonics_order = ivas_sba_get_order_transport( st_ivas->nchan_transport ); // VE: is it needed ?
if ( ( error = ivas_sba_get_hoa_dec_matrix( st_ivas->hOutSetup, &st_ivas->hoa_dec_mtx, ambisonics_order ) ) != IVAS_ERR_OK )
{
ivas_sba_zero_vert_comp( sba_data, st_ivas->sba_analysis_order, st_ivas->sba_planar, output_frame );
return error;
}
}
else if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) && !st_ivas->hIntSetup.is_loudspeaker_setup )
{
IVAS_OUTPUT_SETUP out_setup;
return ( nchan_remapped );
ivas_output_init( &out_setup, AUDIO_CONFIG_7_1_4 );
if ( ( error = ivas_sba_get_hoa_dec_matrix( out_setup, &st_ivas->hoa_dec_mtx, st_ivas->hIntSetup.ambisonics_order ) ) != IVAS_ERR_OK )
{
return error;
}
}
}
if ( st_ivas->renderer_type != RENDERER_BINAURAL_MIXER_CONV && st_ivas->renderer_type != RENDERER_BINAURAL_MIXER_CONV_ROOM &&
st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC && st_ivas->sba_mode != SBA_MODE_SPAR )
{
if ( ( error = ivas_dirac_dec_open( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
}
for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
{
if ( ( error = create_sce_dec( st_ivas, sce_id, ivas_total_brate / st_ivas->nchan_transport ) ) != IVAS_ERR_OK )
{
return error;
}
reset_indices_dec( st_ivas->hSCE[sce_id]->hCoreCoder[0] );
}
/*-------------------------------------------------------------------*
* ivas_sba_dmx_dec()
*
*
*-------------------------------------------------------------------*/
for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
if ( ( error = create_cpe_dec( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK )
{
return error;
}
static void ivas_sba_dmx_dec(
float sba_data[][L_FRAME48k], /* i : SBA signals */
const int16_t nchan_transport, /* i : number of transport channels */
const int16_t output_frame /* i : frame length */
)
for ( n = 0; n < CPE_CHANNELS; n++ )
{
int16_t i;
float tmp_f[DIRAC_MAX_TRANS_CHANS];
reset_indices_dec( st_ivas->hCPE[cpe_id]->hCoreCoder[n] );
}
}
if ( nchan_transport >= 7 )
/* create CPE element for DFT Stereo like upmix */
if ( st_ivas->sba_dirac_stereo_flag )
{
for ( i = 0; i < output_frame; i++ )
if ( ( error = create_cpe_dec( st_ivas, cpe_id, ivas_total_brate / ( st_ivas->nSCE + st_ivas->nCPE ) ) ) != IVAS_ERR_OK )
{
tmp_f[0] = 0.506415f * sba_data[0][i] + 0.506415f * sba_data[1][i] + 0.506415f * sba_data[2][i] + 0.506415f * sba_data[3][i] + 0.506415f * sba_data[4][i] + 0.506415f * sba_data[5][i] + 0.506415f * sba_data[6][i];
tmp_f[1] = -0.000000f * sba_data[0][i] + 0.531020f * sba_data[1][i] + 0.662171f * sba_data[2][i] + 0.294694f * sba_data[3][i] + -0.294694f * sba_data[4][i] + -0.662171f * sba_data[5][i] + -0.531020f * sba_data[6][i];
tmp_f[2] = 0.679200f * sba_data[0][i] + 0.423475f * sba_data[1][i] + -0.151136f * sba_data[2][i] + -0.611938f * sba_data[3][i] + -0.611938f * sba_data[4][i] + -0.151136f * sba_data[5][i] + 0.423475f * sba_data[6][i];
tmp_f[3] = 0.000000f * sba_data[0][i] + 0.833385f * sba_data[1][i] + -0.370891f * sba_data[2][i] + -0.668323f * sba_data[3][i] + 0.668323f * sba_data[4][i] + 0.370891f * sba_data[5][i] + -0.833385f * sba_data[6][i];
tmp_f[4] = 0.854817f * sba_data[0][i] + -0.190215f * sba_data[1][i] + -0.770164f * sba_data[2][i] + 0.532970f * sba_data[3][i] + 0.532970f * sba_data[4][i] + -0.770164f * sba_data[5][i] + -0.190215f * sba_data[6][i];
tmp_f[5] = 0.000000f * sba_data[0][i] + 0.691125f * sba_data[1][i] + -1.245365f * sba_data[2][i] + 1.552944f * sba_data[3][i] + -1.552944f * sba_data[4][i] + 1.245365f * sba_data[5][i] + -0.691125f * sba_data[6][i];
tmp_f[6] = 1.592881f * sba_data[0][i] + -1.435137f * sba_data[1][i] + 0.993145f * sba_data[2][i] + -0.354449f * sba_data[3][i] + -0.354449f * sba_data[4][i] + 0.993145f * sba_data[5][i] + -1.435137f * sba_data[6][i];
return error;
}
sba_data[0][i] = tmp_f[0];
sba_data[1][i] = tmp_f[1];
sba_data[2][i] = sba_data[7][i];
sba_data[3][i] = tmp_f[2];
sba_data[4][i] = tmp_f[3];
sba_data[8][i] = tmp_f[4];
sba_data[9][i] = tmp_f[5];
sba_data[15][i] = tmp_f[6];
st_ivas->hCPE[0]->hCoreCoder[0] = st_ivas->hSCE[0]->hCoreCoder[0]; /* don't allocate unnecessary core coder, simply point to core coder of SCE element */
}
return;
/* set CNA/CNG flags */
if ( st_ivas->sba_mode == SBA_MODE_SPAR && st_ivas->nchan_transport == 1 )
{
st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag = 0; /* Todo: Check if these can be enabled */
st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag = 0;
}
else if ( nchan_transport >= 5 )
else if ( st_ivas->nchan_transport == 1 && ( ( st_ivas->renderer_type == RENDERER_DIRAC && st_ivas->hDirAC->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) || ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) ) )
{
for ( i = 0; i < output_frame; i++ )
st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag = 1;
st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag = 1;
}
else if ( st_ivas->nchan_transport == 2 )
{
for ( n = 0; n < CPE_CHANNELS; n++ )
{
tmp_f[0] = 0.708982f * sba_data[0][i] + 0.708982f * sba_data[1][i] + 0.708982f * sba_data[2][i] + 0.708982f * sba_data[3][i] + 0.708982f * sba_data[4][i];
tmp_f[1] = 0.000000f * sba_data[0][i] + 1.005966f * sba_data[1][i] + 0.621721f * sba_data[2][i] + -0.621721f * sba_data[3][i] + -1.005966f * sba_data[4][i];
tmp_f[2] = 1.057735f * sba_data[0][i] + 0.326858f * sba_data[1][i] + -0.855726f * sba_data[2][i] + -0.855726f * sba_data[3][i] + 0.326858f * sba_data[4][i];
tmp_f[3] = 0.000000f * sba_data[0][i] + 1.079884f * sba_data[1][i] + -1.747289f * sba_data[2][i] + 1.747289f * sba_data[3][i] + -1.079884f * sba_data[4][i];
tmp_f[4] = 1.837208f * sba_data[0][i] + -1.486333f * sba_data[1][i] + 0.567729f * sba_data[2][i] + 0.567729f * sba_data[3][i] + -1.486333f * sba_data[4][i];
st_ivas->hCPE[0]->hCoreCoder[n]->cna_dirac_flag = 0; /* Todo: Check if these can be enabled */
st_ivas->hCPE[0]->hCoreCoder[n]->cng_sba_flag = 1;
}
}
sba_data[0][i] = tmp_f[0];
sba_data[1][i] = tmp_f[1];
sba_data[2][i] = sba_data[5][i];
sba_data[3][i] = tmp_f[2];
sba_data[4][i] = tmp_f[3];
sba_data[8][i] = tmp_f[4];
if ( st_ivas->nCPE > 1 )
{
if ( ( error = create_mct_dec( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
}
/* set number of output channels used for synthesis/decoding */
n = getNumChanSynthesis( st_ivas );
return;
if ( n > 0 )
{
if ( ( st_ivas->mem_hp20_out = (float **) count_malloc( n * sizeof( float * ) ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) );
}
}
else if ( nchan_transport >= 3 )
else
{
st_ivas->mem_hp20_out = NULL;
}
/*A-format to ACN/SN3D*/
for ( i = 0; i < output_frame; i++ )
for ( i = 0; i < n; i++ )
{
tmp_f[0] = 0.5f * ( sba_data[0][i] + sba_data[1][i] + sba_data[2][i] + sba_data[3][i] );
tmp_f[1] = sba_data[0][i] - sba_data[1][i];
tmp_f[2] = sba_data[2][i] - sba_data[3][i];
tmp_f[3] = sba_data[0][i] + sba_data[1][i] - sba_data[2][i] - sba_data[3][i];
sba_data[0][i] = tmp_f[0];
sba_data[1][i] = tmp_f[1];
sba_data[2][i] = tmp_f[2];
sba_data[3][i] = tmp_f[3];
if ( ( st_ivas->mem_hp20_out[i] = (float *) count_malloc( L_HP20_MEM * sizeof( float ) ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) );
}
return;
set_f( st_ivas->mem_hp20_out[i], 0.0f, L_HP20_MEM );
}
else if ( nchan_transport == 2 )
if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_ROOM )
{
/* do nothing for stereo DMX, upmix done in DirAC*/
return;
if ( ( error = ivas_render_config_open( &( st_ivas->hRenderConfig ) ) ) != IVAS_ERR_OK )
{
return error;
}
else if ( nchan_transport == 1 )
if ( ivas_render_config_init_from_rom( &st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_ROOM ) != IVAS_ERR_OK )
{
/* do nothing; simply use omni */
return;
return IVAS_ERR_INTERNAL_FATAL;
}
else
}
if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM )
{
assert( 0 && "SBA: number of transport channels not supported." );
if ( ( error = ivas_binRenderer_open( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
}
/*-------------------------------------------------------------------------*
* ivas_ism2sba()
*
* ISM transformed into SBA in TD domain.
*-------------------------------------------------------------------------*/
void ivas_ism2sba(
float buffer_td[][L_FRAME48k], /* i/o: TD signal buffers */
ISM_RENDERER_HANDLE hIsmRendererData, /* i/o: renderer data */
const ISM_METADATA_HANDLE hIsmMetaData[], /* i : object metadata */
const int16_t num_objects, /* i : number of objects */
const int16_t output_frame, /* i : output frame length per channel */
const int16_t sba_order /* i : Ambisonic (SBA) order */
)
else if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC )
{
int16_t i, j, k;
float buffer_tmp[16][L_FRAME48k];
float gains[16];
float g1, g2;
int16_t azimuth, elevation;
int16_t sba_num_chans;
assert( ( sba_order <= 3 ) && "Only order up to 3 is supported!" );
assert( hIsmRendererData != NULL && "hIsmRendererData not allocated!" );
/* Init*/
sba_num_chans = ( sba_order + 1 ) * ( sba_order + 1 );
for ( j = 0; j < sba_num_chans; j++ )
if ( ( error = ivas_dirac_dec_init_binaural_data( st_ivas ) ) != IVAS_ERR_OK )
{
set_zero( buffer_tmp[j], output_frame );
return error;
}
for ( i = 0; i < num_objects; i++ )
}
else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD )
{
azimuth = (int16_t) ( hIsmMetaData[i]->azimuth + 0.5f );
elevation = (int16_t) ( hIsmMetaData[i]->elevation + 0.5f );
/*get HOA gets for direction (ACN/SN3D)*/
ivas_dirac_dec_get_response(
azimuth,
elevation,
gains,
sba_order );
if ( ( error = ivas_td_binaural_open( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
for ( j = 0; j < sba_num_chans; j++ )
if ( st_ivas->hRenderConfig->roomAcoustics.late_reverb_on )
{
g2 = 0.f;
for ( k = 0; k < output_frame; k++ )
if ( ( st_ivas->hCrend = (CREND_HANDLE) count_malloc( sizeof( CREND_DATA ) ) ) == NULL )
{
g2 += 1.f / output_frame;
g1 = 1.0f - g2;
buffer_tmp[j][k] += ( g2 * gains[j] + g1 * hIsmRendererData->prev_gains[i][j] ) * buffer_td[i][k];
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR Crend\n" );
}
hIsmRendererData->prev_gains[i][j] = gains[j];
}
}
else if ( st_ivas->renderer_type == RENDERER_MC )
{
if ( ( error = ivas_ls_setup_conversion_open( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
}
else if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX )
{
if ( ( error = ivas_mono_dmx_renderer_open( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
}
else if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM )
{
if ( ivas_crend_open( st_ivas ) != IVAS_ERR_OK )
{
return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "ivas_crend_open failed" );
}
}
ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses, &numCldfbSyntheses );
for ( j = 0; j < sba_num_chans; j++ )
for ( i = 0; i < numCldfbAnalyses; i++ )
{
if ( ( error = openCldfb( &( st_ivas->cldfbAnaDec[i] ), CLDFB_ANALYSIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK )
{
return error;
}
}
for ( ; i < MAX_INTERN_CHANNELS; i++ )
{
mvr2r( buffer_tmp[j], buffer_td[j], output_frame );
st_ivas->cldfbAnaDec[i] = NULL;
}
return;
for ( i = 0; i < numCldfbSyntheses; i++ )
{
if ( ( error = openCldfb( &( st_ivas->cldfbSynDec[i] ), CLDFB_SYNTHESIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK )
{
return error;
}
}
for ( ; i < MAX_OUTPUT_CHANNELS; i++ )
{
st_ivas->cldfbSynDec[i] = NULL;
}
/* CLDFB Interpolation weights */
if ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->sba_mode == SBA_MODE_SPAR )
{
ivas_spar_get_cldfb_gains( st_ivas->hSpar, st_ivas->cldfbAnaDec[0], st_ivas->cldfbSynDec[0], hDecoderConfig );
}
return error;
}
#endif
/*-------------------------------------------------------------------*
* ivas_sba_dec_decoder()
......@@ -451,20 +549,12 @@ ivas_error ivas_sba_dec_reconfigure(
Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
)
{
int16_t n;
int16_t sce_id, cpe_id;
int16_t nchan_transport;
int16_t nchan_transport_old;
int32_t sba_total_brate;
int16_t nSCE_old;
int16_t nCPE_old;
int16_t i;
int16_t nchan_transport, nchan_transport_old;
int16_t nSCE_old, nCPE_old, nchan_hp20_old;
AUDIO_CONFIG intern_config_old;
int16_t numCldfbAnalyses_old;
int16_t numCldfbAnalyses;
int16_t numCldfbSyntheses;
int16_t numCldfbSyntheses_old;
int16_t numCldfbAnalyses_old, numCldfbAnalyses, numCldfbSyntheses, numCldfbSyntheses_old;
int16_t sba_dirac_stereo_flag_old;
uint16_t i;
int32_t ivas_total_brate, last_ivas_total_brate;
ivas_error error;
......@@ -479,7 +569,8 @@ ivas_error ivas_sba_dec_reconfigure(
ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old );
numCldfbAnalyses = 0;
sba_total_brate = ivas_total_brate;
nchan_hp20_old = getNumChanSynthesis( st_ivas );
nSCE_old = st_ivas->nSCE;
nCPE_old = st_ivas->nCPE;
......@@ -488,7 +579,8 @@ ivas_error ivas_sba_dec_reconfigure(
st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order );
ivas_sba_config( sba_total_brate, st_ivas->sba_analysis_order, -1, &nchan_transport, st_ivas->sba_planar, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init, st_ivas->sba_mode );
ivas_sba_config( ivas_total_brate, st_ivas->sba_analysis_order, -1, &nchan_transport, st_ivas->sba_planar, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init );
st_ivas->nchan_transport = nchan_transport;
/* renderer might have changed */
......@@ -504,7 +596,8 @@ ivas_error ivas_sba_dec_reconfigure(
if ( st_ivas->sba_mode != SBA_MODE_SPAR )
{
st_ivas->sba_dirac_stereo_flag = ( st_ivas->nchan_transport == 1 && st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_STEREO );
if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, st_ivas->sba_planar, st_ivas->sba_mode, -1 ) ) != IVAS_ERR_OK )
if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, st_ivas->sba_mode, -1 ) ) != IVAS_ERR_OK )
{
return error;
}
......@@ -516,15 +609,13 @@ ivas_error ivas_sba_dec_reconfigure(
sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER );
ivas_spar_config( st_ivas->hDecoderConfig->ivas_total_brate, sba_order_internal, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->hSpar->core_nominal_brate, st_ivas->sid_format );
if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->sba_analysis_order, st_ivas->sba_planar,
st_ivas->sba_mode, IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) ) != IVAS_ERR_OK )
if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->sba_analysis_order, st_ivas->sba_mode, IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) ) != IVAS_ERR_OK )
{
return error;
}
}
if ( st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC &&
( last_ivas_total_brate > IVAS_SID_4k4 || nchan_transport != nchan_transport_old ) && ( st_ivas->sba_mode != SBA_MODE_SPAR ) )
if ( st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC && ( last_ivas_total_brate > IVAS_SID_5k2 || nchan_transport != nchan_transport_old ) && ( st_ivas->sba_mode != SBA_MODE_SPAR ) )
{
if ( st_ivas->hDirAC != NULL )
{
......@@ -555,253 +646,17 @@ ivas_error ivas_sba_dec_reconfigure(
}
}
/*-----------------------------------------------------------------*
* Allocate, initalize, and configure SCE/CPE/MCT handles
*-----------------------------------------------------------------*/
if ( nchan_transport == nchan_transport_old )
{
for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
{
st_ivas->hSCE[sce_id]->element_brate = ivas_total_brate / st_ivas->nchan_transport;
st_ivas->hSCE[sce_id]->hCoreCoder[0]->total_brate = st_ivas->hSCE[sce_id]->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */
}
for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
st_ivas->hCPE[cpe_id]->element_brate = ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS;
/* prepare bitstream buffers */
for ( n = 0; n < CPE_CHANNELS; n++ )
{
st_ivas->hCPE[cpe_id]->hCoreCoder[n]->total_brate = st_ivas->hCPE[cpe_id]->element_brate / ( st_ivas->nCPE > 1 ? 1 : CPE_CHANNELS ); /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */
}
}
if ( st_ivas->nCPE > 1 )
{
if ( ( error = mct_dec_reconfigure( st_ivas, 0 ) ) != IVAS_ERR_OK )
{
return error;
}
}
}
else
{
int16_t nSCE_existing;
int16_t nCPE_existing;
nSCE_existing = min( nSCE_old, st_ivas->nSCE );
nCPE_existing = min( nCPE_old, st_ivas->nCPE );
/* destroy superfluous core coder elements */
for ( sce_id = st_ivas->nSCE; sce_id < nSCE_old; sce_id++ )
{
destroy_sce_dec( st_ivas->hSCE[sce_id] );
st_ivas->hSCE[sce_id] = NULL;
/* remove dummy CPE needed for 1TC->Stereo rendering via DFT stereo*/
if ( sba_dirac_stereo_flag_old )
{
#ifdef DEBUGGING
assert( st_ivas->hCPE[0] );
#endif
st_ivas->hCPE[0]->hCoreCoder[0] = st_ivas->hCPE[0]->hCoreCoder[1] = NULL;
destroy_cpe_dec( st_ivas->hCPE[0] );
st_ivas->hCPE[0] = NULL;
}
}
for ( cpe_id = st_ivas->nCPE; cpe_id < nCPE_old; cpe_id++ )
{
destroy_cpe_dec( st_ivas->hCPE[cpe_id] );
st_ivas->hCPE[cpe_id] = NULL;
}
if ( st_ivas->nCPE <= 1 && st_ivas->hMCT != NULL )
{
ivas_mct_dec_close( &st_ivas->hMCT );
}
/* special case, if we have MCT now and had a single CPE before, remove the MDCT Stereo handles from the first CPE*/
if ( st_ivas->nCPE > 1 && nCPE_old == 1 )
{
count_free( st_ivas->hCPE[0]->hStereoMdct );
st_ivas->hCPE[0]->hStereoMdct = NULL;
}
for ( sce_id = 0; sce_id < nSCE_existing; sce_id++ )
{
st_ivas->hSCE[sce_id]->element_brate = ivas_total_brate / st_ivas->nchan_transport;
st_ivas->hSCE[sce_id]->hCoreCoder[0]->total_brate = st_ivas->hSCE[sce_id]->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */
}
for ( ; sce_id < st_ivas->nSCE; sce_id++ )
{
if ( ( error = create_sce_dec( st_ivas, sce_id, ivas_total_brate / st_ivas->nchan_transport ) ) != IVAS_ERR_OK )
{
return error;
}
}
for ( cpe_id = 0; cpe_id < nCPE_existing; cpe_id++ )
{
st_ivas->hCPE[cpe_id]->element_brate = ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS;
/* prepare bitstream buffers */
for ( n = 0; n < CPE_CHANNELS; n++ )
{
st_ivas->hCPE[cpe_id]->hCoreCoder[n]->total_brate = st_ivas->hCPE[cpe_id]->element_brate / ( st_ivas->nCPE > 1 ? 1 : CPE_CHANNELS ); /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */
}
}
for ( ; cpe_id < st_ivas->nCPE; cpe_id++ )
{
if ( ( error = create_cpe_dec( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK )
{
return error;
}
}
/* create CPE element for DFT Stereo like upmix */
if ( st_ivas->sba_dirac_stereo_flag )
{
if ( ( error = create_cpe_dec( st_ivas, 0, ivas_total_brate / ( st_ivas->nSCE + st_ivas->nCPE ) ) ) != IVAS_ERR_OK )
{
return error;
}
st_ivas->hCPE[0]->hCoreCoder[0] = st_ivas->hSCE[0]->hCoreCoder[0]; /* don't allocate unnecessary core coder, simply point to core coder of SCE element */
}
if ( st_ivas->nCPE > 1 && nCPE_old <= 1 )
{
if ( nCPE_old == 1 )
{
/* set correct nominal bitrates and igf config already here, needed for the correct init of the MDCT Stereo handles for MCT */
for ( n = 0; n < CPE_CHANNELS; n++ )
{
st_ivas->hCPE[0]->hCoreCoder[n]->total_brate = st_ivas->hCPE[0]->element_brate;
st_ivas->hCPE[0]->hCoreCoder[n]->bits_frame_nominal = (int16_t) ( st_ivas->hCPE[0]->element_brate / FRAMES_PER_SEC );
st_ivas->hCPE[0]->hCoreCoder[n]->igf = 0;
}
}
if ( ( error = create_mct_dec( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
}
else if ( st_ivas->hMCT != NULL && st_ivas->nCPE > 1 )
{
if ( ( error = mct_dec_reconfigure( st_ivas, st_ivas->nCPE != nCPE_old ) ) != IVAS_ERR_OK )
{
return error;
}
}
/* special case, if we have a single CPE and had MCT before we need to init the MDCT stereo handles here */
if ( st_ivas->nCPE == 1 && nCPE_old > 1 )
{
if ( ( st_ivas->hCPE[st_ivas->nCPE - 1]->hStereoMdct = (STEREO_MDCT_DEC_DATA_HANDLE) count_malloc( sizeof( STEREO_MDCT_DEC_DATA ) ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MDCT Stereo \n" ) );
}
st_ivas->hCPE[st_ivas->nCPE - 1]->hStereoMdct->use_itd = 0;
st_ivas->hCPE[st_ivas->nCPE - 1]->hStereoMdct->reverse_dmx = 0;
st_ivas->hCPE[st_ivas->nCPE - 1]->hStereoMdct->smooth_ratio = 1.f;
for ( n = 0; n < CPE_CHANNELS; n++ )
{
/* reset mct_chan_mode */
st_ivas->hCPE[0]->hCoreCoder[n]->mct_chan_mode = MCT_CHAN_MODE_REGULAR;
}
}
ivas_corecoder_dec_reconfig( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, sba_dirac_stereo_flag_old );
/*-----------------------------------------------------------------*
* HP20 memories
*-----------------------------------------------------------------*/
if ( nchan_transport > nchan_transport_old )
{
/* create additional hp20 memories */
float **old_mem_hp20_out;
uint16_t n_old;
if ( sba_dirac_stereo_flag_old )
{
n_old = CPE_CHANNELS;
}
else
{
n_old = nchan_transport_old;
}
n = st_ivas->nchan_transport;
/* save old mem_hp_20 pointer */
old_mem_hp20_out = st_ivas->mem_hp20_out;
st_ivas->mem_hp20_out = NULL;
if ( ( st_ivas->mem_hp20_out = (float **) count_malloc( n * sizeof( float * ) ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) );
}
for ( i = 0; i < n_old; i++ )
{
st_ivas->mem_hp20_out[i] = old_mem_hp20_out[i];
old_mem_hp20_out[i] = NULL;
}
for ( ; i < nchan_transport; i++ )
{
if ( ( st_ivas->mem_hp20_out[i] = (float *) count_malloc( L_HP20_MEM * sizeof( float ) ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) );
}
set_f( st_ivas->mem_hp20_out[i], 0.0f, L_HP20_MEM );
}
count_free( old_mem_hp20_out );
old_mem_hp20_out = NULL;
}
else if ( nchan_transport < nchan_transport_old )
{
/* remove superfluous hp20 memories */
float **old_mem_hp20_out;
if ( st_ivas->sba_dirac_stereo_flag )
{
n = CPE_CHANNELS;
}
else
{
n = st_ivas->nchan_transport;
}
/* save old mem_hp_20 pointer */
old_mem_hp20_out = st_ivas->mem_hp20_out;
st_ivas->mem_hp20_out = NULL;
if ( ( st_ivas->mem_hp20_out = (float **) count_malloc( n * sizeof( float * ) ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) );
}
for ( i = 0; i < n; i++ )
{
st_ivas->mem_hp20_out[i] = old_mem_hp20_out[i];
old_mem_hp20_out[i] = NULL;
}
for ( ; i < nchan_transport_old; i++ )
{
count_free( old_mem_hp20_out[i] );
old_mem_hp20_out[i] = NULL;
}
count_free( old_mem_hp20_out );
old_mem_hp20_out = NULL;
}
}
ivas_hp20_dec_reconfig( st_ivas, nchan_hp20_old );
/*-----------------------------------------------------------------*
* CLDFB instances
......@@ -862,47 +717,6 @@ ivas_error ivas_sba_dec_reconfigure(
}
}
/*-----------------------------------------------------------------*
* Set CNA/CNG flags
*-----------------------------------------------------------------*/
if ( st_ivas->sba_mode == SBA_MODE_SPAR && st_ivas->nchan_transport == 1 )
{
/* skip as done in init function */
}
else if ( st_ivas->nchan_transport == 1 && ( ( st_ivas->renderer_type == RENDERER_DIRAC && st_ivas->hDirAC->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) || ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) )
{
st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag = 1;
st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag = 1;
}
else if ( st_ivas->nchan_transport == 2 )
{
for ( n = 0; n < CPE_CHANNELS; n++ )
{
st_ivas->hCPE[0]->hCoreCoder[n]->cna_dirac_flag = 0;
st_ivas->hCPE[0]->hCoreCoder[n]->cng_sba_flag = 1;
}
}
else
{
for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
for ( n = 0; n < CPE_CHANNELS; n++ )
{
st_ivas->hCPE[cpe_id]->hCoreCoder[n]->cna_dirac_flag = 0;
st_ivas->hCPE[cpe_id]->hCoreCoder[n]->cng_sba_flag = 0;
}
}
}
/* special case, if the decoder goes from 1TC DTX to 2TC active frame (in case the bitstream started with an SBA SID frame), allocate DTX memories */
if ( last_ivas_total_brate <= IVAS_SID_4k4 && st_ivas->nCPE >= 1 )
{
if ( ( error = initMdctStereoDtxData( st_ivas->hCPE[0] ) ) != IVAS_ERR_OK )
{
return error;
}
}
/*-------------------------------------------------------------------*
* Reallocate and initialize binaural rendering handles
......
......@@ -91,7 +91,7 @@ ivas_error ivas_sce_dec(
*-----------------------------------------------------------------*/
/* set total_brate - needed in DTX */
if ( !st_ivas->bfi && ( ivas_total_brate == IVAS_SID_4k4 || ivas_total_brate == IVAS_SID_5k ) )
if ( !st_ivas->bfi && ( ivas_total_brate == IVAS_SID_5k2 ) )
{
st->total_brate = ivas_total_brate - nb_bits_metadata * FRAMES_PER_SEC;
assert( st->total_brate == SID_2k40 && "SCE SID must be 2.4kbps!" );
......@@ -100,7 +100,7 @@ ivas_error ivas_sce_dec(
{
st->total_brate = ivas_total_brate;
}
else if ( !st_ivas->bfi && ( last_ivas_total_brate <= SID_2k40 || last_ivas_total_brate == IVAS_SID_4k4 ) )
else if ( !st_ivas->bfi && ( last_ivas_total_brate <= SID_2k40 || last_ivas_total_brate == IVAS_SID_5k2 ) )
{
#ifdef PARAM_ISM_DTX_CNG
if ( st_ivas->ivas_format != ISM_FORMAT )
......@@ -177,7 +177,7 @@ ivas_error ivas_sce_dec(
}
/* set "total_brate" */
if ( !st_ivas->bfi && ( ivas_total_brate == IVAS_SID_4k4 || ivas_total_brate == IVAS_SID_5k ) )
if ( !st_ivas->bfi && ( ivas_total_brate == IVAS_SID_5k2 ) )
{
st->total_brate = ivas_total_brate - nb_bits_metadata * FRAMES_PER_SEC;
}
......@@ -290,13 +290,17 @@ ivas_error ivas_sce_dec(
for ( i = 0; i < n; i++ )
{
dbgwrite( &tmpF, sizeof( float ), 1, output_frame, fname( debug_dir, "element_brate", 0, sce_id, DEC ) );
dbgwrite( &st->element_mode, 2, 1, output_frame, fname( debug_dir, "element_mode", 0, sce_id, DEC ) );
dbgwrite( &st->element_mode, sizeof( int16_t ), 1, output_frame, fname( debug_dir, "element_mode", 0, sce_id, DEC ) );
dbgwrite( output, sizeof( float ), output_frame, 1, fname( debug_dir, "output.sce", 0, sce_id, DEC ) );
tmpF = 0;
dbgwrite( &tmpF, sizeof( float ), 1, output_frame, fname( debug_dir, "output.cpe", 0, sce_id, DEC ) );
dbgwrite( &tmpF, sizeof( float ), 1, output_frame, fname( debug_dir, "output.mct", 0, sce_id, DEC ) );
}
}
#endif
wmops_sub_end();
return error;
}
......@@ -354,11 +358,7 @@ ivas_error create_sce_dec(
st->total_brate = hSCE->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */
st->mct_chan_mode = MCT_CHAN_MODE_REGULAR;
#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT
if ( ( error = init_decoder( st, 0, st_ivas->mc_mode ) ) != IVAS_ERR_OK )
#else
if ( ( error = init_decoder( st, 0 ) ) != IVAS_ERR_OK )
#endif
{
return error;
}
......
......@@ -89,7 +89,7 @@ ivas_error ivas_spar_dec_open(
}
/* MD handle */
if ( ( error = ivas_spar_md_dec_open( &hSpar->hMdDec, st_ivas->hDecoderConfig, num_channels_internal ) ) != IVAS_ERR_OK )
if ( ( error = ivas_spar_md_dec_open( &hSpar->hMdDec, st_ivas->hDecoderConfig, num_channels_internal, sba_order_internal ) ) != IVAS_ERR_OK )
{
return error;
}
......@@ -241,6 +241,10 @@ ivas_error ivas_spar_dec(
next_bit_pos_orig = st0->next_bit_pos;
last_bit_pos = (int16_t) ( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ) - 1 );
if ( !st0->bfi && hDecoderConfig->ivas_total_brate == IVAS_SID_5k2 )
{
last_bit_pos -= SID_FORMAT_NBITS;
}
nb_bits_read_orig = *nb_bits_read;
last_bit_pos -= nb_bits_read_orig;
......@@ -260,6 +264,15 @@ ivas_error ivas_spar_dec(
st0->bit_stream = bit_stream_orig;
st0->next_bit_pos = next_bit_pos_orig;
if ( !st0->bfi && hDecoderConfig->ivas_total_brate == IVAS_SID_5k2 )
{
int16_t zero_pad_bits;
*nb_bits_read += SID_FORMAT_NBITS;
zero_pad_bits = (int16_t) ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - *nb_bits_read;
assert( zero_pad_bits <= 1 );
*nb_bits_read += zero_pad_bits;
}
wmops_sub_end();
return error;
......@@ -456,7 +469,6 @@ void ivas_spar_get_cldfb_gains(
}
hSpar->hFbMixer->cldfb_cross_fade_start = cf_cldfb_start;
hSpar->hFbMixer->cldfb_cross_fade_end = cf_cldfb_end;
hSpar->hFbMixer->cldfb_latency = decfb_delay;
if ( num_cf_slots > 3 || pt_len > 10 * CLDFB_NO_CHANNELS_MAX || stride > CLDFB_NO_CHANNELS_MAX || split_band == IVAS_MAX_NUM_BANDS )
{
......@@ -628,18 +640,25 @@ static void ivas_spar_dec_MD(
if ( ivas_total_brate > FRAME_NO_DATA && !bfi )
{
if ( ivas_total_brate > IVAS_SID_5k )
if ( ivas_total_brate > IVAS_SID_5k2 )
{
ivas_parse_spar_header( hDecoderConfig->ivas_total_brate, sba_order, st0, &table_idx );
if ( hSpar->hMdDec->spar_hoa_md_flag )
{
hSpar->hMdDec->spar_md.num_bands = IVAS_MAX_NUM_BANDS;
}
else
{
hSpar->hMdDec->spar_md.num_bands = min( SPAR_DIRAC_SPLIT_START_BAND, IVAS_MAX_NUM_BANDS );
}
if ( hSpar->hMdDec->table_idx != table_idx )
{
hSpar->hMdDec->table_idx = table_idx;
hSpar->hTdDecorr->ducking_flag = ivas_spar_br_table_consts[table_idx].td_ducking;
ivas_spar_md_dec_init( hSpar->hMdDec, hDecoderConfig, num_channels );
ivas_spar_md_dec_init( hSpar->hMdDec, hDecoderConfig, num_channels, sba_order );
}
}
......@@ -662,7 +681,7 @@ static void ivas_spar_dec_MD(
* Read AGC bits
*---------------------------------------------------------------------*/
if ( ivas_total_brate > IVAS_SID_5k && !bfi && hSpar->hMdDec->dtx_vad )
if ( ivas_total_brate > IVAS_SID_5k2 && !bfi && hSpar->hMdDec->dtx_vad )
{
hSpar->AGC_flag = get_next_indice( st0, 1 );
......@@ -673,7 +692,7 @@ static void ivas_spar_dec_MD(
* MD smoothing
*---------------------------------------------------------------------*/
if ( st0->m_old_frame_type == ZERO_FRAME && ivas_total_brate == IVAS_SID_5k && st0->prev_bfi == 0 && hSpar->hMdDec->spar_md_cfg.nchan_transport == 1 )
if ( st0->m_old_frame_type == ZERO_FRAME && ivas_total_brate == IVAS_SID_5k2 && st0->prev_bfi == 0 && hSpar->hMdDec->spar_md_cfg.nchan_transport == 1 )
{
ivas_spar_setup_md_smoothing( hSpar->hMdDec, num_bands_out );
}
......@@ -775,7 +794,8 @@ void ivas_spar_get_parameters(
weight = ivas_spar_get_cldfb_slot_gain( hSpar, hDecoderConfig, ts, &ts0, &ts1, &weight_20ms );
split_band = SPAR_DIRAC_SPLIT_START_BAND;
split_band = hSpar->hMdDec->spar_md.num_bands;
for ( spar_band = 0; spar_band < num_spar_bands; spar_band++ )
{
for ( out_ch = 0; out_ch < num_ch_out; out_ch++ )
......@@ -971,22 +991,10 @@ void ivas_spar_dec_upmixer(
if ( hSpar->hPCA != NULL )
{
#ifdef SPAR_SCALING_HARMONIZATION
for ( out_ch = 0; out_ch < num_in_ingest; out_ch++ )
{
v_multc( output[out_ch], MDFT_NORM_SCALING, output[out_ch], output_frame );
}
#endif
ivas_pca_dec( hSpar->hPCA, output_frame, num_in_ingest, hDecoderConfig->ivas_total_brate, hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, output );
#ifdef DEBUG_SBA_AUDIO_DUMP
/* Dump audio signal after ivas_pca_dec */
ivas_spar_dump_signal_wav( output_frame, NULL, output, num_in_ingest, spar_foa_dec_wav[2], "ivas_pca_dec()" );
#endif
#ifdef SPAR_SCALING_HARMONIZATION
for ( out_ch = 0; out_ch < num_in_ingest; out_ch++ )
{
v_multc( output[out_ch], PCM16_TO_FLT_FAC, output[out_ch], output_frame );
}
#endif
}
......@@ -1003,20 +1011,17 @@ void ivas_spar_dec_upmixer(
{
mvr2r( pPcm_tmp[hSpar->hTdDecorr->num_apd_outputs - 1 - i], output[nchan_internal - 1 - i], output_frame );
}
hSpar->hFbMixer->fb_cfg->num_in_chans = num_in_ingest;
}
else
{
hSpar->hFbMixer->fb_cfg->num_in_chans = num_in_ingest;
}
/*---------------------------------------------------------------------*
* Prepare CLDFB buffers
*---------------------------------------------------------------------*/
/* set-up pointers */
if ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_FOA )
if ( hDecoderConfig->output_config != AUDIO_CONFIG_FOA )
{
/* at this point, output channels are used as intermediate procesing buffers */
for ( in_ch = 0; in_ch < MAX_OUTPUT_CHANNELS; in_ch++ )
......@@ -1057,7 +1062,7 @@ void ivas_spar_dec_upmixer(
/* determine if we can skip certain data */
ivas_spar_get_skip_mat( hSpar, numch_out, numch_in, num_spar_bands, b_skip_mat ); /* this can be precomputed based on bitrate and format*/
numch_out_dirac = st_ivas->hDecoderConfig->nchan_out;
numch_out_dirac = hDecoderConfig->nchan_out;
for ( int16_t i_sf = 0; i_sf < MAX_PARAM_SPATIAL_SUBFRAMES; i_sf++ )
{
......@@ -1078,7 +1083,7 @@ void ivas_spar_dec_upmixer(
for ( ts = 0; ts < MAX_PARAM_SPATIAL_SUBFRAMES; ts++ )
{
/* determine SPAR parameters for this time slots */
ivas_spar_get_parameters( hSpar, st_ivas->hDecoderConfig, ts + i_sf * MAX_PARAM_SPATIAL_SUBFRAMES, numch_out, numch_in, num_spar_bands, mixer_mat );
ivas_spar_get_parameters( hSpar, hDecoderConfig, ts + i_sf * MAX_PARAM_SPATIAL_SUBFRAMES, numch_out, numch_in, num_spar_bands, mixer_mat );
for ( cldfb_band = 0; cldfb_band < num_cldfb_bands; cldfb_band++ )
{
......@@ -1127,7 +1132,7 @@ void ivas_spar_dec_upmixer(
}
}
if ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_FOA )
if ( hDecoderConfig->output_config != AUDIO_CONFIG_FOA && hDecoderConfig->output_config != AUDIO_CONFIG_STEREO && hDecoderConfig->output_config != AUDIO_CONFIG_MONO )
{
ivas_dirac_dec( st_ivas, output, nchan_internal, cldfb_in_ts_re, cldfb_in_ts_im, i_sf );
}
......@@ -1152,8 +1157,7 @@ void ivas_spar_dec_upmixer(
}
else
{
if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_FOA ||
!( st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL_ROOM ) )
if ( hDecoderConfig->output_config == AUDIO_CONFIG_FOA || !( st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL_ROOM ) )
{
for ( ts = 0; ts < MAX_PARAM_SPATIAL_SUBFRAMES; ts++ )
{
......
......@@ -83,7 +83,7 @@ static ivas_error ivas_spar_set_dec_config( ivas_spar_md_dec_state_t *hMdDec, co
static void ivas_parse_parameter_bitstream_dtx( ivas_spar_md_t *pSpar_md, Decoder_State *st, const int16_t bw, const int16_t num_bands, int16_t *num_dmx_per_band, int16_t *num_dec_per_band );
static ivas_error ivas_deindex_real_index( int16_t **index, const int16_t q_levels, const float min_value, const float max_value, float **quant, const int16_t num_ch, const int16_t dim2 );
static ivas_error ivas_deindex_real_index( const int16_t *index, const int16_t q_levels, const float min_value, const float max_value, float *quant, const int16_t num_ch_dim2 );
static void ivas_spar_dec_parse_md_bs( ivas_spar_md_dec_state_t *hMdDec, Decoder_State *st, int16_t *nB, int16_t *bands_bw, int16_t *dtx_vad, const int32_t ivas_total_brate, const int16_t use_planar_coeff, const int16_t sba_inactive_mode );
......@@ -251,7 +251,8 @@ static ivas_error ivas_spar_md_dec_matrix_open(
ivas_error ivas_spar_md_dec_open(
ivas_spar_md_dec_state_t **hMdDec_out, /* i/o: SPAR MD decoder handle */
const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */
const int16_t num_channels /* i : number of internal channels */
const int16_t num_channels, /* i : number of internal channels */
const int16_t sba_order /* i : SBA order */
)
{
ivas_spar_md_dec_state_t *hMdDec;
......@@ -271,7 +272,7 @@ ivas_error ivas_spar_md_dec_open(
hMdDec->table_idx = 0; /* just to initialize state variables*/
if ( ( error = ivas_spar_md_dec_init( hMdDec, hDecoderConfig, num_channels ) ) != IVAS_ERR_OK )
if ( ( error = ivas_spar_md_dec_init( hMdDec, hDecoderConfig, num_channels, sba_order ) ) != IVAS_ERR_OK )
{
return error;
}
......@@ -432,15 +433,18 @@ void ivas_spar_md_dec_close(
ivas_error ivas_spar_md_dec_init(
ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */
const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */
const int16_t num_channels /* i : number of internal channels */
const int16_t num_channels, /* i : number of internal channels */
const int16_t sba_order /* i : SBA order */
)
{
int16_t i, j, k;
int16_t nchan_transport;
float pFC[IVAS_MAX_NUM_BANDS], PR_minmax[2];
hMdDec->spar_md_cfg.gen_bs = 1; // VE2DB : always 1 - can it be removed?
ivas_spar_set_bitrate_config( &hMdDec->spar_md_cfg, hMdDec->table_idx, min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND ) );
hMdDec->spar_hoa_md_flag = ivas_sba_get_spar_hoa_md_flag( sba_order, hDecoderConfig->ivas_total_brate );
hMdDec->spar_md.num_bands = ( hMdDec->spar_hoa_md_flag ) ? IVAS_MAX_NUM_BANDS : min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND );
ivas_spar_set_bitrate_config( &hMdDec->spar_md_cfg, hMdDec->table_idx, hMdDec->spar_md.num_bands );
nchan_transport = hMdDec->spar_md_cfg.nchan_transport;
......@@ -525,7 +529,6 @@ ivas_error ivas_spar_md_dec_init(
ivas_clear_band_coeff_idx( hMdDec->spar_md_prev.band_coeffs_idx_mapped, IVAS_MAX_NUM_BANDS );
hMdDec->spar_md.dtx_vad = 0;
hMdDec->spar_md.num_bands = min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND );
hMdDec->td_decorr_flag = 1;
set_f( hMdDec->spar_md.en_ratio_slow, 0.0f, IVAS_MAX_NUM_BANDS );
......@@ -624,7 +627,7 @@ void ivas_spar_md_dec_process(
char f_name[100];
int16_t num_bands = nB;
int16_t num_subframes = 1, num_block_groups = 1, num_elements = 1, byte_size = sizeof( float );
int16_t num_ch = 2 * sba_order + 2;
int16_t num_ch = ivas_sba_get_nchan_metadata( sba_order );
for ( b = 0; b < num_bands; b++ )
{
sprintf( f_name, "spar_band_pred_coeffs_dec.bin" );
......@@ -647,7 +650,7 @@ void ivas_spar_md_dec_process(
( b == 0 && frame == 0 ) ? dbgwrite( &byte_size, sizeof( byte_size ), 1, 1, f_name ) : false;
for ( j = 0; j < ( hMdDec->spar_md_cfg.num_decorr_per_band[bw * b] - hMdDec->spar_md_cfg.num_dmx_chans_per_band[bw * b] ); j++ )
{
for ( int16_t k = 0; k < hMdDec->spar_md_cfg.num_dmx_chans_per_band[bw * b] - 1; k++ )
for ( k = 0; k < hMdDec->spar_md_cfg.num_dmx_chans_per_band[bw * b] - 1; k++ )
{
dbgwrite( &hMdDec->spar_md.band_coeffs[b].C_re[j][k], sizeof( float ), 1, 1, f_name );
}
......@@ -667,9 +670,7 @@ void ivas_spar_md_dec_process(
}
#endif
/* SPAR to DirAC and DirAC to SPAR conversion */ // VE2DB: -> "DirAC to SPAR conversion" only?
if ( st_ivas->sba_mode == SBA_MODE_SPAR ) // VE2DB: this looks obsolete
{
/* SPAR to DirAC conversion */
ivas_spar_to_dirac( st_ivas, hMdDec, dtx_vad, num_bands_out );
/* set correct number of bands*/
......@@ -678,12 +679,11 @@ void ivas_spar_md_dec_process(
{
nB = nB >> 1;
}
}
/* expand DirAC MD to all time slots */
for ( i_ts = 1; i_ts < MAX_PARAM_SPATIAL_SUBFRAMES; i_ts++ )
{
for ( b = 0; b < min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND ); b++ )
for ( b = 0; b < hMdDec->spar_md.num_bands; b++ )
{
for ( j = 0; j < IVAS_SPAR_MAX_CH - 1; j++ )
{
......@@ -1207,7 +1207,6 @@ static void ivas_get_spar_matrices(
for ( j = 1; j < numch_out; j++ )
{
for ( k = dmx_ch; k < numch_out; k++ )
{
for ( m = 0; m < numch_out; m++ )
{
......@@ -1344,7 +1343,6 @@ void ivas_spar_dec_gen_umx_mat(
)
{
int16_t i, j, b, i_ts, num_out_ch;
int16_t fb_ducking_flag = 0; // VE2DB: always 0 - can it be removed?
num_out_ch = hMdDec->spar_md_cfg.num_umx_chs;
......@@ -1373,11 +1371,6 @@ void ivas_spar_dec_gen_umx_mat(
}
}
}
if ( fb_ducking_flag )
{
assert( 0 ); /* fb_ducking_flag not supported */
}
}
else
{
......@@ -1392,23 +1385,27 @@ void ivas_spar_dec_gen_umx_mat(
}
}
}
}
#ifdef SPAR_HOA_DBG
/* for ( b = 0; b < 1; b++)
#ifdef DEBUG_SBA_MD_DUMP
{
fprintf( stdout, "\n\nMixer Matrix band %d\n\n", b );
static FILE *f_mat = 0;
if ( f_mat == 0 )
f_mat = fopen( "mixer_mat_dec", "w" );
for ( i = 0; i < num_out_ch; i++ )
{
for ( j = 0; j < num_out_ch; j++ )
{
fprintf( stdout, "%.2f,\t", hMdDec->mixer_mat[i][j][0][b] );
for ( b = 0; b < num_bands_out; b++ )
{
fprintf( f_mat, "%f\n", hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] );
}
}
}
fprintf( stdout, "\n" );
}
fprintf( stdout, "\n" );
}*/
#endif
}
ivas_spar_dec_compute_ramp_down_post_matrix( hMdDec, num_bands_out, bfi );
......@@ -1433,20 +1430,20 @@ static void ivas_spar_dec_parse_md_bs(
const int16_t sba_inactive_mode )
{
int16_t i, j, k, num_bands;
int16_t ii, jj, ndec, ndm, b, idx;
uint16_t qsi;
ivas_quant_strat_t qs;
int16_t strat, freq_diff, no_ec;
int16_t do_diff[IVAS_MAX_NUM_BANDS];
int16_t planarCP = 0;
int16_t planarCP;
float quant[IVAS_SPAR_MAX_C_COEFF];
*dtx_vad = 1;
*bands_bw = 1;
qsi = 0;
num_bands = hMdDec->spar_md.num_bands;
if ( hMdDec->spar_md_cfg.gen_bs == 1 )
{
if ( ivas_total_brate > IVAS_SID_5k )
if ( ivas_total_brate > IVAS_SID_5k2 )
{
if ( hMdDec->spar_md_cfg.quant_strat_bits > 0 )
{
......@@ -1498,6 +1495,7 @@ static void ivas_spar_dec_parse_md_bs(
}
hMdDec->valid_bands[i] = 1;
}
for ( i = 0; i < num_bands; i++ )
{
for ( j = 0; j < ( IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS ); j++ )
......@@ -1509,10 +1507,8 @@ static void ivas_spar_dec_parse_md_bs(
}
}
ivas_parse_parameter_bitstream_dtx( &hMdDec->spar_md, st0, *bands_bw, *nB,
hMdDec->spar_md_cfg.num_dmx_chans_per_band, hMdDec->spar_md_cfg.num_decorr_per_band );
{
int16_t ndec, b, idx;
ivas_parse_parameter_bitstream_dtx( &hMdDec->spar_md, st0, *bands_bw, *nB, hMdDec->spar_md_cfg.num_dmx_chans_per_band, hMdDec->spar_md_cfg.num_decorr_per_band );
for ( i = *nB - 1; i >= 0; i-- )
{
ndec = hMdDec->spar_md_cfg.num_decorr_per_band[( *bands_bw ) * i];
......@@ -1531,14 +1527,16 @@ static void ivas_spar_dec_parse_md_bs(
hMdDec->valid_bands[idx] = 1;
}
}
*nB = num_bands;
*bands_bw = 1;
}
return;
}
qs = hMdDec->spar_md_cfg.quant_strat[qsi];
planarCP = 0;
if ( ( qsi == 2 ) && ( use_planar_coeff ) )
{
planarCP = 1;
......@@ -1547,6 +1545,7 @@ static void ivas_spar_dec_parse_md_bs(
#endif
}
strat = get_next_indice( st0, 3 );
#ifdef SPAR_HOA_DBG
/*fprintf(stdout, "\n\n no_ec = %d, strat = %d\n", no_ec, strat);*/
#endif
......@@ -1600,101 +1599,51 @@ static void ivas_spar_dec_parse_md_bs(
for ( i = 0; i < *nB; i++ )
{
int16_t ii, jj;
int16_t *index_scratch[IVAS_SPAR_P_LOWERTRI];
float *quant_scratch[IVAS_SPAR_P_LOWERTRI];
int16_t ndec = hMdDec->spar_md_cfg.num_decorr_per_band[( *bands_bw ) * i];
int16_t ndm = hMdDec->spar_md_cfg.num_dmx_chans_per_band[( *bands_bw ) * i];
int16_t **index = (int16_t **) &index_scratch[0];
float **quant = (float **) &quant_scratch[0];
float coeff_decd[IVAS_SPAR_MAX_CH - 1];
float coeff_decx_re[IVAS_SPAR_P_LOWERTRI];
int16_t pred_index_re[IVAS_SPAR_MAX_CH - 1];
int16_t drct_index_re[IVAS_SPAR_MAX_C_COEFF];
int16_t decd_index_re[IVAS_SPAR_MAX_CH - 1];
int16_t decx_index_re[IVAS_SPAR_P_LOWERTRI];
for ( j = 0; j < ndm + ndec - 1; j++ )
{
pred_index_re[j] = hMdDec->spar_md.band_coeffs_idx[i].pred_index_re[j];
}
for ( j = 0; j < ndec * ( ndm - 1 ); j++ )
{
drct_index_re[j] = hMdDec->spar_md.band_coeffs_idx[i].drct_index_re[j];
}
for ( j = 0; j < ndec; j++ )
{
decd_index_re[j] = hMdDec->spar_md.band_coeffs_idx[i].decd_index_re[j];
}
ndec = hMdDec->spar_md_cfg.num_decorr_per_band[( *bands_bw ) * i];
ndm = hMdDec->spar_md_cfg.num_dmx_chans_per_band[( *bands_bw ) * i];
index[0] = &pred_index_re[0];
quant[0] = &hMdDec->spar_md.band_coeffs[i].pred_re[0];
ivas_deindex_real_index( hMdDec->spar_md.band_coeffs_idx[i].pred_index_re, qs.PR.q_levels[0], qs.PR.min, qs.PR.max, hMdDec->spar_md.band_coeffs[i].pred_re, ndm + ndec - 1 );
ivas_deindex_real_index( index, qs.PR.q_levels[0], qs.PR.min, qs.PR.max, quant, 1, ndm + ndec - 1 );
j = 0;
for ( ii = 0; ii < ndec; ii++ )
{
for ( jj = 0; jj < ndm - 1; jj++ )
{
hMdDec->spar_md.band_coeffs[i].C_re[ii][jj] = 0;
quant[j] = hMdDec->spar_md.band_coeffs[i].C_re[ii][jj];
j++;
}
}
ivas_deindex_real_index( hMdDec->spar_md.band_coeffs_idx[i].drct_index_re, qs.C.q_levels[0], qs.C.min, qs.C.max, quant, ndec * ( ndm - 1 ) );
j = 0;
for ( ii = 0; ii < ndec; ii++ )
{
for ( jj = 0; jj < ndm - 1; jj++ )
{
index[j] = &drct_index_re[j];
quant[j] = &hMdDec->spar_md.band_coeffs[i].C_re[ii][jj];
hMdDec->spar_md.band_coeffs[i].C_re[ii][jj] = quant[j];
j++;
}
}
ivas_deindex_real_index( index, qs.C.q_levels[0], qs.C.min, qs.C.max, quant, ndec * ( ndm - 1 ), 1 );
index[0] = &decd_index_re[0];
quant[0] = &coeff_decd[0];
ivas_deindex_real_index( index, qs.P_r.q_levels[0], qs.P_r.min, qs.P_r.max, quant, 1, ndm + ndec - 1 );
index[0] = &decx_index_re[0];
quant[0] = &coeff_decx_re[0];
ivas_deindex_real_index( index, qs.P_c.q_levels[0], qs.P_c.min, qs.P_c.max, quant, 1, ndec * ( ndec - 1 ) >> 2 );
ivas_deindex_real_index( hMdDec->spar_md.band_coeffs_idx[i].decd_index_re, qs.P_r.q_levels[0], qs.P_r.min, qs.P_r.max, hMdDec->spar_md.band_coeffs[i].P_re, ndm + ndec - 1 );
/* Store prior coefficient indices */
for ( j = 0; j < ndm + ndec - 1; j++ )
{
hMdDec->spar_md_prev.band_coeffs_idx[i].pred_index_re[j] = pred_index_re[j];
hMdDec->spar_md_prev.band_coeffs_idx[i].pred_index_re[j] = hMdDec->spar_md.band_coeffs_idx[i].pred_index_re[j];
}
for ( j = 0; j < ndec * ( ndm - 1 ); j++ )
{
hMdDec->spar_md_prev.band_coeffs_idx[i].drct_index_re[j] = drct_index_re[j];
}
for ( j = 0; j < ndec; j++ )
{
hMdDec->spar_md_prev.band_coeffs_idx[i].decd_index_re[j] = decd_index_re[j];
}
for ( k = 0; k < ndec; k++ )
{
hMdDec->spar_md.band_coeffs[i].P_re[k] = 0;
hMdDec->spar_md_prev.band_coeffs_idx[i].drct_index_re[j] = hMdDec->spar_md.band_coeffs_idx[i].drct_index_re[j];
}
for ( j = 0; j < ndec; j++ )
{
/* Don't bother adding in the decx parameters */
hMdDec->spar_md.band_coeffs[i].P_re[j] = coeff_decd[j];
hMdDec->spar_md_prev.band_coeffs_idx[i].decd_index_re[j] = hMdDec->spar_md.band_coeffs_idx[i].decd_index_re[j];
}
hMdDec->valid_bands[i] |= ( do_diff[i] == 0 ) ? 1 : 0;
}
}
else
{
*dtx_vad = hMdDec->spar_md.dtx_vad;
*nB = num_bands;
*bands_bw = num_bands / *nB;
for ( i = 0; i < *nB; i++ )
{
hMdDec->valid_bands[i] = 1;
}
}
#ifdef SPAR_HOA_DBG
int16_t b;
b = 0;
......@@ -1787,14 +1736,14 @@ static void ivas_decode_arith_bs(
const int16_t freq_diff,
const int16_t planarCP )
{
int16_t i, ndm, ndec;
int16_t i, j, ndm, ndec;
ivas_cell_dim_t pred_cell_dims[IVAS_MAX_NUM_BANDS];
ivas_cell_dim_t drct_cell_dims[IVAS_MAX_NUM_BANDS];
ivas_cell_dim_t decd_cell_dims[IVAS_MAX_NUM_BANDS];
ivas_cell_dim_t decx_cell_dims[IVAS_MAX_NUM_BANDS];
int16_t symbol_arr_re[IVAS_MAX_INPUT_LEN];
int16_t symbol_arr_old_re[IVAS_MAX_INPUT_LEN];
int16_t any_diff = 0;
int16_t any_diff;
for ( i = 0; i < nB; i++ )
{
......@@ -1802,6 +1751,13 @@ static void ivas_decode_arith_bs(
ndec = hMdDec->spar_md_cfg.num_decorr_per_band[bands_bw * i];
pred_cell_dims[i].dim1 = ndm + ndec - 1;
if ( hMdDec->spar_hoa_md_flag )
{
if ( i >= SPAR_DIRAC_SPLIT_START_BAND )
{
pred_cell_dims[i].dim1 -= ( FOA_CHANNELS - 1 );
}
}
pred_cell_dims[i].dim2 = 1;
drct_cell_dims[i].dim1 = ndec;
drct_cell_dims[i].dim2 = ndm - 1;
......@@ -1811,6 +1767,7 @@ static void ivas_decode_arith_bs(
decx_cell_dims[i].dim2 = 1;
}
any_diff = 0;
for ( i = 0; i < nB; i++ )
{
if ( pDo_diff[i] != 0 )
......@@ -1822,6 +1779,20 @@ static void ivas_decode_arith_bs(
if ( any_diff == 1 )
{
if ( hMdDec->spar_hoa_md_flag )
{
for ( i = 0; i < nB; i++ )
{
if ( i >= SPAR_DIRAC_SPLIT_START_BAND )
{
for ( j = 0; j < pred_cell_dims[i].dim1; j++ )
{
hMdDec->spar_md_prev.band_coeffs_idx_mapped[i].pred_index_re[j] =
hMdDec->spar_md_prev.band_coeffs_idx_mapped[i].pred_index_re[j + ( FOA_CHANNELS - 1 )];
}
}
}
}
ivas_copy_band_coeffs_idx_to_arr( hMdDec->spar_md_prev.band_coeffs_idx_mapped, nB, symbol_arr_old_re, pred_cell_dims, PRED_COEFF, planarCP );
}
......@@ -1830,6 +1801,25 @@ static void ivas_decode_arith_bs(
ivas_fill_band_coeffs_idx( hMdDec->spar_md.band_coeffs_idx, nB, symbol_arr_re, pred_cell_dims, PRED_COEFF, planarCP );
if ( hMdDec->spar_hoa_md_flag )
{
for ( i = 0; i < nB; i++ )
{
if ( i >= SPAR_DIRAC_SPLIT_START_BAND )
{
for ( j = pred_cell_dims[i].dim1 - 1; j >= 0; j-- )
{
hMdDec->spar_md.band_coeffs_idx[i].pred_index_re[j + ( FOA_CHANNELS - 1 )] =
hMdDec->spar_md.band_coeffs_idx[i].pred_index_re[j];
}
for ( j = 0; j < FOA_CHANNELS - 1; j++ )
{
hMdDec->spar_md.band_coeffs_idx[i].pred_index_re[j] = 0;
}
}
}
}
if ( any_diff == 1 )
{
ivas_copy_band_coeffs_idx_to_arr( hMdDec->spar_md_prev.band_coeffs_idx_mapped, nB, symbol_arr_old_re, drct_cell_dims, DRCT_COEFF, planarCP );
......@@ -2065,23 +2055,40 @@ static void ivas_decode_huffman_bs(
const int16_t planarCP )
{
int16_t i, j;
int16_t ndm, ndec;
int16_t pred_dim, drct_dim, decd_dim, pred_offset;
for ( i = 0; i < nB; i++ )
{
int16_t ndm, ndec;
int16_t pred_dim, drct_dim, decd_dim;
ndm = hMdDec->spar_md_cfg.num_dmx_chans_per_band[bands_bw * i];
ndec = hMdDec->spar_md_cfg.num_decorr_per_band[bands_bw * i];
pred_dim = ndec + ndm - 1;
drct_dim = ndec * ( ndm - 1 );
decd_dim = ndec;
pred_offset = 0;
if ( hMdDec->spar_hoa_md_flag )
{
if ( i >= SPAR_DIRAC_SPLIT_START_BAND )
{
pred_offset = FOA_CHANNELS - 1;
}
}
for ( j = 0; j < pred_dim; j++ )
for ( j = pred_offset; j < pred_dim; j++ )
{
ivas_huffman_decode( &hMdDec->huff_coeffs.pred_huff_re[qsi], st0,
&hMdDec->spar_md.band_coeffs_idx[i].pred_index_re[j] );
ivas_huffman_decode( &hMdDec->huff_coeffs.pred_huff_re[qsi], st0, &hMdDec->spar_md.band_coeffs_idx[i].pred_index_re[j] );
}
if ( hMdDec->spar_hoa_md_flag )
{
if ( i >= SPAR_DIRAC_SPLIT_START_BAND )
{
for ( j = 0; j < pred_offset; j++ )
{
hMdDec->spar_md.band_coeffs_idx[i].pred_index_re[j] = 0;
}
}
}
for ( j = 0; j < drct_dim; j++ )
......@@ -2092,8 +2099,7 @@ static void ivas_decode_huffman_bs(
}
else
{
ivas_huffman_decode( &hMdDec->huff_coeffs.drct_huff_re[qsi], st0,
&hMdDec->spar_md.band_coeffs_idx[i].drct_index_re[j] );
ivas_huffman_decode( &hMdDec->huff_coeffs.drct_huff_re[qsi], st0, &hMdDec->spar_md.band_coeffs_idx[i].drct_index_re[j] );
}
}
......@@ -2105,8 +2111,7 @@ static void ivas_decode_huffman_bs(
}
else
{
ivas_huffman_decode( &hMdDec->huff_coeffs.decd_huff_re[qsi], st0,
&hMdDec->spar_md.band_coeffs_idx[i].decd_index_re[j] );
ivas_huffman_decode( &hMdDec->huff_coeffs.decd_huff_re[qsi], st0, &hMdDec->spar_md.band_coeffs_idx[i].decd_index_re[j] );
}
}
}
......@@ -2324,35 +2329,29 @@ static void ivas_spar_unquant_dtx_indicies(
{
int16_t i, b;
int16_t q_lvl;
float **ppVal, *pVal, val;
int16_t **ppIdx, *pIdx, idx;
float val;
int16_t idx;
float pr_min_max[2];
pr_min_max[0] = pSpar_md->min_max[0];
pr_min_max[1] = pSpar_md->min_max[1];
ppVal = (float **) &pVal;
ppIdx = (int16_t **) &pIdx;
ppVal[0] = (float *) &val;
ppIdx[0] = (int16_t *) &idx;
for ( b = 0; b < nB; b++ )
{
for ( i = 0; i < FOA_CHANNELS - 1; i++ )
{
q_lvl = dtx_pr_real_q_levels[ndm_per_band[bw * b] - 1][i];
ppIdx[0][0] = pSpar_md->band_coeffs_idx[b].pred_index_re[i];
ivas_deindex_real_index( ppIdx, q_lvl, pr_min_max[0], pr_min_max[1], ppVal, 1, 1 );
pSpar_md->band_coeffs[b].pred_re[i] = ppVal[0][0];
idx = pSpar_md->band_coeffs_idx[b].pred_index_re[i];
ivas_deindex_real_index( &idx, q_lvl, pr_min_max[0], pr_min_max[1], &val, 1 );
pSpar_md->band_coeffs[b].pred_re[i] = val;
}
for ( i = 0; i < FOA_CHANNELS - ndm_per_band[bw * b]; i++ )
{
q_lvl = dtx_pd_real_q_levels[ndm_per_band[bw * b] - 1][i];
ppIdx[0][0] = pSpar_md->band_coeffs_idx[b].decd_index_re[i];
ivas_deindex_real_index( ppIdx, q_lvl, dtx_pd_real_min_max[0], dtx_pd_real_min_max[1], ppVal, 1, 1 );
pSpar_md->band_coeffs[b].P_re[i] = ppVal[0][0];
idx = pSpar_md->band_coeffs_idx[b].decd_index_re[i];
ivas_deindex_real_index( &idx, q_lvl, dtx_pd_real_min_max[0], dtx_pd_real_min_max[1], &val, 1 );
pSpar_md->band_coeffs[b].P_re[i] = val;
}
}
......@@ -2374,27 +2373,21 @@ static void ivas_parse_parameter_bitstream_dtx(
int16_t *num_dmx_per_band,
int16_t *num_dec_per_band )
{
int16_t i, j;
float **ppVal, *pVal, val;
int16_t **ppIdx, *pIdx, idx;
int16_t i, j, ndec, ndm;
float val;
int16_t idx;
float pr_min_max[2];
int16_t pr_q_lvls, pr, pd, pd_q_lvls, pr_pd_bits;
int16_t pr_q_lvls1, pr_q_lvls2, pr_idx1, pr_idx2, pr_pr_bits;
int16_t zero_pad_bits, sid_bits_len;
sid_bits_len = st0->next_bit_pos;
ppVal = (float **) &pVal;
ppIdx = (int16_t **) &pIdx;
ppVal[0] = (float *) &val;
ppIdx[0] = (int16_t *) &idx;
pr_min_max[0] = pSpar_md->min_max[0];
pr_min_max[1] = pSpar_md->min_max[1];
for ( i = 0; i < num_bands; i++ )
{
int16_t ndec = num_dec_per_band[bw * i];
int16_t ndm = num_dmx_per_band[bw * i];
ndec = num_dec_per_band[bw * i];
ndm = num_dmx_per_band[bw * i];
for ( j = 0; j < FOA_CHANNELS - 1; j++ )
{
......@@ -2427,16 +2420,13 @@ static void ivas_parse_parameter_bitstream_dtx(
pr = (int16_t) floor( value / pd_q_lvls );
pd = value - pr * pd_q_lvls;
val = dtx_pd_real_min_max[0];
ivas_quantise_real_values( &val, pd_q_lvls, dtx_pd_real_min_max[0], dtx_pd_real_min_max[1], &idx, &val, 1 );
pd = pd + idx;
ppVal[0][0] = dtx_pd_real_min_max[0];
ivas_quantise_real_values( ppVal, pd_q_lvls, dtx_pd_real_min_max[0], dtx_pd_real_min_max[1], ppIdx, ppVal, 1, 1 );
pd = pd + ppIdx[0][0];
ppVal[0][0] = pr_min_max[0];
ivas_quantise_real_values( ppVal, pr_q_lvls, pr_min_max[0], pr_min_max[1], ppIdx, ppVal, 1, 1 );
pr = pr + ppIdx[0][0];
val = pr_min_max[0];
ivas_quantise_real_values( &val, pr_q_lvls, pr_min_max[0], pr_min_max[1], &idx, &val, 1 );
pr = pr + idx;
if ( ( j + 1 ) <= ndec )
{
......@@ -2456,17 +2446,15 @@ static void ivas_parse_parameter_bitstream_dtx(
pr_idx2 = (int16_t) floor( value / pr_q_lvls1 );
pr_idx1 = value - pr_idx2 * pr_q_lvls1;
val = pr_min_max[0];
ivas_quantise_real_values( &val, pr_q_lvls1, pr_min_max[0], pr_min_max[1], &idx, &val, 1 );
ppVal[0][0] = pr_min_max[0];
ivas_quantise_real_values( ppVal, pr_q_lvls1, pr_min_max[0], pr_min_max[1], ppIdx, ppVal, 1, 1 );
pr_idx1 += ppIdx[0][0];
pr_idx1 += idx;
ppVal[0][0] = pr_min_max[0];
ivas_quantise_real_values( ppVal, pr_q_lvls2, pr_min_max[0], pr_min_max[1], ppIdx, ppVal, 1, 1 );
pr_idx2 += ppIdx[0][0];
val = pr_min_max[0];
ivas_quantise_real_values( &val, pr_q_lvls2, pr_min_max[0], pr_min_max[1], &idx, &val, 1 );
pr_idx2 += idx;
pSpar_md->band_coeffs_idx[i].pred_index_re[pr_idx_1 - 1] = pr_idx1;
pSpar_md->band_coeffs_idx[i].pred_index_re[pr_idx_2 - 1] = pr_idx2;
}
......@@ -2495,15 +2483,14 @@ static void ivas_parse_parameter_bitstream_dtx(
*-----------------------------------------------------------------------------------------*/
static ivas_error ivas_deindex_real_index(
int16_t **index,
const int16_t *index,
const int16_t q_levels,
const float min_value,
const float max_value,
float **quant,
const int16_t num_ch,
const int16_t dim2 )
float *quant,
const int16_t dim )
{
int16_t i, j;
int16_t i;
float q_step;
if ( q_levels == 0 )
......@@ -2513,24 +2500,17 @@ static ivas_error ivas_deindex_real_index(
if ( q_levels == 1 )
{
for ( i = 0; i < num_ch; i++ )
{
for ( j = 0; j < dim2; j++ )
for ( i = 0; i < dim; i++ )
{
quant[i][j] = 0;
}
quant[i] = 0;
}
}
else
{
q_step = ( max_value - min_value ) / ( q_levels - 1 );
for ( i = 0; i < num_ch; i++ )
{
for ( j = 0; j < dim2; j++ )
for ( i = 0; i < dim; i++ )
{
quant[i][j] = index[i][j] * q_step;
}
quant[i] = index[i] * q_step;
}
}
......@@ -2760,8 +2740,7 @@ void ivas_spar_to_dirac(
/* DirAC MD averaged over 4 subframes and converted to SPAR format similar to encoder processing */
if ( hMdDec->spar_md_cfg.nchan_transport > 1 )
{
ivas_get_spar_md_from_dirac( azi_dirac, ele_dirac, diffuseness, 1, NULL, &hMdDec->spar_md, &hMdDec->spar_md_cfg,
end_band, num_bands_out, sba_order_internal, dtx_vad, NULL );
ivas_get_spar_md_from_dirac( azi_dirac, ele_dirac, diffuseness, 1, NULL, &hMdDec->spar_md, &hMdDec->spar_md_cfg, end_band, num_bands_out, ( hMdDec->spar_hoa_md_flag ) ? 1 : sba_order_internal, dtx_vad, NULL );
/* temporarily copy frame-wise prediction coefficients in DirAC bands*/
for ( pred_idx = 0; pred_idx < FOA_CHANNELS - 1; pred_idx++ )
......@@ -2773,8 +2752,7 @@ void ivas_spar_to_dirac(
}
}
ivas_get_spar_md_from_dirac( azi_dirac, ele_dirac, diffuseness, MAX_PARAM_SPATIAL_SUBFRAMES, NULL, &hMdDec->spar_md, &hMdDec->spar_md_cfg,
end_band, num_bands_out, sba_order_internal, dtx_vad, NULL );
ivas_get_spar_md_from_dirac( azi_dirac, ele_dirac, diffuseness, MAX_PARAM_SPATIAL_SUBFRAMES, NULL, &hMdDec->spar_md, &hMdDec->spar_md_cfg, end_band, num_bands_out, ( hMdDec->spar_hoa_md_flag ) ? 1 : sba_order_internal, dtx_vad, NULL );
/* expand DirAC TC 20ms MD for residual channels to all subframes*/
for ( block = 0; block < MAX_PARAM_SPATIAL_SUBFRAMES; block++ )
......
......@@ -39,6 +39,10 @@
#include "stat_dec.h"
#include "ivas_cnst.h"
#include "ivas_stat_com.h"
#include "ivas_stat_rend.h"
#ifdef EXT_RENDERER
#include "common_api_types.h" // VE2AT: don't we want to avoid this include in the library? I admit that the rules hefre are not 100% clear to me but introducing it just for IVAS_QUATERNION is not necessry I think
#endif
/*----------------------------------------------------------------------------------*
......@@ -123,7 +127,6 @@ typedef struct stereo_dft_dec_data_struct
const float *win_8k; /* DFT window residual */
/*Bands*/
int16_t band_res[STEREO_DFT_DEC_DFT_NB];
int16_t band_limits[STEREO_DFT_BAND_MAX + 1];
......@@ -216,14 +219,10 @@ typedef struct stereo_dft_dec_data_struct
float smooth_buf[SBA_DIRAC_STEREO_NUM_BANDS][SBA_DIRAC_NRG_SMOOTH_LONG + 1];
float smooth_fac[NB_DIV][SBA_DIRAC_STEREO_NUM_BANDS];
} STEREO_DFT_DEC_DATA, *STEREO_DFT_DEC_DATA_HANDLE;
/*----------------------------------------------------------------------------------*
* DFT Stereo mono output structure
*----------------------------------------------------------------------------------*/
/* DFT Stereo mono output structure */
typedef struct stereo_dft_dmx_out_data_structure
{
float targetGain; /* TCA gain norm applied on target (or right) channel in current frame */
......@@ -320,10 +319,8 @@ typedef struct stereo_mdct_dec_data_structure
int16_t prev_ms_mask[NB_DIV][MAX_SFB];
float lastCoh;
#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT
int16_t noise_seeds_channels[CPE_CHANNELS];
int16_t noise_seed_common;
#endif
int16_t isSBAStereoMode;
} STEREO_MDCT_DEC_DATA, *STEREO_MDCT_DEC_DATA_HANDLE;
......@@ -430,6 +427,7 @@ typedef struct dirac_dec_stack_mem
float *reference_power;
float *onset_filter;
} DIRAC_DEC_STACK_MEM, *DIRAC_DEC_STACK_MEM_HANDLE;
typedef struct param_ism_rendering
......@@ -659,7 +657,6 @@ typedef struct ivas_dirac_dec_data_structure
int16_t spar_to_dirac_write_idx;
int16_t dirac_md_buffer_length;
int16_t numSimultaneousDirections; /* 1 or 2 */
DIFFUSE_DISTRIBUTION_HANDLE hDiffuseDist;
......@@ -715,6 +712,7 @@ typedef struct ivas_dirac_dec_data_structure
PARAM_ISM_RENDERING_HANDLE hParamIsmRendering;
IVAS_FB_MIXER_HANDLE hFbMdft;
int16_t dirac_to_spar_md_bands[DIRAC_MAX_NBANDS];
} DIRAC_DEC_DATA, *DIRAC_DEC_HANDLE;
......@@ -809,7 +807,7 @@ typedef struct ivas_spar_md_dec_state_t
ivas_huff_coeffs_t huff_coeffs;
int16_t table_idx;
int16_t dtx_vad;
int16_t spar_hoa_md_flag;
} ivas_spar_md_dec_state_t;
......@@ -876,7 +874,7 @@ typedef struct ivas_spar_dec_lib_t
int16_t dirac_to_spar_md_bands[DIRAC_MAX_NBANDS];
int16_t enc_param_start_band;
int32_t core_nominal_brate; /* Nominal bitrate for core coding */
int32_t i_subframe;
int16_t i_subframe;
#ifdef DEBUG_SBA_AUDIO_DUMP
int16_t numOutChannels;
......@@ -986,7 +984,7 @@ typedef struct mct_dec_data_structure
/*----------------------------------------------------------------------------------*
* EFAP structures
*----------------------------------------------------------------------------------*/
// VE2AT: move to ivas_rom_rend.h ?
typedef struct EFAP_VERTEX
{
float azi; /* azimuth of the loudspeaker */
......@@ -995,6 +993,7 @@ typedef struct EFAP_VERTEX
int16_t idx; /* integer, that corresponds to the first index for the LS in the 1D output */
int16_t isNaN; /* used to indicate if the vertex is a virtual speaker */
EFAP_VTX_DMX_TYPE dmxType; /* virtual speaker downmix type */
} EFAP_VERTEX;
typedef struct EFAP_VERTEX_DATA
......@@ -1044,10 +1043,11 @@ typedef struct EFAP
} EFAP, *EFAP_HANDLE;
/*----------------------------------------------------------------------------------*
* VBAP structures
*----------------------------------------------------------------------------------*/
// VE2AT: move to ivas_rom_rend.h ?
enum SpeakerNodeGroup
{
SPEAKER_NODE_BOTTOM_HALF,
......@@ -1105,7 +1105,7 @@ typedef struct vbap_data_structure
/*----------------------------------------------------------------------------------*
* renderer structures
*----------------------------------------------------------------------------------*/
// VE2AT: move to ivas_rom_rend.h ?
typedef struct renderer_struct
{
float prev_gains[MAX_CICP_CHANNELS - 1][MAX_OUTPUT_CHANNELS];
......@@ -1113,59 +1113,6 @@ typedef struct renderer_struct
} ISM_RENDERER_DATA, *ISM_RENDERER_HANDLE;
/*----------------------------------------------------------------------------------*
* Loudspeaker Configuration Conversion structure
*----------------------------------------------------------------------------------*/
typedef struct ivas_LS_setupconversion_struct
{
float *dmxMtx[MAX_OUTPUT_CHANNELS];
float *targetEnergyPrev[MAX_OUTPUT_CHANNELS];
float *dmxEnergyPrev[MAX_OUTPUT_CHANNELS];
int16_t sfbOffset[MAX_SFB + 2];
int16_t sfbCnt;
} LSSETUP_CONVERSION_STRUCT, *LSSETUP_CONVERSION_HANDLE;
typedef struct ivas_LS_setupconversion_matrix
{
int16_t index;
float value;
} LS_CONVERSION_MATRIX;
typedef struct ivas_LS_setupconversion_mapping
{
AUDIO_CONFIG input_config;
AUDIO_CONFIG output_config;
const LS_CONVERSION_MATRIX *conversion_matrix;
} LS_CONVERSION_MAPPING;
typedef struct ivas_mono_downmix_renderer_struct
{
float inputEnergy[CLDFB_NO_CHANNELS_MAX];
float protoEnergy[CLDFB_NO_CHANNELS_MAX];
} MONO_DOWNMIX_RENDERER_STRUCT, *MONO_DOWNMIX_RENDERER_HANDLE;
/*----------------------------------------------------------------------------------*
* Custom Loudspeaker configuration structure
*----------------------------------------------------------------------------------*/
typedef struct ivas_LS_setup_custom
{
int16_t is_planar_setup; /* flag to indicate if setup is planar or not */
int16_t num_spk; /* number of custom loudspeakers */
float ls_azimuth[MAX_OUTPUT_CHANNELS]; /* custom loudspeaker azimuths */
float ls_elevation[MAX_OUTPUT_CHANNELS]; /* custom loudspeaker elevations */
int16_t num_lfe; /* number of LFE channels */
int16_t lfe_idx[MAX_OUTPUT_CHANNELS]; /* index for LFE channel insertion */
int16_t separate_ch_found; /* flag to indicate if a center channel was found */
float separate_ch_gains[MAX_OUTPUT_CHANNELS]; /* gains to pan McMASA separateChannel in case no center channel is present */
} LSSETUP_CUSTOM_STRUCT, *LSSETUP_CUSTOM_HANDLE;
/*----------------------------------------------------------------------------------*
* MASA decoder structures
......@@ -1225,7 +1172,7 @@ typedef struct ivas_masa_decoder_struct
/*----------------------------------------------------------------------------------*
* Binaural Rendering structure
*----------------------------------------------------------------------------------*/
// VE2AT: move to ivas_rom_rend.h ?
/* Binaural reverberator structure */
typedef struct ivas_binaural_reverb_struct
{
......@@ -1303,13 +1250,13 @@ typedef struct ivas_dirac_dec_binaural_data_structure
typedef struct ivas_binaural_rendering_conv_module_struct
{
const float *filterTapsLeftReal[CLDFB_NO_CHANNELS_MAX][MAX_OUTPUT_CHANNELS];
const float *filterTapsLeftImag[CLDFB_NO_CHANNELS_MAX][MAX_OUTPUT_CHANNELS];
const float *filterTapsRightReal[CLDFB_NO_CHANNELS_MAX][MAX_OUTPUT_CHANNELS];
const float *filterTapsRightImag[CLDFB_NO_CHANNELS_MAX][MAX_OUTPUT_CHANNELS];
float ***filterTapsLeftReal;
float ***filterTapsLeftImag;
float ***filterTapsRightReal;
float ***filterTapsRightImag;
float filterStatesLeftReal[BINAURAL_CONVBANDS][MAX_OUTPUT_CHANNELS][BINAURAL_NTAPS_MAX];
float filterStatesLeftImag[BINAURAL_CONVBANDS][MAX_OUTPUT_CHANNELS][BINAURAL_NTAPS_MAX];
float ***filterStatesLeftReal;
float ***filterStatesLeftImag;
int16_t numTapsArray[BINAURAL_CONVBANDS];
int16_t numTaps;
......@@ -1344,18 +1291,24 @@ typedef struct ivas_binaural_rendering_struct
/*----------------------------------------------------------------------------------*
* Head tracking data structure
*----------------------------------------------------------------------------------*/
// VE2AT: move to ivas_rom_rend.h ?
#ifndef EXT_RENDERER
/* Quaternion type for head orientation */
typedef struct Quaternion_struct
{
float w, x, y, z;
} Quaternion;
#endif
typedef struct ivas_binaural_head_track_struct
{
int16_t num_quaternions;
#ifdef EXT_RENDERER
IVAS_QUATERNION Quaternions[MAX_PARAM_SPATIAL_SUBFRAMES];
#else
Quaternion Quaternions[MAX_PARAM_SPATIAL_SUBFRAMES];
#endif
float Rmat[3][3];
float Rmat_prev[3][3];
......@@ -1371,7 +1324,7 @@ typedef struct ivas_binaural_head_track_struct
/*----------------------------------------------------------------------------------*
* TD ISm Object Renderer structure
*----------------------------------------------------------------------------------*/
// VE2AT: move to ivas_rom_rend.h ?
typedef struct
{
SFX_OpMode_t OpMode; /* Operating mode. This effect can only be TRANSIENT or OFF. */
......@@ -1435,7 +1388,6 @@ typedef struct TDREND_LIST_Item_s
} TDREND_LIST_Item_t;
typedef struct
{
int16_t modelROM; /* Flag that indicates that the model resides in ROM (controls init/dealloc). */
......@@ -1516,6 +1468,7 @@ typedef struct
float *W_dyn;
float *azimBsShape_dyn;
float *elevBsShape_dyn;
} ModelParamsITD_t;
typedef struct
......@@ -1679,22 +1632,22 @@ typedef struct ivas_binaural_td_rendering_struct
/*------------------------------------------------------------------------------------------*
* Crend structures
*------------------------------------------------------------------------------------------*/
// VE2AT: move to ivas_rom_rend.h ?
typedef struct ivas_hrtfs_structure
{
float *pOut_to_bin_re[IVAS_MAX_NUM_CH][BINAURAL_CHANNELS];
float *pOut_to_bin_im[IVAS_MAX_NUM_CH][BINAURAL_CHANNELS];
float *pOut_to_bin_re[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS];
float *pOut_to_bin_im[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS];
float *pOut_to_bin_diffuse_re[BINAURAL_CHANNELS];
float *pOut_to_bin_diffuse_im[BINAURAL_CHANNELS];
float latency_s;
uint16_t num_iterations[IVAS_MAX_NUM_CH][BINAURAL_CHANNELS];
uint16_t num_iterations[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS];
uint16_t num_iterations_diffuse[BINAURAL_CHANNELS];
uint16_t *pIndex_frequency_max[IVAS_MAX_NUM_CH][BINAURAL_CHANNELS];
uint16_t *pIndex_frequency_max[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS];
uint16_t *pIndex_frequency_max_diffuse[BINAURAL_CHANNELS];
uint16_t index_frequency_max_diffuse;
int16_t max_num_ir;
int16_t max_num_iterations;
float inv_diffuse_weight[IVAS_MAX_NUM_CH]; /* inverse diffuse weights array, access one inverse weight by pInvDiffuseWeight[channel] */
float inv_diffuse_weight[MAX_INTERN_CHANNELS]; /* inverse diffuse weights array, access one inverse weight by pInvDiffuseWeight[channel] */
float gain_lfe;
} HRTFS_DATA, *HRTFS_HANDLE;
......@@ -1713,6 +1666,7 @@ typedef struct ivas_roomAcoustics_t
float pAcoustic_dsr[CLDFB_NO_CHANNELS_MAX]; /* - The room's Diffuse to Source Ratio per center frequency */
float acousticPreDelay; /* Time elapsed between input signal and late reverberation start, float, range [0.001..10] */
float inputPreDelay; /* Offset in seconds from where DSR is computed in the RIR (0 = at source), float, range [0.001..10] */
} ivas_roomAcoustics_t;
typedef struct ivas_render_config_t
......@@ -1721,6 +1675,7 @@ typedef struct ivas_render_config_t
ivas_renderTypeOverride renderer_type_override;
#endif
ivas_roomAcoustics_t roomAcoustics;
} RENDER_CONFIG_DATA, *RENDER_CONFIG_HANDLE;
......@@ -1832,11 +1787,11 @@ typedef struct ivas_orient_trk_state_t
} ivas_orient_trk_state_t;
/* Crend structures */
/* Main Crend structure */
typedef struct ivas_crend_state_t
{
float *freq_buffer_re[IVAS_MAX_NUM_CH];
float *freq_buffer_im[IVAS_MAX_NUM_CH];
float *freq_buffer_re[MAX_INTERN_CHANNELS];
float *freq_buffer_im[MAX_INTERN_CHANNELS];
float *freq_buffer_re_diffuse;
float *freq_buffer_im_diffuse;
float *prev_out_buffer[BINAURAL_CHANNELS];
......@@ -1853,7 +1808,7 @@ typedef struct ivas_crend_state_t
/*----------------------------------------------------------------------------------*
* LFE decoder structures
* LFE decoder structure
*----------------------------------------------------------------------------------*/
typedef struct ivas_lfe_dec_data_structure
......
......@@ -90,7 +90,8 @@ void stereo_dft_dec_sid_coh(
int16_t bits_tmp;
int16_t b;
nr_of_sid_stereo_bits = ( IVAS_SID_4k4 - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS;
/* TODO: still use old number of bits to keep bitexactness in output */
nr_of_sid_stereo_bits = ( 4400 /*IVAS_SID_5k2*/ - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS;
/* If the coherence is not encoded due to lack of bits set alpha to zero which leads to that the coherence */
/* from the previous frame is used. */
......@@ -173,6 +174,7 @@ void stereo_dft_dec_sid_coh(
( *nb_bits )++;
}
dtx_read_padding_bits( st, ( IVAS_SID_5k2 - 4400 ) / FRAMES_PER_SEC );
return;
}
......@@ -343,7 +345,7 @@ static void stereo_dft_generate_comfort_noise(
ptr2 = ptr1 + 1;
for ( i = 0; i < st->L_frame / 2 - 1; i++ )
{
*ptr0++ = 2.0f * sqrtf( st->lp_ener / st->L_frame * 0.5f ) / sqrtf( *ptr1 * *ptr1 + *ptr2 * *ptr2 );
*ptr0++ = 2.0f * sqrtf( st->lp_ener / st->L_frame * 0.5f ) * inv_sqrt( *ptr1 * *ptr1 + *ptr2 * *ptr2 );
ptr1 += 2;
ptr2 += 2;
}
......@@ -653,9 +655,9 @@ void stereo_dtf_cng(
hCPE->hStereoCng->nr_dft_frames++;
}
if ( ivas_total_brate <= IVAS_SID_4k4 )
if ( ivas_total_brate <= IVAS_SID_5k2 )
{
if ( hCPE->hStereoCng->nr_sid_frames < SID_INIT && ivas_total_brate == IVAS_SID_4k4 )
if ( hCPE->hStereoCng->nr_sid_frames < SID_INIT && ivas_total_brate == IVAS_SID_5k2 )
{
hCPE->hStereoCng->nr_sid_frames++;
}
......@@ -707,7 +709,7 @@ void stereo_cng_dec_update(
if ( hCPE->element_mode == IVAS_CPE_DFT )
{
if ( ivas_total_brate == IVAS_SID_4k4 || ivas_total_brate == FRAME_NO_DATA )
if ( ivas_total_brate == IVAS_SID_5k2 || ivas_total_brate == FRAME_NO_DATA )
{
hCPE->hStereoCng->prev_sid_nodata = 1;
}
......@@ -769,7 +771,9 @@ void stereo_cng_compute_PScorr(
enrS += *outputSptr * *outputSptr;
dotPS += *outputPptr++ * *outputSptr++;
}
c_PS = ( dotPS + EPSILON ) / sqrtf( enrP * enrS + EPSILON );
c_PS = ( dotPS + EPSILON ) * inv_sqrt( enrP * enrS + EPSILON );
*c_PS_LT = STEREO_TD_PS_CORR_FILT * *c_PS_LT + ( 1 - STEREO_TD_PS_CORR_FILT ) * c_PS;
return;
......@@ -806,7 +810,7 @@ static void stereo_cng_compute_LRcorr(
dotLR += output[0][i] * output[1][i];
}
c_LR = fabsf( dotLR + EPSILON ) / sqrtf( enrL * enrR + EPSILON );
c_LR = fabsf( dotLR + EPSILON ) * inv_sqrt( enrL * enrR + EPSILON );
c = ( enrL + DELTA ) / ( enrR + DELTA );
hCPE->hStereoTD->c_LR_LT = STEREO_TD_PS_CORR_FILT * hCPE->hStereoTD->c_LR_LT + ( 1 - STEREO_TD_PS_CORR_FILT ) * c_LR;
hCPE->hStereoCng->c_LR_LT = hCPE->hStereoTD->c_LR_LT;
......@@ -930,7 +934,7 @@ void stereo_cna_update_params(
}
/* estimate L/R correlation factor and ILD in time domain */
c_LR = fabsf( dotLR + EPSILON ) / sqrtf( enrL * enrR + EPSILON );
c_LR = fabsf( dotLR + EPSILON ) * inv_sqrt( enrL * enrR + EPSILON );
c = ( enrL + DELTA ) / ( enrR + DELTA );
c_ILD = ( c - 1 ) / ( c + 1 );
}
......
......@@ -1746,7 +1746,7 @@ void stereo_dft_dec_read_BS(
* Initialization
*-----------------------------------------------------------------*/
if ( ivas_total_brate == IVAS_SID_4k4 )
if ( ivas_total_brate == IVAS_SID_5k2 )
{
if ( ivas_format == MASA_FORMAT )
{
......@@ -1760,7 +1760,7 @@ void stereo_dft_dec_read_BS(
hStereoDft->frame_nodata = 0;
hStereoDft->frame_sid_nodata = 1;
hStereoDft->frame_sid = 1;
*nb_bits = ( IVAS_SID_4k4 - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS;
*nb_bits = ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS;
}
}
else if ( ivas_total_brate == FRAME_NO_DATA )
......@@ -1803,7 +1803,7 @@ void stereo_dft_dec_read_BS(
k_offset = STEREO_DFT_OFFSET;
N_div = STEREO_DFT_NBDIV;
if ( ivas_total_brate > IVAS_SID_4k4 )
if ( ivas_total_brate > IVAS_SID_5k2 )
{
mvr2r( hStereoDft->side_gain + 2 * STEREO_DFT_BAND_MAX, sg_tmp, STEREO_DFT_BAND_MAX );
mvr2r( hStereoDft->res_pred_gain + 2 * STEREO_DFT_BAND_MAX, res_pred_gain_tmp, STEREO_DFT_BAND_MAX );
......@@ -1893,7 +1893,7 @@ void stereo_dft_dec_read_BS(
fprintf( pF, "ITD: %d ", hStereoDft->hConfig->itd_mode );
#endif
if ( !( ivas_format == MASA_FORMAT && ivas_total_brate <= IVAS_SID_4k4 ) )
if ( !( ivas_format == MASA_FORMAT && ivas_total_brate <= IVAS_SID_5k2 ) )
{
/*------------------------------------------------------------------*
* read Side gains
......@@ -1974,7 +1974,7 @@ void stereo_dft_dec_read_BS(
#endif
}
}
else if ( *nb_bits <= ( ( IVAS_SID_4k4 - SID_2k40 ) / FRAMES_PER_SEC - STEREO_DFT_ITD_MODE_NBITS - STEREO_DFT_SID_ITD_NBITS - 1 - SID_FORMAT_NBITS ) )
else if ( *nb_bits <= ( ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - STEREO_DFT_ITD_MODE_NBITS - STEREO_DFT_SID_ITD_NBITS - 1 - SID_FORMAT_NBITS ) )
{
itd_mode = get_next_indice( st, STEREO_DFT_ITD_MODE_NBITS );
( *nb_bits ) += STEREO_DFT_ITD_MODE_NBITS; /*ITD mode flag: 1bit*/
......@@ -2016,7 +2016,7 @@ void stereo_dft_dec_read_BS(
stereo_dft_dequantize_ipd( &ind1_ipd[0], hStereoDft->gipd + ( k + k_offset ), 1, STEREO_DFT_GIPD_NBITS );
}
}
else if ( *nb_bits <= ( ( IVAS_SID_4k4 - SID_2k40 ) / FRAMES_PER_SEC - STEREO_DFT_FLAG_BITS - STEREO_DFT_SID_GIPD_NBITS - SID_FORMAT_NBITS ) )
else if ( *nb_bits <= ( ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - STEREO_DFT_FLAG_BITS - STEREO_DFT_SID_GIPD_NBITS - SID_FORMAT_NBITS ) )
{
/* SID frame, only read IPD only if enough bits left in bitstream */
hStereoDft->no_ipd_flag = st->bit_stream[nb];
......@@ -2177,7 +2177,7 @@ void stereo_dft_dec_read_BS(
#endif
}
if ( !( ivas_format == MASA_FORMAT && ivas_total_brate <= IVAS_SID_4k4 ) )
if ( !( ivas_format == MASA_FORMAT && ivas_total_brate <= IVAS_SID_5k2 ) )
{
if ( hStereoDft->side_gain_flag_1 != 2 )
{
......@@ -2185,7 +2185,7 @@ void stereo_dft_dec_read_BS(
}
}
if ( ivas_total_brate > IVAS_SID_4k4 )
if ( ivas_total_brate > IVAS_SID_5k2 )
{
hStereoDft->recovery_flg = stereo_dft_sg_recovery( hStereoDft );
......@@ -2252,12 +2252,12 @@ void stereo_dft_dec_read_BS(
#endif
}
if ( hStereoDft->frame_sid && !( ivas_format == MASA_FORMAT && ivas_total_brate <= IVAS_SID_4k4 ) )
if ( hStereoDft->frame_sid && !( ivas_format == MASA_FORMAT && ivas_total_brate <= IVAS_SID_5k2 ) )
{
stereo_dft_dec_sid_coh( st, hStereoDft->nbands, coh, nb_bits );
}
if ( ivas_total_brate == IVAS_SID_4k4 && ivas_format != MASA_FORMAT )
if ( ivas_total_brate == IVAS_SID_5k2 && ivas_format != MASA_FORMAT )
{
*nb_bits = (int16_t) ( ( element_brate - SID_2k40 ) / FRAMES_PER_SEC ); /* => hCPE->hCoreCoder[0]->total_brate = SID_2k40; */
}
......