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