From 5722f93a740e841cfe929980c7ac4d4f7896d9dc Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 14 Jan 2016 00:18:36 +0100 Subject: video: refactor: shuffle code around struct dec_video should have nothing to do with video filters or outputs, and this huge chunk of code was somehow stuck directly in dec_video.c. --- player/video.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) (limited to 'player/video.c') diff --git a/player/video.c b/player/video.c index 9ec7eacb74..afd0a2aa7a 100644 --- a/player/video.c +++ b/player/video.c @@ -68,6 +68,77 @@ static const char av_desync_help_text[] = static bool decode_coverart(struct dec_video *d_video); +int video_set_colors(struct dec_video *d_video, const char *item, int value) +{ + vf_equalizer_t data; + + data.item = item; + data.value = value; + + MP_VERBOSE(d_video, "set video colors %s=%d \n", item, value); + if (d_video->vfilter) { + int ret = video_vf_vo_control(d_video, VFCTRL_SET_EQUALIZER, &data); + if (ret == CONTROL_TRUE) + return 1; + } + MP_VERBOSE(d_video, "Video attribute '%s' is not supported by selected vo.\n", + item); + return 0; +} + +int video_get_colors(struct dec_video *d_video, const char *item, int *value) +{ + vf_equalizer_t data; + + data.item = item; + + MP_VERBOSE(d_video, "get video colors %s \n", item); + if (d_video->vfilter) { + int ret = video_vf_vo_control(d_video, VFCTRL_GET_EQUALIZER, &data); + if (ret == CONTROL_TRUE) { + *value = data.value; + return 1; + } + } + 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; +} + static void set_allowed_vo_formats(struct vf_chain *c, struct vo *vo) { vo_query_formats(vo, c->allowed_output_formats); -- cgit v1.2.3