mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-17 23:36:41 +01:00
Clean AST meta
This commit is contained in:
parent
bc62a689c0
commit
5aad45ab87
@ -1,18 +1,21 @@
|
|||||||
#include "layout.h"
|
#include "layout.h"
|
||||||
#include "../vgmstream.h"
|
#include "../vgmstream.h"
|
||||||
|
|
||||||
/* set up for the block at the given offset */
|
/* simple headered blocks */
|
||||||
void block_update_ast(off_t block_offset, VGMSTREAM * vgmstream) {
|
void block_update_ast(off_t block_offset, VGMSTREAM * vgmstream) {
|
||||||
|
STREAMFILE* streamFile = vgmstream->ch[0].streamfile;
|
||||||
int i;
|
int i;
|
||||||
vgmstream->current_block_offset = block_offset;
|
size_t block_data, header_size;
|
||||||
vgmstream->current_block_size = read_32bitBE(
|
|
||||||
vgmstream->current_block_offset+4,
|
|
||||||
vgmstream->ch[0].streamfile);
|
|
||||||
vgmstream->next_block_offset = vgmstream->current_block_offset +
|
|
||||||
vgmstream->current_block_size*vgmstream->channels + 0x20;
|
|
||||||
|
|
||||||
for (i=0;i<vgmstream->channels;i++) {
|
/* 0x00: "BLCK", rest: null */
|
||||||
vgmstream->ch[i].offset = vgmstream->current_block_offset +
|
block_data = read_32bitBE(block_offset+0x04,streamFile);
|
||||||
0x20 + vgmstream->current_block_size*i;
|
header_size = 0x20;
|
||||||
|
|
||||||
|
vgmstream->current_block_offset = block_offset;
|
||||||
|
vgmstream->current_block_size = block_data;
|
||||||
|
vgmstream->next_block_offset = block_offset + block_data*vgmstream->channels + header_size;
|
||||||
|
|
||||||
|
for (i = 0; i < vgmstream->channels; i++) {
|
||||||
|
vgmstream->ch[i].offset = block_offset + header_size + block_data*i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,82 +2,60 @@
|
|||||||
#include "../layout/layout.h"
|
#include "../layout/layout.h"
|
||||||
#include "../util.h"
|
#include "../util.h"
|
||||||
|
|
||||||
|
/* .AST - from Nintendo games [Super Mario Galaxy (Wii), Pac-Man Vs (GC)] */
|
||||||
VGMSTREAM * init_vgmstream_ast(STREAMFILE *streamFile) {
|
VGMSTREAM * init_vgmstream_ast(STREAMFILE *streamFile) {
|
||||||
VGMSTREAM * vgmstream = NULL;
|
VGMSTREAM * vgmstream = NULL;
|
||||||
char filename[PATH_LIMIT];
|
off_t start_offset;
|
||||||
|
int loop_flag, channel_count, codec;
|
||||||
coding_t coding_type;
|
|
||||||
|
|
||||||
int codec_number;
|
|
||||||
int channel_count;
|
|
||||||
int loop_flag;
|
|
||||||
|
|
||||||
|
|
||||||
/* check extension, case insensitive */
|
/* checks */
|
||||||
streamFile->get_name(streamFile,filename,sizeof(filename));
|
if (!check_extensions(streamFile, "ast"))
|
||||||
if (strcasecmp("ast",filename_extension(filename))) goto fail;
|
|
||||||
|
|
||||||
/* check header */
|
|
||||||
if ((uint32_t)read_32bitBE(0,streamFile)!=0x5354524D || /* "STRM" */
|
|
||||||
read_16bitBE(0xa,streamFile)!=0x10 ||
|
|
||||||
/* check that file = header (0x40) + data */
|
|
||||||
read_32bitBE(4,streamFile)+0x40!=get_streamfile_size(streamFile))
|
|
||||||
goto fail;
|
goto fail;
|
||||||
|
if (read_32bitBE(0x00,streamFile) != 0x5354524D) /* "STRM" */
|
||||||
/* check for a first block */
|
goto fail;
|
||||||
if (read_32bitBE(0x40,streamFile)!=0x424C434B) /* "BLCK" */
|
if (read_16bitBE(0x0a,streamFile) != 0x10) /* ? */
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
/* check type details */
|
if (read_32bitBE(0x04,streamFile)+0x40 != get_streamfile_size(streamFile))
|
||||||
codec_number = read_16bitBE(8,streamFile);
|
goto fail;
|
||||||
loop_flag = read_16bitBE(0xe,streamFile);
|
codec = read_16bitBE(0x08,streamFile);
|
||||||
channel_count = read_16bitBE(0xc,streamFile);
|
channel_count = read_16bitBE(0x0c,streamFile);
|
||||||
/*max_block = read_32bitBE(0x20,streamFile);*/
|
loop_flag = read_16bitBE(0x0e,streamFile);
|
||||||
|
//max_block = read_32bitBE(0x20,streamFile);
|
||||||
|
|
||||||
switch (codec_number) {
|
start_offset = 0x40;
|
||||||
case 0:
|
if (read_32bitBE(start_offset,streamFile) != 0x424C434B) /* "BLCK" */
|
||||||
coding_type = coding_NGC_AFC;
|
goto fail;
|
||||||
|
|
||||||
|
|
||||||
|
/* build the VGMSTREAM */
|
||||||
|
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||||
|
if (!vgmstream) goto fail;
|
||||||
|
|
||||||
|
vgmstream->meta_type = meta_AST;
|
||||||
|
vgmstream->sample_rate = read_32bitBE(0x10,streamFile);
|
||||||
|
vgmstream->num_samples = read_32bitBE(0x14,streamFile);
|
||||||
|
vgmstream->loop_start_sample = read_32bitBE(0x18,streamFile);
|
||||||
|
vgmstream->loop_end_sample = read_32bitBE(0x1c,streamFile);
|
||||||
|
|
||||||
|
vgmstream->layout_type = layout_blocked_ast;
|
||||||
|
switch (codec) {
|
||||||
|
case 0x00: /* , Pikmin 2 (GC) */
|
||||||
|
vgmstream->coding_type = coding_NGC_AFC;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 0x01: /* Mario Kart: Double Dash!! (GC) */
|
||||||
coding_type = coding_PCM16BE;
|
vgmstream->coding_type = coding_PCM16BE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* build the VGMSTREAM */
|
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
|
||||||
|
goto fail;
|
||||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
|
||||||
if (!vgmstream) goto fail;
|
|
||||||
|
|
||||||
/* fill in the vital statistics */
|
|
||||||
vgmstream->num_samples = read_32bitBE(0x14,streamFile);
|
|
||||||
vgmstream->sample_rate = read_32bitBE(0x10,streamFile);
|
|
||||||
/* channels and loop flag are set by allocate_vgmstream */
|
|
||||||
vgmstream->loop_start_sample = read_32bitBE(0x18,streamFile);
|
|
||||||
vgmstream->loop_end_sample = read_32bitBE(0x1c,streamFile);
|
|
||||||
|
|
||||||
vgmstream->coding_type = coding_type;
|
|
||||||
vgmstream->layout_type = layout_blocked_ast;
|
|
||||||
vgmstream->meta_type = meta_AST;
|
|
||||||
|
|
||||||
/* open the file for reading by each channel */
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
for (i=0;i<channel_count;i++) {
|
|
||||||
vgmstream->ch[i].streamfile = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
|
|
||||||
|
|
||||||
if (!vgmstream->ch[i].streamfile) goto fail;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* start me up */
|
|
||||||
block_update_ast(0x40,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;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user