[FFmpeg-devel] [PATCH] make image2 muxer/demuxer support sequence of individual rawvideo files

Peter Ross pross
Thu Feb 10 06:20:53 CET 2011


---
 libavformat/img2.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/libavformat/img2.c b/libavformat/img2.c
index 9583eea..8137970 100644
--- a/libavformat/img2.c
+++ b/libavformat/img2.c
@@ -31,6 +31,7 @@ typedef struct {
     int img_number;
     int img_count;
     int is_pipe;
+    int is_y;
     char path[1024];
 } VideoData;
 
@@ -55,6 +56,7 @@ static const IdStrMap img_tags[] = {
     { CODEC_ID_MPEG2VIDEO, "mpg2-img"},
     { CODEC_ID_MPEG4     , "mpg4-img"},
     { CODEC_ID_FFV1      , "ffv1-img"},
+    { CODEC_ID_RAWVIDEO  , "raw"},
     { CODEC_ID_RAWVIDEO  , "y"},
     { CODEC_ID_BMP       , "bmp"},
     { CODEC_ID_GIF       , "gif"},
@@ -240,6 +242,8 @@ static int read_header(AVFormatContext *s1, AVFormatParameters *ap)
         st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
         st->codec->codec_id = s1->audio_codec_id;
     }else{
+        const char *str= strrchr(s->path, '.');
+        s->is_y = str && !strcasecmp(str + 1, "y");
         st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
         st->codec->codec_id = av_str2id(img_tags, s->path);
     }
@@ -277,7 +281,7 @@ static int read_packet(AVFormatContext *s1, AVPacket *pkt)
             }
             size[i]= url_fsize(f[i]);
 
-            if(codec->codec_id != CODEC_ID_RAWVIDEO)
+            if(codec->codec_id != CODEC_ID_RAWVIDEO || !s->is_y)
                 break;
             filename[ strlen(filename) - 1 ]= 'U' + i;
         }
@@ -323,6 +327,7 @@ static int read_packet(AVFormatContext *s1, AVPacket *pkt)
 static int write_header(AVFormatContext *s)
 {
     VideoData *img = s->priv_data;
+    const char *str;
 
     img->img_number = 1;
     av_strlcpy(img->path, s->filename, sizeof(img->path));
@@ -333,6 +338,8 @@ static int write_header(AVFormatContext *s)
     else
         img->is_pipe = 1;
 
+    str = strrchr(img->path, '.');
+    img->is_y = str && !strcasecmp(str + 1, "y");
     return 0;
 }
 
@@ -358,7 +365,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
                 return AVERROR(EIO);
             }
 
-            if(codec->codec_id != CODEC_ID_RAWVIDEO)
+            if(codec->codec_id != CODEC_ID_RAWVIDEO || !img->is_y)
                 break;
             filename[ strlen(filename) - 1 ]= 'U' + i;
         }
@@ -366,7 +373,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
         pb[0] = s->pb;
     }
 
-    if(codec->codec_id == CODEC_ID_RAWVIDEO){
+    if(codec->codec_id == CODEC_ID_RAWVIDEO && img->is_y){
         int ysize = codec->width * codec->height;
         put_buffer(pb[0], pkt->data        , ysize);
         put_buffer(pb[1], pkt->data + ysize, (pkt->size - ysize)/2);
-- 
1.7.1


-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20110210/2713ba25/attachment.pgp>



More information about the ffmpeg-devel mailing list