diff options
author | Leo Izen <[email protected]> | 2025-03-12 11:27:13 -0400 |
---|---|---|
committer | Leo Izen <[email protected]> | 2025-08-19 11:26:47 -0400 |
commit | c6cc2115f45ac26ae42442f8796996eb410f4028 (patch) | |
tree | a3a3d8e4d332bbb5c96c39283af4efa777c684da | |
parent | 52dba25661305e3c4a6209d46aea43cd327c960e (diff) |
avcodec/webp: use new EXIF parse API
Switch over to the new API to parse EXIF metadata.
Signed-off-by: Leo Izen <[email protected]>
-rw-r--r-- | libavcodec/webp.c | 28 | ||||
-rw-r--r-- | tests/ref/fate/exif-image-webp | 3 |
2 files changed, 15 insertions, 16 deletions
diff --git a/libavcodec/webp.c b/libavcodec/webp.c index 489cf6f016..56c3ec6d28 100644 --- a/libavcodec/webp.c +++ b/libavcodec/webp.c @@ -1456,38 +1456,34 @@ FF_ENABLE_DEPRECATION_WARNINGS break; } case MKTAG('E', 'X', 'I', 'F'): { - int le, ifd_offset, exif_offset = bytestream2_tell(&gb); - AVDictionary *exif_metadata = NULL; - GetByteContext exif_gb; + AVBufferRef *exif_buf = NULL; if (s->has_exif) { av_log(avctx, AV_LOG_VERBOSE, "Ignoring extra EXIF chunk\n"); goto exif_end; } + if (!(vp8x_flags & VP8X_FLAG_EXIF_METADATA)) av_log(avctx, AV_LOG_WARNING, "EXIF chunk present, but Exif bit not set in the " "VP8X header\n"); - s->has_exif = 1; - bytestream2_init(&exif_gb, avpkt->data + exif_offset, - avpkt->size - exif_offset); - if (ff_tdecode_header(&exif_gb, &le, &ifd_offset) < 0) { - av_log(avctx, AV_LOG_ERROR, "invalid TIFF header " - "in Exif data\n"); + exif_buf = av_buffer_alloc(chunk_size); + if (!exif_buf) { + av_log(avctx, AV_LOG_WARNING, "unable to allocate EXIF buffer\n"); goto exif_end; } + s->has_exif = 1; + memcpy(exif_buf->data, gb.buffer, chunk_size); - bytestream2_seek(&exif_gb, ifd_offset, SEEK_SET); - 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; + /* if this succeeds then exif_buf is either freed or transferred to the AVFrame */ + ret = ff_exif_attach_buffer(avctx, p, exif_buf, AV_EXIF_TIFF_HEADER); + if (ret < 0) { + av_log(avctx, AV_LOG_WARNING, "unable to attach EXIF buffer\n"); + av_buffer_unref(&exif_buf); } - av_dict_copy(&p->metadata, exif_metadata, 0); - exif_end: - av_dict_free(&exif_metadata); bytestream2_skip(&gb, chunk_size); break; } diff --git a/tests/ref/fate/exif-image-webp b/tests/ref/fate/exif-image-webp index 3a0e6e2c24..7c01ae3d66 100644 --- a/tests/ref/fate/exif-image-webp +++ b/tests/ref/fate/exif-image-webp @@ -197,4 +197,7 @@ TAG:ExifIFD/ExposureMode= 0 TAG:ExifIFD/WhiteBalance= 0 TAG:ExifIFD/DigitalZoomRatio= 4000:4000 TAG:ExifIFD/SceneCaptureType= 0 +[SIDE_DATA] +side_data_type=EXIF metadata +[/SIDE_DATA] [/FRAME] |