summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Kost <ensonic@users.sf.net>2009-03-26 18:54:56 +0200
committerStefan Kost <ensonic@users.sf.net>2009-03-31 12:27:09 +0300
commit2f90615d14574c62453f55a854f4599bce1391a3 (patch)
treefdf88b150b1da1e981bbd7ab5d947aa426ccc32f
parent79de0b8d67df6fbbe79455adc2e06858295f5c03 (diff)
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.
-rw-r--r--sys/xvimage/xvimagesink.c35
1 files changed, 16 insertions, 19 deletions
diff --git a/sys/xvimage/xvimagesink.c b/sys/xvimage/xvimagesink.c
index 818ffd2b1..bb348b45d 100644
--- a/sys/xvimage/xvimagesink.c
+++ b/sys/xvimage/xvimagesink.c
@@ -1408,34 +1408,34 @@ gst_xvimagesink_get_xv_support (GstXvImageSink * xvimagesink,
*/
const Atom atom = XInternAtom (xcontext->disp, colorkey, False);
guint32 ckey = 0;
- guint32 keymask;
- gint bits;
gboolean set_attr = TRUE;
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
- * note that the colorkey is independent from the display
- * depth (xcontext->depth). We only handle these 2 cases, because
- * they're the only types of devices we've encountered. If we don't
- * recognise it, leave it alone */
+ * We only handle these 2 cases, because they're the only types of
+ * devices we've encountered. If we don't recognise it, leave it alone
+ */
cr = (xvimagesink->colorkey >> 16);
cg = (xvimagesink->colorkey >> 8) & 0xFF;
cb = (xvimagesink->colorkey) & 0xFF;
- if (bits == 16) { /* RGB 565 */
+ switch (xcontext->depth) {
+ case 16: /* RGB 565 */
cr >>= 3;
cg >>= 2;
cb >>= 3;
ckey = (cr << 11) | (cg << 5) | cb;
- } else if (bits == 24 || bits == 32) { /* RGB 888 / ARGB 8888 */
+ break;
+ case 24:
+ case 32: /* RGB 888 / ARGB 8888 */
ckey = (cr << 16) | (cg << 8) | cb;
- } else
+ break;
+ default:
+ GST_DEBUG_OBJECT (xvimagesink,
+ "Unknown bit depth %d for Xv Colorkey - not adjusting",
+ xcontext->depth);
set_attr = FALSE;
+ break;
+ }
if (set_attr) {
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,
(gint) ckey);
- } else {
- GST_DEBUG_OBJECT (xvimagesink,
- "Unknown bit depth %d for Xv Colorkey - not adjusting", bits);
}
todo--;
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 &&
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");
intersection = gst_caps_ref (caps);
image_format = xvimagesink->xcontext->last_format;