changeset 545:afe2c9a33928 libavformat

pts/dts 100l fix
author michael
date Sun, 03 Oct 2004 11:16:40 +0000
parents 1244786bfb26
children 7c5ec900b38a
files mpeg.c
diffstat 1 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mpeg.c	Sun Oct 03 03:14:09 2004 +0000
+++ b/mpeg.c	Sun Oct 03 11:16:40 2004 +0000
@@ -895,6 +895,7 @@
     int best_score= INT_MIN;
     int ignore_constraints=0;
     int64_t scr= s->last_scr;
+    PacketDesc *timestamp_packet;
 
 retry:
     for(i=0; i<ctx->nb_streams; i++){
@@ -957,12 +958,20 @@
 
     assert(avail_space >= s->packet_size || ignore_constraints);
     
-    if(stream->premux_packet->unwritten_size == stream->premux_packet->size)
+    timestamp_packet= stream->premux_packet;
+    if(timestamp_packet->unwritten_size == timestamp_packet->size){
         trailer_size= 0;
-    else
-        trailer_size= stream->premux_packet->unwritten_size;
+    }else{
+        trailer_size= timestamp_packet->unwritten_size;
+        timestamp_packet= timestamp_packet->next;
+    }
 
-    es_size= flush_packet(ctx, best_i, stream->premux_packet->pts, stream->premux_packet->dts, scr, trailer_size);
+    if(timestamp_packet){
+        es_size= flush_packet(ctx, best_i, timestamp_packet->pts, timestamp_packet->dts, scr, trailer_size);
+    }else{
+        assert(fifo_size(&stream->fifo, stream->fifo.rptr) == trailer_size);
+        es_size= flush_packet(ctx, best_i, AV_NOPTS_VALUE, AV_NOPTS_VALUE, scr, trailer_size);
+    }
 
     if (s->is_vcd) {
         /* Write one or more padding sectors, if necessary, to reach