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