diff options
author | wm4 <wm4@nowhere> | 2018-01-16 11:42:07 +0100 |
---|---|---|
committer | Kevin Mitchell <kevmitch@gmail.com> | 2018-01-18 00:59:07 -0800 |
commit | 0536ef306c5cdf03d4593f783cda9c0b6cebec60 (patch) | |
tree | be2c99a33252aa0ab777e7df9594bf3928f1361e /video/mp_image.c | |
parent | 7533d3c3a80cb2205d64c343d2c0987f5b2a2e7e (diff) | |
download | mpv-0536ef306c5cdf03d4593f783cda9c0b6cebec60.tar.bz2 mpv-0536ef306c5cdf03d4593f783cda9c0b6cebec60.tar.xz |
mp_image: fix some metadata loss with conversion from/to AVFrame
This fixes that AVFrames passing through libavfilter (such as with
--lavfi-complex) implicitly stripped some fields. I'm not actually sure
what to do with the mp_image_params.color.light field here (what happens
if the colorspace changed?) - there is no equivalent in AVFrame or
FFmpeg at all.
It did not affect the old --vf code, because it doesn't allow
libavfilter to change the metadata.
Also log the .light field in verbose mode.
Diffstat (limited to 'video/mp_image.c')
-rw-r--r-- | video/mp_image.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/video/mp_image.c b/video/mp_image.c index 9682a708ec..37a4a3cf02 100644 --- a/video/mp_image.c +++ b/video/mp_image.c @@ -620,11 +620,12 @@ char *mp_image_params_to_str_buf(char *b, size_t bs, mp_snprintf_cat(b, bs, "[%s]", mp_imgfmt_to_name(p->hw_subfmt)); if (p->hw_flags) mp_snprintf_cat(b, bs, "[0x%x]", p->hw_flags); - mp_snprintf_cat(b, bs, " %s/%s/%s/%s", + mp_snprintf_cat(b, bs, " %s/%s/%s/%s/%s", m_opt_choice_str(mp_csp_names, p->color.space), m_opt_choice_str(mp_csp_prim_names, p->color.primaries), m_opt_choice_str(mp_csp_trc_names, p->color.gamma), - m_opt_choice_str(mp_csp_levels_names, p->color.levels)); + m_opt_choice_str(mp_csp_levels_names, p->color.levels), + m_opt_choice_str(mp_csp_light_names, p->color.light)); if (p->color.sig_peak) mp_snprintf_cat(b, bs, " SP=%f", p->color.sig_peak); mp_snprintf_cat(b, bs, " CL=%s", @@ -868,6 +869,9 @@ struct mp_image *mp_image_from_av_frame(struct AVFrame *src) dst->params.rotate = p->rotate; dst->params.stereo_in = p->stereo_in; dst->params.stereo_out = p->stereo_out; + dst->params.spherical = p->spherical; + // Might be incorrect if colorspace changes. + dst->params.color.light = p->color.light; } #if LIBAVUTIL_VERSION_MICRO >= 100 @@ -965,6 +969,14 @@ struct AVFrame *mp_image_to_av_frame(struct mp_image *src) abort(); new_ref->icc_profile = NULL; } + + if (src->params.color.sig_peak) { + AVContentLightMetadata *clm = + av_content_light_metadata_create_side_data(dst); + if (!clm) + abort(); + clm->MaxCLL = src->params.color.sig_peak * MP_REF_WHITE; + } #endif talloc_free(new_ref); |