mirror of
https://github.com/claunia/flac.git
synced 2025-12-16 18:54:26 +00:00
libFLAC/stream_decoder.c: Use current position as bound when seeking
This commit is contained in:
committed by
Erik de Castro Lopo
parent
bfd4f13f3e
commit
159cd6c41a
@@ -3032,15 +3032,26 @@ FLAC__bool seek_to_absolute_sample_(FLAC__StreamDecoder *decoder, FLAC__uint64 s
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* First, we set an upper and lower bound on where in the
|
* First, we set an upper and lower bound on where in the
|
||||||
* stream we will search. For now we assume the worst case
|
* stream we will search. For now we take the current position
|
||||||
* scenario, which is our best guess at the beginning of
|
* as one bound and, depending on where the target position lies,
|
||||||
* the first frame and end of the stream.
|
* the beginning of the first frame or the end of the stream as
|
||||||
|
* the other bound.
|
||||||
*/
|
*/
|
||||||
lower_bound = first_frame_offset;
|
lower_bound = first_frame_offset;
|
||||||
lower_bound_sample = 0;
|
lower_bound_sample = 0;
|
||||||
upper_bound = stream_length;
|
upper_bound = stream_length;
|
||||||
upper_bound_sample = total_samples > 0 ? total_samples : target_sample /*estimate it*/;
|
upper_bound_sample = total_samples > 0 ? total_samples : target_sample /*estimate it*/;
|
||||||
|
|
||||||
|
if(decoder->protected_->state == FLAC__STREAM_DECODER_READ_FRAME) {
|
||||||
|
if(target_sample < decoder->private_->samples_decoded) {
|
||||||
|
if(FLAC__stream_decoder_get_decode_position(decoder, &upper_bound))
|
||||||
|
upper_bound_sample = decoder->private_->samples_decoded;
|
||||||
|
} else {
|
||||||
|
if(FLAC__stream_decoder_get_decode_position(decoder, &lower_bound))
|
||||||
|
lower_bound_sample = decoder->private_->samples_decoded;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now we refine the bounds if we have a seektable with
|
* Now we refine the bounds if we have a seektable with
|
||||||
* suitable points. Note that according to the spec they
|
* suitable points. Note that according to the spec they
|
||||||
|
|||||||
Reference in New Issue
Block a user