From 2f46b23d51684eef7cfa2bd5fa5e2892772ca816 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 10 Dec 2013 19:08:56 +0100 Subject: video: move handling of brightness and deinterlacing control Handling of brightness/gamma/saturation/etc. and deinterlacing is moved from vf_vo.c to dec_video.c. --- mpvcore/player/command.c | 12 ++++++------ mpvcore/player/video.c | 1 + video/decode/dec_video.c | 40 ++++++++++++++++++++++++++++++++++++++-- video/decode/dec_video.h | 5 ++++- video/filter/vf_vo.c | 27 --------------------------- 5 files changed, 49 insertions(+), 36 deletions(-) diff --git a/mpvcore/player/command.c b/mpvcore/player/command.c index 339327d280..7f92c50bd9 100644 --- a/mpvcore/player/command.c +++ b/mpvcore/player/command.c @@ -1189,13 +1189,13 @@ static int probe_deint_filters(struct MPContext *mpctx, const char *cmd) static int get_deinterlacing(struct MPContext *mpctx) { - struct vf_chain *c = mpctx->d_video->vfilter; + struct dec_video *vd = mpctx->d_video; int enabled = 0; - if (vf_control_any(c, VFCTRL_GET_DEINTERLACE, &enabled) != CONTROL_OK) + if (video_vf_vo_control(vd, VFCTRL_GET_DEINTERLACE, &enabled) != CONTROL_OK) enabled = -1; if (enabled < 0) { // vf_lavfi doesn't support VFCTRL_GET_DEINTERLACE - if (vf_find_by_label(c, VF_DEINTERLACE_LABEL)) + if (vf_find_by_label(vd->vfilter, VF_DEINTERLACE_LABEL)) enabled = 1; } return enabled; @@ -1203,14 +1203,14 @@ static int get_deinterlacing(struct MPContext *mpctx) static void set_deinterlacing(struct MPContext *mpctx, bool enable) { - struct vf_chain *c = mpctx->d_video->vfilter; - if (vf_find_by_label(c, VF_DEINTERLACE_LABEL)) { + struct dec_video *vd = mpctx->d_video; + if (vf_find_by_label(vd->vfilter, VF_DEINTERLACE_LABEL)) { if (!enable) edit_filters(mpctx, STREAM_VIDEO, "del", "@" VF_DEINTERLACE_LABEL); } else { if ((get_deinterlacing(mpctx) > 0) != enable) { int arg = enable; - if (vf_control_any(c, VFCTRL_SET_DEINTERLACE, &arg) != CONTROL_OK) + if (video_vf_vo_control(vd, VFCTRL_SET_DEINTERLACE, &arg) != CONTROL_OK) probe_deint_filters(mpctx, "pre"); } } diff --git a/mpvcore/player/video.c b/mpvcore/player/video.c index 2f069a634b..7584f84c1c 100644 --- a/mpvcore/player/video.c +++ b/mpvcore/player/video.c @@ -123,6 +123,7 @@ int reinit_video_chain(struct MPContext *mpctx) d_video->opts = mpctx->opts; d_video->header = sh; d_video->fps = sh->video->fps; + d_video->vo = mpctx->video_out; mpctx->initialized_flags |= INITIALIZED_VCODEC; vo_control(mpctx->video_out, VOCTRL_GET_HWDEC_INFO, &d_video->hwdec_info); diff --git a/video/decode/dec_video.c b/video/decode/dec_video.c index 4e97ef33ef..02e52368de 100644 --- a/video/decode/dec_video.c +++ b/video/decode/dec_video.c @@ -88,7 +88,7 @@ int video_set_colors(struct dec_video *d_video, const char *item, int value) mp_dbg(MSGT_DECVIDEO, MSGL_V, "set video colors %s=%d \n", item, value); if (d_video->vfilter) { - int ret = vf_control_any(d_video->vfilter, VFCTRL_SET_EQUALIZER, &data); + int ret = video_vf_vo_control(d_video, VFCTRL_SET_EQUALIZER, &data); if (ret == CONTROL_TRUE) return 1; } @@ -105,7 +105,7 @@ int video_get_colors(struct dec_video *d_video, const char *item, int *value) mp_dbg(MSGT_DECVIDEO, MSGL_V, "get video colors %s \n", item); if (d_video->vfilter) { - int ret = vf_control_any(d_video->vfilter, VFCTRL_GET_EQUALIZER, &data); + int ret = video_vf_vo_control(d_video, VFCTRL_GET_EQUALIZER, &data); if (ret == CONTROL_TRUE) { *value = data.value; return 1; @@ -452,3 +452,39 @@ int video_reconfig_filters(struct dec_video *d_video, return 0; } + +// Send a VCTRL, or if it doesn't work, translate it to a VOCTRL and try the VO. +int video_vf_vo_control(struct dec_video *d_video, int vf_cmd, void *data) +{ + if (d_video->vfilter && d_video->vfilter->initialized > 0) { + int r = vf_control_any(d_video->vfilter, vf_cmd, data); + if (r != CONTROL_UNKNOWN) + return r; + } + + switch (vf_cmd) { + case VFCTRL_GET_DEINTERLACE: + return vo_control(d_video->vo, VOCTRL_GET_DEINTERLACE, data) == VO_TRUE; + case VFCTRL_SET_DEINTERLACE: + return vo_control(d_video->vo, VOCTRL_SET_DEINTERLACE, data) == VO_TRUE; + case VFCTRL_SET_EQUALIZER: { + vf_equalizer_t *eq = data; + if (!d_video->vo->config_ok) + return CONTROL_FALSE; // vo not configured? + struct voctrl_set_equalizer_args param = { + eq->item, eq->value + }; + return vo_control(d_video->vo, VOCTRL_SET_EQUALIZER, ¶m) == VO_TRUE; + } + case VFCTRL_GET_EQUALIZER: { + vf_equalizer_t *eq = data; + if (!d_video->vo->config_ok) + return CONTROL_FALSE; // vo not configured? + struct voctrl_get_equalizer_args param = { + eq->item, &eq->value + }; + return vo_control(d_video->vo, VOCTRL_GET_EQUALIZER, ¶m) == VO_TRUE; + } + } + return CONTROL_UNKNOWN; +} diff --git a/video/decode/dec_video.h b/video/decode/dec_video.h index 7d30e6fd91..c15f0d9aba 100644 --- a/video/decode/dec_video.h +++ b/video/decode/dec_video.h @@ -25,12 +25,13 @@ #include "video/hwdec.h" #include "video/mp_image.h" -struct osd_state; struct mp_decoder_list; +struct vo; struct dec_video { struct MPOpts *opts; struct vf_chain *vfilter; // video filter chain + struct vo *vo; // (still) needed by video_set/get_colors const struct vd_functions *vd_driver; struct mp_hwdec_info hwdec_info; // video output hwdec handles struct sh_stream *header; @@ -95,4 +96,6 @@ int video_vd_control(struct dec_video *d_video, int cmd, void *arg); int video_reconfig_filters(struct dec_video *d_video, const struct mp_image_params *params); +int video_vf_vo_control(struct dec_video *d_video, int vf_cmd, void *data); + #endif /* MPLAYER_DEC_VIDEO_H */ diff --git a/video/filter/vf_vo.c b/video/filter/vf_vo.c index 631ab558f1..4f90f6ab3e 100644 --- a/video/filter/vf_vo.c +++ b/video/filter/vf_vo.c @@ -65,33 +65,6 @@ static int control(struct vf_instance *vf, int request, void *data) video_out = data; return CONTROL_OK; } - if (!video_out) - return CONTROL_FALSE; - - switch (request) { - case VFCTRL_GET_DEINTERLACE: - return vo_control(video_out, VOCTRL_GET_DEINTERLACE, data) == VO_TRUE; - case VFCTRL_SET_DEINTERLACE: - return vo_control(video_out, VOCTRL_SET_DEINTERLACE, data) == VO_TRUE; - case VFCTRL_SET_EQUALIZER: { - vf_equalizer_t *eq = data; - if (!video_out->config_ok) - return CONTROL_FALSE; // vo not configured? - struct voctrl_set_equalizer_args param = { - eq->item, eq->value - }; - return vo_control(video_out, VOCTRL_SET_EQUALIZER, ¶m) == VO_TRUE; - } - case VFCTRL_GET_EQUALIZER: { - vf_equalizer_t *eq = data; - if (!video_out->config_ok) - return CONTROL_FALSE; // vo not configured? - struct voctrl_get_equalizer_args param = { - eq->item, &eq->value - }; - return vo_control(video_out, VOCTRL_GET_EQUALIZER, ¶m) == VO_TRUE; - } - } return CONTROL_UNKNOWN; } -- cgit v1.2.3