This prevents potential ABI issues with GetByteContext. Signed-off-by: James Almer <jamr...@gmail.com> --- libavcodec/exif.c | 16 +++++++++++++--- libavcodec/exif.h | 6 ++++-- libavcodec/mjpegdec.c | 2 +- libavcodec/webp.c | 2 +- libavformat/avidec.c | 4 ++-- 5 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/libavcodec/exif.c b/libavcodec/exif.c index 07ce1741c2..2874772db4 100644 --- a/libavcodec/exif.c +++ b/libavcodec/exif.c @@ -92,7 +92,7 @@ static int exif_decode_tag(void *logctx, GetByteContext *gbytes, int le, // store metadata or proceed with next IFD ret = ff_tis_ifd(id); if (ret) { - ret = avpriv_exif_decode_ifd(logctx, gbytes, le, depth + 1, metadata); + ret = ff_exif_decode_ifd(logctx, gbytes, le, depth + 1, metadata); } else { const char *name = exif_get_tag_name(id); char *use_name = (char*) name; @@ -119,8 +119,8 @@ static int exif_decode_tag(void *logctx, GetByteContext *gbytes, int le, } -int avpriv_exif_decode_ifd(void *logctx, GetByteContext *gbytes, int le, - int depth, AVDictionary **metadata) +int ff_exif_decode_ifd(void *logctx, GetByteContext *gbytes, + int le, int depth, AVDictionary **metadata) { int i, ret; int entries; @@ -140,3 +140,13 @@ int avpriv_exif_decode_ifd(void *logctx, GetByteContext *gbytes, int le, // return next IDF offset or 0x000000000 or a value < 0 for failure return ff_tget_long(gbytes, le); } + +int avpriv_exif_decode_ifd(void *logctx, const uint8_t *buf, int size, + int le, int depth, AVDictionary **metadata) +{ + GetByteContext gb; + + bytestream2_init(&gb, buf, size); + + return ff_exif_decode_ifd(logctx, &gb, le, depth, metadata); +} diff --git a/libavcodec/exif.h b/libavcodec/exif.h index 5f09208b9d..314065b4b2 100644 --- a/libavcodec/exif.h +++ b/libavcodec/exif.h @@ -164,7 +164,9 @@ static const struct exif_tag tag_list[] = { // JEITA CP-3451 EXIF specification: /** Recursively decodes all IFD's and * adds included TAGS into the metadata dictionary. */ -int avpriv_exif_decode_ifd(void *logctx, GetByteContext *gbytes, int le, - int depth, AVDictionary **metadata); +int avpriv_exif_decode_ifd(void *logctx, const uint8_t *buf, int size, + int le, int depth, AVDictionary **metadata); +int ff_exif_decode_ifd(void *logctx, GetByteContext *gbytes, + int le, int depth, AVDictionary **metadata); #endif /* AVCODEC_EXIF_H */ diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 5b2409755c..d980ac99a1 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -1867,7 +1867,7 @@ static int mjpeg_decode_app(MJpegDecodeContext *s) // read 0th IFD and store the metadata // (return values > 0 indicate the presence of subimage metadata) - ret = avpriv_exif_decode_ifd(s->avctx, &gbytes, le, 0, &s->exif_metadata); + ret = ff_exif_decode_ifd(s->avctx, &gbytes, le, 0, &s->exif_metadata); if (ret < 0) { av_log(s->avctx, AV_LOG_ERROR, "mjpeg: error decoding EXIF data\n"); } diff --git a/libavcodec/webp.c b/libavcodec/webp.c index efa864a6f1..c8475faa2d 100644 --- a/libavcodec/webp.c +++ b/libavcodec/webp.c @@ -1504,7 +1504,7 @@ static int webp_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, } bytestream2_seek(&exif_gb, ifd_offset, SEEK_SET); - if (avpriv_exif_decode_ifd(avctx, &exif_gb, le, 0, &exif_metadata) < 0) { + if (ff_exif_decode_ifd(avctx, &exif_gb, le, 0, &exif_metadata) < 0) { av_log(avctx, AV_LOG_ERROR, "error decoding Exif data\n"); goto exif_end; } diff --git a/libavformat/avidec.c b/libavformat/avidec.c index b8a31dcff2..3ff515d492 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -401,10 +401,10 @@ static int avi_extract_stream_metadata(AVFormatContext *s, AVStream *st) // skip 4 byte padding bytestream2_skip(&gb, 4); offset = bytestream2_tell(&gb); - bytestream2_init(&gb, data + offset, data_size - offset); // decode EXIF tags from IFD, AVI is always little-endian - return avpriv_exif_decode_ifd(s, &gb, 1, 0, &st->metadata); + return avpriv_exif_decode_ifd(s, data + offset, data_size - offset, + 1, 0, &st->metadata); break; case MKTAG('C', 'A', 'S', 'I'): avpriv_request_sample(s, "RIFF stream data tag type CASI (%u)", tag); -- 2.14.2 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel