From: James Zern via ffmpeg-devel <ffmpeg-devel@ffmpeg.org> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Cc: James Zern <jzern@google.com>, Maryla Ustarroz-Calonge <maryla@google.com> Subject: Re: [FFmpeg-devel] [PATCH 1/2] avcodec/libaom: Add HDR10+ metadata support Date: Fri, 30 May 2025 13:01:50 -0700 Message-ID: <CABWgkXLdtVgt2iPmXcMpYh49KmPuTNJinQVsne1UdCP+2iLNzg@mail.gmail.com> (raw) In-Reply-To: <20250530105250.1968118-1-maryla@google.com> On Fri, May 30, 2025 at 3:52 AM Maryla Ustarroz-Calonge via ffmpeg-devel <ffmpeg-devel@ffmpeg.org> wrote: > > Signed-off-by: Maryla Ustarroz-Calonge <maryla@google.com> > --- > libavcodec/libaomdec.c | 62 ++++++++++++++++++++++++++++++++++++++++++ > libavcodec/libaomenc.c | 60 ++++++++++++++++++++++++++++++++++++++++ > libavcodec/version.h | 2 +- > 3 files changed, 123 insertions(+), 1 deletion(-) > > diff --git a/libavcodec/libaomdec.c b/libavcodec/libaomdec.c > index 69eec8b089..5995f0ab9b 100644 > --- a/libavcodec/libaomdec.c > +++ b/libavcodec/libaomdec.c > @@ -28,11 +28,15 @@ > > #include "libavutil/common.h" > #include "libavutil/cpu.h" > +#include "libavutil/hdr_dynamic_metadata.h" > #include "libavutil/imgutils.h" > > +#include "libavcodec/bytestream.h" This can be "bytestream.h" and added to the group below. > + > #include "avcodec.h" > #include "codec_internal.h" > #include "decode.h" > +#include "itut35.h" > #include "libaom.h" > #include "profiles.h" > > @@ -137,6 +141,59 @@ static int set_pix_fmt(AVCodecContext *avctx, struct aom_image *img) > } > } > > +static int decode_metadata_itu_t_t35(AVFrame *frame, > + const uint8_t *buffer, size_t buffer_size) > +{ > + if (buffer_size < 6) > + return AVERROR(EINVAL); > + > + GetByteContext bc; > + bytestream2_init(&bc, buffer, buffer_size); > + > + const int country_code = bytestream2_get_byteu(&bc); > + const int provider_code = bytestream2_get_be16u(&bc); > + const int provider_oriented_code = bytestream2_get_be16u(&bc); > + const int application_identifier = bytestream2_get_byteu(&bc); > + > + if (country_code == ITU_T_T35_COUNTRY_CODE_US > + && provider_code == ITU_T_T35_PROVIDER_CODE_SMTPE > + && provider_oriented_code == 1 > + && application_identifier == 4) { Is there a spec or other source that can be referenced for these values? The same goes for the setting of the values in libaomenc.c > [...] > diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c > index 9a384fcc39..4d899559d0 100644 > --- a/libavcodec/libaomenc.c > +++ b/libavcodec/libaomenc.c > @@ -33,12 +33,15 @@ > #include "libavutil/base64.h" > #include "libavutil/common.h" > #include "libavutil/cpu.h" > +#include "libavutil/hdr_dynamic_metadata.h" > #include "libavutil/imgutils.h" > #include "libavutil/mathematics.h" > #include "libavutil/mem.h" > #include "libavutil/opt.h" > #include "libavutil/pixdesc.h" > > +#include "libavcodec/bytestream.h" This can be "bytestream.h" and added to the group below. > + > #include "av1.h" > #include "avcodec.h" > #include "bsf.h" > @@ -46,6 +49,7 @@ > #include "dovi_rpu.h" > #include "encode.h" > #include "internal.h" > +#include "itut35.h" > #include "libaom.h" > #include "packet_internal.h" > #include "profiles.h" > @@ -326,6 +330,57 @@ static av_cold int codecctl_int(AVCodecContext *avctx, > return 0; > } > > +static int add_hdr_plus(AVCodecContext *avctx, struct aom_image *img, const AVFrame *frame) > +{ > + // Check for HDR10+ > + AVFrameSideData *side_data = > + av_frame_get_side_data(frame, AV_FRAME_DATA_DYNAMIC_HDR_PLUS); > + if (!side_data) > + return 0; > + > + size_t payload_size; > + AVDynamicHDRPlus *hdr_plus = (AVDynamicHDRPlus *)side_data->buf->data; > + int res = av_dynamic_hdr_plus_to_t35(hdr_plus, NULL, &payload_size); > + if (res < 0) { > + log_encoder_error(avctx, "Error finding the size of HDR10+"); > + return res; > + } > + > + uint8_t *hdr_plus_buf; > + // Extra bytes for the country code, provider code, provider oriented code and app id. > + const size_t hdr_plus_buf_size = payload_size + 6; > + hdr_plus_buf = av_malloc(hdr_plus_buf_size); > + if (!hdr_plus_buf) > + return AVERROR(ENOMEM); > + > + uint8_t *payload = hdr_plus_buf; > + bytestream_put_byte(&payload, ITU_T_T35_COUNTRY_CODE_US); > + bytestream_put_be16(&payload, ITU_T_T35_PROVIDER_CODE_SMTPE); > + bytestream_put_be16(&payload, 0x01); // provider_oriented_code > + bytestream_put_byte(&payload, 0x04); // application_identifier > + > + res = av_dynamic_hdr_plus_to_t35(hdr_plus, &payload, &payload_size); > + if (res < 0) { > + av_free(hdr_plus_buf); > + log_encoder_error(avctx, "Error encoding HDR10+ from side data"); > + return res; > + } > + > +#if AOM_IMAGE_ABI_VERSION < 8 This can be removed. configure requires libaom >= 2.0.0; in that version AOM_IMAGE_ABI_VERSION is 9. _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
prev parent reply other threads:[~2025-05-30 20:02 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2025-05-30 10:52 Maryla Ustarroz-Calonge via ffmpeg-devel 2025-05-30 10:52 ` [FFmpeg-devel] [PATCH 2/2] avcodec/libaom: Add tests for " Maryla Ustarroz-Calonge via ffmpeg-devel 2025-05-30 12:52 ` Andreas Rheinhardt 2025-06-02 9:34 ` Maryla Ustarroz via ffmpeg-devel 2025-06-05 7:27 ` Andreas Rheinhardt 2025-06-13 7:16 ` Maryla Ustarroz via ffmpeg-devel 2025-05-30 20:01 ` James Zern via ffmpeg-devel [this message]
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=CABWgkXLdtVgt2iPmXcMpYh49KmPuTNJinQVsne1UdCP+2iLNzg@mail.gmail.com \ --to=ffmpeg-devel@ffmpeg.org \ --cc=jzern@google.com \ --cc=maryla@google.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git