1
0
mirror of https://github.com/mpv-player/mpv synced 2025-01-17 20:48:46 +00:00

vf: add vf_control wrapper

Slightly cleaner, although rather redundant. But still, why wasn't this
added 10 years ago?
This commit is contained in:
wm4 2013-07-15 00:57:04 +02:00
parent 17ab38bc66
commit 88e813aae6
3 changed files with 12 additions and 6 deletions

View File

@ -55,7 +55,7 @@ int get_video_quality_max(sh_video_t *sh_video)
{
vf_instance_t *vf = sh_video->vfilter;
if (vf) {
int ret = vf->control(vf, VFCTRL_QUERY_MAX_PP_LEVEL, NULL);
int ret = vf_control(vf, VFCTRL_QUERY_MAX_PP_LEVEL, NULL);
if (ret > 0) {
mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "[PP] Using external postprocessing filter, max q = %d.\n", ret);
return ret;
@ -74,7 +74,7 @@ int set_video_colors(sh_video_t *sh_video, const char *item, int value)
mp_dbg(MSGT_DECVIDEO, MSGL_V, "set video colors %s=%d \n", item, value);
if (vf) {
int ret = vf->control(vf, VFCTRL_SET_EQUALIZER, &data);
int ret = vf_control(vf, VFCTRL_SET_EQUALIZER, &data);
if (ret == CONTROL_TRUE)
return 1;
}
@ -92,7 +92,7 @@ int get_video_colors(sh_video_t *sh_video, const char *item, int *value)
mp_dbg(MSGT_DECVIDEO, MSGL_V, "get video colors %s \n", item);
if (vf) {
int ret = vf->control(vf, VFCTRL_GET_EQUALIZER, &data);
int ret = vf_control(vf, VFCTRL_GET_EQUALIZER, &data);
if (ret == CONTROL_TRUE) {
*value = data.value;
return 1;
@ -129,10 +129,10 @@ void set_video_colorspace(struct sh_video *sh)
struct mp_csp_details requested;
get_detected_video_colorspace(sh, &requested);
vf->control(vf, VFCTRL_SET_YUV_COLORSPACE, &requested);
vf_control(vf, VFCTRL_SET_YUV_COLORSPACE, &requested);
struct mp_csp_details actual = MP_CSP_DETAILS_DEFAULTS;
vf->control(vf, VFCTRL_GET_YUV_COLORSPACE, &actual);
vf_control(vf, VFCTRL_GET_YUV_COLORSPACE, &actual);
int success = actual.format == requested.format
&& actual.levels_in == requested.levels_in
@ -146,7 +146,7 @@ void set_video_colorspace(struct sh_video *sh)
&& requested.format == MP_CSP_SMPTE_240M) {
// BT.709 is pretty close, much better than BT.601
requested.format = MP_CSP_BT_709;
vf->control(vf, VFCTRL_SET_YUV_COLORSPACE, &requested);
vf_control(vf, VFCTRL_SET_YUV_COLORSPACE, &requested);
}
}

View File

@ -123,6 +123,11 @@ const m_obj_list_t vf_obj_list = {
M_ST_OFF(vf_info_t, opts)
};
int vf_control(struct vf_instance *vf, int cmd, void *arg)
{
return vf->control(vf, cmd, arg);
}
// Get a new image for filter output, with size and pixel format according to
// the last vf_config call.
struct mp_image *vf_alloc_out_image(struct vf_instance *vf)

View File

@ -109,6 +109,7 @@ typedef struct vf_seteq {
#define VFCTRL_SET_YUV_COLORSPACE 22 // arg is struct mp_csp_details*
#define VFCTRL_GET_YUV_COLORSPACE 23 // arg is struct mp_csp_details*
int vf_control(struct vf_instance *vf, int cmd, void *arg);
struct mp_image *vf_alloc_out_image(struct vf_instance *vf);
void vf_make_out_image_writeable(struct vf_instance *vf, struct mp_image *img);