summaryrefslogtreecommitdiffstats
path: root/player/command.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-08-15 12:04:35 +0200
committerwm4 <wm4@nowhere>2020-08-15 12:05:11 +0200
commit112d2a2c500682003798ae60fc6cd0d5dabbe174 (patch)
tree1174d1c0210a0fe9e1a46e765fa18f4a3e63df73 /player/command.c
parente107342ff929886f1a07cd569847998631ae15c5 (diff)
downloadmpv-112d2a2c500682003798ae60fc6cd0d5dabbe174.tar.bz2
mpv-112d2a2c500682003798ae60fc6cd0d5dabbe174.tar.xz
command: export alpha type in format properties
Diffstat (limited to 'player/command.c')
-rw-r--r--player/command.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/player/command.c b/player/command.c
index 1a20962c29..560b9d71e2 100644
--- a/player/command.c
+++ b/player/command.c
@@ -2175,6 +2175,13 @@ static int property_imgparams(struct mp_image_params p, int action, void *arg)
for (int i = 0; i < desc.num_planes; i++)
bpp += desc.bpp[i] >> (desc.xs[i] + desc.ys[i]);
+ // Alpha type is not supported by FFmpeg, so MP_ALPHA_AUTO may mean alpha
+ // is of an unknown type, or simply not present. Normalize to AUTO=no alpha.
+ if (!!(desc.flags & MP_IMGFLAG_ALPHA) != (p.alpha != MP_ALPHA_AUTO)) {
+ p.alpha =
+ (desc.flags & MP_IMGFLAG_ALPHA) ? MP_ALPHA_STRAIGHT : MP_ALPHA_AUTO;
+ }
+
struct m_sub_property props[] = {
{"pixelformat", SUB_PROP_STR(mp_imgfmt_to_name(p.imgfmt))},
{"average-bpp", SUB_PROP_INT(bpp),
@@ -2201,6 +2208,10 @@ static int property_imgparams(struct mp_image_params p, int action, void *arg)
{"stereo-in",
SUB_PROP_STR(m_opt_choice_str(mp_stereo3d_names, p.stereo3d))},
{"rotate", SUB_PROP_INT(p.rotate)},
+ {"alpha",
+ SUB_PROP_STR(m_opt_choice_str(mp_alpha_names, p.alpha)),
+ // avoid using "auto" for "no", so just make it unavailable
+ .unavailable = p.alpha == MP_ALPHA_AUTO},
{0}
};