[FFmpeg-cvslog] avformat/mux: change avoid_negative_ts code to support later addition of AVStreams

Michael Niedermayer git at videolan.org
Fri Apr 26 14:58:16 CEST 2013


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Fri Apr 26 11:37:42 2013 +0200| [060f14f493104e049481f12e9dc21330801bd137] | committer: Michael Niedermayer

avformat/mux: change avoid_negative_ts code to support later addition of AVStreams

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

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

 libavformat/mux.c |   28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/libavformat/mux.c b/libavformat/mux.c
index 1529eec..1e18309 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -495,22 +495,26 @@ static int compute_pkt_fields2(AVFormatContext *s, AVStream *st, AVPacket *pkt)
  */
 static int write_packet(AVFormatContext *s, AVPacket *pkt)
 {
-    int ret, did_split, i;
+    int ret, did_split;
 
     if (s->avoid_negative_ts > 0) {
         AVStream *st = s->streams[pkt->stream_index];
-        if (pkt->dts != AV_NOPTS_VALUE) {
-            if (!st->mux_ts_offset && pkt->dts < 0) {
-                for (i = 0; i < s->nb_streams; i++) {
-                    s->streams[i]->mux_ts_offset =
-                        av_rescale_q_rnd(-pkt->dts,
-                                            st->time_base,
-                                            s->streams[i]->time_base,
-                                            AV_ROUND_UP);
-                }
-            }
-            pkt->dts += st->mux_ts_offset;
+
+        if (pkt->dts < 0 && pkt->dts != AV_NOPTS_VALUE && !s->offset) {
+            s->offset = -pkt->dts;
+            s->offset_timebase = st->time_base;
         }
+
+        if (s->offset && !st->mux_ts_offset) {
+            st->mux_ts_offset =
+                av_rescale_q_rnd(s->offset,
+                                 s->offset_timebase,
+                                 st->time_base,
+                                 AV_ROUND_UP);
+        }
+
+        if (pkt->dts != AV_NOPTS_VALUE)
+            pkt->dts += st->mux_ts_offset;
         if (pkt->pts != AV_NOPTS_VALUE)
             pkt->pts += st->mux_ts_offset;
     }



More information about the ffmpeg-cvslog mailing list