diff options
author | Vittorio Giovara <vittorio.giovara@gmail.com> | 2019-03-13 01:36:30 +0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2019-03-13 01:36:30 +0300 |
commit | 38a413213216fc7add112f67e26326492c859c08 (patch) | |
tree | 51074425df7cda2d3c4bee136540635672c16479 /libavcodec/libdav1d.c | |
parent | 36bb2cc200d0ee4c43de06f030d7956949b1f88c (diff) |
libdav1d: Add support for reading hdr10 metadata
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec/libdav1d.c')
-rw-r--r-- | libavcodec/libdav1d.c | 28 |
1 files changed, 28 insertions, 0 deletions
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; } |