mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-28 08:20:54 +01:00
SLI: ignore comments and cleanup
This commit is contained in:
parent
21f6696354
commit
6ea7e4a256
@ -3,51 +3,40 @@
|
|||||||
|
|
||||||
|
|
||||||
/* .sli+ogg/opus - KiriKiri engine / WaveLoopManager loop points loader [Fate/Stay Night (PC), World End Economica (PC)] */
|
/* .sli+ogg/opus - KiriKiri engine / WaveLoopManager loop points loader [Fate/Stay Night (PC), World End Economica (PC)] */
|
||||||
VGMSTREAM * init_vgmstream_sli_ogg(STREAMFILE *streamFile) {
|
VGMSTREAM* init_vgmstream_sli_ogg(STREAMFILE* sf) {
|
||||||
VGMSTREAM* vgmstream = NULL;
|
VGMSTREAM* vgmstream = NULL;
|
||||||
STREAMFILE * streamData = NULL;
|
STREAMFILE* sf_data = NULL;
|
||||||
int32_t loop_start = -1, loop_length = -1;
|
int32_t loop_start = -1, loop_length = -1;
|
||||||
int32_t loop_from = -1, loop_to = -1;
|
int32_t loop_from = -1, loop_to = -1;
|
||||||
|
|
||||||
/* checks */
|
/* checks */
|
||||||
if (!check_extensions(streamFile, "sli"))
|
if (!check_extensions(sf, "sli"))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
{
|
{
|
||||||
/* try with file.ogg/opus.sli=header and file.ogg/opus=data */
|
/* try with file.ogg/opus.sli=header and file.ogg/opus=data */
|
||||||
char basename[PATH_LIMIT];
|
char basename[PATH_LIMIT];
|
||||||
get_streamfile_basename(streamFile,basename,PATH_LIMIT);
|
get_streamfile_basename(sf,basename,PATH_LIMIT);
|
||||||
streamData = open_streamfile_by_filename(streamFile, basename);
|
sf_data = open_streamfile_by_filename(sf, basename);
|
||||||
if (!streamData) goto fail;
|
if (!sf_data) goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!is_id32be(0x00, sf_data, "OggS"))
|
||||||
|
goto fail;
|
||||||
|
|
||||||
/* let the real initer do the parsing */
|
/* let the real initer do the parsing */
|
||||||
if (check_extensions(streamData, "ogg")) { /* Fate/Stay Night (PC) */
|
if (is_id32be(0x1c, sf_data, "Opus")) { /* Sabbat of the Witch (PC) */
|
||||||
#ifdef VGM_USE_VORBIS
|
vgmstream = init_vgmstream_ogg_opus(sf_data);
|
||||||
vgmstream = init_vgmstream_ogg_vorbis(streamData);
|
if (!vgmstream) goto fail;
|
||||||
|
|
||||||
|
/* somehow sli+opus use 0 encoder delay in the OpusHead (to simplify looping?) */
|
||||||
|
vgmstream->meta_type = meta_OPUS_SLI;
|
||||||
|
}
|
||||||
|
else { /* Fate/Stay Night (PC) */
|
||||||
|
vgmstream = init_vgmstream_ogg_vorbis(sf_data);
|
||||||
if (!vgmstream) goto fail;
|
if (!vgmstream) goto fail;
|
||||||
|
|
||||||
vgmstream->meta_type = meta_OGG_SLI;
|
vgmstream->meta_type = meta_OGG_SLI;
|
||||||
#else
|
|
||||||
goto fail;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else if (check_extensions(streamData, "opus")) { /* Sabbat of the Witch (PC) */
|
|
||||||
#ifdef VGM_USE_FFMPEG
|
|
||||||
vgmstream = init_vgmstream_ffmpeg(streamData);
|
|
||||||
if (!vgmstream) goto fail;
|
|
||||||
|
|
||||||
/* FFmpeg's Opus encoder delay is borked but no need to fix:
|
|
||||||
* somehow sli+opus use 0 in the OpusHead (to simplify looping?) */
|
|
||||||
|
|
||||||
vgmstream->meta_type = meta_OPUS_SLI;
|
|
||||||
#else
|
|
||||||
goto fail;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
goto fail;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -59,11 +48,17 @@ VGMSTREAM * init_vgmstream_sli_ogg(STREAMFILE *streamFile) {
|
|||||||
int line_ok;
|
int line_ok;
|
||||||
|
|
||||||
sli_offset = 0;
|
sli_offset = 0;
|
||||||
while ((loop_start == -1 || loop_length == -1) && sli_offset < get_streamfile_size(streamFile)) {
|
while ((loop_start == -1 || loop_length == -1) && sli_offset < get_streamfile_size(sf)) {
|
||||||
char *endptr, *foundptr;
|
char *endptr, *foundptr;
|
||||||
|
|
||||||
bytes_read = read_line(line, sizeof(line), sli_offset, streamFile, &line_ok);
|
bytes_read = read_line(line, sizeof(line), sli_offset, sf, &line_ok);
|
||||||
if (!line_ok) goto fail;
|
if (!line_ok) goto fail;
|
||||||
|
sli_offset += bytes_read;
|
||||||
|
/* files may be padded with 0s */
|
||||||
|
|
||||||
|
/* comments in v2.0 [Sabbath of the Witch (PC), KARAKARA (PC)] */
|
||||||
|
if (line[0] == '#')
|
||||||
|
continue;
|
||||||
|
|
||||||
if (memcmp("LoopStart=", line,10) == 0 && line[10] != '\0') {
|
if (memcmp("LoopStart=", line,10) == 0 && line[10] != '\0') {
|
||||||
loop_start = strtol(line + 10, &endptr, 10);
|
loop_start = strtol(line + 10, &endptr, 10);
|
||||||
@ -78,7 +73,7 @@ VGMSTREAM * init_vgmstream_sli_ogg(STREAMFILE *streamFile) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* a completely different format (2.0?), also with .sli extension and can be handled similarly */
|
/* a completely different format ("#2.00"?), can be handled similarly */
|
||||||
if ((foundptr = strstr(line,"To=")) != NULL && isdigit(foundptr[3])) {
|
if ((foundptr = strstr(line,"To=")) != NULL && isdigit(foundptr[3])) {
|
||||||
loop_to = strtol(foundptr + 3, &endptr, 10);
|
loop_to = strtol(foundptr + 3, &endptr, 10);
|
||||||
if (*endptr != ';') {
|
if (*endptr != ';') {
|
||||||
@ -92,7 +87,6 @@ VGMSTREAM * init_vgmstream_sli_ogg(STREAMFILE *streamFile) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sli_offset += bytes_read;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,11 +100,11 @@ VGMSTREAM * init_vgmstream_sli_ogg(STREAMFILE *streamFile) {
|
|||||||
goto fail; /* if there's no loop points the .sli wasn't valid */
|
goto fail; /* if there's no loop points the .sli wasn't valid */
|
||||||
}
|
}
|
||||||
|
|
||||||
close_streamfile(streamData);
|
close_streamfile(sf_data);
|
||||||
return vgmstream;
|
return vgmstream;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
close_streamfile(streamData);
|
close_streamfile(sf_data);
|
||||||
close_vgmstream(vgmstream);
|
close_vgmstream(vgmstream);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,6 @@ VGMSTREAM* (*init_vgmstream_functions[])(STREAMFILE* sf) = {
|
|||||||
init_vgmstream_vpk,
|
init_vgmstream_vpk,
|
||||||
init_vgmstream_genh,
|
init_vgmstream_genh,
|
||||||
init_vgmstream_ogg_vorbis,
|
init_vgmstream_ogg_vorbis,
|
||||||
init_vgmstream_sli_ogg,
|
|
||||||
init_vgmstream_sfl_ogg,
|
init_vgmstream_sfl_ogg,
|
||||||
init_vgmstream_sadb,
|
init_vgmstream_sadb,
|
||||||
init_vgmstream_ps2_bmdx,
|
init_vgmstream_ps2_bmdx,
|
||||||
@ -529,6 +528,7 @@ VGMSTREAM* (*init_vgmstream_functions[])(STREAMFILE* sf) = {
|
|||||||
init_vgmstream_mic_koei,
|
init_vgmstream_mic_koei,
|
||||||
init_vgmstream_seb,
|
init_vgmstream_seb,
|
||||||
init_vgmstream_ps2_pnb,
|
init_vgmstream_ps2_pnb,
|
||||||
|
init_vgmstream_sli_ogg,
|
||||||
|
|
||||||
/* lowest priority metas (should go after all metas, and TXTH should go before raw formats) */
|
/* lowest priority metas (should go after all metas, and TXTH should go before raw formats) */
|
||||||
init_vgmstream_txth, /* proper parsers should supersede TXTH, once added */
|
init_vgmstream_txth, /* proper parsers should supersede TXTH, once added */
|
||||||
|
Loading…
Reference in New Issue
Block a user