mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-02-26 22:59:31 +01:00
Add TXTH sample_mode "blocks" (where bytes = blocks*interleave*channels)
This commit is contained in:
parent
6ba3b684fb
commit
c26ad84497
@ -47,7 +47,7 @@ typedef struct {
|
|||||||
int data_size_set;
|
int data_size_set;
|
||||||
uint32_t start_offset;
|
uint32_t start_offset;
|
||||||
|
|
||||||
int sample_type_bytes;
|
int sample_type;
|
||||||
uint32_t num_samples;
|
uint32_t num_samples;
|
||||||
uint32_t loop_start_sample;
|
uint32_t loop_start_sample;
|
||||||
uint32_t loop_end_sample;
|
uint32_t loop_end_sample;
|
||||||
@ -345,7 +345,7 @@ VGMSTREAM * init_vgmstream_txth(STREAMFILE *streamFile) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef VGM_USE_FFMPEG
|
#ifdef VGM_USE_FFMPEG
|
||||||
if ((txth.sample_type_bytes || txth.num_samples_data_size) && (txth.codec == XMA1 || txth.codec == XMA2)) {
|
if ((txth.sample_type==1 || txth.num_samples_data_size) && (txth.codec == XMA1 || txth.codec == XMA2)) {
|
||||||
/* manually find sample offsets */
|
/* manually find sample offsets */
|
||||||
ms_sample_data msd = {0};
|
ms_sample_data msd = {0};
|
||||||
|
|
||||||
@ -353,7 +353,7 @@ VGMSTREAM * init_vgmstream_txth(STREAMFILE *streamFile) {
|
|||||||
msd.channels = txth.channels;
|
msd.channels = txth.channels;
|
||||||
msd.data_offset = txth.start_offset;
|
msd.data_offset = txth.start_offset;
|
||||||
msd.data_size = txth.data_size;
|
msd.data_size = txth.data_size;
|
||||||
if (txth.sample_type_bytes) {
|
if (txth.sample_type==1) {
|
||||||
msd.loop_flag = txth.loop_flag;
|
msd.loop_flag = txth.loop_flag;
|
||||||
msd.loop_start_b = txth.loop_start_sample;
|
msd.loop_start_b = txth.loop_start_sample;
|
||||||
msd.loop_end_b = txth.loop_end_sample;
|
msd.loop_end_b = txth.loop_end_sample;
|
||||||
@ -364,7 +364,7 @@ VGMSTREAM * init_vgmstream_txth(STREAMFILE *streamFile) {
|
|||||||
xma_get_samples(&msd, streamFile);
|
xma_get_samples(&msd, streamFile);
|
||||||
|
|
||||||
vgmstream->num_samples = msd.num_samples;
|
vgmstream->num_samples = msd.num_samples;
|
||||||
if (txth.sample_type_bytes) {
|
if (txth.sample_type==1) {
|
||||||
vgmstream->loop_start_sample = msd.loop_start_sample;
|
vgmstream->loop_start_sample = msd.loop_start_sample;
|
||||||
vgmstream->loop_end_sample = msd.loop_end_sample;
|
vgmstream->loop_end_sample = msd.loop_end_sample;
|
||||||
}
|
}
|
||||||
@ -523,8 +523,9 @@ static int parse_keyval(STREAMFILE * streamFile, STREAMFILE * streamText, txth_h
|
|||||||
txth->data_size_set = 1;
|
txth->data_size_set = 1;
|
||||||
}
|
}
|
||||||
else if (0==strcmp(key,"sample_type")) {
|
else if (0==strcmp(key,"sample_type")) {
|
||||||
if (0==strcmp(val,"bytes")) txth->sample_type_bytes = 1;
|
if (0==strcmp(val,"samples")) txth->sample_type = 0;
|
||||||
else if (0==strcmp(val,"samples")) txth->sample_type_bytes = 0;
|
else if (0==strcmp(val,"bytes")) txth->sample_type = 1;
|
||||||
|
else if (0==strcmp(val,"blocks")) txth->sample_type = 2;
|
||||||
else goto fail;
|
else goto fail;
|
||||||
}
|
}
|
||||||
else if (0==strcmp(key,"num_samples")) {
|
else if (0==strcmp(key,"num_samples")) {
|
||||||
@ -534,14 +535,18 @@ static int parse_keyval(STREAMFILE * streamFile, STREAMFILE * streamText, txth_h
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!parse_num(streamFile,val, &txth->num_samples)) goto fail;
|
if (!parse_num(streamFile,val, &txth->num_samples)) goto fail;
|
||||||
if (txth->sample_type_bytes)
|
if (txth->sample_type==1)
|
||||||
txth->num_samples = get_bytes_to_samples(txth, txth->num_samples);
|
txth->num_samples = get_bytes_to_samples(txth, txth->num_samples);
|
||||||
|
if (txth->sample_type==2)
|
||||||
|
txth->num_samples = get_bytes_to_samples(txth, txth->num_samples * (txth->interleave*txth->channels));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (0==strcmp(key,"loop_start_sample")) {
|
else if (0==strcmp(key,"loop_start_sample")) {
|
||||||
if (!parse_num(streamFile,val, &txth->loop_start_sample)) goto fail;
|
if (!parse_num(streamFile,val, &txth->loop_start_sample)) goto fail;
|
||||||
if (txth->sample_type_bytes)
|
if (txth->sample_type==1)
|
||||||
txth->loop_start_sample = get_bytes_to_samples(txth, txth->loop_start_sample);
|
txth->loop_start_sample = get_bytes_to_samples(txth, txth->loop_start_sample);
|
||||||
|
if (txth->sample_type==2)
|
||||||
|
txth->loop_start_sample = get_bytes_to_samples(txth, txth->loop_start_sample * (txth->interleave*txth->channels));
|
||||||
if (txth->loop_adjust)
|
if (txth->loop_adjust)
|
||||||
txth->loop_start_sample += txth->loop_adjust;
|
txth->loop_start_sample += txth->loop_adjust;
|
||||||
}
|
}
|
||||||
@ -551,8 +556,10 @@ static int parse_keyval(STREAMFILE * streamFile, STREAMFILE * streamText, txth_h
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!parse_num(streamFile,val, &txth->loop_end_sample)) goto fail;
|
if (!parse_num(streamFile,val, &txth->loop_end_sample)) goto fail;
|
||||||
if (txth->sample_type_bytes)
|
if (txth->sample_type==1)
|
||||||
txth->loop_end_sample = get_bytes_to_samples(txth, txth->loop_end_sample);
|
txth->loop_end_sample = get_bytes_to_samples(txth, txth->loop_end_sample);
|
||||||
|
if (txth->sample_type==2)
|
||||||
|
txth->loop_end_sample = get_bytes_to_samples(txth, txth->loop_end_sample * (txth->interleave*txth->channels));
|
||||||
}
|
}
|
||||||
if (txth->loop_adjust)
|
if (txth->loop_adjust)
|
||||||
txth->loop_end_sample += txth->loop_adjust;
|
txth->loop_end_sample += txth->loop_adjust;
|
||||||
@ -560,13 +567,17 @@ static int parse_keyval(STREAMFILE * streamFile, STREAMFILE * streamText, txth_h
|
|||||||
else if (0==strcmp(key,"skip_samples")) {
|
else if (0==strcmp(key,"skip_samples")) {
|
||||||
if (!parse_num(streamFile,val, &txth->skip_samples)) goto fail;
|
if (!parse_num(streamFile,val, &txth->skip_samples)) goto fail;
|
||||||
txth->skip_samples_set = 1;
|
txth->skip_samples_set = 1;
|
||||||
if (txth->sample_type_bytes)
|
if (txth->sample_type==1)
|
||||||
txth->skip_samples = get_bytes_to_samples(txth, txth->skip_samples);
|
txth->skip_samples = get_bytes_to_samples(txth, txth->skip_samples);
|
||||||
|
if (txth->sample_type==2)
|
||||||
|
txth->skip_samples = get_bytes_to_samples(txth, txth->skip_samples * (txth->interleave*txth->channels));
|
||||||
}
|
}
|
||||||
else if (0==strcmp(key,"loop_adjust")) {
|
else if (0==strcmp(key,"loop_adjust")) {
|
||||||
if (!parse_num(streamFile,val, &txth->loop_adjust)) goto fail;
|
if (!parse_num(streamFile,val, &txth->loop_adjust)) goto fail;
|
||||||
if (txth->sample_type_bytes)
|
if (txth->sample_type==1)
|
||||||
txth->loop_adjust = get_bytes_to_samples(txth, txth->loop_adjust);
|
txth->loop_adjust = get_bytes_to_samples(txth, txth->loop_adjust);
|
||||||
|
if (txth->sample_type==2)
|
||||||
|
txth->loop_adjust = get_bytes_to_samples(txth, txth->loop_adjust * (txth->interleave*txth->channels));
|
||||||
}
|
}
|
||||||
else if (0==strcmp(key,"loop_flag")) {
|
else if (0==strcmp(key,"loop_flag")) {
|
||||||
if (!parse_num(streamFile,val, &txth->loop_flag)) goto fail;
|
if (!parse_num(streamFile,val, &txth->loop_flag)) goto fail;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user