[FFmpeg-devel] [PATCH 3/3] tiff: read more tags of type string
Paul B Mahol
onemda at gmail.com
Mon Jul 16 03:03:08 CEST 2012
Signed-off-by: Paul B Mahol <onemda at gmail.com>
---
libavcodec/tiff.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
libavcodec/tiff.h | 8 ++++++++
2 files changed, 55 insertions(+), 0 deletions(-)
diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 61a7f51..ebbb83c 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -287,12 +287,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;
};
}
@@ -907,6 +927,33 @@ 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_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_PAGENAME:
+ ADD_METADATA(count, "page_name", NULL);
+ 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..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