nutenc: keep track of max_pts
authorMichael Niedermayer <michaelni@gmx.at>
Sun, 19 Aug 2012 21:34:38 +0000 (23:34 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Sun, 26 Aug 2012 20:15:20 +0000 (22:15 +0200)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavformat/nut.h
libavformat/nutenc.c

index 2d16f3e..39743db 100644 (file)
@@ -103,6 +103,8 @@ typedef struct {
     AVRational *time_base;
     struct AVTreeNode *syncpoints;
     int sp_count;
+    int64_t max_pts;
+    AVRational *max_pts_tb;
 } NUTContext;
 
 extern const AVCodecTag ff_nut_subtitle_tags[];
index 00f4653..97bed1e 100644 (file)
@@ -863,6 +863,11 @@ static int nut_write_packet(AVFormatContext *s, AVPacket *pkt){
             nus->keyframe_pts[nut->sp_count] = pkt->pts;
     }
 
+    if(!nut->max_pts_tb || av_compare_ts(nut->max_pts, *nut->max_pts_tb, pkt->pts, *nus->time_base) < 0) {
+        nut->max_pts = pkt->pts;
+        nut->max_pts_tb = nus->time_base;
+    }
+
     return 0;
 }