Loading apps/encoder.c +57 −2 Original line number Diff line number Diff line Loading @@ -43,6 +43,19 @@ #endif #include "wmc_auto.h" #ifdef DEBUG_FORCE_DIR /* Windows does not define the S_ISREG and S_ISDIR macros in stat.h, so we do. We have to define _CRT_INTERNAL_NONSTDC_NAMES 1 before #including sys/stat.h in order for Microsoft's stat.h to define names like S_IFMT, S_IFREG, and S_IFDIR, rather than just defining _S_IFMT, _S_IFREG, and _S_IFDIR as it normally does. */ #include <sys/stat.h> #if !defined( S_ISREG ) && defined( S_IFMT ) && defined( S_IFREG ) #define S_ISREG( m ) ( ( (m) &S_IFMT ) == S_IFREG ) #endif #if !defined( S_ISDIR ) && defined( S_IFMT ) && defined( S_IFDIR ) #define S_ISDIR( m ) ( ( (m) &S_IFMT ) == S_IFDIR ) #endif #endif #define WMC_TOOL_SKIP Loading Loading @@ -192,6 +205,9 @@ int main( int16_t *pcmBuf = NULL; #ifdef DEBUGGING FILE *f_forcedModeProfile = NULL; #ifdef DEBUG_FORCE_DIR bool f_forceModeDir = false; #endif #ifdef DEBUG_SBA int16_t numTransportChannels = 1; #endif Loading Loading @@ -546,8 +562,26 @@ int main( #ifdef DEBUGGING IVAS_ENC_FORCED_MODE forcedMode = arg.forcedMode; int32_t force_profile_cnt = 0; #ifdef DEBUG_FORCE_DIR struct stat path_stat; #endif if ( arg.forcedModeFile ) { #ifdef DEBUG_FORCE_DIR if ( stat( arg.forcedModeFile, &path_stat ) != 0 ) { fprintf( stderr, "\nError: The profile file/dir could not be opened: %s\n\n", arg.forcedModeFile ); usage_enc(); goto cleanup; } /* check if it is a directory */ if ( S_ISDIR( path_stat.st_mode ) ) { f_forceModeDir = true; } else { if ( ( f_forcedModeProfile = fopen( arg.forcedModeFile, "rb" ) ) == NULL ) { Loading @@ -556,6 +590,15 @@ int main( goto cleanup; } } #else if ( ( f_forcedModeProfile = fopen( arg.forcedModeFile, "rb" ) ) == NULL ) { fprintf( stderr, "\nError: Incorrect mode specification or the profile file could not be opened: %s\n\n", arg.forcedModeFile ); usage_enc(); goto cleanup; } #endif } #endif /*------------------------------------------------------------------------------------------* Loading Loading @@ -708,9 +751,18 @@ int main( } /* Force mode not set when configuring, set in first frame even if not reading from file */ if ( f_forcedModeProfile || frame == 0 ) if ( f_forcedModeProfile || #ifdef DEBUG_FORCE_DIR f_forceModeDir || #endif frame == 0 ) { if ( ( error = IVAS_ENC_SetForcedMode( hIvasEnc, forcedMode ) ) != IVAS_ERR_OK ) if ( ( error = IVAS_ENC_SetForcedMode( hIvasEnc, forcedMode #ifdef DEBUG_FORCE_DIR , arg.forcedModeFile #endif ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_ENC_SetForcedMode failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); goto cleanup; Loading Loading @@ -1897,6 +1949,9 @@ static void usage_enc( void ) #ifdef DEBUGGING fprintf( stdout, "-force T : Force specific mode, T = (speech, music, ACELP, GSC, TCX, HQ),\n" ); fprintf( stdout, " alternatively, T can be a text file where each line contains \"nb_frames T\"\n" ); #ifdef DEBUG_FORCE_DIR fprintf( stdout, " or T can be a directory containing external binary files for modes/parameters enforcement\n" ); #endif #ifdef DEBUG_SBA fprintf( stdout, "-tag : Tag name for intermediate debug files\n" ); #endif Loading lib_com/options.h +1 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,7 @@ /*#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 */ #define DEBUG_FORCE_DIR /* Force modes/parameters by reading from external binary files */ #endif #ifdef DEBUG_MODE_MDCT Loading lib_debug/debug.c +19 −1 Original line number Diff line number Diff line Loading @@ -363,6 +363,13 @@ int16_t dbgread( { index = in_count; in_fileptr[index] = fopen( filename, "rb" ); #ifdef DEBUG_FORCE_DIR if ( in_fileptr[index] == NULL ) { /* file does not exist or could not be opened -> just return */ return -1; } #endif in_filename[index] = malloc( sizeof( char ) * ( strlen( filename ) + 1 ) ); strcpy( in_filename[index], filename ); in_count++; Loading Loading @@ -751,7 +758,7 @@ int16_t tweakdbgfolder( const char *filename, char *filename_mod, int16_t *textm #endif #ifdef DEBUG_MODE_INFO #ifdef DEBUGGING /*-------------------------------------------------------------------* * fname() * Loading @@ -773,8 +780,19 @@ char *fname( { char idd[5] = ".idX"; idd[3] = (char) ( id + '0' ); #ifdef DEBUG_FORCE_DIR size_t len; #endif strcpy( tmp_fname, dir ); #ifdef DEBUG_FORCE_DIR len = strlen( tmp_fname ); if ( tmp_fname[len - 1] != '/' && tmp_fname[len - 1] != '\\' ) { /* add trailing '/' slash */ strcat( tmp_fname, "/" ); } #endif strcat( tmp_fname, file ); if ( enc_dec == DEC ) Loading lib_debug/debug.h +5 −1 Original line number Diff line number Diff line Loading @@ -60,12 +60,16 @@ extern int16_t debug_level; #define DEBUG_LINE( level ) if ( 0 ) #endif #ifdef DEBUG_MODE_INFO #ifdef DEBUGGING extern char tmp_fname[]; extern char debug_dir[6]; char *fname( char *dir, char *file, const int16_t n, const int16_t id, const int16_t enc_dec ); #endif #ifdef DEBUG_FORCE_DIR #define FORCE_DIR_MAX_LENGTH 255 /* maximum length of the directory for modes/parameters enforcement */ #endif /*------------------------------------------------------------------------------------------* * Read/write I/O tool *------------------------------------------------------------------------------------------*/ Loading lib_enc/ivas_core_pre_proc_front.c +41 −0 Original line number Diff line number Diff line Loading @@ -459,6 +459,14 @@ ivas_error pre_proc_front_ivas( st->vad_flag = wb_vad( st, fr_bands, &i, &i, &i, &snr_sum_he, &localVAD_HE_SAD, &( st->flag_noisy_speech_snr ), NULL, NULL, -1000.0f, -1000.0f ); #ifdef DEBUG_FORCE_DIR dbgwrite( &st->vad_flag, sizeof( int16_t ), 1, 1, "res/force_vad_flag.enf" ); if ( st->force_dir[0] != '\0' ) { dbgread( &st->vad_flag, sizeof( int16_t ), 1, fname( st->force_dir, "force_vad_flag.enf", -1, -1, -1 ) ); } #endif if ( force_front_vad == 1 || front_vad_flag == 1 ) { Loading Loading @@ -507,6 +515,15 @@ ivas_error pre_proc_front_ivas( st->bwidth = hCPE->hCoreCoder[0]->bwidth; } #ifdef DEBUG_FORCE_DIR dbgwrite( &st->bwidth, sizeof( int16_t ), 1, 1, "res/force_bwidth.enf" ); if ( st->force_dir[0] != '\0' ) { dbgread( &st->bwidth, sizeof( int16_t ), 1, fname( st->force_dir, "force_bwidth.enf", -1, -1, -1 ) ); } #endif /*----------------------------------------------------------------* * Noise energy down-ward update and total noise energy estimation * Long-term energies and relative frame energy updates Loading Loading @@ -743,6 +760,15 @@ ivas_error pre_proc_front_ivas( smc_dec = ivas_smc_gmm( st, hStereoClassif, localVAD_HE_SAD, Etot, lsp_new, *cor_map_sum, epsP, PS, non_staX, *relE, &high_lpn_flag, flag_spitch ); #ifdef DEBUG_FORCE_DIR dbgwrite( &smc_dec, sizeof( int16_t ), 1, 1, "res/force_smc_dec_loc1.enf" ); if ( st->force_dir[0] != '\0' ) { dbgread( &smc_dec, sizeof( int16_t ), 1, fname( st->force_dir, "force_smc_dec_loc1.enf", -1, -1, -1 ) ); } #endif #ifdef DEBUGGING if ( st->idchan == 0 ) { Loading Loading @@ -851,6 +877,21 @@ ivas_error pre_proc_front_ivas( ivas_smc_mode_selection( st, element_brate, smc_dec, *relE, Etot, attack_flag, inp_12k8, S_map, flag_spitch ); } #ifdef DEBUG_FORCE_DIR dbgwrite( &smc_dec, sizeof( int16_t ), 1, 1, "res/force_smc_dec_loc2.enf" ); dbgwrite( &st->sp_aud_decision0, sizeof( int16_t ), 1, 1, "res/force_sp_aud_decision0.enf" ); dbgwrite( &st->sp_aud_decision1, sizeof( int16_t ), 1, 1, "res/force_sp_aud_decision1.enf" ); dbgwrite( &st->sp_aud_decision2, sizeof( int16_t ), 1, 1, "res/force_sp_aud_decision2.enf" ); if ( st->force_dir[0] != '\0' ) { dbgread( &smc_dec, sizeof( int16_t ), 1, fname( st->force_dir, "force_smc_dec_loc2.enf", -1, -1, -1 ) ); dbgread( &st->sp_aud_decision0, sizeof( int16_t ), 1, fname( st->force_dir, "force_sp_aud_decision0.enf", -1, -1, -1 ) ); dbgread( &st->sp_aud_decision1, sizeof( int16_t ), 1, fname( st->force_dir, "force_sp_aud_decision1.enf", -1, -1, -1 ) ); dbgread( &st->sp_aud_decision2, sizeof( int16_t ), 1, fname( st->force_dir, "force_sp_aud_decision2.enf", -1, -1, -1 ) ); } #endif /*----------------------------------------------------------------* * Final VAD correction (when HE-SAD is used instead of the normal VAD, * rewrite the VAD flag by VAD flag with DTX hangover for further processing) Loading Loading
apps/encoder.c +57 −2 Original line number Diff line number Diff line Loading @@ -43,6 +43,19 @@ #endif #include "wmc_auto.h" #ifdef DEBUG_FORCE_DIR /* Windows does not define the S_ISREG and S_ISDIR macros in stat.h, so we do. We have to define _CRT_INTERNAL_NONSTDC_NAMES 1 before #including sys/stat.h in order for Microsoft's stat.h to define names like S_IFMT, S_IFREG, and S_IFDIR, rather than just defining _S_IFMT, _S_IFREG, and _S_IFDIR as it normally does. */ #include <sys/stat.h> #if !defined( S_ISREG ) && defined( S_IFMT ) && defined( S_IFREG ) #define S_ISREG( m ) ( ( (m) &S_IFMT ) == S_IFREG ) #endif #if !defined( S_ISDIR ) && defined( S_IFMT ) && defined( S_IFDIR ) #define S_ISDIR( m ) ( ( (m) &S_IFMT ) == S_IFDIR ) #endif #endif #define WMC_TOOL_SKIP Loading Loading @@ -192,6 +205,9 @@ int main( int16_t *pcmBuf = NULL; #ifdef DEBUGGING FILE *f_forcedModeProfile = NULL; #ifdef DEBUG_FORCE_DIR bool f_forceModeDir = false; #endif #ifdef DEBUG_SBA int16_t numTransportChannels = 1; #endif Loading Loading @@ -546,8 +562,26 @@ int main( #ifdef DEBUGGING IVAS_ENC_FORCED_MODE forcedMode = arg.forcedMode; int32_t force_profile_cnt = 0; #ifdef DEBUG_FORCE_DIR struct stat path_stat; #endif if ( arg.forcedModeFile ) { #ifdef DEBUG_FORCE_DIR if ( stat( arg.forcedModeFile, &path_stat ) != 0 ) { fprintf( stderr, "\nError: The profile file/dir could not be opened: %s\n\n", arg.forcedModeFile ); usage_enc(); goto cleanup; } /* check if it is a directory */ if ( S_ISDIR( path_stat.st_mode ) ) { f_forceModeDir = true; } else { if ( ( f_forcedModeProfile = fopen( arg.forcedModeFile, "rb" ) ) == NULL ) { Loading @@ -556,6 +590,15 @@ int main( goto cleanup; } } #else if ( ( f_forcedModeProfile = fopen( arg.forcedModeFile, "rb" ) ) == NULL ) { fprintf( stderr, "\nError: Incorrect mode specification or the profile file could not be opened: %s\n\n", arg.forcedModeFile ); usage_enc(); goto cleanup; } #endif } #endif /*------------------------------------------------------------------------------------------* Loading Loading @@ -708,9 +751,18 @@ int main( } /* Force mode not set when configuring, set in first frame even if not reading from file */ if ( f_forcedModeProfile || frame == 0 ) if ( f_forcedModeProfile || #ifdef DEBUG_FORCE_DIR f_forceModeDir || #endif frame == 0 ) { if ( ( error = IVAS_ENC_SetForcedMode( hIvasEnc, forcedMode ) ) != IVAS_ERR_OK ) if ( ( error = IVAS_ENC_SetForcedMode( hIvasEnc, forcedMode #ifdef DEBUG_FORCE_DIR , arg.forcedModeFile #endif ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_ENC_SetForcedMode failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); goto cleanup; Loading Loading @@ -1897,6 +1949,9 @@ static void usage_enc( void ) #ifdef DEBUGGING fprintf( stdout, "-force T : Force specific mode, T = (speech, music, ACELP, GSC, TCX, HQ),\n" ); fprintf( stdout, " alternatively, T can be a text file where each line contains \"nb_frames T\"\n" ); #ifdef DEBUG_FORCE_DIR fprintf( stdout, " or T can be a directory containing external binary files for modes/parameters enforcement\n" ); #endif #ifdef DEBUG_SBA fprintf( stdout, "-tag : Tag name for intermediate debug files\n" ); #endif Loading
lib_com/options.h +1 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,7 @@ /*#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 */ #define DEBUG_FORCE_DIR /* Force modes/parameters by reading from external binary files */ #endif #ifdef DEBUG_MODE_MDCT Loading
lib_debug/debug.c +19 −1 Original line number Diff line number Diff line Loading @@ -363,6 +363,13 @@ int16_t dbgread( { index = in_count; in_fileptr[index] = fopen( filename, "rb" ); #ifdef DEBUG_FORCE_DIR if ( in_fileptr[index] == NULL ) { /* file does not exist or could not be opened -> just return */ return -1; } #endif in_filename[index] = malloc( sizeof( char ) * ( strlen( filename ) + 1 ) ); strcpy( in_filename[index], filename ); in_count++; Loading Loading @@ -751,7 +758,7 @@ int16_t tweakdbgfolder( const char *filename, char *filename_mod, int16_t *textm #endif #ifdef DEBUG_MODE_INFO #ifdef DEBUGGING /*-------------------------------------------------------------------* * fname() * Loading @@ -773,8 +780,19 @@ char *fname( { char idd[5] = ".idX"; idd[3] = (char) ( id + '0' ); #ifdef DEBUG_FORCE_DIR size_t len; #endif strcpy( tmp_fname, dir ); #ifdef DEBUG_FORCE_DIR len = strlen( tmp_fname ); if ( tmp_fname[len - 1] != '/' && tmp_fname[len - 1] != '\\' ) { /* add trailing '/' slash */ strcat( tmp_fname, "/" ); } #endif strcat( tmp_fname, file ); if ( enc_dec == DEC ) Loading
lib_debug/debug.h +5 −1 Original line number Diff line number Diff line Loading @@ -60,12 +60,16 @@ extern int16_t debug_level; #define DEBUG_LINE( level ) if ( 0 ) #endif #ifdef DEBUG_MODE_INFO #ifdef DEBUGGING extern char tmp_fname[]; extern char debug_dir[6]; char *fname( char *dir, char *file, const int16_t n, const int16_t id, const int16_t enc_dec ); #endif #ifdef DEBUG_FORCE_DIR #define FORCE_DIR_MAX_LENGTH 255 /* maximum length of the directory for modes/parameters enforcement */ #endif /*------------------------------------------------------------------------------------------* * Read/write I/O tool *------------------------------------------------------------------------------------------*/ Loading
lib_enc/ivas_core_pre_proc_front.c +41 −0 Original line number Diff line number Diff line Loading @@ -459,6 +459,14 @@ ivas_error pre_proc_front_ivas( st->vad_flag = wb_vad( st, fr_bands, &i, &i, &i, &snr_sum_he, &localVAD_HE_SAD, &( st->flag_noisy_speech_snr ), NULL, NULL, -1000.0f, -1000.0f ); #ifdef DEBUG_FORCE_DIR dbgwrite( &st->vad_flag, sizeof( int16_t ), 1, 1, "res/force_vad_flag.enf" ); if ( st->force_dir[0] != '\0' ) { dbgread( &st->vad_flag, sizeof( int16_t ), 1, fname( st->force_dir, "force_vad_flag.enf", -1, -1, -1 ) ); } #endif if ( force_front_vad == 1 || front_vad_flag == 1 ) { Loading Loading @@ -507,6 +515,15 @@ ivas_error pre_proc_front_ivas( st->bwidth = hCPE->hCoreCoder[0]->bwidth; } #ifdef DEBUG_FORCE_DIR dbgwrite( &st->bwidth, sizeof( int16_t ), 1, 1, "res/force_bwidth.enf" ); if ( st->force_dir[0] != '\0' ) { dbgread( &st->bwidth, sizeof( int16_t ), 1, fname( st->force_dir, "force_bwidth.enf", -1, -1, -1 ) ); } #endif /*----------------------------------------------------------------* * Noise energy down-ward update and total noise energy estimation * Long-term energies and relative frame energy updates Loading Loading @@ -743,6 +760,15 @@ ivas_error pre_proc_front_ivas( smc_dec = ivas_smc_gmm( st, hStereoClassif, localVAD_HE_SAD, Etot, lsp_new, *cor_map_sum, epsP, PS, non_staX, *relE, &high_lpn_flag, flag_spitch ); #ifdef DEBUG_FORCE_DIR dbgwrite( &smc_dec, sizeof( int16_t ), 1, 1, "res/force_smc_dec_loc1.enf" ); if ( st->force_dir[0] != '\0' ) { dbgread( &smc_dec, sizeof( int16_t ), 1, fname( st->force_dir, "force_smc_dec_loc1.enf", -1, -1, -1 ) ); } #endif #ifdef DEBUGGING if ( st->idchan == 0 ) { Loading Loading @@ -851,6 +877,21 @@ ivas_error pre_proc_front_ivas( ivas_smc_mode_selection( st, element_brate, smc_dec, *relE, Etot, attack_flag, inp_12k8, S_map, flag_spitch ); } #ifdef DEBUG_FORCE_DIR dbgwrite( &smc_dec, sizeof( int16_t ), 1, 1, "res/force_smc_dec_loc2.enf" ); dbgwrite( &st->sp_aud_decision0, sizeof( int16_t ), 1, 1, "res/force_sp_aud_decision0.enf" ); dbgwrite( &st->sp_aud_decision1, sizeof( int16_t ), 1, 1, "res/force_sp_aud_decision1.enf" ); dbgwrite( &st->sp_aud_decision2, sizeof( int16_t ), 1, 1, "res/force_sp_aud_decision2.enf" ); if ( st->force_dir[0] != '\0' ) { dbgread( &smc_dec, sizeof( int16_t ), 1, fname( st->force_dir, "force_smc_dec_loc2.enf", -1, -1, -1 ) ); dbgread( &st->sp_aud_decision0, sizeof( int16_t ), 1, fname( st->force_dir, "force_sp_aud_decision0.enf", -1, -1, -1 ) ); dbgread( &st->sp_aud_decision1, sizeof( int16_t ), 1, fname( st->force_dir, "force_sp_aud_decision1.enf", -1, -1, -1 ) ); dbgread( &st->sp_aud_decision2, sizeof( int16_t ), 1, fname( st->force_dir, "force_sp_aud_decision2.enf", -1, -1, -1 ) ); } #endif /*----------------------------------------------------------------* * Final VAD correction (when HE-SAD is used instead of the normal VAD, * rewrite the VAD flag by VAD flag with DTX hangover for further processing) Loading