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; diff --git a/input/input.c b/input/input.c index d783f53aca..d3ad18075d 100644 --- a/input/input.c +++ b/input/input.c @@ -126,7 +126,6 @@ static const mp_cmd_t mp_cmds[] = { #ifdef CONFIG_DVBIN { MP_CMD_DVB_SET_CHANNEL, "dvb_set_channel", { ARG_INT, ARG_INT } }, #endif - { MP_CMD_SWITCH_RATIO, "switch_ratio", { OARG_FLOAT(0) } }, { MP_CMD_SCREENSHOT, "screenshot", { OARG_INT(0), OARG_INT(0) } }, { MP_CMD_LOADFILE, "loadfile", { ARG_STRING, OARG_INT(0) } }, { MP_CMD_LOADLIST, "loadlist", { ARG_STRING, OARG_INT(0) } }, @@ -199,9 +198,12 @@ static const struct legacy_cmd legacy_cmds[] = { {"osd_show_text", "show_text"}, {"osd_show_property_text", "show_text"}, {"osd_show_progression", "show_progress"}, - // Approximate + // Approximate (can fail if user added additional whitespace) {"pt_step 1", "playlist_next"}, {"pt_step -1", "playlist_prev"}, + // Switch_ratio without argument resets aspect ratio + {"switch_ratio ", "set aspect "}, + {"switch_ratio", "set aspect 0"}, {0} }; diff --git a/input/input.h b/input/input.h index 0fa5c32971..158d71b8ac 100644 --- a/input/input.h +++ b/input/input.h @@ -41,7 +41,6 @@ enum mp_command_type { MP_CMD_TV_LAST_CHANNEL, MP_CMD_TV_SET_FREQ, MP_CMD_TV_SET_NORM, - MP_CMD_SWITCH_RATIO, MP_CMD_FRAME_STEP, MP_CMD_SPEED_MULT, MP_CMD_RUN,