summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeo Izen <leo.izen@gmail.com>2024-02-04 04:24:42 -0500
committerKacper Michajłow <kasper93@gmail.com>2024-03-19 09:49:04 +0100
commit3e7d36c295f726e701d1ceea6af83382f7b2f59e (patch)
tree31b48f01912c2d73810bdd2290e5c79565f1f32e
parent227916d5eddf9a6d425b7cc56379a3c837c63315 (diff)
downloadmpv-master.tar.bz2
mpv-master.tar.xz
video/image_writer: attach MDVC metadata and CLLI metadataHEADmaster
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>
-rw-r--r--video/image_writer.c15
-rw-r--r--video/mp_image.c6
2 files changed, 8 insertions, 13 deletions
diff --git a/video/image_writer.c b/video/image_writer.c
index 8f5f4ed877..62dd34f288 100644
--- a/video/image_writer.c
+++ b/video/image_writer.c
@@ -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"
diff --git a/video/mp_image.c b/video/mp_image.c
index a8c0262aa7..609fb17bf0 100644
--- a/video/mp_image.c
+++ b/video/mp_image.c
@@ -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);