Merge pull request #775 from bnnm/aifc-etc

aifc etc
This commit is contained in:
bnnm 2020-12-05 19:46:00 +01:00 committed by GitHub
commit 67d38465e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 252 additions and 220 deletions

View File

@ -80,7 +80,7 @@ static void oki16_expand_nibble(VGMSTREAMCHANNEL* stream, off_t byte_offset, int
}
/* Possible variation for adp_konami (Viper hardware):
* delta = ((n&7) + 0.5) * stepsize / 4; clamps 2047,-2048; nigh nibble first
* delta = ((n&7) + 0.5) * stepsize / 4; clamps 2047,-2048
*
* Results are very similar, but can't verify actual decoding, and oki4s is used in
* Jubeat (also Konami) so it makes sense they would have reused it.
@ -144,7 +144,7 @@ void decode_pcfx(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing,
}
/* OKI variation with 16-bit output (vs standard's 12-bit), found in FrontWing's PS2 games (Sweet Legacy, Hooligan).
* Reverse engineered from the ELF with help from the folks at hcs. */
* Reverse engineered from the ELF with help from the folks at hcs. Codec has no name so OKI16 is just a description. */
void decode_oki16(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel) {
int i, sample_count = 0;
int32_t hist1 = stream->adpcm_history1_32;
@ -176,7 +176,7 @@ void decode_oki16(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing
}
/* OKI variation with 16-bit output (vs standard's 12-bit) and pre-adjusted tables (shifted by 4), found in Jubeat Clan (AC).
* Reverse engineered from the DLLs. */
* Reverse engineered from the DLLs (libbmsd-engine.dll). Internally code calls it "adpcm", so OKI4S is just a description. */
void decode_oki4s(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel) {
int i, sample_count = 0;
int32_t hist1 = stream->adpcm_history1_32;
@ -195,7 +195,7 @@ void decode_oki4s(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing
for (i = first_sample; i < first_sample + samples_to_do; i++, sample_count += channelspacing) {
off_t byte_offset = is_stereo ?
stream->offset + i : /* stereo: one nibble per channel */
stream->offset + i/2; /* mono: consecutive nibbles (assumed) */
stream->offset + i/2; /* mono: consecutive nibbles */
int nibble_shift =
is_stereo ? ((channel&1) ? 0:4) : ((i&1) ? 0:4); /* even = high, odd = low */

View File

@ -330,8 +330,27 @@ VGMSTREAM* init_vgmstream_aifc(STREAMFILE* sf) {
loop_flag = 0;
}
}
}
if (!loop_flag && mark_offset) {
int mark_count = read_u16be(mark_offset + 0x00,sf);
/* Relic has "beg loop" "end loop" comments but no actual looping? */
/* use "beg/end" loop comments [Battle Tryst (Arcade)]
* Relic codec has 3 "beg loop" "end loop" "start offset" comments, but always begin = 0 and end = -1 */
if (mark_count == 2) {
/* per mark:
* 00(2): id
* 02(4): sample point
* 06(1): string size
* --(-): string (non-null terminated)
* --(1): null terminator */
/* simplified... */
if (read_u32be(mark_offset + 0x09,sf) == 0x62656720 && /* "beg " */
read_u32be(mark_offset + 0x19,sf) == 0x656E6420) { /* "end " */
loop_start = read_s32be(mark_offset + 0x04, sf);
loop_end = read_s32be(mark_offset + 0x14, sf);
loop_flag = 1;
}
}
}

View File

@ -6,7 +6,20 @@
static int read_pos_file(uint8_t* buf, size_t bufsize, STREAMFILE* sf);
static int find_ogg_loops(ffmpeg_codec_data* data, int32_t* p_loop_start, int32_t* p_loop_end);
/* parses any file supported by FFmpeg and not handled elsewhere (mainly: MP4/AAC, MP3, MPC, FLAC) */
/* parses any format supported by FFmpeg and not handled elsewhere:
* - MP3 (.mp3, .mus): Marc Ecko's Getting Up (PC)
* - MPC (.mpc): Moonshine Runners (PC), Asphalt 7 (PC)
* - FLAC (.flac): Warcraft 3 Reforged (PC), Call of Duty: Ghosts (PC)
* - DUCK (.wav): Sonic Jam (SAT), Virtua Fighter 2 (SAT)
* - ALAC/AAC (.caf): Chrono Trigger (iOS)
* - ATRAC3 (.oma, .aa3): demuxed PSP/PS3 videos
* - WMA/WMAPRO (.wma): Castlevania Symphony of the Night (Xbox)
* - AC3 (.ac3): some PS2 games
*
* May also catch files that are supported elsewhere but rejected due to bugs,
* but those should be fixed in their parser for proper loops/etc support
* (catch-all behavior may be disabled later).
*/
VGMSTREAM* init_vgmstream_ffmpeg(STREAMFILE* sf) {
VGMSTREAM* vgmstream = NULL;
ffmpeg_codec_data* data = NULL;

View File

@ -167,14 +167,14 @@ static void load_default_config(play_config_t* def, play_config_t* tcfg) {
def->fade_time_set = 1;
}
/* loop priority: #i > #e > #E */
/* loop priority: #i > #e > #E (respect player's ignore too) */
if (tcfg->really_force_loop) {
def->ignore_loop = 0;
//def->ignore_loop = 0;
def->force_loop = 0;
def->really_force_loop = 1;
}
if (tcfg->force_loop) {
def->ignore_loop = 0;
//def->ignore_loop = 0;
def->force_loop = 1;
def->really_force_loop = 0;
}