mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-15 19:13:20 +01:00
Fix some XWB XACT2 looping [Blue Dragon, Prey]
This commit is contained in:
parent
7f2e8f58db
commit
7f90359e40
@ -154,7 +154,7 @@ VGMSTREAM * init_vgmstream_xwb(STREAMFILE *streamFile) {
|
||||
if (xwb.xact == 1) { //LoopRegion (bytes within data)
|
||||
xwb.loop_start = (uint32_t)read_32bit(off+0x10, streamFile);
|
||||
xwb.loop_end = (uint32_t)read_32bit(off+0x14, streamFile);//length
|
||||
} else if (xwb.xact == 2) {//LoopRegion (bytes within data) or XMALoopRegion (bits within data)
|
||||
} else if (xwb.xact == 2 && xwb.version <= 38) {//LoopRegion (bytes within data) or XMALoopRegion (bits within data)
|
||||
xwb.loop_start = (uint32_t)read_32bit(off+0x10, streamFile);
|
||||
xwb.loop_end = (uint32_t)read_32bit(off+0x14, streamFile);//length (LoopRegion) or offset (XMALoopRegion)
|
||||
} else {//LoopRegion (samples)
|
||||
@ -239,7 +239,8 @@ VGMSTREAM * init_vgmstream_xwb(STREAMFILE *streamFile) {
|
||||
xwb.loop_start_sample = (xwb.loop_start) / block_size / samples_per_frame;
|
||||
xwb.loop_end_sample = (xwb.loop_start + xwb.loop_end) / block_size / samples_per_frame;
|
||||
}
|
||||
else if (xwb.xact == 2 && (xwb.codec == XMA1 || xwb.codec == XMA2) && xwb.loop_flag) {
|
||||
else if (xwb.xact == 2 && xwb.version <= 38 /* v38: byte offset, v40+: sample offset, v39: ? */
|
||||
&& (xwb.codec == XMA1 || xwb.codec == XMA2) && xwb.loop_flag) {
|
||||
/* need to manually find sample offsets, thanks to Microsoft dumb headers */
|
||||
xma_sample_data xma_sd;
|
||||
memset(&xma_sd,0,sizeof(xma_sample_data));
|
||||
@ -258,9 +259,15 @@ VGMSTREAM * init_vgmstream_xwb(STREAMFILE *streamFile) {
|
||||
xma_get_samples(&xma_sd, streamFile);
|
||||
xwb.loop_start_sample = xma_sd.loop_start_sample;
|
||||
xwb.loop_end_sample = xma_sd.loop_end_sample;
|
||||
|
||||
// todo fix properly (XWB loop_start/end seem to count padding samples while XMA1 RIFF doesn't)
|
||||
xwb.loop_start_sample -= 512;
|
||||
xwb.loop_end_sample -= 512;
|
||||
//this doesn't seem ok because can fall within 0 to 512 (ie.- first frame)
|
||||
//if (xwb.loop_start_sample) xwb.loop_start_sample -= 512;
|
||||
//if (xwb.loop_end_sample) xwb.loop_end_sample -= 512;
|
||||
|
||||
//add padding back until it's fixed (affects looping)
|
||||
// (in rare cases this causes a glitch in FFmpeg since it has a bug where it's missing some samples)
|
||||
xwb.num_samples += 64 + 512;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user