mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-29 19:37:30 +01:00
Add CAF .caf/empty extension, cleanup [Baten Kaitos (GC), Fragile (Wii)]
This commit is contained in:
parent
79080d34f3
commit
c0906d1b0f
@ -88,7 +88,7 @@ static const char* extension_list[] = {
|
|||||||
"cbd2",
|
"cbd2",
|
||||||
"ccc",
|
"ccc",
|
||||||
"cd",
|
"cd",
|
||||||
"cfn",
|
"cfn", //fake extension/header id for .caf (to be removed)
|
||||||
"ckd",
|
"ckd",
|
||||||
"cnk",
|
"cnk",
|
||||||
"cps",
|
"cps",
|
||||||
@ -557,7 +557,7 @@ static const layout_info layout_info_list[] = {
|
|||||||
{layout_xa_blocked, "CD-ROM XA"},
|
{layout_xa_blocked, "CD-ROM XA"},
|
||||||
{layout_blocked_ea_schl, "blocked (EA SCHl)"},
|
{layout_blocked_ea_schl, "blocked (EA SCHl)"},
|
||||||
{layout_blocked_ea_1snh, "blocked (EA 1SNh)"},
|
{layout_blocked_ea_1snh, "blocked (EA 1SNh)"},
|
||||||
{layout_caf_blocked, "CAF blocked"},
|
{layout_blocked_caf, "blocked (CAF)"},
|
||||||
{layout_wsi_blocked, ".wsi blocked"},
|
{layout_wsi_blocked, ".wsi blocked"},
|
||||||
{layout_xvas_blocked, ".xvas blocked"},
|
{layout_xvas_blocked, ".xvas blocked"},
|
||||||
{layout_str_snds_blocked, ".str SNDS blocked"},
|
{layout_str_snds_blocked, ".str SNDS blocked"},
|
||||||
@ -651,7 +651,7 @@ static const meta_info meta_info_list[] = {
|
|||||||
{meta_DSP_STR, "assumed Conan Gamecube STR File by .str extension"},
|
{meta_DSP_STR, "assumed Conan Gamecube STR File by .str extension"},
|
||||||
{meta_EA_SCHL, "Electronic Arts SCHl header (variable)"},
|
{meta_EA_SCHL, "Electronic Arts SCHl header (variable)"},
|
||||||
{meta_EA_SCHL_fixed, "Electronic Arts SCHl header (fixed)"},
|
{meta_EA_SCHL_fixed, "Electronic Arts SCHl header (fixed)"},
|
||||||
{meta_CFN, "tri-Crescendo CAF Header"},
|
{meta_CAF, "tri-Crescendo CAF Header"},
|
||||||
{meta_PS2_VPK, "VPK Header"},
|
{meta_PS2_VPK, "VPK Header"},
|
||||||
{meta_GENH, "GENH Generic Header"},
|
{meta_GENH, "GENH Generic Header"},
|
||||||
{meta_DSP_SADB, "Procyon Studio SADB header"},
|
{meta_DSP_SADB, "Procyon Studio SADB header"},
|
||||||
|
@ -86,8 +86,8 @@ void render_vgmstream_blocked(sample * buffer, int32_t sample_count, VGMSTREAM *
|
|||||||
case layout_blocked_ea_1snh:
|
case layout_blocked_ea_1snh:
|
||||||
block_update_ea_1snh(vgmstream->next_block_offset,vgmstream);
|
block_update_ea_1snh(vgmstream->next_block_offset,vgmstream);
|
||||||
break;
|
break;
|
||||||
case layout_caf_blocked:
|
case layout_blocked_caf:
|
||||||
caf_block_update(vgmstream->next_block_offset,vgmstream);
|
block_update_caf(vgmstream->next_block_offset,vgmstream);
|
||||||
break;
|
break;
|
||||||
case layout_wsi_blocked:
|
case layout_wsi_blocked:
|
||||||
wsi_block_update(vgmstream->next_block_offset,vgmstream);
|
wsi_block_update(vgmstream->next_block_offset,vgmstream);
|
||||||
|
@ -1,26 +1,21 @@
|
|||||||
#include "layout.h"
|
#include "layout.h"
|
||||||
#include "../vgmstream.h"
|
#include "../vgmstream.h"
|
||||||
|
|
||||||
/* set up for the block at the given offset */
|
/* each block is a new CAF header */
|
||||||
void caf_block_update(off_t block_offset, VGMSTREAM * vgmstream) {
|
void block_update_caf(off_t block_offset, VGMSTREAM * vgmstream) {
|
||||||
int i;
|
STREAMFILE* streamFile = vgmstream->ch[0].streamfile;
|
||||||
|
int i,ch;
|
||||||
|
|
||||||
vgmstream->current_block_offset = block_offset;
|
vgmstream->current_block_offset = block_offset;
|
||||||
vgmstream->current_block_size = read_32bitBE(
|
vgmstream->next_block_offset = block_offset + read_32bitBE(block_offset+0x04, streamFile);
|
||||||
vgmstream->current_block_offset+0x14,
|
vgmstream->current_block_size = read_32bitBE(block_offset+0x14, streamFile);
|
||||||
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++) {
|
for (ch = 0; ch < vgmstream->channels; ch++) {
|
||||||
vgmstream->ch[i].offset = vgmstream->current_block_offset +
|
vgmstream->ch[ch].offset = block_offset + read_32bitBE(block_offset+0x10+(0x08*ch), streamFile);
|
||||||
read_32bitBE(block_offset+0x10+(8*i),vgmstream->ch[0].streamfile);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* coeffs */
|
/* re-read coeffs (though blocks seem to repeat them) */
|
||||||
for (i=0;i<16;i++) {
|
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[ch].adpcm_coef[i] = read_16bitBE(block_offset+0x34 + 0x2c*ch + 0x02*i, streamFile);
|
||||||
vgmstream->ch[1].adpcm_coef[i] = read_16bitBE(block_offset+0x60+(2*i),vgmstream->ch[0].streamfile);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,7 @@ void xa_block_update(off_t block_offset, VGMSTREAM * vgmstream);
|
|||||||
|
|
||||||
void block_update_ea_schl(off_t block_offset, VGMSTREAM * vgmstream);
|
void block_update_ea_schl(off_t block_offset, VGMSTREAM * vgmstream);
|
||||||
void block_update_ea_1snh(off_t block_offset, VGMSTREAM * vgmstream);
|
void block_update_ea_1snh(off_t block_offset, VGMSTREAM * vgmstream);
|
||||||
|
void block_update_caf(off_t block_offset, VGMSTREAM * vgmstream);
|
||||||
void caf_block_update(off_t block_offset, VGMSTREAM * vgmstream);
|
|
||||||
|
|
||||||
void wsi_block_update(off_t block_offset, VGMSTREAM * vgmstream);
|
void wsi_block_update(off_t block_offset, VGMSTREAM * vgmstream);
|
||||||
|
|
||||||
|
@ -2,74 +2,64 @@
|
|||||||
#include "../layout/layout.h"
|
#include "../layout/layout.h"
|
||||||
#include "../util.h"
|
#include "../util.h"
|
||||||
|
|
||||||
|
/* CAF - from tri-Crescendo games [Baten Kaitos 1/2 (GC), Fragile (Wii)] */
|
||||||
VGMSTREAM * init_vgmstream_caf(STREAMFILE *streamFile) {
|
VGMSTREAM * init_vgmstream_caf(STREAMFILE *streamFile) {
|
||||||
VGMSTREAM * vgmstream = NULL;
|
VGMSTREAM * vgmstream = NULL;
|
||||||
char filename[PATH_LIMIT];
|
off_t start_offset, offset;
|
||||||
|
size_t file_size;
|
||||||
// Calculate sample length ...
|
int channel_count, loop_flag;
|
||||||
int32_t num_of_samples=0;
|
int32_t num_samples = 0;
|
||||||
int32_t block_count=0;
|
uint32_t loop_start = -1;
|
||||||
|
|
||||||
uint32_t loop_start=-1;
|
|
||||||
|
|
||||||
off_t offset=0;
|
/* checks */
|
||||||
off_t next_block;
|
/* .caf: header id, .cfn: fake extension? , "" is accepted as files don't have extensions in the disc */
|
||||||
off_t file_length;
|
if (!check_extensions(streamFile,"caf,cfn,"))
|
||||||
int i;
|
goto fail;
|
||||||
|
if (read_32bitBE(0x00,streamFile) != 0x43414620) /* "CAF " */
|
||||||
|
goto fail;
|
||||||
|
|
||||||
/* check extension, case insensitive */
|
/* get total samples */
|
||||||
streamFile->get_name(streamFile,filename,sizeof(filename));
|
offset = 0;
|
||||||
if (strcasecmp("cfn",filename_extension(filename))) goto fail;
|
file_size = get_streamfile_size(streamFile);
|
||||||
|
while (offset < file_size) {
|
||||||
|
off_t next_block = read_32bitBE(offset+0x04,streamFile);
|
||||||
|
num_samples += read_32bitBE(offset+0x14,streamFile)/8*14;
|
||||||
|
|
||||||
/* Check "CAF " ID */
|
if(read_32bitBE(offset+0x20,streamFile)==read_32bitBE(offset+0x08,streamFile)) {
|
||||||
if (read_32bitBE(0,streamFile)!=0x43414620) goto fail;
|
loop_start = num_samples - read_32bitBE(offset+0x14,streamFile)/8*14;
|
||||||
|
|
||||||
// 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;
|
|
||||||
}
|
}
|
||||||
|
offset += next_block;
|
||||||
}
|
}
|
||||||
|
|
||||||
caf_block_update(0,vgmstream);
|
start_offset = 0x00;
|
||||||
|
channel_count = 2; /* always stereo */
|
||||||
|
loop_flag = (loop_start!=-1);
|
||||||
|
|
||||||
|
|
||||||
|
/* build the VGMSTREAM */
|
||||||
|
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||||
|
if (!vgmstream) goto fail;
|
||||||
|
|
||||||
|
vgmstream->sample_rate = 32000;
|
||||||
|
vgmstream->num_samples = num_samples;
|
||||||
|
if (loop_flag) {
|
||||||
|
vgmstream->loop_start_sample = loop_start;
|
||||||
|
vgmstream->loop_end_sample = num_samples;
|
||||||
|
}
|
||||||
|
|
||||||
|
vgmstream->meta_type = meta_CAF;
|
||||||
|
vgmstream->coding_type = coding_NGC_DSP;
|
||||||
|
vgmstream->layout_type = layout_blocked_caf;
|
||||||
|
|
||||||
|
if ( !vgmstream_open_stream(vgmstream,streamFile,start_offset) )
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
block_update_caf(start_offset,vgmstream);
|
||||||
|
|
||||||
return vgmstream;
|
return vgmstream;
|
||||||
|
|
||||||
/* clean up anything we may have opened */
|
|
||||||
fail:
|
fail:
|
||||||
if (vgmstream) close_vgmstream(vgmstream);
|
close_vgmstream(vgmstream);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -956,7 +956,7 @@ void render_vgmstream(sample * buffer, int32_t sample_count, VGMSTREAM * vgmstre
|
|||||||
case layout_xa_blocked:
|
case layout_xa_blocked:
|
||||||
case layout_blocked_ea_schl:
|
case layout_blocked_ea_schl:
|
||||||
case layout_blocked_ea_1snh:
|
case layout_blocked_ea_1snh:
|
||||||
case layout_caf_blocked:
|
case layout_blocked_caf:
|
||||||
case layout_wsi_blocked:
|
case layout_wsi_blocked:
|
||||||
case layout_str_snds_blocked:
|
case layout_str_snds_blocked:
|
||||||
case layout_ws_aud_blocked:
|
case layout_ws_aud_blocked:
|
||||||
|
@ -225,7 +225,7 @@ typedef enum {
|
|||||||
layout_xa_blocked,
|
layout_xa_blocked,
|
||||||
layout_blocked_ea_schl,
|
layout_blocked_ea_schl,
|
||||||
layout_blocked_ea_1snh,
|
layout_blocked_ea_1snh,
|
||||||
layout_caf_blocked,
|
layout_blocked_caf,
|
||||||
layout_wsi_blocked,
|
layout_wsi_blocked,
|
||||||
layout_str_snds_blocked,
|
layout_str_snds_blocked,
|
||||||
layout_ws_aud_blocked,
|
layout_ws_aud_blocked,
|
||||||
@ -319,7 +319,7 @@ typedef enum {
|
|||||||
meta_RSF, /* Retro Studios RSF (Metroid Prime .rsf) [no header_id] */
|
meta_RSF, /* Retro Studios RSF (Metroid Prime .rsf) [no header_id] */
|
||||||
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_CAF, /* tri-Crescendo CAF */
|
||||||
meta_MYSPD, /* U-Sing .myspd */
|
meta_MYSPD, /* U-Sing .myspd */
|
||||||
meta_HIS, /* Her Ineractive .his */
|
meta_HIS, /* Her Ineractive .his */
|
||||||
meta_BNSF, /* Bandai Namco Sound Format */
|
meta_BNSF, /* Bandai Namco Sound Format */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user