From e7b4f401739a47d0a1422cff1b71c586e90e2fa8 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 15 Oct 2025 19:49:05 +0200 Subject: [PATCH] port float MR !2260 --- lib_com/edct.c | 41 ++------------- lib_com/prot.h | 15 +++--- lib_com/tcx_utils.c | 7 +-- lib_dec/ivas_init_dec.c | 18 +++---- lib_dec/lib_dec.c | 100 ++++++++++++++++++------------------ lib_enc/init_enc.c | 32 ++++++------ lib_enc/ivas_cpe_enc.c | 2 +- lib_enc/ivas_sce_enc.c | 2 +- lib_enc/ivas_spar_encoder.c | 2 +- 9 files changed, 89 insertions(+), 130 deletions(-) diff --git a/lib_com/edct.c b/lib_com/edct.c index d7af669c6..c336ccdd8 100644 --- a/lib_com/edct.c +++ b/lib_com/edct.c @@ -44,6 +44,7 @@ #include "prot.h" #include "wmc_auto.h" #include /* for cosf, sinf */ +#include static ivas_error get_edct_table( const float **edct_table, @@ -226,7 +227,6 @@ void edst( return; } -#define FAST_EDXT /* optimized FFT-based DCT/DST algorithm */ /*-------------------------------------------------------------------------* * edxt() @@ -243,9 +243,8 @@ void edxt( ) { const float pi_len = EVS_PI / length; - int16_t k, m; + int16_t k; -#ifdef FAST_EDXT if ( kernelType == MDST_II || kernelType == MDCT_II ) { const int16_t Nm1 = length - 1; @@ -351,42 +350,8 @@ void edxt( } } else -#endif - if ( kernelType & 1 ) /* DST */ { - const float offK = ( kernelType == MDST_II && synthesis ? 0.5f : 1.0f - 0.5f * ( kernelType >> 1 ) ); - const float offM = ( kernelType == MDST_II && synthesis ? 1.0f : 0.5f ); - - for ( k = 0; k < length; k++ ) - { - y[k] = 0.f; - for ( m = 0; m < length; m++ ) - { - y[k] += x[m] * sinf( pi_len * ( m + offM ) * ( k + offK ) ); - } - } - if ( offK == 1.f ) - { - y[length - 1] *= 0.5f; /* scale Nyquist sample */ - } - } - else /* kernelType 0, 2: DCT */ - { - const float offK = ( kernelType == MDCT_II && synthesis ? 0.5f : 0.5f - 0.5f * ( kernelType >> 1 ) ); - const float offM = ( kernelType == MDCT_II && synthesis ? 0.0f : 0.5f ); - - for ( k = 0; k < length; k++ ) - { - y[k] = 0.f; - for ( m = 0; m < length; m++ ) - { - y[k] += x[m] * cosf( pi_len * ( m + offM ) * ( k + offK ) ); - } - } - if ( offK == 0.f ) - { - y[0] *= 0.5f; /* scale lowest (i.e. DC) sample */ - } + assert( !"Unsupported Kernel type in edxt()" ); } v_multc( y, ( kernelType == MDCT_II ? -1.f : 1.f ) * sqrtf( 2.f / length ), y, length ); diff --git a/lib_com/prot.h b/lib_com/prot.h index fa039ea74..1a6b62e1c 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -2244,15 +2244,12 @@ void read_next_force( #endif ivas_error init_encoder( - Encoder_State *st, /* i/o: state structure */ - Encoder_Struct *st_ivas, /* i/o: encoder state structure */ - const int16_t idchan, /* i : channel ID */ - const int16_t var_SID_rate_flag, /* i : flag for variable SID update rate */ - const int16_t interval_SID, /* i : interval for SID update */ - const int16_t vad_only_flag, /* i : flag to indicate front-VAD structure */ - const ISM_MODE ism_mode /* i : ISM mode */ - , - const int32_t element_brate /* element bitrate */ + Encoder_State *st, /* i/o: state structure */ + Encoder_Struct *st_ivas, /* i/o: encoder state structure */ + const int16_t idchan, /* i : channel ID */ + const int16_t vad_only_flag, /* i : flag to indicate front-VAD structure */ + const ISM_MODE ism_mode, /* i : ISM mode */ + const int32_t element_brate /* i : element bitrate */ ); void LPDmem_enc_init( diff --git a/lib_com/tcx_utils.c b/lib_com/tcx_utils.c index 458a43d72..d37ecf207 100644 --- a/lib_com/tcx_utils.c +++ b/lib_com/tcx_utils.c @@ -568,14 +568,11 @@ void lpc2mdct( if ( noInverse ) { - for ( i = 0; i < length; i++ ) - { - mdct_gains[i] = (float) ( sqrt( RealData[i] * RealData[i] + ImagData[i] * ImagData[i] ) ); - } + assert( !"not supported option in lpc2mdct()" ); } else - /* Get amplitude */ { + /* Get amplitude */ for ( i = 0; i < length; i++ ) { mdct_gains[i] = (float) ( 1.0f / max( EPSILON, sqrt( RealData[i] * RealData[i] + ImagData[i] * ImagData[i] ) ) ); diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 0c6511055..86f0629bb 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1513,7 +1513,7 @@ ivas_error ivas_init_decoder( return error; } - if ( hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_FOA && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_MONO && !( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL && st_ivas->intern_config == IVAS_AUDIO_CONFIG_FOA ) ) + if ( output_config != IVAS_AUDIO_CONFIG_FOA && output_config != IVAS_AUDIO_CONFIG_STEREO && output_config != IVAS_AUDIO_CONFIG_MONO && !( output_config == IVAS_AUDIO_CONFIG_EXTERNAL && st_ivas->intern_config == IVAS_AUDIO_CONFIG_FOA ) ) { if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) { @@ -1535,7 +1535,7 @@ ivas_error ivas_init_decoder( st_ivas->hQMetaData->numTwoDirBands = (uint8_t) st_ivas->hQMetaData->q_direction[0].cfg.nbands; } - ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), + ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0, 1 ); } st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); @@ -1659,7 +1659,7 @@ ivas_error ivas_init_decoder( return error; } - if ( hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_FOA && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_MONO ) + if ( output_config != IVAS_AUDIO_CONFIG_FOA && output_config != IVAS_AUDIO_CONFIG_STEREO && output_config != IVAS_AUDIO_CONFIG_MONO ) { if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) { @@ -1681,7 +1681,7 @@ ivas_error ivas_init_decoder( st_ivas->hQMetaData->numTwoDirBands = (uint8_t) st_ivas->hQMetaData->q_direction[0].cfg.nbands; } - ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), + ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0, 1 ); } @@ -1784,7 +1784,7 @@ ivas_error ivas_init_decoder( } reset_indices_dec( st_ivas->hSCE[0]->hCoreCoder[0] ); - if ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { if ( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nchan_ism, NULL ) ) != IVAS_ERR_OK ) { @@ -2128,7 +2128,7 @@ ivas_error ivas_init_decoder( if ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { - if ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, output_Fs ) ) != IVAS_ERR_OK ) { return error; } @@ -2292,7 +2292,7 @@ ivas_error ivas_init_decoder( } if ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { - if ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, output_Fs ) ) != IVAS_ERR_OK ) { return error; } @@ -2355,7 +2355,7 @@ ivas_error ivas_init_decoder( { if ( st_ivas->hBinRenderer->render_lfe ) { - if ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + if ( output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { /* Account for filterbank delay */ delay_ns += IVAS_FB_DEC_DELAY_NS; @@ -2416,7 +2416,7 @@ ivas_error ivas_init_decoder( if ( ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) && st_ivas->hDecoderConfig->Opt_tsm ) { - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { if ( ( error = ivas_jbm_dec_metadata_open( st_ivas ) ) != IVAS_ERR_OK ) { diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 35ea145e1..abba30ea6 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1317,18 +1317,23 @@ ivas_error IVAS_DEC_GetEditableParameters( IVAS_DEC_HANDLE hIvasDec, IVAS_EDITABLE_PARAMETERS *hIvasEditableParameters ) { - ivas_error error; + int16_t obj; + Decoder_Struct *st_ivas; + ISM_MODE ism_mode; - if ( !( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || - ( hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT && hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) || - ( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT && ( hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) ) ) + if ( hIvasEditableParameters == NULL || hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { - return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Object editing no supported in this operation mode." ); + return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - if ( hIvasEditableParameters == NULL || hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + st_ivas = hIvasDec->st_ivas; + ism_mode = st_ivas->ism_mode; + + if ( !( st_ivas->ivas_format == ISM_FORMAT || + ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) || + ( st_ivas->ivas_format == MASA_ISM_FORMAT && ( ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) ) ) { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; + return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Object editing no supported in this operation mode." ); } #ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST @@ -1341,34 +1346,32 @@ ivas_error IVAS_DEC_GetEditableParameters( #endif hIvasEditableParameters->gain_bed = 1.0f; - hIvasEditableParameters->num_obj = hIvasDec->st_ivas->nchan_ism; - if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) + hIvasEditableParameters->num_obj = st_ivas->nchan_ism; + if ( st_ivas->ivas_format == ISM_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) { - if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + if ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_SBA_MODE_DISC ) { - int16_t obj; for ( obj = 0; obj < hIvasEditableParameters->num_obj; obj++ ) { - hIvasEditableParameters->ism_metadata[obj].azimuth = hIvasDec->st_ivas->hIsmMetaData[obj]->azimuth; - hIvasEditableParameters->ism_metadata[obj].elevation = hIvasDec->st_ivas->hIsmMetaData[obj]->elevation; - hIvasEditableParameters->ism_metadata[obj].yaw = hIvasDec->st_ivas->hIsmMetaData[obj]->yaw; - hIvasEditableParameters->ism_metadata[obj].pitch = hIvasDec->st_ivas->hIsmMetaData[obj]->pitch; - hIvasEditableParameters->ism_metadata[obj].radius = hIvasDec->st_ivas->hIsmMetaData[obj]->radius; - hIvasEditableParameters->ism_metadata[obj].gain = hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain; - hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = hIvasDec->st_ivas->hIsmMetaData[obj]->non_diegetic_flag; + hIvasEditableParameters->ism_metadata[obj].azimuth = st_ivas->hIsmMetaData[obj]->azimuth; + hIvasEditableParameters->ism_metadata[obj].elevation = st_ivas->hIsmMetaData[obj]->elevation; + hIvasEditableParameters->ism_metadata[obj].yaw = st_ivas->hIsmMetaData[obj]->yaw; + hIvasEditableParameters->ism_metadata[obj].pitch = st_ivas->hIsmMetaData[obj]->pitch; + hIvasEditableParameters->ism_metadata[obj].radius = st_ivas->hIsmMetaData[obj]->radius; + hIvasEditableParameters->ism_metadata[obj].gain = st_ivas->hIsmMetaData[obj]->edited_gain; + hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = st_ivas->hIsmMetaData[obj]->non_diegetic_flag; } - if ( hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + if ( ism_mode == ISM_SBA_MODE_DISC ) { hIvasEditableParameters->gain_bed = 1.0f; } } - else if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) + else if ( ism_mode == ISM_MODE_PARAM ) { - int16_t obj; for ( obj = 0; obj < hIvasEditableParameters->num_obj; obj++ ) { - hIvasEditableParameters->ism_metadata[obj].azimuth = hIvasDec->st_ivas->hParamIsmDec->azimuth_values[obj]; - hIvasEditableParameters->ism_metadata[obj].elevation = hIvasDec->st_ivas->hParamIsmDec->elevation_values[obj]; + hIvasEditableParameters->ism_metadata[obj].azimuth = st_ivas->hParamIsmDec->azimuth_values[obj]; + hIvasEditableParameters->ism_metadata[obj].elevation = st_ivas->hParamIsmDec->elevation_values[obj]; hIvasEditableParameters->ism_metadata[obj].yaw = 0.0f; hIvasEditableParameters->ism_metadata[obj].pitch = 0.0f; hIvasEditableParameters->ism_metadata[obj].radius = 0.0f; @@ -1382,9 +1385,7 @@ ivas_error IVAS_DEC_GetEditableParameters( } } - error = IVAS_ERR_OK; - - return error; + return IVAS_ERR_OK; } @@ -1398,7 +1399,14 @@ ivas_error IVAS_DEC_SetEditableParameters( IVAS_DEC_HANDLE hIvasDec, IVAS_EDITABLE_PARAMETERS hIvasEditableParameters ) { - ivas_error error; + int16_t obj; + Decoder_Struct *st_ivas; + ISM_MODE ism_mode; + + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } if ( !( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || ( hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT && hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) || @@ -1408,11 +1416,6 @@ ivas_error IVAS_DEC_SetEditableParameters( return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Object editing no supported in this operation mode." ); } - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } - #ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST if ( !hIvasDec->hasBeenFedFirstGoodFrame ) { @@ -1420,39 +1423,38 @@ ivas_error IVAS_DEC_SetEditableParameters( } #endif - error = IVAS_ERR_OK; + st_ivas = hIvasDec->st_ivas; + ism_mode = st_ivas->ism_mode; #ifdef DEBUGGING - assert( hIvasEditableParameters.num_obj == hIvasDec->st_ivas->nchan_ism ); + assert( hIvasEditableParameters.num_obj == st_ivas->nchan_ism ); #endif - if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) + if ( st_ivas->ivas_format == ISM_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) { - if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + if ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_SBA_MODE_DISC ) { - int16_t obj; for ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) { - hIvasDec->st_ivas->hIsmMetaData[obj]->edited_azimuth = hIvasEditableParameters.ism_metadata[obj].azimuth; - hIvasDec->st_ivas->hIsmMetaData[obj]->edited_elevation = hIvasEditableParameters.ism_metadata[obj].elevation; - hIvasDec->st_ivas->hIsmMetaData[obj]->edited_radius = hIvasEditableParameters.ism_metadata[obj].radius; + st_ivas->hIsmMetaData[obj]->edited_azimuth = hIvasEditableParameters.ism_metadata[obj].azimuth; + st_ivas->hIsmMetaData[obj]->edited_elevation = hIvasEditableParameters.ism_metadata[obj].elevation; + st_ivas->hIsmMetaData[obj]->edited_radius = hIvasEditableParameters.ism_metadata[obj].radius; - hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain = hIvasEditableParameters.ism_metadata[obj].gain; + st_ivas->hIsmMetaData[obj]->edited_gain = hIvasEditableParameters.ism_metadata[obj].gain; - hIvasDec->st_ivas->hIsmMetaData[obj]->edited_yaw = hIvasEditableParameters.ism_metadata[obj].yaw; - hIvasDec->st_ivas->hIsmMetaData[obj]->edited_pitch = hIvasEditableParameters.ism_metadata[obj].pitch; + st_ivas->hIsmMetaData[obj]->edited_yaw = hIvasEditableParameters.ism_metadata[obj].yaw; + st_ivas->hIsmMetaData[obj]->edited_pitch = hIvasEditableParameters.ism_metadata[obj].pitch; - hIvasDec->st_ivas->hIsmMetaData[obj]->non_diegetic_flag = hIvasEditableParameters.ism_metadata[obj].non_diegetic_flag; + st_ivas->hIsmMetaData[obj]->non_diegetic_flag = hIvasEditableParameters.ism_metadata[obj].non_diegetic_flag; } - if ( hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + if ( ism_mode == ISM_SBA_MODE_DISC ) { - hIvasDec->st_ivas->hSbaIsmData->gain_bed = hIvasEditableParameters.gain_bed; + st_ivas->hSbaIsmData->gain_bed = hIvasEditableParameters.gain_bed; } } - else if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) + else if ( ism_mode == ISM_MODE_PARAM ) { - int16_t obj; for ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) { } @@ -1463,7 +1465,7 @@ ivas_error IVAS_DEC_SetEditableParameters( } } - return error; + return IVAS_ERR_OK; } diff --git a/lib_enc/init_enc.c b/lib_enc/init_enc.c index e920f21bc..f5aab5580 100644 --- a/lib_enc/init_enc.c +++ b/lib_enc/init_enc.c @@ -54,21 +54,19 @@ *-----------------------------------------------------------------------*/ ivas_error init_encoder( - Encoder_State *st, /* i/o: state structure */ - Encoder_Struct *st_ivas, /* i/o: encoder state structure */ - const int16_t idchan, /* i : channel ID */ - const int16_t var_SID_rate_flag, /* i : flag for variable SID update rate */ - const int16_t interval_SID, /* i : interval for SID update */ - const int16_t vad_only_flag, /* i : flag to indicate front-VAD structure */ - const ISM_MODE ism_mode, /* i : ISM mode */ - const int32_t element_brate /* i : element bitrate */ + Encoder_State *st, /* i/o: state structure */ + Encoder_Struct *st_ivas, /* i/o: encoder state structure */ + const int16_t idchan, /* i : channel ID */ + const int16_t vad_only_flag, /* i : flag to indicate front-VAD structure */ + const ISM_MODE ism_mode, /* i : ISM mode */ + const int32_t element_brate /* i : element bitrate */ ) { - int16_t i; + int16_t i, input_frame; ivas_error error; int32_t igf_brate; - error = IVAS_ERR_OK; + input_frame = (int16_t) ( st->input_Fs / FRAMES_PER_SEC ); /*-----------------------------------------------------------------* * General parameters @@ -303,11 +301,11 @@ ivas_error init_encoder( st->old_input_signal = st->input_buff; if ( st->element_mode == EVS_MONO ) { - st->input = st->input_buff + st->input_Fs / FRAMES_PER_SEC + NS2SA( st->input_Fs, DELAY_FIR_RESAMPL_NS ); + st->input = st->input_buff + input_frame + NS2SA( st->input_Fs, DELAY_FIR_RESAMPL_NS ); } else { - st->input = st->input_buff + st->input_Fs / FRAMES_PER_SEC; + st->input = st->input_buff + input_frame; } } else @@ -438,7 +436,7 @@ ivas_error init_encoder( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX variables\n" ) ); } - dtx_enc_init( st, var_SID_rate_flag, interval_SID ); + dtx_enc_init( st, st_ivas->hEncoderConfig->var_SID_rate_flag, st_ivas->hEncoderConfig->interval_SID ); } else { @@ -475,7 +473,7 @@ ivas_error init_encoder( st->core = -1; st->rf_mode = 0; - return error; + return IVAS_ERR_OK; } /*-----------------------------------------------------------------* @@ -862,11 +860,11 @@ ivas_error init_encoder( if ( st->element_mode > EVS_MONO ) { - InitTransientDetection( (int16_t) ( st->input_Fs / FRAMES_PER_SEC ), 0, st->hTranDet, 1 ); + InitTransientDetection( input_frame, 0, st->hTranDet, 1 ); } else { - InitTransientDetection( (int16_t) ( st->input_Fs / FRAMES_PER_SEC ), NS2SA( st->input_Fs, DELAY_FIR_RESAMPL_NS ), st->hTranDet, 0 ); + InitTransientDetection( input_frame, NS2SA( st->input_Fs, DELAY_FIR_RESAMPL_NS ), st->hTranDet, 0 ); } /*-----------------------------------------------------------------* @@ -878,7 +876,7 @@ ivas_error init_encoder( st->bits_frame_channel = 0; st->side_bits_frame_channel = 0; - return error; + return IVAS_ERR_OK; } diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 6761e54ed..2d35653b7 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -955,7 +955,7 @@ ivas_error create_cpe_enc( st->total_brate = hCPE->element_brate / ( st_ivas->nCPE > 1 ? 1 : CPE_CHANNELS ); /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ st->mct_chan_mode = MCT_CHAN_MODE_REGULAR; - if ( ( error = init_encoder( st, st_ivas, n, hEncoderConfig->var_SID_rate_flag, hEncoderConfig->interval_SID, 0, ISM_MODE_NONE, hCPE->element_brate ) ) != IVAS_ERR_OK ) + if ( ( error = init_encoder( st, st_ivas, n, 0, ISM_MODE_NONE, hCPE->element_brate ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc.c index 02d81d083..0f7e80cc1 100644 --- a/lib_enc/ivas_sce_enc.c +++ b/lib_enc/ivas_sce_enc.c @@ -373,7 +373,7 @@ 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->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, hSCE->element_brate ) ) != IVAS_ERR_OK ) + if ( ( error = init_encoder( st, st_ivas, 0, 0, st_ivas->ism_mode, hSCE->element_brate ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 1d0459a33..79b00113f 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -223,7 +223,7 @@ 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->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, hSpar->hCoreCoderVAD->total_brate ) ) != IVAS_ERR_OK ) + if ( ( error = init_encoder( hSpar->hCoreCoderVAD, st_ivas, 0, 1, st_ivas->ism_mode, hSpar->hCoreCoderVAD->total_brate ) ) != IVAS_ERR_OK ) { return error; } -- GitLab