annotate postproc/rgb2rgb.c @ 3161:950496933384

configure cleanups: a few typos a few reordering (C src / _blah=no / cc_check && _blah=yes) preliminary support to display a summary of enabled modules at the end of the run of ./configure (only AO & VO right now/check for _{a,v}omodules) cleanups of config.mak : X_LIBS gathered everything and whatever - no longer the case Makefile cleanups to match the ones done in config.mak NB: it still compiles here (but I'm pretty sure this will break on some systems :)
author pl
date Tue, 27 Nov 2001 17:58:29 +0000
parents ab67556586fa
children e3a9fae516e4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2694
2924350d92ed bgr32to16, bgr32to15 (needed for palette stuff)
michael
parents: 2677
diff changeset
1 /*
2538
71320898b333 Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents: 2535
diff changeset
2 *
71320898b333 Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents: 2535
diff changeset
3 * rgb2rgb.c, Software RGB to RGB convertor
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents: 2725
diff changeset
4 * pluralize by Software PAL8 to RGB convertor
ae79207a3055 Move yuv2rgb to postprocess
nick
parents: 2725
diff changeset
5 * Software YUV to YUV convertor
ae79207a3055 Move yuv2rgb to postprocess
nick
parents: 2725
diff changeset
6 * Software YUV to RGB convertor
2538
71320898b333 Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents: 2535
diff changeset
7 * Written by Nick Kurshev.
3132
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
8 * palette & yuv & runtime cpu stuff by Michael (michaelni@gmx.at) (under GPL)
2538
71320898b333 Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents: 2535
diff changeset
9 */
2504
13e1c5ab417a vo_vesa: rgb2rgb support
nick
parents:
diff changeset
10 #include <inttypes.h>
13e1c5ab417a vo_vesa: rgb2rgb support
nick
parents:
diff changeset
11 #include "../config.h"
13e1c5ab417a vo_vesa: rgb2rgb support
nick
parents:
diff changeset
12 #include "rgb2rgb.h"
3132
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
13 #include "../cpudetect.h"
2538
71320898b333 Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents: 2535
diff changeset
14
3132
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
15 #ifdef ARCH_X86
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
16 #define CAN_COMPILE_X86_ASM
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
17 #endif
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
18
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
19 #ifdef CAN_COMPILE_X86_ASM
2755
2f93f4351765 rgb32tobgr32 / bgr32torgb32
michael
parents: 2746
diff changeset
20 static const uint64_t mask32b __attribute__((aligned(8))) = 0x000000FF000000FFULL;
2f93f4351765 rgb32tobgr32 / bgr32torgb32
michael
parents: 2746
diff changeset
21 static const uint64_t mask32g __attribute__((aligned(8))) = 0x0000FF000000FF00ULL;
2f93f4351765 rgb32tobgr32 / bgr32torgb32
michael
parents: 2746
diff changeset
22 static const uint64_t mask32r __attribute__((aligned(8))) = 0x00FF000000FF0000ULL;
2538
71320898b333 Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents: 2535
diff changeset
23 static const uint64_t mask32 __attribute__((aligned(8))) = 0x00FFFFFF00FFFFFFULL;
71320898b333 Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents: 2535
diff changeset
24 static const uint64_t mask24l __attribute__((aligned(8))) = 0x0000000000FFFFFFULL;
71320898b333 Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents: 2535
diff changeset
25 static const uint64_t mask24h __attribute__((aligned(8))) = 0x0000FFFFFF000000ULL;
2746
dece635a28e3 Minor speedup of rgb32to24. (performance is not successful)
nick
parents: 2741
diff changeset
26 static const uint64_t mask24hh __attribute__((aligned(8))) = 0xffff000000000000ULL;
dece635a28e3 Minor speedup of rgb32to24. (performance is not successful)
nick
parents: 2741
diff changeset
27 static const uint64_t mask24hhh __attribute__((aligned(8))) = 0xffffffff00000000ULL;
dece635a28e3 Minor speedup of rgb32to24. (performance is not successful)
nick
parents: 2741
diff changeset
28 static const uint64_t mask24hhhh __attribute__((aligned(8))) = 0xffffffffffff0000ULL;
2538
71320898b333 Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents: 2535
diff changeset
29 static const uint64_t mask15b __attribute__((aligned(8))) = 0x001F001F001F001FULL; /* 00000000 00011111 xxB */
71320898b333 Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents: 2535
diff changeset
30 static const uint64_t mask15rg __attribute__((aligned(8))) = 0x7FE07FE07FE07FE0ULL; /* 01111111 11100000 RGx */
2698
22652c028692 faster 15to16 bit rgb (the mmx routine is limited by memory speed so there is no difference ): but the c routine is faster
michael
parents: 2697
diff changeset
31 static const uint64_t mask15s __attribute__((aligned(8))) = 0xFFE0FFE0FFE0FFE0ULL;
2741
b8a692c59b64 MMX2, 3DNOW, MMX optimized rgb32(24)to16(15) stuff
nick
parents: 2740
diff changeset
32 static const uint64_t red_16mask __attribute__((aligned(8))) = 0x0000f8000000f800ULL;
b8a692c59b64 MMX2, 3DNOW, MMX optimized rgb32(24)to16(15) stuff
nick
parents: 2740
diff changeset
33 static const uint64_t green_16mask __attribute__((aligned(8)))= 0x000007e0000007e0ULL;
b8a692c59b64 MMX2, 3DNOW, MMX optimized rgb32(24)to16(15) stuff
nick
parents: 2740
diff changeset
34 static const uint64_t blue_16mask __attribute__((aligned(8))) = 0x0000001f0000001fULL;
b8a692c59b64 MMX2, 3DNOW, MMX optimized rgb32(24)to16(15) stuff
nick
parents: 2740
diff changeset
35 static const uint64_t red_15mask __attribute__((aligned(8))) = 0x00007c000000f800ULL;
b8a692c59b64 MMX2, 3DNOW, MMX optimized rgb32(24)to16(15) stuff
nick
parents: 2740
diff changeset
36 static const uint64_t green_15mask __attribute__((aligned(8)))= 0x000003e0000007e0ULL;
b8a692c59b64 MMX2, 3DNOW, MMX optimized rgb32(24)to16(15) stuff
nick
parents: 2740
diff changeset
37 static const uint64_t blue_15mask __attribute__((aligned(8))) = 0x0000001f0000001fULL;
2755
2f93f4351765 rgb32tobgr32 / bgr32torgb32
michael
parents: 2746
diff changeset
38 #if 0
2f93f4351765 rgb32tobgr32 / bgr32torgb32
michael
parents: 2746
diff changeset
39 static volatile uint64_t __attribute__((aligned(8))) b5Dither;
2f93f4351765 rgb32tobgr32 / bgr32torgb32
michael
parents: 2746
diff changeset
40 static volatile uint64_t __attribute__((aligned(8))) g5Dither;
2f93f4351765 rgb32tobgr32 / bgr32torgb32
michael
parents: 2746
diff changeset
41 static volatile uint64_t __attribute__((aligned(8))) g6Dither;
2f93f4351765 rgb32tobgr32 / bgr32torgb32
michael
parents: 2746
diff changeset
42 static volatile uint64_t __attribute__((aligned(8))) r5Dither;
2f93f4351765 rgb32tobgr32 / bgr32torgb32
michael
parents: 2746
diff changeset
43
2f93f4351765 rgb32tobgr32 / bgr32torgb32
michael
parents: 2746
diff changeset
44 static uint64_t __attribute__((aligned(8))) dither4[2]={
2f93f4351765 rgb32tobgr32 / bgr32torgb32
michael
parents: 2746
diff changeset
45 0x0103010301030103LL,
2f93f4351765 rgb32tobgr32 / bgr32torgb32
michael
parents: 2746
diff changeset
46 0x0200020002000200LL,};
2f93f4351765 rgb32tobgr32 / bgr32torgb32
michael
parents: 2746
diff changeset
47
2f93f4351765 rgb32tobgr32 / bgr32torgb32
michael
parents: 2746
diff changeset
48 static uint64_t __attribute__((aligned(8))) dither8[2]={
2f93f4351765 rgb32tobgr32 / bgr32torgb32
michael
parents: 2746
diff changeset
49 0x0602060206020602LL,
2f93f4351765 rgb32tobgr32 / bgr32torgb32
michael
parents: 2746
diff changeset
50 0x0004000400040004LL,};
2f93f4351765 rgb32tobgr32 / bgr32torgb32
michael
parents: 2746
diff changeset
51 #endif
2535
b44113f46c96 cant compile on non x86 bugfix
michael
parents: 2517
diff changeset
52 #endif
2513
nick
parents: 2512
diff changeset
53
3132
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
54 #define RGB2YUV_SHIFT 8
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
55 #define BY ((int)( 0.098*(1<<RGB2YUV_SHIFT)+0.5))
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
56 #define BV ((int)(-0.071*(1<<RGB2YUV_SHIFT)+0.5))
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
57 #define BU ((int)( 0.439*(1<<RGB2YUV_SHIFT)+0.5))
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
58 #define GY ((int)( 0.504*(1<<RGB2YUV_SHIFT)+0.5))
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
59 #define GV ((int)(-0.368*(1<<RGB2YUV_SHIFT)+0.5))
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
60 #define GU ((int)(-0.291*(1<<RGB2YUV_SHIFT)+0.5))
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
61 #define RY ((int)( 0.257*(1<<RGB2YUV_SHIFT)+0.5))
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
62 #define RV ((int)( 0.439*(1<<RGB2YUV_SHIFT)+0.5))
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
63 #define RU ((int)(-0.148*(1<<RGB2YUV_SHIFT)+0.5))
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
64
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
65 //Note: we have C, MMX, MMX2, 3DNOW version therse no 3DNOW+MMX2 one
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
66 //Plain C versions
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
67 #undef HAVE_MMX
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
68 #undef HAVE_MMX2
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
69 #undef HAVE_3DNOW
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
70 #undef ARCH_X86
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
71 #define RENAME(a) a ## _C
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
72 #include "rgb2rgb_template.c"
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
73
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
74 #ifdef CAN_COMPILE_X86_ASM
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
75
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
76 //MMX versions
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
77 #undef RENAME
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
78 #define HAVE_MMX
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
79 #undef HAVE_MMX2
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
80 #undef HAVE_3DNOW
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
81 #define ARCH_X86
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
82 #define RENAME(a) a ## _MMX
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
83 #include "rgb2rgb_template.c"
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
84
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
85 //MMX2 versions
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
86 #undef RENAME
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
87 #define HAVE_MMX
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
88 #define HAVE_MMX2
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
89 #undef HAVE_3DNOW
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
90 #define ARCH_X86
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
91 #define RENAME(a) a ## _MMX2
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
92 #include "rgb2rgb_template.c"
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
93
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
94 //3DNOW versions
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
95 #undef RENAME
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
96 #define HAVE_MMX
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
97 #undef HAVE_MMX2
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
98 #define HAVE_3DNOW
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
99 #define ARCH_X86
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
100 #define RENAME(a) a ## _3DNow
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
101 #include "rgb2rgb_template.c"
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
102
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
103 #endif //CAN_COMPILE_X86_ASM
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
104
2718
9c5e64493742 Well - old algorithms and new stuff rgb24to16(15)
nick
parents: 2711
diff changeset
105 void rgb24to32(const uint8_t *src,uint8_t *dst,unsigned src_size)
2504
13e1c5ab417a vo_vesa: rgb2rgb support
nick
parents:
diff changeset
106 {
3132
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
107 #ifdef CAN_COMPILE_X86_ASM
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
108 // ordered per speed fasterst first
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
109 if(gCpuCaps.hasMMX2)
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
110 rgb24to32_MMX2(src, dst, src_size);
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
111 else if(gCpuCaps.has3DNow)
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
112 rgb24to32_3DNow(src, dst, src_size);
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
113 else if(gCpuCaps.hasMMX)
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
114 rgb24to32_MMX(src, dst, src_size);
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
115 else
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
116 rgb24to32_C(src, dst, src_size);
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
117 #else
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
118 rgb24to32_C(src, dst, src_size);
2510
42e1ae2c8f5f mmx optimized 24to32
nick
parents: 2508
diff changeset
119 #endif
2504
13e1c5ab417a vo_vesa: rgb2rgb support
nick
parents:
diff changeset
120 }
2505
2aaa11d22f91 vo_vesa: more rgb2rgb support
nick
parents: 2504
diff changeset
121
2718
9c5e64493742 Well - old algorithms and new stuff rgb24to16(15)
nick
parents: 2711
diff changeset
122 void rgb32to24(const uint8_t *src,uint8_t *dst,unsigned src_size)
2505
2aaa11d22f91 vo_vesa: more rgb2rgb support
nick
parents: 2504
diff changeset
123 {
3132
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
124 #ifdef CAN_COMPILE_X86_ASM
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
125 // ordered per speed fasterst first
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
126 if(gCpuCaps.hasMMX2)
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
127 rgb32to24_MMX2(src, dst, src_size);
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
128 else if(gCpuCaps.has3DNow)
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
129 rgb32to24_3DNow(src, dst, src_size);
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
130 else if(gCpuCaps.hasMMX)
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
131 rgb32to24_MMX(src, dst, src_size);
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
132 else
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
133 rgb32to24_C(src, dst, src_size);
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
134 #else
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
135 rgb32to24_C(src, dst, src_size);
2517
3d507ef1e3ed 32to24: MMX, MMX2, 3DNOW optimization
nick
parents: 2516
diff changeset
136 #endif
2505
2aaa11d22f91 vo_vesa: more rgb2rgb support
nick
parents: 2504
diff changeset
137 }
2506
501752469c39 vo_vesa: more rgb2rgb support
nick
parents: 2505
diff changeset
138
2538
71320898b333 Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents: 2535
diff changeset
139 /*
71320898b333 Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents: 2535
diff changeset
140 Original by Strepto/Astral
71320898b333 Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents: 2535
diff changeset
141 ported to gcc & bugfixed : A'rpi
2564
3d04a0991dce cosmetic
nick
parents: 2538
diff changeset
142 MMX2, 3DNOW optimization by Nick Kurshev
2698
22652c028692 faster 15to16 bit rgb (the mmx routine is limited by memory speed so there is no difference ): but the c routine is faster
michael
parents: 2697
diff changeset
143 32bit c version, and and&add trick by Michael Niedermayer
2538
71320898b333 Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents: 2535
diff changeset
144 */
2718
9c5e64493742 Well - old algorithms and new stuff rgb24to16(15)
nick
parents: 2711
diff changeset
145 void rgb15to16(const uint8_t *src,uint8_t *dst,unsigned src_size)
2506
501752469c39 vo_vesa: more rgb2rgb support
nick
parents: 2505
diff changeset
146 {
3132
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
147 #ifdef CAN_COMPILE_X86_ASM
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
148 // ordered per speed fasterst first
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
149 if(gCpuCaps.hasMMX2)
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
150 rgb15to16_MMX2(src, dst, src_size);
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
151 else if(gCpuCaps.has3DNow)
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
152 rgb15to16_3DNow(src, dst, src_size);
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
153 else if(gCpuCaps.hasMMX)
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
154 rgb15to16_MMX(src, dst, src_size);
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
155 else
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
156 rgb15to16_C(src, dst, src_size);
2506
501752469c39 vo_vesa: more rgb2rgb support
nick
parents: 2505
diff changeset
157 #else
3132
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
158 rgb15to16_C(src, dst, src_size);
2506
501752469c39 vo_vesa: more rgb2rgb support
nick
parents: 2505
diff changeset
159 #endif
501752469c39 vo_vesa: more rgb2rgb support
nick
parents: 2505
diff changeset
160 }
2694
2924350d92ed bgr32to16, bgr32to15 (needed for palette stuff)
michael
parents: 2677
diff changeset
161
2924350d92ed bgr32to16, bgr32to15 (needed for palette stuff)
michael
parents: 2677
diff changeset
162 /**
2924350d92ed bgr32to16, bgr32to15 (needed for palette stuff)
michael
parents: 2677
diff changeset
163 * Pallete is assumed to contain bgr32
2924350d92ed bgr32to16, bgr32to15 (needed for palette stuff)
michael
parents: 2677
diff changeset
164 */
2718
9c5e64493742 Well - old algorithms and new stuff rgb24to16(15)
nick
parents: 2711
diff changeset
165 void palette8torgb32(const uint8_t *src, uint8_t *dst, unsigned num_pixels, const uint8_t *palette)
2694
2924350d92ed bgr32to16, bgr32to15 (needed for palette stuff)
michael
parents: 2677
diff changeset
166 {
2718
9c5e64493742 Well - old algorithms and new stuff rgb24to16(15)
nick
parents: 2711
diff changeset
167 unsigned i;
2702
440312d953a8 yv12toyuy2 in MMX
michael
parents: 2701
diff changeset
168 for(i=0; i<num_pixels; i++)
2718
9c5e64493742 Well - old algorithms and new stuff rgb24to16(15)
nick
parents: 2711
diff changeset
169 ((unsigned *)dst)[i] = ((unsigned *)palette)[ src[i] ];
2694
2924350d92ed bgr32to16, bgr32to15 (needed for palette stuff)
michael
parents: 2677
diff changeset
170 }
2924350d92ed bgr32to16, bgr32to15 (needed for palette stuff)
michael
parents: 2677
diff changeset
171
2697
1eaf3f89e49f palette to bgr24
michael
parents: 2694
diff changeset
172 /**
1eaf3f89e49f palette to bgr24
michael
parents: 2694
diff changeset
173 * Pallete is assumed to contain bgr32
1eaf3f89e49f palette to bgr24
michael
parents: 2694
diff changeset
174 */
2718
9c5e64493742 Well - old algorithms and new stuff rgb24to16(15)
nick
parents: 2711
diff changeset
175 void palette8torgb24(const uint8_t *src, uint8_t *dst, unsigned num_pixels, const uint8_t *palette)
2697
1eaf3f89e49f palette to bgr24
michael
parents: 2694
diff changeset
176 {
2718
9c5e64493742 Well - old algorithms and new stuff rgb24to16(15)
nick
parents: 2711
diff changeset
177 unsigned i;
2697
1eaf3f89e49f palette to bgr24
michael
parents: 2694
diff changeset
178 /*
1eaf3f89e49f palette to bgr24
michael
parents: 2694
diff changeset
179 writes 1 byte o much and might cause alignment issues on some architectures?
2702
440312d953a8 yv12toyuy2 in MMX
michael
parents: 2701
diff changeset
180 for(i=0; i<num_pixels; i++)
2718
9c5e64493742 Well - old algorithms and new stuff rgb24to16(15)
nick
parents: 2711
diff changeset
181 ((unsigned *)(&dst[i*3])) = ((unsigned *)palette)[ src[i] ];
2697
1eaf3f89e49f palette to bgr24
michael
parents: 2694
diff changeset
182 */
2702
440312d953a8 yv12toyuy2 in MMX
michael
parents: 2701
diff changeset
183 for(i=0; i<num_pixels; i++)
2697
1eaf3f89e49f palette to bgr24
michael
parents: 2694
diff changeset
184 {
1eaf3f89e49f palette to bgr24
michael
parents: 2694
diff changeset
185 //FIXME slow?
1eaf3f89e49f palette to bgr24
michael
parents: 2694
diff changeset
186 dst[0]= palette[ src[i]*4+0 ];
1eaf3f89e49f palette to bgr24
michael
parents: 2694
diff changeset
187 dst[1]= palette[ src[i]*4+1 ];
1eaf3f89e49f palette to bgr24
michael
parents: 2694
diff changeset
188 dst[2]= palette[ src[i]*4+2 ];
1eaf3f89e49f palette to bgr24
michael
parents: 2694
diff changeset
189 dst+= 3;
1eaf3f89e49f palette to bgr24
michael
parents: 2694
diff changeset
190 }
1eaf3f89e49f palette to bgr24
michael
parents: 2694
diff changeset
191 }
1eaf3f89e49f palette to bgr24
michael
parents: 2694
diff changeset
192
2718
9c5e64493742 Well - old algorithms and new stuff rgb24to16(15)
nick
parents: 2711
diff changeset
193 void rgb32to16(const uint8_t *src, uint8_t *dst, unsigned src_size)
2694
2924350d92ed bgr32to16, bgr32to15 (needed for palette stuff)
michael
parents: 2677
diff changeset
194 {
3132
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
195 #ifdef CAN_COMPILE_X86_ASM
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
196 // ordered per speed fasterst first
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
197 if(gCpuCaps.hasMMX2)
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
198 rgb32to16_MMX2(src, dst, src_size);
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
199 else if(gCpuCaps.has3DNow)
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
200 rgb32to16_3DNow(src, dst, src_size);
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
201 else if(gCpuCaps.hasMMX)
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
202 rgb32to16_MMX(src, dst, src_size);
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
203 else
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
204 rgb32to16_C(src, dst, src_size);
2741
b8a692c59b64 MMX2, 3DNOW, MMX optimized rgb32(24)to16(15) stuff
nick
parents: 2740
diff changeset
205 #else
3132
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
206 rgb32to16_C(src, dst, src_size);
2741
b8a692c59b64 MMX2, 3DNOW, MMX optimized rgb32(24)to16(15) stuff
nick
parents: 2740
diff changeset
207 #endif
2694
2924350d92ed bgr32to16, bgr32to15 (needed for palette stuff)
michael
parents: 2677
diff changeset
208 }
2924350d92ed bgr32to16, bgr32to15 (needed for palette stuff)
michael
parents: 2677
diff changeset
209
2718
9c5e64493742 Well - old algorithms and new stuff rgb24to16(15)
nick
parents: 2711
diff changeset
210 void rgb32to15(const uint8_t *src, uint8_t *dst, unsigned src_size)
2694
2924350d92ed bgr32to16, bgr32to15 (needed for palette stuff)
michael
parents: 2677
diff changeset
211 {
3132
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
212 #ifdef CAN_COMPILE_X86_ASM
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
213 // ordered per speed fasterst first
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
214 if(gCpuCaps.hasMMX2)
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
215 rgb32to15_MMX2(src, dst, src_size);
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
216 else if(gCpuCaps.has3DNow)
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
217 rgb32to15_3DNow(src, dst, src_size);
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
218 else if(gCpuCaps.hasMMX)
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
219 rgb32to15_MMX(src, dst, src_size);
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
220 else
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
221 rgb32to15_C(src, dst, src_size);
2741
b8a692c59b64 MMX2, 3DNOW, MMX optimized rgb32(24)to16(15) stuff
nick
parents: 2740
diff changeset
222 #else
3132
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
223 rgb32to15_C(src, dst, src_size);
2741
b8a692c59b64 MMX2, 3DNOW, MMX optimized rgb32(24)to16(15) stuff
nick
parents: 2740
diff changeset
224 #endif
2694
2924350d92ed bgr32to16, bgr32to15 (needed for palette stuff)
michael
parents: 2677
diff changeset
225 }
2924350d92ed bgr32to16, bgr32to15 (needed for palette stuff)
michael
parents: 2677
diff changeset
226
2718
9c5e64493742 Well - old algorithms and new stuff rgb24to16(15)
nick
parents: 2711
diff changeset
227 void rgb24to16(const uint8_t *src, uint8_t *dst, unsigned src_size)
9c5e64493742 Well - old algorithms and new stuff rgb24to16(15)
nick
parents: 2711
diff changeset
228 {
3132
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
229 #ifdef CAN_COMPILE_X86_ASM
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
230 // ordered per speed fasterst first
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
231 if(gCpuCaps.hasMMX2)
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
232 rgb24to16_MMX2(src, dst, src_size);
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
233 else if(gCpuCaps.has3DNow)
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
234 rgb24to16_3DNow(src, dst, src_size);
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
235 else if(gCpuCaps.hasMMX)
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
236 rgb24to16_MMX(src, dst, src_size);
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
237 else
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
238 rgb24to16_C(src, dst, src_size);
2740
1583214489a2 optimized rgb24to16 stuff
nick
parents: 2738
diff changeset
239 #else
3132
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
240 rgb24to16_C(src, dst, src_size);
2740
1583214489a2 optimized rgb24to16 stuff
nick
parents: 2738
diff changeset
241 #endif
2718
9c5e64493742 Well - old algorithms and new stuff rgb24to16(15)
nick
parents: 2711
diff changeset
242 }
9c5e64493742 Well - old algorithms and new stuff rgb24to16(15)
nick
parents: 2711
diff changeset
243
9c5e64493742 Well - old algorithms and new stuff rgb24to16(15)
nick
parents: 2711
diff changeset
244 void rgb24to15(const uint8_t *src, uint8_t *dst, unsigned src_size)
9c5e64493742 Well - old algorithms and new stuff rgb24to16(15)
nick
parents: 2711
diff changeset
245 {
3132
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
246 #ifdef CAN_COMPILE_X86_ASM
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
247 // ordered per speed fasterst first
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
248 if(gCpuCaps.hasMMX2)
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
249 rgb24to15_MMX2(src, dst, src_size);
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
250 else if(gCpuCaps.has3DNow)
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
251 rgb24to15_3DNow(src, dst, src_size);
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
252 else if(gCpuCaps.hasMMX)
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
253 rgb24to15_MMX(src, dst, src_size);
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
254 else
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
255 rgb24to15_C(src, dst, src_size);
2741
b8a692c59b64 MMX2, 3DNOW, MMX optimized rgb32(24)to16(15) stuff
nick
parents: 2740
diff changeset
256 #else
3132
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
257 rgb24to15_C(src, dst, src_size);
2741
b8a692c59b64 MMX2, 3DNOW, MMX optimized rgb32(24)to16(15) stuff
nick
parents: 2740
diff changeset
258 #endif
2718
9c5e64493742 Well - old algorithms and new stuff rgb24to16(15)
nick
parents: 2711
diff changeset
259 }
2694
2924350d92ed bgr32to16, bgr32to15 (needed for palette stuff)
michael
parents: 2677
diff changeset
260
2924350d92ed bgr32to16, bgr32to15 (needed for palette stuff)
michael
parents: 2677
diff changeset
261 /**
2924350d92ed bgr32to16, bgr32to15 (needed for palette stuff)
michael
parents: 2677
diff changeset
262 * Palette is assumed to contain bgr16, see rgb32to16 to convert the palette
2924350d92ed bgr32to16, bgr32to15 (needed for palette stuff)
michael
parents: 2677
diff changeset
263 */
2718
9c5e64493742 Well - old algorithms and new stuff rgb24to16(15)
nick
parents: 2711
diff changeset
264 void palette8torgb16(const uint8_t *src, uint8_t *dst, unsigned num_pixels, const uint8_t *palette)
2694
2924350d92ed bgr32to16, bgr32to15 (needed for palette stuff)
michael
parents: 2677
diff changeset
265 {
2718
9c5e64493742 Well - old algorithms and new stuff rgb24to16(15)
nick
parents: 2711
diff changeset
266 unsigned i;
2702
440312d953a8 yv12toyuy2 in MMX
michael
parents: 2701
diff changeset
267 for(i=0; i<num_pixels; i++)
2694
2924350d92ed bgr32to16, bgr32to15 (needed for palette stuff)
michael
parents: 2677
diff changeset
268 ((uint16_t *)dst)[i] = ((uint16_t *)palette)[ src[i] ];
2924350d92ed bgr32to16, bgr32to15 (needed for palette stuff)
michael
parents: 2677
diff changeset
269 }
2924350d92ed bgr32to16, bgr32to15 (needed for palette stuff)
michael
parents: 2677
diff changeset
270
2924350d92ed bgr32to16, bgr32to15 (needed for palette stuff)
michael
parents: 2677
diff changeset
271 /**
2924350d92ed bgr32to16, bgr32to15 (needed for palette stuff)
michael
parents: 2677
diff changeset
272 * Pallete is assumed to contain bgr15, see rgb32to15 to convert the palette
2924350d92ed bgr32to16, bgr32to15 (needed for palette stuff)
michael
parents: 2677
diff changeset
273 */
2718
9c5e64493742 Well - old algorithms and new stuff rgb24to16(15)
nick
parents: 2711
diff changeset
274 void palette8torgb15(const uint8_t *src, uint8_t *dst, unsigned num_pixels, const uint8_t *palette)
2694
2924350d92ed bgr32to16, bgr32to15 (needed for palette stuff)
michael
parents: 2677
diff changeset
275 {
2718
9c5e64493742 Well - old algorithms and new stuff rgb24to16(15)
nick
parents: 2711
diff changeset
276 unsigned i;
2702
440312d953a8 yv12toyuy2 in MMX
michael
parents: 2701
diff changeset
277 for(i=0; i<num_pixels; i++)
2694
2924350d92ed bgr32to16, bgr32to15 (needed for palette stuff)
michael
parents: 2677
diff changeset
278 ((uint16_t *)dst)[i] = ((uint16_t *)palette)[ src[i] ];
2697
1eaf3f89e49f palette to bgr24
michael
parents: 2694
diff changeset
279 }
2755
2f93f4351765 rgb32tobgr32 / bgr32torgb32
michael
parents: 2746
diff changeset
280
2f93f4351765 rgb32tobgr32 / bgr32torgb32
michael
parents: 2746
diff changeset
281 void rgb32tobgr32(const uint8_t *src, uint8_t *dst, unsigned int src_size)
2f93f4351765 rgb32tobgr32 / bgr32torgb32
michael
parents: 2746
diff changeset
282 {
3132
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
283 #ifdef CAN_COMPILE_X86_ASM
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
284 // ordered per speed fasterst first
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
285 if(gCpuCaps.hasMMX2)
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
286 rgb32tobgr32_MMX2(src, dst, src_size);
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
287 else if(gCpuCaps.has3DNow)
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
288 rgb32tobgr32_3DNow(src, dst, src_size);
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
289 else if(gCpuCaps.hasMMX)
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
290 rgb32tobgr32_MMX(src, dst, src_size);
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
291 else
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
292 rgb32tobgr32_C(src, dst, src_size);
2755
2f93f4351765 rgb32tobgr32 / bgr32torgb32
michael
parents: 2746
diff changeset
293 #else
3132
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
294 rgb32tobgr32_C(src, dst, src_size);
2755
2f93f4351765 rgb32tobgr32 / bgr32torgb32
michael
parents: 2746
diff changeset
295 #endif
2f93f4351765 rgb32tobgr32 / bgr32torgb32
michael
parents: 2746
diff changeset
296 }
2f93f4351765 rgb32tobgr32 / bgr32torgb32
michael
parents: 2746
diff changeset
297
2702
440312d953a8 yv12toyuy2 in MMX
michael
parents: 2701
diff changeset
298 /**
440312d953a8 yv12toyuy2 in MMX
michael
parents: 2701
diff changeset
299 *
2724
c08b7af26782 yuy2toyv12 fixed and speedup
michael
parents: 2723
diff changeset
300 * height should be a multiple of 2 and width should be a multiple of 16 (if this is a
c08b7af26782 yuy2toyv12 fixed and speedup
michael
parents: 2723
diff changeset
301 * problem for anyone then tell me, and ill fix it)
2702
440312d953a8 yv12toyuy2 in MMX
michael
parents: 2701
diff changeset
302 */
2723
22aba8af94af fixed yv12toyuy2
michael
parents: 2720
diff changeset
303 void yv12toyuy2(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,
2725
5bba527c9a4c unsigned stuff
michael
parents: 2724
diff changeset
304 unsigned int width, unsigned int height,
5bba527c9a4c unsigned stuff
michael
parents: 2724
diff changeset
305 unsigned int lumStride, unsigned int chromStride, unsigned int dstStride)
2701
9b47bc409083 yv12 <-> yuy2 in C
michael
parents: 2698
diff changeset
306 {
3132
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
307 #ifdef CAN_COMPILE_X86_ASM
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
308 // ordered per speed fasterst first
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
309 if(gCpuCaps.hasMMX2)
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
310 yv12toyuy2_MMX2(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride);
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
311 else if(gCpuCaps.has3DNow)
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
312 yv12toyuy2_3DNow(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride);
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
313 else if(gCpuCaps.hasMMX)
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
314 yv12toyuy2_MMX(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride);
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
315 else
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
316 yv12toyuy2_C(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride);
2702
440312d953a8 yv12toyuy2 in MMX
michael
parents: 2701
diff changeset
317 #else
3132
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
318 yv12toyuy2_C(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride);
2702
440312d953a8 yv12toyuy2 in MMX
michael
parents: 2701
diff changeset
319 #endif
2701
9b47bc409083 yv12 <-> yuy2 in C
michael
parents: 2698
diff changeset
320 }
9b47bc409083 yv12 <-> yuy2 in C
michael
parents: 2698
diff changeset
321
2724
c08b7af26782 yuy2toyv12 fixed and speedup
michael
parents: 2723
diff changeset
322 /**
c08b7af26782 yuy2toyv12 fixed and speedup
michael
parents: 2723
diff changeset
323 *
c08b7af26782 yuy2toyv12 fixed and speedup
michael
parents: 2723
diff changeset
324 * height should be a multiple of 2 and width should be a multiple of 16 (if this is a
c08b7af26782 yuy2toyv12 fixed and speedup
michael
parents: 2723
diff changeset
325 * problem for anyone then tell me, and ill fix it)
c08b7af26782 yuy2toyv12 fixed and speedup
michael
parents: 2723
diff changeset
326 */
c08b7af26782 yuy2toyv12 fixed and speedup
michael
parents: 2723
diff changeset
327 void yuy2toyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
2725
5bba527c9a4c unsigned stuff
michael
parents: 2724
diff changeset
328 unsigned int width, unsigned int height,
5bba527c9a4c unsigned stuff
michael
parents: 2724
diff changeset
329 unsigned int lumStride, unsigned int chromStride, unsigned int srcStride)
2701
9b47bc409083 yv12 <-> yuy2 in C
michael
parents: 2698
diff changeset
330 {
3132
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
331 #ifdef CAN_COMPILE_X86_ASM
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
332 // ordered per speed fasterst first
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
333 if(gCpuCaps.hasMMX2)
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
334 yuy2toyv12_MMX2(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride);
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
335 else if(gCpuCaps.has3DNow)
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
336 yuy2toyv12_3DNow(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride);
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
337 else if(gCpuCaps.hasMMX)
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
338 yuy2toyv12_MMX(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride);
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
339 else
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
340 yuy2toyv12_C(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride);
2704
b4c6699d3893 yuy2toyv12 in MMX
michael
parents: 2702
diff changeset
341 #else
3132
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
342 yuy2toyv12_C(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride);
2704
b4c6699d3893 yuy2toyv12 in MMX
michael
parents: 2702
diff changeset
343 #endif
2723
22aba8af94af fixed yv12toyuy2
michael
parents: 2720
diff changeset
344 }
2801
318c240363c7 uyvy->uv12 added
arpi
parents: 2800
diff changeset
345
318c240363c7 uyvy->uv12 added
arpi
parents: 2800
diff changeset
346 /**
318c240363c7 uyvy->uv12 added
arpi
parents: 2800
diff changeset
347 *
318c240363c7 uyvy->uv12 added
arpi
parents: 2800
diff changeset
348 * height should be a multiple of 2 and width should be a multiple of 16 (if this is a
318c240363c7 uyvy->uv12 added
arpi
parents: 2800
diff changeset
349 * problem for anyone then tell me, and ill fix it)
3132
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
350 * chrominance data is only taken from every secound line others are ignored FIXME write HQ version
2801
318c240363c7 uyvy->uv12 added
arpi
parents: 2800
diff changeset
351 */
318c240363c7 uyvy->uv12 added
arpi
parents: 2800
diff changeset
352 void uyvytoyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
318c240363c7 uyvy->uv12 added
arpi
parents: 2800
diff changeset
353 unsigned int width, unsigned int height,
318c240363c7 uyvy->uv12 added
arpi
parents: 2800
diff changeset
354 unsigned int lumStride, unsigned int chromStride, unsigned int srcStride)
318c240363c7 uyvy->uv12 added
arpi
parents: 2800
diff changeset
355 {
3132
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
356 #ifdef CAN_COMPILE_X86_ASM
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
357 // ordered per speed fasterst first
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
358 if(gCpuCaps.hasMMX2)
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
359 uyvytoyv12_MMX2(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride);
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
360 else if(gCpuCaps.has3DNow)
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
361 uyvytoyv12_3DNow(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride);
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
362 else if(gCpuCaps.hasMMX)
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
363 uyvytoyv12_MMX(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride);
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
364 else
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
365 uyvytoyv12_C(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride);
2847
1d92268eb8fc uyvytoyv12 in MMX (untested)
michael
parents: 2806
diff changeset
366 #else
3132
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
367 uyvytoyv12_C(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride);
2847
1d92268eb8fc uyvytoyv12 in MMX (untested)
michael
parents: 2806
diff changeset
368 #endif
2801
318c240363c7 uyvy->uv12 added
arpi
parents: 2800
diff changeset
369 }
318c240363c7 uyvy->uv12 added
arpi
parents: 2800
diff changeset
370
3132
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
371 /**
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
372 *
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
373 * height should be a multiple of 2 and width should be a multiple of 2 (if this is a
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
374 * problem for anyone then tell me, and ill fix it)
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
375 * chrominance data is only taken from every secound line others are ignored FIXME write HQ version
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
376 */
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
377 void rgb24toyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
378 unsigned int width, unsigned int height,
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
379 unsigned int lumStride, unsigned int chromStride, unsigned int srcStride)
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
380 {
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
381 #ifdef CAN_COMPILE_X86_ASM
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
382 // ordered per speed fasterst first
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
383 if(gCpuCaps.hasMMX2)
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
384 rgb24toyv12_MMX2(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride);
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
385 else if(gCpuCaps.has3DNow)
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
386 rgb24toyv12_3DNow(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride);
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
387 else if(gCpuCaps.hasMMX)
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
388 rgb24toyv12_MMX(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride);
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
389 else
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
390 rgb24toyv12_C(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride);
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
391 #else
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
392 rgb24toyv12_C(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride);
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
393 #endif
ab67556586fa runtime cpu detection
michael
parents: 2847
diff changeset
394 }