mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-18 15:54:05 +01:00
add another style of .sli
git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@364 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
parent
9ae3307b15
commit
fc806393bc
@ -26,6 +26,8 @@ VGMSTREAM * init_vgmstream_sli_ogg(STREAMFILE *streamFile) {
|
||||
int done;
|
||||
int32_t loop_start = -1;
|
||||
int32_t loop_length = -1;
|
||||
int32_t loop_from = -1;
|
||||
int32_t loop_to = -1;
|
||||
|
||||
/* check extension, case insensitive */
|
||||
streamFile->get_name(streamFile,filename,sizeof(filename));
|
||||
@ -51,6 +53,7 @@ VGMSTREAM * init_vgmstream_sli_ogg(STREAMFILE *streamFile) {
|
||||
sli_offset = 0;
|
||||
while ((loop_start == -1 || loop_length == -1) && sli_offset < get_streamfile_size(streamFile)) {
|
||||
char *endptr;
|
||||
char *foundptr;
|
||||
bytes_read=get_streamfile_dos_line(sizeof(linebuffer),linebuffer,sli_offset,streamFile,&done);
|
||||
if (!done) goto fail;
|
||||
|
||||
@ -69,10 +72,25 @@ VGMSTREAM * init_vgmstream_sli_ogg(STREAMFILE *streamFile) {
|
||||
}
|
||||
}
|
||||
|
||||
/* a completely different format, also with .sli extension and can be handled similarly */
|
||||
if ((foundptr=strstr(linebuffer,"To="))!=NULL && isdigit(foundptr[3])) {
|
||||
loop_to = strtol(foundptr+3,&endptr,10);
|
||||
if (*endptr != ';') {
|
||||
loop_to = -1;
|
||||
}
|
||||
}
|
||||
if ((foundptr=strstr(linebuffer,"From="))!=NULL && isdigit(foundptr[5])) {
|
||||
loop_from = strtol(foundptr+5,&endptr,10);
|
||||
if (*endptr != ';') {
|
||||
loop_from = -1;
|
||||
}
|
||||
}
|
||||
|
||||
sli_offset += bytes_read;
|
||||
}
|
||||
|
||||
if (loop_start != -1 && loop_length != -1) {
|
||||
if ((loop_start != -1 && loop_length != -1) ||
|
||||
(loop_to != -1 && loop_from != -1)) {
|
||||
/* install loops */
|
||||
if (!vgmstream->loop_flag) {
|
||||
vgmstream->loop_flag = 1;
|
||||
@ -81,11 +99,16 @@ VGMSTREAM * init_vgmstream_sli_ogg(STREAMFILE *streamFile) {
|
||||
if (!vgmstream->loop_ch) goto fail;
|
||||
}
|
||||
|
||||
vgmstream->loop_start_sample = loop_start;
|
||||
vgmstream->loop_end_sample = loop_start+loop_length;
|
||||
}
|
||||
|
||||
vgmstream->meta_type = meta_OGG_SLI;
|
||||
if (loop_to != -1 && loop_from != -1) {
|
||||
vgmstream->loop_start_sample = loop_to;
|
||||
vgmstream->loop_end_sample = loop_from;
|
||||
vgmstream->meta_type = meta_OGG_SLI2;
|
||||
} else {
|
||||
vgmstream->loop_start_sample = loop_start;
|
||||
vgmstream->loop_end_sample = loop_start+loop_length;
|
||||
vgmstream->meta_type = meta_OGG_SLI;
|
||||
}
|
||||
} else goto fail; /* if there's no loop points the .sli wasn't valid */
|
||||
|
||||
return vgmstream;
|
||||
|
||||
|
@ -1253,7 +1253,10 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
|
||||
snprintf(temp,TEMPSIZE,"Ogg Vorbis");
|
||||
break;
|
||||
case meta_OGG_SLI:
|
||||
snprintf(temp,TEMPSIZE,"Ogg Vorbis with .sli for looping");
|
||||
snprintf(temp,TEMPSIZE,"Ogg Vorbis with .sli (start,length) for looping");
|
||||
break;
|
||||
case meta_OGG_SLI2:
|
||||
snprintf(temp,TEMPSIZE,"Ogg Vorbis with .sli (from,to) for looping");
|
||||
break;
|
||||
#endif
|
||||
case meta_DSP_SADB:
|
||||
|
@ -217,6 +217,7 @@ typedef enum {
|
||||
#ifdef VGM_USE_VORBIS
|
||||
meta_ogg_vorbis, /* ogg vorbis */
|
||||
meta_OGG_SLI, /* Ogg Vorbis file w/ companion .sli for looping */
|
||||
meta_OGG_SLI2, /* Ogg Vorbis file w/ different styled .sli for looping */
|
||||
#endif
|
||||
|
||||
meta_AIFC, /* Audio Interchange File Format AIFF-C */
|
||||
|
Loading…
x
Reference in New Issue
Block a user