mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-02-17 19:19:16 +01:00
redone .wsd support with standard dsp header processing, update readme
git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@615 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
parent
06f16296b7
commit
64a2daf4e5
@ -133,6 +133,7 @@ GC/Wii DSP ADPCM:
|
||||
- .tydsp
|
||||
- .vjdsp
|
||||
- .waa, .wac, .wad, .wam
|
||||
- .wsd
|
||||
- .wsi
|
||||
- .ydsp
|
||||
- .ymf
|
||||
@ -172,6 +173,7 @@ Yamaha ADPCM:
|
||||
IMA ADPCM:
|
||||
- .dvi (DVI IMA ADPCM)
|
||||
- .idvi (DVI IMA ADPCM)
|
||||
- .ivaud (IMA ADPCM)
|
||||
- .stma (DVI IMA ADPCM)
|
||||
- .strm (IMA ADPCM)
|
||||
|
||||
|
@ -190,8 +190,7 @@ META_OBJS=meta/adx_header.o \
|
||||
meta/ps2_mcg.o \
|
||||
meta/redspark.o \
|
||||
meta/ps2_vgs.o \
|
||||
meta/ivaud.o \
|
||||
meta/wii_wsd.o
|
||||
meta/ivaud.o
|
||||
|
||||
OBJECTS=vgmstream.o streamfile.o util.o $(CODING_OBJS) $(LAYOUT_OBJS) $(META_OBJS)
|
||||
|
||||
|
@ -746,10 +746,6 @@
|
||||
RelativePath=".\meta\wii_sts.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\meta\wii_wsd.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\meta\ws_aud.c"
|
||||
>
|
||||
|
@ -150,6 +150,5 @@ libmeta_la_SOURCES += ps2_mcg.c
|
||||
libmeta_la_SOURCES += redspark.c
|
||||
libmeta_la_SOURCES += ivaud.c
|
||||
libmeta_la_SOURCES += ps2_vgs.c
|
||||
libmeta_la_SOURCES += wii_wsd.c
|
||||
|
||||
EXTRA_DIST = meta.h
|
||||
|
@ -1239,3 +1239,126 @@ fail:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* .wsd files, two DSP files stuck together */
|
||||
/* found in Phantom Brave Wii */
|
||||
VGMSTREAM * init_vgmstream_wii_wsd(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
char filename[260];
|
||||
|
||||
off_t channel_1_start, channel_2_start, channel_1_size, channel_2_size;
|
||||
|
||||
struct dsp_header ch0_header,ch1_header;
|
||||
|
||||
/* check extension, case insensitive */
|
||||
streamFile->get_name(streamFile,filename,sizeof(filename));
|
||||
if (strcasecmp("wsd",filename_extension(filename))) goto fail;
|
||||
|
||||
/* read .wsd header */
|
||||
channel_1_start = read_32bitBE(0x0,streamFile);
|
||||
channel_2_start = read_32bitBE(0x4,streamFile);
|
||||
channel_1_size = read_32bitBE(0x8,streamFile);
|
||||
channel_2_size = read_32bitBE(0xc,streamFile);
|
||||
|
||||
/* check header */
|
||||
if (channel_1_size != channel_2_size) goto fail;
|
||||
if (channel_1_start != 0x20) goto fail;
|
||||
if (channel_1_size < 0x20 || channel_2_size < 0x20) goto fail;
|
||||
if (channel_1_start + channel_1_size > channel_2_start) goto fail;
|
||||
if (channel_2_start + channel_2_size > get_streamfile_size(streamFile))
|
||||
goto fail;
|
||||
|
||||
/* get DSP headers */
|
||||
if (read_dsp_header(&ch0_header, channel_1_start, streamFile)) goto fail;
|
||||
if (read_dsp_header(&ch1_header, channel_2_start, streamFile)) goto fail;
|
||||
|
||||
/* check initial predictor/scale */
|
||||
if (ch0_header.initial_ps !=
|
||||
(uint8_t)read_8bit(channel_1_start + 0x60, streamFile))
|
||||
goto fail;
|
||||
|
||||
if (ch1_header.initial_ps !=
|
||||
(uint8_t)read_8bit(channel_2_start + 0x60, streamFile))
|
||||
goto fail;
|
||||
|
||||
/* check type==0 and gain==0 */
|
||||
if (ch0_header.format || ch0_header.gain ||
|
||||
ch1_header.format || ch1_header.gain)
|
||||
goto fail;
|
||||
|
||||
/* check for agreement */
|
||||
if (
|
||||
ch0_header.sample_count != ch1_header.sample_count ||
|
||||
ch0_header.nibble_count != ch1_header.nibble_count ||
|
||||
ch0_header.sample_rate != ch1_header.sample_rate ||
|
||||
ch0_header.loop_flag != ch1_header.loop_flag ||
|
||||
ch0_header.loop_start_offset != ch1_header.loop_start_offset ||
|
||||
ch0_header.loop_end_offset != ch1_header.loop_end_offset
|
||||
) goto fail;
|
||||
|
||||
if (ch0_header.loop_flag) {
|
||||
off_t loop_off;
|
||||
/* check loop predictor/scale */
|
||||
loop_off = ch0_header.loop_start_offset/16*8;
|
||||
if (ch0_header.loop_ps !=
|
||||
(uint8_t)read_8bit(channel_1_start+0x60+loop_off,streamFile))
|
||||
goto fail;
|
||||
if (ch1_header.loop_ps !=
|
||||
(uint8_t)read_8bit(channel_2_start+0x60+loop_off,streamFile))
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
|
||||
vgmstream = allocate_vgmstream(2,ch0_header.loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
/* fill in the vital statistics */
|
||||
vgmstream->num_samples = ch0_header.sample_count;
|
||||
vgmstream->sample_rate = ch0_header.sample_rate;
|
||||
|
||||
vgmstream->loop_start_sample = dsp_nibbles_to_samples(
|
||||
ch0_header.loop_start_offset);
|
||||
vgmstream->loop_end_sample = dsp_nibbles_to_samples(
|
||||
ch0_header.loop_end_offset)+1;
|
||||
|
||||
vgmstream->coding_type = coding_NGC_DSP;
|
||||
vgmstream->layout_type = layout_none;
|
||||
vgmstream->meta_type = meta_DSP_WII_WSD;
|
||||
|
||||
/* coeffs */
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<16;i++) {
|
||||
vgmstream->ch[0].adpcm_coef[i] = ch0_header.coef[i];
|
||||
vgmstream->ch[1].adpcm_coef[i] = ch1_header.coef[i];
|
||||
}
|
||||
}
|
||||
|
||||
/* initial history */
|
||||
/* always 0 that I've ever seen, but for completeness... */
|
||||
vgmstream->ch[0].adpcm_history1_16 = ch0_header.initial_hist1;
|
||||
vgmstream->ch[0].adpcm_history2_16 = ch0_header.initial_hist2;
|
||||
vgmstream->ch[1].adpcm_history1_16 = ch1_header.initial_hist1;
|
||||
vgmstream->ch[1].adpcm_history2_16 = ch1_header.initial_hist2;
|
||||
|
||||
/* open the file for reading */
|
||||
vgmstream->ch[0].streamfile = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
|
||||
if (!vgmstream->ch[0].streamfile) goto fail;
|
||||
|
||||
vgmstream->ch[1].streamfile = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
|
||||
if (!vgmstream->ch[1].streamfile) goto fail;
|
||||
vgmstream->ch[1].streamfile = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
|
||||
|
||||
vgmstream->ch[0].channel_start_offset =
|
||||
vgmstream->ch[0].offset=channel_1_start+0x60;
|
||||
vgmstream->ch[1].channel_start_offset =
|
||||
vgmstream->ch[1].offset=channel_2_start+0x60;
|
||||
|
||||
return vgmstream;
|
||||
|
||||
fail:
|
||||
/* clean up anything we may have opened */
|
||||
if (vgmstream) close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1,90 +0,0 @@
|
||||
#include "meta.h"
|
||||
#include "../util.h"
|
||||
|
||||
/* WSD - Phantom Brave (WII) */
|
||||
VGMSTREAM * init_vgmstream_wii_wsd(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
char filename[260];
|
||||
off_t start_offset;
|
||||
int loop_flag;
|
||||
int channel_count;
|
||||
int coef1_start;
|
||||
int coef2_start;
|
||||
int second_channel_start;
|
||||
|
||||
/* check extension, case insensitive */
|
||||
streamFile->get_name(streamFile,filename,sizeof(filename));
|
||||
if (strcasecmp("wsd",filename_extension(filename))) goto fail;
|
||||
|
||||
/* check header, first file should alwas start at 0x20 */
|
||||
if (read_32bitBE(0x00,streamFile) != 0x00000020) /* 0x20 */
|
||||
goto fail;
|
||||
|
||||
loop_flag = (read_32bitBE(0x2C,streamFile) != 0x0);
|
||||
channel_count = read_32bitBE(0x38,streamFile);
|
||||
|
||||
/* WSD contains always 2 files, one for the
|
||||
left channel and one or the right channel */
|
||||
if ((channel_count) !=2)
|
||||
goto fail;
|
||||
|
||||
coef1_start = 0x3C;
|
||||
coef2_start = (read_32bitBE(0x4,streamFile))+0x1C;
|
||||
second_channel_start = (read_32bitBE(0x4,streamFile))+0x60;
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
/* fill in the vital statistics */
|
||||
start_offset = 0x80;
|
||||
vgmstream->channels = channel_count;
|
||||
vgmstream->sample_rate = read_32bitBE(0x28,streamFile);
|
||||
vgmstream->coding_type = coding_NGC_DSP;
|
||||
vgmstream->num_samples = read_32bitBE(0x24,streamFile)/channel_count/8*14;
|
||||
if (loop_flag) {
|
||||
vgmstream->loop_start_sample = read_32bitBE(0x30,streamFile)/channel_count/8*14;
|
||||
vgmstream->loop_end_sample = read_32bitBE(0x34,streamFile)/channel_count/8*14;
|
||||
}
|
||||
|
||||
/* no interleave, we have 2 dsp files in 1 file here */
|
||||
vgmstream->layout_type = layout_none;
|
||||
vgmstream->meta_type = meta_WII_WSD;
|
||||
|
||||
/* Retrieves the coef tables */
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<16;i++) {
|
||||
vgmstream->ch[0].adpcm_coef[i] = read_16bitBE(coef1_start+i*2,streamFile);
|
||||
}
|
||||
if (vgmstream->channels) {
|
||||
for (i=0;i<16;i++) {
|
||||
vgmstream->ch[1].adpcm_coef[i] = read_16bitBE(coef2_start +i*2,streamFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* open the file for reading */
|
||||
vgmstream->ch[0].streamfile = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
|
||||
|
||||
if (!vgmstream->ch[0].streamfile) goto fail;
|
||||
|
||||
vgmstream->ch[0].channel_start_offset=
|
||||
vgmstream->ch[0].offset=start_offset;
|
||||
|
||||
if (channel_count == 2) {
|
||||
vgmstream->ch[1].streamfile = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
|
||||
|
||||
if (!vgmstream->ch[1].streamfile) goto fail;
|
||||
|
||||
vgmstream->ch[1].channel_start_offset=
|
||||
vgmstream->ch[1].offset=second_channel_start;
|
||||
}
|
||||
|
||||
return vgmstream;
|
||||
|
||||
/* clean up anything we may have opened */
|
||||
fail:
|
||||
if (vgmstream) close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
@ -2125,8 +2125,8 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
|
||||
case meta_PC_IVAUD:
|
||||
snprintf(temp,TEMPSIZE,"assumed GTA IV Audio file by .ivaud extension");
|
||||
break;
|
||||
case meta_WII_WSD:
|
||||
snprintf(temp,TEMPSIZE,"Phantom Brave WSD Header");
|
||||
case meta_DSP_WII_WSD:
|
||||
snprintf(temp,TEMPSIZE,"Standard Nintendo DSP headers in .wsd");
|
||||
break;
|
||||
default:
|
||||
snprintf(temp,TEMPSIZE,"THEY SHOULD HAVE SENT A POET");
|
||||
|
@ -168,6 +168,7 @@ typedef enum {
|
||||
meta_DSP_AMTS, /* .amts */
|
||||
meta_DSP_WII_IDSP, /* .gcm with IDSP header */
|
||||
meta_DSP_WII_MUS, /* .mus */
|
||||
meta_DSP_WII_WSD, /* Phantom Brave (WII) */
|
||||
|
||||
/* Nintendo */
|
||||
meta_STRM, /* STRM */
|
||||
@ -381,7 +382,6 @@ typedef enum {
|
||||
meta_ZSD, /* Dragon Booster ZSD */
|
||||
meta_RedSpark, /* "RedSpark" RSD (MadWorld) */
|
||||
meta_PC_IVAUD, /* .ivaud GTA IV */
|
||||
meta_WII_WSD, /* Phantom Brave (WII) */
|
||||
} meta_t;
|
||||
|
||||
typedef struct {
|
||||
|
@ -168,6 +168,7 @@ gchar *vgmstream_exts [] = {
|
||||
"tk5",
|
||||
"zsd",
|
||||
"ivaud",
|
||||
"wsd",
|
||||
/* terminator */
|
||||
NULL
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user