mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-28 08:20:54 +01:00
git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@201 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
parent
1dce587022
commit
1f8dca2256
@ -71,4 +71,6 @@ VGMSTREAM * init_vgmstream_xbox_wavm(STREAMFILE *streamFile);
|
||||
|
||||
VGMSTREAM * init_vgmstream_xbox_xwav(STREAMFILE *streamFile);
|
||||
|
||||
VGMSTREAM * init_vgmstream_ngc_str(STREAMFILE *streamFile);
|
||||
|
||||
#endif
|
||||
|
@ -419,6 +419,68 @@ fail:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* str: a very simple header format with implicit loop values
|
||||
* it's allways in interleaved stereo format
|
||||
*/
|
||||
VGMSTREAM * init_vgmstream_ngc_str(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
char filename[260];
|
||||
|
||||
struct dsp_header header;
|
||||
const off_t start_offset = 0x60;
|
||||
int i;
|
||||
|
||||
/* check extension, case insensitive */
|
||||
streamFile->get_name(streamFile,filename,sizeof(filename));
|
||||
if (strcasecmp("str",filename_extension(filename))) goto fail;
|
||||
|
||||
/* always 0xFAAF0001 @ offset 0 */
|
||||
if (read_32bitBE(0x00,streamFile)!=0xFAAF0001) goto fail;
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
/* always loop & stereo */
|
||||
vgmstream = allocate_vgmstream(2,1);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
/* fill in the vital statistics */
|
||||
vgmstream->num_samples = read_32bitBE(0x08,streamFile);
|
||||
vgmstream->sample_rate = read_32bitBE(0x04,streamFile);
|
||||
|
||||
/* always loop to the beginning */
|
||||
vgmstream->loop_start_sample=0;
|
||||
vgmstream->loop_end_sample=vgmstream->num_samples;
|
||||
|
||||
vgmstream->coding_type = coding_NGC_DSP;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = read_32bitBE(0x0C,streamFile);
|
||||
vgmstream->meta_type = meta_DSP_STR;
|
||||
|
||||
/* coeffs */
|
||||
for (i=0;i<16;i++) {
|
||||
vgmstream->ch[0].adpcm_coef[i] = read_16bitBE(0x10+(i*2),streamFile);
|
||||
vgmstream->ch[1].adpcm_coef[i] = read_16bitBE(0x30+(i*2),streamFile);
|
||||
}
|
||||
|
||||
/* open the file for reading */
|
||||
for (i=0;i<2;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=start_offset+
|
||||
vgmstream->interleave_block_size*i;
|
||||
}
|
||||
|
||||
return vgmstream;
|
||||
|
||||
fail:
|
||||
/* clean up anything we may have opened */
|
||||
if (vgmstream) close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* a bunch of formats that are identical except for file extension,
|
||||
* but have different interleaves */
|
||||
|
||||
|
@ -55,37 +55,42 @@ VGMSTREAM * init_vgmstream_ps2_vag(STREAMFILE *streamFile) {
|
||||
if(read_32bitBE(0x20,streamFile)==0x53746572) // vag Stereo
|
||||
channel_count=2;
|
||||
case 'p':
|
||||
/* Search for loop in VAG */
|
||||
fileLength = get_streamfile_size(streamFile);
|
||||
|
||||
do {
|
||||
readOffset+=0x10;
|
||||
if(read_32bitBE(0x04,streamFile)==0x00000004) {
|
||||
loop_flag=(read_32bitBE(0x14,streamFile)!=0);
|
||||
channel_count=2;
|
||||
} else {
|
||||
/* Search for loop in VAG */
|
||||
fileLength = get_streamfile_size(streamFile);
|
||||
|
||||
// Loop Start ...
|
||||
if(read_8bit(readOffset+0x01,streamFile)==0x06) {
|
||||
if(loopStart==0) loopStart = readOffset;
|
||||
}
|
||||
do {
|
||||
readOffset+=0x10;
|
||||
|
||||
// Loop Start ...
|
||||
if(read_8bit(readOffset+0x01,streamFile)==0x06) {
|
||||
if(loopStart==0) loopStart = readOffset;
|
||||
}
|
||||
|
||||
// Loop End ...
|
||||
if(read_8bit(readOffset+0x01,streamFile)==0x03) {
|
||||
if(loopEnd==0) loopEnd = readOffset;
|
||||
}
|
||||
// Loop End ...
|
||||
if(read_8bit(readOffset+0x01,streamFile)==0x03) {
|
||||
if(loopEnd==0) loopEnd = readOffset;
|
||||
}
|
||||
|
||||
// Loop from end to beginning ...
|
||||
if((read_8bit(readOffset+0x01,streamFile)==0x01)) {
|
||||
// Check if we have the eof tag after the loop point ...
|
||||
// if so we don't loop, if not present, we loop from end to start ...
|
||||
read_streamfile(readbuf,readOffset+0x10,0x10,streamFile);
|
||||
if((readbuf[0]!=0) && (readbuf[0]!=0x0c)) {
|
||||
if(memcmp(readbuf,eofVAG,0x10) && (memcmp(readbuf,eofVAG2,0x10))) {
|
||||
loopStart = 0x40;
|
||||
loopEnd = readOffset;
|
||||
// Loop from end to beginning ...
|
||||
if((read_8bit(readOffset+0x01,streamFile)==0x01)) {
|
||||
// Check if we have the eof tag after the loop point ...
|
||||
// if so we don't loop, if not present, we loop from end to start ...
|
||||
read_streamfile(readbuf,readOffset+0x10,0x10,streamFile);
|
||||
if((readbuf[0]!=0) && (readbuf[0]!=0x0c)) {
|
||||
if(memcmp(readbuf,eofVAG,0x10) && (memcmp(readbuf,eofVAG2,0x10))) {
|
||||
loopStart = 0x40;
|
||||
loopEnd = readOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} while (streamFile->get_offset(streamFile)<(off_t)fileLength);
|
||||
loop_flag = (loopEnd!=0);
|
||||
} while (streamFile->get_offset(streamFile)<(off_t)fileLength);
|
||||
loop_flag = (loopEnd!=0);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
goto fail;
|
||||
@ -108,12 +113,27 @@ VGMSTREAM * init_vgmstream_ps2_vag(STREAMFILE *streamFile) {
|
||||
start_offset=0x800;
|
||||
break;
|
||||
case 'p': // VAGp
|
||||
vgmstream->layout_type=layout_none;
|
||||
vgmstream->sample_rate = read_32bitBE(0x10,streamFile);
|
||||
vgmstream->num_samples = read_32bitBE(0x0C,streamFile)/16*28;
|
||||
vgmstream->meta_type=meta_PS2_VAGp;
|
||||
interleave=0x10; // used for loop calc
|
||||
start_offset=0x30;
|
||||
|
||||
if(read_32bitBE(0x04,streamFile)==0x00000004) {
|
||||
vgmstream->channels=2;
|
||||
vgmstream->num_samples = read_32bitBE(0x0C,streamFile);
|
||||
|
||||
if(loop_flag) {
|
||||
vgmstream->loop_start_sample=read_32bitBE(0x14,streamFile);
|
||||
vgmstream->loop_end_sample =read_32bitBE(0x18,streamFile);
|
||||
}
|
||||
|
||||
start_offset=0x80;
|
||||
vgmstream->layout_type=layout_interleave;
|
||||
vgmstream->meta_type=meta_PS2_VAGs;
|
||||
} else {
|
||||
vgmstream->layout_type=layout_none;
|
||||
vgmstream->num_samples = read_32bitBE(0x0C,streamFile)/16*28;
|
||||
vgmstream->meta_type=meta_PS2_VAGp;
|
||||
start_offset=0x30;
|
||||
}
|
||||
break;
|
||||
case 'V': // pGAV
|
||||
vgmstream->layout_type=layout_interleave;
|
||||
@ -135,14 +155,16 @@ VGMSTREAM * init_vgmstream_ps2_vag(STREAMFILE *streamFile) {
|
||||
vgmstream->interleave_block_size=interleave;
|
||||
|
||||
/* Don't add the header size to loop calc points */
|
||||
loopStart-=start_offset;
|
||||
loopEnd-=start_offset;
|
||||
if(vgmstream->meta_type!=meta_PS2_VAGs) {
|
||||
loopStart-=start_offset;
|
||||
loopEnd-=start_offset;
|
||||
|
||||
if(loop_flag!=0) {
|
||||
vgmstream->loop_start_sample = (int32_t)((loopStart/(interleave*channel_count))*interleave)/16*28;
|
||||
vgmstream->loop_start_sample += (int32_t)(loopStart%(interleave*channel_count))/16*28;
|
||||
vgmstream->loop_end_sample = (int32_t)((loopEnd/(interleave*channel_count))*interleave)/16*28;
|
||||
vgmstream->loop_end_sample += (int32_t)(loopEnd%(interleave*channel_count))/16*28;
|
||||
if(loop_flag!=0) {
|
||||
vgmstream->loop_start_sample = (int32_t)((loopStart/(interleave*channel_count))*interleave)/16*28;
|
||||
vgmstream->loop_start_sample += (int32_t)(loopStart%(interleave*channel_count))/16*28;
|
||||
vgmstream->loop_end_sample = (int32_t)((loopEnd/(interleave*channel_count))*interleave)/16*28;
|
||||
vgmstream->loop_end_sample += (int32_t)(loopEnd%(interleave*channel_count))/16*28;
|
||||
}
|
||||
}
|
||||
|
||||
/* Compression Scheme */
|
||||
|
@ -15,7 +15,7 @@
|
||||
* List of functions that will recognize files. These should correspond pretty
|
||||
* directly to the metadata types
|
||||
*/
|
||||
#define INIT_VGMSTREAM_FCNS 34
|
||||
#define INIT_VGMSTREAM_FCNS 35
|
||||
VGMSTREAM * (*init_vgmstream_fcns[INIT_VGMSTREAM_FCNS])(STREAMFILE *streamFile) = {
|
||||
init_vgmstream_adx, /* 0 */
|
||||
init_vgmstream_brstm, /* 1 */
|
||||
@ -50,7 +50,8 @@ VGMSTREAM * (*init_vgmstream_fcns[INIT_VGMSTREAM_FCNS])(STREAMFILE *streamFile)
|
||||
init_vgmstream_ps2_ild, /* 30 */
|
||||
init_vgmstream_ps2_pnb, /* 31 */
|
||||
init_vgmstream_xbox_wavm, /* 32 */
|
||||
init_vgmstream_xbox_xwav /* 33 */
|
||||
init_vgmstream_xbox_xwav, /* 33 */
|
||||
init_vgmstream_ngc_str /* 34 */
|
||||
};
|
||||
|
||||
/* internal version with all parameters */
|
||||
@ -721,6 +722,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
|
||||
break;
|
||||
case meta_PS2_VAGp:
|
||||
snprintf(temp,TEMPSIZE,"Sony VAG Mono header (VAGp)");
|
||||
break;
|
||||
case meta_PS2_VAGs:
|
||||
snprintf(temp,TEMPSIZE,"Sony VAG Stereo header (VAGp)");
|
||||
break;
|
||||
case meta_PS2_VAGm:
|
||||
snprintf(temp,TEMPSIZE,"Sony VAG Mono header (VAGm)");
|
||||
|
@ -62,6 +62,8 @@ typedef enum {
|
||||
meta_DSP_JETTERS, /* Bomberman Jetters .dsp */
|
||||
meta_DSP_MSS,
|
||||
meta_DSP_GCM,
|
||||
meta_DSP_STR, /* Conan .str files */
|
||||
|
||||
/* Nintendo */
|
||||
meta_STRM, /* STRM */
|
||||
meta_RSTM, /* RSTM (similar to STRM) */
|
||||
@ -99,6 +101,7 @@ typedef enum {
|
||||
meta_PS2_ILD, /* ILD File */
|
||||
meta_PS2_PNB, /* PsychoNauts Bgm File */
|
||||
meta_PSX_XA, /* CD-XA with RIFF header */
|
||||
meta_PS2_VAGs, /* VAG Stereo from Kingdom Hearts */
|
||||
|
||||
meta_XBOX_WAVM, /* XBOX WAVM File */
|
||||
meta_XBOX_RIFF, /* XBOX RIFF/WAVE File */
|
||||
|
Loading…
Reference in New Issue
Block a user