]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/raw.c
Fix aspect ratio.
[ffmpeg] / libavformat / raw.c
index 08e75c5f59aa847b42c2c3d460810a6519da845a..d4b138953734813ceb174245f777d0d00ed1b83a 100644 (file)
@@ -85,7 +85,10 @@ static int raw_read_header(AVFormatContext *s, AVFormatParameters *ap)
             av_set_pts_info(st, 64, 1, st->codec->sample_rate);
             break;
         case CODEC_TYPE_VIDEO:
-            av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den);
+            if(ap->time_base.num)
+                av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den);
+            else
+                av_set_pts_info(st, 64, 1, 25);
             st->codec->width = ap->width;
             st->codec->height = ap->height;
             st->codec->pix_fmt = ap->pix_fmt;
@@ -102,7 +105,7 @@ static int raw_read_header(AVFormatContext *s, AVFormatParameters *ap)
 
 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;
@@ -116,6 +119,12 @@ static int raw_read_packet(AVFormatContext *s, AVPacket *pkt)
     /* 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;
 }
 
@@ -844,6 +853,8 @@ static int rawvideo_read_packet(AVFormatContext *s, AVPacket *pkt)
         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) {