diff raw.c @ 2929:67246a772057 libavformat

Set pts/dts in raw (yuv,rgb,pcm) demuxers.
author michael
date Sat, 12 Jan 2008 00:24:10 +0000
parents cf6976fdd05f
children 2a4192999b55
line wrap: on
line diff
--- a/raw.c	Sat Jan 12 00:15:05 2008 +0000
+++ b/raw.c	Sat Jan 12 00:24:10 2008 +0000
@@ -105,7 +105,7 @@
 
 static int raw_read_packet(AVFormatContext *s, AVPacket *pkt)
 {
-    int ret, size;
+    int ret, size, bps;
     //    AVStream *st = s->streams[0];
 
     size= RAW_PACKET_SIZE;
@@ -119,6 +119,12 @@
     /* note: we need to modify the packet size here to handle the last
        packet */
     pkt->size = ret;
+
+    bps= av_get_bits_per_sample(s->streams[0]->codec->codec_id);
+    assert(bps); // if false there IS a bug elsewhere (NOT in this function)
+    pkt->dts=
+    pkt->pts= pkt->pos*8 / (bps * s->streams[0]->codec->channels);
+
     return ret;
 }
 
@@ -847,6 +853,8 @@
         return -1;
 
     ret= av_get_packet(s->pb, pkt, packet_size);
+    pkt->pts=
+    pkt->dts= pkt->pos / packet_size;
 
     pkt->stream_index = 0;
     if (ret != packet_size) {