Skip to content
Commits on Source (15)
......@@ -1043,10 +1043,17 @@ void ivas_param_ism_enc(
const int16_t input_frame /* i : input frame length per channel */
);
#ifndef PARAM_ISM_REFACTOR
void ivas_param_ism_enc_close(
DIRAC_ENC_HANDLE *hDirAC, /* i/o: encoder DirAC handle */
const int32_t input_Fs /* i : input sampling_rate */
);
#else
void ivas_param_ism_enc_close(
PARAM_ISM_CONFIG_HANDLE *hParamIsm, /* i/o: ParamISM handle */
const int32_t input_Fs /* i : input sampling_rate */
);
#endif
void ivas_ism_metadata_close(
ISM_METADATA_HANDLE hIsmMetaData[], /* i/o : object metadata handles */
......@@ -1085,7 +1092,11 @@ ivas_error ivas_param_ism_dec_open(
);
void ivas_param_ism_dec_close(
#ifndef PARAM_ISM_REFACTOR
DIRAC_DEC_HANDLE *hDirAC, /* i/o: decoder DirAC handle */
#else
PARAM_ISM_DEC_HANDLE *hParamIsmDec, /* i/o: decoder ParamISM handle */
#endif
SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom_out, /* i/o: common spatial renderer data */
const AUDIO_CONFIG output_config /* i : output audio configuration */
);
......
......@@ -150,36 +150,6 @@ typedef struct
} ECSQ_instance;
/*----------------------------------------------------------------------------------*
* PARAMETRIC ISM encoder/decoder (common) structure
*----------------------------------------------------------------------------------*/
typedef struct ivas_param_ism_data_structure
{
int16_t nbands;
int16_t nblocks[MAX_PARAM_ISM_NBANDS];
int16_t band_grouping[MAX_PARAM_ISM_NBANDS + 1];
int16_t azi_index[MAX_NUM_OBJECTS];
int16_t ele_index[MAX_NUM_OBJECTS];
int16_t obj_indices[MAX_PARAM_ISM_NBANDS][MAX_PARAM_ISM_NBLOCKS][MAX_PARAM_ISM_WAVE];
int16_t power_ratios_idx[MAX_PARAM_ISM_NBANDS][MAX_PARAM_ISM_NBLOCKS];
int16_t last_az_sgn[MAX_NUM_OBJECTS];
int16_t last_az_diff[MAX_NUM_OBJECTS];
int16_t last_el_sgn[MAX_NUM_OBJECTS];
int16_t last_el_diff[MAX_NUM_OBJECTS];
int16_t flag_noisy_speech;
int16_t noisy_speech_buffer[PARAM_ISM_HYS_BUF_SIZE];
int16_t flag_equal_energy;
float last_dmx_gain;
float last_cardioid_left[MAX_NUM_OBJECTS];
} PARAM_ISM_CONFIG_DATA, *PARAM_ISM_CONFIG_HANDLE;
/*----------------------------------------------------------------------------------*
* Declaration of DirAC common (encoder & decoder) structure
......@@ -813,4 +783,39 @@ typedef struct ivas_fb_mixer_state_structure
} IVAS_FB_MIXER_DATA, *IVAS_FB_MIXER_HANDLE;
/*----------------------------------------------------------------------------------*
* PARAMETRIC ISM encoder/decoder (common) structure
*----------------------------------------------------------------------------------*/
typedef struct ivas_param_ism_data_structure
{
#ifdef PARAM_ISM_REFACTOR
IVAS_FB_MIXER_HANDLE hFbMixer;
#endif
int16_t nbands;
int16_t nblocks[MAX_PARAM_ISM_NBANDS];
int16_t band_grouping[MAX_PARAM_ISM_NBANDS + 1];
int16_t azi_index[MAX_NUM_OBJECTS];
int16_t ele_index[MAX_NUM_OBJECTS];
int16_t obj_indices[MAX_PARAM_ISM_NBANDS][MAX_PARAM_ISM_NBLOCKS][MAX_PARAM_ISM_WAVE];
int16_t power_ratios_idx[MAX_PARAM_ISM_NBANDS][MAX_PARAM_ISM_NBLOCKS];
int16_t last_az_sgn[MAX_NUM_OBJECTS];
int16_t last_az_diff[MAX_NUM_OBJECTS];
int16_t last_el_sgn[MAX_NUM_OBJECTS];
int16_t last_el_diff[MAX_NUM_OBJECTS];
int16_t flag_noisy_speech;
int16_t noisy_speech_buffer[PARAM_ISM_HYS_BUF_SIZE];
int16_t flag_equal_energy;
float last_dmx_gain;
float last_cardioid_left[MAX_NUM_OBJECTS];
} PARAM_ISM_CONFIG_DATA, *PARAM_ISM_CONFIG_HANDLE;
#endif /* IVAS_STAT_COM */
......@@ -174,6 +174,7 @@
#define FIX_747_ISM_TODOS /* VA: issue 747 - address ISM ToDos */
#define FIX_ISMRENDERER_HANDLE_DEALLOC /* VA: issue 781: harmonize Deallocation of handle 'hIsmRendererData' */
#define FIX_782_OSBA_FUNCTION_NAMES /* VA: fix 782: correct OSBA function names */
#define PARAM_ISM_REFACTOR /* FhG: Issue 768: Refactoring to decouple hDirAC and hParamISM */
/* #################### End BE switches ################################## */
......
......@@ -186,7 +186,11 @@ ivas_error ivas_dec(
}
else if ( st_ivas->ism_mode == ISM_MODE_PARAM )
{
#ifndef PARAM_ISM_REFACTOR
if ( ( error = ivas_ism_metadata_dec( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, st_ivas->hDirAC->hParamIsm, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hSCE[0]->hCoreCoder[0] ) ) != IVAS_ERR_OK )
#else
if ( ( error = ivas_ism_metadata_dec( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, st_ivas->hParamIsmDec->hParamIsm, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hSCE[0]->hCoreCoder[0] ) ) != IVAS_ERR_OK )
#endif
{
return error;
}
......
......@@ -85,8 +85,10 @@ static ivas_error ivas_dirac_dec_config_internal(
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC Config\n" ) );
}
#ifndef PARAM_ISM_REFACTOR
hDirAC->hParamIsm = NULL;
hDirAC->hParamIsmRendering = NULL;
#endif
st_ivas->hDirAC = hDirAC;
}
......@@ -1535,7 +1537,9 @@ void ivas_dirac_dec_set_md_map(
hDirAC = st_ivas->hDirAC;
hSpatParamRendCom = st_ivas->hSpatParamRendCom;
#ifdef DEBUGGING
#ifndef PARAM_ISM_REFACTOR
assert( hDirAC );
#endif
assert( hSpatParamRendCom );
#endif
......@@ -1562,7 +1566,11 @@ void ivas_dirac_dec_set_md_map(
{
ivas_jbm_dec_get_md_map_even_spacing( nCldfbTs, num_slots_in_subfr, 0, hSpatParamRendCom->dirac_md_buffer_length, hSpatParamRendCom->render_to_md_map );
}
#ifndef PARAM_ISM_REFACTOR
else if ( hDirAC->hConfig == NULL || hDirAC->hConfig->dec_param_estim == 0 )
#else
else if ( hDirAC == NULL || hDirAC->hConfig == NULL || hDirAC->hConfig->dec_param_estim == 0 )
#endif
{
ivas_jbm_dec_get_md_map( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbTs, num_slots_in_subfr, 0, hSpatParamRendCom->dirac_md_buffer_length, hSpatParamRendCom->render_to_md_map );
}
......@@ -1571,7 +1579,11 @@ void ivas_dirac_dec_set_md_map(
ivas_jbm_dec_get_md_map( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbTs, num_slots_in_subfr, hSpatParamRendCom->dirac_read_idx, hSpatParamRendCom->dirac_md_buffer_length, hSpatParamRendCom->render_to_md_map );
}
#ifndef PARAM_ISM_REFACTOR
if ( hDirAC->hConfig == NULL || hDirAC->hConfig->dec_param_estim == 0 )
#else
if ( hDirAC == NULL || hDirAC->hConfig == NULL || hDirAC->hConfig->dec_param_estim == 0 )
#endif
{
float tmp;
int16_t sf_idx, slot_idx, slot_idx_abs;
......
......@@ -2426,6 +2426,9 @@ void ivas_initialize_handles_dec(
/* spatial coding handles */
st_ivas->hDirAC = NULL;
#ifdef PARAM_ISM_REFACTOR
st_ivas->hParamIsmDec = NULL;
#endif
st_ivas->hSpar = NULL;
st_ivas->hMasa = NULL;
st_ivas->hQMetaData = NULL;
......@@ -2578,7 +2581,11 @@ void ivas_destroy_dec(
/* DirAC handle */
if ( st_ivas->ivas_format == ISM_FORMAT )
{
#ifndef PARAM_ISM_REFACTOR
ivas_param_ism_dec_close( &( st_ivas->hDirAC ), &( st_ivas->hSpatParamRendCom ), st_ivas->hDecoderConfig->output_config );
#else
ivas_param_ism_dec_close( &( st_ivas->hParamIsmDec ), &( st_ivas->hSpatParamRendCom ), st_ivas->hDecoderConfig->output_config );
#endif
}
else
{
......
......@@ -179,7 +179,11 @@ static ivas_error ivas_ism_bitrate_switching_dec(
if ( st_ivas->ism_mode == ISM_MODE_DISC && last_ism_mode == ISM_MODE_PARAM )
{
/* Deallocate the ParamISM struct */
#ifndef PARAM_ISM_REFACTOR
ivas_param_ism_dec_close( &( st_ivas->hDirAC ), &( st_ivas->hSpatParamRendCom ), st_ivas->hDecoderConfig->output_config );
#else
ivas_param_ism_dec_close( &( st_ivas->hParamIsmDec ), &( st_ivas->hSpatParamRendCom ), st_ivas->hDecoderConfig->output_config );
#endif
if ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB
#ifdef SPLIT_REND_WITH_HEAD_ROT
......
......@@ -116,10 +116,17 @@ ivas_error ivas_ism_dtx_dec(
if ( ivas_total_brate == IVAS_SID_5k2 && !st_ivas->bfi )
{
#ifndef PARAM_ISM_REFACTOR
if ( st_ivas->hDirAC != NULL )
{
st_ivas->hDirAC->hParamIsm->flag_noisy_speech = flag_noisy_speech;
}
#else
if ( st_ivas->hParamIsmDec != NULL )
{
st_ivas->hParamIsmDec->hParamIsm->flag_noisy_speech = flag_noisy_speech;
}
#endif
st_ivas->hISMDTX.sce_id_dtx = sce_id_dtx;
}
......@@ -130,8 +137,13 @@ ivas_error ivas_ism_dtx_dec(
{
for ( ch = 0; ch < nchan_ism; ch++ )
{
#ifndef PARAM_ISM_REFACTOR
st_ivas->hDirAC->azimuth_values[ch] = st_ivas->hIsmMetaData[ch]->azimuth;
st_ivas->hDirAC->elevation_values[ch] = st_ivas->hIsmMetaData[ch]->elevation;
#else
st_ivas->hParamIsmDec->azimuth_values[ch] = st_ivas->hIsmMetaData[ch]->azimuth;
st_ivas->hParamIsmDec->elevation_values[ch] = st_ivas->hIsmMetaData[ch]->elevation;
#endif
}
}
......
This diff is collapsed.
......@@ -160,7 +160,11 @@ ivas_error ivas_jbm_dec_tc(
}
else if ( st_ivas->ism_mode == ISM_MODE_PARAM )
{
#ifndef PARAM_ISM_REFACTOR
if ( ( error = ivas_ism_metadata_dec( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, st_ivas->hDirAC->hParamIsm, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hSCE[0]->hCoreCoder[0] ) ) != IVAS_ERR_OK )
#else
if ( ( error = ivas_ism_metadata_dec( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, st_ivas->hParamIsmDec->hParamIsm, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hSCE[0]->hCoreCoder[0] ) ) != IVAS_ERR_OK )
#endif
{
return error;
}
......@@ -2354,8 +2358,13 @@ void ivas_jbm_dec_copy_tc_no_tsm(
if ( st_ivas->ivas_format == ISM_FORMAT )
{
#ifndef PARAM_ISM_REFACTOR
cldfb_real_buffer = st_ivas->hDirAC->hParamIsmRendering->Cldfb_RealBuffer_tc;
cldfb_imag_buffer = st_ivas->hDirAC->hParamIsmRendering->Cldfb_ImagBuffer_tc;
#else
cldfb_real_buffer = st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc;
cldfb_imag_buffer = st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc;
#endif
num_freq_bands = st_ivas->hSpatParamRendCom->num_freq_bands;
ivas_ism_param_dec_tc_gain_ajust( st_ivas, output_frame, output_frame / 2, tc );
}
......
......@@ -399,6 +399,7 @@ typedef struct
} ISM_DTX_DATA_DEC;
#ifndef PARAM_ISM_REFACTOR
/*----------------------------------------------------------------------------------*
* DirAC decoder structures
*----------------------------------------------------------------------------------*/
......@@ -435,6 +436,53 @@ typedef struct ivas_dirac_dec_data_structure
IVAS_FB_MIXER_HANDLE hFbMdft;
} DIRAC_DEC_DATA, *DIRAC_DEC_HANDLE;
#else
/*----------------------------------------------------------------------------------*
* ParamISM decoder structures
*----------------------------------------------------------------------------------*/
typedef struct param_ism_rendering
{
float *proto_matrix;
float *interpolator;
float mixing_matrix_lin_old[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_CHAN * PARAM_ISM_MAX_DMX];
float mixing_matrix_lin[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_CHAN * PARAM_ISM_MAX_DMX];
float *Cldfb_RealBuffer_tc;
float *Cldfb_ImagBuffer_tc;
} PARAM_ISM_RENDERING_DATA, *PARAM_ISM_RENDERING_HANDLE;
typedef struct ivas_param_ism_dec_data_structure
{
/*Parameter decoding*/
float azimuth_values[MAX_PARAM_SPATIAL_SUBFRAMES * IVAS_MAX_NUM_BANDS];
float elevation_values[MAX_PARAM_SPATIAL_SUBFRAMES * IVAS_MAX_NUM_BANDS];
float power_ratios[MAX_PARAM_ISM_NBANDS][MAX_PARAM_ISM_NBLOCKS][MAX_PARAM_ISM_WAVE];
/*sub-modules*/
PARAM_ISM_CONFIG_HANDLE hParamIsm; /* Parametric ISM common handle */
PARAM_ISM_RENDERING_HANDLE hParamIsmRendering; /* ParamISM rendering handle */
} PARAM_ISM_DEC_DATA, *PARAM_ISM_DEC_HANDLE;
/*----------------------------------------------------------------------------------*
* DirAC decoder structures
*----------------------------------------------------------------------------------*/
typedef struct ivas_dirac_dec_data_structure
{
DIRAC_CONFIG_DATA_HANDLE hConfig;
int16_t band_grouping[IVAS_MAX_NUM_BANDS + 1];
int16_t dithering_seed;
int16_t spar_to_dirac_write_idx;
IVAS_FB_MIXER_HANDLE hFbMdft;
} DIRAC_DEC_DATA, *DIRAC_DEC_HANDLE;
#endif
/*----------------------------------------------------------------------------------*
......@@ -1070,6 +1118,9 @@ typedef struct Decoder_Struct
ISM_DTX_DATA_DEC hISMDTX; /* ISM DTX structure */
ISM_RENDERER_HANDLE hIsmRendererData; /* ISM renderer handle */
DIRAC_DEC_HANDLE hDirAC; /* DirAC handle */
#ifdef PARAM_ISM_REFACTOR
PARAM_ISM_DEC_HANDLE hParamIsmDec; /* ParamISM handle */
#endif
SPAR_DEC_HANDLE hSpar; /* SPAR handle */
IVAS_QMETADATA_HANDLE hQMetaData; /* q_metadata handle */
MCT_DEC_HANDLE hMCT; /* MCT handle */
......
......@@ -322,6 +322,10 @@ void ivas_initialize_handles_enc(
/* DirAC handle */
st_ivas->hDirAC = NULL;
#ifdef PARAM_ISM_REFACTOR
/* ParamISM handle */
st_ivas->hParamIsm = NULL;
#endif
/* SPAR handle */
st_ivas->hSpar = NULL;
......@@ -1087,9 +1091,11 @@ void ivas_destroy_enc(
)
{
int16_t i, n, nchan_inp;
#ifndef PARAM_ISM_REFACTOR
IVAS_FORMAT ivas_format;
ivas_format = st_ivas->hEncoderConfig->ivas_format;
#endif
nchan_inp = st_ivas->hEncoderConfig->nchan_inp;
/* SCE handles */
......@@ -1139,6 +1145,7 @@ void ivas_destroy_enc(
/* Q Metadata handle */
ivas_qmetadata_close( &( st_ivas->hQMetaData ) );
#ifndef PARAM_ISM_REFACTOR
/* DirAC handle */
if ( ivas_format == ISM_FORMAT )
{
......@@ -1148,6 +1155,13 @@ void ivas_destroy_enc(
{
ivas_dirac_enc_close( &( st_ivas->hDirAC ), st_ivas->hEncoderConfig->input_Fs );
}
#else
/* DirAC handle */
ivas_dirac_enc_close( &( st_ivas->hDirAC ), st_ivas->hEncoderConfig->input_Fs );
/* ParamISM handle */
ivas_param_ism_enc_close( &( st_ivas->hParamIsm ), st_ivas->hEncoderConfig->input_Fs );
#endif
/* SPAR handle */
ivas_spar_enc_close( &( st_ivas->hSpar ), st_ivas->hEncoderConfig->input_Fs, nchan_inp, 0 );
......
......@@ -210,11 +210,19 @@ ivas_error ivas_ism_enc(
}
#ifdef DEBUG_MODE_PARAM_ISM
#ifndef PARAM_ISM_REFACTOR
if ( st_ivas->hDirAC != NULL )
dbgwrite( &( st_ivas->hDirAC->hParamIsm->flag_noisy_speech ), sizeof( int16_t ), 1, 1, "./res/ParamISM_noisy_speech_flag_enc.dat" );
dbgwrite( &( st_ivas->hISMDTX->dtx_flag ), sizeof( int16_t ), 1, 1, "./res/ParamISM_DTX_CNG_flag_enc.dat" );
dbgwrite( &( st_ivas->hISMDTX->sce_id_dtx ), sizeof( int16_t ), 1, input_frame, "./res/sce_id_dtx" );
dbgwrite( &( dtx_flag ), sizeof( int16_t ), 1, input_frame, "./res/dtx_flag" );
#else
if ( st_ivas->hParamIsmDec != NULL )
dbgwrite( &( st_ivas->hParamIsmDec->hParamIsm->flag_noisy_speech ), sizeof( int16_t ), 1, 1, "./res/ParamISM_noisy_speech_flag_enc.dat" );
dbgwrite( &( st_ivas->hISMDTX->dtx_flag ), sizeof( int16_t ), 1, 1, "./res/ParamISM_DTX_CNG_flag_enc.dat" );
dbgwrite( &( st_ivas->hISMDTX->sce_id_dtx ), sizeof( int16_t ), 1, input_frame, "./res/sce_id_dtx" );
dbgwrite( &( dtx_flag ), sizeof( int16_t ), 1, input_frame, "./res/dtx_flag" );
#endif
#endif
}
......@@ -226,7 +234,11 @@ ivas_error ivas_ism_enc(
if ( st_ivas->ism_mode == ISM_MODE_PARAM )
{
ivas_param_ism_compute_noisy_speech_flag( st_ivas );
#ifndef PARAM_ISM_REFACTOR
flag_noisy_speech = st_ivas->hDirAC->hParamIsm->flag_noisy_speech;
#else
flag_noisy_speech = st_ivas->hParamIsm->flag_noisy_speech;
#endif
}
if ( dtx_flag )
......@@ -236,15 +248,26 @@ ivas_error ivas_ism_enc(
else if ( st_ivas->ism_mode == ISM_MODE_PARAM )
{
#ifdef FIX_747_ISM_TODOS
#ifndef PARAM_ISM_REFACTOR
if ( ( error = ivas_ism_metadata_enc( &st_ivas->hEncoderConfig->ivas_total_brate, nchan_ism, nchan_transport_ism, st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData,
nb_bits_metadata, vad_flag, st_ivas->ism_mode, st_ivas->hDirAC->hParamIsm, st_ivas->hEncoderConfig->ism_extended_metadata_flag, -1, 0, NULL, st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame ) ) != IVAS_ERR_OK )
#else
if ( ( error = ivas_ism_metadata_enc( &st_ivas->hEncoderConfig->ivas_total_brate, nchan_ism, nchan_transport_ism, st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData,
nb_bits_metadata, vad_flag, st_ivas->ism_mode, st_ivas->hParamIsm, st_ivas->hEncoderConfig->ism_extended_metadata_flag, -1, 0, NULL, st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame ) ) != IVAS_ERR_OK )
#endif
{
return error;
}
#else
#ifndef PARAM_ISM_REFACTOR
ivas_ism_metadata_enc( &st_ivas->hEncoderConfig->ivas_total_brate, nchan_ism, nchan_transport_ism, st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData,
nb_bits_metadata, vad_flag, st_ivas->ism_mode, st_ivas->hDirAC->hParamIsm, st_ivas->hEncoderConfig->ism_extended_metadata_flag, -1, 0, NULL,
st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame );
#else
ivas_ism_metadata_enc( &st_ivas->hEncoderConfig->ivas_total_brate, nchan_ism, nchan_transport_ism, st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData,
nb_bits_metadata, vad_flag, st_ivas->ism_mode, st_ivas->hParamIsmDec->hParamIsm, st_ivas->hEncoderConfig->ism_extended_metadata_flag, -1, 0, NULL,
st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame );
#endif
#endif
}
else /* ISM_MODE_DISC */
......@@ -504,7 +527,11 @@ ivas_error ivas_ism_enc_config(
if ( st_ivas->ism_mode == ISM_MODE_DISC && last_ism_mode == ISM_MODE_PARAM )
{
/* Deallocate the memory used by ParamISM when switch to Discrete ISM */
#ifndef PARAM_ISM_REFACTOR
ivas_param_ism_enc_close( &( st_ivas->hDirAC ), st_ivas->hEncoderConfig->input_Fs );
#else
ivas_param_ism_enc_close( &( st_ivas->hParamIsm ), st_ivas->hEncoderConfig->input_Fs );
#endif
}
}
......
......@@ -235,7 +235,11 @@ void ivas_param_ism_stereo_dmx(
dmx_gain = 0;
ene_dmx = 0;
ene_data = 0;
#ifndef PARAM_ISM_REFACTOR
last_dmx_gain = st_ivas->hDirAC->hParamIsm->last_dmx_gain;
#else
last_dmx_gain = st_ivas->hParamIsm->last_dmx_gain;
#endif
/* Set the stereo dmx to zero */
set_zero( stereo_dmx[0], L_FRAME48k );
......@@ -245,7 +249,11 @@ void ivas_param_ism_stereo_dmx(
for ( i = 0; i < st_ivas->hEncoderConfig->nchan_ism; i++ )
{
hIsmMetaData = st_ivas->hIsmMetaData[i];
#ifndef PARAM_ISM_REFACTOR
last_cardioid_left = st_ivas->hDirAC->hParamIsm->last_cardioid_left[i];
#else
last_cardioid_left = st_ivas->hParamIsm->last_cardioid_left[i];
#endif
/*Compute the Cardioids for the corresponding object direction */
tmp = hIsmMetaData->azimuth * ( EVS_PI / 180 );
tmp_1 = ( EVS_PI / 2 ) + azi_shift;
......@@ -288,7 +296,11 @@ void ivas_param_ism_stereo_dmx(
ene_data += ( tmp * tmp ); /* energy of all objects combined */
}
}
#ifndef PARAM_ISM_REFACTOR
st_ivas->hDirAC->hParamIsm->last_cardioid_left[i] = cardioid_left[i];
#else
st_ivas->hParamIsm->last_cardioid_left[i] = cardioid_left[i];
#endif
}
/* Energy compensation */
......@@ -322,7 +334,12 @@ void ivas_param_ism_stereo_dmx(
stereo_dmx[1][j] *= dmx_gain;
}
}
#ifndef PARAM_ISM_REFACTOR
st_ivas->hDirAC->hParamIsm->last_dmx_gain = dmx_gain;
#else
st_ivas->hParamIsm->last_dmx_gain = dmx_gain;
#endif
/* Copy the stereo dmx to data variable */
mvr2r( stereo_dmx[0], data[0], input_frame );
mvr2r( stereo_dmx[1], data[1], input_frame );
......@@ -345,24 +362,37 @@ ivas_error ivas_param_ism_enc_open(
{
int16_t i;
IVAS_FB_CFG *fb_cfg;
#ifndef PARAM_ISM_REFACTOR
DIRAC_ENC_HANDLE hDirAC;
#else
PARAM_ISM_CONFIG_HANDLE hParamIsm;
#endif
int16_t max_bins;
int32_t input_Fs;
ivas_error error;
error = IVAS_ERR_OK;
#ifndef PARAM_ISM_REFACTOR
/* Assign memory to DirAC handle */
if ( ( hDirAC = (DIRAC_ENC_HANDLE) malloc( sizeof( DIRAC_ENC_DATA ) ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) );
}
#endif
/* Assign memory to Param Object handle */
#ifndef PARAM_ISM_REFACTOR
if ( ( hDirAC->hParamIsm = (PARAM_ISM_CONFIG_HANDLE) malloc( sizeof( PARAM_ISM_CONFIG_DATA ) ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Param ISM\n" ) );
}
#else
if ( ( hParamIsm = (PARAM_ISM_CONFIG_HANDLE) malloc( sizeof( PARAM_ISM_CONFIG_DATA ) ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Param ISM\n" ) );
}
#endif
input_Fs = st_ivas->hEncoderConfig->input_Fs;
......@@ -374,29 +404,62 @@ ivas_error ivas_param_ism_enc_open(
}
/* Allocate and initialize FB mixer handle */
#ifndef PARAM_ISM_REFACTOR
if ( ( error = ivas_FB_mixer_open( &( hDirAC->hFbMixer ), input_Fs, fb_cfg, 0 ) ) != IVAS_ERR_OK )
{
return error;
}
#else
if ( ( error = ivas_FB_mixer_open( &( hParamIsm->hFbMixer ), input_Fs, fb_cfg, 0 ) ) != IVAS_ERR_OK )
{
return error;
}
#endif
#ifndef PARAM_ISM_REFACTOR
ivas_param_ism_config( hDirAC->hParamIsm, st_ivas->hEncoderConfig->nchan_inp );
#else
ivas_param_ism_config( hParamIsm, st_ivas->hEncoderConfig->nchan_inp );
#endif
/* Assign memories for Band and Block grouping */
#ifndef PARAM_ISM_REFACTOR
hDirAC->hParamIsm->nbands = MAX_PARAM_ISM_NBANDS;
#else
hParamIsm->nbands = MAX_PARAM_ISM_NBANDS;
#endif
max_bins = (int16_t) ( ( MDFT_FB_BANDS_240 * input_Fs ) / 48000 );
#ifndef PARAM_ISM_REFACTOR
for ( i = 0; i < ( hDirAC->hParamIsm->nbands + 1 ); i++ )
#else
for ( i = 0; i < ( hParamIsm->nbands + 1 ); i++ )
#endif
{
#ifndef PARAM_ISM_REFACTOR
hDirAC->hParamIsm->band_grouping[i] = CLDFB_TO_MDFT_FAC * Param_ISM_band_grouping[i];
#else
hParamIsm->band_grouping[i] = CLDFB_TO_MDFT_FAC * Param_ISM_band_grouping[i];
#endif
if ( ( Param_ISM_band_grouping[i] * CLDFB_TO_MDFT_FAC ) > max_bins )
{
#ifndef PARAM_ISM_REFACTOR
hDirAC->hParamIsm->band_grouping[i] = max_bins;
#else
hParamIsm->band_grouping[i] = max_bins;
#endif
}
}
#ifndef PARAM_ISM_REFACTOR
set_s( hDirAC->hParamIsm->noisy_speech_buffer, 0, PARAM_ISM_HYS_BUF_SIZE );
st_ivas->hDirAC = hDirAC;
#else
set_s( hParamIsm->noisy_speech_buffer, 0, PARAM_ISM_HYS_BUF_SIZE );
st_ivas->hParamIsm = hParamIsm;
#endif
return error;
}
......@@ -408,6 +471,7 @@ ivas_error ivas_param_ism_enc_open(
* Close Param ISM encoder handle
*-------------------------------------------------------------------------*/
#ifndef PARAM_ISM_REFACTOR
void ivas_param_ism_enc_close(
DIRAC_ENC_HANDLE *hDirAC, /* i/o: encoder DirAC handle */
const int32_t input_Fs /* i : input sampling_rate */
......@@ -431,6 +495,25 @@ void ivas_param_ism_enc_close(
return;
}
#else
void ivas_param_ism_enc_close(
PARAM_ISM_CONFIG_HANDLE *hParamIsm, /* i/o: ParamISM handle */
const int32_t input_Fs /* i : input sampling_rate */
)
{
if ( hParamIsm == NULL || *hParamIsm == NULL )
{
return;
}
ivas_FB_mixer_close( &( *hParamIsm )->hFbMixer, input_Fs, 0 );
free( ( *hParamIsm ) );
( *hParamIsm ) = NULL;
return;
}
#endif
/*-------------------------------------------------------------------------*
......@@ -454,12 +537,18 @@ void ivas_param_ism_enc(
float *p_fb_RealBuffer[MAX_NUM_OBJECTS];
float *p_fb_ImagBuffer[MAX_NUM_OBJECTS];
float reference_power_obj[MAX_NUM_OBJECTS][PARAM_ISM_MDFT_NO_SLOTS][DIRAC_NO_FB_BANDS_MAX];
#ifndef PARAM_ISM_REFACTOR
DIRAC_ENC_HANDLE hDirAC;
#endif
PARAM_ISM_CONFIG_HANDLE hParamIsm;
nchan_ism = st_ivas->hEncoderConfig->nchan_ism;
#ifndef PARAM_ISM_REFACTOR
hDirAC = st_ivas->hDirAC;
hParamIsm = hDirAC->hParamIsm;
#else
hParamIsm = st_ivas->hParamIsm;
#endif
push_wmops( "ivas_param_ism_enc" );
......@@ -478,9 +567,15 @@ void ivas_param_ism_enc(
for ( ts = 0; ts < num_time_slots; ts++ )
{
#ifndef PARAM_ISM_REFACTOR
ivas_fb_mixer_get_windowed_fr( hDirAC->hFbMixer, pcm_in, p_fb_RealBuffer, p_fb_ImagBuffer, l_ts, l_ts, hDirAC->hFbMixer->fb_cfg->num_in_chans );
ivas_fb_mixer_update_prior_input( hDirAC->hFbMixer, pcm_in, l_ts, hDirAC->hFbMixer->fb_cfg->num_in_chans );
#else
ivas_fb_mixer_get_windowed_fr( hParamIsm->hFbMixer, pcm_in, p_fb_RealBuffer, p_fb_ImagBuffer, l_ts, l_ts, hParamIsm->hFbMixer->fb_cfg->num_in_chans );
ivas_fb_mixer_update_prior_input( hParamIsm->hFbMixer, pcm_in, l_ts, hParamIsm->hFbMixer->fb_cfg->num_in_chans );
#endif
for ( i = 0; i < nchan_ism; i++ )
{
......@@ -515,6 +610,7 @@ void ivas_param_ism_compute_noisy_speech_flag(
{
int16_t i;
#ifndef PARAM_ISM_REFACTOR
/* Move the Noisy speech buffer */
for ( i = 0; i < ( PARAM_ISM_HYS_BUF_SIZE - 1 ); i++ )
{
......@@ -553,6 +649,46 @@ void ivas_param_ism_compute_noisy_speech_flag(
st_ivas->hDirAC->hParamIsm->flag_noisy_speech = st_ivas->hDirAC->hParamIsm->flag_noisy_speech && st_ivas->hDirAC->hParamIsm->noisy_speech_buffer[i];
}
}
#else
/* Move the Noisy speech buffer */
for ( i = 0; i < ( PARAM_ISM_HYS_BUF_SIZE - 1 ); i++ )
{
st_ivas->hParamIsm->noisy_speech_buffer[i] = st_ivas->hParamIsm->noisy_speech_buffer[i + 1];
}
/* Set flag_noisy_speech to 0 for cases where object energies are not roughly equal */
if ( !st_ivas->hParamIsm->flag_equal_energy )
{
st_ivas->hParamIsm->noisy_speech_buffer[i] = 0;
st_ivas->hParamIsm->flag_noisy_speech = 0;
}
else
{
/* For the current frame, make a decision based on some core-coder flags */
if ( st_ivas->hSCE[0]->hCoreCoder[0]->flag_noisy_speech_snr && st_ivas->hSCE[1]->hCoreCoder[0]->flag_noisy_speech_snr )
{
if ( st_ivas->hSCE[0]->hCoreCoder[0]->vad_flag || st_ivas->hSCE[1]->hCoreCoder[0]->vad_flag )
{
st_ivas->hParamIsm->noisy_speech_buffer[i] = 0;
}
else
{
st_ivas->hParamIsm->noisy_speech_buffer[i] = 1;
}
}
else
{
st_ivas->hParamIsm->noisy_speech_buffer[i] = 0;
}
/* Do a decision based on hysteresis */
st_ivas->hParamIsm->flag_noisy_speech = 1;
for ( i = 0; i < PARAM_ISM_HYS_BUF_SIZE; i++ )
{
st_ivas->hParamIsm->flag_noisy_speech = st_ivas->hParamIsm->flag_noisy_speech && st_ivas->hParamIsm->noisy_speech_buffer[i];
}
}
#endif
return;
}
......@@ -585,7 +585,9 @@ typedef struct front_vad_enc
typedef struct ivas_dirac_enc_data_structure
{
DIRAC_CONFIG_DATA_HANDLE hConfig;
#ifndef PARAM_ISM_REFACTOR
PARAM_ISM_CONFIG_HANDLE hParamIsm; /* Parametric ISM handle */
#endif
IVAS_FB_MIXER_HANDLE hFbMixer;
......@@ -1227,6 +1229,9 @@ typedef struct
ISM_METADATA_HANDLE hIsmMetaData[MAX_NUM_OBJECTS]; /* ISM metadata handles (storage for one frame of read ISM metadata) */
ISM_DTX_HANDLE hISMDTX; /* ISM DTX handle */
DIRAC_ENC_HANDLE hDirAC; /* DirAC data handle */
#ifdef PARAM_ISM_REFACTOR
PARAM_ISM_CONFIG_HANDLE hParamIsm; /* Parametric ISM handle */
#endif
SPAR_ENC_HANDLE hSpar; /* SPAR encoder handle */
MASA_ENCODER_HANDLE hMasa; /* MASA encoder data and configuration */
IVAS_QMETADATA_HANDLE hQMetaData; /* Metadata handle for q_metadata parametric spatial coding DirAC/MASA*/
......