Commit 1c71f185 authored by Michael Niedermayer's avatar Michael Niedermayer

avcodec/tiff_common: Improve formating of long arrays

Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 4d5d905e
......@@ -75,6 +75,15 @@ unsigned ff_tget(GetByteContext *gb, int type, int le)
}
}
static char *auto_sep(int count, char *sep, int i, int columns)
{
if (sep)
return i ? sep : "";
if (i && i%columns) {
return ", ";
} else
return columns < count ? "\n" : "";
}
int ff_tadd_rational_metadata(int count, const char *name, const char *sep,
GetByteContext *gb, int le, AVDictionary **metadata)
......@@ -88,14 +97,13 @@ int ff_tadd_rational_metadata(int count, const char *name, const char *sep,
return AVERROR_INVALIDDATA;
if (bytestream2_get_bytes_left(gb) < count * sizeof(int64_t))
return AVERROR_INVALIDDATA;
if (!sep) sep = ", ";
av_bprint_init(&bp, 10 * count, AV_BPRINT_SIZE_UNLIMITED);
for (i = 0; i < count; i++) {
nom = ff_tget_long(gb, le);
denom = ff_tget_long(gb, le);
av_bprintf(&bp, "%s%i:%i", (i ? sep : ""), nom, denom);
av_bprintf(&bp, "%s%7i:%-7i", auto_sep(count, sep, i, 4), nom, denom);
}
if ((i = av_bprint_finalize(&bp, &ap))) {
......@@ -122,12 +130,11 @@ int ff_tadd_long_metadata(int count, const char *name, const char *sep,
return AVERROR_INVALIDDATA;
if (bytestream2_get_bytes_left(gb) < count * sizeof(int32_t))
return AVERROR_INVALIDDATA;
if (!sep) sep = ", ";
av_bprint_init(&bp, 10 * count, AV_BPRINT_SIZE_UNLIMITED);
for (i = 0; i < count; i++) {
av_bprintf(&bp, "%s%i", (i ? sep : ""), ff_tget_long(gb, le));
av_bprintf(&bp, "%s%7i", auto_sep(count, sep, i, 8), ff_tget_long(gb, le));
}
if ((i = av_bprint_finalize(&bp, &ap))) {
......@@ -154,12 +161,11 @@ int ff_tadd_doubles_metadata(int count, const char *name, const char *sep,
return AVERROR_INVALIDDATA;
if (bytestream2_get_bytes_left(gb) < count * sizeof(int64_t))
return AVERROR_INVALIDDATA;
if (!sep) sep = ", ";
av_bprint_init(&bp, 10 * count, 100 * count);
for (i = 0; i < count; i++) {
av_bprintf(&bp, "%s%f", (i ? sep : ""), ff_tget_double(gb, le));
av_bprintf(&bp, "%s%f", auto_sep(count, sep, i, 4), ff_tget_double(gb, le));
}
if ((i = av_bprint_finalize(&bp, &ap))) {
......@@ -186,12 +192,11 @@ int ff_tadd_shorts_metadata(int count, const char *name, const char *sep,
return AVERROR_INVALIDDATA;
if (bytestream2_get_bytes_left(gb) < count * sizeof(int16_t))
return AVERROR_INVALIDDATA;
if (!sep) sep = ", ";
av_bprint_init(&bp, 10 * count, AV_BPRINT_SIZE_UNLIMITED);
for (i = 0; i < count; i++) {
av_bprintf(&bp, "%s%i", (i ? sep : ""), ff_tget_short(gb, le));
av_bprintf(&bp, "%s%5i", auto_sep(count, sep, i, 8), ff_tget_short(gb, le));
}
if ((i = av_bprint_finalize(&bp, &ap))) {
......@@ -218,12 +223,11 @@ int ff_tadd_bytes_metadata(int count, const char *name, const char *sep,
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_UNLIMITED);
for (i = 0; i < count; i++) {
av_bprintf(&bp, "%s%i", (i ? sep : ""), bytestream2_get_byte(gb));
av_bprintf(&bp, "%s%3i", auto_sep(count, sep, i, 16), bytestream2_get_byte(gb));
}
if ((i = av_bprint_finalize(&bp, &ap))) {
......
This diff is collapsed.
......@@ -20,6 +20,6 @@ interlaced_frame=0
top_field_first=0
repeat_pict=0
TAG:document_name=image_small.tiff
TAG:page_number=0 / 1
TAG:page_number= 0 / 1
TAG:software=ImageMagick 6.5.8-0 2010-02-09 Q16 http://www.imagemagick.org
[/FRAME]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment