Add .lse Ogg [Labyrinth of Refrain (PC)]

This commit is contained in:
bnnm 2018-09-27 23:41:26 +02:00
parent 5594f5068e
commit c0d484a715
3 changed files with 24 additions and 0 deletions

View File

@ -199,6 +199,7 @@ static const char* extension_list[] = {
"lpcm",
"lpk",
"lps",
"lse",
"lsf",
"lstm", //fake extension, for STMs
"lwav", //fake extension, for WAVs
@ -1095,6 +1096,7 @@ static const meta_info meta_info_list[] = {
{meta_NXA, "Entergram NXA header"},
{meta_ADPCM_CAPCOM, "Capcom .ADPCM header"},
{meta_UE4OPUS, "Epic Games UE4OPUS header"},
{meta_OGG_LSE, "Ogg Vorbis (LSE header)"},
};

View File

@ -247,6 +247,18 @@ static void mus_ogg_decryption_callback(void *ptr, size_t size, size_t nmemb, vo
}
}
static void lse_ogg_decryption_callback(void *ptr, size_t size, size_t nmemb, void *datasource) {
size_t bytes_read = size*nmemb;
ogg_vorbis_streamfile * const ov_streamfile = datasource;
int i;
/* bytes are xor'd with variable key */
for (i = 0; i < bytes_read; i++) {
int key = 0xC2 + (ov_streamfile->offset + i) % 256;
((uint8_t*)ptr)[i] ^= key;
}
}
/* Ogg Vorbis, by way of libvorbisfile; may contain loop comments */
VGMSTREAM * init_vgmstream_ogg_vorbis(STREAMFILE *streamFile) {
@ -262,6 +274,7 @@ VGMSTREAM * init_vgmstream_ogg_vorbis(STREAMFILE *streamFile) {
int is_eno = 0;
int is_gwm = 0;
int is_mus = 0;
int is_lse = 0;
/* check extension */
@ -288,6 +301,8 @@ VGMSTREAM * init_vgmstream_ogg_vorbis(STREAMFILE *streamFile) {
is_gwm = 1;
} else if (check_extensions(streamFile,"mus")) { /* .mus: Redux - Dark Matters (PC) */
is_mus = 1;
} else if (check_extensions(streamFile,"lse")) { /* .lse: Labyrinth of Refrain: Coven of Dusk (PC) */
is_lse = 1;
} else {
goto fail;
}
@ -394,6 +409,12 @@ VGMSTREAM * init_vgmstream_ogg_vorbis(STREAMFILE *streamFile) {
ovmi.meta_type = meta_OGG_MUS;
}
/* check .lse [Labyrinth of Refrain: Coven of Dusk (PC)], encrypted */
if (is_lse) {
ovmi.decryption_callback = lse_ogg_decryption_callback;
ovmi.meta_type = meta_OGG_LSE;
}
return init_vgmstream_ogg_vorbis_callbacks(streamFile, NULL, start_offset, &ovmi);

View File

@ -706,6 +706,7 @@ typedef enum {
meta_NXA,
meta_ADPCM_CAPCOM,
meta_UE4OPUS,
meta_OGG_LSE,
} meta_t;