summaryrefslogtreecommitdiff
path: root/libavcodec/tiff_common.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-09-24 20:50:22 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-09-29 12:19:47 +0200
commit7859e89ff0f9b3e701284230d275c59d8a5d615a (patch)
tree6f5295208efc2d33c8b32da8d5024528203d646c /libavcodec/tiff_common.c
parentd87ff555025e90ef285425216c29be95034e2485 (diff)
avcodec/tiff_common: add ff_tadd_bytes_metadata()
The le argument is passed so the function has the same prototype as the other similar functions. It is otherwise unused Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/tiff_common.c')
-rw-r--r--libavcodec/tiff_common.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/libavcodec/tiff_common.c b/libavcodec/tiff_common.c
index b7bd587bbd..130093547e 100644
--- a/libavcodec/tiff_common.c
+++ b/libavcodec/tiff_common.c
@@ -207,6 +207,37 @@ int ff_tadd_shorts_metadata(int count, const char *name, const char *sep,
}
+int ff_tadd_bytes_metadata(int count, const char *name, const char *sep,
+ GetByteContext *gb, int le, AVDictionary **metadata)
+{
+ AVBPrint bp;
+ char *ap;
+ int i;
+
+ if (count >= INT_MAX / sizeof(int8_t) || count <= 0)
+ return AVERROR_INVALIDDATA;
+ if (bytestream2_get_bytes_left(gb) < count * sizeof(int8_t))
+ return AVERROR_INVALIDDATA;
+ if (!sep) sep = ", ";
+
+ av_bprint_init(&bp, 10 * count, AV_BPRINT_SIZE_AUTOMATIC);
+
+ for (i = 0; i < count; i++) {
+ av_bprintf(&bp, "%s%i", (i ? sep : ""), bytestream2_get_byte(gb));
+ }
+
+ if ((i = av_bprint_finalize(&bp, &ap))) {
+ return i;
+ }
+ if (!ap) {
+ return AVERROR(ENOMEM);
+ }
+
+ av_dict_set(metadata, name, ap, AV_DICT_DONT_STRDUP_VAL);
+
+ return 0;
+}
+
int ff_tadd_string_metadata(int count, const char *name,
GetByteContext *gb, int le, AVDictionary **metadata)
{