[FFmpeg-devel] [PATCH] libdav1d: Add support for reading hdr10 metadata
James Almer
jamrial at gmail.com
Wed Mar 13 00:46:40 EET 2019
On 3/5/2019 3:19 PM, Vittorio Giovara wrote:
> ---
> configure | 2 +-
> libavcodec/libdav1d.c | 30 +++++++++++++++++++++++++++++-
> 2 files changed, 30 insertions(+), 2 deletions(-)
>
> diff --git a/configure b/configure
> index dcead3a300..a5cef4bc09 100755
> --- a/configure
> +++ b/configure
> @@ -6142,7 +6142,7 @@ enabled libcelt && require libcelt celt/celt.h celt_decode -lcelt0 &&
> die "ERROR: libcelt must be installed and version must be >= 0.11.0."; }
> enabled libcaca && require_pkg_config libcaca caca caca.h caca_create_canvas
> enabled libcodec2 && require libcodec2 codec2/codec2.h codec2_create -lcodec2
> -enabled libdav1d && require_pkg_config libdav1d "dav1d >= 0.1.0" "dav1d/dav1d.h" dav1d_version
> +enabled libdav1d && require_pkg_config libdav1d "dav1d >= 0.2.0" "dav1d/dav1d.h" dav1d_version
> enabled libdavs2 && require_pkg_config libdavs2 "davs2 >= 1.6.0" davs2.h davs2_decoder_open
> enabled libdc1394 && require_pkg_config libdc1394 libdc1394-2 dc1394/dc1394.h dc1394_new
> enabled libdrm && require_pkg_config libdrm libdrm xf86drm.h drmGetVersion
> diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c
> index ed02da4ebf..355dd184f4 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/opt.h"
>
> #include "avcodec.h"
> @@ -90,7 +91,7 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame)
> Libdav1dContext *dav1d = c->priv_data;
> Dav1dData *data = &dav1d->data;
> Dav1dPicture *p;
> - int res;
> + int i, res;
>
> if (!data->sz) {
> AVPacket pkt = { 0 };
> @@ -206,6 +207,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 (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;
> }
Pushed alongside my patches.
More information about the ffmpeg-devel
mailing list