Merge pull request #414 from bnnm/hca

Fix installed TXTP loops in HCA files
This commit is contained in:
bnnm 2019-05-23 23:59:23 +02:00 committed by GitHub
commit 0de4762bfc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 3 deletions

View File

@ -193,7 +193,7 @@ void free_ea_mt(ea_mt_codec_data *data, int channels);
hca_codec_data *init_hca(STREAMFILE *streamFile);
void decode_hca(hca_codec_data * data, sample * outbuf, int32_t samples_to_do);
void reset_hca(hca_codec_data * data);
void loop_hca(hca_codec_data * data);
void loop_hca(hca_codec_data * data, int32_t num_sample);
void free_hca(hca_codec_data * data);
int test_hca_key(hca_codec_data * data, unsigned long long keycode);

View File

@ -130,9 +130,19 @@ void reset_hca(hca_codec_data * data) {
data->samples_to_discard = data->info.encoderDelay;
}
void loop_hca(hca_codec_data * data) {
void loop_hca(hca_codec_data * data, int32_t num_sample) {
if (!data) return;
/* manually calc loop values if not set (should only happen with installed/forced looping,
* as actual files usually pad encoder delay so earliest loopStartBlock becomes 1-2,
* probably for decoding cleanup so this may not be as exact) */
if (data->info.loopStartBlock == 0 && data->info.loopStartDelay == 0) {
int target_sample = num_sample + data->info.encoderDelay;
data->info.loopStartBlock = target_sample / data->info.samplesPerBlock;
data->info.loopStartDelay = target_sample - (data->info.loopStartBlock * data->info.samplesPerBlock);
}
data->current_block = data->info.loopStartBlock;
data->samples_filled = 0;
data->samples_consumed = 0;

View File

@ -2162,7 +2162,7 @@ int vgmstream_do_loop(VGMSTREAM * vgmstream) {
/* prepare certain codecs' internal state for looping */
if (vgmstream->coding_type == coding_CRI_HCA) {
loop_hca(vgmstream->codec_data);
loop_hca(vgmstream->codec_data, vgmstream->loop_sample);
}
if (vgmstream->coding_type == coding_EA_MT) {