mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-18 15:54:05 +01:00
adding CFN support + misc fixes
git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@205 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
parent
f132224ca8
commit
f0f2345a24
@ -57,6 +57,9 @@ void render_vgmstream_blocked(sample * buffer, int32_t sample_count, VGMSTREAM *
|
|||||||
case layout_ea_blocked:
|
case layout_ea_blocked:
|
||||||
ea_block_update(vgmstream->next_block_offset,vgmstream);
|
ea_block_update(vgmstream->next_block_offset,vgmstream);
|
||||||
break;
|
break;
|
||||||
|
case layout_caf_blocked:
|
||||||
|
caf_block_update(vgmstream->next_block_offset,vgmstream);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
26
src/layout/caf_blocked.c
Normal file
26
src/layout/caf_blocked.c
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#include "layout.h"
|
||||||
|
#include "../vgmstream.h"
|
||||||
|
|
||||||
|
/* set up for the block at the given offset */
|
||||||
|
void caf_block_update(off_t block_offset, VGMSTREAM * vgmstream) {
|
||||||
|
int i;
|
||||||
|
|
||||||
|
vgmstream->current_block_offset = block_offset;
|
||||||
|
vgmstream->current_block_size = read_32bitBE(
|
||||||
|
vgmstream->current_block_offset+0x14,
|
||||||
|
vgmstream->ch[0].streamfile);
|
||||||
|
vgmstream->next_block_offset = vgmstream->current_block_offset +
|
||||||
|
(off_t)read_32bitBE(vgmstream->current_block_offset+0x04,
|
||||||
|
vgmstream->ch[0].streamfile);
|
||||||
|
|
||||||
|
for (i=0;i<vgmstream->channels;i++) {
|
||||||
|
vgmstream->ch[i].offset = vgmstream->current_block_offset +
|
||||||
|
read_32bitBE(block_offset+0x10+(8*i),vgmstream->ch[0].streamfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* coeffs */
|
||||||
|
for (i=0;i<16;i++) {
|
||||||
|
vgmstream->ch[0].adpcm_coef[i] = read_16bitBE(block_offset+0x34+(2*i),vgmstream->ch[0].streamfile);
|
||||||
|
vgmstream->ch[1].adpcm_coef[i] = read_16bitBE(block_offset+0x60+(2*i),vgmstream->ch[0].streamfile);
|
||||||
|
}
|
||||||
|
}
|
@ -16,6 +16,8 @@ void xbox_block_update(off_t block_offset, VGMSTREAM * vgmstream);
|
|||||||
|
|
||||||
void ea_block_update(off_t block_offset, VGMSTREAM * vgmstream);
|
void ea_block_update(off_t block_offset, VGMSTREAM * vgmstream);
|
||||||
|
|
||||||
|
void caf_block_update(off_t block_offset, VGMSTREAM * vgmstream);
|
||||||
|
|
||||||
void render_vgmstream_interleave(sample * buffer, int32_t sample_count, VGMSTREAM * vgmstream);
|
void render_vgmstream_interleave(sample * buffer, int32_t sample_count, VGMSTREAM * vgmstream);
|
||||||
|
|
||||||
void render_vgmstream_nolayout(sample * buffer, int32_t sample_count, VGMSTREAM * vgmstream);
|
void render_vgmstream_nolayout(sample * buffer, int32_t sample_count, VGMSTREAM * vgmstream);
|
||||||
|
@ -242,6 +242,10 @@
|
|||||||
RelativePath=".\meta\ngc_adpdtk.c"
|
RelativePath=".\meta\ngc_adpdtk.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\meta\ngc_caf.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\meta\ngc_dsp_std.c"
|
RelativePath=".\meta\ngc_dsp_std.c"
|
||||||
>
|
>
|
||||||
@ -410,6 +414,10 @@
|
|||||||
RelativePath=".\layout\blocked.c"
|
RelativePath=".\layout\blocked.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\layout\caf_blocked.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\layout\ea_block.c"
|
RelativePath=".\layout\ea_block.c"
|
||||||
>
|
>
|
||||||
|
@ -226,8 +226,8 @@ VGMSTREAM * init_vgmstream_ea(STREAMFILE *streamFile) {
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
ea_block_update(vgmstream->next_block_offset,vgmstream);
|
ea_block_update(vgmstream->next_block_offset,vgmstream);
|
||||||
vgmstream->num_samples+=vgmstream->current_block_size*28;
|
vgmstream->num_samples+=(int32_t)vgmstream->current_block_size*28;
|
||||||
} while(vgmstream->next_block_offset<(file_length-block_length));
|
} while(vgmstream->next_block_offset<(off_t)(file_length-block_length));
|
||||||
}
|
}
|
||||||
|
|
||||||
ea_block_update(start_offset+header_length,vgmstream);
|
ea_block_update(start_offset+header_length,vgmstream);
|
||||||
|
@ -75,4 +75,6 @@ VGMSTREAM * init_vgmstream_ngc_str(STREAMFILE *streamFile);
|
|||||||
|
|
||||||
VGMSTREAM * init_vgmstream_ea(STREAMFILE *streamFile);
|
VGMSTREAM * init_vgmstream_ea(STREAMFILE *streamFile);
|
||||||
|
|
||||||
|
VGMSTREAM * init_vgmstream_caf(STREAMFILE *streamFile);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
78
src/meta/ngc_caf.c
Normal file
78
src/meta/ngc_caf.c
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
#include "meta.h"
|
||||||
|
#include "../util.h"
|
||||||
|
|
||||||
|
extern caf_block_update(off_t block_offset, VGMSTREAM * vgmstream);
|
||||||
|
|
||||||
|
VGMSTREAM * init_vgmstream_caf(STREAMFILE *streamFile) {
|
||||||
|
VGMSTREAM * vgmstream = NULL;
|
||||||
|
char filename[260];
|
||||||
|
|
||||||
|
// Calculate sample length ...
|
||||||
|
int32_t num_of_samples=0;
|
||||||
|
int32_t block_count=0;
|
||||||
|
|
||||||
|
uint32_t loop_start=-1;
|
||||||
|
|
||||||
|
off_t offset=0;
|
||||||
|
off_t next_block;
|
||||||
|
off_t file_length;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* check extension, case insensitive */
|
||||||
|
streamFile->get_name(streamFile,filename,sizeof(filename));
|
||||||
|
if (strcasecmp("cfn",filename_extension(filename))) goto fail;
|
||||||
|
|
||||||
|
/* Check "CAF " ID */
|
||||||
|
if (read_32bitBE(0,streamFile)!=0x43414620) goto fail;
|
||||||
|
|
||||||
|
// Calculate sample length ...
|
||||||
|
file_length=(off_t)get_streamfile_size(streamFile);
|
||||||
|
|
||||||
|
do {
|
||||||
|
next_block=read_32bitBE(offset+0x04,streamFile);
|
||||||
|
num_of_samples+=read_32bitBE(offset+0x14,streamFile)/8*14;
|
||||||
|
|
||||||
|
if(read_32bitBE(offset+0x20,streamFile)==read_32bitBE(offset+0x08,streamFile)) {
|
||||||
|
loop_start=num_of_samples-read_32bitBE(offset+0x14,streamFile)/8*14;
|
||||||
|
}
|
||||||
|
offset+=next_block;
|
||||||
|
block_count++;
|
||||||
|
} while(offset<file_length);
|
||||||
|
|
||||||
|
/* build the VGMSTREAM */
|
||||||
|
vgmstream = allocate_vgmstream(2,(loop_start!=-1)); /* always stereo */
|
||||||
|
if (!vgmstream) goto fail;
|
||||||
|
|
||||||
|
vgmstream->channels=2;
|
||||||
|
vgmstream->sample_rate=32000;
|
||||||
|
vgmstream->num_samples=num_of_samples;
|
||||||
|
|
||||||
|
if(loop_start!=-1) {
|
||||||
|
vgmstream->loop_start_sample=loop_start;
|
||||||
|
vgmstream->loop_end_sample=num_of_samples;
|
||||||
|
}
|
||||||
|
|
||||||
|
vgmstream->coding_type = coding_NGC_DSP;
|
||||||
|
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++) {
|
||||||
|
vgmstream->ch[i].streamfile = streamFile->open(streamFile,filename,0x8000);
|
||||||
|
|
||||||
|
if (!vgmstream->ch[i].streamfile) goto fail;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
caf_block_update(0,vgmstream);
|
||||||
|
|
||||||
|
return vgmstream;
|
||||||
|
|
||||||
|
/* clean up anything we may have opened */
|
||||||
|
fail:
|
||||||
|
if (vgmstream) close_vgmstream(vgmstream);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
@ -69,10 +69,10 @@ VGMSTREAM * init_vgmstream_ps2_mib(STREAMFILE *streamFile) {
|
|||||||
/* Get the first 16 values */
|
/* Get the first 16 values */
|
||||||
fileLength = get_streamfile_size(streamFile);
|
fileLength = get_streamfile_size(streamFile);
|
||||||
|
|
||||||
readOffset+=read_streamfile(mibBuffer,0,0x10,streamFile);
|
readOffset+=(off_t)read_streamfile(mibBuffer,0,0x10,streamFile);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
readOffset+=read_streamfile(testBuffer,readOffset,0x10,streamFile);
|
readOffset+=(off_t)read_streamfile(testBuffer,readOffset,0x10,streamFile);
|
||||||
|
|
||||||
if(!memcmp(testBuffer,mibBuffer,0x10)) {
|
if(!memcmp(testBuffer,mibBuffer,0x10)) {
|
||||||
if(interleave==0) interleave=readOffset-0x10;
|
if(interleave==0) interleave=readOffset-0x10;
|
||||||
@ -93,7 +93,7 @@ VGMSTREAM * init_vgmstream_ps2_mib(STREAMFILE *streamFile) {
|
|||||||
if(loopEnd==0) loopEnd = readOffset-0x10;
|
if(loopEnd==0) loopEnd = readOffset-0x10;
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (streamFile->get_offset(streamFile)<fileLength);
|
} while (streamFile->get_offset(streamFile)<(int32_t)fileLength);
|
||||||
|
|
||||||
if(gotMIH)
|
if(gotMIH)
|
||||||
channel_count=read_32bitLE(0x08,streamFileMIH);
|
channel_count=read_32bitLE(0x08,streamFileMIH);
|
||||||
@ -121,7 +121,7 @@ VGMSTREAM * init_vgmstream_ps2_mib(STREAMFILE *streamFile) {
|
|||||||
if(!strcasecmp("mi4",filename_extension(filename)))
|
if(!strcasecmp("mi4",filename_extension(filename)))
|
||||||
vgmstream->sample_rate = 48000;
|
vgmstream->sample_rate = 48000;
|
||||||
|
|
||||||
vgmstream->num_samples = fileLength/16/channel_count*28;
|
vgmstream->num_samples = (int32_t)(fileLength/16/channel_count*28);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(loopStart!=0) {
|
if(loopStart!=0) {
|
||||||
|
@ -67,7 +67,7 @@ VGMSTREAM * init_vgmstream_ps2_str(STREAMFILE *streamFile) {
|
|||||||
if (!vgmstream->ch[i].streamfile) goto fail;
|
if (!vgmstream->ch[i].streamfile) goto fail;
|
||||||
|
|
||||||
vgmstream->ch[i].channel_start_offset=
|
vgmstream->ch[i].channel_start_offset=
|
||||||
vgmstream->ch[i].offset=0+vgmstream->interleave_block_size*i;
|
vgmstream->ch[i].offset+=(off_t)(vgmstream->interleave_block_size*i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ off_t init_xa_channel(int channel,STREAMFILE* streamFile) {
|
|||||||
begin:
|
begin:
|
||||||
|
|
||||||
// 0 can't be a correct value
|
// 0 can't be a correct value
|
||||||
if(block_offset>=filelength)
|
if(block_offset>=(off_t)filelength)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
currentChannel=read_8bit(block_offset-7,streamFile);
|
currentChannel=read_8bit(block_offset-7,streamFile);
|
||||||
|
@ -39,7 +39,7 @@ VGMSTREAM * init_vgmstream_xbox_wavm(STREAMFILE *streamFile) {
|
|||||||
vgmstream->sample_rate = 44100;
|
vgmstream->sample_rate = 44100;
|
||||||
|
|
||||||
vgmstream->coding_type = coding_XBOX;
|
vgmstream->coding_type = coding_XBOX;
|
||||||
vgmstream->num_samples = get_streamfile_size(streamFile) / 36 * 64 / vgmstream->channels;
|
vgmstream->num_samples = (int32_t)(get_streamfile_size(streamFile) / 36 * 64 / vgmstream->channels);
|
||||||
vgmstream->layout_type = layout_xbox_blocked;
|
vgmstream->layout_type = layout_xbox_blocked;
|
||||||
vgmstream->current_block_size=36*vgmstream->channels;
|
vgmstream->current_block_size=36*vgmstream->channels;
|
||||||
vgmstream->current_block_offset=0;
|
vgmstream->current_block_offset=0;
|
||||||
|
@ -52,9 +52,9 @@ VGMSTREAM * init_vgmstream_xbox_xwav(STREAMFILE *streamFile) {
|
|||||||
if(read_32bitBE(start_offset,streamFile)==0x64617461)
|
if(read_32bitBE(start_offset,streamFile)==0x64617461)
|
||||||
break;
|
break;
|
||||||
start_offset+=4;
|
start_offset+=4;
|
||||||
} while (start_offset<get_streamfile_size(streamFile));
|
} while (start_offset<(off_t)get_streamfile_size(streamFile));
|
||||||
|
|
||||||
if(start_offset>=get_streamfile_size(streamFile))
|
if(start_offset>=(off_t)get_streamfile_size(streamFile))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
start_offset+=4;
|
start_offset+=4;
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* List of functions that will recognize files. These should correspond pretty
|
* List of functions that will recognize files. These should correspond pretty
|
||||||
* directly to the metadata types
|
* directly to the metadata types
|
||||||
*/
|
*/
|
||||||
#define INIT_VGMSTREAM_FCNS 36
|
#define INIT_VGMSTREAM_FCNS 37
|
||||||
VGMSTREAM * (*init_vgmstream_fcns[INIT_VGMSTREAM_FCNS])(STREAMFILE *streamFile) = {
|
VGMSTREAM * (*init_vgmstream_fcns[INIT_VGMSTREAM_FCNS])(STREAMFILE *streamFile) = {
|
||||||
init_vgmstream_adx, /* 0 */
|
init_vgmstream_adx, /* 0 */
|
||||||
init_vgmstream_brstm, /* 1 */
|
init_vgmstream_brstm, /* 1 */
|
||||||
@ -52,7 +52,8 @@ VGMSTREAM * (*init_vgmstream_fcns[INIT_VGMSTREAM_FCNS])(STREAMFILE *streamFile)
|
|||||||
init_vgmstream_xbox_wavm, /* 32 */
|
init_vgmstream_xbox_wavm, /* 32 */
|
||||||
init_vgmstream_xbox_xwav, /* 33 */
|
init_vgmstream_xbox_xwav, /* 33 */
|
||||||
init_vgmstream_ngc_str, /* 34 */
|
init_vgmstream_ngc_str, /* 34 */
|
||||||
init_vgmstream_ea /* 35 */
|
init_vgmstream_ea, /* 35 */
|
||||||
|
init_vgmstream_caf /* 36 */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* internal version with all parameters */
|
/* internal version with all parameters */
|
||||||
@ -229,6 +230,7 @@ void render_vgmstream(sample * buffer, int32_t sample_count, VGMSTREAM * vgmstre
|
|||||||
case layout_xa_blocked:
|
case layout_xa_blocked:
|
||||||
case layout_xbox_blocked:
|
case layout_xbox_blocked:
|
||||||
case layout_ea_blocked:
|
case layout_ea_blocked:
|
||||||
|
case layout_caf_blocked:
|
||||||
render_vgmstream_blocked(buffer,sample_count,vgmstream);
|
render_vgmstream_blocked(buffer,sample_count,vgmstream);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -612,6 +614,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
|
|||||||
break;
|
break;
|
||||||
case layout_ea_blocked:
|
case layout_ea_blocked:
|
||||||
snprintf(temp,TEMPSIZE,"Electronic Arts Audio Blocks");
|
snprintf(temp,TEMPSIZE,"Electronic Arts Audio Blocks");
|
||||||
|
break;
|
||||||
|
case layout_caf_blocked:
|
||||||
|
snprintf(temp,TEMPSIZE,"CAF blocked");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
snprintf(temp,TEMPSIZE,"INCONCEIVABLE");
|
snprintf(temp,TEMPSIZE,"INCONCEIVABLE");
|
||||||
@ -780,6 +785,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
|
|||||||
break;
|
break;
|
||||||
case meta_EAXA_PSX:
|
case meta_EAXA_PSX:
|
||||||
snprintf(temp,TEMPSIZE,"Electronic Arts With PSX ADPCM");
|
snprintf(temp,TEMPSIZE,"Electronic Arts With PSX ADPCM");
|
||||||
|
break;
|
||||||
|
case meta_CFN:
|
||||||
|
snprintf(temp,TEMPSIZE,"Namco CAF Header");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
snprintf(temp,TEMPSIZE,"THEY SHOULD HAVE SENT A POET");
|
snprintf(temp,TEMPSIZE,"THEY SHOULD HAVE SENT A POET");
|
||||||
|
@ -44,6 +44,7 @@ typedef enum {
|
|||||||
layout_xa_blocked,
|
layout_xa_blocked,
|
||||||
layout_xbox_blocked,
|
layout_xbox_blocked,
|
||||||
layout_ea_blocked,
|
layout_ea_blocked,
|
||||||
|
layout_caf_blocked,
|
||||||
#if 0
|
#if 0
|
||||||
layout_strm_blocked, /* */
|
layout_strm_blocked, /* */
|
||||||
#endif
|
#endif
|
||||||
@ -84,6 +85,7 @@ typedef enum {
|
|||||||
meta_RSF, /* Retro Studios RSF, no header (.rsf) */
|
meta_RSF, /* Retro Studios RSF, no header (.rsf) */
|
||||||
meta_HALPST, /* HAL Labs HALPST */
|
meta_HALPST, /* HAL Labs HALPST */
|
||||||
meta_GCSW, /* GCSW (PCM) */
|
meta_GCSW, /* GCSW (PCM) */
|
||||||
|
meta_CFN, /* Namco CAF Audio File */
|
||||||
|
|
||||||
meta_PS2_SShd, /* .ADS with SShd header */
|
meta_PS2_SShd, /* .ADS with SShd header */
|
||||||
meta_PS2_NPSF, /* Namco Production Sound File */
|
meta_PS2_NPSF, /* Namco Production Sound File */
|
||||||
|
@ -112,6 +112,7 @@ char * extension_list[] = {
|
|||||||
"sng\0SNG Audio File (*.SNG)\0",
|
"sng\0SNG Audio File (*.SNG)\0",
|
||||||
"asf\0ASF Audio File (*.ASF)\0",
|
"asf\0ASF Audio File (*.ASF)\0",
|
||||||
"eam\0EAM Audio File (*.EAM)\0"
|
"eam\0EAM Audio File (*.EAM)\0"
|
||||||
|
"cfn\0CFN Audio File (*.CFN)\0"
|
||||||
};
|
};
|
||||||
|
|
||||||
void about(HWND hwndParent) {
|
void about(HWND hwndParent) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user