From: "Xiang, Haihao" <haihao.xiang-at-intel.com@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: Haihao Xiang <haihao.xiang@intel.com>
Subject: [FFmpeg-devel] [PATCH 2/3] lavc/vaapi_encode_av1: Insert HDR_MDCV metadata if have
Date: Mon, 15 Apr 2024 10:07:53 +0800
Message-ID: <20240415020754.674831-2-haihao.xiang@intel.com> (raw)
In-Reply-To: <20240415020754.674831-1-haihao.xiang@intel.com>
From: Haihao Xiang <haihao.xiang@intel.com>
Only look for HDR_MDVC on key frame on the output.
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
---
libavcodec/vaapi_encode_av1.c | 46 +++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/libavcodec/vaapi_encode_av1.c b/libavcodec/vaapi_encode_av1.c
index 4b417b05e7..4077d21202 100644
--- a/libavcodec/vaapi_encode_av1.c
+++ b/libavcodec/vaapi_encode_av1.c
@@ -23,6 +23,7 @@
#include "libavutil/pixdesc.h"
#include "libavutil/opt.h"
+#include "libavutil/mastering_display_metadata.h"
#include "cbs_av1.h"
#include "put_bits.h"
@@ -663,6 +664,51 @@ static int vaapi_encode_av1_init_picture_params(AVCodecContext *avctx,
priv->nb_mh = 0;
+ if (pic->type == PICTURE_TYPE_IDR) {
+ AVFrameSideData *sd =
+ av_frame_get_side_data(pic->input_image,
+ AV_FRAME_DATA_MASTERING_DISPLAY_METADATA);
+ if (sd) {
+ AVMasteringDisplayMetadata *mdm =
+ (AVMasteringDisplayMetadata *)sd->data;
+ if (mdm->has_primaries && mdm->has_luminance) {
+ AV1RawOBU *obu = &priv->mh[priv->nb_mh++];
+ AV1RawMetadata *md = &obu->obu.metadata;
+ AV1RawMetadataHDRMDCV *mdcv = &md->metadata.hdr_mdcv;
+ const int chroma_den = 1 << 16;
+ const int max_luma_den = 1 << 8;
+ const int min_luma_den = 1 << 14;
+
+ memset(obu, 0, sizeof(*obu));
+ obu->header.obu_type = AV1_OBU_METADATA;
+ md->metadata_type = AV1_METADATA_TYPE_HDR_MDCV;
+
+ for (i = 0; i < 3; i++) {
+ mdcv->primary_chromaticity_x[i] =
+ av_rescale(mdm->display_primaries[i][0].num, chroma_den,
+ mdm->display_primaries[i][0].den);
+ mdcv->primary_chromaticity_y[i] =
+ av_rescale(mdm->display_primaries[i][1].num, chroma_den,
+ mdm->display_primaries[i][1].den);
+ }
+
+ mdcv->white_point_chromaticity_x =
+ av_rescale(mdm->white_point[0].num, chroma_den,
+ mdm->white_point[0].den);
+ mdcv->white_point_chromaticity_y =
+ av_rescale(mdm->white_point[1].num, chroma_den,
+ mdm->white_point[1].den);
+
+ mdcv->luminance_max =
+ av_rescale(mdm->max_luminance.num, max_luma_den,
+ mdm->max_luminance.den);
+ mdcv->luminance_min =
+ av_rescale(mdm->min_luminance.num, min_luma_den,
+ mdm->min_luminance.den);
+ }
+ }
+ }
+
end:
ff_cbs_fragment_reset(obu);
return ret;
--
2.34.1
_______________________________________________
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".
next prev parent reply other threads:[~2024-04-15 2:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-15 2:07 [FFmpeg-devel] [PATCH 1/3] lavc/vaapi_encode_av1: implement write_extra_header callback Xiang, Haihao
2024-04-15 2:07 ` Xiang, Haihao [this message]
2024-04-15 2:07 ` [FFmpeg-devel] [PATCH 3/3] lavc/vaapi_encode_av1: insert HDR_CLL metadata if have Xiang, Haihao
2024-05-08 6:50 ` [FFmpeg-devel] [PATCH 1/3] lavc/vaapi_encode_av1: implement write_extra_header callback Xiang, Haihao
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=20240415020754.674831-2-haihao.xiang@intel.com \
--to=haihao.xiang-at-intel.com@ffmpeg.org \
--cc=ffmpeg-devel@ffmpeg.org \
--cc=haihao.xiang@intel.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