Skip to content
......@@ -88,8 +88,7 @@ void ivas_mct_side_bits(
for ( ch = 0; ch < nChannels; ch++ )
{
st = sts[ch];
if (
st->mct_chan_mode == MCT_CHAN_MODE_IGNORE )
if ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE )
{
continue;
}
......@@ -115,8 +114,7 @@ void ivas_mct_side_bits(
{
st = sts[ch];
if (
st->mct_chan_mode == MCT_CHAN_MODE_IGNORE )
if ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE )
{
chBitRatios[ch] = 0;
st->bits_frame_channel = 0;
......@@ -203,8 +201,7 @@ void ivas_mct_core_dec(
for ( ch = 0, i = 0; ch < nChannels; ch++ )
{
if (
sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE )
if ( sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE )
{
continue;
}
......
......@@ -54,14 +54,12 @@
* Local function prototypes
*-----------------------------------------------------------------------*/
static ivas_error ivas_mc_dec_reconfig( Decoder_Struct *st_ivas, uint16_t *nSamplesRendered,
#if defined SPLIT_REND_WITH_HEAD_ROT
const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */
void *data /* o : output synthesis signal */
#ifdef SPLIT_REND_WITH_HEAD_ROT
static ivas_error ivas_mc_dec_reconfig( Decoder_Struct *st_ivas, uint16_t *nSamplesRendered, const PCM_RESOLUTION pcm_resolution, void *data );
#else
int16_t *data /* o : output synthesis signal */
static ivas_error ivas_mc_dec_reconfig( Decoder_Struct *st_ivas, uint16_t *nSamplesRendered, int16_t *data );
#endif
);
/*--------------------------------------------------------------------------*
* ivas_mct_dec()
......@@ -378,6 +376,7 @@ ivas_error create_mct_dec(
cp_bitrate = st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport * CPE_CHANNELS;
}
#endif
/* indicate LFE for appropriate core-coder channel */
for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
......@@ -515,6 +514,7 @@ ivas_error mct_dec_reconfigure(
cp_bitrate = st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport * CPE_CHANNELS;
}
#endif
/* set correct nominal bitrates and igf config already here, otherwise we
* run into a number of problems */
for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
......@@ -657,7 +657,7 @@ ivas_error ivas_mc_dec_config(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
const int16_t idx, /* i : LS config. index */
uint16_t *nSamplesRendered, /* o : samples flushed from last frame (JBM) */
#if defined SPLIT_REND_WITH_HEAD_ROT
#ifdef SPLIT_REND_WITH_HEAD_ROT
const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */
void *data /* o : output synthesis signal */
#else
......@@ -669,8 +669,6 @@ ivas_error ivas_mc_dec_config(
MC_MODE last_mc_mode;
ivas_error error;
error = IVAS_ERR_OK;
/* store last frame MC mode */
last_mc_mode = st_ivas->mc_mode;
......@@ -692,18 +690,22 @@ ivas_error ivas_mc_dec_config(
{
if ( st_ivas->hDecoderConfig->last_ivas_total_brate != st_ivas->hDecoderConfig->ivas_total_brate || st_ivas->transport_config != signaled_config || last_mc_mode != st_ivas->mc_mode )
{
ivas_mc_dec_reconfig( st_ivas, nSamplesRendered,
#if defined SPLIT_REND_WITH_HEAD_ROT
pcm_resolution,
#ifdef SPLIT_REND_WITH_HEAD_ROT
if ( ( error = ivas_mc_dec_reconfig( st_ivas, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK )
#else
if ( ( error = ivas_mc_dec_reconfig( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK )
#endif
data );
{
return error;
}
}
}
st_ivas->transport_config = signaled_config;
}
return error;
return IVAS_ERR_OK;
}
......@@ -716,7 +718,7 @@ ivas_error ivas_mc_dec_config(
static ivas_error ivas_mc_dec_reconfig(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
uint16_t *nSamplesRendered, /* o : number of samples flushed from the last frame (JBM) */
#if defined SPLIT_REND_WITH_HEAD_ROT
#ifdef SPLIT_REND_WITH_HEAD_ROT
const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */
void *data /* o : output synthesis signal */
#else
......@@ -803,11 +805,11 @@ static ivas_error ivas_mc_dec_reconfig(
tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs );
if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity )
{
if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, last_mc_mode, ISM_MODE_NONE, nSamplesRendered,
#if defined SPLIT_REND_WITH_HEAD_ROT
pcm_resolution,
#ifdef SPLIT_REND_WITH_HEAD_ROT
if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, last_mc_mode, ISM_MODE_NONE, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK )
#else
if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, last_mc_mode, ISM_MODE_NONE, nSamplesRendered, data ) ) != IVAS_ERR_OK )
#endif
data ) ) != IVAS_ERR_OK )
{
return error;
}
......@@ -822,7 +824,6 @@ static ivas_error ivas_mc_dec_reconfig(
}
}
if ( st_ivas->mc_mode == MC_MODE_MCT )
{
st_ivas->nchan_transport = ivas_mc_ls_setup_get_num_channels( ivas_mc_map_output_config_to_mc_ls_setup( st_ivas->transport_config ) );
......@@ -962,11 +963,8 @@ static ivas_error ivas_mc_dec_reconfig(
ivas_mc_paramupmix_dec_close( &( st_ivas->hMCParamUpmix ) );
}
if ( st_ivas->hLFE != NULL )
{
/* LFE handle */
ivas_lfe_dec_close( &( st_ivas->hLFE ) );
}
#endif
}
else if ( st_ivas->mc_mode == MC_MODE_MCMASA )
......@@ -1010,11 +1008,8 @@ static ivas_error ivas_mc_dec_reconfig(
}
#ifdef NONBE_FIX_722_MEMORY_LEAK_IN_PARAMUPMIX
if ( st_ivas->hLFE != NULL )
{
/* LFE handle */
ivas_lfe_dec_close( &( st_ivas->hLFE ) );
}
#endif
}
......@@ -1063,7 +1058,6 @@ static ivas_error ivas_mc_dec_reconfig(
if ( st->hHQ_core == NULL )
{
if ( ( st->hHQ_core = (HQ_DEC_HANDLE) malloc( sizeof( HQ_DEC_DATA ) ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HQ core\n" ) );
......@@ -1127,7 +1121,6 @@ static ivas_error ivas_mc_dec_reconfig(
}
}
/*-----------------------------------------------------------------*
* re-configure HP20 memories
*-----------------------------------------------------------------*/
......@@ -1137,10 +1130,10 @@ static ivas_error ivas_mc_dec_reconfig(
return error;
}
/*-----------------------------------------------------------------*
* Allocate the LFE handle that is coded separately after the allocation of the core coders
*-----------------------------------------------------------------*/
if ( ( st_ivas->mc_mode == MC_MODE_MCT || st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) && st_ivas->hLFE == NULL )
{
int32_t binauralization_delay_ns = st_ivas->binaural_latency_ns;
......@@ -1226,12 +1219,12 @@ static ivas_error ivas_mc_dec_reconfig(
if ( ( st_ivas->hCrendWrapper != NULL ) && ( st_ivas->hCrendWrapper->hCrend != NULL ) && ( st_ivas->renderer_type != RENDERER_BINAURAL_MIXER_CONV && st_ivas->renderer_type != RENDERER_BINAURAL_MIXER_CONV_ROOM && ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD || st_ivas->hIntSetup.output_config != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) )
#endif
{
ivas_rend_closeCrend( &( st_ivas->hCrendWrapper )
#ifdef SPLIT_REND_WITH_HEAD_ROT
,
st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses
ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ), st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses );
#else
ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) );
#endif
);
}
if ( st_ivas->hBinRendererTd != NULL && ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD ) )
......@@ -1272,12 +1265,11 @@ static ivas_error ivas_mc_dec_reconfig(
if ( st_ivas->hIntSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB )
{
if ( ( error = ivas_rend_initCrendWrapper( &st_ivas->hCrendWrapper
#ifdef SPLIT_REND_WITH_HEAD_ROT
,
1
if ( ( error = ivas_rend_initCrendWrapper( &st_ivas->hCrendWrapper, 1 ) ) != IVAS_ERR_OK )
#else
if ( ( error = ivas_rend_initCrendWrapper( &st_ivas->hCrendWrapper ) ) != IVAS_ERR_OK )
#endif
) ) != IVAS_ERR_OK )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend Wrapper\n" );
}
......@@ -1301,12 +1293,11 @@ static ivas_error ivas_mc_dec_reconfig(
}
else if ( st_ivas->hCrendWrapper == NULL && ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) )
{
if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs
#ifdef SPLIT_REND_WITH_HEAD_ROT
,
st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses
if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs, st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK )
#else
if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK )
#endif
) ) != IVAS_ERR_OK )
{
return error;
}
......@@ -1347,6 +1338,7 @@ static ivas_error ivas_mc_dec_reconfig(
/*-----------------------------------------------------------------*
* Reconfigure TC buffer
*-----------------------------------------------------------------*/
if ( st_ivas->hDecoderConfig->Opt_5ms == 1 )
{
int16_t tc_nchan_full_new;
......
......@@ -99,8 +99,7 @@ void ivas_mct_dec_mct(
/*first get core and overlap info for all channels*/
for ( ch = 0; ch < nchan; ch++ )
{
if (
hMCT->currBlockDataCnt && sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE )
if ( hMCT->currBlockDataCnt && sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE )
{
hMCT->mc_global_ild[ch] = get_next_indice( sts[0], SMDCT_GLOBAL_ILD_BITS );
}
......@@ -124,8 +123,7 @@ void ivas_mct_dec_mct(
for ( ch = 0; ch < nchan; ch++ )
{
if (
sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE )
if ( sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE )
{
nchan_active++;
}
......@@ -305,8 +303,7 @@ void mctStereoIGF_dec(
if ( sum_s( singleChEle, ( hMCT->nchan_out_woLFE ) ) != 0 )
{
for ( ch = 0; ch < ( hMCT->nchan_out_woLFE );
ch++ )
for ( ch = 0; ch < ( hMCT->nchan_out_woLFE ); ch++ )
{
if ( singleChEle[ch] )
{
......
......@@ -197,6 +197,7 @@ static void dec_prm_tcx_sidebits(
getTCXparam( st, st0, hm_cfg, param, 0, 0, ( ( ch > 0 ) && ( tnsSize ) && ( tnsSize[0] + tnsSize[1] > 0 ) ? tnsSize : NULL ), p_param, nTnsBitsTCX10, 0 );
st->side_bits_frame_channel = st0->next_bit_pos - start_bit_pos;
return;
}
......@@ -523,7 +524,6 @@ void ivas_mdct_core_invQ(
TONALMDCTCONC_NOISE_GEN_MODE noise_gen_mode_bfi;
push_wmops( "mdct_core_invQ" );
sts = hCPE->hCoreCoder;
bfi = sts[0]->bfi;
noise_gen_mode_bfi = NOISE_GEN_MODE_UNDEF;
......@@ -1043,8 +1043,7 @@ void ivas_mdct_core_tns_ns(
L_frameTCX_glob[ch] = st->hTcxDec->L_frameTCX / nSubframes[ch];
L_spec[ch] = st->hTcxCfg->tcx_coded_lines / nSubframes[ch];
if (
( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) || ( st->bfi && st->core == ACELP_CORE ) ) /* indicates LFE with no content, or odd number of channels */
if ( ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) || ( st->bfi && st->core == ACELP_CORE ) ) /* indicates LFE with no content, or odd number of channels */
{
if ( st->hTonalMDCTConc != NULL )
{
......
......@@ -187,6 +187,7 @@ void ivas_mono_stereo_downmix_mcmasa(
return;
}
#ifdef FIX_764_HARM_CODE
/*-------------------------------------------------------------------------
* ivas_apply_non_diegetic_panning()
......
......@@ -82,9 +82,7 @@ ivas_error ivas_td_binaural_renderer(
int16_t ism_md_subframe_update;
int16_t nchan_transport;
nchan_transport = ( st_ivas->ism_mode == ISM_MASA_MODE_DISC || st_ivas->ism_mode == ISM_SBA_MODE_DISC )
? st_ivas->nchan_ism
: st_ivas->nchan_transport;
nchan_transport = ( st_ivas->ism_mode == ISM_MASA_MODE_DISC || st_ivas->ism_mode == ISM_SBA_MODE_DISC ) ? st_ivas->nchan_ism : st_ivas->nchan_transport;
if ( st_ivas->hDecoderConfig->Opt_delay_comp )
{
......@@ -100,18 +98,11 @@ ivas_error ivas_td_binaural_renderer(
ism_md_subframe_update = 2;
}
return ivas_td_binaural_renderer_unwrap(
st_ivas->hReverb,
st_ivas->transport_config,
st_ivas->hBinRendererTd,
nchan_transport,
LFE_CHANNEL, st_ivas->ivas_format,
st_ivas->hIsmMetaData,
return ivas_td_binaural_renderer_unwrap( st_ivas->hReverb, st_ivas->transport_config, st_ivas->hBinRendererTd, nchan_transport, LFE_CHANNEL, st_ivas->ivas_format, st_ivas->hIsmMetaData,
( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->enableCombinedOrientation : NULL,
( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->Quaternions : NULL,
( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->listenerPos : NULL,
ism_md_subframe_update, output, output_frame,
MAX_PARAM_SPATIAL_SUBFRAMES );
ism_md_subframe_update, output, output_frame, MAX_PARAM_SPATIAL_SUBFRAMES );
}
......@@ -216,14 +207,20 @@ ivas_error ivas_td_binaural_renderer_sf(
}
if ( subframe_idx == ism_md_subframe_update_jbm )
{
TDREND_Update_object_positions( st_ivas->hBinRendererTd, nchan_ism, st_ivas->ivas_format, st_ivas->hIsmMetaData );
if ( ( error = TDREND_Update_object_positions( st_ivas->hBinRendererTd, nchan_ism, st_ivas->ivas_format, st_ivas->hIsmMetaData ) ) != IVAS_ERR_OK )
{
return error;
}
}
/* Update the listener's location/orientation */
TDREND_Update_listener_orientation( st_ivas->hBinRendererTd,
if ( ( error = TDREND_Update_listener_orientation( st_ivas->hBinRendererTd,
( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->enableCombinedOrientation[subframe_idx] : 0,
( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->Quaternions : NULL,
( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->listenerPos : NULL );
( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->listenerPos : NULL ) ) != IVAS_ERR_OK )
{
return error;
}
if ( st_ivas->hRenderConfig != NULL && st_ivas->hIntSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB )
{
......
......@@ -92,7 +92,6 @@ ivas_error ivas_omasa_data_open(
hMasaIsmData->q_azimuth_old[ch] = 0.0f;
}
for ( obj_idx = 0; obj_idx < MAX_NUM_OBJECTS; obj_idx++ )
{
set_s( hMasaIsmData->azimuth_ism[obj_idx], 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR );
......@@ -154,7 +153,7 @@ void ivas_omasa_data_close(
ivas_error ivas_omasa_dec_config(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */
#if defined SPLIT_REND_WITH_HEAD_ROT
#ifdef SPLIT_REND_WITH_HEAD_ROT
const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */
void *data /* o : output synthesis signal */
#else
......@@ -202,11 +201,11 @@ ivas_error ivas_omasa_dec_config(
{
st_ivas->hCPE[0]->nchan_out = 1;
}
else if ( ( error = ivas_masa_dec_reconfigure( st_ivas, nSamplesRendered,
#if defined SPLIT_REND_WITH_HEAD_ROT
pcm_resolution,
#ifdef SPLIT_REND_WITH_HEAD_ROT
else if ( ( error = ivas_masa_dec_reconfigure( st_ivas, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK )
#else
else if ( ( error = ivas_masa_dec_reconfigure( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK )
#endif
data ) ) != IVAS_ERR_OK )
{
return error;
}
......@@ -632,8 +631,7 @@ void ivas_omasa_dirac_rend(
dirac_read_idx = st_ivas->hSpatParamRendCom->dirac_read_idx;
ivas_dirac_dec( st_ivas, output, st_ivas->nchan_transport,
MAX_PARAM_SPATIAL_SUBFRAMES );
ivas_dirac_dec( st_ivas, output, st_ivas->nchan_transport, MAX_PARAM_SPATIAL_SUBFRAMES );
st_ivas->hSpatParamRendCom->dirac_read_idx = dirac_read_idx; /* Original read index is needed for the next function which will update it again */
......@@ -706,8 +704,7 @@ ivas_error ivas_omasa_dirac_td_binaural(
delay_signal( data_separated_objects[n], output_frame, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size );
}
ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, output, st_ivas->nchan_transport,
MAX_PARAM_SPATIAL_SUBFRAMES );
ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, output, st_ivas->nchan_transport, MAX_PARAM_SPATIAL_SUBFRAMES );
if ( ( error = ivas_td_binaural_renderer( st_ivas, p_sepobj, output_frame ) ) != IVAS_ERR_OK )
{
......
......@@ -43,6 +43,81 @@
#include "wmc_auto.h"
#ifdef FIX_782_OSBA_FUNCTION_NAMES
/*-------------------------------------------------------------------*
* ivas_osba_data_open()
*
* Allocate and initialize SBA_ISM rendering handle
*-------------------------------------------------------------------*/
ivas_error ivas_osba_data_open(
Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */
)
{
SBA_ISM_DATA_HANDLE hSbaIsmData;
int16_t i;
if ( ( hSbaIsmData = (SBA_ISM_DATA_HANDLE) malloc( sizeof( SBA_ISM_DATA ) ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for OSBA data\n" ) );
}
hSbaIsmData->delayBuffer_nchan = st_ivas->nchan_ism;
hSbaIsmData->delayBuffer_size = (int16_t) ( ( st_ivas->hDecoderConfig->output_Fs / 50 ) / MAX_PARAM_SPATIAL_SUBFRAMES );
if ( ( hSbaIsmData->delayBuffer = (float **) malloc( hSbaIsmData->delayBuffer_nchan * sizeof( float * ) ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for OSBA delay buffer \n" ) );
}
for ( i = 0; i < hSbaIsmData->delayBuffer_nchan; i++ )
{
if ( ( hSbaIsmData->delayBuffer[i] = (float *) malloc( hSbaIsmData->delayBuffer_size * sizeof( float ) ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for OSBA delay buffer \n" ) );
}
set_zero( hSbaIsmData->delayBuffer[i], hSbaIsmData->delayBuffer_size );
}
st_ivas->hSbaIsmData = hSbaIsmData;
return IVAS_ERR_OK;
}
/*-------------------------------------------------------------------*
* ivas_osba_data_close()
*
* Deallocate SBA_ISM rendering handle
*-------------------------------------------------------------------*/
void ivas_osba_data_close(
SBA_ISM_DATA_HANDLE *hSbaIsmData /* i/o: OSBA rendering handle */
)
{
int16_t i;
if ( hSbaIsmData == NULL || *hSbaIsmData == NULL )
{
return;
}
if ( ( *hSbaIsmData )->delayBuffer != NULL )
{
for ( i = 0; i < ( *hSbaIsmData )->delayBuffer_nchan; i++ )
{
free( ( *hSbaIsmData )->delayBuffer[i] );
}
free( ( *hSbaIsmData )->delayBuffer );
( *hSbaIsmData )->delayBuffer = NULL;
}
free( *hSbaIsmData );
*hSbaIsmData = NULL;
return;
}
#else
/*-------------------------------------------------------------------*
* ivas_masa_ism_data_open()
*
......@@ -65,6 +140,8 @@ ivas_error ivas_masa_ism_data_open(
return IVAS_ERR_OK;
}
/*-------------------------------------------------------------------*
* ivas_masa_ism_data_close()
*
......@@ -127,15 +204,15 @@ ivas_error ivas_sba_ism_separate_object_renderer_open(
set_zero( st_ivas->hMasaIsmData->delayBuffer[i], st_ivas->hMasaIsmData->delayBuffer_size );
}
return IVAS_ERR_OK;
}
#endif
/*--------------------------------------------------------------------------*
* ivas_osba_dirac_td_binaural()
*
* Binaural rendering in OMASA format
* Binaural rendering in OSBA format
*--------------------------------------------------------------------------*/
ivas_error ivas_osba_dirac_td_binaural(
......@@ -146,7 +223,6 @@ ivas_error ivas_osba_dirac_td_binaural(
{
int16_t n;
float data_separated_objects[MAX_NUM_OBJECTS][L_FRAME48k];
ivas_error error;
float *p_sepobj[MAX_NUM_OBJECTS];
int16_t channel_offset;
......@@ -164,13 +240,16 @@ ivas_error ivas_osba_dirac_td_binaural(
}
#ifdef OSBA_SPLIT_RENDERING
if ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED &&
st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
if ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
#endif
{
for ( n = 0; n < st_ivas->nchan_ism; n++ )
{
#ifdef FIX_782_OSBA_FUNCTION_NAMES
delay_signal( data_separated_objects[n], output_frame, st_ivas->hSbaIsmData->delayBuffer[n], st_ivas->hSbaIsmData->delayBuffer_size );
#else
delay_signal( data_separated_objects[n], output_frame, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size );
#endif
}
}
......@@ -183,8 +262,7 @@ ivas_error ivas_osba_dirac_td_binaural(
}
else
{
ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, &output[channel_offset], st_ivas->nchan_transport,
MAX_PARAM_SPATIAL_SUBFRAMES );
ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, &output[channel_offset], st_ivas->nchan_transport, MAX_PARAM_SPATIAL_SUBFRAMES );
}
#ifdef DEBUG_OSBA
......@@ -200,8 +278,7 @@ ivas_error ivas_osba_dirac_td_binaural(
}
#endif
#ifdef OSBA_SPLIT_RENDERING
if ( ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ||
( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
{
int16_t slot_idx, num_cldfb_bands, b, nchan_transport_orig;
float Cldfb_RealBuffer[CLDFB_NO_CHANNELS_MAX];
......@@ -266,6 +343,12 @@ ivas_error ivas_osba_dirac_td_binaural(
}
/*-------------------------------------------------------------------------*
* ivas_osba_ism_metadata_dec()
*
* ISM metadata decoding in OSBA format.
*-------------------------------------------------------------------------*/
ivas_error ivas_osba_ism_metadata_dec(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
const int32_t ism_total_brate, /* i : ISM total bitrate */
......@@ -280,7 +363,6 @@ ivas_error ivas_osba_ism_metadata_dec(
nchan_transport_ism = st_ivas->nchan_ism;
*nchan_ism = st_ivas->nchan_ism;
/* decode ISM metadata */
if ( ( error = ivas_ism_metadata_dec( ism_total_brate, *nchan_ism, &nchan_transport_ism, st_ivas->hIsmMetaData, NULL, st_ivas->bfi,
nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hCPE[0]->hCoreCoder[0] ) ) != IVAS_ERR_OK )
......@@ -291,6 +373,7 @@ ivas_error ivas_osba_ism_metadata_dec(
return IVAS_ERR_OK;
}
/*-------------------------------------------------------------------------*
* ivas_osba_render()
*
......@@ -329,7 +412,11 @@ ivas_error ivas_osba_render(
for ( n = 0; n < nchan_ism; n++ )
{
mvr2r( output_f[n], tmp_ism_out[n], output_frame );
#ifdef FIX_782_OSBA_FUNCTION_NAMES
delay_signal( tmp_ism_out[n], output_frame, st_ivas->hSbaIsmData->delayBuffer[n], st_ivas->hSbaIsmData->delayBuffer_size );
#else
delay_signal( tmp_ism_out[n], output_frame, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size );
#endif
}
if ( st_ivas->renderer_type == RENDERER_OSBA_AMBI )
......
......@@ -1124,6 +1124,7 @@ void ivas_ls_setup_conversion_process_mdct_param_mc(
return;
}
/*-------------------------------------------------------------------------
* ivas_ls_setup_conversion_process_param_mc()
*
......@@ -1149,7 +1150,6 @@ void ivas_lssetupconversion_process_param_mc(
LSSETUP_CONVERSION_HANDLE hLsSetUpConversion;
push_wmops( "LS_Renderer_Process_Param_MC" );
/* inits */
inChannels = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe;
outChannels = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe;
......@@ -1197,7 +1197,6 @@ void ivas_lssetupconversion_process_param_mc(
Cldfb_RealBuffer_InOut[chOutIdx][slotIdx][bandIdx] += tmpDMXSig;
targetEnergy[chOutIdx][bandIdx] += tmpDMXSig * tmpDMXSig;
tmpDMXSig = dmxCoeff * Cldfb_ImagBuffer_tmp[chInIdx][bandIdx];
Cldfb_ImagBuffer_InOut[chOutIdx][slotIdx][bandIdx] += tmpDMXSig;
targetEnergy[chOutIdx][bandIdx] += tmpDMXSig * tmpDMXSig;
......
......@@ -362,8 +362,7 @@ void ivas_renderer_select(
*renderer_type = RENDERER_DIRAC;
ivas_format = ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_NONE ) ? SBA_FORMAT : st_ivas->ivas_format; /* treat ISM_SBA_MODE_NONE just like SBA_FORMAT */
if ( ivas_format == SBA_FORMAT &&
( output_config != IVAS_AUDIO_CONFIG_5_1 && output_config != IVAS_AUDIO_CONFIG_5_1_2 && output_config != IVAS_AUDIO_CONFIG_5_1_4 && output_config != IVAS_AUDIO_CONFIG_7_1 && output_config != IVAS_AUDIO_CONFIG_7_1_4 && output_config != IVAS_AUDIO_CONFIG_LS_CUSTOM && output_config != IVAS_AUDIO_CONFIG_MONO && output_config != IVAS_AUDIO_CONFIG_STEREO ) )
if ( ivas_format == SBA_FORMAT && ( output_config != IVAS_AUDIO_CONFIG_5_1 && output_config != IVAS_AUDIO_CONFIG_5_1_2 && output_config != IVAS_AUDIO_CONFIG_5_1_4 && output_config != IVAS_AUDIO_CONFIG_7_1 && output_config != IVAS_AUDIO_CONFIG_7_1_4 && output_config != IVAS_AUDIO_CONFIG_LS_CUSTOM && output_config != IVAS_AUDIO_CONFIG_MONO && output_config != IVAS_AUDIO_CONFIG_STEREO ) )
{
if ( output_config == IVAS_AUDIO_CONFIG_HOA2 || output_config == IVAS_AUDIO_CONFIG_FOA )
{
......@@ -481,6 +480,7 @@ void ivas_renderer_select(
else if ( st_ivas->mc_mode == MC_MODE_MCMASA )
{
*internal_config = output_config;
/* No rendering for 1TC to Mono or Stereo and 2TC to Stereo */
if ( output_config == IVAS_AUDIO_CONFIG_MONO || output_config == IVAS_AUDIO_CONFIG_STEREO )
{
......
......@@ -200,7 +200,6 @@ void stereo_dft_dec_core_switching(
#if defined( DEBUG_MODE_DFT ) && defined( DEBUG_STEREO_DFT_NOCORE )
stereo_dft_dec_analyze( hCPE, output, DFT, 0, output_frame, output_frame, DFT_STEREO_DEC_ANA_NOCORE, 0, 0 );
#else
/* resample DFT analysis memories in case of internal sampling rate change */
if ( st->last_L_frame != st->L_frame && st->last_L_frame <= L_FRAME16k && st->L_frame <= L_FRAME16k )
{
......@@ -442,7 +441,6 @@ void stereo_dft_dec_core_switching(
}
#endif
/*----------------------------------------------------------------*
* enhanced stereo filling: allpass filter
*----------------------------------------------------------------*/
......
......@@ -55,7 +55,6 @@ static int16_t ivas_qmetadata_raw_decode_dir( IVAS_QDIRECTION *q_direction, uint
static uint16_t ivas_qmetadata_DecodeQuasiUniform( const uint16_t *bitstream, int16_t *index, const uint16_t alphabet_size );
static int16_t ivas_qmetadata_ReorderElevationDecoded( const int16_t elev_dist, const int16_t elev_avg, const int16_t elev_alph );
static int16_t read_directions( IVAS_QDIRECTION *q_direction, const uint8_t coding_subbands, const uint8_t masa_subframes, uint16_t *bitstream, int16_t *pbit_pos, int16_t *ind_order );
......@@ -548,7 +547,6 @@ int16_t ivas_qmetadata_dec_decode(
#ifdef DEBUGGING
assert( ( diff_bits <= 0 ) || ( q_direction->not_in_2D == 0 ) );
#endif
/* Read raw-coded bits*/
for ( b = start_band; b < nbands; b++ )
{
......@@ -1075,7 +1073,6 @@ int16_t ivas_qmetadata_dec_decode_hr_384_512(
/* move 2 dir data to its correct subband */
if ( bits_sph_idx == 11 )
{
int16_t nblocks;
d = hQMetaData->q_direction[1].cfg.nbands - 1;
nblocks = hQMetaData->q_direction[0].cfg.nblocks;
......@@ -1316,7 +1313,6 @@ int16_t ivas_qmetadata_dec_sid_decode(
}
else
{
/* Decode diffuseness*/
for ( b = start_band; b < nbands; b++ )
{
......@@ -1351,9 +1347,7 @@ int16_t ivas_qmetadata_dec_sid_decode(
q_direction->band_data[b].spherical_index[i] = value;
}
deindex_spherical_component( q_direction->band_data[b].spherical_index[0], &avg_azimuth, &avg_elevation,
&q_direction->band_data[b].azimuth_index[0], &q_direction->band_data[b].elevation_index[0], q_direction->band_data[b].bits_sph_idx[0],
q_direction->cfg.mc_ls_setup );
deindex_spherical_component( q_direction->band_data[b].spherical_index[0], &avg_azimuth, &avg_elevation, &q_direction->band_data[b].azimuth_index[0], &q_direction->band_data[b].elevation_index[0], q_direction->band_data[b].bits_sph_idx[0], q_direction->cfg.mc_ls_setup );
ivas_qmetadata_azimuth_elevation_to_direction_vector( avg_azimuth, avg_elevation, avg_direction_vector );
ivas_qmetadata_azimuth_elevation_to_direction_vector( q_direction->band_data[b].azimuth[nblocks - 1], q_direction->band_data[b].elevation[nblocks - 1], direction_vector );
......@@ -1982,8 +1976,7 @@ static int16_t ivas_qmetadata_entropy_decode_dir(
}
/*decode elevation*/
q_direction->band_data[b].elevation[m] = deindex_elevation( &q_direction->band_data[b].elevation_index[m], q_direction->band_data[b].bits_sph_idx[m],
q_direction->cfg.mc_ls_setup );
q_direction->band_data[b].elevation[m] = deindex_elevation( &q_direction->band_data[b].elevation_index[m], q_direction->band_data[b].bits_sph_idx[m], q_direction->cfg.mc_ls_setup );
}
}
}
......@@ -2047,8 +2040,7 @@ static int16_t ivas_qmetadata_entropy_decode_dir(
}
/*decode elevation*/
q_direction->band_data[b].elevation[m] = deindex_elevation( &q_direction->band_data[b].elevation_index[m], q_direction->band_data[b].bits_sph_idx[m],
q_direction->cfg.mc_ls_setup );
q_direction->band_data[b].elevation[m] = deindex_elevation( &q_direction->band_data[b].elevation_index[m], q_direction->band_data[b].bits_sph_idx[m], q_direction->cfg.mc_ls_setup );
}
}
}
......@@ -2084,8 +2076,7 @@ static int16_t ivas_qmetadata_entropy_decode_dir(
}
/*decode elevation*/
q_direction->band_data[b].elevation[m] = deindex_elevation( &q_direction->band_data[b].elevation_index[m], q_direction->band_data[b].bits_sph_idx[m],
q_direction->cfg.mc_ls_setup );
q_direction->band_data[b].elevation[m] = deindex_elevation( &q_direction->band_data[b].elevation_index[m], q_direction->band_data[b].bits_sph_idx[m], q_direction->cfg.mc_ls_setup );
}
}
}
......@@ -2114,10 +2105,7 @@ static int16_t ivas_qmetadata_entropy_decode_dir(
}
else
{
q_direction->band_data[b].azimuth[m] = deindex_azimuth( q_direction->band_data[b].azimuth_index[m],
q_direction->band_data[b].bits_sph_idx[m],
q_direction->band_data[b].elevation_index[m], 0,
q_direction->cfg.mc_ls_setup );
q_direction->band_data[b].azimuth[m] = deindex_azimuth( q_direction->band_data[b].azimuth_index[m], q_direction->band_data[b].bits_sph_idx[m], q_direction->band_data[b].elevation_index[m], 0, q_direction->cfg.mc_ls_setup );
}
}
}
......@@ -2150,10 +2138,7 @@ static int16_t ivas_qmetadata_entropy_decode_dir(
}
else
{
q_direction->band_data[b].azimuth[m] = deindex_azimuth( q_direction->band_data[b].azimuth_index[m],
q_direction->band_data[b].bits_sph_idx[m],
q_direction->band_data[b].elevation_index[m], 0,
q_direction->cfg.mc_ls_setup );
q_direction->band_data[b].azimuth[m] = deindex_azimuth( q_direction->band_data[b].azimuth_index[m], q_direction->band_data[b].bits_sph_idx[m], q_direction->band_data[b].elevation_index[m], 0, q_direction->cfg.mc_ls_setup );
}
if ( ( q_direction->cfg.mc_ls_setup != MC_LS_SETUP_INVALID ) && ( nblocks > 1 ) )
{
......@@ -2228,9 +2213,7 @@ static int16_t ivas_qmetadata_raw_decode_dir_512(
}
else
{
deindex_spherical_component( q_direction->band_data[b].spherical_index[m], &q_direction->band_data[b].azimuth[m], &q_direction->band_data[b].elevation[m],
&q_direction->band_data[b].azimuth_index[m], &q_direction->band_data[b].elevation_index[m], q_direction->band_data[b].bits_sph_idx[m],
q_direction->cfg.mc_ls_setup );
deindex_spherical_component( q_direction->band_data[b].spherical_index[m], &q_direction->band_data[b].azimuth[m], &q_direction->band_data[b].elevation[m], &q_direction->band_data[b].azimuth_index[m], &q_direction->band_data[b].elevation_index[m], q_direction->band_data[b].bits_sph_idx[m], q_direction->cfg.mc_ls_setup );
}
}
}
......@@ -2285,8 +2268,7 @@ static int16_t ivas_qmetadata_raw_decode_dir(
q_direction->band_data[b].elevation_index[m] = 0;
azith_alph = no_phi_masa[bits_direction_masa[diff_idx] - 1][0];
q_direction->band_data[b].azimuth_index[m] = ivas_qmetadata_DecodeQuasiUniform( bitstream, index, azith_alph );
q_direction->band_data[b].azimuth[m] = deindex_azimuth( q_direction->band_data[b].azimuth_index[m], q_direction->band_data[b].bits_sph_idx[m], 0, 1,
q_direction->cfg.mc_ls_setup );
q_direction->band_data[b].azimuth[m] = deindex_azimuth( q_direction->band_data[b].azimuth_index[m], q_direction->band_data[b].bits_sph_idx[m], 0, 1, q_direction->cfg.mc_ls_setup );
}
}
}
......@@ -2343,8 +2325,7 @@ static uint16_t ivas_qmetadata_DecodeQuasiUniform(
*------------------------------------------------------------------------*/
/*! r: Value decoded from the bitstream */
int16_t
ivas_qmetadata_DecodeExtendedGR(
int16_t ivas_qmetadata_DecodeExtendedGR(
uint16_t *bitstream, /* i : pointer to the bitstream to read */
int16_t *index, /* i/o: position in the bitstream to start reading (gets updated with reading) */
const int16_t alph_size, /* i : size of the alphabet, used to calculate the number of bits needed */
......@@ -2733,13 +2714,9 @@ static int16_t decode_azimuth(
}
else
{
q_direction->band_data[idx_subband].azimuth_index[k] = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos,
q_direction->band_data[idx_subband].azimuth_m_alphabet[k], MASA_GR_ORD_AZ - ( q_direction->band_data[idx_subband].bits_sph_idx[k] == 2 ) );
q_direction->band_data[idx_subband].azimuth_index[k] = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, q_direction->band_data[idx_subband].azimuth_m_alphabet[k], MASA_GR_ORD_AZ - ( q_direction->band_data[idx_subband].bits_sph_idx[k] == 2 ) );
q_direction->band_data[idx_subband].azimuth[k] = deindex_azimuth( q_direction->band_data[idx_subband].azimuth_index[k],
q_direction->band_data[idx_subband].bits_sph_idx[k],
q_direction->band_data[idx_subband].elevation_index[k], 1,
q_direction->cfg.mc_ls_setup );
q_direction->band_data[idx_subband].azimuth[k] = deindex_azimuth( q_direction->band_data[idx_subband].azimuth_index[k], q_direction->band_data[idx_subband].bits_sph_idx[k], q_direction->band_data[idx_subband].elevation_index[k], 1, q_direction->cfg.mc_ls_setup );
}
}
}
......@@ -2760,12 +2737,8 @@ static int16_t decode_azimuth(
{
if ( no_phi_masa[q_direction->band_data[idx_subband].bits_sph_idx[k] - 1][q_direction->band_data[idx_subband].elevation_index[k]] > 1 )
{
q_direction->band_data[idx_subband].azimuth_index[k] = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos,
q_direction->band_data[idx_subband].azimuth_m_alphabet[k], MASA_GR_ORD_AZ - byteBuffer );
q_direction->band_data[idx_subband].azimuth[k] = deindex_azimuth( q_direction->band_data[idx_subband].azimuth_index[k],
q_direction->band_data[idx_subband].bits_sph_idx[k],
q_direction->band_data[idx_subband].elevation_index[k], 1,
q_direction->cfg.mc_ls_setup );
q_direction->band_data[idx_subband].azimuth_index[k] = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, q_direction->band_data[idx_subband].azimuth_m_alphabet[k], MASA_GR_ORD_AZ - byteBuffer );
q_direction->band_data[idx_subband].azimuth[k] = deindex_azimuth( q_direction->band_data[idx_subband].azimuth_index[k], q_direction->band_data[idx_subband].bits_sph_idx[k], q_direction->band_data[idx_subband].elevation_index[k], 1, q_direction->cfg.mc_ls_setup );
}
else
{
......@@ -2795,13 +2768,9 @@ static int16_t decode_azimuth(
{
if ( no_phi_masa[q_direction->band_data[idx_subband].bits_sph_idx[k] - 1][q_direction->band_data[idx_subband].elevation_index[k]] > 1 )
{
q_direction->band_data[idx_subband].azimuth_index[k] = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos,
q_direction->band_data[idx_subband].azimuth_m_alphabet[k], MASA_GR_ORD_AZ - 1 - byteBuffer );
q_direction->band_data[idx_subband].azimuth_index[k] = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, q_direction->band_data[idx_subband].azimuth_m_alphabet[k], MASA_GR_ORD_AZ - 1 - byteBuffer );
q_direction->band_data[idx_subband].azimuth_index[k] += min_idx;
q_direction->band_data[idx_subband].azimuth[k] = deindex_azimuth( q_direction->band_data[idx_subband].azimuth_index[k],
q_direction->band_data[idx_subband].bits_sph_idx[k],
q_direction->band_data[idx_subband].elevation_index[k], 1,
q_direction->cfg.mc_ls_setup );
q_direction->band_data[idx_subband].azimuth[k] = deindex_azimuth( q_direction->band_data[idx_subband].azimuth_index[k], q_direction->band_data[idx_subband].bits_sph_idx[k], q_direction->band_data[idx_subband].elevation_index[k], 1, q_direction->cfg.mc_ls_setup );
}
else
{
......@@ -2901,8 +2870,7 @@ static int16_t decode_elevation(
if ( q_direction->band_data[j].elevation_index[k] < MASA_NO_INDEX )
{
q_direction->band_data[j].elevation_index[k] = same_idx;
q_direction->band_data[j].elevation[k] = deindex_elevation( &q_direction->band_data[j].elevation_index[k], q_direction->band_data[j].bits_sph_idx[k],
q_direction->cfg.mc_ls_setup );
q_direction->band_data[j].elevation[k] = deindex_elevation( &q_direction->band_data[j].elevation_index[k], q_direction->band_data[j].bits_sph_idx[k], q_direction->cfg.mc_ls_setup );
}
}
}
......@@ -2917,8 +2885,7 @@ static int16_t decode_elevation(
if ( q_direction->band_data[j].elevation_index[k] < MASA_NO_INDEX )
{
q_direction->band_data[j].elevation_index[k] = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, q_direction->band_data[j].elevation_m_alphabet[k], GR_ord_elevation );
q_direction->band_data[j].elevation[k] = deindex_elevation( &q_direction->band_data[j].elevation_index[k], q_direction->band_data[j].bits_sph_idx[k],
q_direction->cfg.mc_ls_setup );
q_direction->band_data[j].elevation[k] = deindex_elevation( &q_direction->band_data[j].elevation_index[k], q_direction->band_data[j].bits_sph_idx[k], q_direction->cfg.mc_ls_setup );
}
}
}
......@@ -2986,9 +2953,7 @@ static int16_t decode_fixed_rate(
q_direction->band_data[b].spherical_index[m] = value;
nbits += q_direction->band_data[b].bits_sph_idx[m];
deindex_spherical_component( q_direction->band_data[b].spherical_index[m], &q_direction->band_data[b].azimuth[m], &q_direction->band_data[b].elevation[m],
&q_direction->band_data[b].azimuth_index[m], &q_direction->band_data[b].elevation_index[m], q_direction->band_data[b].bits_sph_idx[m],
q_direction->cfg.mc_ls_setup );
deindex_spherical_component( q_direction->band_data[b].spherical_index[m], &q_direction->band_data[b].azimuth[m], &q_direction->band_data[b].elevation[m], &q_direction->band_data[b].azimuth_index[m], &q_direction->band_data[b].elevation_index[m], q_direction->band_data[b].bits_sph_idx[m], q_direction->cfg.mc_ls_setup );
}
return nbits;
......@@ -3101,6 +3066,7 @@ static void set_zero_direction(
const int16_t len )
{
int16_t k;
for ( k = 0; k < len; k++ )
{
q_direction->band_data[idx_band].azimuth[k] = 0;
......@@ -3476,7 +3442,6 @@ static ivas_error read_huf(
return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong Huffman codeword for average index in coherence encoding." );
}
#endif
*num_bits_read = end_pos;
return IVAS_ERR_OK;
......@@ -3536,6 +3501,7 @@ static int16_t read_GR_min_removed_data(
decoded_idx[j] += min_index;
}
}
#ifdef DEBUGGING
assert( nbits == *p_bit_pos - bit_pos );
#endif
......@@ -3777,6 +3743,7 @@ static int16_t read_coherence_data(
#ifdef NONBE_FIX_760_COHERENCE_MASA
int16_t extra_cv;
#endif
coding_subbands = hQMetaData->q_direction[idx_dir].cfg.nbands;
#ifdef NONBE_FIX_760_COHERENCE_MASA
extra_cv = (int16_t) ( coding_subbands / MASA_FACTOR_CV_COH );
......
......@@ -40,11 +40,6 @@
#include "prot.h"
/*-----------------------------------------------------------------------*
* Local function prototypes
*-----------------------------------------------------------------------*/
/*-------------------------------------------------------------------*
* deindex_elevation()
*
......
......@@ -212,8 +212,7 @@ ivas_error ivas_sba_dec_reconfigure(
ivas_spar_md_dec_matrix_close( st_ivas->hSpar->hMdDec, num_channels );
num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order_internal, ivas_total_brate, st_ivas->last_active_ivas_total_brate );
if ( ( error = ivas_spar_md_dec_matrix_open( st_ivas->hSpar->hMdDec, num_channels,
num_md_sub_frames ) ) != IVAS_ERR_OK )
if ( ( error = ivas_spar_md_dec_matrix_open( st_ivas->hSpar->hMdDec, num_channels, num_md_sub_frames ) ) != IVAS_ERR_OK )
{
return error;
}
......@@ -289,12 +288,14 @@ ivas_error ivas_sba_dec_reconfigure(
{
ivas_binRenderer_close( &st_ivas->hBinRenderer );
}
#ifdef NONBE_FIX_736_FOA_BR_SWITCH
if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) ) ) != IVAS_ERR_OK )
{
return error;
}
#endif
#ifndef NONBE_FIX_736_FOA_BR_SWITCH
if ( ( ( st_ivas->renderer_type != RENDERER_DISABLE ) && ( st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC ) ) || ( ( hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_FOA ) && ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO ) && ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_MONO ) ) || ( last_ivas_total_brate > IVAS_256k && ivas_total_brate <= IVAS_256k ) || ( last_ivas_total_brate <= IVAS_256k && ivas_total_brate > IVAS_256k ) )
#else
......@@ -327,14 +328,6 @@ ivas_error ivas_sba_dec_reconfigure(
#ifdef NONBE_FIX_736_FOA_BR_SWITCH
else
{
#endif
#ifndef NONBE_FIX_736_FOA_BR_SWITCH
if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) ) ) != IVAS_ERR_OK )
{
return error;
}
#endif
#ifdef NONBE_FIX_736_FOA_BR_SWITCH
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 );
......@@ -350,12 +343,12 @@ ivas_error ivas_sba_dec_reconfigure(
st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0 );
}
#endif
if ( st_ivas->renderer_type == RENDERER_DISABLE )
{
ivas_dirac_rend_close( &( st_ivas->hDirACRend ) );
ivas_spat_hSpatParamRendCom_close( &( st_ivas->hSpatParamRendCom ) );
ivas_dirac_dec_close( &( st_ivas->hDirAC ) );
vbap_free_data( &( st_ivas->hVBAPdata ) );
}
......@@ -407,6 +400,13 @@ ivas_error ivas_sba_dec_reconfigure(
}
}
#ifdef FIX_782_OSBA_FUNCTION_NAMES
/* Allocate memory for OSBA delay buffer */
if ( ( error = ivas_osba_data_open( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
#else
if ( ( error = ivas_masa_ism_data_open( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
......@@ -417,6 +417,7 @@ ivas_error ivas_sba_dec_reconfigure(
{
return error;
}
#endif
#ifndef NONBE_FIX_752_OSBA_MISCONFIG_MCT
st_ivas->nchan_transport += st_ivas->nchan_ism;
......@@ -437,7 +438,7 @@ ivas_error ivas_sba_dec_reconfigure(
}
#endif
ivas_ism_metadata_close( st_ivas->hIsmMetaData, 0 );
ivas_masa_ism_data_close( &st_ivas->hMasaIsmData );
ivas_osba_data_close( &st_ivas->hSbaIsmData );
/* Time Domain binaural renderer handle */
if ( st_ivas->hBinRendererTd != NULL )
......@@ -524,6 +525,7 @@ ivas_error ivas_sba_dec_reconfigure(
/*-----------------------------------------------------------------*
* JBM TC buffer
*-----------------------------------------------------------------*/
if ( st_ivas->hDecoderConfig->Opt_5ms == 1 )
{
int16_t tc_nchan_to_allocate;
......@@ -596,6 +598,7 @@ ivas_error ivas_sba_dec_reconfigure(
return error;
}
/*-------------------------------------------------------------------*
* ivas_sba_dec_digest_tc()
*
......@@ -686,7 +689,7 @@ ivas_error ivas_sba_dec_digest_tc(
*
*-------------------------------------------------------------------*/
void ivas_sba_dec_render(
ivas_error ivas_sba_dec_render(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */
uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */
......@@ -700,6 +703,7 @@ void ivas_sba_dec_render(
SPAR_DEC_HANDLE hSpar;
SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom;
float *output_f_local[MAX_OUTPUT_CHANNELS];
ivas_error error;
hSpar = st_ivas->hSpar;
hSpatParamRendCom = st_ivas->hSpatParamRendCom;
......@@ -744,9 +748,10 @@ void ivas_sba_dec_render(
if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC )
{
ivas_sba_linear_renderer( output_f, *nSamplesRendered, st_ivas->hIntSetup.nchan_out_woLFE,
0,
st_ivas->hDecoderConfig->output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx );
if ( ( error = ivas_sba_linear_renderer( output_f, *nSamplesRendered, st_ivas->hIntSetup.nchan_out_woLFE, 0, st_ivas->hDecoderConfig->output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ) ) != IVAS_ERR_OK )
{
return error;
}
}
if ( st_ivas->hDirAC != NULL && hSpar->slots_rendered == hSpar->num_slots )
......@@ -763,5 +768,5 @@ void ivas_sba_dec_render(
*nSamplesAvailableNext = ( hSpar->num_slots - hSpar->slots_rendered ) * slot_size;
return;
return IVAS_ERR_OK;
}
......@@ -180,6 +180,7 @@ static int16_t ivas_sba_dirac_stereo_band_config(
return nbands;
}
static float get_panning(
const int16_t aziDeg,
const int16_t eleDeg )
......@@ -214,6 +215,7 @@ static float get_panning(
return panning;
}
/*-------------------------------------------------------------------*
* map_params_dirac_to_stereo()
*
......@@ -246,7 +248,6 @@ static void map_params_dirac_to_stereo(
float subframe_band_nrg[NB_DIV][SBA_DIRAC_STEREO_NUM_BANDS];
float smooth_long_avg[NB_DIV][SBA_DIRAC_STEREO_NUM_BANDS];
float smooth_short_avg[NB_DIV][SBA_DIRAC_STEREO_NUM_BANDS];
float *side_gain, *res_pred_gain;
IVAS_QDIRECTION *q_direction;
......@@ -877,22 +878,18 @@ void ivas_sba_dirac_stereo_dec(
}
/* mapping of DirAC parameters (azimuth, elevation, diffuseness) to DFT Stereo parameters (side gain, prediction gain) */
map_params_dirac_to_stereo( hStereoDft, st_ivas->hQMetaData, tmp_synth, DFT[0],
st_ivas->ivas_format == MC_FORMAT,
map_params_dirac_to_stereo( hStereoDft, st_ivas->hQMetaData, tmp_synth, DFT[0], st_ivas->ivas_format == MC_FORMAT,
( ( st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT ) || mcmasa ) ? hSCE->hCoreCoder[0]->L_frame : output_frame,
( ( st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT ) || mcmasa ) );
if ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && !mcmasa )
{
set_f( hStereoDft->res_pred_gain, 1.f, 3 * STEREO_DFT_BAND_MAX );
}
/* DFT Stereo upmix */
stereo_dft_dec( hStereoDft, hCPE->hCoreCoder[0], DFT, NULL, NULL, 1 /*st_ivas->sba_dirac_stereo_flag*/, sba_mono_flag,
( st_ivas->hSpar != NULL && !mcmasa ) ? st_ivas->hSpar->hMdDec : NULL,
( st_ivas->hSpar != NULL && !mcmasa ) ? st_ivas->hSpar->hFbMixer->cross_fade_start_offset : 0,
st_ivas->hDecoderConfig->output_Fs, st_ivas->nchan_transport,
ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate,
st_ivas->last_active_ivas_total_brate ) );
stereo_dft_dec( hStereoDft, hCPE->hCoreCoder[0], DFT, NULL, NULL, 1 /*st_ivas->sba_dirac_stereo_flag*/, sba_mono_flag, ( st_ivas->hSpar != NULL && !mcmasa ) ? st_ivas->hSpar->hMdDec : NULL, ( st_ivas->hSpar != NULL && !mcmasa ) ? st_ivas->hSpar->hFbMixer->cross_fade_start_offset : 0,
st_ivas->hDecoderConfig->output_Fs, st_ivas->nchan_transport, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ) );
/* DFT synthesis */
stereo_dft_dec_synthesize( hCPE, DFT, 0, output[0], output_frame );
......@@ -924,8 +921,7 @@ void ivas_sba_dirac_stereo_dec(
/* upmix ACELP BWE */
ivas_sba_dirac_stereo_compute_hb_gain( hStereoDft, hb_gain );
ivas_sba_dirac_stereo_upmix_hb( hb_synth_stereo, hSCE->save_hb_synth, hb_gain, output_frame,
( ( st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT ) || mcmasa ), sba_mono_flag, hSCE->hCoreCoder[0]->bwidth, hStereoDft );
ivas_sba_dirac_stereo_upmix_hb( hb_synth_stereo, hSCE->save_hb_synth, hb_gain, output_frame, ( ( st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT ) || mcmasa ), sba_mono_flag, hSCE->hCoreCoder[0]->bwidth, hStereoDft );
/* add HB to ACELP core */
v_add( output[0], hb_synth_stereo[0], output[0], output_frame );
......
......@@ -76,7 +76,6 @@ void ivas_sba2mc_cldfb(
int16_t nb_channels_in;
push_wmops( "ivas_sba2mc_cldfb" );
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!" );
......@@ -124,7 +123,6 @@ void ivas_sba2mc_cldfb(
}
pop_wmops();
return;
}
......@@ -152,7 +150,6 @@ void ivas_mc2sba(
int16_t sba_num_chans;
assert( ( sba_order <= 3 ) && "Only order up to 3 is supported!" );
/* Init*/
sba_num_chans = ( sba_order + 1 ) * ( sba_order + 1 );
for ( j = 0; j < sba_num_chans; j++ )
......@@ -212,6 +209,7 @@ void ivas_mc2sba(
return;
}
#ifdef NONBE_FIX_727_MC_PARAMUPMIX_HEADROTATION
/*-------------------------------------------------------------------------*
* ivas_param_mc_mc2sba_cldfb()
......@@ -289,6 +287,7 @@ void ivas_param_mc_mc2sba_cldfb(
}
#endif
/*-------------------------------------------------------------------*
* ivas_sba_remapTCs()
*
......@@ -731,8 +730,7 @@ void ivas_sba_mix_matrix_determiner(
/* Mixing matrix determiner */
num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands;
ivas_spar_dec_gen_umx_mat( hSpar->hMdDec, nchan_transport, num_bands_out, bfi,
num_md_sub_frames );
ivas_spar_dec_gen_umx_mat( hSpar->hMdDec, nchan_transport, num_bands_out, bfi, num_md_sub_frames );
return;
}
......
......@@ -129,7 +129,7 @@ static void sns_2st_dec(
void sns_avq_dec(
int16_t *index, /* i : Quantization indices */
float SNS_Q[NB_DIV][M], /* o : Quantized SNS vectors */
const int16_t L_frame,
const int16_t L_frame, /* i : frame length */
const int16_t numlpc /* i : Number of sets of lpc */
)
{
......@@ -194,7 +194,6 @@ void sns_avq_dec_stereo(
if ( stereo_mode == 2 )
{
/* MS coding */
sns_1st_dec( *indexl++, TCX_20_CORE, L_frame, mid_q );
sns_2st_dec( mid_q, indexl );
......@@ -217,7 +216,6 @@ void sns_avq_dec_stereo(
else
{
/* LR decoding */
sns_1st_dec( *indexl++, TCX_20_CORE, L_frame, SNS_Ql );
sns_2st_dec( SNS_Ql, indexl );
......
......@@ -52,7 +52,7 @@
* Local function prototypes
*--------------------------------------------------------------------*/
static void ivas_spar_dec_MD( Decoder_Struct *st_ivas, Decoder_State *st0 );
static ivas_error ivas_spar_dec_MD( Decoder_Struct *st_ivas, Decoder_State *st0 );
/*-------------------------------------------------------------------------
......@@ -72,7 +72,7 @@ ivas_error ivas_spar_dec_open(
IVAS_FB_CFG *fb_cfg;
int16_t i, j, b, active_w_mixing;
int32_t output_Fs;
int16_t num_decor_chs;
int16_t num_decor_chs, map_idx;
error = IVAS_ERR_OK;
sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER );
......@@ -114,9 +114,7 @@ ivas_error ivas_spar_dec_open(
}
/* MD handle */
if ( ( error = ivas_spar_md_dec_open( &hSpar->hMdDec, st_ivas->hDecoderConfig, num_channels_internal, sba_order_internal, st_ivas->sid_format,
st_ivas->last_active_ivas_total_brate /* i : IVAS last active bitrate */
) ) != IVAS_ERR_OK )
if ( ( error = ivas_spar_md_dec_open( &hSpar->hMdDec, st_ivas->hDecoderConfig, num_channels_internal, sba_order_internal, st_ivas->sid_format, st_ivas->last_active_ivas_total_brate ) ) != IVAS_ERR_OK )
{
return error;
}
......@@ -206,14 +204,11 @@ ivas_error ivas_spar_dec_open(
hSpar->num_slots = DEFAULT_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME;
/* init render timeslot mapping */
{
int16_t map_idx;
set_s( hSpar->render_to_md_map, 0, MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME );
for ( map_idx = 0; map_idx < DEFAULT_JBM_CLDFB_TIMESLOTS; map_idx++ )
{
hSpar->render_to_md_map[map_idx] = map_idx;
}
}
/* allocate transport channels*/
if (
......@@ -237,6 +232,7 @@ ivas_error ivas_spar_dec_open(
{
nchan_to_allocate = 2 * BINAURAL_CHANNELS;
}
if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK )
{
return error;
......@@ -314,7 +310,6 @@ ivas_error ivas_spar_dec(
ivas_error error;
push_wmops( "ivas_spar_decode" );
error = IVAS_ERR_OK;
hDecoderConfig = st_ivas->hDecoderConfig;
......@@ -346,6 +341,7 @@ ivas_error ivas_spar_dec(
{
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;
......@@ -367,7 +363,14 @@ ivas_error ivas_spar_dec(
st0->total_brate = hDecoderConfig->ivas_total_brate; /* to avoid BER detect */
}
ivas_spar_dec_MD( st_ivas, st0 );
/*---------------------------------------------------------------------*
* Decode SPAR metadata
*---------------------------------------------------------------------*/
if ( ( error = ivas_spar_dec_MD( st_ivas, st0 ) ) != IVAS_ERR_OK )
{
return error;
}
*nb_bits_read = st0->next_bit_pos + nb_bits_read_orig;
st0->bit_stream = bit_stream_orig;
......@@ -408,15 +411,13 @@ static int16_t ivas_get_spar_table_idx_from_coded_idx(
for ( i = 0; i < IVAS_SPAR_BR_TABLE_LEN; i++ )
{
ind1[j] = 0;
if ( ( ivas_spar_br_table_consts[i].ivas_total_brate == ivas_total_brate ) &&
( ivas_spar_br_table_consts[i].sba_order == sba_order ) )
if ( ( ivas_spar_br_table_consts[i].ivas_total_brate == ivas_total_brate ) && ( ivas_spar_br_table_consts[i].sba_order == sba_order ) )
{
ind1[j++] = i;
}
}
assert( j > 0 );
*bitlen = ivas_get_bits_to_encode( j - 1 );
ind2 = get_next_indice( st0, *bitlen );
......@@ -725,7 +726,7 @@ int16_t ivas_is_res_channel(
* IVAS SPAR MD decoder
*-------------------------------------------------------------------*/
static void ivas_spar_dec_MD(
static ivas_error ivas_spar_dec_MD(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
Decoder_State *st0 /* i/o: decoder state structure - for bitstream handling*/
)
......@@ -733,6 +734,7 @@ static void ivas_spar_dec_MD(
int16_t num_channels, table_idx, num_bands_out, bfi, sba_order;
int32_t ivas_total_brate;
int16_t num_md_sub_frames;
ivas_error error;
DECODER_CONFIG_HANDLE hDecoderConfig = st_ivas->hDecoderConfig;
SPAR_DEC_HANDLE hSpar = st_ivas->hSpar;
......@@ -746,8 +748,7 @@ static void ivas_spar_dec_MD(
bfi = st_ivas->bfi;
ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
num_channels = ivas_sba_get_nchan_metadata( sba_order, ivas_total_brate );
num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order, st_ivas->hDecoderConfig->ivas_total_brate,
st_ivas->last_active_ivas_total_brate );
num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order, hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate );
num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands;
......@@ -774,7 +775,10 @@ static void ivas_spar_dec_MD(
hSpar->hTdDecorr->ducking_flag = ivas_spar_br_table_consts[table_idx].td_ducking;
}
ivas_spar_md_dec_init( hSpar->hMdDec, hDecoderConfig, num_channels, sba_order );
if ( ( error = ivas_spar_md_dec_init( hSpar->hMdDec, hDecoderConfig, num_channels, sba_order ) ) != IVAS_ERR_OK )
{
return error;
}
}
}
......@@ -831,7 +835,7 @@ static void ivas_spar_dec_MD(
}
pop_wmops();
return;
return IVAS_ERR_OK;
}
......@@ -1193,8 +1197,10 @@ void ivas_spar_dec_set_render_map(
hSpar->num_slots = nCldfbTs;
hSpar->slots_rendered = 0;
hSpar->subframes_rendered = 0;
set_s( hSpar->render_to_md_map, 0, MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME );
ivas_jbm_dec_get_adapted_subframes( nCldfbTs, hSpar->subframe_nbslots, &hSpar->nb_subframes );
st_ivas->hTcBuffer->nb_subframes = hSpar->nb_subframes;
mvs2s( hSpar->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, hSpar->nb_subframes );
ivas_jbm_dec_get_md_map( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbTs, 1, 0, DEFAULT_JBM_CLDFB_TIMESLOTS, hSpar->render_to_md_map );
......@@ -1219,16 +1225,9 @@ void ivas_spar_dec_set_render_params(
int16_t num_bands_out;
hSpar = st_ivas->hSpar;
/*---------------------------------------------------------------------*
* Gen umx mat
*---------------------------------------------------------------------*/
nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport;
num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands;
ivas_spar_dec_gen_umx_mat( hSpar->hMdDec, nchan_transport, num_bands_out, st_ivas->bfi,
ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate,
st_ivas->last_active_ivas_total_brate ) );
ivas_spar_dec_gen_umx_mat( hSpar->hMdDec, nchan_transport, num_bands_out, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ) );
ivas_spar_dec_set_render_map( st_ivas, n_cldfb_slots );
......@@ -1461,8 +1460,7 @@ void ivas_spar_dec_upmixer_sf(
num_cldfb_bands = hSpar->hFbMixer->pFb->fb_bin_to_band.num_cldfb_bands;
numch_in = hSpar->hFbMixer->fb_cfg->num_in_chans;
numch_out = hSpar->hFbMixer->fb_cfg->num_out_chans;
num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, hDecoderConfig->ivas_total_brate,
st_ivas->last_active_ivas_total_brate );
num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate );
slot_size = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS );
slot_idx_start = hSpar->slots_rendered;
for ( i = 0; i < nchan_internal; i++ )
......
......@@ -90,6 +90,7 @@ static void ivas_spar_dec_parse_md_bs( ivas_spar_md_dec_state_t *hMdDec, Decoder
*
* Allocate and initialize SPAR MD decoder matrices
*------------------------------------------------------------------------*/
ivas_error ivas_spar_md_dec_matrix_open(
ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */
const int16_t num_channels, /* i : number of internal channels */
......@@ -351,6 +352,7 @@ ivas_error ivas_spar_md_dec_open(
*
* Deallocate SPAR MD decoder matrices
*------------------------------------------------------------------------*/
void ivas_spar_md_dec_matrix_close(
ivas_spar_md_dec_state_t *hMdDecoder, /* i/o: SPAR MD decoder handle */
const int16_t num_channels /* i : number of internal channels */
......@@ -500,6 +502,7 @@ ivas_error ivas_spar_md_dec_init(
int16_t i, j;
int16_t nchan_transport;
float pFC[IVAS_MAX_NUM_BANDS], PR_minmax[2];
ivas_error error;
ivas_sba_get_spar_hoa_md_flag( sba_order, hDecoderConfig->ivas_total_brate, &hMdDec->spar_hoa_md_flag, &hMdDec->spar_hoa_dirac2spar_md_flag );
......@@ -517,7 +520,10 @@ ivas_error ivas_spar_md_dec_init(
pFC[i] = ivas_fb_fcs_12band_1ms[i] * hDecoderConfig->output_Fs * 0.5f;
}
ivas_spar_set_dec_config( hMdDec, nchan_transport, pFC );
if ( ( error = ivas_spar_set_dec_config( hMdDec, nchan_transport, pFC ) ) != IVAS_ERR_OK )
{
return error;
}
if ( nchan_transport != 2 && ( ( hMdDec->spar_md_cfg.remix_unmix_order == 2 ) || ( hMdDec->spar_md_cfg.remix_unmix_order == 1 ) ) )
{
......@@ -629,6 +635,7 @@ static ivas_error ivas_spar_set_dec_config(
return IVAS_ERR_OK;
}
/*-----------------------------------------------------------------------------------------*
* Function ivas_dec_mono_sba_handling()
*
......@@ -663,6 +670,7 @@ static void ivas_dec_mono_sba_handling(
}
}
}
/* Combine the SPAR prediction coefs flag with the azimuth, elevation and energy ratio flag.*/
#ifdef NONBE_FIX_698_SBA_MSAN
mono_flag = mono_flag && ivas_spar_chk_zero_coefs( st_ivas );
......@@ -692,8 +700,11 @@ static void ivas_dec_mono_sba_handling(
}
}
}
return;
}
/*-----------------------------------------------------------------------------------------*
* Function ivas_spar_md_dec_process()
*
......@@ -720,9 +731,7 @@ void ivas_spar_md_dec_process(
num_md_chs = ivas_sba_get_nchan_metadata( sba_order, st_ivas->hDecoderConfig->ivas_total_brate );
num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order, st_ivas->hDecoderConfig->ivas_total_brate,
st_ivas->last_active_ivas_total_brate );
num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate );
if ( hMdDec->spar_md_cfg.nchan_transport > 1 && hMdDec->spar_md_cfg.nchan_transport <= 3 )
{
......@@ -762,8 +771,7 @@ void ivas_spar_md_dec_process(
/* SPAR to DirAC conversion */
if ( hMdDec->spar_hoa_dirac2spar_md_flag == 1 )
{
ivas_spar_to_dirac( st_ivas, hMdDec, dtx_vad, num_bands_out, bw,
dyn_active_w_flag );
ivas_spar_to_dirac( st_ivas, hMdDec, dtx_vad, num_bands_out, bw, dyn_active_w_flag );
}
/* set correct number of bands*/
......@@ -891,8 +899,7 @@ int16_t ivas_spar_chk_zero_coefs(
ndm = hMdDec->spar_md_cfg.num_dmx_chans_per_band[0];
#ifndef NONBE_FIX_698_SBA_MSAN
num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order, st_ivas->hDecoderConfig->ivas_total_brate,
st_ivas->last_active_ivas_total_brate );
num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate );
for ( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ )
{
#endif
......@@ -938,6 +945,7 @@ int16_t ivas_spar_chk_zero_coefs(
#ifndef NONBE_FIX_698_SBA_MSAN
}
#endif
return mono;
}
......@@ -1593,6 +1601,7 @@ 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 );
#ifdef NONBE_FIX_723_SBA_BR_SWITCH_MSAN
active_brate = ( ivas_total_brate > IVAS_SID_5k2 ) ? ivas_total_brate : last_active_brate;
......@@ -1842,6 +1851,7 @@ static void ivas_decode_arith_bs(
}
}
}
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 );
}
......@@ -1874,7 +1884,6 @@ static void ivas_decode_arith_bs(
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 );
}
ivas_arith_decode_cmplx_cell_array( &hMdDec->arith_coeffs.drct_arith_re[qsi], &hMdDec->arith_coeffs.drct_arith_re_diff[qsi],
st0, drct_cell_dims, pDo_diff, nB, symbol_arr_re, symbol_arr_old_re );
......@@ -2278,6 +2287,7 @@ static void ivas_parse_parameter_bitstream_dtx(
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;
pr_min_max[0] = pSpar_md->min_max[0];
pr_min_max[1] = pSpar_md->min_max[1];
......@@ -2458,6 +2468,7 @@ void ivas_spar_to_dirac(
int16_t active_w_vlbr;
int16_t i, num_subframes;
int16_t active_w;
SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom;
active_w = ( dyn_active_w_flag == 1 ) || ( hMdDec->spar_md_cfg.active_w == 1 );
sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER );
......@@ -2465,7 +2476,6 @@ void ivas_spar_to_dirac(
end_band = min( num_bands_out, SPAR_DIRAC_SPLIT_START_BAND ) / bw;
hDirAC = st_ivas->hDirAC;
SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom;
hSpatParamRendCom = st_ivas->hSpatParamRendCom;
dirac_to_spar_md_bands = st_ivas->hSpar->dirac_to_spar_md_bands;
......@@ -2637,9 +2647,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, ( hMdDec->spar_hoa_md_flag ) ? 1 : sba_order_internal, dtx_vad, NULL,
st_ivas->hQMetaData->useLowerRes, active_w_vlbr,
dyn_active_w_flag );
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, st_ivas->hQMetaData->useLowerRes, active_w_vlbr, dyn_active_w_flag );
/* temporarily copy frame-wise prediction coefficients in DirAC bands*/
for ( pred_idx = 0; pred_idx < FOA_CHANNELS - 1; pred_idx++ )
......@@ -2652,11 +2660,9 @@ void ivas_spar_to_dirac(
}
int16_t num_md_sub_frames;
num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order_internal, st_ivas->hDecoderConfig->ivas_total_brate,
st_ivas->last_active_ivas_total_brate );
ivas_get_spar_md_from_dirac( azi_dirac, ele_dirac, diffuseness, num_md_sub_frames, NULL, &hMdDec->spar_md, &hMdDec->spar_md_cfg,
end_band, num_bands_out / bw, ( hMdDec->spar_hoa_md_flag ) ? 1 : sba_order_internal, dtx_vad, NULL, st_ivas->hQMetaData->useLowerRes, active_w_vlbr,
dyn_active_w_flag );
num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order_internal, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate );
ivas_get_spar_md_from_dirac( azi_dirac, ele_dirac, diffuseness, num_md_sub_frames, NULL, &hMdDec->spar_md, &hMdDec->spar_md_cfg, end_band, num_bands_out / bw, ( hMdDec->spar_hoa_md_flag ) ? 1 : sba_order_internal, dtx_vad, NULL, st_ivas->hQMetaData->useLowerRes, active_w_vlbr, dyn_active_w_flag );
if ( st_ivas->hQMetaData->useLowerRes && dtx_vad )
{
for ( band = SPAR_DIRAC_SPLIT_START_BAND; band < IVAS_MAX_NUM_BANDS; band++ )
......@@ -2674,6 +2680,7 @@ void ivas_spar_to_dirac(
}
}
}
/* expand DirAC TC 20ms MD for residual channels to all subframes*/
for ( block = 0; block < num_md_sub_frames; block++ )
{
......