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.
This commit is contained in:
wm4
2013-12-10 20:07:39 +01:00
parent 5f0585177e
commit 2f46b23d51
5 changed files with 49 additions and 36 deletions
+6 -6
View File
@@ -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");
}
}
+1
View File
@@ -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);
+38 -2
View File
@@ -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, &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;
}
+4 -1
View File
@@ -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 */
-27
View File
@@ -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, &param) == 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, &param) == VO_TRUE;
}
}
return CONTROL_UNKNOWN;
}