Mercurial > mplayer.hg
annotate libvo/mga_common.c @ 2985:44e4572d5673
missing #include's
author | pl |
---|---|
date | Sun, 18 Nov 2001 21:59:20 +0000 |
parents | a8145a712f25 |
children | 48bfd1d278d1 |
rev | line source |
---|---|
413 | 1 |
566 | 2 #include "fastmemcpy.h" |
2625 | 3 #include "../mmx_defs.h" |
1 | 4 |
5 // mga_vid drawing functions | |
6 | |
56 | 7 static int mga_next_frame=0; |
8 | |
9 static mga_vid_config_t mga_vid_config; | |
10 static uint8_t *vid_data, *frames[4]; | |
11 static int f; | |
12 | |
202 | 13 static void draw_alpha(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){ |
14 int x,y; | |
15 uint32_t bespitch = (mga_vid_config.src_width + 31) & ~31; | |
466 | 16 switch(mga_vid_config.format){ |
17 case MGA_VID_FORMAT_YV12: | |
470 | 18 case MGA_VID_FORMAT_IYUV: |
19 case MGA_VID_FORMAT_I420: | |
326 | 20 vo_draw_alpha_yv12(w,h,src,srca,stride,vid_data+bespitch*y0+x0,bespitch); |
466 | 21 break; |
22 case MGA_VID_FORMAT_YUY2: | |
326 | 23 vo_draw_alpha_yuy2(w,h,src,srca,stride,vid_data+2*(bespitch*y0+x0),2*bespitch); |
466 | 24 break; |
25 case MGA_VID_FORMAT_UYVY: | |
26 vo_draw_alpha_yuy2(w,h,src,srca,stride,vid_data+2*(bespitch*y0+x0)+1,2*bespitch); | |
27 break; | |
28 } | |
1 | 29 } |
30 | |
31 | |
32 //static void | |
33 //write_slice_g200(uint8_t *y,uint8_t *cr, uint8_t *cb,uint32_t slice_num) | |
34 | |
35 static void | |
36 draw_slice_g200(uint8_t *image[], int stride[], int width,int height,int x,int y) | |
37 { | |
38 uint8_t *src; | |
39 uint8_t *src2; | |
40 uint8_t *dest; | |
41 uint32_t bespitch,h,w; | |
42 | |
284 | 43 bespitch = (mga_vid_config.src_width + 31) & ~31; |
1 | 44 |
284 | 45 dest = vid_data + bespitch*y + x; |
1 | 46 src = image[0]; |
284 | 47 for(h=0; h < height; h++) |
48 { | |
49 memcpy(dest, src, width); | |
50 src += stride[0]; | |
51 dest += bespitch; | |
52 } | |
1 | 53 |
54 width/=2;height/=2;x/=2;y/=2; | |
55 | |
284 | 56 dest = vid_data + bespitch*mga_vid_config.src_height + bespitch*y + 2*x; |
1 | 57 src = image[1]; |
58 src2 = image[2]; | |
59 for(h=0; h < height; h++) | |
60 { | |
2625 | 61 #ifdef HAVE_MMX |
62 asm( | |
63 "xorl %%eax, %%eax \n\t" | |
64 "1: \n\t" | |
65 PREFETCH" 64(%1, %%eax) \n\t" | |
66 PREFETCH" 64(%2, %%eax) \n\t" | |
67 "movq (%1, %%eax), %%mm0 \n\t" | |
68 "movq 8(%1, %%eax), %%mm2 \n\t" | |
69 "movq %%mm0, %%mm1 \n\t" | |
70 "movq %%mm2, %%mm3 \n\t" | |
71 "movq (%2, %%eax), %%mm4 \n\t" | |
72 "movq 8(%2, %%eax), %%mm5 \n\t" | |
73 "punpcklbw %%mm4, %%mm0 \n\t" | |
74 "punpckhbw %%mm4, %%mm1 \n\t" | |
75 "punpcklbw %%mm5, %%mm2 \n\t" | |
76 "punpckhbw %%mm5, %%mm3 \n\t" | |
77 MOVNTQ" %%mm0, (%0, %%eax, 2) \n\t" | |
78 MOVNTQ" %%mm1, 8(%0, %%eax, 2) \n\t" | |
79 MOVNTQ" %%mm2, 16(%0, %%eax, 2) \n\t" | |
80 MOVNTQ" %%mm3, 24(%0, %%eax, 2) \n\t" | |
81 "addl $16, %%eax \n\t" | |
82 "cmpl %3, %%eax \n\t" | |
83 " jb 1b \n\t" | |
84 ::"r"(dest), "r"(src), "r"(src2), "r" (width-15) | |
85 : "memory", "%eax" | |
86 ); | |
87 for(w= (width&(~15)); w < width; w++) | |
88 { | |
89 dest[2*w+0] = src[w]; | |
90 dest[2*w+1] = src2[w]; | |
91 } | |
92 #else | |
1 | 93 for(w=0; w < width; w++) |
94 { | |
95 dest[2*w+0] = src[w]; | |
96 dest[2*w+1] = src2[w]; | |
97 } | |
2625 | 98 #endif |
1 | 99 dest += bespitch; |
284 | 100 src += stride[1]; |
101 src2+= stride[2]; | |
1 | 102 } |
2625 | 103 #ifdef HAVE_MMX |
104 asm( | |
105 EMMS" \n\t" | |
106 SFENCE" \n\t" | |
107 ::: "memory" | |
108 ); | |
109 #endif | |
1 | 110 } |
111 | |
112 static void | |
113 draw_slice_g400(uint8_t *image[], int stride[], int w,int h,int x,int y) | |
114 { | |
115 uint8_t *src; | |
116 uint8_t *dest; | |
117 uint32_t bespitch,bespitch2; | |
118 int i; | |
119 | |
120 bespitch = (mga_vid_config.src_width + 31) & ~31; | |
121 bespitch2 = bespitch/2; | |
122 | |
123 dest = vid_data + bespitch * y + x; | |
124 src = image[0]; | |
125 for(i=0;i<h;i++){ | |
126 memcpy(dest,src,w); | |
127 src+=stride[0]; | |
128 dest += bespitch; | |
129 } | |
130 | |
131 w/=2;h/=2;x/=2;y/=2; | |
132 | |
133 dest = vid_data + bespitch*mga_vid_config.src_height + bespitch2 * y + x; | |
134 src = image[1]; | |
135 for(i=0;i<h;i++){ | |
136 memcpy(dest,src,w); | |
137 src+=stride[1]; | |
138 dest += bespitch2; | |
139 } | |
140 | |
141 dest = vid_data + bespitch*mga_vid_config.src_height | |
142 + bespitch*mga_vid_config.src_height / 4 | |
143 + bespitch2 * y + x; | |
144 src = image[2]; | |
145 for(i=0;i<h;i++){ | |
146 memcpy(dest,src,w); | |
147 src+=stride[2]; | |
148 dest += bespitch2; | |
149 } | |
150 | |
151 } | |
152 | |
153 static uint32_t | |
154 draw_slice(uint8_t *src[], int stride[], int w,int h,int x,int y) | |
155 { | |
156 if (mga_vid_config.card_type == MGA_G200) | |
157 draw_slice_g200(src,stride,w,h,x,y); | |
158 else | |
159 draw_slice_g400(src,stride,w,h,x,y); | |
160 return 0; | |
161 } | |
162 | |
163 static void | |
31 | 164 vo_mga_flip_page(void) |
1 | 165 { |
47 | 166 |
167 // printf("-- flip to %d --\n",mga_next_frame); | |
1 | 168 |
47 | 169 #if 1 |
170 ioctl(f,MGA_VID_FSEL,&mga_next_frame); | |
56 | 171 mga_next_frame=(mga_next_frame+1)%mga_vid_config.num_frames; |
47 | 172 vid_data=frames[mga_next_frame]; |
173 #endif | |
1 | 174 |
175 } | |
176 | |
177 | |
178 static void | |
179 write_frame_yuy2(uint8_t *y) | |
180 { | |
181 uint8_t *dest; | |
182 uint32_t bespitch,h; | |
183 int len=2*mga_vid_config.src_width; | |
184 | |
185 dest = vid_data; | |
186 bespitch = (mga_vid_config.src_width + 31) & ~31; | |
187 | |
188 // y+=2*mga_vid_config.src_width*mga_vid_config.src_height; | |
189 | |
190 for(h=0; h < mga_vid_config.src_height; h++) | |
191 { | |
192 // y -= 2*mga_vid_config.src_width; | |
193 memcpy(dest, y, len); | |
194 y += len; | |
195 dest += 2*bespitch; | |
196 } | |
197 } | |
198 | |
199 | |
200 static uint32_t | |
201 draw_frame(uint8_t *src[]) | |
202 { | |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
413
diff
changeset
|
203 switch(mga_vid_config.format){ |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
413
diff
changeset
|
204 case MGA_VID_FORMAT_YUY2: |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
413
diff
changeset
|
205 write_frame_yuy2(src[0]);break; |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
413
diff
changeset
|
206 case MGA_VID_FORMAT_UYVY: |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
413
diff
changeset
|
207 write_frame_yuy2(src[0]);break; |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
413
diff
changeset
|
208 } |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
413
diff
changeset
|
209 return 0; |
1 | 210 } |
211 | |
212 static uint32_t | |
213 query_format(uint32_t format) | |
214 { | |
215 switch(format){ | |
216 case IMGFMT_YV12: | |
470 | 217 case IMGFMT_I420: |
218 case IMGFMT_IYUV: | |
1 | 219 case IMGFMT_YUY2: |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
413
diff
changeset
|
220 case IMGFMT_UYVY: |
1 | 221 // case IMGFMT_RGB|24: |
222 // case IMGFMT_BGR|24: | |
223 return 1; | |
224 } | |
225 return 0; | |
226 } | |
227 | |
56 | 228 static int mga_init(){ |
229 char *frame_mem; | |
230 | |
231 mga_vid_config.num_frames=4; | |
232 mga_vid_config.version=MGA_VID_VERSION; | |
233 if (ioctl(f,MGA_VID_CONFIG,&mga_vid_config)) | |
234 { | |
275 | 235 perror("Error in mga_vid_config ioctl()"); |
236 printf("Your mga_vid driver version is incompatible with this MPlayer version!\n"); | |
56 | 237 return -1; |
238 } | |
239 ioctl(f,MGA_VID_ON,0); | |
240 | |
241 frames[0] = (char*)mmap(0,mga_vid_config.frame_size*mga_vid_config.num_frames,PROT_WRITE,MAP_SHARED,f,0); | |
242 frames[1] = frames[0] + 1*mga_vid_config.frame_size; | |
243 frames[2] = frames[0] + 2*mga_vid_config.frame_size; | |
244 frames[3] = frames[0] + 3*mga_vid_config.frame_size; | |
245 mga_next_frame = 0; | |
246 vid_data = frames[mga_next_frame]; | |
247 | |
248 //clear the buffer | |
249 memset(frames[0],0x80,mga_vid_config.frame_size*mga_vid_config.num_frames); | |
250 | |
251 return 0; | |
252 | |
253 } | |
254 | |
1637 | 255 static int mga_uninit(){ |
256 ioctl( f,MGA_VID_OFF,0 ); | |
257 munmap(frames[0],mga_vid_config.frame_size*mga_vid_config.num_frames); | |
258 close(f); | |
259 } |