mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-25 07:20:10 +01:00
Cast off_t to off64_t when printf'ing for future 4GB file support
This commit is contained in:
parent
79e60556a8
commit
7d91ef1432
@ -109,10 +109,7 @@ void decode_atrac9(VGMSTREAM *vgmstream, sample * outbuf, int32_t samples_to_do,
|
||||
|
||||
/* read one raw block (superframe) and advance offsets */
|
||||
bytes = read_streamfile(data->data_buffer,stream->offset, data->info.superframeSize,stream->streamfile);
|
||||
if (bytes != data->data_buffer_size) {
|
||||
VGM_LOG("ATRAC9: read %x vs expected %x bytes at %lx\n", bytes, data->info.superframeSize, stream->offset);
|
||||
goto decode_fail;
|
||||
}
|
||||
if (bytes != data->data_buffer_size) goto decode_fail;
|
||||
|
||||
stream->offset += bytes;
|
||||
|
||||
@ -131,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 %lx, missing %i samples\n", stream->offset, (samples_to_do - samples_done));
|
||||
VGM_LOG("ATRAC9: decode fail at %"PRIx64", missing %i samples\n", (off64_t)stream->offset, (samples_to_do - samples_done));
|
||||
memset(outbuf + samples_done * channels, 0, (samples_to_do - samples_done) * sizeof(sample) * channels);
|
||||
}
|
||||
|
||||
|
@ -122,22 +122,17 @@ void decode_celt_fsb(VGMSTREAM *vgmstream, sample * outbuf, int32_t samples_to_d
|
||||
|
||||
/* FSB DLLs do seem to check this fixed value */
|
||||
if (read_32bitBE(stream->offset+0x00,stream->streamfile) != 0x17C30DF3) {
|
||||
VGM_LOG("CELT: unknown frame ID at %lx\n",stream->offset);
|
||||
goto decode_fail;
|
||||
}
|
||||
|
||||
frame_size = read_32bitLE(stream->offset+0x04,stream->streamfile);
|
||||
if (frame_size > FSB_CELT_MAX_DATA_SIZE) {
|
||||
VGM_LOG("CELT: frame size %x bigger than expected\n", frame_size);
|
||||
goto decode_fail;
|
||||
}
|
||||
|
||||
/* read and decode one raw block and advance offsets */
|
||||
bytes = read_streamfile(data_buffer,stream->offset+0x08, frame_size,stream->streamfile);
|
||||
if (bytes != frame_size) {
|
||||
VGM_LOG("CELT: read %x vs expected %x bytes at %lx\n", bytes,frame_size,stream->offset);
|
||||
goto decode_fail;
|
||||
}
|
||||
if (bytes != frame_size) goto decode_fail;
|
||||
|
||||
switch(data->version) {
|
||||
case CELT_0_06_1:
|
||||
@ -151,10 +146,7 @@ void decode_celt_fsb(VGMSTREAM *vgmstream, sample * outbuf, int32_t samples_to_d
|
||||
default:
|
||||
goto decode_fail;
|
||||
}
|
||||
if (status != CELT_OK) {
|
||||
VGM_LOG("CELT: decode failed with %i at %lx\n", status,stream->offset);
|
||||
goto decode_fail;
|
||||
}
|
||||
if (status != CELT_OK) goto decode_fail;
|
||||
|
||||
stream->offset += 0x04+0x04+frame_size;
|
||||
data->samples_filled += FSB_CELT_SAMPLES_PER_FRAME;
|
||||
@ -165,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 %lx, missing %i samples\n", stream->offset, (samples_to_do - samples_done));
|
||||
VGM_LOG("CELT: decode fail at %"PRIx64", missing %i samples\n", (off64_t)stream->offset, (samples_to_do - samples_done));
|
||||
memset(outbuf + samples_done * channels, 0, (samples_to_do - samples_done) * sizeof(sample) * channels);
|
||||
}
|
||||
|
||||
|
@ -467,19 +467,19 @@ static void ms_audio_get_samples(ms_sample_data * msd, STREAMFILE *streamFile, i
|
||||
|
||||
/* full packet skip, no new frames start in this packet (prev frames can end here) */
|
||||
if (packet_skip_count == 0x7FF) { /* XMA1, 11b */
|
||||
VGM_LOG("MS_SAMPLES: XMA1 full packet_skip %i at 0x%lx\n", packet_skip_count, (off_t)offset_b/8);
|
||||
VGM_LOG("MS_SAMPLES: XMA1 full packet_skip %i at 0x%"PRIx64"\n", packet_skip_count, (off64_t)offset_b/8);
|
||||
packet_skip_count = 0;
|
||||
continue;
|
||||
}
|
||||
else if (packet_skip_count == 0xFF) { /* XMA2, 8b*/
|
||||
VGM_LOG("MS_SAMPLES: XMA2 full packet_skip %i at 0x%lx\n", packet_skip_count, (off_t)offset_b/8);
|
||||
VGM_LOG("MS_SAMPLES: XMA2 full packet_skip %i at 0x%"PRIx64"\n", packet_skip_count, (off64_t)offset_b/8);
|
||||
packet_skip_count = 0;
|
||||
continue;
|
||||
}
|
||||
offset += packet_size * (packet_skip_count); /* skip packets not owned by the first stream, since we only need samples from it */
|
||||
|
||||
/* unusual but not impossible, as the encoder can interleave packets in any way */
|
||||
VGM_ASSERT(packet_skip_count > 10, "MS_SAMPLES: found big packet skip %i at 0x%lx\n", packet_skip_count, (off_t)offset_b/8);
|
||||
VGM_ASSERT(packet_skip_count > 10, "MS_SAMPLES: found big packet skip %i at 0x%"PRIx64"\n", packet_skip_count, (off64_t)offset_b/8);
|
||||
|
||||
packet_offset_b = header_size_b + first_frame_b;
|
||||
|
||||
@ -535,7 +535,7 @@ static void ms_audio_get_samples(ms_sample_data * msd, STREAMFILE *streamFile, i
|
||||
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%lx (bit 0x%lx)\n", new_skip, (off_t)frame_offset_b/8, (off_t)frame_offset_b);
|
||||
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_ASSERT(start_skip, "MS_SAMPLES: more than one start_skip (%i)\n", new_skip); //ignore, happens due to incorrect tilehdr_size
|
||||
frame_offset_b += 10;
|
||||
|
||||
@ -551,7 +551,7 @@ static void ms_audio_get_samples(ms_sample_data * msd, STREAMFILE *streamFile, i
|
||||
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%lx (bit 0x%lx)\n", new_skip, (off_t)frame_offset_b/8, (off_t)frame_offset_b);
|
||||
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_ASSERT(end_skip, "MS_SAMPLES: more than one end_skip (%i)\n", new_skip);//ignore, happens due to incorrect tilehdr_size
|
||||
frame_offset_b += 10;
|
||||
|
||||
|
@ -97,7 +97,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 %lx\n", data->physical_offset);
|
||||
VGM_LOG("OPUS: buffer can't hold OggS at %"PRIx64"\n", (off64_t)data->physical_offset);
|
||||
data->page_size = 0;
|
||||
break;
|
||||
}
|
||||
@ -150,7 +150,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 %lx + %x vs %x\n", 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));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -172,7 +172,7 @@ static size_t opus_io_size(STREAMFILE *streamfile, opus_io_data* data) {
|
||||
|
||||
/* logical size can be bigger though */
|
||||
if (physical_offset > get_streamfile_size(streamfile)) {
|
||||
VGM_LOG("OPUS: wrong size %lx\n", physical_offset);
|
||||
VGM_LOG("OPUS: wrong size\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -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 %lx\n", bytes, blockSize, offset);
|
||||
VGM_LOG("HCA: read %x vs expected %x bytes at %"PRIx64"\n", bytes, blockSize, (off64_t)offset);
|
||||
break;
|
||||
}
|
||||
|
||||
/* decode frame */
|
||||
status = clHCA_DecodeBlock(data->handle, (void*)(data->data_buffer), blockSize);
|
||||
if (status < 0) {
|
||||
VGM_LOG("HCA: decode fail at %lx\n", offset);
|
||||
VGM_LOG("HCA: decode fail at %"PRIx64", code=%i\n", (off64_t)offset, status);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -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%08lx\n", data->streams_size, stream->offset);
|
||||
"MPEG FSB: %i streams with non-constant interleave found @ 0x%08"PRIx64"\n", data->streams_size, (off64_t)stream->offset);
|
||||
break;
|
||||
|
||||
case MPEG_P3D: /* fixed interleave, not frame-aligned (ie. blocks may end/start in part of a frame) */
|
||||
|
@ -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%08lx, last=0x%08lx\n", new_offset, last_offset);
|
||||
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);
|
||||
return 0; /* keep on truckin' */
|
||||
}
|
||||
|
||||
|
@ -419,7 +419,7 @@ static int ealayer3_rebuild_mpeg_frame(vgm_bitstream* is_0, ealayer3_frame_info*
|
||||
|| eaf_0->version != eaf_1->version
|
||||
|| eaf_0->granule_index == eaf_1->granule_index
|
||||
|| !eaf_0->common_size || !eaf_1->common_size)) {
|
||||
VGM_LOG("MPEG EAL3: EA-frames for MPEG1 don't match at 0x%lx\n", os->info_offset);
|
||||
VGM_LOG("MPEG EAL3: EA-frames for MPEG1 don't match\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -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%lx but expected less than 0x%x at 0x%lx\n", os->b_off/8, expected_frame_size, os->info_offset);
|
||||
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);
|
||||
}
|
||||
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%lx\n", eaf->v1_pcm_decode_discard, stream->offset);
|
||||
VGM_ASSERT(eaf->v1_pcm_number > 0x100, "MPEG EAL3: big samples %i at 0x%lx\n", eaf->v1_pcm_number, stream->offset);
|
||||
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);
|
||||
|
||||
/* read + write PCM block samples (always BE) */
|
||||
for (i = 0; i < eaf->v1_pcm_number * data->channels_per_frame; i++) {
|
||||
|
@ -56,11 +56,11 @@ mpeg_codec_data *init_mpeg(STREAMFILE *streamfile, off_t start_offset, coding_t
|
||||
|
||||
rc = mpg123_decode(main_m, data->buffer,data->buffer_size, NULL,0, &bytes_done);
|
||||
if (rc != MPG123_OK && rc != MPG123_NEW_FORMAT && rc != MPG123_NEED_MORE) {
|
||||
VGM_LOG("MPEG: unable to set up mpg123 @ 0x%08lx to 0x%08lx\n", start_offset, read_offset);
|
||||
VGM_LOG("MPEG: unable to set up mpg123 at start offset\n");
|
||||
goto fail; //handle MPG123_DONE?
|
||||
}
|
||||
if (read_offset > 0x5000) { /* don't hang in some incorrectly detected formats */
|
||||
VGM_LOG("MPEG: unable to find mpeg data @ 0x%08lx to 0x%08lx\n", start_offset, read_offset);
|
||||
VGM_LOG("MPEG: unable to find mpeg data at start offset\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -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 %lx\n",stream->offset);
|
||||
VGM_LOG("MPEG: cannot parse frame @ around %"PRIx64"\n",(off64_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);
|
||||
|
@ -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 @ %08lx\n", stream->offset);
|
||||
VGM_LOG("MTA2: bad block @ 0x%"PRIx64"\n", (off64_t)stream->offset);
|
||||
stream->offset += 0x10;
|
||||
repeat = 0;
|
||||
}
|
||||
|
@ -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 @ %08lx\n", stream->offset);
|
||||
VGM_LOG("MTAF: bad block @ %"PRIx64"\n", (off64_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%lx\n", stream->offset);
|
||||
VGM_ASSERT(init_idx < 0 || init_idx > 31, "MTAF: bad header idx @ 0x%"PRIx64"\n", (off64_t)stream->offset);
|
||||
/* avoid index out of range in corrupt files */
|
||||
if (init_idx < 0) {
|
||||
init_idx = 0;
|
||||
|
@ -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 %lx\n", frame_offset);
|
||||
VGM_ASSERT_ONCE(coef_index > 4 || shift_factor > 12, "DTK: incorrect coefs/shift at %"PRIx64"\n", (off64_t)frame_offset);
|
||||
|
||||
/* decode nibbles */
|
||||
for (i = first_sample; i < first_sample+samples_to_do; i++) {
|
||||
|
@ -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 %lx\n", frame_offset);
|
||||
VGM_ASSERT_ONCE(coef_index > 5 || shift_factor > 12, "PS-ADPCM: incorrect coefs/shift at %"PRIx64"\n", (off64_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 %lx\n", frame_offset); /* meta should set PSX-badflags */
|
||||
VGM_ASSERT_ONCE(flag > 7,"PS-ADPCM: unknown flag at %"PRIx64"\n", (off64_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 %lx\n", frame_offset);
|
||||
VGM_ASSERT_ONCE(coef_index > 5 || shift_factor > 12, "PS-ADPCM: incorrect coefs/shift at %"PRIx64"\n", (off64_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 %lx\n", offset);
|
||||
VGM_ASSERT_ONCE(loop_start_found && flag == 0x06, "PS LOOPS: multiple loop start found at %"PRIx64"\n", (off64_t)offset);
|
||||
|
||||
if (flag == 0x06 && !loop_start_found) {
|
||||
loop_start = num_samples; /* loop start before this frame */
|
||||
|
@ -69,6 +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);
|
||||
free_vorbis_custom(data);
|
||||
return NULL;
|
||||
}
|
||||
@ -136,7 +137,6 @@ void decode_vorbis_custom(VGMSTREAM * vgmstream, sample * outbuf, int32_t sample
|
||||
default: goto decode_fail;
|
||||
}
|
||||
if(!ok) {
|
||||
VGM_LOG("Vorbis: cannot parse packet @ around %lx\n",stream->offset);
|
||||
goto decode_fail;
|
||||
}
|
||||
|
||||
@ -144,20 +144,15 @@ 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) @ %lx\n",(size_t)data->op.bytes,stream->offset);
|
||||
VGM_LOG("Vorbis: not an audio packet (size=0x%x) @ %"PRIx64"\n",(size_t)data->op.bytes,(off64_t)stream->offset);
|
||||
//VGM_LOGB(data->op.packet, (size_t)data->op.bytes,0);
|
||||
continue; /* seems ok? */
|
||||
} else if (rc != 0) {
|
||||
VGM_LOG("Vorbis: cannot parse Vorbis block @ %lx\n",stream->offset);
|
||||
goto decode_fail;
|
||||
}
|
||||
continue; /* rarely happens, seems ok? */
|
||||
} else if (rc != 0) goto decode_fail;
|
||||
|
||||
/* finally decode the logical block into samples */
|
||||
rc = vorbis_synthesis_blockin(&data->vd,&data->vb);
|
||||
if (rc != 0) {
|
||||
VGM_LOG("Vorbis: cannot decode Vorbis block @ %lx\n",stream->offset);
|
||||
goto decode_fail; /* ? */
|
||||
}
|
||||
if (rc != 0) goto decode_fail; /* ? */
|
||||
|
||||
|
||||
data->samples_full = 1;
|
||||
}
|
||||
@ -167,6 +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));
|
||||
memset(outbuf + samples_done * channels, 0, (samples_to_do - samples_done) * channels * sizeof(sample));
|
||||
}
|
||||
|
||||
|
@ -60,18 +60,12 @@ int vorbis_custom_parse_packet_fsb(VGMSTREAMCHANNEL *stream, vorbis_custom_codec
|
||||
/* get next packet size from the FSB 16b header (doesn't count this 16b) */
|
||||
data->op.bytes = (uint16_t)read_16bitLE(stream->offset, stream->streamfile);
|
||||
stream->offset += 2;
|
||||
if (data->op.bytes == 0 || data->op.bytes == 0xFFFF || data->op.bytes > data->buffer_size) {
|
||||
VGM_LOG("FSB Vorbis: wrong packet (0x%lx) @ %lx\n", data->op.bytes, stream->offset-2);
|
||||
goto fail; /* EOF or end padding */
|
||||
}
|
||||
if (data->op.bytes == 0 || data->op.bytes == 0xFFFF || data->op.bytes > data->buffer_size) goto fail; /* EOF or end padding */
|
||||
|
||||
/* read raw block */
|
||||
bytes = read_streamfile(data->buffer,stream->offset, data->op.bytes,stream->streamfile);
|
||||
stream->offset += data->op.bytes;
|
||||
if (bytes != data->op.bytes) {
|
||||
VGM_LOG("Wwise Vorbis: wrong bytes (0x%lx) @ %lx\n", data->op.bytes, stream->offset-bytes);
|
||||
goto fail; /* wrong packet? */
|
||||
}
|
||||
if (bytes != data->op.bytes) goto fail; /* wrong packet? */
|
||||
|
||||
return 1;
|
||||
|
||||
|
@ -55,18 +55,12 @@ int vorbis_custom_parse_packet_ogl(VGMSTREAMCHANNEL *stream, vorbis_custom_codec
|
||||
/* get next packet size from the OGL 16b header (upper 14b) */
|
||||
data->op.bytes = (uint16_t)read_16bitLE(stream->offset, stream->streamfile) >> 2;
|
||||
stream->offset += 2;
|
||||
if (data->op.bytes == 0 || data->op.bytes == 0xFFFF || data->op.bytes > data->buffer_size) {
|
||||
VGM_LOG("OGL Vorbis: wrong packet (0x%lx) @ %lx\n", data->op.bytes, stream->offset-2);
|
||||
goto fail; /* EOF or end padding */
|
||||
}
|
||||
if (data->op.bytes == 0 || data->op.bytes == 0xFFFF || data->op.bytes > data->buffer_size) goto fail; /* EOF or end padding */
|
||||
|
||||
/* read raw block */
|
||||
bytes = read_streamfile(data->buffer,stream->offset, data->op.bytes,stream->streamfile);
|
||||
stream->offset += data->op.bytes;
|
||||
if (bytes != data->op.bytes) {
|
||||
VGM_LOG("OGL Vorbis: wrong bytes (0x%lx) @ %lx\n", data->op.bytes, stream->offset-bytes);
|
||||
goto fail; /* wrong packet? */
|
||||
}
|
||||
if (bytes != data->op.bytes) goto fail; /* wrong packet? */
|
||||
|
||||
return 1;
|
||||
|
||||
|
@ -61,7 +61,6 @@ int vorbis_custom_setup_init_sk(STREAMFILE *streamFile, off_t start_offset, vorb
|
||||
return 1;
|
||||
|
||||
fail:
|
||||
VGM_LOG("SK Vorbis: failed to setup init packets @ around 0x%08lx\n", offset);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -75,31 +74,22 @@ int vorbis_custom_parse_packet_sk(VGMSTREAMCHANNEL *stream, vorbis_custom_codec_
|
||||
/* read OggS/SK page and get current packet */
|
||||
res = get_page_info(stream->streamfile, stream->offset, &packet_offset, &packet_size, &page_packets, data->current_packet);
|
||||
data->current_packet++;
|
||||
if (!res || packet_size > data->buffer_size) {
|
||||
VGM_LOG("FSB Vorbis: wrong packet (0x%x) @ %lx\n", packet_size, stream->offset);
|
||||
goto fail;
|
||||
}
|
||||
if (!res || packet_size > data->buffer_size) goto fail;
|
||||
|
||||
/* read raw block */
|
||||
data->op.bytes = read_streamfile(data->buffer, packet_offset, packet_size, stream->streamfile);
|
||||
if (data->op.bytes != packet_size) {
|
||||
VGM_LOG("SK Vorbis: read error, 0x%x packet size vs 0x%lx bytes @ %lx\n", packet_size, data->op.bytes, packet_offset);
|
||||
goto fail; /* wrong packet? */
|
||||
}
|
||||
|
||||
if (data->op.bytes != packet_size) goto fail; /* wrong packet? */
|
||||
|
||||
/* go next page when processed all packets in page */
|
||||
if (data->current_packet >= page_packets) {
|
||||
/* processed all packets in page, go to next */
|
||||
if (!get_page_info(stream->streamfile, stream->offset, &packet_offset, &packet_size, &page_packets, -1)) goto fail;
|
||||
stream->offset = packet_offset + packet_size;
|
||||
data->current_packet = 0;
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
|
||||
fail:
|
||||
VGM_LOG("SK Vorbis: failed to parse packet @ around 0x%08lx\n", stream->offset);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -175,7 +165,7 @@ static int get_page_info(STREAMFILE *streamFile, off_t page_offset, off_t *out_p
|
||||
return 1;
|
||||
|
||||
fail:
|
||||
VGM_LOG("SK Vorbis: failed to read page @ 0x%08lx\n", page_offset);
|
||||
//VGM_LOG("SK Vorbis: failed to read page @ 0x%08lx\n", page_offset);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -188,10 +178,8 @@ static int build_header(uint8_t * buf, size_t bufsize, STREAMFILE *streamFile, o
|
||||
put_8bit (buf+0x00, read_8bit(packet_offset,streamFile)); /* packet_type */
|
||||
memcpy (buf+0x01, "vorbis", 6); /* id */
|
||||
bytes = read_streamfile(buf+0x07,packet_offset+0x03, packet_size-0x03,streamFile); /* copy rest (all except id+"SK") */
|
||||
if (packet_size-0x03 != bytes) {
|
||||
VGM_LOG("SK Vorbis: packet (size 0x%x) not copied correctly (bytes=%x) @ 0x%lx\n", packet_size, bytes, packet_offset);
|
||||
if (packet_size-0x03 != bytes)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0x07+packet_size-0x03;
|
||||
}
|
||||
|
@ -68,27 +68,20 @@ int vorbis_custom_parse_packet_vid1(VGMSTREAMCHANNEL *stream, vorbis_custom_code
|
||||
|
||||
/* get packet info the VID1 header */
|
||||
get_packet_header(stream->streamfile, &stream->offset, (uint32_t*)&data->op.bytes);
|
||||
if (data->op.bytes == 0 || data->op.bytes > data->buffer_size) {
|
||||
VGM_LOG("VID1 Vorbis: wrong packet (0x%lx) @ %lx\n", data->op.bytes, stream->offset);
|
||||
goto fail; /* EOF or end padding */
|
||||
}
|
||||
if (data->op.bytes == 0 || data->op.bytes > data->buffer_size) goto fail; /* EOF or end padding */
|
||||
|
||||
/* read raw block */
|
||||
bytes = read_streamfile(data->buffer,stream->offset, data->op.bytes,stream->streamfile);
|
||||
stream->offset += data->op.bytes;
|
||||
if (bytes != data->op.bytes) {
|
||||
VGM_LOG("VID1 Vorbis: wrong bytes (0x%lx) @ %lx\n", data->op.bytes, stream->offset-bytes);
|
||||
goto fail; /* wrong packet? */
|
||||
}
|
||||
//todo: sometimes there are short packets like 01be590000 and Vorbis complains and skips, no idea
|
||||
if (bytes != data->op.bytes) goto fail; /* wrong packet? */
|
||||
|
||||
//todo: sometimes there are short packets like 01be590000 and Vorbis complains and skips, no idea
|
||||
|
||||
/* test block end (weird size calc but seems ok) */
|
||||
if ((stream->offset - (data->block_offset + 0x34)) >= (data->block_size - 0x06)) {
|
||||
stream->offset = data->block_offset + read_32bitBE(data->block_offset + 0x04,stream->streamfile);
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
|
||||
fail:
|
||||
|
@ -103,17 +103,11 @@ int vorbis_custom_parse_packet_wwise(VGMSTREAMCHANNEL *stream, vorbis_custom_cod
|
||||
|
||||
/* reconstruct a Wwise packet, if needed; final bytes may be bigger than packet_size so we get the header offsets here */
|
||||
header_size = get_packet_header(stream->streamfile, stream->offset, data->config.header_type, (int*)&data->op.granulepos, &packet_size, data->config.big_endian);
|
||||
if (!header_size || packet_size > data->buffer_size) {
|
||||
VGM_LOG("Wwise Vorbis: wrong packet (0x%x) @ %lx\n", packet_size, stream->offset);
|
||||
goto fail;
|
||||
}
|
||||
if (!header_size || packet_size > data->buffer_size) goto fail;
|
||||
|
||||
data->op.bytes = rebuild_packet(data->buffer, data->buffer_size, stream->streamfile,stream->offset, data, data->config.big_endian);
|
||||
stream->offset += header_size + packet_size;
|
||||
if (!data->op.bytes || data->op.bytes >= 0xFFFF) {
|
||||
VGM_LOG("Wwise Vorbis: wrong bytes (0x%lx) @ %lx\n", data->op.bytes, stream->offset-header_size-packet_size);
|
||||
goto fail;
|
||||
}
|
||||
if (!data->op.bytes || data->op.bytes >= 0xFFFF) goto fail;
|
||||
|
||||
return 1;
|
||||
|
||||
@ -184,7 +178,7 @@ static size_t rebuild_packet(uint8_t * obuf, size_t obufsize, STREAMFILE *stream
|
||||
if (!rc) goto fail;
|
||||
|
||||
if (ow.b_off % 8 != 0) {
|
||||
VGM_LOG("Wwise Vorbis: didn't write exactly audio packet: 0x%lx + %li bits\n", ow.b_off / 8, ow.b_off % 8);
|
||||
//VGM_LOG("Wwise Vorbis: didn't write exactly audio packet: 0x%lx + %li bits\n", ow.b_off / 8, ow.b_off % 8);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -228,7 +222,7 @@ static size_t rebuild_setup(uint8_t * obuf, size_t obufsize, STREAMFILE *streamF
|
||||
if (!rc) goto fail;
|
||||
|
||||
if (ow.b_off % 8 != 0) {
|
||||
VGM_LOG("Wwise Vorbis: didn't write exactly setup packet: 0x%lx + %li bits\n", ow.b_off / 8, ow.b_off % 8);
|
||||
//VGM_LOG("Wwise Vorbis: didn't write exactly setup packet: 0x%lx + %li bits\n", ow.b_off / 8, ow.b_off % 8);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -1024,7 +1018,7 @@ static int ww2ogg_codebook_library_rebuild(vgm_bitstream * ow, vgm_bitstream * i
|
||||
/* check that we used exactly all bytes */
|
||||
/* note: if all bits are used in the last byte there will be one extra 0 byte */
|
||||
if ( 0 != cb_size && iw->b_off/8+1 != cb_size ) {
|
||||
VGM_LOG("Wwise Vorbis: codebook size mistach (expected 0x%x, wrote 0x%lx)\n", cb_size, iw->b_off/8+1);
|
||||
//VGM_LOG("Wwise Vorbis: codebook size mistach (expected 0x%x, wrote 0x%lx)\n", cb_size, iw->b_off/8+1);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include "../util.h"
|
||||
|
||||
// todo this is based on Kazzuya's old code; different emus (PCSX, Mame, Mednafen, etc) do
|
||||
// XA coefs int math in different ways (see comments below), not be 100% accurate.
|
||||
// XA coefs int math in different ways (see comments below), not 100% accurate.
|
||||
// May be implemented like the SNES/SPC700 BRR.
|
||||
|
||||
/* XA ADPCM gain values */
|
||||
@ -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 %lx\n", frame_offset);
|
||||
VGM_LOG("bad frames at %"PRIx64"\n", (off64_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 %lx\n", sp_offset);
|
||||
VGM_ASSERT(coef_index > 4 || shift_factor > 12, "XA: incorrect coefs/shift at %"PRIx64"\n", (off64_t)sp_offset);
|
||||
if (coef_index > 4)
|
||||
coef_index = 0; /* only 4 filters are used, rest is apparently 0 */
|
||||
if (shift_factor > 12)
|
||||
|
@ -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%lx\n", vgmstream->current_block_offset);
|
||||
VGM_LOG("layout_blocked: wrong block samples at 0x%"PRIx64"\n", (off64_t)vgmstream->current_block_offset);
|
||||
memset(buffer + samples_written*vgmstream->channels, 0, (sample_count - samples_written) * vgmstream->channels * sizeof(sample));
|
||||
break;
|
||||
}
|
||||
|
@ -54,8 +54,6 @@ void block_update_ea_1snh(off_t block_offset, VGMSTREAM * vgmstream) {
|
||||
block_offset += block_size;
|
||||
}
|
||||
|
||||
VGM_LOG("of=%lx, next=%lx, data=%x\n", block_offset, block_offset + block_size, block_size);//getchar();
|
||||
|
||||
vgmstream->current_block_offset = block_offset;
|
||||
vgmstream->next_block_offset = block_offset + block_size;
|
||||
vgmstream->current_block_size = block_size - block_header;
|
||||
@ -99,8 +97,8 @@ void block_update_ea_1snh(off_t block_offset, VGMSTREAM * vgmstream) {
|
||||
vgmstream->ch[i].offset = adpcm_offset + 0x08*vgmstream->channels;
|
||||
}
|
||||
|
||||
VGM_ASSERT(vgmstream->current_block_samples != (block_size - block_header - 0x04 - 0x08*vgmstream->channels) * 2 / vgmstream->channels,
|
||||
"EA 1SHN blocked: different expected vs block num samples at %lx\n", block_offset);
|
||||
//VGM_ASSERT(vgmstream->current_block_samples != (block_size - block_header - 0x04 - 0x08*vgmstream->channels) * 2 / vgmstream->channels,
|
||||
// "EA 1SHN blocked: different expected vs block num samples at %lx\n", block_offset);
|
||||
}
|
||||
else {
|
||||
for(i = 0; i < vgmstream->channels; i++) {
|
||||
|
@ -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 %lx\n", frame_format, block_offset);
|
||||
VGM_ASSERT(frame_format == 1, "H4M: unknown frame_format %x at %"PRIx64"\n", frame_format, (off64_t)block_offset);
|
||||
|
||||
/* pass current mode to the decoder */
|
||||
vgmstream->codec_config = (frame_format << 8) | (vgmstream->codec_config & 0xFF);
|
||||
|
@ -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 %lx\n", block_offset);
|
||||
"XA block: subchannel change at %"PRIx64"\n", (off64_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 %lx\n", block_offset);
|
||||
"XA block: non audio block found at %"PRIx64"\n", (off64_t)block_offset);
|
||||
block_samples = 0; /* not an audio sector */
|
||||
}
|
||||
|
||||
|
@ -333,7 +333,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 %lx\n", awc->stream_offset);
|
||||
VGM_LOG("AWC: music found, but block doesn't start with seek table at %"PRIx64"\n", (off64_t)awc->stream_offset);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -330,7 +330,7 @@ static VGMSTREAM * parse_s10a_header(STREAMFILE *streamFile, off_t offset, uint1
|
||||
if (ast_offset == 0xFFFFFFFF) {
|
||||
/* RAM asset */
|
||||
sns_offset = snr_offset + get_snr_size(streamFile, snr_offset);
|
||||
;VGM_LOG("EA S10A: RAM at sns=%lx, sns=%lx\n", snr_offset, sns_offset);
|
||||
//;VGM_LOG("EA S10A: RAM at sns=%lx, sns=%lx\n", snr_offset, sns_offset);
|
||||
vgmstream = init_vgmstream_eaaudiocore_header(streamFile, streamFile, snr_offset, sns_offset, meta_EA_SNR_SNS);
|
||||
if (!vgmstream)
|
||||
goto fail;
|
||||
@ -345,7 +345,7 @@ static VGMSTREAM * parse_s10a_header(STREAMFILE *streamFile, off_t offset, uint1
|
||||
goto fail;
|
||||
|
||||
sns_offset = ast_offset;
|
||||
;VGM_LOG("EA S10A: stream at sns=%lx, sns=%lx\n", snr_offset, sns_offset);
|
||||
//;VGM_LOG("EA S10A: stream at sns=%lx, sns=%lx\n", snr_offset, sns_offset);
|
||||
vgmstream = init_vgmstream_eaaudiocore_header(streamFile, astFile, snr_offset, sns_offset, meta_EA_SNR_SNS);
|
||||
if (!vgmstream)
|
||||
goto fail;
|
||||
|
@ -238,7 +238,7 @@ static size_t eaac_io_size(STREAMFILE *streamfile, eaac_io_data* data) {
|
||||
|
||||
/* logical size can be bigger in EA-XMA though */
|
||||
if (physical_offset > get_streamfile_size(streamfile)) {
|
||||
VGM_LOG("EA EAAC: wrong size %lx\n", physical_offset);
|
||||
VGM_LOG("EA EAAC: wrong size\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1039,7 +1039,7 @@ static int parse_variable_header(STREAMFILE* streamFile, ea_header* ea, off_t be
|
||||
break;
|
||||
|
||||
default:
|
||||
VGM_LOG("EA SCHl: unknown patch 0x%02x at 0x%04lx\n", patch_type, (offset-1));
|
||||
VGM_LOG("EA SCHl: unknown patch 0x%02x\n", patch_type);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ VGMSTREAM * init_vgmstream_fsb5(STREAMFILE *streamFile) {
|
||||
// /* found in some XMA2/Vorbis/FADPCM */
|
||||
// break;
|
||||
default:
|
||||
VGM_LOG("FSB5: unknown extraflag 0x%x at %lx + 0x04 (size 0x%x)\n", extraflag_type, extraflag_offset, extraflag_size);
|
||||
VGM_LOG("FSB5: unknown extraflag 0x%x at %"PRIx64" + 0x04 (size 0x%x)\n", extraflag_type, (off64_t)extraflag_offset, extraflag_size);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ VGMSTREAM * init_vgmstream_nus3bank(STREAMFILE *streamFile) {
|
||||
|
||||
total_subsongs++;
|
||||
if (total_subsongs == target_subsong) {
|
||||
;VGM_LOG("NUS3BANK: subsong header offset %lx\n", header_offset);
|
||||
//;VGM_LOG("NUS3BANK: subsong header offset %lx\n", header_offset);
|
||||
subfile_offset = stream_offset;
|
||||
subfile_size = stream_size;
|
||||
name_size = stream_name_size;
|
||||
@ -142,7 +142,7 @@ VGMSTREAM * init_vgmstream_nus3bank(STREAMFILE *streamFile) {
|
||||
}
|
||||
}
|
||||
|
||||
;VGM_LOG("NUS3BANK: subfile=%lx, size=%x\n", subfile_offset, subfile_size);
|
||||
//;VGM_LOG("NUS3BANK: subfile=%lx, size=%x\n", subfile_offset, subfile_size);
|
||||
|
||||
temp_streamFile = setup_nus3bank_streamfile(streamFile, subfile_offset,subfile_size, fake_ext);
|
||||
if (!temp_streamFile) goto fail;
|
||||
|
@ -389,7 +389,7 @@ static int parse_pk_header(ubi_bao_header * bao, STREAMFILE *streamFile) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
;VGM_LOG("BAO stream: id=%x, offset=%lx, size=%x, res=%s\n", bao->stream_id, bao->stream_offset, bao->stream_size, (bao->is_external ? bao->resource_name : "internal"));
|
||||
;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"));
|
||||
|
||||
return 1;
|
||||
fail:
|
||||
@ -432,7 +432,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 %lx (%lx)\n", descriptor_type, offset, offset+0x20);
|
||||
VGM_LOG("UBI BAO: unknown type %x at %"PRIx64" + %x\n", descriptor_type, (off64_t)offset, 0x20);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -451,7 +451,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 %lx (%lx)\n", descriptor_subtype, offset, offset+header_size+0x04);
|
||||
VGM_LOG("UBI BAO: unknown subtype %x at %"PRIx64" + %x\n", descriptor_subtype, (off64_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);
|
||||
@ -475,7 +475,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 %lx\n", offset);
|
||||
;VGM_LOG("BAO header at %"PRIx64"\n", (off64_t)offset);
|
||||
bao->version = bao_version;
|
||||
|
||||
switch(bao->version) {
|
||||
@ -501,7 +501,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 %lx\n", offset); goto fail;
|
||||
default: VGM_LOG("UBI BAO: unknown codec at %"PRIx64"\n", (off64_t)offset); goto fail;
|
||||
}
|
||||
|
||||
bao->prefetch_size = read_32bit(offset + header_size + 0x74, streamFile);
|
||||
@ -533,11 +533,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 %lx\n", offset); goto fail;
|
||||
default: VGM_LOG("UBI BAO: unknown codec at %"PRIx64"\n", (off64_t)offset); goto fail;
|
||||
}
|
||||
|
||||
if (read_32bit(offset+header_size+0x20, streamFile) & 0x10) {
|
||||
VGM_LOG("UBI BAO: possible full loop at %lx\n", offset);
|
||||
VGM_LOG("UBI BAO: possible full loop at %"PRIx64"\n", (off64_t)offset);
|
||||
/* RIFFs may have "smpl" and this flag, even when data shouldn't loop... */
|
||||
}
|
||||
|
||||
@ -562,7 +562,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 %lx\n", offset); goto fail;
|
||||
default: VGM_LOG("UBI BAO: unknown codec at %"PRIx64"\n", (off64_t)offset); goto fail;
|
||||
}
|
||||
|
||||
bao->prefetch_size = read_32bit(offset+header_size+0x84, streamFile);
|
||||
@ -596,7 +596,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 %lx\n", offset); goto fail;
|
||||
default: VGM_LOG("UBI BAO: unknown codec at %"PRIx64"\n", (off64_t)offset); goto fail;
|
||||
}
|
||||
|
||||
bao->prefetch_size = read_32bit(offset + header_size + 0x78, streamFile);
|
||||
@ -613,7 +613,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 %lx\n", offset);
|
||||
VGM_LOG("UBI BAO: unknown BAO version at %"PRIx64"\n", (off64_t)offset);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -297,7 +297,7 @@ static int get_loop_points(STREAMFILE *streamFile, int *out_loop_start, int *out
|
||||
break;
|
||||
|
||||
default:
|
||||
VGM_LOG("Jade: unknown LIST chunk at %lx\n", offset);
|
||||
VGM_LOG("Jade: unknown LIST chunk\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -771,7 +771,7 @@ static int get_xsb_name(char * buf, size_t maxsize, int target_subsong, xwb_head
|
||||
size = 0x14;
|
||||
|
||||
if (flag != 0x01) {
|
||||
VGM_LOG("XSB: xsb flag 0x%x at offset 0x%08lx not implemented\n", flag, off);
|
||||
//VGM_LOG("XSB: xsb flag 0x%x at offset 0x%08lx not implemented\n", flag, off);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -802,7 +802,7 @@ static int get_xsb_name(char * buf, size_t maxsize, int target_subsong, xwb_head
|
||||
//} else if (flag==0x11) { /* Stardew Valley (Switch) */
|
||||
// suboff = size; //???
|
||||
} else {
|
||||
VGM_LOG("XSB: xsb flag 0x%x (size=%x) at offset 0x%08lx not implemented\n", flag, size, off);
|
||||
//VGM_LOG("XSB: xsb flag 0x%x (size=%x) at offset 0x%08lx not implemented\n", flag, size, off);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
@ -813,7 +813,7 @@ static int get_xsb_name(char * buf, size_t maxsize, int target_subsong, xwb_head
|
||||
}
|
||||
|
||||
if (s->wavebank+1 > xsb.xsb_wavebanks_count) {
|
||||
VGM_LOG("XSB: unknown xsb wavebank id %i at offset 0x%lx\n", s->wavebank, off);
|
||||
//VGM_LOG("XSB: unknown xsb wavebank id %i at offset 0x%lx\n", s->wavebank, off);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -883,7 +883,7 @@ static int get_xsb_name(char * buf, size_t maxsize, int target_subsong, xwb_head
|
||||
|
||||
if (w->sound_count == xwb->total_subsongs) {
|
||||
if (!cfg__selected_wavebank) {
|
||||
VGM_LOG("XSB: multiple xsb wavebanks with the same number of sounds, use -w to specify one of the wavebanks\n");
|
||||
//VGM_LOG("XSB: multiple xsb wavebanks with the same number of sounds, use -w to specify one of the wavebanks\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -898,17 +898,17 @@ static int get_xsb_name(char * buf, size_t maxsize, int target_subsong, xwb_head
|
||||
}
|
||||
|
||||
if (!cfg__selected_wavebank) {
|
||||
VGM_LOG("XSB: multiple xsb wavebanks but autodetect didn't work\n");
|
||||
//VGM_LOG("XSB: multiple xsb wavebanks but autodetect didn't work\n");
|
||||
goto fail;
|
||||
}
|
||||
if (xsb.xsb_wavebanks[cfg__selected_wavebank-1].sound_count == 0) {
|
||||
VGM_LOG("XSB: xsb selected wavebank %i has no sounds\n", cfg__selected_wavebank);
|
||||
//VGM_LOG("XSB: xsb selected wavebank %i has no sounds\n", cfg__selected_wavebank);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (cfg__start_sound) {
|
||||
if (xsb.xsb_wavebanks[cfg__selected_wavebank-1].sound_count - (cfg__start_sound-1) < xwb->total_subsongs) {
|
||||
VGM_LOG("XSB: starting sound too high (max in selected wavebank is %i)\n", xsb.xsb_wavebanks[cfg__selected_wavebank-1].sound_count - xwb->total_subsongs + 1);
|
||||
//VGM_LOG("XSB: starting sound too high (max in selected wavebank is %i)\n", xsb.xsb_wavebanks[cfg__selected_wavebank-1].sound_count - xwb->total_subsongs + 1);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -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%lx + 0x%x\n", streamfile->filesize, offset, length);
|
||||
VGM_ASSERT_ONCE(offset > streamfile->filesize, "STDIO: reading over filesize 0x%x @ 0x%"PRIx64" + 0x%x\n", streamfile->filesize, (off64_t)offset, length);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -253,7 +253,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%lx + 0x%x\n", streamfile->filesize, offset, length);
|
||||
VGM_ASSERT_ONCE(offset > streamfile->filesize, "BUFFER: reading over filesize 0x%x @ 0x%"PRIx64" + 0x%x\n", streamfile->filesize, (off64_t)offset, length);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -16,16 +16,29 @@
|
||||
#include "streamtypes.h"
|
||||
#include "util.h"
|
||||
|
||||
|
||||
/* MSVC fixes (though mingw uses MSVCRT but not MSC_VER, maybe use AND?) */
|
||||
#if defined(__MSVCRT__) || defined(_MSC_VER)
|
||||
#include <io.h>
|
||||
|
||||
#ifndef fseeko
|
||||
#define fseeko fseek
|
||||
#endif
|
||||
#ifndef ftello
|
||||
#define ftello ftell
|
||||
#endif
|
||||
|
||||
#define dup _dup
|
||||
|
||||
#ifdef fileno
|
||||
#undef fileno
|
||||
#endif
|
||||
#define fileno _fileno
|
||||
#define fdopen _fdopen
|
||||
|
||||
// #ifndef off64_t
|
||||
// #define off_t __int64
|
||||
// #endif
|
||||
#endif
|
||||
|
||||
#if defined(XBMC)
|
||||
|
Loading…
Reference in New Issue
Block a user