mirror of
https://github.com/mpv-player/mpv
synced 2025-02-28 03:10:55 +00:00
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).
This commit is contained in:
parent
bf385e1140
commit
e13eb3fede
@ -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 \
|
||||
|
@ -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})),
|
||||
|
@ -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)
|
||||
|
@ -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};
|
||||
}
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user