adding XBOX XWAV support

git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@195 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
fastelbja 2008-05-24 15:11:32 +00:00
parent f7de62c8c9
commit f9b3ee049c
6 changed files with 101 additions and 3 deletions

View File

@ -318,6 +318,10 @@
RelativePath=".\meta\xbox_wavm.c"
>
</File>
<File
RelativePath=".\meta\xbox_xwav.c"
>
</File>
</Filter>
</Filter>
<Filter

View File

@ -69,4 +69,6 @@ VGMSTREAM * init_vgmstream_ps2_pnb(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_xbox_wavm(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_xbox_xwav(STREAMFILE *streamFile);
#endif

86
src/meta/xbox_xwav.c Normal file
View File

@ -0,0 +1,86 @@
#include "meta.h"
#include "../util.h"
/* XWAV
XWAV use the common RIFF/WAVE format with Codec ID = 0x0069
It has been renamed to xwav to avoid vgmstream to handle all RIFF/WAV format
known extensions : XWAV
2008-05-24 - Fastelbja : First version ...
*/
VGMSTREAM * init_vgmstream_xbox_xwav(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("xwav",filename_extension(filename))) goto fail;
/* Check for headers */
if(!((read_32bitBE(0x00,streamFile)==0x52494646) &&
(read_32bitBE(0x08,streamFile)==0x57415645) &&
(read_32bitBE(0x0C,streamFile)==0x666D7420) &&
(read_16bitLE(0x14,streamFile)==0x0069)))
goto fail;
/* No loop on wavm */
loop_flag = 0;
/* Always stereo files */
channel_count=read_16bitLE(0x16,streamFile);
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
/* fill in the vital statistics */
vgmstream->channels = channel_count;
vgmstream->sample_rate = read_32bitLE(0x18,streamFile);
/* search for "data" */
start_offset=0x1C;
do {
if(read_32bitBE(start_offset,streamFile)==0x64617461)
break;
start_offset+=4;
} while (start_offset<get_streamfile_size(streamFile));
if(start_offset>=get_streamfile_size(streamFile))
goto fail;
start_offset+=4;
vgmstream->coding_type = coding_XBOX;
vgmstream->num_samples = read_32bitLE(start_offset,streamFile) / 36 * 64 / vgmstream->channels;
vgmstream->layout_type = layout_xbox_blocked;
vgmstream->current_block_size=36*vgmstream->channels;
vgmstream->current_block_offset=start_offset+4;
xbox_block_update(start_offset+4,vgmstream);
vgmstream->meta_type = meta_XBOX_RIFF;
/* open the file for reading by each channel */
{
for (i=0;i<channel_count;i++) {
vgmstream->ch[i].streamfile = streamFile->open(streamFile,filename,36);
if (!vgmstream->ch[i].streamfile) goto fail;
}
}
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 33
#define INIT_VGMSTREAM_FCNS 34
VGMSTREAM * (*init_vgmstream_fcns[INIT_VGMSTREAM_FCNS])(STREAMFILE *streamFile) = {
init_vgmstream_adx, /* 0 */
init_vgmstream_brstm, /* 1 */
@ -49,7 +49,8 @@ VGMSTREAM * (*init_vgmstream_fcns[INIT_VGMSTREAM_FCNS])(STREAMFILE *streamFile)
init_vgmstream_ps2_str, /* 29 */
init_vgmstream_ps2_ild, /* 30 */
init_vgmstream_ps2_pnb, /* 31 */
init_vgmstream_xbox_wavm /* 32 */
init_vgmstream_xbox_wavm, /* 32 */
init_vgmstream_xbox_xwav /* 33 */
};
/* internal version with all parameters */
@ -741,6 +742,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
break;
case meta_XBOX_WAVM:
snprintf(temp,TEMPSIZE,"assumed Xbox WAVM file by .wavm extension");
break;
case meta_XBOX_RIFF:
snprintf(temp,TEMPSIZE,"Xbox RIFF/WAVE file with 0x0069 Codec ID");
break;
default:
snprintf(temp,TEMPSIZE,"THEY SHOULD HAVE SENT A POET");

View File

@ -101,6 +101,7 @@ typedef enum {
meta_PSX_XA, /* CD-XA with RIFF header */
meta_XBOX_WAVM, /* XBOX WAVM File */
meta_XBOX_RIFF, /* XBOX RIFF/WAVE File */
meta_RAW, /* RAW PCM file */

View File

@ -106,7 +106,8 @@ char * extension_list[] = {
"str\0STR Audio File (*.STR)\0",
"ild\0ILD Audio File (*.ILD)\0",
"pnb\0PNB Audio File (*.PNB)\0",
"wavm\0WAVM Audio File (*.WAVM)\0"
"wavm\0WAVM Audio File (*.WAVM)\0",
"xwav\0XWAV Audio File (*.XWAV)\0"
};
void about(HWND hwndParent) {