diff ffm.c @ 468:60f897e8dd2d libavformat

pass AVPacket into av_write_frame() fixes the random dts/pts during encoding asf preroll fix no more initial zero frames for b frame encoding mpeg-es dts during demuxing fixed .ffm timestamp scale fixed, ffm is still broken though
author michael
date Sat, 29 May 2004 02:06:32 +0000
parents 3a40642dc4df
children 813b0119a98e
line wrap: on
line diff
--- a/ffm.c	Tue May 25 23:06:00 2004 +0000
+++ b/ffm.c	Sat May 29 02:06:32 2004 +0000
@@ -222,15 +222,16 @@
     return -1;
 }
 
-static int ffm_write_packet(AVFormatContext *s, int stream_index,
-                            const uint8_t *buf, int size, int64_t force_pts)
+static int ffm_write_packet(AVFormatContext *s, AVPacket *pkt)
 {
-    AVStream *st = s->streams[stream_index];
+    AVStream *st = s->streams[pkt->stream_index];
     FFMStream *fst = st->priv_data;
     int64_t pts;
     uint8_t header[FRAME_HEADER_SIZE];
     int duration;
+    int size= pkt->size;
 
+    //XXX/FIXME use duration from pkt
     if (st->codec.codec_type == CODEC_TYPE_AUDIO) {
         duration = ((float)st->codec.frame_size / st->codec.sample_rate * 1000000.0);
     } else {
@@ -239,9 +240,9 @@
 
     pts = fst->pts;
     /* packet size & key_frame */
-    header[0] = stream_index;
+    header[0] = pkt->stream_index;
     header[1] = 0;
-    if (st->codec.coded_frame->key_frame) //if st->codec.coded_frame==NULL then there is a bug somewhere else
+    if (pkt->flags & PKT_FLAG_KEY)
         header[1] |= FLAG_KEY_FRAME;
     header[2] = (size >> 16) & 0xff;
     header[3] = (size >> 8) & 0xff;
@@ -250,7 +251,7 @@
     header[6] = (duration >> 8) & 0xff;
     header[7] = duration & 0xff;
     ffm_write_data(s, header, FRAME_HEADER_SIZE, pts, 1);
-    ffm_write_data(s, buf, size, pts, 0);
+    ffm_write_data(s, pkt->data, size, pts, 0);
 
     fst->pts += duration;
     return 0;
@@ -467,6 +468,9 @@
         fst = av_mallocz(sizeof(FFMStream));
         if (!fst)
             goto fail;
+            
+        av_set_pts_info(st, 64, 1, 1000000);
+            
         st->priv_data = fst;
 
         codec = &st->codec;