From 4407dd26e1873fa8e91c6d84e0f5812ddc73290c Mon Sep 17 00:00:00 2001 From: bnnm Date: Mon, 11 Sep 2023 00:56:24 +0200 Subject: [PATCH 1/2] Fix some .rpgmv [Omori (PC)] --- src/meta/encrypted.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/meta/encrypted.c b/src/meta/encrypted.c index 120fcb1c..a9e18ccc 100644 --- a/src/meta/encrypted.c +++ b/src/meta/encrypted.c @@ -154,8 +154,8 @@ static VGMSTREAM* init_vgmstream_encrypted_rpgmvo_riff(STREAMFILE* sf) { e.key_size = 0x10; load_key(&cfg, e.keybuf, e.key_size); cfg.start = 0x10; - cfg.max_offset = 0x10; - + cfg.max_offset = 0x20; + e.temp_sf = setup_ogg_vorbis_streamfile(sf, &cfg); if (!e.temp_sf) goto fail; From c84589cae2d08e1e3ba7c7939abe13262578d450 Mon Sep 17 00:00:00 2001 From: bnnm Date: Mon, 11 Sep 2023 00:57:32 +0200 Subject: [PATCH 2/2] Fix PS4 .bsnd num_samples --- src/meta/idtech.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/meta/idtech.c b/src/meta/idtech.c index 191515ae..99641c23 100644 --- a/src/meta/idtech.c +++ b/src/meta/idtech.c @@ -389,7 +389,7 @@ VGMSTREAM* init_vgmstream_bsnf(STREAMFILE* sf) { if (stream_size != get_streamfile_size(sb)) goto fail; - loop_flag = (loop_start > 0); + loop_flag = (loop_start > 0); /* loops from 0 on some codecs aren't detectable though */ start_offset = 0x00; /* build the VGMSTREAM */ @@ -404,13 +404,18 @@ VGMSTREAM* init_vgmstream_bsnf(STREAMFILE* sf) { vgmstream->num_streams = num_languages; strncpy(vgmstream->stream_name, language, STREAM_NAME_SIZE); + /* for codecs with explicit encoder delay (mp3/at9/etc) num_samples includes it + * ex. mus_c05_dream_doorloop_* does full loops; with some codecs loop start is encoder delay and num_samples + * has extra delay samples compared to codecs with implicit delay (ex. mp3 1152 to 101152 vs ogg 0 to 100000), + * but there is no header value for encoder delay, maybe engine hardcodes it? */ + switch (codec) { #ifdef VGM_USE_MPEG case 0x0055: { mpeg_custom_config cfg = { 0 }; - cfg.skip_samples = 1152; /* seems ok */ + //cfg.skip_samples = 1152; /* observed default */ vgmstream->codec_data = init_mpeg_custom(sb, start_offset, &vgmstream->coding_type, vgmstream->channels, MPEG_STANDARD, &cfg); if (!vgmstream->codec_data) goto fail; @@ -451,14 +456,20 @@ VGMSTREAM* init_vgmstream_bsnf(STREAMFILE* sf) { case 0x42D2: { atrac9_config cfg = { 0 }; + /* extra offset: RIFF fmt extra data (extra size, frame size, GUID, etc), no fact samples/delay */ + cfg.channels = vgmstream->channels; - cfg.encoder_delay = read_u16le(extra_offset + 0x02, sf); + //cfg.encoder_delay = read_u16le(extra_offset + 0x02, sf) / 4; /* seemingly one subframe = 256 */ cfg.config_data = read_u32be(extra_offset + 0x1c, sf); vgmstream->codec_data = init_atrac9(&cfg); if (!vgmstream->codec_data) goto fail; vgmstream->coding_type = coding_ATRAC9; vgmstream->layout_type = layout_none; + + vgmstream->num_samples -= cfg.encoder_delay; + vgmstream->loop_start_sample -= cfg.encoder_delay; + vgmstream->loop_end_sample -= cfg.encoder_delay; break; } #endif