comparison libvo/mga_common.c @ 1:3b5f5d1c5041

Initial revision
author arpi_esp
date Sat, 24 Feb 2001 20:28:24 +0000
parents
children 1fc618eba830
comparison
equal deleted inserted replaced
0:c1bb2c071d63 1:3b5f5d1c5041
1
2 // mga_vid drawing functions
3
4 static void
5 write_frame_g200(uint8_t *y,uint8_t *cr, uint8_t *cb)
6 {
7 uint8_t *dest;
8 uint32_t bespitch,h,w;
9
10 dest = vid_data;
11 bespitch = (mga_vid_config.src_width + 31) & ~31;
12
13 for(h=0; h < mga_vid_config.src_height; h++)
14 {
15 memcpy(dest, y, mga_vid_config.src_width);
16 y += mga_vid_config.src_width;
17 dest += bespitch;
18 }
19
20 for(h=0; h < mga_vid_config.src_height/2; h++)
21 {
22 for(w=0; w < mga_vid_config.src_width/2; w++)
23 {
24 *dest++ = *cb++;
25 *dest++ = *cr++;
26 }
27 dest += bespitch - mga_vid_config.src_width;
28 }
29 }
30
31 static void
32 write_frame_g400(uint8_t *y,uint8_t *cr, uint8_t *cb)
33 {
34 uint8_t *dest;
35 uint32_t bespitch,h;
36
37 dest = vid_data;
38 bespitch = (mga_vid_config.src_width + 31) & ~31;
39
40 for(h=0; h < mga_vid_config.src_height; h++)
41 {
42 memcpy(dest, y, mga_vid_config.src_width);
43 y += mga_vid_config.src_width;
44 dest += bespitch;
45 }
46
47 for(h=0; h < mga_vid_config.src_height/2; h++)
48 {
49 memcpy(dest, cb, mga_vid_config.src_width/2);
50 cb += mga_vid_config.src_width/2;
51 dest += bespitch/2;
52 }
53
54 for(h=0; h < mga_vid_config.src_height/2; h++)
55 {
56 memcpy(dest, cr, mga_vid_config.src_width/2);
57 cr += mga_vid_config.src_width/2;
58 dest += bespitch/2;
59 }
60 }
61
62 //static void
63 //write_slice_g200(uint8_t *y,uint8_t *cr, uint8_t *cb,uint32_t slice_num)
64
65 static void
66 draw_slice_g200(uint8_t *image[], int stride[], int width,int height,int x,int y)
67 {
68 uint8_t *src;
69 uint8_t *src2;
70 uint8_t *dest;
71 uint32_t bespitch,h,w;
72
73 bespitch = (mga_vid_config.src_width + 31) & ~31;
74
75 dest = vid_data + bespitch * y * x;
76 src = image[0];
77 for(h=0; h < height; h++)
78 {
79 memcpy(dest, src, width);
80 src += stride[0];
81 dest += bespitch;
82 }
83
84 width/=2;height/=2;x/=2;y/=2;
85
86 dest = vid_data + bespitch * mga_vid_config.src_height +
87 bespitch * y + 2*x;
88 src = image[1];
89 src2 = image[2];
90 for(h=0; h < height; h++)
91 {
92 for(w=0; w < width; w++)
93 {
94 dest[2*w+0] = src[w];
95 dest[2*w+1] = src2[w];
96 }
97 dest += bespitch;
98 src += stride[1];
99 src2+= stride[2];
100 }
101 }
102
103 static void
104 draw_slice_g400(uint8_t *image[], int stride[], int w,int h,int x,int y)
105 {
106 uint8_t *src;
107 uint8_t *dest;
108 uint32_t bespitch,bespitch2;
109 int i;
110
111 bespitch = (mga_vid_config.src_width + 31) & ~31;
112 bespitch2 = bespitch/2;
113
114 dest = vid_data + bespitch * y + x;
115 src = image[0];
116 for(i=0;i<h;i++){
117 memcpy(dest,src,w);
118 src+=stride[0];
119 dest += bespitch;
120 }
121
122 w/=2;h/=2;x/=2;y/=2;
123
124 dest = vid_data + bespitch*mga_vid_config.src_height + bespitch2 * y + x;
125 src = image[1];
126 for(i=0;i<h;i++){
127 memcpy(dest,src,w);
128 src+=stride[1];
129 dest += bespitch2;
130 }
131
132 dest = vid_data + bespitch*mga_vid_config.src_height
133 + bespitch*mga_vid_config.src_height / 4
134 + bespitch2 * y + x;
135 src = image[2];
136 for(i=0;i<h;i++){
137 memcpy(dest,src,w);
138 src+=stride[2];
139 dest += bespitch2;
140 }
141
142 }
143
144 static uint32_t
145 draw_slice(uint8_t *src[], int stride[], int w,int h,int x,int y)
146 {
147 if (mga_vid_config.card_type == MGA_G200)
148 draw_slice_g200(src,stride,w,h,x,y);
149 else
150 draw_slice_g400(src,stride,w,h,x,y);
151 return 0;
152 }
153
154 static void
155 flip_page(void)
156 {
157 #if 0
158 ioctl(f,MGA_VID_FSEL,&next_frame);
159
160 if (next_frame)
161 vid_data = frame1;
162 else
163 vid_data = frame0;
164
165 next_frame = 2 - next_frame; // switch between fields A1 and B1
166
167 #endif
168 }
169
170
171 static void
172 write_frame_yuy2(uint8_t *y)
173 {
174 uint8_t *dest;
175 uint32_t bespitch,h;
176 int len=2*mga_vid_config.src_width;
177
178 dest = vid_data;
179 bespitch = (mga_vid_config.src_width + 31) & ~31;
180
181 // y+=2*mga_vid_config.src_width*mga_vid_config.src_height;
182
183 for(h=0; h < mga_vid_config.src_height; h++)
184 {
185 // y -= 2*mga_vid_config.src_width;
186 memcpy(dest, y, len);
187 y += len;
188 dest += 2*bespitch;
189 }
190 }
191
192
193 static uint32_t
194 draw_frame(uint8_t *src[])
195 {
196 if (mga_vid_config.format==MGA_VID_FORMAT_YUY2)
197 write_frame_yuy2(src[0]);
198 else
199 if (mga_vid_config.card_type == MGA_G200)
200 write_frame_g200(src[0], src[2], src[1]);
201 else
202 write_frame_g400(src[0], src[2], src[1]);
203
204 //flip_page();
205 return 0;
206 }
207
208 static uint32_t
209 query_format(uint32_t format)
210 {
211 switch(format){
212 case IMGFMT_YV12:
213 case IMGFMT_YUY2:
214 // case IMGFMT_RGB|24:
215 // case IMGFMT_BGR|24:
216 return 1;
217 }
218 return 0;
219 }
220