summaryrefslogtreecommitdiffstats
path: root/libvo
diff options
context:
space:
mode:
authorUoti Urpala <uau@glyph.nonexistent.invalid>2009-11-15 15:21:40 +0200
committerUoti Urpala <uau@glyph.nonexistent.invalid>2009-11-15 17:03:41 +0200
commit98ee8dd15976501157c894ec385c4c551c6614ad (patch)
tree0ca98500193f1e76da5ecc15d2076abec9caee59 /libvo
parent201bef7ee150f9d852996b379c926ba0c47320d5 (diff)
downloadmpv-98ee8dd15976501157c894ec385c4c551c6614ad.tar.bz2
mpv-98ee8dd15976501157c894ec385c4c551c6614ad.tar.xz
Add yuv_colorspace property, implemented in vo_vdpau and vo_xv
Add a property to select YUV colorspace. Currently implemented only in vo_vdpau and vo_xv. Allows switching between BT.601, BT.709 and SMPTE-240M (vdpau only). The xv support uses the "XV_ITURBT_709" attribute. At least my NVIDIA card supports that; I don't know whether other xv implementations do. Bind the colorspace switch to the 'c' key by default. 'c' is currently used by vo_sdl for some fullscreen mode change thing, but at the moment that does not conflict and if it will in the future then vo_sdl can change. VDPAU part based on a patch from Lauri Mylläri <lauri.myllari@gmail.com>
Diffstat (limited to 'libvo')
-rw-r--r--libvo/video_out.h3
-rw-r--r--libvo/vo_vdpau.c59
-rw-r--r--libvo/vo_xv.c9
-rw-r--r--libvo/x11_common.c8
4 files changed, 64 insertions, 15 deletions
diff --git a/libvo/video_out.h b/libvo/video_out.h
index 50602e83a4..17c387a320 100644
--- a/libvo/video_out.h
+++ b/libvo/video_out.h
@@ -88,6 +88,9 @@ typedef struct {
#define VOCTRL_UPDATE_SCREENINFO 32
+#define VOCTRL_SET_YUV_COLORSPACE 33
+#define VOCTRL_GET_YUV_COLORSPACE 34
+
// Vo can be used by xover
#define VOCTRL_XOVERLAY_SUPPORT 22
diff --git a/libvo/vo_vdpau.c b/libvo/vo_vdpau.c
index 6eef93842f..a228b00787 100644
--- a/libvo/vo_vdpau.c
+++ b/libvo/vo_vdpau.c
@@ -124,6 +124,8 @@ struct vdpctx {
int output_surface_width, output_surface_height;
VdpVideoMixer video_mixer;
+ int user_colorspace;
+ int colorspace;
int deint;
int deint_type;
int deint_counter;
@@ -541,6 +543,33 @@ static int win_x11_init_vdpau_flip_queue(struct vo *vo)
return 0;
}
+static void update_csc_matrix(struct vo *vo)
+{
+ struct vdpctx *vc = vo->priv;
+ struct vdp_functions *vdp = vc->vdp;
+ VdpStatus vdp_st;
+
+ const VdpColorStandard vdp_colors[] = {VDP_COLOR_STANDARD_ITUR_BT_601,
+ VDP_COLOR_STANDARD_ITUR_BT_709,
+ VDP_COLOR_STANDARD_SMPTE_240M};
+ char * const vdp_names[] = {"BT.601", "BT.709", "SMPTE-240M"};
+ int csp = vc->colorspace;
+ mp_msg(MSGT_VO, MSGL_V, "[vdpau] Updating CSC matrix for %s\n",
+ vdp_names[csp]);
+
+ VdpCSCMatrix matrix;
+ vdp_st = vdp->generate_csc_matrix(&vc->procamp, vdp_colors[csp], &matrix);
+ CHECK_ST_WARNING("Error when generating CSC matrix");
+
+ const VdpVideoMixerAttribute attributes[] =
+ {VDP_VIDEO_MIXER_ATTRIBUTE_CSC_MATRIX};
+ const void *attribute_values[] = {&matrix};
+ vdp_st = vdp->video_mixer_set_attribute_values(vc->video_mixer, 1,
+ attributes,
+ attribute_values);
+ CHECK_ST_WARNING("Error when setting CSC matrix");
+}
+
static int create_vdp_mixer(struct vo *vo, VdpChromaType vdp_chroma_type)
{
struct vdpctx *vc = vo->priv;
@@ -611,6 +640,7 @@ static int create_vdp_mixer(struct vo *vo, VdpChromaType vdp_chroma_type)
skip_chroma_attrib,
skip_chroma_value_ptr);
+ update_csc_matrix(vo);
return 0;
}
@@ -803,6 +833,10 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
vc->image_format = format;
vc->vid_width = width;
vc->vid_height = height;
+ if (vc->user_colorspace == 0)
+ vc->colorspace = width >= 1280 || height > 576 ? 1 : 0;
+ else
+ vc->colorspace = vc->user_colorspace - 1;
free_video_specific(vo);
if (IMGFMT_IS_VDPAU(vc->image_format) && !create_vdp_decoder(vo, 2))
return -1;
@@ -1543,12 +1577,14 @@ static int preinit(struct vo *vo, const char *arg)
vc->deint_type = 3;
vc->chroma_deint = 1;
+ vc->user_colorspace = 1;
const opt_t subopts[] = {
{"deint", OPT_ARG_INT, &vc->deint, (opt_test_f)int_non_neg},
{"chroma-deint", OPT_ARG_BOOL, &vc->chroma_deint, NULL},
{"pullup", OPT_ARG_BOOL, &vc->pullup, NULL},
{"denoise", OPT_ARG_FLOAT, &vc->denoise, NULL},
{"sharpen", OPT_ARG_FLOAT, &vc->sharpen, NULL},
+ {"colorspace", OPT_ARG_INT, &vc->user_colorspace, NULL},
{"fps", OPT_ARG_FLOAT, &vc->user_fps, NULL},
{NULL}
};
@@ -1623,11 +1659,6 @@ static int set_equalizer(struct vo *vo, const char *name, int value)
{
struct vdpctx *vc = vo->priv;
struct vdp_functions *vdp = vc->vdp;
- VdpStatus vdp_st;
- VdpCSCMatrix matrix;
- static const VdpVideoMixerAttribute attributes[] =
- {VDP_VIDEO_MIXER_ATTRIBUTE_CSC_MATRIX};
- const void *attribute_values[] = {&matrix};
if (!strcasecmp(name, "brightness"))
vc->procamp.brightness = value / 100.0;
@@ -1640,15 +1671,8 @@ static int set_equalizer(struct vo *vo, const char *name, int value)
else
return VO_NOTIMPL;
- vdp_st = vdp->generate_csc_matrix(&vc->procamp,
- VDP_COLOR_STANDARD_ITUR_BT_601,
- &matrix);
- CHECK_ST_WARNING("Error when generating CSC matrix");
- vdp_st = vdp->video_mixer_set_attribute_values(vc->video_mixer, 1,
- attributes,
- attribute_values);
- CHECK_ST_WARNING("Error when setting CSC matrix");
- return VO_TRUE;
+ update_csc_matrix(vo);
+ return true;
}
static int control(struct vo *vo, uint32_t request, void *data)
@@ -1712,6 +1736,13 @@ static int control(struct vo *vo, uint32_t request, void *data)
struct voctrl_get_equalizer_args *args = data;
return get_equalizer(vo, args->name, args->valueptr);
}
+ case VOCTRL_SET_YUV_COLORSPACE:
+ vc->colorspace = *(int *)data % 3;
+ update_csc_matrix(vo);
+ return true;
+ case VOCTRL_GET_YUV_COLORSPACE:
+ *(int *)data = vc->colorspace;
+ return true;
case VOCTRL_ONTOP:
vo_x11_ontop(vo);
return VO_TRUE;
diff --git a/libvo/vo_xv.c b/libvo/vo_xv.c
index 886fd0a0d7..9a030ac71c 100644
--- a/libvo/vo_xv.c
+++ b/libvo/vo_xv.c
@@ -817,6 +817,15 @@ static int control(struct vo *vo, uint32_t request, void *data)
struct voctrl_get_equalizer_args *args = data;
return vo_xv_get_eq(vo, x11->xv_port, args->name, args->valueptr);
}
+ case VOCTRL_SET_YUV_COLORSPACE:;
+ int given_cspc = *(int *)data % 2;
+ return vo_xv_set_eq(vo, x11->xv_port, "bt_709", given_cspc * 200 - 100);
+ case VOCTRL_GET_YUV_COLORSPACE:;
+ int bt709_enabled;
+ if (!vo_xv_get_eq(vo, x11->xv_port, "bt_709", &bt709_enabled))
+ return false;
+ *(int *)data = bt709_enabled == 100;
+ return true;
case VOCTRL_ONTOP:
vo_x11_ontop(vo);
return VO_TRUE;
diff --git a/libvo/x11_common.c b/libvo/x11_common.c
index 621880e137..e617aad082 100644
--- a/libvo/x11_common.c
+++ b/libvo/x11_common.c
@@ -1651,7 +1651,7 @@ double vo_vm_get_fps(struct vo *vo)
if (!XF86VidModeGetModeLine(x11->display, x11->screen, &clock, &modeline))
return 0;
if (modeline.privsize)
- Xfree(modeline.private);
+ XFree(modeline.private);
return 1e3 * clock / modeline.htotal / modeline.vtotal;
}
#endif
@@ -1906,6 +1906,9 @@ int vo_xv_set_eq(struct vo *vo, uint32_t xv_port, char *name, int value)
else if (!strcmp(attributes[i].name, "XV_BLUE_INTENSITY")
&& (!strcasecmp(name, "blue_intensity")))
port_value = value;
+ else if (!strcmp(attributes[i].name, "XV_ITURBT_709")
+ && (!strcasecmp(name, "bt_709")))
+ port_value = value;
else
continue;
@@ -1987,6 +1990,9 @@ int vo_xv_get_eq(struct vo *vo, uint32_t xv_port, char *name, int *value)
else if (!strcmp(attributes[i].name, "XV_BLUE_INTENSITY")
&& (!strcasecmp(name, "blue_intensity")))
*value = val;
+ else if (!strcmp(attributes[i].name, "XV_ITURBT_709")
+ && (!strcasecmp(name, "bt_709")))
+ *value = val;
else
continue;