shithub: opusfile

Download patch

ref: 33d179715a45f8171408ae7ba0de8d5a377ae668
parent: 872188c156d5aebebac6823be8fa37b3c04a080c
author: Timothy B. Terriberry <tterribe@xiph.org>
date: Mon Dec 14 13:38:26 EST 2015

Fix timestamp check for seek-free seek.

We avoid seeking when the seek target lies within the packets
 buffered from the current page.
However, the calculation of the page start time was _adding_ the
 first packet's duration to its end time, instead of subtracting
 it.

--- a/src/opusfile.c
+++ b/src/opusfile.c
@@ -2263,7 +2263,7 @@
                generally 1 second or less), we can loop them continuously
                without seeking at all.*/
             OP_ALWAYS_TRUE(!op_granpos_add(&prev_page_gp,_of->op[0].granulepos,
-             op_get_packet_duration(_of->op[0].packet,_of->op[0].bytes)));
+             -op_get_packet_duration(_of->op[0].packet,_of->op[0].bytes)));
             if(op_granpos_cmp(prev_page_gp,_target_gp)<=0){
               /*Don't call op_decode_clear(), because it will dump our
                  packets.*/