@@ -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);
+}
@@ -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 */
@@ -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");
}
@@ -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;
}
@@ -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);
This prevents potential ABI issues with GetByteContext. Signed-off-by: James Almer <jamrial@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(-)