mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-17 23:36:41 +01:00
Add FFDL Ogg [Final Fantasy Dimensions (Android)]
This commit is contained in:
parent
c720d6ce37
commit
fa4fc1f64c
@ -1302,10 +1302,14 @@
|
||||
RelativePath=".\meta\xa.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\meta\fag.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\meta\fag.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\meta\ffdl.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\meta\psx_gms.c"
|
||||
>
|
||||
|
@ -415,6 +415,7 @@
|
||||
<ClCompile Include="meta\ps3_mta2.c" />
|
||||
<ClCompile Include="meta\xa.c" />
|
||||
<ClCompile Include="meta\fag.c" />
|
||||
<ClCompile Include="meta\ffdl.c" />
|
||||
<ClCompile Include="meta\psx_gms.c" />
|
||||
<ClCompile Include="meta\ea_swvr.c" />
|
||||
<ClCompile Include="meta\raw.c" />
|
||||
|
@ -802,6 +802,9 @@
|
||||
<ClCompile Include="meta\fag.c">
|
||||
<Filter>meta\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="meta\ffdl.c">
|
||||
<Filter>meta\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="meta\psx_gms.c">
|
||||
<Filter>meta\Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
83
src/meta/ffdl.c
Normal file
83
src/meta/ffdl.c
Normal file
@ -0,0 +1,83 @@
|
||||
#include "meta.h"
|
||||
#include "../coding/coding.h"
|
||||
|
||||
|
||||
/* FFDL - Matrix Software wrapper [Final Fantasy Dimensions (Android/iOS)] */
|
||||
VGMSTREAM * init_vgmstream_ffdl(STREAMFILE *sf) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
STREAMFILE *temp_sf = NULL;
|
||||
int loop_flag = 0, is_ffdl = 0;
|
||||
int32_t num_samples = 0, loop_start_sample = 0, loop_end_sample = 0;
|
||||
off_t start_offset;
|
||||
size_t file_size;
|
||||
|
||||
|
||||
/* checks */
|
||||
/* .ogg/logg: probably extension
|
||||
* (extensionless): for files without names in Android .obb bigfile */
|
||||
if (!check_extensions(sf, "ogg,logg,bin,"))
|
||||
goto fail;
|
||||
|
||||
/* "FFDL" is a wrapper used in all of the game's files, that may contain standard
|
||||
* Ogg/MP4 or "mtxs" w/ loops + Ogg/MP4, and may concatenate multiple of them
|
||||
* (without size in sight), so they should be split externally first. */
|
||||
|
||||
start_offset = 0x00;
|
||||
|
||||
/* may start with wrapper (not split) */
|
||||
if (read_u32be(0x00,sf) == 0x4646444C) { /* "FFDL" */
|
||||
is_ffdl = 1;
|
||||
start_offset += 0x04;
|
||||
}
|
||||
|
||||
/* may start with sample info (split) or after "FFDL" */
|
||||
if (read_u32be(start_offset+0x00,sf) == 0x6D747873) { /* "mtxs" */
|
||||
is_ffdl = 1;
|
||||
|
||||
num_samples = read_s32le(start_offset + 0x04,sf);
|
||||
loop_start_sample = read_s32le(start_offset + 0x08,sf);
|
||||
loop_end_sample = read_s32le(start_offset + 0x0c,sf);
|
||||
loop_flag = !(loop_start_sample==0 && loop_end_sample==num_samples);
|
||||
|
||||
start_offset += 0x10;
|
||||
}
|
||||
|
||||
if (!is_ffdl)
|
||||
goto fail; /* don't parse regular files */
|
||||
|
||||
file_size = get_streamfile_size(sf) - start_offset;
|
||||
|
||||
if (read_u32be(start_offset,sf) == 0x4F676753) { /* "OggS" */
|
||||
temp_sf = setup_subfile_streamfile(sf, start_offset, file_size, "ogg");
|
||||
if (!temp_sf) goto fail;
|
||||
|
||||
#ifdef VGM_USE_VORBIS
|
||||
vgmstream = init_vgmstream_ogg_vorbis(temp_sf);
|
||||
if (!vgmstream) goto fail;
|
||||
#else
|
||||
goto fail;
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* install loops */
|
||||
if (loop_flag) {
|
||||
/* num_samples is erratic (can be bigger = padded, or smaller = cut; doesn't matter for looping though) */
|
||||
//;VGM_ASSERT(vgmstream->num_samples != num_samples,
|
||||
// "FFDL: mtxs samples = %i vs num_samples = %i\n", num_samples, vgmstream->num_samples);
|
||||
//vgmstream->num_samples = num_samples;
|
||||
|
||||
/* loop samples are within num_samples, and don't have encoder delay (loop_start=0 starts from encoder_delay) */
|
||||
vgmstream_force_loop(vgmstream, 1, loop_start_sample, loop_end_sample);
|
||||
}
|
||||
|
||||
close_streamfile(temp_sf);
|
||||
return vgmstream;
|
||||
|
||||
fail:
|
||||
close_streamfile(temp_sf);
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
@ -831,4 +831,6 @@ VGMSTREAM * init_vgmstream_dsf(STREAMFILE * streamFile);
|
||||
|
||||
VGMSTREAM * init_vgmstream_208(STREAMFILE * streamFile);
|
||||
|
||||
VGMSTREAM * init_vgmstream_ffdl(STREAMFILE * streamFile);
|
||||
|
||||
#endif /*_META_H*/
|
||||
|
@ -466,6 +466,7 @@ VGMSTREAM * (*init_vgmstream_functions[])(STREAMFILE *streamFile) = {
|
||||
init_vgmstream_dsf,
|
||||
init_vgmstream_208,
|
||||
init_vgmstream_dsp_ds2,
|
||||
init_vgmstream_ffdl,
|
||||
|
||||
/* lowest priority metas (should go after all metas, and TXTH should go before raw formats) */
|
||||
init_vgmstream_txth, /* proper parsers should supersede TXTH, once added */
|
||||
|
Loading…
x
Reference in New Issue
Block a user