diff --git a/lib_com/edct.c b/lib_com/edct.c index d7af669c6598d25ec74b5d5d05af7d5fe667f7a5..c336ccdd81ee95b8b7efac4fd5e2c94a7348081a 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 5f7ab86cf1b7c7ee447c853e104672c520dff706..c624212fc3060e0b874a32170932fbf5c9183f11 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -2247,14 +2247,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 /* element bitrate */ ); void LPDmem_enc_init( diff --git a/lib_com/tcx_utils.c b/lib_com/tcx_utils.c index 458a43d72bf7b49254959d4897d88f997ce6e922..d37ecf207bdd514e006a0dd87022f875d0109ac0 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 f83de6eb2e85e176456c5e2c6a788be3e3091e6b..11359e665830f88a0e42ee9689446f448185f672 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1520,7 +1520,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 ) { @@ -1542,7 +1542,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 ); @@ -1667,7 +1667,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 ) { @@ -1689,7 +1689,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 ); } @@ -2126,7 +2126,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; } @@ -2156,8 +2156,8 @@ ivas_error ivas_init_decoder( } } - if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, - st_ivas->hRenderConfig, st_ivas->hHrtfCrend, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, 0, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, output_config, + st_ivas->hRenderConfig, st_ivas->hHrtfCrend, st_ivas->hHrtfStatistics, output_Fs, 0, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) { return error; } @@ -2259,7 +2259,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; } @@ -2322,7 +2322,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; @@ -2377,7 +2377,7 @@ ivas_error ivas_init_decoder( if ( ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) && 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_enc/init_enc.c b/lib_enc/init_enc.c index e920f21bc9ff957a3f3787e2a88d7ef484b452e8..f5aab5580bbb8dd954fe3a2ae17b064ebf8bbf6d 100755 --- 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 7c5b66cb8ca5f650ab98d7c24ccafb800a315059..2c954fde2e27488962d9ad083c3d3da3b21b6811 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -925,7 +925,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_init_enc.c b/lib_enc/ivas_init_enc.c index 54e0a8c7e5cda49456c97f85bf217b811b0742e8..336e5fcbfe905367258a625a89215ad678aba837 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -782,7 +782,7 @@ ivas_error ivas_init_encoder( { st_ivas->mc_mode = ivas_mc_mode_select( hEncoderConfig->mc_input_setup, ivas_total_brate ); - if ( ( error = ivas_create_lfe_lpf_enc( &st_ivas->hLfeLpf, hEncoderConfig->input_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_create_lfe_lpf_enc( &st_ivas->hLfeLpf, input_Fs ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc.c index 913fe907542f53f549525d32fd9ce63a3930eedc..5d1f56ab30c3243eb0f0187e1b32761ee14979d7 100644 --- a/lib_enc/ivas_sce_enc.c +++ b/lib_enc/ivas_sce_enc.c @@ -367,7 +367,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 1d0459a3331cddc71b7a80b46489aabf3cd14974..79b00113fcc57bcd55e3951aac232820daa1e3bf 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; }