[Gstreamer-bugs] [Bug 112621] Changed - lots of plugins get RGB caps wrong

bugzilla-daemon at widget.gnome.org bugzilla-daemon at widget.gnome.org
Fri May 9 12:41:58 PDT 2003


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

http://bugzilla.gnome.org/show_bug.cgi?id=112621

Changed by ds at schleef.org.

--- shadow/112621	Fri May  9 11:44:50 2003
+++ shadow/112621.tmp.26591	Fri May  9 15:41:58 2003
@@ -60,6 +60,45 @@
 I assume I can do "redpart = pixel & gst_caps_get_int(caps,
 "red_mask")" at any time with any RGB video on any machine.
 
 Is this true or not before/after the patch?
 
 
+
+------- Additional Comments From ds at schleef.org  2003-05-09 15:41 -------
+You can still cast a 32-bit RGB pixel to a guint32 and pull out the
+color component using the color masks -- but you need to convert the
+color masks to the host's byte order first.
+
+Right now, a lot of things are using endianness==G_BYTE_ORDER, which
+means that for a given subpixel arrangement in memory, the masks are
+different depending on the endianness.  I think that a particular
+memory arrangement should have exactly one authoritative caps, and
+using G_BYTE_ORDER doesn't allow this.  Currently, few plugins get the
+color masks correct for G_BYTE_ORDER on big endian machines.  Thus,
+one of the primary benefits of using G_BIG_ENDIAN is that caps can be
+defined without #ifdefs.
+
+(The main advantage of using G_BIG_ENDIAN over G_LITTLE_ENDIAN is that
+the masks read in memory order.)
+
+Example code:
+
+  endianness = gst_caps_get_int(caps,"endianness");
+  red_mask = gst_caps_get_int(caps,"red_mask");
+  if(endianness!=G_BYTE_ORDER)red_mask=GUINT32_SWAP_BE_LE(red_mask);
+  
+  pixel = *(guint32 *)data;
+  red_part = pixel&red_mask;
+
+for bpp=16, you'd use
+
+  pixel = *(guint16 *)data;
+  red_part = pixel&red_mask;
+
+This works for any combination of host endianness and data endianness.
+ I don't think that anything less addresses the problem correctly.
+
+However, I don't think that anyone will actually use caps in this way.
+ The primary use of RGB caps appears to be converting to/from a
+library's #define'd format.  This mostly just means knowing how to
+specify the library's format as gst caps.





More information about the Gstreamer-bugs mailing list