aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/tiff_common.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-09-29 22:08:08 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-10-03 18:47:50 +0200
commit1c71f185add9c1e449001c3a9726a26a167c9a23 (patch)
tree96ddb1d849c1512d631da544b83af27d47f3fc2d /libavcodec/tiff_common.c
parent4d5d905eed1e18cd688c3305b115fb07a2f105f5 (diff)
downloadffmpeg-1c71f185add9c1e449001c3a9726a26a167c9a23.tar.gz
avcodec/tiff_common: Improve formating of long arrays
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/tiff_common.c')
-rw-r--r--libavcodec/tiff_common.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/libavcodec/tiff_common.c b/libavcodec/tiff_common.c
index f051022952..6a10d71743 100644
--- a/libavcodec/tiff_common.c
+++ b/libavcodec/tiff_common.c
@@ -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))) {