video/image_writer: attach MDVC metadata and CLLI metadata

This commit allows image_writer to attach HDR metadata to AVFrames via
the corresponding AVFrameSideData attachments, if present. It does this
by calling pl_avframe_set_color, already used by mp_image_to_avframe.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
This commit is contained in:
Leo Izen 2024-02-04 04:24:42 -05:00 committed by Kacper Michajłow
parent 227916d5ed
commit 3e7d36c295
2 changed files with 8 additions and 13 deletions

View File

@ -136,19 +136,18 @@ static void prepare_avframe(AVFrame *pic, AVCodecContext *avctx,
pic->format = avctx->pix_fmt;
pic->width = avctx->width;
pic->height = avctx->height;
avctx->color_range = pic->color_range =
pl_levels_to_av(image->params.repr.levels);
pl_avframe_set_repr(pic, image->params.repr);
avctx->colorspace = pic->colorspace;
avctx->color_range = pic->color_range;
if (!tag_csp)
return;
avctx->color_primaries = pic->color_primaries =
pl_primaries_to_av(image->params.color.primaries);
avctx->color_trc = pic->color_trc =
pl_transfer_to_av(image->params.color.transfer);
avctx->colorspace = pic->colorspace =
pl_system_to_av(image->params.repr.sys);
pl_avframe_set_color(pic, image->params.color);
avctx->color_primaries = pic->color_primaries;
avctx->color_trc = pic->color_trc;
avctx->chroma_sample_location = pic->chroma_location =
pl_chroma_to_av(image->params.chroma_location);
mp_dbg(log, "mapped color params:\n"
" trc = %s\n"
" primaries = %s\n"

View File

@ -1203,11 +1203,7 @@ struct AVFrame *mp_image_to_av_frame(struct mp_image *src)
if (src->fields & MP_IMGFIELD_REPEAT_FIRST)
dst->repeat_pict = 1;
dst->colorspace = pl_system_to_av(src->params.repr.sys);
dst->color_range = pl_levels_to_av(src->params.repr.levels);
dst->color_primaries =
pl_primaries_to_av(src->params.color.primaries);
dst->color_trc = pl_transfer_to_av(src->params.color.transfer);
pl_avframe_set_repr(dst, src->params.repr);
dst->chroma_location = pl_chroma_to_av(src->params.chroma_location);