mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-28 00:20:47 +01:00
Add Gameloft .VXN [Mobile games]
This commit is contained in:
parent
d84dd0369f
commit
77b849a024
@ -185,6 +185,7 @@ VGMSTREAM_DECLARE_FILE_TYPE("MIC", mic);
|
||||
VGMSTREAM_DECLARE_FILE_TYPE("MIHB", mihb);
|
||||
VGMSTREAM_DECLARE_FILE_TYPE("MNSTR", mnstr);
|
||||
//"mp4", //common
|
||||
VGMSTREAM_DECLARE_FILE_TYPE("MPC", mpc);
|
||||
VGMSTREAM_DECLARE_FILE_TYPE("MPDSP", mpdsp);
|
||||
VGMSTREAM_DECLARE_FILE_TYPE("MPDS", mpds);
|
||||
VGMSTREAM_DECLARE_FILE_TYPE("MSA", msa);
|
||||
@ -328,6 +329,7 @@ VGMSTREAM_DECLARE_FILE_TYPE("VOI", voi);
|
||||
VGMSTREAM_DECLARE_FILE_TYPE("VPK", vpk);
|
||||
VGMSTREAM_DECLARE_FILE_TYPE("VS", vs);
|
||||
VGMSTREAM_DECLARE_FILE_TYPE("VSF", vsf);
|
||||
VGMSTREAM_DECLARE_FILE_TYPE("VXN", vxn);
|
||||
|
||||
VGMSTREAM_DECLARE_FILE_TYPE("WAA", waa);
|
||||
VGMSTREAM_DECLARE_FILE_TYPE("WAC", wac);
|
||||
|
@ -179,6 +179,7 @@ static const char* extension_list[] = {
|
||||
"mihb",
|
||||
"mnstr",
|
||||
//"mp4", //common
|
||||
"mpc", //FFmpeg, not parsed (musepack)
|
||||
"mpdsp",
|
||||
"mpds",
|
||||
"msa",
|
||||
@ -327,6 +328,7 @@ static const char* extension_list[] = {
|
||||
"vpk",
|
||||
"vs",
|
||||
"vsf",
|
||||
"vxn",
|
||||
|
||||
"waa",
|
||||
"wac",
|
||||
@ -908,6 +910,7 @@ static const meta_info meta_info_list[] = {
|
||||
{meta_UBI_SB, "Ubisoft SBx header"},
|
||||
{meta_NAAC, "Namco NAAC header"},
|
||||
{meta_EZW, "EZ2DJ EZWAVE header"},
|
||||
{meta_VXN, "Gameloft VXN header"},
|
||||
|
||||
#ifdef VGM_USE_VORBIS
|
||||
{meta_OGG_VORBIS, "Ogg Vorbis"},
|
||||
|
@ -1198,6 +1198,10 @@
|
||||
RelativePath=".\meta\vsf.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\meta\vxn.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\meta\waa_wac_wad_wam.c"
|
||||
>
|
||||
|
@ -405,6 +405,7 @@
|
||||
<ClCompile Include="meta\ubi_sb.c" />
|
||||
<ClCompile Include="meta\vs.c" />
|
||||
<ClCompile Include="meta\vsf.c" />
|
||||
<ClCompile Include="meta\vxn.c" />
|
||||
<ClCompile Include="meta\waa_wac_wad_wam.c" />
|
||||
<ClCompile Include="meta\wii_04sw.c" />
|
||||
<ClCompile Include="meta\wii_bns.c" />
|
||||
|
@ -730,6 +730,9 @@
|
||||
<ClCompile Include="meta\vsf.c">
|
||||
<Filter>meta\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="meta\vxn.c">
|
||||
<Filter>meta\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="meta\waa_wac_wad_wam.c">
|
||||
<Filter>meta\Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
@ -693,4 +693,6 @@ VGMSTREAM * init_vgmstream_ubi_sb(STREAMFILE * streamFile);
|
||||
|
||||
VGMSTREAM * init_vgmstream_ezw(STREAMFILE * streamFile);
|
||||
|
||||
VGMSTREAM * init_vgmstream_vxn(STREAMFILE * streamFile);
|
||||
|
||||
#endif /*_META_H*/
|
||||
|
102
src/meta/vxn.c
Normal file
102
src/meta/vxn.c
Normal file
@ -0,0 +1,102 @@
|
||||
#include "meta.h"
|
||||
#include "../coding/coding.h"
|
||||
|
||||
/* VXN - from Gameloft mobile games */
|
||||
VGMSTREAM * init_vgmstream_vxn(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
int loop_flag = 0, channel_count, codec, sample_rate, block_align, bits, num_samples;
|
||||
off_t start_offset, stream_offset, chunk_offset, first_offset = 0x00;
|
||||
size_t stream_size;
|
||||
int total_streams, target_stream = streamFile->stream_index;
|
||||
|
||||
/* check extensions */
|
||||
if (!check_extensions(streamFile,"vxn"))
|
||||
goto fail;
|
||||
|
||||
/* check header/version chunk (RIFF-like format with many custom chunks) */
|
||||
if (read_32bitBE(0x00,streamFile) != 0x566F784E) /* "VoxN" */
|
||||
goto fail;
|
||||
if (read_32bitLE(0x10,streamFile) != get_streamfile_size(streamFile) )
|
||||
goto fail;
|
||||
|
||||
if (!find_chunk_le(streamFile, 0x41666D74,first_offset,0, &chunk_offset,NULL)) /* "Afmt" */
|
||||
goto fail;
|
||||
codec = (uint16_t)read_16bitLE(chunk_offset+0x00, streamFile);
|
||||
channel_count = (uint16_t)read_16bitLE(chunk_offset+0x02, streamFile);
|
||||
sample_rate = read_32bitLE(chunk_offset+0x04, streamFile);
|
||||
block_align = (uint16_t)read_16bitLE(chunk_offset+0x08, streamFile);
|
||||
bits = (uint16_t)read_16bitLE(chunk_offset+0x0a, streamFile);
|
||||
|
||||
/* files are divided into segment subsongs, often a leadout and loop in that order
|
||||
* (the "Plst" and "Rule" chunks may have order info) */
|
||||
if (!find_chunk_le(streamFile, 0x5365676D,first_offset,0, &chunk_offset,NULL)) /* "Segm" */
|
||||
goto fail;
|
||||
total_streams = read_32bitLE(chunk_offset+0x00, streamFile);
|
||||
if (target_stream == 0) target_stream = 1;
|
||||
if (target_stream < 0 || target_stream > total_streams || total_streams < 1) goto fail;
|
||||
|
||||
stream_offset = read_32bitLE(chunk_offset+0x04 + (target_stream-1)*0x18 + 0x00, streamFile);
|
||||
stream_size = read_32bitLE(chunk_offset+0x04 + (target_stream-1)*0x18 + 0x04, streamFile);
|
||||
num_samples = read_32bitLE(chunk_offset+0x04 + (target_stream-1)*0x18 + 0x08, streamFile);
|
||||
|
||||
if (!find_chunk_le(streamFile, 0x44617461,first_offset,0, &chunk_offset,NULL)) /* "Data" */
|
||||
goto fail;
|
||||
start_offset = chunk_offset + stream_offset;
|
||||
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
vgmstream->sample_rate = sample_rate;
|
||||
vgmstream->num_samples = num_samples;
|
||||
vgmstream->num_streams = total_streams;
|
||||
|
||||
vgmstream->meta_type = meta_VXN;
|
||||
|
||||
switch (codec) {
|
||||
|
||||
case 0x0002: /* MSADPCM (ex. Asphalt 7) */
|
||||
if (bits != 4) goto fail;
|
||||
|
||||
vgmstream->coding_type = coding_MSADPCM;
|
||||
vgmstream->interleave_block_size = block_align;
|
||||
vgmstream->layout_type = layout_none;
|
||||
break;
|
||||
|
||||
case 0x0011: /* MS-IMA (ex. Asphalt 6) */
|
||||
if (bits != 16) goto fail;
|
||||
|
||||
vgmstream->coding_type = coding_MS_IMA;
|
||||
vgmstream->interleave_block_size = block_align;
|
||||
vgmstream->layout_type = layout_none;
|
||||
break;
|
||||
|
||||
#ifdef VGM_USE_FFMPEG
|
||||
case 0x0800: { /* Musepack (ex. Asphalt Xtreme) */
|
||||
ffmpeg_codec_data * ffmpeg_data = NULL;
|
||||
if (bits != 0xFFFF) goto fail;
|
||||
|
||||
ffmpeg_data = init_ffmpeg_offset(streamFile, start_offset,stream_size);
|
||||
if (!ffmpeg_data) goto fail;
|
||||
vgmstream->codec_data = ffmpeg_data;
|
||||
vgmstream->coding_type = coding_FFmpeg;
|
||||
vgmstream->layout_type = layout_none;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
default:
|
||||
VGM_LOG("VXN: unknown codec 0x%02x\n", codec);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* open the file for reading */
|
||||
if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) )
|
||||
goto fail;
|
||||
return vgmstream;
|
||||
|
||||
fail:
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
@ -365,7 +365,8 @@ VGMSTREAM * (*init_vgmstream_functions[])(STREAMFILE *streamFile) = {
|
||||
init_vgmstream_pc_ast,
|
||||
init_vgmstream_naac,
|
||||
init_vgmstream_ubi_sb,
|
||||
init_vgmstream_ezw,
|
||||
init_vgmstream_ezw,
|
||||
init_vgmstream_vxn,
|
||||
|
||||
init_vgmstream_txth, /* should go at the end (lower priority) */
|
||||
#ifdef VGM_USE_FFMPEG
|
||||
|
@ -628,7 +628,8 @@ typedef enum {
|
||||
meta_PC_AST, /* Dead Rising (PC) */
|
||||
meta_NAAC, /* Namco AAC (3DS) */
|
||||
meta_UBI_SB, /* Ubisoft banks */
|
||||
meta_EZW, /* EZ2DJ (Arcade) EZWAV */
|
||||
meta_EZW, /* EZ2DJ (Arcade) EZWAV */
|
||||
meta_VXN, /* Gameloft mobile games */
|
||||
|
||||
#ifdef VGM_USE_VORBIS
|
||||
meta_OGG_VORBIS, /* Ogg Vorbis */
|
||||
|
Loading…
Reference in New Issue
Block a user