summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libFLAC/stream_decoder.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/libFLAC/stream_decoder.c b/src/libFLAC/stream_decoder.c
index aa63b2ca..3ca7f44f 100644
--- a/src/libFLAC/stream_decoder.c
+++ b/src/libFLAC/stream_decoder.c
@@ -3130,8 +3130,10 @@ FLAC__bool seek_to_absolute_sample_(FLAC__StreamDecoder *decoder, FLAC__uint64 s
/* a little less accurate: */
if(upper_bound - lower_bound < 0xffffffff)
pos = (FLAC__int64)lower_bound + (FLAC__int64)(((target_sample - lower_bound_sample) * (upper_bound - lower_bound)) / (upper_bound_sample - lower_bound_sample)) - approx_bytes_per_frame;
- else /* @@@ WATCHOUT, ~2TB limit */
- pos = (FLAC__int64)lower_bound + (FLAC__int64)((((target_sample - lower_bound_sample)>>8) * ((upper_bound - lower_bound)>>8)) / ((upper_bound_sample - lower_bound_sample)>>16)) - approx_bytes_per_frame;
+ else { /* @@@ WATCHOUT, ~2TB limit */
+ FLAC__uint64 ratio = (1<<16) / (upper_bound_sample - lower_bound_sample);
+ pos = (FLAC__int64)lower_bound + (FLAC__int64)((((target_sample - lower_bound_sample)>>8) * ((upper_bound - lower_bound)>>8) * ratio)) - approx_bytes_per_frame;
+ }
#endif
if(pos >= (FLAC__int64)upper_bound)
pos = (FLAC__int64)upper_bound - 1;