]> granicus.if.org Git - handbrake/commitdiff
reader: fix p-to-p seconds for non-seekable streams
authorJohn Stebbins <jstebbins.hb@gmail.com>
Fri, 11 Mar 2016 20:44:24 +0000 (13:44 -0700)
committerJohn Stebbins <jstebbins.hb@gmail.com>
Fri, 11 Mar 2016 20:44:24 +0000 (13:44 -0700)
This broke when sync was reworked.  Sync now expects job->pts_to_start
to be relative to the first frame that it sees.

libhb/reader.c

index 78a302d7e1bfdf92ac86c7938f7cd41cb4f2f2b3..cc98362902fb58986c70d3332e44235524effe0c 100644 (file)
@@ -733,7 +733,11 @@ static int reader_work( hb_work_object_t * w, hb_buffer_t ** buf_in,
                 if (!r->start_found && start >= r->pts_to_start)
                 {
                     // pts_to_start point found
-                    r->start_found = 1;
+                    // Note that this code path only gets executed for
+                    // medai where we have not performed an initial seek
+                    // to get close to the start time. So the 'start' time
+                    // is the time since the first frame.
+
                     if (r->stream)
                     {
                         // libav multi-threaded decoders can get into
@@ -744,6 +748,21 @@ static int reader_work( hb_work_object_t * w, hb_buffer_t ** buf_in,
                         hb_buffer_close( &buf );
                         continue;
                     }
+                    r->start_found = 1;
+                    // sync.c also pays attention to job->pts_to_start
+                    // It eats up the 10 second slack that we build in
+                    // to the start time here in reader (so that video
+                    // decode is clean at the start time).
+                    // sync.c expects pts_to_start to be relative to the
+                    // first timestamp it sees.
+                    if (r->job->pts_to_start > start)
+                    {
+                        r->job->pts_to_start -= start;
+                    }
+                    else
+                    {
+                        r->job->pts_to_start = 0;
+                    }
                 }
                 // This log is handy when you need to debug timing problems
                 //hb_log("id %x scr_offset %"PRId64