osdep: Remove cruft
[mplayer.git] / libvo / vosub_vidix.c
blobb9ff829faa078d539b0235706414afb56fe37fd5
1 /*
2 * vosub_vidix.c
4 * Copyright (C) Nick Kurshev <nickols_k@mail.ru> - 2002
5 * Copyright (C) Alex Beregszaszi
7 * You can redistribute this file under terms and conditions
8 * of GNU General Public licence v2 or later.
10 * This file contains vidix interface to any mplayer's VO plugin.
11 * (Partly based on vesa_lvo.c from mplayer's package)
14 #include <inttypes.h>
15 #include <unistd.h>
16 #include <fcntl.h>
17 #ifndef __MINGW32__
18 #include <sys/ioctl.h>
19 #include <sys/mman.h>
20 #endif
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include <errno.h>
26 #include "config.h"
27 #include "mp_msg.h"
28 #include "help_mp.h"
30 #include "vidix/vidixlib.h"
31 #include "fastmemcpy.h"
32 #include "osd.h"
33 #include "video_out.h"
34 #include "sub.h"
35 #include "vosub_vidix.h"
36 #include "old_vo_wrapper.h"
38 #include "libmpcodecs/vfcap.h"
39 #include "libmpcodecs/mp_image.h"
41 #define NUM_FRAMES VID_PLAY_MAXFRAMES /* Temporary: driver will overwrite it */
43 static VDL_HANDLE vidix_handler = NULL;
44 static uint8_t *vidix_mem = NULL;
45 static uint8_t next_frame;
46 static unsigned image_Bpp,image_height,image_width,src_format,forced_fourcc=0;
47 static int video_on=0;
49 static vidix_capability_t vidix_cap;
50 static vidix_playback_t vidix_play;
51 static vidix_fourcc_t vidix_fourcc;
52 static struct vo_old_functions *vo_server;
53 static vidix_yuv_t dstrides;
54 /*static uint32_t (*server_control)(uint32_t request, void *data, ...);*/
56 int vidix_start(void)
58 int err;
59 if((err=vdlPlaybackOn(vidix_handler))!=0)
61 mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SUB_VIDIX_CantStartPlayback,strerror(err));
62 return -1;
64 video_on=1;
65 return 0;
68 int vidix_stop(void)
70 int err;
71 if((err=vdlPlaybackOff(vidix_handler))!=0)
73 mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SUB_VIDIX_CantStopPlayback,strerror(err));
74 return -1;
76 video_on=0;
77 return 0;
80 void vidix_term( void )
82 if( mp_msg_test(MSGT_VO,MSGL_DBG2) ) {
83 mp_msg(MSGT_VO,MSGL_DBG2, "vosub_vidix: vidix_term() was called\n"); }
84 vidix_stop();
85 vdlClose(vidix_handler);
86 // vo_server->control=server_control;
89 static int vidix_draw_slice_420(uint8_t *image[], int stride[], int w,int h,int x,int y)
91 uint8_t *src;
92 uint8_t *dest;
93 int i;
95 /* Plane Y */
96 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y;
97 dest += dstrides.y*y + x;
98 src = image[0];
99 for(i=0;i<h;i++){
100 memcpy(dest,src,w);
101 src+=stride[0];
102 dest += dstrides.y;
105 if (vidix_play.flags & VID_PLAY_INTERLEAVED_UV)
107 int hi,wi;
108 uint8_t *src2;
109 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.v;
110 dest += dstrides.y*y/2 + x; // <- is this correct ?
111 h/=2;
112 w/=2;
113 src = image[1];
114 src2 = image[2];
115 for(hi = 0; hi < h; hi++)
117 for(wi = 0; wi < w; wi++)
119 dest[2*wi+0] = src[wi];
120 dest[2*wi+1] = src2[wi];
122 dest += dstrides.y;
123 src += stride[1];
124 src2+= stride[2];
127 else
129 /* Plane V */
130 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.v;
131 dest += dstrides.v*y/4 + x;
132 src = image[1];
133 for(i=0;i<h/2;i++){
134 memcpy(dest,src,w/2);
135 src+=stride[1];
136 dest+=dstrides.v/2;
139 /* Plane U */
140 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.u;
141 dest += dstrides.u*y/4 + x;
142 src = image[2];
143 for(i=0;i<h/2;i++){
144 memcpy(dest,src,w/2);
145 src+=stride[2];
146 dest += dstrides.u/2;
148 return 0;
150 return -1;
153 static int vidix_draw_slice_410(uint8_t *image[], int stride[], int w,int h,int x,int y)
155 uint8_t *src;
156 uint8_t *dest;
157 int i;
159 /* Plane Y */
160 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y;
161 dest += dstrides.y*y + x;
162 src = image[0];
163 for(i=0;i<h;i++){
164 memcpy(dest,src,w);
165 src+=stride[0];
166 dest += dstrides.y;
169 if (vidix_play.flags & VID_PLAY_INTERLEAVED_UV)
171 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_SUB_VIDIX_InterleavedUvForYuv410pNotSupported);
173 else
175 /* Plane V */
176 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.v;
177 dest += dstrides.v*y/8 + x;
178 src = image[1];
179 for(i=0;i<h/4;i++){
180 memcpy(dest,src,w/4);
181 src+=stride[1];
182 dest+=dstrides.v/4;
185 /* Plane U */
186 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.u;
187 dest += dstrides.u*y/8 + x;
188 src = image[2];
189 for(i=0;i<h/4;i++){
190 memcpy(dest,src,w/4);
191 src+=stride[2];
192 dest += dstrides.u/4;
194 return 0;
196 return -1;
199 static int vidix_draw_slice_packed(uint8_t *image[], int stride[], int w,int h,int x,int y)
201 uint8_t *src;
202 uint8_t *dest;
203 int i;
205 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y;
206 dest += dstrides.y*y + x;
207 src = image[0];
208 for(i=0;i<h;i++){
209 memcpy(dest,src,w*image_Bpp);
210 src+=stride[0];
211 dest += dstrides.y;
213 return 0;
216 int vidix_draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y)
218 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_SUB_VIDIX_DummyVidixdrawsliceWasCalled);
219 return -1;
222 static uint32_t vidix_draw_image(mp_image_t *mpi){
223 if( mp_msg_test(MSGT_VO,MSGL_DBG2) ) {
224 mp_msg(MSGT_VO,MSGL_DBG2, "vosub_vidix: vidix_draw_image() was called\n"); }
226 // if -dr or -slices then do nothing:
227 if(mpi->flags&(MP_IMGFLAG_DIRECT|MP_IMGFLAG_DRAW_CALLBACK)) return VO_TRUE;
229 vo_server->draw_slice(mpi->planes,mpi->stride,
230 vidix_play.src.w,vidix_play.src.h,vidix_play.src.x,vidix_play.src.y);
231 return VO_TRUE;
234 int vidix_draw_frame(uint8_t *image[])
236 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_SUB_VIDIX_DummyVidixdrawframeWasCalled);
237 return -1;
240 void vidix_flip_page(void)
242 if( mp_msg_test(MSGT_VO,MSGL_DBG2) ) {
243 mp_msg(MSGT_VO,MSGL_DBG2, "vosub_vidix: vidix_flip_page() was called\n"); }
244 if(vo_doublebuffering)
246 vdlPlaybackFrameSelect(vidix_handler,next_frame);
247 next_frame=(next_frame+1)%vidix_play.num_frames;
251 static void draw_alpha(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)
253 uint32_t apitch,bespitch;
254 char *lvo_mem;
255 lvo_mem = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y;
256 apitch = vidix_play.dest.pitch.y-1;
257 switch(vidix_play.fourcc){
258 case IMGFMT_YV12:
259 case IMGFMT_IYUV:
260 case IMGFMT_I420:
261 case IMGFMT_YVU9:
262 case IMGFMT_IF09:
263 case IMGFMT_Y8:
264 case IMGFMT_Y800:
265 bespitch = (vidix_play.src.w + apitch) & (~apitch);
266 vo_draw_alpha_yv12(w,h,src,srca,stride,lvo_mem+bespitch*y0+x0,bespitch);
267 break;
268 case IMGFMT_YUY2:
269 bespitch = (vidix_play.src.w*2 + apitch) & (~apitch);
270 vo_draw_alpha_yuy2(w,h,src,srca,stride,lvo_mem+bespitch*y0+2*x0,bespitch);
271 break;
272 case IMGFMT_UYVY:
273 bespitch = (vidix_play.src.w*2 + apitch) & (~apitch);
274 vo_draw_alpha_yuy2(w,h,src,srca,stride,lvo_mem+bespitch*y0+2*x0+1,bespitch);
275 break;
276 case IMGFMT_RGB32:
277 case IMGFMT_BGR32:
278 bespitch = (vidix_play.src.w*4 + apitch) & (~apitch);
279 vo_draw_alpha_rgb32(w,h,src,srca,stride,lvo_mem+y0*bespitch+4*x0,bespitch);
280 break;
281 case IMGFMT_RGB24:
282 case IMGFMT_BGR24:
283 bespitch = (vidix_play.src.w*3 + apitch) & (~apitch);
284 vo_draw_alpha_rgb24(w,h,src,srca,stride,lvo_mem+y0*bespitch+3*x0,bespitch);
285 break;
286 case IMGFMT_RGB16:
287 case IMGFMT_BGR16:
288 bespitch = (vidix_play.src.w*2 + apitch) & (~apitch);
289 vo_draw_alpha_rgb16(w,h,src,srca,stride,lvo_mem+y0*bespitch+2*x0,bespitch);
290 break;
291 case IMGFMT_RGB15:
292 case IMGFMT_BGR15:
293 bespitch = (vidix_play.src.w*2 + apitch) & (~apitch);
294 vo_draw_alpha_rgb15(w,h,src,srca,stride,lvo_mem+y0*bespitch+2*x0,bespitch);
295 break;
296 default:
297 return;
301 void vidix_draw_osd(void)
303 if( mp_msg_test(MSGT_VO,MSGL_DBG2) ) {
304 mp_msg(MSGT_VO,MSGL_DBG2, "vosub_vidix: vidix_draw_osd() was called\n"); }
305 /* TODO: hw support */
306 vo_draw_text(vidix_play.src.w,vidix_play.src.h,draw_alpha);
309 uint32_t vidix_query_fourcc(uint32_t format)
311 if( mp_msg_test(MSGT_VO,MSGL_DBG2) ) {
312 mp_msg(MSGT_VO,MSGL_DBG2, "vosub_vidix: query_format was called: %x (%s)\n",format,vo_format_name(format)); }
313 vidix_fourcc.fourcc = format;
314 vdlQueryFourcc(vidix_handler,&vidix_fourcc);
315 if (vidix_fourcc.depth == VID_DEPTH_NONE)
316 return 0;
317 return VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_HWSCALE_UP|VFCAP_HWSCALE_DOWN|VFCAP_OSD|VFCAP_ACCEPT_STRIDE;
320 int vidix_grkey_support(void)
322 return(vidix_fourcc.flags & VID_CAP_COLORKEY);
325 int vidix_grkey_get(vidix_grkey_t *gr_key)
327 return(vdlGetGrKeys(vidix_handler, gr_key));
330 int vidix_grkey_set(const vidix_grkey_t *gr_key)
332 return(vdlSetGrKeys(vidix_handler, gr_key));
336 static int is_422_planes_eq=0;
337 int vidix_init(unsigned src_width,unsigned src_height,
338 unsigned x_org,unsigned y_org,unsigned dst_width,
339 unsigned dst_height,unsigned format,unsigned dest_bpp,
340 unsigned vid_w,unsigned vid_h)
342 void *tmp, *tmpa;
343 size_t i;
344 int err;
345 uint32_t sstride,apitch;
346 if( mp_msg_test(MSGT_VO,MSGL_DBG2) )
347 mp_msg(MSGT_VO,MSGL_DBG2, "vosub_vidix: vidix_init() was called\n"
348 "src_w=%u src_h=%u dest_x_y_w_h = %u %u %u %u\n"
349 "format=%s dest_bpp=%u vid_w=%u vid_h=%u\n"
350 ,src_width,src_height,x_org,y_org,dst_width,dst_height
351 ,vo_format_name(format),dest_bpp,vid_w,vid_h);
353 if(vidix_query_fourcc(format) == 0)
355 mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SUB_VIDIX_UnsupportedFourccForThisVidixDriver,
356 format,vo_format_name(format));
357 return -1;
360 if(((vidix_cap.maxwidth != -1) && (vid_w > vidix_cap.maxwidth)) ||
361 ((vidix_cap.minwidth != -1) && (vid_w < vidix_cap.minwidth)) ||
362 ((vidix_cap.maxheight != -1) && (vid_h > vidix_cap.maxheight)) ||
363 ((vidix_cap.minwidth != -1 ) && (vid_h < vidix_cap.minheight)))
365 mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SUB_VIDIX_VideoServerHasUnsupportedResolution,
366 vid_w, vid_h, vidix_cap.minwidth, vidix_cap.minheight,
367 vidix_cap.maxwidth, vidix_cap.maxheight);
368 return -1;
371 err = 0;
372 switch(dest_bpp)
374 case 1: err = ((vidix_fourcc.depth & VID_DEPTH_1BPP) != VID_DEPTH_1BPP); break;
375 case 2: err = ((vidix_fourcc.depth & VID_DEPTH_2BPP) != VID_DEPTH_2BPP); break;
376 case 4: err = ((vidix_fourcc.depth & VID_DEPTH_4BPP) != VID_DEPTH_4BPP); break;
377 case 8: err = ((vidix_fourcc.depth & VID_DEPTH_8BPP) != VID_DEPTH_8BPP); break;
378 case 12:err = ((vidix_fourcc.depth & VID_DEPTH_12BPP) != VID_DEPTH_12BPP); break;
379 case 15:err = ((vidix_fourcc.depth & VID_DEPTH_15BPP) != VID_DEPTH_15BPP); break;
380 case 16:err = ((vidix_fourcc.depth & VID_DEPTH_16BPP) != VID_DEPTH_16BPP); break;
381 case 24:err = ((vidix_fourcc.depth & VID_DEPTH_24BPP) != VID_DEPTH_24BPP); break;
382 case 32:err = ((vidix_fourcc.depth & VID_DEPTH_32BPP) != VID_DEPTH_32BPP); break;
383 default: err=1; break;
385 if(err)
387 mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SUB_VIDIX_VideoServerHasUnsupportedColorDepth
388 ,vidix_fourcc.depth);
389 return -1;
391 if((dst_width > src_width || dst_height > src_height) && (vidix_cap.flags & FLAG_UPSCALER) != FLAG_UPSCALER)
393 mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SUB_VIDIX_DriverCantUpscaleImage,
394 src_width, src_height, dst_width, dst_height);
395 return -1;
397 if((dst_width > src_width || dst_height > src_height) && (vidix_cap.flags & FLAG_DOWNSCALER) != FLAG_DOWNSCALER)
399 mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SUB_VIDIX_DriverCantDownscaleImage,
400 src_width, src_height, dst_width, dst_height);
401 return -1;
403 image_width = src_width;
404 image_height = src_height;
405 src_format = format;
406 if(forced_fourcc) format = forced_fourcc;
407 memset(&vidix_play,0,sizeof(vidix_playback_t));
408 vidix_play.fourcc = format;
409 vidix_play.capability = vidix_cap.flags; /* every ;) */
410 vidix_play.blend_factor = 0; /* for now */
411 /* display the full picture.
412 Nick: we could implement here zooming to a specified area -- alex */
413 vidix_play.src.x = vidix_play.src.y = 0;
414 vidix_play.src.w = src_width;
415 vidix_play.src.h = src_height;
416 vidix_play.dest.x = x_org;
417 vidix_play.dest.y = y_org;
418 vidix_play.dest.w = dst_width;
419 vidix_play.dest.h = dst_height;
420 // vidix_play.num_frames=vo_doublebuffering?NUM_FRAMES-1:1;
421 /* we aren't mad...3 buffers are more than enough */
422 vidix_play.num_frames=vo_doublebuffering?3:1;
423 vidix_play.src.pitch.y = vidix_play.src.pitch.u = vidix_play.src.pitch.v = 0;
425 if((err=vdlConfigPlayback(vidix_handler,&vidix_play))!=0)
427 mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SUB_VIDIX_CantConfigurePlayback,strerror(err));
428 return -1;
430 if ( mp_msg_test(MSGT_VO,MSGL_V) ) {
431 mp_msg(MSGT_VO,MSGL_V, "vosub_vidix: using %d buffer(s)\n", vidix_play.num_frames); }
433 vidix_mem = vidix_play.dga_addr;
435 tmp = calloc(image_width, image_height);
436 tmpa = malloc(image_width * image_height);
437 memset(tmpa, 1, image_width * image_height);
438 /* clear every frame with correct address and frame_size */
439 /* HACK: use draw_alpha to clear Y component */
440 for (i = 0; i < vidix_play.num_frames; i++) {
441 next_frame = i;
442 memset(vidix_mem + vidix_play.offsets[i], 0x80,
443 vidix_play.frame_size);
444 draw_alpha(0, 0, image_width, image_height, tmp, tmpa, image_width);
446 free(tmp);
447 free(tmpa);
448 /* show one of the "clear" frames */
449 vidix_flip_page();
451 switch(format)
453 case IMGFMT_YV12:
454 case IMGFMT_I420:
455 case IMGFMT_IYUV:
456 case IMGFMT_YVU9:
457 case IMGFMT_IF09:
458 case IMGFMT_Y800:
459 case IMGFMT_Y8:
460 apitch = vidix_play.dest.pitch.y-1;
461 dstrides.y = (image_width + apitch) & ~apitch;
462 apitch = vidix_play.dest.pitch.v-1;
463 dstrides.v = (image_width + apitch) & ~apitch;
464 apitch = vidix_play.dest.pitch.u-1;
465 dstrides.u = (image_width + apitch) & ~apitch;
466 image_Bpp=1;
467 break;
468 case IMGFMT_RGB32:
469 case IMGFMT_BGR32:
470 apitch = vidix_play.dest.pitch.y-1;
471 dstrides.y = (image_width*4 + apitch) & ~apitch;
472 dstrides.u = dstrides.v = 0;
473 image_Bpp=4;
474 break;
475 case IMGFMT_RGB24:
476 case IMGFMT_BGR24:
477 apitch = vidix_play.dest.pitch.y-1;
478 dstrides.y = (image_width*3 + apitch) & ~apitch;
479 dstrides.u = dstrides.v = 0;
480 image_Bpp=3;
481 break;
482 default:
483 apitch = vidix_play.dest.pitch.y-1;
484 dstrides.y = (image_width*2 + apitch) & ~apitch;
485 dstrides.u = dstrides.v = 0;
486 image_Bpp=2;
487 break;
489 /* tune some info here */
490 sstride = src_width*image_Bpp;
491 if(!forced_fourcc)
493 is_422_planes_eq = sstride == dstrides.y;
495 if(src_format == IMGFMT_YV12 || src_format == IMGFMT_I420 || src_format == IMGFMT_IYUV)
496 vo_server->draw_slice = vidix_draw_slice_420;
497 else if (src_format == IMGFMT_YVU9 || src_format == IMGFMT_IF09)
498 vo_server->draw_slice = vidix_draw_slice_410;
499 else vo_server->draw_slice = vidix_draw_slice_packed;
501 return 0;
504 static uint32_t vidix_get_image(mp_image_t *mpi)
506 if(mpi->type==MP_IMGTYPE_STATIC && vidix_play.num_frames>1) return VO_FALSE;
507 if(mpi->flags&MP_IMGFLAG_READABLE) return VO_FALSE; /* slow video ram */
508 if(( (mpi->stride[0]==dstrides.y && (!(mpi->flags&MP_IMGFLAG_PLANAR) ||
509 (mpi->stride[1]==dstrides.u && mpi->stride[2]==dstrides.v)) )
510 || (mpi->flags&(MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_ACCEPT_WIDTH))) &&
511 (!forced_fourcc && !(vidix_play.flags & VID_PLAY_INTERLEAVED_UV)))
513 if(mpi->flags&MP_IMGFLAG_ACCEPT_WIDTH){
514 // check if only width is enough to represent strides:
515 if(mpi->flags&MP_IMGFLAG_PLANAR){
516 if((dstrides.y>>1)!=dstrides.v || dstrides.v!=dstrides.u) return VO_FALSE;
517 } else {
518 if(dstrides.y % (mpi->bpp/8)) return VO_FALSE;
521 mpi->planes[0]=vidix_mem+vidix_play.offsets[next_frame]+vidix_play.offset.y;
522 mpi->width=mpi->stride[0]=dstrides.y;
523 if(mpi->flags&MP_IMGFLAG_PLANAR)
525 mpi->planes[1]=vidix_mem+vidix_play.offsets[next_frame]+vidix_play.offset.v;
526 mpi->stride[1]=dstrides.v >> mpi->chroma_x_shift;
527 mpi->planes[2]=vidix_mem+vidix_play.offsets[next_frame]+vidix_play.offset.u;
528 mpi->stride[2]=dstrides.u >> mpi->chroma_x_shift;
529 } else
530 mpi->width/=mpi->bpp/8;
531 mpi->flags|=MP_IMGFLAG_DIRECT;
532 return VO_TRUE;
534 return VO_FALSE;
537 uint32_t vidix_control(uint32_t request, void *data)
539 switch (request) {
540 case VOCTRL_QUERY_FORMAT:
541 return vidix_query_fourcc(*((uint32_t*)data));
542 case VOCTRL_GET_IMAGE:
543 return vidix_get_image(data);
544 case VOCTRL_DRAW_IMAGE:
545 return vidix_draw_image(data);
546 case VOCTRL_GET_FRAME_NUM:
547 *(uint32_t *)data = next_frame;
548 return VO_TRUE;
549 case VOCTRL_SET_FRAME_NUM:
550 next_frame = *(uint32_t *)data;
551 return VO_TRUE;
552 case VOCTRL_GET_NUM_FRAMES:
553 *(uint32_t *)data = vidix_play.num_frames;
554 return VO_TRUE;
555 case VOCTRL_SET_EQUALIZER:
557 vidix_video_eq_t info;
559 if(!video_on) return VO_FALSE;
561 struct voctrl_set_equalizer_args *args = data;
563 /* vidix eq ranges are -1000..1000 */
564 if (!strcasecmp(args->name, "brightness"))
566 info.brightness = args->value*10;
567 info.cap = VEQ_CAP_BRIGHTNESS;
569 else if (!strcasecmp(args->name, "contrast"))
571 info.contrast = args->value*10;
572 info.cap = VEQ_CAP_CONTRAST;
574 else if (!strcasecmp(args->name, "saturation"))
576 info.saturation = args->value*10;
577 info.cap = VEQ_CAP_SATURATION;
579 else if (!strcasecmp(args->name, "hue"))
581 info.hue = args->value*10;
582 info.cap = VEQ_CAP_HUE;
585 if (vdlPlaybackSetEq(vidix_handler, &info) == 0)
586 return VO_TRUE;
587 return VO_FALSE;
589 case VOCTRL_GET_EQUALIZER:
591 vidix_video_eq_t info;
593 if(!video_on) return VO_FALSE;
594 if (vdlPlaybackGetEq(vidix_handler, &info) != 0)
595 return VO_FALSE;
597 struct voctrl_get_equalizer_args *args = data;
599 /* vidix eq ranges are -1000..1000 */
600 if (!strcasecmp(args->name, "brightness"))
602 if (info.cap & VEQ_CAP_BRIGHTNESS)
603 *args->valueptr = info.brightness/10;
605 else if (!strcasecmp(args->name, "contrast"))
607 if (info.cap & VEQ_CAP_CONTRAST)
608 *args->valueptr = info.contrast/10;
610 else if (!strcasecmp(args->name, "saturation"))
612 if (info.cap & VEQ_CAP_SATURATION)
613 *args->valueptr = info.saturation/10;
615 else if (!strcasecmp(args->name, "hue"))
617 if (info.cap & VEQ_CAP_HUE)
618 *args->valueptr = info.hue/10;
621 return VO_TRUE;
624 return VO_NOTIMPL;
625 // WARNING: we drop extra parameters (...) here!
626 // return server_control(request,data); //VO_NOTIMPL;
629 int vidix_preinit(const char *drvname, struct vo_old_functions *server)
631 int err;
632 if( mp_msg_test(MSGT_VO,MSGL_DBG2) ) {
633 mp_msg(MSGT_VO,MSGL_DBG2, "vosub_vidix: vidix_preinit(%s) was called\n",drvname); }
634 if(vdlGetVersion() != VIDIX_VERSION)
636 mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SUB_VIDIX_YouHaveWrongVersionOfVidixLibrary);
637 return -1;
639 #ifndef __MINGW32__
640 vidix_handler = vdlOpen(MP_VIDIX_PFX,
641 drvname ? drvname[0] == ':' ? &drvname[1] : drvname[0] ? drvname : NULL : NULL,
642 TYPE_OUTPUT,
643 verbose);
644 #else
645 vidix_handler = vdlOpen(get_path("vidix/"),
646 drvname ? drvname[0] == ':' ? &drvname[1] : drvname[0] ? drvname : NULL : NULL,
647 TYPE_OUTPUT,
648 verbose);
649 #endif
651 if(vidix_handler == NULL)
653 mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SUB_VIDIX_CouldntFindWorkingVidixDriver);
654 return -1;
656 if((err=vdlGetCapability(vidix_handler,&vidix_cap)) != 0)
658 mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SUB_VIDIX_CouldntGetCapability,strerror(err));
659 return -1;
661 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SUB_VIDIX_Description, vidix_cap.name);
662 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SUB_VIDIX_Author, vidix_cap.author);
663 /* we are able to tune up this stuff depend on fourcc format */
664 server->draw_slice=vidix_draw_slice;
665 server->draw_frame=vidix_draw_frame;
666 server->flip_page=vidix_flip_page;
667 server->draw_osd=vidix_draw_osd;
668 // server_control = server->control;
669 // server->control=vidix_control;
670 vo_server = server;
671 return 0;