]> git.sesse.net Git - ffmpeg/commitdiff
tiffdec: support embedded ICC profiles
authorLynne <dev@lynne.ee>
Fri, 10 Jan 2020 21:55:19 +0000 (21:55 +0000)
committerLynne <dev@lynne.ee>
Mon, 13 Jan 2020 23:26:25 +0000 (23:26 +0000)
libavcodec/tiff.c
libavcodec/tiff.h

index 636614aa2806688af442aed78a2cc32513e6f887..e8357114deb5d5910adcd9e253d56c55114b5e7b 100644 (file)
@@ -1218,6 +1218,8 @@ static void set_sar(TiffContext *s, unsigned tag, unsigned num, unsigned den)
 
 static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
 {
+    AVFrameSideData *sd;
+    GetByteContext gb_temp;
     unsigned tag, type, count, off, value = 0, value2 = 1; // value2 is a denominator so init. to 1
     int i, start;
     int pos;
@@ -1643,6 +1645,22 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
             }
         }
         break;
+    case TIFF_ICC_PROFILE:
+        if (type != TIFF_UNDEFINED)
+            return AVERROR_INVALIDDATA;
+
+        gb_temp = s->gb;
+        bytestream2_seek(&gb_temp, SEEK_SET, off);
+
+        if (bytestream2_get_bytes_left(&gb_temp) < count)
+            return AVERROR_INVALIDDATA;
+
+        sd = av_frame_new_side_data(frame, AV_FRAME_DATA_ICC_PROFILE, count);
+        if (!sd)
+            return AVERROR(ENOMEM);
+
+        bytestream2_get_bufferu(&gb_temp, sd->data, count);
+        break;
     case TIFF_ARTIST:
         ADD_METADATA(count, "artist", NULL);
         break;
index 2184c2c8296821661cafa3226ac6f4489fb66f54..c07a5d4fa934ad4910cf1a4a2ef613cf33646a38 100644 (file)
@@ -92,6 +92,7 @@ enum TiffTags {
     TIFF_MODEL_TIEPOINT     = 0x8482,
     TIFF_MODEL_PIXEL_SCALE  = 0x830E,
     TIFF_MODEL_TRANSFORMATION= 0x8480,
+    TIFF_ICC_PROFILE        = 0x8773,
     TIFF_GEO_KEY_DIRECTORY  = 0x87AF,
     TIFF_GEO_DOUBLE_PARAMS  = 0x87B0,
     TIFF_GEO_ASCII_PARAMS   = 0x87B1,