[FFmpeg-cvslog] avcodec/tiff: Make pixel format checks tighter

Michael Niedermayer git at videolan.org
Sun Aug 24 02:12:36 CEST 2014


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sun Aug 24 01:54:45 2014 +0200| [ab1e4312887d8e560d027803871b55b883910714] | committer: Michael Niedermayer

avcodec/tiff: Make pixel format checks tighter

Fixes assertion failure with imgsrc001-lzma.tiff

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

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ab1e4312887d8e560d027803871b55b883910714
---

 libavcodec/tiff.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 613ad3d..1e2d235 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -490,7 +490,9 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, uint8_t *dst, int strid
     const uint8_t *ssrc = src;
     int width = ((s->width * s->bpp) + 7) >> 3;
     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(p->format);
-    int is_yuv = !(desc->flags & AV_PIX_FMT_FLAG_RGB) && desc->nb_components >= 2;
+    int is_yuv = !(desc->flags & AV_PIX_FMT_FLAG_RGB) &&
+                 (desc->flags & AV_PIX_FMT_FLAG_PLANAR) &&
+                 desc->nb_components >= 3;
 
     if (s->planar)
         width /= s->bppcount;
@@ -723,7 +725,9 @@ static int init_image(TiffContext *s, ThreadFrame *frame)
 
     if (s->photometric == TIFF_PHOTOMETRIC_YCBCR) {
         const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(s->avctx->pix_fmt);
-        if((desc->flags & AV_PIX_FMT_FLAG_RGB) || desc->nb_components < 3) {
+        if((desc->flags & AV_PIX_FMT_FLAG_RGB) ||
+           !(desc->flags & AV_PIX_FMT_FLAG_PLANAR) ||
+           desc->nb_components < 3) {
             av_log(s->avctx, AV_LOG_ERROR, "Unsupported YCbCr variant\n");
             return AVERROR_INVALIDDATA;
         }



More information about the ffmpeg-cvslog mailing list