diff options
author | wm4 <wm4@nowhere> | 2013-05-18 11:44:17 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-05-18 17:45:54 +0200 |
commit | f569d245ba37898a79e853cb6fbd906dd992b531 (patch) | |
tree | 713d484af2df18abf8c388863ea6341d64a981aa /core/mplayer.c | |
parent | d1b37aff32f459e2d9fd8361beb14138458012ec (diff) | |
download | mpv-f569d245ba37898a79e853cb6fbd906dd992b531.tar.bz2 mpv-f569d245ba37898a79e853cb6fbd906dd992b531.tar.xz |
core: allow changing filter filters at runtime
Add the "vf" command, which allows changing the video filter chain at
runtime. For example, the 'y' key could be bound to toggle deinterlacing
by adding 'y vf toggle yadif' to the input.conf.
Reconfiguring the video filter chain normally resets the VO, so that it
will be "stuck" until a new video frame is rendered. To mitigate this, a
seek to the current position is issued when the filter chain is changed.
This is done only if playback is paused, because normal playback will
show an actual new frame quickly enough.
If vdpau hardware decoding is used, filter insertion (whether it fails
or not) will break the video for a while. This is because vo_vdpau
resets decoding related things on vo_config().
Diffstat (limited to 'core/mplayer.c')
-rw-r--r-- | core/mplayer.c | 46 |
1 files changed, 34 insertions, 12 deletions
diff --git a/core/mplayer.c b/core/mplayer.c index ac597beac1..a0b18cab62 100644 --- a/core/mplayer.c +++ b/core/mplayer.c @@ -2466,6 +2466,39 @@ static void update_fps(struct MPContext *mpctx) #endif } +static void recreate_video_filters(struct MPContext *mpctx) +{ + struct MPOpts *opts = &mpctx->opts; + struct sh_video *sh_video = mpctx->sh_video; + assert(sh_video); + + vf_uninit_filter_chain(sh_video->vfilter); + + char *vf_arg[] = { + "_oldargs_", (char *)mpctx->video_out, NULL + }; + sh_video->vfilter = vf_open_filter(opts, NULL, "vo", vf_arg); + + sh_video->vfilter = append_filters(sh_video->vfilter, opts->vf_settings); + + struct vf_instance *vf = sh_video->vfilter; + mpctx->osd->render_subs_in_filter + = vf->control(vf, VFCTRL_INIT_OSD, NULL) == VO_TRUE; +} + +int reinit_video_filters(struct MPContext *mpctx) +{ + struct sh_video *sh_video = mpctx->sh_video; + + if (!sh_video) + return -2; + + recreate_video_filters(mpctx); + video_reinit_vo(sh_video); + + return sh_video->vf_initialized > 0 ? 0 : -1; +} + int reinit_video_chain(struct MPContext *mpctx) { struct MPOpts *opts = &mpctx->opts; @@ -2518,18 +2551,7 @@ int reinit_video_chain(struct MPContext *mpctx) STREAM_CTRL_GET_ASPECT_RATIO, &ar) != STREAM_UNSUPPORTED) mpctx->sh_video->stream_aspect = ar; - { - char *vf_arg[] = { - "_oldargs_", (char *)mpctx->video_out, NULL - }; - sh_video->vfilter = vf_open_filter(opts, NULL, "vo", vf_arg); - } - - sh_video->vfilter = append_filters(sh_video->vfilter, opts->vf_settings); - - struct vf_instance *vf = sh_video->vfilter; - mpctx->osd->render_subs_in_filter - = vf->control(vf, VFCTRL_INIT_OSD, NULL) == VO_TRUE; + recreate_video_filters(mpctx); init_best_video_codec(sh_video, opts->video_decoders); |