From 33d179715a45f8171408ae7ba0de8d5a377ae668 Mon Sep 17 00:00:00 2001
From: "Timothy B. Terriberry" <tterribe@xiph.org>
Date: Mon, 14 Dec 2015 18:38:26 -0800
Subject: [PATCH] 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.
---
 src/opusfile.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/opusfile.c b/src/opusfile.c
index cb372e4..1acb420 100644
--- a/src/opusfile.c
+++ b/src/opusfile.c
@@ -2263,7 +2263,7 @@ static int op_pcm_seek_page(OggOpusFile *_of,
                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.*/
-- 
GitLab