summaryrefslogtreecommitdiffstats
path: root/command.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-09-22 05:13:29 +0200
committerwm4 <wm4@nowhere>2012-10-12 10:10:31 +0200
commit9939776e5ee70818d9cc4a5a7cd9f09da4239164 (patch)
tree78fcbc6d3604f6fb39a70b02e4057e487d3b4f62 /command.c
parentd3562198249d51087e8a23a6fafafd140eaaf935 (diff)
downloadmpv-9939776e5ee70818d9cc4a5a7cd9f09da4239164.tar.bz2
mpv-9939776e5ee70818d9cc4a5a7cd9f09da4239164.tar.xz
commands: make "aspect" property writeable, replaces "switch_ratio"
Move the code for "switch_ratio" to the M_PROPERTY_SET case of the "aspect" property. The rules are exactly the same, e.g. setting a ratio smaller than 0.1 sets the pixel aspect ratio to 1:1. For now, we define that writing "0" sets the PAR to 1:1, and disallow -1 (possibly reserve it to reset to default aspect ratio).
Diffstat (limited to 'command.c')
-rw-r--r--command.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/command.c b/command.c
index 7c2ab61c96..e18389b878 100644
--- a/command.c
+++ b/command.c
@@ -1187,7 +1187,20 @@ static int mp_property_aspect(m_option_t *prop, int action, void *arg,
{
if (!mpctx->sh_video)
return M_PROPERTY_UNAVAILABLE;
- return m_property_float_ro(prop, action, arg, mpctx->sh_video->aspect);
+ switch (action) {
+ case M_PROPERTY_SET: {
+ float f = *(float *)arg;
+ if (f < 0.1)
+ f = (float)mpctx->sh_video->disp_w / mpctx->sh_video->disp_h;
+ mpctx->opts.movie_aspect = f;
+ video_reset_aspect(mpctx->sh_video);
+ return M_PROPERTY_OK;
+ }
+ case M_PROPERTY_GET:
+ *(float *)arg = mpctx->sh_video->aspect;
+ return M_PROPERTY_OK;
+ }
+ return M_PROPERTY_NOT_IMPLEMENTED;
}
// For subtitle related properties using the generic option bridge.
@@ -1429,7 +1442,7 @@ static const m_option_t mp_properties[] = {
{ "fps", mp_property_fps, CONF_TYPE_FLOAT,
0, 0, 0, NULL },
{ "aspect", mp_property_aspect, CONF_TYPE_FLOAT,
- 0, 0, 0, NULL },
+ CONF_RANGE, 0, 10, NULL },
{ "video", mp_property_video, CONF_TYPE_INT,
CONF_RANGE, -2, 65535, NULL },
{ "program", mp_property_program, CONF_TYPE_INT,
@@ -1838,16 +1851,6 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
}
break;
- case MP_CMD_SWITCH_RATIO:
- if (!sh_video)
- break;
- if (cmd->nargs == 0 || cmd->args[0].v.f == -1)
- opts->movie_aspect = (float) sh_video->disp_w / sh_video->disp_h;
- else
- opts->movie_aspect = cmd->args[0].v.f;
- video_reset_aspect(sh_video);
- break;
-
case MP_CMD_SPEED_MULT: {
float v = cmd->args[0].v.f;
v *= mpctx->opts.playback_speed;