[FFmpeg-cvslog] avcodec/tiff: improve lut handling for DNG

Paul B Mahol git at videolan.org
Fri Sep 23 21:29:16 EEST 2022


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Fri Sep 23 17:30:55 2022 +0200| [ec8be8a913d64af210afee27cbedfafcbcbd05c9] | committer: Paul B Mahol

avcodec/tiff: improve lut handling for DNG

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ec8be8a913d64af210afee27cbedfafcbcbd05c9
---

 libavcodec/tiff.c | 8 ++++----
 libavcodec/tiff.h | 1 +
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 226050744f..4da77a3a31 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -283,16 +283,15 @@ static uint16_t av_always_inline dng_process_color16(uint16_t value,
     float value_norm;
 
     // Lookup table lookup
-    if (lut)
-        value = lut[value];
+    value = lut[value];
 
     // Black level subtraction
     value = av_clip_uint16_c((unsigned)value - black_level);
 
     // Color scaling
-    value_norm = (float)value * scale_factor;
+    value_norm = (float)value * scale_factor * 65535.f;
 
-    value = av_clip_uint16_c(value_norm * 65535);
+    value = av_clip_uint16_c(lrintf(value_norm));
 
     return value;
 }
@@ -1414,6 +1413,7 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
         else if (count > 1)
             s->sub_ifd = ff_tget(&s->gb, TIFF_LONG, s->le); /** Only get the first SubIFD */
         break;
+    case TIFF_GRAY_RESPONSE_CURVE:
     case DNG_LINEARIZATION_TABLE:
         if (count > FF_ARRAY_ELEMS(s->dng_lut))
             return AVERROR_INVALIDDATA;
diff --git a/libavcodec/tiff.h b/libavcodec/tiff.h
index c07a5d4fa9..9d2ab90f52 100644
--- a/libavcodec/tiff.h
+++ b/libavcodec/tiff.h
@@ -66,6 +66,7 @@ enum TiffTags {
     TIFF_PAGE_NAME          = 0x11D,
     TIFF_XPOS               = 0x11E,
     TIFF_YPOS               = 0x11F,
+    TIFF_GRAY_RESPONSE_CURVE= 0x123,
     TIFF_T4OPTIONS          = 0x124,
     TIFF_T6OPTIONS,
     TIFF_RES_UNIT           = 0x128,



More information about the ffmpeg-cvslog mailing list