mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-15 11:07:40 +01:00
Merge pull request #306 from chrispable/master
Add Konami / Sony ATRAC3 support for VA3 files
This commit is contained in:
commit
02cd3fbf4b
@ -543,7 +543,12 @@ int main(int argc, char ** argv) {
|
||||
|
||||
fail:
|
||||
if (!cfg.play_sdtout)
|
||||
{
|
||||
if (outfile != NULL)
|
||||
{
|
||||
fclose(outfile);
|
||||
}
|
||||
}
|
||||
close_vgmstream(vgmstream);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
@ -393,6 +393,7 @@ static const char* extension_list[] = {
|
||||
|
||||
"v0",
|
||||
//"v1", //dual channel with v0
|
||||
"va3", //konami atrac3, FFMPEG - DDR Supernova 2 AC
|
||||
"vag",
|
||||
"vai",
|
||||
"vas",
|
||||
@ -1092,6 +1093,7 @@ static const meta_info meta_info_list[] = {
|
||||
{meta_ADPCM_CAPCOM, "Capcom .ADPCM header"},
|
||||
{meta_UE4OPUS, "Epic Games UE4OPUS header"},
|
||||
{meta_XWMA, "Microsoft XWMA RIFF header"},
|
||||
{meta_VA3, "Konami / Sony ATRAC3 Header" },
|
||||
|
||||
};
|
||||
|
||||
|
@ -186,6 +186,7 @@
|
||||
<ClCompile Include="meta\x360_cxs.c" />
|
||||
<ClCompile Include="meta\x360_tra.c" />
|
||||
<ClCompile Include="formats.c" />
|
||||
<ClCompile Include="meta\ps2_va3.c" />
|
||||
<ClCompile Include="streamfile.c" />
|
||||
<ClCompile Include="util.c" />
|
||||
<ClCompile Include="vgmstream.c" />
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Header Files">
|
||||
@ -1465,5 +1465,8 @@
|
||||
<ClCompile Include="meta\ktss.c">
|
||||
<Filter>meta\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="meta\ps2_va3.c">
|
||||
<Filter>meta\Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -629,6 +629,8 @@ VGMSTREAM * init_vgmstream_ta_aac_mobile(STREAMFILE *streamFile);
|
||||
VGMSTREAM * init_vgmstream_ta_aac_mobile_vorbis(STREAMFILE *streamFile);
|
||||
VGMSTREAM * init_vgmstream_ta_aac_vita(STREAMFILE *streamFile);
|
||||
|
||||
VGMSTREAM * init_vgmstream_va3(STREAMFILE *streamFile);
|
||||
|
||||
VGMSTREAM * init_vgmstream_ps3_mta2(STREAMFILE *streamFile);
|
||||
|
||||
VGMSTREAM * init_vgmstream_ngc_ulw(STREAMFILE * streamFile);
|
||||
|
82
src/meta/ps2_va3.c
Normal file
82
src/meta/ps2_va3.c
Normal file
@ -0,0 +1,82 @@
|
||||
#include "meta.h"
|
||||
#include "../coding/coding.h"
|
||||
|
||||
/* VA3 - Konami / Sont Atrac3 Container */
|
||||
|
||||
|
||||
/* PS2 DDR Supernova 2 Arcade */
|
||||
VGMSTREAM * init_vgmstream_va3(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
off_t start_offset;
|
||||
int loop_flag, channel_count;
|
||||
uint32_t data_size, loop_start, loop_end, codec_id;
|
||||
|
||||
/* check extension, case insensitive */
|
||||
if (!check_extensions(streamFile, "va3"))
|
||||
goto fail;
|
||||
|
||||
if (read_32bitBE(0x00, streamFile) != 0x21334156) /* "!3AV" */
|
||||
goto fail;
|
||||
|
||||
/* va3 header */
|
||||
start_offset = 0x800;
|
||||
data_size = read_32bitLE(0x04, streamFile);// get_streamfile_size(streamFile) - start_offset;
|
||||
// pretty sure 0x4 LE 32 bit is some sort of filesize...
|
||||
|
||||
loop_flag = 0;
|
||||
//0x18 is 1... what is this?
|
||||
channel_count = 2;
|
||||
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count, loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
|
||||
vgmstream->sample_rate = read_32bitLE(0x14, streamFile);
|
||||
vgmstream->num_samples = read_32bitLE(0x08, streamFile);
|
||||
vgmstream->channels = channel_count;
|
||||
vgmstream->meta_type = meta_VA3;
|
||||
loop_start = 0;
|
||||
loop_end = 0;
|
||||
|
||||
#ifdef VGM_USE_FFMPEG
|
||||
{
|
||||
ffmpeg_codec_data *ffmpeg_data = NULL;
|
||||
uint8_t buf[200];
|
||||
int32_t bytes, samples_size = 1024, block_size, encoder_delay, joint_stereo;
|
||||
block_size = 0xC0 * vgmstream->channels;
|
||||
//max_samples = (data_size / block_size) * samples_size;
|
||||
encoder_delay = 0x0;
|
||||
joint_stereo = 0;
|
||||
|
||||
/* make a fake riff so FFmpeg can parse the ATRAC3 */
|
||||
bytes = ffmpeg_make_riff_atrac3(buf, 200, vgmstream->num_samples, data_size, vgmstream->channels, vgmstream->sample_rate, block_size, joint_stereo, encoder_delay);
|
||||
if (bytes <= 0) goto fail;
|
||||
|
||||
ffmpeg_data = init_ffmpeg_header_offset(streamFile, buf, bytes, start_offset, data_size);
|
||||
if (!ffmpeg_data) goto fail;
|
||||
vgmstream->codec_data = ffmpeg_data;
|
||||
vgmstream->coding_type = coding_FFmpeg;
|
||||
vgmstream->layout_type = layout_none;
|
||||
//vgmstream->num_samples = max_samples;
|
||||
|
||||
if (loop_flag) {
|
||||
vgmstream->loop_start_sample = (loop_start / block_size) * samples_size;
|
||||
vgmstream->loop_end_sample = (loop_end / block_size) * samples_size;
|
||||
}
|
||||
|
||||
}
|
||||
#else
|
||||
goto fail;
|
||||
#endif
|
||||
|
||||
/* open the file for reading */
|
||||
if (!vgmstream_open_stream(vgmstream, streamFile, start_offset))
|
||||
goto fail;
|
||||
return vgmstream;
|
||||
|
||||
fail:
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
@ -345,6 +345,7 @@ VGMSTREAM * (*init_vgmstream_functions[])(STREAMFILE *streamFile) = {
|
||||
init_vgmstream_ta_aac_mobile,
|
||||
init_vgmstream_ta_aac_mobile_vorbis,
|
||||
init_vgmstream_ta_aac_vita,
|
||||
init_vgmstream_va3,
|
||||
init_vgmstream_ps3_mta2,
|
||||
init_vgmstream_ngc_ulw,
|
||||
init_vgmstream_pc_xa30,
|
||||
|
@ -699,6 +699,7 @@ typedef enum {
|
||||
meta_ADPCM_CAPCOM,
|
||||
meta_UE4OPUS,
|
||||
meta_XWMA,
|
||||
meta_VA3, /* DDR Supernova 2 AC */
|
||||
|
||||
} meta_t;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user