Mercurial > mplayer.hg
annotate libvo/mga_common.c @ 1124:0e95f30ffd4c
-frames and -benchmark options to make chl & gabucino happy
author | arpi_esp |
---|---|
date | Wed, 13 Jun 2001 21:55:24 +0000 |
parents | 0375ced94bd7 |
children | 248972c26eee |
rev | line source |
---|---|
413 | 1 |
566 | 2 #include "fastmemcpy.h" |
1 | 3 |
4 // mga_vid drawing functions | |
5 | |
56 | 6 static int mga_next_frame=0; |
7 | |
8 static mga_vid_config_t mga_vid_config; | |
9 static uint8_t *vid_data, *frames[4]; | |
10 static int f; | |
11 | |
202 | 12 static void draw_alpha(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){ |
13 int x,y; | |
14 uint32_t bespitch = (mga_vid_config.src_width + 31) & ~31; | |
466 | 15 switch(mga_vid_config.format){ |
16 case MGA_VID_FORMAT_YV12: | |
470 | 17 case MGA_VID_FORMAT_IYUV: |
18 case MGA_VID_FORMAT_I420: | |
326 | 19 vo_draw_alpha_yv12(w,h,src,srca,stride,vid_data+bespitch*y0+x0,bespitch); |
466 | 20 break; |
21 case MGA_VID_FORMAT_YUY2: | |
326 | 22 vo_draw_alpha_yuy2(w,h,src,srca,stride,vid_data+2*(bespitch*y0+x0),2*bespitch); |
466 | 23 break; |
24 case MGA_VID_FORMAT_UYVY: | |
25 vo_draw_alpha_yuy2(w,h,src,srca,stride,vid_data+2*(bespitch*y0+x0)+1,2*bespitch); | |
26 break; | |
27 } | |
1 | 28 } |
29 | |
30 | |
31 //static void | |
32 //write_slice_g200(uint8_t *y,uint8_t *cr, uint8_t *cb,uint32_t slice_num) | |
33 | |
34 static void | |
35 draw_slice_g200(uint8_t *image[], int stride[], int width,int height,int x,int y) | |
36 { | |
37 uint8_t *src; | |
38 uint8_t *src2; | |
39 uint8_t *dest; | |
40 uint32_t bespitch,h,w; | |
41 | |
284 | 42 bespitch = (mga_vid_config.src_width + 31) & ~31; |
1 | 43 |
284 | 44 dest = vid_data + bespitch*y + x; |
1 | 45 src = image[0]; |
284 | 46 for(h=0; h < height; h++) |
47 { | |
48 memcpy(dest, src, width); | |
49 src += stride[0]; | |
50 dest += bespitch; | |
51 } | |
1 | 52 |
53 width/=2;height/=2;x/=2;y/=2; | |
54 | |
284 | 55 dest = vid_data + bespitch*mga_vid_config.src_height + bespitch*y + 2*x; |
1 | 56 src = image[1]; |
57 src2 = image[2]; | |
58 for(h=0; h < height; h++) | |
59 { | |
60 for(w=0; w < width; w++) | |
61 { | |
62 dest[2*w+0] = src[w]; | |
63 dest[2*w+1] = src2[w]; | |
64 } | |
65 dest += bespitch; | |
284 | 66 src += stride[1]; |
67 src2+= stride[2]; | |
1 | 68 } |
69 } | |
70 | |
71 static void | |
72 draw_slice_g400(uint8_t *image[], int stride[], int w,int h,int x,int y) | |
73 { | |
74 uint8_t *src; | |
75 uint8_t *dest; | |
76 uint32_t bespitch,bespitch2; | |
77 int i; | |
78 | |
79 bespitch = (mga_vid_config.src_width + 31) & ~31; | |
80 bespitch2 = bespitch/2; | |
81 | |
82 dest = vid_data + bespitch * y + x; | |
83 src = image[0]; | |
84 for(i=0;i<h;i++){ | |
85 memcpy(dest,src,w); | |
86 src+=stride[0]; | |
87 dest += bespitch; | |
88 } | |
89 | |
90 w/=2;h/=2;x/=2;y/=2; | |
91 | |
92 dest = vid_data + bespitch*mga_vid_config.src_height + bespitch2 * y + x; | |
93 src = image[1]; | |
94 for(i=0;i<h;i++){ | |
95 memcpy(dest,src,w); | |
96 src+=stride[1]; | |
97 dest += bespitch2; | |
98 } | |
99 | |
100 dest = vid_data + bespitch*mga_vid_config.src_height | |
101 + bespitch*mga_vid_config.src_height / 4 | |
102 + bespitch2 * y + x; | |
103 src = image[2]; | |
104 for(i=0;i<h;i++){ | |
105 memcpy(dest,src,w); | |
106 src+=stride[2]; | |
107 dest += bespitch2; | |
108 } | |
109 | |
110 } | |
111 | |
112 static uint32_t | |
113 draw_slice(uint8_t *src[], int stride[], int w,int h,int x,int y) | |
114 { | |
115 if (mga_vid_config.card_type == MGA_G200) | |
116 draw_slice_g200(src,stride,w,h,x,y); | |
117 else | |
118 draw_slice_g400(src,stride,w,h,x,y); | |
119 return 0; | |
120 } | |
121 | |
122 static void | |
31 | 123 vo_mga_flip_page(void) |
1 | 124 { |
47 | 125 |
126 // printf("-- flip to %d --\n",mga_next_frame); | |
1 | 127 |
47 | 128 #if 1 |
129 ioctl(f,MGA_VID_FSEL,&mga_next_frame); | |
56 | 130 mga_next_frame=(mga_next_frame+1)%mga_vid_config.num_frames; |
47 | 131 vid_data=frames[mga_next_frame]; |
132 #endif | |
1 | 133 |
134 } | |
135 | |
136 | |
137 static void | |
138 write_frame_yuy2(uint8_t *y) | |
139 { | |
140 uint8_t *dest; | |
141 uint32_t bespitch,h; | |
142 int len=2*mga_vid_config.src_width; | |
143 | |
144 dest = vid_data; | |
145 bespitch = (mga_vid_config.src_width + 31) & ~31; | |
146 | |
147 // y+=2*mga_vid_config.src_width*mga_vid_config.src_height; | |
148 | |
149 for(h=0; h < mga_vid_config.src_height; h++) | |
150 { | |
151 // y -= 2*mga_vid_config.src_width; | |
152 memcpy(dest, y, len); | |
153 y += len; | |
154 dest += 2*bespitch; | |
155 } | |
156 } | |
157 | |
158 | |
159 static uint32_t | |
160 draw_frame(uint8_t *src[]) | |
161 { | |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
413
diff
changeset
|
162 switch(mga_vid_config.format){ |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
413
diff
changeset
|
163 case MGA_VID_FORMAT_YUY2: |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
413
diff
changeset
|
164 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
|
165 case MGA_VID_FORMAT_UYVY: |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
413
diff
changeset
|
166 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
|
167 } |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
413
diff
changeset
|
168 return 0; |
1 | 169 } |
170 | |
171 static uint32_t | |
172 query_format(uint32_t format) | |
173 { | |
174 switch(format){ | |
175 case IMGFMT_YV12: | |
470 | 176 case IMGFMT_I420: |
177 case IMGFMT_IYUV: | |
1 | 178 case IMGFMT_YUY2: |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
413
diff
changeset
|
179 case IMGFMT_UYVY: |
1 | 180 // case IMGFMT_RGB|24: |
181 // case IMGFMT_BGR|24: | |
182 return 1; | |
183 } | |
184 return 0; | |
185 } | |
186 | |
56 | 187 static int mga_init(){ |
188 char *frame_mem; | |
189 | |
190 mga_vid_config.num_frames=4; | |
191 mga_vid_config.version=MGA_VID_VERSION; | |
192 if (ioctl(f,MGA_VID_CONFIG,&mga_vid_config)) | |
193 { | |
275 | 194 perror("Error in mga_vid_config ioctl()"); |
195 printf("Your mga_vid driver version is incompatible with this MPlayer version!\n"); | |
56 | 196 return -1; |
197 } | |
198 ioctl(f,MGA_VID_ON,0); | |
199 | |
200 frames[0] = (char*)mmap(0,mga_vid_config.frame_size*mga_vid_config.num_frames,PROT_WRITE,MAP_SHARED,f,0); | |
201 frames[1] = frames[0] + 1*mga_vid_config.frame_size; | |
202 frames[2] = frames[0] + 2*mga_vid_config.frame_size; | |
203 frames[3] = frames[0] + 3*mga_vid_config.frame_size; | |
204 mga_next_frame = 0; | |
205 vid_data = frames[mga_next_frame]; | |
206 | |
207 //clear the buffer | |
208 memset(frames[0],0x80,mga_vid_config.frame_size*mga_vid_config.num_frames); | |
209 | |
210 return 0; | |
211 | |
212 } | |
213 |