annotate Gui/wm/wsconv.c @ 1865:538b993b3518

-skin option
author gabucino
date Fri, 07 Sep 2001 20:43:37 +0000
parents d237c5d4b216
children 016f6d583733
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
2 #include <stdlib.h>
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
3 #include <stdio.h>
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
4
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
5 #include "../../config.h"
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
6 #ifdef xHAVE_MMX
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
7 #include "../../main/libvo/mmx.h"
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
8 #include "../../main/libvo/fastmemcpy.h"
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
9 #endif
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
10 #include "wsconv.h"
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
11
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
12 wsTConvFunc wsConvFunc = NULL;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
13
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
14 // ---
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
15
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
16 #define COPY_RGB_24(src,dst) dst[0]=src[0];dst[1]=src[1];dst[2]=src[2]
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
17
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
18 #define SWAP_RGB_24(src,dst) dst[1]=src[0];dst[1]=src[1];dst[2]=src[0]
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
19
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
20 void BGR8880_to_RGB555_c( unsigned char * in_pixels, unsigned char * out_pixels, int num_pixels)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
21 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
22 unsigned short pixel;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
23 int i;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
24 for(i = 0; i < num_pixels; i++)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
25 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
26 PACK_RGB15(in_pixels[0],in_pixels[1],in_pixels[2],pixel);
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
27 *(unsigned short*)out_pixels = pixel;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
28 in_pixels += 4;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
29 out_pixels += 2;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
30 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
31 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
32
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
33 void BGR8880_to_BGR555_c( unsigned char * in_pixels, unsigned char * out_pixels, int num_pixels)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
34 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
35 unsigned short pixel;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
36 int i;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
37 for(i = 0; i < num_pixels; i++)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
38 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
39 PACK_RGB15(in_pixels[2],in_pixels[1],in_pixels[0],pixel);
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
40 *(unsigned short*)out_pixels = pixel;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
41 in_pixels += 4;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
42 out_pixels += 2;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
43 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
44 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
45
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
46 void BGR8880_to_RGB565_c( unsigned char * in_pixels, unsigned char * out_pixels, int num_pixels)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
47 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
48 unsigned short pixel;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
49 int i;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
50 for(i = 0; i < num_pixels; i++)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
51 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
52 PACK_RGB16(in_pixels[0],in_pixels[1],in_pixels[2],pixel);
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
53 *(unsigned short*)out_pixels = pixel;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
54 in_pixels += 4;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
55 out_pixels += 2;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
56 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
57 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
58
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
59 void BGR8880_to_BGR565_c( unsigned char * in_pixels, unsigned char * out_pixels, int num_pixels)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
60 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
61 unsigned short pixel;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
62 int i;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
63 for(i = 0; i < num_pixels; i++)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
64 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
65 PACK_RGB16(in_pixels[2],in_pixels[1],in_pixels[0],pixel);
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
66 *(unsigned short*)out_pixels = pixel;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
67 in_pixels += 4;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
68 out_pixels += 2;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
69 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
70 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
71
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
72 void BGR8880_to_RGB888_c( unsigned char * in_pixels, unsigned char * out_pixels,int num_pixels )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
73 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
74 int i;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
75 for(i = 0; i < num_pixels; i++)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
76 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
77 COPY_RGB_24(in_pixels,out_pixels);
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
78 in_pixels += 4;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
79 out_pixels += 3;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
80 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
81 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
82
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
83 void BGR8880_to_BGR888_c( unsigned char * in_pixels, unsigned char * out_pixels,int num_pixels )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
84 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
85 int i;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
86 for(i = 0; i < num_pixels; i++)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
87 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
88 SWAP_RGB_24(in_pixels,out_pixels);
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
89 in_pixels += 4;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
90 out_pixels += 3;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
91 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
92 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
93
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
94 void BGR8880_to_BGR8880_c( unsigned char * in_pixels, unsigned char * out_pixels,int num_pixels )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
95 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
96 int i;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
97 for(i = 0; i < num_pixels; i++)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
98 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
99 SWAP_RGB_24(in_pixels,out_pixels);
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
100 in_pixels += 4;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
101 out_pixels += 4;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
102 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
103 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
104
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
105 void BGR8880_to_RGB8880_c( unsigned char * in_pixels, unsigned char * out_pixels,int num_pixels )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
106 { memcpy( out_pixels,in_pixels,num_pixels * 4 ); }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
107
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
108 /*
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
109
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
110 unsigned char * map_5_to_8[32];
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
111 unsigned char * map_6_to_8[64];
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
112
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
113 #define POINTER_TO_GUINT16(a) *((unsigned short*)a)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
114 #define RGB16_TO_R(pixel) map_5_to_8[pixel & RGB16_LOWER_MASK]
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
115 #define RGB16_TO_G(pixel) map_6_to_8[(pixel & RGB16_MIDDLE_MASK)>>5]
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
116 #define RGB16_TO_B(pixel) map_5_to_8[(pixel & RGB16_UPPER_MASK)>>11]
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
117 #define RGB16_LOWER_MASK 0x001f
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
118 #define RGB16_MIDDLE_MASK 0x07e0
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
119 #define RGB16_UPPER_MASK 0xf800
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
120
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
121 void RGB565_to_RGB888_c( unsigned char * in_pixels, unsigned char * out_pixels,int num_pixels)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
122 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
123 unsigned short in_pixel;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
124 int i;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
125 for(i = 0; i < num_pixels; i++)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
126 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
127 in_pixel = POINTER_TO_GUINT16(in_pixels);
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
128 out_pixels[0] = RGB16_TO_R(in_pixel);
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
129 out_pixels[1] = RGB16_TO_G(in_pixel);
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
130 out_pixels[2] = RGB16_TO_B(in_pixel);
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
131 in_pixels += 2;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
132 out_pixels += 3;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
133 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
134 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
135
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
136 */
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
137
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
138 // ---
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
139
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
140 #ifdef xHAVE_MMX
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
141
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
142 #define LOAD_32(in) movq_m2r(*in, mm0); in += 8;\
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
143 movq_m2r(*in, mm1); in += 8
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
144
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
145 #define PACK_32_TO_24 movq_r2r(mm0, mm2);\
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
146 pand_m2r(rgb32_l_mask,mm0);\
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
147 pand_m2r(rgb32_u_mask,mm2);\
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
148 psrlq_i2r(8, mm2);\
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
149 por_r2r(mm2,mm0);\
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
150 movq_r2r(mm1, mm2);\
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
151 pand_m2r(rgb32_l_mask,mm1);\
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
152 pand_m2r(rgb32_u_mask,mm2);\
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
153 psrlq_i2r(8, mm2);\
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
154 por_r2r(mm2,mm1);
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
155
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
156 #define WRITE_24(out) movq_r2m(mm0, *out); out+=6;\
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
157 movq_r2m(mm1, *out); out+=6;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
158
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
159 #define WRITE_16(out) movq_r2m(mm0, *out); out+=8;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
160
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
161 static mmx_t rgb32_l_mask; // Mask for the lower of 2 RGB24 pixels
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
162 static mmx_t rgb32_u_mask; // Mask for the upper of 2 RGB24 pixels
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
163
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
164 static mmx_t rgb32_r_mask; // Mask for the reds of 2 RGB32 pixels
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
165 static mmx_t rgb32_g_mask; // Mask for the greens of 2 RGB32 pixels
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
166 static mmx_t rgb32_b_mask; // Mask for the blues of 2 RGB32 pixels
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
167
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
168 static mmx_t lower_dword_mask; // Mask for the lower doublewords
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
169 static mmx_t upper_dword_mask; // Mask for the upper doublewords
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
170
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
171 void BGR8880_to_RGB888_mmx(unsigned char * in_pixels,unsigned char * out_pixels,int num_pixels)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
172 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
173 int imax = num_pixels/4;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
174 int i;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
175
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
176 for(i = 0; i < imax; i++)
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
177 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
178 LOAD_32(in_pixels);
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
179 PACK_32_TO_24;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
180 WRITE_24(out_pixels);
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
181 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
182 emms();
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
183 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
184
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
185 #endif
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
186
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
187 // ---
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
188
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
189 void initConverter( void )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
190 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
191 #ifdef xHAVE_MMX
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
192 // int i;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
193
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
194 // for(i = 0; i < 64; i++) map_6_to_8[i] = (unsigned char)((float)i/63.0*255.0+0.5);
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
195 // for(i = 0; i < 32; i++) map_5_to_8[i] = (unsigned char)((float)i/31.0*255.0+0.5);
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
196
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
197 rgb32_l_mask.q = 0x0000000000FFFFFFLL; // Mask for the lower of 2 RGB32 pixels
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
198 rgb32_u_mask.q = 0x00FFFFFF00000000LL; // Mask for the upper of 2 RGB32 pixels
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
199
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
200 rgb32_r_mask.q = 0x000000FF000000FFLL; // Mask for the reds of 2 RGB32 pixels
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
201 rgb32_g_mask.q = 0x0000FF000000FF00LL; // Mask for the greens of 2 RGB32 pixels
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
202 rgb32_b_mask.q = 0x00FF000000FF0000LL; // Mask for the blues of 2 RGB32 pixels
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
203 #endif
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
204 }