From 17a3ac4cf2b8bfc5dee912fb35568f3de6825991 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Mon, 29 Sep 2025 03:11:07 +0200 Subject: [PATCH] mp_image: add support for AVAlphaMode --- video/mp_image.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/video/mp_image.c b/video/mp_image.c index 9d159cd13c..7584d9bcdd 100644 --- a/video/mp_image.c +++ b/video/mp_image.c @@ -1102,9 +1102,17 @@ struct mp_image *mp_image_from_av_frame(struct AVFrame *src) dst->params.stereo3d = p->stereo3d; // Might be incorrect if colorspace changes. dst->params.light = p->light; +#if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(60, 11, 100) || PL_API_VER < 356 dst->params.repr.alpha = p->repr.alpha; +#endif } +#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(60, 11, 100) && PL_API_VER >= 356 + // mp_image_setfmt sets to PL_ALPHA_INDEPENDENT, if format has alpha. + if (dst->params.repr.alpha == PL_ALPHA_INDEPENDENT) + dst->params.repr.alpha = pl_alpha_from_av(src->alpha_mode); +#endif + sd = av_frame_get_side_data(src, AV_FRAME_DATA_DISPLAYMATRIX); if (sd) { int32_t *matrix = (int32_t *) sd->data;