[FFmpeg-cvslog] swscale/utils: set static/implied HDR metadata

Niklas Haas git at videolan.org
Mon Dec 23 13:44:26 EET 2024


ffmpeg | branch: master | Niklas Haas <git at haasn.dev> | Sat Nov 30 14:48:57 2024 +0100| [5b21b7f52c7a306e4a087f4822089e29d3b8a709] | committer: Niklas Haas

swscale/utils: set static/implied HDR metadata

Provide default values for the fields added in the previous commit.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5b21b7f52c7a306e4a087f4822089e29d3b8a709
---

 libswscale/utils.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/libswscale/utils.c b/libswscale/utils.c
index f8ad093631..bc2a7b602c 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -2654,6 +2654,8 @@ int ff_range_add(RangeList *rl, unsigned int start, unsigned int len)
 SwsFormat ff_fmt_from_frame(const AVFrame *frame, int field)
 {
     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format);
+    const AVColorPrimariesDesc *primaries;
+
     SwsFormat fmt = {
         .width  = frame->width,
         .height = frame->height,
@@ -2710,6 +2712,21 @@ SwsFormat ff_fmt_from_frame(const AVFrame *frame, int field)
         fmt.interlaced = 1;
     }
 
+    /* Set luminance and gamut information */
+    fmt.color.min_luma = av_make_q(0, 1);
+    switch (fmt.color.trc) {
+    case AVCOL_TRC_SMPTE2084:
+        fmt.color.max_luma = av_make_q(10000, 1); break;
+    case AVCOL_TRC_ARIB_STD_B67:
+        fmt.color.max_luma = av_make_q( 1000, 1); break; /* HLG reference display */
+    default:
+        fmt.color.max_luma = av_make_q(  203, 1); break; /* SDR reference brightness */
+    }
+
+    primaries = av_csp_primaries_desc_from_id(fmt.color.prim);
+    if (primaries)
+        fmt.color.gamut = primaries->prim;
+
     return fmt;
 }
 



More information about the ffmpeg-cvslog mailing list