From 0e496b35ceab612c22cb071a8f90dbf49deac102 Mon Sep 17 00:00:00 2001 From: rtyag Date: Fri, 6 Dec 2024 19:00:41 +1100 Subject: [PATCH 1/3] IVAS downmix dumping debug code --- lib_com/ivas_prot.h | 3 +++ lib_com/options.h | 4 ++++ lib_enc/ivas_core_pre_proc_front.c | 15 +++++++++++++++ lib_enc/ivas_cpe_enc.c | 7 ++++++- lib_enc/ivas_ism_enc.c | 7 ++++++- lib_enc/ivas_sce_enc.c | 7 ++++++- 6 files changed, 40 insertions(+), 3 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 3922b4ac1..22dbc5dc2 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -201,6 +201,9 @@ ivas_error pre_proc_front_ivas( const IVAS_FORMAT ivas_format, /* i : IVAS format */ const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ const int32_t ivas_total_brate /* i : IVAS total bitrate */ +#ifdef DEBUG_MODE_INFO_CORE_CODER_IN + , const int16_t ch_idx +#endif ); ivas_error pre_proc_ivas( diff --git a/lib_com/options.h b/lib_com/options.h index 680c58215..6bacbcfb3 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -75,6 +75,10 @@ /*#define DEBUG_MODE_INFO_PLC */ /* define to output PLC related parameters */ /*#define DEBUG_MODE_INFO_ALLRAD*/ /* define to output generated HOA decoding mtx */ /*#define DEBUG_MODE_LFE */ /* define to output LFE relevant parameters */ + +#ifdef DEBUG_MODE_INFO_TWEAK +#define DEBUG_MODE_INFO_CORE_CODER_IN /*dump core coder input*/ +#endif #endif #ifdef DEBUG_MODE_MDCT diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index d0dbd1603..f59a7875f 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -110,6 +110,10 @@ ivas_error pre_proc_front_ivas( const IVAS_FORMAT ivas_format, /* i : IVAS format */ const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ const int32_t ivas_total_brate /* i : IVAS total bitrate - for setting the DTX */ +#ifdef DEBUG_MODE_INFO_CORE_CODER_IN + , + const int16_t ch_idx +#endif ) { float *inp_12k8, *new_inp_12k8; /* pointers to current frame and new data */ @@ -219,6 +223,17 @@ ivas_error pre_proc_front_ivas( } } +#ifdef DEBUG_MODE_INFO_CORE_CODER_IN + { + int16_t tmpF[L_FRAME48k]; + for ( int16_t isample = 0; isample < input_frame; isample++ ) + { + tmpF[isample] = (int16_t) signal_in[isample]; + } + dbgwrite( &tmpF, sizeof( int16_t ), input_frame, 1, strcat( fname( debug_dir, "input_dmx", 0, ch_idx + 1, ENC ), ".pcm" ) ); + } +#endif + lMemRecalc_12k8 = 0; lMemRecalc = 0; if ( element_mode == IVAS_CPE_TD || element_mode == IVAS_CPE_MDCT ) diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 480b559dc..e08490d7a 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -474,7 +474,12 @@ ivas_error ivas_cpe_enc( error = pre_proc_front_ivas( NULL, hCPE, hCPE->element_brate, nb_bits_metadata, input_frame, n, old_inp_12k8[n], old_inp_16k[n], &ener[n], &relE[n], A[n], Aw[n], epsP[n], lsp_new[n], lsp_mid[n], &vad_hover_flag[n], &attack_flag[n], realBuffer[n], imagBuffer[n], old_wsp[n], pitch_fr[n], voicing_fr[n], &loc_harm[n], &cor_map_sum[n], &vad_flag_dtx[n], enerBuffer[n], - fft_buff[n], A[0], lsp_new[0], currFlatness[n], tdm_ratio_idx, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, band_energies_LR, 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, 0, 0, ivas_format, st_ivas->hMCT != NULL, ivas_total_brate ); + fft_buff[n], A[0], lsp_new[0], currFlatness[n], tdm_ratio_idx, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, band_energies_LR, 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, 0, 0, ivas_format, st_ivas->hMCT != NULL, ivas_total_brate +#ifdef DEBUG_MODE_INFO_CORE_CODER_IN + , + ( (cpe_id * CPE_CHANNELS) + n) +#endif + ); if ( error != IVAS_ERR_OK ) { return error; diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index db689cc9f..9f7850ca6 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -175,7 +175,12 @@ ivas_error ivas_ism_enc( error = pre_proc_front_ivas( hSCE, NULL, hSCE->element_brate, nb_bits_metadata[sce_id], input_frame, 0, old_inp_12k8[sce_id][0], old_inp_16k[sce_id][0], &ener[sce_id][0], &relE[sce_id][0], A[sce_id][0], Aw[sce_id][0], epsP[sce_id][0], lsp_new[sce_id][0], lsp_mid[sce_id][0], &vad_hover_flag[sce_id][0], &attack_flag[sce_id][0], realBuffer[sce_id][0], imagBuffer[sce_id][0], old_wsp[sce_id][0], pitch_fr[sce_id][0], voicing_fr[sce_id][0], &loc_harm[sce_id][0], &cor_map_sum[sce_id][0], &vad_flag_dtx[sce_id][0], enerBuffer[sce_id][0], - fft_buff[sce_id][0], A[sce_id][0], lsp_new[sce_id][0], currFlatness[0], 0, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, NULL, 0, 0, 0, 0, ISM_FORMAT, 0, st_ivas->hEncoderConfig->ivas_total_brate ); + fft_buff[sce_id][0], A[sce_id][0], lsp_new[sce_id][0], currFlatness[0], 0, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, NULL, 0, 0, 0, 0, ISM_FORMAT, 0, st_ivas->hEncoderConfig->ivas_total_brate +#ifdef DEBUG_MODE_INFO_CORE_CODER_IN + , + sce_id +#endif + ); if ( error != IVAS_ERR_OK ) { return error; diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc.c index ae6496657..e08f1b7bd 100644 --- a/lib_enc/ivas_sce_enc.c +++ b/lib_enc/ivas_sce_enc.c @@ -184,7 +184,12 @@ ivas_error ivas_sce_enc( &ener[0], &relE[0], A[0], Aw[0], epsP[0], lsp_new[0], lsp_mid[0], &vad_hover_flag[0], &attack_flag[0], realBuffer[0], imagBuffer[0], old_wsp[0], pitch_fr[0], voicing_fr[0], &loc_harm[0], &cor_map_sum[0], &vad_flag_dtx[0], enerBuffer[0], fft_buff[0], A[0], lsp_new[0], currFlatness[0], 0, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, NULL, flag_16k_smc, - st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->force_front_vad : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_dtx_flag : 0, ivas_format, 0, st_ivas->hEncoderConfig->ivas_total_brate ); + st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->force_front_vad : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_dtx_flag : 0, ivas_format, 0, st_ivas->hEncoderConfig->ivas_total_brate +#ifdef DEBUG_MODE_INFO_CORE_CODER_IN + , + sce_id +#endif + ); if ( error != IVAS_ERR_OK ) { return error; -- GitLab From dd14203594ef058956ec1c60fe4c738c0d298052 Mon Sep 17 00:00:00 2001 From: rtyag Date: Fri, 6 Dec 2024 21:31:40 +1100 Subject: [PATCH 2/3] review comments --- lib_com/ivas_prot.h | 2 +- lib_com/options.h | 6 +----- lib_enc/ivas_core_pre_proc_front.c | 13 ++++++++----- lib_enc/ivas_cpe_enc.c | 14 +++++--------- lib_enc/ivas_ism_enc.c | 10 +++++----- lib_enc/ivas_sce_enc.c | 5 ++--- 6 files changed, 22 insertions(+), 28 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 22dbc5dc2..e39433fec 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -201,7 +201,7 @@ ivas_error pre_proc_front_ivas( const IVAS_FORMAT ivas_format, /* i : IVAS format */ const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ const int32_t ivas_total_brate /* i : IVAS total bitrate */ -#ifdef DEBUG_MODE_INFO_CORE_CODER_IN +#ifdef DEBUG_MODE_INFO , const int16_t ch_idx #endif ); diff --git a/lib_com/options.h b/lib_com/options.h index 6bacbcfb3..f92116c6a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -71,14 +71,10 @@ /*#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/" */ -/*#define DEBUG_MODE_INFO_TWEAK*/ /* enable command line switch to specify subdirectory for debug info output inside "./res/" */ +/*#define DEBUG_MODE_INFO_TWEAK*/ /* enable command line switch to specify subdirectory for debug info output inside "./res/" */ /*#define DEBUG_MODE_INFO_PLC */ /* define to output PLC related parameters */ /*#define DEBUG_MODE_INFO_ALLRAD*/ /* define to output generated HOA decoding mtx */ /*#define DEBUG_MODE_LFE */ /* define to output LFE relevant parameters */ - -#ifdef DEBUG_MODE_INFO_TWEAK -#define DEBUG_MODE_INFO_CORE_CODER_IN /*dump core coder input*/ -#endif #endif #ifdef DEBUG_MODE_MDCT diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index f59a7875f..87dd87b8e 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -43,6 +43,9 @@ #include "ivas_prot.h" #include "wmc_auto.h" #include +#ifdef DEBUG_MODE_INFO +#include "string.h" +#endif /*---------------------------------------------------------------* @@ -110,7 +113,7 @@ ivas_error pre_proc_front_ivas( const IVAS_FORMAT ivas_format, /* i : IVAS format */ const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ const int32_t ivas_total_brate /* i : IVAS total bitrate - for setting the DTX */ -#ifdef DEBUG_MODE_INFO_CORE_CODER_IN +#ifdef DEBUG_MODE_INFO , const int16_t ch_idx #endif @@ -223,14 +226,14 @@ ivas_error pre_proc_front_ivas( } } -#ifdef DEBUG_MODE_INFO_CORE_CODER_IN +#ifdef DEBUG_MODE_INFO { - int16_t tmpF[L_FRAME48k]; + int16_t tmp_dmx_in[L_FRAME48k]; for ( int16_t isample = 0; isample < input_frame; isample++ ) { - tmpF[isample] = (int16_t) signal_in[isample]; + tmp_dmx_in[isample] = (int16_t) signal_in[isample]; } - dbgwrite( &tmpF, sizeof( int16_t ), input_frame, 1, strcat( fname( debug_dir, "input_dmx", 0, ch_idx + 1, ENC ), ".pcm" ) ); + dbgwrite( &tmp_dmx_in, sizeof( int16_t ), input_frame, 1, strcat( fname( debug_dir, "input_dmx", 0, ch_idx + 1, ENC ), ".pcm" ) ); } #endif diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index e08490d7a..c3c40a55a 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -458,10 +458,6 @@ ivas_error ivas_cpe_enc( } #ifdef DEBUG_MODE_INFO - for ( n = 0; n < n_CoreChannels; n++ ) - { - dbgwrite( sts[0]->input - NS2SA( sts[0]->input_Fs, ACELP_LOOK_NS ), sizeof( float ), input_frame, 1, fname( debug_dir, "input_DMX", n, sts[n]->id_element, ENC ) ); - } dbgwrite( &hCPE->element_mode, sizeof( int16_t ), 1, input_frame, fname( debug_dir, "element_mode", 0, sts[0]->id_element, ENC ) ); #endif @@ -474,12 +470,12 @@ ivas_error ivas_cpe_enc( error = pre_proc_front_ivas( NULL, hCPE, hCPE->element_brate, nb_bits_metadata, input_frame, n, old_inp_12k8[n], old_inp_16k[n], &ener[n], &relE[n], A[n], Aw[n], epsP[n], lsp_new[n], lsp_mid[n], &vad_hover_flag[n], &attack_flag[n], realBuffer[n], imagBuffer[n], old_wsp[n], pitch_fr[n], voicing_fr[n], &loc_harm[n], &cor_map_sum[n], &vad_flag_dtx[n], enerBuffer[n], - fft_buff[n], A[0], lsp_new[0], currFlatness[n], tdm_ratio_idx, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, band_energies_LR, 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, 0, 0, ivas_format, st_ivas->hMCT != NULL, ivas_total_brate -#ifdef DEBUG_MODE_INFO_CORE_CODER_IN + fft_buff[n], A[0], lsp_new[0], currFlatness[n], tdm_ratio_idx, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, band_energies_LR, 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, 0, 0, ivas_format, st_ivas->hMCT != NULL, ivas_total_brate +#ifdef DEBUG_MODE_INFO , - ( (cpe_id * CPE_CHANNELS) + n) -#endif - ); + ( st_ivas->nSCE + ( cpe_id * CPE_CHANNELS ) + n ) +#endif + ); if ( error != IVAS_ERR_OK ) { return error; diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index 9f7850ca6..bc7ced57f 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -175,12 +175,12 @@ ivas_error ivas_ism_enc( error = pre_proc_front_ivas( hSCE, NULL, hSCE->element_brate, nb_bits_metadata[sce_id], input_frame, 0, old_inp_12k8[sce_id][0], old_inp_16k[sce_id][0], &ener[sce_id][0], &relE[sce_id][0], A[sce_id][0], Aw[sce_id][0], epsP[sce_id][0], lsp_new[sce_id][0], lsp_mid[sce_id][0], &vad_hover_flag[sce_id][0], &attack_flag[sce_id][0], realBuffer[sce_id][0], imagBuffer[sce_id][0], old_wsp[sce_id][0], pitch_fr[sce_id][0], voicing_fr[sce_id][0], &loc_harm[sce_id][0], &cor_map_sum[sce_id][0], &vad_flag_dtx[sce_id][0], enerBuffer[sce_id][0], - fft_buff[sce_id][0], A[sce_id][0], lsp_new[sce_id][0], currFlatness[0], 0, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, NULL, 0, 0, 0, 0, ISM_FORMAT, 0, st_ivas->hEncoderConfig->ivas_total_brate -#ifdef DEBUG_MODE_INFO_CORE_CODER_IN + fft_buff[sce_id][0], A[sce_id][0], lsp_new[sce_id][0], currFlatness[0], 0, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, NULL, 0, 0, 0, 0, ISM_FORMAT, 0, st_ivas->hEncoderConfig->ivas_total_brate +#ifdef DEBUG_MODE_INFO , - sce_id -#endif - ); + st->id_element +#endif + ); if ( error != IVAS_ERR_OK ) { return error; diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc.c index e08f1b7bd..a1d6d5945 100644 --- a/lib_enc/ivas_sce_enc.c +++ b/lib_enc/ivas_sce_enc.c @@ -172,7 +172,6 @@ ivas_error ivas_sce_enc( } #ifdef DEBUG_MODE_INFO - dbgwrite( st->input - NS2SA( st->input_Fs, ACELP_LOOK_NS ), sizeof( float ), input_frame, 1, "res/input_DMX" ); dbgwrite( &st->element_mode, sizeof( int16_t ), 1, input_frame, fname( debug_dir, "element_mode", 0, st->id_element, ENC ) ); #endif @@ -185,9 +184,9 @@ ivas_error ivas_sce_enc( realBuffer[0], imagBuffer[0], old_wsp[0], pitch_fr[0], voicing_fr[0], &loc_harm[0], &cor_map_sum[0], &vad_flag_dtx[0], enerBuffer[0], fft_buff[0], A[0], lsp_new[0], currFlatness[0], 0, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, NULL, flag_16k_smc, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->force_front_vad : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_dtx_flag : 0, ivas_format, 0, st_ivas->hEncoderConfig->ivas_total_brate -#ifdef DEBUG_MODE_INFO_CORE_CODER_IN +#ifdef DEBUG_MODE_INFO , - sce_id + st->id_element #endif ); if ( error != IVAS_ERR_OK ) -- GitLab From e1450424a69f1a1430a30dd51299d908315049d4 Mon Sep 17 00:00:00 2001 From: rtyag Date: Mon, 9 Dec 2024 22:00:36 +1100 Subject: [PATCH 3/3] delay the dumped signal to get continuous output for stereo mode switching case --- lib_enc/ivas_core_pre_proc_front.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index 87dd87b8e..0c31acdf1 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -231,9 +231,9 @@ ivas_error pre_proc_front_ivas( int16_t tmp_dmx_in[L_FRAME48k]; for ( int16_t isample = 0; isample < input_frame; isample++ ) { - tmp_dmx_in[isample] = (int16_t) signal_in[isample]; + tmp_dmx_in[isample] = (int16_t) signal_in[isample - NS2SA( st->input_Fs, ACELP_LOOK_NS )]; } - dbgwrite( &tmp_dmx_in, sizeof( int16_t ), input_frame, 1, strcat( fname( debug_dir, "input_dmx", 0, ch_idx + 1, ENC ), ".pcm" ) ); + dbgwrite( tmp_dmx_in, sizeof( int16_t ), input_frame, 1, strcat( fname( debug_dir, "ivas_input_dmx", 0, ch_idx + 1, ENC ), ".pcm" ) ); } #endif -- GitLab