[FFmpeg-devel] [PATCH] tiff: read more tags of type string
Paul B Mahol
onemda at gmail.com
Sat Jul 14 23:05:36 CEST 2012
Signed-off-by: Paul B Mahol <onemda at gmail.com>
---
libavcodec/tiff.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
libavcodec/tiff.h | 8 ++++++++
2 files changed, 52 insertions(+), 0 deletions(-)
diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 88f5238..95f21b8 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -280,12 +280,29 @@ static int add_shorts_metadata(const uint8_t **buf, int count, const char *name,
return 0;
}
+static int add_string_metadata(const uint8_t **buf, int count, const char *name,
+ TiffContext *s)
+{
+ char *value;
+
+ value = av_malloc(count + 1);
+ if (!value)
+ return AVERROR(ENOMEM);
+
+ memcpy(value, *buf, count);
+ value[count] = 0;
+
+ av_dict_set(&s->picture.metadata, name, value, AV_DICT_DONT_STRDUP_VAL);
+ return 0;
+}
+
static int add_metadata(const uint8_t **buf, int count, int type,
const char *name, const char *sep, TiffContext *s)
{
switch(type) {
case TIFF_DOUBLE: return add_doubles_metadata(buf, count, name, sep, s);
case TIFF_SHORT : return add_shorts_metadata(buf, count, name, sep, s);
+ case TIFF_STRING: return add_string_metadata(buf, count, name, s);
default : return AVERROR_INVALIDDATA;
};
}
@@ -901,6 +918,33 @@ static int tiff_decode_tag(TiffContext *s, const uint8_t *start,
}
}
break;
+ case TIFF_ARTIST:
+ ADD_METADATA(count, "artist", buf);
+ break;
+ case TIFF_COPYRIGHT:
+ ADD_METADATA(count, "copyright", buf);
+ break;
+ case TIFF_DATE:
+ ADD_METADATA(count, "date", buf);
+ break;
+ case TIFF_HOST_COMPUTER:
+ ADD_METADATA(count, "computer", buf);
+ break;
+ case TIFF_IMAGE_DESCRIPTION:
+ ADD_METADATA(count, "description", buf);
+ break;
+ case TIFF_MAKE:
+ ADD_METADATA(count, "make", buf);
+ break;
+ case TIFF_MODEL:
+ ADD_METADATA(count, "model", buf);
+ break;
+ case TIFF_PAGENAME:
+ ADD_METADATA(count, "page_name", buf);
+ break;
+ case TIFF_SOFTWARE_NAME:
+ ADD_METADATA(count, "software", buf);
+ 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..50e91b3 100644
--- a/libavcodec/tiff.h
+++ b/libavcodec/tiff.h
@@ -41,6 +41,9 @@ enum TiffTags{
TIFF_COMPR,
TIFF_INVERT = 0x106,
TIFF_FILL_ORDER = 0x10A,
+ TIFF_IMAGE_DESCRIPTION = 0x10E,
+ TIFF_MAKE = 0x10F,
+ TIFF_MODEL = 0x110,
TIFF_STRIP_OFFS = 0x111,
TIFF_SAMPLES_PER_PIXEL = 0x115,
TIFF_ROWSPERSTRIP = 0x116,
@@ -48,12 +51,16 @@ enum TiffTags{
TIFF_XRES = 0x11A,
TIFF_YRES = 0x11B,
TIFF_PLANAR = 0x11C,
+ TIFF_PAGENAME = 0x11D,
TIFF_XPOS = 0x11E,
TIFF_YPOS = 0x11F,
TIFF_T4OPTIONS = 0x124,
TIFF_T6OPTIONS,
TIFF_RES_UNIT = 0x128,
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 +71,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,
--
1.7.7
More information about the ffmpeg-devel
mailing list