[FFmpeg-devel,v11,14/14] lavc/tiff: Initialize WhiteLevel DNG tag value

Submitted by velocityra@gmail.com on Aug. 8, 2019, 8:52 p.m.

Details

Message ID 20190808205233.16368-14-velocityra@gmail.com
State New
Headers show

Commit Message

velocityra@gmail.com Aug. 8, 2019, 8:52 p.m.
From: Nick Renieris <velocityra@gmail.com>

Inited to (2^BitsPerSample)-1 as per the DNG Specification

This fixes decoding for "X7 CinemaDNG" samples here:
- https://www.dji.com/gr/zenmuse-x7/info#downloads

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

Patch hide | download patch | download mbox

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 47140cddbc..47f2a5a441 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -1787,7 +1787,7 @@  again:
     s->photometric = TIFF_PHOTOMETRIC_NONE;
     s->compr       = TIFF_RAW;
     s->fill_order  = 0;
-    s->white_level = 0;
+    s->white_level = (1 << s->bpp) - 1; /* Default value as per the spec */
     s->is_bayer    = 0;
     s->is_tiled    = 0;
     s->is_jpeg     = 0;
@@ -2044,7 +2044,7 @@  again:
         FFSWAP(int,      p->linesize[0], p->linesize[1]);
     }
 
-    if (s->is_bayer && s->white_level && s->bpp == 16 &&
+    if (s->is_bayer && (s->white_level != (1 << s->bpp) - 1) && s->bpp == 16 &&
         !(s->tiff_type == TIFF_TYPE_DNG || s->tiff_type == TIFF_TYPE_CINEMADNG)) {
         uint16_t *dst = (uint16_t *)p->data[0];
         for (i = 0; i < s->height; i++) {