xv: fix last pixel for big-endian machines in YV12 -> NV12 conversion
PATCH 1/2 xv: fix last pixel for big-endian machines in YV12 -> NV12 conversion
--- src/nouveau_xv.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
src/nouveau_xv.c +4 -1
@@ -552,8 +552,11 @@ NVCopyNV12ColorPlanes(unsigned char *src1, unsigned char *src2,if (e) {unsigned short *vud = (unsigned short *) vuvud; - +#if X_BYTE_ORDER ==X_BIG_ENDIAN + *vud = us[0 ] | (vs[0 ]<<8 ); +#else *vud = vs[0 ] | (us[0 ]<<8 ); +#endif } dst += dstPitch;
Signature · 1 line
1.8.1.5
A message that is not in the archive (sent off-list or not yet received): 1375080039-22607-1-git-send-email-imirkin-FrUbXkNCsVf2fBVCVOL8/[email protected]
PATCH 2/2 xv: speed up YV12 -> NV12 conversion using SSE2 if available
memcpy() goes from taking 45% to 66% of total function time, which translates to a 30% decrease in NVPutImage runtime.
--- src/nouveau_xv.c | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-)
src/nouveau_xv.c +26 -7
@@ -25,6 +25,8 @@#include "config.h" #endif +#include <immintrin.h> +#include "xf86xv.h" #include <X11/extensions/Xv.h> #include "exa.h"
@@ -532,30 +534,47 @@ NVCopyNV12ColorPlanes(unsigned char *src1, unsigned char *src2, w >>=1 ; h >>=1 ; +#ifdef __SSE2__ + l = w >>3 ; + e = w &7 ; +#else l = w >>1 ; e = w &1 ; +#endif for (j =0 ; j < h; j++) {unsigned char *us = src1;unsigned char *vs = src2;unsigned int *vuvud = (unsigned int *) dst; +unsigned short *vud;for (i =0 ; i < l; i++) { -#if X_BYTE_ORDER ==X_BIG_ENDIAN +#ifdef __SSE2__ +_mm_storeu_si128 ( + (void *)vuvud, +_mm_unpacklo_epi8 ( +_mm_loadl_epi64 ((void *)vs), +_mm_loadl_epi64 ((void *)us))); + vuvud+=4 ; + us+=8 ; + vs+=8 ; +#else /* __SSE2__ */ +# if X_BYTE_ORDER ==X_BIG_ENDIAN *vuvud++ = (vs[0 ]<<24 ) | (us[0 ]<<16 ) | (vs[1 ]<<8 ) | us[1 ]; -#else +# else *vuvud++ = vs[0 ] | (us[0 ]<<8 ) | (vs[1 ]<<16 ) | (us[1 ]<<24 ); -#endif +# endif us+=2 ; vs+=2 ; +#endif /* __SSE2__ */ } -if (e) { -unsigned short *vud = (unsigned short *) vuvud; + vud = (unsigned short *)vuvud; +for (i =0 ; i < e; i++) {#if X_BYTE_ORDER ==X_BIG_ENDIAN - *vud = us[0 ] | (vs[0 ]<<8 ); + vud[i] = us[i] | (vs[i]<<8 );#else - *vud = vs[0 ] | (us[0 ]<<8 ); + vud[i] = vs[i] | (us[i]<<8 );#endif }
Signature · 1 line
1.8.1.5
A message that is not in the archive (sent off-list or not yet received): 1375080039-22607-2-git-send-email-imirkin-FrUbXkNCsVf2fBVCVOL8/[email protected]
Re: [PATCH 2/2] xv: speed up YV12 -> NV12 conversion using SSE2 if available
Quoted 13 lines · Ilia Mirkin
memcpy()goes from taking 45% to 66% of total function time, which translates to a 30% decrease in NVPutImage runtime.--- src/nouveau_xv.c | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-)src/nouveau_xv.c +0
-0
src/nouveau_xv.c line 29
Quoted 5 lines
src/nouveau_xv.c +2
-0@@ -25,6 +25,8 @@#include "config.h" #endif +#include <immintrin.h> +
Unfortunately, immintrin.h is not available on most architectures, leading to build failures as can be seen on
https://buildd.debian.org/status/package.php?p=xserver-xorg-video-nouveau.
Any ideas?
Quoted 60 lines
src/nouveau_xv.c +24
-7#include "xf86xv.h" #include <X11/extensions/Xv.h> #include "exa.h" @@ -532,30 +534,47 @@ NVCopyNV12ColorPlanes(unsigned char *src1, unsigned char *src2, w >>=1 ; h >>=1 ; +#ifdef __SSE2__ + l = w >>3 ; + e = w &7 ; +#else l = w >>1 ; e = w &1 ; +#endif for (j =0 ; j < h; j++) {unsigned char *us = src1;unsigned char *vs = src2;unsigned int *vuvud = (unsigned int *) dst; +unsigned short *vud;for (i =0 ; i < l; i++) { -#if X_BYTE_ORDER ==X_BIG_ENDIAN +#ifdef __SSE2__ +_mm_storeu_si128 ( + (void *)vuvud, +_mm_unpacklo_epi8 ( +_mm_loadl_epi64 ((void *)vs), +_mm_loadl_epi64 ((void *)us))); + vuvud+=4 ; + us+=8 ; + vs+=8 ; +#else /* __SSE2__ */ +# if X_BYTE_ORDER ==X_BIG_ENDIAN *vuvud++ = (vs[0 ]<<24 ) | (us[0 ]<<16 ) | (vs[1 ]<<8 ) | us[1 ]; -#else +# else *vuvud++ = vs[0 ] | (us[0 ]<<8 ) | (vs[1 ]<<16 ) | (us[1 ]<<24 ); -#endif +# endif us+=2 ; vs+=2 ; +#endif /* __SSE2__ */ } -if (e) { -unsigned short *vud = (unsigned short *) vuvud; + vud = (unsigned short *)vuvud; +for (i =0 ; i < e; i++) {#if X_BYTE_ORDER ==X_BIG_ENDIAN - *vud = us[0 ] | (vs[0 ]<<8 ); + vud[i] = us[i] | (vs[i]<<8 );#else - *vud = vs[0 ] | (us[0 ]<<8 ); + vud[i] = vs[i] | (us[i]<<8 );#endif }Signature · 1 line
1.8.1.5
Cheers,
Sven
A message that is not in the archive (sent off-list or not yet received): CAKb7Uvi-nVtxhENZnwm6kbRaOW-a_Gv5D_v6Ex1CuyJWTE5aUw@mail.gmail.com
A message that is not in the archive (sent off-list or not yet received): CAKb7Uvi-nVtxhENZnwm6kbRaOW-a_Gv5D_v6Ex1CuyJWTE5aUw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH 2/2] xv: speed up YV12 -> NV12 conversion using SSE2 if available
Quoted 11 lines · Ilia Mirkin
Quoted 4 lines · Sven Joachim
Unfortunately,
immintrin.his not available on most architectures, leading to build failures as can be seen on
https://buildd.debian.org/status/package.php?p=xserver-xorg-video-nouveau.Sorry :( I thought that
immintrin.hwould be available everywhere and just end up empty since none of the __SSE*__ would be defined. I was wrong.Quoted 1 line
Quoted 4 lines
Quoted 1 line
Any ideas?
A fix is checked into master already:
http://cgit.freedesktop.org/nouveau/xf86-video-nouveau/commit/?id=1df177f35a05db505577cdc929e63fde906a704b
Ah, good to hear and sorry that I didn't check myself. I'll merge that commit into the Debian package.
Cheers,
Sven