mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-12-01 01:27:20 +01:00
Add CLI -O flag for performance testing
This commit is contained in:
parent
8ae9fff5e7
commit
e90e65ae52
@ -30,7 +30,7 @@ extern int optind, opterr, optopt;
|
|||||||
|
|
||||||
static size_t make_wav_header(uint8_t * buf, size_t buf_size, int32_t sample_count, int32_t sample_rate, int channels, int smpl_chunk, int32_t loop_start, int32_t loop_end);
|
static size_t make_wav_header(uint8_t * buf, size_t buf_size, int32_t sample_count, int32_t sample_rate, int channels, int smpl_chunk, int32_t loop_start, int32_t loop_end);
|
||||||
|
|
||||||
static void usage(const char * name) {
|
static void usage(const char * name, int is_full) {
|
||||||
fprintf(stderr,"vgmstream CLI decoder " VERSION " " __DATE__ "\n"
|
fprintf(stderr,"vgmstream CLI decoder " VERSION " " __DATE__ "\n"
|
||||||
"Usage: %s [-o outfile.wav] [options] infile\n"
|
"Usage: %s [-o outfile.wav] [options] infile\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
@ -52,10 +52,16 @@ static void usage(const char * name) {
|
|||||||
" -x: decode and print adxencd command line to encode as ADX\n"
|
" -x: decode and print adxencd command line to encode as ADX\n"
|
||||||
" -g: decode and print oggenc command line to encode as OGG\n"
|
" -g: decode and print oggenc command line to encode as OGG\n"
|
||||||
" -b: decode and print batch variable commands\n"
|
" -b: decode and print batch variable commands\n"
|
||||||
" -r: output a second file after resetting (for testing)\n"
|
" -h: print extra commands\n"
|
||||||
" -k N: seeks to N samples before decoding (for testing)\n"
|
|
||||||
" -t file: print if tags are found in file (for testing)\n"
|
|
||||||
, name);
|
, name);
|
||||||
|
if (is_full) {
|
||||||
|
fprintf(stderr,
|
||||||
|
" -r: output a second file after resetting (for reset testing)\n"
|
||||||
|
" -k N: seeks to N samples before decoding (for seek testing)\n"
|
||||||
|
" -t file: print tags found in file (for tag testing)\n"
|
||||||
|
" -O: decode but don't write to file (for performance testing)\n"
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -63,6 +69,7 @@ typedef struct {
|
|||||||
char * infilename;
|
char * infilename;
|
||||||
char * outfilename;
|
char * outfilename;
|
||||||
char * tag_filename;
|
char * tag_filename;
|
||||||
|
int decode_only;
|
||||||
int ignore_loop;
|
int ignore_loop;
|
||||||
int force_loop;
|
int force_loop;
|
||||||
int really_force_loop;
|
int really_force_loop;
|
||||||
@ -101,7 +108,7 @@ static int parse_config(cli_config *cfg, int argc, char ** argv) {
|
|||||||
opterr = 0;
|
opterr = 0;
|
||||||
|
|
||||||
/* read config */
|
/* read config */
|
||||||
while ((opt = getopt(argc, argv, "o:l:f:d:ipPcmxeLEFrgb2:s:t:k:")) != -1) {
|
while ((opt = getopt(argc, argv, "o:l:f:d:ipPcmxeLEFrgb2:s:t:k:hO")) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'o':
|
case 'o':
|
||||||
cfg->outfilename = optarg;
|
cfg->outfilename = optarg;
|
||||||
@ -167,18 +174,24 @@ static int parse_config(cli_config *cfg, int argc, char ** argv) {
|
|||||||
case 'k':
|
case 'k':
|
||||||
cfg->seek_samples = atoi(optarg);
|
cfg->seek_samples = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'O':
|
||||||
|
cfg->decode_only = 1;
|
||||||
|
break;
|
||||||
|
case 'h':
|
||||||
|
usage(argv[0], 1);
|
||||||
|
goto fail;
|
||||||
case '?':
|
case '?':
|
||||||
fprintf(stderr, "Unknown option -%c found\n", optopt);
|
fprintf(stderr, "Unknown option -%c found\n", optopt);
|
||||||
goto fail;
|
goto fail;
|
||||||
default:
|
default:
|
||||||
usage(argv[0]);
|
usage(argv[0], 0);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* filename goes last */
|
/* filename goes last */
|
||||||
if (optind != argc - 1) {
|
if (optind != argc - 1) {
|
||||||
usage(argv[0]);
|
usage(argv[0], 0);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
cfg->infilename = argv[optind];
|
cfg->infilename = argv[optind];
|
||||||
@ -435,7 +448,7 @@ int main(int argc, char ** argv) {
|
|||||||
if (cfg.play_sdtout) {
|
if (cfg.play_sdtout) {
|
||||||
outfile = stdout;
|
outfile = stdout;
|
||||||
}
|
}
|
||||||
else if (!cfg.print_metaonly) {
|
else if (!cfg.print_metaonly && !cfg.decode_only) {
|
||||||
if (!cfg.outfilename) {
|
if (!cfg.outfilename) {
|
||||||
/* note that outfilename_temp must persist outside this block, hence the external array */
|
/* note that outfilename_temp must persist outside this block, hence the external array */
|
||||||
strcpy(outfilename_temp, cfg.infilename);
|
strcpy(outfilename_temp, cfg.infilename);
|
||||||
@ -521,7 +534,7 @@ int main(int argc, char ** argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* slap on a .wav header */
|
/* slap on a .wav header */
|
||||||
{
|
if (!cfg.decode_only) {
|
||||||
uint8_t wav_buf[0x100];
|
uint8_t wav_buf[0x100];
|
||||||
int channels_write = (cfg.only_stereo != -1) ? 2 : channels;
|
int channels_write = (cfg.only_stereo != -1) ? 2 : channels;
|
||||||
size_t bytes_done;
|
size_t bytes_done;
|
||||||
@ -563,13 +576,15 @@ int main(int argc, char ** argv) {
|
|||||||
|
|
||||||
apply_fade(buf, vgmstream, to_get, i, len_samples, fade_samples, channels);
|
apply_fade(buf, vgmstream, to_get, i, len_samples, fade_samples, channels);
|
||||||
|
|
||||||
swap_samples_le(buf, channels * to_get); /* write PC endian */
|
if (!cfg.decode_only) {
|
||||||
if (cfg.only_stereo != -1) {
|
swap_samples_le(buf, channels * to_get); /* write PC endian */
|
||||||
for (j = 0; j < to_get; j++) {
|
if (cfg.only_stereo != -1) {
|
||||||
fwrite(buf + j*channels + (cfg.only_stereo*2), sizeof(sample_t), 2, outfile);
|
for (j = 0; j < to_get; j++) {
|
||||||
|
fwrite(buf + j*channels + (cfg.only_stereo*2), sizeof(sample_t), 2, outfile);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fwrite(buf, sizeof(sample_t), to_get * channels, outfile);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
fwrite(buf, sizeof(sample_t), to_get * channels, outfile);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -577,7 +592,7 @@ int main(int argc, char ** argv) {
|
|||||||
outfile = NULL;
|
outfile = NULL;
|
||||||
|
|
||||||
|
|
||||||
/* try again with (for testing reset_vgmstream, simulates a seek to 0) */
|
/* try again with (for testing reset_vgmstream, simulates a seek to 0 after changing internal state) */
|
||||||
if (cfg.test_reset) {
|
if (cfg.test_reset) {
|
||||||
char outfilename_reset[PATH_LIMIT];
|
char outfilename_reset[PATH_LIMIT];
|
||||||
strcpy(outfilename_reset, cfg.outfilename);
|
strcpy(outfilename_reset, cfg.outfilename);
|
||||||
@ -597,7 +612,7 @@ int main(int argc, char ** argv) {
|
|||||||
apply_seek(buf, vgmstream, cfg.seek_samples);
|
apply_seek(buf, vgmstream, cfg.seek_samples);
|
||||||
|
|
||||||
/* slap on a .wav header */
|
/* slap on a .wav header */
|
||||||
{
|
if (!cfg.decode_only) {
|
||||||
uint8_t wav_buf[0x100];
|
uint8_t wav_buf[0x100];
|
||||||
int channels_write = (cfg.only_stereo != -1) ? 2 : channels;
|
int channels_write = (cfg.only_stereo != -1) ? 2 : channels;
|
||||||
size_t bytes_done;
|
size_t bytes_done;
|
||||||
@ -619,13 +634,15 @@ int main(int argc, char ** argv) {
|
|||||||
|
|
||||||
apply_fade(buf, vgmstream, to_get, i, len_samples, fade_samples, channels);
|
apply_fade(buf, vgmstream, to_get, i, len_samples, fade_samples, channels);
|
||||||
|
|
||||||
swap_samples_le(buf, channels * to_get); /* write PC endian */
|
if (!cfg.decode_only) {
|
||||||
if (cfg.only_stereo != -1) {
|
swap_samples_le(buf, channels * to_get); /* write PC endian */
|
||||||
for (j = 0; j < to_get; j++) {
|
if (cfg.only_stereo != -1) {
|
||||||
fwrite(buf + j*channels + (cfg.only_stereo*2), sizeof(sample_t), 2, outfile);
|
for (j = 0; j < to_get; j++) {
|
||||||
|
fwrite(buf + j*channels + (cfg.only_stereo*2), sizeof(sample_t), 2, outfile);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fwrite(buf, sizeof(sample_t) * channels, to_get, outfile);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
fwrite(buf, sizeof(sample_t) * channels, to_get, outfile);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(outfile);
|
fclose(outfile);
|
||||||
|
14
cli/vrts.bat
14
cli/vrts.bat
@ -29,6 +29,7 @@ set OP_NODELETE=
|
|||||||
REM # -nc: don't report correct files
|
REM # -nc: don't report correct files
|
||||||
set OP_NOCORRECT=
|
set OP_NOCORRECT=
|
||||||
REM # -p: performance test (decode with new exe and no comparison done)
|
REM # -p: performance test (decode with new exe and no comparison done)
|
||||||
|
REM # -P: performance test (same but also don't write file)
|
||||||
set OP_PERFORMANCE=
|
set OP_PERFORMANCE=
|
||||||
REM # -fc <exe>: file comparer (Windows's FC is slow)
|
REM # -fc <exe>: file comparer (Windows's FC is slow)
|
||||||
set OP_CMD_FC=fc /a /b
|
set OP_CMD_FC=fc /a /b
|
||||||
@ -43,7 +44,8 @@ if "%~1"=="-f" set OP_SEARCH=%2
|
|||||||
if "%~1"=="-r" set OP_RECURSIVE=/s
|
if "%~1"=="-r" set OP_RECURSIVE=/s
|
||||||
if "%~1"=="-nd" set OP_NODELETE=true
|
if "%~1"=="-nd" set OP_NODELETE=true
|
||||||
if "%~1"=="-nc" set OP_NOCORRECT=true
|
if "%~1"=="-nc" set OP_NOCORRECT=true
|
||||||
if "%~1"=="-p" set OP_PERFORMANCE=true
|
if "%~1"=="-p" set OP_PERFORMANCE=1
|
||||||
|
if "%~1"=="-P" set OP_PERFORMANCE=2
|
||||||
if "%~1"=="-fc" set OP_CMD_FC=%2
|
if "%~1"=="-fc" set OP_CMD_FC=%2
|
||||||
shift
|
shift
|
||||||
goto set_options
|
goto set_options
|
||||||
@ -198,9 +200,15 @@ REM # ########################################################################
|
|||||||
set CMD_FILE=%CMD_FILE:"=%
|
set CMD_FILE=%CMD_FILE:"=%
|
||||||
REM echo VTRS: file %CMD_FILE%
|
REM echo VTRS: file %CMD_FILE%
|
||||||
|
|
||||||
REM # new temp output
|
|
||||||
set WAV_NEW=%CMD_FILE%.test.wav
|
set WAV_NEW=%CMD_FILE%.test.wav
|
||||||
set CMD_VGM_NEW="%OP_CMD_NEW%" -o "%WAV_NEW%" "%CMD_FILE%"
|
if "%OP_PERFORMANCE%" == "2" (
|
||||||
|
REM # don't actually write file
|
||||||
|
set CMD_VGM_NEW="%OP_CMD_NEW%" -O "%CMD_FILE%"
|
||||||
|
) else (
|
||||||
|
REM # new temp output
|
||||||
|
set CMD_VGM_NEW="%OP_CMD_NEW%" -o "%WAV_NEW%" "%CMD_FILE%"
|
||||||
|
)
|
||||||
|
|
||||||
%CMD_VGM_NEW% 1> nul 2>&1 & REM || goto error
|
%CMD_VGM_NEW% 1> nul 2>&1 & REM || goto error
|
||||||
|
|
||||||
call :echo_color %C_O% "%CMD_FILE%" "done"
|
call :echo_color %C_O% "%CMD_FILE%" "done"
|
||||||
|
Loading…
Reference in New Issue
Block a user