Updated vgmstream to r1034

CQTexperiment
Chris Moeller 2014-06-26 21:16:37 -07:00
parent a1f436587e
commit 0d8f42031e
22 changed files with 83 additions and 97 deletions

View File

@ -169,16 +169,16 @@ static void
nwa_decode_block(NWAData *nwa)
{
/* 今回読み込む/デコードするデータの大きさを得る */
int curblocksize, curcompsize;
int curblocksize;
if (nwa->curblock != nwa->blocks - 1)
{
curblocksize = nwa->blocksize * (nwa->bps / 8);
curcompsize = nwa->offsets[nwa->curblock + 1] - nwa->offsets[nwa->curblock];
//curcompsize = nwa->offsets[nwa->curblock + 1] - nwa->offsets[nwa->curblock];
}
else
{
curblocksize = nwa->restsize * (nwa->bps / 8);
curcompsize = nwa->blocksize * (nwa->bps / 8) * 2;
//curcompsize = nwa->blocksize * (nwa->bps / 8) * 2;
}
nwa->samples_in_buffer = 0;

View File

@ -14,12 +14,9 @@ static int find_key(STREAMFILE *file, uint8_t type, uint16_t *xor_start, uint16_
VGMSTREAM * init_vgmstream_adx(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
off_t stream_offset;
size_t filesize;
uint16_t version_signature;
int loop_flag=0;
int channel_count;
int32_t loop_start_offset=0;
int32_t loop_end_offset=0;
int32_t loop_start_sample=0;
int32_t loop_end_sample=0;
meta_t header_type;
@ -33,8 +30,6 @@ VGMSTREAM * init_vgmstream_adx(STREAMFILE *streamFile) {
streamFile->get_name(streamFile,filename,sizeof(filename));
if (strcasecmp("adx",filename_extension(filename))) goto fail;
filesize = get_streamfile_size(streamFile);
/* check first 2 bytes */
if ((uint16_t)read_16bitBE(0,streamFile)!=0x8000) goto fail;
@ -78,9 +73,9 @@ VGMSTREAM * init_vgmstream_adx(STREAMFILE *streamFile) {
if (stream_offset-6 >= 0x2c) { /* enough space for loop info? */
loop_flag = (read_32bitBE(0x18,streamFile) != 0);
loop_start_sample = read_32bitBE(0x1c,streamFile);
loop_start_offset = read_32bitBE(0x20,streamFile);
//loop_start_offset = read_32bitBE(0x20,streamFile);
loop_end_sample = read_32bitBE(0x24,streamFile);
loop_end_offset = read_32bitBE(0x28,streamFile);
//loop_end_offset = read_32bitBE(0x28,streamFile);
}
} else if (version_signature == 0x0400) {
@ -97,9 +92,9 @@ VGMSTREAM * init_vgmstream_adx(STREAMFILE *streamFile) {
loop_flag = (read_32bitBE(0x24,streamFile) != 0);
loop_start_sample = read_32bitBE(0x28,streamFile);
loop_start_offset = read_32bitBE(0x2c,streamFile);
//loop_start_offset = read_32bitBE(0x2c,streamFile);
loop_end_sample = read_32bitBE(0x30,streamFile);
loop_end_offset = read_32bitBE(0x34,streamFile);
//loop_end_offset = read_32bitBE(0x34,streamFile);
}
} else if (version_signature == 0x0500) { /* found in some SFD : Buggy Heat, appears to have no loop */
header_type = meta_ADX_05;

View File

@ -11,7 +11,6 @@
VGMSTREAM * init_vgmstream_ahx(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
off_t stream_offset;
size_t filesize;
char filename[PATH_LIMIT];
int channel_count = 1;
int loop_flag = 0;
@ -21,8 +20,6 @@ VGMSTREAM * init_vgmstream_ahx(STREAMFILE *streamFile) {
streamFile->get_name(streamFile,filename,sizeof(filename));
if (strcasecmp("ahx",filename_extension(filename))) goto fail;
filesize = get_streamfile_size(streamFile);
/* check first 2 bytes */
if ((uint16_t)read_16bitBE(0,streamFile)!=0x8000) goto fail;

View File

@ -24,7 +24,6 @@ VGMSTREAM * init_vgmstream_eacs(STREAMFILE *streamFile) {
int channel_count;
int loop_flag=0;
char little_endian=0;
off_t start_offset;
EACSHeader *ea_header = NULL;
int32_t samples_count=0;
int i;
@ -46,7 +45,6 @@ VGMSTREAM * init_vgmstream_eacs(STREAMFILE *streamFile) {
little_endian=1;
/* check type details */
start_offset = read_32bitLE(0x04,streamFile);
if((uint32_t)read_32bitBE(0x08,streamFile)==0x45414353) { /* EACS */
read_streamfile((uint8_t*)ea_header,0x08,sizeof(EACSHeader),streamFile);

View File

@ -534,11 +534,12 @@ fail:
// FSB3 & FSB4 MPEG TEST
VGMSTREAM * init_vgmstream_fsb_mpeg(STREAMFILE *streamFile) {
#ifdef VGM_USE_MPEG
VGMSTREAM * vgmstream = NULL;
char filename[PATH_LIMIT];
off_t start_offset;
int channel_count, channels, encoding, loop_flag, fsb_mainheader_len, fsb_subheader_len, FSBFlag;
long sample_rate = 0, num_samples = 0, rate;
int channel_count, channels, loop_flag, fsb_mainheader_len, fsb_subheader_len, FSBFlag, rate;
long sample_rate = 0, num_samples = 0;
uint16_t mp3ID;
#ifdef VGM_USE_MPEG
@ -581,7 +582,7 @@ VGMSTREAM * init_vgmstream_fsb_mpeg(STREAMFILE *streamFile) {
/* Check the MPEG Sync Header */
mp3ID = read_16bitLE(start_offset,streamFile);
if (mp3ID&0x7FF != 0x7FF)
if ((mp3ID&0x7FF) != 0x7FF)
goto fail;
channel_count = read_16bitLE(fsb_mainheader_len+0x3E,streamFile);
@ -594,17 +595,11 @@ VGMSTREAM * init_vgmstream_fsb_mpeg(STREAMFILE *streamFile) {
num_samples = (read_32bitLE(fsb_mainheader_len+0x2C,streamFile));
#ifdef VGM_USE_MPEG
mpeg_data = init_mpeg_codec_data(streamFile, start_offset, -1, -1, &mpeg_coding_type, &rate, &channels); // -1 to not check sample rate or channels
if (!mpeg_data) goto fail;
mpeg_data = init_mpeg_codec_data(streamFile, start_offset, -1, -1, &mpeg_coding_type, &rate, &channels); // -1 to not check sample rate or channels
if (!mpeg_data) goto fail;
//channel_count = channels;
sample_rate = rate;
#else
// reject if no MPEG support
goto fail;
#endif
//channel_count = channels;
sample_rate = rate;
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
@ -621,16 +616,10 @@ VGMSTREAM * init_vgmstream_fsb_mpeg(STREAMFILE *streamFile) {
}
vgmstream->meta_type = meta_FSB_MPEG;
#ifdef VGM_USE_MPEG
/* NOTE: num_samples seems to be quite wrong for MPEG */
vgmstream->codec_data = mpeg_data;
vgmstream->layout_type = layout_mpeg;
vgmstream->coding_type = mpeg_coding_type;
#else
// reject if no MPEG support
goto fail;
#endif
/* NOTE: num_samples seems to be quite wrong for MPEG */
vgmstream->codec_data = mpeg_data;
vgmstream->layout_type = layout_mpeg;
vgmstream->coding_type = mpeg_coding_type;
#if 0
if (loop_flag) {
@ -656,7 +645,6 @@ VGMSTREAM * init_vgmstream_fsb_mpeg(STREAMFILE *streamFile) {
}
}
#ifdef VGM_USE_MPEG
else if(vgmstream->layout_type == layout_mpeg) {
for (i=0;i<channel_count;i++) {
vgmstream->ch[i].streamfile = streamFile->open(streamFile,filename,MPEG_BUFFER_SIZE);
@ -664,7 +652,6 @@ VGMSTREAM * init_vgmstream_fsb_mpeg(STREAMFILE *streamFile) {
}
}
#endif
else { goto fail; }
}
@ -672,7 +659,6 @@ VGMSTREAM * init_vgmstream_fsb_mpeg(STREAMFILE *streamFile) {
/* clean up anything we may have opened */
fail:
#ifdef VGM_USE_MPEG
if (mpeg_data) {
mpg123_delete(mpeg_data->m);
free(mpeg_data);
@ -681,18 +667,19 @@ fail:
vgmstream->codec_data = NULL;
}
}
#endif
if (vgmstream) close_vgmstream(vgmstream);
#endif
return NULL;
}
#if 0
// FSB5 MPEG
VGMSTREAM * init_vgmstream_fsb5_mpeg(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
char filename[PATH_LIMIT];
off_t start_offset;
int channel_count, channels, encoding, loop_flag, fsb_mainheader_len, fsb_subheader_len, FSBFlag;
long sample_rate = 0, num_samples = 0, rate;
int channel_count, channels, loop_flag, fsb_mainheader_len, fsb_subheader_len, FSBFlag, rate;
long sample_rate = 0, num_samples = 0;
uint16_t mp3ID;
#ifdef VGM_USE_MPEG
@ -731,7 +718,7 @@ VGMSTREAM * init_vgmstream_fsb5_mpeg(STREAMFILE *streamFile) {
/* Check the MPEG Sync Header */
mp3ID = read_16bitLE(start_offset,streamFile);
if (mp3ID&0x7FF != 0x7FF)
if ((mp3ID&0x7FF) != 0x7FF)
goto fail;
channel_count = read_16bitLE(fsb_mainheader_len+0x3E,streamFile);
@ -835,3 +822,4 @@ fail:
if (vgmstream) close_vgmstream(vgmstream);
return NULL;
}
#endif

View File

@ -20,8 +20,6 @@ VGMSTREAM * init_vgmstream_fsb5(STREAMFILE *streamFile) {
int SampleHeaderStart, SampleHeaderLength, NameTableLength, SampleDataLength, CodingID, SampleMode;
int ExtraFlag, ExtraFlagStart, ExtraFlagType, ExtraFlagSize, ExtraFlagEnd;
size_t fileLength;
/* check extension, case insensitive */
streamFile->get_name(streamFile,filename,sizeof(filename));
if (strcasecmp("fsb",filename_extension(filename))) goto fail;

View File

@ -55,10 +55,10 @@ VGMSTREAM * init_vgmstream_genh(STREAMFILE *streamFile) {
/* 12 = NGC DSP */
/* 13 = 8bit unsingned PCM */
/* 14 = PSX ADPCM (bad flagged) */
/* 15 = Microsoft IMA (MS ADPCM)
/* 16 = 8-bit PCM (unsigned)
/* 17 = Apple Quicktime 4-bit IMA ADPCM;
/* ... others to come */
/* 15 = Microsoft IMA (MS ADPCM) */
/* 16 = 8-bit PCM (unsigned) */
/* 17 = Apple Quicktime 4-bit IMA ADPCM */
switch (read_32bitLE(0x18,streamFile)) {
case 0:
coding = coding_PSX;
@ -142,10 +142,16 @@ VGMSTREAM * init_vgmstream_genh(STREAMFILE *streamFile) {
coef[0] = read_32bitLE(0x24,streamFile);
coef[1] = read_32bitLE(0x28,streamFile);
dsp_interleave_type = read_32bitLE(0x2C,streamFile);
coef_type = read_32bitLE(0x30,streamFile); /* 0 - normal coefs
1 - splitted coefs (16byte rows) */
/* DSP coefficient variants */
/* bit 0 - split coefs (2 arrays) */
/* bit 1 - little endian coefs */
coef_type = read_32bitLE(0x30,streamFile);
/* when using split coefficients, 2nd array is at: */
coef_splitted[0] = read_32bitLE(0x34,streamFile);
coef_splitted[1] = read_32bitLE(0x38,streamFile);
//if (coding == coding_XBOX && channel_count != 2) goto fail;
/* build the VGMSTREAM */
@ -298,14 +304,23 @@ VGMSTREAM * init_vgmstream_genh(STREAMFILE *streamFile) {
chstreamfile =
streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
if (coef_type == 0) {
for (j=0;j<16;j++) {
vgmstream->ch[i].adpcm_coef[j] = read_16bitBE(coef[i]+j*2,streamFile);
{
int16_t (*read_16bit)(off_t , STREAMFILE*);
if ((coef_type & 2) == 0) {
read_16bit = read_16bitBE;
} else {
read_16bit = read_16bitLE;
}
} else if (coef_type == 1) {
for (j=0;j<8;j++) {
vgmstream->ch[i].adpcm_coef[j*2]=read_16bitBE(coef[i]+j*2,streamFile);
vgmstream->ch[i].adpcm_coef[j*2+1]=read_16bitBE(coef_splitted[i]+j*2,streamFile);
if ((coef_type & 1) == 0) {
for (j=0;j<16;j++) {
vgmstream->ch[i].adpcm_coef[j] = read_16bit(coef[i]+j*2,streamFile);
}
} else {
for (j=0;j<8;j++) {
vgmstream->ch[i].adpcm_coef[j*2]=read_16bit(coef[i]+j*2,streamFile);
vgmstream->ch[i].adpcm_coef[j*2+1]=read_16bit(coef_splitted[i]+j*2,streamFile);
}
}
}
chstart_offset =start_offset+vgmstream->interleave_block_size*i;

View File

@ -9,7 +9,6 @@ VGMSTREAM * init_vgmstream_ivaud(STREAMFILE *streamFile) {
char filename[PATH_LIMIT];
off_t start_offset;
off_t block_table_offset;
int block_count;
int loop_flag = 0;
int channel_count;
int i;
@ -52,7 +51,7 @@ VGMSTREAM * init_vgmstream_ivaud(STREAMFILE *streamFile) {
/* Calc num_samples */
start_offset = read_32bitLE(0x2C,streamFile);
block_count = read_32bitLE(0x08,streamFile);
//block_count = read_32bitLE(0x08,streamFile);
vgmstream->next_block_offset = read_32bitLE(0x2C,streamFile);
// to avoid troubles with "extra" samples

View File

@ -1736,7 +1736,7 @@ VGMSTREAM * init_vgmstream_dsp_str_ig(STREAMFILE *streamFile) {
}
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(2,ch0_header.loop_flag);
vgmstream = allocate_vgmstream(channel_count, ch0_header.loop_flag);
if (!vgmstream) goto fail;
/* fill in the vital statistics */
@ -1849,7 +1849,7 @@ VGMSTREAM * init_vgmstream_dsp_xiii(STREAMFILE *streamFile) {
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(2,ch1_header.loop_flag);
vgmstream = allocate_vgmstream(channel_count, ch1_header.loop_flag);
if (!vgmstream) goto fail;
/* fill in the vital statistics */
@ -1905,7 +1905,6 @@ VGMSTREAM * init_vgmstream_wii_ndp(STREAMFILE *streamFile) {
char filename[PATH_LIMIT];
struct dsp_header ch0_header,ch1_header;
off_t ch1_header_start, ch2_header_start, ch1_start, ch2_start;
int channel_count;
int i;
/* check extension, case insensitive */
@ -1921,7 +1920,7 @@ VGMSTREAM * init_vgmstream_wii_ndp(STREAMFILE *streamFile) {
if ((read_32bitLE(0x8,streamFile)+0x18 != get_streamfile_size(streamFile))) /* NDP */
goto fail;
channel_count = (read_16bitLE(0x10,streamFile) != 2);
//channel_count = (read_16bitLE(0x10,streamFile) != 2);
ch1_header_start = 0x18;
ch2_header_start = 0x78;
@ -1967,7 +1966,7 @@ VGMSTREAM * init_vgmstream_wii_ndp(STREAMFILE *streamFile) {
}
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(2,ch0_header.loop_flag);
vgmstream = allocate_vgmstream(2, ch0_header.loop_flag);
if (!vgmstream) goto fail;
/* fill in the vital statistics */
@ -2066,7 +2065,7 @@ VGMSTREAM * init_vgmstream_dsp_cabelas(STREAMFILE *streamFile) {
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(2,1);
vgmstream = allocate_vgmstream(channel_count, 1);
if (!vgmstream) goto fail;
/* fill in the vital statistics */
@ -2461,4 +2460,5 @@ fail:
/* clean up anything we may have opened */
if (vgmstream) close_vgmstream(vgmstream);
return NULL;
}
}

View File

@ -11,8 +11,6 @@ VGMSTREAM * init_vgmstream_ps2_2pfs(STREAMFILE *streamFile)
VGMSTREAM * vgmstream = NULL;
char filename[PATH_LIMIT];
size_t fileLength;
off_t readOffset = 0;
off_t start_offset;
int loop_flag = 0;

View File

@ -57,6 +57,10 @@ VGMSTREAM * init_vgmstream_ps2_ast(STREAMFILE *streamFile) {
vgmstream->num_samples = (read_32bitLE(0x04,streamFile)-start_offset)*28/16/channel_count;
vgmstream->interleave_block_size = read_32bitLE(0x10,streamFile);
}
else
{
goto fail;
}
vgmstream->layout_type = layout_interleave;
vgmstream->coding_type = coding_PSX;

View File

@ -12,9 +12,11 @@ VGMSTREAM * init_vgmstream_ps2_hsf(STREAMFILE *streamFile)
size_t fileLength;
size_t frequencyFlag;
#if 0
off_t readOffset = 0;
uint8_t testBuffer[0x10];
off_t loopEndOffset;
#endif
/* check extension, case insensitive */
streamFile->get_name(streamFile,filename,sizeof(filename));
@ -57,7 +59,7 @@ VGMSTREAM * init_vgmstream_ps2_hsf(STREAMFILE *streamFile)
vgmstream->loop_start_sample = 0;
vgmstream->loop_end_sample = vgmstream->num_samples;
/*
#if 0
readOffset = fileLength - 0x10;
do
@ -72,7 +74,7 @@ VGMSTREAM * init_vgmstream_ps2_hsf(STREAMFILE *streamFile)
}
} while (readOffset > 0);
*/
#endif
}
/* open the file for reading */

View File

@ -12,8 +12,8 @@ VGMSTREAM * init_vgmstream_ps2_vgs(STREAMFILE *streamFile) {
size_t fileLength;
off_t readOffset = 0;
off_t start_offset;
off_t loop_start_offset;
off_t loop_end_offset;
off_t loop_start_offset = 0;
off_t loop_end_offset = 0;
uint8_t testBuffer[0x10];
int loop_flag = 0;

View File

@ -64,4 +64,4 @@ VGMSTREAM * init_vgmstream_ps2_xau(STREAMFILE *streamFile)
fail:
if (vgmstream) close_vgmstream(vgmstream);
return NULL;
}
}

View File

@ -11,8 +11,6 @@ VGMSTREAM * init_vgmstream_ps3_ivag(STREAMFILE *streamFile)
VGMSTREAM * vgmstream = NULL;
char filename[PATH_LIMIT];
size_t fileLength;
off_t readOffset = 0;
off_t start_offset;
int loop_flag = 0;

View File

@ -9,8 +9,6 @@ VGMSTREAM * init_vgmstream_ps3_vawx(STREAMFILE *streamFile)
VGMSTREAM * vgmstream = NULL;
char filename[PATH_LIMIT];
size_t fileLength;
off_t readOffset = 0;
off_t start_offset;
int loop_flag = 0;

View File

@ -114,14 +114,13 @@ off_t init_xa_channel(int* channel,STREAMFILE* streamFile) {
size_t filelength=get_streamfile_size(streamFile);
int8_t currentChannel;
int8_t subAudio;
// 0 can't be a correct value
if(block_offset>=(off_t)filelength)
return 0;
currentChannel=read_8bit(block_offset-7,streamFile);
subAudio=read_8bit(block_offset-6,streamFile);
//subAudio=read_8bit(block_offset-6,streamFile);
*channel=currentChannel;
//if (!((currentChannel==channel) && (subAudio==0x64))) {
// block_offset+=2352;

View File

@ -539,7 +539,7 @@ VGMSTREAM * init_vgmstream_rifx(STREAMFILE *streamFile) {
off_t file_size = -1;
int sample_count = 0;
int fact_sample_count = -1;
//int fact_sample_count = -1;
off_t start_offset = -1;
off_t wiih_offset = -1;
uint32_t wiih_size = 0;
@ -624,7 +624,7 @@ VGMSTREAM * init_vgmstream_rifx(STREAMFILE *streamFile) {
break;
case 0x66616374: /* fact */
if (chunk_size != 4) break;
fact_sample_count = read_32bitBE(current_chunk+8, streamFile);
//fact_sample_count = read_32bitBE(current_chunk+8, streamFile);
break;
case 0x57696948: /* WiiH */
wiih_size = read_32bitBE(current_chunk+4, streamFile);

View File

@ -963,12 +963,10 @@ fail:
/* RSD6OGG */
VGMSTREAM * init_vgmstream_rsd6oogv(STREAMFILE *streamFile) {
#ifdef VGM_USE_VORBIS
char filename[PATH_LIMIT];
off_t start_offset;
int loop_flag;
int channel_count;
/* check extension, case insensitive */
streamFile->get_name(streamFile,filename,sizeof(filename));
if (strcasecmp("rsd",filename_extension(filename))) goto fail;
@ -979,7 +977,6 @@ VGMSTREAM * init_vgmstream_rsd6oogv(STREAMFILE *streamFile) {
if (read_32bitBE(0x4,streamFile) != 0x4F4F4756) /* OOGV */
goto fail;
#ifdef VGM_USE_VORBIS
{
vgm_vorbis_info_t inf;
VGMSTREAM * result = NULL;
@ -995,10 +992,10 @@ VGMSTREAM * init_vgmstream_rsd6oogv(STREAMFILE *streamFile) {
return result;
}
}
#endif
fail:
/* clean up anything we may have opened */
#endif
return NULL;
}

View File

@ -23,7 +23,7 @@ static STREAMFILE *open_scdint_with_STREAMFILE(STREAMFILE *file, const char * fi
VGMSTREAM * init_vgmstream_sqex_scd(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
char filename[PATH_LIMIT];
off_t start_offset, meta_offset_offset, meta_offset, post_meta_offset, size_offset;
off_t start_offset, meta_offset_offset, meta_offset, post_meta_offset;
int32_t loop_start, loop_end;
int loop_flag = 0;
@ -48,14 +48,14 @@ VGMSTREAM * init_vgmstream_sqex_scd(STREAMFILE *streamFile) {
/* version 3 BE, as seen in FFXIII for PS3 */
read_32bit = read_32bitBE;
read_16bit = read_16bitBE;
size_offset = 0x14;
//size_offset = 0x14;
meta_offset_offset = 0x40 + read_16bit(0xe,streamFile);
} else if (read_32bitLE(8,streamFile) == 3 ||
read_32bitLE(8,streamFile) == 2) {
/* version 2/3 LE, as seen in FFXIV for ?? */
read_32bit = read_32bitLE;
read_16bit = read_16bitLE;
size_offset = 0x10;
//size_offset = 0x10;
meta_offset_offset = 0x40 + read_16bit(0xe,streamFile);
} else goto fail;

View File

@ -119,7 +119,6 @@ VGMSTREAM * init_vgmstream_ss_stream(STREAMFILE *streamFile) {
int loop_flag=0;
int channels;
int channel_count;
int freq_flag;
off_t start_offset;
int i;
@ -129,7 +128,7 @@ VGMSTREAM * init_vgmstream_ss_stream(STREAMFILE *streamFile) {
strcasecmp("ss7",filename_extension(filename))) goto fail;
loop_flag = 0;
freq_flag = read_8bit(0x08,streamFile);
//freq_flag = read_8bit(0x08,streamFile);
if (read_8bit(0x0C,streamFile) == 0) {
channels = 1;

View File

@ -58,4 +58,5 @@ VGMSTREAM * init_vgmstream_xbox_wavm(STREAMFILE *streamFile) {
fail:
if (vgmstream) close_vgmstream(vgmstream);
return NULL;
}
}