Skip to content

Commit 1083849

Browse files
Traneptorapull[bot]
authored andcommitted
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>
1 parent 3ec14a4 commit 1083849

2 files changed

Lines changed: 8 additions & 13 deletions

File tree

video/image_writer.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,19 +136,18 @@ static void prepare_avframe(AVFrame *pic, AVCodecContext *avctx,
136136
pic->format = avctx->pix_fmt;
137137
pic->width = avctx->width;
138138
pic->height = avctx->height;
139-
avctx->color_range = pic->color_range =
140-
pl_levels_to_av(image->params.repr.levels);
139+
pl_avframe_set_repr(pic, image->params.repr);
140+
avctx->colorspace = pic->colorspace;
141+
avctx->color_range = pic->color_range;
141142

142143
if (!tag_csp)
143144
return;
144-
avctx->color_primaries = pic->color_primaries =
145-
pl_primaries_to_av(image->params.color.primaries);
146-
avctx->color_trc = pic->color_trc =
147-
pl_transfer_to_av(image->params.color.transfer);
148-
avctx->colorspace = pic->colorspace =
149-
pl_system_to_av(image->params.repr.sys);
145+
pl_avframe_set_color(pic, image->params.color);
146+
avctx->color_primaries = pic->color_primaries;
147+
avctx->color_trc = pic->color_trc;
150148
avctx->chroma_sample_location = pic->chroma_location =
151149
pl_chroma_to_av(image->params.chroma_location);
150+
152151
mp_dbg(log, "mapped color params:\n"
153152
" trc = %s\n"
154153
" primaries = %s\n"

video/mp_image.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,11 +1203,7 @@ struct AVFrame *mp_image_to_av_frame(struct mp_image *src)
12031203
if (src->fields & MP_IMGFIELD_REPEAT_FIRST)
12041204
dst->repeat_pict = 1;
12051205

1206-
dst->colorspace = pl_system_to_av(src->params.repr.sys);
1207-
dst->color_range = pl_levels_to_av(src->params.repr.levels);
1208-
dst->color_primaries =
1209-
pl_primaries_to_av(src->params.color.primaries);
1210-
dst->color_trc = pl_transfer_to_av(src->params.color.transfer);
1206+
pl_avframe_set_repr(dst, src->params.repr);
12111207

12121208
dst->chroma_location = pl_chroma_to_av(src->params.chroma_location);
12131209

0 commit comments

Comments
 (0)