Mesa (master): st/xorg: Advertise support for XvMC

Michel Dänzer daenzer at kemper.freedesktop.org
Tue Aug 23 06:39:48 PDT 2011


Module: Mesa
Branch: master
Commit: 8f26b59f53d6d80bf7d3c39a4dd3c438a2c305a4
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=8f26b59f53d6d80bf7d3c39a4dd3c438a2c305a4

Author: Maarten Lankhorst <m.b.lankhorst at gmail.com>
Date:   Fri Jul 29 19:37:51 2011 +0200

st/xorg: Advertise support for XvMC

Formats were based on a patch sent to xf86-video-nouveau by Bryan Cain

Signed-off-by: Maarten Lankhorst <m.b.lankhorst at gmail.com>

[Michel Dänzer: Add xorg_xvmc.c to SConscript.]

---

 src/gallium/state_trackers/xorg/SConscript     |    1 +
 src/gallium/state_trackers/xorg/xorg_tracker.h |    7 ++
 src/gallium/state_trackers/xorg/xorg_xv.c      |    2 +
 src/gallium/state_trackers/xorg/xorg_xvmc.c    |  119 ++++++++++++++++++++++++
 4 files changed, 129 insertions(+), 0 deletions(-)

diff --git a/src/gallium/state_trackers/xorg/SConscript b/src/gallium/state_trackers/xorg/SConscript
index 4ea4ec4..1768f70 100644
--- a/src/gallium/state_trackers/xorg/SConscript
+++ b/src/gallium/state_trackers/xorg/SConscript
@@ -32,6 +32,7 @@ sources = [
     'xorg_output.c',
     'xorg_renderer.c',
     'xorg_xv.c',
+    'xorg_xvmc.c',
 ]
 
 st_xorg = env.ConvenienceLibrary(
diff --git a/src/gallium/state_trackers/xorg/xorg_tracker.h b/src/gallium/state_trackers/xorg/xorg_tracker.h
index 664e8c7..84a3a2f 100644
--- a/src/gallium/state_trackers/xorg/xorg_tracker.h
+++ b/src/gallium/state_trackers/xorg/xorg_tracker.h
@@ -222,4 +222,11 @@ void
 xorg_xv_init(ScreenPtr pScreen);
 
 
+/***********************************************************************
+ * xorg_xvmc.c
+ */
+void
+xorg_xvmc_init(ScreenPtr pScreen, char *name);
+
+
 #endif /* _XORG_TRACKER_H_ */
diff --git a/src/gallium/state_trackers/xorg/xorg_xv.c b/src/gallium/state_trackers/xorg/xorg_xv.c
index af4992f..67fd6df 100644
--- a/src/gallium/state_trackers/xorg/xorg_xv.c
+++ b/src/gallium/state_trackers/xorg/xorg_xv.c
@@ -750,6 +750,8 @@ xorg_xv_init(ScreenPtr pScreen)
 
    if (num_adaptors) {
       xf86XVScreenInit(pScreen, adaptors, num_adaptors);
+      if (textured_adapter)
+         xorg_xvmc_init(pScreen, textured_adapter->name);
    } else {
       xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
                  "Disabling Xv because no adaptors could be initialized.\n");
diff --git a/src/gallium/state_trackers/xorg/xorg_xvmc.c b/src/gallium/state_trackers/xorg/xorg_xvmc.c
new file mode 100644
index 0000000..0f3f3f0
--- /dev/null
+++ b/src/gallium/state_trackers/xorg/xorg_xvmc.c
@@ -0,0 +1,119 @@
+#include "xorg_tracker.h"
+
+#include <xf86.h>
+#include <xf86xv.h>
+#include <xf86xvmc.h>
+#include <X11/extensions/Xv.h>
+#include <X11/extensions/XvMC.h>
+#include <fourcc.h>
+
+#define FOURCC_RGB 0x0000003
+#define XVIMAGE_RGB								\
+{										\
+	FOURCC_RGB,								\
+	XvRGB,									\
+	LSBFirst,								\
+	{									\
+		'R', 'G', 'B', 0x00,						\
+		0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71	\
+	},									\
+	32,									\
+	XvPacked,								\
+	1,									\
+	24, 0x00FF0000, 0x0000FF00, 0x000000FF,					\
+	0, 0, 0,								\
+	0, 0, 0,								\
+	0, 0, 0,								\
+	{									\
+		'B','G','R','X',						\
+		0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0		\
+	},									\
+	XvTopToBottom								\
+}
+
+static int subpicture_index_list[] = {
+   FOURCC_RGB,
+   FOURCC_IA44,
+   FOURCC_AI44
+};
+
+static XF86MCImageIDList subpicture_list =
+{
+   sizeof(subpicture_index_list)/sizeof(*subpicture_index_list),
+   subpicture_index_list
+};
+
+static XF86MCSurfaceInfoRec yv12_mpeg2_surface =
+{
+   FOURCC_I420,
+   XVMC_CHROMA_FORMAT_420,
+   0,
+   2048, 2048, 2048, 2048,
+   XVMC_IDCT | XVMC_MPEG_2,
+   XVMC_SUBPICTURE_INDEPENDENT_SCALING | XVMC_BACKEND_SUBPICTURE,
+   &subpicture_list
+};
+
+static const XF86MCSurfaceInfoRec uyvy_mpeg2_surface =
+{
+   FOURCC_UYVY,
+   XVMC_CHROMA_FORMAT_422,
+   0,
+   2048, 2048, 2048, 2048,
+   XVMC_IDCT | XVMC_MPEG_2,
+   XVMC_SUBPICTURE_INDEPENDENT_SCALING | XVMC_BACKEND_SUBPICTURE,
+   &subpicture_list
+};
+
+static XF86MCSurfaceInfoPtr surfaces[] =
+{
+   (XF86MCSurfaceInfoPtr)&yv12_mpeg2_surface,
+   (XF86MCSurfaceInfoPtr)&uyvy_mpeg2_surface
+};
+
+static const XF86ImageRec rgb_subpicture = XVIMAGE_RGB;
+static const XF86ImageRec ia44_subpicture = XVIMAGE_IA44;
+static const XF86ImageRec ai44_subpicture = XVIMAGE_AI44;
+
+static XF86ImagePtr subpictures[] =
+{
+   (XF86ImagePtr)&rgb_subpicture,
+   (XF86ImagePtr)&ia44_subpicture,
+   (XF86ImagePtr)&ai44_subpicture
+};
+
+static const XF86MCAdaptorRec adaptor_template =
+{
+   "",
+   sizeof(surfaces)/sizeof(*surfaces),
+   surfaces,
+   sizeof(subpictures)/sizeof(*subpictures),
+   subpictures,
+   (xf86XvMCCreateContextProcPtr)NULL,
+   (xf86XvMCDestroyContextProcPtr)NULL,
+   (xf86XvMCCreateSurfaceProcPtr)NULL,
+   (xf86XvMCDestroySurfaceProcPtr)NULL,
+   (xf86XvMCCreateSubpictureProcPtr)NULL,
+   (xf86XvMCDestroySubpictureProcPtr)NULL
+};
+
+void
+xorg_xvmc_init(ScreenPtr pScreen, char *name)
+{
+   ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+   XF86MCAdaptorPtr adaptorXvMC = xf86XvMCCreateAdaptorRec();
+   if (!adaptorXvMC)
+      return;
+
+   *adaptorXvMC = adaptor_template;
+   adaptorXvMC->name = name;
+   xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+              "[XvMC] Associated with %s.\n", name);
+   if (!xf86XvMCScreenInit(pScreen, 1, &adaptorXvMC))
+      xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+                 "[XvMC] Failed to initialize extension.\n");
+   else
+      xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                 "[XvMC] Extension initialized.\n");
+   xf86XvMCDestroyAdaptorRec(adaptorXvMC);
+}



More information about the mesa-commit mailing list