diff options
author | Stefan Kost <ensonic@users.sf.net> | 2009-03-26 18:54:56 +0200 |
---|---|---|
committer | Stefan Kost <ensonic@users.sf.net> | 2009-03-31 12:27:09 +0300 |
commit | 2f90615d14574c62453f55a854f4599bce1391a3 (patch) | |
tree | fdf88b150b1da1e981bbd7ab5d947aa426ccc32f | |
parent | 79de0b8d67df6fbbe79455adc2e06858295f5c03 (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.c | 47 |
1 files changed, 22 insertions, 25 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, | |||
1408 | */ | 1408 | */ |
1409 | const Atom atom = XInternAtom (xcontext->disp, colorkey, False); | 1409 | const Atom atom = XInternAtom (xcontext->disp, colorkey, False); |
1410 | guint32 ckey = 0; | 1410 | guint32 ckey = 0; |
1411 | guint32 keymask; | ||
1412 | gint bits; | ||
1413 | gboolean set_attr = TRUE; | 1411 | gboolean set_attr = TRUE; |
1414 | guint cr, cg, cb; | 1412 | guint cr, cg, cb; |
1415 | 1413 | ||
1416 | /* Count the bits in the colorkey mask 'max' value */ | ||
1417 | bits = 0; | ||
1418 | for (keymask = (guint32) (attr[i].max_value); | ||
1419 | keymask != 0; keymask >>= 1) | ||
1420 | bits++; | ||
1421 | |||
1422 | /* set a colorkey in the right format RGB565/RGB888 | 1414 | /* set a colorkey in the right format RGB565/RGB888 |
1423 | * note that the colorkey is independent from the display | 1415 | * We only handle these 2 cases, because they're the only types of |
1424 | * depth (xcontext->depth). We only handle these 2 cases, because | 1416 | * devices we've encountered. If we don't recognise it, leave it alone |
1425 | * they're the only types of devices we've encountered. If we don't | 1417 | */ |
1426 | * recognise it, leave it alone */ | ||
1427 | cr = (xvimagesink->colorkey >> 16); | 1418 | cr = (xvimagesink->colorkey >> 16); |
1428 | cg = (xvimagesink->colorkey >> 8) & 0xFF; | 1419 | cg = (xvimagesink->colorkey >> 8) & 0xFF; |
1429 | cb = (xvimagesink->colorkey) & 0xFF; | 1420 | cb = (xvimagesink->colorkey) & 0xFF; |
1430 | if (bits == 16) { /* RGB 565 */ | 1421 | switch (xcontext->depth) { |
1431 | cr >>= 3; | 1422 | case 16: /* RGB 565 */ |
1432 | cg >>= 2; | 1423 | cr >>= 3; |
1433 | cb >>= 3; | 1424 | cg >>= 2; |
1434 | ckey = (cr << 11) | (cg << 5) | cb; | 1425 | cb >>= 3; |
1435 | } else if (bits == 24 || bits == 32) { /* RGB 888 / ARGB 8888 */ | 1426 | ckey = (cr << 11) | (cg << 5) | cb; |
1436 | ckey = (cr << 16) | (cg << 8) | cb; | 1427 | break; |
1437 | } else | 1428 | case 24: |
1438 | set_attr = FALSE; | 1429 | case 32: /* RGB 888 / ARGB 8888 */ |
1430 | ckey = (cr << 16) | (cg << 8) | cb; | ||
1431 | break; | ||
1432 | default: | ||
1433 | GST_DEBUG_OBJECT (xvimagesink, | ||
1434 | "Unknown bit depth %d for Xv Colorkey - not adjusting", | ||
1435 | xcontext->depth); | ||
1436 | set_attr = FALSE; | ||
1437 | break; | ||
1438 | } | ||
1439 | 1439 | ||
1440 | if (set_attr) { | 1440 | if (set_attr) { |
1441 | ckey = CLAMP (ckey, (guint32) attr[i].min_value, | 1441 | ckey = CLAMP (ckey, (guint32) attr[i].min_value, |
@@ -1446,9 +1446,6 @@ gst_xvimagesink_get_xv_support (GstXvImageSink * xvimagesink, | |||
1446 | 1446 | ||
1447 | XvSetPortAttribute (xcontext->disp, xcontext->xv_port_id, atom, | 1447 | XvSetPortAttribute (xcontext->disp, xcontext->xv_port_id, atom, |
1448 | (gint) ckey); | 1448 | (gint) ckey); |
1449 | } else { | ||
1450 | GST_DEBUG_OBJECT (xvimagesink, | ||
1451 | "Unknown bit depth %d for Xv Colorkey - not adjusting", bits); | ||
1452 | } | 1449 | } |
1453 | todo--; | 1450 | todo--; |
1454 | xvimagesink->have_colorkey = TRUE; | 1451 | xvimagesink->have_colorkey = TRUE; |
@@ -2357,7 +2354,7 @@ gst_xvimagesink_buffer_alloc (GstBaseSink * bsink, guint64 offset, guint size, | |||
2357 | 2354 | ||
2358 | if (G_LIKELY (xvimagesink->xcontext->last_caps && | 2355 | if (G_LIKELY (xvimagesink->xcontext->last_caps && |
2359 | gst_caps_is_equal (caps, xvimagesink->xcontext->last_caps))) { | 2356 | gst_caps_is_equal (caps, xvimagesink->xcontext->last_caps))) { |
2360 | GST_DEBUG_OBJECT (xvimagesink, | 2357 | GST_LOG_OBJECT (xvimagesink, |
2361 | "buffer alloc for same last_caps, reusing caps"); | 2358 | "buffer alloc for same last_caps, reusing caps"); |
2362 | intersection = gst_caps_ref (caps); | 2359 | intersection = gst_caps_ref (caps); |
2363 | image_format = xvimagesink->xcontext->last_format; | 2360 | image_format = xvimagesink->xcontext->last_format; |