2017-08-20 02:18:48 +02:00
|
|
|
#include "layout.h"
|
|
|
|
#include "../coding/coding.h"
|
|
|
|
#include "../vgmstream.h"
|
|
|
|
|
2017-12-17 17:38:54 +01:00
|
|
|
/* EA SNS/SPS blocks */
|
2017-11-25 01:18:27 +01:00
|
|
|
void block_update_ea_sns(off_t block_offset, VGMSTREAM * vgmstream) {
|
2017-08-20 02:18:48 +02:00
|
|
|
STREAMFILE* streamFile = vgmstream->ch[0].streamfile;
|
|
|
|
uint32_t block_size, block_samples;
|
|
|
|
size_t file_size = get_streamfile_size(streamFile);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* always BE */
|
|
|
|
block_size = read_32bitBE(block_offset + 0x00,streamFile);
|
|
|
|
block_samples = read_32bitBE(block_offset + 0x04,streamFile);
|
|
|
|
|
|
|
|
/* EOF */
|
|
|
|
if (block_size == 0 || block_offset >= file_size) {
|
|
|
|
vgmstream->current_block_offset = file_size;
|
|
|
|
vgmstream->next_block_offset = file_size + 0x04;
|
|
|
|
vgmstream->current_block_samples = vgmstream->num_samples;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-12-17 17:38:54 +01:00
|
|
|
/* At 0x00(1): block flag
|
|
|
|
* - in SNS: 0x00=normal block, 0x80=last block (not mandatory)
|
|
|
|
* - in SPS: 0x48=header, 0x44=normal block, 0x45=last block (empty) */
|
|
|
|
block_size &= 0x00FFFFFF;
|
2017-08-20 02:18:48 +02:00
|
|
|
|
|
|
|
for (i = 0; i < vgmstream->channels; i++) {
|
|
|
|
off_t channel_start = 0x00;
|
|
|
|
vgmstream->ch[i].offset = block_offset + 0x08 + channel_start;
|
2017-12-01 20:04:33 +01:00
|
|
|
|
|
|
|
/* also fix first offset (for EALayer3) */
|
|
|
|
if (block_offset == vgmstream->ch[i].channel_start_offset) {
|
|
|
|
vgmstream->ch[i].channel_start_offset = vgmstream->ch[i].offset;
|
|
|
|
}
|
2017-08-20 02:18:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
vgmstream->current_block_offset = block_offset;
|
|
|
|
vgmstream->next_block_offset = block_offset + block_size;
|
|
|
|
vgmstream->current_block_samples = block_samples;
|
|
|
|
}
|