[FFmpeg-cvslog] libdav1d: Add support for reading hdr10 metadata

Vittorio Giovara git at videolan.org
Wed Mar 13 00:45:46 EET 2019


ffmpeg | branch: master | Vittorio Giovara <vittorio.giovara at gmail.com> | Tue Mar 12 19:36:30 2019 -0300| [38a413213216fc7add112f67e26326492c859c08] | committer: James Almer

libdav1d: Add support for reading hdr10 metadata

Signed-off-by: James Almer <jamrial at gmail.com>

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

 libavcodec/libdav1d.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c
index 948e9f4ea2..f20ae7d5c5 100644
--- a/libavcodec/libdav1d.c
+++ b/libavcodec/libdav1d.c
@@ -22,6 +22,7 @@
 #include <dav1d/dav1d.h>
 
 #include "libavutil/avassert.h"
+#include "libavutil/mastering_display_metadata.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/opt.h"
 
@@ -274,6 +275,33 @@ FF_ENABLE_DEPRECATION_WARNINGS
         return AVERROR_INVALIDDATA;
     }
 
+    if (p->mastering_display) {
+        AVMasteringDisplayMetadata *mastering = av_mastering_display_metadata_create_side_data(frame);
+        if (!mastering)
+            return AVERROR(ENOMEM);
+
+        for (int i = 0; i < 3; i++) {
+            mastering->display_primaries[i][0] = av_make_q(p->mastering_display->primaries[i][0], 1 << 16);
+            mastering->display_primaries[i][1] = av_make_q(p->mastering_display->primaries[i][1], 1 << 16);
+        }
+        mastering->white_point[0] = av_make_q(p->mastering_display->white_point[0], 1 << 16);
+        mastering->white_point[1] = av_make_q(p->mastering_display->white_point[1], 1 << 16);
+
+        mastering->max_luminance = av_make_q(p->mastering_display->max_luminance, 1 << 8);
+        mastering->min_luminance = av_make_q(p->mastering_display->min_luminance, 1 << 14);
+
+        mastering->has_primaries = 1;
+        mastering->has_luminance = 1;
+    }
+    if (p->content_light) {
+        AVContentLightMetadata *light = av_content_light_metadata_create_side_data(frame);
+        if (!light)
+            return AVERROR(ENOMEM);
+
+        light->MaxCLL = p->content_light->max_content_light_level;
+        light->MaxFALL = p->content_light->max_frame_average_light_level;
+    }
+
     return 0;
 }
 



More information about the ffmpeg-cvslog mailing list