From 13d7dce233ffc71317ce90b1b54254c7656edfc5 Mon Sep 17 00:00:00 2001 From: rhb Date: Fri, 30 Sep 2022 12:13:00 +0200 Subject: [PATCH 1/2] reduce dynamic RAM consumption in MCT IGF --- lib_com/options.h | 2 +- lib_com/prot.h | 8 ++++++++ lib_enc/igf_enc.c | 4 ++++ lib_enc/ivas_mct_enc_mct.c | 9 +++++++++ lib_enc/ivas_stereo_mdct_core_enc.c | 9 +++++++++ lib_enc/tcx_utils_enc.c | 4 ++++ 6 files changed, 35 insertions(+), 1 deletion(-) mode change 100644 => 100755 lib_com/options.h mode change 100644 => 100755 lib_com/prot.h mode change 100644 => 100755 lib_enc/igf_enc.c mode change 100644 => 100755 lib_enc/ivas_mct_enc_mct.c mode change 100644 => 100755 lib_enc/ivas_stereo_mdct_core_enc.c mode change 100644 => 100755 lib_enc/tcx_utils_enc.c diff --git a/lib_com/options.h b/lib_com/options.h old mode 100644 new mode 100755 index 3c30e33d86..b0c3079cd5 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -150,7 +150,7 @@ #define ALIGN_SID_SIZE /* Issue 111: make all DTX modes use one SID frame bitrate (5.2 kbps) */ #define FIX_135_MDCT_STEREO_MODE_UNINITIALIZED /* Issue 135: fix uninitialized value usage in SBA MDCT-Stereo core with PLC */ - +#define DRAM_REDUCTION_MCT_IGF /* Issue 121: reduce dynamic RAM consumption in MCT IGF */ /* ################## End DEVELOPMENT switches ######################### */ diff --git a/lib_com/prot.h b/lib_com/prot.h old mode 100644 new mode 100755 index f793d75bb7..1d3b55633c --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -7396,7 +7396,11 @@ void ProcessStereoIGF( Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */ int16_t ms_mask[2][MAX_SFB], /* i : bandwise MS mask */ float *pITFMDCTSpectrum[CPE_CHANNELS][2], /* i : MDCT spectrum fir ITF */ +#ifdef DRAM_REDUCTION_MCT_IGF + float *pPowerSpectrum[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ +#else float pPowerSpectrum[CPE_CHANNELS][N_MAX], /* i : MDCT^2 + MDST^2 spectrum, or estimate */ +#endif float *pPowerSpectrumMsInv[CPE_CHANNELS][2], /* i : inverse power spectrum */ float *inv_spectrum[CPE_CHANNELS][2], /* i : inverse spectrum */ const int16_t frameno, /* i : flag indicating index of current subframe*/ @@ -9794,7 +9798,11 @@ void IGFEncApplyStereo( const IGF_ENC_INSTANCE_HANDLE hIGFEnc[CPE_CHANNELS], /* i : instance handle of IGF Encoder */ const int16_t igfGridIdx, /* i : IGF grid index */ Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */ +#ifdef DRAM_REDUCTION_MCT_IGF + float *pPowerSpectrum[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ +#else float pPowerSpectrum[CPE_CHANNELS][N_MAX], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ +#endif float *pPowerSpectrumMsInv[CPE_CHANNELS][2], /* i/o: inverse power spectrum */ float *inv_spectrum[CPE_CHANNELS][2], /* i : inverse spectrum */ const int16_t frameno, /* i : flag indicating index of current subframe */ diff --git a/lib_enc/igf_enc.c b/lib_enc/igf_enc.c old mode 100644 new mode 100755 index 2cf98207bb..ac69fa2ed8 --- a/lib_enc/igf_enc.c +++ b/lib_enc/igf_enc.c @@ -1852,7 +1852,11 @@ void IGFEncApplyStereo( const IGF_ENC_INSTANCE_HANDLE hIGFEnc[CPE_CHANNELS], /* i : instance handle of IGF Encoder */ const int16_t igfGridIdx, /* i : IGF grid index */ Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */ +#ifdef DRAM_REDUCTION_MCT_IGF + float *pPowerSpectrum[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ +#else float pPowerSpectrum[CPE_CHANNELS][N_MAX], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ +#endif float *pPowerSpectrumMsInv[CPE_CHANNELS][2], /* i/o: inverse power spectrum */ float *inv_spectrum[CPE_CHANNELS][2], /* i : inverse spectrum */ const int16_t frameno, /* i : flag indicating index of current subfr. */ diff --git a/lib_enc/ivas_mct_enc_mct.c b/lib_enc/ivas_mct_enc_mct.c old mode 100644 new mode 100755 index 62ff9be888..309a023fe7 --- a/lib_enc/ivas_mct_enc_mct.c +++ b/lib_enc/ivas_mct_enc_mct.c @@ -834,7 +834,11 @@ void mctStereoIGF_enc( float *p_powerSpecMsInv[CPE_CHANNELS][NB_DIV]; float *p_inv_spectrum[CPE_CHANNELS][NB_DIV]; float *p_orig_spectrum[CPE_CHANNELS][NB_DIV]; +#ifdef DRAM_REDUCTION_MCT_IGF + float *p_powerSpec[NB_DIV]; +#else float p_powerSpec[NB_DIV][N_MAX]; +#endif int16_t singleChEle[MCT_MAX_CHANNELS]; L_subframeTCX = 0; /* to avoid compilation warning */ @@ -855,10 +859,15 @@ void mctStereoIGF_enc( p_st[0] = sts[ch1]; p_st[1] = sts[ch2]; +#ifdef DRAM_REDUCTION_MCT_IGF + p_powerSpec[0] = powerSpec[ch1]; + p_powerSpec[1] = powerSpec[ch2]; +#else mvr2r( powerSpec[ch1], p_powerSpec[0], L_FRAME48k ); set_f( &p_powerSpec[0][L_FRAME48k], 0.f, N_MAX - L_FRAME48k ); mvr2r( powerSpec[ch2], p_powerSpec[1], L_FRAME48k ); set_f( &p_powerSpec[1][L_FRAME48k], 0.f, N_MAX - L_FRAME48k ); +#endif /* Band-wise M/S for MDST */ nSubframes = p_st[0]->hTcxEnc->tcxMode == TCX_20 ? 1 : NB_DIV; diff --git a/lib_enc/ivas_stereo_mdct_core_enc.c b/lib_enc/ivas_stereo_mdct_core_enc.c old mode 100644 new mode 100755 index c41df7b24e..664998967c --- a/lib_enc/ivas_stereo_mdct_core_enc.c +++ b/lib_enc/ivas_stereo_mdct_core_enc.c @@ -129,6 +129,9 @@ void stereo_mdct_core_enc( float *p_orig_spectrum_long[CPE_CHANNELS], orig_spectrum_long[CPE_CHANNELS][N_MAX]; /* MDCT output (L/R). */ float *orig_spectrum[CPE_CHANNELS][2]; /* Pointers to MDCT output for a short block (L/R) */ float powerSpec[CPE_CHANNELS][N_MAX]; +#ifdef DRAM_REDUCTION_MCT_IGF + float *p_powerSpec[CPE_CHANNELS]; +#endif float powerSpecMsInv_long[CPE_CHANNELS][N_MAX]; /* MS inv power spectrum, also inverse MDST spectrum */ float *powerSpecMsInv[CPE_CHANNELS][2]; float quantized_spectrum_long[CPE_CHANNELS][N_MAX]; /* quantized MDCT spectrum, inv ms mask mdst spectrum, scratch for MS spectra in the MS decision */ @@ -351,7 +354,13 @@ void stereo_mdct_core_enc( hStereoMdct->mdct_stereo_mode[n] == SMDCT_BW_MS ) && !hStereoMdct->isSBAStereoMode ) { +#ifdef DRAM_REDUCTION_MCT_IGF + p_powerSpec[0] = powerSpec[0]; + p_powerSpec[1] = powerSpec[1]; + ProcessStereoIGF( hStereoMdct, sts, ms_mask, orig_spectrum, p_powerSpec, powerSpecMsInv, inv_spectrum, n, hCPE->hCoreCoder[0]->sp_aud_decision0, hCPE->hCoreCoder[0]->element_brate, 0 ); +#else ProcessStereoIGF( hStereoMdct, sts, ms_mask, orig_spectrum, powerSpec, powerSpecMsInv, inv_spectrum, n, hCPE->hCoreCoder[0]->sp_aud_decision0, hCPE->hCoreCoder[0]->element_brate, 0 ); +#endif } else { diff --git a/lib_enc/tcx_utils_enc.c b/lib_enc/tcx_utils_enc.c old mode 100644 new mode 100755 index ca88663355..6ced5b3f94 --- a/lib_enc/tcx_utils_enc.c +++ b/lib_enc/tcx_utils_enc.c @@ -1509,7 +1509,11 @@ void ProcessStereoIGF( Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */ int16_t ms_mask[2][MAX_SFB], /* i : bandwise MS mask */ float *pITFMDCTSpectrum[CPE_CHANNELS][2], /* i : MDCT spectrum fir ITF */ +#ifdef DRAM_REDUCTION_MCT_IGF + float *pPowerSpectrum[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ +#else float pPowerSpectrum[CPE_CHANNELS][N_MAX], /* i : MDCT^2 + MDST^2 spectrum, or estimate */ +#endif float *pPowerSpectrumMsInv[CPE_CHANNELS][2], /* i : inverse power spectrum */ float *inv_spectrum[CPE_CHANNELS][2], /* i : inverse spectrum */ const int16_t frameno, /* i : flag indicating index of current subfr. */ -- GitLab From 37cc900f79603ba5675b6c4a59273eab8b71fc7e Mon Sep 17 00:00:00 2001 From: rhb Date: Fri, 30 Sep 2022 12:19:33 +0200 Subject: [PATCH 2/2] some minor formatting --- lib_com/prot.h | 6 +++--- lib_enc/igf_enc.c | 4 ++-- lib_enc/tcx_utils_enc.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib_com/prot.h b/lib_com/prot.h index 1d3b55633c..86e9e172e3 100755 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -7397,7 +7397,7 @@ void ProcessStereoIGF( int16_t ms_mask[2][MAX_SFB], /* i : bandwise MS mask */ float *pITFMDCTSpectrum[CPE_CHANNELS][2], /* i : MDCT spectrum fir ITF */ #ifdef DRAM_REDUCTION_MCT_IGF - float *pPowerSpectrum[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ + float *pPowerSpectrum[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ #else float pPowerSpectrum[CPE_CHANNELS][N_MAX], /* i : MDCT^2 + MDST^2 spectrum, or estimate */ #endif @@ -7406,7 +7406,7 @@ void ProcessStereoIGF( const int16_t frameno, /* i : flag indicating index of current subframe*/ const int16_t sp_aud_decision0, /* i : sp_aud_decision0 */ const int32_t element_brate, /* i : element bitrate */ - const int16_t mct_on /* i : flag mct block (1) or stereo (0) */ + const int16_t mct_on /* i : flag mct block (1) or stereo (0) */ ); void AnalyzePowerSpectrum( @@ -9799,7 +9799,7 @@ void IGFEncApplyStereo( const int16_t igfGridIdx, /* i : IGF grid index */ Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */ #ifdef DRAM_REDUCTION_MCT_IGF - float *pPowerSpectrum[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ + float *pPowerSpectrum[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ #else float pPowerSpectrum[CPE_CHANNELS][N_MAX], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ #endif diff --git a/lib_enc/igf_enc.c b/lib_enc/igf_enc.c index ac69fa2ed8..7b658908b5 100755 --- a/lib_enc/igf_enc.c +++ b/lib_enc/igf_enc.c @@ -1853,7 +1853,7 @@ void IGFEncApplyStereo( const int16_t igfGridIdx, /* i : IGF grid index */ Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */ #ifdef DRAM_REDUCTION_MCT_IGF - float *pPowerSpectrum[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ + float *pPowerSpectrum[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ #else float pPowerSpectrum[CPE_CHANNELS][N_MAX], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ #endif @@ -1862,7 +1862,7 @@ void IGFEncApplyStereo( const int16_t frameno, /* i : flag indicating index of current subfr. */ const int16_t sp_aud_decision0, /* i : sp_aud_decision0 */ const int32_t element_brate, /* i : element bitrate */ - const int16_t mct_on /* i : flag mct block (1) or stereo (0) */ + const int16_t mct_on /* i : flag mct block (1) or stereo (0) */ ) { float *pPowerSpectrumParameter[2]; /* If it is NULL it informs a function that specific handling is needed */ diff --git a/lib_enc/tcx_utils_enc.c b/lib_enc/tcx_utils_enc.c index 6ced5b3f94..9b272f0dee 100755 --- a/lib_enc/tcx_utils_enc.c +++ b/lib_enc/tcx_utils_enc.c @@ -1510,7 +1510,7 @@ void ProcessStereoIGF( int16_t ms_mask[2][MAX_SFB], /* i : bandwise MS mask */ float *pITFMDCTSpectrum[CPE_CHANNELS][2], /* i : MDCT spectrum fir ITF */ #ifdef DRAM_REDUCTION_MCT_IGF - float *pPowerSpectrum[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ + float *pPowerSpectrum[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ #else float pPowerSpectrum[CPE_CHANNELS][N_MAX], /* i : MDCT^2 + MDST^2 spectrum, or estimate */ #endif -- GitLab