Extra logs on broken RIFF

This commit is contained in:
bnnm 2022-05-13 16:40:33 +02:00
parent a16e8e95c7
commit 74a83e224f
4 changed files with 23 additions and 6 deletions

View File

@ -579,7 +579,7 @@ Console location and format depends on plugin:
- *Audacious*: start with `audacious -V` from terminal
- CLI utils: printed to stdout directly
Only a few errors are printed ATM but may be helpful for more common cases.
Only a few errors types are printed but may be helpful for more common cases.
## Tagging
Some of vgmstream's plugins support simple read-only tagging via external files.

View File

@ -119,7 +119,7 @@ static const char* extension_list[] = {
"brstm",
"brstmspm",
"brwav",
"brwsd",
"brwsd", //fake extension for RWSD (non-format)
"bsnd",
"btsnd",
"bvg",
@ -1225,7 +1225,8 @@ static const meta_info meta_info_list[] = {
{meta_HCA, "CRI HCA header"},
{meta_SVAG_SNK, "SNK SVAG header"},
{meta_PS2_VDS_VDM, "Procyon Studio VDS/VDM header"},
{meta_FFMPEG, "FFmpeg supported file format"},
{meta_FFMPEG, "FFmpeg supported format"},
{meta_FFMPEG_faulty, "FFmpeg supported format (check log)"},
{meta_X360_CXS, "tri-Crescendo CXS header"},
{meta_AKB, "Square-Enix AKB header"},
{meta_X360_PASX, "Premium Agency PASX header"},

View File

@ -7,7 +7,6 @@ static int read_pos_file(uint8_t* buf, size_t bufsize, STREAMFILE* sf);
static int find_meta_loops(ffmpeg_codec_data* data, int32_t* p_loop_start, int32_t* p_loop_end);
/* parses any format supported by FFmpeg and not handled elsewhere:
* - MP3 (.mp3, .mus): Marc Ecko's Getting Up (PC)
* - MPC (.mpc, mp+): Moonshine Runners (PC), Asphalt 7 (PC)
* - FLAC (.flac): Warcraft 3 Reforged (PC), Call of Duty: Ghosts (PC)
* - DUCK (.wav): Sonic Jam (SAT), Virtua Fighter 2 (SAT)
@ -26,6 +25,7 @@ VGMSTREAM* init_vgmstream_ffmpeg(STREAMFILE* sf) {
int loop_flag = 0, channels, sample_rate;
int32_t loop_start = 0, loop_end = 0, num_samples = 0, encoder_delay = 0;
int total_subsongs, target_subsong = sf->stream_index;
int faulty = 0; /* mark wonky rips in hopes people may fix them */
/* no checks */
//if (!check_extensions(sf, "..."))
@ -102,6 +102,21 @@ VGMSTREAM* init_vgmstream_ffmpeg(STREAMFILE* sf) {
ffmpeg_set_skip_samples(data, encoder_delay);
}
/* detect broken RIFFs */
if (is_id32be(0x00, sf, "RIFF")) {
uint32_t size = read_u32le(0x04, sf);
/* There is a log in RIFF too but to be extra sure and sometimes FFmpeg don't handle it (this is mainly for wrong AT3).
* Some proper RIFF can be parsed here too (like DUCK). */
if (size + 0x08 > get_streamfile_size(sf)) {
vgm_logi("RIFF/FFmpeg: incorrect size, file may have missing data\n");
faulty = 1;
}
else if (size + 0x08 < get_streamfile_size(sf)) {
vgm_logi("RIFF/FFmpeg: incorrect size, file may have padded data\n");
faulty = 1;
}
}
/* default but often inaccurate when calculated using bitrate (wrong for VBR) */
if (!num_samples) {
num_samples = ffmpeg_get_samples(data); /* may be 0 if FFmpeg can't precalculate it */
@ -115,7 +130,7 @@ VGMSTREAM* init_vgmstream_ffmpeg(STREAMFILE* sf) {
vgmstream = allocate_vgmstream(channels, loop_flag);
if (!vgmstream) goto fail;
vgmstream->meta_type = meta_FFMPEG;
vgmstream->meta_type = faulty ? meta_FFMPEG_faulty : meta_FFMPEG;
vgmstream->sample_rate = sample_rate;
vgmstream->codec_data = data;

View File

@ -587,7 +587,8 @@ typedef enum {
meta_HCA, /* CRI HCA */
meta_SVAG_SNK,
meta_PS2_VDS_VDM, /* Graffiti Kingdom */
meta_FFMPEG, /* any file supported by FFmpeg */
meta_FFMPEG,
meta_FFMPEG_faulty,
meta_X360_CXS, /* Eternal Sonata (Xbox 360) */
meta_AKB, /* SQEX iOS */
meta_X360_PASX, /* Namco PASX (Soul Calibur II HD X360) */