mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-02-21 20:59:52 +01:00
EAAC: Implemented looped gigasamples
This commit is contained in:
parent
7eb3b1cc5b
commit
3d95d56559
@ -1086,12 +1086,19 @@ static VGMSTREAM * init_vgmstream_eaaudiocore_header(STREAMFILE* sf_head, STREAM
|
||||
}
|
||||
break;
|
||||
case EAAC_TYPE_GIGASAMPLE: /* rarely seen [Def Jam Icon (X360)] */
|
||||
if (eaac.loop_flag) {
|
||||
VGM_LOG("EAAC: Looped gigasample found.\n");
|
||||
if (eaac.version == EAAC_VERSION_V1) {
|
||||
/* not seen so far, need samples */
|
||||
VGM_LOG("EAAC: Found SPS gigasample\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
header_size += 0x04;
|
||||
eaac.prefetch_samples = read_32bitBE(header_offset + 0x08, sf_head);
|
||||
eaac.prefetch_samples = read_32bitBE(header_offset + eaac.loop_flag ? 0x0c : 0x08, sf_head);
|
||||
|
||||
if (eaac.loop_flag && eaac.loop_start >= eaac.prefetch_samples) {
|
||||
header_size += 0x04;
|
||||
eaac.loop_offset = read_32bitBE(header_offset + 0x10, sf_head);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1122,6 +1129,19 @@ static VGMSTREAM * init_vgmstream_eaaudiocore_header(STREAMFILE* sf_head, STREAM
|
||||
if (eaac.version == EAAC_VERSION_V1) {
|
||||
eaac.loop_offset -= header_block_size;
|
||||
}
|
||||
|
||||
if (eaac.prefetch_samples != 0) {
|
||||
if (eaac.loop_start == 0) {
|
||||
/* loop from the beginning */
|
||||
eaac.loop_offset = 0x00;
|
||||
} else if (eaac.loop_start < eaac.prefetch_samples) {
|
||||
/* loop from the second RAM block */
|
||||
eaac.loop_offset = read_32bitBE(eaac.prefetch_offset, sf_head) & 0x00FFFFFF;
|
||||
} else {
|
||||
/* loop from offset within SNS */
|
||||
eaac.loop_offset += read_32bitBE(eaac.prefetch_offset, sf_head) & 0x00FFFFFF;
|
||||
}
|
||||
}
|
||||
} else if (eaac.loop_start > 0) {
|
||||
/* RAM assets have two blocks in case of actual loops */
|
||||
/* find the second block by getting the first block size */
|
||||
@ -1347,10 +1367,10 @@ static size_t calculate_eaac_size(STREAMFILE *sf, eaac_header *ea, uint32_t num_
|
||||
|
||||
if (is_ram) {
|
||||
/* RAM data only consists of one block (two for looped sounds) */
|
||||
if (ea->loop_start > 0 && !looped) looped = 1;
|
||||
if (ea->loop_start > 0 && ea->loop_start < num_samples && !looped) looped = 1;
|
||||
else break;
|
||||
} else if (ea->version == EAAC_VERSION_V0 && block_id == EAAC_BLOCKID0_END) {
|
||||
if (ea->loop_offset > 0 && !looped) looped = 1;
|
||||
if (ea->loop_offset > 0 && ea->loop_start >= ea->prefetch_samples && !looped) looped = 1;
|
||||
else break;
|
||||
}
|
||||
}
|
||||
@ -1431,8 +1451,6 @@ static STREAMFILE *setup_eaac_streamfile(eaac_header *ea, STREAMFILE* sf_head, S
|
||||
}
|
||||
} else {
|
||||
if (ea->type == EAAC_TYPE_GIGASAMPLE) {
|
||||
/* not seen so far, need samples */
|
||||
VGM_LOG("EAAC: Found SPS gigasample\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user