From b75b18055794aae9459d1c7824e4a052e6558f23 Mon Sep 17 00:00:00 2001 From: bnnm Date: Sat, 1 Dec 2018 02:39:25 +0100 Subject: [PATCH 1/9] Add minor opus bad data check --- src/coding/ffmpeg_decoder_custom_opus.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/coding/ffmpeg_decoder_custom_opus.c b/src/coding/ffmpeg_decoder_custom_opus.c index 1203ece0..8b580170 100644 --- a/src/coding/ffmpeg_decoder_custom_opus.c +++ b/src/coding/ffmpeg_decoder_custom_opus.c @@ -205,6 +205,12 @@ static size_t opus_io_size(STREAMFILE *streamfile, opus_io_data* data) { default: return 0; } + + if (data_size == 0 ) { + VGM_LOG("OPUS: data_size is 0 at %"PRIx64"\n", (off64_t)physical_offset); + return 0; /* bad rip? or could 'break' and truck along */ + } + oggs_size = 0x1b + (int)(data_size / 0xFF + 1); /* OggS page: base size + lacing values */ physical_offset += data_size + skip_size; From 0706aeffbfcd88b2508f24f39d1a989147d2c7ef Mon Sep 17 00:00:00 2001 From: bnnm Date: Sat, 1 Dec 2018 02:40:28 +0100 Subject: [PATCH 2/9] Fix some GENH with small header_size and allow N channel DSPs - "DSP coef right offset" becomes "DSP coef spacing" when channels is more than 2 --- src/meta/genh.c | 93 +++++++++++++++++++++++++++++-------------------- 1 file changed, 56 insertions(+), 37 deletions(-) diff --git a/src/meta/genh.c b/src/meta/genh.c index b9d37dc5..86b91fd4 100644 --- a/src/meta/genh.c +++ b/src/meta/genh.c @@ -52,8 +52,10 @@ typedef struct { int loop_flag; - int32_t coef[2]; - int32_t coef_splitted[2]; + int32_t coef_offset; + int32_t coef_spacing; + int32_t coef_split_offset; + int32_t coef_split_spacing; int32_t coef_type; int32_t coef_interleave_type; int coef_big_endian; @@ -233,16 +235,16 @@ VGMSTREAM * init_vgmstream_genh(STREAMFILE *streamFile) { for (i=0;ichannels;i++) { int16_t (*read_16bit)(off_t , STREAMFILE*) = genh.coef_big_endian ? read_16bitBE : read_16bitLE; - /* normal/split coefs bit flag */ - if ((genh.coef_type & 1) == 0) { /* not set: normal coefs, all 16 interleaved into one array */ - for (j=0;j<16;j++) { - vgmstream->ch[i].adpcm_coef[j] = read_16bit(genh.coef[i]+j*2,streamFile); + /* normal/split coefs */ + if ((genh.coef_type & 1) == 0) { /* normal mode */ + for (j = 0; j < 16; j++) { + vgmstream->ch[i].adpcm_coef[j] = read_16bit(genh.coef_offset + i*genh.coef_spacing + j*2, streamFile); } } - else { /* set: split coefs, 8 coefs in the main array, additional offset to 2nd array given at 0x34 for left, 0x38 for right */ - for (j=0;j<8;j++) { - vgmstream->ch[i].adpcm_coef[j*2]=read_16bit(genh.coef[i]+j*2,streamFile); - vgmstream->ch[i].adpcm_coef[j*2+1]=read_16bit(genh.coef_splitted[i]+j*2,streamFile); + else { /* split coefs, 8 coefs in the main array, additional offset to 2nd array given at 0x34 for left, 0x38 for right */ + for (j = 0; j < 8; j++) { + vgmstream->ch[i].adpcm_coef[j*2] = read_16bit(genh.coef_offset + i*genh.coef_spacing + j*2, streamFile); + vgmstream->ch[i].adpcm_coef[j*2+1] = read_16bit(genh.coef_split_offset + i*genh.coef_split_spacing + j*2, streamFile); } } } @@ -344,10 +346,10 @@ fail: static int parse_genh(STREAMFILE * streamFile, genh_header * genh) { size_t header_size; - genh->channels = read_32bitLE(0x4,streamFile); + genh->channels = read_32bitLE(0x04,streamFile); - genh->interleave = read_32bitLE(0x8,streamFile); - genh->sample_rate = read_32bitLE(0xc,streamFile); + genh->interleave = read_32bitLE(0x08,streamFile); + genh->sample_rate = read_32bitLE(0x0c,streamFile); genh->loop_start_sample = read_32bitLE(0x10,streamFile); genh->loop_end_sample = read_32bitLE(0x14,streamFile); @@ -359,37 +361,54 @@ static int parse_genh(STREAMFILE * streamFile, genh_header * genh) { genh->start_offset = 0x800; header_size = 0x800; } - /* check for audio data start past header end */ - if (header_size > genh->start_offset) goto fail; - genh->coef[0] = read_32bitLE(0x24,streamFile); - genh->coef[1] = read_32bitLE(0x28,streamFile); - genh->coef_interleave_type = read_32bitLE(0x2C,streamFile); + if (header_size > genh->start_offset) /* audio data start past header end */ + goto fail; + if (header_size < 0x24) /* absolute minimum for GENH */ + goto fail; + + /* DSP coefficients */ + if (header_size >= 0x30) { + genh->coef_offset = read_32bitLE(0x24,streamFile); + if (genh->channels == 2) /* old meaning, "coef right offset" */ + genh->coef_spacing = read_32bitLE(0x28,streamFile) - genh->coef_offset; + else if (genh->channels > 2) /* new meaning, "coef spacing" */ + genh->coef_spacing = read_32bitLE(0x28,streamFile); + genh->coef_interleave_type = read_32bitLE(0x2C,streamFile); + } /* DSP coefficient variants */ - /* bit 0 flag - split coefs (2 arrays) */ - /* bit 1 flag - little endian coefs (for some 3DS) */ - genh->coef_type = read_32bitLE(0x30,streamFile); - genh->coef_big_endian = ((genh->coef_type & 2) == 0); + if (header_size >= 0x34) { + /* bit 0 flag - split coefs (2 arrays) */ + /* bit 1 flag - little endian coefs (for some 3DS) */ + genh->coef_type = read_32bitLE(0x30,streamFile); + genh->coef_big_endian = ((genh->coef_type & 2) == 0); + } - /* when using split coefficients, 2nd array is at: */ - genh->coef_splitted[0] = read_32bitLE(0x34,streamFile); - genh->coef_splitted[1] = read_32bitLE(0x38,streamFile); + /* DSP split coefficients' 2nd array */ + if (header_size >= 0x3c) { + genh->coef_split_offset = read_32bitLE(0x34,streamFile); + if (genh->channels == 2) /* old meaning, "coef right offset" */ + genh->coef_split_spacing = read_32bitLE(0x38,streamFile) - genh->coef_split_offset; + else if (genh->channels > 2) /* new meaning, "coef spacing" */ + genh->coef_split_spacing = read_32bitLE(0x38,streamFile); + } + + /* extended fields */ + if (header_size >= 0x54) { + genh->num_samples = read_32bitLE(0x40,streamFile); + genh->skip_samples = read_32bitLE(0x44,streamFile); /* for FFmpeg based codecs */ + genh->skip_samples_mode = read_8bit(0x48,streamFile); /* 0=autodetect, 1=force manual value @ 0x44 */ + genh->codec_mode = read_8bit(0x4b,streamFile); + if ((genh->codec == ATRAC3 || genh->codec == ATRAC3PLUS) && genh->codec_mode==0) + genh->codec_mode = read_8bit(0x49,streamFile); + if ((genh->codec == XMA1 || genh->codec == XMA2) && genh->codec_mode==0) + genh->codec_mode = read_8bit(0x4a,streamFile); + genh->data_size = read_32bitLE(0x50,streamFile); + } - /* other fields */ - genh->num_samples = read_32bitLE(0x40,streamFile); - genh->skip_samples = read_32bitLE(0x44,streamFile); /* for FFmpeg based codecs */ - genh->skip_samples_mode = read_8bit(0x48,streamFile); /* 0=autodetect, 1=force manual value @ 0x44 */ - genh->codec_mode = read_8bit(0x4b,streamFile); - if ((genh->codec == ATRAC3 || genh->codec == ATRAC3PLUS) && genh->codec_mode==0) - genh->codec_mode = read_8bit(0x49,streamFile); - if ((genh->codec == XMA1 || genh->codec == XMA2) && genh->codec_mode==0) - genh->codec_mode = read_8bit(0x4a,streamFile); - genh->data_size = read_32bitLE(0x50,streamFile); if (genh->data_size == 0) genh->data_size = get_streamfile_size(streamFile) - genh->start_offset; - - genh->num_samples = genh->num_samples > 0 ? genh->num_samples : genh->loop_end_sample; genh->loop_flag = genh->loop_start_sample != -1; From 13e0b1b348f458c63774e3faf6d0d013d5f522c1 Mon Sep 17 00:00:00 2001 From: bnnm Date: Sat, 1 Dec 2018 02:41:56 +0100 Subject: [PATCH 3/9] Fix some TXTH operator/body_file issues --- src/meta/txth.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/meta/txth.c b/src/meta/txth.c index 53a4b5a6..00978529 100644 --- a/src/meta/txth.c +++ b/src/meta/txth.c @@ -303,17 +303,17 @@ VGMSTREAM * init_vgmstream_txth(STREAMFILE *streamFile) { int16_t (*read_16bit)(off_t , STREAMFILE*) = txth.coef_big_endian ? read_16bitBE : read_16bitLE; /* normal/split coefs */ - if (txth.coef_mode == 0) { - for (j=0;j<16;j++) { - vgmstream->ch[i].adpcm_coef[j] = read_16bit(txth.coef_offset + i*txth.coef_spacing + j*2,txth.streamHead); + if (txth.coef_mode == 0) { /* normal mode */ + for (j = 0; j < 16; j++) { + vgmstream->ch[i].adpcm_coef[j] = read_16bit(txth.coef_offset + i*txth.coef_spacing + j*2, txth.streamHead); } } - else { + else { /* split coefs */ goto fail; //IDK what is this /* - for (j=0;j<8;j++) { - vgmstream->ch[i].adpcm_coef[j*2]=read_16bit(coef[i]+j*2,txth.streamHead); - vgmstream->ch[i].adpcm_coef[j*2+1]=read_16bit(coef_splitted[i]+j*2,txth.streamHead); + for (j = 0; j < 8; j++) { + vgmstream->ch[i].adpcm_coef[j*2] = read_16bit(genh.coef_offset + i*genh.coef_spacing + j*2, txth.streamHead); + vgmstream->ch[i].adpcm_coef[j*2+1] = read_16bit(genh.coef_split_offset + i*genh.coef_split_spacing + j*2, txth.streamHead); } */ } @@ -508,6 +508,7 @@ static int parse_txth(txth_header * txth) { bytes_read = get_streamfile_text_line(TXT_LINE_MAX,line, txt_offset,txth->streamText, &line_done); if (!line_done) goto fail; + //;VGM_LOG("TXTH: line=%s\n",line); txt_offset += bytes_read; @@ -759,6 +760,11 @@ static int parse_keyval(STREAMFILE * streamFile_, txth_header * txth, const char txth->streambody_opened = 1; } + /* use body as header when opening a .txth directly to simplify things */ + if (txth->streamfile_is_txth && !txth->streamhead_opened) { + txth->streamHead = txth->streamBody; + } + txth->data_size = !txth->streamBody ? 0 : get_streamfile_size(txth->streamBody) - txth->start_offset; /* re-evaluate */ } @@ -841,13 +847,14 @@ static int parse_num(STREAMFILE * streamFile, txth_header * txth, const char * v else goto fail; } - if (value_mul) + /* operators, but only if current value wasn't set to 0 right before */ + if (value_mul && txth->value_mul) *out_value = (*out_value) * value_mul; - if (value_div) + if (value_div && txth->value_div) *out_value = (*out_value) / value_div; - if (value_add) + if (value_add && txth->value_add) *out_value = (*out_value) + value_add; - if (value_sub) + if (value_sub && txth->value_sub) *out_value = (*out_value) - value_sub; //;VGM_LOG("TXTH: val=%s, read %u (0x%x)\n", val, *out_value, *out_value); From c87aff04f93974a2a2209ff61297de1c96ee3b30 Mon Sep 17 00:00:00 2001 From: bnnm Date: Sat, 1 Dec 2018 02:47:57 +0100 Subject: [PATCH 4/9] Add opus+sli looping [Sabbat of the Witch (PC)] --- src/formats.c | 6 +++--- src/meta/sli.c | 41 +++++++++++++++++++++++++++++------------ src/vgmstream.h | 2 +- 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/src/formats.c b/src/formats.c index d6f1e798..8530d34b 100644 --- a/src/formats.c +++ b/src/formats.c @@ -1046,9 +1046,9 @@ static const meta_info meta_info_list[] = { {meta_PC_FLX, "Ultima IX .FLX header"}, {meta_MOGG, "Harmonix Music Systems MOGG Vorbis"}, {meta_OGG_VORBIS, "Ogg Vorbis"}, - {meta_OGG_SLI, "Ogg Vorbis with .sli (start,length) for looping"}, - {meta_OGG_SLI2, "Ogg Vorbis with .sli (from,to) for looping"}, - {meta_OGG_SFL, "Ogg Vorbis with SFPL for looping"}, + {meta_OGG_SLI, "Ogg Vorbis with .sli looping"}, + {meta_OPUS_SLI, "Ogg Opus with .sli looping"}, + {meta_OGG_SFL, "Ogg Vorbis with SFPL looping"}, {meta_OGG_KOVS, "Ogg Vorbis (KOVS header)"}, {meta_OGG_encrypted, "Ogg Vorbis (encrypted)"}, {meta_KMA9, "Koei Tecmo KMA9 header"}, diff --git a/src/meta/sli.c b/src/meta/sli.c index f4ed5024..2ecf5427 100644 --- a/src/meta/sli.c +++ b/src/meta/sli.c @@ -2,7 +2,7 @@ #include -/* .sli - loop points associated with a similarly named .ogg [Fate/Stay Night (PC), World End Economica (PC)]*/ +/* .sli+ogg/opus - KiriKiri engine / WaveLoopManager loop points loader [Fate/Stay Night (PC), World End Economica (PC)] */ VGMSTREAM * init_vgmstream_sli_ogg(STREAMFILE *streamFile) { VGMSTREAM * vgmstream = NULL; STREAMFILE * streamData = NULL; @@ -14,23 +14,42 @@ VGMSTREAM * init_vgmstream_sli_ogg(STREAMFILE *streamFile) { goto fail; { - /* try with file.ogg.sli=header and file.ogg=data */ + /* try with file.ogg/opus.sli=header and file.ogg/opus=data */ char basename[PATH_LIMIT]; get_streamfile_basename(streamFile,basename,PATH_LIMIT); streamData = open_streamfile_by_filename(streamFile, basename); if (!streamData) goto fail; - - if (!check_extensions(streamData, "ogg")) - goto fail; } -#ifdef VGM_USE_VORBIS + /* let the real initer do the parsing */ - vgmstream = init_vgmstream_ogg_vorbis(streamData); - if (!vgmstream) goto fail; + if (check_extensions(streamData, "ogg")) { /* Fate/Stay Night (PC) */ +#ifdef VGM_USE_VORBIS + vgmstream = init_vgmstream_ogg_vorbis(streamData); + if (!vgmstream) goto fail; + + vgmstream->meta_type = meta_OGG_SLI; #else goto fail; #endif + } + else if (check_extensions(streamData, "opus")) { /* Sabbat of the Witch (PC) */ +#ifdef VGM_USE_FFMPEG + vgmstream = init_vgmstream_ffmpeg(streamData); + if (!vgmstream) goto fail; + + /* FFmpeg's Opus encoder delay is borked but no need to fix: + * somehow sli+opus use 0 in the OpusHead (to simplify looping?) */ + + vgmstream->meta_type = meta_OPUS_SLI; +#else + goto fail; +#endif + } + else { + goto fail; + } + /* find loop text */ { @@ -77,13 +96,11 @@ VGMSTREAM * init_vgmstream_sli_ogg(STREAMFILE *streamFile) { } } - if (loop_start != -1 && loop_length != -1) { + if (loop_start != -1 && loop_length != -1) { /* v1 */ vgmstream_force_loop(vgmstream,1,loop_start, loop_start+loop_length); - vgmstream->meta_type = meta_OGG_SLI; } - else if (loop_from != -1 && loop_to != -1) { + else if (loop_from != -1 && loop_to != -1) { /* v2 */ vgmstream_force_loop(vgmstream,1,loop_to, loop_from); - vgmstream->meta_type = meta_OGG_SLI2; } else { goto fail; /* if there's no loop points the .sli wasn't valid */ diff --git a/src/vgmstream.h b/src/vgmstream.h index 9a3f81d9..da7709b5 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -641,7 +641,7 @@ typedef enum { meta_MOGG, /* Harmonix Music Systems MOGG Vorbis */ meta_OGG_VORBIS, /* Ogg Vorbis */ meta_OGG_SLI, /* Ogg Vorbis file w/ companion .sli for looping */ - meta_OGG_SLI2, /* Ogg Vorbis file w/ different styled .sli for looping */ + meta_OPUS_SLI, /* Ogg Opus file w/ companion .sli for looping */ meta_OGG_SFL, /* Ogg Vorbis file w/ .sfl (RIFF SFPL) for looping */ meta_OGG_KOVS, /* Ogg Vorbis with header and encryption (Koei Tecmo Games) */ meta_OGG_encrypted, /* Ogg Vorbis with encryption */ From b3d77689a777168087390b1cac502a24f35b1593 Mon Sep 17 00:00:00 2001 From: bnnm Date: Sat, 1 Dec 2018 14:00:59 +0100 Subject: [PATCH 5/9] Fix Winamp not showing default subsong title --- winamp/in_vgmstream.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/winamp/in_vgmstream.c b/winamp/in_vgmstream.c index ef88df28..10f2c44a 100644 --- a/winamp/in_vgmstream.c +++ b/winamp/in_vgmstream.c @@ -1436,6 +1436,7 @@ __declspec(dllexport) In_Module * winampGetInModule2() { #define WINAMP_TAGS_ENTRY_SIZE 2048 typedef struct { + int loaded; in_char filename[PATH_LIMIT]; /* tags are loaded for this file */ int tag_count; @@ -1457,8 +1458,9 @@ static void load_tagfile_info(in_char* filename) { char *path; - if (settings.tagfile_disable) { - last_tags.tag_count = 0; /* maybe helps if setting changes during play */ + if (settings.tagfile_disable) { /* reset values if setting changes during play */ + last_tags.loaded = 0; + last_tags.tag_count = 0; return; } @@ -1469,6 +1471,8 @@ static void load_tagfile_info(in_char* filename) { return; /* not changed, tags still apply */ } + last_tags.loaded = 0; + /* tags are now for this filename, find tagfile path */ wa_ichar_to_char(filename_utf8, PATH_LIMIT, filename_clean); strcpy(tagfile_path_utf8,filename_utf8); @@ -1517,6 +1521,7 @@ static void load_tagfile_info(in_char* filename) { } close_streamfile(tagFile); + last_tags.loaded = 1; } } @@ -1529,16 +1534,17 @@ static int winampGetExtendedFileInfo_common(in_char* filename, char *metadata, c int i, tag_found; int max_len; + /* load list current tags, if necessary */ + load_tagfile_info(filename); + if (!last_tags.loaded) /* tagfile not found, fail so default get_title takes over */ + goto fail; + /* always called (value in ms), must return ok so other tags get called */ if (strcasecmp(metadata, "length") == 0) { strcpy(ret, "0");//todo should export but shows GetFileInfo's ms if not provided return 1; } - /* load list current tags, if necessary */ - load_tagfile_info(filename); - - #if 0 /* special case to fill WA5's unified dialog */ if (strcasecmp(metadata, "formatinformation") == 0) { From 42bc5de623fe3a8f9ea641f77f13be65e5a127d6 Mon Sep 17 00:00:00 2001 From: bnnm Date: Sat, 1 Dec 2018 14:01:52 +0100 Subject: [PATCH 6/9] Add From Software .xps/.xps+dat [Metal Wolf Chaos (Xbox), Otogi (Xbox)] --- src/formats.c | 4 +- src/libvgmstream.vcproj | 4 + src/libvgmstream.vcxproj | 1 + src/libvgmstream.vcxproj.filters | 3 + src/meta/meta.h | 3 + src/meta/xps.c | 223 +++++++++++++++++++++++++++++++ src/vgmstream.c | 2 + src/vgmstream.h | 1 + 8 files changed, 240 insertions(+), 1 deletion(-) create mode 100644 src/meta/xps.c diff --git a/src/formats.c b/src/formats.c index 8530d34b..015cc16c 100644 --- a/src/formats.c +++ b/src/formats.c @@ -472,6 +472,7 @@ static const char* extension_list[] = { "xwb", "xmd", "xopus", + "xps", "xwc", "xwm", "xwma", @@ -1112,7 +1113,8 @@ static const meta_info meta_info_list[] = { {meta_VS_FFX, "Square VS header"}, {meta_NWAV, "Chunsoft NWAV header"}, {meta_XPCM, "Circus XPCM header"}, - {meta_MSF_TAMASOFT, "TamaSoft MSF header"}, + {meta_MSF_TAMASOFT, "Tama-Soft MSF header"}, + {meta_XPS_DAT, "From Software .XPS+DAT header"}, }; diff --git a/src/libvgmstream.vcproj b/src/libvgmstream.vcproj index cfc9bf4a..2ad722bc 100644 --- a/src/libvgmstream.vcproj +++ b/src/libvgmstream.vcproj @@ -1625,6 +1625,10 @@ + + + diff --git a/src/libvgmstream.vcxproj.filters b/src/libvgmstream.vcxproj.filters index a82efc8b..3ebfb4bc 100644 --- a/src/libvgmstream.vcxproj.filters +++ b/src/libvgmstream.vcxproj.filters @@ -1465,6 +1465,9 @@ meta\Source Files + + meta\Source Files + meta\Source Files diff --git a/src/meta/meta.h b/src/meta/meta.h index 01158936..3e6f0f50 100644 --- a/src/meta/meta.h +++ b/src/meta/meta.h @@ -810,4 +810,7 @@ VGMSTREAM * init_vgmstream_xpcm(STREAMFILE * streamFile); VGMSTREAM * init_vgmstream_msf_tamasoft(STREAMFILE * streamFile); +VGMSTREAM * init_vgmstream_xps_dat(STREAMFILE * streamFile); +VGMSTREAM * init_vgmstream_xps(STREAMFILE * streamFile); + #endif /*_META_H*/ diff --git a/src/meta/xps.c b/src/meta/xps.c new file mode 100644 index 00000000..da84fbb5 --- /dev/null +++ b/src/meta/xps.c @@ -0,0 +1,223 @@ +#include "meta.h" +#include "../coding/coding.h" + +static void read_xps_name(VGMSTREAM *vgmstream, STREAMFILE *streamFile, int file_id); + +/* .XPS+DAT - From Software games streams [Metal Wolf Chaos (Xbox), Otogi (Xbox)] */ +VGMSTREAM * init_vgmstream_xps_dat(STREAMFILE *streamFile) { + VGMSTREAM * vgmstream = NULL; + STREAMFILE * streamData = NULL; + off_t start_offset, header_offset; + size_t stream_size; + int loop_flag, channel_count, sample_rate, codec, loop_start_sample, loop_end_sample, file_id; + int total_subsongs, target_subsong = streamFile->stream_index; + + + /* checks */ + if (!check_extensions(streamFile, "xps")) + goto fail; + + if (read_32bitLE(0x00,streamFile) != get_streamfile_size(streamFile)) + goto fail; + if (read_32bitBE(0x0c,streamFile) != 0x64696666) /* "diff" */ + goto fail; + + /* handle .xps+dat (bank .xps are done below) */ + streamData = open_streamfile_by_ext(streamFile, "dat"); + if (!streamData) goto fail; + + /* 0x00: approximate file size */ + + total_subsongs = read_32bitLE(0x04,streamData); + if (target_subsong == 0) target_subsong = 1; + if (target_subsong < 0 || target_subsong > total_subsongs || total_subsongs < 1) goto fail; + + header_offset = 0x20 + 0x94*(target_subsong-1); /* could start at 0x0c too */ + + file_id = read_32bitLE(header_offset+0x00,streamData); + start_offset = read_32bitLE(header_offset+0x04,streamData); + stream_size = read_32bitLE(header_offset+0x08,streamData); + /* 0x0c: loop start offset? */ + /* 0x10: loop end offset? */ + /* 0x14: always null? */ + codec = read_16bitLE(header_offset+0x18,streamData); + channel_count = read_16bitLE(header_offset+0x1a,streamData); + sample_rate = read_32bitLE(header_offset+0x1c,streamData); + /* 0x20: average bitrate */ + /* 0x24: block size, bps */ + loop_flag = read_32bitLE(header_offset+0x5c,streamData); + loop_start_sample = read_32bitLE(header_offset+0x6c,streamData); + loop_end_sample = read_32bitLE(header_offset+0x70,streamData) + 1; /* a "smpl" chunk basically */ + + + /* build the VGMSTREAM */ + vgmstream = allocate_vgmstream(channel_count, loop_flag); + if (!vgmstream) goto fail; + + vgmstream->sample_rate = sample_rate; + vgmstream->meta_type = meta_XPS_DAT; + vgmstream->loop_start_sample = loop_start_sample; + vgmstream->loop_end_sample = loop_end_sample; + vgmstream->num_streams = total_subsongs; + vgmstream->stream_size = stream_size; + + switch(codec) { + case 0x01: + vgmstream->coding_type = coding_PCM16LE; + vgmstream->layout_type = layout_interleave; + vgmstream->interleave_block_size = 0x02; + vgmstream->num_samples = pcm_bytes_to_samples(stream_size, channel_count, 16); + break; + + case 0x69: + vgmstream->coding_type = coding_XBOX_IMA; + vgmstream->layout_type = layout_none; + vgmstream->num_samples = xbox_ima_bytes_to_samples(stream_size, channel_count); + break; + + default: + goto fail; + } + + read_xps_name(vgmstream, streamFile, file_id); + + if (!vgmstream_open_stream(vgmstream,streamData,start_offset)) + goto fail; + + close_streamfile(streamData); + return vgmstream; + +fail: + close_streamfile(streamData); + close_vgmstream(vgmstream); + return NULL; +} + +static void read_xps_name(VGMSTREAM *vgmstream, STREAMFILE *streamFile, int file_id) { + int i, entries; + int name_id = -1, udss_name_id; + off_t entry_offset = 0x10; + + + /* main section + stream sections (usually same number but not always) */ + entries = read_32bitLE(0x04,streamFile); + + /* "sid\0" entries: find name_id of file_id */ + for (i = 0; i < entries; i++) { + off_t entry_base = entry_offset; + size_t entry_size = read_32bitLE(entry_base+0x00,streamFile); + uint32_t entry_id = read_32bitBE(entry_base+0x04,streamFile); + size_t entry_pad = read_32bitLE(entry_base+0x08,streamFile); + /* 0x0c: always null, rest: entry (format varies) */ + + entry_offset += entry_size + entry_pad + 0x10; + + /* sound info entry */ + if (entry_id == 0x73696400) { /* "sid\0" */ + int entry_file_id = read_32bitLE(entry_base+0x10,streamFile); + int entry_name_id = read_32bitLE(entry_base+0x14,streamFile); + if (entry_file_id == file_id && name_id == -1) { + name_id = entry_name_id; + } + continue; + } + + /* sound stream entry, otherwise no good */ + if (entry_id != 0x75647373) { /* "udss" */ + goto fail; + } + + udss_name_id = read_32bitLE(entry_base+0x10,streamFile); + if (udss_name_id == name_id) { + off_t name_offset = entry_base + 0x10 + 0x08; + size_t name_size = entry_size - 0x08; /* includes null */ + read_string(vgmstream->stream_name,name_size, name_offset,streamFile); + return; + } + } + +fail: + return; +} + +/* .XPS - From Software games banks [Metal Wolf Chaos (Xbox), Otogi (Xbox)] */ +VGMSTREAM * init_vgmstream_xps(STREAMFILE *streamFile) { + VGMSTREAM * vgmstream = NULL; + STREAMFILE * streamData = NULL; + int i, entries; + off_t entry_offset = 0x10; + int total_subsongs, target_subsong = streamFile->stream_index; + + + /* checks */ + if (!check_extensions(streamFile, "xps")) + goto fail; + + if (read_32bitLE(0x00,streamFile) != get_streamfile_size(streamFile)) + goto fail; + if (read_32bitBE(0x0c,streamFile) != 0x64696666) /* "diff" */ + goto fail; + + /* handle .xps alone (stream .xps+data are done above) */ + streamData = open_streamfile_by_ext(streamFile, "dat"); + if (streamData) goto fail; + + /* main section + bank sections (usually same number but not always) */ + entries = read_32bitLE(0x04,streamFile); + + total_subsongs = 0; + if (target_subsong == 0) target_subsong = 1; + if (target_subsong < 0 /*|| target_subsong > total_subsongs || total_subsongs < 1*/) goto fail; + + + /* parse entries: skip (there is probably a stream/bank flag here) */ + for (i = 0; i < entries; i++) { + off_t entry_base = entry_offset; + size_t entry_size = read_32bitLE(entry_base+0x00,streamFile); + uint32_t entry_id = read_32bitBE(entry_base+0x04,streamFile); + size_t entry_pad = read_32bitLE(entry_base+0x08,streamFile); + /* 0x0c: always null, rest: entry (format varies) */ + + entry_offset += entry_size + entry_pad + 0x10; + + /* sound info entry */ + if (entry_id == 0x73696400) { /* "sid\0" */ + /* keep looking for sound banks */ + continue; + } + + /* sound bank entry, otherwise no good */ + if (entry_id != 0x75647362) { /* "udsb" */ + goto fail; + } + + total_subsongs++; + + /* open internal RIFF */ + if (target_subsong == total_subsongs && vgmstream == NULL) { + STREAMFILE* temp_streamFile; + off_t subsong_offset = entry_base+0x18; + size_t subsong_size = read_32bitLE(entry_base+0x14,streamFile); + + temp_streamFile = setup_subfile_streamfile(streamFile, subsong_offset,subsong_size, "wav"); + if (!temp_streamFile) goto fail; + + vgmstream = init_vgmstream_riff(temp_streamFile); + close_streamfile(temp_streamFile); + if (!vgmstream) goto fail; + + } + } + + /* subsong not found */ + if (!vgmstream) + goto fail; + + vgmstream->num_streams = total_subsongs; + return vgmstream; + +fail: + close_streamfile(streamData); + close_vgmstream(vgmstream); + return NULL; +} diff --git a/src/vgmstream.c b/src/vgmstream.c index 2e870bb4..1f455f6a 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -450,6 +450,8 @@ VGMSTREAM * (*init_vgmstream_functions[])(STREAMFILE *streamFile) = { init_vgmstream_nwav, init_vgmstream_xpcm, init_vgmstream_msf_tamasoft, + init_vgmstream_xps_dat, + init_vgmstream_xps, /* lowest priority metas (should go after all metas, and TXTH should go before raw formats) */ init_vgmstream_txth, /* proper parsers should supersede TXTH, once added */ diff --git a/src/vgmstream.h b/src/vgmstream.h index da7709b5..cb107e02 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -706,6 +706,7 @@ typedef enum { meta_NWAV, meta_XPCM, meta_MSF_TAMASOFT, + meta_XPS_DAT, } meta_t; From 7a5cf59951ce1e41b1018b9412343de6cc683579 Mon Sep 17 00:00:00 2001 From: bnnm Date: Sat, 1 Dec 2018 18:33:43 +0100 Subject: [PATCH 7/9] Remove custom Opus skip_samples for newer FFmpeg + libopus --- src/coding/ffmpeg_decoder_custom_opus.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/coding/ffmpeg_decoder_custom_opus.c b/src/coding/ffmpeg_decoder_custom_opus.c index 8b580170..9be9b21b 100644 --- a/src/coding/ffmpeg_decoder_custom_opus.c +++ b/src/coding/ffmpeg_decoder_custom_opus.c @@ -622,9 +622,12 @@ static ffmpeg_codec_data * init_ffmpeg_custom_opus(STREAMFILE *streamFile, off_t ffmpeg_data = init_ffmpeg_offset(temp_streamFile, 0x00,get_streamfile_size(temp_streamFile)); if (!ffmpeg_data) goto fail; - if (ffmpeg_data->skipSamples <= 0) { - ffmpeg_set_skip_samples(ffmpeg_data, skip); - } + /* FFmpeg + libopus: skips samples, notifies skip in codecCtx->delay (not in stream->skip_samples) + * FFmpeg + opus: *doesn't* skip, also notifies skip in codecCtx->delay, hurray (possibly fixed in recent versions) + * FFmpeg + opus is audibly buggy with some low bitrate SSB Ultimate files too */ + //if (ffmpeg_data->skipSamples <= 0) { + // ffmpeg_set_skip_samples(ffmpeg_data, skip); + //} close_streamfile(temp_streamFile); return ffmpeg_data; From a960a12e5864e8aa6ba1644e41533d8a21da69d4 Mon Sep 17 00:00:00 2001 From: bnnm Date: Sat, 1 Dec 2018 18:34:23 +0100 Subject: [PATCH 8/9] Fix some compiler warning/errors with libs disabled --- doc/BUILD.md | 2 +- ext_libs/clHCA.c | 6 +++--- src/meta/pos.c | 6 +++++- src/meta/ue4opus.c | 8 ++++---- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/doc/BUILD.md b/doc/BUILD.md index 8f9c260d..1d330660 100644 --- a/doc/BUILD.md +++ b/doc/BUILD.md @@ -30,7 +30,7 @@ **With GCC**: use the *./Makefile* in the root folder, see inside for options. For compilation flags check the *Makefile* in each folder. You may need to manually rebuild if you change a *.h* file (use *make clean*). -In Linux, Makefiles can be used to cross-compile with the MingW headers, but may not be updated to generate native code at the moment. It should be fixable with some effort. Autotools should build it as vgmstream-cli instead (see the Audacious section). +In Linux, Makefiles can be used to cross-compile with the MingW headers, but may not be updated to generate native code at the moment. It should be fixable with some effort. Autotools should build it as vgmstream-cli instead (see the Audacious section). Some Linux distributions like Arch Linux include pre-patched vgmstream with most libraries, you may want that instead (see: https://aur.archlinux.org/packages/vgmstream-kode54-git/). Windows CMD example: ``` diff --git a/ext_libs/clHCA.c b/ext_libs/clHCA.c index 0faea50b..5a7ae962 100644 --- a/ext_libs/clHCA.c +++ b/ext_libs/clHCA.c @@ -1551,9 +1551,9 @@ static const unsigned int decode5_imdct_window_int[128] = { static const float *decode5_imdct_window = (const float *)decode5_imdct_window_int; static void decoder5_run_imdct(stChannel *ch, int subframe) { - const static unsigned int size = HCA_SAMPLES_PER_SUBFRAME; - const static unsigned int half = HCA_SAMPLES_PER_SUBFRAME / 2; - const static unsigned int mdct_bits = HCA_MDCT_BITS; + static const unsigned int size = HCA_SAMPLES_PER_SUBFRAME; + static const unsigned int half = HCA_SAMPLES_PER_SUBFRAME / 2; + static const unsigned int mdct_bits = HCA_MDCT_BITS; /* apply DCT-IV to dequantized spectra */ diff --git a/src/meta/pos.c b/src/meta/pos.c index 0c904d62..5e499ce6 100644 --- a/src/meta/pos.c +++ b/src/meta/pos.c @@ -15,11 +15,12 @@ VGMSTREAM * init_vgmstream_pos(STREAMFILE *streamFile) { streamData = open_streamfile_by_ext(streamFile, "wav"); if (streamData) { - vgmstream = init_vgmstream_riff(streamData); + vgmstream = init_vgmstream_riff(streamData); if (!vgmstream) goto fail; vgmstream->meta_type = meta_RIFF_WAVE_POS; } else { +#ifdef VGM_USE_VORBIS /* hack for Ogg with external loops */ streamData = open_streamfile_by_ext(streamFile, "ogg"); if (streamData) { @@ -29,6 +30,9 @@ VGMSTREAM * init_vgmstream_pos(STREAMFILE *streamFile) { else { goto fail; } +#else + goto fail; +#endif } close_streamfile(streamData); diff --git a/src/meta/ue4opus.c b/src/meta/ue4opus.c index 516dac08..b3a3e489 100644 --- a/src/meta/ue4opus.c +++ b/src/meta/ue4opus.c @@ -29,9 +29,6 @@ VGMSTREAM * init_vgmstream_ue4opus(STREAMFILE *streamFile) { start_offset = 0x11; data_size = get_streamfile_size(streamFile) - start_offset; - /* usually uses 60ms for music (delay of 360 samples) */ - skip = ue4_opus_get_encoder_delay(start_offset, streamFile); - /* build the VGMSTREAM */ vgmstream = allocate_vgmstream(channel_count, loop_flag); @@ -39,10 +36,13 @@ VGMSTREAM * init_vgmstream_ue4opus(STREAMFILE *streamFile) { vgmstream->meta_type = meta_UE4OPUS; vgmstream->sample_rate = sample_rate; - vgmstream->num_samples = num_samples - skip; #ifdef VGM_USE_FFMPEG { + /* usually uses 60ms for music (delay of 360 samples) */ + skip = ue4_opus_get_encoder_delay(start_offset, streamFile); + vgmstream->num_samples = num_samples - skip; + vgmstream->codec_data = init_ffmpeg_ue4_opus(streamFile, start_offset,data_size, vgmstream->channels, skip, vgmstream->sample_rate); if (!vgmstream->codec_data) goto fail; vgmstream->coding_type = coding_FFmpeg; From eaa176864c5d21d10fd1c4da66c9f5ebe4dc1ae7 Mon Sep 17 00:00:00 2001 From: bnnm Date: Sat, 1 Dec 2018 18:52:30 +0100 Subject: [PATCH 9/9] Simplify debug off_t casting for easier build Also reorder some custom opus funcs that don't depend on ffmpeg --- src/coding/atrac9_decoder.c | 2 +- src/coding/celt_fsb_decoder.c | 2 +- src/coding/coding_utils.c | 10 ++++----- src/coding/ffmpeg_decoder_custom_opus.c | 29 +++++++++++++------------ src/coding/hca_decoder.c | 4 ++-- src/coding/mpeg_custom_utils.c | 2 +- src/coding/mpeg_custom_utils_awc.c | 2 +- src/coding/mpeg_custom_utils_ealayer3.c | 6 ++--- src/coding/mpeg_decoder.c | 2 +- src/coding/mta2_decoder.c | 2 +- src/coding/mtaf_decoder.c | 4 ++-- src/coding/ngc_dtk_decoder.c | 2 +- src/coding/psx_decoder.c | 8 +++---- src/coding/vorbis_custom_decoder.c | 6 ++--- src/coding/xa_decoder.c | 4 ++-- src/layout/blocked.c | 2 +- src/layout/blocked_h4m.c | 2 +- src/layout/blocked_xa.c | 4 ++-- src/meta/awc.c | 2 +- src/meta/fsb5.c | 2 +- src/meta/ubi_bao.c | 20 ++++++++--------- src/streamfile.c | 4 ++-- 22 files changed, 61 insertions(+), 60 deletions(-) diff --git a/src/coding/atrac9_decoder.c b/src/coding/atrac9_decoder.c index d46a7c43..209c37fa 100644 --- a/src/coding/atrac9_decoder.c +++ b/src/coding/atrac9_decoder.c @@ -128,7 +128,7 @@ void decode_atrac9(VGMSTREAM *vgmstream, sample * outbuf, int32_t samples_to_do, decode_fail: /* on error just put some 0 samples */ - VGM_LOG("ATRAC9: decode fail at %"PRIx64", missing %i samples\n", (off64_t)stream->offset, (samples_to_do - samples_done)); + VGM_LOG("ATRAC9: decode fail at %x, missing %i samples\n", (uint32_t)stream->offset, (samples_to_do - samples_done)); memset(outbuf + samples_done * channels, 0, (samples_to_do - samples_done) * sizeof(sample) * channels); } diff --git a/src/coding/celt_fsb_decoder.c b/src/coding/celt_fsb_decoder.c index dbf3ba2f..b2805ccc 100644 --- a/src/coding/celt_fsb_decoder.c +++ b/src/coding/celt_fsb_decoder.c @@ -157,7 +157,7 @@ void decode_celt_fsb(VGMSTREAM *vgmstream, sample * outbuf, int32_t samples_to_d decode_fail: /* on error just put some 0 samples */ - VGM_LOG("CELT: decode fail at %"PRIx64", missing %i samples\n", (off64_t)stream->offset, (samples_to_do - samples_done)); + VGM_LOG("CELT: decode fail at %x, missing %i samples\n", (uint32_t)stream->offset, (samples_to_do - samples_done)); memset(outbuf + samples_done * channels, 0, (samples_to_do - samples_done) * sizeof(sample) * channels); } diff --git a/src/coding/coding_utils.c b/src/coding/coding_utils.c index 537b97cd..8b601ccd 100644 --- a/src/coding/coding_utils.c +++ b/src/coding/coding_utils.c @@ -470,17 +470,17 @@ static void ms_audio_parse_header(STREAMFILE *streamFile, int xma_version, off_t /* full packet skip, no new frames start in this packet (prev frames can end here) * standardized to some value */ if (*packet_skip_count == 0x7FF) { /* XMA1, 11b */ - VGM_LOG("MS_SAMPLES: XMA1 full packet_skip at 0x%"PRIx64"\n", (off64_t)offset_b/8); + VGM_LOG("MS_SAMPLES: XMA1 full packet_skip at 0x%x\n", (uint32_t)offset_b/8); *packet_skip_count = 0x800; } else if (*packet_skip_count == 0xFF) { /* XMA2, 8b*/ - VGM_LOG("MS_SAMPLES: XMA2 full packet_skip at 0x%"PRIx64"\n", (off64_t)offset_b/8); + VGM_LOG("MS_SAMPLES: XMA2 full packet_skip at 0x%x\n", (uint32_t)offset_b/8); *packet_skip_count = 0x800; } /* unusual but not impossible, as the encoder can interleave packets in any way */ VGM_ASSERT((*packet_skip_count > 10 && *packet_skip_count < 0x800), - "MS_SAMPLES: found big packet skip %i at 0x%"PRIx64"\n", *packet_skip_count, (off64_t)offset_b/8); + "MS_SAMPLES: found big packet skip %i at 0x%x\n", *packet_skip_count, (uint32_t)offset_b/8); } /** @@ -636,7 +636,7 @@ static void ms_audio_get_skips(STREAMFILE *streamFile, int xma_version, off_t da frame_offset_b += 1; if (flag) { int new_skip = read_bitsBE_b(frame_offset_b, 10, streamFile); - //;VGM_LOG("MS_SAMPLES: start_skip %i at 0x%"PRIx64" (bit 0x%"PRIx64")\n", new_skip, (off64_t)frame_offset_b/8, (off64_t)frame_offset_b); + //;VGM_LOG("MS_SAMPLES: start_skip %i at 0x%x (bit 0x%x)\n", new_skip, (uint32_t)frame_offset_b/8, (uint32_t)frame_offset_b); frame_offset_b += 10; if (new_skip > samples_per_frame) /* from xmaencode */ @@ -651,7 +651,7 @@ static void ms_audio_get_skips(STREAMFILE *streamFile, int xma_version, off_t da frame_offset_b += 1; if (flag) { int new_skip = read_bitsBE_b(frame_offset_b, 10, streamFile); - //;VGM_LOG("MS_SAMPLES: end_skip %i at 0x%"PRIx64" (bit 0x%"PRIx64")\n", new_skip, (off64_t)frame_offset_b/8, (off64_t)frame_offset_b); + //;VGM_LOG("MS_SAMPLES: end_skip %i at 0x%x (bit 0x%x)\n", new_skip, (uint32_t)frame_offset_b/8, (uint32_t)frame_offset_b); frame_offset_b += 10; if (new_skip > samples_per_frame) /* from xmaencode */ diff --git a/src/coding/ffmpeg_decoder_custom_opus.c b/src/coding/ffmpeg_decoder_custom_opus.c index 9be9b21b..92e0513d 100644 --- a/src/coding/ffmpeg_decoder_custom_opus.c +++ b/src/coding/ffmpeg_decoder_custom_opus.c @@ -119,7 +119,7 @@ static size_t opus_io_read(STREAMFILE *streamfile, uint8_t *dest, off_t offset, data->page_size = oggs_size + data_size; if (data->page_size > sizeof(data->page_buffer)) { /* happens on bad reads/EOF too */ - VGM_LOG("OPUS: buffer can't hold OggS at %"PRIx64"\n", (off64_t)data->physical_offset); + VGM_LOG("OPUS: buffer can't hold OggS at %x\n", (uint32_t)data->physical_offset); data->page_size = 0; break; } @@ -173,7 +173,7 @@ static size_t opus_io_size(STREAMFILE *streamfile, opus_io_data* data) { return data->logical_size; if (data->stream_offset + data->stream_size > get_streamfile_size(streamfile)) { - VGM_LOG("OPUS: wrong streamsize %"PRIx64" + %x vs %x\n", (off64_t)data->stream_offset, data->stream_size, get_streamfile_size(streamfile)); + VGM_LOG("OPUS: wrong streamsize %x + %x vs %x\n", (uint32_t)data->stream_offset, data->stream_size, get_streamfile_size(streamfile)); return 0; } @@ -207,7 +207,7 @@ static size_t opus_io_size(STREAMFILE *streamfile, opus_io_data* data) { } if (data_size == 0 ) { - VGM_LOG("OPUS: data_size is 0 at %"PRIx64"\n", (off64_t)physical_offset); + VGM_LOG("OPUS: data_size is 0 at %x\n", (uint32_t)physical_offset); return 0; /* bad rip? or could 'break' and truck along */ } @@ -507,14 +507,22 @@ fail: return 0; } -/************************** */ - -#ifdef VGM_USE_FFMPEG - static size_t opus_get_packet_samples(const uint8_t * buf, int len) { return opus_packet_get_nb_frames(buf, len) * opus_packet_get_samples_per_frame(buf, 48000); } +/************************** */ + +static size_t get_xopus_packet_size(int packet, STREAMFILE * streamfile) { + /* XOPUS has a packet size table at the beginning, get size from there. + * Maybe should copy the table during setup to avoid IO, but all XOPUS are + * quite small so it isn't very noticeable. */ + return (uint16_t)read_16bitLE(0x20 + packet*0x02, streamfile); +} + + +#ifdef VGM_USE_FFMPEG + static size_t custom_opus_get_samples(off_t offset, size_t data_size, STREAMFILE *streamFile, opus_type_t type) { size_t num_samples = 0; off_t end_offset = offset + data_size; @@ -602,13 +610,6 @@ size_t ea_opus_get_encoder_delay(off_t offset, STREAMFILE *streamFile) { } -static size_t get_xopus_packet_size(int packet, STREAMFILE * streamfile) { - /* XOPUS has a packet size table at the beginning, get size from there. - * Maybe should copy the table during setup to avoid IO, but all XOPUS are - * quite small so it isn't very noticeable. */ - return (uint16_t)read_16bitLE(0x20 + packet*0x02, streamfile); -} - /* ******************************************************* */ diff --git a/src/coding/hca_decoder.c b/src/coding/hca_decoder.c index ab88ff33..c8c0ba9c 100644 --- a/src/coding/hca_decoder.c +++ b/src/coding/hca_decoder.c @@ -99,14 +99,14 @@ void decode_hca(hca_codec_data * data, sample * outbuf, int32_t samples_to_do) { /* read frame */ bytes = read_streamfile(data->data_buffer, offset, blockSize, data->streamfile); if (bytes != blockSize) { - VGM_LOG("HCA: read %x vs expected %x bytes at %"PRIx64"\n", bytes, blockSize, (off64_t)offset); + VGM_LOG("HCA: read %x vs expected %x bytes at %x\n", bytes, blockSize, (uint32_t)offset); break; } /* decode frame */ status = clHCA_DecodeBlock(data->handle, (void*)(data->data_buffer), blockSize); if (status < 0) { - VGM_LOG("HCA: decode fail at %"PRIx64", code=%i\n", (off64_t)offset, status); + VGM_LOG("HCA: decode fail at %x, code=%i\n", (uint32_t)offset, status); break; } diff --git a/src/coding/mpeg_custom_utils.c b/src/coding/mpeg_custom_utils.c index 990c2873..a7a6b817 100644 --- a/src/coding/mpeg_custom_utils.c +++ b/src/coding/mpeg_custom_utils.c @@ -157,7 +157,7 @@ int mpeg_custom_parse_frame_default(VGMSTREAMCHANNEL *stream, mpeg_codec_data *d } VGM_ASSERT(data->streams_size > 1 && current_interleave != current_data_size+current_padding, - "MPEG FSB: %i streams with non-constant interleave found @ 0x%08"PRIx64"\n", data->streams_size, (off64_t)stream->offset); + "MPEG FSB: %i streams with non-constant interleave found @ 0x%08x\n", data->streams_size, (uint32_t)stream->offset); break; case MPEG_P3D: /* fixed interleave, not frame-aligned (ie. blocks may end/start in part of a frame) */ diff --git a/src/coding/mpeg_custom_utils_awc.c b/src/coding/mpeg_custom_utils_awc.c index 24b2c5b8..7bfd542e 100644 --- a/src/coding/mpeg_custom_utils_awc.c +++ b/src/coding/mpeg_custom_utils_awc.c @@ -59,7 +59,7 @@ static size_t get_repeated_data_size(STREAMFILE *streamFile, off_t new_offset, o } fail: - VGM_LOG("AWC: can't find repeat size, new=0x%08"PRIx64", last=0x%08"PRIx64"\n", (off64_t)new_offset, (off64_t)last_offset); + VGM_LOG("AWC: can't find repeat size, new=0x%08x, last=0x%08x\n", (uint32_t)new_offset, (uint32_t)last_offset); return 0; /* keep on truckin' */ } diff --git a/src/coding/mpeg_custom_utils_ealayer3.c b/src/coding/mpeg_custom_utils_ealayer3.c index f21c09f5..4a544b4f 100644 --- a/src/coding/mpeg_custom_utils_ealayer3.c +++ b/src/coding/mpeg_custom_utils_ealayer3.c @@ -529,7 +529,7 @@ static int ealayer3_rebuild_mpeg_frame(vgm_bitstream* is_0, ealayer3_frame_info* if (os->b_off/8 > expected_frame_size) { /* bit reservoir! shouldn't happen with free bitrate, otherwise it's hard to fix as needs complex buffering/calcs */ - VGM_LOG("MPEG EAL3: written 0x%"PRIx64" but expected less than 0x%x at 0x%"PRIx64"\n", (off64_t)(os->b_off/8), expected_frame_size, (off64_t)os->info_offset); + VGM_LOG("MPEG EAL3: written 0x%x but expected less than 0x%x at 0x%x\n", (uint32_t)(os->b_off/8), expected_frame_size, (uint32_t)os->info_offset); } else { /* fill ancillary data (should be ignored, but 0x00 seems to improve mpg123's free bitrate detection) */ @@ -564,8 +564,8 @@ static int ealayer3_write_pcm_block(VGMSTREAMCHANNEL *stream, mpeg_codec_data *d if (!eaf->pcm_size) return 1; - VGM_ASSERT(eaf->v1_pcm_decode_discard > 576, "MPEG EAL3: big discard %i at 0x%"PRIx64"\n", eaf->v1_pcm_decode_discard, (off64_t)stream->offset); - VGM_ASSERT(eaf->v1_pcm_number > 0x100, "MPEG EAL3: big samples %i at 0x%"PRIx64"\n", eaf->v1_pcm_number, (off64_t)stream->offset); + VGM_ASSERT(eaf->v1_pcm_decode_discard > 576, "MPEG EAL3: big discard %i at 0x%x\n", eaf->v1_pcm_decode_discard, (uint32_t)stream->offset); + VGM_ASSERT(eaf->v1_pcm_number > 0x100, "MPEG EAL3: big samples %i at 0x%x\n", eaf->v1_pcm_number, (uint32_t)stream->offset); /* read + write PCM block samples (always BE) */ for (i = 0; i < eaf->v1_pcm_number * data->channels_per_frame; i++) { diff --git a/src/coding/mpeg_decoder.c b/src/coding/mpeg_decoder.c index 8136e412..fd9c5f2e 100644 --- a/src/coding/mpeg_decoder.c +++ b/src/coding/mpeg_decoder.c @@ -402,7 +402,7 @@ static void decode_mpeg_custom_stream(VGMSTREAMCHANNEL *stream, mpeg_codec_data default: ok = mpeg_custom_parse_frame_default(stream, data, num_stream); break; } if (!ok) { - VGM_LOG("MPEG: cannot parse frame @ around %"PRIx64"\n",(off64_t)stream->offset); + VGM_LOG("MPEG: cannot parse frame @ around %x\n",(uint32_t)stream->offset); goto decode_fail; /* mpg123 could resync but custom MPEGs wouldn't need that */ } //;VGM_LOG("MPEG: read results: bytes_in_buffer=0x%x, new offset=%lx\n", ms->bytes_in_buffer, stream->offset); diff --git a/src/coding/mta2_decoder.c b/src/coding/mta2_decoder.c index 4f4ca57a..09617da2 100644 --- a/src/coding/mta2_decoder.c +++ b/src/coding/mta2_decoder.c @@ -79,7 +79,7 @@ static void mta2_block_update(VGMSTREAMCHANNEL * stream) { } if (block_size <= 0 || block_tracks < 0) { /* nonsense block (maybe at EOF) */ - VGM_LOG("MTA2: bad block @ 0x%"PRIx64"\n", (off64_t)stream->offset); + VGM_LOG("MTA2: bad block @ 0x%x\n", (uint32_t)stream->offset); stream->offset += 0x10; repeat = 0; } diff --git a/src/coding/mtaf_decoder.c b/src/coding/mtaf_decoder.c index 7b9778ef..e2d0b182 100644 --- a/src/coding/mtaf_decoder.c +++ b/src/coding/mtaf_decoder.c @@ -109,7 +109,7 @@ static void mtaf_block_update(VGMSTREAMCHANNEL * stream) { } if (block_size <= 0 || block_tracks < 0) { /* nonsense block (maybe at EOF) */ - VGM_LOG("MTAF: bad block @ %"PRIx64"\n", (off64_t)stream->offset); + VGM_LOG("MTAF: bad block @ %x\n", (uint32_t)stream->offset); stream->offset += 0x10; repeat = 0; } @@ -146,7 +146,7 @@ void decode_mtaf(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t init_idx = read_16bitLE(stream->offset+4+0+c*2, stream->streamfile); /* step-L/R */ int32_t init_hist = read_16bitLE(stream->offset+4+4+c*4, stream->streamfile); /* hist-L/R: hist 16bit + empty 16bit */ - VGM_ASSERT(init_idx < 0 || init_idx > 31, "MTAF: bad header idx @ 0x%"PRIx64"\n", (off64_t)stream->offset); + VGM_ASSERT(init_idx < 0 || init_idx > 31, "MTAF: bad header idx @ 0x%x\n", (uint32_t)stream->offset); /* avoid index out of range in corrupt files */ if (init_idx < 0) { init_idx = 0; diff --git a/src/coding/ngc_dtk_decoder.c b/src/coding/ngc_dtk_decoder.c index b9138c90..4ea57cc0 100644 --- a/src/coding/ngc_dtk_decoder.c +++ b/src/coding/ngc_dtk_decoder.c @@ -23,7 +23,7 @@ void decode_ngc_dtk(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspaci coef_index = ((uint8_t)read_8bit(frame_offset+channel,stream->streamfile) >> 4) & 0xf; shift_factor = ((uint8_t)read_8bit(frame_offset+channel,stream->streamfile) >> 0) & 0xf; /* rare but happens, also repeated headers don't match (ex. Ikaruga (GC) SONG02.adp) */ - VGM_ASSERT_ONCE(coef_index > 4 || shift_factor > 12, "DTK: incorrect coefs/shift at %"PRIx64"\n", (off64_t)frame_offset); + VGM_ASSERT_ONCE(coef_index > 4 || shift_factor > 12, "DTK: incorrect coefs/shift at %x\n", (uint32_t)frame_offset); /* decode nibbles */ for (i = first_sample; i < first_sample+samples_to_do; i++) { diff --git a/src/coding/psx_decoder.c b/src/coding/psx_decoder.c index 057ced73..45aa9793 100644 --- a/src/coding/psx_decoder.c +++ b/src/coding/psx_decoder.c @@ -63,7 +63,7 @@ void decode_psx(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, shift_factor = ((uint8_t)read_8bit(frame_offset+0x00,stream->streamfile) >> 0) & 0xf; flag = (uint8_t)read_8bit(frame_offset+0x01,stream->streamfile); /* only lower nibble needed */ - VGM_ASSERT_ONCE(coef_index > 5 || shift_factor > 12, "PS-ADPCM: incorrect coefs/shift at %"PRIx64"\n", (off64_t)frame_offset); + VGM_ASSERT_ONCE(coef_index > 5 || shift_factor > 12, "PS-ADPCM: incorrect coefs/shift at %x\n", (uint32_t)frame_offset); if (coef_index > 5) /* needed by inFamous (PS3) (maybe it's supposed to use more filters?) */ coef_index = 0; /* upper filters aren't used in PS1/PS2, maybe in PSP/PS3? */ if (shift_factor > 12) @@ -71,7 +71,7 @@ void decode_psx(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, if (is_badflags) /* some games store garbage or extra internal logic in the flags, must be ignored */ flag = 0; - VGM_ASSERT_ONCE(flag > 7,"PS-ADPCM: unknown flag at %"PRIx64"\n", (off64_t)frame_offset); /* meta should use PSX-badflags */ + VGM_ASSERT_ONCE(flag > 7,"PS-ADPCM: unknown flag at %x\n", (uint32_t)frame_offset); /* meta should use PSX-badflags */ /* decode nibbles */ for (i = first_sample; i < first_sample + samples_to_do; i++) { @@ -123,7 +123,7 @@ void decode_psx_configurable(VGMSTREAMCHANNEL * stream, sample * outbuf, int cha coef_index = ((uint8_t)read_8bit(frame_offset+0x00,stream->streamfile) >> 4) & 0xf; shift_factor = ((uint8_t)read_8bit(frame_offset+0x00,stream->streamfile) >> 0) & 0xf; - VGM_ASSERT_ONCE(coef_index > 5 || shift_factor > 12, "PS-ADPCM: incorrect coefs/shift at %"PRIx64"\n", (off64_t)frame_offset); + VGM_ASSERT_ONCE(coef_index > 5 || shift_factor > 12, "PS-ADPCM: incorrect coefs/shift at %x\n", (uint32_t)frame_offset); if (coef_index > 5) /* needed by Afrika (PS3) (maybe it's supposed to use more filters?) */ coef_index = 0; /* upper filters aren't used in PS1/PS2, maybe in PSP/PS3? */ if (shift_factor > 12) @@ -180,7 +180,7 @@ static int ps_find_loop_offsets_internal(STREAMFILE *streamFile, off_t start_off uint8_t flag = (uint8_t)read_8bit(offset+0x01,streamFile) & 0x0F; /* lower nibble only (for HEVAG) */ /* theoretically possible and would use last 0x06 */ - VGM_ASSERT_ONCE(loop_start_found && flag == 0x06, "PS LOOPS: multiple loop start found at %"PRIx64"\n", (off64_t)offset); + VGM_ASSERT_ONCE(loop_start_found && flag == 0x06, "PS LOOPS: multiple loop start found at %x\n", (uint32_t)offset); if (flag == 0x06 && !loop_start_found) { loop_start = num_samples; /* loop start before this frame */ diff --git a/src/coding/vorbis_custom_decoder.c b/src/coding/vorbis_custom_decoder.c index 2a0ba6c6..b5f3da95 100644 --- a/src/coding/vorbis_custom_decoder.c +++ b/src/coding/vorbis_custom_decoder.c @@ -69,7 +69,7 @@ vorbis_custom_codec_data * init_vorbis_custom(STREAMFILE *streamFile, off_t star return data; fail: - VGM_LOG("VORBIS: init fail at around 0x%"PRIx64"\n", (off64_t)start_offset); + VGM_LOG("VORBIS: init fail at around 0x%x\n", (uint32_t)start_offset); free_vorbis_custom(data); return NULL; } @@ -144,7 +144,7 @@ void decode_vorbis_custom(VGMSTREAM * vgmstream, sample * outbuf, int32_t sample /* parse the fake ogg packet into a logical vorbis block */ rc = vorbis_synthesis(&data->vb,&data->op); if (rc == OV_ENOTAUDIO) { - VGM_LOG("Vorbis: not an audio packet (size=0x%x) @ %"PRIx64"\n",(size_t)data->op.bytes,(off64_t)stream->offset); + VGM_LOG("Vorbis: not an audio packet (size=0x%x) @ %x\n",(size_t)data->op.bytes,(uint32_t)stream->offset); //VGM_LOGB(data->op.packet, (size_t)data->op.bytes,0); continue; /* rarely happens, seems ok? */ } else if (rc != 0) goto decode_fail; @@ -162,7 +162,7 @@ void decode_vorbis_custom(VGMSTREAM * vgmstream, sample * outbuf, int32_t sample decode_fail: /* on error just put some 0 samples */ - VGM_LOG("VORBIS: decode fail at %"PRIx64", missing %i samples\n", (off64_t)stream->offset, (samples_to_do - samples_done)); + VGM_LOG("VORBIS: decode fail at %x, missing %i samples\n", (uint32_t)stream->offset, (samples_to_do - samples_done)); memset(outbuf + samples_done * channels, 0, (samples_to_do - samples_done) * channels * sizeof(sample)); } diff --git a/src/coding/xa_decoder.c b/src/coding/xa_decoder.c index d0c69459..58c3c21a 100644 --- a/src/coding/xa_decoder.c +++ b/src/coding/xa_decoder.c @@ -76,7 +76,7 @@ void decode_xa(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, i if (read_32bitBE(frame_offset+0x00,stream->streamfile) != read_32bitBE(frame_offset+0x04,stream->streamfile) || read_32bitBE(frame_offset+0x08,stream->streamfile) != read_32bitBE(frame_offset+0x0c,stream->streamfile)) { - VGM_LOG("bad frames at %"PRIx64"\n", (off64_t)frame_offset); + VGM_LOG("bad frames at %x\n", (uint32_t)frame_offset); } @@ -90,7 +90,7 @@ void decode_xa(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, i coef_index = ((uint8_t)read_8bit(sp_offset,stream->streamfile) >> 4) & 0xf; shift_factor = ((uint8_t)read_8bit(sp_offset,stream->streamfile) >> 0) & 0xf; - VGM_ASSERT(coef_index > 4 || shift_factor > 12, "XA: incorrect coefs/shift at %"PRIx64"\n", (off64_t)sp_offset); + VGM_ASSERT(coef_index > 4 || shift_factor > 12, "XA: incorrect coefs/shift at %x\n", (uint32_t)sp_offset); if (coef_index > 4) coef_index = 0; /* only 4 filters are used, rest is apparently 0 */ if (shift_factor > 12) diff --git a/src/layout/blocked.c b/src/layout/blocked.c index abe7e595..2e6e4836 100644 --- a/src/layout/blocked.c +++ b/src/layout/blocked.c @@ -40,7 +40,7 @@ void render_vgmstream_blocked(sample * buffer, int32_t sample_count, VGMSTREAM * if (samples_this_block < 0) { /* probably block bug or EOF, next calcs would give wrong values/segfaults/infinite loop */ - VGM_LOG("layout_blocked: wrong block samples at 0x%"PRIx64"\n", (off64_t)vgmstream->current_block_offset); + VGM_LOG("layout_blocked: wrong block samples at 0x%x\n", (uint32_t)vgmstream->current_block_offset); memset(buffer + samples_written*vgmstream->channels, 0, (sample_count - samples_written) * vgmstream->channels * sizeof(sample)); break; } diff --git a/src/layout/blocked_h4m.c b/src/layout/blocked_h4m.c index 5c5c4082..38a17adf 100644 --- a/src/layout/blocked_h4m.c +++ b/src/layout/blocked_h4m.c @@ -48,7 +48,7 @@ void block_update_h4m(off_t block_offset, VGMSTREAM * vgmstream) { block_skip += (audio_bytes / vgmstream->num_streams) * (vgmstream->stream_index-1); } - VGM_ASSERT(frame_format == 1, "H4M: unknown frame_format %x at %"PRIx64"\n", frame_format, (off64_t)block_offset); + VGM_ASSERT(frame_format == 1, "H4M: unknown frame_format %x at %x\n", frame_format, (uint32_t)block_offset); /* pass current mode to the decoder */ vgmstream->codec_config = (frame_format << 8) | (vgmstream->codec_config & 0xFF); diff --git a/src/layout/blocked_xa.c b/src/layout/blocked_xa.c index 329e4475..8ab45fdc 100644 --- a/src/layout/blocked_xa.c +++ b/src/layout/blocked_xa.c @@ -26,7 +26,7 @@ void block_update_xa(off_t block_offset, VGMSTREAM * vgmstream) { VGM_ASSERT(block_offset + 0x930 < get_streamfile_size(streamFile) && (uint8_t)read_8bit(block_offset + 0x000 + 0x11,streamFile) != (uint8_t)read_8bit(block_offset + 0x930 + 0x11,streamFile), - "XA block: subchannel change at %"PRIx64"\n", (off64_t)block_offset); + "XA block: subchannel change at %x\n", (uint32_t)block_offset); /* submode flag bits (typical audio value = 0x64 01100100) * - 7 (0x80 10000000): end of file @@ -53,7 +53,7 @@ void block_update_xa(off_t block_offset, VGMSTREAM * vgmstream) { } else { ;VGM_ASSERT_ONCE(block_offset < get_streamfile_size(streamFile), - "XA block: non audio block found at %"PRIx64"\n", (off64_t)block_offset); + "XA block: non audio block found at %x\n", (uint32_t)block_offset); block_samples = 0; /* not an audio sector */ } diff --git a/src/meta/awc.c b/src/meta/awc.c index e13f1971..1ff2d1eb 100644 --- a/src/meta/awc.c +++ b/src/meta/awc.c @@ -337,7 +337,7 @@ static int parse_awc_header(STREAMFILE* streamFile, awc_header* awc) { /* If music, data is divided into blocks of block_chunk size with padding. * Each block has a header/seek table and interleaved data for all channels */ if (awc->is_music && read_32bit(awc->stream_offset, streamFile) != 0) { - VGM_LOG("AWC: music found, but block doesn't start with seek table at %"PRIx64"\n", (off64_t)awc->stream_offset); + VGM_LOG("AWC: music found, but block doesn't start with seek table at %x\n", (uint32_t)awc->stream_offset); goto fail; } diff --git a/src/meta/fsb5.c b/src/meta/fsb5.c index 7dee157c..a9445b5d 100644 --- a/src/meta/fsb5.c +++ b/src/meta/fsb5.c @@ -188,7 +188,7 @@ VGMSTREAM * init_vgmstream_fsb5(STREAMFILE *streamFile) { // /* found in some XMA2/Vorbis/FADPCM */ // break; default: - VGM_LOG("FSB5: unknown extraflag 0x%x at %"PRIx64" + 0x04 (size 0x%x)\n", extraflag_type, (off64_t)extraflag_offset, extraflag_size); + VGM_LOG("FSB5: unknown extraflag 0x%x at %x + 0x04 (size 0x%x)\n", extraflag_type, (uint32_t)extraflag_offset, extraflag_size); break; } diff --git a/src/meta/ubi_bao.c b/src/meta/ubi_bao.c index 9e6dab78..3194ecca 100644 --- a/src/meta/ubi_bao.c +++ b/src/meta/ubi_bao.c @@ -391,7 +391,7 @@ static int parse_pk_header(ubi_bao_header * bao, STREAMFILE *streamFile) { goto fail; } - ;VGM_LOG("BAO stream: id=%x, offset=%"PRIx64", size=%x, res=%s\n", bao->stream_id, (off64_t)bao->stream_offset, bao->stream_size, (bao->is_external ? bao->resource_name : "internal")); + ;VGM_LOG("BAO stream: id=%x, offset=%x, size=%x, res=%s\n", bao->stream_id, (uint32_t)bao->stream_offset, bao->stream_size, (bao->is_external ? bao->resource_name : "internal")); return 1; fail: @@ -434,7 +434,7 @@ static int parse_bao(ubi_bao_header * bao, STREAMFILE *streamFile, off_t offset) case 0x70000000: bao->types_count[7]++; break; /* project info? (sometimes special id 0x7fffffff) */ case 0x80000000: bao->types_count[8]++; break; /* unknown (some id/info?) */ default: - VGM_LOG("UBI BAO: unknown type %x at %"PRIx64" + %x\n", descriptor_type, (off64_t)offset, 0x20); + VGM_LOG("UBI BAO: unknown type %x at %x + %x\n", descriptor_type, (uint32_t)offset, 0x20); goto fail; } @@ -453,7 +453,7 @@ static int parse_bao(ubi_bao_header * bao, STREAMFILE *streamFile, off_t offset) case 0x00000007: bao->subtypes_count[7]++; break; /* related to other header BAOs? */ case 0x00000008: bao->subtypes_count[8]++; break; /* ? (almost empty with some unknown value) */ default: - VGM_LOG("UBI BAO: unknown subtype %x at %"PRIx64" + %x\n", descriptor_subtype, (off64_t)offset, header_size+0x04); + VGM_LOG("UBI BAO: unknown subtype %x at %x + %x\n", descriptor_subtype, (uint32_t)offset, header_size+0x04); goto fail; } //;VGM_ASSERT(descriptor_subtype != 0x01, "UBI BAO: subtype %x at %lx (%lx)\n", descriptor_subtype, offset, offset+header_size+0x04); @@ -477,7 +477,7 @@ static int parse_bao(ubi_bao_header * bao, STREAMFILE *streamFile, off_t offset) * - channels, ?, sample rate, average bit rate?, samples, full stream_size?, codec, etc * - subtable entries, subtable size (may contain offsets/ids, cues, etc) * - extra data per codec (ex. XMA header in some versions) */ - ;VGM_LOG("BAO header at %"PRIx64"\n", (off64_t)offset); + ;VGM_LOG("BAO header at %x\n", (uint32_t)offset); bao->version = bao_version; switch(bao->version) { @@ -503,7 +503,7 @@ static int parse_bao(ubi_bao_header * bao, STREAMFILE *streamFile, off_t offset) case 0x03: bao->codec = UBI_ADPCM; break; case 0x05: bao->codec = RAW_XMA1; break; case 0x09: bao->codec = RAW_DSP; break; - default: VGM_LOG("UBI BAO: unknown codec at %"PRIx64"\n", (off64_t)offset); goto fail; + default: VGM_LOG("UBI BAO: unknown codec at %x\n", (uint32_t)offset); goto fail; } bao->prefetch_size = read_32bit(offset + header_size + 0x74, streamFile); @@ -535,11 +535,11 @@ static int parse_bao(ubi_bao_header * bao, STREAMFILE *streamFile, off_t offset) switch(bao->header_codec) { case 0x06: bao->codec = RAW_PSX; break; case 0x07: bao->codec = FMT_AT3; break; - default: VGM_LOG("UBI BAO: unknown codec at %"PRIx64"\n", (off64_t)offset); goto fail; + default: VGM_LOG("UBI BAO: unknown codec at %x\n", (uint32_t)offset); goto fail; } if (read_32bit(offset+header_size+0x20, streamFile) & 0x10) { - VGM_LOG("UBI BAO: possible full loop at %"PRIx64"\n", (off64_t)offset); + VGM_LOG("UBI BAO: possible full loop at %x\n", (uint32_t)offset); /* RIFFs may have "smpl" and this flag, even when data shouldn't loop... */ } @@ -564,7 +564,7 @@ static int parse_bao(ubi_bao_header * bao, STREAMFILE *streamFile, off_t offset) case 0x02: bao->codec = UBI_ADPCM; break; case 0x03: bao->codec = FMT_OGG; break; case 0x04: bao->codec = RAW_XMA2; break; - default: VGM_LOG("UBI BAO: unknown codec at %"PRIx64"\n", (off64_t)offset); goto fail; + default: VGM_LOG("UBI BAO: unknown codec at %x\n", (uint32_t)offset); goto fail; } bao->prefetch_size = read_32bit(offset+header_size+0x84, streamFile); @@ -598,7 +598,7 @@ static int parse_bao(ubi_bao_header * bao, STREAMFILE *streamFile, off_t offset) case 0x04: bao->codec = RAW_XMA2; break; case 0x05: bao->codec = RAW_PSX; break; case 0x06: bao->codec = RAW_AT3; break; - default: VGM_LOG("UBI BAO: unknown codec at %"PRIx64"\n", (off64_t)offset); goto fail; + default: VGM_LOG("UBI BAO: unknown codec at %x\n", (uint32_t)offset); goto fail; } bao->prefetch_size = read_32bit(offset + header_size + 0x78, streamFile); @@ -615,7 +615,7 @@ static int parse_bao(ubi_bao_header * bao, STREAMFILE *streamFile, off_t offset) case 0x00280306: /* Far Cry 3: Blood Dragon (X360)-file */ case 0x00290106: /* Splinter Cell Blacklist? */ default: /* others possibly using BAO: Avatar X360/PS3/PC, Just Dance, Watch_Dogs, Far Cry Primal, Far Cry 4 */ - VGM_LOG("UBI BAO: unknown BAO version at %"PRIx64"\n", (off64_t)offset); + VGM_LOG("UBI BAO: unknown BAO version at %x\n", (uint32_t)offset); goto fail; } diff --git a/src/streamfile.c b/src/streamfile.c index 48b84622..52713b81 100644 --- a/src/streamfile.c +++ b/src/streamfile.c @@ -53,7 +53,7 @@ static size_t read_stdio(STDIOSTREAMFILE *streamfile,uint8_t * dest, off_t offse /* ignore requests at EOF */ if (offset >= streamfile->filesize) { //offset = streamfile->filesize; /* seems fseek doesn't clamp offset */ - VGM_ASSERT_ONCE(offset > streamfile->filesize, "STDIO: reading over filesize 0x%x @ 0x%"PRIx64" + 0x%x\n", streamfile->filesize, (off64_t)offset, length); + VGM_ASSERT_ONCE(offset > streamfile->filesize, "STDIO: reading over filesize 0x%x @ 0x%x + 0x%x\n", streamfile->filesize, (uint32_t)offset, length); break; } @@ -254,7 +254,7 @@ static size_t buffer_read(BUFFER_STREAMFILE *streamfile, uint8_t * dest, off_t o /* ignore requests at EOF */ if (offset >= streamfile->filesize) { //offset = streamfile->filesize; /* seems fseek doesn't clamp offset */ - VGM_ASSERT_ONCE(offset > streamfile->filesize, "BUFFER: reading over filesize 0x%x @ 0x%"PRIx64" + 0x%x\n", streamfile->filesize, (off64_t)offset, length); + VGM_ASSERT_ONCE(offset > streamfile->filesize, "BUFFER: reading over filesize 0x%x @ 0x%x + 0x%x\n", streamfile->filesize, (uint32_t)offset, length); break; }