summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Sorg <jay.sorg@gmail.com>2014-09-23 20:31:45 -0700
committerJay Sorg <jay.sorg@gmail.com>2014-09-23 20:31:45 -0700
commitc7b2e9994c4d8d4cbc73b3e433e281feddd7ba6e (patch)
tree7e996c50becbd1472ed417f61d2a16318fd6fa07
parentece8138b0ea17067492bffae5e7474e0ecca2f7a (diff)
downloadxrdp-proprietary-c7b2e9994c4d8d4cbc73b3e433e281feddd7ba6e.tar.gz
xrdp-proprietary-c7b2e9994c4d8d4cbc73b3e433e281feddd7ba6e.zip
Xorg: start accel XV
-rw-r--r--xorg/server/module/Makefile15
-rw-r--r--xorg/server/module/rdp.h7
-rw-r--r--xorg/server/module/rdpXv.c112
-rw-r--r--xorg/server/module/x86/i420_to_rgb32_x86_sse2.asm22
-rw-r--r--xorg/server/module/x86/uyvy_to_rgb32_x86_sse2.asm22
-rw-r--r--xorg/server/module/x86/yuy2_to_rgb32_x86_sse2.asm22
-rw-r--r--xorg/server/module/x86/yv12_to_rgb32_x86_sse2.asm22
7 files changed, 213 insertions, 9 deletions
diff --git a/xorg/server/module/Makefile b/xorg/server/module/Makefile
index 0901d17a..49cbb3e3 100644
--- a/xorg/server/module/Makefile
+++ b/xorg/server/module/Makefile
@@ -8,6 +8,8 @@ rdpCursor.o rdpMain.o rdpRandR.o rdpMisc.o rdpReg.o \
rdpComposite.o rdpGlyphs.o rdpPixmap.o rdpInput.o rdpClientCon.o rdpCapture.o \
rdpTrapezoids.o rdpXv.o
+;OBJS += i420_to_rgb32_x86_sse2.o yv12_to_rgb32_x86_sse2.o yuy2_to_rgb32_x86_sse2.o uyvy_to_rgb32_x86_sse2.o
+
CFLAGS = -g -O2 -Wall -fPIC -I/usr/include/xorg -I/usr/include/pixman-1 \
-I../../../common
@@ -22,3 +24,16 @@ libxorgxrdp.so: $(OBJS) Makefile
clean:
rm -f $(OBJS) libxorgxrdp.so
+
+i420_to_rgb32_x86_sse2.o: x86/i420_to_rgb32_x86_sse2.asm
+ yasm -f elf32 -g dwarf2 x86/i420_to_rgb32_x86_sse2.asm
+
+yv12_to_rgb32_x86_sse2.o: x86/yv12_to_rgb32_x86_sse2.asm
+ yasm -f elf32 -g dwarf2 x86/yv12_to_rgb32_x86_sse2.asm
+
+yuy2_to_rgb32_x86_sse2.o: x86/yuy2_to_rgb32_x86_sse2.asm
+ yasm -f elf32 -g dwarf2 x86/yuy2_to_rgb32_x86_sse2.asm
+
+uyvy_to_rgb32_x86_sse2.o: x86/uyvy_to_rgb32_x86_sse2.asm
+ yasm -f elf32 -g dwarf2 x86/uyvy_to_rgb32_x86_sse2.asm
+
diff --git a/xorg/server/module/rdp.h b/xorg/server/module/rdp.h
index 61dfbb1c..2909c7bc 100644
--- a/xorg/server/module/rdp.h
+++ b/xorg/server/module/rdp.h
@@ -194,6 +194,8 @@ struct _rdpCounts
CARD32 callCount[64 - 23];
};
+typedef int (*yuv_to_rgb32_proc)(unsigned char *yuvs, int width, int height, int *rgbs);
+
/* move this to common header */
struct _rdpRec
{
@@ -265,6 +267,11 @@ struct _rdpRec
struct _rdpCounts counts;
+ yuv_to_rgb32_proc i420_to_rgb32;
+ yuv_to_rgb32_proc yv12_to_rgb32;
+ yuv_to_rgb32_proc yuy2_to_rgb32;
+ yuv_to_rgb32_proc uyvy_to_rgb32;
+
};
typedef struct _rdpRec rdpRec;
typedef struct _rdpRec * rdpPtr;
diff --git a/xorg/server/module/rdpXv.c b/xorg/server/module/rdpXv.c
index 694b1553..741766e5 100644
--- a/xorg/server/module/rdpXv.c
+++ b/xorg/server/module/rdpXv.c
@@ -46,6 +46,12 @@ XVideo
#define LLOGLN(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
+/* use simd, run time */
+int g_xv_use_accel = 1;
+
+/* use simd, compile time, if zero, g_xv_use_accel does not matter */
+#define XV_USE_ACCEL 0
+
#define T_NUM_ENCODINGS 1
static XF86VideoEncodingRec g_xrdpVidEncodings[T_NUM_ENCODINGS] =
{ { 0, "XV_IMAGE", 2046, 2046, { 1, 1 } } };
@@ -54,6 +60,18 @@ static XF86VideoEncodingRec g_xrdpVidEncodings[T_NUM_ENCODINGS] =
static XF86VideoFormatRec g_xrdpVidFormats[T_NUM_FORMATS] =
{ { 0, TrueColor } };
+/* YV12
+ I420
+ 12 bpp planar
+ YUV 4:2:0 8 bit Y plane followed by 8 bit 2x2 subsampled
+ U and V planes. */
+
+/* YUY2
+ UYVY
+ 16 bpp packed
+ YUV 4:2:2 Y sample at every pixel, U and V sampled at
+ every second pixel */
+
/* XVIMAGE_YV12 FOURCC_YV12 0x32315659 */
/* XVIMAGE_YUY2 FOURCC_YUY2 0x32595559 */
/* XVIMAGE_UYVY FOURCC_UYVY 0x59565955 */
@@ -397,10 +415,11 @@ stretch_RGB32_RGB32(int *src, int src_width, int src_height,
iv += ov;
}
- return 0;
+ return 0;
}
/*****************************************************************************/
+/* see hw/xfree86/common/xf86xv.c for info */
static int
xrdpVidPutImage(ScrnInfoPtr pScrn,
short src_x, short src_y, short drw_x, short drw_y,
@@ -420,6 +439,7 @@ xrdpVidPutImage(ScrnInfoPtr pScrn,
int index;
int jndex;
int num_clips;
+ int error;
RegionRec dreg;
BoxRec box;
@@ -436,33 +456,43 @@ xrdpVidPutImage(ScrnInfoPtr pScrn,
}
rgbend32 = rgborg32 + width * height;
+ error = 0;
switch (format)
{
case FOURCC_YV12:
LLOGLN(10, ("xrdpVidPutImage: FOURCC_YV12"));
- YV12_to_RGB32(buf, width, height, rgborg32);
+ error = dev->yv12_to_rgb32(buf, width, height, rgborg32);
break;
case FOURCC_I420:
LLOGLN(10, ("xrdpVidPutImage: FOURCC_I420"));
- I420_to_RGB32(buf, width, height, rgborg32);
+ error = dev->i420_to_rgb32(buf, width, height, rgborg32);
break;
case FOURCC_YUY2:
LLOGLN(10, ("xrdpVidPutImage: FOURCC_YUY2"));
- YUY2_to_RGB32(buf, width, height, rgborg32);
+ error = YUY2_to_RGB32(buf, width, height, rgborg32);
break;
case FOURCC_UYVY:
LLOGLN(10, ("xrdpVidPutImage: FOURCC_UYVY"));
- UYVY_to_RGB32(buf, width, height, rgborg32);
+ error = UYVY_to_RGB32(buf, width, height, rgborg32);
break;
default:
LLOGLN(0, ("xrdpVidPutImage: unknown format 0x%8.8x", format));
g_free(rgborg32);
return Success;
}
-
- stretch_RGB32_RGB32(rgborg32, width, height,
- src_x, src_y, src_w, src_h,
- rgbend32, drw_w, drw_h);
+ if (error != 0)
+ {
+ g_free(rgborg32);
+ return Success;
+ }
+ error = stretch_RGB32_RGB32(rgborg32, width, height,
+ src_x, src_y, src_w, src_h,
+ rgbend32, drw_w, drw_h);
+ if (error != 0)
+ {
+ g_free(rgborg32);
+ return Success;
+ }
box.x1 = drw_x;
box.y1 = drw_y;
@@ -579,10 +609,31 @@ xrdpVidQueryImageAttributes(ScrnInfoPtr pScrn, int id,
return size;
}
+#if defined(__x86_64__) || defined(__AMD64__) || defined (_M_AMD64)
+int
+i420_to_rgb32_amd64_sse2(unsigned char *yuvs, int width, int height, int *rgbs);
+int
+yv12_to_rgb32_amd64_sse2(unsigned char *yuvs, int width, int height, int *rgbs);
+int
+yuy2_to_rgb32_amd64_sse2(unsigned char *yuvs, int width, int height, int *rgbs);
+int
+uyvy_to_rgb32_amd64_sse2(unsigned char *yuvs, int width, int height, int *rgbs);
+#elif defined(__x86__) || defined(_M_IX86) || defined(__i386__)
+int
+i420_to_rgb32_x86_sse2(unsigned char *yuvs, int width, int height, int *rgbs);
+int
+yv12_to_rgb32_x86_sse2(unsigned char *yuvs, int width, int height, int *rgbs);
+int
+yuy2_to_rgb32_x86_sse2(unsigned char *yuvs, int width, int height, int *rgbs);
+int
+uyvy_to_rgb32_x86_sse2(unsigned char *yuvs, int width, int height, int *rgbs);
+#endif
+
/*****************************************************************************/
Bool
rdpXvInit(ScreenPtr pScreen, ScrnInfoPtr pScrn)
{
+ rdpPtr dev;
XF86VideoAdaptorPtr adaptor;
DevUnion* pDevUnion;
int bytes;
@@ -628,6 +679,49 @@ rdpXvInit(ScreenPtr pScreen, ScrnInfoPtr pScrn)
return 0;
}
xf86XVFreeVideoAdaptorRec(adaptor);
+
+ dev = XRDPPTR(pScrn);
+ /* assign functions */
+ LLOGLN(0, ("rdpXvInit: assigning yuv functions"));
+#if XV_USE_ACCEL
+ if (g_xv_use_accel)
+ {
+#if defined(__x86_64__) || defined(__AMD64__) || defined (_M_AMD64)
+ dev->yv12_to_rgb32 = yv12_to_rgb32_amd64_sse2;
+ dev->i420_to_rgb32 = i420_to_rgb32_amd64_sse2;
+ dev->yuy2_to_rgb32 = yuy2_to_rgb32_amd64_sse2;
+ dev->uyvy_to_rgb32 = uyvy_to_rgb32_amd64_sse2;
+ LLOGLN(0, ("rdpXvInit: sse amd64 yuv functions assigned"));
+#elif defined(__x86__) || defined(_M_IX86) || defined(__i386__)
+ dev->yv12_to_rgb32 = yv12_to_rgb32_x86_sse2;
+ dev->i420_to_rgb32 = i420_to_rgb32_x86_sse2;
+ dev->yuy2_to_rgb32 = yuy2_to_rgb32_x86_sse2;
+ dev->uyvy_to_rgb32 = uyvy_to_rgb32_x86_sse2;
+ LLOGLN(0, ("rdpXvInit: sse x86 yuv functions assigned"));
+#else
+ dev->yv12_to_rgb32 = YV12_to_RGB32;
+ dev->i420_to_rgb32 = I420_to_RGB32;
+ dev->yuy2_to_rgb32 = YUY2_to_RGB32;
+ dev->uyvy_to_rgb32 = UYVY_to_RGB32;
+ LLOGLN(0, ("rdpXvInit: warning, c yuv functions assigned"));
+#endif
+ }
+ else
+ {
+ dev->yv12_to_rgb32 = YV12_to_RGB32;
+ dev->i420_to_rgb32 = I420_to_RGB32;
+ dev->yuy2_to_rgb32 = YUY2_to_RGB32;
+ dev->uyvy_to_rgb32 = UYVY_to_RGB32;
+ LLOGLN(0, ("rdpXvInit: warning, c yuv functions assigned"));
+ }
+#else
+ dev->yv12_to_rgb32 = YV12_to_RGB32;
+ dev->i420_to_rgb32 = I420_to_RGB32;
+ dev->yuy2_to_rgb32 = YUY2_to_RGB32;
+ dev->uyvy_to_rgb32 = UYVY_to_RGB32;
+ LLOGLN(0, ("rdpXvInit: warning, c yuv functions assigned"));
+#endif
+
return 1;
}
diff --git a/xorg/server/module/x86/i420_to_rgb32_x86_sse2.asm b/xorg/server/module/x86/i420_to_rgb32_x86_sse2.asm
new file mode 100644
index 00000000..2b7e3ac7
--- /dev/null
+++ b/xorg/server/module/x86/i420_to_rgb32_x86_sse2.asm
@@ -0,0 +1,22 @@
+
+%macro PROC 1
+ align 16
+ global %1
+ %1:
+%endmacro
+
+;int
+;i420_to_rgb32_x86_sse2(unsigned char *yuvs, int width, int height, int *rgbs)
+
+PROC i420_to_rgb32_x86_sse2
+ push ebx
+ push esi
+ push edi
+
+ mov eax, 0
+ pop edi
+ pop esi
+ pop ebx
+ ret
+ align 16
+
diff --git a/xorg/server/module/x86/uyvy_to_rgb32_x86_sse2.asm b/xorg/server/module/x86/uyvy_to_rgb32_x86_sse2.asm
new file mode 100644
index 00000000..d3ba81d3
--- /dev/null
+++ b/xorg/server/module/x86/uyvy_to_rgb32_x86_sse2.asm
@@ -0,0 +1,22 @@
+
+%macro PROC 1
+ align 16
+ global %1
+ %1:
+%endmacro
+
+;int
+;uyvy_to_rgb32_x86_sse2(unsigned char *yuvs, int width, int height, int *rgbs)
+
+PROC uyvy_to_rgb32_x86_sse2
+ push ebx
+ push esi
+ push edi
+
+ mov eax, 0
+ pop edi
+ pop esi
+ pop ebx
+ ret
+ align 16
+
diff --git a/xorg/server/module/x86/yuy2_to_rgb32_x86_sse2.asm b/xorg/server/module/x86/yuy2_to_rgb32_x86_sse2.asm
new file mode 100644
index 00000000..da03e26f
--- /dev/null
+++ b/xorg/server/module/x86/yuy2_to_rgb32_x86_sse2.asm
@@ -0,0 +1,22 @@
+
+%macro PROC 1
+ align 16
+ global %1
+ %1:
+%endmacro
+
+;int
+;yuy2_to_rgb32_x86_sse2(unsigned char *yuvs, int width, int height, int *rgbs)
+
+PROC yuy2_to_rgb32_x86_sse2
+ push ebx
+ push esi
+ push edi
+
+ mov eax, 0
+ pop edi
+ pop esi
+ pop ebx
+ ret
+ align 16
+
diff --git a/xorg/server/module/x86/yv12_to_rgb32_x86_sse2.asm b/xorg/server/module/x86/yv12_to_rgb32_x86_sse2.asm
new file mode 100644
index 00000000..2d0533ea
--- /dev/null
+++ b/xorg/server/module/x86/yv12_to_rgb32_x86_sse2.asm
@@ -0,0 +1,22 @@
+
+%macro PROC 1
+ align 16
+ global %1
+ %1:
+%endmacro
+
+;int
+;yv12_to_rgb32_x86_sse2(unsigned char *yuvs, int width, int height, int *rgbs)
+
+PROC yv12_to_rgb32_x86_sse2
+ push ebx
+ push esi
+ push edi
+
+ mov eax, 0
+ pop edi
+ pop esi
+ pop ebx
+ ret
+ align 16
+