Skip to content
......@@ -2380,7 +2380,6 @@ void ivas_dirac_dec_render_sf(
if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM )
{
#ifdef OSBA_ROOM_IR
/* render objects in combined format onto the CICP19 channels for BINAURAL_ROOM_IR */
if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM )
......@@ -2395,6 +2394,7 @@ void ivas_dirac_dec_render_sf(
int16_t n_samples_to_render;
int16_t interp_offset;
float gain, prev_gain;
num_objects = st_ivas->nchan_ism;
nchan_out_woLFE = st_ivas->hIntSetup.nchan_out_woLFE;
n_slots_to_render = st_ivas->hSpar->subframe_nbslots[st_ivas->hSpar->subframes_rendered];
......@@ -2403,9 +2403,7 @@ void ivas_dirac_dec_render_sf(
if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] )
{
ivas_jbm_dec_get_adapted_linear_interpolator( n_samples_to_render,
n_samples_to_render,
st_ivas->hIsmRendererData->interpolator );
ivas_jbm_dec_get_adapted_linear_interpolator( n_samples_to_render, n_samples_to_render, st_ivas->hIsmRendererData->interpolator );
interp_offset = 0;
}
......@@ -2467,7 +2465,6 @@ void ivas_dirac_dec_render_sf(
}
#endif
#ifdef SPLIT_REND_WITH_HEAD_ROT
if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
{
......
......@@ -363,12 +363,11 @@ ivas_error ivas_dec_setup(
#ifdef JBM_FOR_OSBA
,
nSamplesRendered,
#if defined SPLIT_REND_WITH_HEAD_ROT
#ifdef SPLIT_REND_WITH_HEAD_ROT
pcm_resolution,
#endif
data
#endif
) ) != IVAS_ERR_OK )
{
return error;
......@@ -481,14 +480,13 @@ ivas_error ivas_dec_setup(
/* set Ambisonic (SBA) order used for analysis and coding */
st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order );
#endif
if ( st_ivas->ini_frame > 0 && ivas_total_brate != st_ivas->last_active_ivas_total_brate )
{
if ( ( error = ivas_sba_dec_reconfigure( st_ivas
#ifdef JBM_FOR_OSBA
,
nSamplesRendered,
#if defined SPLIT_REND_WITH_HEAD_ROT
#ifdef SPLIT_REND_WITH_HEAD_ROT
pcm_resolution,
#endif
data
......@@ -504,6 +502,7 @@ ivas_error ivas_dec_setup(
/* set Ambisonic (SBA) order used for analysis and coding */
st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order );
#endif
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 );
/*correct number of CPEs for discrete ISM coding*/
......@@ -632,7 +631,7 @@ ivas_error ivas_dec_setup(
#ifdef JBM_FOR_OSBA
,
nSamplesRendered,
#if defined SPLIT_REND_WITH_HEAD_ROT
#ifdef SPLIT_REND_WITH_HEAD_ROT
pcm_resolution,
#endif
data
......@@ -641,6 +640,7 @@ ivas_error ivas_dec_setup(
{
return error;
}
st_ivas->last_active_ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
st_ivas->hDecoderConfig->ivas_total_brate = ivas_total_brate;
}
......@@ -1972,7 +1972,6 @@ ivas_error ivas_init_decoder(
}
else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD )
{
if ( ( error = ivas_td_binaural_open( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
......@@ -1986,7 +1985,6 @@ ivas_error ivas_init_decoder(
}
}
if ( st_ivas->hDecoderConfig->Opt_5ms )
{
granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES );
......@@ -2682,12 +2680,8 @@ void ivas_destroy_dec(
st_ivas->hLsSetupCustom = NULL;
}
/* Downmix structure */
if ( st_ivas->hMonoDmxRenderer != NULL )
{
free( st_ivas->hMonoDmxRenderer );
st_ivas->hMonoDmxRenderer = NULL;
}
/* Mono downmix structure */
ivas_mono_dmx_renderer_close( &st_ivas->hMonoDmxRenderer );
/* OSBA structure */
ivas_osba_data_close( &st_ivas->hSbaIsmData );
......
......@@ -67,7 +67,11 @@ static ivas_error ivas_ism_bitrate_switching_dec(
int16_t tc_nchan_tc_new;
int16_t tc_nchan_allocate_new;
int16_t tc_granularity_new;
#ifdef NONBE_FIX_839_MC_RS_CHANNEL_ALLOC
int16_t nchan_out_buff, nchan_out_buff_old;
#else
int16_t ch, nchan_out_buff, nchan_out_buff_old;
#endif
AUDIO_CONFIG intern_config_old;
IVAS_OUTPUT_SETUP hIntSetupOld;
RENDERER_TYPE renderer_type_old;
......@@ -81,7 +85,11 @@ static ivas_error ivas_ism_bitrate_switching_dec(
st_ivas->ism_mode = last_ism_mode;
ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old );
st_ivas->ism_mode = ism_mode;
#ifdef NONBE_FIX_839_MC_RS_CHANNEL_ALLOC
nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 );
#else
nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate );
#endif
if ( ( error = ivas_ism_config( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->nchan_ism, NULL, 0, NULL, NULL, element_brate_tmp, NULL, NULL, 0 ) ) != IVAS_ERR_OK )
{
......@@ -146,11 +154,11 @@ static ivas_error ivas_ism_bitrate_switching_dec(
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, MC_MODE_NONE, last_ism_mode, nSamplesRendered,
#ifdef SPLIT_REND_WITH_HEAD_ROT
pcm_resolution,
if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, MC_MODE_NONE, last_ism_mode, 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, MC_MODE_NONE, last_ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK )
#endif
data ) ) != IVAS_ERR_OK )
{
return error;
}
......@@ -271,16 +279,9 @@ static ivas_error ivas_ism_bitrate_switching_dec(
/* Close the TD Binaural renderer */
if ( st_ivas->hBinRendererTd->HrFiltSet_p->ModelParams.modelROM == TRUE )
{
if ( st_ivas->hBinRendererTd != NULL )
{
ivas_td_binaural_close( &st_ivas->hBinRendererTd );
}
if ( st_ivas->hHrtfTD != NULL )
{
st_ivas->hHrtfTD = NULL;
}
if ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB )
{
......@@ -331,6 +332,14 @@ static ivas_error ivas_ism_bitrate_switching_dec(
if ( !st_ivas->hDecoderConfig->Opt_5ms )
{
#ifdef NONBE_FIX_839_MC_RS_CHANNEL_ALLOC
nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 );
if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK )
{
return error;
}
#else
nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate );
if ( nchan_out_buff > nchan_out_buff_old )
......@@ -352,11 +361,13 @@ static ivas_error ivas_ism_bitrate_switching_dec(
st_ivas->p_output_f[ch] = NULL;
}
}
#endif
}
/*-----------------------------------------------------------------*
* Reconfigure TC buffer
* JBM TC buffers
*-----------------------------------------------------------------*/
if ( st_ivas->hDecoderConfig->Opt_5ms )
{
int16_t tc_nchan_full_new;
......
......@@ -171,7 +171,7 @@ ivas_error ivas_ism_dtx_dec(
*-------------------------------------------------------------------*/
void ivas_ism_dtx_limit_noise_energy_for_near_silence(
SCE_DEC_HANDLE hSCE[], /* i/o: SCE encoder structures */
SCE_DEC_HANDLE hSCE[], /* i/o: SCE decoder structures */
const int16_t sce_id_dtx, /* i : SCE DTX ID */
const int16_t nchan_transport /* i : number of transport channels */
)
......
......@@ -928,8 +928,8 @@ static int16_t decode_radius(
*-------------------------------------------------------------------*/
void ivas_ism_metadata_sid_dec(
SCE_DEC_HANDLE hSCE[MAX_SCE], /* i/o: SCE encoder structure */
const int32_t ism_total_brate, /* i : ISms total bitrate */
SCE_DEC_HANDLE hSCE[MAX_SCE], /* i/o: SCE decoder structure */
const int32_t ism_total_brate, /* i : ISM total bitrate */
const int16_t bfi, /* i : bfi flag */
const int16_t nchan_ism, /* i : number of objects */
const int16_t nchan_transport, /* i : number of transport channels*/
......
......@@ -626,6 +626,7 @@ ivas_error ivas_param_ism_dec_open(
}
set_zero( hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc, n_slots_to_alloc * nchan_transport * hSpatParamRendCom->num_freq_bands );
}
if ( st_ivas->hTcBuffer == NULL )
{
if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, nchan_full, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK )
......@@ -1210,6 +1211,7 @@ void ivas_param_ism_dec_digest_tc(
}
}
}
if ( st_ivas->hDecoderConfig->Opt_tsm || !st_ivas->hDecoderConfig->Opt_5ms )
{
/*TODO : FhG to check*/
......@@ -1218,9 +1220,7 @@ void ivas_param_ism_dec_digest_tc(
for ( ch = 0; ch < nchan_transport; ch++ )
{
/*-----------------------------------------------------------------*
* CLDFB Analysis
*-----------------------------------------------------------------*/
/* CLDFB Analysis */
for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ )
{
if ( st_ivas->hDecoderConfig->Opt_tsm || !st_ivas->hDecoderConfig->Opt_5ms )
......@@ -1277,8 +1277,8 @@ void ivas_ism_param_dec_tc_gain_ajust(
for ( i = 0; i < nSamples; i++ )
{
ene_tc += transport_channels_f[0][i] * transport_channels_f[0][i] + transport_channels_f[1][i] * transport_channels_f[1][i]; // L*L + R*R
ene_sum += ( transport_channels_f[0][i] + transport_channels_f[1][i] ) * ( transport_channels_f[0][i] + transport_channels_f[1][i] ); // (L+R)*(L+R)
ene_tc += transport_channels_f[0][i] * transport_channels_f[0][i] + transport_channels_f[1][i] * transport_channels_f[1][i]; /* L*L + R*R */
ene_sum += ( transport_channels_f[0][i] + transport_channels_f[1][i] ) * ( transport_channels_f[0][i] + transport_channels_f[1][i] ); /* (L+R)*(L+R) */
}
gain = sqrtf( ene_tc / ( ene_sum + EPSILON ) );
if ( st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame > 1 )
......
......@@ -61,14 +61,16 @@ ivas_error ivas_ism_renderer_open(
uint16_t init_interpolator_length;
ivas_error error;
error = IVAS_ERR_OK;
if ( ( st_ivas->hIsmRendererData = (ISM_RENDERER_HANDLE) malloc( sizeof( ISM_RENDERER_DATA ) ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for ISM renderer\n" ) );
}
#ifdef BE_FIX_832_ASAN_ERROR_EFAP_OSBA
if ( st_ivas->hIntSetup.is_loudspeaker_setup && st_ivas->hIntSetup.ls_azimuth != NULL && st_ivas->hIntSetup.ls_elevation != NULL && st_ivas->hEFAPdata == NULL )
#else
if ( st_ivas->hIntSetup.is_loudspeaker_setup && st_ivas->hIntSetup.ls_azimuth != NULL && st_ivas->hIntSetup.ls_elevation != NULL )
#endif
{
if ( ( error = efap_init_data( &( st_ivas->hEFAPdata ), st_ivas->hIntSetup.ls_azimuth, st_ivas->hIntSetup.ls_elevation, st_ivas->hIntSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ) != IVAS_ERR_OK )
{
......@@ -98,13 +100,12 @@ ivas_error ivas_ism_renderer_open(
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for ISM renderer interpolator\n" ) );
}
for ( i = 0; i < interpolator_length; i++ )
{
st_ivas->hIsmRendererData->interpolator[i] = (float) i / ( (float) interpolator_length - 1 );
}
return error;
return IVAS_ERR_OK;
}
......@@ -176,7 +177,6 @@ void ivas_ism_render(
set_f( output_f[i], 0.0f, output_frame );
}
for ( i = 0; i < nchan_ism; i++ )
{
if ( st_ivas->intern_config == IVAS_AUDIO_CONFIG_STEREO )
......@@ -284,7 +284,6 @@ void ivas_ism_render_sf(
for ( i = 0; i < num_objects; i++ )
{
/* Combined rotation: rotate the object positions depending the head and external orientations */
if ( st_ivas->hCombinedOrientationData != NULL && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] == 1 )
{
......
......@@ -185,6 +185,7 @@ ivas_error ivas_jbm_dec_tc(
/* HP filtering */
hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs );
}
if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX )
{
ivas_mono_downmix_render_passive( st_ivas, p_output, output_frame );
......@@ -317,7 +318,6 @@ ivas_error ivas_jbm_dec_tc(
int16_t nchan_ism, nchan_transport_ism;
int16_t dirac_bs_md_write_idx;
st = st_ivas->hCPE[0]->hCoreCoder[0];
set_s( nb_bits_metadata, 0, MAX_SCE + 1 );
/* Set the number of objects for the parametric rendering */
......@@ -334,7 +334,7 @@ ivas_error ivas_jbm_dec_tc(
}
/* MASA metadata decoding */
if ( ( error = ivas_masa_decode( st_ivas, st, &nb_bits_metadata[0] ) ) != IVAS_ERR_OK )
if ( ( error = ivas_masa_decode( st_ivas, st_ivas->hCPE[0]->hCoreCoder[0], &nb_bits_metadata[0] ) ) != IVAS_ERR_OK )
{
return error;
}
......@@ -342,7 +342,7 @@ ivas_error ivas_jbm_dec_tc(
/* Configuration of combined-format bit-budget distribution */
ivas_set_surplus_brate_dec( st_ivas, &ism_total_brate );
st->bit_stream = &( st_ivas->bit_stream[( ism_total_brate / FRAMES_PER_SEC )] );
st_ivas->hCPE[0]->hCoreCoder[0]->bit_stream = &( st_ivas->bit_stream[( ism_total_brate / FRAMES_PER_SEC )] );
/* set ISM parameters and decode ISM metadata in OMASA format */
if ( ( error = ivas_omasa_ism_metadata_dec( st_ivas, ism_total_brate, &nchan_ism, &nchan_transport_ism, dirac_bs_md_write_idx, &nb_bits_metadata[1] ) ) != IVAS_ERR_OK )
......@@ -429,7 +429,6 @@ ivas_error ivas_jbm_dec_tc(
/* core-decoding of transport channels */
if ( st_ivas->nSCE == 1 )
{
st = st_ivas->hSCE[0]->hCoreCoder[0];
if ( ( error = ivas_sce_dec( st_ivas, 0, p_output, output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ) != IVAS_ERR_OK )
{
return error;
......@@ -437,7 +436,6 @@ ivas_error ivas_jbm_dec_tc(
}
else if ( st_ivas->nCPE == 1 )
{
st = st_ivas->hCPE[0]->hCoreCoder[0];
if ( ( error = ivas_cpe_dec( st_ivas, 0, p_output, output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ) != IVAS_ERR_OK )
{
return error;
......@@ -445,7 +443,6 @@ ivas_error ivas_jbm_dec_tc(
}
else if ( st_ivas->nCPE > 1 )
{
st = st_ivas->hCPE[0]->hCoreCoder[0];
if ( ( error = ivas_mct_dec( st_ivas, p_output, output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ) != IVAS_ERR_OK )
{
return error;
......@@ -461,9 +458,7 @@ ivas_error ivas_jbm_dec_tc(
ivas_pca_dec( st_ivas->hSpar->hPCA, output_frame, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, &p_output[sba_ch_idx] );
}
ivas_spar_dec_gen_umx_mat( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, 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( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, 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_sba_dirac_stereo_dec( st_ivas, &p_output[sba_ch_idx], output_frame, 0 );
}
......@@ -508,7 +503,6 @@ ivas_error ivas_jbm_dec_tc(
}
else if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX && st_ivas->ism_mode == ISM_SBA_MODE_DISC )
{
ivas_mono_downmix_render_passive( st_ivas, p_output, output_frame );
/* add W */
......@@ -584,7 +578,7 @@ ivas_error ivas_jbm_dec_tc(
}
/* Rendering */
if ( ( st_ivas->renderer_type == RENDERER_MC ) && ( output_config == IVAS_AUDIO_CONFIG_MONO || output_config == IVAS_AUDIO_CONFIG_STEREO ) )
if ( st_ivas->renderer_type == RENDERER_MC && ( output_config == IVAS_AUDIO_CONFIG_MONO || output_config == IVAS_AUDIO_CONFIG_STEREO ) )
{
/* Compensate loudness for not doing full upmix */
for ( n = 4; n < 8; n++ )
......@@ -765,7 +759,7 @@ ivas_error ivas_jbm_dec_tc(
* Feed decoded transport channels and metadata to the IVAS JBM renderer routine
*--------------------------------------------------------------------------*/
ivas_error ivas_jbm_dec_feed_tc_to_renderer(
void ivas_jbm_dec_feed_tc_to_renderer(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
const int16_t nSamplesForRendering, /* i : number of TC samples available for rendering */
int16_t *nSamplesResidual, /* o : number of samples not fitting into the renderer grid and buffer for the next call*/
......@@ -775,10 +769,8 @@ ivas_error ivas_jbm_dec_feed_tc_to_renderer(
float data_f[MAX_CLDFB_DIGEST_CHANNELS][MAX_JBM_L_FRAME48k]; /* 'float' buffer for transport channels that will be directly converted with the CLDFB */
float *p_data_f[MAX_CLDFB_DIGEST_CHANNELS];
int16_t n, n_render_timeslots;
ivas_error error;
push_wmops( "ivas_jbm_dec_feed_tc_to_rendererer" );
for ( n = 0; n < MAX_CLDFB_DIGEST_CHANNELS; n++ )
{
p_data_f[n] = &data_f[n][0];
......@@ -830,10 +822,7 @@ ivas_error ivas_jbm_dec_feed_tc_to_renderer(
}
else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT )
{
if ( ( error = ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ) ) != IVAS_ERR_OK )
{
return error;
}
ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available );
}
#ifdef JBM_FOR_OSBA
else if ( st_ivas->ivas_format == SBA_ISM_FORMAT )
......@@ -879,10 +868,7 @@ ivas_error ivas_jbm_dec_feed_tc_to_renderer(
n_render_timeslots *= ( st_ivas->hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size );
}
if ( ( error = ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ) ) != IVAS_ERR_OK )
{
return error;
}
ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available );
if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC )
{
......@@ -905,16 +891,12 @@ ivas_error ivas_jbm_dec_feed_tc_to_renderer(
}
else if ( st_ivas->mc_mode == MC_MODE_MCMASA )
{
if ( ( error = ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ) ) != IVAS_ERR_OK )
{
return error;
}
ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available );
}
}
pop_wmops();
return IVAS_ERR_OK;
return;
}
......@@ -939,33 +921,26 @@ ivas_error ivas_jbm_dec_render(
{
int16_t n, nchan_out;
int16_t nchan_transport;
float output[MAX_OUTPUT_CHANNELS
#ifdef JBM_FOR_OSBA
+ MAX_NUM_OBJECTS
float output[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k]; /* 'float' buffer for output synthesis */
#else
float output[MAX_OUTPUT_CHANNELS][L_FRAME48k]; /* 'float' buffer for output synthesis */
#endif
][L_FRAME48k]; /* 'float' buffer for output synthesis */
int16_t nchan_remapped;
int32_t output_Fs;
AUDIO_CONFIG output_config;
int16_t nSamplesAskedLocal;
ivas_error error;
float *p_output[MAX_OUTPUT_CHANNELS
#ifdef JBM_FOR_OSBA
+ MAX_NUM_OBJECTS
#endif
];
float *p_tc[MAX_TRANSPORT_CHANNELS
#ifdef JBM_FOR_OSBA
+ MAX_NUM_OBJECTS
float *p_output[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS];
float *p_tc[MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS];
#else
float *p_output[MAX_OUTPUT_CHANNELS];
float *p_tc[MAX_TRANSPORT_CHANNELS];
#endif
];
SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom;
push_wmops( "ivas_dec_render" );
/*----------------------------------------------------------------*
* Initialization of local vars after struct has been set
*----------------------------------------------------------------*/
......@@ -977,12 +952,11 @@ ivas_error ivas_jbm_dec_render(
output_config = st_ivas->hDecoderConfig->output_config;
nSamplesAskedLocal = nSamplesAsked + st_ivas->hTcBuffer->n_samples_discard;
for ( n = 0; n < MAX_OUTPUT_CHANNELS
#ifdef JBM_FOR_OSBA
+ MAX_NUM_OBJECTS
for ( n = 0; n < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; n++ )
#else
for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ )
#endif
;
n++ )
{
p_output[n] = &output[n][0];
}
......@@ -1133,9 +1107,7 @@ ivas_error ivas_jbm_dec_render(
{
nchan_remapped = st_ivas->nchan_transport;
if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ||
st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ||
st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC )
if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC )
{
if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC )
{
......@@ -1160,7 +1132,6 @@ ivas_error ivas_jbm_dec_render(
nchan_remapped = nchan_transport;
/* Loudspeakers, Ambisonics or Binaural rendering */
if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC )
{
if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV )
......@@ -1173,19 +1144,17 @@ ivas_error ivas_jbm_dec_render(
else if ( st_ivas->renderer_type == RENDERER_OSBA_STEREO )
{
*nSamplesRendered = min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal );
/* render objects */
ivas_ism_render_sf( st_ivas, p_output, *nSamplesRendered );
/* add already rendererd SBA part */
for ( n = 0; n < nchan_out; n++ )
{
v_add( p_output[n], p_tc[n + st_ivas->nchan_ism], p_output[n], *nSamplesRendered );
}
}
else if ( st_ivas->renderer_type == RENDERER_OSBA_AMBI || st_ivas->renderer_type == RENDERER_OSBA_LS
#ifdef JBM_FOR_OSBA
|| st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM
#endif
)
else if ( st_ivas->renderer_type == RENDERER_OSBA_AMBI || st_ivas->renderer_type == RENDERER_OSBA_LS || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM )
{
float output_ism[MAX_OUTPUT_CHANNELS][L_FRAME48k];
float *p_output_ism[MAX_OUTPUT_CHANNELS];
......@@ -1195,7 +1164,11 @@ ivas_error ivas_jbm_dec_render(
p_output_ism[n] = &output_ism[n][0];
}
ivas_sba_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output );
if ( ( error = ivas_sba_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK )
{
return error;
}
#ifdef OSBA_ROOM_IR
if ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM )
#endif
......@@ -1216,8 +1189,11 @@ ivas_error ivas_jbm_dec_render(
}
else if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) /*EXT output = individual objects + HOA3*/
{
if ( ( error = ivas_sba_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, &p_output[st_ivas->nchan_ism] ) ) != IVAS_ERR_OK )
{
return error;
}
ivas_sba_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, &p_output[st_ivas->nchan_ism] );
for ( n = 0; n < st_ivas->nchan_ism; n++ )
{
mvr2r( st_ivas->hTcBuffer->tc[n] + st_ivas->hTcBuffer->n_samples_rendered, p_output[n], *nSamplesRendered );
......@@ -1225,17 +1201,23 @@ ivas_error ivas_jbm_dec_render(
}
else
{
ivas_sba_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output );
if ( ( error = ivas_sba_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK )
{
return error;
}
}
else if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ||
st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM )
}
else if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM )
{
ivas_dirac_dec_binaural_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output );
}
else /* SBA_MODE_SPAR */
{
ivas_sba_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output );
if ( ( error = ivas_sba_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK )
{
return error;
}
if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL )
{
#ifdef DEBUGGING
......@@ -1639,6 +1621,7 @@ ivas_error ivas_jbm_dec_flush_renderer(
tc_local[ch_idx] = &st_ivas->hTcBuffer->tc[ch_idx + 2][hTcBuffer->n_samples_rendered];
mvr2r( st_ivas->hSbaIsmData->delayBuffer[ch_idx], tc_local[ch_idx], st_ivas->hSbaIsmData->delayBuffer_size );
}
/* transfer adapted sf info from hTcBuffer to SPAR and DirAC */
st_ivas->hSpar->nb_subframes = 1;
st_ivas->hSpar->subframes_rendered = 0;
......@@ -1650,9 +1633,11 @@ ivas_error ivas_jbm_dec_flush_renderer(
st_ivas->hSpatParamRendCom->subframe_nbslots[0] = JBM_CLDFB_SLOTS_IN_SUBFRAME;
st_ivas->hSpatParamRendCom->slots_rendered = 0;
st_ivas->hSpatParamRendCom->num_slots = JBM_CLDFB_SLOTS_IN_SUBFRAME;
/* also adapt md maps, just use the last index */
set_s( st_ivas->hSpar->render_to_md_map, last_spar_md_idx, n_slots_still_available );
set_s( st_ivas->hSpatParamRendCom->render_to_md_map, last_dirac_md_idx, n_slots_still_available );
/* render the last subframe */
if ( ( error = ivas_osba_dirac_td_binaural_jbm( st_ivas, (uint16_t) hTcBuffer->n_samples_granularity, nSamplesRendered, &nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK )
{
......@@ -1678,7 +1663,7 @@ ivas_error ivas_jbm_dec_flush_renderer(
if ( st_ivas->hDecoderConfig->Opt_Limiter )
#endif
{
if ( !( st_ivas->ivas_format == MONO_FORMAT ) )
if ( st_ivas->ivas_format != MONO_FORMAT )
{
#ifndef DISABLE_LIMITER
ivas_limiter_dec( st_ivas->hLimiter, p_output, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect );
......@@ -2241,12 +2226,12 @@ ivas_error ivas_jbm_dec_tc_buffer_open(
if ( hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_NONE )
{
hTcBuffer->tc_buffer = NULL;
for ( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS
#ifdef JBM_FOR_OSBA
+ MAX_NUM_OBJECTS
for ( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ )
#else
for ( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS; ch_idx++ )
#endif
;
ch_idx++ )
{
hTcBuffer->tc[ch_idx] = NULL;
}
......@@ -2266,19 +2251,18 @@ ivas_error ivas_jbm_dec_tc_buffer_open(
n_samp_residual = 0;
}
nsamp_to_allocate = hTcBuffer->nchan_buffer_full * n_samp_full;
nsamp_to_allocate += nchan_residual * n_samp_residual;
if ( nsamp_to_allocate == 0 )
{
hTcBuffer->tc_buffer = NULL;
for ( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS
#ifdef JBM_FOR_OSBA
+ MAX_NUM_OBJECTS
for ( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ )
#else
for ( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS; ch_idx++ )
#endif
;
ch_idx++ )
{
hTcBuffer->tc[ch_idx] = NULL;
}
......@@ -2302,12 +2286,11 @@ ivas_error ivas_jbm_dec_tc_buffer_open(
hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset];
offset += n_samp_residual;
}
for ( ; ch_idx < MAX_TRANSPORT_CHANNELS
#ifdef JBM_FOR_OSBA
+ MAX_NUM_OBJECTS
for ( ; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ )
#else
for ( ; ch_idx < MAX_TRANSPORT_CHANNELS; ch_idx++ )
#endif
;
ch_idx++ )
{
hTcBuffer->tc[ch_idx] = NULL;
}
......@@ -2420,13 +2403,12 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure(
hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset];
offset += n_samp_residual;
}
for ( ; ch_idx < MAX_TRANSPORT_CHANNELS
#ifdef JBM_FOR_OSBA
+ MAX_NUM_OBJECTS
for ( ; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ )
#else
for ( ; ch_idx < MAX_TRANSPORT_CHANNELS; ch_idx++ )
#endif
;
ch_idx++ )
{
hTcBuffer->tc[ch_idx] = NULL;
}
......@@ -2489,15 +2471,15 @@ void ivas_jbm_dec_tc_buffer_close(
if ( *phTcBuffer != NULL )
{
for ( i = 0; i < MAX_TRANSPORT_CHANNELS
#ifdef JBM_FOR_OSBA
+ MAX_NUM_OBJECTS
for ( i = 0; i < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; i++ )
#else
for ( i = 0; i < MAX_TRANSPORT_CHANNELS; i++ )
#endif
;
i++ )
{
( *phTcBuffer )->tc[i] = NULL;
}
if ( ( *phTcBuffer )->tc_buffer != NULL )
{
free( ( *phTcBuffer )->tc_buffer );
......@@ -2659,9 +2641,10 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode(
*--------------------------------------------------------------------------*/
void ivas_jbm_dec_copy_tc_no_tsm(
Decoder_Struct *st_ivas,
float *tc[],
const int16_t output_frame )
Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
float *tc[], /* i : transport channels */
const int16_t output_frame /* i : output frame size */
)
{
int16_t n_ch_full_copy;
int16_t n_ch_cldfb;
......
......@@ -622,9 +622,7 @@ ivas_error ivas_masa_dec_open(
st_ivas->hMasa = hMasa;
/* allocate transport channels*/
if (
st_ivas->hDecoderConfig->Opt_5ms &&
st_ivas->hTcBuffer == NULL && st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM && st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC )
if ( st_ivas->hDecoderConfig->Opt_5ms && st_ivas->hTcBuffer == NULL && st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM && st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC )
{
int16_t nchan_to_allocate;
TC_BUFFER_MODE buffer_mode;
......@@ -1505,11 +1503,11 @@ ivas_error ivas_masa_dec_reconfigure(
{
if ( n_samples_granularity < st_ivas->hTcBuffer->n_samples_granularity )
{
if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, n_samples_granularity, st_ivas->renderer_type, st_ivas->intern_config, &st_ivas->hIntSetup, MC_MODE_NONE, ISM_MASA_MODE_DISC, nSamplesRendered,
#ifdef SPLIT_REND_WITH_HEAD_ROT
pcm_resolution,
if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, n_samples_granularity, st_ivas->renderer_type, st_ivas->intern_config, &st_ivas->hIntSetup, MC_MODE_NONE, ISM_MASA_MODE_DISC, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK )
#else
if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, n_samples_granularity, st_ivas->renderer_type, st_ivas->intern_config, &st_ivas->hIntSetup, MC_MODE_NONE, ISM_MASA_MODE_DISC, nSamplesRendered, data ) ) != IVAS_ERR_OK )
#endif
data ) ) != IVAS_ERR_OK )
{
return error;
}
......@@ -1615,7 +1613,11 @@ void ivas_spar_param_to_masa_param_mapping(
for ( slot_idx = 0; slot_idx < hSpar->subframe_nbslots[subframe]; slot_idx++ )
{
sf = hSpar->render_to_md_map[slot_idx + slot_idx_start] / JBM_CLDFB_SLOTS_IN_SUBFRAME;
#ifndef FIX_MSAN_USAN_ERROR_JBM
if ( subframe < SPAR_META_DELAY_SUBFRAMES )
#else
if ( ( sf < SPAR_META_DELAY_SUBFRAMES ) )
#endif
{
mixer_mat_index = sf + MAX_PARAM_SPATIAL_SUBFRAMES - SPAR_META_DELAY_SUBFRAMES + 1;
for ( band = 0; band < SPAR_DIRAC_SPLIT_START_BAND; band++ )
......
......@@ -2063,7 +2063,7 @@ static int16_t ivas_param_mc_bin2dec(
/*-------------------------------------------------------------------------
* ivas_param_mc_uniform_encoder()
* ivas_param_mc_uniform_decoder()
*
* decode a uniformily coded sequence of float values
*------------------------------------------------------------------------*/
......
......@@ -443,7 +443,11 @@ void ivas_mc_paramupmix_dec(
}
}
#ifdef NONBE_FIX_839_MC_RS_CHANNEL_ALLOC
for ( ch = first_empty_channel; ch < ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ); ch++ )
#else
for ( ch = first_empty_channel; ch < ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); ch++ )
#endif
{
set_f( output_f[ch], 0.0f, output_frame );
}
......@@ -657,6 +661,7 @@ ivas_error ivas_mc_paramupmix_dec_open(
/* allocate transport channels*/
hMCParamUpmix->free_param_interpolator = 0;
hMCParamUpmix->param_interpolator = NULL;
#ifdef NONBE_FIX_808_JBM_PARAMUPMIX_RS
if ( st_ivas->hDecoderConfig->Opt_5ms == 1 )
{
......@@ -669,6 +674,7 @@ ivas_error ivas_mc_paramupmix_dec_open(
ivas_jbm_dec_get_adapted_linear_interpolator( DEFAULT_JBM_CLDFB_TIMESLOTS, DEFAULT_JBM_CLDFB_TIMESLOTS, hMCParamUpmix->param_interpolator );
}
#endif
if ( st_ivas->hDecoderConfig->Opt_5ms == 1 && st_ivas->hTcBuffer == NULL )
{
int16_t nchan_to_allocate;
......@@ -684,6 +690,7 @@ ivas_error ivas_mc_paramupmix_dec_open(
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for interpolator\n" ) );
}
#endif
if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO )
{
buffer_mode = TC_BUFFER_MODE_BUFFER;
......@@ -694,6 +701,7 @@ ivas_error ivas_mc_paramupmix_dec_open(
{
nchan_to_allocate = MC_PARAMUPMIX_MAX_INPUT_CHANS;
}
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;
......@@ -1005,10 +1013,11 @@ static void ps_pred_process_sf(
static void ivas_mc_paramupmix_dec_sf(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
float *output_f[MAX_OUTPUT_CHANNELS] /* i/o: synthesized core-coder transport channels */
#ifdef SPLIT_REND_WITH_HEAD_ROT
,
float *output_f[MAX_OUTPUT_CHANNELS], /* i/o: synthesized core-coder transport channels */
const int16_t slot_index_start
#else
float *output_f[MAX_OUTPUT_CHANNELS] /* i/o: synthesized core-coder transport channels */
#endif
)
{
......@@ -1020,6 +1029,17 @@ static void ivas_mc_paramupmix_dec_sf(
int16_t noparamupmix_delay, n_samples_rendered;
MC_PARAMUPMIX_DEC_HANDLE hMCParamUpmix;
int16_t subframeIdx, idx_in, maxBand;
#ifdef NONBE_FIX_835_JBM_PARAMUPMIX_HEADROT
float Cldfb_RealBuffer_subfr[MAX_INTERN_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX];
float Cldfb_ImagBuffer_subfr[MAX_INTERN_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX];
#ifdef SPLIT_REND_WITH_HEAD_ROT
float Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX];
float Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX];
#else
float Cldfb_RealBuffer_Binaural[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX];
float Cldfb_ImagBuffer_Binaural[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX];
#endif
#else
#ifdef SPLIT_REND_WITH_HEAD_ROT
float Cldfb_RealBuffer_subfr[MC_PARAMUPMIX_MAX_INPUT_CHANS][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX];
float Cldfb_ImagBuffer_subfr[MC_PARAMUPMIX_MAX_INPUT_CHANS][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX];
......@@ -1031,6 +1051,7 @@ static void ivas_mc_paramupmix_dec_sf(
float Cldfb_ImagBuffer_subfr[3 + MC_PARAMUPMIX_MAX_TRANSPORT_CHANS][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX];
float Cldfb_RealBuffer_Binaural[BINAURAL_CHANNELS][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX];
float Cldfb_ImagBuffer_Binaural[BINAURAL_CHANNELS][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX];
#endif
#endif
hMCParamUpmix = st_ivas->hMCParamUpmix;
......@@ -1119,10 +1140,21 @@ static void ivas_mc_paramupmix_dec_sf(
idx_in += 2;
}
#ifdef NONBE_FIX_835_JBM_PARAMUPMIX_HEADROT
if ( st_ivas->hCombinedOrientationData && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV )
{
for ( slot_idx = 0; slot_idx < st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->subframes_rendered]; slot_idx++ )
{
ivas_param_mc_mc2sba_cldfb( st_ivas->hTransSetup, hMCParamUpmix->hoa_encoder, slot_idx, Cldfb_RealBuffer_subfr, Cldfb_ImagBuffer_subfr, maxBand, GAIN_LFE );
}
}
#endif
#ifdef SPLIT_REND_WITH_HEAD_ROT
/*LFE handling for split rendering cases*/
if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
{
#ifndef NONBE_FIX_835_JBM_PARAMUPMIX_HEADROT
for ( idx_lfe = 0; idx_lfe < st_ivas->hIntSetup.num_lfe; idx_lfe++ )
{
ch = st_ivas->hIntSetup.index_lfe[idx_lfe];
......@@ -1132,8 +1164,8 @@ static void ivas_mc_paramupmix_dec_sf(
}
idx_in++;
}
#endif
#ifdef SPLIT_REND_WITH_HEAD_ROT
if ( st_ivas->hSplitBinRend.hCldfbDataOut != NULL )
{
for ( slot_idx = 0; slot_idx < st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->subframes_rendered]; slot_idx++ )
......@@ -1147,7 +1179,6 @@ static void ivas_mc_paramupmix_dec_sf(
st_ivas->hSplitBinRend.hCldfbDataOut->config = st_ivas->hIntSetup.output_config;
}
#endif
}
#endif
......
......@@ -731,12 +731,16 @@ static ivas_error ivas_mc_dec_reconfig(
int16_t tc_granularity_new;
AUDIO_CONFIG intern_config_old;
IVAS_OUTPUT_SETUP hIntSetupOld;
#ifdef NONBE_FIX_839_MC_RS_CHANNEL_ALLOC
int16_t nchan_out_buff_old, nchan_out_buff;
#endif
error = IVAS_ERR_OK;
ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
nchan_transport_old = st_ivas->nchan_transport;
#ifdef NONBE_FIX_839_MC_RS_CHANNEL_ALLOC
nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 );
#endif
last_mc_mode = ivas_mc_mode_select( ivas_mc_map_output_config_to_mc_ls_setup( st_ivas->transport_config ), st_ivas->hDecoderConfig->last_ivas_total_brate ); /* NB: this assumes that LS config remains the same between frames */
/* we have to temporally set the current mc_mode back to the previous one to make sure the following call to
......@@ -1319,7 +1323,7 @@ static ivas_error ivas_mc_dec_reconfig(
}
/*-----------------------------------------------------------------*
* Reconfigure TC buffer
* JBM TC buffers
*-----------------------------------------------------------------*/
if ( st_ivas->hDecoderConfig->Opt_5ms == 1 )
......@@ -1332,11 +1336,13 @@ static ivas_error ivas_mc_dec_reconfig(
tc_nchan_tc_new = ivas_jbm_dec_get_num_tc_channels( st_ivas );
tc_nchan_allocate_new = tc_nchan_tc_new;
tc_nchan_full_new = tc_nchan_tc_new;
if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC )
{
tc_nchan_allocate_new = 2 * BINAURAL_CHANNELS;
tc_nchan_full_new = tc_nchan_allocate_new;
}
if ( st_ivas->mc_mode == MC_MODE_PARAMMC && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_MONO && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO )
{
tc_nchan_full_new = 0;
......@@ -1345,6 +1351,7 @@ static ivas_error ivas_mc_dec_reconfig(
else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX )
{
tc_nchan_allocate_new = MC_PARAMUPMIX_MAX_INPUT_CHANS;
tc_buffer_mode_new = TC_BUFFER_MODE_RENDERER;
if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO )
{
tc_buffer_mode_new = TC_BUFFER_MODE_BUFFER;
......@@ -1385,5 +1392,46 @@ static ivas_error ivas_mc_dec_reconfig(
}
}
#ifdef NONBE_FIX_839_MC_RS_CHANNEL_ALLOC
/*-----------------------------------------------------------------*
* floating-point output audio buffers
*-----------------------------------------------------------------*/
if ( !st_ivas->hDecoderConfig->Opt_5ms )
{
#ifdef NONBE_FIX_839_MC_RS_CHANNEL_ALLOC
nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 );
if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK )
{
return error;
}
#else
int16_t nchan_out_buff, ch;
nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate );
if ( nchan_out_buff > nchan_out_buf_old )
{
for ( ch = nchan_out_buf_old; ch < nchan_out_buff; ch++ )
{
/* note: these are intra-frame heap memories */
if ( ( st_ivas->p_output_f[ch] = (float *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) /* note: 32000 == max internal sampling rate */
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) );
}
}
}
else
{
for ( ch = nchan_out_buff; ch < nchan_out_buf_old; ch++ )
{
free( st_ivas->p_output_f[ch] );
st_ivas->p_output_f[ch] = NULL;
}
}
#endif
}
#endif
return error;
}
......@@ -76,6 +76,28 @@ ivas_error ivas_mono_dmx_renderer_open(
}
/*-------------------------------------------------------------------------
* ivas_mono_dmx_renderer_close()
*
* Close decoder downmix handle
*-------------------------------------------------------------------------*/
void ivas_mono_dmx_renderer_close(
MONO_DOWNMIX_RENDERER_HANDLE *hMonoDmxRenderer /* i/ i/o: Mono downmix structure */
)
{
if ( hMonoDmxRenderer == NULL || *hMonoDmxRenderer == NULL )
{
return;
}
free( *hMonoDmxRenderer );
*hMonoDmxRenderer = NULL;
return;
}
/*-------------------------------------------------------------------------
* ivas_mono_downmix_render_passive()
*
......
......@@ -180,7 +180,11 @@ ivas_error ivas_omasa_dec_config(
ivas_format_orig = st_ivas->ivas_format;
st_ivas->ivas_format = st_ivas->last_ivas_format;
ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old );
#ifdef NONBE_FIX_839_MC_RS_CHANNEL_ALLOC
nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 );
#else
nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate );
#endif
st_ivas->ivas_format = ivas_format_orig;
......@@ -308,11 +312,7 @@ ivas_error ivas_omasa_dec_config(
}
else
{
if ( st_ivas->hMonoDmxRenderer != NULL )
{
free( st_ivas->hMonoDmxRenderer );
st_ivas->hMonoDmxRenderer = NULL;
}
ivas_mono_dmx_renderer_close( &st_ivas->hMonoDmxRenderer );
}
}
......@@ -341,15 +341,8 @@ ivas_error ivas_omasa_dec_config(
else
{
/* TD renderer handle */
if ( st_ivas->hBinRendererTd != NULL )
{
ivas_td_binaural_close( &st_ivas->hBinRendererTd );
}
if ( st_ivas->hHrtfTD != NULL ) // VE: this is copied from ivas_ism_bitrate_switching() but a review is needed
{
st_ivas->hHrtfTD = NULL;
}
/* ISM renderer handle + ISM data handle */
ivas_omasa_separate_object_renderer_close( st_ivas );
......@@ -414,6 +407,14 @@ ivas_error ivas_omasa_dec_config(
if ( !st_ivas->hDecoderConfig->Opt_5ms )
{
#ifdef NONBE_FIX_839_MC_RS_CHANNEL_ALLOC
nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 );
if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK )
{
return error;
}
#else
nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate );
if ( nchan_out_buff > nchan_out_buff_old )
......@@ -435,6 +436,7 @@ ivas_error ivas_omasa_dec_config(
st_ivas->p_output_f[k] = NULL;
}
}
#endif
}
}
......
......@@ -119,9 +119,9 @@ void ivas_osba_data_close(
/*--------------------------------------------------------------------------*
* ivas_osba_dirac_td_binaural()
* ivas_osba_dirac_td_binaural_jbm()
*
* Binaural rendering in OSBA format
* Binaural rendering in JBM OSBA format
*--------------------------------------------------------------------------*/
#ifdef JBM_FOR_OSBA
......@@ -136,7 +136,10 @@ ivas_error ivas_osba_dirac_td_binaural_jbm(
int16_t n;
ivas_error error;
ivas_sba_dec_render( st_ivas, nSamplesAsked, nSamplesRendered, nSamplesAvailable, &output_f[2] );
if ( ( error = ivas_sba_dec_render( st_ivas, nSamplesAsked, nSamplesRendered, nSamplesAvailable, &output_f[2] ) ) != IVAS_ERR_OK )
{
return error;
}
if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, output_f, *nSamplesRendered ) ) != IVAS_ERR_OK )
{
......@@ -156,6 +159,13 @@ ivas_error ivas_osba_dirac_td_binaural_jbm(
}
#endif
/*--------------------------------------------------------------------------*
* ivas_osba_dirac_td_binaural()
*
* Binaural rendering in OSBA format
*--------------------------------------------------------------------------*/
ivas_error ivas_osba_dirac_td_binaural(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
float *output[], /* o : output synthesis signal */
......@@ -192,13 +202,11 @@ ivas_error ivas_osba_dirac_td_binaural(
if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV )
{
if ( ( error = ivas_sba_upmixer_renderer( st_ivas,
#ifdef JBM_FOR_OSBA
output,
if ( ( error = ivas_sba_upmixer_renderer( st_ivas, output, output_frame ) ) != IVAS_ERR_OK )
#else
&output[channel_offset],
if ( ( error = ivas_sba_upmixer_renderer( st_ivas, &output[channel_offset], output_frame ) ) != IVAS_ERR_OK )
#endif
output_frame ) ) != IVAS_ERR_OK )
{
return error;
}
......
......@@ -89,11 +89,11 @@ void ivas_renderer_select(
{
if ( st_ivas->ism_mode == ISM_MODE_PARAM )
{
if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL
#ifdef SPLIT_REND_WITH_HEAD_ROT
|| output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM
if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
#else
if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL )
#endif
)
{
*renderer_type = RENDERER_BINAURAL_PARAMETRIC;
}
......@@ -142,11 +142,12 @@ void ivas_renderer_select(
else if ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT || ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && st_ivas->nchan_transport <= 2 ) )
{
*internal_config = output_config;
if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL
#ifdef SPLIT_REND_WITH_HEAD_ROT
|| output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM
if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
#else
if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL )
#endif
)
{
*renderer_type = RENDERER_BINAURAL_PARAMETRIC;
}
......@@ -158,6 +159,7 @@ void ivas_renderer_select(
else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT )
{
*internal_config = IVAS_AUDIO_CONFIG_HOA3;
if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB
#ifdef SPLIT_REND_WITH_HEAD_ROT
|| output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM
......@@ -170,6 +172,7 @@ void ivas_renderer_select(
{
*renderer_type = RENDERER_BINAURAL_FASTCONV_ROOM;
}
#ifdef OSBA_ROOM_IR
if ( st_ivas->ivas_format == SBA_ISM_FORMAT && *renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM )
{
......@@ -205,11 +208,11 @@ void ivas_renderer_select(
{
*internal_config = output_config;
if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL
#ifdef SPLIT_REND_WITH_HEAD_ROT
|| output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM
if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
#else
if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL )
#endif
)
{
*renderer_type = RENDERER_BINAURAL_PARAMETRIC;
}
......
......@@ -260,8 +260,9 @@ void ivas_pca_dec(
return;
}
#ifdef DEBUGGING
assert( ivas_total_brate == PCA_BRATE ); /* the remaining code is defined at 256k where there are 4 dmx channel */
#endif
if ( !bfi )
{
/* set PCA by-pass mode indicator */
......@@ -312,6 +313,5 @@ void ivas_pca_dec(
pca_dec_update_dquat( hPCA, ql, qr );
hPCA->prev_pca_bypass = 0;
return;
}
......@@ -105,7 +105,7 @@ ivas_error ivas_sba_dec_reconfigure(
#ifdef JBM_FOR_OSBA
,
uint16_t *nSamplesFlushed, /* o : number of samples flushed */
#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
......@@ -121,7 +121,11 @@ ivas_error ivas_sba_dec_reconfigure(
int32_t ivas_total_brate;
int32_t last_ivas_total_brate;
int16_t num_channels, num_md_sub_frames;
#ifdef NONBE_FIX_839_MC_RS_CHANNEL_ALLOC
int16_t nchan_out_buff, nchan_out_buff_old;
#else
int16_t ch, nchan_out_buff, nchan_out_buff_old;
#endif
int16_t sba_analysis_order_old;
#ifdef JBM_FOR_OSBA
int16_t sba_analysis_order_old_flush;
......@@ -132,10 +136,8 @@ ivas_error ivas_sba_dec_reconfigure(
#ifdef JBM_FOR_OSBA
int16_t granularity_new;
#endif
ism_mode_old = st_ivas->ism_mode;
error = IVAS_ERR_OK;
ism_mode_old = st_ivas->ism_mode;
hDecoderConfig = st_ivas->hDecoderConfig;
ivas_total_brate = hDecoderConfig->ivas_total_brate;
last_ivas_total_brate = st_ivas->last_active_ivas_total_brate;
......@@ -148,10 +150,11 @@ ivas_error ivas_sba_dec_reconfigure(
* Set SBA high-level parameters
* Save old SBA high-level parameters
*-----------------------------------------------------------------*/
nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, sba_analysis_order_old, last_ivas_total_brate );
nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, sba_analysis_order_old, last_ivas_total_brate );
ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old );
nchan_hp20_old = getNumChanSynthesis( st_ivas );
if ( st_ivas->ivas_format == SBA_ISM_FORMAT )
{
if ( ivas_total_brate >= IVAS_256k )
......@@ -177,7 +180,6 @@ ivas_error ivas_sba_dec_reconfigure(
#ifdef JBM_FOR_OSBA
*nSamplesFlushed = 0;
granularity_new = st_ivas->hTcBuffer->n_samples_granularity;
/* we may need to flush only for binaural and OSBA and TSM */
......@@ -192,12 +194,11 @@ ivas_error ivas_sba_dec_reconfigure(
/* copy the logic from ivas_renderer_select(), because calling this function has too many side effects that would affect the flushing */
if ( ivas_get_sba_num_TCs( ivas_total_brate, sba_order_internal ) <= 2 )
{
if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL
#ifdef SPLIT_REND_WITH_HEAD_ROT
|| 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 || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
#else
if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL )
#endif
)
{
renderer_type_new = RENDERER_BINAURAL_PARAMETRIC;
}
......@@ -221,15 +222,17 @@ ivas_error ivas_sba_dec_reconfigure(
renderer_type_new = RENDERER_BINAURAL_FASTCONV_ROOM;
}
}
/* determine new granularity */
granularity_new = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS );
/* this will change anyway only with binaural */
if ( renderer_type_new == RENDERER_BINAURAL_FASTCONV && st_ivas->ism_mode == ISM_SBA_MODE_DISC )
{
granularity_new *= JBM_CLDFB_SLOTS_IN_SUBFRAME;
}
/* flush renderer on granularity change form 5ms to 1.25ms, again only possible for binaural rendering */
/* flush renderer on granularity change form 5ms to 1.25ms, again only possible for binaural rendering */
if ( granularity_new < st_ivas->hTcBuffer->n_samples_granularity )
{
/* write back info for correct rendering of the flushable samples */
......@@ -239,14 +242,16 @@ ivas_error ivas_sba_dec_reconfigure(
st_ivas->sba_analysis_order = sba_analysis_order_old;
#endif
st_ivas->hDecoderConfig->ivas_total_brate = last_ivas_total_brate;
if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, granularity_new, st_ivas->renderer_type, st_ivas->intern_config, &st_ivas->hIntSetup, st_ivas->mc_mode, ism_mode_old, nSamplesFlushed,
#ifdef SPLIT_REND_WITH_HEAD_ROT
pcm_resolution,
if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, granularity_new, st_ivas->renderer_type, st_ivas->intern_config, &st_ivas->hIntSetup, st_ivas->mc_mode, ism_mode_old, nSamplesFlushed, pcm_resolution, data ) ) != IVAS_ERR_OK )
#else
if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, granularity_new, st_ivas->renderer_type, st_ivas->intern_config, &st_ivas->hIntSetup, st_ivas->mc_mode, ism_mode_old, nSamplesFlushed, data ) ) != IVAS_ERR_OK )
#endif
data ) ) != IVAS_ERR_OK )
{
return error;
}
/* restore correct values for the current frame*/
st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order );
st_ivas->hDecoderConfig->ivas_total_brate = ivas_total_brate;
......@@ -266,7 +271,7 @@ ivas_error ivas_sba_dec_reconfigure(
if ( ism_mode_old != ISM_SBA_MODE_DISC )
#endif
{
if ( st_ivas->hDirAC == NULL && st_ivas->hSpar != NULL ) // ToDo; this never happens
if ( st_ivas->hDirAC == NULL && st_ivas->hSpar != NULL )
{
st_ivas->hTcBuffer->num_slots = st_ivas->hSpar->num_slots;
st_ivas->hTcBuffer->nb_subframes = st_ivas->hSpar->nb_subframes;
......@@ -283,9 +288,11 @@ ivas_error ivas_sba_dec_reconfigure(
mvs2s( st_ivas->hSpatParamRendCom->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
}
}
/*-----------------------------------------------------------------*
* Allocate, initialize, and configure SBA handles
*-----------------------------------------------------------------*/
int16_t sba_order_internal;
SPAR_DEC_HANDLE hSpar;
hSpar = st_ivas->hSpar;
......@@ -302,7 +309,6 @@ ivas_error ivas_sba_dec_reconfigure(
if ( nchan_transport_old != ivas_get_sba_num_TCs( ivas_total_brate, sba_order_internal ) || ( last_ivas_total_brate >= IVAS_512k && ivas_total_brate < IVAS_512k ) || ( last_ivas_total_brate < IVAS_512k && ivas_total_brate >= IVAS_512k ) )
{
ivas_spar_dec_close( &( st_ivas->hSpar ), hDecoderConfig->output_Fs, 1 );
if ( ( error = ivas_spar_dec_open( st_ivas, 1 ) ) != IVAS_ERR_OK )
......@@ -310,12 +316,9 @@ ivas_error ivas_sba_dec_reconfigure(
return error;
}
}
else if ( last_ivas_total_brate < IVAS_24k4 && ivas_total_brate >= IVAS_24k4 )
{
num_channels = st_ivas->hSpar->hMdDec->spar_md_cfg.num_umx_chs;
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 );
......@@ -324,8 +327,8 @@ ivas_error ivas_sba_dec_reconfigure(
return error;
}
}
if ( ( hSpar->hPCA == NULL ) &&
( st_ivas->hDecoderConfig->ivas_total_brate == PCA_BRATE && st_ivas->sba_order == 1 ) && ( st_ivas->ivas_format == SBA_FORMAT ) )
if ( hSpar->hPCA == NULL && st_ivas->hDecoderConfig->ivas_total_brate == PCA_BRATE && st_ivas->sba_order == 1 && st_ivas->ivas_format == SBA_FORMAT )
{
if ( ( hSpar->hPCA = (PCA_DEC_STATE *) malloc( sizeof( PCA_DEC_STATE ) ) ) == NULL )
{
......@@ -334,6 +337,7 @@ ivas_error ivas_sba_dec_reconfigure(
ivas_pca_dec_init( hSpar->hPCA );
}
ivas_spar_config( ivas_total_brate, sba_order_internal, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &hSpar->core_nominal_brate, st_ivas->sid_format );
}
else
......@@ -355,7 +359,6 @@ ivas_error ivas_sba_dec_reconfigure(
st_ivas->hSpar->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered;
mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpar->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
#endif
if ( st_ivas->nchan_transport == 1 )
{
st_ivas->element_mode_init = IVAS_SCE;
......@@ -397,17 +400,17 @@ ivas_error ivas_sba_dec_reconfigure(
}
#ifdef JBM_FOR_OSBA
if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX && !st_ivas->hMonoDmxRenderer )
if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX && st_ivas->hMonoDmxRenderer == NULL )
{
if ( ( error = ivas_mono_dmx_renderer_open( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
}
if ( st_ivas->renderer_type != RENDERER_MONO_DOWNMIX && st_ivas->hMonoDmxRenderer != NULL )
if ( st_ivas->renderer_type != RENDERER_MONO_DOWNMIX )
{
free( st_ivas->hMonoDmxRenderer );
st_ivas->hMonoDmxRenderer = NULL;
ivas_mono_dmx_renderer_close( &st_ivas->hMonoDmxRenderer );
}
#endif
......@@ -487,6 +490,7 @@ ivas_error ivas_sba_dec_reconfigure(
if ( ism_mode_old == ISM_MODE_NONE && st_ivas->ism_mode == ISM_SBA_MODE_DISC )
{
int32_t temp_brate[MAX_SCE];
st_ivas->ism_mode = ISM_SBA_MODE_DISC;
if ( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nchan_ism, temp_brate ) ) != IVAS_ERR_OK )
{
......@@ -521,11 +525,7 @@ ivas_error ivas_sba_dec_reconfigure(
}
else
{
if ( st_ivas->hMonoDmxRenderer != NULL )
{
free( st_ivas->hMonoDmxRenderer );
st_ivas->hMonoDmxRenderer = NULL;
}
ivas_mono_dmx_renderer_close( &st_ivas->hMonoDmxRenderer );
}
if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV )
......@@ -561,12 +561,9 @@ ivas_error ivas_sba_dec_reconfigure(
if ( st_ivas->hBinRendererTd->HrFiltSet_p->ModelParams.modelROM == TRUE )
{
ivas_td_binaural_close( &st_ivas->hBinRendererTd );
if ( st_ivas->hHrtfTD != NULL )
{
st_ivas->hHrtfTD = NULL;
}
}
}
nchan_transport_old += st_ivas->nchan_ism;
st_ivas->ism_mode = ISM_MODE_NONE;
}
......@@ -624,14 +621,14 @@ ivas_error ivas_sba_dec_reconfigure(
}
/*-----------------------------------------------------------------*
* JBM TC buffer
* JBM TC buffers
*-----------------------------------------------------------------*/
if ( st_ivas->hDecoderConfig->Opt_5ms == 1
#ifdef JBM_FOR_OSBA
|| st_ivas->ivas_format == SBA_ISM_FORMAT
if ( st_ivas->hDecoderConfig->Opt_5ms == 1 || st_ivas->ivas_format == SBA_ISM_FORMAT )
#else
if ( st_ivas->hDecoderConfig->Opt_5ms == 1 )
#endif
)
{
int16_t tc_nchan_to_allocate;
int16_t tc_nchan_tc;
......@@ -660,11 +657,12 @@ ivas_error ivas_sba_dec_reconfigure(
{
tc_nchan_to_allocate = 2 * BINAURAL_CHANNELS;
}
else if ( st_ivas->ivas_format == SBA_FORMAT
#ifdef JBM_FOR_OSBA
|| st_ivas->ivas_format == SBA_ISM_FORMAT
else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT )
#else
else if ( st_ivas->ivas_format == SBA_FORMAT )
#endif
)
{
tc_nchan_to_allocate = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate );
#ifdef JBM_FOR_OSBA
......@@ -682,19 +680,17 @@ ivas_error ivas_sba_dec_reconfigure(
}
}
if ( tc_nchan_tc != st_ivas->hTcBuffer->nchan_transport_jbm || tc_nchan_to_allocate != st_ivas->hTcBuffer->nchan_transport_internal || tc_buffer_mode != st_ivas->hTcBuffer->tc_buffer_mode
#ifdef JBM_FOR_OSBA
|| granularity_new != st_ivas->hTcBuffer->n_samples_granularity
if ( tc_nchan_tc != st_ivas->hTcBuffer->nchan_transport_jbm || tc_nchan_to_allocate != st_ivas->hTcBuffer->nchan_transport_internal || tc_buffer_mode != st_ivas->hTcBuffer->tc_buffer_mode || granularity_new != st_ivas->hTcBuffer->n_samples_granularity )
#else
if ( tc_nchan_tc != st_ivas->hTcBuffer->nchan_transport_jbm || tc_nchan_to_allocate != st_ivas->hTcBuffer->nchan_transport_internal || tc_buffer_mode != st_ivas->hTcBuffer->tc_buffer_mode )
#endif
)
{
if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas, tc_buffer_mode, tc_nchan_tc, tc_nchan_to_allocate, tc_nchan_to_allocate,
#ifdef JBM_FOR_OSBA
granularity_new
if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas, tc_buffer_mode, tc_nchan_tc, tc_nchan_to_allocate, tc_nchan_to_allocate, granularity_new ) ) != IVAS_ERR_OK )
#else
NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS )
if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas, tc_buffer_mode, tc_nchan_tc, tc_nchan_to_allocate, tc_nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK )
#endif
) ) != IVAS_ERR_OK )
{
return error;
}
......@@ -736,6 +732,12 @@ ivas_error ivas_sba_dec_reconfigure(
{
nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate );
#ifdef NONBE_FIX_839_MC_RS_CHANNEL_ALLOC
if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK )
{
return error;
}
#else
if ( nchan_out_buff > nchan_out_buff_old )
{
for ( ch = nchan_out_buff_old; ch < nchan_out_buff; ch++ )
......@@ -755,9 +757,10 @@ ivas_error ivas_sba_dec_reconfigure(
st_ivas->p_output_f[ch] = NULL;
}
}
#endif
}
return error;
return IVAS_ERR_OK;
}
......@@ -767,31 +770,28 @@ ivas_error ivas_sba_dec_reconfigure(
*
*-------------------------------------------------------------------*/
ivas_error ivas_sba_dec_digest_tc(
void ivas_sba_dec_digest_tc(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
const int16_t nCldfbSlots, /* i : number of CLDFB slots */
const int16_t nSamplesForRendering /* i : number of samples provided */
)
{
int16_t ch_idx;
ivas_error error;
#ifdef NONBE_FIX_826_JBM_MASA_CNA_CNG
int16_t nchan_transport;
#endif
error = IVAS_ERR_OK;
/* set the md map */
if ( st_ivas->hDirAC )
{
ivas_dirac_dec_set_md_map( st_ivas, nCldfbSlots );
}
if ( st_ivas->ivas_format == SBA_FORMAT
#ifdef JBM_FOR_OSBA
|| st_ivas->ivas_format == SBA_ISM_FORMAT
if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT )
#else
if ( st_ivas->ivas_format == SBA_FORMAT )
#endif
)
{
ivas_spar_dec_digest_tc( st_ivas, st_ivas->nchan_transport, nCldfbSlots, nSamplesForRendering );
}
......@@ -858,7 +858,7 @@ ivas_error ivas_sba_dec_digest_tc(
generate_masking_noise_lb_dirac( st->hFdCngDec->hFdCngCom, st_ivas->hTcBuffer->tc[1], nCldfbSlots, st->cna_dirac_flag && st->flag_cna );
}
return error;
return;
}
......@@ -882,6 +882,7 @@ ivas_error 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;
......@@ -926,7 +927,10 @@ ivas_error 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 );
if ( ( error = ivas_sba_linear_renderer( output_f, *nSamplesRendered, st_ivas->hIntSetup.nchan_out_woLFE, 0, st_ivas->hDecoderConfig->output_config, st_ivas->hOutSetup ) ) != IVAS_ERR_OK )
{
return error;
}
}
if ( st_ivas->hDirAC != NULL && hSpar->slots_rendered == hSpar->num_slots )
......
......@@ -425,8 +425,6 @@ void ivas_ism2sba_sf(
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++ )
......@@ -471,7 +469,6 @@ ivas_error ivas_sba_upmixer_renderer(
ivas_error error;
push_wmops( "ivas_sba_upmixer_renderer" );
nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate );
/* Upmixer + Renderer */
......@@ -517,7 +514,7 @@ ivas_error ivas_sba_linear_renderer(
float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */
const int16_t output_frame, /* i : output frame length per channel */
const int16_t nchan_in, /* i : number of input ambisonics channels */
const int16_t nchan_ism,
const int16_t nchan_ism, /* i : number of objects */
const AUDIO_CONFIG output_config, /* i : output audio configuration */
const IVAS_OUTPUT_SETUP output_setup /* i : output format setup */
)
......
......@@ -211,13 +211,11 @@ ivas_error ivas_spar_dec_open(
}
/* allocate transport channels*/
if (
( st_ivas->hDecoderConfig->Opt_5ms
#ifdef JBM_FOR_OSBA
|| st_ivas->ivas_format == SBA_ISM_FORMAT
if ( ( st_ivas->hDecoderConfig->Opt_5ms || st_ivas->ivas_format == SBA_ISM_FORMAT ) && st_ivas->hTcBuffer == NULL )
#else
if ( ( st_ivas->hDecoderConfig->Opt_5ms ) && st_ivas->hTcBuffer == NULL )
#endif
) &&
st_ivas->hTcBuffer == NULL )
{
int16_t nchan_to_allocate;
int16_t nchan_tc;
......@@ -235,10 +233,7 @@ ivas_error ivas_spar_dec_open(
{
nchan_to_allocate += st_ivas->nchan_ism;
}
#endif
#ifdef JBM_FOR_OSBA
granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS );
#endif
......@@ -279,18 +274,11 @@ ivas_error ivas_spar_dec_open(
nchan_tc = 0;
nchan_to_allocate = 0;
}
#endif
if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas,
buffer_mode,
nchan_tc,
nchan_to_allocate,
nchan_to_allocate,
#ifdef JBM_FOR_OSBA
granularity
if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, granularity ) ) != IVAS_ERR_OK )
#else
NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS )
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 )
#endif
) ) != IVAS_ERR_OK )
{
return error;
}
......@@ -1424,6 +1412,7 @@ void ivas_spar_dec_upmixer(
nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport;
nchan_out = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe;
n_samples_sf = JBM_CLDFB_SLOTS_IN_SUBFRAME * NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS );
#ifdef JBM_FOR_OSBA
nchan_internal_total = nchan_internal;
sba_ch_offset = 0;
......@@ -1433,6 +1422,7 @@ void ivas_spar_dec_upmixer(
sba_ch_offset = st_ivas->nchan_ism;
}
#endif
for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ )
{
#ifdef JBM_FOR_OSBA
......@@ -1558,31 +1548,28 @@ void ivas_spar_dec_upmixer_sf(
)
{
int16_t cldfb_band, num_cldfb_bands, numch_in, numch_out;
float *cldfb_in_ts_re[MAX_OUTPUT_CHANNELS
#ifdef OSBA_ROOM_IR
+ MAX_NUM_OBJECTS
#endif
][CLDFB_NO_COL_MAX];
float *cldfb_in_ts_im[MAX_OUTPUT_CHANNELS
#ifdef OSBA_ROOM_IR
+ MAX_NUM_OBJECTS
float *cldfb_in_ts_re[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][CLDFB_NO_COL_MAX];
float *cldfb_in_ts_im[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][CLDFB_NO_COL_MAX];
#else
float *cldfb_in_ts_re[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX];
float *cldfb_in_ts_im[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX];
#endif
][CLDFB_NO_COL_MAX];
int16_t i, b, ts, out_ch, in_ch;
int16_t num_spar_bands, spar_band, nchan_transport;
int16_t num_in_ingest, split_band;
int16_t slot_size, slot_idx_start;
float *p_tc[MAX_OUTPUT_CHANNELS
#ifdef OSBA_ROOM_IR
+ MAX_NUM_OBJECTS
float *p_tc[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS];
#else
float *p_tc[MAX_OUTPUT_CHANNELS];
#endif
];
int16_t md_idx;
float Pcm_tmp[MAX_OUTPUT_CHANNELS
#ifdef OSBA_ROOM_IR
+ MAX_NUM_OBJECTS
float Pcm_tmp[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k];
#else
float Pcm_tmp[MAX_OUTPUT_CHANNELS][L_FRAME48k];
#endif
][L_FRAME48k];
int16_t numch_out_dirac;
float mixer_mat[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS];
int16_t b_skip_mat[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH];
......@@ -1602,6 +1589,7 @@ void ivas_spar_dec_upmixer_sf(
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;
#ifdef JBM_FOR_OSBA
if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC )
{
......@@ -1701,12 +1689,11 @@ void ivas_spar_dec_upmixer_sf(
if ( hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_FOA )
{
/* at this point, output channels are used as intermediate procesing buffers */
for ( in_ch = 0; in_ch < MAX_OUTPUT_CHANNELS
#ifdef OSBA_ROOM_IR
+ MAX_NUM_OBJECTS
for ( in_ch = 0; in_ch < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; in_ch++ )
#else
for ( in_ch = 0; in_ch < MAX_OUTPUT_CHANNELS; in_ch++ )
#endif
;
in_ch++ )
{
for ( ts = 0; ts < MAX_PARAM_SPATIAL_SUBFRAMES; ts++ )
{
......@@ -1749,14 +1736,10 @@ void ivas_spar_dec_upmixer_sf(
{
for ( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ )
{
cldfbAnalysis_ts(
&p_tc[in_ch][ts * num_cldfb_bands],
cldfb_in_ts_re[in_ch][ts],
cldfb_in_ts_im[in_ch][ts],
num_cldfb_bands,
st_ivas->cldfbAnaDec[in_ch] );
cldfbAnalysis_ts( &p_tc[in_ch][ts * num_cldfb_bands], cldfb_in_ts_re[in_ch][ts], cldfb_in_ts_im[in_ch][ts], num_cldfb_bands, st_ivas->cldfbAnaDec[in_ch] );
}
}
#ifdef OSBA_ROOM_IR
if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM )
{
......@@ -1765,12 +1748,7 @@ void ivas_spar_dec_upmixer_sf(
{
for ( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ )
{
cldfbAnalysis_ts(
&p_tc[in_ch][ts * num_cldfb_bands],
cldfb_in_ts_re[in_ch][ts],
cldfb_in_ts_im[in_ch][ts],
num_cldfb_bands,
st_ivas->cldfbAnaDec[in_ch] );
cldfbAnalysis_ts( &p_tc[in_ch][ts * num_cldfb_bands], cldfb_in_ts_re[in_ch][ts], cldfb_in_ts_im[in_ch][ts], num_cldfb_bands, st_ivas->cldfbAnaDec[in_ch] );
}
}
}
......@@ -1899,8 +1877,7 @@ void ivas_spar_dec_upmixer_sf(
}
else
{
if ( ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_FOA ||
!( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB
if ( ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_FOA || !( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB
#ifdef SPLIT_REND_WITH_HEAD_ROT
|| st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM
#endif
......