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