From 7d967a2b498d1005984bac68d41e48914b470549 Mon Sep 17 00:00:00 2001 From: bnnm Date: Sun, 19 Jan 2025 00:25:30 +0100 Subject: [PATCH] cleanup: fix recent issue with certain meta --- src/meta/hd_bd.c | 2 +- src/meta/pphd.c | 2 +- src/meta/xabp.c | 4 ++-- src/util/meta_utils.c | 3 ++- src/util/meta_utils.h | 2 ++ 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/meta/hd_bd.c b/src/meta/hd_bd.c index d9d347b9..09cf0753 100644 --- a/src/meta/hd_bd.c +++ b/src/meta/hd_bd.c @@ -88,8 +88,8 @@ VGMSTREAM* init_vgmstream_hd_bd(STREAMFILE* sf) { h.coding = coding_PSX; h.layout = layout_none; - h.open_stream = true; + h.has_subsongs = true; // detect hdb pasted together (handle as a separate meta?) if (get_streamfile_size(sf) == hd_size + bd_size) { diff --git a/src/meta/pphd.c b/src/meta/pphd.c index 0745d8ae..517b8a3d 100644 --- a/src/meta/pphd.c +++ b/src/meta/pphd.c @@ -69,8 +69,8 @@ VGMSTREAM* init_vgmstream_pphd(STREAMFILE* sf) { h.coding = coding_PSX; h.layout = layout_none; - h.open_stream = true; + h.has_subsongs = true; h.sf_head = sf; h.sf_body = open_streamfile_by_ext(sf,"pbd"); diff --git a/src/meta/xabp.c b/src/meta/xabp.c index c1c28c4a..625e4967 100644 --- a/src/meta/xabp.c +++ b/src/meta/xabp.c @@ -40,6 +40,7 @@ VGMSTREAM* init_vgmstream_xabp(STREAMFILE* sf) { h.coding = coding_PSX; h.layout = layout_none; h.open_stream = true; + h.has_subsongs = true; h.sf_head = sf; h.sf_body = open_streamfile_by_ext(sf,"bd"); @@ -47,10 +48,9 @@ VGMSTREAM* init_vgmstream_xabp(STREAMFILE* sf) { // Entries/offsets aren't ordered .bd not it seems to have sizes (maybe mixes notes+streams into one) // Since PS-ADPCM is wired to play until end frame end or loop, it's probably designed like that. - // It also repeats entries (different ID but same config) but for now just prints it as is. + // It also repeats entries (different ID but same config) but for now just prints it as is; this also happens in bigfiles. h.loop_flag = ps_find_stream_info(h.sf_body, h.stream_offset, bd_size - h.stream_offset, h.channels, h.interleave, &h.loop_start, &h.loop_end, &h.stream_size); h.num_samples = ps_bytes_to_samples(h.stream_size, h.channels); -VGM_LOG("s=%x, %x\n", h.stream_offset, h.stream_size); vgmstream = alloc_metastream(&h); close_streamfile(h.sf_body); diff --git a/src/util/meta_utils.c b/src/util/meta_utils.c index 0a64ba65..bea8b060 100644 --- a/src/util/meta_utils.c +++ b/src/util/meta_utils.c @@ -15,7 +15,7 @@ VGMSTREAM* alloc_metastream(meta_header_t* h) { return NULL; } - if (h->target_subsong < 0 || h->target_subsong > h->total_subsongs || h->total_subsongs < 1) { + if (h->has_subsongs && (h->target_subsong < 0 || h->target_subsong > h->total_subsongs || h->total_subsongs < 1)) { VGM_LOG("meta: wrong subsongs %i vs %i\n", h->target_subsong, h->total_subsongs); return NULL; } @@ -36,6 +36,7 @@ VGMSTREAM* alloc_metastream(meta_header_t* h) { vgmstream->num_streams = h->total_subsongs; vgmstream->stream_size = h->stream_size; vgmstream->interleave_block_size = h->interleave; + vgmstream->interleave_last_block_size = h->interleave_last; vgmstream->allow_dual_stereo = h->allow_dual_stereo; if (h->name_offset) diff --git a/src/util/meta_utils.h b/src/util/meta_utils.h index 4c3b37bc..3e7e3107 100644 --- a/src/util/meta_utils.h +++ b/src/util/meta_utils.h @@ -24,6 +24,7 @@ typedef struct { int total_subsongs; int32_t interleave; + int32_t interleave_last; /* common helpers */ uint32_t stream_offset; /* where current stream starts */ @@ -54,6 +55,7 @@ typedef struct { bool open_stream; + bool has_subsongs; bool allow_dual_stereo; } meta_header_t;