[PR] avutil/hdr_dynamic_metadata: fix from_t35 NULL return and version doc (PR #24013)
Marcos Ashton via ffmpeg-devel <[email protected]> Tue, 04 Aug 2026 21:33:59 -0000
| Newsgroups | gmane.comp.video.ffmpeg.devel |
|---|---|
| Message-ID | <178587924025.59.501403937729624334@29965ddac10e> |
PR #24013 opened by Marcos Ashton (MarcosAsh) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24013 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24013.patch ## Summary av_dynamic_hdr_plus_from_t35() returns AVERROR(ENOMEM) when passed a NULL AVDynamicHDRPlus. A NULL output struct is invalid API usage by the caller, not an allocation failure, and nothing is allocated on that path. av_dynamic_hdr_smpte2094_app5_from_t35() already returns AVERROR(EINVAL) for the same condition. This switches it to AVERROR(EINVAL) so the two parsers agree. Both in-tree callers (libavformat/matroskadec.c and libavcodec/itut35.c) allocate the struct before calling and only propagate the return value, so neither changes behavior. Also corrects the documentation for AVDynamicHDRPlus.application_version, which says the value shall be set to 0. That contradicts both sides of the implementation: av_dynamic_hdr_plus_to_t35() ignores the field and always writes 1, the value CTA-861-H specifies for the HDR10+ payload, and av_dynamic_hdr_plus_from_t35() sets it from the parsed payload rather than validating it against 0. No in-tree code assigns the field. >From 01b5a15c68b80a10bb3dac5691aef1adad953bde Mon Sep 17 00:00:00 2001 From: Marcos Ashton Iglesias <[email protected]> Date: Tue, 4 Aug 2026 22:15:17 +0100 Subject: [PATCH] avutil/hdr_dynamic_metadata: fix from_t35 NULL return and version doc av_dynamic_hdr_plus_from_t35() returned AVERROR(ENOMEM) when passed a NULL AVDynamicHDRPlus. A NULL output struct is invalid API usage by the caller, not an allocation failure, and nothing is allocated on that path. av_dynamic_hdr_smpte2094_app5_from_t35() already returns AVERROR(EINVAL) for the same condition; make the two parsers agree. The documentation for AVDynamicHDRPlus.application_version said the value shall be set to 0, which contradicts both sides of the implementation: av_dynamic_hdr_plus_to_t35() ignores the field and always writes 1, the value CTA-861-H specifies for the HDR10+ payload, and av_dynamic_hdr_plus_from_t35() sets the field from the parsed payload rather than validating it against 0. No FFmpeg code assigns this field, so document the contract the implementation provides. Signed-off-by: marcos ashton <[email protected]> --- libavutil/hdr_dynamic_metadata.c | 2 +- libavutil/hdr_dynamic_metadata.h | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/libavutil/hdr_dynamic_metadata.c b/libavutil/hdr_dynamic_metadata.c index 9c89625421..4c9ac25970 100644 --- a/libavutil/hdr_dynamic_metadata.c +++ b/libavutil/hdr_dynamic_metadata.c @@ -64,7 +64,7 @@ int av_dynamic_hdr_plus_from_t35(AVDynamicHDRPlus *s, const uint8_t *data, int ret; if (!s) - return AVERROR(ENOMEM); + return AVERROR(EINVAL); if (size > AV_HDR_PLUS_MAX_PAYLOAD_SIZE) return AVERROR(EINVAL); diff --git a/libavutil/hdr_dynamic_metadata.h b/libavutil/hdr_dynamic_metadata.h index a051ac7471..5881c35220 100644 --- a/libavutil/hdr_dynamic_metadata.h +++ b/libavutil/hdr_dynamic_metadata.h @@ -248,7 +248,11 @@ typedef struct AVDynamicHDRPlus { /** * Application version in the application defining document in ST-2094 - * suite. The value shall be set to 0. + * suite. CTA-861-H sets this to 1 for the HDR10+ payload carried in a + * Rec. ITU-T T.35 message. + * + * av_dynamic_hdr_plus_from_t35() sets this field from the parsed payload. + * av_dynamic_hdr_plus_to_t35() ignores it and always writes 1. */ uint8_t application_version; -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]