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/core.h | 3 ++ player/video.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++ video/decode/dec_video.c | 71 ------------------------------------------------ video/decode/dec_video.h | 6 +--- 4 files changed, 75 insertions(+), 76 deletions(-) diff --git a/player/core.h b/player/core.h index 5c5466a3ae..cb81c88b2e 100644 --- a/player/core.h +++ b/player/core.h @@ -512,6 +512,9 @@ void update_osd_msg(struct MPContext *mpctx); bool update_subtitles(struct MPContext *mpctx, double video_pts); // video.c +int video_get_colors(struct dec_video *d_video, const char *item, int *value); +int video_set_colors(struct dec_video *d_video, const char *item, int value); +int video_vf_vo_control(struct dec_video *d_video, int vf_cmd, void *data); void reset_video_state(struct MPContext *mpctx); int reinit_video_chain(struct MPContext *mpctx); int reinit_video_filters(struct MPContext *mpctx); 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); diff --git a/video/decode/dec_video.c b/video/decode/dec_video.c index 772bab2f16..b120a69957 100644 --- a/video/decode/dec_video.c +++ b/video/decode/dec_video.c @@ -79,41 +79,6 @@ int video_vd_control(struct dec_video *d_video, int cmd, void *arg) return CONTROL_UNKNOWN; } -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; -} - void video_uninit(struct dec_video *d_video) { mp_image_unrefp(&d_video->waiting_decoded_mpi); @@ -398,39 +363,3 @@ struct mp_image *video_decode(struct dec_video *d_video, d_video->decoded_pts = pts; return mpi; } - -// 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 fe325806c6..7f59d6bd3b 100644 --- a/video/decode/dec_video.h +++ b/video/decode/dec_video.h @@ -87,11 +87,7 @@ struct mp_image *video_decode(struct dec_video *d_video, struct demux_packet *packet, int drop_frame); -int video_get_colors(struct dec_video *d_video, const char *item, int *value); -int video_set_colors(struct dec_video *d_video, const char *item, int value); -void video_reset_decoding(struct dec_video *d_video); int video_vd_control(struct dec_video *d_video, int cmd, void *arg); - -int video_vf_vo_control(struct dec_video *d_video, int vf_cmd, void *data); +void video_reset_decoding(struct dec_video *d_video); #endif /* MPLAYER_DEC_VIDEO_H */ -- cgit v1.2.3