mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-12 01:30:49 +01:00
Add TXTH "loop_flag = auto" to autodetect PS-ADPCM loop points
This commit is contained in:
parent
06c8ab1b3f
commit
6b4f54df92
@ -57,6 +57,7 @@ typedef struct {
|
||||
|
||||
uint32_t loop_flag;
|
||||
int loop_flag_set;
|
||||
int loop_flag_auto;
|
||||
|
||||
uint32_t coef_offset;
|
||||
uint32_t coef_spacing;
|
||||
@ -132,6 +133,13 @@ VGMSTREAM * init_vgmstream_txth(STREAMFILE *streamFile) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* try to autodetect PS-ADPCM loop data */
|
||||
if (txth.loop_flag_auto && coding == coding_PSX) {
|
||||
size_t data_size = get_streamfile_size(streamFile) - txth.start_offset;
|
||||
txth.loop_flag = ps_find_loop_offsets(streamFile, txth.start_offset, data_size, txth.channels, txth.interleave,
|
||||
(int32_t*)&txth.loop_start_sample, (int32_t*)&txth.loop_end_sample);
|
||||
}
|
||||
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(txth.channels,txth.loop_flag);
|
||||
@ -583,8 +591,13 @@ static int parse_keyval(STREAMFILE * streamFile, STREAMFILE * streamText, txth_h
|
||||
txth->loop_adjust = get_bytes_to_samples(txth, txth->loop_adjust * (txth->interleave*txth->channels));
|
||||
}
|
||||
else if (0==strcmp(key,"loop_flag")) {
|
||||
if (!parse_num(streamFile,val, &txth->loop_flag)) goto fail;
|
||||
txth->loop_flag_set = 1;
|
||||
if (0==strcmp(val,"auto")) {
|
||||
txth->loop_flag_auto = 1;
|
||||
}
|
||||
else {
|
||||
if (!parse_num(streamFile,val, &txth->loop_flag)) goto fail;
|
||||
txth->loop_flag_set = 1;
|
||||
}
|
||||
}
|
||||
else if (0==strcmp(key,"coef_offset")) {
|
||||
if (!parse_num(streamFile,val, &txth->coef_offset)) goto fail;
|
||||
@ -602,6 +615,9 @@ static int parse_keyval(STREAMFILE * streamFile, STREAMFILE * streamText, txth_h
|
||||
else if (0==strcmp(key,"coef_mode")) {
|
||||
if (!parse_num(streamFile,val, &txth->coef_mode)) goto fail;
|
||||
}
|
||||
else if (0==strcmp(key,"psx_loops")) {
|
||||
if (!parse_num(streamFile,val, &txth->coef_mode)) goto fail;
|
||||
}
|
||||
else {
|
||||
VGM_LOG("TXTH: unknown key=%s, val=%s\n", key,val);
|
||||
goto fail;
|
||||
|
Loading…
Reference in New Issue
Block a user