diff mbox series

[FFmpeg-devel] tiff: add support for one more tag

Message ID CAPYw7P6bAU-gnEUcmnzW1e=QsL6HygmDTmFNZj1rTbFphGMtsw@mail.gmail.com
State New
Headers show
Series [FFmpeg-devel] tiff: add support for one more tag | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Paul B Mahol Oct. 2, 2022, 6:32 p.m. UTC
Patch attached.
diff mbox series

Patch

From c3dc0b0bf8fe84692ae0c877c6f33880ad7992c5 Mon Sep 17 00:00:00 2001
From: Paul B Mahol <onemda@gmail.com>
Date: Sun, 2 Oct 2022 20:32:34 +0200
Subject: [PATCH] avcodec/tiff: add support for one more tag

Also be less strict about tag order.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavcodec/tiff.c | 9 +++++++--
 libavcodec/tiff.h | 1 +
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index fd9db18c0b..0a8df6a788 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -1264,7 +1264,7 @@  static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
     if (ret < 0) {
         goto end;
     }
-    if (tag <= s->last_tag)
+    if (s->avctx->strict_std_compliance >= FF_COMPLIANCE_STRICT && tag <= s->last_tag)
         return AVERROR_INVALIDDATA;
 
     // We ignore TIFF_STRIP_SIZE as it is sometimes in the logic but wrong order around TIFF_STRIP_OFFS
@@ -1783,7 +1783,8 @@  static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
         }
         break;
     case DNG_AS_SHOT_NEUTRAL:
-        if (type != TIFF_RATIONAL)
+        if (type != TIFF_RATIONAL &&
+            type != TIFF_SHORT)
             break;
 
         for (int i = 0; i < 3; i++) {
@@ -1845,6 +1846,10 @@  static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
             }
         }
         break;
+    case DNG_PRIVATE_DATA:
+        for (int i = 0; i < count; i++)
+            ff_tget(&s->gb, type, s->le);
+        break;
     case CINEMADNG_TIME_CODES:
     case CINEMADNG_FRAME_RATE:
     case CINEMADNG_T_STOP:
diff --git a/libavcodec/tiff.h b/libavcodec/tiff.h
index e67c59abad..e491d8ea28 100644
--- a/libavcodec/tiff.h
+++ b/libavcodec/tiff.h
@@ -113,6 +113,7 @@  enum DngTags {
     DNG_ANALOG_BALANCE      = 0xC627,
     DNG_AS_SHOT_NEUTRAL     = 0xC628,
     DNG_AS_SHOT_WHITE_XY    = 0xC629,
+    DNG_PRIVATE_DATA        = 0xC634,
 };
 
 /** list of CinemaDNG tags */
-- 
2.37.2