mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-15 02:57:38 +01:00
Improved EA videos support
This commit is contained in:
parent
b3bf371129
commit
1f356cde5e
@ -136,6 +136,7 @@ static const char* extension_list[] = {
|
||||
"data",
|
||||
"dax",
|
||||
"dbm",
|
||||
"dct",
|
||||
"dcs",
|
||||
"ddsp",
|
||||
"de2",
|
||||
@ -274,6 +275,7 @@ static const char* extension_list[] = {
|
||||
"lwma", //fake extension for .wma, FFmpeg/not parsed
|
||||
|
||||
"mab",
|
||||
"mad",
|
||||
"map",
|
||||
"matx",
|
||||
"mc3",
|
||||
|
@ -6,89 +6,81 @@
|
||||
void block_update_ea_1snh(off_t block_offset, VGMSTREAM * vgmstream) {
|
||||
STREAMFILE* streamFile = vgmstream->ch[0].streamfile;
|
||||
int i;
|
||||
size_t block_size = 0, block_header = 0;
|
||||
uint32_t block_id;
|
||||
size_t block_size = 0, block_header = 0, audio_size = 0;
|
||||
int32_t (*read_32bit)(off_t,STREAMFILE*) = vgmstream->codec_endian ? read_32bitBE : read_32bitLE;
|
||||
size_t file_size = get_streamfile_size(streamFile);
|
||||
|
||||
|
||||
/* EOF reads: signal we have nothing and let the layout fail */
|
||||
if (block_offset >= file_size) {
|
||||
if (block_offset >= get_streamfile_size(streamFile)) {
|
||||
vgmstream->current_block_offset = block_offset;
|
||||
vgmstream->next_block_offset = block_offset;
|
||||
vgmstream->current_block_samples = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
block_id = read_32bitBE(block_offset + 0x00, streamFile);
|
||||
|
||||
while (block_offset < file_size) {
|
||||
uint32_t id = read_32bitBE(block_offset+0x00,streamFile);
|
||||
/* BE in SAT, but one file may have both BE and LE chunks [FIFA 98 (SAT): movie LE, audio BE] */
|
||||
if (guess_endianness32bit(block_offset + 0x04, streamFile))
|
||||
block_size = read_32bitBE(block_offset + 0x04, streamFile);
|
||||
else
|
||||
block_size = read_32bitLE(block_offset + 0x04, streamFile);
|
||||
|
||||
/* BE in SAT, but one file may have both BE and LE chunks [FIFA 98 (SAT): movie LE, audio BE] */
|
||||
if (guess_endianness32bit(block_offset+0x04,streamFile))
|
||||
block_size = read_32bitBE(block_offset+0x04,streamFile);
|
||||
else
|
||||
block_size = read_32bitLE(block_offset+0x04,streamFile);
|
||||
block_header = 0;
|
||||
|
||||
block_header = 0;
|
||||
if (block_id == 0x31534E68 || block_id == 0x53454144) { /* "1SNh" "SEAD" audio header */
|
||||
int is_sead = (block_id == 0x53454144);
|
||||
int is_eacs = read_32bitBE(block_offset + 0x08, streamFile) == 0x45414353;
|
||||
int is_zero = read_32bitBE(block_offset + 0x08, streamFile) == 0x00;
|
||||
|
||||
if (id == 0x31534E68 || id == 0x53454144) { /* "1SNh" "SEAD" audio header */
|
||||
int is_sead = (id == 0x53454144);
|
||||
int is_eacs = read_32bitBE(block_offset+0x08, streamFile) == 0x45414353;
|
||||
|
||||
block_header = is_eacs ? 0x28 : (is_sead ? 0x14 : 0x2c);
|
||||
if (block_header >= block_size) /* sometimes has audio data after header */
|
||||
block_header = 0;
|
||||
}
|
||||
else if (id == 0x31534E64 || id == 0x534E4443) { /* "1SNd" "SNDC" audio data */
|
||||
block_header = 0x08;
|
||||
}
|
||||
else if (id == 0x00000000 || id == 0xFFFFFFFF || id == 0x31534E65) { /* EOF or "1SNe" */
|
||||
vgmstream->current_block_samples = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (block_header) {
|
||||
break;
|
||||
}
|
||||
|
||||
block_offset += block_size;
|
||||
block_header = (is_eacs || is_zero) ? 0x28 : (is_sead ? 0x14 : 0x2c);
|
||||
if (block_header >= block_size) /* sometimes has audio data after header */
|
||||
block_header = 0;
|
||||
} else if (block_id == 0x31534E64 || block_id == 0x534E4443) { /* "1SNd" "SNDC" audio data */
|
||||
block_header = 0x08;
|
||||
} else if (block_id == 0x00000000 || block_id == 0xFFFFFFFF || block_id == 0x31534E65) { /* EOF or "1SNe" */
|
||||
vgmstream->current_block_samples = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
vgmstream->current_block_offset = block_offset;
|
||||
vgmstream->next_block_offset = block_offset + block_size;
|
||||
vgmstream->current_block_size = block_size - block_header;
|
||||
if (vgmstream->current_block_samples == -1)
|
||||
if (block_header == 0) {
|
||||
/* no audio data, skip this block */
|
||||
vgmstream->current_block_samples = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
audio_size = block_size - block_header;
|
||||
|
||||
/* set new channel offsets and block sizes */
|
||||
switch(vgmstream->coding_type) {
|
||||
case coding_PCM8_int:
|
||||
case coding_ULAW_int:
|
||||
vgmstream->current_block_size /= vgmstream->channels;
|
||||
vgmstream->current_block_samples = pcm_bytes_to_samples(audio_size, vgmstream->channels, 8);
|
||||
for (i=0;i<vgmstream->channels;i++) {
|
||||
vgmstream->ch[i].offset = block_offset + block_header + i;
|
||||
}
|
||||
break;
|
||||
|
||||
case coding_PCM16_int:
|
||||
vgmstream->current_block_size /= vgmstream->channels;
|
||||
vgmstream->current_block_samples = pcm_bytes_to_samples(audio_size, vgmstream->channels, 16);
|
||||
for (i=0;i<vgmstream->channels;i++) {
|
||||
vgmstream->ch[i].offset = block_offset + block_header + (i*2);
|
||||
}
|
||||
break;
|
||||
|
||||
case coding_PSX:
|
||||
vgmstream->current_block_size /= vgmstream->channels;
|
||||
vgmstream->current_block_samples = ps_bytes_to_samples(audio_size, vgmstream->channels);
|
||||
for (i=0;i<vgmstream->channels;i++) {
|
||||
vgmstream->ch[i].offset = block_offset + block_header + i*vgmstream->current_block_size;
|
||||
vgmstream->ch[i].offset = block_offset + block_header + i*(audio_size/vgmstream->channels);
|
||||
}
|
||||
break;
|
||||
|
||||
case coding_DVI_IMA:
|
||||
if (vgmstream->codec_config == 1) { /* ADPCM hist */
|
||||
vgmstream->current_block_samples = read_32bit(block_offset + block_header, streamFile);
|
||||
vgmstream->current_block_size = 0; // - (0x04 + 0x08*vgmstream->channels); /* should be equivalent */
|
||||
|
||||
for(i = 0; i < vgmstream->channels; i++) {
|
||||
off_t adpcm_offset = block_offset + block_header + 0x04;
|
||||
@ -101,6 +93,7 @@ void block_update_ea_1snh(off_t block_offset, VGMSTREAM * vgmstream) {
|
||||
// "EA 1SHN blocked: different expected vs block num samples at %lx\n", block_offset);
|
||||
}
|
||||
else {
|
||||
vgmstream->current_block_samples = ima_bytes_to_samples(audio_size, vgmstream->channels);
|
||||
for(i = 0; i < vgmstream->channels; i++) {
|
||||
vgmstream->ch[i].offset = block_offset + block_header;
|
||||
}
|
||||
|
@ -30,13 +30,13 @@ typedef struct {
|
||||
static int parse_header(STREAMFILE* streamFile, ea_header* ea, off_t begin_offset);
|
||||
static VGMSTREAM * init_vgmstream_main(STREAMFILE *streamFile, ea_header* ea);
|
||||
|
||||
static void set_ea_1snh_num_samples(STREAMFILE* streamFile, off_t start_offset, ea_header* ea);
|
||||
static void set_ea_1snh_num_samples(VGMSTREAM *vgmstream, STREAMFILE *streamFile, ea_header *ea, int find_loop);
|
||||
static int get_ea_1snh_ima_version(STREAMFILE* streamFile, off_t start_offset, const ea_header* ea);
|
||||
|
||||
/* EA 1SNh - from early EA games, stream (~1996, ex. Need for Speed) */
|
||||
VGMSTREAM * init_vgmstream_ea_1snh(STREAMFILE *streamFile) {
|
||||
ea_header ea = {0};
|
||||
off_t eacs_offset;
|
||||
ea_header ea = { 0 };
|
||||
off_t offset, eacs_offset;
|
||||
|
||||
|
||||
/* checks */
|
||||
@ -44,24 +44,35 @@ VGMSTREAM * init_vgmstream_ea_1snh(STREAMFILE *streamFile) {
|
||||
* .lasf: fake for plugins
|
||||
* .cnk: some PS games
|
||||
* .sng: fake for plugins (to mimic EA SCHl's common extension)
|
||||
* .uv/tgq: some SAT games (video only?) */
|
||||
if (!check_extensions(streamFile,"asf,lasf,as4,cnk,sng,uv,tgq"))
|
||||
* .uv/tgq: some SAT games (video only?)
|
||||
* .tgv: videos
|
||||
* (extensionless): Need for Speed (SAT) (videos) */
|
||||
if (!check_extensions(streamFile, "asf,lasf,as4,cnk,sng,uv,tgq,tgv,"))
|
||||
goto fail;
|
||||
|
||||
if (read_32bitBE(0x00,streamFile) != 0x31534E68 && /* "1SNh" */
|
||||
read_32bitBE(0x00,streamFile) != 0x53454144) /* "SEAD" */
|
||||
offset = 0x00;
|
||||
|
||||
/* in videos, either TGVk or 1SNh block comes first */
|
||||
if (read_32bitBE(0x00, streamFile) == 0x5447566B) { /* "TGVk" */
|
||||
offset = read_32bitBE(0x04, streamFile);
|
||||
} else if (read_32bitLE(0x00, streamFile) == 0x5447566B) { /* "kVGT" */
|
||||
offset = read_32bitLE(0x04, streamFile);
|
||||
}
|
||||
|
||||
if (read_32bitBE(offset + 0x00, streamFile) != 0x31534E68 && /* "1SNh" */
|
||||
read_32bitBE(offset + 0x00, streamFile) != 0x53454144) /* "SEAD" */
|
||||
goto fail;
|
||||
|
||||
/* stream is divided into blocks/chunks: 1SNh=audio header, 1SNd=data xN, 1SNl=loop end, 1SNe=end.
|
||||
* Video uses various blocks (kVGT/fVGT/etc) and sometimes alt audio blocks (SEAD/SNDC/SEND). */
|
||||
ea.is_sead = read_32bitBE(0x00,streamFile) == 0x53454144;
|
||||
* Video uses various blocks (TGVk/TGVf/etc) and sometimes alt audio blocks (SEAD/SNDC/SEND). */
|
||||
ea.is_sead = read_32bitBE(offset + 0x00, streamFile) == 0x53454144;
|
||||
|
||||
/* use block size as endian marker (Saturn = BE) */
|
||||
ea.big_endian = guess_endianness32bit(0x04,streamFile);
|
||||
ea.big_endian = guess_endianness32bit(offset + 0x04, streamFile);
|
||||
|
||||
eacs_offset = 0x08; /* after 1SNh block id+size */
|
||||
eacs_offset = offset + 0x08; /* after 1SNh block id+size */
|
||||
|
||||
if (!parse_header(streamFile,&ea, eacs_offset))
|
||||
if (!parse_header(streamFile, &ea, eacs_offset))
|
||||
goto fail;
|
||||
return init_vgmstream_main(streamFile, &ea);
|
||||
|
||||
@ -113,6 +124,8 @@ VGMSTREAM * init_vgmstream_ea_eacs(STREAMFILE *streamFile) {
|
||||
if (ea.total_subsongs == target_subsong) {
|
||||
/* 0x00: some id or flags? */
|
||||
eacs_offset = read_32bitLE(bank_offset + 0x04, streamFile);
|
||||
if (read_32bitBE(eacs_offset, streamFile) != 0x45414353)
|
||||
goto fail;
|
||||
/* rest: not sure if part of this header */
|
||||
}
|
||||
}
|
||||
@ -176,9 +189,14 @@ static VGMSTREAM * init_vgmstream_main(STREAMFILE *streamFile, ea_header* ea) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
||||
if (!vgmstream_open_stream(vgmstream,streamFile,ea->data_offset))
|
||||
goto fail;
|
||||
|
||||
if (ea->num_samples == 0) {
|
||||
/* header does not specify number of samples, need to calculate it manually */
|
||||
set_ea_1snh_num_samples(vgmstream, streamFile, ea, 0);
|
||||
}
|
||||
|
||||
return vgmstream;
|
||||
|
||||
fail:
|
||||
@ -187,10 +205,13 @@ fail:
|
||||
}
|
||||
|
||||
static int parse_header(STREAMFILE* streamFile, ea_header* ea, off_t offset) {
|
||||
int32_t (*read_32bit)(off_t,STREAMFILE*) = ea->big_endian ? read_32bitBE : read_32bitLE;
|
||||
/* audio header is always little endian in early games, use sample rate for detection */
|
||||
int32_t (*read_32bit)(off_t,STREAMFILE*);
|
||||
|
||||
if (read_32bitBE(offset+0x00, streamFile) == 0x45414353) { /* "EACS" */
|
||||
/* EACS subheader (PC, SAT) */
|
||||
read_32bit = guess_endianness32bit(offset + 0x04, streamFile) ? read_32bitBE : read_32bitLE;
|
||||
|
||||
ea->sample_rate = read_32bit(offset+0x04, streamFile);
|
||||
ea->bits = read_8bit(offset+0x08, streamFile);
|
||||
ea->channels = read_8bit(offset+0x09, streamFile);
|
||||
@ -210,26 +231,35 @@ static int parse_header(STREAMFILE* streamFile, ea_header* ea, off_t offset) {
|
||||
}
|
||||
else if (ea->is_sead) {
|
||||
/* alt subheader (found in some PC videos) */
|
||||
read_32bit = guess_endianness32bit(offset + 0x00, streamFile) ? read_32bitBE : read_32bitLE;
|
||||
|
||||
ea->sample_rate = read_32bit(offset+0x00, streamFile);
|
||||
ea->channels = read_32bit(offset+0x04, streamFile);
|
||||
ea->codec = read_32bit(offset+0x08, streamFile);
|
||||
|
||||
if (ea->codec == EA_CODEC_IMA)
|
||||
ea->codec_config = get_ea_1snh_ima_version(streamFile, 0x00, ea);
|
||||
}
|
||||
else if (read_32bitBE(offset + 0x00, streamFile) == 0x00) {
|
||||
/* found in early videos, similar to EACS */
|
||||
read_32bit = guess_endianness32bit(offset + 0x04, streamFile) ? read_32bitBE : read_32bitLE;
|
||||
|
||||
set_ea_1snh_num_samples(streamFile, 0x00, ea);
|
||||
if (ea->loop_start_offset) /* offset found, now find actual start sample */
|
||||
set_ea_1snh_num_samples(streamFile, 0x00, ea);
|
||||
ea->sample_rate = read_32bit(offset + 0x04, streamFile);
|
||||
ea->bits = read_8bit(offset + 0x08, streamFile);
|
||||
ea->channels = read_8bit(offset + 0x09, streamFile);
|
||||
ea->codec = read_8bit(offset + 0x0a, streamFile);
|
||||
ea->type = read_8bit(offset + 0x0b, streamFile); /* block type? 0=1SNh, -1=bank */
|
||||
|
||||
if (ea->codec == EA_CODEC_IMA)
|
||||
ea->codec_config = get_ea_1snh_ima_version(streamFile, 0x00, ea);
|
||||
}
|
||||
else {
|
||||
/* alt subheader (PS) */
|
||||
read_32bit = guess_endianness32bit(offset + 0x00, streamFile) ? read_32bitBE : read_32bitLE;
|
||||
|
||||
ea->sample_rate = read_32bit(offset+0x00, streamFile);
|
||||
ea->channels = read_8bit(offset+0x18, streamFile);
|
||||
ea->codec = EA_CODEC_PSX;
|
||||
|
||||
set_ea_1snh_num_samples(streamFile, 0x00, ea);
|
||||
if (ea->loop_start_offset) /* offset found, now find actual start sample */
|
||||
set_ea_1snh_num_samples(streamFile, 0x00, ea);
|
||||
}
|
||||
|
||||
ea->loop_flag = (ea->loop_end > 0);
|
||||
@ -238,69 +268,45 @@ static int parse_header(STREAMFILE* streamFile, ea_header* ea, off_t offset) {
|
||||
}
|
||||
|
||||
/* get total samples by parsing block headers, needed when EACS isn't present */
|
||||
static void set_ea_1snh_num_samples(STREAMFILE* streamFile, off_t start_offset, ea_header* ea) {
|
||||
int num_samples = 0, loop_start = 0, loop_end = 0, loop_start_offset = 0;
|
||||
off_t block_offset = start_offset;
|
||||
size_t block_size, block_header, block_samples;
|
||||
int32_t (*read_32bit)(off_t,STREAMFILE*) = ea->big_endian ? read_32bitBE : read_32bitLE;
|
||||
size_t file_size = get_streamfile_size(streamFile);
|
||||
static void set_ea_1snh_num_samples(VGMSTREAM *vgmstream, STREAMFILE *streamFile, ea_header *ea, int find_loop) {
|
||||
int32_t num_samples = 0, block_id;
|
||||
size_t file_size;
|
||||
int32_t(*read_32bit)(off_t, STREAMFILE *) = ea->big_endian ? read_32bitBE : read_32bitLE;
|
||||
int loop_end_found = 0;
|
||||
|
||||
file_size = get_streamfile_size(streamFile);
|
||||
vgmstream->next_block_offset = ea->data_offset;
|
||||
|
||||
while (block_offset < file_size) {
|
||||
uint32_t id = read_32bitBE(block_offset+0x00,streamFile);
|
||||
block_size = read_32bit(block_offset+0x04,streamFile);
|
||||
block_header = 0;
|
||||
block_samples = 0;
|
||||
while (vgmstream->next_block_offset < file_size) {
|
||||
block_update_ea_1snh(vgmstream->next_block_offset, vgmstream);
|
||||
block_id = read_32bit(vgmstream->current_block_offset, streamFile);
|
||||
|
||||
if (id == 0x31534E68 || id == 0x53454144) { /* "1SNh" "SEAD" audio header */
|
||||
int is_sead = (id == 0x53454144);
|
||||
int is_eacs = read_32bitBE(block_offset+0x08, streamFile) == 0x45414353;
|
||||
|
||||
block_header = is_eacs ? 0x28 : (is_sead ? 0x14 : 0x2c);
|
||||
if (block_header >= block_size) /* sometimes has audio data after header */
|
||||
block_header = 0;
|
||||
}
|
||||
else if (id == 0x31534E64 || id == 0x534E4443) { /* "1SNd" "SNDC" audio data */
|
||||
block_header = 0x08;
|
||||
}
|
||||
else if (id == 0x00000000 || id == 0xFFFFFFFF || id == 0x31534E65) { /* EOF or "1SNe" */
|
||||
break;
|
||||
}
|
||||
else if (id == 0x31534E6C) { /* "1SNl" loop point found */
|
||||
loop_start_offset = read_32bit(block_offset+0x08,streamFile);
|
||||
loop_end = num_samples;
|
||||
}
|
||||
|
||||
if (block_header) {
|
||||
switch(ea->codec) {
|
||||
case EA_CODEC_PSX:
|
||||
block_samples = ps_bytes_to_samples(block_size - block_header, ea->channels);
|
||||
break;
|
||||
case EA_CODEC_IMA:
|
||||
if (ea->codec_config == 1)
|
||||
block_samples = read_32bit(block_offset + block_header, streamFile);
|
||||
else
|
||||
block_samples = ima_bytes_to_samples(block_size - block_header, ea->channels);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* if there is a loop start offset set, this was called again just to find it */
|
||||
if (ea->loop_start_offset && ea->loop_start_offset == block_offset) {
|
||||
ea->loop_start = num_samples;
|
||||
if (find_loop && vgmstream->current_block_offset == ea->loop_start_offset) {
|
||||
vgmstream->loop_start_sample = num_samples;
|
||||
vgmstream->loop_end_sample = ea->loop_end;
|
||||
return;
|
||||
}
|
||||
|
||||
num_samples += block_samples;
|
||||
block_offset += block_size;
|
||||
if (block_id == 0x00000000 || block_id == 0xFFFFFFFF || block_id == 0x31534E65) { /* EOF or "1SNe" */
|
||||
break;
|
||||
} else if (!find_loop && block_id == 0x31534E6C) { /* "1SNl" loop point found */
|
||||
ea->loop_start_offset = read_32bit(vgmstream->current_block_offset + 0x08, streamFile);
|
||||
ea->loop_end = num_samples;
|
||||
loop_end_found = 1;
|
||||
}
|
||||
|
||||
num_samples += vgmstream->current_block_samples;
|
||||
}
|
||||
|
||||
vgmstream->num_samples = num_samples;
|
||||
|
||||
ea->num_samples = num_samples;
|
||||
ea->loop_start = loop_start;
|
||||
ea->loop_end = loop_end;
|
||||
ea->loop_start_offset = loop_start_offset;
|
||||
/* reset once we're done */
|
||||
block_update_ea_1snh(ea->data_offset, vgmstream);
|
||||
|
||||
if (loop_end_found) {
|
||||
/* recurse to find loop start sample */
|
||||
set_ea_1snh_num_samples(vgmstream, streamFile, ea, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/* find codec version used, with or without ADPCM hist per block */
|
||||
@ -311,10 +317,13 @@ static int get_ea_1snh_ima_version(STREAMFILE* streamFile, off_t start_offset, c
|
||||
|
||||
while (block_offset < file_size) {
|
||||
uint32_t id = read_32bitBE(block_offset+0x00,streamFile);
|
||||
size_t block_size;
|
||||
|
||||
size_t block_size = read_32bitLE(block_offset+0x04,streamFile);
|
||||
if (block_size > 0x00F00000) /* BE in SAT, but one file may have both BE and LE chunks */
|
||||
block_size = read_32bitBE(block_offset+0x04,streamFile);
|
||||
/* BE in SAT, but one file may have both BE and LE chunks */
|
||||
if (guess_endianness32bit(block_offset + 0x04, streamFile))
|
||||
block_size = read_32bitBE(block_offset + 0x04, streamFile);
|
||||
else
|
||||
block_size = read_32bitLE(block_offset + 0x04, streamFile);
|
||||
|
||||
if (id == 0x31534E64 || id == 0x534E4443) { /* "1SNd" "SNDC" audio data */
|
||||
size_t ima_samples = read_32bit(block_offset + 0x08, streamFile);
|
||||
|
@ -173,13 +173,25 @@ VGMSTREAM * init_vgmstream_ea_schl_video(STREAMFILE *streamFile) {
|
||||
|
||||
|
||||
/* check extension */
|
||||
/* .vp6: ~late */
|
||||
if (!check_extensions(streamFile,"vp6"))
|
||||
goto fail;
|
||||
|
||||
/* check initial movie block id */
|
||||
if (read_32bitBE(0x00,streamFile) != 0x4D566864) /* "MVhd" */
|
||||
/* .uv: early */
|
||||
/* .dct: early-mid [ex. Need for Speed II SE (PC), FIFA 98 (PC)] */
|
||||
/* .mad: mid */
|
||||
/* .vp6: late */
|
||||
if (check_extensions(streamFile, "vp6")) {
|
||||
/* check initial movie block id */
|
||||
if (read_32bitBE(0x00, streamFile) != 0x4D566864) /* "MVhd" */
|
||||
goto fail;
|
||||
} else if (check_extensions(streamFile, "uv,dct")) {
|
||||
/* starts with audio header block */
|
||||
if (read_32bitBE(0x00, streamFile) != EA_BLOCKID_HEADER) /* "SCHl" */
|
||||
goto fail;
|
||||
} else if (check_extensions(streamFile, "mad")) {
|
||||
/* check initial movie block id */
|
||||
if (read_32bitBE(0x00, streamFile) != 0x4D41446B) /* "MADk" */
|
||||
goto fail;
|
||||
} else {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* use block size to check endianness */
|
||||
if (guess_endianness32bit(0x04, streamFile)) {
|
||||
@ -208,7 +220,7 @@ VGMSTREAM * init_vgmstream_ea_schl_video(STREAMFILE *streamFile) {
|
||||
offset += block_size;
|
||||
}
|
||||
|
||||
if (start_offset == 0)
|
||||
if (offset >= get_streamfile_size(streamFile))
|
||||
goto fail;
|
||||
|
||||
/* find target subsong (one per each SHxx multilang block) */
|
||||
@ -1654,7 +1666,7 @@ static void update_ea_stream_size_and_samples(STREAMFILE* streamFile, off_t star
|
||||
}
|
||||
|
||||
/* manually read totals */
|
||||
block_update(start_offset, vgmstream);
|
||||
vgmstream->next_block_offset = start_offset;
|
||||
while (vgmstream->next_block_offset < file_size) {
|
||||
block_update_ea_schl(vgmstream->next_block_offset, vgmstream);
|
||||
if (vgmstream->current_block_samples < 0)
|
||||
@ -1682,7 +1694,7 @@ static void update_ea_stream_size_and_samples(STREAMFILE* streamFile, off_t star
|
||||
}
|
||||
|
||||
/* reset once we're done */
|
||||
block_update(start_offset, vgmstream);
|
||||
block_update_ea_schl(start_offset, vgmstream);
|
||||
|
||||
/* only use calculated samples with multiple subfiles (rarely header samples may be less due to padding) */
|
||||
if (standalone && multiple_schl) {
|
||||
|
Loading…
Reference in New Issue
Block a user