mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-02-18 03:26:57 +01:00
Simplify block parsing by just having 0 samples on empty blocks
This commit is contained in:
parent
6f4388045e
commit
dd64be04dd
@ -6,37 +6,24 @@
|
||||
void block_update_ea_wve_ad10(off_t block_offset, VGMSTREAM * vgmstream) {
|
||||
STREAMFILE* streamFile = vgmstream->ch[0].streamfile;
|
||||
int i;
|
||||
size_t block_size = 0;
|
||||
size_t file_size = get_streamfile_size(streamFile);
|
||||
size_t channel_size = 0, interleave = 0;
|
||||
uint32_t block_id = read_32bitBE(block_offset+0x00, streamFile);
|
||||
size_t block_size = read_32bitBE(block_offset+0x04, streamFile);
|
||||
|
||||
|
||||
while (block_offset < file_size) {
|
||||
uint32_t block_id = read_32bitBE(block_offset+0x00, streamFile);
|
||||
|
||||
block_size = read_32bitBE(block_offset+0x04, streamFile);
|
||||
|
||||
if (block_id == 0x41643130 || block_id == 0x41643131) { /* "Ad10/Ad11" audio block/footer found */
|
||||
break;
|
||||
}
|
||||
/* rest may be "MDEC" video blocks */
|
||||
|
||||
block_offset += block_size;
|
||||
/* accept "Ad10/Ad11" audio block/footer */
|
||||
if (block_id == 0x41643130 || block_id == 0x41643131) {
|
||||
channel_size = block_size - 0x08; /* one block per channel */
|
||||
interleave = block_size;
|
||||
block_size = block_size*vgmstream->channels;
|
||||
}
|
||||
/* rest could be "MDEC" video blocks with 0 size/samples */
|
||||
|
||||
/* EOF reads (unsure if this helps) */
|
||||
if (block_offset >= file_size) {
|
||||
vgmstream->current_block_offset = block_offset;
|
||||
vgmstream->next_block_offset = block_offset + 0x04;
|
||||
vgmstream->current_block_size = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
/* set offsets */
|
||||
for (i = 0; i < vgmstream->channels; i++) {
|
||||
vgmstream->ch[i].offset = block_offset + block_size*i + 0x08;
|
||||
}
|
||||
|
||||
vgmstream->current_block_size = block_size - 0x08; /* one block per channel */
|
||||
vgmstream->current_block_size = channel_size;
|
||||
vgmstream->current_block_offset = block_offset;
|
||||
vgmstream->next_block_offset = block_offset + block_size*vgmstream->channels;
|
||||
vgmstream->next_block_offset = block_offset + block_size;
|
||||
|
||||
for (i = 0; i < vgmstream->channels; i++) {
|
||||
vgmstream->ch[i].offset = (block_offset + 0x08) + interleave*i;
|
||||
}
|
||||
}
|
||||
|
@ -6,32 +6,23 @@
|
||||
void block_update_ea_wve_au00(off_t block_offset, VGMSTREAM * vgmstream) {
|
||||
STREAMFILE* streamFile = vgmstream->ch[0].streamfile;
|
||||
int i;
|
||||
size_t block_size = 0, interleave;
|
||||
size_t file_size = get_streamfile_size(streamFile);
|
||||
size_t channel_size = 0;
|
||||
uint32_t block_id = read_32bitBE(block_offset+0x00, streamFile);
|
||||
size_t block_size = read_32bitBE(block_offset+0x04, streamFile);
|
||||
|
||||
|
||||
while (block_offset < file_size) {
|
||||
uint32_t block_id = read_32bitBE(block_offset+0x00, streamFile);
|
||||
|
||||
block_size = read_32bitBE(block_offset+0x04, streamFile);
|
||||
|
||||
if (block_id == 0x61753030 || block_id == 0x61753031) { /* "au00/au01" audio block/footer found */
|
||||
break;
|
||||
}
|
||||
/* rest may be "MDEC" video blocks */
|
||||
|
||||
block_offset += block_size;
|
||||
/* accept "au00/au01" audio block/footer */
|
||||
if (block_id == 0x61753030 || block_id == 0x61753031) {
|
||||
/* adjusted to frame boundaries as blocks have padding */
|
||||
channel_size = ((block_size - 0x10) / vgmstream->interleave_block_size * vgmstream->interleave_block_size) / vgmstream->channels;
|
||||
}
|
||||
/* rest could be "MDEC" video blocks with 0 size/samples */
|
||||
|
||||
/* size adjusted to frame boundaries as blocks have padding */
|
||||
interleave = ((block_size - 0x10) / vgmstream->interleave_block_size * vgmstream->interleave_block_size) / vgmstream->channels;
|
||||
|
||||
/* set offsets */
|
||||
for (i = 0; i < vgmstream->channels; i++) {
|
||||
vgmstream->ch[i].offset = (block_offset + 0x10) + interleave*i;
|
||||
}
|
||||
|
||||
vgmstream->current_block_size = interleave;
|
||||
vgmstream->current_block_size = channel_size;
|
||||
vgmstream->current_block_offset = block_offset;
|
||||
vgmstream->next_block_offset = block_offset + block_size;
|
||||
|
||||
for (i = 0; i < vgmstream->channels; i++) {
|
||||
vgmstream->ch[i].offset = (block_offset + 0x10) + channel_size*i;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user