summaryrefslogtreecommitdiff
path: root/libavformat/img2enc.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-11-06 01:25:59 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-11-06 01:31:41 +0100
commit67ee2d2f6d89b46b1ee045ce4ae8764086e620b6 (patch)
tree8faf4be127977678b3a0d21ab8a708b60eb16a20 /libavformat/img2enc.c
parent6dfcc7abdd5c5c312521c0d030bfc7290847d1c3 (diff)
img2enc: check pix_fmt for split planes mode.
Found-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/img2enc.c')
-rw-r--r--libavformat/img2enc.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c
index c485569d71..0ab7c65760 100644
--- a/libavformat/img2enc.c
+++ b/libavformat/img2enc.c
@@ -24,6 +24,7 @@
#include "libavutil/avstring.h"
#include "libavutil/log.h"
#include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
#include "avformat.h"
#include "avio_internal.h"
#include "internal.h"
@@ -42,6 +43,7 @@ static int write_header(AVFormatContext *s)
{
VideoMuxData *img = s->priv_data;
AVStream *st = s->streams[0];
+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(st->codec->pix_fmt);
const char *str;
av_strlcpy(img->path, s->filename, sizeof(img->path));
@@ -56,7 +58,10 @@ static int write_header(AVFormatContext *s)
img->split_planes = str
&& !av_strcasecmp(str + 1, "y")
&& s->nb_streams == 1
- && st->codec->codec_id == AV_CODEC_ID_RAWVIDEO;
+ && st->codec->codec_id == AV_CODEC_ID_RAWVIDEO
+ && desc
+ &&(desc->flags & PIX_FMT_PLANAR)
+ && desc->nb_components >= 3;
return 0;
}