diff options
Diffstat (limited to 'libavformat/img2.c')
-rw-r--r-- | libavformat/img2.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/libavformat/img2.c b/libavformat/img2.c index bad58550c2..7480d43bfe 100644 --- a/libavformat/img2.c +++ b/libavformat/img2.c @@ -3,20 +3,20 @@ * Copyright (c) 2000, 2001, 2002 Fabrice Bellard * Copyright (c) 2004 Michael Niedermayer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * Libav is distributed in the hope that it will be useful, + * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -32,6 +32,7 @@ typedef struct { int img_number; int img_count; int is_pipe; + int split_planes; /**< use independent file for each Y, U, V plane */ char path[1024]; } VideoData; @@ -57,6 +58,7 @@ static const IdStrMap img_tags[] = { { CODEC_ID_MPEG4 , "mpg4-img"}, { CODEC_ID_FFV1 , "ffv1-img"}, { CODEC_ID_RAWVIDEO , "y"}, + { CODEC_ID_RAWVIDEO , "raw"}, { CODEC_ID_BMP , "bmp"}, { CODEC_ID_GIF , "gif"}, { CODEC_ID_TARGA , "tga"}, @@ -241,6 +243,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->split_planes = str && !strcasecmp(str + 1, "y"); st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = av_str2id(img_tags, s->path); } @@ -278,7 +282,7 @@ static int read_packet(AVFormatContext *s1, AVPacket *pkt) } size[i]= avio_size(f[i]); - if(codec->codec_id != CODEC_ID_RAWVIDEO) + if(!s->split_planes) break; filename[ strlen(filename) - 1 ]= 'U' + i; } @@ -287,7 +291,7 @@ static int read_packet(AVFormatContext *s1, AVPacket *pkt) infer_size(&codec->width, &codec->height, size[0]); } else { f[0] = s1->pb; - if (f[0]->eof_reached) + if (url_feof(f[0])) return AVERROR(EIO); size[0]= 4096; } @@ -324,6 +328,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)); @@ -334,6 +339,8 @@ static int write_header(AVFormatContext *s) else img->is_pipe = 1; + str = strrchr(img->path, '.'); + img->split_planes = str && !strcasecmp(str + 1, "y"); return 0; } @@ -359,7 +366,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt) return AVERROR(EIO); } - if(codec->codec_id != CODEC_ID_RAWVIDEO) + if(!img->split_planes) break; filename[ strlen(filename) - 1 ]= 'U' + i; } @@ -367,7 +374,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt) pb[0] = s->pb; } - if(codec->codec_id == CODEC_ID_RAWVIDEO){ + if(img->split_planes){ int ysize = codec->width * codec->height; avio_write(pb[0], pkt->data , ysize); avio_write(pb[1], pkt->data + ysize, (pkt->size - ysize)/2); @@ -440,7 +447,7 @@ AVInputFormat ff_image2pipe_demuxer = { AVOutputFormat ff_image2_muxer = { .name = "image2", .long_name = NULL_IF_CONFIG_SMALL("image2 sequence"), - .extensions = "bmp,jpeg,jpg,ljpg,pam,pbm,pcx,pgm,pgmyuv,png," + .extensions = "bmp,dpx,jpeg,jpg,ljpg,pam,pbm,pcx,pgm,pgmyuv,png," "ppm,sgi,tga,tif,tiff,jp2", .priv_data_size = sizeof(VideoData), .video_codec = CODEC_ID_MJPEG, |