mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-17 23:36:41 +01:00
Fix TXTH auto data_size with subsongs to calc up to next start_offset
This commit is contained in:
parent
d9c3720f73
commit
4acd10d1b1
@ -777,8 +777,22 @@ static int parse_keyval(STREAMFILE * streamFile_, txth_header * txth, const char
|
|||||||
else if (is_string(key,"start_offset")) {
|
else if (is_string(key,"start_offset")) {
|
||||||
if (!parse_num(txth->streamHead,txth,val, &txth->start_offset)) goto fail;
|
if (!parse_num(txth->streamHead,txth,val, &txth->start_offset)) goto fail;
|
||||||
if (!txth->data_size_set) {
|
if (!txth->data_size_set) {
|
||||||
txth->data_size = !txth->streamBody ? 0 :
|
uint32_t body_size = !txth->streamBody ? 0 : get_streamfile_size(txth->streamBody);
|
||||||
get_streamfile_size(txth->streamBody) - txth->start_offset; /* re-evaluate */
|
|
||||||
|
/* with subsongs we want to clamp body_size from this subsong start to next subsong start */
|
||||||
|
if (txth->subsong_count > 1 && txth->target_subsong < txth->subsong_count) {
|
||||||
|
uint32_t next_offset;
|
||||||
|
/* temp move to next start_offset and move back*/
|
||||||
|
txth->target_subsong++;
|
||||||
|
parse_num(txth->streamHead,txth,val, &next_offset);
|
||||||
|
txth->target_subsong--;
|
||||||
|
if (next_offset > txth->start_offset) {
|
||||||
|
body_size = next_offset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (body_size && body_size > txth->start_offset)
|
||||||
|
txth->data_size = body_size - txth->start_offset; /* re-evaluate */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (is_string(key,"data_size")) {
|
else if (is_string(key,"data_size")) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user