diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c index e5f72590a60dc700b31ed3d3f6b089f9d6a333b9..f8e70061bfa51ca2f6915e002341c99736bfe67e 100644 --- a/lib_com/bitstream.c +++ b/lib_com/bitstream.c @@ -833,12 +833,13 @@ static ivas_error write_indices_element( /* restore previous pointer position */ pt_stream_loc = pt_stream_backup; } - +#ifndef ISSUE_24_CLEANUP_MCT_LFE /* TODO implemented only for MCT for now */ if ( ( st_ivas->hEncoderConfig->ivas_format == MC_FORMAT ) && ( st_ivas->mc_mode == MC_MODE_MCT ) && ( element_id * CPE_CHANNELS + n == LFE_CHANNEL ) ) { continue; } +#endif #ifdef ENABLE_BITRATE_VERIFICATION total_nb_bits = #endif diff --git a/lib_com/core_com_config.c b/lib_com/core_com_config.c index 120d0876d1f32569cf4bd8afe3b5089af9924789..d138fe1a1ed28c2dc77f12c855af07457a843319 100644 --- a/lib_com/core_com_config.c +++ b/lib_com/core_com_config.c @@ -247,16 +247,21 @@ int16_t getResq( *-------------------------------------------------------------------*/ int16_t getTnsAllowed( - const int32_t total_brate, /* i : total bitrate */ - const int16_t igf, /* i : flag indicating IGF activity*/ - const int16_t element_mode, /* i : IVAS element mode */ + const int32_t total_brate, /* i : total bitrate */ + const int16_t igf, /* i : flag indicating IGF activity*/ + const int16_t element_mode /* i : IVAS element mode */ +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , const MCT_CHAN_MODE mct_chan_mode /* i : MCT channel mode */ +#endif ) { int16_t tnsAllowed = 0; +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( mct_chan_mode != MCT_CHAN_MODE_LFE ) { +#endif if ( igf ) { if ( total_brate > HQ_16k40 || ( ( total_brate > HQ_13k20 ) && element_mode == IVAS_CPE_DFT ) ) @@ -268,7 +273,9 @@ int16_t getTnsAllowed( { tnsAllowed = 1; } +#ifndef ISSUE_24_CLEANUP_MCT_LFE } +#endif return tnsAllowed; } @@ -411,16 +418,21 @@ int16_t getIgfPresent( const int16_t element_mode, /* i : IVAS element mode */ const int32_t total_brate, /* i : total bitrate */ const int16_t bwidth, /* i : audio bandwidth */ - const int16_t rf_mode, /* i : flag to signal the RF mode */ + const int16_t rf_mode /* i : flag to signal the RF mode */ +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , const int16_t mct_chan_mode /* i : MCT channel mode */ +#endif ) { int16_t igfPresent = 0; +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( mct_chan_mode == MCT_CHAN_MODE_LFE ) { return igfPresent; } +#endif if ( bwidth == SWB ) { @@ -808,8 +820,11 @@ void init_tcx_cfg( const int16_t infoIGFStopFreq, const int16_t element_mode, const int16_t ini_frame, - const int16_t MCT_flag, + const int16_t MCT_flag +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , const MCT_CHAN_MODE mct_chan_mode /* i : MDCT channel mode */ +#endif ) { int16_t i; @@ -840,13 +855,20 @@ void init_tcx_cfg( /* set number of coded lines */ hTcxCfg->tcx_coded_lines = getNumTcxCodedLines( bwidth ); +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( mct_chan_mode == MCT_CHAN_MODE_LFE ) { hTcxCfg->tcx_coded_lines = MCT_LFE_MAX_LINE; } +#endif /* TNS in TCX */ hTcxCfg->pCurrentTnsConfig = NULL; - hTcxCfg->fIsTNSAllowed = getTnsAllowed( total_brate, igf, element_mode, mct_chan_mode ); + hTcxCfg->fIsTNSAllowed = getTnsAllowed( total_brate, igf, element_mode +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + mct_chan_mode +#endif + ); if ( hTcxCfg->fIsTNSAllowed ) { diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index d7674b43735d439a5971a67f013fbe8567b6f29c..0b326ba8a58421e11ac8d21f8ac332e27195955f 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1283,18 +1283,26 @@ typedef enum #define NBBITS_MCT_RATIO 4 #define BITRATE_MCT_RATIO_RANGE ( 1 << NBBITS_MCT_RATIO ) /* Range of the coded bitrate distribution ratio */ +#ifndef ISSUE_24_CLEANUP_MCT_LFE #define LFE_BITS 180 - #define MCT_LFE_MAX_LINE 24 +#endif #define MCT_NUM_BLOCK_DATA_BITS 4 +#ifndef ISSUE_24_CLEANUP_MCT_LFE typedef enum { MCT_CHAN_MODE_REGULAR, MCT_CHAN_MODE_LFE, MCT_CHAN_MODE_IGNORE } MCT_CHAN_MODE; - +#else +typedef enum +{ + MCT_CHAN_MODE_REGULAR, + MCT_CHAN_MODE_IGNORE +} MCT_CHAN_MODE; +#endif /*----------------------------------------------------------------------------------* * Parametric MC Constants diff --git a/lib_com/ivas_mct_com.c b/lib_com/ivas_mct_com.c index 5ef4d294781b5027c1db1eeeeca326c40078784f..5a6eafed5be5d31471155dbc1311509a506c7a51 100644 --- a/lib_com/ivas_mct_com.c +++ b/lib_com/ivas_mct_com.c @@ -66,11 +66,13 @@ void splitAvailableBitsMCT( int16_t min_chan_bits[MCT_MAX_CHANNELS], min_bits_tot, remaining_bits; int16_t core[MCT_MAX_CHANNELS]; MCT_CHAN_MODE mct_chan_mode[MCT_MAX_CHANNELS]; +#ifndef ISSUE_24_CLEANUP_MCT_LFE int16_t num_lfe; int16_t lfe_channel; num_lfe = 0; lfe_channel = -1; +#endif min_bits_tot = 0; for ( i = 0; i < nchan; i++ ) @@ -85,18 +87,23 @@ void splitAvailableBitsMCT( mct_chan_mode[i] = ( (Decoder_State *) sts[i] )->mct_chan_mode; core[i] = ( (Decoder_State *) sts[i] )->core; } - +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( mct_chan_mode[i] == MCT_CHAN_MODE_LFE ) { num_lfe++; lfe_channel = i; assert( lfe_channel == LFE_CHANNEL ); } +#endif } for ( i = 0; i < nchan; i++ ) { - if ( mct_chan_mode[i] != MCT_CHAN_MODE_LFE && mct_chan_mode[i] != MCT_CHAN_MODE_IGNORE ) + if ( +#ifndef ISSUE_24_CLEANUP_MCT_LFE + mct_chan_mode[i] != MCT_CHAN_MODE_LFE && +#endif + mct_chan_mode[i] != MCT_CHAN_MODE_IGNORE ) { min_chan_bits[i] = 0; @@ -128,7 +135,11 @@ void splitAvailableBitsMCT( bits_frame_channel = &( (Decoder_State *) sts[i] )->bits_frame_channel; } - if ( mct_chan_mode[i] != MCT_CHAN_MODE_LFE && mct_chan_mode[i] != MCT_CHAN_MODE_IGNORE ) + if ( +#ifndef ISSUE_24_CLEANUP_MCT_LFE + mct_chan_mode[i] != MCT_CHAN_MODE_LFE && +#endif + mct_chan_mode[i] != MCT_CHAN_MODE_IGNORE ) { assert( split_ratio[i] >= 1 && split_ratio[i] < BITRATE_MCT_RATIO_RANGE ); *bits_frame_channel = split_ratio[i] * remaining_bits / BITRATE_MCT_RATIO_RANGE + min_chan_bits[i]; @@ -162,7 +173,11 @@ void splitAvailableBitsMCT( bits_frame_channel = &( (Decoder_State *) sts[i] )->bits_frame_channel; } - if ( mct_chan_mode[i] != MCT_CHAN_MODE_LFE && mct_chan_mode[i] != MCT_CHAN_MODE_IGNORE ) + if ( +#ifndef ISSUE_24_CLEANUP_MCT_LFE + mct_chan_mode[i] != MCT_CHAN_MODE_LFE && +#endif + mct_chan_mode[i] != MCT_CHAN_MODE_IGNORE ) { *bits_frame_channel -= diff * split_ratio[i] / BITRATE_MCT_RATIO_RANGE; *bits_frame_channel = max( min_chan_bits[i], *bits_frame_channel ); diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index fef0aa2a41d305037444e08cabb9bb880427918e..2e7bc2799c5a0d968b07b5e7be44a73c78f10758 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -2233,7 +2233,9 @@ void decoder_tcx_imdct( float synthFB[], const int16_t bfi, /* i : Bad frame indicator */ const int16_t frame_cnt, /* i : frame counter in the super frame */ +#ifndef ISSUE_24_CLEANUP_MCT_LFE const int16_t isLFE, /* i : is LFE */ +#endif const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ ); @@ -2798,7 +2800,9 @@ void ivas_mdct_core_whitening_enc( int16_t tnsSize[CPE_CHANNELS][NB_DIV], /* o : size of TNS */ int16_t p_param[CPE_CHANNELS][NB_DIV], /* o : pointer to parameter array */ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ +#ifndef ISSUE_24_CLEANUP_MCT_LFE int16_t *LFE_off, /* o : flag if LFE has content */ +#endif const int16_t mct_on, /* i : flag mct block (1) or stereo (0) */ const int16_t nChannels /* i : total number of coded channels */ ); @@ -2816,7 +2820,9 @@ void ivas_mct_core_enc( void ivas_mdct_quant_coder( CPE_ENC_HANDLE hCPE, /* i/o: Encoder CPE handle */ +#ifndef ISSUE_24_CLEANUP_MCT_LFE const int16_t LFE_off, /* i : flag if LFE has content */ +#endif int16_t tnsBits[CPE_CHANNELS][NB_DIV], /* i : bits needed for TNS parameters */ int16_t tnsSize[CPE_CHANNELS][NB_DIV], /* i : size of TNS */ int16_t p_param[CPE_CHANNELS][NB_DIV], /* i : pointer to parameter array */ @@ -2867,7 +2873,9 @@ void ivas_mdct_dec_side_bits_frame_channel( int16_t param_lpc[MCT_MAX_CHANNELS][NPRM_LPC_NEW], /* o : lpc_parameters */ int16_t p_param[CPE_CHANNELS][NB_DIV], /* o : pointer to param buffer */ Decoder_State *st0, /* i : pointer to bitstream handle */ +#ifndef ISSUE_24_CLEANUP_MCT_LFE int16_t *LFE_off, /* o : flag if LFE has content */ +#endif int16_t nTnsBitsTCX10[CPE_CHANNELS][NB_DIV], /* o : number of bits for TNS */ int16_t param[CPE_CHANNELS][DEC_NPRM_DIV * NB_DIV], /* i/o: parameters buffer */ const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ @@ -2887,7 +2895,9 @@ void ivas_mct_side_bits( void ivas_mdct_core_invQ( CPE_DEC_HANDLE hCPE, /* i/o: CPE handle */ +#ifndef ISSUE_24_CLEANUP_MCT_LFE const int16_t LFE_off, /* i : flag if LFE content */ +#endif int16_t nTnsBitsTCX10[CPE_CHANNELS][NB_DIV], /* i : number of TNS bits */ int16_t p_param[CPE_CHANNELS][NB_DIV], /* i : pointer to param buffer */ int16_t param_lpc[CPE_CHANNELS][NPRM_LPC_NEW], /* i : lpc parameters */ @@ -2905,14 +2915,18 @@ void ivas_mdct_core_reconstruct( CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ float *x[][NB_DIV], /* i/o: pointers to synthesis @internal_FS */ float signal_outFB[CPE_CHANNELS][L_FRAME_PLUS], /* o : synthesis @output_FS */ +#ifndef ISSUE_24_CLEANUP_MCT_LFE const int16_t LFE_off, /* i : flag if LFE content */ +#endif int16_t fUseTns[CPE_CHANNELS][NB_DIV], /* i : flage TNS enabled */ const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */ ); void ivas_mdct_core_tns_ns( CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ +#ifndef ISSUE_24_CLEANUP_MCT_LFE const int16_t LFE_off, /* i : flag if LFE has content */ +#endif int16_t fUseTns[CPE_CHANNELS][NB_DIV], /* i : two entries for each channel in TCX10 */ STnsData tnsData[CPE_CHANNELS][NB_DIV], /* o : TNS parameter */ float *x[CPE_CHANNELS][NB_DIV], /* o : synthesis @internal_FS */ diff --git a/lib_com/options.h b/lib_com/options.h index c5df07148e4b7005ff84885ad292687a2f49851b..cce0aff4601d055c7f111b7ef353d7739ee978c7 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -64,7 +64,7 @@ /*#define DEBUG_MODE_TCX*/ /* output most important TCX core parameters to the subdirectory "res/" */ /*#define DEBUG_MODE_DFT*/ /* output most important DFT stereo parameters to the subdirectory "res/" */ /*#define DEBUG_MODE_TD*/ /* output most important TD stereo parameters to the subdirectory "res/ */ -/*#define DEBUG_MODE_DIRAC*/ /* output most important DIRAC parameters to the subdirectory "res/" */ +//#define DEBUG_MODE_DIRAC /* output most important DIRAC parameters to the subdirectory "res/" */ /*#define DEBUG_MODE_MDCT*/ /* output most important MDCT parameters to the subdirectory "res/" */ /*#define DEBUG_MODE_PARAM_MC */ /* output Parametric MC paramters to the subdirectory "res/" */ /*#define DEBUG_MODE_PARAM_ISM*/ /* output Parametric ISM paramters to the subdirectory "res/" */ @@ -167,6 +167,9 @@ #define FIX_ISM_DTX_CLICKS /* FhG: fix for clicks in ISM DTX for inactive to active TCX transitions */ +#define ISSUE_24_CLEANUP_MCT_LFE /* Issue 24: Cleanup LFE path withing MCT */ + + /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ #endif diff --git a/lib_com/prot.h b/lib_com/prot.h index 51d1cb1e20c4df051f2a4f0df8b1ddd961df1176..65846708efb7b3d9dfb6e7fb2c665299a3a223ad 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -7153,8 +7153,11 @@ void WindowSignal( int16_t *L_frame, /* i/o: frame length */ float out[], /* o : output windowed signal */ const int16_t truncate_aldo, /* i : nonzero to truncate long ALDO slope */ - const int16_t fullband, /* i : fullband flag */ - const int16_t isLfe /* i : LFE flag */ + const int16_t fullband /* i : fullband flag */ +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + const int16_t isLfe /* i : LFE flag */ +#endif ); void HBAutocorrelation( @@ -7307,8 +7310,11 @@ void tcx_get_windows( const float **left_win, /* o : left overlap window */ int16_t *right_overlap, /* o : right overlap length */ const float **right_win, /* o : right overlap window */ - const int16_t fullband, /* i : fullband flag */ - const int16_t isLfe /* i : LFE flag */ + const int16_t fullband /* i : fullband flag */ +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + const int16_t isLfe /* i : LFE flag */ +#endif ); void tcx_windowing_analysis( @@ -9495,11 +9501,15 @@ void TonalMDCTConceal_SaveTimeSignal( const int16_t numSamples ); void TonalMDCTConceal_Detect( - const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ - const float pitchLag, /*IN */ - int16_t *umIndices, /*OUT*/ - const PsychoacousticParameters *psychParamsCurrent, /*IN*/ - const int16_t isLfe ); + const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ + const float pitchLag, /*IN */ + int16_t *umIndices, /*OUT*/ + const PsychoacousticParameters *psychParamsCurrent /*IN*/ +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + const int16_t isLfe +#endif +); void TonalMDCTConceal_Apply( TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ @@ -9631,10 +9641,13 @@ int16_t getTcxonly( ); int16_t getTnsAllowed( - const int32_t total_brate, /* i : total bitrate */ - const int16_t igf, /* i : flag indicating IGF activity*/ - const int16_t element_mode, /* i : IVAS element mode */ + const int32_t total_brate, /* i : total bitrate */ + const int16_t igf, /* i : flag indicating IGF activity*/ + const int16_t element_mode /* i : IVAS element mode */ +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , const MCT_CHAN_MODE mct_chan_mode /* i : MCT channel mode */ +#endif ); int16_t getCtxHm( @@ -9676,8 +9689,11 @@ int16_t getIgfPresent( const int16_t element_mode, /* i : IVAS element mode */ const int32_t total_brate, /* i : total bitrate */ const int16_t bwidth, /* i : audio bandwidth */ - const int16_t rf_mode, /* i : flag to signal the RF mode */ + const int16_t rf_mode /* i : flag to signal the RF mode */ +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , const int16_t mct_chan_mode /* i : MCT channel mode */ +#endif ); int16_t getCnaPresent( @@ -9974,6 +9990,9 @@ void init_tcx_cfg( const int16_t infoIGFStopFreq, const int16_t element_mode, const int16_t ini_frame, - const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ + const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */ +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , const MCT_CHAN_MODE mct_chan_mode /* i : MCT channel mode */ +#endif ); diff --git a/lib_com/tcx_utils.c b/lib_com/tcx_utils.c index 07618c7cd21ce15d5a3de2c053159ac4509b1636..7eede5ae650d3c9033968ca70034a6c1e38ce3ca 100644 --- a/lib_com/tcx_utils.c +++ b/lib_com/tcx_utils.c @@ -59,16 +59,20 @@ void tcx_get_windows( const float **left_win, /* o : left overlap window */ int16_t *right_overlap, /* o : right overlap length */ const float **right_win, /* o : right overlap window */ - const int16_t fullband, /* i : fullband flag */ - const int16_t isLfe /* i : LFE flag */ + const int16_t fullband /* i : fullband flag */ +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + const int16_t isLfe /* i : LFE flag */ +#endif ) { +#ifndef ISSUE_24_CLEANUP_MCT_LFE /* LFE is only FULL_OVERLAP*/ if ( isLfe ) { assert( left_mode == FULL_OVERLAP && right_mode == FULL_OVERLAP ); } - +#endif if ( !fullband ) { /* Left part */ @@ -91,6 +95,7 @@ void tcx_get_windows( } else if ( left_mode == FULL_OVERLAP ) { +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( isLfe ) { *left_overlap = hTcxCfg->tcx_mdct_window_length; @@ -98,9 +103,12 @@ void tcx_get_windows( } else { +#endif *left_overlap = hTcxCfg->tcx_mdct_window_length; *left_win = hTcxCfg->tcx_aldo_window_1_trunc; +#ifndef ISSUE_24_CLEANUP_MCT_LFE } +#endif } else { @@ -121,6 +129,7 @@ void tcx_get_windows( } else if ( right_mode == FULL_OVERLAP ) { +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( isLfe ) { *right_overlap = hTcxCfg->tcx_mdct_window_length; @@ -128,9 +137,12 @@ void tcx_get_windows( } else { +#endif *right_overlap = hTcxCfg->tcx_mdct_window_delay; *right_win = hTcxCfg->tcx_aldo_window_2; +#ifndef ISSUE_24_CLEANUP_MCT_LFE } +#endif } else { @@ -164,6 +176,7 @@ void tcx_get_windows( } else if ( left_mode == FULL_OVERLAP ) { +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( isLfe ) { *left_overlap = hTcxCfg->tcx_mdct_window_lengthFB; @@ -171,9 +184,12 @@ void tcx_get_windows( } else { +#endif *left_overlap = hTcxCfg->tcx_mdct_window_lengthFB; *left_win = hTcxCfg->tcx_aldo_window_1_FB_trunc; +#ifndef ISSUE_24_CLEANUP_MCT_LFE } +#endif } else { @@ -199,6 +215,7 @@ void tcx_get_windows( } else if ( right_mode == FULL_OVERLAP ) { +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( isLfe ) { *right_overlap = hTcxCfg->tcx_mdct_window_lengthFB; @@ -206,9 +223,12 @@ void tcx_get_windows( } else { +#endif *right_overlap = hTcxCfg->tcx_mdct_window_delayFB; *right_win = hTcxCfg->tcx_aldo_window_2_FB; +#ifndef ISSUE_24_CLEANUP_MCT_LFE } +#endif } else { @@ -276,8 +296,11 @@ void WindowSignal( int16_t *L_frame, /* i/o: frame length */ float out[], /* o : output windowed signal */ const int16_t truncate_aldo, /* i : nonzero to truncate long ALDO slope */ - const int16_t fullband, /* i : fullband flag */ - const int16_t isLfe /* i : LFE flag */ + const int16_t fullband /* i : fullband flag */ +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + const int16_t isLfe /* i : LFE flag */ +#endif ) { int16_t l, r; @@ -288,7 +311,12 @@ void WindowSignal( * Init * *-----------------------------------------------------------*/ - tcx_get_windows( hTcxCfg, left_overlap_mode, right_overlap_mode, &l, &left_win, &r, &right_win, fullband, isLfe ); + tcx_get_windows( hTcxCfg, left_overlap_mode, right_overlap_mode, &l, &left_win, &r, &right_win, fullband +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + isLfe +#endif + ); /* Init lengths */ @@ -314,7 +342,11 @@ void WindowSignal( tcx_windowing_analysis( in - l / 2 + offset, *L_frame, l, left_win, r, right_win, out ); - if ( left_overlap_mode == FULL_OVERLAP && truncate_aldo && !isLfe ) + if ( left_overlap_mode == FULL_OVERLAP && truncate_aldo +#ifndef ISSUE_24_CLEANUP_MCT_LFE + && !isLfe +#endif + ) { /* fade truncated ALDO window to avoid discontinuities */ if ( !fullband ) diff --git a/lib_dec/core_dec_init.c b/lib_dec/core_dec_init.c index 1e238fb52f1603f5638fa7ece5dce5031f73a830..6d6ebeef86800182fbee4d5992066fd405956581 100644 --- a/lib_dec/core_dec_init.c +++ b/lib_dec/core_dec_init.c @@ -190,7 +190,12 @@ void open_decoder_LPD( { if ( !is_init || st->element_mode != IVAS_CPE_MDCT ) { - init_tcx_cfg( st->hTcxCfg, total_brate, st->sr_core, st->output_Fs, st->L_frame, st->bwidth, st->hTcxDec->L_frameTCX, st->fscale, encoderLookahead, encoderLookaheadFB, st->preemph_fac, st->tcxonly, st->rf_flag, st->igf, st->hIGFDec->infoIGFStopFreq, st->element_mode, st->ini_frame, MCT_flag, st->mct_chan_mode ); + init_tcx_cfg( st->hTcxCfg, total_brate, st->sr_core, st->output_Fs, st->L_frame, st->bwidth, st->hTcxDec->L_frameTCX, st->fscale, encoderLookahead, encoderLookaheadFB, st->preemph_fac, st->tcxonly, st->rf_flag, st->igf, st->hIGFDec->infoIGFStopFreq, st->element_mode, st->ini_frame, MCT_flag +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + st->mct_chan_mode +#endif + ); } else { @@ -670,10 +675,19 @@ void open_decoder_LPD( st->last_tns_active = 0; st->second_last_tns_active = 0; st->second_last_core = -1; - /* TODO: also apply for MCT modes, once issue #24 is solved */ - if ( st->hTcxCfg != NULL && !MCT_flag && st->element_mode != EVS_MONO ) + + if ( st->hTcxCfg != NULL && +#ifndef ISSUE_24_CLEANUP_MCT_LFE + !MCT_flag && +#endif + st->element_mode != EVS_MONO ) { - st->hTcxCfg->fIsTNSAllowed = getTnsAllowed( is_init ? total_brate : st->bits_frame_nominal * FRAMES_PER_SEC, st->igf, st->element_mode, st->mct_chan_mode ); + st->hTcxCfg->fIsTNSAllowed = getTnsAllowed( is_init ? total_brate : st->bits_frame_nominal * FRAMES_PER_SEC, st->igf, st->element_mode +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + st->mct_chan_mode +#endif + ); } if ( hTcxDec != NULL ) { diff --git a/lib_dec/core_dec_switch.c b/lib_dec/core_dec_switch.c index a092255a38897557b1260d1cd9860907a810aa15..b02d0a78f5ae2ba639ec634ce3c99d389ec565af 100644 --- a/lib_dec/core_dec_switch.c +++ b/lib_dec/core_dec_switch.c @@ -91,7 +91,12 @@ void mode_switch_decoder_LPD( switchWB = 1; /*force init when coming from MODE1*/ } - st->igf = getIgfPresent( st->element_mode, total_brate, bwidth, st->rf_flag, st->mct_chan_mode ); + st->igf = getIgfPresent( st->element_mode, total_brate, bwidth, st->rf_flag +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + st->mct_chan_mode +#endif + ); if ( st->hIGFDec != NULL ) { @@ -140,7 +145,12 @@ void mode_switch_decoder_LPD( if ( st->hTcxCfg != NULL ) { st->hTcxCfg->pCurrentTnsConfig = NULL; - st->hTcxCfg->fIsTNSAllowed = getTnsAllowed( total_brate, st->igf, st->element_mode, st->mct_chan_mode ); + st->hTcxCfg->fIsTNSAllowed = getTnsAllowed( total_brate, st->igf, st->element_mode +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + st->mct_chan_mode +#endif + ); } if ( st->hTcxCfg->fIsTNSAllowed && st->hIGFDec != NULL && st->hTcxCfg != NULL ) diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c index 9c8172589405790afab9bd795820260975bbb10b..fbdd150217ff246abdd3ca4cbe898278b5ef06d2 100644 --- a/lib_dec/dec_tcx.c +++ b/lib_dec/dec_tcx.c @@ -107,7 +107,11 @@ void decoder_tcx( decoder_tcx_tns( st, L_frame_glob, L_spec, L_frame, L_frameTCX, &x[0], fUseTns, &tnsData, bfi, frame_cnt, 0 ); decoder_tcx_imdct( st, L_frame_glob, L_frameTCX_glob, L_spec, tcx_offset, tcx_offsetFB, L_frame, L_frameTCX, left_rect, &x[0], &xn_buf[0], MDCT_IV, - fUseTns, &synth[0], &synthFB[0], bfi, frame_cnt, 0, sba_dirac_stereo_flag ); + fUseTns, &synth[0], &synthFB[0], bfi, frame_cnt, +#ifndef ISSUE_24_CLEANUP_MCT_LFE + 0, +#endif + sba_dirac_stereo_flag ); return; } @@ -335,7 +339,12 @@ void IMDCT( v_multc( old_syn_overl, hTcxDec->conceal_eof_gain * st->last_concealed_gain_syn_deemph, old_syn_overl, overlap ); } - if ( ( L_frameTCX == hTcxDec->L_frameTCX >> 1 || st->mct_chan_mode == MCT_CHAN_MODE_LFE ) && ( st->tcxonly ) ) + if ( ( L_frameTCX == hTcxDec->L_frameTCX >> 1 +#ifndef ISSUE_24_CLEANUP_MCT_LFE + || st->mct_chan_mode == MCT_CHAN_MODE_LFE +#endif + ) && + ( st->tcxonly ) ) { /* Mode decision in PLC @@ -354,7 +363,9 @@ void IMDCT( if ( ( !bfi && hTcxCfg->tcx_last_overlap_mode != FULL_OVERLAP ) || ( bfi && ( hTcxCfg->tcx_last_overlap_mode != FULL_OVERLAP ) && ( hTcxCfg->tcx_curr_overlap_mode != FULL_OVERLAP ) ) ) { +#ifndef ISSUE_24_CLEANUP_MCT_LFE assert( st->mct_chan_mode != MCT_CHAN_MODE_LFE ); +#endif /* minimum or half overlap, two transforms, grouping into one window */ L_win = L_frame >> 1; L_ola = ( hTcxCfg->tcx_last_overlap_mode == MIN_OVERLAP ) ? tcx_mdct_window_min_length : tcx_mdct_window_half_length; @@ -392,7 +403,11 @@ void IMDCT( /* To assure that no garbage values are passed to overlap */ set_zero( xn_buf + L_frame + tcx_offset + ( L_ola >> 1 ), overlap - tcx_offset - ( L_ola >> 1 ) ); } - else if ( !bfi && ( frame_cnt == 0 ) && ( hTcxCfg->tcx_curr_overlap_mode == FULL_OVERLAP ) && st->mct_chan_mode != MCT_CHAN_MODE_LFE ) + else if ( !bfi && ( frame_cnt == 0 ) && ( hTcxCfg->tcx_curr_overlap_mode == FULL_OVERLAP ) +#ifndef ISSUE_24_CLEANUP_MCT_LFE + && st->mct_chan_mode != MCT_CHAN_MODE_LFE +#endif + ) { /* special overlap attempt, two transforms, grouping into one window */ @@ -553,7 +568,13 @@ void IMDCT( /* Window and overlap-add past frame if past frame is TCX */ if ( ( frame_cnt != 0 ) || ( st->last_core_bfi > ACELP_CORE ) ) { - if ( ( ( L_frameTCX == hTcxDec->L_frameTCX >> 1 || st->mct_chan_mode == MCT_CHAN_MODE_LFE ) && ( st->tcxonly ) ) || ( hTcxCfg->tcx_last_overlap_mode == TRANSITION_OVERLAP ) ) + if ( ( ( L_frameTCX == hTcxDec->L_frameTCX >> 1 +#ifndef ISSUE_24_CLEANUP_MCT_LFE + || st->mct_chan_mode == MCT_CHAN_MODE_LFE +#endif + ) && + ( st->tcxonly ) ) || + ( hTcxCfg->tcx_last_overlap_mode == TRANSITION_OVERLAP ) ) { if ( !bfi && ( frame_cnt > 0 ) && ( index == 0 ) && ( hTcxCfg->tcx_curr_overlap_mode == FULL_OVERLAP ) && ( st->last_core != ACELP_CORE ) ) { @@ -616,7 +637,11 @@ void IMDCT( } } - if ( !aldo && ( ( ( L_frameTCX == hTcxDec->L_frameTCX >> 1 ) && frame_cnt > 0 ) || L_frameTCX != ( hTcxDec->L_frameTCX >> 1 ) ) && st->mct_chan_mode != MCT_CHAN_MODE_LFE ) + if ( !aldo && ( ( ( L_frameTCX == hTcxDec->L_frameTCX >> 1 ) && frame_cnt > 0 ) || L_frameTCX != ( hTcxDec->L_frameTCX >> 1 ) ) +#ifndef ISSUE_24_CLEANUP_MCT_LFE + && st->mct_chan_mode != MCT_CHAN_MODE_LFE +#endif + ) { /* Compute windowed synthesis in case of switching to ALDO windows in next frame */ mvr2r( xn_buf + L_frame - nz, old_out, nz + overlap ); @@ -1557,9 +1582,11 @@ void decoder_tcx_imdct( const int16_t fUseTns, /* i : flag that is set if TNS data is present */ float synth[], /* i/o: synth[-M..L_frame] */ float synthFB[], - const int16_t bfi, /* i : Bad frame indicator */ - const int16_t frame_cnt, /* i : frame counter in the super frame */ - const int16_t isLFE, /* i : is LFE */ + const int16_t bfi, /* i : Bad frame indicator */ + const int16_t frame_cnt, /* i : frame counter in the super frame */ +#ifndef ISSUE_24_CLEANUP_MCT_LFE + const int16_t isLFE, /* i : is LFE */ +#endif const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ ) { @@ -1591,7 +1618,11 @@ void decoder_tcx_imdct( hTcxCfg->tcx_last_overlap_mode = hTcxCfg->tcx_curr_overlap_mode; } - if ( !isLFE && st->igf ) + if ( +#ifndef ISSUE_24_CLEANUP_MCT_LFE + !isLFE && +#endif + st->igf ) { proc = st->hIGFDec->flatteningTrigger; @@ -1689,7 +1720,18 @@ void decoder_tcx_imdct( if ( st->element_mode != IVAS_CPE_DFT && !sba_dirac_stereo_flag ) { - IMDCT( xn_bufFB, hTcxDec->syn_Overl, hTcxDec->syn_Overl_TDAC, xn_buf, st->mct_chan_mode == MCT_CHAN_MODE_LFE ? hTcxCfg->tcx_mdct_window : hTcxCfg->tcx_aldo_window_1_trunc, st->mct_chan_mode == MCT_CHAN_MODE_LFE ? hTcxCfg->tcx_mdct_window : hTcxCfg->tcx_aldo_window_2, hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_min_length, index, + IMDCT( xn_bufFB, hTcxDec->syn_Overl, hTcxDec->syn_Overl_TDAC, xn_buf, +#ifndef ISSUE_24_CLEANUP_MCT_LFE + st->mct_chan_mode == MCT_CHAN_MODE_LFE ? hTcxCfg->tcx_mdct_window : hTcxCfg->tcx_aldo_window_1_trunc, +#else + hTcxCfg->tcx_aldo_window_1_trunc, +#endif +#ifndef ISSUE_24_CLEANUP_MCT_LFE + st->mct_chan_mode == MCT_CHAN_MODE_LFE ? hTcxCfg->tcx_mdct_window : hTcxCfg->tcx_aldo_window_2, +#else + hTcxCfg->tcx_aldo_window_2, +#endif + hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_min_length, index, kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, max( L_frameTCX, L_spec ) >> 1, L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_outLB, 0, st, 0, acelp_zir ); } @@ -1709,7 +1751,13 @@ void decoder_tcx_imdct( if ( st->element_mode != EVS_MONO ) { - IMDCT( x_tmp, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB, st->mct_chan_mode == MCT_CHAN_MODE_LFE ? hTcxCfg->tcx_mdct_windowFB : hTcxCfg->tcx_aldo_window_1_FB_trunc, st->mct_chan_mode == MCT_CHAN_MODE_LFE ? hTcxCfg->tcx_mdct_windowFB : hTcxCfg->tcx_aldo_window_2_FB, hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, + IMDCT( x_tmp, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB, +#ifndef ISSUE_24_CLEANUP_MCT_LFE + st->mct_chan_mode == MCT_CHAN_MODE_LFE ? hTcxCfg->tcx_mdct_windowFB : hTcxCfg->tcx_aldo_window_1_FB_trunc, st->mct_chan_mode == MCT_CHAN_MODE_LFE ? hTcxCfg->tcx_mdct_windowFB : hTcxCfg->tcx_aldo_window_2_FB, +#else + hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, +#endif + hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, max( L_frameTCX, L_spec ) >> 1, L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out, 1, st, FSCALE_DENOM * L_frameTCX_glob / L_frame_glob, acelp_zir ); } else diff --git a/lib_dec/er_util.c b/lib_dec/er_util.c index 809b0134d9653d91a028804f78eee5468a801782..75f553f1e83602560ac49cbedfb048e4710b23d9 100644 --- a/lib_dec/er_util.c +++ b/lib_dec/er_util.c @@ -318,8 +318,12 @@ int16_t GetPLCModeDecision( { TonalMDCTConceal_Detect( st->hTonalMDCTConc, ( hTcxDec->tcxltp_last_gain_unmodified > 0 ) ? st->old_fpitch : 0, &numIndices, - ( st->element_mode == IVAS_CPE_MDCT ? &( st->hTcxCfg->psychParamsTCX20 ) : st->hTcxCfg->psychParamsCurrent ), - st->mct_chan_mode == MCT_CHAN_MODE_LFE ); + ( st->element_mode == IVAS_CPE_MDCT ? &( st->hTcxCfg->psychParamsTCX20 ) : st->hTcxCfg->psychParamsCurrent ) +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + st->mct_chan_mode == MCT_CHAN_MODE_LFE +#endif + ); if ( ( numIndices > 10 ) || ( ( numIndices > 5 ) && ( fabs( hTcxDec->tcxltp_third_last_pitch - hTcxDec->tcxltp_second_last_pitch ) < 0.5f ) ) || ( ( numIndices > 0 ) && ( ( st->last_good <= UNVOICED_TRANSITION ) || ( hTcxDec->tcxltp_last_gain_unmodified <= 0.4f ) ) && ( fabs( hTcxDec->tcxltp_third_last_pitch - hTcxDec->tcxltp_second_last_pitch ) < 0.5f ) ) ) { diff --git a/lib_dec/init_dec.c b/lib_dec/init_dec.c index 34ee7a3cec83ca8730cb700ca95f065c0b062466..97aa4a0fc836bf20a7ed38cf339df8a1268d307e 100644 --- a/lib_dec/init_dec.c +++ b/lib_dec/init_dec.c @@ -326,7 +326,11 @@ ivas_error init_decoder( set_f( st->old_synth_sw, 0.0f, NS2SA( 48000, FRAME_SIZE_NS - ACELP_LOOK_NS - DELAY_BWE_TOTAL_NS ) ); } - if ( ( idchan == 0 || st->element_mode == IVAS_CPE_MDCT || st->element_mode == IVAS_SCE || st->element_mode == EVS_MONO ) && st->mct_chan_mode != MCT_CHAN_MODE_LFE ) + if ( ( idchan == 0 || st->element_mode == IVAS_CPE_MDCT || st->element_mode == IVAS_SCE || st->element_mode == EVS_MONO ) +#ifndef ISSUE_24_CLEANUP_MCT_LFE + && st->mct_chan_mode != MCT_CHAN_MODE_LFE +#endif + ) { if ( ( st->hHQ_core = (HQ_DEC_HANDLE) malloc( sizeof( HQ_DEC_DATA ) ) ) == NULL ) { @@ -519,17 +523,21 @@ ivas_error init_decoder( } /* open synthesis for output sampling rate */ +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( st->mct_chan_mode != MCT_CHAN_MODE_LFE ) { +#endif if ( ( error = openCldfb( &st->cldfbSyn, CLDFB_SYNTHESIS, st->output_Fs, CLDFB_PROTOTYPE_1_25MS ) ) != IVAS_ERR_OK ) { return error; } +#ifndef ISSUE_24_CLEANUP_MCT_LFE } else { st->cldfbSyn = NULL; } +#endif st->cldfbSynHB = NULL; @@ -585,7 +593,11 @@ ivas_error init_decoder( *-----------------------------------------------------------------*/ /* TCX-LTP */ - if ( ( idchan == 0 || st->element_mode == IVAS_CPE_MDCT ) && st->mct_chan_mode != MCT_CHAN_MODE_LFE ) + if ( ( idchan == 0 || st->element_mode == IVAS_CPE_MDCT ) +#ifndef ISSUE_24_CLEANUP_MCT_LFE + && st->mct_chan_mode != MCT_CHAN_MODE_LFE +#endif + ) { if ( ( st->hTcxLtpDec = (TCX_LTP_DEC_HANDLE) malloc( sizeof( TCX_LTP_DEC_DATA ) ) ) == NULL ) { @@ -598,7 +610,7 @@ ivas_error init_decoder( } /* TCX core */ - // VE: reduction possible for MCT_CHAN_MODE_LFE channel - see I1-172 + if ( idchan == 0 || st->element_mode == IVAS_CPE_MDCT ) { if ( ( st->hTcxDec = (TCX_DEC_HANDLE) malloc( sizeof( TCX_DEC_DATA ) ) ) == NULL ) @@ -617,7 +629,11 @@ ivas_error init_decoder( } /* TCX config. data structure */ - if ( ( idchan == 0 || st->element_mode == IVAS_CPE_MDCT ) && st->mct_chan_mode != MCT_CHAN_MODE_LFE ) + if ( ( idchan == 0 || st->element_mode == IVAS_CPE_MDCT ) +#ifndef ISSUE_24_CLEANUP_MCT_LFE + && st->mct_chan_mode != MCT_CHAN_MODE_LFE +#endif + ) { if ( ( st->hTcxCfg = (TCX_CONFIG_HANDLE) malloc( sizeof( TCX_config ) ) ) == NULL ) { @@ -630,7 +646,11 @@ ivas_error init_decoder( } /* Tonal MDCT concealment data structure */ - if ( ( idchan == 0 || st->element_mode == IVAS_CPE_MDCT ) && st->mct_chan_mode != MCT_CHAN_MODE_LFE ) + if ( ( idchan == 0 || st->element_mode == IVAS_CPE_MDCT ) +#ifndef ISSUE_24_CLEANUP_MCT_LFE + && st->mct_chan_mode != MCT_CHAN_MODE_LFE +#endif + ) { if ( ( st->hTonalMDCTConc = (TonalMDCTConcealPtr) malloc( sizeof( TonalMDCTConceal_INSTANCE ) ) ) == NULL ) { @@ -646,7 +666,11 @@ ivas_error init_decoder( * IGF *-----------------------------------------------------------------*/ - if ( ( idchan == 0 || st->element_mode == IVAS_CPE_MDCT ) && st->mct_chan_mode != MCT_CHAN_MODE_LFE ) + if ( ( idchan == 0 || st->element_mode == IVAS_CPE_MDCT ) +#ifndef ISSUE_24_CLEANUP_MCT_LFE + && st->mct_chan_mode != MCT_CHAN_MODE_LFE +#endif + ) { if ( ( st->hIGFDec = (IGF_DEC_INSTANCE_HANDLE) malloc( sizeof( IGFDEC_INSTANCE ) ) ) == NULL ) { diff --git a/lib_dec/ivas_cpe_dec.c b/lib_dec/ivas_cpe_dec.c index 17d2efd51620d437b020f13899a8b75c16fded61..5156aad08c16c209e9fab116858cf2b04d08e983 100755 --- a/lib_dec/ivas_cpe_dec.c +++ b/lib_dec/ivas_cpe_dec.c @@ -691,10 +691,12 @@ ivas_error create_cpe_dec( st->total_brate = hCPE->element_brate / ( 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; +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCT && ( n + cpe_id * CPE_CHANNELS ) == LFE_CHANNEL ) { st->mct_chan_mode = MCT_CHAN_MODE_LFE; } +#endif if ( ( error = init_decoder( st, n, st_ivas->mc_mode ) ) != IVAS_ERR_OK ) { @@ -835,8 +837,12 @@ void destroy_cpe_dec( int16_t n; Decoder_State *st; - /* make sure we deallocate a potential distinct hTcxCfg for a MCT LFE channel (can only happen in rs) */ - if ( hCPE->hCoreCoder[1] != NULL && hCPE->hCoreCoder[1]->mct_chan_mode == MCT_CHAN_MODE_LFE && hCPE->hCoreCoder[1]->hTcxCfg != hCPE->hCoreCoder[0]->hTcxCfg ) + /* make sure we deallocate a potential distinct hTcxCfg for a MCT LFE channel (can only happen in rs) */ /*TODO Check this again with LFE clean up!*/ + if ( hCPE->hCoreCoder[1] != NULL +#ifndef ISSUE_24_CLEANUP_MCT_LFE + && hCPE->hCoreCoder[1]->mct_chan_mode == MCT_CHAN_MODE_LFE +#endif + && hCPE->hCoreCoder[1]->hTcxCfg != hCPE->hCoreCoder[0]->hTcxCfg ) { hCPE->hCoreCoder[1]->mct_chan_mode = MCT_CHAN_MODE_IGNORE; } diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 8eb822a32ef7ebede16f5d0a7b89d5f873b712c3..b4eb783624a3e2115d73c4dda09e06d991af8799 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -477,10 +477,12 @@ ivas_error ivas_dec( /* LFE channel decoder */ if ( st_ivas->mc_mode == MC_MODE_MCT ) { +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( st_ivas->hCPE[1]->hCoreCoder[1]->hTcxCfg == NULL ) { st_ivas->hCPE[1]->hCoreCoder[1]->hTcxCfg = st_ivas->hCPE[1]->hCoreCoder[0]->hTcxCfg; } +#endif ivas_lfe_dec( st_ivas->hLFE, st, output_frame, st_ivas->bfi, output_lfe_ch ); } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 3d09726e5e837105bb1a787d84e78dea01dc6b9e..c0f073af4b1ffb4f3bdad13b712f84c37396aa5b 100755 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1404,13 +1404,14 @@ ivas_error ivas_init_decoder( return error; } +#ifndef ISSUE_24_CLEANUP_MCT_LFE /* reuse core-coder buffers for LFE decoder */ cpe_id = LFE_CHANNEL / CPE_CHANNELS; n = LFE_CHANNEL % CPE_CHANNELS; st_ivas->hLFE->prevsynth_buf = &st_ivas->hCPE[cpe_id]->hCoreCoder[n]->old_synth_sw[0]; st_ivas->hLFE->prior_out_buffer = &st_ivas->hCPE[cpe_id]->hCoreCoder[n]->previoussynth[0]; - +#endif set_zero( st_ivas->hLFE->prevsynth_buf, LFE_PLC_BUFLEN ); set_zero( st_ivas->hLFE->prior_out_buffer, L_FRAME48k ); } @@ -1570,7 +1571,11 @@ void destroy_core_dec( hCoreCoder->hTcxDec = NULL; } - if ( hCoreCoder->hTcxCfg != NULL && hCoreCoder->mct_chan_mode != MCT_CHAN_MODE_LFE ) + if ( hCoreCoder->hTcxCfg != NULL +#ifndef ISSUE_24_CLEANUP_MCT_LFE + && hCoreCoder->mct_chan_mode != MCT_CHAN_MODE_LFE +#endif + ) { free( hCoreCoder->hTcxCfg ); hCoreCoder->hTcxCfg = NULL; diff --git a/lib_dec/ivas_mct_core_dec.c b/lib_dec/ivas_mct_core_dec.c index 7e11b23c9a91da28664cd07c259ea63e26b6e429..5222d39b6436c2c2e4ae3563eec0235a3fa968e6 100644 --- a/lib_dec/ivas_mct_core_dec.c +++ b/lib_dec/ivas_mct_core_dec.c @@ -70,7 +70,11 @@ void ivas_mct_side_bits( Decoder_State *st, *sts[MCT_MAX_CHANNELS]; nf_side_bits = 0; - nChannels = hMCT->nchan_out_woLFE + hMCT->num_lfe; + nChannels = hMCT->nchan_out_woLFE +#ifndef ISSUE_24_CLEANUP_MCT_LFE + + hMCT->num_lfe +#endif + ; /*initializations */ for ( cpe_id = 0, i = 0; cpe_id < nCPE; cpe_id++ ) @@ -88,7 +92,11 @@ void ivas_mct_side_bits( for ( ch = 0; ch < nChannels; ch++ ) { st = sts[ch]; - if ( st->mct_chan_mode == MCT_CHAN_MODE_LFE || st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) + if ( +#ifndef ISSUE_24_CLEANUP_MCT_LFE + st->mct_chan_mode == MCT_CHAN_MODE_LFE || +#endif + st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) { continue; } @@ -108,15 +116,17 @@ void ivas_mct_side_bits( availableBits = 0; ivas_mct_dec_mct( hMCT, sts, nChannels ); - /* availableBits = ((hMCT->mc_bitrate/50) - sts[0]->next_bit_pos); - availableBits -= NBBITS_MCT_RATIO * nChannels;*/ /*read channel bitrate ratios from bitstream*/ for ( ch = 0; ch < nChannels; ch++ ) { st = sts[ch]; - if ( ( st->mct_chan_mode == MCT_CHAN_MODE_LFE && hMCT->LFE_off ) || st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) + if ( +#ifndef ISSUE_24_CLEANUP_MCT_LFE + ( st->mct_chan_mode == MCT_CHAN_MODE_LFE && hMCT->LFE_off ) || +#endif + st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) { chBitRatios[ch] = 0; st->bits_frame_channel = 0; @@ -189,7 +199,11 @@ void ivas_mct_core_dec( * Initializations *--------------------------------------------------------------------------------*/ - nChannels = hMCT->nchan_out_woLFE + hMCT->num_lfe; + nChannels = hMCT->nchan_out_woLFE +#ifndef ISSUE_24_CLEANUP_MCT_LFE + + hMCT->num_lfe +#endif + ; /*initializations */ for ( cpe_id = 0, i = 0; cpe_id < nCPE; cpe_id++ ) @@ -203,7 +217,11 @@ void ivas_mct_core_dec( for ( ch = 0, i = 0; ch < nChannels; ch++ ) { - if ( sts[ch]->mct_chan_mode == MCT_CHAN_MODE_LFE || sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) + if ( +#ifndef ISSUE_24_CLEANUP_MCT_LFE + sts[ch]->mct_chan_mode == MCT_CHAN_MODE_LFE || +#endif + sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) { continue; } @@ -232,7 +250,11 @@ void ivas_mct_core_dec( { st = sts[ch]; - if ( st->mct_chan_mode == MCT_CHAN_MODE_LFE || sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) /*indicates LFE */ + if ( +#ifndef ISSUE_24_CLEANUP_MCT_LFE + st->mct_chan_mode == MCT_CHAN_MODE_LFE || +#endif + sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) /*indicates LFE */ { continue; } diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index eeecd4d8fa38a1b1b501ff5c3e01ee58ae2a0144..4492968ad8e32902084ae90566a379fbfabf6ae1 100755 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -106,10 +106,12 @@ ivas_error ivas_mct_dec( } } +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( !st_ivas->bfi ) { hMCT->LFE_off = 0; /* in case of PLC, stick to LFE_off of previous frame; otherwise, the update happens in ivas_mdct_dec_side_bits_frame_channel() */ } +#endif for ( cpe_id = 0; cpe_id < nCPE; cpe_id++ ) { @@ -131,9 +133,14 @@ ivas_error ivas_mct_dec( if ( !st_ivas->bfi ) { - ivas_mdct_dec_side_bits_frame_channel( st_ivas->hCPE[cpe_id], param_lpc[cpe_id], p_param[cpe_id], st_ivas->hCPE[0]->hCoreCoder[0], - &hMCT->LFE_off, nTnsBitsTCX10[cpe_id], param[cpe_id], 1, +#ifndef ISSUE_24_CLEANUP_MCT_LFE + ivas_mdct_dec_side_bits_frame_channel( st_ivas->hCPE[cpe_id], param_lpc[cpe_id], p_param[cpe_id], st_ivas->hCPE[0]->hCoreCoder[0], &hMCT->LFE_off, nTnsBitsTCX10[cpe_id], param[cpe_id], 1, ( ( cpe_id + 1 ) * CPE_CHANNELS > st_ivas->nchan_transport ) ); +#else + ivas_mdct_dec_side_bits_frame_channel( st_ivas->hCPE[cpe_id], param_lpc[cpe_id], p_param[cpe_id], st_ivas->hCPE[0]->hCoreCoder[0], nTnsBitsTCX10[cpe_id], param[cpe_id], 1, + ( ( cpe_id + 1 ) * CPE_CHANNELS > hMCT->nchan_out_woLFE ) ); +#endif + st_ivas->BER_detect |= st_ivas->hCPE[cpe_id]->hCoreCoder[0]->BER_detect; st_ivas->BER_detect |= st_ivas->hCPE[cpe_id]->hCoreCoder[1]->BER_detect; @@ -156,7 +163,13 @@ ivas_error ivas_mct_dec( set_zero( x[n][1], L_FRAME48k / 2 ); } - ivas_mdct_core_invQ( st_ivas->hCPE[cpe_id], hMCT->LFE_off, nTnsBitsTCX10[cpe_id], p_param[cpe_id], param_lpc[cpe_id], param[cpe_id], + ivas_mdct_core_invQ( st_ivas->hCPE[cpe_id] +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + hMCT->LFE_off +#endif + , + nTnsBitsTCX10[cpe_id], p_param[cpe_id], param_lpc[cpe_id], param[cpe_id], fUseTns[cpe_id], tnsData[cpe_id], x, x, Aq[cpe_id], NULL, 1 ); st_ivas->BER_detect |= st_ivas->hCPE[cpe_id]->hCoreCoder[0]->BER_detect; @@ -189,7 +202,11 @@ ivas_error ivas_mct_dec( x[n][1] = &output[n + cpe_id * CPE_CHANNELS][L_FRAME48k / 2]; } - ivas_mdct_core_tns_ns( hCPE, hMCT->LFE_off, fUseTns[cpe_id], tnsData[cpe_id], x, Aq[cpe_id], 1 ); + ivas_mdct_core_tns_ns( hCPE, +#ifndef ISSUE_24_CLEANUP_MCT_LFE + hMCT->LFE_off, +#endif + fUseTns[cpe_id], tnsData[cpe_id], x, Aq[cpe_id], 1 ); } if ( st_ivas->renderer_type == RENDERER_MC ) @@ -224,7 +241,11 @@ ivas_error ivas_mct_dec( x[n][1] = &output[n + cpe_id * CPE_CHANNELS][L_FRAME48k / 2]; } - ivas_mdct_core_reconstruct( hCPE, x, synth, hMCT->LFE_off, fUseTns[cpe_id], 1 ); + ivas_mdct_core_reconstruct( hCPE, x, synth, +#ifndef ISSUE_24_CLEANUP_MCT_LFE + hMCT->LFE_off, +#endif + fUseTns[cpe_id], 1 ); /*----------------------------------------------------------------* * CoreCoder Post-processing and updates @@ -232,10 +253,12 @@ ivas_error ivas_mct_dec( for ( n = 0; n < CPE_CHANNELS; n++ ) { +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( sts[n]->mct_chan_mode == MCT_CHAN_MODE_LFE ) { break; } +#endif if ( st_ivas->sba_dirac_stereo_flag ) { @@ -281,6 +304,23 @@ ivas_error ivas_mct_dec( } #endif } +#ifdef ISSUE_24_CLEANUP_MCT_LFE + /* move channels after LFE to correct output for multi-channel MCT */ + if ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCT ) + { + float tmp[L_FRAME48k]; + + /*save center channel output*/ + mvr2r( output[hMCT->nchan_out_woLFE - 1], tmp, output_frame ); + + for ( n = hMCT->nchan_out_woLFE - 1; n >= LFE_CHANNEL; n-- ) + { + mvr2r( output[n - 1], output[n + 1], output_frame ); + } + mvr2r( tmp, output[LFE_CHANNEL - 1], output_frame ); + set_zero( output[LFE_CHANNEL], output_frame ); + } +#endif #ifdef DEBUG_MODE_INFO for ( cpe_id = 0; cpe_id < nCPE; cpe_id++ ) @@ -316,7 +356,7 @@ ivas_error create_mct_dec( int16_t max_blocks; int16_t cpe_id; - /*-----------------------------------------------------------------* + /*--------------------------------------------------------- --------* * Allocate MCT handle *-----------------------------------------------------------------*/ @@ -330,6 +370,7 @@ ivas_error create_mct_dec( *-----------------------------------------------------------------*/ /* Determine active channels */ +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCT ) { hMCT->num_lfe = st_ivas->hTransSetup.num_lfe; @@ -345,6 +386,16 @@ ivas_error create_mct_dec( hMCT->num_lfe = 0; hMCT->nchan_out_woLFE = st_ivas->nchan_transport; } +#else + if ( ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_PARAMMC ) || st_ivas->ivas_format == SBA_FORMAT ) + { + hMCT->nchan_out_woLFE = st_ivas->nchan_transport; + } + else if ( st_ivas->mc_mode == MC_MODE_MCT ) + { + hMCT->nchan_out_woLFE = st_ivas->nchan_transport - st_ivas->hTransSetup.num_lfe; + } +#endif else { assert( !"IVAS format currently not supported for MCT" ); @@ -358,14 +409,21 @@ ivas_error create_mct_dec( for ( n = 0; n < CPE_CHANNELS; n++ ) { st_ivas->hCPE[cpe_id]->hCoreCoder[n]->mct_chan_mode = MCT_CHAN_MODE_REGULAR; +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( ( hMCT->num_lfe > 0 ) && ( ( n + cpe_id * CPE_CHANNELS ) == LFE_CHANNEL ) ) { st_ivas->hCPE[cpe_id]->hCoreCoder[n]->mct_chan_mode = MCT_CHAN_MODE_LFE; } +#endif } } /* in case we have an uneven number of transport channels, indicate last channel ID as inactive */ - if ( ( hMCT->nchan_out_woLFE + hMCT->num_lfe ) % 2 ) + if ( ( hMCT->nchan_out_woLFE +#ifndef ISSUE_24_CLEANUP_MCT_LFE + + hMCT->num_lfe +#endif + ) % + 2 ) { st_ivas->hCPE[st_ivas->nCPE - 1]->hCoreCoder[1]->mct_chan_mode = MCT_CHAN_MODE_IGNORE; } @@ -445,6 +503,7 @@ ivas_error mct_dec_reconfigure( if ( b_nchan_change ) { /* Determine active channels */ +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCT ) { hMCT->num_lfe = st_ivas->hTransSetup.num_lfe; @@ -460,6 +519,16 @@ ivas_error mct_dec_reconfigure( hMCT->num_lfe = 0; hMCT->nchan_out_woLFE = st_ivas->nchan_transport; } +#else + if ( ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_PARAMMC ) || st_ivas->ivas_format == SBA_FORMAT ) + { + hMCT->nchan_out_woLFE = st_ivas->nchan_transport; + } + else if ( st_ivas->mc_mode == MC_MODE_MCT ) + { + hMCT->nchan_out_woLFE = st_ivas->nchan_transport - st_ivas->hTransSetup.num_lfe; + } +#endif else { assert( !"IVAS format currently not supported for MCT" ); @@ -472,15 +541,22 @@ ivas_error mct_dec_reconfigure( for ( n = 0; n < CPE_CHANNELS; n++ ) { st_ivas->hCPE[cpe_id]->hCoreCoder[n]->mct_chan_mode = MCT_CHAN_MODE_REGULAR; +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( ( hMCT->num_lfe > 0 ) && ( ( n + cpe_id * CPE_CHANNELS ) == LFE_CHANNEL ) ) { st_ivas->hCPE[cpe_id]->hCoreCoder[n]->mct_chan_mode = MCT_CHAN_MODE_LFE; } +#endif } } /* in case we have an uneven number of transport channels, indicate last channel ID as inactive */ - if ( ( hMCT->nchan_out_woLFE + hMCT->num_lfe ) % 2 ) + if ( ( hMCT->nchan_out_woLFE +#ifndef ISSUE_24_CLEANUP_MCT_LFE + + hMCT->num_lfe +#endif + ) % + 2 ) { st_ivas->hCPE[st_ivas->nCPE - 1]->hCoreCoder[1]->mct_chan_mode = MCT_CHAN_MODE_IGNORE; } @@ -497,10 +573,19 @@ ivas_error mct_dec_reconfigure( st->total_brate = st_ivas->hCPE[cpe_id]->element_brate; - if ( !( ( st->mct_chan_mode == MCT_CHAN_MODE_LFE ) || ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) ) ) + if ( !( +#ifndef ISSUE_24_CLEANUP_MCT_LFE + ( st->mct_chan_mode == MCT_CHAN_MODE_LFE ) || +#endif + ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) ) ) { st->bits_frame_nominal = (int16_t) ( st_ivas->hCPE[cpe_id]->element_brate / FRAMES_PER_SEC ); - st->igf = getIgfPresent( st->element_mode, st->bits_frame_nominal * FRAMES_PER_SEC, st->bwidth, st->rf_flag, st->mct_chan_mode ); + st->igf = getIgfPresent( st->element_mode, st->bits_frame_nominal * FRAMES_PER_SEC, st->bwidth, st->rf_flag +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + st->mct_chan_mode +#endif + ); if ( st->igf ) { IGFDecSetMode( st->hIGFDec, st_ivas->hCPE[cpe_id]->element_brate, st->bwidth, st->element_mode, -1, -1, st->rf_flag ); @@ -895,8 +980,14 @@ static ivas_error ivas_mc_dec_reconfig( } } - st->hTcxCfg->fIsTNSAllowed = getTnsAllowed( ivas_total_brate, st->igf, st->element_mode, st->mct_chan_mode ); + st->hTcxCfg->fIsTNSAllowed = getTnsAllowed( ivas_total_brate, st->igf, st->element_mode +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + st->mct_chan_mode +#endif + ); } +#ifndef ISSUE_24_CLEANUP_MCT_LFE else if ( last_mc_mode == MC_MODE_PARAMMC && st_ivas->mc_mode == MC_MODE_MCT && nchan_transport_old > 2 ) { #ifdef DEBUGGING @@ -906,7 +997,7 @@ static ivas_error ivas_mc_dec_reconfig( st->mct_chan_mode = MCT_CHAN_MODE_LFE; st->hTcxCfg->fIsTNSAllowed = 0; } - +#endif if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { uint8_t separateChannelEnabled; @@ -989,9 +1080,11 @@ static ivas_error ivas_mc_dec_reconfig( return error; } +#ifndef ISSUE_24_CLEANUP_MCT_LFE /* reuse core-coder buffers for LFE decoder */ st_ivas->hLFE->prevsynth_buf = &st_ivas->hCPE[1]->hCoreCoder[1]->old_synth_sw[0]; st_ivas->hLFE->prior_out_buffer = &st_ivas->hCPE[1]->hCoreCoder[1]->previoussynth[0]; +#endif set_zero( st_ivas->hLFE->prevsynth_buf, LFE_PLC_BUFLEN ); set_zero( st_ivas->hLFE->prior_out_buffer, L_FRAME48k ); diff --git a/lib_dec/ivas_mct_dec_mct.c b/lib_dec/ivas_mct_dec_mct.c index 7177785984335e307778d3166401851188d13e81..68a846b876dea6667e43abe6365e0dfc60e4498b 100644 --- a/lib_dec/ivas_mct_dec_mct.c +++ b/lib_dec/ivas_mct_dec_mct.c @@ -49,8 +49,11 @@ static void indexToChannelPair( MCT_DEC_BLOCK_DATA_HANDLE hBlock, const int16_t nChannels, - const int16_t pairIdx, + const int16_t pairIdx +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , Decoder_State **sts /* i/o: decoder state structure */ +#endif ) { int16_t ch1, ch2; @@ -60,10 +63,12 @@ static void indexToChannelPair( { for ( ch1 = 0; ch1 < ch2; ch1++ ) { +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( sts[ch1]->mct_chan_mode == MCT_CHAN_MODE_LFE || sts[ch2]->mct_chan_mode == MCT_CHAN_MODE_LFE ) { continue; } +#endif if ( tmpIdx == pairIdx ) { @@ -105,7 +110,11 @@ void ivas_mct_dec_mct( /*first get core and overlap info for all channels*/ for ( ch = 0; ch < nchan; ch++ ) { - if ( ( sts[ch]->mct_chan_mode != MCT_CHAN_MODE_LFE ) && hMCT->currBlockDataCnt && sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) + if ( +#ifndef ISSUE_24_CLEANUP_MCT_LFE + ( sts[ch]->mct_chan_mode != MCT_CHAN_MODE_LFE ) && +#endif + hMCT->currBlockDataCnt && sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) { hMCT->mc_global_ild[ch] = get_next_indice( sts[0], SMDCT_GLOBAL_ILD_BITS ); } @@ -119,7 +128,11 @@ void ivas_mct_dec_mct( { for ( ch = 0; ch < nchan; ch++ ) { - if ( sts[ch]->mct_chan_mode != MCT_CHAN_MODE_LFE && sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) + if ( +#ifndef ISSUE_24_CLEANUP_MCT_LFE + sts[ch]->mct_chan_mode != MCT_CHAN_MODE_LFE && +#endif + sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) { hMCT->lowE_ch[ch] = get_next_indice( sts[0], 1 ); } @@ -128,7 +141,11 @@ void ivas_mct_dec_mct( for ( ch = 0; ch < nchan; ch++ ) { - if ( sts[ch]->mct_chan_mode != MCT_CHAN_MODE_LFE && sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) + if ( +#ifndef ISSUE_24_CLEANUP_MCT_LFE + sts[ch]->mct_chan_mode != MCT_CHAN_MODE_LFE && +#endif + sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) { nchan_active++; } @@ -141,7 +158,12 @@ void ivas_mct_dec_mct( /*get channel pair index from BS*/ channelPairIndex = get_next_indice( sts[0], hMCT->bitsChannelPairIndex ); - indexToChannelPair( hBlock, nchan, channelPairIndex, sts ); + indexToChannelPair( hBlock, nchan, channelPairIndex +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + sts +#endif + ); /*point to decoder states of actual channels to read block pair bits*/ p_st[0] = sts[hBlock->ch1]; @@ -170,7 +192,12 @@ static void applyGlobalILD( int16_t nSubframes, L_subframeTCX; float qratio; - for ( ch = 0; ch < ( hMCT->nchan_out_woLFE + hMCT->num_lfe ); ch++ ) + for ( ch = 0; ch < ( hMCT->nchan_out_woLFE +#ifndef ISSUE_24_CLEANUP_MCT_LFE + + hMCT->num_lfe +#endif + ); + ch++ ) { nSubframes = ( sts[ch]->core == TCX_20_CORE ) ? 1 : NB_DIV; L_subframeTCX = sts[ch]->hTcxDec->L_frameTCX / nSubframes; @@ -252,7 +279,11 @@ void mctStereoIGF_dec( float *p_x[CPE_CHANNELS][NB_DIV]; int16_t singleChEle[MCT_MAX_CHANNELS]; - set_s( singleChEle, 1, ( hMCT->nchan_out_woLFE + hMCT->num_lfe ) ); + set_s( singleChEle, 1, ( hMCT->nchan_out_woLFE +#ifndef ISSUE_24_CLEANUP_MCT_LFE + + hMCT->num_lfe +#endif + ) ); for ( b = 0; b < hMCT->currBlockDataCnt; b++ ) { @@ -305,9 +336,18 @@ void mctStereoIGF_dec( } - if ( sum_s( singleChEle, ( hMCT->nchan_out_woLFE + hMCT->num_lfe ) ) != 0 ) + if ( sum_s( singleChEle, ( hMCT->nchan_out_woLFE +#ifndef ISSUE_24_CLEANUP_MCT_LFE + + hMCT->num_lfe +#endif + ) ) != 0 ) { - for ( ch = 0; ch < ( hMCT->nchan_out_woLFE + hMCT->num_lfe ); ch++ ) + for ( ch = 0; ch < ( hMCT->nchan_out_woLFE +#ifndef ISSUE_24_CLEANUP_MCT_LFE + + hMCT->num_lfe +#endif + ); + ch++ ) { if ( singleChEle[ch] ) { @@ -316,7 +356,11 @@ void mctStereoIGF_dec( { continue; } - if ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE || st->mct_chan_mode == MCT_CHAN_MODE_LFE ) + if ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE +#ifndef ISSUE_24_CLEANUP_MCT_LFE + || st->mct_chan_mode == MCT_CHAN_MODE_LFE +#endif + ) { continue; } diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c index 7763290f8718b03ab40211b3ce781899be1b1996..83aac5cbc1a915310f4603de74638960595879be 100644 --- a/lib_dec/ivas_mdct_core_dec.c +++ b/lib_dec/ivas_mdct_core_dec.c @@ -162,22 +162,26 @@ static void dec_prm_tcx_sidebits( getTCXWindowing( st->core, st->last_core, st->element_mode, st->hTcxCfg, st0 ); st->hTcxDec->kernel_type[0] = st->hTcxDec->kernel_type[1] = MDCT_IV; +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( st->element_mode == IVAS_CPE_MDCT && st->mct_chan_mode != MCT_CHAN_MODE_LFE ) { +#endif st->hTcxDec->kernel_type[0] = get_next_indice( st0, st->last_core_from_bs != ACELP_CORE ? 2 : 1 ); if ( st->core == TCX_10_CORE ) { st->hTcxDec->kernel_type[1] = 2 * ( st->hTcxDec->kernel_type[0] & 1 ) + get_next_indice( st0, 1 ); } +#ifndef ISSUE_24_CLEANUP_MCT_LFE } + if ( st->mct_chan_mode == MCT_CHAN_MODE_LFE ) { st->hTcxCfg->tcx_curr_overlap_mode = FULL_OVERLAP; st->hTcxCfg->tcx_last_overlap_mode = FULL_OVERLAP; st->hTcxCfg->last_aldo = 0; } - +#endif if ( st->core == TCX_20_CORE ) { st->transform_type[0] = st->transform_type[1] = TCX_20; @@ -294,11 +298,13 @@ static void dec_prm_tcx_spec( *-----------------------------------------------------------------*/ void ivas_mdct_dec_side_bits_frame_channel( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - int16_t param_lpc[MCT_MAX_CHANNELS][NPRM_LPC_NEW], /* o : lpc_parameters */ - int16_t p_param[CPE_CHANNELS][NB_DIV], /* o : pointer to param buffer */ - Decoder_State *st0, /* i : pointer to bitstream handle */ - int16_t *LFE_off, /* o : flag if LFE has content */ + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ + int16_t param_lpc[MCT_MAX_CHANNELS][NPRM_LPC_NEW], /* o : lpc_parameters */ + int16_t p_param[CPE_CHANNELS][NB_DIV], /* o : pointer to param buffer */ + Decoder_State *st0, /* i : pointer to bitstream handle */ +#ifndef ISSUE_24_CLEANUP_MCT_LFE + int16_t *LFE_off, /* o : flag if LFE has content */ +#endif int16_t nTnsBitsTCX10[CPE_CHANNELS][NB_DIV], /* o : number of bits for TNS */ int16_t param[CPE_CHANNELS][DEC_NPRM_DIV * NB_DIV], /* i/o: parameters buffer */ const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ @@ -340,11 +346,14 @@ void ivas_mdct_dec_side_bits_frame_channel( continue; } st = sts[ch]; +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( st->mct_chan_mode == MCT_CHAN_MODE_LFE ) { *LFE_off = get_next_indice( st0, 1 ); } - else if ( MCT_flag ) + else +#endif + if ( MCT_flag ) { tmp = get_next_indice( st0, 1 ); if ( tmp ) @@ -362,7 +371,11 @@ void ivas_mdct_dec_side_bits_frame_channel( for ( ch = 0; ch < CPE_CHANNELS; ch++ ) { st = sts[ch]; +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( ( st->mct_chan_mode == MCT_CHAN_MODE_LFE && *LFE_off ) || ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) ) +#else + if ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) +#endif { sts[ch]->coder_type = INACTIVE; sts[ch]->side_bits_frame_channel = 0; @@ -390,7 +403,11 @@ void ivas_mdct_dec_side_bits_frame_channel( { st = sts[ch]; +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( ( st->mct_chan_mode == MCT_CHAN_MODE_LFE && *LFE_off ) || ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) ) +#else + if ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) +#endif { skipped_first_channel = 1; continue; @@ -404,7 +421,11 @@ void ivas_mdct_dec_side_bits_frame_channel( param_lpc[0][0] = get_next_indice( st0, 1 ) << 1; /* read low br mode flag (if it is possible to be non-zero) */ - if ( sts[0]->element_brate == IVAS_48k && !( ( sts[0]->core == TCX_20 && sts[1]->core == TCX_20 ) || sts[1]->mct_chan_mode == MCT_CHAN_MODE_LFE ) ) + if ( sts[0]->element_brate == IVAS_48k && !( ( sts[0]->core == TCX_20 && sts[1]->core == TCX_20 ) +#ifndef ISSUE_24_CLEANUP_MCT_LFE + || sts[1]->mct_chan_mode == MCT_CHAN_MODE_LFE +#endif + ) ) { sns_low_br_mode = get_next_indice( st0, 1 ); } @@ -433,8 +454,10 @@ void ivas_mdct_dec_side_bits_frame_channel( *-----------------------------------------------------------------*/ void ivas_mdct_core_invQ( - CPE_DEC_HANDLE hCPE, /* i/o: CPE handle */ - const int16_t LFE_off, /* i : flag if LFE content */ + CPE_DEC_HANDLE hCPE, /* i/o: CPE handle */ +#ifndef ISSUE_24_CLEANUP_MCT_LFE + const int16_t LFE_off, /* i : flag if LFE content */ +#endif int16_t nTnsBitsTCX10[CPE_CHANNELS][NB_DIV], /* i : number of TNS bits */ int16_t p_param[CPE_CHANNELS][NB_DIV], /* i : pointer to param buffer */ int16_t param_lpc[CPE_CHANNELS][NPRM_LPC_NEW], /* i : lpc parameters */ @@ -521,7 +544,11 @@ void ivas_mdct_core_invQ( { st = sts[ch]; - if ( ( st->mct_chan_mode == MCT_CHAN_MODE_LFE && LFE_off ) || ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) ) /* indicates LFE with no content, or odd number of channels */ +#ifndef ISSUE_24_CLEANUP_MCT_LFE + if ( ( st->mct_chan_mode == MCT_CHAN_MODE_LFE && LFE_off ) || ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) ) +#else + if ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) +#endif { st->total_brate = st->bits_frame_channel; continue; @@ -575,12 +602,13 @@ void ivas_mdct_core_invQ( /* PLC: [Common: mode decision] * PLC: Decide which Concealment to use. Update pitch lags if needed */ st->core = GetPLCModeDecision( st ); - +#ifndef ISSUE_24_CLEANUP_MCT_LFE /*disable ACELP_PLC for LFE channel */ if ( st->mct_chan_mode == MCT_CHAN_MODE_LFE ) { st->core = st->last_core; } +#endif } if ( ( !st->bfi || st->hTcxCfg->psychParamsCurrent == NULL ) && st->core > ACELP_CORE ) @@ -670,7 +698,11 @@ void ivas_mdct_core_invQ( { st = sts[ch]; - if ( ( st->mct_chan_mode == MCT_CHAN_MODE_LFE && LFE_off ) || ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) ) /* indicates LFE with no content, or odd number of channels */ +#ifndef ISSUE_24_CLEANUP_MCT_LFE + if ( ( st->mct_chan_mode == MCT_CHAN_MODE_LFE && LFE_off ) || ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) ) +#else + if ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) +#endif { set_f( x[ch][0], 0.f, st->hTcxCfg->tcx_coded_lines ); /* usually set in decoder_tcx_invQ(), needed for concealment */ @@ -727,10 +759,12 @@ void ivas_mdct_core_invQ( } } +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( st->mct_chan_mode == MCT_CHAN_MODE_LFE ) /*indicates LFE with no content*/ { set_f( &x[ch][0][MCT_LFE_MAX_LINE], 0.f, st->hTcxCfg->tcx_coded_lines - MCT_LFE_MAX_LINE ); } +#endif } pop_wmops(); @@ -748,9 +782,11 @@ void ivas_mdct_core_reconstruct( CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ float *x[][NB_DIV], /* i/o: synthesis @internal_FS */ float signal_outFB[CPE_CHANNELS][L_FRAME_PLUS], /* o : synthesis @output_FS */ - const int16_t LFE_off, /* i : flag if LFE content */ - int16_t fUseTns[CPE_CHANNELS][NB_DIV], /* i : flage TNS enabled */ - const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0)*/ +#ifndef ISSUE_24_CLEANUP_MCT_LFE + const int16_t LFE_off, /* i : flag if LFE content */ +#endif + int16_t fUseTns[CPE_CHANNELS][NB_DIV], /* i : flage TNS enabled */ + const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0)*/ ) { int16_t ch, k, bfi; @@ -772,7 +808,9 @@ void ivas_mdct_core_reconstruct( int16_t pitch[CPE_CHANNELS][NB_SUBFR16k]; float pit_gain[CPE_CHANNELS][NB_SUBFR16k]; +#ifndef ISSUE_24_CLEANUP_MCT_LFE int16_t isLFE; +#endif int16_t skip_decoding; set_f( xn_buf, 0, L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX ); @@ -787,16 +825,21 @@ void ivas_mdct_core_reconstruct( st = sts[ch]; skip_decoding = 0; - if ( ( st->mct_chan_mode == MCT_CHAN_MODE_LFE && LFE_off ) || ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) ) /* indicates LFE with no content, or odd number of channels */ +#ifndef ISSUE_24_CLEANUP_MCT_LFE + if ( ( st->mct_chan_mode == MCT_CHAN_MODE_LFE && LFE_off ) || ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) ) +#else + if ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) +#endif { skip_decoding = 1; } - +#ifndef ISSUE_24_CLEANUP_MCT_LFE isLFE = 0; if ( st->mct_chan_mode == MCT_CHAN_MODE_LFE ) { isLFE = 1; } +#endif nSubframes[ch] = ( st->core == TCX_20_CORE ) ? 1 : NB_DIV; synth = synth_buf + st->hTcxDec->old_synth_len; @@ -822,7 +865,11 @@ void ivas_mdct_core_reconstruct( decoder_tcx_imdct( st, L_frame_global[ch], L_frame_globalTCX[ch], L_spec[ch], tcx_offset[ch], tcx_offsetFB[ch], L_frame[ch], L_frameTCX[ch], left_rect[ch], &x[ch][k][0], xn_buf, ( ( hCPE->nchan_out == 1 && st->hTcxDec->kernel_type[k] == MDST_IV ) || st->hTcxCfg->tcx_last_overlap_mode == TRANSITION_OVERLAP ) ? MDCT_IV : st->hTcxDec->kernel_type[k], - fUseTns[ch][k], &synth[k * L_frame[ch]], &synthFB[k * L_frameTCX[ch]], bfi, k, isLFE, 0 ); + fUseTns[ch][k], &synth[k * L_frame[ch]], &synthFB[k * L_frameTCX[ch]], bfi, k, +#ifndef ISSUE_24_CLEANUP_MCT_LFE + isLFE, +#endif + 0 ); } else { @@ -968,8 +1015,10 @@ void ivas_mdct_core_reconstruct( *-----------------------------------------------------------------*/ void ivas_mdct_core_tns_ns( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - const int16_t LFE_off, /* i : flag if LFE has content */ + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ +#ifndef ISSUE_24_CLEANUP_MCT_LFE + const int16_t LFE_off, /* i : flag if LFE has content */ +#endif int16_t fUseTns[CPE_CHANNELS][NB_DIV], /* i : two entries for each channel in TCX10 */ STnsData tnsData[CPE_CHANNELS][NB_DIV], /* o : TNS parameter */ float *x[CPE_CHANNELS][NB_DIV], /* o : synthesis @internal_FS */ @@ -1006,7 +1055,11 @@ void ivas_mdct_core_tns_ns( L_frameTCX_glob[ch] = st->hTcxDec->L_frameTCX / nSubframes[ch]; L_spec[ch] = st->hTcxCfg->tcx_coded_lines / nSubframes[ch]; - if ( ( st->mct_chan_mode == MCT_CHAN_MODE_LFE && LFE_off ) || ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) || ( st->bfi && st->core == ACELP_CORE ) ) /* indicates LFE with no content, or odd number of channels */ + if ( +#ifndef ISSUE_24_CLEANUP_MCT_LFE + ( st->mct_chan_mode == MCT_CHAN_MODE_LFE && LFE_off ) || +#endif + ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) || ( st->bfi && st->core == ACELP_CORE ) ) /* indicates LFE with no content, or odd number of channels */ { if ( st->hTonalMDCTConc != NULL ) { diff --git a/lib_dec/ivas_out_setup_conversion.c b/lib_dec/ivas_out_setup_conversion.c index 225a1c85b5f9ecdcf444ceebda5552857c6bb4a6..b396fa415cd01ad0317602d5a58df9ce417d48b0 100644 --- a/lib_dec/ivas_out_setup_conversion.c +++ b/lib_dec/ivas_out_setup_conversion.c @@ -600,7 +600,13 @@ void ivas_ls_setup_conversion_process_mdct( { dmxCoeff = hLsSetUpConversion->dmxMtx[chInIdx][chOutIdx]; - if ( !( chInIdx == LFE_CHANNEL && st_ivas->hMCT->LFE_off ) && mct_chan_mode[chInIdx] != MCT_CHAN_MODE_IGNORE ) + if ( +#ifndef ISSUE_24_CLEANUP_MCT_LFE + !( chInIdx == LFE_CHANNEL && st_ivas->hMCT->LFE_off ) && +#else + chInIdx != LFE_CHANNEL && +#endif + mct_chan_mode[chInIdx] != MCT_CHAN_MODE_IGNORE ) { /* Step 1: Compute the target energy and DMX signal (possible since we have all signals in TCX20 resolution) */ if ( dmxCoeff ) @@ -693,7 +699,13 @@ void ivas_ls_setup_conversion_process_mdct( /* Step 4: Perform equalization */ for ( chInIdx = 0; chInIdx < inChannels; chInIdx++ ) { - if ( !( chInIdx == LFE_CHANNEL && st_ivas->hMCT->LFE_off ) && mct_chan_mode[chInIdx] != MCT_CHAN_MODE_IGNORE ) + if ( +#ifndef ISSUE_24_CLEANUP_MCT_LFE + !( chInIdx == LFE_CHANNEL && st_ivas->hMCT->LFE_off ) && +#else + chInIdx != LFE_CHANNEL && +#endif + mct_chan_mode[chInIdx] != MCT_CHAN_MODE_IGNORE ) { if ( transform_type[chInIdx][0] == TCX_20 ) { diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 3bfd806bdfab445b049eeb299952a7f7cb590da9..8c27a09baf05bb2de82c968601beaceab2f45e17 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -954,10 +954,13 @@ typedef struct mct_dec_data_structure int16_t chBitRatios[MCT_MAX_CHANNELS]; int16_t lowE_ch[MCT_MAX_CHANNELS]; /* note: pointer to local parameter */ +#ifndef ISSUE_24_CLEANUP_MCT_LFE int16_t LFE_off; +#endif uint16_t mc_global_ild[MCT_MAX_CHANNELS]; /* note: pointer to local parameter */ +#ifndef ISSUE_24_CLEANUP_MCT_LFE int16_t num_lfe; - +#endif } MCT_DEC_DATA, *MCT_DEC_HANDLE; @@ -973,9 +976,15 @@ typedef struct ivas_lfe_dec_data_structure int16_t lfe_dec_indices_coeffs_tbl[IVAS_MAX_NUM_QUANT_STRATS][IVAS_MAX_NUM_DCT_COEF_GROUPS]; float lfe_block_delay_s; int16_t lfe_prior_buf_len; +#ifndef ISSUE_24_CLEANUP_MCT_LFE float *prior_out_buffer; float *prevsynth_buf; +#else + float prior_out_buffer[L_FRAME48k]; + + float prevsynth_buf[LFE_PLC_BUFLEN]; +#endif float *lfe_delay_buf; int16_t lfe_addl_delay; int16_t bfi_count; diff --git a/lib_dec/ivas_stereo_mdct_core_dec.c b/lib_dec/ivas_stereo_mdct_core_dec.c index 651f6402c6e6de45ecd1cd6f8090d9660983222e..ab8844c8e895bef1a7d5fe025b9e245b6cdee640 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec.c +++ b/lib_dec/ivas_stereo_mdct_core_dec.c @@ -221,7 +221,11 @@ void stereo_mdct_core_dec( if ( !bfi ) { - ivas_mdct_dec_side_bits_frame_channel( hCPE, param_lpc, p_param, hCPE->hCoreCoder[0], NULL, nTnsBitsTCX10, param, 0, 0 ); + ivas_mdct_dec_side_bits_frame_channel( hCPE, param_lpc, p_param, hCPE->hCoreCoder[0], +#ifndef ISSUE_24_CLEANUP_MCT_LFE + NULL, +#endif + nTnsBitsTCX10, param, 0, 0 ); if ( sts[0]->igf ) { @@ -252,7 +256,11 @@ void stereo_mdct_core_dec( } } - ivas_mdct_core_invQ( hCPE, 0, nTnsBitsTCX10, p_param, param_lpc, param, fUseTns, tnsData, x_0, x, Aq, ms_mask, 0 ); + ivas_mdct_core_invQ( hCPE, +#ifndef ISSUE_24_CLEANUP_MCT_LFE + 0, +#endif + nTnsBitsTCX10, p_param, param_lpc, param, fUseTns, tnsData, x_0, x, Aq, ms_mask, 0 ); for ( ch = 0; ch < nChannels; ch++ ) { @@ -345,7 +353,11 @@ void stereo_mdct_core_dec( stereo_decoder_tcx( hCPE->hStereoMdct, ms_mask, x_0[1], x[0], x[1], &hCPE->hStereoMdct->mdct_stereo_mode[0], sts[0]->core, sts[1]->core, sts[0]->igf, L_frameTCX[0], L_frameTCX[1], 0, sts[0]->last_core, sts[1]->last_core, 0 ); } - ivas_mdct_core_tns_ns( hCPE, 0, fUseTns, tnsData, x, Aq, 0 ); + ivas_mdct_core_tns_ns( hCPE, +#ifndef ISSUE_24_CLEANUP_MCT_LFE + 0, +#endif + fUseTns, tnsData, x, Aq, 0 ); if ( st_ivas->renderer_type == RENDERER_MC_PARAMMC && ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_MONO || st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_STEREO ) ) { @@ -359,7 +371,11 @@ void stereo_mdct_core_dec( apply_dmx_weights( hCPE, x, sts[0]->transform_type, sts[1]->transform_type ); } - ivas_mdct_core_reconstruct( hCPE, x, signal_outFB_tmp, 0, fUseTns, 0 ); + ivas_mdct_core_reconstruct( hCPE, x, signal_outFB_tmp, +#ifndef ISSUE_24_CLEANUP_MCT_LFE + 0, +#endif + fUseTns, 0 ); mvr2r( signal_out_tmp[0], signal_out[0], L_FRAME48k ); mvr2r( signal_out_tmp[1], signal_out[1], L_FRAME48k ); diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index 2e98d358f8d7fd98629285c78947f27a2870353f..144f7950e976bf44af0a64acd3b43dd84ea68b74 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -969,12 +969,13 @@ ivas_error stereo_memory_dec( for ( i = 0; i < CPE_CHANNELS; ++i ) { deleteFdCngDec( &hCPE->hCoreCoder[i]->hFdCngDec ); - +#ifndef ISSUE_24_CLEANUP_MCT_LFE /* deallocate CLDFB synthesis for LFE channel */ if ( hCPE->hCoreCoder[i]->mct_chan_mode == MCT_CHAN_MODE_LFE ) { deleteCldfb( &hCPE->hCoreCoder[i]->cldfbSyn ); } +#endif } } else diff --git a/lib_dec/ivas_tcx_core_dec.c b/lib_dec/ivas_tcx_core_dec.c index 56059bd29dd020e1faea2125800610efa3300747..b5dcfd2bbede473d6a2ee5b8e5bbf6742162a994 100644 --- a/lib_dec/ivas_tcx_core_dec.c +++ b/lib_dec/ivas_tcx_core_dec.c @@ -95,11 +95,25 @@ void stereo_tcx_init_dec( st->hTcxCfg->ctx_hm = getCtxHm( st->element_mode, st->bits_frame_nominal * FRAMES_PER_SEC, st->rf_flag ); st->hTcxCfg->resq = getResq( st->bits_frame_nominal * FRAMES_PER_SEC ); hTcxDec->tcx_lpc_shaped_ari = getTcxLpcShapedAri( st->bits_frame_nominal * FRAMES_PER_SEC, st->rf_flag, st->element_mode ); - st->igf = getIgfPresent( st->element_mode, st->bits_frame_nominal * FRAMES_PER_SEC, st->bwidth, st->rf_flag, st->mct_chan_mode ); - /* TODO: also apply for MCT modes, once issue #24 is solved */ - if ( !MCT_flag && st->element_mode != EVS_MONO ) + st->igf = getIgfPresent( st->element_mode, st->bits_frame_nominal * FRAMES_PER_SEC, st->bwidth, st->rf_flag +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + st->mct_chan_mode +#endif + ); + + if ( +#ifndef ISSUE_24_CLEANUP_MCT_LFE + !MCT_flag && +#endif + st->element_mode != EVS_MONO ) { - st->hTcxCfg->fIsTNSAllowed = getTnsAllowed( st->bits_frame_nominal * FRAMES_PER_SEC, st->igf, st->element_mode, st->mct_chan_mode ); + st->hTcxCfg->fIsTNSAllowed = getTnsAllowed( st->bits_frame_nominal * FRAMES_PER_SEC, st->igf, st->element_mode +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + st->mct_chan_mode +#endif + ); } if ( hTcxLtpDec != NULL ) { diff --git a/lib_dec/tonalMDCTconcealment.c b/lib_dec/tonalMDCTconcealment.c index cb27b57ebf852b74e91c4da7657f08a1be5c9cb4..81fa9fdf90606dad00025db95b6214a257b1259c 100644 --- a/lib_dec/tonalMDCTconcealment.c +++ b/lib_dec/tonalMDCTconcealment.c @@ -386,15 +386,24 @@ static void CalcMDXT( const TonalMDCTConcealPtr hTonalMDCTConc, const char type, const float *timeSignal, - float *mdxtOutput, - const int16_t isLfe ) + float *mdxtOutput +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + const int16_t isLfe +#endif +) { float windowedTimeSignal[L_FRAME_PLUS + 2 * L_MDCT_OVLP_MAX]; int16_t left_overlap, right_overlap; int16_t L_frame; L_frame = hTonalMDCTConc->nSamples; - WindowSignal( hTonalMDCTConc->tcx_cfg, hTonalMDCTConc->tcx_cfg->tcx_offsetFB, FULL_OVERLAP, FULL_OVERLAP, &left_overlap, &right_overlap, timeSignal, &L_frame, windowedTimeSignal, 1, 1, isLfe ); + WindowSignal( hTonalMDCTConc->tcx_cfg, hTonalMDCTConc->tcx_cfg->tcx_offsetFB, FULL_OVERLAP, FULL_OVERLAP, &left_overlap, &right_overlap, timeSignal, &L_frame, windowedTimeSignal, 1, 1 +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + isLfe +#endif + ); if ( type == 'S' ) { @@ -413,8 +422,12 @@ void TonalMDCTConceal_Detect( const TonalMDCTConcealPtr hTonalMDCTConc, const float pitchLag, int16_t *numIndices, - const PsychoacousticParameters *psychParamsCurrent, - const int16_t isLfe ) + const PsychoacousticParameters *psychParamsCurrent +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + const int16_t isLfe +#endif +) { float secondLastMDST[L_FRAME_MAX]; /* 32 bits are required */ float secondLastMDCT[L_FRAME_MAX]; /* 32 bits are required */ @@ -431,10 +444,18 @@ void TonalMDCTConceal_Detect( { if ( !hTonalMDCTConc->secondLastBlockData.tonalConcealmentActive ) { - CalcMDXT( hTonalMDCTConc, 'S', hTonalMDCTConc->secondLastPcmOut, secondLastMDST, - isLfe ); - CalcMDXT( hTonalMDCTConc, 'C', hTonalMDCTConc->secondLastPcmOut, secondLastMDCT, - isLfe ); + CalcMDXT( hTonalMDCTConc, 'S', hTonalMDCTConc->secondLastPcmOut, secondLastMDST +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + isLfe +#endif + ); + CalcMDXT( hTonalMDCTConc, 'C', hTonalMDCTConc->secondLastPcmOut, secondLastMDCT +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + isLfe +#endif + ); hTonalMDCTConc->nNonZeroSamples = 0; for ( i = 0; i < hTonalMDCTConc->nSamples; i++ ) { diff --git a/lib_enc/bw_detect.c b/lib_enc/bw_detect.c index 8ca63d28f2629a9ac8f5019b3768c00795261158..810527e0ef2b6aab7f373d4fa5edbe02795c153a 100755 --- a/lib_enc/bw_detect.c +++ b/lib_enc/bw_detect.c @@ -671,6 +671,7 @@ void set_bw_stereo( if ( hCPE->element_mode == IVAS_CPE_MDCT ) { +#ifndef ISSUE_24_CLEANUP_MCT_LFE /* do not check bandwidth in LFE channel */ if ( sts[0]->mct_chan_mode == MCT_CHAN_MODE_LFE ) { @@ -691,6 +692,19 @@ void set_bw_stereo( sts[0]->bwidth = max( sts[0]->input_bwidth, sts[1]->input_bwidth ); sts[1]->bwidth = max( sts[0]->input_bwidth, sts[1]->input_bwidth ); } +#else + /* ensure that both CPE channels have the same audio band-width */ + if ( sts[0]->input_bwidth == sts[1]->input_bwidth ) + { + sts[0]->bwidth = sts[0]->input_bwidth; + sts[1]->bwidth = sts[0]->input_bwidth; + } + else + { + sts[0]->bwidth = max( sts[0]->input_bwidth, sts[1]->input_bwidth ); + sts[1]->bwidth = max( sts[0]->input_bwidth, sts[1]->input_bwidth ); + } +#endif } sts[0]->bwidth = max( sts[0]->bwidth, WB ); @@ -723,7 +737,11 @@ int16_t set_bw_mct( for ( ch = 0; ch < CPE_CHANNELS; ch++ ) { st = hCPE[cpe_id]->hCoreCoder[ch]; - if ( st->mct_chan_mode == MCT_CHAN_MODE_LFE || st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) + if ( +#ifndef ISSUE_24_CLEANUP_MCT_LFE + st->mct_chan_mode == MCT_CHAN_MODE_LFE || +#endif + st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) { continue; } diff --git a/lib_enc/cod_tcx.c b/lib_enc/cod_tcx.c index 8c647be38a0c3b96ea33b77f2c66f6e2c743ba9a..ee948998a1ac48fdfdc95cd728a559b9cb27bd81 100644 --- a/lib_enc/cod_tcx.c +++ b/lib_enc/cod_tcx.c @@ -73,7 +73,12 @@ void HBAutocorrelation( * Windowing * *-----------------------------------------------------------*/ - WindowSignal( hTcxCfg, hTcxCfg->tcx_offset, left_overlap_mode, right_overlap_mode, &left_overlap, &right_overlap, speech, &L_frame, xn_buf, 1, 0, 0 ); + WindowSignal( hTcxCfg, hTcxCfg->tcx_offset, left_overlap_mode, right_overlap_mode, &left_overlap, &right_overlap, speech, &L_frame, xn_buf, 1, 0 +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + 0 +#endif + ); /*-----------------------------------------------------------* * Autocorrelation * @@ -134,11 +139,15 @@ void TNSAnalysisStereo( for ( ch = 0; ch < CPE_CHANNELS; ch++ ) { st = sts[ch]; - +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( st->mct_chan_mode == MCT_CHAN_MODE_LFE ) +#else + if ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) +#endif { continue; } + hTcxEnc = st->hTcxEnc; nSubframes = ( hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV; @@ -382,8 +391,11 @@ void TNSAnalysisStereo( /* individual decision for each channel */ for ( ch = 0; ch < CPE_CHANNELS; ch++ ) { - +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( sts[ch]->mct_chan_mode == MCT_CHAN_MODE_LFE ) +#else + if ( sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) +#endif { continue; } @@ -465,10 +477,15 @@ void TNSAnalysisStereo( /* we have the decision, set filter data accordingly */ for ( ch = 0; ch < CPE_CHANNELS; ch++ ) { +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( sts[ch]->mct_chan_mode == MCT_CHAN_MODE_LFE ) +#else + if ( sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) +#endif { continue; } + nSubframes = ( sts[ch]->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV; for ( k = 0; k < nSubframes; k++ ) @@ -501,10 +518,15 @@ void TNSAnalysisStereo( for ( ch = 0; ch < CPE_CHANNELS; ch++ ) { st = sts[ch]; +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( st->mct_chan_mode == MCT_CHAN_MODE_LFE ) +#else + if ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) +#endif { continue; } + nSubframes = ( st->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV; for ( k = 0; k < nSubframes; k++ ) @@ -970,11 +992,12 @@ void EstimateStereoTCXNoiseLevel( { fac_ns_q = param_core[ch] + n * NPRM_DIV + 1; maxNfCalcBw = min( noiseFillingBorder[ch][n], (int16_t) ( hTcxEnc->measuredBwRatio * (float) L_frame[ch][n] + 0.5f ) ); +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( st->mct_chan_mode == MCT_CHAN_MODE_LFE ) { maxNfCalcBw = min( maxNfCalcBw, MCT_LFE_MAX_LINE ); } - +#endif if ( ( total_brate >= HQ_96k && ( st->element_mode <= IVAS_SCE || st->bwidth < SWB ) ) || total_brate > IVAS_192k ) { fac_ns[ch][n] = 0.0f; @@ -2107,7 +2130,12 @@ void coder_tcx( if ( st->hTcxCfg->tcx_last_overlap_mode == TRANSITION_OVERLAP ) { - WindowSignal( hTcxCfg, hTcxCfg->tcx_offsetFB, hTcxCfg->tcx_last_overlap_mode, hTcxCfg->tcx_curr_overlap_mode, &left_overlap, &right_overlap, st->hTcxEnc->speech_TCX, &L_frame, win, 1, 1, 0 ); + WindowSignal( hTcxCfg, hTcxCfg->tcx_offsetFB, hTcxCfg->tcx_last_overlap_mode, hTcxCfg->tcx_curr_overlap_mode, &left_overlap, &right_overlap, st->hTcxEnc->speech_TCX, &L_frame, win, 1, 1 +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + 0 +#endif + ); /* Compute MDCT for xn_buf[] */ TCX_MDCT( win, spectrum, left_overlap, L_frame - ( left_overlap + right_overlap ) / 2, right_overlap, st->element_mode ); @@ -2116,7 +2144,12 @@ void coder_tcx( { wtda( st->hTcxEnc->new_speech_TCX, win, NULL, hTcxCfg->tcx_last_overlap_mode, hTcxCfg->tcx_curr_overlap_mode, L_frame ); - WindowSignal( hTcxCfg, hTcxCfg->tcx_offsetFB, hTcxCfg->tcx_last_overlap_mode == ALDO_WINDOW ? FULL_OVERLAP : hTcxCfg->tcx_last_overlap_mode, hTcxCfg->tcx_curr_overlap_mode == ALDO_WINDOW ? FULL_OVERLAP : hTcxCfg->tcx_curr_overlap_mode, &left_overlap, &right_overlap, st->hTcxEnc->speech_TCX, &L_frame, winMDST, 1, 1, 0 ); + WindowSignal( hTcxCfg, hTcxCfg->tcx_offsetFB, hTcxCfg->tcx_last_overlap_mode == ALDO_WINDOW ? FULL_OVERLAP : hTcxCfg->tcx_last_overlap_mode, hTcxCfg->tcx_curr_overlap_mode == ALDO_WINDOW ? FULL_OVERLAP : hTcxCfg->tcx_curr_overlap_mode, &left_overlap, &right_overlap, st->hTcxEnc->speech_TCX, &L_frame, winMDST, 1, 1 +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + 0 +#endif + ); edct( win, spectrum, L_frame, st->element_mode ); diff --git a/lib_enc/core_enc_init.c b/lib_enc/core_enc_init.c index a87bfefb874d890f08f4f4258c3a964755a08753..f89f4a132c0b38ba00ea4697e83dc151ab8e1970 100644 --- a/lib_enc/core_enc_init.c +++ b/lib_enc/core_enc_init.c @@ -261,7 +261,12 @@ static void init_tcx( hTcxEnc->spectrum[0] = hTcxEnc->spectrum_long; hTcxEnc->spectrum[1] = hTcxEnc->spectrum_long + N_TCX10_MAX; - init_tcx_cfg( st->hTcxCfg, total_brate, st->sr_core, st->input_Fs, st->L_frame, st->bwidth, hTcxEnc->L_frameTCX, st->fscale, st->encoderLookahead_enc, st->encoderLookahead_FB, st->preemph_fac, st->tcxonly, st->rf_mode, st->igf, st->hIGFEnc != NULL ? st->hIGFEnc->infoStopFrequency : 0, st->element_mode, st->ini_frame, MCT_flag, st->mct_chan_mode ); + init_tcx_cfg( st->hTcxCfg, total_brate, st->sr_core, st->input_Fs, st->L_frame, st->bwidth, hTcxEnc->L_frameTCX, st->fscale, st->encoderLookahead_enc, st->encoderLookahead_FB, st->preemph_fac, st->tcxonly, st->rf_mode, st->igf, st->hIGFEnc != NULL ? st->hIGFEnc->infoStopFrequency : 0, st->element_mode, st->ini_frame, MCT_flag +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + st->mct_chan_mode +#endif + ); /* Init TCX target bits correction factor */ hTcxEnc->tcx_target_bits_fac = 1.0f; diff --git a/lib_enc/core_enc_switch.c b/lib_enc/core_enc_switch.c index 14fcac389443b9e5fd358353b5101959384e4292..806afd273bcc1ab4ad4e9cceb7f2cf8b2b60c3ee 100644 --- a/lib_enc/core_enc_switch.c +++ b/lib_enc/core_enc_switch.c @@ -95,7 +95,12 @@ void core_coder_mode_switch( st->bits_frame_nominal = (int16_t) ( (float) st->L_frame / (float) st->fscale * (float) FSCALE_DENOM / 128.0f * (float) st->total_brate / 100.0f + 0.49f ); - st->igf = getIgfPresent( st->element_mode, st->total_brate, st->bwidth, st->rf_mode, st->mct_chan_mode ); + st->igf = getIgfPresent( st->element_mode, st->total_brate, st->bwidth, st->rf_mode +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + st->mct_chan_mode +#endif + ); /* switch IGF configuration */ if ( st->igf ) @@ -112,7 +117,12 @@ void core_coder_mode_switch( hTcxEnc->tcx_lpc_shaped_ari = getTcxLpcShapedAri( st->total_brate, st->rf_mode, st->element_mode ); st->hTcxCfg->tcxRateLoopOpt = ( st->hTcxCfg->resq && !st->tcxonly ) ? 1 : st->hTcxCfg->tcxRateLoopOpt; - st->hTcxCfg->fIsTNSAllowed = getTnsAllowed( st->total_brate, st->igf, st->element_mode, st->mct_chan_mode ); + st->hTcxCfg->fIsTNSAllowed = getTnsAllowed( st->total_brate, st->igf, st->element_mode +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + st->mct_chan_mode +#endif + ); if ( st->hTcxCfg->fIsTNSAllowed ) { @@ -151,7 +161,12 @@ void core_coder_mode_switch( } else { - st->igf = getIgfPresent( st->element_mode, st->total_brate, st->bwidth, st->rf_mode, st->mct_chan_mode ); + st->igf = getIgfPresent( st->element_mode, st->total_brate, st->bwidth, st->rf_mode +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + st->mct_chan_mode +#endif + ); init_coder_ace_plus( st, last_total_brate, MCT_flag ); } diff --git a/lib_enc/evs_enc.c b/lib_enc/evs_enc.c index b90f10359b2eddf3bb4250e421fc41b8fc1bc7f2..44c34a2bd7a6942fc17bc938d5dca44f2c95f59f 100644 --- a/lib_enc/evs_enc.c +++ b/lib_enc/evs_enc.c @@ -686,7 +686,12 @@ static void configure_core_coder( } } - st->igf = getIgfPresent( 0, st->total_brate, st->bwidth, st->rf_mode, st->mct_chan_mode ); + st->igf = getIgfPresent( 0, st->total_brate, st->bwidth, st->rf_mode +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + st->mct_chan_mode +#endif + ); if ( st->core_brate != SID_2k40 && st->core_brate != FRAME_NO_DATA ) { diff --git a/lib_enc/ext_sig_ana.c b/lib_enc/ext_sig_ana.c index 9e1ad869ab239d34105dbbc93b7573f34a75c87c..0588f0ddf1638c2610c24dba5e8b954548120da0 100644 --- a/lib_enc/ext_sig_ana.c +++ b/lib_enc/ext_sig_ana.c @@ -215,8 +215,10 @@ void core_signal_analysis_high_bitrate( if ( transform_type[frameno] == TCX_20 && st->hTcxCfg->tcx_last_overlap_mode != TRANSITION_OVERLAP ) { +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( st->mct_chan_mode != MCT_CHAN_MODE_LFE ) { +#endif wtda( hTcxEnc->new_speech_TCX, tcx20Win, NULL, overlap_mode[frameno], overlap_mode[frameno + 1], L_frameTCX ); if ( windowed_samples != NULL ) /* store overlap data for later */ @@ -225,6 +227,7 @@ void core_signal_analysis_high_bitrate( windowed_samples[0] = (float) overlap_mode[frameno]; windowed_samples[1] = (float) overlap_mode[frameno + 1]; } +#ifndef ISSUE_24_CLEANUP_MCT_LFE } else { @@ -233,17 +236,27 @@ void core_signal_analysis_high_bitrate( st->element_mode != IVAS_CPE_MDCT /* truncate_aldo */, 1, 1 ); } - +#endif if ( st->element_mode != IVAS_CPE_MDCT ) { /* Windowing of the 2xTCX5 subframes or 1xTCX10 or 1xTCX20 */ - WindowSignal( st->hTcxCfg, st->hTcxCfg->tcx_offsetFB, overlap_mode[frameno] == ALDO_WINDOW ? FULL_OVERLAP : overlap_mode[frameno], overlap_mode[frameno + 1] == ALDO_WINDOW ? FULL_OVERLAP : overlap_mode[frameno + 1], &left_overlap, &right_overlap, &hTcxEnc->speech_TCX[frameno * tcx10SizeFB], &L_subframe, mdstWin, 1, 1, 0 ); + WindowSignal( st->hTcxCfg, st->hTcxCfg->tcx_offsetFB, overlap_mode[frameno] == ALDO_WINDOW ? FULL_OVERLAP : overlap_mode[frameno], overlap_mode[frameno + 1] == ALDO_WINDOW ? FULL_OVERLAP : overlap_mode[frameno + 1], &left_overlap, &right_overlap, &hTcxEnc->speech_TCX[frameno * tcx10SizeFB], &L_subframe, mdstWin, 1, 1 +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + 0 +#endif + ); } } else { /* Windowing of the 2xTCX5 subframes or 1xTCX10 or 1xTCX20 */ - WindowSignal( st->hTcxCfg, st->hTcxCfg->tcx_offsetFB, overlap_mode[frameno], overlap_mode[frameno + 1], &left_overlap, &right_overlap, &hTcxEnc->speech_TCX[frameno * tcx10SizeFB], &L_subframe, tcx20Win, st->element_mode != IVAS_CPE_MDCT, 1, 0 ); + WindowSignal( st->hTcxCfg, st->hTcxCfg->tcx_offsetFB, overlap_mode[frameno], overlap_mode[frameno + 1], &left_overlap, &right_overlap, &hTcxEnc->speech_TCX[frameno * tcx10SizeFB], &L_subframe, tcx20Win, st->element_mode != IVAS_CPE_MDCT, 1 +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + 0 +#endif + ); if ( windowed_samples != NULL ) /* save windowed speech_TCX samples */ { @@ -282,8 +295,15 @@ void core_signal_analysis_high_bitrate( for ( i = 0; i < 2; i++ ) { +#ifndef ISSUE_24_CLEANUP_MCT_LFE assert( st->mct_chan_mode != MCT_CHAN_MODE_LFE ); - WindowSignal( st->hTcxCfg, folding_offset, i == 0 ? RECTANGULAR_OVERLAP : MIN_OVERLAP, i == 1 ? RECTANGULAR_OVERLAP : MIN_OVERLAP, &left_overlap, &right_overlap, tcx20Win + i * tcx5SizeFB, &L_subframe, tcx5Win, st->element_mode != IVAS_CPE_MDCT, 1, 0 ); +#endif + WindowSignal( st->hTcxCfg, folding_offset, i == 0 ? RECTANGULAR_OVERLAP : MIN_OVERLAP, i == 1 ? RECTANGULAR_OVERLAP : MIN_OVERLAP, &left_overlap, &right_overlap, tcx20Win + i * tcx5SizeFB, &L_subframe, tcx5Win, st->element_mode != IVAS_CPE_MDCT, 1 +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + 0 +#endif + ); TCX_MDCT( tcx5Win, hTcxEnc->spectrum[frameno] + i * tcx5SizeFB, left_overlap, L_subframe - ( left_overlap + right_overlap ) / 2, right_overlap, st->element_mode ); @@ -298,7 +318,11 @@ void core_signal_analysis_high_bitrate( { assert( transform_type[frameno] == TCX_10 || transform_type[frameno] == TCX_20 ); - if ( transform_type[frameno] == TCX_20 && st->hTcxCfg->tcx_last_overlap_mode != TRANSITION_OVERLAP && st->mct_chan_mode != MCT_CHAN_MODE_LFE ) + if ( transform_type[frameno] == TCX_20 && st->hTcxCfg->tcx_last_overlap_mode != TRANSITION_OVERLAP +#ifndef ISSUE_24_CLEANUP_MCT_LFE + && st->mct_chan_mode != MCT_CHAN_MODE_LFE +#endif + ) { edct( tcx20Win, hTcxEnc->spectrum[frameno], L_subframe, st->element_mode ); @@ -323,12 +347,13 @@ void core_signal_analysis_high_bitrate( { v_multc( hTcxEnc->spectrum[frameno] + L_FRAME16k / nSubframes, (float) ( st->bwidth_sw_cnt ) / (float) BWS_TRAN_PERIOD, hTcxEnc->spectrum[frameno] + L_FRAME16k / nSubframes, L_subframe - L_FRAME16k / nSubframes ); } - +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( st->mct_chan_mode == MCT_CHAN_MODE_LFE ) { set_f( &hTcxEnc->spectrum[frameno][MCT_LFE_MAX_LINE], 0.f, L_subframe - MCT_LFE_MAX_LINE ); st->hTcxCfg->tcx_coded_lines = MCT_LFE_MAX_LINE; } +#endif if ( st->element_mode != IVAS_CPE_MDCT ) { @@ -345,14 +370,23 @@ void core_signal_analysis_high_bitrate( { L_subframe = L_frameTCX / nSubframes; - if ( transform_type[frameno] == TCX_20 && st->hTcxCfg->tcx_last_overlap_mode != TRANSITION_OVERLAP && st->mct_chan_mode != MCT_CHAN_MODE_LFE ) + if ( transform_type[frameno] == TCX_20 && st->hTcxCfg->tcx_last_overlap_mode != TRANSITION_OVERLAP +#ifndef ISSUE_24_CLEANUP_MCT_LFE + && st->mct_chan_mode != MCT_CHAN_MODE_LFE +#endif + ) { wtda_ext( hTcxEnc->new_speech_TCX, mdstWin, overlap_mode[frameno], overlap_mode[frameno + 1], L_frameTCX, 3 ); } else { /* Windowing for the MDST */ - WindowSignal( st->hTcxCfg, st->hTcxCfg->tcx_offsetFB, overlap_mode[frameno] == ALDO_WINDOW ? FULL_OVERLAP : overlap_mode[frameno], overlap_mode[frameno + 1] == ALDO_WINDOW ? FULL_OVERLAP : overlap_mode[frameno + 1], &left_overlap, &right_overlap, &hTcxEnc->speech_TCX[frameno * tcx10SizeFB], &L_subframe, mdstWin, 0, 1, st->mct_chan_mode == MCT_CHAN_MODE_LFE ); + WindowSignal( st->hTcxCfg, st->hTcxCfg->tcx_offsetFB, overlap_mode[frameno] == ALDO_WINDOW ? FULL_OVERLAP : overlap_mode[frameno], overlap_mode[frameno + 1] == ALDO_WINDOW ? FULL_OVERLAP : overlap_mode[frameno + 1], &left_overlap, &right_overlap, &hTcxEnc->speech_TCX[frameno * tcx10SizeFB], &L_subframe, mdstWin, 0, 1 +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + st->mct_chan_mode == MCT_CHAN_MODE_LFE +#endif + ); } if ( transform_type[frameno] == TCX_5 ) @@ -383,8 +417,15 @@ void core_signal_analysis_high_bitrate( for ( i = 0; i < 2; i++ ) { +#ifndef ISSUE_24_CLEANUP_MCT_LFE assert( st->mct_chan_mode != MCT_CHAN_MODE_LFE ); - WindowSignal( st->hTcxCfg, folding_offset, i == 0 ? RECTANGULAR_OVERLAP : MIN_OVERLAP, i == 1 ? RECTANGULAR_OVERLAP : MIN_OVERLAP, &left_overlap, &right_overlap, mdstWin + i * tcx5SizeFB, &L_subframe, tcx5Win, 0, 1, 0 ); +#endif + WindowSignal( st->hTcxCfg, folding_offset, i == 0 ? RECTANGULAR_OVERLAP : MIN_OVERLAP, i == 1 ? RECTANGULAR_OVERLAP : MIN_OVERLAP, &left_overlap, &right_overlap, mdstWin + i * tcx5SizeFB, &L_subframe, tcx5Win, 0, 1 +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + 0 +#endif + ); TCX_MDST( tcx5Win, mdst_spectrum[frameno] + i * tcx5SizeFB, left_overlap, L_subframe - ( left_overlap + right_overlap ) / 2, right_overlap, st->element_mode ); /* high-band gain control in case of BWS */ @@ -396,7 +437,11 @@ void core_signal_analysis_high_bitrate( } else /* transform_type[frameno] != TCX_5 */ { - if ( transform_type[frameno] == TCX_20 && st->hTcxCfg->tcx_last_overlap_mode != TRANSITION_OVERLAP && st->mct_chan_mode != MCT_CHAN_MODE_LFE ) + if ( transform_type[frameno] == TCX_20 && st->hTcxCfg->tcx_last_overlap_mode != TRANSITION_OVERLAP +#ifndef ISSUE_24_CLEANUP_MCT_LFE + && st->mct_chan_mode != MCT_CHAN_MODE_LFE +#endif + ) { edst( mdstWin, mdst_spectrum[frameno], L_subframe, st->element_mode ); @@ -421,11 +466,12 @@ void core_signal_analysis_high_bitrate( v_multc( mdst_spectrum[frameno] + L_FRAME16k / nSubframes, (float) ( st->bwidth_sw_cnt ) / (float) BWS_TRAN_PERIOD, mdst_spectrum[frameno] + L_FRAME16k / nSubframes, L_subframe - L_FRAME16k / nSubframes ); } } - +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( st->mct_chan_mode == MCT_CHAN_MODE_LFE ) { set_f( &mdst_spectrum[frameno][MCT_LFE_MAX_LINE], 0.f, L_subframe - MCT_LFE_MAX_LINE ); } +#endif } if ( st->element_mode != IVAS_CPE_MDCT ) diff --git a/lib_enc/hq_core_enc.c b/lib_enc/hq_core_enc.c index 4bc332fd5e39cbb7acdd1db5e1a9c74c40074127..43b5ebd68c7c377da7346e7ae6196ef414453108 100644 --- a/lib_enc/hq_core_enc.c +++ b/lib_enc/hq_core_enc.c @@ -116,7 +116,12 @@ void hq_core_enc( left_overlap = -1; right_overlap = -1; - WindowSignal( st->hTcxCfg, st->hTcxCfg->tcx_offsetFB, TRANSITION_OVERLAP, FULL_OVERLAP, &left_overlap, &right_overlap, st->hTcxEnc->speech_TCX, &L_spec, wtda_audio, 1, 1, 0 ); + WindowSignal( st->hTcxCfg, st->hTcxCfg->tcx_offsetFB, TRANSITION_OVERLAP, FULL_OVERLAP, &left_overlap, &right_overlap, st->hTcxEnc->speech_TCX, &L_spec, wtda_audio, 1, 1 +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + 0 +#endif + ); TCX_MDCT( wtda_audio, t_audio, left_overlap, L_spec - ( left_overlap + right_overlap ) / 2, right_overlap, st->element_mode ); diff --git a/lib_enc/init_enc.c b/lib_enc/init_enc.c index 16b1cf0c29146414b805a25703a2cd90559e8936..d73434c15f54a1c9675d2b7e6d8b307ae8ee8225 100644 --- a/lib_enc/init_enc.c +++ b/lib_enc/init_enc.c @@ -731,7 +731,11 @@ ivas_error init_encoder( * IGF *-----------------------------------------------------------------*/ - if ( ( idchan == 0 || st->element_mode == IVAS_CPE_MDCT ) && st->mct_chan_mode != MCT_CHAN_MODE_LFE ) + if ( ( idchan == 0 || st->element_mode == IVAS_CPE_MDCT ) +#ifndef ISSUE_24_CLEANUP_MCT_LFE + && st->mct_chan_mode != MCT_CHAN_MODE_LFE +#endif + ) { if ( ( st->hIGFEnc = (IGF_ENC_INSTANCE_HANDLE) malloc( sizeof( IGF_ENC_INSTANCE ) ) ) == NULL ) { @@ -751,7 +755,12 @@ ivas_error init_encoder( if ( st->codec_mode == MODE2 || st->element_mode > EVS_MONO ) { - st->igf = getIgfPresent( st->element_mode, st->total_brate, st->bwidth, st->rf_mode, st->mct_chan_mode ); + st->igf = getIgfPresent( st->element_mode, st->total_brate, st->bwidth, st->rf_mode +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + st->mct_chan_mode +#endif + ); } else { @@ -805,9 +814,10 @@ ivas_error init_encoder( /*-----------------------------------------------------------------* * Transient detector *-----------------------------------------------------------------*/ - +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( st->mct_chan_mode != MCT_CHAN_MODE_LFE ) { +#endif if ( ( st->hTranDet = (TRAN_DET_HANDLE) malloc( sizeof( TRAN_DET_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Transient Detection\n" ) ); @@ -821,11 +831,13 @@ ivas_error init_encoder( { InitTransientDetection( (int16_t) ( st->input_Fs / FRAMES_PER_SEC ), NS2SA( st->input_Fs, DELAY_FIR_RESAMPL_NS ), st->hTranDet, 0 ); } +#ifndef ISSUE_24_CLEANUP_MCT_LFE } else { st->hTranDet = NULL; } +#endif /*-----------------------------------------------------------------* * IVAS parameters diff --git a/lib_enc/ivas_core_enc.c b/lib_enc/ivas_core_enc.c index 002e499f4b253c171c1201ec130527c304db90e7..0c85ca186dcafd0c1084465c8b6d34b350aaa028 100644 --- a/lib_enc/ivas_core_enc.c +++ b/lib_enc/ivas_core_enc.c @@ -259,7 +259,15 @@ ivas_error ivas_core_enc( if ( MCT_flag ) { ivas_mdct_core_whitening_enc( hCPE, old_inp_16k, old_wsp, pitch_buf, hMCT->p_mdst_spectrum_long[cpe_id], hMCT->tnsBits[cpe_id], hMCT->p_orig_spectrum_long[cpe_id], - hMCT->tnsSize[cpe_id], hMCT->p_param[cpe_id], hMCT->hBstr, &hMCT->LFE_off, 1, hMCT->nchan_out_woLFE + hMCT->num_lfe ); + hMCT->tnsSize[cpe_id], hMCT->p_param[cpe_id], hMCT->hBstr, +#ifndef ISSUE_24_CLEANUP_MCT_LFE + &hMCT->LFE_off, +#endif + 1, hMCT->nchan_out_woLFE +#ifndef ISSUE_24_CLEANUP_MCT_LFE + + hMCT->num_lfe +#endif + ); } else { diff --git a/lib_enc/ivas_corecoder_enc_reconfig.c b/lib_enc/ivas_corecoder_enc_reconfig.c index cfe3a1badf7477fb347e89779d5ff030c215876c..cbb48495bf6b7f34fcf079df5eebf284e4b0f4d7 100644 --- a/lib_enc/ivas_corecoder_enc_reconfig.c +++ b/lib_enc/ivas_corecoder_enc_reconfig.c @@ -381,8 +381,12 @@ ivas_error ivas_corecoder_enc_reconfig( st_ivas->hCPE[0]->hCoreCoder[n]->igf = getIgfPresent( st_ivas->hCPE[0]->hCoreCoder[n]->element_mode, st_ivas->hCPE[0]->hCoreCoder[n]->bits_frame_nominal * FRAMES_PER_SEC, st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, - st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode, - st_ivas->hCPE[0]->hCoreCoder[n]->mct_chan_mode ); + st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + st_ivas->hCPE[0]->hCoreCoder[n]->mct_chan_mode +#endif + ); if ( st_ivas->hCPE[0]->hCoreCoder[n]->igf ) { @@ -449,8 +453,12 @@ ivas_error ivas_corecoder_enc_reconfig( st_ivas->hCPE[0]->hCoreCoder[n]->igf = getIgfPresent( st_ivas->hCPE[0]->hCoreCoder[n]->element_mode, st_ivas->hCPE[0]->hCoreCoder[n]->bits_frame_nominal * FRAMES_PER_SEC, st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, - st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode, - st_ivas->hCPE[0]->hCoreCoder[n]->mct_chan_mode ); + st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + st_ivas->hCPE[0]->hCoreCoder[n]->mct_chan_mode +#endif + ); if ( st_ivas->hCPE[0]->hCoreCoder[n]->igf ) { diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index f9b787ac563f21c3015b916703110ae0362031bc..184a867cd1a13dda60a27833465f18b4cbc88334 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -154,7 +154,14 @@ ivas_error ivas_cpe_enc( } mvr2r( data_f_ch0, sts[0]->input, input_frame ); +#ifdef ISSUE_24_CLEANUP_MCT_LFE + if ( data_f_ch1 != NULL ) /*this may happen for cases with odd number of channels*/ + { + mvr2r( data_f_ch1, sts[1]->input, input_frame ); + } +#else mvr2r( data_f_ch1, sts[1]->input, input_frame ); +#endif /*----------------------------------------------------------------* * Stereo technology selection @@ -296,12 +303,27 @@ ivas_error ivas_cpe_enc( { if ( st_ivas->hMCT ) { +#ifdef ISSUE_24_CLEANUP_MCT_LFE + int16_t lfe_bits; + lfe_bits = ( ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCT ? st_ivas->hLFE->lfe_bits : 0 ); +#endif sts[n]->total_brate = hCPE->element_brate; +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( sts[n]->mct_chan_mode != MCT_CHAN_MODE_LFE ) { +#endif sts[n]->bits_frame_nominal = (int16_t) ( hCPE->element_brate / FRAMES_PER_SEC ); - sts[n]->bits_frame_channel = (int16_t) ( ( ivas_total_brate / FRAMES_PER_SEC - ( st_ivas->hMCT->num_lfe == FALSE ? 0 : LFE_BITS ) - nb_bits_metadata ) / st_ivas->hMCT->nchan_out_woLFE ); + sts[n]->bits_frame_channel = (int16_t) ( ( ivas_total_brate / FRAMES_PER_SEC - +#ifndef ISSUE_24_CLEANUP_MCT_LFE + ( st_ivas->hMCT->num_lfe == FALSE ? 0 : LFE_BITS ) - +#else + lfe_bits - +#endif + nb_bits_metadata ) / + st_ivas->hMCT->nchan_out_woLFE ); +#ifndef ISSUE_24_CLEANUP_MCT_LFE } +#endif } else { @@ -660,10 +682,14 @@ ivas_error ivas_cpe_enc( /* Store previous attack detection flag */ for ( n = 0; n < CPE_CHANNELS; n++ ) { +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( sts[n]->mct_chan_mode != MCT_CHAN_MODE_LFE ) { +#endif sts[n]->hTranDet->transientDetector.prev_bIsAttackPresent = sts[n]->hTranDet->transientDetector.bIsAttackPresent; +#ifndef ISSUE_24_CLEANUP_MCT_LFE } +#endif } #ifdef DEBUG_MODE_INFO @@ -827,11 +853,12 @@ ivas_error create_cpe_enc( copy_encoder_config( st_ivas, st, 1 ); 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; +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCT && ( n + cpe_id * CPE_CHANNELS ) == LFE_CHANNEL ) { st->mct_chan_mode = MCT_CHAN_MODE_LFE; } - +#endif if ( ( error = init_encoder( st, n, hEncoderConfig->var_SID_rate_flag, hEncoderConfig->interval_SID, 0, st_ivas->ism_mode ) ) != IVAS_ERR_OK ) { return error; diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c index 5cbcb57daf4e789f8f308808c5c26b9875083d34..c2c2e284c2ae200d2146122d403ad4acf6f7c1aa 100644 --- a/lib_enc/ivas_mct_core_enc.c +++ b/lib_enc/ivas_mct_core_enc.c @@ -51,7 +51,9 @@ *----------------------------------------------------------*/ static void FindChannelRatio( - MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */ +#ifndef ISSUE_24_CLEANUP_MCT_LFE + MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */ +#endif Encoder_State **sts, /* i/o: encoder state structure */ int16_t chBitRatios[MCT_MAX_CHANNELS], /* o : bit-disctribution channel ratios */ const int16_t nChannels /* i : number of channels to be coded */ @@ -69,7 +71,11 @@ static void FindChannelRatio( sum_nrg = 0; for ( i = 0; i < nChannels; i++ ) { - if ( sts[i]->mct_chan_mode != MCT_CHAN_MODE_IGNORE && sts[i]->mct_chan_mode != MCT_CHAN_MODE_LFE ) + if ( sts[i]->mct_chan_mode != MCT_CHAN_MODE_IGNORE +#ifndef ISSUE_24_CLEANUP_MCT_LFE + && sts[i]->mct_chan_mode != MCT_CHAN_MODE_LFE +#endif + ) { sum_nrg += nrg[i]; } @@ -78,7 +84,11 @@ static void FindChannelRatio( for ( i = 0; i < nChannels; i++ ) { - if ( sts[i]->mct_chan_mode != MCT_CHAN_MODE_IGNORE && sts[i]->mct_chan_mode != MCT_CHAN_MODE_LFE ) + if ( sts[i]->mct_chan_mode != MCT_CHAN_MODE_IGNORE +#ifndef ISSUE_24_CLEANUP_MCT_LFE + && sts[i]->mct_chan_mode != MCT_CHAN_MODE_LFE +#endif + ) { chRatio = nrg[i] * sum_nrg; chBitRatios[i] = min( BITRATE_MCT_RATIO_RANGE - 1, max( 1, (uint16_t) ( BITRATE_MCT_RATIO_RANGE * chRatio + 0.5f ) ) ); @@ -87,15 +97,17 @@ static void FindChannelRatio( { chBitRatios[i] = 0; } +#ifndef ISSUE_24_CLEANUP_MCT_LFE else if ( hMCT->num_lfe ) { assert( sts[i]->mct_chan_mode == MCT_CHAN_MODE_LFE ); chBitRatios[i] = !hMCT->LFE_off; } +#endif } #ifdef DEBUG_MODE_MDCT - for ( i = 0; i < nchan; i++ ) + for ( i = 0; i < nChannels; i++ ) { dbgwrite( &chBitRatios[i], sizeof( int16_t ), 1, 1, "./res/chBitRatio" ); /* dbgwrite(&chRatio[i], sizeof(float),1,1,"./res/chRatio");*/ @@ -237,6 +249,8 @@ void ivas_mct_core_enc( total_side_bits = 0; nCPE = nChannels / CPE_CHANNELS; + + /*in case of odd number of channels*/ if ( ( nCPE * CPE_CHANNELS ) != nChannels ) { nCPE++; @@ -255,7 +269,11 @@ void ivas_mct_core_enc( for ( ch = 0; ch < CPE_CHANNELS; ch++ ) { sts[i] = hCPE[cpe_id]->hCoreCoder[ch]; - if ( hCPE[cpe_id]->hCoreCoder[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE || hCPE[cpe_id]->hCoreCoder[ch]->mct_chan_mode == MCT_CHAN_MODE_LFE ) + if ( hCPE[cpe_id]->hCoreCoder[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE +#ifndef ISSUE_24_CLEANUP_MCT_LFE + || hCPE[cpe_id]->hCoreCoder[ch]->mct_chan_mode == MCT_CHAN_MODE_LFE +#endif + ) { i++; continue; @@ -304,7 +322,11 @@ void ivas_mct_core_enc( { st = sts[ch]; - if ( ( st->mct_chan_mode == MCT_CHAN_MODE_LFE && hMCT->LFE_off ) || st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) + if ( +#ifndef ISSUE_24_CLEANUP_MCT_LFE + ( st->mct_chan_mode == MCT_CHAN_MODE_LFE && hMCT->LFE_off ) || +#endif + st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) { continue; } @@ -332,7 +354,11 @@ void ivas_mct_core_enc( for ( ch = 0; ch < nChannels; ch++ ) { - if ( sts[ch]->mct_chan_mode == MCT_CHAN_MODE_LFE || sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) + if ( +#ifndef ISSUE_24_CLEANUP_MCT_LFE + sts[ch]->mct_chan_mode == MCT_CHAN_MODE_LFE || +#endif + sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) { continue; } @@ -379,7 +405,11 @@ void ivas_mct_core_enc( for ( ch = 0; ch < nChannels; ch++ ) { st = sts[ch]; - if ( sts[ch]->mct_chan_mode == MCT_CHAN_MODE_LFE || sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) + if ( +#ifndef ISSUE_24_CLEANUP_MCT_LFE + sts[ch]->mct_chan_mode == MCT_CHAN_MODE_LFE || +#endif + sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) { continue; } @@ -411,7 +441,11 @@ void ivas_mct_core_enc( for ( ch = 0; ch < nChannels; ch++ ) { st = sts[ch]; - if ( sts[ch]->mct_chan_mode == MCT_CHAN_MODE_LFE || sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) + if ( +#ifndef ISSUE_24_CLEANUP_MCT_LFE + sts[ch]->mct_chan_mode == MCT_CHAN_MODE_LFE || +#endif + sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) { continue; } @@ -432,7 +466,11 @@ void ivas_mct_core_enc( for ( ch = 0; ch < nChannels; ch++ ) { st = sts[ch]; - if ( sts[ch]->mct_chan_mode == MCT_CHAN_MODE_LFE || sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) + if ( +#ifndef ISSUE_24_CLEANUP_MCT_LFE + sts[ch]->mct_chan_mode == MCT_CHAN_MODE_LFE || +#endif + sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) { continue; } @@ -445,7 +483,11 @@ void ivas_mct_core_enc( { st = sts[ch]; - if ( ( ( st->mct_chan_mode == MCT_CHAN_MODE_LFE ) && hMCT->LFE_off ) || sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) + if ( +#ifndef ISSUE_24_CLEANUP_MCT_LFE + ( ( st->mct_chan_mode == MCT_CHAN_MODE_LFE ) && hMCT->LFE_off ) || +#endif + sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) { continue; } @@ -460,7 +502,11 @@ void ivas_mct_core_enc( write_mct_bitstream( sts, hMCT, nChannels ); - FindChannelRatio( hMCT, sts, chBitRatios, nChannels ); + FindChannelRatio( +#ifndef ISSUE_24_CLEANUP_MCT_LFE + hMCT, +#endif + sts, chBitRatios, nChannels ); nAvailBits = (int16_t) ( ( ivas_total_brate / FRAMES_PER_SEC ) - NBITS_BWIDTH - hMCT->nBitsMCT - lfe_bits ); @@ -488,13 +534,21 @@ void ivas_mct_core_enc( /*substract bits needed for the bitrate ratios */ for ( ch = 0; ch < nChannels; ch++ ) { - if ( ( ( sts[ch]->mct_chan_mode == MCT_CHAN_MODE_LFE ) && hMCT->LFE_off ) || sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) + if ( +#ifndef ISSUE_24_CLEANUP_MCT_LFE + ( ( sts[ch]->mct_chan_mode == MCT_CHAN_MODE_LFE ) && hMCT->LFE_off ) || +#endif + sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) { continue; } nAvailBits -= NBBITS_MCT_RATIO; } - nAvailBits -= total_side_bits + ( hMCT->num_lfe ? 1 : 0 ) + hMCT->nchan_out_woLFE; /* if MC 1 extra bit that was initially send to signal LFE_off */ + nAvailBits -= total_side_bits +#ifndef ISSUE_24_CLEANUP_MCT_LFE + + ( hMCT->num_lfe ? 1 : 0 ) +#endif + + hMCT->nchan_out_woLFE; /* if MC 1 extra bit that was initially send to signal LFE_off */ #ifdef DEBUG_MODE_MDCT dbgwrite( &nAvailBits, sizeof( int16_t ), 1, 1, "./res/availBits" ); @@ -508,7 +562,11 @@ void ivas_mct_core_enc( for ( ch = 0; ch < nChannels; ch++ ) { - if ( ( ( sts[ch]->mct_chan_mode == MCT_CHAN_MODE_LFE ) && hMCT->LFE_off ) || sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) + if ( +#ifndef ISSUE_24_CLEANUP_MCT_LFE + ( ( sts[ch]->mct_chan_mode == MCT_CHAN_MODE_LFE ) && hMCT->LFE_off ) || +#endif + sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) { continue; } @@ -531,15 +589,18 @@ void ivas_mct_core_enc( { continue; } - +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( !( ( st->mct_chan_mode == MCT_CHAN_MODE_LFE ) && hMCT->LFE_off ) ) /* indicates LFE with no content */ { +#endif st->total_brate = ( st->bits_frame_channel + st->side_bits_frame_channel ) * FRAMES_PER_SEC; #ifdef DEBUGGING total_brate += st->total_brate; #endif +#ifndef ISSUE_24_CLEANUP_MCT_LFE } +#endif } #ifdef DEBUGGING if ( hCPE[cpe_id]->hMetaData != NULL ) @@ -551,7 +612,11 @@ void ivas_mct_core_enc( #ifdef DEBUGGING format_bits = ( ivas_format == MC_FORMAT ? IVAS_FORMAT_SIGNALING_NBITS + MC_LS_SETUP_BITS : IVAS_FORMAT_SIGNALING_NBITS_SBA + SBA_ORDER_BITS + SBA_PLANAR_BITS ); - mct_bits += hMCT->nBitsMCT + ( hMCT->num_lfe ? 1 : 0 ) + hMCT->nchan_out_woLFE; + mct_bits += hMCT->nBitsMCT +#ifndef ISSUE_24_CLEANUP_MCT_LFE + + ( hMCT->num_lfe ? 1 : 0 ) +#endif + + hMCT->nchan_out_woLFE; assert( ( total_brate + ( NBITS_BWIDTH + format_bits + mct_bits + sba_meta + lfe_bits ) * FRAMES_PER_SEC ) == ivas_total_brate ); #endif diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c index b66a2c5733c4622d6315b87d01e16f8a051fede5..75191d0a412361b4b8732f3472e12cec085a3ddc 100644 --- a/lib_enc/ivas_mct_enc.c +++ b/lib_enc/ivas_mct_enc.c @@ -90,7 +90,61 @@ static void set_mct_enc_params( return; } +/*-------------------------------------------------------------------* + * map_input_to_cpe_channels() + * + * for MC_MODE map input channels to cpe channels + * mid channel (ch==2) is mapped to last odd-channel CPE + * all channels after LFE are mapped to cpe_id=1 and onwards + * E.g. for 5_1 and for 3 CPEs: + * cpe_id 0: L=data[0] R=data[1] + * cpe_id 1: L=data[4] R=data[5] + * cpe_id 2: L=data[2] (mid) R=NULL + *-------------------------------------------------------------------*/ +#ifdef ISSUE_24_CLEANUP_MCT_LFE +static void map_input_to_cpe_channels( + const Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ + float *pdata[MAX_INPUT_CHANNELS], /* o: mapped input pointers */ + float data[MCT_MAX_CHANNELS][L_FRAME48k] /* i: input channel data */ +) +{ + int16_t i, n; + + i = 0; + for ( n = 0; n < LFE_CHANNEL - 1; n++ ) + { + pdata[i] = data[n]; + i++; + } + + if ( st_ivas->hEncoderConfig->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCT ) + { + for ( n = LFE_CHANNEL + 1; n < st_ivas->nchan_transport; n++ ) + { + pdata[i] = data[n]; + i++; + } + pdata[i] = data[LFE_CHANNEL - 1]; + } + else + { + for ( ; n < st_ivas->nchan_transport; n++ ) + { + pdata[i] = data[n]; + i++; + } + } + + /* odd channel CPE*/ + if ( ( st_ivas->nchan_transport < st_ivas->nCPE * CPE_CHANNELS ) || ( st_ivas->mc_mode == MC_MODE_MCT && st_ivas->hMCT->nchan_out_woLFE < st_ivas->nCPE * CPE_CHANNELS ) ) + { + pdata[st_ivas->nCPE * CPE_CHANNELS - 1] = NULL; + } + + return; +} +#endif /*-------------------------------------------------------------------* * ivas_mct_enc() * @@ -114,6 +168,9 @@ ivas_error ivas_mct_enc( int16_t max_bwidth; int32_t ivas_total_brate; ivas_error error; +#ifdef ISSUE_24_CLEANUP_MCT_LFE + float *pdata[MAX_INPUT_CHANNELS]; +#endif error = IVAS_ERR_OK; @@ -143,11 +200,22 @@ ivas_error ivas_mct_enc( hMCT->p_orig_spectrum_long[cpe_id][n] = orig_spectrum_long[cpe_id][n]; hCPE->hCoreCoder[n]->input_bwidth = hCPE->hCoreCoder[n]->last_input_bwidth; /* updated in BWD */ hCPE->hCoreCoder[n]->bwidth = hCPE->hCoreCoder[n]->last_bwidth; /* updated in BWD */ +#ifdef ISSUE_24_CLEANUP_MCT_LFE + /* reset channel mode from previous state*/ + if ( ( hCPE->cpe_id * CPE_CHANNELS + n ) >= hMCT->nchan_out_woLFE ) + { + hCPE->hCoreCoder[n]->mct_chan_mode = MCT_CHAN_MODE_IGNORE; + } + else + { + hCPE->hCoreCoder[n]->mct_chan_mode = MCT_CHAN_MODE_REGULAR; + } +#endif } } - +#ifndef ISSUE_24_CLEANUP_MCT_LFE hMCT->LFE_off = 1; /* disable LFE coding by default for the moment */ - +#endif /* reconfiguration in case of bitrate switching */ if ( ivas_total_brate != st_ivas->hEncoderConfig->last_ivas_total_brate ) { @@ -163,24 +231,45 @@ ivas_error ivas_mct_enc( /* set coded audio band-width */ switch_bw = set_bw_mct( st_ivas->hCPE, st_ivas->nCPE ); +#ifdef ISSUE_24_CLEANUP_MCT_LFE + /*for MC and MCT remove pointer to LFE input that has been processed seperately */ + map_input_to_cpe_channels( st_ivas, pdata, data ); +#endif /* pre-processing */ for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { +#ifdef ISSUE_24_CLEANUP_MCT_LFE + if ( ( error = ivas_cpe_enc( st_ivas, cpe_id, pdata[cpe_id * CPE_CHANNELS], pdata[cpe_id * CPE_CHANNELS + 1], input_frame, nb_bits_metadata ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_cpe_enc( st_ivas, cpe_id, data[cpe_id * CPE_CHANNELS], data[cpe_id * CPE_CHANNELS + 1], input_frame, nb_bits_metadata ) ) != IVAS_ERR_OK ) +#endif { return error; } } /* joint MCT encoding */ - ivas_mct_core_enc( ivas_format, hMCT, st_ivas->hCPE, hMCT->nchan_out_woLFE + hMCT->num_lfe, ivas_total_brate, switch_bw, ( ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCT ) ? (int16_t) st_ivas->hLFE->lfe_bits : 0, st_ivas->hEncoderConfig->sba_order ); + ivas_mct_core_enc( ivas_format, hMCT, st_ivas->hCPE, +#ifndef ISSUE_24_CLEANUP_MCT_LFE + hMCT->nchan_out_woLFE + hMCT->num_lfe +#else + hMCT->nchan_out_woLFE +#endif + , + ivas_total_brate, switch_bw, + ( ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCT ) ? (int16_t) st_ivas->hLFE->lfe_bits : 0, + st_ivas->hEncoderConfig->sba_order ); /* Spectrum quantization and coding */ for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { hCPE = st_ivas->hCPE[cpe_id]; - ivas_mdct_quant_coder( hCPE, hMCT->LFE_off, hMCT->tnsBits[cpe_id], hMCT->tnsSize[cpe_id], hMCT->p_param[cpe_id], 1 ); + ivas_mdct_quant_coder( hCPE, +#ifndef ISSUE_24_CLEANUP_MCT_LFE + hMCT->LFE_off, +#endif + 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) */ for ( n = 0; n < CPE_CHANNELS; n++ ) @@ -235,23 +324,30 @@ ivas_error create_mct_enc( if ( ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCT ) { hMCT->nchan_out_woLFE = st_ivas->hEncoderConfig->nchan_inp - 1; /* LFE channel is coded separately */ +#ifndef ISSUE_24_CLEANUP_MCT_LFE hMCT->num_lfe = TRUE; +#endif } else if ( ivas_format == SBA_FORMAT ) { hMCT->nchan_out_woLFE = ivas_get_sba_num_TCs( ivas_total_brate, st_ivas->sba_analysis_order ); - +#ifndef ISSUE_24_CLEANUP_MCT_LFE hMCT->num_lfe = FALSE; +#endif } else if ( ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_PARAMMC ) { hMCT->nchan_out_woLFE = ivas_param_mc_getNumTransportChannels( ivas_total_brate, st_ivas->hEncoderConfig->mc_input_setup ); +#ifndef ISSUE_24_CLEANUP_MCT_LFE hMCT->num_lfe = FALSE; +#endif } else if ( ivas_format == SBA_FORMAT ) { hMCT->nchan_out_woLFE = ivas_sba_get_nchan( st_ivas->sba_analysis_order, st_ivas->hEncoderConfig->sba_planar ); +#ifndef ISSUE_24_CLEANUP_MCT_LFE hMCT->num_lfe = FALSE; +#endif } else { @@ -260,21 +356,27 @@ ivas_error create_mct_enc( cp_bitrate = ivas_total_brate / hMCT->nchan_out_woLFE * CPE_CHANNELS; - /* indicate LFE for appropriate core-coder channel */ for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { for ( n = 0; n < CPE_CHANNELS; n++ ) { st_ivas->hCPE[cpe_id]->hCoreCoder[n]->mct_chan_mode = MCT_CHAN_MODE_REGULAR; +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( ( hMCT->num_lfe > 0 ) && ( ( n + cpe_id * CPE_CHANNELS ) == LFE_CHANNEL ) ) { st_ivas->hCPE[cpe_id]->hCoreCoder[n]->mct_chan_mode = MCT_CHAN_MODE_LFE; } +#endif } } /* in case we have an uneven number of transport channels, indicate last channel ID as inactive */ - if ( ( hMCT->nchan_out_woLFE + hMCT->num_lfe ) % 2 ) + if ( ( hMCT->nchan_out_woLFE +#ifndef ISSUE_24_CLEANUP_MCT_LFE + + hMCT->num_lfe +#endif + ) % + 2 ) { st_ivas->hCPE[st_ivas->nCPE - 1]->hCoreCoder[1]->mct_chan_mode = MCT_CHAN_MODE_IGNORE; } @@ -360,17 +462,23 @@ ivas_error mct_enc_reconfigure( if ( ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCT ) { hMCT->nchan_out_woLFE = st_ivas->hEncoderConfig->nchan_inp - 1; /* LFE channel is coded separately */ +#ifndef ISSUE_24_CLEANUP_MCT_LFE hMCT->num_lfe = TRUE; +#endif } else if ( ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_PARAMMC ) { hMCT->nchan_out_woLFE = ivas_param_mc_getNumTransportChannels( ivas_total_brate, st_ivas->hEncoderConfig->mc_input_setup ); +#ifndef ISSUE_24_CLEANUP_MCT_LFE hMCT->num_lfe = FALSE; +#endif } else if ( ivas_format == SBA_FORMAT ) { hMCT->nchan_out_woLFE = st_ivas->nchan_transport; +#ifndef ISSUE_24_CLEANUP_MCT_LFE hMCT->num_lfe = FALSE; +#endif } else { @@ -380,22 +488,28 @@ ivas_error mct_enc_reconfigure( cp_bitrate = ivas_total_brate / hMCT->nchan_out_woLFE * CPE_CHANNELS; - /* indicate LFE for appropriate core-coder channel */ for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { st_ivas->hCPE[cpe_id]->element_brate = cp_bitrate; for ( n = 0; n < CPE_CHANNELS; n++ ) { st_ivas->hCPE[cpe_id]->hCoreCoder[n]->mct_chan_mode = MCT_CHAN_MODE_REGULAR; +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( ( hMCT->num_lfe > 0 ) && ( ( n + cpe_id * CPE_CHANNELS ) == LFE_CHANNEL ) ) { st_ivas->hCPE[cpe_id]->hCoreCoder[n]->mct_chan_mode = MCT_CHAN_MODE_LFE; } +#endif } } /* in case we have an uneven number of transport channels, indicate last channel ID as inactive */ - if ( ( hMCT->nchan_out_woLFE + hMCT->num_lfe ) % 2 ) + if ( ( hMCT->nchan_out_woLFE +#ifndef ISSUE_24_CLEANUP_MCT_LFE + + hMCT->num_lfe +#endif + ) % + 2 ) { st_ivas->hCPE[st_ivas->nCPE - 1]->hCoreCoder[1]->mct_chan_mode = MCT_CHAN_MODE_IGNORE; } @@ -412,10 +526,19 @@ ivas_error mct_enc_reconfigure( st->total_brate = st_ivas->hCPE[cpe_id]->element_brate; - if ( !( ( st->mct_chan_mode == MCT_CHAN_MODE_LFE ) || ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) ) ) + if ( !( +#ifndef ISSUE_24_CLEANUP_MCT_LFE + ( st->mct_chan_mode == MCT_CHAN_MODE_LFE ) || +#endif + ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) ) ) { st->bits_frame_nominal = (int16_t) ( st_ivas->hCPE[cpe_id]->element_brate / FRAMES_PER_SEC ); - st->igf = getIgfPresent( st->element_mode, st->bits_frame_nominal * FRAMES_PER_SEC, st->bwidth, st->rf_mode, st->mct_chan_mode ); + st->igf = getIgfPresent( st->element_mode, st->bits_frame_nominal * FRAMES_PER_SEC, st->bwidth, st->rf_mode +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + st->mct_chan_mode +#endif + ); if ( st->igf ) { IGFEncSetMode( st->hIGFEnc, st_ivas->hCPE[cpe_id]->element_brate, st->bwidth, st->element_mode, st->rf_mode ); @@ -763,10 +886,16 @@ static ivas_error ivas_mc_enc_reconfig( } } - st->igf = getIgfPresent( st->element_mode, st->total_brate, st->bwidth, st->rf_mode, st->mct_chan_mode ); + st->igf = getIgfPresent( st->element_mode, st->total_brate, st->bwidth, st->rf_mode +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + st->mct_chan_mode +#endif + ); /* set last core to TCX20 */ st->last_core = TCX_20_CORE; } +#ifndef ISSUE_24_CLEANUP_MCT_LFE else if ( last_mc_mode == MC_MODE_PARAMMC && st_ivas->mc_mode == MC_MODE_MCT && nchan_transport_old > 2 ) { #ifdef DEBUGGING @@ -774,7 +903,7 @@ static ivas_error ivas_mc_enc_reconfig( #endif st_ivas->hCPE[1]->hCoreCoder[1]->mct_chan_mode = MCT_CHAN_MODE_LFE; } - +#endif 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 ); diff --git a/lib_enc/ivas_mct_enc_mct.c b/lib_enc/ivas_mct_enc_mct.c index ee0c529b8bab2758c7f97463529bc6ee1db12e90..9c0e43caa0291367f263909b8362439b0f5d4c60 100644 --- a/lib_enc/ivas_mct_enc_mct.c +++ b/lib_enc/ivas_mct_enc_mct.c @@ -62,7 +62,11 @@ void getChannelEnergies( for ( ch = 0; ch < nchan; ch++ ) { st = sts[ch]; - if ( st->mct_chan_mode != MCT_CHAN_MODE_IGNORE && st->mct_chan_mode != MCT_CHAN_MODE_LFE ) + if ( st->mct_chan_mode != MCT_CHAN_MODE_IGNORE +#ifndef ISSUE_24_CLEANUP_MCT_LFE + && st->mct_chan_mode != MCT_CHAN_MODE_LFE +#endif + ) { nSubframes = ( st->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV; L_subframe = st->hTcxEnc->L_frameTCX / nSubframes; @@ -156,7 +160,11 @@ static void getCorrelationMatrix( int16_t ch1, ch2, n, nchan; float tmp; - nchan = hMCT->nchan_out_woLFE + hMCT->num_lfe; + nchan = hMCT->nchan_out_woLFE +#ifndef ISSUE_24_CLEANUP_MCT_LFE + + hMCT->num_lfe +#endif + ; /* correlation */ for ( ch1 = 0; ch1 < nchan; ch1++ ) @@ -166,8 +174,12 @@ static void getCorrelationMatrix( xCorrMatrix[ch1][ch2] = 0; 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[ch1]->mct_chan_mode != MCT_CHAN_MODE_LFE && - sts[ch2]->mct_chan_mode != MCT_CHAN_MODE_LFE ) + sts[ch2]->mct_chan_mode != MCT_CHAN_MODE_IGNORE +#ifndef ISSUE_24_CLEANUP_MCT_LFE + && sts[ch1]->mct_chan_mode != MCT_CHAN_MODE_LFE && + sts[ch2]->mct_chan_mode != MCT_CHAN_MODE_LFE +#endif + ) { int16_t nSubframes = ( sts[ch1]->core == TCX_20_CORE ? 1 : NB_DIV ); int16_t L_subframe = sts[ch1]->hTcxEnc->L_frameTCX / nSubframes; @@ -225,9 +237,19 @@ static void getBestCorrelation( *_ch2 = -1; *max_corr = 0.f; - for ( ch1 = 0; ch1 < ( hMCT->nchan_out_woLFE + hMCT->num_lfe ); ch1++ ) + for ( ch1 = 0; ch1 < ( hMCT->nchan_out_woLFE +#ifndef ISSUE_24_CLEANUP_MCT_LFE + + hMCT->num_lfe +#endif + ); + ch1++ ) { - for ( ch2 = ch1 + 1; ch2 < ( hMCT->nchan_out_woLFE + hMCT->num_lfe ); ch2++ ) + for ( ch2 = ch1 + 1; ch2 < ( hMCT->nchan_out_woLFE +#ifndef ISSUE_24_CLEANUP_MCT_LFE + + hMCT->num_lfe +#endif + ); + ch2++ ) { if ( fabsf( *max_corr ) < fabsf( xCorrMatrix[ch1][ch2] ) ) { @@ -308,13 +330,27 @@ static void updateCorrelationMatrix( int16_t ch1, ch2, n; /* correlation: */ - for ( ch1 = 0; ch1 < ( hMCT->nchan_out_woLFE + hMCT->num_lfe ); ch1++ ) + for ( ch1 = 0; ch1 < ( hMCT->nchan_out_woLFE +#ifndef ISSUE_24_CLEANUP_MCT_LFE + + hMCT->num_lfe +#endif + ); + ch1++ ) { - for ( ch2 = ch1; ch2 < ( hMCT->nchan_out_woLFE + hMCT->num_lfe ); ch2++ ) + for ( ch2 = ch1; ch2 < ( hMCT->nchan_out_woLFE +#ifndef ISSUE_24_CLEANUP_MCT_LFE + + hMCT->num_lfe +#endif + ); + ch2++ ) { 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[ch1]->mct_chan_mode != MCT_CHAN_MODE_LFE && - sts[ch2]->mct_chan_mode != MCT_CHAN_MODE_LFE ) + sts[ch2]->mct_chan_mode != MCT_CHAN_MODE_IGNORE +#ifndef ISSUE_24_CLEANUP_MCT_LFE + && sts[ch1]->mct_chan_mode != MCT_CHAN_MODE_LFE && + sts[ch2]->mct_chan_mode != MCT_CHAN_MODE_LFE +#endif + ) { int16_t nSubframes = ( sts[ch1]->core == TCX_20_CORE ? 1 : NB_DIV ); @@ -341,8 +377,11 @@ static void updateCorrelationMatrix( static int16_t channelPairToIndex( const int16_t chIdx1, const int16_t chIdx2, - const int16_t nChannels, + const int16_t nChannels +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , Encoder_State **sts /* i/o: encoder state structure */ +#endif ) { int16_t ch1, ch2; @@ -354,11 +393,12 @@ static int16_t channelPairToIndex( { for ( ch1 = 0; ch1 < ch2; ch1++ ) { +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( sts[ch1]->mct_chan_mode == MCT_CHAN_MODE_LFE || sts[ch2]->mct_chan_mode == MCT_CHAN_MODE_LFE ) { continue; } - +#endif if ( ch1 == chIdx1 && ch2 == chIdx2 ) { return pairIdx; @@ -398,7 +438,11 @@ static void getGlobalILD( /*calculate total energy without LFE*/ for ( ch = 0; ch < nchan; ch++ ) { - if ( sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE && sts[ch]->mct_chan_mode != MCT_CHAN_MODE_LFE ) + if ( sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE +#ifndef ISSUE_24_CLEANUP_MCT_LFE + && sts[ch]->mct_chan_mode != MCT_CHAN_MODE_LFE +#endif + ) { meanE += nrg[ch]; cnt++; @@ -410,7 +454,11 @@ static void getGlobalILD( meanE = max( meanE / cnt, EPSILON ); for ( ch = 0; ch < nchan; ch++ ) { - if ( sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE && sts[ch]->mct_chan_mode != MCT_CHAN_MODE_LFE ) + if ( sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE +#ifndef ISSUE_24_CLEANUP_MCT_LFE + && sts[ch]->mct_chan_mode != MCT_CHAN_MODE_LFE +#endif + ) { nSubframes = ( sts[ch]->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV; L_subframe = sts[ch]->hTcxEnc->L_frameTCX / nSubframes; @@ -483,11 +531,19 @@ void apply_MCT_enc( /*Determine active channels*/ for ( ch = 0; ch < nchan; ch++ ) { - if ( sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE && sts[ch]->mct_chan_mode != MCT_CHAN_MODE_LFE ) + if ( sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE +#ifndef ISSUE_24_CLEANUP_MCT_LFE + && sts[ch]->mct_chan_mode != MCT_CHAN_MODE_LFE +#endif + ) { count_active_ch++; } +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) +#else + else +#endif { hMCT->mc_global_ild[ch] = 0; } @@ -508,8 +564,16 @@ void apply_MCT_enc( { for ( ch1 = 0; ch1 < ch2; ch1++ ) { - if ( sts[ch1]->mct_chan_mode != MCT_CHAN_MODE_IGNORE && sts[ch1]->mct_chan_mode != MCT_CHAN_MODE_LFE && - sts[ch2]->mct_chan_mode != MCT_CHAN_MODE_IGNORE && sts[ch2]->mct_chan_mode != MCT_CHAN_MODE_LFE ) + if ( sts[ch1]->mct_chan_mode != MCT_CHAN_MODE_IGNORE +#ifndef ISSUE_24_CLEANUP_MCT_LFE + && sts[ch1]->mct_chan_mode != MCT_CHAN_MODE_LFE +#endif + && + sts[ch2]->mct_chan_mode != MCT_CHAN_MODE_IGNORE +#ifndef ISSUE_24_CLEANUP_MCT_LFE + && sts[ch2]->mct_chan_mode != MCT_CHAN_MODE_LFE +#endif + ) { sumCorrDiff += fabsf( hMCT->lastxCorrMatrix[ch1][ch2] - xCorrMatrix[ch1][ch2] ); } @@ -600,8 +664,12 @@ void apply_MCT_enc( } /* calculate all related values: */ +#ifndef ISSUE_24_CLEANUP_MCT_LFE assert( sts[ch1]->mct_chan_mode != MCT_CHAN_MODE_IGNORE && sts[ch1]->mct_chan_mode != MCT_CHAN_MODE_LFE && sts[ch2]->mct_chan_mode != MCT_CHAN_MODE_IGNORE && sts[ch2]->mct_chan_mode != MCT_CHAN_MODE_LFE ); +#else + assert( sts[ch1]->mct_chan_mode != MCT_CHAN_MODE_IGNORE && sts[ch2]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ); +#endif getBlockValues( sts, ch1, ch2, hMCT->hBlockData[currBlockDataCnt], mdst_spectrum, inv_spectrum, inv_mdst_spectrum ); @@ -686,7 +754,11 @@ void apply_MCT_enc( for ( ch = 0; ch < nchan; ch++ ) { - if ( sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE && sts[ch]->mct_chan_mode != MCT_CHAN_MODE_LFE ) + if ( sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE +#ifndef ISSUE_24_CLEANUP_MCT_LFE + && sts[ch]->mct_chan_mode != MCT_CHAN_MODE_LFE +#endif + ) { if ( ( !cpEle[ch] ) || hMCT->currBlockDataCnt == 0 ) { @@ -771,7 +843,11 @@ void write_mct_bitstream( /* first write core info and overlap mode for all channels */ for ( ch = 0; ch < nchan; ch++ ) { - if ( ( sts[ch]->mct_chan_mode != MCT_CHAN_MODE_LFE ) && hMCT->currBlockDataCnt && sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) + if ( +#ifndef ISSUE_24_CLEANUP_MCT_LFE + ( sts[ch]->mct_chan_mode != MCT_CHAN_MODE_LFE ) && +#endif + hMCT->currBlockDataCnt && sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) { push_next_indice( hBstr, hMCT->mc_global_ild[ch], SMDCT_GLOBAL_ILD_BITS ); } @@ -781,7 +857,11 @@ void write_mct_bitstream( { for ( ch = 0; ch < nchan; ch++ ) { - if ( sts[ch]->mct_chan_mode != MCT_CHAN_MODE_LFE && sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) + if ( +#ifndef ISSUE_24_CLEANUP_MCT_LFE + sts[ch]->mct_chan_mode != MCT_CHAN_MODE_LFE && +#endif + sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) { push_next_indice( hBstr, hMCT->lowE_ch[ch], 1 ); } @@ -794,7 +874,12 @@ void write_mct_bitstream( hBlock = hMCT->hBlockData[pair]; /*calculate channel pair index and write it to BS*/ - channelPairIndex = channelPairToIndex( hBlock->ch1, hBlock->ch2, nchan, sts ); + channelPairIndex = channelPairToIndex( hBlock->ch1, hBlock->ch2, nchan +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + sts +#endif + ); push_next_indice( hBstr, channelPairIndex, hMCT->bitsChannelPairIndex ); /*point to encoder states of actual channels to write block pair bits*/ @@ -838,7 +923,11 @@ void mctStereoIGF_enc( int16_t singleChEle[MCT_MAX_CHANNELS]; L_subframeTCX = 0; /* to avoid compilation warning */ - set_s( singleChEle, 1, hMCT->nchan_out_woLFE + hMCT->num_lfe ); + set_s( singleChEle, 1, hMCT->nchan_out_woLFE +#ifndef ISSUE_24_CLEANUP_MCT_LFE + + hMCT->num_lfe +#endif + ); for ( b = 0; b < hMCT->currBlockDataCnt; b++ ) { @@ -889,15 +978,28 @@ void mctStereoIGF_enc( } /* channel elements that are coded separately detected */ - if ( sum_s( singleChEle, ( hMCT->nchan_out_woLFE + hMCT->num_lfe ) ) != 0 ) + if ( sum_s( singleChEle, ( hMCT->nchan_out_woLFE +#ifndef ISSUE_24_CLEANUP_MCT_LFE + + hMCT->num_lfe +#endif + ) ) != 0 ) { - for ( ch = 0; ch < ( hMCT->nchan_out_woLFE + hMCT->num_lfe ); ch++ ) + for ( ch = 0; ch < ( hMCT->nchan_out_woLFE +#ifndef ISSUE_24_CLEANUP_MCT_LFE + + hMCT->num_lfe +#endif + ); + ch++ ) { if ( singleChEle[ch] ) { st = sts[ch]; - if ( st->mct_chan_mode == MCT_CHAN_MODE_LFE || st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) + if ( +#ifndef ISSUE_24_CLEANUP_MCT_LFE + st->mct_chan_mode == MCT_CHAN_MODE_LFE || +#endif + st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) { continue; } diff --git a/lib_enc/ivas_mdct_core_enc.c b/lib_enc/ivas_mdct_core_enc.c index ef9264d5df2feffbad446ea5bf010bb368a1f64d..62223d9005a36bf4c4b827bd5ce1cab72dc9c556 100755 --- a/lib_enc/ivas_mdct_core_enc.c +++ b/lib_enc/ivas_mdct_core_enc.c @@ -88,16 +88,19 @@ static void enc_prm_pre_mdct( { writeTCXWindowing( hBstr, st->hTcxCfg->tcx_last_overlap_mode ); } - +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( st->element_mode == IVAS_CPE_MDCT && st->mct_chan_mode != MCT_CHAN_MODE_LFE ) { +#endif push_next_indice( hBstr, st->hTcxEnc->kernel_type[0], st->last_core != ACELP_CORE ? 2 : 1 ); if ( st->core == TCX_10_CORE ) { assert( ( st->hTcxEnc->kernel_type[0] & 1 ) == ( st->hTcxEnc->kernel_type[1] >> 1 ) ); push_next_indice( hBstr, st->hTcxEnc->kernel_type[1] & 1, 1 ); } +#ifndef ISSUE_24_CLEANUP_MCT_LFE } +#endif st->glr_reset = 0; #ifdef DEBUG_PLOT_BITS @@ -288,7 +291,12 @@ static void kernel_switch_update_transforms( int16_t i, leftOverlap = 0, rightOverlap = 0; const float *left_win, *right_win; - tcx_get_windows( hTcxCfg, (int16_t) windowedTimeSignal[0], (int16_t) windowedTimeSignal[1], &leftOverlap, &left_win, &rightOverlap, &right_win, 1, 0 ); + tcx_get_windows( hTcxCfg, (int16_t) windowedTimeSignal[0], (int16_t) windowedTimeSignal[1], &leftOverlap, &left_win, &rightOverlap, &right_win, 1 +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + 0 +#endif + ); if ( speech_TCX != NULL && tcxTransType != TCX_20 && (int16_t) windowedTimeSignal[0] == FULL_OVERLAP && s - leftOverlap > minWindowLen ) { for ( i = minWindowLen; i >= 0; i-- ) /* outer left folding of shortened long ALDO slope */ @@ -311,7 +319,12 @@ static void kernel_switch_update_transforms( s = hTcxCfg->tcx5SizeFB; /* obtain 1st TCX5 again */ nSubframes *= 2; - WindowSignal( hTcxCfg, leftOverlap / 2, RECTANGULAR_OVERLAP, MIN_OVERLAP, &leftOverlap, &rightOverlap, windowedTimeSignal + 2, &s, tcx5Win, 0, 1, 0 ); + WindowSignal( hTcxCfg, leftOverlap / 2, RECTANGULAR_OVERLAP, MIN_OVERLAP, &leftOverlap, &rightOverlap, windowedTimeSignal + 2, &s, tcx5Win, 0, 1 +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + 0 +#endif + ); kernel_switch_trafo( tcx5Win, sigR, leftOverlap, s /* L_subfr. */ - ( leftOverlap + rightOverlap ) / 2, rightOverlap, kernelType ); if ( kernelType & 1 ) /* 2nd TCX5 is kernelType 3 */ @@ -576,9 +589,11 @@ void ivas_mdct_core_whitening_enc( int16_t tnsSize[CPE_CHANNELS][NB_DIV], /* o : number of tns parameters put into prm */ int16_t p_param[CPE_CHANNELS][NB_DIV], /* o : pointer to the parameter table */ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - int16_t *LFE_off, /* o : flag if LFE has zero content */ - const int16_t mct_on, /* i : flag mct block (1) or stereo (0) */ - const int16_t nChannels /* i : total number of coded channels */ +#ifndef ISSUE_24_CLEANUP_MCT_LFE + int16_t *LFE_off, /* o : flag if LFE has zero content */ +#endif + const int16_t mct_on, /* i : flag mct block (1) or stereo (0) */ + const int16_t nChannels /* i : total number of coded channels */ ) { int16_t n, ch, nSubframes, L_subframe, L_subframeTCX, tcx_subframe_coded_lines; @@ -612,10 +627,14 @@ void ivas_mdct_core_whitening_enc( for ( ch = 0; ch < CPE_CHANNELS; ch++ ) { +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( sts[ch]->mct_chan_mode != MCT_CHAN_MODE_LFE ) { +#endif stereo_tcx_init_enc( sts[ch] ); +#ifndef ISSUE_24_CLEANUP_MCT_LFE } +#endif set_s( tnsSize[ch], 0, 2 ); set_s( tnsBits[ch], 0, 2 ); @@ -655,10 +674,14 @@ void ivas_mdct_core_whitening_enc( for ( ch = 0; ch < CPE_CHANNELS; ch++ ) { st = sts[ch]; +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( st->mct_chan_mode != MCT_CHAN_MODE_LFE ) { +#endif SetTCXModeInfo( st, st->hTranDet, &st->hTcxCfg->tcx_curr_overlap_mode ); +#ifndef ISSUE_24_CLEANUP_MCT_LFE } +#endif } } @@ -672,12 +695,14 @@ void ivas_mdct_core_whitening_enc( for ( ch = 0; ch < CPE_CHANNELS; ch++ ) { st = sts[ch]; - +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( st->mct_chan_mode == MCT_CHAN_MODE_LFE ) +#else + if ( ( hCPE->cpe_id * CPE_CHANNELS + ch ) >= nChannels ) +#endif { continue; } - SetCurrentPsychParams( st->core, 0, st->hTcxCfg ); /* tcx ltp analysis on the 12.8kHz weighted speech, saves preproc resampling to sr_core */ @@ -689,13 +714,21 @@ void ivas_mdct_core_whitening_enc( #ifndef FIX_MDCT_BASED_BWD if ( st->hTcxEnc->transform_type[0] == TCX_20 && st->hTcxCfg->tcx_last_overlap_mode != TRANSITION_OVERLAP ) { +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( st->mct_chan_mode != MCT_CHAN_MODE_LFE ) +#else + if ( st->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) +#endif { bw_detect( st, NULL, st->hTcxEnc->spectrum[0], NULL ); } } #else +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( st->mct_chan_mode != MCT_CHAN_MODE_LFE && st->hTcxCfg->tcx_last_overlap_mode != TRANSITION_OVERLAP ) +#else + if ( st->hTcxCfg->tcx_last_overlap_mode != TRANSITION_OVERLAP ) +#endif { nSubframes = ( st->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV; @@ -820,7 +853,11 @@ void ivas_mdct_core_whitening_enc( { TCX_ENC_HANDLE hTcxEncCh = sts[ch]->hTcxEnc; - if ( ( hCPE->cpe_id * CPE_CHANNELS + ch ) >= nChannels || sts[ch]->mct_chan_mode == MCT_CHAN_MODE_LFE ) + if ( ( hCPE->cpe_id * CPE_CHANNELS + ch ) >= nChannels +#ifndef ISSUE_24_CLEANUP_MCT_LFE + || sts[ch]->mct_chan_mode == MCT_CHAN_MODE_LFE +#endif + ) { hTcxEncCh->kernel_symmetry_past = hTcxEncCh->kernel_type[0] = 0; @@ -849,7 +886,11 @@ void ivas_mdct_core_whitening_enc( for ( ch = 0; ch < CPE_CHANNELS; ch++ ) { - if ( ( hCPE->cpe_id * CPE_CHANNELS + ch ) >= nChannels || sts[ch]->mct_chan_mode == MCT_CHAN_MODE_LFE ) + if ( ( hCPE->cpe_id * CPE_CHANNELS + ch ) >= nChannels +#ifndef ISSUE_24_CLEANUP_MCT_LFE + || sts[ch]->mct_chan_mode == MCT_CHAN_MODE_LFE +#endif + ) { continue; } @@ -894,7 +935,11 @@ void ivas_mdct_core_whitening_enc( } /* MCT: detect whether there are silent channels and set mct_chan_mode accordingly */ - if ( st->mct_chan_mode != MCT_CHAN_MODE_LFE && mct_on ) + if ( +#ifndef ISSUE_24_CLEANUP_MCT_LFE + st->mct_chan_mode != MCT_CHAN_MODE_LFE && +#endif + mct_on ) { chE_tot = sum_f( chE, NB_DIV ); @@ -911,7 +956,11 @@ void ivas_mdct_core_whitening_enc( } /* set low br mode, if possible. Can later be discarded, depending on the stereo mode used for SNS parameter decoding */ - if ( hCPE->element_brate == IVAS_48k && !( ( sts[0]->core == TCX_20 && sts[1]->core == TCX_20 ) || sts[1]->mct_chan_mode == MCT_CHAN_MODE_LFE ) ) + if ( hCPE->element_brate == IVAS_48k && !( ( sts[0]->core == TCX_20 && sts[1]->core == TCX_20 ) +#ifndef ISSUE_24_CLEANUP_MCT_LFE + || sts[1]->mct_chan_mode == MCT_CHAN_MODE_LFE +#endif + ) ) { sns_low_br_mode = !sts[0]->sp_aud_decision0; } @@ -938,7 +987,11 @@ void ivas_mdct_core_whitening_enc( for ( ch = 0; ch < CPE_CHANNELS; ch++ ) { param_lpc[ch][0] = ch; - if ( sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE || sts[ch]->mct_chan_mode == MCT_CHAN_MODE_LFE ) + if ( sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE +#ifndef ISSUE_24_CLEANUP_MCT_LFE + || sts[ch]->mct_chan_mode == MCT_CHAN_MODE_LFE +#endif + ) { continue; } @@ -961,7 +1014,11 @@ void ivas_mdct_core_whitening_enc( for ( ch = 0; ch < CPE_CHANNELS; ch++ ) { - if ( sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE || sts[ch]->mct_chan_mode == MCT_CHAN_MODE_LFE ) + if ( sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE +#ifndef ISSUE_24_CLEANUP_MCT_LFE + || sts[ch]->mct_chan_mode == MCT_CHAN_MODE_LFE +#endif + ) { continue; } @@ -989,7 +1046,11 @@ void ivas_mdct_core_whitening_enc( /* first deinterleave once more */ for ( ch = 0; ch < CPE_CHANNELS; ch++ ) { - if ( sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE || sts[ch]->mct_chan_mode == MCT_CHAN_MODE_LFE ) + if ( sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE +#ifndef ISSUE_24_CLEANUP_MCT_LFE + || sts[ch]->mct_chan_mode == MCT_CHAN_MODE_LFE +#endif + ) { continue; } @@ -1010,7 +1071,11 @@ void ivas_mdct_core_whitening_enc( for ( ch = 0; ch < CPE_CHANNELS; ch++ ) { - if ( sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE || sts[ch]->mct_chan_mode == MCT_CHAN_MODE_LFE ) + if ( sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE +#ifndef ISSUE_24_CLEANUP_MCT_LFE + || sts[ch]->mct_chan_mode == MCT_CHAN_MODE_LFE +#endif + ) { continue; } @@ -1032,8 +1097,9 @@ void ivas_mdct_core_whitening_enc( } } } - - /*check whether LFE channel is active*/ +#ifndef ISSUE_24_CLEANUP_MCT_LFE +/*check whether LFE channel is active*/ +#endif for ( ch = 0; ch < CPE_CHANNELS; ch++ ) { /*no need to write last channel bit in case of odd channels*/ @@ -1046,12 +1112,15 @@ void ivas_mdct_core_whitening_enc( if ( mct_on ) /* signal bits should be written only for MCT*/ { +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( st->mct_chan_mode == MCT_CHAN_MODE_LFE ) { assert( *LFE_off == 1 ); push_next_indice( hBstr, *LFE_off, 1 ); } - else if ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) + else +#endif + if ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) { push_next_indice( hBstr, 1, 1 ); } @@ -1068,7 +1137,11 @@ void ivas_mdct_core_whitening_enc( { st = sts[ch]; - if ( ( st->mct_chan_mode == MCT_CHAN_MODE_LFE && ( *LFE_off ) ) || ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) ) +#ifndef ISSUE_24_CLEANUP_MCT_LFE + if ( ( st->mct_chan_mode == MCT_CHAN_MODE_LFE && ( LFE_off ) ) || ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) ) +#else + if ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) +#endif { st->side_bits_frame_channel = 0; /*dummy initialization to prevent range coder crashing in case all channels are silent and bits are distributed to channel 0 */ @@ -1113,7 +1186,11 @@ void ivas_mdct_core_whitening_enc( { st = sts[ch]; - if ( ( st->mct_chan_mode == MCT_CHAN_MODE_LFE && ( *LFE_off ) ) || ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) ) +#ifndef ISSUE_24_CLEANUP_MCT_LFE + if ( ( st->mct_chan_mode == MCT_CHAN_MODE_LFE && ( LFE_off ) ) || ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) ) +#else + if ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) +#endif { skipped_first_channel = 1; continue; @@ -1127,7 +1204,11 @@ void ivas_mdct_core_whitening_enc( { push_next_indice( hBstr, param_lpc[0][0] >> 1, 1 ); - if ( st->element_brate == IVAS_48k && !( ( sts[0]->core == TCX_20 && sts[1]->core == TCX_20 ) || sts[1]->mct_chan_mode == MCT_CHAN_MODE_LFE ) ) + if ( st->element_brate == IVAS_48k && !( ( sts[0]->core == TCX_20 && sts[1]->core == TCX_20 ) +#ifndef ISSUE_24_CLEANUP_MCT_LFE + || sts[1]->mct_chan_mode == MCT_CHAN_MODE_LFE +#endif + ) ) { /* write classifier decision to signal low br mode for SNS encoding, for all other configs, low_br mode is not possible */ push_next_indice( hBstr, sns_low_br_mode, 1 ); @@ -1142,7 +1223,11 @@ void ivas_mdct_core_whitening_enc( for ( ch = 0; ch < CPE_CHANNELS; ch++ ) { st = sts[ch]; +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( ( st->mct_chan_mode == MCT_CHAN_MODE_LFE && ( *LFE_off ) ) || ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) ) +#else + if ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) +#endif { continue; } @@ -1168,8 +1253,10 @@ void ivas_mdct_core_whitening_enc( *---------------------------------------------------------------*/ void ivas_mdct_quant_coder( - CPE_ENC_HANDLE hCPE, /* i/o: Encoder CPE handle */ - const int16_t LFE_off, /* i : flag if LFE is inactive */ + CPE_ENC_HANDLE hCPE, /* i/o: Encoder CPE handle */ +#ifndef ISSUE_24_CLEANUP_MCT_LFE + const int16_t LFE_off, /* i : flag if LFE is inactive */ +#endif int16_t tnsBits[CPE_CHANNELS][NB_DIV], /* i : bits needed for TNS parameters */ int16_t tnsSize[CPE_CHANNELS][NB_DIV], /* i : size of TNS */ int16_t p_param[CPE_CHANNELS][NB_DIV], /* i : pointer to parameter array */ @@ -1215,7 +1302,11 @@ void ivas_mdct_quant_coder( st = sts[ch]; - if ( ( st->mct_chan_mode == MCT_CHAN_MODE_LFE && LFE_off ) || ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) ) +#ifndef ISSUE_24_CLEANUP_MCT_LFE + if ( ( st->mct_chan_mode == MCT_CHAN_MODE_LFE && ( LFE_off ) ) || ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) ) +#else + if ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) +#endif { ignore_chan[ch] = 1; continue; @@ -1275,7 +1366,11 @@ void ivas_mdct_quant_coder( { st = sts[ch]; - if ( ( st->mct_chan_mode == MCT_CHAN_MODE_LFE && LFE_off ) || ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) ) +#ifndef ISSUE_24_CLEANUP_MCT_LFE + if ( ( st->mct_chan_mode == MCT_CHAN_MODE_LFE && ( LFE_off ) ) || ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) ) +#else + if ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) +#endif { /*Enable appropriate upadte of tcx_curr_overlap_mode even for uncoded channel index 1*/ L_frameTCX[ch][0] = ( st->core == TCX_10_CORE ) ? st->hTcxEnc->L_frameTCX >> 1 : st->hTcxEnc->L_frameTCX; @@ -1302,7 +1397,11 @@ void ivas_mdct_quant_coder( * Generate Bitstream *---------------------------------------------------------------*/ - if ( ( ( st->mct_chan_mode == MCT_CHAN_MODE_LFE ) && LFE_off ) || ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) ) +#ifndef ISSUE_24_CLEANUP_MCT_LFE + if ( ( st->mct_chan_mode == MCT_CHAN_MODE_LFE && ( LFE_off ) ) || ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) ) +#else + if ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) +#endif { continue; } diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index 868c31ffe0d2bb58002ba0158bca0c85cf70882f..6638a8948893cd39c5278f7d59122448c75a1237 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -941,11 +941,14 @@ typedef struct mct_enc_data_structure float lastxCorrMatrix[MCT_MAX_CHANNELS][MCT_MAX_CHANNELS]; int16_t lowE_ch[MCT_MAX_CHANNELS]; +#ifndef ISSUE_24_CLEANUP_MCT_LFE int16_t LFE_off; +#endif uint16_t mc_global_ild[MCT_MAX_CHANNELS]; int16_t nBitsMCT; /* number of bits spent on mct side info */ +#ifndef ISSUE_24_CLEANUP_MCT_LFE int16_t num_lfe; - +#endif /* pointers to local buffers */ float *p_mdst_spectrum_long[MCT_MAX_BLOCKS][CPE_CHANNELS]; float *p_orig_spectrum_long[MCT_MAX_BLOCKS][CPE_CHANNELS]; diff --git a/lib_enc/ivas_stereo_mdct_core_enc.c b/lib_enc/ivas_stereo_mdct_core_enc.c index 9500da4fb9d21b5e7181d2349306a66fc5e46774..fa9b108f0075e489fd36560a78baaf2b5a978777 100644 --- a/lib_enc/ivas_stereo_mdct_core_enc.c +++ b/lib_enc/ivas_stereo_mdct_core_enc.c @@ -235,7 +235,11 @@ void stereo_mdct_core_enc( *---------------------------------------------------------------*/ ivas_mdct_core_whitening_enc( hCPE, new_samples, old_wsp, pitch_buf, p_mdst_spectrum_long, - tnsBits, p_orig_spectrum_long, tnsSize, p_param, hBstr, NULL, 0, CPE_CHANNELS ); + tnsBits, p_orig_spectrum_long, tnsSize, p_param, hBstr, +#ifndef ISSUE_24_CLEANUP_MCT_LFE + NULL, +#endif + 0, CPE_CHANNELS ); for ( ch = 0; ch < CPE_CHANNELS; ch++ ) { @@ -449,7 +453,11 @@ void stereo_mdct_core_enc( } #endif - ivas_mdct_quant_coder( hCPE, 0, tnsBits, tnsSize, p_param, 0 ); + ivas_mdct_quant_coder( hCPE, +#ifndef ISSUE_24_CLEANUP_MCT_LFE + 0, +#endif + tnsBits, tnsSize, p_param, 0 ); pop_wmops(); diff --git a/lib_enc/ivas_stereo_switching_enc.c b/lib_enc/ivas_stereo_switching_enc.c index 1be9af224e8341d63fbfbfd1763d3d8820fd2519..0e6fe1496bd03ad3d770befe24a51544b18b4b77 100644 --- a/lib_enc/ivas_stereo_switching_enc.c +++ b/lib_enc/ivas_stereo_switching_enc.c @@ -526,7 +526,12 @@ ivas_error stereo_memory_enc( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hIGFEnc\n" ) ); } - st->igf = getIgfPresent( st->element_mode, st->total_brate, st->bwidth, st->rf_mode, st->mct_chan_mode ); + st->igf = getIgfPresent( st->element_mode, st->total_brate, st->bwidth, st->rf_mode +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + st->mct_chan_mode +#endif + ); /* allocate and initialize MDCT stereo structure */ if ( ( hCPE->hStereoMdct = (STEREO_MDCT_ENC_DATA_HANDLE) malloc( sizeof( STEREO_MDCT_ENC_DATA ) ) ) == NULL ) diff --git a/lib_enc/ivas_tcx_core_enc.c b/lib_enc/ivas_tcx_core_enc.c index 40a97cc33e712c50fed8ea33204153e82bd57c03..3bda423fadd1f51d543cb07329a919f807e8f044 100644 --- a/lib_enc/ivas_tcx_core_enc.c +++ b/lib_enc/ivas_tcx_core_enc.c @@ -99,10 +99,20 @@ void stereo_tcx_init_enc( st->hTcxCfg->ctx_hm = getCtxHm( st->element_mode, st->bits_frame_nominal * FRAMES_PER_SEC, st->rf_mode ); st->hTcxCfg->resq = getResq( st->bits_frame_nominal * FRAMES_PER_SEC ); st->hTcxEnc->tcx_lpc_shaped_ari = getTcxLpcShapedAri( st->bits_frame_nominal * FRAMES_PER_SEC, st->rf_mode, st->element_mode ); - st->igf = getIgfPresent( st->element_mode, st->bits_frame_nominal * FRAMES_PER_SEC, st->bwidth, st->rf_mode, st->mct_chan_mode ); + st->igf = getIgfPresent( st->element_mode, st->bits_frame_nominal * FRAMES_PER_SEC, st->bwidth, st->rf_mode +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + st->mct_chan_mode +#endif + ); if ( st->element_mode != EVS_MONO ) { - st->hTcxCfg->fIsTNSAllowed = getTnsAllowed( st->bits_frame_nominal * FRAMES_PER_SEC, st->igf, st->element_mode, st->mct_chan_mode ); + st->hTcxCfg->fIsTNSAllowed = getTnsAllowed( st->bits_frame_nominal * FRAMES_PER_SEC, st->igf, st->element_mode +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + st->mct_chan_mode +#endif + ); } st->core_brate = st->total_brate; diff --git a/lib_enc/pre_proc.c b/lib_enc/pre_proc.c index bbeba48a1649f2ad69b4be4ef38cb45a7b6be101..feb0df75ca24bd5feabfe8006d6ce07b51746384 100755 --- a/lib_enc/pre_proc.c +++ b/lib_enc/pre_proc.c @@ -621,7 +621,12 @@ void pre_proc( st->gamma = GAMMA16k; } - st->igf = getIgfPresent( EVS_MONO, st->total_brate, st->bwidth, st->rf_mode, MCT_CHAN_MODE_REGULAR ); /* TBV: needs checking */ + st->igf = getIgfPresent( EVS_MONO, st->total_brate, st->bwidth, st->rf_mode +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + MCT_CHAN_MODE_REGULAR +#endif + ); } st->coder_type = st->coder_type_raw; diff --git a/lib_enc/transient_detection.c b/lib_enc/transient_detection.c index 91106686c091fe908b9fd9955a479335c6a42963..83f9e2e7a09e26353b7a8ded866256d33fae89d4 100644 --- a/lib_enc/transient_detection.c +++ b/lib_enc/transient_detection.c @@ -324,17 +324,18 @@ void SetTCXModeInfo( hTcxEnc->tcxMode = NO_TCX; } } - +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( st->mct_chan_mode == MCT_CHAN_MODE_LFE ) { hTcxEnc->tcxMode = TCX_20; *tcxModeOverlap = FULL_OVERLAP; st->hTcxCfg->tcx_last_overlap_mode = st->hTcxCfg->tcx_curr_overlap_mode; } - - +#endif +#ifndef ISSUE_24_CLEANUP_MCT_LFE if ( st->mct_chan_mode != MCT_CHAN_MODE_LFE ) { +#endif /* set the left window overlap */ if ( st->last_core == ACELP_CORE || st->last_core == AMR_WB_CORE ) { @@ -403,7 +404,9 @@ void SetTCXModeInfo( hTcxEnc->tfm_mem = 0.75f; } } +#ifndef ISSUE_24_CLEANUP_MCT_LFE } +#endif /* for the ACELP -> TCX transition frames use full right window overlap */ if ( ( st->hTcxCfg->tcx_last_overlap_mode == TRANSITION_OVERLAP ) && ( *tcxModeOverlap == ALDO_WINDOW ) ) diff --git a/lib_enc/updt_enc.c b/lib_enc/updt_enc.c index cc2d5fce36637a9b754806d76706c54bb838f73f..b194de06d5d117483e8b0b3e936a878d8866298a 100644 --- a/lib_enc/updt_enc.c +++ b/lib_enc/updt_enc.c @@ -408,7 +408,12 @@ void updt_enc_common( st->gamma = GAMMA16k; } - st->igf = getIgfPresent( EVS_MONO, st->total_brate, st->bwidth, st->rf_mode, MCT_CHAN_MODE_REGULAR ); + st->igf = getIgfPresent( EVS_MONO, st->total_brate, st->bwidth, st->rf_mode +#ifndef ISSUE_24_CLEANUP_MCT_LFE + , + MCT_CHAN_MODE_REGULAR +#endif + ); } /* update FER clas */