[FFmpeg-cvslog] hls: fix min DTS code, try #2

Michael Niedermayer git at videolan.org
Tue Aug 21 01:56:49 CEST 2012


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Tue Aug 21 01:48:04 2012 +0200| [3ac754b93b9da480641c67d4193edb5838bfd2fa] | committer: Michael Niedermayer

hls: fix min DTS code, try #2

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3ac754b93b9da480641c67d4193edb5838bfd2fa
---

 libavformat/hls.c |   18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index 54e971a..00c3cf0 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -646,11 +646,21 @@ start:
         }
         /* Check if this stream has the packet with the lowest dts */
         if (var->pkt.data) {
-            struct variant *minvar = c->variants[minvariant];
-            if (minvariant < 0 ||
-                av_compare_ts(var->pkt.dts, var->ctx->streams[var->pkt.stream_index]->time_base,
-                              minvar->pkt.dts, minvar->ctx->streams[minvar->pkt.stream_index]->time_base) > 0)
+            if(minvariant < 0) {
                 minvariant = i;
+            } else {
+                struct variant *minvar = c->variants[minvariant];
+                int64_t dts    =    var->pkt.dts;
+                int64_t mindts = minvar->pkt.dts;
+                AVStream *st   =    var->ctx->streams[   var->pkt.stream_index];
+                AVStream *minst= minvar->ctx->streams[minvar->pkt.stream_index];
+
+                if(   st->start_time != AV_NOPTS_VALUE)    dts -=    st->start_time;
+                if(minst->start_time != AV_NOPTS_VALUE) mindts -= minst->start_time;
+
+                if (av_compare_ts(dts, st->time_base, mindts, minst->time_base) < 0)
+                    minvariant = i;
+            }
         }
     }
     if (c->end_of_segment) {



More information about the ffmpeg-cvslog mailing list