From a8ffd97e4e730d2161959bf4245af2bdc063b91c Mon Sep 17 00:00:00 2001 From: malenov Date: Fri, 10 Jan 2025 11:15:28 +0100 Subject: [PATCH 1/7] enable the support of -force TCX10|TCX20 on the encoder command-line --- apps/encoder.c | 33 +++++++++++++++++++++++++++++- lib_com/cnst.h | 6 ++++++ lib_com/options.h | 3 ++- lib_enc/core_enc_init.c | 1 - lib_enc/ivas_decision_matrix_enc.c | 11 ++++++++++ lib_enc/lib_enc.c | 9 ++++++++ lib_enc/lib_enc.h | 5 +++++ lib_enc/transient_detection_fx.c | 12 +++++++++++ 8 files changed, 77 insertions(+), 3 deletions(-) diff --git a/apps/encoder.c b/apps/encoder.c index a1b7f0d10..f6dacfb91 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -998,7 +998,24 @@ static bool parseCmdlIVAS_enc( } else { +#ifdef SUPPORT_FORCE_TCX10_TCX20 + if ( arg->forcedMode == IVAS_ENC_FORCE_TCX10 ) + { + strcpy( stmp, "TCX10" ); + } + else if ( arg->forcedMode == IVAS_ENC_FORCE_TCX20 ) + { + strcpy( stmp, "TCX20" ); + } + else + { + strncpy( stmp, argv[i + 1], sizeof( stmp ) ); + } + + fprintf( stdout, "Forcing codec to: %s\n", stmp ); +#else fprintf( stdout, "Forcing codec to: %s\n", argv[i + 1] ); +#endif } i += 2; @@ -1919,10 +1936,24 @@ static IVAS_ENC_FORCED_MODE parseForcedMode( { return IVAS_ENC_FORCE_GSC; } - if ( ( strcmp( forcedModeChar, "TCX" ) == 0 ) || ( strcmp( forcedModeChar, "'TCX'" ) == 0 ) ) + if ( ( strcmp( forcedModeChar, "TCX" ) == 0 ) || ( strcmp( forcedModeChar, "'TCX'" ) == 0 ) +#ifdef SUPPORT_FORCE_TCX10_TCX20 + || ( strcmp( forcedModeChar, "TCX20" ) == 0 ) || ( strcmp( forcedModeChar, "'TCX20'" ) == 0 ) +#endif + ) { +#ifdef SUPPORT_FORCE_TCX10_TCX20 + return IVAS_ENC_FORCE_TCX20; +#else return IVAS_ENC_FORCE_TCX; +#endif + } +#ifdef SUPPORT_FORCE_TCX10_TCX20 + if ( ( strcmp( forcedModeChar, "TCX10" ) == 0 ) || ( strcmp( forcedModeChar, "'TCX10'" ) == 0 ) ) + { + return IVAS_ENC_FORCE_TCX10; } +#endif if ( ( strcmp( forcedModeChar, "HQ" ) == 0 ) || ( strcmp( forcedModeChar, "'HQ'" ) == 0 ) ) { return IVAS_ENC_FORCE_HQ; diff --git a/lib_com/cnst.h b/lib_com/cnst.h index fe16db670..6e24b0d1b 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -190,8 +190,14 @@ #define FORCE_MUSIC 101 /* debugging - force music on the command line */ #define FORCE_ACELP 102 /* debugging - force ACELP core on the command line */ #define FORCE_GSC 103 /* debugging - force GSC core on the command line */ +#ifdef SUPPORT_FORCE_TCX10_TCX20 +#define FORCE_TCX10 104 /* debugging - force TCX10 core on the command line */ +#define FORCE_TCX20 105 /* debugging - force TCX20 core on the command line */ +#define FORCE_HQ 106 /* debugging - force HQ core on the command line */ +#else #define FORCE_TCX 104 /* debugging - force TCX core on the command line */ #define FORCE_HQ 105 /* debugging - force HQ core on the command line */ +#endif #define FORCE_TD_RENDERER 201 #define FORCE_CLDFB_RENDERER 202 #endif diff --git a/lib_com/options.h b/lib_com/options.h index 343515281..019accbf0 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -45,12 +45,13 @@ #pragma warning(disable:4310) /* cast truncates constant value this affects mainly constants tables*/ #endif -/*#define DEBUGGING*/ /* Allows debugging message to be printed out during runtime */ +#define DEBUGGING /* Allows debugging message to be printed out during runtime */ #ifdef DEBUGGING #define DEBUG_MODE_INFO /* Define to output most important parameters to the subdirectory "res/" */ #define DEBUG_MODE_INFO_TWEAK /* Enable command line switch to specify subdirectory for debug info output inside "./res/" */ #define DEBUG_FORCE_MDCT_STEREO_MODE /* Force stereo mode decision for MDCT stereo: -stereo 3 1 forces L/R coding and -stereo 3 2 forces full M/S coding */ /*#define DBG_WAV_WRITER*/ /* Enable dbgwrite_wav() function for generating ".wav" files */ +#define SUPPORT_FORCE_TCX10_TCX20 /* VA: Enable -force tcx10|tcx20 command-line option */ #endif #define SUPPORT_JBM_TRACEFILE /* Support for JBM tracefile, which is needed for 3GPP objective/subjective testing, but not relevant for real-world implementations */ diff --git a/lib_enc/core_enc_init.c b/lib_enc/core_enc_init.c index e09166f8a..80aa5fc06 100644 --- a/lib_enc/core_enc_init.c +++ b/lib_enc/core_enc_init.c @@ -989,7 +989,6 @@ static void init_modes_ivas_fx( move16(); } - /* TCX mode (TCX20 TCX10_10 or NO_TCX) */ if ( st->hTcxEnc != NULL ) { diff --git a/lib_enc/ivas_decision_matrix_enc.c b/lib_enc/ivas_decision_matrix_enc.c index 0ecafc6c3..af0ce375d 100644 --- a/lib_enc/ivas_decision_matrix_enc.c +++ b/lib_enc/ivas_decision_matrix_enc.c @@ -244,10 +244,21 @@ void ivas_decision_matrix_enc_fx( { st->core = ACELP_CORE; } +#ifdef SUPPORT_FORCE_TCX10_TCX20 + else if ( st->force == FORCE_TCX10 ) + { + st->core = TCX_10_CORE; + } + else if ( st->force == FORCE_TCX20 ) + { + st->core = TCX_20_CORE; + } +#else else if ( st->force == FORCE_TCX ) { st->core = TCX_20_CORE; } +#endif else if ( st->force == FORCE_HQ && st->element_mode != IVAS_CPE_MDCT && element_brate >= IVAS_24k4 ) { st->core = HQ_CORE; diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 281e131f7..c78fbe107 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -2690,9 +2690,18 @@ static ivas_error forcedModeApiToInternal( case IVAS_ENC_FORCE_GSC: *forcedModeInternal = FORCE_GSC; break; +#ifdef SUPPORT_FORCE_TCX10_TCX20 + case IVAS_ENC_FORCE_TCX10: + *forcedModeInternal = FORCE_TCX10; + break; + case IVAS_ENC_FORCE_TCX20: + *forcedModeInternal = FORCE_TCX20; + break; +#else case IVAS_ENC_FORCE_TCX: *forcedModeInternal = FORCE_TCX; break; +#endif case IVAS_ENC_FORCE_HQ: *forcedModeInternal = FORCE_HQ; break; diff --git a/lib_enc/lib_enc.h b/lib_enc/lib_enc.h index 1fd4e0ad0..c23f56df9 100644 --- a/lib_enc/lib_enc.h +++ b/lib_enc/lib_enc.h @@ -127,7 +127,12 @@ typedef enum _IVAS_ENC_FORCED_MODE IVAS_ENC_FORCE_MUSIC, IVAS_ENC_FORCE_ACELP, IVAS_ENC_FORCE_GSC, +#ifdef SUPPORT_FORCE_TCX10_TCX20 + IVAS_ENC_FORCE_TCX10, + IVAS_ENC_FORCE_TCX20, +#else IVAS_ENC_FORCE_TCX, +#endif IVAS_ENC_FORCE_HQ, IVAS_ENC_FORCE_UNFORCED, IVAS_ENC_FORCE_UNDEFINED = 0xffff diff --git a/lib_enc/transient_detection_fx.c b/lib_enc/transient_detection_fx.c index bb977b432..0a5527241 100644 --- a/lib_enc/transient_detection_fx.c +++ b/lib_enc/transient_detection_fx.c @@ -715,6 +715,18 @@ void SetTCXModeInfo_ivas_fx( move16(); } } + +#ifdef SUPPORT_FORCE_TCX10_TCX20 + if ( st->force == FORCE_TCX10 ) + { + hTcxEnc->tcxMode = TCX_10; + } + else if ( st->force == FORCE_TCX20 ) + { + hTcxEnc->tcxMode = TCX_20; + } +#endif + /* set the left window overlap */ test(); test(); -- GitLab From b73bbdfb6f41a393674b75f4380fabb770dc4119 Mon Sep 17 00:00:00 2001 From: malenov Date: Fri, 10 Jan 2025 14:50:00 +0100 Subject: [PATCH 2/7] forgot adding DEBUGGING macro --- lib_enc/transient_detection_fx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib_enc/transient_detection_fx.c b/lib_enc/transient_detection_fx.c index 0a5527241..3a59bead4 100644 --- a/lib_enc/transient_detection_fx.c +++ b/lib_enc/transient_detection_fx.c @@ -717,6 +717,7 @@ void SetTCXModeInfo_ivas_fx( } #ifdef SUPPORT_FORCE_TCX10_TCX20 +#ifdef DEBUGGING if ( st->force == FORCE_TCX10 ) { hTcxEnc->tcxMode = TCX_10; @@ -725,6 +726,7 @@ void SetTCXModeInfo_ivas_fx( { hTcxEnc->tcxMode = TCX_20; } +#endif #endif /* set the left window overlap */ -- GitLab From afed8fc4fae2a82cfdef76f9a22eebd6b4807d1b Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Fri, 10 Jan 2025 16:33:23 +0100 Subject: [PATCH 3/7] fix forcing TCX10 --- lib_enc/ivas_decision_matrix_enc.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib_enc/ivas_decision_matrix_enc.c b/lib_enc/ivas_decision_matrix_enc.c index af0ce375d..27da71324 100644 --- a/lib_enc/ivas_decision_matrix_enc.c +++ b/lib_enc/ivas_decision_matrix_enc.c @@ -245,11 +245,7 @@ void ivas_decision_matrix_enc_fx( st->core = ACELP_CORE; } #ifdef SUPPORT_FORCE_TCX10_TCX20 - else if ( st->force == FORCE_TCX10 ) - { - st->core = TCX_10_CORE; - } - else if ( st->force == FORCE_TCX20 ) + else if ( st->force == FORCE_TCX20 || st->force == FORCE_TCX10 ) /* Initalizations should always happen with TCX20*/ { st->core = TCX_20_CORE; } -- GitLab From ba33d15b159f31dedf560cabfab5a723582dbc34 Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Fri, 10 Jan 2025 18:49:10 +0100 Subject: [PATCH 4/7] clang format --- apps/encoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/encoder.c b/apps/encoder.c index f6dacfb91..60c500df6 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -1940,7 +1940,7 @@ static IVAS_ENC_FORCED_MODE parseForcedMode( #ifdef SUPPORT_FORCE_TCX10_TCX20 || ( strcmp( forcedModeChar, "TCX20" ) == 0 ) || ( strcmp( forcedModeChar, "'TCX20'" ) == 0 ) #endif - ) + ) { #ifdef SUPPORT_FORCE_TCX10_TCX20 return IVAS_ENC_FORCE_TCX20; -- GitLab From c079855811c077b5fec3117bd076c167bf0969de Mon Sep 17 00:00:00 2001 From: malenov Date: Thu, 16 Jan 2025 12:22:58 +0100 Subject: [PATCH 5/7] add warning about TCX10 supported from 48 kbps --- apps/encoder.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/apps/encoder.c b/apps/encoder.c index 60c500df6..b06b5de0d 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -353,6 +353,15 @@ int main( goto cleanup; } +#ifdef SUPPORT_FORCE_TCX10_TCX20 +#ifdef DEBUGGING + if ( arg.forcedMode == IVAS_ENC_FORCE_TCX10 && totalBitrate < 48000 ) + { + fprintf( stderr, "Warning: Enforcing the TCX10 mode is only supported for bitrates higher or equal than 48 kbps!\n\n" ); + } +#endif +#endif + /*------------------------------------------------------------------------------------------* * Configure and initialize (allocate memory for static variables) the encoder *------------------------------------------------------------------------------------------*/ -- GitLab From 2909c6d4ff10e93acdc77b57de144a88f2c47905 Mon Sep 17 00:00:00 2001 From: malenov Date: Thu, 16 Jan 2025 12:35:01 +0100 Subject: [PATCH 6/7] deactivate DEBUGGING by default --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 019accbf0..1c73045ce 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -45,7 +45,7 @@ #pragma warning(disable:4310) /* cast truncates constant value this affects mainly constants tables*/ #endif -#define DEBUGGING /* Allows debugging message to be printed out during runtime */ +/*#define DEBUGGING*/ /* Allows debugging message to be printed out during runtime */ #ifdef DEBUGGING #define DEBUG_MODE_INFO /* Define to output most important parameters to the subdirectory "res/" */ #define DEBUG_MODE_INFO_TWEAK /* Enable command line switch to specify subdirectory for debug info output inside "./res/" */ -- GitLab From 34d391e037cf875a6435f65b76b8e24bd1fe0308 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Thu, 16 Jan 2025 14:14:36 +0100 Subject: [PATCH 7/7] Trigger Build -- GitLab