Browse code

avcodec/tiff: Check that pix_fmt is a yuv variant for TIFF_PHOTOMETRIC_YCBCR

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>

Michael Niedermayer authored on 2014/08/20 04:08:34
Showing 1 changed files
... ...
@@ -643,6 +643,15 @@ static int init_image(TiffContext *s, ThreadFrame *frame)
643 643
                s->bpp, s->bppcount);
644 644
         return AVERROR_INVALIDDATA;
645 645
     }
646
+
647
+    if (s->photometric == TIFF_PHOTOMETRIC_YCBCR) {
648
+        const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(s->avctx->pix_fmt);
649
+        if((desc->flags & AV_PIX_FMT_FLAG_RGB) || desc->nb_components < 3) {
650
+            av_log(s->avctx, AV_LOG_ERROR, "Unsupported YCbCr variant\n");
651
+            return AVERROR_INVALIDDATA;
652
+        }
653
+    }
654
+
646 655
     if (s->width != s->avctx->width || s->height != s->avctx->height) {
647 656
         ret = ff_set_dimensions(s->avctx, s->width, s->height);
648 657
         if (ret < 0)