2008-07-14 13:02:39 +02:00
|
|
|
#include "meta.h"
|
|
|
|
#include "../util.h"
|
|
|
|
|
2008-10-20 20:06:35 +02:00
|
|
|
/* RSD */
|
|
|
|
/* RSD2VAG */
|
|
|
|
VGMSTREAM * init_vgmstream_rsd2vag(STREAMFILE *streamFile) {
|
2008-07-14 13:02:39 +02:00
|
|
|
VGMSTREAM * vgmstream = NULL;
|
|
|
|
char filename[260];
|
|
|
|
off_t start_offset;
|
2008-10-20 20:06:35 +02:00
|
|
|
|
|
|
|
int loop_flag;
|
2008-07-14 13:02:39 +02:00
|
|
|
int channel_count;
|
2008-10-20 20:06:35 +02:00
|
|
|
|
|
|
|
/* check extension, case insensitive */
|
2008-07-14 13:02:39 +02:00
|
|
|
streamFile->get_name(streamFile,filename,sizeof(filename));
|
|
|
|
if (strcasecmp("rsd",filename_extension(filename))) goto fail;
|
|
|
|
|
|
|
|
/* check header */
|
2008-10-20 20:06:35 +02:00
|
|
|
if (read_32bitBE(0x0,streamFile) != 0x52534432) /* RSD2 */
|
|
|
|
goto fail;
|
|
|
|
if (read_32bitBE(0x4,streamFile) != 0x56414720) /* VAG\0x20 */
|
2008-07-14 13:02:39 +02:00
|
|
|
goto fail;
|
|
|
|
|
2008-10-20 20:06:35 +02:00
|
|
|
loop_flag = 0;
|
|
|
|
channel_count = read_32bitLE(0x8,streamFile);
|
2008-07-14 13:02:39 +02:00
|
|
|
|
|
|
|
/* build the VGMSTREAM */
|
|
|
|
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
2008-10-20 20:06:35 +02:00
|
|
|
if (!vgmstream) goto fail;
|
2008-07-14 13:02:39 +02:00
|
|
|
|
2008-10-20 20:06:35 +02:00
|
|
|
/* fill in the vital statistics */
|
|
|
|
start_offset = 0x800;
|
|
|
|
vgmstream->channels = channel_count;
|
|
|
|
vgmstream->sample_rate = read_32bitLE(0x10,streamFile);
|
|
|
|
vgmstream->coding_type = coding_PSX;
|
|
|
|
vgmstream->num_samples = (get_streamfile_size(streamFile)-0x800)*28/16/channel_count;
|
|
|
|
if (loop_flag) {
|
|
|
|
vgmstream->loop_start_sample = loop_flag;
|
|
|
|
vgmstream->loop_end_sample = (get_streamfile_size(streamFile)-0x800)*28/16/channel_count;
|
|
|
|
}
|
2008-07-14 13:02:39 +02:00
|
|
|
|
2008-10-20 20:06:35 +02:00
|
|
|
vgmstream->layout_type = layout_interleave;
|
|
|
|
vgmstream->interleave_block_size = read_32bitLE(0x14,streamFile);
|
|
|
|
vgmstream->meta_type = meta_RSD2VAG;
|
2008-07-14 13:02:39 +02:00
|
|
|
|
2008-10-20 20:06:35 +02:00
|
|
|
/* open the file for reading */
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
STREAMFILE * file;
|
|
|
|
file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
|
|
|
|
if (!file) goto fail;
|
|
|
|
for (i=0;i<channel_count;i++) {
|
|
|
|
vgmstream->ch[i].streamfile = file;
|
|
|
|
|
|
|
|
vgmstream->ch[i].channel_start_offset=
|
|
|
|
vgmstream->ch[i].offset=start_offset+
|
|
|
|
vgmstream->interleave_block_size*i;
|
|
|
|
|
|
|
|
}
|
2008-07-14 13:02:39 +02:00
|
|
|
}
|
2008-07-25 19:49:09 +02:00
|
|
|
|
2008-10-20 20:06:35 +02:00
|
|
|
return vgmstream;
|
2008-10-17 22:35:24 +02:00
|
|
|
|
2008-10-20 20:06:35 +02:00
|
|
|
fail:
|
|
|
|
/* clean up anything we may have opened */
|
|
|
|
if (vgmstream) close_vgmstream(vgmstream);
|
|
|
|
return NULL;
|
|
|
|
}
|
2008-10-17 22:35:24 +02:00
|
|
|
|
2008-08-10 00:38:44 +02:00
|
|
|
|
2008-10-20 20:06:35 +02:00
|
|
|
/* RSD2XADP */
|
|
|
|
VGMSTREAM * init_vgmstream_rsd2xadp(STREAMFILE *streamFile) {
|
|
|
|
VGMSTREAM * vgmstream = NULL;
|
|
|
|
char filename[260];
|
|
|
|
off_t start_offset;
|
2008-07-29 15:07:10 +02:00
|
|
|
|
2008-10-20 20:06:35 +02:00
|
|
|
int loop_flag;
|
|
|
|
int channel_count;
|
2008-07-29 15:07:10 +02:00
|
|
|
|
2008-10-20 20:06:35 +02:00
|
|
|
/* check extension, case insensitive */
|
|
|
|
streamFile->get_name(streamFile,filename,sizeof(filename));
|
|
|
|
if (strcasecmp("rsd",filename_extension(filename))) goto fail;
|
2008-07-25 19:49:09 +02:00
|
|
|
|
2008-10-20 20:06:35 +02:00
|
|
|
/* check header */
|
|
|
|
if (read_32bitBE(0x0,streamFile) != 0x52534432) /* RSD2 */
|
|
|
|
goto fail;
|
|
|
|
if (read_32bitBE(0x4,streamFile) != 0x58414450) /* XADP */
|
|
|
|
goto fail;
|
2008-07-25 19:49:09 +02:00
|
|
|
|
2008-10-20 20:06:35 +02:00
|
|
|
loop_flag = 0;
|
|
|
|
channel_count = read_32bitLE(0x8,streamFile);
|
|
|
|
|
|
|
|
/* build the VGMSTREAM */
|
|
|
|
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
|
|
|
if (!vgmstream) goto fail;
|
2008-07-25 19:49:09 +02:00
|
|
|
|
2008-10-20 20:06:35 +02:00
|
|
|
/* fill in the vital statistics */
|
|
|
|
start_offset = read_32bitLE(0x18,streamFile); /* not sure about this */
|
2008-07-14 13:02:39 +02:00
|
|
|
vgmstream->channels = channel_count;
|
2008-10-20 20:06:35 +02:00
|
|
|
vgmstream->sample_rate = read_32bitLE(0x10,streamFile);
|
|
|
|
vgmstream->coding_type = coding_XBOX;
|
|
|
|
vgmstream->num_samples = (get_streamfile_size(streamFile)-start_offset)*64/36/channel_count;
|
|
|
|
if (loop_flag) {
|
|
|
|
vgmstream->loop_start_sample = loop_flag;
|
|
|
|
vgmstream->loop_end_sample = (get_streamfile_size(streamFile)-start_offset)*28/16/channel_count;
|
|
|
|
}
|
2008-07-14 13:02:39 +02:00
|
|
|
|
2008-10-20 20:06:35 +02:00
|
|
|
vgmstream->layout_type = layout_interleave;
|
|
|
|
vgmstream->interleave_block_size = 0x24;
|
|
|
|
vgmstream->meta_type = meta_RSD2XADP;
|
2008-08-10 00:38:44 +02:00
|
|
|
|
2008-07-14 13:02:39 +02:00
|
|
|
/* open the file for reading */
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
STREAMFILE * file;
|
|
|
|
file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
|
|
|
|
if (!file) goto fail;
|
|
|
|
for (i=0;i<channel_count;i++) {
|
|
|
|
vgmstream->ch[i].streamfile = file;
|
|
|
|
|
2008-10-17 22:35:24 +02:00
|
|
|
|
|
|
|
if (vgmstream->coding_type == coding_XBOX) {
|
2008-08-10 22:08:03 +02:00
|
|
|
vgmstream->layout_type=layout_none;
|
2008-08-10 00:38:44 +02:00
|
|
|
vgmstream->ch[i].channel_start_offset=start_offset;
|
|
|
|
} else {
|
|
|
|
vgmstream->ch[i].channel_start_offset=
|
|
|
|
start_offset+vgmstream->interleave_block_size*i;
|
|
|
|
}
|
|
|
|
vgmstream->ch[i].offset = vgmstream->ch[i].channel_start_offset;
|
2008-07-14 13:02:39 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2008-10-20 20:06:35 +02:00
|
|
|
|
|
|
|
return vgmstream;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
/* clean up anything we may have opened */
|
|
|
|
if (vgmstream) close_vgmstream(vgmstream);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* RSD4VAG */
|
|
|
|
VGMSTREAM * init_vgmstream_rsd4vag(STREAMFILE *streamFile) {
|
|
|
|
VGMSTREAM * vgmstream = NULL;
|
|
|
|
char filename[260];
|
|
|
|
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;
|
|
|
|
|
|
|
|
/* check header */
|
|
|
|
if (read_32bitBE(0x0,streamFile) != 0x52534434) /* RSD4 */
|
|
|
|
goto fail;
|
|
|
|
if (read_32bitBE(0x4,streamFile) != 0x56414720) /* VAG\0x20 */
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
loop_flag = 0;
|
|
|
|
channel_count = read_32bitLE(0x8,streamFile);
|
|
|
|
|
|
|
|
/* build the VGMSTREAM */
|
|
|
|
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
|
|
|
/* fill in the vital statistics */
|
|
|
|
start_offset = 0x800;
|
|
|
|
vgmstream->channels = channel_count;
|
|
|
|
vgmstream->sample_rate = read_32bitLE(0x10,streamFile);
|
|
|
|
vgmstream->coding_type = coding_PSX;
|
|
|
|
vgmstream->num_samples = (get_streamfile_size(streamFile)-0x800)*28/16/channel_count;
|
|
|
|
if (loop_flag) {
|
|
|
|
vgmstream->loop_start_sample = loop_flag;
|
|
|
|
vgmstream->loop_end_sample = (get_streamfile_size(streamFile)-0x800)*28/16/channel_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
vgmstream->layout_type = layout_interleave;
|
|
|
|
vgmstream->interleave_block_size = read_32bitLE(0xC,streamFile);
|
|
|
|
vgmstream->meta_type = meta_RSD4VAG;
|
|
|
|
|
|
|
|
/* open the file for reading */
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
STREAMFILE * file;
|
|
|
|
file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
|
|
|
|
if (!file) goto fail;
|
|
|
|
for (i=0;i<channel_count;i++) {
|
|
|
|
vgmstream->ch[i].streamfile = file;
|
|
|
|
|
|
|
|
vgmstream->ch[i].channel_start_offset=
|
|
|
|
vgmstream->ch[i].offset=start_offset+
|
|
|
|
vgmstream->interleave_block_size*i;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2008-07-14 13:02:39 +02:00
|
|
|
|
|
|
|
return vgmstream;
|
|
|
|
|
2008-10-20 20:06:35 +02:00
|
|
|
fail:
|
2008-07-14 13:02:39 +02:00
|
|
|
/* clean up anything we may have opened */
|
2008-10-20 20:06:35 +02:00
|
|
|
if (vgmstream) close_vgmstream(vgmstream);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* RSD4PCMB */
|
|
|
|
VGMSTREAM * init_vgmstream_rsd4pcmb(STREAMFILE *streamFile) {
|
|
|
|
VGMSTREAM * vgmstream = NULL;
|
|
|
|
char filename[260];
|
|
|
|
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;
|
|
|
|
|
|
|
|
/* check header */
|
|
|
|
if (read_32bitBE(0x0,streamFile) != 0x52534434) /* RSD4 */
|
|
|
|
goto fail;
|
|
|
|
if (read_32bitBE(0x4,streamFile) != 0x50434D42) /* PCMB */
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
loop_flag = 0;
|
|
|
|
channel_count = read_32bitLE(0x8,streamFile);
|
|
|
|
|
|
|
|
/* 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_32bitLE(0x10,streamFile);
|
|
|
|
vgmstream->coding_type = coding_PCM16BE;
|
|
|
|
vgmstream->num_samples = (get_streamfile_size(streamFile)-0x800)/2/channel_count;
|
|
|
|
if (loop_flag) {
|
|
|
|
vgmstream->loop_start_sample = loop_flag;
|
|
|
|
vgmstream->loop_end_sample = (get_streamfile_size(streamFile)-0x800)/2/channel_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
vgmstream->layout_type = layout_interleave;
|
|
|
|
vgmstream->interleave_block_size = 0x2;
|
|
|
|
vgmstream->meta_type = meta_RSD4PCMB;
|
|
|
|
|
|
|
|
/* open the file for reading */
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
STREAMFILE * file;
|
|
|
|
file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
|
|
|
|
if (!file) goto fail;
|
|
|
|
for (i=0;i<channel_count;i++) {
|
|
|
|
vgmstream->ch[i].streamfile = file;
|
|
|
|
|
|
|
|
vgmstream->ch[i].channel_start_offset=
|
|
|
|
vgmstream->ch[i].offset=start_offset+
|
|
|
|
vgmstream->interleave_block_size*i;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return vgmstream;
|
|
|
|
|
2008-07-14 13:02:39 +02:00
|
|
|
fail:
|
2008-10-20 20:06:35 +02:00
|
|
|
/* clean up anything we may have opened */
|
2008-07-14 13:02:39 +02:00
|
|
|
if (vgmstream) close_vgmstream(vgmstream);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-08-10 00:38:44 +02:00
|
|
|
|
2008-10-20 20:06:35 +02:00
|
|
|
|
|
|
|
/* RSD6VAG */
|
|
|
|
VGMSTREAM * init_vgmstream_rsd6vag(STREAMFILE *streamFile) {
|
|
|
|
VGMSTREAM * vgmstream = NULL;
|
|
|
|
char filename[260];
|
|
|
|
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;
|
|
|
|
|
|
|
|
/* check header */
|
|
|
|
if (read_32bitBE(0x0,streamFile) != 0x52534436) /* RSD6 */
|
|
|
|
goto fail;
|
|
|
|
if (read_32bitBE(0x4,streamFile) != 0x56414720) /* VAG\0x20 */
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
loop_flag = 0;
|
|
|
|
channel_count = read_32bitLE(0x8,streamFile);
|
|
|
|
|
|
|
|
/* build the VGMSTREAM */
|
|
|
|
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
|
|
|
/* fill in the vital statistics */
|
|
|
|
start_offset = 0x800;
|
|
|
|
vgmstream->channels = channel_count;
|
|
|
|
vgmstream->sample_rate = read_32bitLE(0x10,streamFile);
|
|
|
|
vgmstream->coding_type = coding_PSX;
|
|
|
|
vgmstream->num_samples = (get_streamfile_size(streamFile)-0x800)*28/16/channel_count;
|
|
|
|
if (loop_flag) {
|
|
|
|
vgmstream->loop_start_sample = loop_flag;
|
|
|
|
vgmstream->loop_end_sample = (get_streamfile_size(streamFile)-0x800)*28/16/channel_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
vgmstream->layout_type = layout_interleave;
|
|
|
|
vgmstream->interleave_block_size = read_32bitLE(0xC,streamFile);
|
|
|
|
vgmstream->meta_type = meta_RSD6VAG;
|
|
|
|
|
|
|
|
/* open the file for reading */
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
STREAMFILE * file;
|
|
|
|
file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
|
|
|
|
if (!file) goto fail;
|
|
|
|
for (i=0;i<channel_count;i++) {
|
|
|
|
vgmstream->ch[i].streamfile = file;
|
|
|
|
|
|
|
|
vgmstream->ch[i].channel_start_offset=
|
|
|
|
vgmstream->ch[i].offset=start_offset+
|
|
|
|
vgmstream->interleave_block_size*i;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return vgmstream;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
/* clean up anything we may have opened */
|
|
|
|
if (vgmstream) close_vgmstream(vgmstream);
|
|
|
|
return NULL;
|
|
|
|
}
|