From 21316f3c84876cbc4bdd71726e36ead47c9e4694 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 10 Feb 2002 00:30:24 +0000 Subject: [PATCH] rgb24toyv12 in MMX (untested) Originally committed as revision 4623 to svn://svn.mplayerhq.hu/mplayer/trunk/postproc --- postproc/rgb2rgb.c | 16 +++ postproc/rgb2rgb_template.c | 244 +++++++++++++++++++++++++++++++++++- 2 files changed, 258 insertions(+), 2 deletions(-) diff --git a/postproc/rgb2rgb.c b/postproc/rgb2rgb.c index 52ddcf5749..7668a395c8 100644 --- a/postproc/rgb2rgb.c +++ b/postproc/rgb2rgb.c @@ -16,6 +16,8 @@ #define CAN_COMPILE_X86_ASM #endif +#define FAST_BGR2YV12 // use 7 bit coeffs instead of 15bit + #ifdef CAN_COMPILE_X86_ASM static const uint64_t mask32b __attribute__((aligned(8))) = 0x000000FF000000FFULL; static const uint64_t mask32g __attribute__((aligned(8))) = 0x0000FF000000FF00ULL; @@ -35,6 +37,20 @@ static const uint64_t blue_16mask __attribute__((aligned(8))) = 0x0000001f000000 static const uint64_t red_15mask __attribute__((aligned(8))) = 0x00007c000000f800ULL; static const uint64_t green_15mask __attribute__((aligned(8)))= 0x000003e0000007e0ULL; static const uint64_t blue_15mask __attribute__((aligned(8))) = 0x0000001f0000001fULL; + +#ifdef FAST_BGR2YV12 +static const uint64_t bgr2YCoeff __attribute__((aligned(8))) = 0x000000210041000DULL; +static const uint64_t bgr2UCoeff __attribute__((aligned(8))) = 0x0000FFEEFFDC0038ULL; +static const uint64_t bgr2VCoeff __attribute__((aligned(8))) = 0x00000038FFD2FFF8ULL; +#else +static const uint64_t bgr2YCoeff __attribute__((aligned(8))) = 0x000020E540830C8BULL; +static const uint64_t bgr2UCoeff __attribute__((aligned(8))) = 0x0000ED0FDAC23831ULL; +static const uint64_t bgr2VCoeff __attribute__((aligned(8))) = 0x00003831D0E6F6EAULL; +#endif +static const uint64_t bgr2YOffset __attribute__((aligned(8))) = 0x1010101010101010ULL; +static const uint64_t bgr2UVOffset __attribute__((aligned(8)))= 0x8080808080808080ULL; +static const uint64_t w1111 __attribute__((aligned(8))) = 0x0001000100010001ULL; + #if 0 static volatile uint64_t __attribute__((aligned(8))) b5Dither; static volatile uint64_t __attribute__((aligned(8))) g5Dither; diff --git a/postproc/rgb2rgb_template.c b/postproc/rgb2rgb_template.c index ac6e237c17..2db74cdb5b 100644 --- a/postproc/rgb2rgb_template.c +++ b/postproc/rgb2rgb_template.c @@ -899,7 +899,7 @@ asm volatile( EMMS" \n\t" * * height should be a multiple of 2 and width should be a multiple of 2 (if this is a * problem for anyone then tell me, and ill fix it) - * chrominance data is only taken from every secound line others are ignored FIXME write HQ version + * chrominance data is only taken from every secound line others are ignored in the C version FIXME write HQ version */ static inline void RENAME(rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, unsigned int width, unsigned int height, @@ -907,7 +907,247 @@ static inline void RENAME(rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_ { int y; const int chromWidth= width>>1; - for(y=0; y