summaryrefslogtreecommitdiffstats
path: root/video/mp_image.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-01-12 11:54:53 +0100
committerwm4 <wm4@nowhere>2017-01-12 13:58:28 +0100
commit162c2e2d00c46c989fdf116181a21f8701ad99be (patch)
treea044d103854116494d43449a667bf51556266886 /video/mp_image.c
parent26d25d567f49d0f98f7c21a18be7bd921e351f8d (diff)
downloadmpv-162c2e2d00c46c989fdf116181a21f8701ad99be.tar.bz2
mpv-162c2e2d00c46c989fdf116181a21f8701ad99be.tar.xz
vd_lavc, mp_image: remove code duplication for AVFrame<->mp_image
Mostly affects conversion of the colorimetric parameters. Not changing AV_FRAME_DATA_MASTERING_DISPLAY_METADATA handling - that's too messy, as decoders typically output it for keyframes only, and would require weird caching that can't even be done on the level of the frame rewrapping functions.
Diffstat (limited to 'video/mp_image.c')
-rw-r--r--video/mp_image.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/video/mp_image.c b/video/mp_image.c
index 9781386129..37d8f67343 100644
--- a/video/mp_image.c
+++ b/video/mp_image.c
@@ -712,6 +712,15 @@ static void mp_image_copy_fields_from_av_frame(struct mp_image *dst,
AVHWFramesContext *fctx = (void *)src->hw_frames_ctx->data;
dst->params.hw_subfmt = pixfmt2imgfmt(fctx->sw_format);
}
+
+ dst->params.color = (struct mp_colorspace){
+ .space = avcol_spc_to_mp_csp(src->colorspace),
+ .levels = avcol_range_to_mp_csp_levels(src->color_range),
+ .primaries = avcol_pri_to_mp_csp_prim(src->color_primaries),
+ .gamma = avcol_trc_to_mp_csp_trc(src->color_trc),
+ };
+
+ dst->params.chroma_location = avchroma_location_to_mp(src->chroma_location);
}
// Copy properties and data of the mp_image into the AVFrame, without taking
@@ -742,6 +751,11 @@ static void mp_image_copy_fields_to_av_frame(struct AVFrame *dst,
dst->colorspace = mp_csp_to_avcol_spc(src->params.color.space);
dst->color_range = mp_csp_levels_to_avcol_range(src->params.color.levels);
+ dst->color_primaries =
+ mp_csp_prim_to_avcol_pri(src->params.color.primaries);
+ dst->color_trc = mp_csp_trc_to_avcol_trc(src->params.color.gamma);
+
+ dst->chroma_location = mp_chroma_location_to_av(src->params.chroma_location);
}
// Create a new mp_image reference to av_frame.