add support for VPK + various fix on VAG + ADS

git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@206 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
fastelbja 2008-06-07 21:11:33 +00:00
parent f0f2345a24
commit b462417ddf
10 changed files with 358 additions and 249 deletions

View File

@ -298,6 +298,10 @@
RelativePath=".\meta\ps2_vag.c"
>
</File>
<File
RelativePath=".\meta\ps2_vpk.c"
>
</File>
<File
RelativePath=".\meta\psx_cdxa.c"
>

View File

@ -77,4 +77,6 @@ VGMSTREAM * init_vgmstream_ea(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_caf(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_ps2_vpk(STREAMFILE *streamFile);
#endif

View File

@ -56,7 +56,6 @@ VGMSTREAM * init_vgmstream_caf(STREAMFILE *streamFile) {
vgmstream->layout_type = layout_caf_blocked;
vgmstream->meta_type = meta_CFN;
/* open the file for reading by each channel */
{
for (i=0;i<2;i++) {
@ -75,4 +74,3 @@ fail:
if (vgmstream) close_vgmstream(vgmstream);
return NULL;
}

View File

@ -9,6 +9,8 @@ VGMSTREAM * init_vgmstream_ps2_ads(STREAMFILE *streamFile) {
int loop_flag=0;
int channel_count;
off_t start_offset,test_offset;
int ads_type_2=0;
int i;
/* check extension, case insensitive */
@ -51,19 +53,38 @@ VGMSTREAM * init_vgmstream_ps2_ads(STREAMFILE *streamFile) {
vgmstream->num_samples = read_32bitLE(0x24,streamFile)/2/vgmstream->channels;
}
vgmstream->interleave_block_size = read_32bitLE(0x14,streamFile);
vgmstream->layout_type = layout_interleave;
vgmstream->meta_type = meta_PS2_SShd;
/* Get loop point values */
if(vgmstream->loop_flag) {
vgmstream->loop_start_sample = read_32bitLE(0x18,streamFile);
vgmstream->loop_end_sample = read_32bitLE(0x1C,streamFile);
if(vgmstream->interleave_block_size==0x10) {
vgmstream->loop_start_sample = read_32bitLE(0x18,streamFile);
vgmstream->loop_end_sample = read_32bitLE(0x1C,streamFile);
} else {
vgmstream->loop_start_sample = (read_32bitLE(0x18,streamFile)*0x10)/16*28;
vgmstream->loop_end_sample = (read_32bitLE(0x1C,streamFile)*0x10)/16*28;
}
}
/* don't know why, but it does happen, in ps2 too :( */
if (vgmstream->loop_end_sample > vgmstream->num_samples)
vgmstream->loop_end_sample = vgmstream->num_samples;
vgmstream->interleave_block_size = read_32bitLE(0x14,streamFile);
vgmstream->layout_type = layout_interleave;
vgmstream->meta_type = meta_PS2_SShd;
start_offset=0x28;
// Hack for files with start_offset = 0x800
ads_type_2=1;
for(test_offset=start_offset;test_offset<0x800;test_offset+=4) {
if (read_32bitLE(test_offset,streamFile)!=0)
ads_type_2=0;
}
if((ads_type_2==1)){
start_offset=0x800;
}
/* open the file for reading by each channel */
{
@ -74,7 +95,7 @@ VGMSTREAM * init_vgmstream_ps2_ads(STREAMFILE *streamFile) {
vgmstream->ch[i].channel_start_offset=
vgmstream->ch[i].offset=
(off_t)(0x28+vgmstream->interleave_block_size*i);
(off_t)(start_offset+vgmstream->interleave_block_size*i);
}
}

View File

@ -55,7 +55,7 @@ VGMSTREAM * init_vgmstream_ps2_vag(STREAMFILE *streamFile) {
if(read_32bitBE(0x20,streamFile)==0x53746572) // vag Stereo
channel_count=2;
case 'p':
if(read_32bitBE(0x04,streamFile)==0x00000004) {
if(read_32bitBE(0x04,streamFile)<=0x00000004) {
loop_flag=(read_32bitBE(0x14,streamFile)!=0);
channel_count=2;
} else {
@ -128,6 +128,14 @@ VGMSTREAM * init_vgmstream_ps2_vag(STREAMFILE *streamFile) {
start_offset=0x80;
vgmstream->layout_type=layout_interleave;
vgmstream->meta_type=meta_PS2_VAGs;
// Double VAG Header @ 0x0000 & 0x1000
if(read_32bitBE(0,streamFile)==read_32bitBE(0x1000,streamFile)) {
vgmstream->num_samples = read_32bitBE(0x0C,streamFile)/16*28;
interleave=0x1000;
start_offset=0;
}
} else {
vgmstream->layout_type=layout_none;
vgmstream->num_samples = read_32bitBE(0x0C,streamFile)/16*28;

70
src/meta/ps2_vpk.c Normal file
View File

@ -0,0 +1,70 @@
#include "meta.h"
#include "../util.h"
/* VPK */
VGMSTREAM * init_vgmstream_ps2_vpk(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
char filename[260];
int loop_flag=0;
int channel_count;
off_t start_offset;
int i;
/* check extension, case insensitive */
streamFile->get_name(streamFile,filename,sizeof(filename));
if (strcasecmp("vpk",filename_extension(filename))) goto fail;
/* check VPK Header */
if (read_32bitBE(0x00,streamFile) != 0x204B5056)
goto fail;
/* check loop */
loop_flag = (read_32bitLE(0x7FC,streamFile)!=0);
channel_count=read_32bitLE(0x14,streamFile);
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
/* fill in the vital statistics */
vgmstream->channels = read_32bitLE(0x14,streamFile);
vgmstream->sample_rate = read_32bitLE(0x10,streamFile);
/* Check for Compression Scheme */
vgmstream->coding_type = coding_PSX;
vgmstream->num_samples = read_32bitLE(0x04,streamFile)/16*28;
/* Get loop point values */
if(vgmstream->loop_flag) {
vgmstream->loop_start_sample = read_32bitLE(0x7FC,streamFile);
vgmstream->loop_end_sample = vgmstream->num_samples;
}
vgmstream->interleave_block_size = read_32bitLE(0x0C,streamFile)/2;
vgmstream->layout_type = layout_interleave;
vgmstream->meta_type = meta_PS2_VPK;
start_offset = (off_t)read_32bitLE(0x08,streamFile);
/* open the file for reading by each channel */
{
for (i=0;i<channel_count;i++) {
vgmstream->ch[i].streamfile = streamFile->open(streamFile,filename,vgmstream->interleave_block_size);
if (!vgmstream->ch[i].streamfile) goto fail;
vgmstream->ch[i].channel_start_offset=
vgmstream->ch[i].offset=
(off_t)(start_offset+vgmstream->interleave_block_size*i);
}
}
return vgmstream;
/* clean up anything we may have opened */
fail:
if (vgmstream) close_vgmstream(vgmstream);
return NULL;
}

View File

@ -15,7 +15,7 @@
* List of functions that will recognize files. These should correspond pretty
* directly to the metadata types
*/
#define INIT_VGMSTREAM_FCNS 37
#define INIT_VGMSTREAM_FCNS 38
VGMSTREAM * (*init_vgmstream_fcns[INIT_VGMSTREAM_FCNS])(STREAMFILE *streamFile) = {
init_vgmstream_adx, /* 0 */
init_vgmstream_brstm, /* 1 */
@ -53,7 +53,8 @@ VGMSTREAM * (*init_vgmstream_fcns[INIT_VGMSTREAM_FCNS])(STREAMFILE *streamFile)
init_vgmstream_xbox_xwav, /* 33 */
init_vgmstream_ngc_str, /* 34 */
init_vgmstream_ea, /* 35 */
init_vgmstream_caf /* 36 */
init_vgmstream_caf, /* 36 */
init_vgmstream_ps2_vpk /* 37 */
};
/* internal version with all parameters */
@ -788,6 +789,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
break;
case meta_CFN:
snprintf(temp,TEMPSIZE,"Namco CAF Header");
break;
case meta_PS2_VPK:
snprintf(temp,TEMPSIZE,"VPK Header");
break;
default:
snprintf(temp,TEMPSIZE,"THEY SHOULD HAVE SENT A POET");

View File

@ -106,6 +106,7 @@ typedef enum {
meta_PS2_PNB, /* PsychoNauts Bgm File */
meta_PSX_XA, /* CD-XA with RIFF header */
meta_PS2_VAGs, /* VAG Stereo from Kingdom Hearts */
meta_PS2_VPK, /* VPK Audio File */
meta_XBOX_WAVM, /* XBOX WAVM File */
meta_XBOX_RIFF, /* XBOX RIFF/WAVE File */

View File

@ -111,8 +111,9 @@ char * extension_list[] = {
"wp2\0WP2 Audio File (*.WP2)\0",
"sng\0SNG Audio File (*.SNG)\0",
"asf\0ASF Audio File (*.ASF)\0",
"eam\0EAM Audio File (*.EAM)\0"
"cfn\0CFN Audio File (*.CFN)\0"
"eam\0EAM Audio File (*.EAM)\0",
"cfn\0CFN Audio File (*.CFN)\0",
"vpk\0VPK Audio File (*.VPK)\0"
};
void about(HWND hwndParent) {