Skip to content
...@@ -163,6 +163,7 @@ ivas_error ivas_dirac_enc_open( ...@@ -163,6 +163,7 @@ ivas_error ivas_dirac_enc_open(
st_ivas->hDirAC = hDirAC; st_ivas->hDirAC = hDirAC;
st_ivas->hSpar->enc_param_start_band = st_ivas->hDirAC->hConfig->enc_param_start_band; st_ivas->hSpar->enc_param_start_band = st_ivas->hDirAC->hConfig->enc_param_start_band;
return error; return error;
} }
...@@ -280,7 +281,7 @@ void ivas_dirac_enc_close( ...@@ -280,7 +281,7 @@ void ivas_dirac_enc_close(
* *
*------------------------------------------------------------------------*/ *------------------------------------------------------------------------*/
void ivas_dirac_enc( ivas_error ivas_dirac_enc(
DIRAC_ENC_HANDLE hDirAC, /* i/o: encoder DirAC handle */ DIRAC_ENC_HANDLE hDirAC, /* i/o: encoder DirAC handle */
IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */
BSTR_ENC_HANDLE hMetaData, /* i/o: Metadata bitstream handle */ BSTR_ENC_HANDLE hMetaData, /* i/o: Metadata bitstream handle */
...@@ -290,12 +291,14 @@ void ivas_dirac_enc( ...@@ -290,12 +291,14 @@ void ivas_dirac_enc(
const int16_t input_frame, /* i : input frame length */ const int16_t input_frame, /* i : input frame length */
const int16_t dtx_vad, /* i : DTX vad flag */ const int16_t dtx_vad, /* i : DTX vad flag */
const IVAS_FORMAT ivas_format, /* i : ivas format */ const IVAS_FORMAT ivas_format, /* i : ivas format */
int16_t hodirac_flag ) /* i : hodirac flag */ const int16_t hodirac_flag /* i : hodirac flag */
)
{ {
int16_t orig_dirac_bands; int16_t orig_dirac_bands;
float dir[3], avg_dir[3]; float dir[3], avg_dir[3];
float energySum, vecLen; float energySum, vecLen;
int16_t i, j, b, i_ts; int16_t i, j, b, i_ts;
ivas_error error;
push_wmops( "ivas_dirac_enc" ); push_wmops( "ivas_dirac_enc" );
ivas_dirac_param_est_enc( hDirAC, hQMetaData->q_direction, hQMetaData->useLowerRes, data_f, ppIn_FR_real, ppIn_FR_imag, input_frame, ivas_format, hodirac_flag, hodirac_flag ? HOA2_CHANNELS : FOA_CHANNELS, &( hDirAC->mono_frame_count ), &( hQMetaData->dirac_mono_flag ) ); ivas_dirac_param_est_enc( hDirAC, hQMetaData->q_direction, hQMetaData->useLowerRes, data_f, ppIn_FR_real, ppIn_FR_imag, input_frame, ivas_format, hodirac_flag, hodirac_flag ? HOA2_CHANNELS : FOA_CHANNELS, &( hDirAC->mono_frame_count ), &( hQMetaData->dirac_mono_flag ) );
...@@ -323,7 +326,10 @@ void ivas_dirac_enc( ...@@ -323,7 +326,10 @@ void ivas_dirac_enc(
} }
} }
ivas_qmetadata_enc_encode( hMetaData, hQMetaData, hodirac_flag ); if ( ( error = ivas_qmetadata_enc_encode( hMetaData, hQMetaData, hodirac_flag ) ) != IVAS_ERR_OK )
{
return error;
}
} }
else else
{ {
...@@ -398,7 +404,7 @@ void ivas_dirac_enc( ...@@ -398,7 +404,7 @@ void ivas_dirac_enc(
} }
pop_wmops(); pop_wmops();
return; return IVAS_ERR_OK;
} }
...@@ -473,6 +479,7 @@ static int16_t ivas_dirac_get_mono_flag( ...@@ -473,6 +479,7 @@ static int16_t ivas_dirac_get_mono_flag(
} }
} }
} }
/* If any band contains multi-channel content it's not mono */ /* If any band contains multi-channel content it's not mono */
if ( any_mc_band ) if ( any_mc_band )
{ {
...@@ -486,6 +493,7 @@ static int16_t ivas_dirac_get_mono_flag( ...@@ -486,6 +493,7 @@ static int16_t ivas_dirac_get_mono_flag(
local_mono_flag = 1; local_mono_flag = 1;
} }
} }
/* Hysteresis - only after DIRAC_MONO_FRAME_THRESH frames on mono will the actual mono flag be set */ /* Hysteresis - only after DIRAC_MONO_FRAME_THRESH frames on mono will the actual mono flag be set */
if ( local_mono_flag ) if ( local_mono_flag )
{ {
...@@ -787,9 +795,7 @@ void ivas_dirac_param_est_enc( ...@@ -787,9 +795,7 @@ void ivas_dirac_param_est_enc(
} }
if ( !hodirac_flag ) if ( !hodirac_flag )
{ {
for ( band_m_idx = 0; band_m_idx < hDirAC->hConfig->nbands; band_m_idx++ ) for ( band_m_idx = 0; band_m_idx < hDirAC->hConfig->nbands; band_m_idx++ )
{ {
renormalization_factor[band_m_idx] = EPSILON; renormalization_factor[band_m_idx] = EPSILON;
......
...@@ -244,7 +244,7 @@ ivas_error ivas_enc( ...@@ -244,7 +244,7 @@ ivas_error ivas_enc(
/* SBA/MASA metadata encoding and SBA/MASA metadata bitstream writing */ /* SBA/MASA metadata encoding and SBA/MASA metadata bitstream writing */
hMetaData = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData : st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData; hMetaData = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData : st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData;
if ( st_ivas->hQMetaData != NULL && ivas_format != SBA_FORMAT ) if ( st_ivas->hQMetaData != NULL && ivas_format == MASA_FORMAT )
{ {
ivas_masa_estimate_energy( st_ivas->hMasa, data_f, input_frame, st_ivas->nchan_transport ); /* energy-estimation uses TF-resolution: 4x24 */ ivas_masa_estimate_energy( st_ivas->hMasa, data_f, input_frame, st_ivas->nchan_transport ); /* energy-estimation uses TF-resolution: 4x24 */
...@@ -252,8 +252,8 @@ ivas_error ivas_enc( ...@@ -252,8 +252,8 @@ ivas_error ivas_enc(
{ {
return error; return error;
} }
if ( ( error = ivas_masa_encode( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, &nb_bits_metadata[0], st_ivas->nchan_transport, ivas_format,
ivas_total_brate, hEncoderConfig->Opt_DTX_ON, st_ivas->nchan_transport == 2 ? st_ivas->hCPE[0]->element_mode : -1, if ( ( error = ivas_masa_encode( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, &nb_bits_metadata[0], st_ivas->nchan_transport, ivas_format, ivas_total_brate, hEncoderConfig->Opt_DTX_ON, st_ivas->nchan_transport == 2 ? st_ivas->hCPE[0]->element_mode : -1,
ISM_MODE_NONE, -1, NULL, -1, NULL, 0, 0 ) ) != IVAS_ERR_OK ) ISM_MODE_NONE, -1, NULL, -1, NULL, 0, 0 ) ) != IVAS_ERR_OK )
{ {
return error; return error;
...@@ -395,14 +395,13 @@ ivas_error ivas_enc( ...@@ -395,14 +395,13 @@ ivas_error ivas_enc(
#ifndef NONBE_CR_FIX_735_SBA_HP20_BRATE_SWITCHING #ifndef NONBE_CR_FIX_735_SBA_HP20_BRATE_SWITCHING
ivas_osba_enc_reconfig( st_ivas ); ivas_osba_enc_reconfig( st_ivas );
#endif #endif
/* Analyze objects and determine needed audio signals */ /* Analyze objects and determine needed audio signals */
ivas_osba_enc( st_ivas->hOSba, st_ivas->hIsmMetaData, data_f, input_frame, hEncoderConfig->nchan_ism, st_ivas->ism_mode, st_ivas->sba_analysis_order,
hEncoderConfig->input_Fs
#ifdef FIX_732_PLANAR_SBA_OSBA #ifdef FIX_732_PLANAR_SBA_OSBA
, ivas_osba_enc( st_ivas->hOSba, st_ivas->hIsmMetaData, data_f, input_frame, hEncoderConfig->nchan_ism, st_ivas->ism_mode, st_ivas->sba_analysis_order, hEncoderConfig->input_Fs, hEncoderConfig->sba_planar );
hEncoderConfig->sba_planar #else
ivas_osba_enc( st_ivas->hOSba, st_ivas->hIsmMetaData, data_f, input_frame, hEncoderConfig->nchan_ism, st_ivas->ism_mode, st_ivas->sba_analysis_order, hEncoderConfig->input_Fs );
#endif #endif
);
if ( st_ivas->ism_mode == ISM_MODE_NONE ) if ( st_ivas->ism_mode == ISM_MODE_NONE )
{ {
...@@ -479,7 +478,6 @@ ivas_error ivas_enc( ...@@ -479,7 +478,6 @@ ivas_error ivas_enc(
} }
else else
{ {
n = hEncoderConfig->nchan_ism; n = hEncoderConfig->nchan_ism;
#ifndef FIX_759_CODE_COVERAGE_OSBA #ifndef FIX_759_CODE_COVERAGE_OSBA
st = st_ivas->hCPE[0]->hCoreCoder[0]; st = st_ivas->hCPE[0]->hCoreCoder[0];
...@@ -640,9 +638,7 @@ ivas_error ivas_enc( ...@@ -640,9 +638,7 @@ ivas_error ivas_enc(
ivas_mcmasa_enc( st_ivas->hMcMasa, st_ivas->hQMetaData, st_ivas->hMasa, data_f, input_frame, st_ivas->nchan_transport, nchan_inp ); ivas_mcmasa_enc( st_ivas->hMcMasa, st_ivas->hQMetaData, st_ivas->hMasa, data_f, input_frame, st_ivas->nchan_transport, nchan_inp );
if ( ( error = ivas_masa_encode( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, &nb_bits_metadata[0], st_ivas->nchan_transport, ivas_format, ivas_total_brate, 0, -1, if ( ( error = ivas_masa_encode( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, &nb_bits_metadata[0], st_ivas->nchan_transport, ivas_format, ivas_total_brate, 0, -1,
ISM_MODE_NONE, -1, NULL, -1, NULL, 0, 0 ISM_MODE_NONE, -1, NULL, -1, NULL, 0, 0 ) ) != IVAS_ERR_OK )
) ) != IVAS_ERR_OK )
{ {
return error; return error;
} }
......
...@@ -115,6 +115,7 @@ ivas_error ivas_spar_covar_enc_open( ...@@ -115,6 +115,7 @@ ivas_error ivas_spar_covar_enc_open(
return error; return error;
} }
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
* ivas_spar_covar_enc_close() * ivas_spar_covar_enc_close()
* *
...@@ -295,9 +296,7 @@ void ivas_enc_cov_handler_process( ...@@ -295,9 +296,7 @@ void ivas_enc_cov_handler_process(
pFb->fb_bin_to_band.pp_short_stride_bin_to_band, pFb->fb_bin_to_band.pp_short_stride_bin_to_band,
pFb->fb_bin_to_band.p_short_stride_start_bin_per_band, pFb->fb_bin_to_band.p_short_stride_start_bin_per_band,
pFb->fb_bin_to_band.p_short_stride_num_bins_per_band, pFb->fb_bin_to_band.p_short_stride_num_bins_per_band,
start_band, end_band, start_band, end_band, cov_real, HOA_md_ind );
cov_real,
HOA_md_ind );
if ( is_sba ) if ( is_sba )
{ {
...@@ -413,7 +412,6 @@ static void ivas_band_cov( ...@@ -413,7 +412,6 @@ static void ivas_band_cov(
{ {
for ( j = i; j < num_chans; j++ ) for ( j = i; j < num_chans; j++ )
{ {
int16_t i1 = HOA_md_ind[i]; int16_t i1 = HOA_md_ind[i];
int16_t j1 = HOA_md_ind[j]; int16_t j1 = HOA_md_ind[j];
......
...@@ -208,6 +208,7 @@ static int16_t ivas_arithCoder_encode_array_diff( ...@@ -208,6 +208,7 @@ static int16_t ivas_arithCoder_encode_array_diff(
return -1; return -1;
} }
} }
return 0; return 0;
} }
......
...@@ -82,7 +82,6 @@ ivas_error front_vad( ...@@ -82,7 +82,6 @@ ivas_error front_vad(
ivas_error error; ivas_error error;
error = IVAS_ERR_OK; error = IVAS_ERR_OK;
push_wmops( "front_vad" ); push_wmops( "front_vad" );
if ( hCPE != NULL ) if ( hCPE != NULL )
...@@ -301,7 +300,6 @@ ivas_error front_vad_create( ...@@ -301,7 +300,6 @@ ivas_error front_vad_create(
set_f( hFrontVad->delay_buf, 0, hFrontVad->delay_samples ); set_f( hFrontVad->delay_buf, 0, hFrontVad->delay_samples );
} }
*hFrontVad_out = hFrontVad; *hFrontVad_out = hFrontVad;
return IVAS_ERR_OK; return IVAS_ERR_OK;
...@@ -388,9 +386,7 @@ ivas_error front_vad_spar( ...@@ -388,9 +386,7 @@ ivas_error front_vad_spar(
ivas_error error; ivas_error error;
push_wmops( "front_vad_SPAR" ); push_wmops( "front_vad_SPAR" );
error = IVAS_ERR_OK; error = IVAS_ERR_OK;
hFrontVad = hSpar->hFrontVad; hFrontVad = hSpar->hFrontVad;
st = hSpar->hCoreCoderVAD; st = hSpar->hCoreCoderVAD;
...@@ -493,6 +489,5 @@ ivas_error front_vad_spar( ...@@ -493,6 +489,5 @@ ivas_error front_vad_spar(
} }
pop_wmops(); pop_wmops();
return error; return error;
} }
...@@ -235,6 +235,7 @@ int16_t getNumChanAnalysis( ...@@ -235,6 +235,7 @@ int16_t getNumChanAnalysis(
{ {
n = st_ivas->hEncoderConfig->nchan_ism + ( st_ivas->sba_analysis_order + 1 ) * ( st_ivas->sba_analysis_order + 1 ); n = st_ivas->hEncoderConfig->nchan_ism + ( st_ivas->sba_analysis_order + 1 ) * ( st_ivas->sba_analysis_order + 1 );
} }
return n; return n;
} }
...@@ -377,6 +378,7 @@ ivas_error ivas_init_encoder( ...@@ -377,6 +378,7 @@ ivas_error ivas_init_encoder(
int16_t sce_id, cpe_id; int16_t sce_id, cpe_id;
IVAS_FORMAT ivas_format; IVAS_FORMAT ivas_format;
int32_t input_Fs, ivas_total_brate; int32_t input_Fs, ivas_total_brate;
int32_t element_brate_tmp[MAX_NUM_OBJECTS];
ENCODER_CONFIG_HANDLE hEncoderConfig; ENCODER_CONFIG_HANDLE hEncoderConfig;
ivas_error error; ivas_error error;
...@@ -488,7 +490,6 @@ ivas_error ivas_init_encoder( ...@@ -488,7 +490,6 @@ ivas_error ivas_init_encoder(
return error; return error;
} }
/* prepare stereo downmix for EVS */ /* prepare stereo downmix for EVS */
if ( hEncoderConfig->stereo_dmx_evs == 1 ) if ( hEncoderConfig->stereo_dmx_evs == 1 )
{ {
...@@ -512,8 +513,6 @@ ivas_error ivas_init_encoder( ...@@ -512,8 +513,6 @@ ivas_error ivas_init_encoder(
} }
else if ( ivas_format == ISM_FORMAT ) else if ( ivas_format == ISM_FORMAT )
{ {
int32_t element_brate_tmp[MAX_NUM_OBJECTS];
st_ivas->ism_mode = ivas_ism_mode_select( hEncoderConfig->nchan_inp, ivas_total_brate ); st_ivas->ism_mode = ivas_ism_mode_select( hEncoderConfig->nchan_inp, ivas_total_brate );
if ( ( error = ivas_ism_metadata_enc_create( st_ivas, hEncoderConfig->nchan_inp, element_brate_tmp ) ) != IVAS_ERR_OK ) if ( ( error = ivas_ism_metadata_enc_create( st_ivas, hEncoderConfig->nchan_inp, element_brate_tmp ) ) != IVAS_ERR_OK )
...@@ -598,7 +597,6 @@ ivas_error ivas_init_encoder( ...@@ -598,7 +597,6 @@ ivas_error ivas_init_encoder(
for ( n = 0; n < CPE_CHANNELS; n++ ) for ( n = 0; n < CPE_CHANNELS; n++ )
{ {
if ( hEncoderConfig->Opt_DTX_ON ) if ( hEncoderConfig->Opt_DTX_ON )
{ {
st_ivas->hCPE[cpe_id]->hCoreCoder[n]->cng_sba_flag = 1; st_ivas->hCPE[cpe_id]->hCoreCoder[n]->cng_sba_flag = 1;
...@@ -616,7 +614,6 @@ ivas_error ivas_init_encoder( ...@@ -616,7 +614,6 @@ ivas_error ivas_init_encoder(
} }
else if ( ivas_format == MASA_ISM_FORMAT ) else if ( ivas_format == MASA_ISM_FORMAT )
{ {
int32_t element_brate_tmp[MAX_NUM_OBJECTS];
int32_t ism_total_brate; int32_t ism_total_brate;
int16_t k; int16_t k;
...@@ -677,7 +674,6 @@ ivas_error ivas_init_encoder( ...@@ -677,7 +674,6 @@ ivas_error ivas_init_encoder(
} }
else if ( ivas_format == SBA_ISM_FORMAT ) else if ( ivas_format == SBA_ISM_FORMAT )
{ {
int32_t element_brate_tmp[MAX_NUM_OBJECTS];
st_ivas->ism_mode = ISM_MODE_NONE; st_ivas->ism_mode = ISM_MODE_NONE;
if ( ivas_total_brate >= IVAS_256k ) if ( ivas_total_brate >= IVAS_256k )
...@@ -710,12 +706,10 @@ ivas_error ivas_init_encoder( ...@@ -710,12 +706,10 @@ ivas_error ivas_init_encoder(
if ( st_ivas->ism_mode == ISM_MODE_NONE ) if ( st_ivas->ism_mode == ISM_MODE_NONE )
{ {
sce_id = 0;
/* allocate and initialize SBA core-coders */ /* allocate and initialize SBA core-coders */
if ( st_ivas->nchan_transport == 1 ) if ( st_ivas->nchan_transport == 1 )
{ {
if ( ( error = create_sce_enc( st_ivas, 0, ivas_total_brate ) ) != IVAS_ERR_OK )
if ( ( error = create_sce_enc( st_ivas, sce_id, ivas_total_brate ) ) != IVAS_ERR_OK )
{ {
return error; return error;
} }
...@@ -740,7 +734,6 @@ ivas_error ivas_init_encoder( ...@@ -740,7 +734,6 @@ ivas_error ivas_init_encoder(
else else
{ {
/* allocate and initialize MCT core coder */ /* allocate and initialize MCT core coder */
st_ivas->nCPE += ( st_ivas->hEncoderConfig->nchan_ism + 1 ) >> 1; st_ivas->nCPE += ( st_ivas->hEncoderConfig->nchan_ism + 1 ) >> 1;
for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
......
...@@ -167,9 +167,7 @@ int16_t ivas_ism_dtx_enc( ...@@ -167,9 +167,7 @@ int16_t ivas_ism_dtx_enc(
if ( dtx_flag ) if ( dtx_flag )
{ {
/* reset the bitstream (IVAS format signaling was already written) */ /* reset the bitstream (IVAS format signaling was already written) */
reset_indices_enc( hSCE[0]->hCoreCoder[0]->hBstr, reset_indices_enc( hSCE[0]->hCoreCoder[0]->hBstr, hSCE[0]->hCoreCoder[0]->hBstr->nb_ind_tot );
hSCE[0]->hCoreCoder[0]->hBstr->nb_ind_tot );
} }
/*------------------------------------------------------------------* /*------------------------------------------------------------------*
......
...@@ -348,6 +348,7 @@ ivas_error ivas_ism_enc( ...@@ -348,6 +348,7 @@ ivas_error ivas_ism_enc(
/*----------------------------------------------------------------* /*----------------------------------------------------------------*
* Core codec configuration * Core codec configuration
*----------------------------------------------------------------*/ *----------------------------------------------------------------*/
#ifdef IGF_MEMORY_ALLOC_OPT #ifdef IGF_MEMORY_ALLOC_OPT
/* IGF reconfiguration */ /* IGF reconfiguration */
if ( hSCE->last_element_brate != hSCE->element_brate || st->last_bwidth != st->bwidth ) if ( hSCE->last_element_brate != hSCE->element_brate || st->last_bwidth != st->bwidth )
...@@ -504,8 +505,7 @@ ivas_error ivas_ism_enc_config( ...@@ -504,8 +505,7 @@ ivas_error ivas_ism_enc_config(
st_ivas->nSCE = st_ivas->nchan_transport; st_ivas->nSCE = st_ivas->nchan_transport;
st_ivas->nCPE = 0; st_ivas->nCPE = 0;
if ( ( error = ivas_ism_config( st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hEncoderConfig->nchan_inp, NULL, 0, NULL, NULL, element_brate_tmp, NULL, NULL, if ( ( error = ivas_ism_config( st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hEncoderConfig->nchan_inp, NULL, 0, NULL, NULL, element_brate_tmp, NULL, NULL, 0 ) ) != IVAS_ERR_OK )
0 ) ) != IVAS_ERR_OK )
{ {
return error; return error;
} }
......
...@@ -137,8 +137,7 @@ ivas_error ivas_masa_enc_open( ...@@ -137,8 +137,7 @@ ivas_error ivas_masa_enc_open(
} }
} }
ivas_masa_set_elements( st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, st_ivas->hQMetaData, &hEncoderConfig->element_mode_init, &st_ivas->nSCE, &st_ivas->nCPE, ivas_masa_set_elements( st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, st_ivas->hQMetaData, &hEncoderConfig->element_mode_init, &st_ivas->nSCE, &st_ivas->nCPE, hEncoderConfig->ivas_format, st_ivas->ism_mode, ism_total_brate );
hEncoderConfig->ivas_format, st_ivas->ism_mode, ism_total_brate );
mvs2s( DirAC_block_grouping, hMasa->config.block_grouping, MAX_PARAM_SPATIAL_SUBFRAMES + 1 ); mvs2s( DirAC_block_grouping, hMasa->config.block_grouping, MAX_PARAM_SPATIAL_SUBFRAMES + 1 );
mvs2s( MASA_band_grouping_24, hMasa->config.band_grouping, MASA_FREQUENCY_BANDS + 1 ); mvs2s( MASA_band_grouping_24, hMasa->config.band_grouping, MASA_FREQUENCY_BANDS + 1 );
...@@ -253,6 +252,7 @@ ivas_error ivas_masa_encode( ...@@ -253,6 +252,7 @@ ivas_error ivas_masa_encode(
int16_t masa_sid_descriptor; int16_t masa_sid_descriptor;
int16_t low_bitrate_mode; int16_t low_bitrate_mode;
int32_t masa_total_brate; int32_t masa_total_brate;
ivas_error error;
masa_sid_descriptor = -1; masa_sid_descriptor = -1;
h_orig_metadata = NULL; h_orig_metadata = NULL;
...@@ -475,8 +475,7 @@ ivas_error ivas_masa_encode( ...@@ -475,8 +475,7 @@ ivas_error ivas_masa_encode(
if ( ivas_format == MASA_ISM_FORMAT && ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) if ( ivas_format == MASA_ISM_FORMAT && ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ )
{ {
/* encode MASA/ISM energy ratios */ /* encode MASA/ISM energy ratios */
ivas_encode_masaism_metadata( hMasa, hQMetaData, hMetaData, hIsmMetaData, nchan_ism, low_bitrate_mode, hOMasa->nCodingBands, hOMasa->nSubframes, ivas_encode_masaism_metadata( hMasa, hQMetaData, hMetaData, hIsmMetaData, nchan_ism, low_bitrate_mode, hOMasa->nCodingBands, hOMasa->nSubframes, idx_separated_object, ism_imp );
idx_separated_object, ism_imp );
} }
else else
{ {
...@@ -497,16 +496,25 @@ ivas_error ivas_masa_encode( ...@@ -497,16 +496,25 @@ ivas_error ivas_masa_encode(
{ {
if ( masa_total_brate >= IVAS_512k ) if ( masa_total_brate >= IVAS_512k )
{ {
ivas_qmetadata_enc_encode_hr_384_512( hMetaData, hQMetaData, 16, 4 ); if ( ( error = ivas_qmetadata_enc_encode_hr_384_512( hMetaData, hQMetaData, 16, 4 ) ) != IVAS_ERR_OK )
{
return error;
}
} }
else else
{ {
ivas_qmetadata_enc_encode_hr_384_512( hMetaData, hQMetaData, 11, 3 ); if ( ( error = ivas_qmetadata_enc_encode_hr_384_512( hMetaData, hQMetaData, 11, 3 ) ) != IVAS_ERR_OK )
{
return error;
}
} }
} }
else else
{ {
ivas_qmetadata_enc_encode( hMetaData, hQMetaData, 0 ); if ( ( error = ivas_qmetadata_enc_encode( hMetaData, hQMetaData, 0 ) ) != IVAS_ERR_OK )
{
return error;
}
} }
if ( ivas_format == MASA_ISM_FORMAT && ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) if ( ivas_format == MASA_ISM_FORMAT && ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ )
...@@ -691,8 +699,8 @@ ivas_error ivas_masa_enc_config( ...@@ -691,8 +699,8 @@ ivas_error ivas_masa_enc_config(
} }
} }
ivas_masa_set_elements( ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, hQMetaData, &st_ivas->hEncoderConfig->element_mode_init, &st_ivas->nSCE, &st_ivas->nCPE, ivas_masa_set_elements( ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, hQMetaData, &st_ivas->hEncoderConfig->element_mode_init, &st_ivas->nSCE, &st_ivas->nCPE, ivas_format, st_ivas->ism_mode, ism_total_brate );
ivas_format, st_ivas->ism_mode, ism_total_brate );
hQMetaData->is_masa_ivas_format = 1; hQMetaData->is_masa_ivas_format = 1;
if ( ivas_format == MASA_FORMAT || ivas_format == MASA_ISM_FORMAT ) if ( ivas_format == MASA_FORMAT || ivas_format == MASA_ISM_FORMAT )
...@@ -856,7 +864,6 @@ ivas_error ivas_masa_enc_config( ...@@ -856,7 +864,6 @@ ivas_error ivas_masa_enc_config(
set_c( (int8_t *) hMasa->data.twoDirBands, 1, hMasa->config.numCodingBands ); set_c( (int8_t *) hMasa->data.twoDirBands, 1, hMasa->config.numCodingBands );
} }
/* Transmit stereo signals using a mono downmix at lowest bitrates */ /* Transmit stereo signals using a mono downmix at lowest bitrates */
if ( ( ivas_format == MASA_FORMAT || ivas_format == MASA_ISM_FORMAT ) && st_ivas->nCPE == 1 && st_ivas->hCPE[0]->hStereoDft != NULL && st_ivas->hCPE[0]->hStereoDft->hConfig != NULL ) if ( ( ivas_format == MASA_FORMAT || ivas_format == MASA_ISM_FORMAT ) && st_ivas->nCPE == 1 && st_ivas->hCPE[0]->hStereoDft != NULL && st_ivas->hCPE[0]->hStereoDft->hConfig != NULL )
{ {
...@@ -974,6 +981,7 @@ static void combine_freqbands_and_subframes( ...@@ -974,6 +981,7 @@ static void combine_freqbands_and_subframes(
} }
} }
} }
if ( numCodingBands <= MAX_REDUCED_NBANDS ) if ( numCodingBands <= MAX_REDUCED_NBANDS )
{ {
/* reduce metadata *frequency* resolution. time resolution is not touched */ /* reduce metadata *frequency* resolution. time resolution is not touched */
...@@ -1109,6 +1117,13 @@ static void combine_freqbands_and_subframes( ...@@ -1109,6 +1117,13 @@ static void combine_freqbands_and_subframes(
return; return;
} }
/*-------------------------------------------------------------------*
* ivas_masa_combine_directions()
*
*
*-------------------------------------------------------------------*/
void ivas_masa_combine_directions( void ivas_masa_combine_directions(
MASA_ENCODER_HANDLE hMasa ) MASA_ENCODER_HANDLE hMasa )
{ {
...@@ -1467,10 +1482,7 @@ static void detect_metadata_composition( ...@@ -1467,10 +1482,7 @@ static void detect_metadata_composition(
/* Check surround coherence separately if we do not have already knowledge of coherence */ /* Check surround coherence separately if we do not have already knowledge of coherence */
if ( cohPresent == FALSE ) if ( cohPresent == FALSE )
{ {
cohPresent = ivas_masa_surrcoh_signicant( hMeta->common_meta.surround_coherence, cohPresent = ivas_masa_surrcoh_signicant( hMeta->common_meta.surround_coherence, hMeta->common_meta.diffuse_to_total_ratio, nSubFrames, MASA_FREQUENCY_BANDS );
hMeta->common_meta.diffuse_to_total_ratio,
nSubFrames,
MASA_FREQUENCY_BANDS );
} }
/* Set output flags */ /* Set output flags */
...@@ -1982,8 +1994,7 @@ void ivas_masa_enc_reconfigure( ...@@ -1982,8 +1994,7 @@ void ivas_masa_enc_reconfigure(
} }
} }
ivas_masa_set_elements( ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, st_ivas->hQMetaData, &tmp, &tmp, &tmp, ivas_masa_set_elements( ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, st_ivas->hQMetaData, &tmp, &tmp, &tmp, st_ivas->hEncoderConfig->ivas_format, st_ivas->ism_mode, ism_total_brate );
st_ivas->hEncoderConfig->ivas_format, st_ivas->ism_mode, ism_total_brate );
} }
return; return;
...@@ -2617,8 +2628,10 @@ void ivas_merge_masa_metadata( ...@@ -2617,8 +2628,10 @@ void ivas_merge_masa_metadata(
{ {
energyTimesRatioMASA[1] = 0.0f; energyTimesRatioMASA[1] = 0.0f;
} }
/* target is original MASA diffuseness */ /* target is original MASA diffuseness */
total_diff_nrg = eneBand * hMeta->common_meta.diffuse_to_total_ratio[sf][band]; total_diff_nrg = eneBand * hMeta->common_meta.diffuse_to_total_ratio[sf][band];
/* criterion is mean of ISM ratio and new ratio */ /* criterion is mean of ISM ratio and new ratio */
energyTimesRatioISM = ( hOMasaMeta->directional_meta[0].energy_ratio[sf][band] + ( 1.0f - total_diff_nrg / ( EPSILON + eneBand + hMasa->data.hOmasaData->energy_ism[sf][band] ) ) ) / 2.0f * hMasa->data.hOmasaData->energy_ism[sf][band]; energyTimesRatioISM = ( hOMasaMeta->directional_meta[0].energy_ratio[sf][band] + ( 1.0f - total_diff_nrg / ( EPSILON + eneBand + hMasa->data.hOmasaData->energy_ism[sf][band] ) ) ) / 2.0f * hMasa->data.hOmasaData->energy_ism[sf][band];
...@@ -3605,7 +3618,9 @@ static void ivas_encode_masaism_metadata( ...@@ -3605,7 +3618,9 @@ static void ivas_encode_masaism_metadata(
} }
} }
} }
calculate_nbits_meta( nchan_ism, hOmasaData->q_energy_ratio_ism, hOmasaData->masa_to_total_energy_ratio, numSf, numCodingBands, bits_ism, idx_separated_object, ism_imp ); calculate_nbits_meta( nchan_ism, hOmasaData->q_energy_ratio_ism, hOmasaData->masa_to_total_energy_ratio, numSf, numCodingBands, bits_ism, idx_separated_object, ism_imp );
/* quantize directions */ /* quantize directions */
for ( obj = 0; obj < nchan_ism; obj++ ) for ( obj = 0; obj < nchan_ism; obj++ )
{ {
......
...@@ -216,6 +216,7 @@ ivas_error ivas_mct_enc( ...@@ -216,6 +216,7 @@ ivas_error ivas_mct_enc(
} }
} }
} }
/* reconfiguration in case of bitrate switching */ /* reconfiguration in case of bitrate switching */
if ( ivas_total_brate != st_ivas->hEncoderConfig->last_ivas_total_brate ) if ( ivas_total_brate != st_ivas->hEncoderConfig->last_ivas_total_brate )
{ {
...@@ -266,6 +267,7 @@ ivas_error ivas_mct_enc( ...@@ -266,6 +267,7 @@ ivas_error ivas_mct_enc(
{ {
hCPE->hCoreCoder[0]->hBstr->ind_list = st_ivas->hCPE[cpe_id - 1]->hCoreCoder[1]->hBstr->ind_list + st_ivas->hCPE[cpe_id - 1]->hCoreCoder[1]->hBstr->nb_ind_tot; hCPE->hCoreCoder[0]->hBstr->ind_list = st_ivas->hCPE[cpe_id - 1]->hCoreCoder[1]->hBstr->ind_list + st_ivas->hCPE[cpe_id - 1]->hCoreCoder[1]->hBstr->nb_ind_tot;
} }
ivas_mdct_quant_coder( hCPE, hMCT->tnsBits[cpe_id], hMCT->tnsSize[cpe_id], hMCT->p_param[cpe_id], 1 ); ivas_mdct_quant_coder( hCPE, hMCT->tnsBits[cpe_id], hMCT->tnsSize[cpe_id], hMCT->p_param[cpe_id], 1 );
/* update input samples buffer (as done in ivas_cpe_enc() for other than MCT coding) */ /* update input samples buffer (as done in ivas_cpe_enc() for other than MCT coding) */
...@@ -348,13 +350,13 @@ ivas_error create_mct_enc( ...@@ -348,13 +350,13 @@ ivas_error create_mct_enc(
} }
cp_bitrate = ivas_total_brate / hMCT->nchan_out_woLFE * CPE_CHANNELS; cp_bitrate = ivas_total_brate / hMCT->nchan_out_woLFE * CPE_CHANNELS;
#ifdef NONBE_FIX_752_OSBA_MISCONFIG_MCT #ifdef NONBE_FIX_752_OSBA_MISCONFIG_MCT
if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC )
{ {
cp_bitrate = ivas_total_brate / st_ivas->nchan_transport * CPE_CHANNELS; cp_bitrate = ivas_total_brate / st_ivas->nchan_transport * CPE_CHANNELS;
} }
#endif #endif
for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{ {
for ( n = 0; n < CPE_CHANNELS; n++ ) for ( n = 0; n < CPE_CHANNELS; n++ )
...@@ -744,6 +746,7 @@ static ivas_error ivas_mc_enc_reconfig( ...@@ -744,6 +746,7 @@ static ivas_error ivas_mc_enc_reconfig(
ivas_param_mc_enc_close( &( st_ivas->hParamMC ), st_ivas->hEncoderConfig->input_Fs ); ivas_param_mc_enc_close( &( st_ivas->hParamMC ), st_ivas->hEncoderConfig->input_Fs );
ivas_mc_paramupmix_enc_close( &( st_ivas->hMCParamUpmix ), st_ivas->hEncoderConfig->input_Fs ); ivas_mc_paramupmix_enc_close( &( st_ivas->hMCParamUpmix ), st_ivas->hEncoderConfig->input_Fs );
/* De-allocate McMasa-related handles */ /* De-allocate McMasa-related handles */
ivas_mcmasa_enc_close( &( st_ivas->hMcMasa ), st_ivas->hEncoderConfig->input_Fs ); ivas_mcmasa_enc_close( &( st_ivas->hMcMasa ), st_ivas->hEncoderConfig->input_Fs );
...@@ -822,7 +825,9 @@ static ivas_error ivas_mc_enc_reconfig( ...@@ -822,7 +825,9 @@ static ivas_error ivas_mc_enc_reconfig(
ivas_masa_enc_close( &( st_ivas->hMasa ) ); ivas_masa_enc_close( &( st_ivas->hMasa ) );
st_ivas->hMasa = NULL; st_ivas->hMasa = NULL;
} }
ivas_mc_paramupmix_enc_close( &( st_ivas->hMCParamUpmix ), st_ivas->hEncoderConfig->input_Fs ); ivas_mc_paramupmix_enc_close( &( st_ivas->hMCParamUpmix ), st_ivas->hEncoderConfig->input_Fs );
if ( last_mc_mode == MC_MODE_PARAMUPMIX && st_ivas->hLFE != NULL ) if ( last_mc_mode == MC_MODE_PARAMUPMIX && st_ivas->hLFE != NULL )
{ {
/* LFE handle */ /* LFE handle */
...@@ -874,7 +879,9 @@ static ivas_error ivas_mc_enc_reconfig( ...@@ -874,7 +879,9 @@ static ivas_error ivas_mc_enc_reconfig(
} }
ivas_param_mc_enc_close( &( st_ivas->hParamMC ), st_ivas->hEncoderConfig->input_Fs ); ivas_param_mc_enc_close( &( st_ivas->hParamMC ), st_ivas->hEncoderConfig->input_Fs );
ivas_mc_paramupmix_enc_close( &( st_ivas->hMCParamUpmix ), st_ivas->hEncoderConfig->input_Fs ); ivas_mc_paramupmix_enc_close( &( st_ivas->hMCParamUpmix ), st_ivas->hEncoderConfig->input_Fs );
if ( last_mc_mode == MC_MODE_PARAMUPMIX && st_ivas->hLFE != NULL ) if ( last_mc_mode == MC_MODE_PARAMUPMIX && st_ivas->hLFE != NULL )
{ {
/* LFE handle */ /* LFE handle */
...@@ -942,9 +949,11 @@ static ivas_error ivas_mc_enc_reconfig( ...@@ -942,9 +949,11 @@ static ivas_error ivas_mc_enc_reconfig(
} }
st->igf = getIgfPresent( st->element_mode, st->total_brate, st->bwidth, st->rf_mode ); st->igf = getIgfPresent( st->element_mode, st->total_brate, st->bwidth, st->rf_mode );
/* set last core to TCX20 */ /* set last core to TCX20 */
st->last_core = TCX_20_CORE; st->last_core = TCX_20_CORE;
} }
if ( st_ivas->mc_mode == MC_MODE_MCMASA ) if ( st_ivas->mc_mode == MC_MODE_MCMASA )
{ {
ivas_mcmasa_split_brate( st_ivas->hMcMasa->separateChannelEnabled, st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->nSCE, st_ivas->nCPE, &new_brate_SCE, &new_brate_CPE ); ivas_mcmasa_split_brate( st_ivas->hMcMasa->separateChannelEnabled, st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->nSCE, st_ivas->nCPE, &new_brate_SCE, &new_brate_CPE );
......
...@@ -39,6 +39,11 @@ ...@@ -39,6 +39,11 @@
#include "wmc_auto.h" #include "wmc_auto.h"
#include <assert.h> #include <assert.h>
/*--------------------------------------------------------------*
* Local constants
*---------------------------------------------------------------*/
#define SPAR_CORR_THRES 0.9f #define SPAR_CORR_THRES 0.9f
#define DEFAULT_CORR_THRES 0.3f #define DEFAULT_CORR_THRES 0.3f
...@@ -224,11 +229,9 @@ static void getBestCorrelation( ...@@ -224,11 +229,9 @@ static void getBestCorrelation(
*_ch2 = -1; *_ch2 = -1;
*max_corr = 0.f; *max_corr = 0.f;
for ( ch1 = 0; ch1 < ( hMCT->nchan_out_woLFE ); for ( ch1 = 0; ch1 < ( hMCT->nchan_out_woLFE ); ch1++ )
ch1++ )
{ {
for ( ch2 = ch1 + 1; ch2 < ( hMCT->nchan_out_woLFE ); for ( ch2 = ch1 + 1; ch2 < ( hMCT->nchan_out_woLFE ); ch2++ )
ch2++ )
{ {
if ( fabsf( *max_corr ) < fabsf( xCorrMatrix[ch1][ch2] ) ) if ( fabsf( *max_corr ) < fabsf( xCorrMatrix[ch1][ch2] ) )
{ {
...@@ -309,11 +312,9 @@ static void updateCorrelationMatrix( ...@@ -309,11 +312,9 @@ static void updateCorrelationMatrix(
int16_t ch1, ch2, n; int16_t ch1, ch2, n;
/* correlation: */ /* correlation: */
for ( ch1 = 0; ch1 < ( hMCT->nchan_out_woLFE ); for ( ch1 = 0; ch1 < ( hMCT->nchan_out_woLFE ); ch1++ )
ch1++ )
{ {
for ( ch2 = ch1; ch2 < ( hMCT->nchan_out_woLFE ); for ( ch2 = ch1; ch2 < ( hMCT->nchan_out_woLFE ); ch2++ )
ch2++ )
{ {
if ( sts[ch1]->core == sts[ch2]->core && sts[ch1]->mct_chan_mode != MCT_CHAN_MODE_IGNORE && if ( sts[ch1]->core == sts[ch2]->core && sts[ch1]->mct_chan_mode != MCT_CHAN_MODE_IGNORE &&
sts[ch2]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) sts[ch2]->mct_chan_mode != MCT_CHAN_MODE_IGNORE )
...@@ -766,8 +767,7 @@ void write_mct_bitstream( ...@@ -766,8 +767,7 @@ void write_mct_bitstream(
/* first write core info and overlap mode for all channels */ /* first write core info and overlap mode for all channels */
for ( ch = 0; ch < nchan; ch++ ) for ( ch = 0; ch < nchan; ch++ )
{ {
if ( if ( hMCT->currBlockDataCnt && sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE )
hMCT->currBlockDataCnt && sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE )
{ {
push_next_indice( hBstr, hMCT->mc_global_ild[ch], SMDCT_GLOBAL_ILD_BITS ); push_next_indice( hBstr, hMCT->mc_global_ild[ch], SMDCT_GLOBAL_ILD_BITS );
} }
...@@ -777,8 +777,7 @@ void write_mct_bitstream( ...@@ -777,8 +777,7 @@ void write_mct_bitstream(
{ {
for ( ch = 0; ch < nchan; ch++ ) for ( ch = 0; ch < nchan; ch++ )
{ {
if ( if ( sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE )
sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE )
{ {
push_next_indice( hBstr, hMCT->lowE_ch[ch], 1 ); push_next_indice( hBstr, hMCT->lowE_ch[ch], 1 );
} }
...@@ -898,8 +897,7 @@ void mctStereoIGF_enc( ...@@ -898,8 +897,7 @@ void mctStereoIGF_enc(
/* channel elements that are coded separately detected */ /* channel elements that are coded separately detected */
if ( sum_s( singleChEle, ( hMCT->nchan_out_woLFE ) ) != 0 ) if ( sum_s( singleChEle, ( hMCT->nchan_out_woLFE ) ) != 0 )
{ {
for ( ch = 0; ch < ( hMCT->nchan_out_woLFE ); for ( ch = 0; ch < ( hMCT->nchan_out_woLFE ); ch++ )
ch++ )
{ {
if ( singleChEle[ch] ) if ( singleChEle[ch] )
{ {
......
...@@ -90,7 +90,10 @@ ivas_error ivas_omasa_enc_open( ...@@ -90,7 +90,10 @@ ivas_error ivas_omasa_enc_open(
hOMasa->num_Cldfb_instances = numAnalysisChannels; hOMasa->num_Cldfb_instances = numAnalysisChannels;
for ( i = 0; i < hOMasa->num_Cldfb_instances; i++ ) for ( i = 0; i < hOMasa->num_Cldfb_instances; i++ )
{ {
openCldfb( &( hOMasa->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, st_ivas->hEncoderConfig->input_Fs, CLDFB_PROTOTYPE_5_00MS ); if ( ( error = openCldfb( &( hOMasa->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, st_ivas->hEncoderConfig->input_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK )
{
return error;
}
} }
/* intensity 3-dim */ /* intensity 3-dim */
......
...@@ -280,8 +280,9 @@ ivas_error ivas_osba_enc_reconfig( ...@@ -280,8 +280,9 @@ ivas_error ivas_osba_enc_reconfig(
old_mem_hp20_in = NULL; old_mem_hp20_in = NULL;
} }
} }
ivas_spar_config( ivas_total_brate, min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ),
&st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->hSpar->core_nominal_brate, -1 ); ivas_spar_config( ivas_total_brate, min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ), &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->hSpar->core_nominal_brate, -1 );
hSpar = st_ivas->hSpar; hSpar = st_ivas->hSpar;
if ( st_ivas->nchan_transport == 1 ) if ( st_ivas->nchan_transport == 1 )
...@@ -334,6 +335,7 @@ ivas_error ivas_osba_enc_reconfig( ...@@ -334,6 +335,7 @@ ivas_error ivas_osba_enc_reconfig(
/*-----------------------------------------------------------------* /*-----------------------------------------------------------------*
* Allocate, initialize, and configure SCE/CPE/MCT handles * Allocate, initialize, and configure SCE/CPE/MCT handles
*-----------------------------------------------------------------*/ *-----------------------------------------------------------------*/
if ( old_ism_mode == ISM_MODE_NONE && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) if ( old_ism_mode == ISM_MODE_NONE && st_ivas->ism_mode == ISM_SBA_MODE_DISC )
{ {
#ifndef NONBE_FIX_752_OSBA_MISCONFIG_MCT #ifndef NONBE_FIX_752_OSBA_MISCONFIG_MCT
......
...@@ -63,9 +63,7 @@ static int16_t ivas_qmetadata_entropy_encode_dir( BSTR_ENC_HANDLE hMetaData, IVA ...@@ -63,9 +63,7 @@ static int16_t ivas_qmetadata_entropy_encode_dir( BSTR_ENC_HANDLE hMetaData, IVA
static int16_t ivas_qmetadata_raw_encode_dir( BSTR_ENC_HANDLE hMetaData, IVAS_QDIRECTION *q_direction, const int16_t nbands, const int16_t start_band ); static int16_t ivas_qmetadata_raw_encode_dir( BSTR_ENC_HANDLE hMetaData, IVAS_QDIRECTION *q_direction, const int16_t nbands, const int16_t start_band );
int16_t int16_t ivas_qmetadata_encode_extended_gr_length( const uint16_t value, const uint16_t alphabet_size, const int16_t gr_param );
ivas_qmetadata_encode_extended_gr_length( const uint16_t value, const uint16_t alphabet_size, const int16_t gr_param );
static int16_t ivas_qmetadata_get_optimal_gr_param( uint16_t *unsigned_data, const int16_t count, const int16_t gr_param_count, int16_t *opt_gr_size ); static int16_t ivas_qmetadata_get_optimal_gr_param( uint16_t *unsigned_data, const int16_t count, const int16_t gr_param_count, int16_t *opt_gr_size );
...@@ -467,8 +465,7 @@ ivas_error ivas_qmetadata_enc_encode( ...@@ -467,8 +465,7 @@ ivas_error ivas_qmetadata_enc_encode(
/* Encode quantized directions with EC band-wise */ /* Encode quantized directions with EC band-wise */
if ( ( total_bits_1dir + bits_surround_coh <= hQMetaData->qmetadata_max_bit_req ) && ( bits_dir[d] + bits_diff[d] + bits_coherence[d] + bits_signaling[d] > total_bits_1dir ) && q_direction->cfg.nblocks > 1 ) if ( ( total_bits_1dir + bits_surround_coh <= hQMetaData->qmetadata_max_bit_req ) && ( bits_dir[d] + bits_diff[d] + bits_coherence[d] + bits_signaling[d] > total_bits_1dir ) && q_direction->cfg.nblocks > 1 )
{ {
restore_metadata_buffer( hMetaData, next_ind_start, restore_metadata_buffer( hMetaData, next_ind_start, bit_pos_start );
bit_pos_start );
/* Write signaling */ /* Write signaling */
push_next_indice( hMetaData, 1, 1 ); /*Write 1 bit to signal no EC frame-wise (EC1)*/ push_next_indice( hMetaData, 1, 1 ); /*Write 1 bit to signal no EC frame-wise (EC1)*/
...@@ -545,8 +542,7 @@ ivas_error ivas_qmetadata_enc_encode( ...@@ -545,8 +542,7 @@ ivas_error ivas_qmetadata_enc_encode(
/*Bit budget exceeded, bit reduction strategy?*/ /*Bit budget exceeded, bit reduction strategy?*/
extra_bits = 0; extra_bits = 0;
restore_metadata_buffer( hMetaData, next_ind_start, restore_metadata_buffer( hMetaData, next_ind_start, bit_pos_start );
bit_pos_start );
push_next_indice( hMetaData, 1, 1 ); /*Write 1 bit to signal no EC frame-wise (EC1)*/ push_next_indice( hMetaData, 1, 1 ); /*Write 1 bit to signal no EC frame-wise (EC1)*/
if ( nblocks > 1 ) if ( nblocks > 1 )
...@@ -985,7 +981,6 @@ void ivas_qmetadata_enc_sid_encode( ...@@ -985,7 +981,6 @@ void ivas_qmetadata_enc_sid_encode(
} }
else else
{ {
metadata_sid_bits = ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS; metadata_sid_bits = ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS;
} }
...@@ -2630,6 +2625,7 @@ static int16_t ivas_qmetadata_entropy_encode_dir( ...@@ -2630,6 +2625,7 @@ static int16_t ivas_qmetadata_entropy_encode_dir(
} }
avg_elevation_index = squant( abs_theta, &avg_elevation, theta_cb, no_th ); avg_elevation_index = squant( abs_theta, &avg_elevation, theta_cb, no_th );
if ( q_direction->cfg.mc_ls_setup != MC_LS_SETUP_INVALID ) if ( q_direction->cfg.mc_ls_setup != MC_LS_SETUP_INVALID )
{ {
assert( avg_elevation >= 0 ); assert( avg_elevation >= 0 );
...@@ -2646,7 +2642,9 @@ static int16_t ivas_qmetadata_entropy_encode_dir( ...@@ -2646,7 +2642,9 @@ static int16_t ivas_qmetadata_entropy_encode_dir(
} }
avg_elevation *= sign_th; avg_elevation *= sign_th;
} }
avg_azimuth_index = (uint16_t) ( quantize_phi( avg_azimuth + 180, 0, &avg_azimuth, avg_azimuth_alphabet ) ); avg_azimuth_index = (uint16_t) ( quantize_phi( avg_azimuth + 180, 0, &avg_azimuth, avg_azimuth_alphabet ) );
/* Elevation only if not 2D */ /* Elevation only if not 2D */
if ( q_direction->not_in_2D > 0 ) if ( q_direction->not_in_2D > 0 )
{ {
...@@ -2818,6 +2816,7 @@ static int16_t ivas_qmetadata_entropy_encode_dir( ...@@ -2818,6 +2816,7 @@ static int16_t ivas_qmetadata_entropy_encode_dir(
{ {
all_zero_dist_azimuth_indexes = 0; all_zero_dist_azimuth_indexes = 0;
} }
if ( ( idx >= MASA_LIMIT_IDX_AVG_AZI ) && ( q_direction->cfg.mc_ls_setup != MC_LS_SETUP_INVALID ) && ( use_adapt_avg == 1 ) ) if ( ( idx >= MASA_LIMIT_IDX_AVG_AZI ) && ( q_direction->cfg.mc_ls_setup != MC_LS_SETUP_INVALID ) && ( use_adapt_avg == 1 ) )
{ {
if ( idx % nblocks == 0 ) if ( idx % nblocks == 0 )
...@@ -4772,7 +4771,6 @@ static int16_t encode_spread_coherence_1sf( ...@@ -4772,7 +4771,6 @@ static int16_t encode_spread_coherence_1sf(
GR_ord = 1; GR_ord = 1;
idx_shift = 0; idx_shift = 0;
/* number of codevectors added dependent on number of subbands */ /* number of codevectors added dependent on number of subbands */
extra_cv = coding_subbands / MASA_FACTOR_CV_COH; extra_cv = coding_subbands / MASA_FACTOR_CV_COH;
for ( j = 0; j < coding_subbands; j++ ) for ( j = 0; j < coding_subbands; j++ )
...@@ -5331,7 +5329,6 @@ static int16_t encode_surround_coherence_hr( ...@@ -5331,7 +5329,6 @@ static int16_t encode_surround_coherence_hr(
} }
} }
return nbits; return nbits;
} }
......
...@@ -198,8 +198,9 @@ ivas_error ivas_sba_enc_reconfigure( ...@@ -198,8 +198,9 @@ ivas_error ivas_sba_enc_reconfigure(
old_mem_hp20_in = NULL; old_mem_hp20_in = NULL;
} }
} }
ivas_spar_config( ivas_total_brate, min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ),
&st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->hSpar->core_nominal_brate, -1 ); ivas_spar_config( ivas_total_brate, min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ), &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->hSpar->core_nominal_brate, -1 );
hSpar = st_ivas->hSpar; hSpar = st_ivas->hSpar;
if ( st_ivas->nchan_transport == 1 ) if ( st_ivas->nchan_transport == 1 )
......
...@@ -371,12 +371,11 @@ ivas_error create_sce_enc( ...@@ -371,12 +371,11 @@ ivas_error create_sce_enc(
st->total_brate = hSCE->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ st->total_brate = hSCE->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */
st->mct_chan_mode = MCT_CHAN_MODE_REGULAR; st->mct_chan_mode = MCT_CHAN_MODE_REGULAR;
if ( ( error = init_encoder( st, st_ivas, 0, st_ivas->hEncoderConfig->var_SID_rate_flag, st_ivas->hEncoderConfig->interval_SID, 0, st_ivas->ism_mode
#ifdef IGF_MEMORY_ALLOC_OPT #ifdef IGF_MEMORY_ALLOC_OPT
, if ( ( error = init_encoder( st, st_ivas, 0, st_ivas->hEncoderConfig->var_SID_rate_flag, st_ivas->hEncoderConfig->interval_SID, 0, st_ivas->ism_mode, hSCE->element_brate ) ) != IVAS_ERR_OK )
hSCE->element_brate #else
if ( ( error = init_encoder( st, st_ivas, 0, st_ivas->hEncoderConfig->var_SID_rate_flag, st_ivas->hEncoderConfig->interval_SID, 0, st_ivas->ism_mode ) ) != IVAS_ERR_OK )
#endif #endif
) ) != IVAS_ERR_OK )
{ {
return error; return error;
} }
......
...@@ -185,8 +185,7 @@ ivas_error ivas_spar_enc_open( ...@@ -185,8 +185,7 @@ ivas_error ivas_spar_enc_open(
* Configuration - set SPAR high-level parameters * Configuration - set SPAR high-level parameters
*-----------------------------------------------------------------*/ *-----------------------------------------------------------------*/
ivas_spar_config( hEncoderConfig->ivas_total_brate, min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ), ivas_spar_config( hEncoderConfig->ivas_total_brate, min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ), &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &hSpar->core_nominal_brate, -1 );
&st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &hSpar->core_nominal_brate, -1 );
if ( st_ivas->nchan_transport == 1 ) if ( st_ivas->nchan_transport == 1 )
{ {
...@@ -224,12 +223,11 @@ ivas_error ivas_spar_enc_open( ...@@ -224,12 +223,11 @@ ivas_error ivas_spar_enc_open(
hSpar->hCoreCoderVAD->total_brate = hEncoderConfig->ivas_total_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ hSpar->hCoreCoderVAD->total_brate = hEncoderConfig->ivas_total_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */
hSpar->hCoreCoderVAD->mct_chan_mode = MCT_CHAN_MODE_IGNORE; hSpar->hCoreCoderVAD->mct_chan_mode = MCT_CHAN_MODE_IGNORE;
if ( ( error = init_encoder( hSpar->hCoreCoderVAD, st_ivas, 0, hEncoderConfig->var_SID_rate_flag, hEncoderConfig->interval_SID, 1, st_ivas->ism_mode
#ifdef IGF_MEMORY_ALLOC_OPT #ifdef IGF_MEMORY_ALLOC_OPT
, if ( ( error = init_encoder( hSpar->hCoreCoderVAD, st_ivas, 0, hEncoderConfig->var_SID_rate_flag, hEncoderConfig->interval_SID, 1, st_ivas->ism_mode, hSpar->hCoreCoderVAD->total_brate ) ) != IVAS_ERR_OK )
hSpar->hCoreCoderVAD->total_brate #else
if ( ( error = init_encoder( hSpar->hCoreCoderVAD, st_ivas, 0, hEncoderConfig->var_SID_rate_flag, hEncoderConfig->interval_SID, 1, st_ivas->ism_mode ) ) != IVAS_ERR_OK )
#endif #endif
) ) != IVAS_ERR_OK )
{ {
return error; return error;
} }
...@@ -508,7 +506,10 @@ static ivas_error ivas_spar_cov_md_process( ...@@ -508,7 +506,10 @@ static ivas_error ivas_spar_cov_md_process(
if ( hSpar->hMdEnc->spar_hoa_md_flag == 0 ) if ( hSpar->hMdEnc->spar_hoa_md_flag == 0 )
{ {
ivas_spar_md_enc_process( hSpar->hMdEnc, hEncoderConfig, cov_real, cov_dtx_real, hMetaData, dtx_vad, nchan_inp, sba_order, hSpar->hFbMixer->prior_mixer, *dyn_active_w_flag, hQMetaData->dirac_mono_flag ); if ( ( error = ivas_spar_md_enc_process( hSpar->hMdEnc, hEncoderConfig, cov_real, cov_dtx_real, hMetaData, dtx_vad, nchan_inp, sba_order, hSpar->hFbMixer->prior_mixer, *dyn_active_w_flag, hQMetaData->dirac_mono_flag ) ) != IVAS_ERR_OK )
{
return error;
}
} }
if ( hSpar->hMdEnc->spar_hoa_dirac2spar_md_flag ) if ( hSpar->hMdEnc->spar_hoa_dirac2spar_md_flag )
...@@ -556,7 +557,7 @@ static ivas_error ivas_spar_cov_md_process( ...@@ -556,7 +557,7 @@ static ivas_error ivas_spar_cov_md_process(
if ( hSpar->hMdEnc->spar_hoa_md_flag ) if ( hSpar->hMdEnc->spar_hoa_md_flag )
{ {
ivas_spar_md_enc_process( hSpar->hMdEnc, hEncoderConfig, cov_real, cov_dtx_real, hMetaData, dtx_vad, nchan_inp, sba_order, hSpar->hFbMixer->prior_mixer, *dyn_active_w_flag, hQMetaData->dirac_mono_flag ); error = ivas_spar_md_enc_process( hSpar->hMdEnc, hEncoderConfig, cov_real, cov_dtx_real, hMetaData, dtx_vad, nchan_inp, sba_order, hSpar->hFbMixer->prior_mixer, *dyn_active_w_flag, hQMetaData->dirac_mono_flag );
} }
return error; return error;
...@@ -696,7 +697,10 @@ static ivas_error ivas_spar_enc_process( ...@@ -696,7 +697,10 @@ static ivas_error ivas_spar_enc_process(
hodirac_flag = ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ); hodirac_flag = ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order );
ivas_dirac_enc( st_ivas->hDirAC, hQMetaData, hMetaData, data_f, ppIn_FR_real, ppIn_FR_imag, input_frame, dtx_vad, hEncoderConfig->ivas_format, hodirac_flag ); if ( ( error = ivas_dirac_enc( st_ivas->hDirAC, hQMetaData, hMetaData, data_f, ppIn_FR_real, ppIn_FR_imag, input_frame, dtx_vad, hEncoderConfig->ivas_format, hodirac_flag ) ) != IVAS_ERR_OK )
{
return error;
}
/* Set Energy Ratio to 0.0 if the mono flag has been set */ /* Set Energy Ratio to 0.0 if the mono flag has been set */
if ( hQMetaData->dirac_mono_flag ) if ( hQMetaData->dirac_mono_flag )
......
...@@ -68,12 +68,11 @@ typedef enum ivas_strats_t ...@@ -68,12 +68,11 @@ typedef enum ivas_strats_t
static void ivas_band_mixer( float *cov_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], const int16_t num_ch, int16_t *num_bands, int16_t red_band_fact ); static void ivas_band_mixer( float *cov_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], const int16_t num_ch, int16_t *num_bands, int16_t red_band_fact );
static int16_t ivas_get_huffman_coded_bs( ivas_spar_md_enc_state_t *hMdEnc, BSTR_ENC_HANDLE hMetaData, const int16_t nB, const int16_t qsi, const int16_t bands_bw ); static int16_t ivas_get_huffman_coded_bs( ivas_spar_md_enc_state_t *hMdEnc, BSTR_ENC_HANDLE hMetaData, const int16_t nB, const int16_t qsi, const int16_t bands_bw );
static int16_t ivas_get_arith_coded_bs( ivas_spar_md_enc_state_t *hMdEnc, BSTR_ENC_HANDLE hMetaData, const int16_t *pDo_diff, const int16_t bands_bw, const int16_t nB, const int16_t qsi, const int16_t strat, const int32_t ivas_total_brate ); static int16_t ivas_get_arith_coded_bs( ivas_spar_md_enc_state_t *hMdEnc, BSTR_ENC_HANDLE hMetaData, const int16_t *pDo_diff, const int16_t bands_bw, const int16_t nB, const int16_t qsi, const int16_t strat, const int32_t ivas_total_brate );
static ivas_error ivas_spar_set_enc_config( ivas_spar_md_enc_state_t *hMdEnc, int16_t *max_freq_per_chan, const int16_t nchan_transport, float *pFC, const int16_t nchan_inp ); static void ivas_spar_set_enc_config( ivas_spar_md_enc_state_t *hMdEnc, int16_t *max_freq_per_chan, const int16_t nchan_transport, float *pFC, const int16_t nchan_inp );
static void ivas_select_next_strat( ivas_strats_t prior_strat, ivas_strats_t cs[MAX_QUANT_STRATS], const int16_t dmx_switch, const int16_t dtx_vad ); static void ivas_select_next_strat( ivas_strats_t prior_strat, ivas_strats_t cs[MAX_QUANT_STRATS], const int16_t dmx_switch, const int16_t dtx_vad );
...@@ -318,7 +317,7 @@ ivas_error ivas_spar_md_enc_init( ...@@ -318,7 +317,7 @@ ivas_error ivas_spar_md_enc_init(
* Set configuration for SPAR MD encoder * Set configuration for SPAR MD encoder
*-----------------------------------------------------------------------------------------*/ *-----------------------------------------------------------------------------------------*/
static ivas_error ivas_spar_set_enc_config( static void ivas_spar_set_enc_config(
ivas_spar_md_enc_state_t *hMdEnc, ivas_spar_md_enc_state_t *hMdEnc,
int16_t *max_freq_per_chan, int16_t *max_freq_per_chan,
const int16_t nchan_transport, const int16_t nchan_transport,
...@@ -357,7 +356,7 @@ static ivas_error ivas_spar_set_enc_config( ...@@ -357,7 +356,7 @@ static ivas_error ivas_spar_set_enc_config(
hMdEnc->spar_md_cfg.num_decorr_per_band[i] = hMdEnc->num_umx_ch - tmp_dmx_ch; hMdEnc->spar_md_cfg.num_decorr_per_band[i] = hMdEnc->num_umx_ch - tmp_dmx_ch;
} }
return IVAS_ERR_OK; return;
} }
...@@ -448,8 +447,7 @@ static void write_metadata_buffer( ...@@ -448,8 +447,7 @@ static void write_metadata_buffer(
if ( hMetaData->nb_bits_tot > 0 ) if ( hMetaData->nb_bits_tot > 0 )
{ {
restore_metadata_buffer( hMetaData, next_ind_start, restore_metadata_buffer( hMetaData, next_ind_start, bit_pos_start );
bit_pos_start );
} }
for ( i = 0; i < hMetaData_tmp->nb_ind_tot; i++ ) for ( i = 0; i < hMetaData_tmp->nb_ind_tot; i++ )
......
...@@ -481,9 +481,7 @@ void tdm_configure_enc( ...@@ -481,9 +481,7 @@ void tdm_configure_enc(
* bitbudget distribution between channels (taking into account also metadata bitbudget) * bitbudget distribution between channels (taking into account also metadata bitbudget)
*----------------------------------------------------------------*/ *----------------------------------------------------------------*/
tdm_bit_alloc( ivas_format, tdm_bit_alloc( ivas_format, ism_mode, hCPE->element_brate - nb_bits_metadata * FRAMES_PER_SEC + hCPE->brate_surplus,
ism_mode,
hCPE->element_brate - nb_bits_metadata * FRAMES_PER_SEC + hCPE->brate_surplus,
hStereoTD->tdm_lp_reuse_flag, &( sts[0]->total_brate ), &( sts[1]->total_brate ), hStereoTD->tdm_lp_reuse_flag, &( sts[0]->total_brate ), &( sts[1]->total_brate ),
&( hStereoTD->tdm_low_rate_mode ), sts[1]->coder_type, tdm_ratio_bit_alloc_idx, hStereoTD->tdm_Pitch_reuse_flag, &( hStereoTD->tdm_low_rate_mode ), sts[1]->coder_type, tdm_ratio_bit_alloc_idx, hStereoTD->tdm_Pitch_reuse_flag,
sts[0]->bwidth, sts[1]->bwidth, sts[0]->flag_ACELP16k, hStereoTD->tdm_LRTD_flag, mod_ct, hStereoTD->tdm_inst_ratio_idx ); sts[0]->bwidth, sts[1]->bwidth, sts[0]->flag_ACELP16k, hStereoTD->tdm_LRTD_flag, mod_ct, hStereoTD->tdm_inst_ratio_idx );
......
...@@ -124,11 +124,6 @@ ivas_error IVAS_ENC_Open( ...@@ -124,11 +124,6 @@ ivas_error IVAS_ENC_Open(
( *phIvasEnc )->maxBandwidthUser = false; ( *phIvasEnc )->maxBandwidthUser = false;
resetIsmMetadataProvidedFlags( *phIvasEnc ); resetIsmMetadataProvidedFlags( *phIvasEnc );
/*-----------------------------------------------------------------*
* Initialize indices
*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------* /*-----------------------------------------------------------------*
* Allocate IVAS-codec encoder state * Allocate IVAS-codec encoder state
*-----------------------------------------------------------------*/ *-----------------------------------------------------------------*/
......