summaryrefslogtreecommitdiffstats
path: root/player/video.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-01-14 00:18:36 +0100
committerwm4 <wm4@nowhere>2016-01-14 00:18:36 +0100
commit5722f93a740e841cfe929980c7ac4d4f7896d9dc (patch)
treecf8c438e2a2fcec438d1a1ceb0816b138063e322 /player/video.c
parentbf13bd0d47e5fc6761c51c6ba7056968e60bf4cd (diff)
downloadmpv-5722f93a740e841cfe929980c7ac4d4f7896d9dc.tar.bz2
mpv-5722f93a740e841cfe929980c7ac4d4f7896d9dc.tar.xz
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.
Diffstat (limited to 'player/video.c')
-rw-r--r--player/video.c71
1 files changed, 71 insertions, 0 deletions
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, &param) == 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, &param) == 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);