Add Nippon Ichi SPS subfiles [ClaDun (PSP)]

This commit is contained in:
bnnm 2018-01-27 12:21:25 +01:00
parent 861e1ea796
commit 561c3fa8c1
6 changed files with 94 additions and 0 deletions

View File

@ -1182,6 +1182,10 @@
RelativePath=".\meta\sli.c"
>
</File>
<File
RelativePath=".\meta\sps_n1.c"
>
</File>
<File
RelativePath=".\meta\spt_spd.c"
>

View File

@ -377,6 +377,7 @@
<ClCompile Include="meta\sdt.c" />
<ClCompile Include="meta\sfl.c" />
<ClCompile Include="meta\sli.c" />
<ClCompile Include="meta\sps_n1.c" />
<ClCompile Include="meta\spt_spd.c" />
<ClCompile Include="meta\stm.c" />
<ClCompile Include="meta\str_asr.c" />

View File

@ -721,6 +721,9 @@
<ClCompile Include="meta\sli.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
<ClCompile Include="meta\sps_n1.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
<ClCompile Include="meta\spt_spd.c">
<Filter>meta\Source Files</Filter>
</ClCompile>

View File

@ -700,4 +700,6 @@ VGMSTREAM * init_vgmstream_fsb_encrypted(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_xwc(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_atsl3(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_sps_n1(STREAMFILE *streamFile);
#endif /*_META_H*/

83
src/meta/sps_n1.c Normal file
View File

@ -0,0 +1,83 @@
#include "meta.h"
#include "../coding/coding.h"
static STREAMFILE* setup_sps_streamfile(STREAMFILE *streamfile, off_t subfile_offset, size_t subfile_size, char* extension);
/* .SPS - Nippon Ichi's RIFF AT3 wrapper [ClaDun (PSP)] */
VGMSTREAM * init_vgmstream_sps_n1(STREAMFILE *streamFile) {
VGMSTREAM *vgmstream = NULL;
STREAMFILE *temp_streamFile = NULL;
int type, sample_rate;
off_t subfile_offset;
size_t subfile_size;
/* check extensions */
if ( !check_extensions(streamFile,"sps"))
goto fail;
/* mini header */
type = read_32bitLE(0x00,streamFile); //todo channels? all known VAG are mono and AT3 stereo
subfile_size = read_32bitLE(0x04,streamFile);
sample_rate = (uint16_t)read_16bitLE(0x08,streamFile);
/* 0x0a/0b: stereo+loop flags? */
//num_samples = read_32bitLE(0x0c,streamFile);
subfile_offset = 0x10;
/* init the VGMSTREAM */
switch(type) {
case 1: /* .vag */
temp_streamFile = setup_sps_streamfile(streamFile, subfile_offset, subfile_size, "vag");
if (!temp_streamFile) goto fail;
vgmstream = init_vgmstream_ps2_vag(temp_streamFile);
if (!vgmstream) goto fail;
break;
case 2: /* .at3 */
VGM_LOG("so=%lx, s=%x\n", subfile_offset,subfile_size );
temp_streamFile = setup_sps_streamfile(streamFile, subfile_offset, subfile_size, "at3");
if (!temp_streamFile) goto fail;
VGM_LOG("4\n");
vgmstream = init_vgmstream_riff(temp_streamFile);
if (!vgmstream) goto fail;
break;
default:
goto fail;
}
//VGM_LOG(vgmstream->num_samples != num_samples,
// "SPS: sps num_samples and subfile num_samples don't match\n");
//vgmstream->num_samples = num_samples; //todo adjusted for MAIATRAC3
vgmstream->sample_rate = sample_rate; /* .vag header doesn't match */
close_streamfile(temp_streamFile);
return vgmstream;
fail:
close_streamfile(temp_streamFile);
close_vgmstream(vgmstream);
return NULL;
}
static STREAMFILE* setup_sps_streamfile(STREAMFILE *streamFile, off_t subfile_offset, size_t subfile_size, char* extension) {
STREAMFILE *temp_streamFile = NULL, *new_streamFile = NULL;
/* setup subfile */
new_streamFile = open_wrap_streamfile(streamFile);
if (!new_streamFile) goto fail;
temp_streamFile = new_streamFile;
new_streamFile = open_clamp_streamfile(temp_streamFile, subfile_offset,subfile_size);
if (!new_streamFile) goto fail;
temp_streamFile = new_streamFile;
new_streamFile = open_fakename_streamfile(temp_streamFile, NULL,extension);
if (!new_streamFile) goto fail;
temp_streamFile = new_streamFile;
return temp_streamFile;
fail:
close_streamfile(temp_streamFile);
return NULL;
}

View File

@ -377,6 +377,7 @@ VGMSTREAM * (*init_vgmstream_functions[])(STREAMFILE *streamFile) = {
init_vgmstream_fsb_encrypted,
init_vgmstream_xwc,
init_vgmstream_atsl3,
init_vgmstream_sps_n1,
init_vgmstream_txth, /* should go at the end (lower priority) */
#ifdef VGM_USE_FFMPEG