[FFmpeg-cvslog] tiff: read more tags of type string

Paul B Mahol git at videolan.org
Tue Jul 17 03:35:06 CEST 2012


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Mon Jul 16 00:55:18 2012 +0000| [3071af6cf20c0d8a7d91b68fdd1308d9eda48e69] | committer: Paul B Mahol

tiff: read more tags of type string

Signed-off-by: Paul B Mahol <onemda at gmail.com>

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

 libavcodec/tiff.c |   53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 libavcodec/tiff.h |   10 ++++++++++
 2 files changed, 63 insertions(+)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index d3ec466..47c8645 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -291,12 +291,32 @@ static int add_shorts_metadata(int count, const char *name,
     return 0;
 }
 
+static int add_string_metadata(int count, const char *name,
+                               TiffContext *s)
+{
+    char *value;
+
+    if (bytestream2_get_bytes_left(&s->gb) < count)
+        return AVERROR_INVALIDDATA;
+
+    value = av_malloc(count + 1);
+    if (!value)
+        return AVERROR(ENOMEM);
+
+    bytestream2_get_bufferu(&s->gb, value, count);
+    value[count] = 0;
+
+    av_dict_set(&s->picture.metadata, name, value, AV_DICT_DONT_STRDUP_VAL);
+    return 0;
+}
+
 static int add_metadata(int count, int type,
                         const char *name, const char *sep, TiffContext *s)
 {
     switch(type) {
     case TIFF_DOUBLE: return add_doubles_metadata(count, name, sep, s);
     case TIFF_SHORT : return add_shorts_metadata(count, name, sep, s);
+    case TIFF_STRING: return add_string_metadata(count, name, s);
     default         : return AVERROR_INVALIDDATA;
     };
 }
@@ -913,6 +933,39 @@ static int tiff_decode_tag(TiffContext *s)
             }
         }
         break;
+    case TIFF_ARTIST:
+        ADD_METADATA(count, "artist", NULL);
+        break;
+    case TIFF_COPYRIGHT:
+        ADD_METADATA(count, "copyright", NULL);
+        break;
+    case TIFF_DATE:
+        ADD_METADATA(count, "date", NULL);
+        break;
+    case TIFF_DOCUMENT_NAME:
+        ADD_METADATA(count, "document_name", NULL);
+        break;
+    case TIFF_HOST_COMPUTER:
+        ADD_METADATA(count, "computer", NULL);
+        break;
+    case TIFF_IMAGE_DESCRIPTION:
+        ADD_METADATA(count, "description", NULL);
+        break;
+    case TIFF_MAKE:
+        ADD_METADATA(count, "make", NULL);
+        break;
+    case TIFF_MODEL:
+        ADD_METADATA(count, "model", NULL);
+        break;
+    case TIFF_PAGE_NAME:
+        ADD_METADATA(count, "page_name", NULL);
+        break;
+    case TIFF_PAGE_NUMBER:
+        ADD_METADATA(count, "page_number", " / ");
+        break;
+    case TIFF_SOFTWARE_NAME:
+        ADD_METADATA(count, "software", NULL);
+        break;
     default:
         av_log(s->avctx, AV_LOG_DEBUG, "Unknown or unsupported tag %d/0X%0X\n",
                tag, tag);
diff --git a/libavcodec/tiff.h b/libavcodec/tiff.h
index 258f10b..0abeb8c 100644
--- a/libavcodec/tiff.h
+++ b/libavcodec/tiff.h
@@ -41,6 +41,10 @@ enum TiffTags{
     TIFF_COMPR,
     TIFF_INVERT = 0x106,
     TIFF_FILL_ORDER = 0x10A,
+    TIFF_DOCUMENT_NAME = 0x10D,
+    TIFF_IMAGE_DESCRIPTION = 0x10E,
+    TIFF_MAKE = 0x10F,
+    TIFF_MODEL = 0x110,
     TIFF_STRIP_OFFS = 0x111,
     TIFF_SAMPLES_PER_PIXEL = 0x115,
     TIFF_ROWSPERSTRIP = 0x116,
@@ -48,12 +52,17 @@ enum TiffTags{
     TIFF_XRES = 0x11A,
     TIFF_YRES = 0x11B,
     TIFF_PLANAR = 0x11C,
+    TIFF_PAGE_NAME = 0x11D,
     TIFF_XPOS = 0x11E,
     TIFF_YPOS = 0x11F,
     TIFF_T4OPTIONS = 0x124,
     TIFF_T6OPTIONS,
     TIFF_RES_UNIT = 0x128,
+    TIFF_PAGE_NUMBER = 0x129,
     TIFF_SOFTWARE_NAME = 0x131,
+    TIFF_DATE = 0x132,
+    TIFF_ARTIST = 0x13B,
+    TIFF_HOST_COMPUTER = 0x13C,
     TIFF_PREDICTOR = 0x13D,
     TIFF_PAL = 0x140,
     TIFF_TILE_WIDTH = 0x142,
@@ -64,6 +73,7 @@ enum TiffTags{
     TIFF_YCBCR_SUBSAMPLING = 0x212,
     TIFF_YCBCR_POSITIONING = 0x213,
     TIFF_REFERENCE_BW = 0x214,
+    TIFF_COPYRIGHT = 0x8298,
     TIFF_MODEL_TIEPOINT = 0x8482,
     TIFF_MODEL_PIXEL_SCALE = 0x830E,
     TIFF_MODEL_TRANSFORMATION = 0x8480,



More information about the ffmpeg-cvslog mailing list