[FFmpeg-devel,v10,07/13] lavc/tiff: Don't apply strips-related logic to tiled images

Submitted by velocityra@gmail.com on Aug. 7, 2019, 3:27 p.m.

Details

Message ID 20190807152723.18892-7-velocityra@gmail.com
State New
Headers show

Commit Message

velocityra@gmail.com Aug. 7, 2019, 3:27 p.m.
From: Nick Renieris <velocityra@gmail.com>

Signed-off-by: Nick Renieris <velocityra@gmail.com>
---
 libavcodec/tiff.c | 42 ++++++++++++++++++++++--------------------
 1 file changed, 22 insertions(+), 20 deletions(-)

Patch hide | download patch | download mbox

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index f577639dfa..8db42d2bc5 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -1780,7 +1780,7 @@  again:
         }
     }
 
-    if (!s->strippos && !s->stripoff) {
+    if (!s->is_tiled && !s->strippos && !s->stripoff) {
         av_log(avctx, AV_LOG_ERROR, "Image data is missing\n");
         return AVERROR_INVALIDDATA;
     }
@@ -1788,27 +1788,29 @@  again:
     if ((ret = init_image(s, &frame)) < 0)
         return ret;
 
-    if (s->strips == 1 && !s->stripsize) {
-        av_log(avctx, AV_LOG_WARNING, "Image data size missing\n");
-        s->stripsize = avpkt->size - s->stripoff;
-    }
+    if (!s->is_tiled) {
+        if (s->strips == 1 && !s->stripsize) {
+            av_log(avctx, AV_LOG_WARNING, "Image data size missing\n");
+            s->stripsize = avpkt->size - s->stripoff;
+        }
 
-    if (s->stripsizesoff) {
-        if (s->stripsizesoff >= (unsigned)avpkt->size)
-            return AVERROR_INVALIDDATA;
-        bytestream2_init(&stripsizes, avpkt->data + s->stripsizesoff,
-                         avpkt->size - s->stripsizesoff);
-    }
-    if (s->strippos) {
-        if (s->strippos >= (unsigned)avpkt->size)
-            return AVERROR_INVALIDDATA;
-        bytestream2_init(&stripdata, avpkt->data + s->strippos,
-                         avpkt->size - s->strippos);
-    }
+        if (s->stripsizesoff) {
+            if (s->stripsizesoff >= (unsigned)avpkt->size)
+                return AVERROR_INVALIDDATA;
+            bytestream2_init(&stripsizes, avpkt->data + s->stripsizesoff,
+                            avpkt->size - s->stripsizesoff);
+        }
+        if (s->strippos) {
+            if (s->strippos >= (unsigned)avpkt->size)
+                return AVERROR_INVALIDDATA;
+            bytestream2_init(&stripdata, avpkt->data + s->strippos,
+                            avpkt->size - s->strippos);
+        }
 
-    if (s->rps <= 0 || s->rps % s->subsampling[1]) {
-        av_log(avctx, AV_LOG_ERROR, "rps %d invalid\n", s->rps);
-        return AVERROR_INVALIDDATA;
+        if (s->rps <= 0 || s->rps % s->subsampling[1]) {
+            av_log(avctx, AV_LOG_ERROR, "rps %d invalid\n", s->rps);
+            return AVERROR_INVALIDDATA;
+        }
     }
 
     /* Handle DNG images with JPEG-compressed tiles */