diff options
author | wm4 <wm4@nowhere> | 2016-09-20 15:34:31 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2016-09-20 15:44:16 +0200 |
commit | e13eb3fede680fdadb76efce957806654cda0f23 (patch) | |
tree | d3ae9bc7c32824256588a2896ae64afb57f97825 | |
parent | bf385e1140069fb1c6d41161aece0fe099513ac0 (diff) | |
download | mpv-e13eb3fede680fdadb76efce957806654cda0f23.tar.bz2 mpv-e13eb3fede680fdadb76efce957806654cda0f23.tar.xz |
command: change update handling of some video-related properties
Use the new mechanism, instead of wrapped properties. As usual, extend
the update handling to some options that were forgotten/neglected
before. Rename video_reset_aspect() to video_reset_params() to make it
more "general" (and we can amazingly include write access to
video-aspect as well in this).
-rw-r--r-- | options/m_option.h | 3 | ||||
-rw-r--r-- | options/options.c | 11 | ||||
-rw-r--r-- | player/command.c | 33 | ||||
-rw-r--r-- | video/decode/dec_video.c | 2 | ||||
-rw-r--r-- | video/decode/dec_video.h | 2 |
5 files changed, 19 insertions, 32 deletions
diff --git a/options/m_option.h b/options/m_option.h index e0f8979a66..63ba4fac03 100644 --- a/options/m_option.h +++ b/options/m_option.h @@ -386,7 +386,8 @@ struct m_option { #define UPDATE_VIDEOPOS (1 << 9) // video position (panscan etc.) #define UPDATE_OSD (1 << 10) // related to OSD rendering #define UPDATE_BUILTIN_SCRIPTS (1 << 11) // osc/ytdl -#define UPDATE_OPT_LAST (1 << 11) +#define UPDATE_IMGPAR (1 << 12) // video image params overrides +#define UPDATE_OPT_LAST (1 << 12) // All bits between _FIRST and _LAST (inclusive) #define UPDATE_OPTS_MASK \ diff --git a/options/options.c b/options/options.c index 70d921ab73..1476b384b5 100644 --- a/options/options.c +++ b/options/options.c @@ -424,11 +424,11 @@ const m_option_t mp_opts[] = { // -1 means auto aspect (prefer container size until aspect change) // 0 means square pixels - OPT_ASPECT("video-aspect", movie_aspect, 0, -1.0, 10.0), - OPT_CHOICE("video-aspect-method", aspect_method, 0, + OPT_ASPECT("video-aspect", movie_aspect, UPDATE_IMGPAR, -1.0, 10.0), + OPT_CHOICE("video-aspect-method", aspect_method, UPDATE_IMGPAR, ({"hybrid", 0}, {"bitstream", 1}, {"container", 2})), - OPT_CHOICE("field-dominance", field_dominance, 0, + OPT_CHOICE("field-dominance", field_dominance, UPDATE_IMGPAR, ({"auto", -1}, {"top", 0}, {"bottom", 1})), OPT_SUBSTRUCT("vd-lavc", vd_lavc_params, vd_lavc_conf, 0), @@ -531,9 +531,10 @@ const m_option_t mp_opts[] = { OPT_STRING("force-media-title", media_title, 0), // set aspect ratio of monitor - useful for 16:9 TV-out OPT_FLAG("force-rgba-osd-rendering", force_rgba_osd, 0), - OPT_CHOICE_OR_INT("video-rotate", video_rotate, 0, 0, 359, + OPT_CHOICE_OR_INT("video-rotate", video_rotate, UPDATE_IMGPAR, 0, 359, ({"no", -1})), - OPT_CHOICE_C("video-stereo-mode", video_stereo_mode, 0, mp_stereo3d_names), + OPT_CHOICE_C("video-stereo-mode", video_stereo_mode, UPDATE_IMGPAR, + mp_stereo3d_names), OPT_CHOICE_OR_INT("cursor-autohide", cursor_autohide_delay, 0, 0, 30000, ({"no", -1}, {"always", -2})), diff --git a/player/command.c b/player/command.c index 721a79df83..faa167228b 100644 --- a/player/command.c +++ b/player/command.c @@ -2397,16 +2397,6 @@ static int mp_property_deinterlace(void *ctx, struct m_property *prop, return mp_property_generic_option(mpctx, prop, action, arg); } -static int video_simple_refresh_property(void *ctx, struct m_property *prop, - int action, void *arg) -{ - MPContext *mpctx = ctx; - int r = mp_property_generic_option(mpctx, prop, action, arg); - if (action == M_PROPERTY_SET && r == M_PROPERTY_OK) - mp_force_video_refresh(mpctx); - return r; -} - /// Helper to set vo flags. /** \ingroup PropertyImplHelper */ @@ -2948,14 +2938,6 @@ static int mp_property_aspect(void *ctx, struct m_property *prop, } switch (action) { - case M_PROPERTY_SET: { - mpctx->opts->movie_aspect = *(float *)arg; - if (track && track->d_video) { - video_reset_aspect(track->d_video); - mp_force_video_refresh(mpctx); - } - return M_PROPERTY_OK; - } case M_PROPERTY_PRINT: { if (mpctx->opts->movie_aspect < 0) { *(char **)arg = talloc_asprintf(NULL, "%.3f (original)", aspect); @@ -2967,10 +2949,8 @@ static int mp_property_aspect(void *ctx, struct m_property *prop, *(float *)arg = aspect; return M_PROPERTY_OK; } - case M_PROPERTY_GET_TYPE: - return mp_property_generic_option(mpctx, prop, action, arg); } - return M_PROPERTY_NOT_IMPLEMENTED; + return mp_property_generic_option(mpctx, prop, action, arg); } /// Selected subtitles (RW) @@ -3918,9 +3898,6 @@ static const struct m_property mp_properties_base[] = { {"vf", mp_property_vf}, {"af", mp_property_af}, - {"video-rotate", video_simple_refresh_property}, - {"video-stereo-mode", video_simple_refresh_property}, - {"ab-loop-a", mp_property_ab_loop}, {"ab-loop-b", mp_property_ab_loop}, @@ -5607,6 +5584,14 @@ void mp_option_change_callback(void *ctx, struct m_config_option *co, int flags) if (flags & UPDATE_BUILTIN_SCRIPTS) mp_load_builtin_scripts(mpctx); + + if (flags & UPDATE_IMGPAR) { + struct track *track = mpctx->current_track[0][STREAM_VIDEO]; + if (track && track->d_video) { + video_reset_params(track->d_video); + mp_force_video_refresh(mpctx); + } + } } void mp_notify_property(struct MPContext *mpctx, const char *property) diff --git a/video/decode/dec_video.c b/video/decode/dec_video.c index 2a6a3ec213..51f959ff6d 100644 --- a/video/decode/dec_video.c +++ b/video/decode/dec_video.c @@ -341,7 +341,7 @@ static struct mp_image *decode_packet(struct dec_video *d_video, return mpi; } -void video_reset_aspect(struct dec_video *d_video) +void video_reset_params(struct dec_video *d_video) { d_video->last_format = (struct mp_image_params){0}; } diff --git a/video/decode/dec_video.h b/video/decode/dec_video.h index 1030973e1c..be82e4679a 100644 --- a/video/decode/dec_video.h +++ b/video/decode/dec_video.h @@ -91,6 +91,6 @@ void video_set_start(struct dec_video *d_video, double start_pts); int video_vd_control(struct dec_video *d_video, int cmd, void *arg); void video_reset(struct dec_video *d_video); -void video_reset_aspect(struct dec_video *d_video); +void video_reset_params(struct dec_video *d_video); #endif /* MPLAYER_DEC_VIDEO_H */ |