changeset 479:d84d9d8bb0a4 libavformat

pass timestamps correctly for -sync 0 use zero sized frames in avi to handle duplicate frames
author michael
date Tue, 15 Jun 2004 13:49:12 +0000
parents ac85aafd0971
children cfcca046161a
files avienc.c
diffstat 1 files changed, 17 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/avienc.c	Mon Jun 14 21:30:36 2004 +0000
+++ b/avienc.c	Tue Jun 15 13:49:12 2004 +0000
@@ -43,6 +43,7 @@
     offset_t frames_hdr_all, frames_hdr_strm[MAX_STREAMS];
     int audio_strm_length[MAX_STREAMS];
     int riff_id;
+    int packet_count[MAX_STREAMS];
 
     AVIIndex indexes[MAX_STREAMS];
 } AVIContext;
@@ -382,6 +383,7 @@
             
             put_le32(pb, stream->frame_rate_base); /* scale */
             put_le32(pb, stream->frame_rate); /* rate */
+            av_set_pts_info(s->streams[i], 64, stream->frame_rate_base, stream->frame_rate);
 
             put_le32(pb, 0); /* start */
             avi->frames_hdr_strm[i] = url_ftell(pb); /* remember this offset to fill later */
@@ -404,6 +406,7 @@
             parse_specific_params(stream, &au_byterate, &au_ssize, &au_scale);
             put_le32(pb, au_scale); /* scale */
             put_le32(pb, au_byterate); /* rate */
+//            av_set_pts_info(&s->streams[i], 64, au_scale, au_byterate);
             put_le32(pb, 0); /* start */
             avi->frames_hdr_strm[i] = url_ftell(pb); /* remember this offset to fill later */
             put_le32(pb, 0); /* length, XXX: filled later */
@@ -615,10 +618,23 @@
     ByteIOContext *pb = &s->pb;
     unsigned char tag[5];
     unsigned int flags=0;
-    AVCodecContext *enc;
     const int stream_index= pkt->stream_index;
+    AVCodecContext *enc= &s->streams[stream_index]->codec;;
     int size= pkt->size;
 
+//    av_log(s, AV_LOG_DEBUG, "%lld %d %d\n", pkt->dts, avi->packet_count[stream_index], stream_index);
+    while(enc->codec_type == CODEC_TYPE_VIDEO && pkt->dts != AV_NOPTS_VALUE && pkt->dts > avi->packet_count[stream_index]){
+        AVPacket empty_packet;
+
+        av_init_packet(&empty_packet);
+        empty_packet.size= 0;
+        empty_packet.data= NULL;
+        empty_packet.stream_index= stream_index;
+        avi_write_packet(s, &empty_packet);
+//        av_log(s, AV_LOG_DEBUG, "dup %lld %d\n", pkt->dts, avi->packet_count[stream_index]);
+    }
+    avi->packet_count[stream_index]++;
+
     if (url_ftell(pb) - avi->riff_start > AVI_MAX_RIFF_SIZE) { 
         avi_write_ix(s);
         end_tag(pb, avi->movi_list);
@@ -630,7 +646,6 @@
 	avi->movi_list = avi_start_new_riff(avi, pb, "AVIX", "movi");
     }
     
-    enc = &s->streams[stream_index]->codec;
     avi_stream2fourcc(&tag[0], stream_index, enc->codec_type);
     if(pkt->flags&PKT_FLAG_KEY)
         flags = 0x10;