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

velocityra at gmail.com velocityra at gmail.com
Thu Aug 8 23:52:33 EEST 2019


From: Nick Renieris <velocityra at 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 at gmail.com>
---
 libavcodec/tiff.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

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++) {
-- 
2.21.0.windows.1



More information about the ffmpeg-devel mailing list