diff options
author | wm4 <wm4@nowhere> | 2013-10-31 20:19:40 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-10-31 23:30:14 +0100 |
commit | 94542abf2e2ccb123cf3b0c9eef76a2290dd19b1 (patch) | |
tree | 309891190830d57508df39228bd9f230a65c50cf /mpvcore/player | |
parent | b55d55782274d13eec434702c8f11cfb37a49230 (diff) | |
download | mpv-94542abf2e2ccb123cf3b0c9eef76a2290dd19b1.tar.bz2 mpv-94542abf2e2ccb123cf3b0c9eef76a2290dd19b1.tar.xz |
command: add property to scale window size
Diffstat (limited to 'mpvcore/player')
-rw-r--r-- | mpvcore/player/command.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/mpvcore/player/command.c b/mpvcore/player/command.c index 29352ee3f3..f393318fb6 100644 --- a/mpvcore/player/command.c +++ b/mpvcore/player/command.c @@ -1468,6 +1468,39 @@ static int mp_property_dheight(m_option_t *prop, int action, void *arg, return property_vo_wh(prop, action, arg, mpctx, false); } +static int mp_property_window_scale(m_option_t *prop, int action, void *arg, + MPContext *mpctx) +{ + struct vo *vo = mpctx->video_out; + if (!vo || !vo->hasframe) + return M_PROPERTY_UNAVAILABLE; + + int vid_w = vo->aspdat.prew; + int vid_h = vo->aspdat.preh; + if (vid_w < 1 || vid_h < 1) + return M_PROPERTY_UNAVAILABLE; + + switch (action) { + case M_PROPERTY_SET: { + double scale = *(double *)arg; + int s[2] = {vid_w * scale, vid_h * scale}; + if (s[0] > 0 && s[1] > 0 && vo_control(vo, VOCTRL_SET_WINDOW_SIZE, s) > 0) + return M_PROPERTY_OK; + return M_PROPERTY_UNAVAILABLE; + } + case M_PROPERTY_GET: { + int s[2]; + if (vo_control(vo, VOCTRL_GET_WINDOW_SIZE, s) <= 0 || s[0] < 1 || s[1] < 1) + return M_PROPERTY_UNAVAILABLE; + double xs = (double)s[0] / vid_w; + double ys = (double)s[1] / vid_h; + *(double *)arg = (xs + ys) / 2; + return M_PROPERTY_OK; + } + } + return M_PROPERTY_NOT_IMPLEMENTED; +} + static int mp_property_osd_w(m_option_t *prop, int action, void *arg, MPContext *mpctx) { @@ -1901,6 +1934,8 @@ static const m_option_t mp_properties[] = { 0, 0, 0, NULL }, { "dwidth", mp_property_dwidth, CONF_TYPE_INT }, { "dheight", mp_property_dheight, CONF_TYPE_INT }, + { "window-scale", mp_property_window_scale, CONF_TYPE_DOUBLE, + CONF_RANGE, 0.125, 8 }, { "fps", mp_property_fps, CONF_TYPE_FLOAT, 0, 0, 0, NULL }, { "aspect", mp_property_aspect, CONF_TYPE_FLOAT, |