mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-12-01 01:27:20 +01:00
PS2 VGS - Add simple loop searching. Not sure if I need to subtract 0x30 bytes header?
git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@880 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
parent
3ea0cd0cae
commit
2f61f9c58a
@ -5,8 +5,15 @@
|
|||||||
VGMSTREAM * init_vgmstream_ps2_vgs(STREAMFILE *streamFile) {
|
VGMSTREAM * init_vgmstream_ps2_vgs(STREAMFILE *streamFile) {
|
||||||
VGMSTREAM * vgmstream = NULL;
|
VGMSTREAM * vgmstream = NULL;
|
||||||
char filename[260];
|
char filename[260];
|
||||||
off_t start_offset;
|
|
||||||
int loop_flag = 0;
|
size_t fileLength;
|
||||||
|
off_t readOffset = 0;
|
||||||
|
off_t start_offset;
|
||||||
|
off_t loop_start_offset;
|
||||||
|
off_t loop_end_offset;
|
||||||
|
|
||||||
|
uint8_t testBuffer[0x10];
|
||||||
|
int loop_flag = 0;
|
||||||
int channel_count;
|
int channel_count;
|
||||||
|
|
||||||
/* check extension, case insensitive */
|
/* check extension, case insensitive */
|
||||||
@ -14,12 +21,56 @@ VGMSTREAM * init_vgmstream_ps2_vgs(STREAMFILE *streamFile) {
|
|||||||
if (strcasecmp("vgs",filename_extension(filename))) goto fail;
|
if (strcasecmp("vgs",filename_extension(filename))) goto fail;
|
||||||
|
|
||||||
/* check header */
|
/* check header */
|
||||||
|
|
||||||
/* Look if there's more than 1 one file... */
|
|
||||||
if (read_32bitBE(0x00,streamFile) != 0x56475300)
|
if (read_32bitBE(0x00,streamFile) != 0x56475300)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
loop_flag = 0;
|
// get file length
|
||||||
|
fileLength = get_streamfile_size(streamFile);
|
||||||
|
|
||||||
|
// Find loop start
|
||||||
|
do {
|
||||||
|
readOffset += (off_t)read_streamfile(testBuffer, readOffset, 0x10, streamFile);
|
||||||
|
|
||||||
|
// Loop Start ...
|
||||||
|
if(testBuffer[0x01] == 0x06)
|
||||||
|
{
|
||||||
|
loop_start_offset = readOffset - 0x10;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
} while (streamFile->get_offset(streamFile)<((int32_t)fileLength));
|
||||||
|
|
||||||
|
// start at last line of file and move up
|
||||||
|
readOffset = (int32_t)fileLength - 0x10;
|
||||||
|
|
||||||
|
// Find loop end
|
||||||
|
do {
|
||||||
|
readOffset -= (off_t)read_streamfile(testBuffer, readOffset, 0x10, streamFile);
|
||||||
|
|
||||||
|
// Loop End ...
|
||||||
|
if((testBuffer[0x01]==0x03) && (testBuffer[0x03]!=0x77))
|
||||||
|
{
|
||||||
|
loop_end_offset = readOffset + 0x20;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} while (readOffset > 0);
|
||||||
|
|
||||||
|
// setup loops
|
||||||
|
if (loop_start_offset > 0)
|
||||||
|
{
|
||||||
|
loop_flag = 1;
|
||||||
|
|
||||||
|
// if we have a start loop, use EOF if end loop is not found
|
||||||
|
if (loop_end_offset == 0)
|
||||||
|
{
|
||||||
|
loop_end_offset = (int32_t)fileLength - 0x10;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
loop_flag = 0;
|
||||||
|
}
|
||||||
|
|
||||||
channel_count = 2;
|
channel_count = 2;
|
||||||
|
|
||||||
/* build the VGMSTREAM */
|
/* build the VGMSTREAM */
|
||||||
@ -32,10 +83,12 @@ VGMSTREAM * init_vgmstream_ps2_vgs(STREAMFILE *streamFile) {
|
|||||||
vgmstream->sample_rate = read_32bitBE(0x10,streamFile);
|
vgmstream->sample_rate = read_32bitBE(0x10,streamFile);
|
||||||
vgmstream->coding_type = coding_PSX;
|
vgmstream->coding_type = coding_PSX;
|
||||||
vgmstream->num_samples = ((get_streamfile_size(streamFile)-0x30)/16/channel_count*28);
|
vgmstream->num_samples = ((get_streamfile_size(streamFile)-0x30)/16/channel_count*28);
|
||||||
// if (loop_flag) {
|
|
||||||
// vgmstream->loop_start_sample = 0;
|
if (loop_flag)
|
||||||
// vgmstream->loop_end_sample = (read_32bitLE(0x08,streamFile))/channel_count/32*28;
|
{
|
||||||
//}
|
vgmstream->loop_start_sample = loop_start_offset/16/channel_count*28;
|
||||||
|
vgmstream->loop_end_sample = loop_end_offset/16/channel_count*28;
|
||||||
|
}
|
||||||
|
|
||||||
vgmstream->layout_type = layout_interleave;
|
vgmstream->layout_type = layout_interleave;
|
||||||
vgmstream->interleave_block_size = read_32bitBE(0x04,streamFile)*0x1000;
|
vgmstream->interleave_block_size = read_32bitBE(0x04,streamFile)*0x1000;
|
||||||
|
Loading…
Reference in New Issue
Block a user