Merge svn changes up to r28461
[mplayer.git] / libvo / vosub_vidix.c
blob1c52c3109491fb5d513c53f5951d6007be3418fb
1 /*
2 * vidix interface to any mplayer vo driver
3 * (partly based on vesa_lvo.c)
5 * copyright (C) 2002 Nick Kurshev <nickols_k@mail.ru>
6 * copyright (C) Alex Beregszaszi
8 * This file is part of MPlayer.
10 * MPlayer is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * MPlayer is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #include <inttypes.h>
26 #include <unistd.h>
27 #include <fcntl.h>
28 #ifndef __MINGW32__
29 #include <sys/ioctl.h>
30 #include <sys/mman.h>
31 #endif
32 #include <stdio.h>
33 #include <stdlib.h>
34 #include <string.h>
35 #include <errno.h>
37 #include "config.h"
38 #include "mp_msg.h"
39 #include "help_mp.h"
41 #include "vidix/vidix.h"
42 #include "fastmemcpy.h"
43 #include "osd.h"
44 #include "video_out.h"
45 #include "sub.h"
46 #include "vosub_vidix.h"
47 #include "old_vo_wrapper.h"
49 #include "libmpcodecs/vfcap.h"
50 #include "libmpcodecs/mp_image.h"
52 #define NUM_FRAMES VID_PLAY_MAXFRAMES /* Temporary: driver will overwrite it */
54 static VDXContext *vidix_handler = NULL;
55 static uint8_t *vidix_mem = NULL;
56 static uint8_t next_frame;
57 static unsigned image_Bpp,image_height,image_width,src_format,forced_fourcc=0;
58 static int video_on=0;
60 static vidix_capability_t vidix_cap;
61 static vidix_playback_t vidix_play;
62 static vidix_fourcc_t vidix_fourcc;
63 static struct vo_old_functions *vo_server;
64 static vidix_yuv_t dstrides;
65 /*static uint32_t (*server_control)(uint32_t request, void *data, ...);*/
67 int vidix_start(void)
69 int err;
70 if((err=vdlPlaybackOn(vidix_handler))!=0)
72 mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SUB_VIDIX_CantStartPlayback,strerror(err));
73 return -1;
75 video_on=1;
76 return 0;
79 int vidix_stop(void)
81 int err;
82 if((err=vdlPlaybackOff(vidix_handler))!=0)
84 mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SUB_VIDIX_CantStopPlayback,strerror(err));
85 return -1;
87 video_on=0;
88 return 0;
91 void vidix_term( void )
93 if( mp_msg_test(MSGT_VO,MSGL_DBG2) ) {
94 mp_msg(MSGT_VO,MSGL_DBG2, "vosub_vidix: vidix_term() was called\n"); }
95 vidix_stop();
96 vdlClose(vidix_handler);
97 // vo_server->control=server_control;
100 static int vidix_draw_slice_420(uint8_t *image[], int stride[], int w,int h,int x,int y)
102 uint8_t *src;
103 uint8_t *dest;
104 int i;
106 /* Plane Y */
107 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y;
108 dest += dstrides.y*y + x;
109 src = image[0];
110 for(i=0;i<h;i++){
111 memcpy(dest,src,w);
112 src+=stride[0];
113 dest += dstrides.y;
116 if (vidix_play.flags & VID_PLAY_INTERLEAVED_UV)
118 int hi,wi;
119 uint8_t *src2;
120 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.v;
121 dest += dstrides.y*y/2 + x; // <- is this correct ?
122 h/=2;
123 w/=2;
124 src = image[1];
125 src2 = image[2];
126 for(hi = 0; hi < h; hi++)
128 for(wi = 0; wi < w; wi++)
130 dest[2*wi+0] = src[wi];
131 dest[2*wi+1] = src2[wi];
133 dest += dstrides.y;
134 src += stride[1];
135 src2+= stride[2];
138 else
140 /* Plane V */
141 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.v;
142 dest += dstrides.v*y/4 + x;
143 src = image[1];
144 for(i=0;i<h/2;i++){
145 memcpy(dest,src,w/2);
146 src+=stride[1];
147 dest+=dstrides.v/2;
150 /* Plane U */
151 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.u;
152 dest += dstrides.u*y/4 + x;
153 src = image[2];
154 for(i=0;i<h/2;i++){
155 memcpy(dest,src,w/2);
156 src+=stride[2];
157 dest += dstrides.u/2;
159 return 0;
161 return -1;
164 static int vidix_draw_slice_410(uint8_t *image[], int stride[], int w,int h,int x,int y)
166 uint8_t *src;
167 uint8_t *dest;
168 int i;
170 /* Plane Y */
171 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y;
172 dest += dstrides.y*y + x;
173 src = image[0];
174 for(i=0;i<h;i++){
175 memcpy(dest,src,w);
176 src+=stride[0];
177 dest += dstrides.y;
180 if (vidix_play.flags & VID_PLAY_INTERLEAVED_UV)
182 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_SUB_VIDIX_InterleavedUvForYuv410pNotSupported);
184 else
186 /* Plane V */
187 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.v;
188 dest += dstrides.v*y/8 + x;
189 src = image[1];
190 for(i=0;i<h/4;i++){
191 memcpy(dest,src,w/4);
192 src+=stride[1];
193 dest+=dstrides.v/4;
196 /* Plane U */
197 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.u;
198 dest += dstrides.u*y/8 + x;
199 src = image[2];
200 for(i=0;i<h/4;i++){
201 memcpy(dest,src,w/4);
202 src+=stride[2];
203 dest += dstrides.u/4;
205 return 0;
207 return -1;
210 static int vidix_draw_slice_packed(uint8_t *image[], int stride[], int w,int h,int x,int y)
212 uint8_t *src;
213 uint8_t *dest;
214 int i;
216 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y;
217 dest += dstrides.y*y + x;
218 src = image[0];
219 for(i=0;i<h;i++){
220 memcpy(dest,src,w*image_Bpp);
221 src+=stride[0];
222 dest += dstrides.y;
224 return 0;
227 static int vidix_draw_slice_nv12(uint8_t *image[], int stride[], int w,int h,int x,int y)
229 uint8_t *src;
230 uint8_t *dest;
231 int i;
233 /* Plane Y */
234 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y;
235 dest += dstrides.y*y + x;
236 src = image[0];
237 for(i=0;i<h;i++){
238 memcpy(dest,src,w);
239 src+=stride[0];
240 dest += dstrides.y;
243 /* Plane UV */
244 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.u;
245 dest += dstrides.u*y/2 + x;
246 src = image[1];
247 for(i=0;i<h/2;i++){
248 memcpy(dest,src,w);
249 src+=stride[1];
250 dest+=dstrides.u;
252 return 0;
255 static int vidix_draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y)
257 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_SUB_VIDIX_DummyVidixdrawsliceWasCalled);
258 return -1;
261 static uint32_t vidix_draw_image(mp_image_t *mpi){
262 if( mp_msg_test(MSGT_VO,MSGL_DBG2) ) {
263 mp_msg(MSGT_VO,MSGL_DBG2, "vosub_vidix: vidix_draw_image() was called\n"); }
265 // if -dr or -slices then do nothing:
266 if(mpi->flags&(MP_IMGFLAG_DIRECT|MP_IMGFLAG_DRAW_CALLBACK)) return VO_TRUE;
268 vo_server->draw_slice(mpi->planes,mpi->stride,
269 vidix_play.src.w,vidix_play.src.h,vidix_play.src.x,vidix_play.src.y);
270 return VO_TRUE;
273 static int vidix_draw_frame(uint8_t *image[])
275 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_SUB_VIDIX_DummyVidixdrawframeWasCalled);
276 return -1;
279 static void vidix_flip_page(void)
281 if( mp_msg_test(MSGT_VO,MSGL_DBG2) ) {
282 mp_msg(MSGT_VO,MSGL_DBG2, "vosub_vidix: vidix_flip_page() was called\n"); }
283 if(vo_doublebuffering)
285 vdlPlaybackFrameSelect(vidix_handler,next_frame);
286 next_frame=(next_frame+1)%vidix_play.num_frames;
290 static void draw_alpha(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)
292 uint32_t apitch,bespitch;
293 char *lvo_mem;
294 lvo_mem = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y;
295 apitch = vidix_play.dest.pitch.y-1;
296 switch(vidix_play.fourcc){
297 case IMGFMT_NV12:
298 case IMGFMT_YV12:
299 case IMGFMT_IYUV:
300 case IMGFMT_I420:
301 case IMGFMT_YVU9:
302 case IMGFMT_IF09:
303 case IMGFMT_Y8:
304 case IMGFMT_Y800:
305 bespitch = (vidix_play.src.w + apitch) & (~apitch);
306 vo_draw_alpha_yv12(w,h,src,srca,stride,lvo_mem+bespitch*y0+x0,bespitch);
307 break;
308 case IMGFMT_YUY2:
309 bespitch = (vidix_play.src.w*2 + apitch) & (~apitch);
310 vo_draw_alpha_yuy2(w,h,src,srca,stride,lvo_mem+bespitch*y0+2*x0,bespitch);
311 break;
312 case IMGFMT_UYVY:
313 bespitch = (vidix_play.src.w*2 + apitch) & (~apitch);
314 vo_draw_alpha_yuy2(w,h,src,srca,stride,lvo_mem+bespitch*y0+2*x0+1,bespitch);
315 break;
316 case IMGFMT_RGB32:
317 case IMGFMT_BGR32:
318 bespitch = (vidix_play.src.w*4 + apitch) & (~apitch);
319 vo_draw_alpha_rgb32(w,h,src,srca,stride,lvo_mem+y0*bespitch+4*x0,bespitch);
320 break;
321 case IMGFMT_RGB24:
322 case IMGFMT_BGR24:
323 bespitch = (vidix_play.src.w*3 + apitch) & (~apitch);
324 vo_draw_alpha_rgb24(w,h,src,srca,stride,lvo_mem+y0*bespitch+3*x0,bespitch);
325 break;
326 case IMGFMT_RGB16:
327 case IMGFMT_BGR16:
328 bespitch = (vidix_play.src.w*2 + apitch) & (~apitch);
329 vo_draw_alpha_rgb16(w,h,src,srca,stride,lvo_mem+y0*bespitch+2*x0,bespitch);
330 break;
331 case IMGFMT_RGB15:
332 case IMGFMT_BGR15:
333 bespitch = (vidix_play.src.w*2 + apitch) & (~apitch);
334 vo_draw_alpha_rgb15(w,h,src,srca,stride,lvo_mem+y0*bespitch+2*x0,bespitch);
335 break;
336 default:
337 return;
341 static void vidix_draw_osd(void)
343 if( mp_msg_test(MSGT_VO,MSGL_DBG2) ) {
344 mp_msg(MSGT_VO,MSGL_DBG2, "vosub_vidix: vidix_draw_osd() was called\n"); }
345 /* TODO: hw support */
346 vo_draw_text(vidix_play.src.w,vidix_play.src.h,draw_alpha);
349 uint32_t vidix_query_fourcc(uint32_t format)
351 if( mp_msg_test(MSGT_VO,MSGL_DBG2) ) {
352 mp_msg(MSGT_VO,MSGL_DBG2, "vosub_vidix: query_format was called: %x (%s)\n",format,vo_format_name(format)); }
353 vidix_fourcc.fourcc = format;
354 vdlQueryFourcc(vidix_handler,&vidix_fourcc);
355 if (vidix_fourcc.depth == VID_DEPTH_NONE)
356 return 0;
357 return VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_HWSCALE_UP|VFCAP_HWSCALE_DOWN|VFCAP_OSD|VFCAP_ACCEPT_STRIDE;
360 int vidix_grkey_support(void)
362 return vidix_fourcc.flags & VID_CAP_COLORKEY;
365 int vidix_grkey_get(vidix_grkey_t *gr_key)
367 return vdlGetGrKeys(vidix_handler, gr_key);
370 int vidix_grkey_set(const vidix_grkey_t *gr_key)
372 return vdlSetGrKeys(vidix_handler, gr_key);
376 static int is_422_planes_eq=0;
377 int vidix_init(unsigned src_width,unsigned src_height,
378 unsigned x_org,unsigned y_org,unsigned dst_width,
379 unsigned dst_height,unsigned format,unsigned dest_bpp,
380 unsigned vid_w,unsigned vid_h)
382 void *tmp, *tmpa;
383 size_t i;
384 int err;
385 uint32_t sstride,apitch;
386 if( mp_msg_test(MSGT_VO,MSGL_DBG2) )
387 mp_msg(MSGT_VO,MSGL_DBG2, "vosub_vidix: vidix_init() was called\n"
388 "src_w=%u src_h=%u dest_x_y_w_h = %u %u %u %u\n"
389 "format=%s dest_bpp=%u vid_w=%u vid_h=%u\n"
390 ,src_width,src_height,x_org,y_org,dst_width,dst_height
391 ,vo_format_name(format),dest_bpp,vid_w,vid_h);
393 if(vidix_query_fourcc(format) == 0)
395 mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SUB_VIDIX_UnsupportedFourccForThisVidixDriver,
396 format,vo_format_name(format));
397 return -1;
400 if(((vidix_cap.maxwidth != -1) && (vid_w > vidix_cap.maxwidth)) ||
401 ((vidix_cap.minwidth != -1) && (vid_w < vidix_cap.minwidth)) ||
402 ((vidix_cap.maxheight != -1) && (vid_h > vidix_cap.maxheight)) ||
403 ((vidix_cap.minwidth != -1 ) && (vid_h < vidix_cap.minheight)))
405 mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SUB_VIDIX_VideoServerHasUnsupportedResolution,
406 vid_w, vid_h, vidix_cap.minwidth, vidix_cap.minheight,
407 vidix_cap.maxwidth, vidix_cap.maxheight);
408 return -1;
411 err = 0;
412 switch(dest_bpp)
414 case 1: err = ((vidix_fourcc.depth & VID_DEPTH_1BPP) != VID_DEPTH_1BPP); break;
415 case 2: err = ((vidix_fourcc.depth & VID_DEPTH_2BPP) != VID_DEPTH_2BPP); break;
416 case 4: err = ((vidix_fourcc.depth & VID_DEPTH_4BPP) != VID_DEPTH_4BPP); break;
417 case 8: err = ((vidix_fourcc.depth & VID_DEPTH_8BPP) != VID_DEPTH_8BPP); break;
418 case 12:err = ((vidix_fourcc.depth & VID_DEPTH_12BPP) != VID_DEPTH_12BPP); break;
419 case 15:err = ((vidix_fourcc.depth & VID_DEPTH_15BPP) != VID_DEPTH_15BPP); break;
420 case 16:err = ((vidix_fourcc.depth & VID_DEPTH_16BPP) != VID_DEPTH_16BPP); break;
421 case 24:err = ((vidix_fourcc.depth & VID_DEPTH_24BPP) != VID_DEPTH_24BPP); break;
422 case 32:err = ((vidix_fourcc.depth & VID_DEPTH_32BPP) != VID_DEPTH_32BPP); break;
423 default: err=1; break;
425 if(err)
427 mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SUB_VIDIX_VideoServerHasUnsupportedColorDepth
428 ,vidix_fourcc.depth);
429 return -1;
431 if((dst_width > src_width || dst_height > src_height) && (vidix_cap.flags & FLAG_UPSCALER) != FLAG_UPSCALER)
433 mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SUB_VIDIX_DriverCantUpscaleImage,
434 src_width, src_height, dst_width, dst_height);
435 return -1;
437 if((dst_width > src_width || dst_height > src_height) && (vidix_cap.flags & FLAG_DOWNSCALER) != FLAG_DOWNSCALER)
439 mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SUB_VIDIX_DriverCantDownscaleImage,
440 src_width, src_height, dst_width, dst_height);
441 return -1;
443 image_width = src_width;
444 image_height = src_height;
445 src_format = format;
446 if(forced_fourcc) format = forced_fourcc;
447 memset(&vidix_play,0,sizeof(vidix_playback_t));
448 vidix_play.fourcc = format;
449 vidix_play.capability = vidix_cap.flags; /* every ;) */
450 vidix_play.blend_factor = 0; /* for now */
451 /* display the full picture.
452 Nick: we could implement here zooming to a specified area -- alex */
453 vidix_play.src.x = vidix_play.src.y = 0;
454 vidix_play.src.w = src_width;
455 vidix_play.src.h = src_height;
456 vidix_play.dest.x = x_org;
457 vidix_play.dest.y = y_org;
458 vidix_play.dest.w = dst_width;
459 vidix_play.dest.h = dst_height;
460 // vidix_play.num_frames=vo_doublebuffering?NUM_FRAMES-1:1;
461 /* we aren't mad...3 buffers are more than enough */
462 vidix_play.num_frames=vo_doublebuffering?3:1;
463 vidix_play.src.pitch.y = vidix_play.src.pitch.u = vidix_play.src.pitch.v = 0;
465 if((err=vdlConfigPlayback(vidix_handler,&vidix_play))!=0)
467 mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SUB_VIDIX_CantConfigurePlayback,strerror(err));
468 return -1;
470 if ( mp_msg_test(MSGT_VO,MSGL_V) ) {
471 mp_msg(MSGT_VO,MSGL_V, "vosub_vidix: using %d buffer(s)\n", vidix_play.num_frames); }
473 vidix_mem = vidix_play.dga_addr;
475 tmp = calloc(image_width, image_height);
476 tmpa = malloc(image_width * image_height);
477 memset(tmpa, 1, image_width * image_height);
478 /* clear every frame with correct address and frame_size */
479 /* HACK: use draw_alpha to clear Y component */
480 for (i = 0; i < vidix_play.num_frames; i++) {
481 next_frame = i;
482 memset(vidix_mem + vidix_play.offsets[i], 0x80,
483 vidix_play.frame_size);
484 draw_alpha(0, 0, image_width, image_height, tmp, tmpa, image_width);
486 free(tmp);
487 free(tmpa);
488 /* show one of the "clear" frames */
489 vidix_flip_page();
491 switch(format)
493 case IMGFMT_NV12:
494 case IMGFMT_YV12:
495 case IMGFMT_I420:
496 case IMGFMT_IYUV:
497 case IMGFMT_YVU9:
498 case IMGFMT_IF09:
499 case IMGFMT_Y800:
500 case IMGFMT_Y8:
501 apitch = vidix_play.dest.pitch.y-1;
502 dstrides.y = (image_width + apitch) & ~apitch;
503 apitch = vidix_play.dest.pitch.v-1;
504 dstrides.v = (image_width + apitch) & ~apitch;
505 apitch = vidix_play.dest.pitch.u-1;
506 dstrides.u = (image_width + apitch) & ~apitch;
507 image_Bpp=1;
508 break;
509 case IMGFMT_RGB32:
510 case IMGFMT_BGR32:
511 apitch = vidix_play.dest.pitch.y-1;
512 dstrides.y = (image_width*4 + apitch) & ~apitch;
513 dstrides.u = dstrides.v = 0;
514 image_Bpp=4;
515 break;
516 case IMGFMT_RGB24:
517 case IMGFMT_BGR24:
518 apitch = vidix_play.dest.pitch.y-1;
519 dstrides.y = (image_width*3 + apitch) & ~apitch;
520 dstrides.u = dstrides.v = 0;
521 image_Bpp=3;
522 break;
523 default:
524 apitch = vidix_play.dest.pitch.y-1;
525 dstrides.y = (image_width*2 + apitch) & ~apitch;
526 dstrides.u = dstrides.v = 0;
527 image_Bpp=2;
528 break;
530 /* tune some info here */
531 sstride = src_width*image_Bpp;
532 if(!forced_fourcc)
534 is_422_planes_eq = sstride == dstrides.y;
536 if(src_format == IMGFMT_YV12 || src_format == IMGFMT_I420 || src_format == IMGFMT_IYUV)
537 vo_server->draw_slice = vidix_draw_slice_420;
538 else if (src_format == IMGFMT_YVU9 || src_format == IMGFMT_IF09)
539 vo_server->draw_slice = vidix_draw_slice_410;
540 else if (src_format == IMGFMT_NV12)
541 vo_server->draw_slice = vidix_draw_slice_nv12;
542 else vo_server->draw_slice = vidix_draw_slice_packed;
544 return 0;
547 static uint32_t vidix_get_image(mp_image_t *mpi)
549 if(mpi->type==MP_IMGTYPE_STATIC && vidix_play.num_frames>1) return VO_FALSE;
550 if(mpi->flags&MP_IMGFLAG_READABLE) return VO_FALSE; /* slow video ram */
551 if(( (mpi->stride[0]==dstrides.y && (!(mpi->flags&MP_IMGFLAG_PLANAR) ||
552 (mpi->stride[1]==dstrides.u && mpi->stride[2]==dstrides.v)) )
553 || (mpi->flags&(MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_ACCEPT_WIDTH))) &&
554 (!forced_fourcc && !(vidix_play.flags & VID_PLAY_INTERLEAVED_UV)))
556 if(mpi->flags&MP_IMGFLAG_ACCEPT_WIDTH){
557 // check if only width is enough to represent strides:
558 if(mpi->flags&MP_IMGFLAG_PLANAR){
559 if((dstrides.y>>1)!=dstrides.v || dstrides.v!=dstrides.u) return VO_FALSE;
560 } else {
561 if(dstrides.y % (mpi->bpp/8)) return VO_FALSE;
564 mpi->planes[0]=vidix_mem+vidix_play.offsets[next_frame]+vidix_play.offset.y;
565 mpi->width=mpi->stride[0]=dstrides.y;
566 if(mpi->flags&MP_IMGFLAG_PLANAR)
568 mpi->planes[1]=vidix_mem+vidix_play.offsets[next_frame]+vidix_play.offset.v;
569 mpi->stride[1]=dstrides.v >> mpi->chroma_x_shift;
570 mpi->planes[2]=vidix_mem+vidix_play.offsets[next_frame]+vidix_play.offset.u;
571 mpi->stride[2]=dstrides.u >> mpi->chroma_x_shift;
572 } else
573 mpi->width/=mpi->bpp/8;
574 mpi->flags|=MP_IMGFLAG_DIRECT;
575 return VO_TRUE;
577 return VO_FALSE;
580 uint32_t vidix_control(uint32_t request, void *data)
582 switch (request) {
583 case VOCTRL_QUERY_FORMAT:
584 return vidix_query_fourcc(*((uint32_t*)data));
585 case VOCTRL_GET_IMAGE:
586 return vidix_get_image(data);
587 case VOCTRL_DRAW_IMAGE:
588 return vidix_draw_image(data);
589 case VOCTRL_GET_FRAME_NUM:
590 *(uint32_t *)data = next_frame;
591 return VO_TRUE;
592 case VOCTRL_SET_FRAME_NUM:
593 next_frame = *(uint32_t *)data;
594 return VO_TRUE;
595 case VOCTRL_GET_NUM_FRAMES:
596 *(uint32_t *)data = vidix_play.num_frames;
597 return VO_TRUE;
598 case VOCTRL_SET_EQUALIZER:
600 vidix_video_eq_t info;
602 if(!video_on) return VO_FALSE;
604 struct voctrl_set_equalizer_args *args = data;
606 /* vidix eq ranges are -1000..1000 */
607 if (!strcasecmp(args->name, "brightness"))
609 info.brightness = args->value*10;
610 info.cap = VEQ_CAP_BRIGHTNESS;
612 else if (!strcasecmp(args->name, "contrast"))
614 info.contrast = args->value*10;
615 info.cap = VEQ_CAP_CONTRAST;
617 else if (!strcasecmp(args->name, "saturation"))
619 info.saturation = args->value*10;
620 info.cap = VEQ_CAP_SATURATION;
622 else if (!strcasecmp(args->name, "hue"))
624 info.hue = args->value*10;
625 info.cap = VEQ_CAP_HUE;
628 if (vdlPlaybackSetEq(vidix_handler, &info) == 0)
629 return VO_TRUE;
630 return VO_FALSE;
632 case VOCTRL_GET_EQUALIZER:
634 vidix_video_eq_t info;
636 if(!video_on) return VO_FALSE;
637 if (vdlPlaybackGetEq(vidix_handler, &info) != 0)
638 return VO_FALSE;
640 struct voctrl_get_equalizer_args *args = data;
642 /* vidix eq ranges are -1000..1000 */
643 if (!strcasecmp(args->name, "brightness"))
645 if (info.cap & VEQ_CAP_BRIGHTNESS)
646 *args->valueptr = info.brightness/10;
648 else if (!strcasecmp(args->name, "contrast"))
650 if (info.cap & VEQ_CAP_CONTRAST)
651 *args->valueptr = info.contrast/10;
653 else if (!strcasecmp(args->name, "saturation"))
655 if (info.cap & VEQ_CAP_SATURATION)
656 *args->valueptr = info.saturation/10;
658 else if (!strcasecmp(args->name, "hue"))
660 if (info.cap & VEQ_CAP_HUE)
661 *args->valueptr = info.hue/10;
664 return VO_TRUE;
667 return VO_NOTIMPL;
668 // WARNING: we drop extra parameters (...) here!
669 // return server_control(request,data); //VO_NOTIMPL;
672 int vidix_preinit(const char *drvname, struct vo_old_functions *server)
674 int err;
675 if( mp_msg_test(MSGT_VO,MSGL_DBG2) ) {
676 mp_msg(MSGT_VO,MSGL_DBG2, "vosub_vidix: vidix_preinit(%s) was called\n",drvname); }
678 vidix_handler = vdlOpen(drvname ? drvname[0] == ':' ? &drvname[1] : drvname[0] ? drvname : NULL : NULL,
679 TYPE_OUTPUT,
680 verbose);
682 if(vidix_handler == NULL)
684 mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SUB_VIDIX_CouldntFindWorkingVidixDriver);
685 return -1;
687 if((err=vdlGetCapability(vidix_handler,&vidix_cap)) != 0)
689 mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SUB_VIDIX_CouldntGetCapability,strerror(err));
690 return -1;
692 mp_msg(MSGT_VO,MSGL_V, "[VO_SUB_VIDIX] Description: %s.\n", vidix_cap.name);
693 mp_msg(MSGT_VO,MSGL_V, "[VO_SUB_VIDIX] Author: %s.\n", vidix_cap.author);
694 /* we are able to tune up this stuff depend on fourcc format */
695 server->draw_slice=vidix_draw_slice;
696 server->draw_frame=vidix_draw_frame;
697 server->flip_page=vidix_flip_page;
698 server->draw_osd=vidix_draw_osd;
699 // server_control = server->control;
700 // server->control=vidix_control;
701 vo_server = server;
702 return 0;