diff options
author | Alexey Yakovenko <wakeroid@gmail.com> | 2010-07-31 12:10:38 +0200 |
---|---|---|
committer | Alexey Yakovenko <wakeroid@gmail.com> | 2010-07-31 12:10:38 +0200 |
commit | 066cd203413e5c4609f939fa3eac2593dccdae08 (patch) | |
tree | 9687e68b7fc6feffbc78af00fe9f3a933675cb20 /plugins/dca | |
parent | 751c71f8d95f3915bb0d047cd8a7b9f8f3f13c3a (diff) |
fast seeking in dts streams
Diffstat (limited to 'plugins/dca')
-rw-r--r-- | plugins/dca/dcaplug.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/plugins/dca/dcaplug.c b/plugins/dca/dcaplug.c index 4d7d1131..36accf93 100644 --- a/plugins/dca/dcaplug.c +++ b/plugins/dca/dcaplug.c @@ -94,6 +94,7 @@ typedef struct { int frame_length; int flags; int bit_rate; + int frame_byte_size; char output_buffer[OUT_BUFFER_SIZE]; int remaining; int skipsamples; @@ -404,6 +405,7 @@ dts_init (DB_fileinfo_t *_info, DB_playItem_t *it) { trace ("dca: probe failed\n"); return -1; } + info->frame_byte_size = len; _info->channels = channels_multi (info->flags); _info->samplerate = info->sample_rate; @@ -486,14 +488,12 @@ static int dts_seek_sample (DB_fileinfo_t *_info, int sample) { ddb_dca_state_t *info = (ddb_dca_state_t *)_info; - if (sample >= info->currentsample) { - info->skipsamples = sample - info->currentsample; - } - else { - deadbeef->fseek (info->file, info->offset, SEEK_SET); - info->remaining = 0; - info->skipsamples = sample; - } + // calculate file offset from framesize / framesamples + int nframe = sample / info->frame_length; + int offs = info->frame_byte_size * nframe + info->offset; + deadbeef->fseek (info->file, offs, SEEK_SET); + info->remaining = 0; + info->skipsamples = sample - nframe * info->frame_length; info->currentsample = sample; _info->readpos = sample / _info->samplerate; |