diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-04-20 02:58:02 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-04-20 17:01:46 +0200 |
commit | a94de50ba02f5c260ca7c571b43fb595c8f951b6 (patch) | |
tree | 08a113eb6a16415a16c48442fc5ff800e0664c65 | |
parent | cd4faed89378dfb9ba4c985ef661d10c0d7e7b7e (diff) | |
download | ffmpeg-a94de50ba02f5c260ca7c571b43fb595c8f951b6.tar.gz |
avcodec/exif/exif_add_metadata: add support for SSHORT & SBYTE
No working testcase, this omission was just spoted when the parser apparently went out of
sync.
Reviewed-by; Thilo Borgmann <thilo.borgmann@mail.de>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavcodec/exif.c | 6 | ||||
-rw-r--r-- | libavcodec/tiff.c | 2 | ||||
-rw-r--r-- | libavcodec/tiff_common.c | 10 | ||||
-rw-r--r-- | libavcodec/tiff_common.h | 4 |
4 files changed, 13 insertions, 9 deletions
diff --git a/libavcodec/exif.c b/libavcodec/exif.c index 984adafd10..0f3f80c976 100644 --- a/libavcodec/exif.c +++ b/libavcodec/exif.c @@ -48,9 +48,11 @@ static int exif_add_metadata(AVCodecContext *avctx, int count, int type, { switch(type) { case TIFF_DOUBLE : return ff_tadd_doubles_metadata(count, name, sep, gb, le, metadata); - case TIFF_SHORT : return ff_tadd_shorts_metadata(count, name, sep, gb, le, metadata); + case TIFF_SSHORT : return ff_tadd_shorts_metadata(count, name, sep, gb, le, 1, metadata); + case TIFF_SHORT : return ff_tadd_shorts_metadata(count, name, sep, gb, le, 0, metadata); + case TIFF_SBYTE : return ff_tadd_bytes_metadata(count, name, sep, gb, le, 1, metadata); case TIFF_BYTE : - case TIFF_UNDEFINED: return ff_tadd_bytes_metadata(count, name, sep, gb, le, metadata); + case TIFF_UNDEFINED: return ff_tadd_bytes_metadata(count, name, sep, gb, le, 0, metadata); case TIFF_STRING : return ff_tadd_string_metadata(count, name, gb, le, metadata); case TIFF_SRATIONAL: case TIFF_RATIONAL : return ff_tadd_rational_metadata(count, name, sep, gb, le, metadata); diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c index af1b4e07b6..c6193ad47a 100644 --- a/libavcodec/tiff.c +++ b/libavcodec/tiff.c @@ -221,7 +221,7 @@ static int add_metadata(int count, int type, { switch(type) { case TIFF_DOUBLE: return ff_tadd_doubles_metadata(count, name, sep, &s->gb, s->le, avpriv_frame_get_metadatap(frame)); - case TIFF_SHORT : return ff_tadd_shorts_metadata(count, name, sep, &s->gb, s->le, avpriv_frame_get_metadatap(frame)); + case TIFF_SHORT : return ff_tadd_shorts_metadata(count, name, sep, &s->gb, s->le, 0, avpriv_frame_get_metadatap(frame)); case TIFF_STRING: return ff_tadd_string_metadata(count, name, &s->gb, s->le, avpriv_frame_get_metadatap(frame)); default : return AVERROR_INVALIDDATA; }; diff --git a/libavcodec/tiff_common.c b/libavcodec/tiff_common.c index f14ecf1769..35119af558 100644 --- a/libavcodec/tiff_common.c +++ b/libavcodec/tiff_common.c @@ -176,7 +176,7 @@ int ff_tadd_doubles_metadata(int count, const char *name, const char *sep, int ff_tadd_shorts_metadata(int count, const char *name, const char *sep, - GetByteContext *gb, int le, AVDictionary **metadata) + GetByteContext *gb, int le, int is_signed, AVDictionary **metadata) { AVBPrint bp; char *ap; @@ -190,7 +190,8 @@ int ff_tadd_shorts_metadata(int count, const char *name, const char *sep, av_bprint_init(&bp, 10 * count, AV_BPRINT_SIZE_UNLIMITED); for (i = 0; i < count; i++) { - av_bprintf(&bp, "%s%5i", auto_sep(count, sep, i, 8), ff_tget_short(gb, le)); + int v = is_signed ? (int16_t)ff_tget_short(gb, le) : ff_tget_short(gb, le); + av_bprintf(&bp, "%s%5i", auto_sep(count, sep, i, 8), v); } if ((i = av_bprint_finalize(&bp, &ap))) { @@ -207,7 +208,7 @@ 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) + GetByteContext *gb, int le, int is_signed, AVDictionary **metadata) { AVBPrint bp; char *ap; @@ -221,7 +222,8 @@ int ff_tadd_bytes_metadata(int count, const char *name, const char *sep, av_bprint_init(&bp, 10 * count, AV_BPRINT_SIZE_UNLIMITED); for (i = 0; i < count; i++) { - av_bprintf(&bp, "%s%3i", auto_sep(count, sep, i, 16), bytestream2_get_byte(gb)); + int v = is_signed ? (int8_t)bytestream2_get_byte(gb) : bytestream2_get_byte(gb); + av_bprintf(&bp, "%s%3i", auto_sep(count, sep, i, 16), v); } if ((i = av_bprint_finalize(&bp, &ap))) { diff --git a/libavcodec/tiff_common.h b/libavcodec/tiff_common.h index 01a7b0891b..16c9e50850 100644 --- a/libavcodec/tiff_common.h +++ b/libavcodec/tiff_common.h @@ -121,13 +121,13 @@ int ff_tadd_doubles_metadata(int count, const char *name, const char *sep, * into the metadata dictionary. */ int ff_tadd_shorts_metadata(int count, const char *name, const char *sep, - GetByteContext *gb, int le, AVDictionary **metadata); + GetByteContext *gb, int le, int is_signed, AVDictionary **metadata); /** Adds count bytes converted to a string * into the metadata dictionary. */ int ff_tadd_bytes_metadata(int count, const char *name, const char *sep, - GetByteContext *gb, int le, AVDictionary **metadata); + GetByteContext *gb, int le, int is_signed, AVDictionary **metadata); /** Adds a string of count characters * into the metadata dictionary. |