mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-24 15:00:11 +01:00
Add name_offset/name_size option for TXTH
This commit is contained in:
parent
e53740f27f
commit
9ff2ce5944
16
doc/TXTH.md
16
doc/TXTH.md
@ -190,11 +190,23 @@ body_file = (filename)|*.(extension)|null
|
||||
|
||||
# Subsongs [OPTIONAL]
|
||||
# Sets the number of subsongs in the file, adjusting reads per subsong N:
|
||||
# "value = @(offset) + subsong_offset*N". Mainly for bigfiles with consecutive
|
||||
# headers per subsong, set subsong_offset to 0 when done as it affects any reads.
|
||||
# "value = @(offset) + subsong_offset*N". (number) values aren't adjusted
|
||||
# as they are seen as constants.
|
||||
# Mainly for bigfiles with consecutive headers per subsong, set subsong_offset
|
||||
# to 0 when done as it affects any reads.
|
||||
# The current subsong number is handled externally by plugins or TXTP.
|
||||
subsong_count = (number)|(offset)|(field)
|
||||
subsong_offset = (number)|(offset)|(field)
|
||||
|
||||
# Names [OPTIONAL]
|
||||
# Sets the name of the stream, most useful when used with subsongs.
|
||||
# TXTH will read a string at name_offset, with name_size characters.
|
||||
# name_size defaults to 0, which reads until null-terminator or a
|
||||
# non-ascii character.
|
||||
# name_offset can be a (number) value, but being an offset it's also
|
||||
# adjusted by subsong_offset.
|
||||
name_offset = (number)|(offset)|(field)
|
||||
name_size = (number)|(offset)|(field)
|
||||
```
|
||||
|
||||
## Usages
|
||||
|
@ -76,6 +76,10 @@ typedef struct {
|
||||
uint32_t subsong_count;
|
||||
uint32_t subsong_offset;
|
||||
|
||||
uint32_t name_offset_set;
|
||||
uint32_t name_offset;
|
||||
uint32_t name_size;
|
||||
|
||||
/* original STREAMFILE and its type (may be an unsupported "base" file or a .txth) */
|
||||
STREAMFILE *streamFile;
|
||||
int streamfile_is_txth;
|
||||
@ -194,6 +198,10 @@ VGMSTREAM * init_vgmstream_txth(STREAMFILE *streamFile) {
|
||||
vgmstream->loop_end_sample = txth.loop_end_sample;
|
||||
vgmstream->num_streams = txth.subsong_count;
|
||||
vgmstream->stream_size = txth.data_size;
|
||||
if (txth.name_offset_set) {
|
||||
size_t name_size = txth.name_size ? txth.name_size + 1 : STREAM_NAME_SIZE;
|
||||
read_string(vgmstream->stream_name,name_size, txth.name_offset,txth.streamHead);
|
||||
}
|
||||
|
||||
/* codec specific (taken from GENH with minimal changes) */
|
||||
switch (coding) {
|
||||
@ -720,6 +728,16 @@ static int parse_keyval(STREAMFILE * streamFile_, txth_header * txth, const char
|
||||
else if (0==strcmp(key,"subsong_offset")) {
|
||||
if (!parse_num(txth->streamHead,txth,val, &txth->subsong_offset)) goto fail;
|
||||
}
|
||||
else if (0==strcmp(key,"name_offset")) {
|
||||
if (!parse_num(txth->streamHead,txth,val, &txth->name_offset)) goto fail;
|
||||
txth->name_offset_set = 1;
|
||||
/* special subsong adjustment */
|
||||
if (txth->subsong_offset)
|
||||
txth->name_offset = txth->name_offset + txth->subsong_offset * (txth->target_subsong - 1);
|
||||
}
|
||||
else if (0==strcmp(key,"name_size")) {
|
||||
if (!parse_num(txth->streamHead,txth,val, &txth->name_size)) goto fail;
|
||||
}
|
||||
else if (0==strcmp(key,"header_file")) {
|
||||
if (txth->streamhead_opened) {
|
||||
close_streamfile(txth->streamHead);
|
||||
|
Loading…
Reference in New Issue
Block a user