mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-18 07:44:43 +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;
|
uint32_t loop_flag;
|
||||||
int loop_flag_set;
|
int loop_flag_set;
|
||||||
|
int loop_flag_auto;
|
||||||
|
|
||||||
uint32_t coef_offset;
|
uint32_t coef_offset;
|
||||||
uint32_t coef_spacing;
|
uint32_t coef_spacing;
|
||||||
@ -132,6 +133,13 @@ VGMSTREAM * init_vgmstream_txth(STREAMFILE *streamFile) {
|
|||||||
goto fail;
|
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 */
|
/* build the VGMSTREAM */
|
||||||
vgmstream = allocate_vgmstream(txth.channels,txth.loop_flag);
|
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));
|
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 (0==strcmp(val,"auto")) {
|
||||||
txth->loop_flag_set = 1;
|
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")) {
|
else if (0==strcmp(key,"coef_offset")) {
|
||||||
if (!parse_num(streamFile,val, &txth->coef_offset)) goto fail;
|
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")) {
|
else if (0==strcmp(key,"coef_mode")) {
|
||||||
if (!parse_num(streamFile,val, &txth->coef_mode)) goto fail;
|
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 {
|
else {
|
||||||
VGM_LOG("TXTH: unknown key=%s, val=%s\n", key,val);
|
VGM_LOG("TXTH: unknown key=%s, val=%s\n", key,val);
|
||||||
goto fail;
|
goto fail;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user