]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/img2.c
try to guess the codec for imag2pipe too
[ffmpeg] / libavformat / img2.c
index 7619d7fbc858944ca4561a247a9f0add8fed24b8..072a2f7f56db10ba13b287bd76cbbbbfcb36aa0e 100644 (file)
@@ -37,6 +37,12 @@ static const IdStrMap img_tags[] = {
     { CODEC_ID_MJPEG     , "jpeg"},
     { CODEC_ID_MJPEG     , "jpg"},
     { CODEC_ID_LJPEG     , "ljpg"},
+    { CODEC_ID_PNG       , "png"},
+    { CODEC_ID_PPM       , "ppm"},
+    { CODEC_ID_PGM       , "pgm"},
+    { CODEC_ID_PGMYUV    , "pgmyuv"},
+    { CODEC_ID_PBM       , "pbm"},
+    { CODEC_ID_PAM       , "pam"},
     { CODEC_ID_MPEG1VIDEO, "mpg1-img"},
     { CODEC_ID_MPEG2VIDEO, "mpg2-img"},
     { CODEC_ID_MPEG4     , "mpg4-img"},
@@ -132,6 +138,10 @@ static int image_probe(AVProbeData *p)
         return 0;
 }
 
+enum CodecID av_guess_image2_codec(const char *filename){
+    return av_str2id(img_tags, filename);
+}
+
 static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap)
 {
     VideoData *s = s1->priv_data;
@@ -153,8 +163,10 @@ static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap)
     /* find format */
     if (s1->iformat->flags & AVFMT_NOFILE)
         s->is_pipe = 0;
-    else
+    else{
         s->is_pipe = 1;
+        st->need_parsing= 1;
+    }
         
     if (!ap || !ap->frame_rate) {
         st->codec.frame_rate      = 25;
@@ -177,8 +189,16 @@ static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap)
                         st->codec.frame_rate_base) / st->codec.frame_rate;
     }
     
-    st->codec.codec_type = CODEC_TYPE_VIDEO;
-    st->codec.codec_id = av_str2id(img_tags, s->path);
+    if(ap->video_codec_id){
+        st->codec.codec_type = CODEC_TYPE_VIDEO;
+        st->codec.codec_id = ap->video_codec_id;
+    }else if(ap->audio_codec_id){
+        st->codec.codec_type = CODEC_TYPE_AUDIO;
+        st->codec.codec_id = ap->audio_codec_id;
+    }else{
+        st->codec.codec_type = CODEC_TYPE_VIDEO;
+        st->codec.codec_id = av_str2id(img_tags, s->path);
+    }
 
     return 0;
  
@@ -228,6 +248,7 @@ static int img_read_packet(AVFormatContext *s1, AVPacket *pkt)
         av_free_packet(pkt);
         return AVERROR_IO; /* signal EOF */
     } else {
+        pkt->size = ret;
         s->img_count++;
         s->img_number++;
         return 0;