diff options
author | xylosper <darklin20@gmail.com> | 2015-01-10 20:29:10 +0900 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-01-10 18:53:03 +0100 |
commit | 242558bec1a91b1c04dd0fe346ea6daa628ef710 (patch) | |
tree | 61b9b205b8e23f41c0e9adb7d9d977f0759aef9c | |
parent | 69dad662c9a3d251792affbac38b9df7e02245f9 (diff) | |
download | mpv-242558bec1a91b1c04dd0fe346ea6daa628ef710.tar.bz2 mpv-242558bec1a91b1c04dd0fe346ea6daa628ef710.tar.xz |
command.c: new subproperties for video-params: bpp and depth
bpp(bits-per-pixel) and depth(bit-depth for color component) can
be calculated from pixelformat technically but it requires massive
informations to be implemented in client side.
These subproperties are provided for convenience.
-rw-r--r-- | DOCS/man/input.rst | 6 | ||||
-rw-r--r-- | player/command.c | 12 |
2 files changed, 18 insertions, 0 deletions
diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst index 1a829c152c..d044923654 100644 --- a/DOCS/man/input.rst +++ b/DOCS/man/input.rst @@ -1119,6 +1119,12 @@ 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/w``, ``video-params/h`` Video size as integers, with no aspect correction applied. diff --git a/player/command.c b/player/command.c index f136c4cb46..4e4cbce165 100644 --- a/player/command.c +++ b/player/command.c @@ -2396,8 +2396,20 @@ 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); + 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; + 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)}, {"w", SUB_PROP_INT(p.w)}, {"h", SUB_PROP_INT(p.h)}, {"dw", SUB_PROP_INT(p.d_w)}, |