cleanup: fix recent issue with certain meta

This commit is contained in:
bnnm 2025-01-19 00:25:30 +01:00
parent 85c78d7d37
commit 7d967a2b49
5 changed files with 8 additions and 5 deletions

View File

@ -88,8 +88,8 @@ VGMSTREAM* init_vgmstream_hd_bd(STREAMFILE* sf) {
h.coding = coding_PSX; h.coding = coding_PSX;
h.layout = layout_none; h.layout = layout_none;
h.open_stream = true; h.open_stream = true;
h.has_subsongs = true;
// detect hdb pasted together (handle as a separate meta?) // detect hdb pasted together (handle as a separate meta?)
if (get_streamfile_size(sf) == hd_size + bd_size) { if (get_streamfile_size(sf) == hd_size + bd_size) {

View File

@ -69,8 +69,8 @@ VGMSTREAM* init_vgmstream_pphd(STREAMFILE* sf) {
h.coding = coding_PSX; h.coding = coding_PSX;
h.layout = layout_none; h.layout = layout_none;
h.open_stream = true; h.open_stream = true;
h.has_subsongs = true;
h.sf_head = sf; h.sf_head = sf;
h.sf_body = open_streamfile_by_ext(sf,"pbd"); h.sf_body = open_streamfile_by_ext(sf,"pbd");

View File

@ -40,6 +40,7 @@ VGMSTREAM* init_vgmstream_xabp(STREAMFILE* sf) {
h.coding = coding_PSX; h.coding = coding_PSX;
h.layout = layout_none; h.layout = layout_none;
h.open_stream = true; h.open_stream = true;
h.has_subsongs = true;
h.sf_head = sf; h.sf_head = sf;
h.sf_body = open_streamfile_by_ext(sf,"bd"); 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) // 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. // 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.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); 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); vgmstream = alloc_metastream(&h);
close_streamfile(h.sf_body); close_streamfile(h.sf_body);

View File

@ -15,7 +15,7 @@ VGMSTREAM* alloc_metastream(meta_header_t* h) {
return NULL; 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); VGM_LOG("meta: wrong subsongs %i vs %i\n", h->target_subsong, h->total_subsongs);
return NULL; return NULL;
} }
@ -36,6 +36,7 @@ VGMSTREAM* alloc_metastream(meta_header_t* h) {
vgmstream->num_streams = h->total_subsongs; vgmstream->num_streams = h->total_subsongs;
vgmstream->stream_size = h->stream_size; vgmstream->stream_size = h->stream_size;
vgmstream->interleave_block_size = h->interleave; vgmstream->interleave_block_size = h->interleave;
vgmstream->interleave_last_block_size = h->interleave_last;
vgmstream->allow_dual_stereo = h->allow_dual_stereo; vgmstream->allow_dual_stereo = h->allow_dual_stereo;
if (h->name_offset) if (h->name_offset)

View File

@ -24,6 +24,7 @@ typedef struct {
int total_subsongs; int total_subsongs;
int32_t interleave; int32_t interleave;
int32_t interleave_last;
/* common helpers */ /* common helpers */
uint32_t stream_offset; /* where current stream starts */ uint32_t stream_offset; /* where current stream starts */
@ -54,6 +55,7 @@ typedef struct {
bool open_stream; bool open_stream;
bool has_subsongs;
bool allow_dual_stereo; bool allow_dual_stereo;
} meta_header_t; } meta_header_t;