On Tue, Aug 19, 2025 at 06:33:03PM +0300, [email protected] wrote: > The branch, master has been updated > via 4c3f94f2651ce4d6834fbef10e5c287f25720ac9 (commit) > via fe496b0308f1911138698b92bbafac582fa455d7 (commit) > via 535a07d14e16eb2930d2b1e16605eafa95959139 (commit) > via 8132ee046d1a03c5913759c50fce7beda8d3d627 (commit) <-------- we > are here > via 5d4f873ff31f86f9ae1927f37ca0fcb78da70512 (commit) > via 1e816ebefee0ef479fa76bd2a1fb9ec5d5e807df (commit) > via 93a8091015978c44462626409af71789080bbef4 (commit) > via 303f60684f25ce63951480ef0f759acf41aac938 (commit) > via 5caaadee7954f2014d9e0a17d1edfb961893bcf1 (commit) > via d3190a64c366a79091fe47fddf93c09a7d988802 (commit) > via 44af3829796427b89c4b76b56652cc5932ada616 (commit) > via f5ad1c910c168d05cb01315773ab0bd094c9372f (commit) > via e3aa1154aab2656c91ce61915f79516d9b563b61 (commit) > via c6cc2115f45ac26ae42442f8796996eb410f4028 (commit) > via 52dba25661305e3c4a6209d46aea43cd327c960e (commit) > via bfb17d26306592c85cf0c4e909099c621177b062 (commit) > via ba2ea285e0f270a0a885b414cafaace6a89b9a91 (commit) > via ad77345a5d14862f4701e5ad422b03b14934a5b9 (commit) > via bb90b262d6d23f1bca3587a48abc15b951cbbf05 (commit) > via a99fff4e2d4058c57599ba0b968862af82bdad5b (commit) > from a6b5a382dd7ecdd27c5d0ebba688e1db409d18fd (commit) > > > commit 8132ee046d1a03c5913759c50fce7beda8d3d627 > Author: Leo Izen <[email protected]> > AuthorDate: Sat Apr 12 23:44:42 2025 -0400 > Commit: Leo Izen <[email protected]> > CommitDate: Tue Aug 19 11:26:48 2025 -0400 > > avcodec/libjxldec: read EXIF metadata from container JPEG XL files > > libjxl provides the ability to get EXIF metadata from an ISO18181-2 > JPEG XL container file. This commit enables reading it and attaching > it to an AVFrame using the new EXIF API. > > Signed-off-by: Leo Izen <[email protected]> > > diff --git a/libavcodec/libjxldec.c b/libavcodec/libjxldec.c > index 96c338d1b4..7ea5fc4787 100644 > --- a/libavcodec/libjxldec.c > +++ b/libavcodec/libjxldec.c > @@ -29,6 +29,7 @@ > #include "libavutil/common.h" > #include "libavutil/csp.h" > #include "libavutil/error.h" > +#include "libavutil/intreadwrite.h" > #include "libavutil/mem.h" > #include "libavutil/pixdesc.h" > #include "libavutil/pixfmt.h" > @@ -37,6 +38,7 @@ > #include "avcodec.h" > #include "codec_internal.h" > #include "decode.h" > +#include "exif_internal.h" > #include "internal.h" > > #include <jxl/decode.h> > @@ -59,6 +61,8 @@ typedef struct LibJxlDecodeContext { > int prev_is_last; > AVRational anim_timebase; > AVFrame *frame; > + AVBufferRef *exif; > + size_t exif_pos; > } LibJxlDecodeContext; > > static int libjxl_init_jxl_decoder(AVCodecContext *avctx) > @@ -66,17 +70,24 @@ static int libjxl_init_jxl_decoder(AVCodecContext *avctx) > LibJxlDecodeContext *ctx = avctx->priv_data; > > ctx->events = JXL_DEC_BASIC_INFO | JXL_DEC_FULL_IMAGE > - | JXL_DEC_COLOR_ENCODING | JXL_DEC_FRAME; > + | JXL_DEC_COLOR_ENCODING | JXL_DEC_FRAME > + | JXL_DEC_BOX | JXL_DEC_BOX_COMPLETE; > if (JxlDecoderSubscribeEvents(ctx->decoder, ctx->events) != > JXL_DEC_SUCCESS) { > av_log(avctx, AV_LOG_ERROR, "Error subscribing to JXL events\n"); > return AVERROR_EXTERNAL; > } > > + if (JxlDecoderSetDecompressBoxes(ctx->decoder, JXL_TRUE) != > JXL_DEC_SUCCESS) { > + av_log(avctx, AV_LOG_ERROR, "Error setting compress box mode\n"); > + return AVERROR_EXTERNAL; > + } > + > if (JxlDecoderSetParallelRunner(ctx->decoder, JxlThreadParallelRunner, > ctx->runner) != JXL_DEC_SUCCESS) { > av_log(avctx, AV_LOG_ERROR, "Failed to set > JxlThreadParallelRunner\n"); > return AVERROR_EXTERNAL; > } > > + av_buffer_unref(&ctx->exif); > memset(&ctx->basic_info, 0, sizeof(JxlBasicInfo)); > memset(&ctx->jxl_pixfmt, 0, sizeof(JxlPixelFormat)); > ctx->prev_is_last = 1; > @@ -487,6 +498,28 @@ static int libjxl_receive_frame(AVCodecContext *avctx, > AVFrame *frame) > if (ret < 0) > return ret; > } > + if (ctx->exif) { > + AVExifMetadata ifd = { 0 }; > + /* size may be larger than exif_pos due to the realloc loop > */ > + ret = av_exif_parse_buffer(avctx, ctx->exif->data, > ctx->exif_pos, &ifd, AV_EXIF_T_OFF); > + av_buffer_unref(&ctx->exif); > + if (ret < 0) { > + av_log(avctx, AV_LOG_ERROR, "Unable to parse EXIF > buffer\n"); > + continue; > + } > + /* > + * JPEG XL Codestream orientation overrides EXIF orientation > in all cases. > + * As a result, we remove the EXIF Orientation tag rather > than just zeroing it > + * in order to prevent any ambiguity. libjxl autorotates the > image for us so we > + * do not need to worry about that. > + */ > + ret = av_exif_remove_entry(avctx, &ifd, > av_exif_get_tag_id("Orientation"), 0); > + if (ret < 0) > + av_log(avctx, AV_LOG_WARNING, "Unable to remove > orientation from EXIF buffer\n"); > + ret = ff_exif_attach_ifd(avctx, ctx->frame, &ifd); > + if (ret < 0) > + av_log(avctx, AV_LOG_ERROR, "Unable to attach EXIF > ifd\n"); > + }
i think ifd leaks thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB When you are offended at any man's fault, turn to yourself and study your own failings. Then you will forget your anger. -- Epictetus
signature.asc
Description: PGP signature
_______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
