From d22778ca69689c4606c87ab673a47f0af030edf5 Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Fri, 14 Jun 2013 10:35:31 -0700 Subject: [PATCH] X11rdp: work on xv --- xorg/X11R7.6/rdp/Makefile | 2 +- xorg/X11R7.6/rdp/rdp.h | 3 + xorg/X11R7.6/rdp/rdpxv.c | 225 +++++++++++++++++++++++++++++++++++++- 3 files changed, 224 insertions(+), 6 deletions(-) diff --git a/xorg/X11R7.6/rdp/Makefile b/xorg/X11R7.6/rdp/Makefile index 7373f51a..2eb5e777 100644 --- a/xorg/X11R7.6/rdp/Makefile +++ b/xorg/X11R7.6/rdp/Makefile @@ -12,7 +12,7 @@ rdpPolylines.o rdpPolySegment.o rdpFillSpans.o rdpSetSpans.o \ rdpCopyPlane.o rdpPolyPoint.o rdpPolyArc.o rdpFillPolygon.o \ rdpPolyFillArc.o rdpPolyText8.o rdpPolyText16.o \ rdpImageText8.o rdpImageText16.o rdpImageGlyphBlt.o rdpPolyGlyphBlt.o \ -rdpPushPixels.o \ +rdpPushPixels.o rdpxv.o \ miinitext.o \ fbcmap_mi.o diff --git a/xorg/X11R7.6/rdp/rdp.h b/xorg/X11R7.6/rdp/rdp.h index ae08f38d..22dcdbf7 100644 --- a/xorg/X11R7.6/rdp/rdp.h +++ b/xorg/X11R7.6/rdp/rdp.h @@ -525,6 +525,9 @@ rdpup_check_dirty_screen(rdpPixmapRec* pDirtyPriv); void rdpScheduleDeferredUpdate(void); +int +rdpXvInit(ScreenPtr pScreen); + #if defined(X_BYTE_ORDER) # if X_BYTE_ORDER == X_LITTLE_ENDIAN # define L_ENDIAN diff --git a/xorg/X11R7.6/rdp/rdpxv.c b/xorg/X11R7.6/rdp/rdpxv.c index fc1fb44c..862bbc6a 100644 --- a/xorg/X11R7.6/rdp/rdpxv.c +++ b/xorg/X11R7.6/rdp/rdpxv.c @@ -27,6 +27,8 @@ XVideo extension #include #include "xvdix.h" +#include + static DevPrivateKey g_XvScreenKey; #define GET_XV_SCREEN(pScreen) \ @@ -38,6 +40,57 @@ static DevPrivateKey g_XvScreenKey; #define LLOGLN(_level, _args) \ do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) +#define T_NUM_ENCODINGS 1 +static XvEncodingRec g_encodings[T_NUM_ENCODINGS]; + +#define T_NUM_FORMATS 1 +static XvFormatRec g_formats[T_NUM_FORMATS]; + +#define T_NUM_PORTS 1 +static XvPortRec g_ports[T_NUM_PORTS]; + +#define FOURCC_RV15 0x35315652 +#define FOURCC_RV16 0x36315652 +#define FOURCC_RV24 0x34325652 +#define FOURCC_RV32 0x32335652 + +#define T_NUM_IMAGES 8 +static XvImageRec g_images[T_NUM_IMAGES] = +{ + { + FOURCC_RV15,XvRGB,LSBFirst, + {'R','V','1','5',0,0,0,0,0,0,0,0,0,0,0,0}, + 16, XvPacked, 1, 15, 0x001f, 0x03e0, 0x7c00, 0, 0, 0, 0, 0, 0, 0, 0, 0, + {'R','V','B',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,0}, + XvTopToBottom + }, + { + FOURCC_RV16,XvRGB,LSBFirst, + {'R','V','1','6',0,0,0,0,0,0,0,0,0,0,0,0}, + 16, XvPacked, 1, 16, 0x001f, 0x07e0, 0xf800, 0, 0, 0, 0, 0, 0, 0, 0, 0, + {'R','V','B',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,0}, + XvTopToBottom + }, + { + FOURCC_RV24,XvRGB,LSBFirst, + {'R','V','2','4',0,0,0,0,0,0,0,0,0,0,0,0}, + 32, XvPacked, 1, 24, 0x000000ff, 0x0000ff00, 0x00ff0000, 0, 0, 0, 0, 0, 0, 0, 0, 0, + {'R','V','B',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,0}, + XvTopToBottom + }, + { + FOURCC_RV32, XvRGB, LSBFirst, + {'R','V','3','2',0,0,0,0,0,0,0,0,0,0,0,0}, + 32, XvPacked, 1, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0, 0, 0, 0, 0, 0, 0, 0, 0, + {'R','V','B',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,0}, + XvTopToBottom + }, + XVIMAGE_YV12, + XVIMAGE_YUY2, + XVIMAGE_UYVY, + XVIMAGE_I420 +}; + /*****************************************************************************/ static int rdpXvAllocatePort(unsigned long port, XvPortPtr pPort, XvPortPtr* ppPort) @@ -143,14 +196,131 @@ rdpXvPutImage(ClientPtr client, DrawablePtr pDraw, XvPortPtr pPort, GCPtr pGC, return Success; } +/*****************************************************************************/ +static int +rdpXvPrintFormat(int id) +{ + switch (id) + { + case FOURCC_YV12: + /* big buck bunny 480p h264 */ + /* vob files too */ + LLOGLN(0, ("FOURCC_YV12")); + break; + case FOURCC_I420: + LLOGLN(0, ("FOURCC_I420")); + break; + case FOURCC_RV15: + LLOGLN(0, ("FOURCC_RV15")); + break; + case FOURCC_RV16: + LLOGLN(0, ("FOURCC_RV16")); + break; + case FOURCC_YUY2: + LLOGLN(0, ("FOURCC_YUY2")); + break; + case FOURCC_UYVY: + LLOGLN(0, ("FOURCC_UYVY")); + break; + case FOURCC_RV24: + LLOGLN(0, ("FOURCC_RV24")); + break; + default: + LLOGLN(0, ("other")); + break; + } + return 0; +} + /*****************************************************************************/ static int rdpXvQueryImageAttributes(ClientPtr client, XvPortPtr pPort, XvImagePtr format, CARD16* width, CARD16* height, int* pitches, int* offsets) { + int size; + int tmp; + LLOGLN(0, ("rdpXvQueryImageAttributes:")); - return Success; + + + size = 0; + /* this is same code as all drivers currently have */ + if (*width > 2046) + { + *width = 2046; + } + if (*height > 2046) + { + *height = 2046; + } + /* make w multiple of 4 so that resizing works properly */ + *width = (*width + 3) & ~3; + if (offsets) + { + offsets[0] = 0; + } + LLOGLN(0, ("format %x", format->id)); + rdpXvPrintFormat(format->id); + switch (format->id) + { + case FOURCC_YV12: + case FOURCC_I420: + /* make h be even */ + *height = (*height + 1) & ~1; + /* make w be multiple of 4 (ie. pad it) */ + size = (*width + 3) & ~3; + /* width of a Y row => width of image */ + if (pitches != 0) + { + pitches[0] = size; + } + /* offset of U plane => w*h */ + size *= *height; + if (offsets != 0) + { + offsets[1] = size; + } + /* width of U, V row => width/2 */ + tmp = ((*width >> 1) +3) & ~3; + if (pitches != 0) + { + pitches[1] = pitches[2] = tmp; + } + /* offset of V => Y plane + U plane (w*h + w/2*h/2) */ + tmp *= (*height >> 1); + size += tmp; + size += tmp; + if (offsets != 0) + { + offsets[2] = size; + } + size += tmp; + break; + case FOURCC_RV15: + case FOURCC_RV16: + case FOURCC_YUY2: + case FOURCC_UYVY: + size = (*width) * 2; + if (pitches) + { + pitches[0] = size; + } + size *= *height; + break; + case FOURCC_RV24: + size = (*width) * 3; + if (pitches) + { + pitches[0] = size; + } + size *= *height; + break; + default: + LLOGLN(0, ("rdpXvQueryImageAttributes: error")); + break; + } + return size; } /*****************************************************************************/ @@ -177,6 +347,9 @@ rdpXvQueryAdaptors(ScreenPtr pScreen, XvAdaptorPtr* p_pAdaptors, return Success; } +#ifdef MITSHM +#endif + /*****************************************************************************/ static int rdpXvInitAdaptors(ScreenPtr pScreen) @@ -184,16 +357,28 @@ rdpXvInitAdaptors(ScreenPtr pScreen) XvScreenPtr pxvs = GET_XV_SCREEN(pScreen); XvAdaptorPtr pAdaptor; - pxvs->nAdaptors = 0; - pxvs->pAdaptors = NULL; - pAdaptor = malloc(sizeof(XvAdaptorRec)); memset(pAdaptor, 0, sizeof(XvAdaptorRec)); - pAdaptor->type = 0; + pAdaptor->type = XvInputMask | XvImageMask | XvVideoMask | XvStillMask; pAdaptor->pScreen = pScreen; + pAdaptor->name = "xrdp XVideo adaptor"; + + pAdaptor->nEncodings = T_NUM_ENCODINGS; + pAdaptor->pEncodings = g_encodings; + + pAdaptor->nFormats = T_NUM_FORMATS; + pAdaptor->pFormats = g_formats; + + pAdaptor->nImages = T_NUM_IMAGES; + pAdaptor->pImages = g_images; + + pAdaptor->nPorts = T_NUM_PORTS; + pAdaptor->pPorts = g_ports; + pAdaptor->ddAllocatePort = rdpXvAllocatePort; pAdaptor->ddFreePort = rdpXvFreePort; + pAdaptor->ddPutVideo = rdpXvPutVideo; pAdaptor->ddPutStill = rdpXvPutStill; pAdaptor->ddGetVideo = rdpXvGetVideo; pAdaptor->ddGetStill = rdpXvGetStill; @@ -206,6 +391,36 @@ rdpXvInitAdaptors(ScreenPtr pScreen) pxvs->pAdaptors = pAdaptor; + memset(g_encodings, 0, sizeof(g_encodings)); + g_encodings[0].id = FakeClientID(0); + g_encodings[0].pScreen = pScreen; + g_encodings[0].name = "XV_IMAGE"; + g_encodings[0].width = 2046; + g_encodings[0].height = 2046; + g_encodings[0].rate.numerator = 1; + g_encodings[0].rate.denominator = 1; + + memset(g_formats, 0, sizeof(g_formats)); + g_formats[0].depth = 24; + g_formats[0].visual = TrueColor; + + memset(g_ports, 0, sizeof(g_ports)); + g_ports[0].id = FakeClientID(0); + g_ports[0].pAdaptor = pAdaptor; + g_ports[0].pNotify = 0; + g_ports[0].pDraw = 0; + g_ports[0].grab.id = 0; + g_ports[0].grab.client = 0; + g_ports[0].time = currentTime; + g_ports[0].devPriv.ptr = 0; + + pAdaptor->base_id = g_ports[0].id; + + AddResource(g_ports[0].id, XvRTPort, g_ports); + + pxvs->nAdaptors = 1; + pxvs->pAdaptors = pAdaptor; + return 0; }