Mercurial > mplayer.hg
annotate libvo/vosub_vidix.c @ 4708:000ca7a19331
mem2agpcpy_pic()
author | michael |
---|---|
date | Thu, 14 Feb 2002 22:34:24 +0000 |
parents | 227365bd93c7 |
children | a2df307ed979 |
rev | line source |
---|---|
4010 | 1 /* |
2 * vosub_vidix.c | |
3 * | |
4 * Copyright (C) Nick Kurshev <nickols_k@mail.ru> - 2002 | |
4280 | 5 * Copyright (C) Alex Beregszaszi |
4010 | 6 * |
7 * You can redistribute this file under terms and conditions | |
8 * of GNU General Public licence v2. | |
9 * | |
10 * This file contains vidix interface to any mplayer's VO plugin. | |
11 * (Partly based on vesa_lvo.c from mplayer's package) | |
12 */ | |
13 | |
14 #include <inttypes.h> | |
15 #include <sys/ioctl.h> | |
16 #include <unistd.h> | |
17 #include <fcntl.h> | |
18 #include <sys/mman.h> | |
19 #include <stdio.h> | |
20 #include <stdlib.h> | |
21 #include <string.h> | |
4372 | 22 #include <errno.h> |
4010 | 23 |
24 #include "config.h" | |
25 | |
26 #include "vosub_vidix.h" | |
27 #include "../vidix/vidixlib.h" | |
28 #include "fastmemcpy.h" | |
29 #include "osd.h" | |
30 #include "video_out.h" | |
31 | |
32 #define NUM_FRAMES 10 /* Temporary: driver will overwrite it */ | |
33 #define UNUSED(x) ((void)(x)) /* Removes warning about unused arguments */ | |
34 | |
35 static VDL_HANDLE vidix_handler = NULL; | |
36 static uint8_t *vidix_mem = NULL; | |
37 static uint8_t next_frame; | |
38 static unsigned image_bpp,image_height,image_width,src_format; | |
39 extern int verbose; | |
4372 | 40 static int video_on=0; |
4010 | 41 |
42 static vidix_capability_t vidix_cap; | |
43 static vidix_playback_t vidix_play; | |
44 static vidix_fourcc_t vidix_fourcc; | |
4454 | 45 static vo_functions_t * vo_server; |
4010 | 46 |
4372 | 47 static int vidix_get_bes_da(bes_da_t *); |
4379 | 48 static int vidix_get_video_eq(vidix_video_eq_t *info); |
49 static int vidix_set_video_eq(const vidix_video_eq_t *info); | |
50 static int vidix_get_num_fx(unsigned *info); | |
51 static int vidix_get_oem_fx(vidix_oem_fx_t *info); | |
52 static int vidix_set_oem_fx(const vidix_oem_fx_t *info); | |
53 static int vidix_set_deint(const vidix_deinterlace_t *info); | |
4372 | 54 |
55 static void vidix_query_vaa(vo_vaa_t *vaa) | |
56 { | |
57 memset(vaa,0,sizeof(vo_vaa_t)); | |
58 vaa->query_bes_da=vidix_get_bes_da; | |
4379 | 59 vaa->get_video_eq=vidix_get_video_eq; |
60 vaa->set_video_eq=vidix_set_video_eq; | |
61 vaa->get_num_fx=vidix_get_num_fx; | |
62 vaa->get_oem_fx=vidix_get_oem_fx; | |
63 vaa->set_oem_fx=vidix_set_oem_fx; | |
64 vaa->set_deint=vidix_set_deint; | |
4372 | 65 } |
66 | |
4229 | 67 extern int vo_gamma_brightness; |
68 extern int vo_gamma_saturation; | |
69 extern int vo_gamma_contrast; | |
70 extern int vo_gamma_hue; | |
4317 | 71 extern int vo_gamma_red_intensity; |
72 extern int vo_gamma_green_intensity; | |
73 extern int vo_gamma_blue_intensity; | |
4229 | 74 |
4240 | 75 static vidix_video_eq_t vid_eq; |
4229 | 76 |
4234
0ec1d81c8f94
sorry, i really wanted to add vidix_start and stop as int, to detect if something went into the wrong way (also implement check in vo_xvidix)
alex
parents:
4231
diff
changeset
|
77 int vidix_start(void) |
4198
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
78 { |
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
79 int err; |
4270
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
80 if((err=vdlPlaybackOn(vidix_handler))!=0) |
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
81 { |
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
82 printf("vosub_vidix: Can't start playback: %s\n",strerror(err)); |
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
83 return -1; |
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
84 } |
4379 | 85 video_on=1; |
4270
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
86 if (vidix_cap.flags & FLAG_EQUALIZER) |
4229 | 87 { |
4270
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
88 if(verbose > 1) |
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
89 { |
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
90 printf("vosub_vidix: vo_gamma_brightness=%i\n" |
4229 | 91 "vosub_vidix: vo_gamma_saturation=%i\n" |
92 "vosub_vidix: vo_gamma_contrast=%i\n" | |
93 "vosub_vidix: vo_gamma_hue=%i\n" | |
4317 | 94 "vosub_vidix: vo_gamma_red_intensity=%i\n" |
95 "vosub_vidix: vo_gamma_green_intensity=%i\n" | |
96 "vosub_vidix: vo_gamma_blue_intensity=%i\n" | |
4229 | 97 ,vo_gamma_brightness |
98 ,vo_gamma_saturation | |
99 ,vo_gamma_contrast | |
100 ,vo_gamma_hue | |
4317 | 101 ,vo_gamma_red_intensity |
102 ,vo_gamma_green_intensity | |
103 ,vo_gamma_blue_intensity); | |
4270
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
104 } |
4317 | 105 /* To use full set of vid_eq.cap */ |
4379 | 106 if(vidix_get_video_eq(&vid_eq) == 0) |
4317 | 107 { |
108 vid_eq.brightness = vo_gamma_brightness; | |
109 vid_eq.saturation = vo_gamma_saturation; | |
110 vid_eq.contrast = vo_gamma_contrast; | |
111 vid_eq.hue = vo_gamma_hue; | |
112 vid_eq.red_intensity = vo_gamma_red_intensity; | |
113 vid_eq.green_intensity = vo_gamma_green_intensity; | |
114 vid_eq.blue_intensity = vo_gamma_blue_intensity; | |
115 vid_eq.flags = VEQ_FLG_ITU_R_BT_601; | |
4379 | 116 vidix_set_video_eq(&vid_eq); |
4317 | 117 } |
4198
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
118 } |
4234
0ec1d81c8f94
sorry, i really wanted to add vidix_start and stop as int, to detect if something went into the wrong way (also implement check in vo_xvidix)
alex
parents:
4231
diff
changeset
|
119 return 0; |
4198
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
120 } |
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
121 |
4234
0ec1d81c8f94
sorry, i really wanted to add vidix_start and stop as int, to detect if something went into the wrong way (also implement check in vo_xvidix)
alex
parents:
4231
diff
changeset
|
122 int vidix_stop(void) |
4198
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
123 { |
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
124 int err; |
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
125 if((err=vdlPlaybackOff(vidix_handler))!=0) |
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
126 { |
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
127 printf("vosub_vidix: Can't stop playback: %s\n",strerror(err)); |
4234
0ec1d81c8f94
sorry, i really wanted to add vidix_start and stop as int, to detect if something went into the wrong way (also implement check in vo_xvidix)
alex
parents:
4231
diff
changeset
|
128 return -1; |
4198
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
129 } |
4372 | 130 video_on=0; |
4234
0ec1d81c8f94
sorry, i really wanted to add vidix_start and stop as int, to detect if something went into the wrong way (also implement check in vo_xvidix)
alex
parents:
4231
diff
changeset
|
131 return 0; |
4198
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
132 } |
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
133 |
4010 | 134 void vidix_term( void ) |
135 { | |
136 if(verbose > 1) printf("vosub_vidix: vidix_term() was called\n"); | |
4198
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
137 vidix_stop(); |
4010 | 138 vdlClose(vidix_handler); |
139 } | |
140 | |
4430 | 141 static uint32_t vidix_draw_slice_420(uint8_t *image[], int stride[], int w,int h,int x,int y) |
4010 | 142 { |
143 uint8_t *src; | |
144 uint8_t *dest; | |
4014 | 145 unsigned bespitch,apitch; |
4010 | 146 int i; |
4324
09f15844c960
don't render UV planes if interleaved (also add support later)
alex
parents:
4317
diff
changeset
|
147 |
09f15844c960
don't render UV planes if interleaved (also add support later)
alex
parents:
4317
diff
changeset
|
148 /* Plane Y */ |
4014 | 149 apitch = vidix_play.dest.pitch.y-1; |
150 bespitch = (w + apitch) & ~apitch; | |
4270
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
151 |
4032 | 152 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y; |
4010 | 153 dest += bespitch*y + x; |
154 src = image[0]; | |
155 for(i=0;i<h;i++){ | |
156 memcpy(dest,src,w); | |
157 src+=stride[0]; | |
158 dest += bespitch; | |
159 } | |
160 | |
4324
09f15844c960
don't render UV planes if interleaved (also add support later)
alex
parents:
4317
diff
changeset
|
161 if (vidix_play.flags & VID_PLAY_INTERLEAVED_UV) |
09f15844c960
don't render UV planes if interleaved (also add support later)
alex
parents:
4317
diff
changeset
|
162 { |
09f15844c960
don't render UV planes if interleaved (also add support later)
alex
parents:
4317
diff
changeset
|
163 printf("vosub_vidix: interleaving UV planes not supported yet\n"); |
09f15844c960
don't render UV planes if interleaved (also add support later)
alex
parents:
4317
diff
changeset
|
164 return 0; |
09f15844c960
don't render UV planes if interleaved (also add support later)
alex
parents:
4317
diff
changeset
|
165 } |
09f15844c960
don't render UV planes if interleaved (also add support later)
alex
parents:
4317
diff
changeset
|
166 |
09f15844c960
don't render UV planes if interleaved (also add support later)
alex
parents:
4317
diff
changeset
|
167 /* Plane V */ |
4014 | 168 apitch = vidix_play.dest.pitch.v-1; |
169 bespitch = (w + apitch) & ~apitch; | |
4324
09f15844c960
don't render UV planes if interleaved (also add support later)
alex
parents:
4317
diff
changeset
|
170 |
4032 | 171 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.v; |
4031 | 172 dest += bespitch*y/4 + x; |
4014 | 173 src = image[1]; |
174 for(i=0;i<h/2;i++){ | |
175 memcpy(dest,src,w/2); | |
176 src+=stride[1]; | |
177 dest+=bespitch/2; | |
178 } | |
4324
09f15844c960
don't render UV planes if interleaved (also add support later)
alex
parents:
4317
diff
changeset
|
179 |
09f15844c960
don't render UV planes if interleaved (also add support later)
alex
parents:
4317
diff
changeset
|
180 /* Plane U */ |
4014 | 181 apitch = vidix_play.dest.pitch.u-1; |
182 bespitch = (w + apitch) & ~apitch; | |
4010 | 183 |
4032 | 184 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.u; |
4031 | 185 dest += bespitch*y/4 + x; |
4010 | 186 src = image[2]; |
4014 | 187 for(i=0;i<h/2;i++){ |
188 memcpy(dest,src,w/2); | |
4010 | 189 src+=stride[2]; |
4014 | 190 dest += bespitch/2; |
4010 | 191 } |
192 return 0; | |
193 } | |
194 | |
4430 | 195 static uint32_t vidix_draw_slice_422(uint8_t *image[], int stride[], int w,int h,int x,int y) |
4010 | 196 { |
197 uint8_t *src; | |
198 uint8_t *dest; | |
4014 | 199 unsigned bespitch,apitch; |
4010 | 200 int i; |
4014 | 201 apitch = vidix_play.dest.pitch.y-1; |
202 bespitch = (w*2 + apitch) & ~apitch; | |
4032 | 203 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y; |
4010 | 204 dest += bespitch*y + x; |
205 src = image[0]; | |
206 for(i=0;i<h;i++){ | |
207 memcpy(dest,src,w*2); | |
208 src+=stride[0]; | |
209 dest += bespitch; | |
210 } | |
4240 | 211 |
212 return 0; | |
4010 | 213 } |
214 | |
4454 | 215 static uint32_t vidix_draw_slice_422_fast(uint8_t *image[], int stride[], int w,int h,int x,int y) |
216 { | |
217 uint8_t *src; | |
218 uint8_t *dest; | |
219 unsigned bespitch,apitch; | |
220 int i; | |
221 apitch = vidix_play.dest.pitch.y-1; | |
222 bespitch = (w*2 + apitch) & ~apitch; | |
223 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y; | |
224 dest += bespitch*y + x; | |
225 src = image[0]; | |
226 memcpy(dest,src,h*bespitch); | |
227 return 0; | |
228 } | |
229 | |
4430 | 230 static uint32_t vidix_draw_slice_32(uint8_t *image[], int stride[], int w,int h,int x,int y) |
231 { | |
232 uint8_t *src; | |
233 uint8_t *dest; | |
234 unsigned bespitch,apitch; | |
235 int i; | |
236 apitch = vidix_play.dest.pitch.y-1; | |
237 bespitch = (w*4 + apitch) & ~apitch; | |
238 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y; | |
239 dest += bespitch*y + x; | |
240 src = image[0]; | |
241 for(i=0;i<h;i++){ | |
242 memcpy(dest,src,w*4); | |
243 src+=stride[0]; | |
244 dest += bespitch; | |
245 } | |
246 | |
247 return 0; | |
248 } | |
249 | |
4454 | 250 static uint32_t vidix_draw_slice_32_fast(uint8_t *image[], int stride[], int w,int h,int x,int y) |
251 { | |
252 uint8_t *src; | |
253 uint8_t *dest; | |
254 unsigned bespitch,apitch; | |
255 int i; | |
256 apitch = vidix_play.dest.pitch.y-1; | |
257 bespitch = (w*4 + apitch) & ~apitch; | |
258 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y; | |
259 dest += bespitch*y + x; | |
260 src = image[0]; | |
261 memcpy(dest,src,h*bespitch); | |
262 return 0; | |
263 } | |
264 | |
4430 | 265 static uint32_t vidix_draw_slice_24(uint8_t *image[], int stride[], int w,int h,int x,int y) |
266 { | |
267 uint8_t *src; | |
268 uint8_t *dest; | |
269 unsigned bespitch,apitch; | |
270 int i; | |
271 apitch = vidix_play.dest.pitch.y-1; | |
272 bespitch = (w*3 + apitch) & ~apitch; | |
273 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y; | |
274 dest += bespitch*y + x; | |
275 src = image[0]; | |
276 for(i=0;i<h;i++){ | |
277 memcpy(dest,src,w*3); | |
278 src+=stride[0]; | |
279 dest += bespitch; | |
280 } | |
281 | |
282 return 0; | |
283 } | |
4010 | 284 |
4454 | 285 static uint32_t vidix_draw_slice_24_fast(uint8_t *image[], int stride[], int w,int h,int x,int y) |
286 { | |
287 uint8_t *src; | |
288 uint8_t *dest; | |
289 unsigned bespitch,apitch; | |
290 int i; | |
291 apitch = vidix_play.dest.pitch.y-1; | |
292 bespitch = (w*3 + apitch) & ~apitch; | |
293 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y; | |
294 dest += bespitch*y + x; | |
295 src = image[0]; | |
296 memcpy(dest,src,h*bespitch); | |
297 return 0; | |
298 } | |
299 | |
4010 | 300 uint32_t vidix_draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y) |
301 { | |
4454 | 302 printf("vosub_vidix: Error unoptimized draw_slice was called\nExiting..."); |
303 vidix_term(); | |
304 exit( EXIT_FAILURE ); | |
305 return 0; | |
4010 | 306 } |
307 | |
308 uint32_t vidix_draw_frame(uint8_t *image[]) | |
309 { | |
4454 | 310 int stride[1]; |
4010 | 311 if(verbose > 1) printf("vosub_vidix: vidix_draw_frame() was called\n"); |
312 /* Note it's very strange but sometime for YUY2 draw_frame is called */ | |
313 if(src_format == IMGFMT_YV12 || src_format == IMGFMT_I420 || src_format == IMGFMT_IYUV) | |
4442
49c410f359e0
return error if unknown depth given. more informative error messages. dont exit if draw_frame was called with Planar YUV, only warn the user
alex
parents:
4434
diff
changeset
|
314 printf("vosub_vidix: draw_frame for YUV420 called, frame cannot be written\n"); |
4010 | 315 else |
4430 | 316 if(src_format == IMGFMT_RGB32 || src_format == IMGFMT_BGR32) |
317 stride[0] = vidix_play.src.w*4; | |
318 else | |
319 if(src_format == IMGFMT_RGB24 || src_format == IMGFMT_BGR24) | |
320 stride[0] = vidix_play.src.w*3; | |
321 else | |
4010 | 322 stride[0] = vidix_play.src.w*2; |
4454 | 323 return vo_server->draw_slice(image,stride,vidix_play.src.w,vidix_play.src.h, |
324 vidix_play.src.x,vidix_play.src.y); | |
4010 | 325 } |
326 | |
327 void vidix_flip_page(void) | |
328 { | |
329 if(verbose > 1) printf("vosub_vidix: vidix_flip_page() was called\n"); | |
330 if(vo_doublebuffering) | |
331 { | |
4032 | 332 vdlPlaybackFrameSelect(vidix_handler,next_frame); |
4010 | 333 next_frame=(next_frame+1)%vidix_play.num_frames; |
334 } | |
335 } | |
336 | |
337 static void draw_alpha_null(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) | |
338 { | |
339 UNUSED(x0); | |
340 UNUSED(y0); | |
341 UNUSED(w); | |
342 UNUSED(h); | |
343 UNUSED(src); | |
344 UNUSED(srca); | |
345 UNUSED(stride); | |
346 } | |
347 | |
348 static void draw_alpha(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) | |
349 { | |
4032 | 350 uint32_t apitch,bespitch; |
4010 | 351 void *lvo_mem; |
4032 | 352 lvo_mem = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y; |
353 apitch = vidix_play.dest.pitch.y-1; | |
354 bespitch = (vidix_play.src.w + apitch) & (~apitch); | |
4010 | 355 switch(vidix_play.fourcc){ |
356 case IMGFMT_YV12: | |
357 case IMGFMT_IYUV: | |
358 case IMGFMT_I420: | |
359 vo_draw_alpha_yv12(w,h,src,srca,stride,lvo_mem+bespitch*y0+x0,bespitch); | |
360 break; | |
361 case IMGFMT_YUY2: | |
4032 | 362 vo_draw_alpha_yuy2(w,h,src,srca,stride,lvo_mem+2*(bespitch*y0+x0),2*bespitch); |
4010 | 363 break; |
364 case IMGFMT_UYVY: | |
4032 | 365 vo_draw_alpha_yuy2(w,h,src,srca,stride,lvo_mem+2*(bespitch*y0+x0)+1,2*bespitch); |
4010 | 366 break; |
4430 | 367 case IMGFMT_RGB32: |
368 case IMGFMT_BGR32: | |
369 vo_draw_alpha_rgb32(w,h,src,srca,stride,lvo_mem+4*(y0*bespitch+x0),4*bespitch); | |
370 break; | |
371 case IMGFMT_RGB24: | |
372 case IMGFMT_BGR24: | |
373 vo_draw_alpha_rgb24(w,h,src,srca,stride,lvo_mem+3*(y0*bespitch+x0),3*bespitch); | |
374 break; | |
375 case IMGFMT_RGB16: | |
376 case IMGFMT_BGR16: | |
377 vo_draw_alpha_rgb16(w,h,src,srca,stride,lvo_mem+2*(y0*bespitch+x0),2*bespitch); | |
378 break; | |
379 case IMGFMT_RGB15: | |
380 case IMGFMT_BGR15: | |
381 vo_draw_alpha_rgb15(w,h,src,srca,stride,lvo_mem+2*(y0*bespitch+x0),2*bespitch); | |
382 break; | |
4010 | 383 default: |
384 draw_alpha_null(x0,y0,w,h,src,srca,stride); | |
385 } | |
386 } | |
387 | |
388 void vidix_draw_osd(void) | |
389 { | |
390 if(verbose > 1) printf("vosub_vidix: vidix_draw_osd() was called\n"); | |
391 /* TODO: hw support */ | |
392 vo_draw_text(vidix_play.src.w,vidix_play.src.h,draw_alpha); | |
393 } | |
394 | |
395 uint32_t vidix_query_fourcc(uint32_t format) | |
396 { | |
397 if(verbose > 1) printf("vosub_vidix: query_format was called: %x (%s)\n",format,vo_format_name(format)); | |
398 vidix_fourcc.fourcc = format; | |
399 vdlQueryFourcc(vidix_handler,&vidix_fourcc); | |
4372 | 400 if (vidix_fourcc.depth == VID_DEPTH_NONE) return(0); |
4270
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
401 return(0x2); /* hw support without conversion */ |
4010 | 402 } |
4240 | 403 |
4255 | 404 int vidix_grkey_support(void) |
405 { | |
4270
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
406 return(vidix_fourcc.flags & VID_CAP_COLORKEY); |
4255 | 407 } |
408 | |
4240 | 409 int vidix_grkey_get(vidix_grkey_t *gr_key) |
410 { | |
411 return(vdlGetGrKeys(vidix_handler, gr_key)); | |
412 } | |
413 | |
414 int vidix_grkey_set(const vidix_grkey_t *gr_key) | |
415 { | |
416 return(vdlSetGrKeys(vidix_handler, gr_key)); | |
417 } | |
4372 | 418 |
419 static int vidix_get_bes_da(bes_da_t *info) | |
420 { | |
421 if(!video_on) return EPERM; | |
422 info->dest.x = vidix_play.src.x; | |
423 info->dest.y = vidix_play.src.y; | |
424 info->dest.w = vidix_play.src.w; | |
425 info->dest.h = vidix_play.src.h; | |
426 info->dest.pitch.y = vidix_play.dest.pitch.y; | |
427 info->dest.pitch.u = vidix_play.dest.pitch.u; | |
428 info->dest.pitch.v = vidix_play.dest.pitch.v; | |
429 info->flags = vidix_play.flags; | |
430 info->frame_size = vidix_play.frame_size; | |
431 info->num_frames = vidix_play.num_frames; | |
432 memcpy(info->offsets,vidix_play.offsets,sizeof(unsigned)*vidix_play.num_frames); | |
433 memcpy(&info->offset,&vidix_play.offset,sizeof(vidix_yuv_t)); | |
434 info->dga_addr = vidix_play.dga_addr; | |
435 return 0; | |
436 } | |
4379 | 437 |
438 static int vidix_get_video_eq(vidix_video_eq_t *info) | |
439 { | |
440 if(!video_on) return EPERM; | |
441 return vdlPlaybackGetEq(vidix_handler, info); | |
442 } | |
443 | |
444 static int vidix_set_video_eq(const vidix_video_eq_t *info) | |
445 { | |
446 if(!video_on) return EPERM; | |
447 return vdlPlaybackSetEq(vidix_handler, info); | |
448 } | |
449 | |
450 static int vidix_get_num_fx(unsigned *info) | |
451 { | |
452 if(!video_on) return EPERM; | |
453 return vdlQueryNumOemEffects(vidix_handler, info); | |
454 } | |
455 | |
456 static int vidix_get_oem_fx(vidix_oem_fx_t *info) | |
457 { | |
458 if(!video_on) return EPERM; | |
459 return vdlGetOemEffect(vidix_handler, info); | |
460 } | |
461 | |
462 static int vidix_set_oem_fx(const vidix_oem_fx_t *info) | |
463 { | |
464 if(!video_on) return EPERM; | |
465 return vdlSetOemEffect(vidix_handler, info); | |
466 } | |
467 | |
468 static int vidix_set_deint(const vidix_deinterlace_t *info) | |
469 { | |
470 if(!video_on) return EPERM; | |
471 return vdlPlaybackSetDeint(vidix_handler, info); | |
472 } | |
4454 | 473 |
474 int vidix_init(unsigned src_width,unsigned src_height, | |
475 unsigned x_org,unsigned y_org,unsigned dst_width, | |
476 unsigned dst_height,unsigned format,unsigned dest_bpp, | |
477 unsigned vid_w,unsigned vid_h,const void *info) | |
478 { | |
479 size_t i,awidth; | |
480 int err; | |
481 if(verbose > 1) | |
482 printf("vosub_vidix: vidix_init() was called\n" | |
483 "src_w=%u src_h=%u dest_x_y_w_h = %u %u %u %u\n" | |
484 "format=%s dest_bpp=%u vid_w=%u vid_h=%u\n" | |
485 ,src_width,src_height,x_org,y_org,dst_width,dst_height | |
486 ,vo_format_name(format),dest_bpp,vid_w,vid_h); | |
487 | |
488 if(((vidix_cap.maxwidth != -1) && (vid_w > vidix_cap.maxwidth)) || | |
489 ((vidix_cap.minwidth != -1) && (vid_w < vidix_cap.minwidth)) || | |
490 ((vidix_cap.maxheight != -1) && (vid_h > vidix_cap.maxheight)) || | |
491 ((vidix_cap.minwidth != -1 ) && (vid_h < vidix_cap.minheight))) | |
492 { | |
493 printf("vosub_vidix: video server has unsupported resolution (%dx%d), supported: %dx%d-%dx%d\n", | |
494 vid_w, vid_h, vidix_cap.minwidth, vidix_cap.minheight, | |
495 vidix_cap.maxwidth, vidix_cap.maxheight); | |
496 return -1; | |
497 } | |
498 | |
499 err = 0; | |
500 switch(dest_bpp) | |
501 { | |
502 case 1: err = ((vidix_fourcc.depth & VID_DEPTH_1BPP) != VID_DEPTH_1BPP); break; | |
503 case 2: err = ((vidix_fourcc.depth & VID_DEPTH_2BPP) != VID_DEPTH_2BPP); break; | |
504 case 4: err = ((vidix_fourcc.depth & VID_DEPTH_4BPP) != VID_DEPTH_4BPP); break; | |
505 case 8: err = ((vidix_fourcc.depth & VID_DEPTH_8BPP) != VID_DEPTH_8BPP); break; | |
506 case 12:err = ((vidix_fourcc.depth & VID_DEPTH_12BPP) != VID_DEPTH_12BPP); break; | |
4540 | 507 case 15:err = ((vidix_fourcc.depth & VID_DEPTH_15BPP) != VID_DEPTH_15BPP); break; |
4454 | 508 case 16:err = ((vidix_fourcc.depth & VID_DEPTH_16BPP) != VID_DEPTH_16BPP); break; |
509 case 24:err = ((vidix_fourcc.depth & VID_DEPTH_24BPP) != VID_DEPTH_24BPP); break; | |
510 case 32:err = ((vidix_fourcc.depth & VID_DEPTH_32BPP) != VID_DEPTH_32BPP); break; | |
511 default: err=1; break; | |
512 } | |
513 if(err) | |
514 { | |
515 printf("vosub_vidix: video server has unsupported color depth by vidix (%d)\n" | |
516 ,vidix_fourcc.depth); | |
517 return -1; | |
518 } | |
519 if((dst_width > src_width || dst_height > src_height) && (vidix_cap.flags & FLAG_UPSCALER) != FLAG_UPSCALER) | |
520 { | |
521 printf("vosub_vidix: vidix driver can't upscale image (%d%d -> %d%d)\n", | |
522 src_width, src_height, dst_width, dst_height); | |
523 return -1; | |
524 } | |
525 if((dst_width > src_width || dst_height > src_height) && (vidix_cap.flags & FLAG_DOWNSCALER) != FLAG_DOWNSCALER) | |
526 { | |
527 printf("vosub_vidix: vidix driver can't downscale image (%d%d -> %d%d)\n", | |
528 src_width, src_height, dst_width, dst_height); | |
529 return -1; | |
530 } | |
531 image_width = src_width; | |
532 image_height = src_height; | |
533 src_format = format; | |
534 memset(&vidix_play,0,sizeof(vidix_playback_t)); | |
535 vidix_play.fourcc = format; | |
536 vidix_play.capability = vidix_cap.flags; /* every ;) */ | |
537 vidix_play.blend_factor = 0; /* for now */ | |
538 /* display the full picture. | |
539 Nick: we could implement here zooming to a specified area -- alex */ | |
540 vidix_play.src.x = vidix_play.src.y = 0; | |
541 vidix_play.src.w = src_width; | |
542 vidix_play.src.h = src_height; | |
543 vidix_play.dest.x = x_org; | |
544 vidix_play.dest.y = y_org; | |
545 vidix_play.dest.w = dst_width; | |
546 vidix_play.dest.h = dst_height; | |
4654 | 547 vidix_play.num_frames=vo_doublebuffering?NUM_FRAMES:1; |
4454 | 548 vidix_play.src.pitch.y = vidix_play.src.pitch.u = vidix_play.src.pitch.v = 0; |
549 if(info) | |
550 { | |
551 switch(((const vo_tune_info_t *)info)->pitch[0]) | |
552 { | |
553 case 2: | |
554 case 4: | |
555 case 8: | |
556 case 16: | |
557 case 32: | |
558 case 64: | |
559 case 128: | |
560 case 256: vidix_play.src.pitch.y = ((const vo_tune_info_t *)info)->pitch[0]; | |
561 break; | |
562 default: break; | |
563 } | |
564 switch(((const vo_tune_info_t *)info)->pitch[1]) | |
565 { | |
566 case 2: | |
567 case 4: | |
568 case 8: | |
569 case 16: | |
570 case 32: | |
571 case 64: | |
572 case 128: | |
573 case 256: vidix_play.src.pitch.u = ((const vo_tune_info_t *)info)->pitch[1]; | |
574 break; | |
575 default: break; | |
576 } | |
577 switch(((const vo_tune_info_t *)info)->pitch[2]) | |
578 { | |
579 case 2: | |
580 case 4: | |
581 case 8: | |
582 case 16: | |
583 case 32: | |
584 case 64: | |
585 case 128: | |
586 case 256: vidix_play.src.pitch.v = ((const vo_tune_info_t *)info)->pitch[2]; | |
587 break; | |
588 default: break; | |
589 } | |
590 } | |
591 if((err=vdlConfigPlayback(vidix_handler,&vidix_play))!=0) | |
592 { | |
593 printf("vosub_vidix: Can't configure playback: %s\n",strerror(err)); | |
594 return -1; | |
595 } | |
596 | |
597 vidix_mem = vidix_play.dga_addr; | |
598 | |
599 /* select first frame */ | |
600 next_frame = 0; | |
601 // vdlPlaybackFrameSelect(vidix_handler,next_frame); | |
602 | |
603 /* clear every frame with correct address and frame_size */ | |
604 for (i = 0; i < vidix_play.num_frames; i++) | |
605 memset(vidix_mem + vidix_play.offsets[i], 0x80, | |
606 vidix_play.frame_size); | |
607 /* tune some info here */ | |
608 if(src_format == IMGFMT_YV12 || src_format == IMGFMT_I420 || src_format == IMGFMT_IYUV) | |
609 vo_server->draw_slice = vidix_draw_slice_420; | |
610 else | |
611 if(src_format == IMGFMT_RGB32 || src_format == IMGFMT_BGR32) | |
612 vo_server->draw_slice = | |
613 vidix_play.src.pitch.y == vidix_play.dest.pitch.y ? | |
614 vidix_draw_slice_32_fast: | |
615 vidix_draw_slice_32; | |
616 else | |
617 if(src_format == IMGFMT_RGB24 || src_format == IMGFMT_BGR24) | |
618 vo_server->draw_slice = | |
619 vidix_play.src.pitch.y == vidix_play.dest.pitch.y ? | |
620 vidix_draw_slice_24_fast: | |
621 vidix_draw_slice_24; | |
622 else | |
623 vo_server->draw_slice = | |
624 vidix_play.src.pitch.y == vidix_play.dest.pitch.y ? | |
625 vidix_draw_slice_422_fast: | |
626 vidix_draw_slice_422; | |
627 return 0; | |
628 } | |
629 | |
4592
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4540
diff
changeset
|
630 uint32_t vidix_control(uint32_t request, void *data, ...) |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4540
diff
changeset
|
631 { |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4540
diff
changeset
|
632 switch (request) { |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4540
diff
changeset
|
633 case VOCTRL_QUERY_VAA: |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4540
diff
changeset
|
634 vidix_query_vaa((vo_vaa_t*)data); |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4540
diff
changeset
|
635 return VO_TRUE; |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4540
diff
changeset
|
636 case VOCTRL_QUERY_FORMAT: |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4540
diff
changeset
|
637 return vidix_query_fourcc(*((uint32_t*)data)); |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4540
diff
changeset
|
638 } |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4540
diff
changeset
|
639 return VO_NOTIMPL; |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4540
diff
changeset
|
640 } |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4540
diff
changeset
|
641 |
4454 | 642 int vidix_preinit(const char *drvname,void *server) |
643 { | |
644 int err; | |
645 if(verbose > 1) printf("vosub_vidix: vidix_preinit(%s) was called\n",drvname); | |
646 if(vdlGetVersion() != VIDIX_VERSION) | |
647 { | |
648 printf("vosub_vidix: You have wrong version of VIDIX library\n"); | |
649 return -1; | |
650 } | |
651 vidix_handler = vdlOpen(LIBDIR"/vidix/", | |
652 drvname ? drvname[0] == ':' ? &drvname[1] : drvname[0] ? drvname : NULL : NULL, | |
653 TYPE_OUTPUT, | |
654 verbose); | |
655 if(vidix_handler == NULL) | |
656 { | |
657 printf("vosub_vidix: Couldn't find working VIDIX driver\n"); | |
658 return -1; | |
659 } | |
660 if((err=vdlGetCapability(vidix_handler,&vidix_cap)) != 0) | |
661 { | |
662 printf("vosub_vidix: Couldn't get capability: %s\n",strerror(err)); | |
663 return -1; | |
664 } | |
665 printf("vosub_vidix: Using: %s by %s\n",vidix_cap.name,vidix_cap.author); | |
666 /* we are able to tune up this stuff depend on fourcc format */ | |
667 ((vo_functions_t *)server)->draw_slice=vidix_draw_slice; | |
668 ((vo_functions_t *)server)->draw_frame=vidix_draw_frame; | |
669 ((vo_functions_t *)server)->flip_page=vidix_flip_page; | |
670 ((vo_functions_t *)server)->draw_osd=vidix_draw_osd; | |
4592
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4540
diff
changeset
|
671 ((vo_functions_t *)server)->control=vidix_control; |
4454 | 672 vo_server = server; |
673 return 0; | |
674 } |