mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 05:28:32 +00:00
xvimagesink: use xcontext->depth instead of bits in attr.max_value for colorkey
According to the drivers in http://cgit.freedesktop.org/xorg/driver/ we should format the colorkey depending on xcontext->depth. This is what they will use to interprete the value. The max_value in turn is usualy a constant regardless of the depth.
This commit is contained in:
parent
79de0b8d67
commit
2f90615d14
1 changed files with 22 additions and 25 deletions
|
@ -1408,34 +1408,34 @@ gst_xvimagesink_get_xv_support (GstXvImageSink * xvimagesink,
|
||||||
*/
|
*/
|
||||||
const Atom atom = XInternAtom (xcontext->disp, colorkey, False);
|
const Atom atom = XInternAtom (xcontext->disp, colorkey, False);
|
||||||
guint32 ckey = 0;
|
guint32 ckey = 0;
|
||||||
guint32 keymask;
|
|
||||||
gint bits;
|
|
||||||
gboolean set_attr = TRUE;
|
gboolean set_attr = TRUE;
|
||||||
guint cr, cg, cb;
|
guint cr, cg, cb;
|
||||||
|
|
||||||
/* Count the bits in the colorkey mask 'max' value */
|
|
||||||
bits = 0;
|
|
||||||
for (keymask = (guint32) (attr[i].max_value);
|
|
||||||
keymask != 0; keymask >>= 1)
|
|
||||||
bits++;
|
|
||||||
|
|
||||||
/* set a colorkey in the right format RGB565/RGB888
|
/* set a colorkey in the right format RGB565/RGB888
|
||||||
* note that the colorkey is independent from the display
|
* We only handle these 2 cases, because they're the only types of
|
||||||
* depth (xcontext->depth). We only handle these 2 cases, because
|
* devices we've encountered. If we don't recognise it, leave it alone
|
||||||
* they're the only types of devices we've encountered. If we don't
|
*/
|
||||||
* recognise it, leave it alone */
|
|
||||||
cr = (xvimagesink->colorkey >> 16);
|
cr = (xvimagesink->colorkey >> 16);
|
||||||
cg = (xvimagesink->colorkey >> 8) & 0xFF;
|
cg = (xvimagesink->colorkey >> 8) & 0xFF;
|
||||||
cb = (xvimagesink->colorkey) & 0xFF;
|
cb = (xvimagesink->colorkey) & 0xFF;
|
||||||
if (bits == 16) { /* RGB 565 */
|
switch (xcontext->depth) {
|
||||||
cr >>= 3;
|
case 16: /* RGB 565 */
|
||||||
cg >>= 2;
|
cr >>= 3;
|
||||||
cb >>= 3;
|
cg >>= 2;
|
||||||
ckey = (cr << 11) | (cg << 5) | cb;
|
cb >>= 3;
|
||||||
} else if (bits == 24 || bits == 32) { /* RGB 888 / ARGB 8888 */
|
ckey = (cr << 11) | (cg << 5) | cb;
|
||||||
ckey = (cr << 16) | (cg << 8) | cb;
|
break;
|
||||||
} else
|
case 24:
|
||||||
set_attr = FALSE;
|
case 32: /* RGB 888 / ARGB 8888 */
|
||||||
|
ckey = (cr << 16) | (cg << 8) | cb;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
GST_DEBUG_OBJECT (xvimagesink,
|
||||||
|
"Unknown bit depth %d for Xv Colorkey - not adjusting",
|
||||||
|
xcontext->depth);
|
||||||
|
set_attr = FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (set_attr) {
|
if (set_attr) {
|
||||||
ckey = CLAMP (ckey, (guint32) attr[i].min_value,
|
ckey = CLAMP (ckey, (guint32) attr[i].min_value,
|
||||||
|
@ -1446,9 +1446,6 @@ gst_xvimagesink_get_xv_support (GstXvImageSink * xvimagesink,
|
||||||
|
|
||||||
XvSetPortAttribute (xcontext->disp, xcontext->xv_port_id, atom,
|
XvSetPortAttribute (xcontext->disp, xcontext->xv_port_id, atom,
|
||||||
(gint) ckey);
|
(gint) ckey);
|
||||||
} else {
|
|
||||||
GST_DEBUG_OBJECT (xvimagesink,
|
|
||||||
"Unknown bit depth %d for Xv Colorkey - not adjusting", bits);
|
|
||||||
}
|
}
|
||||||
todo--;
|
todo--;
|
||||||
xvimagesink->have_colorkey = TRUE;
|
xvimagesink->have_colorkey = TRUE;
|
||||||
|
@ -2357,7 +2354,7 @@ gst_xvimagesink_buffer_alloc (GstBaseSink * bsink, guint64 offset, guint size,
|
||||||
|
|
||||||
if (G_LIKELY (xvimagesink->xcontext->last_caps &&
|
if (G_LIKELY (xvimagesink->xcontext->last_caps &&
|
||||||
gst_caps_is_equal (caps, xvimagesink->xcontext->last_caps))) {
|
gst_caps_is_equal (caps, xvimagesink->xcontext->last_caps))) {
|
||||||
GST_DEBUG_OBJECT (xvimagesink,
|
GST_LOG_OBJECT (xvimagesink,
|
||||||
"buffer alloc for same last_caps, reusing caps");
|
"buffer alloc for same last_caps, reusing caps");
|
||||||
intersection = gst_caps_ref (caps);
|
intersection = gst_caps_ref (caps);
|
||||||
image_format = xvimagesink->xcontext->last_format;
|
image_format = xvimagesink->xcontext->last_format;
|
||||||
|
|
Loading…
Reference in a new issue