diff options
-rw-r--r-- | DOCS/man/input.rst | 14 | ||||
-rw-r--r-- | player/command.c | 17 | ||||
-rw-r--r-- | video/img_format.c | 4 |
3 files changed, 19 insertions, 16 deletions
diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst index d044923654..ede28b07bf 100644 --- a/DOCS/man/input.rst +++ b/DOCS/man/input.rst @@ -1119,11 +1119,15 @@ Property list The pixel format as string. This uses the same names as used in other places of mpv. - ``video-params/bpp`` - Bits-per-pixel as integer. - - ``video-params/depth`` - Bit depth for each color component as integer. + ``video-params/average_bpp`` + Average bits-per-pixel as integer. Subsampled planar formats use a + different resolution, which is the reason this value can sometimes be + odd or confusing. Can be unavailable with some formats. + + ``video-params/plane_depth`` + Bit depth for each color component as integer. This is only exposed + for planar or single-component formats, and is unavailable for other + formats. ``video-params/w``, ``video-params/h`` Video size as integers, with no aspect correction applied. diff --git a/player/command.c b/player/command.c index 4e4cbce165..c98568beb1 100644 --- a/player/command.c +++ b/player/command.c @@ -2396,20 +2396,17 @@ static int property_imgparams(struct mp_image_params p, int action, void *arg) double dar = p.d_w / (double)p.d_h; double sar = p.w / (double)p.h; - const struct mp_imgfmt_desc desc = mp_imgfmt_get_desc(p.imgfmt); + struct mp_imgfmt_desc desc = mp_imgfmt_get_desc(p.imgfmt); int bpp = 0; - // unknown bpp for hwdec - if (!IMGFMT_IS_HWACCEL(desc.id)) { - for (int i=0; i<desc.num_planes; ++i) - bpp += desc.bpp[i] >> (desc.xs[i] + desc.ys[i]); - } - // hwdec supports 8bit depth only - const int depth = IMGFMT_IS_HWACCEL(desc.id) ? 8 : desc.plane_bits; + for (int i = 0; i < desc.num_planes; i++) + bpp += desc.bpp[i] >> (desc.xs[i] + desc.ys[i]); struct m_sub_property props[] = { {"pixelformat", SUB_PROP_STR(mp_imgfmt_to_name(p.imgfmt))}, - {"bpp", SUB_PROP_INT(bpp)}, - {"depth", SUB_PROP_INT(depth)}, + {"average_bpp", SUB_PROP_INT(bpp), + .unavailable = !bpp}, + {"plane_depth", SUB_PROP_INT(desc.plane_bits), + .unavailable = !(desc.flags & MP_IMGFLAG_PLANAR)}, {"w", SUB_PROP_INT(p.w)}, {"h", SUB_PROP_INT(p.h)}, {"dw", SUB_PROP_INT(p.d_w)}, diff --git a/video/img_format.c b/video/img_format.c index 7df0923cfe..9f7bf32779 100644 --- a/video/img_format.c +++ b/video/img_format.c @@ -240,8 +240,10 @@ struct mp_imgfmt_desc mp_imgfmt_get_desc(int mpfmt) if ((desc.bpp[0] % 8) != 0) desc.align_x = 8 / desc.bpp[0]; // expect power of 2 - if (pd->flags & AV_PIX_FMT_FLAG_HWACCEL) + if (pd->flags & AV_PIX_FMT_FLAG_HWACCEL) { desc.flags |= MP_IMGFLAG_HWACCEL; + desc.plane_bits = 8; // usually restricted to 8 bit; may change + } return desc; } |