Skip to content

Commit

Permalink
xvimagesink: Add support for the XV_COLORSPACE attribute.
Browse files Browse the repository at this point in the history
The XV_COLORSPACE attribute exists on some Xv adapters, with the same
semantics as the XV_ITURBT_709 attribute that was already supported.

A value of 0 is bt601, and 1 is for bt709 colorspace.

Fixes color shifting issues displaying bt709 content on some Xv
adapters.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/941>
  • Loading branch information
thaytan committed Nov 25, 2020
1 parent 0dc4191 commit c1f91ba
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
25 changes: 20 additions & 5 deletions sys/xvimage/xvcontext.c
Expand Up @@ -159,13 +159,15 @@ gst_xvcontext_get_xv_support (GstXvContext * context,
static const char dbl_buffer[] = "XV_DOUBLE_BUFFER";
static const char colorkey[] = "XV_COLORKEY";
static const char iturbt709[] = "XV_ITURBT_709";
static const char *xv_colorspace = "XV_COLORSPACE";

GST_DEBUG ("Checking %d Xv port attributes", count);

context->have_autopaint_colorkey = FALSE;
context->have_double_buffer = FALSE;
context->have_colorkey = FALSE;
context->have_iturbt709 = FALSE;
context->have_xvcolorspace = FALSE;

for (i = 0; ((i < count) && todo); i++) {
GST_DEBUG ("Got attribute %s", attr[i].name);
Expand Down Expand Up @@ -234,6 +236,9 @@ gst_xvcontext_get_xv_support (GstXvContext * context,
} else if (!strcmp (attr[i].name, iturbt709)) {
todo--;
context->have_iturbt709 = TRUE;
} else if (!strcmp (attr[i].name, xv_colorspace)) {
context->have_xvcolorspace = TRUE;
todo--;
}
}

Expand Down Expand Up @@ -905,7 +910,7 @@ gst_xvcontext_set_colorimetry (GstXvContext * context,
Atom prop_atom;
int xv_value;

if (!context->have_iturbt709)
if (!context->have_iturbt709 && !context->have_xvcolorspace)
return;

switch (colorimetry->matrix) {
Expand All @@ -919,10 +924,20 @@ gst_xvcontext_set_colorimetry (GstXvContext * context,
}

g_mutex_lock (&context->lock);
prop_atom = XInternAtom (context->disp, "XV_ITURBT_709", True);
if (prop_atom != None) {
XvSetPortAttribute (context->disp,
context->xv_port_id, prop_atom, xv_value);
if (context->have_iturbt709) {
prop_atom = XInternAtom (context->disp, "XV_ITURBT_709", True);
if (prop_atom != None) {
XvSetPortAttribute (context->disp,
context->xv_port_id, prop_atom, xv_value);
}
}

if (context->have_xvcolorspace) {
prop_atom = XInternAtom (context->disp, "XV_COLORSPACE", True);
if (prop_atom != None) {
XvSetPortAttribute (context->disp,
context->xv_port_id, prop_atom, xv_value);
}
}
g_mutex_unlock (&context->lock);
}
Expand Down
1 change: 1 addition & 0 deletions sys/xvimage/xvcontext.h
Expand Up @@ -160,6 +160,7 @@ struct _GstXvContext
gboolean have_colorkey;
gboolean have_double_buffer;
gboolean have_iturbt709;
gboolean have_xvcolorspace;

GList *formats_list;

Expand Down

0 comments on commit c1f91ba

Please sign in to comment.