diff mbox

[FFmpeg-devel] avcodec/tiff: correct the default value of YCbCrSubsampling

Message ID a8158908-b519-a8ea-4ca2-89d3f96a6502@gmail.com
State New
Headers show

Commit Message

Skakov Pavel Oct. 2, 2019, 1:20 a.m. UTC
>>> TIFF decoder uses wrong default YCbCrSubsampling value so it breaks
>>> on files that rely on standard default and omit the value.
> This patch broke fate-exif-image-tiff and fate-lavf-tiff.

Patch updated, fixed one more error in code: rps check used subsampling even for non-subsampled formats.
FATE should be happy with this.
diff mbox

Patch

From ecda81bd912581b5fb411dc83f51d1c7a5117b3b Mon Sep 17 00:00:00 2001
From: Pavel Skakov <pavelsx@gmail.com>
Date: Wed, 2 Oct 2019 04:14:32 +0300
Subject: [PATCH] avcodec/tiff: correct the default value of YCbCrSubsampling
 to 2x2

Signed-off-by: Pavel Skakov <pavelsx@gmail.com>
---
 libavcodec/tiff.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 9f24796a88..8b39ca1ebc 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -1869,7 +1869,7 @@  again:
                             avpkt->size - s->strippos);
         }
 
-        if (s->rps <= 0 || s->rps % s->subsampling[1]) {
+        if (s->rps <= 0 || s->photometric == TIFF_PHOTOMETRIC_YCBCR && s->rps % s->subsampling[1]) {
             av_log(avctx, AV_LOG_ERROR, "rps %d invalid\n", s->rps);
             return AVERROR_INVALIDDATA;
         }
@@ -2065,7 +2065,7 @@  static av_cold int tiff_init(AVCodecContext *avctx)
     s->width  = 0;
     s->height = 0;
     s->subsampling[0] =
-    s->subsampling[1] = 1;
+    s->subsampling[1] = 2;
     s->avctx  = avctx;
     ff_lzw_decode_open(&s->lzw);
     if (!s->lzw)
-- 
2.13.2.windows.1