|
From: Daniel K. <ko...@ta...> - 2002-06-19 15:02:29
|
On Wed, Jun 19, 2002 at 10:43:19AM -0400, Bill Fink wrote:
> On Wed, 19 Jun 2002, Stefan Lucke wrote:
> > NO, thouse IDs come from X11.
> > #define FOURCC_YUY2 0x32595559
(Which is actually the hexdump of 'YUY2' [or '2YUY' depending on your
preferred endianness].)
> OK. I'm not sure I totally understand all this. xvinfo on XF 4.2 on
> ATI (both DRI and non-DRI) and NVIDIA all report "id: 0x32595559 (2YUY)"
> as the first available image format. Without the patch, only the ATI
> DRI case has wrong colors. The XF CVS patch may address the ATI DMA/DRI
> issue, but what about the NVIDIA case. Does this mean the NVIDIA X driver
> is currently broken (reporting incorrect image format)?
The more I look into this, it seems that Xv implementations are flawed.
XvImageFormatValues contains an entry byte_order that should tell us
about the endianness the card wants to see. However, on the TiBook (ATI
Rage Mobility M3) at least, this field is set to LSBFirst, where
evidence clearly shows that it had better be MSBFirst. Which tells us
two things: 1) We cannot determine the correct byte order at compile
time. 2) The sane way to automatically probe the correct byte order at
runtime is flawed at least with some cards. Conclusion: We're screwed.
Easy way out: Let the user override default byte order with a runtime
switch. Comments?
Below a little debugging patch to play with. It assumes the default in
current CVS, i.e. LSBFirst for little-endian systems, and MSBFirst on
big-endian machines, tests against the byte order reported by XV, and
bails out if they don't match.
Regards,
Daniel.
--[snip]--
Index: display.c
===================================================================
RCS file: /cvsroot/libdv/libdv/playdv/display.c,v
retrieving revision 1.5
diff -u -r1.5 display.c
--- display.c 26 May 2002 21:02:42 -0000 1.5
+++ display.c 19 Jun 2002 15:01:53 -0000
@@ -33,6 +33,7 @@
#include <stdio.h>
#include <math.h>
#include <string.h>
+#include <endian.h>
#include <libdv/dv_types.h>
#include <libdv/util.h>
@@ -58,6 +59,8 @@
#if HAVE_LIBXV
+#include <X11/X.h>
+
#define XV_FORMAT_MASK 0x03
#define XV_FORMAT_ASIS 0x00
#define XV_FORMAT_NORMAL 0x01
@@ -73,6 +76,12 @@
#define DV_FORMAT_NORMAL 0
#define DV_FORMAT_WIDE 1
+#if BYTE_ORDER == LITTLE_ENDIAN
+# define DV_NATIVE_BYTE_ORDER LSBFirst
+#else
+# define DV_NATIVE_BYTE_ORDER MSBFirst
+#endif
+
static void dv_display_event (dv_display_t *dv_dpy);
static gint dv_display_Xv_init (dv_display_t *dv_dpy, gchar *w_name,
gchar *i_name, int flags, int size);
@@ -441,7 +450,17 @@
} /* if */
for(got_fmt = False, k = 0; k < fmt_cnt; ++k) {
if (dv_dpy->format == fmt_info[k].id) {
+ if (fmt_info[k].byte_order != DV_NATIVE_BYTE_ORDER) {
+ fprintf(stderr, "Xv: %s: Unsupported endianness for format 0x%x: %s\n",
+ ad_info[i].name, fmt_info[k].id,
+ (fmt_info[k].byte_order == LSBFirst) ? "LSBFirst" : "MSBFirst");
+ continue;
+ }
got_fmt = True;
+ fprintf(stderr, "Xv: %s: Advertised byte order is %s\n",
+ ad_info[i].name,
+ (fmt_info[k].byte_order == LSBFirst) ?
+ "LSBFirst" : "MSBFirst");
break;
} /* if */
} /* for */
@@ -462,6 +481,10 @@
++k, ++(dv_dpy->port)) {
if (dv_dpy->arg_xv_port != 0 && dv_dpy->arg_xv_port != dv_dpy->port) continue;
if(!XvGrabPort(dv_dpy->dpy, dv_dpy->port, CurrentTime)) {
+ fprintf(stderr,
+ "Xv: %s: Using format %#08x\n",
+ ad_info[i].name,
+ dv_dpy->format);
fprintf(stderr, "Xv: grabbed port %ld\n",
dv_dpy->port);
got_port = True;
|