mp_image.c: add IMGFMT_MPEG4 (moved from mp_image.h)
[mplayer/glamo.git] / libvo / vo_directfb2.c
blob673882dd495c4a6c4f2edcd1ce51e4eef6875d20
1 /*
2 * MPlayer video driver for DirectFramebuffer device
4 * copyright (C) 2002 Jiri Svoboda <Jiri.Svoboda@seznam.cz>
6 * based on vo_directfb2.c
8 * This file is part of MPlayer.
10 * MPlayer is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (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 GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with MPlayer; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 // directfb includes
27 #include <directfb.h>
29 #define DFB_VERSION(a,b,c) (((a)<<16)|((b)<<8)|(c))
31 // other things
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <string.h>
37 #include "config.h"
38 #include "video_out.h"
39 #include "video_out_internal.h"
40 #include "fastmemcpy.h"
41 #include "sub.h"
42 #include "mp_msg.h"
43 #include "aspect.h"
44 #include "subopt-helper.h"
45 #include "mp_fifo.h"
47 #ifndef min
48 #define min(x,y) (((x)<(y))?(x):(y))
49 #endif
51 #if DIRECTFBVERSION > DFB_VERSION(0,9,17)
52 // triple buffering
53 #define TRIPLE 1
54 #endif
56 static const vo_info_t info = {
57 "Direct Framebuffer Device",
58 "directfb",
59 "Jiri Svoboda Jiri.Svoboda@seznam.cz",
60 "v 2.0 (for DirectFB version >=0.9.13)"
63 const LIBVO_EXTERN(directfb)
65 /******************************
66 * vo_directfb globals *
67 ******************************/
69 #define DFBCHECK(x...) \
70 { \
71 DFBResult err = x; \
73 if (err != DFB_OK) \
74 { \
75 fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \
76 DirectFBErrorFatal( #x, err ); \
77 } \
81 * filled by preinit
84 // main DirectFB handle
85 static IDirectFB *dfb = NULL;
86 // keyboard handle
87 static IDirectFBInputDevice *keyboard = NULL;
88 // A buffer for input events.
89 static IDirectFBEventBuffer *buffer = NULL;
92 * filled during config
95 // handle of used layer
96 static IDirectFBDisplayLayer *layer = NULL;
97 // surface of used layer
98 static IDirectFBSurface *primary = NULL;
99 static int primarylocked = 0;
100 // handle of temporary surface (if used)
101 static IDirectFBSurface *frame = NULL;
102 static int framelocked = 0;
103 // flipping mode flag (layer/surface)
104 static int flipping = 0;
105 // scaling flag
106 static int stretch = 0;
107 // picture position
108 static int xoffset=0,yoffset=0;
109 // picture size
110 static int out_width=0,out_height=0;
111 // frame/primary size
112 static int width=0,height=0;
113 // frame primary format
114 DFBSurfacePixelFormat pixel_format;
116 static void (*draw_alpha_p)(int w, int h, unsigned char *src,
117 unsigned char *srca, int stride, unsigned char *dst,
118 int dstride);
121 /******************************
122 * cmd line parameteres *
123 ******************************/
125 /* command line/config file options */
126 static int layer_id = -1;
127 static int buffer_mode = 1;
128 static int use_input = 1;
129 static int field_parity = -1;
131 /******************************
132 * implementation *
133 ******************************/
135 void unlock(void) {
136 if (frame && framelocked) frame->Unlock(frame);
137 if (primary && primarylocked) primary->Unlock(primary);
140 static int get_parity(strarg_t *arg) {
141 if (strargcmp(arg, "top") == 0)
142 return 0;
143 if (strargcmp(arg, "bottom") == 0)
144 return 1;
145 return -1;
148 static int check_parity(void *arg) {
149 return get_parity(arg) != -1;
152 static int get_mode(strarg_t *arg) {
153 if (strargcmp(arg, "single") == 0)
154 return 1;
155 if (strargcmp(arg, "double") == 0)
156 return 2;
157 if (strargcmp(arg, "triple") == 0)
158 return 3;
159 return 0;
162 static int check_mode(void *arg) {
163 return get_mode(arg) != 0;
166 static int preinit(const char *arg)
168 DFBResult ret;
169 strarg_t mode_str = {0, NULL};
170 strarg_t par_str = {0, NULL};
171 strarg_t dfb_params = {0, NULL};
172 const opt_t subopts[] = {
173 {"input", OPT_ARG_BOOL, &use_input, NULL},
174 {"buffermode", OPT_ARG_STR, &mode_str, check_mode},
175 {"fieldparity", OPT_ARG_STR, &par_str, check_parity},
176 {"layer", OPT_ARG_INT, &layer_id, NULL},
177 {"dfbopts", OPT_ARG_STR, &dfb_params, NULL},
178 {NULL}
181 //mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Preinit entered\n");
183 if (dfb) return 0; // we are already initialized!
185 // set defaults
186 buffer_mode = 1 + vo_doublebuffering; // honor -double switch
187 layer_id = -1;
188 use_input = 1;
189 field_parity = -1;
190 if (subopt_parse(arg, subopts) != 0) {
191 mp_msg( MSGT_VO, MSGL_ERR,
192 "\n-vo directfb command line help:\n"
193 "Example: mplayer -vo directfb:layer=1:buffermode=single\n"
194 "\nOptions (use 'no' prefix to disable):\n"
195 " input Use DirectFB for keyboard input\n"
196 "\nOther options:\n"
197 " layer=n\n"
198 " n=0..xx Use layer with id n for output (0=primary)\n"
199 " buffermode=(single|double|triple)\n"
200 " single Use single buffering\n"
201 " double Use double buffering\n"
202 " triple Use triple buffering\n"
203 " fieldparity=(top|bottom)\n"
204 " top Top field first\n"
205 " bottom Bottom field first\n"
206 " dfbopts=<str>\n"
207 " Specify a parameter list for DirectFB\n"
208 "\n" );
209 return -1;
211 if (mode_str.len)
212 buffer_mode = get_mode(&mode_str);
213 if (par_str.len)
214 field_parity = get_parity(&par_str);
217 if (dfb_params.len > 0)
219 int argc = 2;
220 char arg0[10] = "mplayer";
221 char *arg1 = malloc(dfb_params.len + 7);
222 char* argv[3];
223 char ** a;
225 a = &argv[0];
227 strcpy(arg1, "--dfb:");
228 strncat(arg1, dfb_params.str, dfb_params.len);
230 argv[0]=arg0;
231 argv[1]=arg1;
232 argv[2]=NULL;
234 DFBCHECK (DirectFBInit (&argc,&a));
236 free(arg1);
237 } else {
239 DFBCHECK (DirectFBInit (NULL,NULL));
242 if (((directfb_major_version <= 0) &&
243 (directfb_minor_version <= 9) &&
244 (directfb_micro_version < 13)))
246 mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: Unsupported DirectFB version\n");
247 return 1;
251 * (set options)
254 // uncomment this if you do not wish to create a new VT for DirectFB
255 // DFBCHECK (DirectFBSetOption ("no-vt-switch",""));
257 // uncomment this if you want to allow VT switching
258 // DFBCHECK (DirectFBSetOption ("vt-switching",""));
260 // uncomment this if you want to hide gfx cursor (req dfb >=0.9.9)
261 DFBCHECK (DirectFBSetOption ("no-cursor",""));
263 // bg color fix
264 DFBCHECK (DirectFBSetOption ("bg-color","00000000"));
267 * (Initialize)
270 DFBCHECK (DirectFBCreate (&dfb));
272 #if DIRECTFBVERSION < DFB_VERSION(0,9,17)
273 if (DFB_OK != dfb->SetCooperativeLevel (dfb, DFSCL_FULLSCREEN)) {
274 mp_msg(MSGT_VO, MSGL_WARN,"DirectFB: Warning - cannot switch to fullscreen mode");
276 #endif
279 * (Get keyboard)
282 if (use_input) {
283 ret = dfb->GetInputDevice (dfb, DIDID_KEYBOARD, &keyboard);
284 if (ret==DFB_OK) {
285 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Keyboard init OK\n");
286 } else {
287 keyboard = NULL;
288 mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: Keyboard init FAILED\n");
294 * Create an input buffer for the keyboard.
296 if (keyboard) DFBCHECK (keyboard->CreateEventBuffer (keyboard, &buffer));
298 // just to start clean ...
299 if (buffer) buffer->Reset(buffer);
301 //mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Preinit OK\n");
303 return 0;
307 DFBSurfacePixelFormat convformat(uint32_t format)
309 // add more formats !!!
310 switch (format) {
311 case IMGFMT_RGB32: return DSPF_RGB32; break;
312 case IMGFMT_BGR32: return DSPF_RGB32; break;
313 case IMGFMT_RGB24: return DSPF_RGB24; break;
314 case IMGFMT_BGR24: return DSPF_RGB24; break;
315 case IMGFMT_RGB16: return DSPF_RGB16; break;
316 case IMGFMT_BGR16: return DSPF_RGB16; break;
317 #if DIRECTFBVERSION > DFB_VERSION(0,9,15)
318 case IMGFMT_RGB15: return DSPF_ARGB1555; break;
319 case IMGFMT_BGR15: return DSPF_ARGB1555; break;
320 #else
321 case IMGFMT_RGB15: return DSPF_RGB15; break;
322 case IMGFMT_BGR15: return DSPF_RGB15; break;
323 #endif
324 case IMGFMT_YUY2: return DSPF_YUY2; break;
325 case IMGFMT_UYVY: return DSPF_UYVY; break;
326 case IMGFMT_YV12: return DSPF_YV12; break;
327 case IMGFMT_I420: return DSPF_I420; break;
328 // case IMGFMT_IYUV: return DSPF_IYUV; break;
329 case IMGFMT_RGB8: return DSPF_RGB332; break;
330 case IMGFMT_BGR8: return DSPF_RGB332; break;
332 default: return 0;
334 return 0;
337 typedef struct enum1_s {
338 uint32_t format;
339 int scale;
340 int result;
341 unsigned int id;
342 unsigned int width;
343 unsigned int height;
344 int setsize;
345 } enum1_t;
347 DFBEnumerationResult test_format_callback( unsigned int id,
348 DFBDisplayLayerDescription desc,
349 void *data)
351 enum1_t *params =(enum1_t *)data;
352 IDirectFBDisplayLayer *layer;
353 DFBResult ret;
355 if ((layer_id == -1 )||(layer_id == id)) {
357 ret = dfb->GetDisplayLayer( dfb, id, &layer);
358 if (ret) {
359 DirectFBError( "dfb->GetDisplayLayer failed", ret );
360 return DFENUM_OK;
361 } else {
362 DFBDisplayLayerConfig dlc;
364 if (params->setsize) {
365 dlc.flags = DLCONF_WIDTH |DLCONF_HEIGHT;
366 dlc.width = params->width;
367 dlc.height = params->height;
368 layer->SetConfiguration(layer,&dlc);
372 dlc.flags = DLCONF_PIXELFORMAT;
373 dlc.pixelformat = convformat(params->format);
375 layer->SetOpacity(layer,0);
377 ret = layer->TestConfiguration(layer,&dlc,NULL);
379 layer->Release(layer);
381 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Test format - layer %i scale/pos %i\n",id,(desc.caps & DLCAPS_SCREEN_LOCATION));
383 if (ret==DFB_OK) {
384 // printf("Test OK\n");
385 if (params->result) {
386 if ((!params->scale) && (desc.caps & DLCAPS_SCREEN_LOCATION)) {
387 params->scale=1;
388 params->id=id;
389 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Test format - added layer %i scale/pos %i\n",id,(desc.caps & DLCAPS_SCREEN_LOCATION));
391 } else {
392 params->result=1;
393 params->id=id;
394 if (desc.caps & DLCAPS_SCREEN_LOCATION) params->scale=1;
395 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Test format - added layer %i scale/pos %i\n",id,(desc.caps & DLCAPS_SCREEN_LOCATION));
402 return DFENUM_OK;
405 static int query_format(uint32_t format)
407 int ret = VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_OSD; // osd should be removed the in future -> will be handled outside...
408 enum1_t params;
411 if (!convformat(format)) return 0;
412 // temporarily disable YV12
413 // if (format == IMGFMT_YV12) return 0;
414 // if (format == IMGFMT_I420) return 0;
415 if (format == IMGFMT_IYUV) return 0;
417 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Format query: %s\n",vo_format_name(format));
419 params.format=format;
420 params.scale=0;
421 params.result=0;
422 params.setsize=0;
424 DFBCHECK (dfb->EnumDisplayLayers(dfb,test_format_callback,&params));
426 if (params.result) {
427 if (params.scale) ret |=VFCAP_HWSCALE_UP|VFCAP_HWSCALE_DOWN;
428 return ret;
431 return 0;
434 typedef struct videomode_s {
435 int width;
436 int height;
437 int out_width;
438 int out_height;
439 int overx;
440 int overy;
441 int bpp;
442 } videomode_t;
445 DFBEnumerationResult video_modes_callback( int width,int height,int bpp, void *data)
447 videomode_t *params =(videomode_t *)data;
449 int overx=0,overy=0,closer=0,over=0;
450 int we_are_under=0;
452 //mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Validator entered %i %i %i\n",width,height,bpp);
454 overx=width-params->out_width;
455 overy=height-params->out_height;
457 if (!params->width) {
458 params->width=width;
459 params->height=height;
460 params->overx=overx;
461 params->overy=overy;
462 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Mode added %i %i %i\n",width,height,bpp);
465 if ((params->overy<0)||(params->overx<0)) we_are_under=1; // stored mode is smaller than req mode
466 if (abs(overx*overy)<abs(params->overx * params->overy)) closer=1; // current mode is closer to desired res
467 if ((overx>=0)&&(overy>=0)) over=1; // current mode is bigger or equaul to desired res
468 if ((closer && (over || we_are_under)) || (we_are_under && over)) {
469 params->width=width;
470 params->height=height;
471 params->overx=overx;
472 params->overy=overy;
473 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Better mode added %i %i %i\n",width,height,bpp);
476 return DFENUM_OK;
479 #define CONFIG_ERROR -1
481 static int config(uint32_t s_width, uint32_t s_height, uint32_t d_width,
482 uint32_t d_height, uint32_t flags, char *title,
483 uint32_t format)
486 * (Locals)
489 // decode flags
491 int fs = flags & VOFLAG_FULLSCREEN;
492 int vm = flags & VOFLAG_MODESWITCHING;
494 DFBSurfaceDescription dsc;
495 DFBResult ret;
496 DFBDisplayLayerConfig dlc;
497 DFBSurfaceCapabilities caps;
499 enum1_t params;
501 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config entered [%ix%i]\n",s_width,s_height);
502 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: With requested format: %s\n",vo_format_name(format));
504 // initial cleanup
505 if (frame) {
506 frame->Release(frame);
507 frame=NULL;
510 if (primary) {
511 primary->Release(primary);
512 primary=NULL;
515 if (layer) {
516 layer->Release(layer);
517 layer=NULL;
521 // vm things
523 if (vm) {
524 videomode_t params;
525 params.out_width=d_width;
526 params.out_height=d_height;
527 params.width=0;
528 params.height=0;
529 switch (format) {
530 case IMGFMT_RGB32:
531 case IMGFMT_BGR32:
532 params.bpp=32;
533 break;
534 case IMGFMT_RGB24:
535 case IMGFMT_BGR24:
536 params.bpp=24;
537 break;
538 case IMGFMT_RGB16:
539 case IMGFMT_BGR16:
540 case IMGFMT_RGB15:
541 case IMGFMT_BGR15:
542 params.bpp=16;
543 break;
544 default: params.bpp=0;
547 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config - trying to change videomode\n");
548 DFBCHECK (dfb->EnumVideoModes(dfb,video_modes_callback,&params));
549 ret=dfb->SetVideoMode(dfb,params.width,params.height,params.bpp);
550 if (ret) {
551 ret=dfb->SetVideoMode(dfb,params.width,params.height,24);
552 if (ret) {
553 ret=dfb->SetVideoMode(dfb,params.width,params.height,32);
554 if (ret) {
555 ret=dfb->SetVideoMode(dfb,params.width,params.height,16);
556 if (ret) {
557 ret=dfb->SetVideoMode(dfb,params.width,params.height,8);
562 } // vm end
564 // just to be sure clear primary layer
565 #if DIRECTFBVERSION > DFB_VERSION(0,9,13)
566 ret = dfb->GetDisplayLayer( dfb, DLID_PRIMARY, &layer);
567 if (ret==DFB_OK) {
568 ret = layer->GetSurface(layer,&primary);
569 if (ret==DFB_OK) {
570 primary->Clear(primary,0,0,0,0xff);
571 ret = primary->Flip(primary,NULL,0);
572 if (ret==DFB_OK) {
573 primary->Clear(primary,0,0,0,0xff);
575 primary->Release(primary);
577 primary=NULL;
578 layer->Release(layer);
580 layer=NULL;
581 #endif
583 // find best layer
585 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config - looking for suitable layer\n");
586 params.format=format;
587 params.scale=0;
588 params.result=0;
589 params.width=s_width;
590 params.height=s_height;
591 params.setsize=1;
593 DFBCHECK (dfb->EnumDisplayLayers(dfb,test_format_callback,&params));
595 if (!params.result) {
596 mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: ConfigError - no suitable layer found\n");
597 params.id = DLID_PRIMARY;
600 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config - layer %i\n",params.id);
602 // setup layer
604 DFBCHECK (dfb->GetDisplayLayer( dfb, params.id, &layer));
606 #if DIRECTFBVERSION > DFB_VERSION(0,9,16)
607 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config - switching layer to exclusive mode\n");
608 ret = layer->SetCooperativeLevel (layer, DLSCL_EXCLUSIVE);
610 if (DFB_OK != ret) {
611 mp_msg(MSGT_VO, MSGL_WARN,"DirectFB: Warning - cannot switch layer to exclusive mode. This could cause\nproblems. You may need to select correct pixel format manually!\n");
612 DirectFBError("MPlayer - Switch layer to exlusive mode.",ret);
614 #endif
615 if (params.scale) {
616 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config - changing layer configuration (size)\n");
617 dlc.flags = DLCONF_WIDTH | DLCONF_HEIGHT;
618 dlc.width = s_width;
619 dlc.height = s_height;
621 ret = layer->SetConfiguration(layer,&dlc);
623 if (ret) {
624 mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: ConfigError in layer configuration (size)\n");
625 DirectFBError("MPlayer - Layer size change.",ret);
629 // look if we need to change the pixel format of the layer
630 // and just to be sure also fetch all layer properties
631 dlc.flags = DLCONF_PIXELFORMAT | DLCONF_WIDTH | DLCONF_HEIGHT | DLCONF_OPTIONS | DLCONF_BUFFERMODE;
633 ret = layer->GetConfiguration(layer,&dlc);
635 dlc.flags = DLCONF_PIXELFORMAT | DLCONF_WIDTH | DLCONF_HEIGHT;
637 if (ret) {
638 mp_msg(MSGT_VO, MSGL_WARN,"DirectFB: Warning - could not get layer properties!\n");
639 } else {
640 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Layer reports format:%x\n",dlc.pixelformat);
643 if ((dlc.pixelformat != convformat(params.format)) || (ret != DFB_OK)) {
645 dlc.flags = DLCONF_PIXELFORMAT;
646 dlc.pixelformat = convformat(params.format);
648 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Desired pixelformat: %x\n",dlc.pixelformat);
650 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config - changing layer configuration (format)\n");
651 ret = layer->SetConfiguration(layer,&dlc);
653 if (ret) {
654 unsigned int bpp;
655 mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: ConfigError in layer configuration (format, flags=%x)\n",dlc.flags);
656 DirectFBError("MPlayer - layer pixelformat change",ret);
658 // ugly fbdev workaround - try to switch pixelformat via videomode change
659 switch (dlc.pixelformat) {
660 case DSPF_ARGB:
661 case DSPF_RGB32: bpp=32;break;
662 case DSPF_RGB24: bpp=24;break;
663 case DSPF_RGB16: bpp=16;break;
664 #if DIRECTFBVERSION > DFB_VERSION(0,9,15)
665 case DSPF_ARGB1555: bpp=15;break;
666 #else
667 case DSPF_RGB15: bpp=15;break;
668 #endif
669 case DSPF_RGB332 : bpp=8;break;
672 switch (dlc.pixelformat) {
673 case DSPF_ARGB:
674 case DSPF_RGB32:
675 case DSPF_RGB24:
676 case DSPF_RGB16:
677 #if DIRECTFBVERSION > DFB_VERSION(0,9,15)
678 case DSPF_ARGB1555:
679 #else
680 case DSPF_RGB15:
681 #endif
682 case DSPF_RGB332:
683 mp_msg(MSGT_VO, MSGL_V,"DirectFB: Trying to recover via videomode change (VM).\n");
684 // get size
685 dlc.flags = DLCONF_WIDTH | DLCONF_HEIGHT;
686 if (DFB_OK==layer->GetConfiguration(layer,&dlc)) {
687 // try to set videomode
688 mp_msg(MSGT_VO, MSGL_V,"DirectFB: Videomode %ix%i BPP %i\n",dlc.width,dlc.height,bpp);
689 ret = dfb->SetVideoMode(dfb,dlc.width,dlc.height,bpp);
690 if (ret) DirectFBError("MPlayer - VM - pixelformat change",ret);
694 //get current pixel format
695 dlc.flags = DLCONF_PIXELFORMAT;
696 ret = layer->GetConfiguration(layer,&dlc);
697 if (ret) {
698 DirectFBError("MPlayer - VM - Layer->GetConfiguration",ret);
699 } else {
700 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Layer now has pixelformat [%x]\n",dlc.pixelformat);
703 // check if we were succesful
704 if ((dlc.pixelformat != convformat(params.format)) || (ret != DFB_OK)) {
705 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Recovery failed!.\n");
706 return CONFIG_ERROR;
709 break;
711 default: return CONFIG_ERROR;
717 // flipping of layer
718 // try triple, double... buffering
720 dlc.flags = DLCONF_BUFFERMODE;
721 #ifdef TRIPLE
722 if (buffer_mode > 2) {
723 dlc.buffermode = DLBM_TRIPLE;
724 ret = layer->SetConfiguration( layer, &dlc );
725 } else {
726 ret=!DFB_OK;
729 if (ret!=DFB_OK) {
730 #endif
731 if (buffer_mode > 1) {
732 dlc.buffermode = DLBM_BACKVIDEO;
733 ret = layer->SetConfiguration( layer, &dlc );
734 if (ret!=DFB_OK) {
735 dlc.buffermode = DLBM_BACKSYSTEM;
736 ret = layer->SetConfiguration( layer, &dlc );
739 if (ret == DFB_OK) {
740 mp_msg(MSGT_VO, MSGL_V,"DirectFB: Double buffering is active\n");
742 #ifdef TRIPLE
743 } else {
744 mp_msg(MSGT_VO, MSGL_V,"DirectFB: Triple buffering is active\n");
746 #endif
748 #if DIRECTFBVERSION > DFB_VERSION(0,9,16)
749 if (field_parity != -1) {
750 dlc.flags = DLCONF_OPTIONS;
751 ret = layer->GetConfiguration( layer, &dlc );
752 if (ret==DFB_OK) {
753 dlc.options |= DLOP_FIELD_PARITY;
754 ret = layer->SetConfiguration( layer, &dlc );
755 if (ret==DFB_OK) {
756 layer->SetFieldParity( layer, field_parity );
760 mp_msg( MSGT_VO, MSGL_DBG2, "DirectFB: Requested field parity: ");
761 switch (field_parity) {
762 case -1:
763 mp_msg( MSGT_VO, MSGL_DBG2, "Don't care\n");
764 break;
765 case 0:
766 mp_msg( MSGT_VO, MSGL_DBG2, "Top field first\n");
767 break;
768 case 1:
769 mp_msg( MSGT_VO, MSGL_DBG2, "Bottom field first\n");
770 break;
773 #endif
776 // get layer surface
778 ret = layer->GetSurface(layer,&primary);
780 if (ret) {
781 mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: ConfigError - could not get surface\n");
782 return CONFIG_ERROR; // what shall we report on failure?
785 // test surface for flipping
786 DFBCHECK(primary->GetCapabilities(primary,&caps));
787 #if DIRECTFBVERSION > DFB_VERSION(0,9,13)
788 primary->Clear(primary,0,0,0,0xff);
789 #endif
790 flipping = 0;
791 if (caps & (DSCAPS_FLIPPING
792 #ifdef TRIPLE
793 | DSCAPS_TRIPLE
794 #endif
795 )) {
796 ret = primary->Flip(primary,NULL,0);
797 if (ret==DFB_OK) {
798 flipping = 1;
799 #if DIRECTFBVERSION > DFB_VERSION(0,9,13)
800 primary->Clear(primary,0,0,0,0xff);
801 #ifdef TRIPLE
802 // if we have 3 buffers clean once more
803 if (caps & DSCAPS_TRIPLE) {
804 primary->Flip(primary,NULL,0);
805 primary->Clear(primary,0,0,0,0xff);
806 flipping = 2;
808 #endif
809 #endif
813 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config - flipping = %i\n",flipping);
815 // is scale needed ? Aspect ratio and layer pos/size
818 // get surface size
819 DFBCHECK(primary->GetSize(primary,&width,&height));
821 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config - surface size = %ix%i\n",width,height);
823 aspect_save_orig(s_width,s_height);
824 aspect_save_prescale(d_width,d_height);
825 if (params.scale) {
826 aspect_save_screenres(10000,10000);
827 aspect(&out_width,&out_height,A_ZOOM);
829 ret = layer->SetScreenLocation(layer,(1-(float)out_width/10000)/2,(1-(float)out_height/10000)/2,((float)out_width/10000),((float)out_height/10000));
831 if (ret) mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: ConfigError in layer configuration (position)\n");
833 xoffset = 0;
834 yoffset = 0;
836 } else {
838 aspect_save_screenres(width,height);
840 if(fs) /* -fs */
841 aspect(&out_width,&out_height,A_ZOOM);
842 else
843 aspect(&out_width,&out_height,A_NOZOOM);
846 xoffset = (width - out_width) / 2;
847 yoffset = (height - out_height) / 2;
850 if (((s_width==out_width)&&(s_height==out_height)) || (params.scale)) {
851 stretch = 0;
852 } else {
853 stretch = 1;
857 // temporary buffer in case of not flipping or scaling
858 if ((!flipping) || stretch) {
860 DFBCHECK (primary->GetPixelFormat (primary, &dsc.pixelformat));
862 dsc.flags = DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_WIDTH;
864 dsc.width = s_width;
865 dsc.height = s_height;
867 DFBCHECK (dfb->CreateSurface( dfb, &dsc, &frame));
868 DFBCHECK(frame->GetSize(frame,&width,&height));
869 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Frame is active.\n");
872 // get format for draw_alpha - should be removed soon - osd will be rendered outside vo driver
873 if (frame) {
874 DFBCHECK (frame->GetPixelFormat(frame,&pixel_format));
875 } else {
876 DFBCHECK (primary->GetPixelFormat(primary,&pixel_format));
879 // finally turn on layer
880 layer->SetOpacity(layer,255);
882 //mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Config finished [%ix%i] - [%ix%i]\n",out_width,out_height,width,height);
884 return 0;
887 #include "osdep/keycodes.h"
889 static void check_events(void)
892 if (buffer) {
894 DFBInputEvent event;
896 //if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf ("DirectFB: Check events entered\n");
897 if (buffer->GetEvent(buffer, DFB_EVENT (&event)) == DFB_OK) {
899 if (event.type == DIET_KEYPRESS) {
900 switch (event.key_symbol) {
901 case DIKS_ESCAPE:
902 mplayer_put_key(KEY_ESC);
903 break;
904 case DIKS_PAGE_UP: mplayer_put_key(KEY_PAGE_UP);break;
905 case DIKS_PAGE_DOWN: mplayer_put_key(KEY_PAGE_DOWN);break;
906 case DIKS_CURSOR_UP: mplayer_put_key(KEY_UP);break;
907 case DIKS_CURSOR_DOWN: mplayer_put_key(KEY_DOWN);break;
908 case DIKS_CURSOR_LEFT: mplayer_put_key(KEY_LEFT);break;
909 case DIKS_CURSOR_RIGHT: mplayer_put_key(KEY_RIGHT);break;
910 case DIKS_INSERT: mplayer_put_key(KEY_INSERT);break;
911 case DIKS_DELETE: mplayer_put_key(KEY_DELETE);break;
912 case DIKS_HOME: mplayer_put_key(KEY_HOME);break;
913 case DIKS_END: mplayer_put_key(KEY_END);break;
915 default:mplayer_put_key(event.key_symbol);
919 // empty buffer, because of repeating (keyboard repeat is faster than key handling
920 // and this causes problems during seek)
921 // temporary workaround should be solved in the future
922 buffer->Reset(buffer);
925 //if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf ("DirectFB: Check events finished\n");
928 static void flip_page(void)
930 DFBSurfaceBlittingFlags flags=DSBLIT_NOFX;
932 unlock(); // unlock frame & primary
934 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: Flip page entered");
936 DFBCHECK (primary->SetBlittingFlags(primary,flags));
938 if (frame) {
939 if (stretch) {
940 DFBRectangle rect;
941 rect.x=xoffset;
942 rect.y=yoffset;
943 rect.w=out_width;
944 rect.h=out_height;
946 DFBCHECK (primary->StretchBlit(primary,frame,NULL,&rect));
948 } else {
950 DFBCHECK (primary->Blit(primary,frame,NULL,xoffset,yoffset));
956 #ifdef TRIPLE
957 switch (flipping) {
958 case 1: DFBCHECK (primary->Flip (primary, NULL, DSFLIP_WAIT));
959 break;
960 case 2: DFBCHECK (primary->Flip (primary, NULL, DSFLIP_ONSYNC));
961 break;
962 default:; // should never be reached
964 #else
965 if (flipping) {
966 DFBCHECK (primary->Flip (primary, NULL, DSFLIP_WAITFORSYNC));
968 #endif
974 static void uninit(void)
977 //mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Uninit entered\n");
979 unlock();
982 * (Release)
985 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Releasing buffer\n");
986 if (buffer) buffer->Release (buffer);
987 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Releasing keyboard\n");
988 if (keyboard) keyboard->Release (keyboard);
990 if (frame) {
991 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Releasing frame\n");
992 frame->Release (frame);
993 frame = NULL;
996 // switch off BES
997 // if (layer) layer->SetOpacity(layer,0);
999 if (layer) {
1000 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Releasing layer\n");
1001 layer->Release(layer);
1002 layer = NULL;
1005 if (primary) {
1006 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Releasing primary\n");
1007 primary->Release (primary);
1008 primary = NULL;
1012 /* mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Releasing DirectFB library\n");
1014 dfb->Release (dfb);
1016 //mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Uninit done.\n");
1020 static uint32_t directfb_set_video_eq(char *data, int value) //data==name
1023 DFBColorAdjustment ca;
1024 float factor = (float)0xffff / 200.0;
1026 DFBDisplayLayerDescription desc;
1028 unlock();
1030 if (layer) {
1032 layer->GetDescription(layer,&desc);
1034 ca.flags=DCAF_NONE;
1036 if (! strcmp( data,"brightness" )) {
1037 if (desc.caps & DLCAPS_BRIGHTNESS) {
1038 ca.brightness = value * factor +0x8000;
1039 ca.flags |= DCAF_BRIGHTNESS;
1040 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: SetVEq Brightness 0x%X %i\n",ca.brightness,value);
1041 } else return VO_FALSE;
1044 if (! strcmp( data,"contrast" )) {
1045 if ((desc.caps & DLCAPS_CONTRAST)) {
1046 ca.contrast = value * factor + 0x8000;
1047 ca.flags |= DCAF_CONTRAST;
1048 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: SetVEq Contrast 0x%X %i\n",ca.contrast,value);
1049 } else return VO_FALSE;
1052 if (! strcmp( data,"hue" )) {
1053 if ((desc.caps & DLCAPS_HUE)) {
1054 ca.hue = value * factor + 0x8000;
1055 ca.flags |= DCAF_HUE;
1056 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: SetVEq Hue 0x%X %i\n",ca.hue,value);
1057 } else return VO_FALSE;
1060 if (! strcmp( data,"saturation" )) {
1061 if ((desc.caps & DLCAPS_SATURATION)) {
1062 ca.saturation = value * factor + 0x8000;
1063 ca.flags |= DCAF_SATURATION;
1064 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: SetVEq Saturation 0x%X %i\n",ca.saturation,value);
1065 } else return VO_FALSE;
1068 if (ca.flags != DCAF_NONE) {
1069 layer->SetColorAdjustment(layer,&ca);
1070 return VO_TRUE;
1074 return VO_FALSE;
1078 static uint32_t directfb_get_video_eq(char *data, int *value) // data==name
1081 DFBColorAdjustment ca;
1082 float factor = 200.0 / (float)0xffff;
1084 DFBDisplayLayerDescription desc;
1086 if (layer) {
1088 unlock();
1090 layer->GetDescription(layer,&desc);
1092 layer->GetColorAdjustment(layer,&ca);
1094 if (! strcmp( data,"brightness" )) {
1095 if (desc.caps & DLCAPS_BRIGHTNESS) {
1096 *value = (int) ((ca.brightness-0x8000) * factor);
1097 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: GetVEq Brightness 0x%X %i\n",ca.brightness,*value);
1098 return VO_TRUE;
1099 } else return VO_FALSE;
1102 if (! strcmp( data,"contrast" )) {
1103 if ((desc.caps & DLCAPS_CONTRAST)) {
1104 *value = (int) ((ca.contrast-0x8000) * factor);
1105 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: GetVEq Contrast 0x%X %i\n",ca.contrast,*value);
1106 return VO_TRUE;
1107 } else return VO_FALSE;
1110 if (! strcmp( data,"hue" )) {
1111 if ((desc.caps & DLCAPS_HUE)) {
1112 *value = (int) ((ca.hue-0x8000) * factor);
1113 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: GetVEq Hue 0x%X %i\n",ca.hue,*value);
1114 return VO_TRUE;
1115 } else return VO_FALSE;
1118 if (! strcmp( data,"saturation" )) {
1119 if ((desc.caps & DLCAPS_SATURATION)) {
1120 *value = (int) ((ca.saturation-0x8000) * factor);
1121 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: GetVEq Saturation 0x%X %i\n",ca.saturation,*value);
1122 return VO_TRUE;
1123 } else return VO_FALSE;
1126 return VO_FALSE;
1129 static uint32_t get_image(mp_image_t *mpi)
1132 int err;
1133 uint8_t *dst;
1134 int pitch;
1136 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: get_image() called\n");
1137 if(mpi->flags&MP_IMGFLAG_READABLE) return VO_FALSE; // slow video ram
1138 if(mpi->type==MP_IMGTYPE_STATIC) return VO_FALSE; // it is not static
1140 // printf("width=%d vs. pitch=%d, flags=0x%X \n",mpi->width,pitch,mpi->flags);
1142 if(mpi->flags&(MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_ACCEPT_WIDTH)){
1143 // we're lucky or codec accepts stride => ok, let's go!
1145 if (frame) {
1146 err = frame->Lock(frame,DSLF_WRITE|DSLF_READ,(void *)&dst,&pitch);
1147 framelocked=1;
1148 } else {
1149 err = primary->Lock(primary,DSLF_WRITE,(void *)&dst,&pitch);
1150 primarylocked=1;
1153 if (err) {
1154 mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: DR lock failed!");
1155 return VO_FALSE;
1158 if(mpi->flags&MP_IMGFLAG_PLANAR){
1159 //YV12 format
1160 mpi->planes[0]=dst;
1161 if(mpi->flags&MP_IMGFLAG_SWAPPED){
1162 mpi->planes[1]=dst + pitch*height;
1163 mpi->planes[2]=mpi->planes[1] + pitch*height/4;
1164 } else {
1165 mpi->planes[2]=dst + pitch*height;
1166 mpi->planes[1]=mpi->planes[2] + pitch*height/4;
1168 mpi->width=width;
1169 mpi->stride[0]=pitch;
1170 mpi->stride[1]=mpi->stride[2]=pitch/2;
1171 } else {
1172 //YUY2 and RGB formats
1173 mpi->planes[0]=dst;
1174 mpi->width=width;
1175 mpi->stride[0]=pitch;
1178 // center image
1180 if (!frame) {
1181 if(mpi->flags&MP_IMGFLAG_PLANAR){
1182 mpi->planes[0]= dst + yoffset * pitch + xoffset;
1183 mpi->planes[1]+= ((yoffset * pitch) >> 2) + (xoffset >> 1);
1184 mpi->planes[2]+= ((yoffset * pitch) >> 2) + (xoffset >> 1);
1185 } else {
1186 mpi->planes[0]=dst + yoffset * pitch + xoffset * (mpi->bpp >> 3);
1190 mpi->flags|=MP_IMGFLAG_DIRECT;
1191 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: get_image() SUCCESS -> Direct Rendering ENABLED\n");
1192 return VO_TRUE;
1195 return VO_FALSE;
1198 static int draw_slice(uint8_t *src[], int stride[], int w, int h, int x, int y)
1200 int i;
1201 unsigned int pitch;
1202 uint8_t *dst;
1203 uint8_t *dst2;
1204 uint8_t *srcp;
1205 unsigned int p;
1207 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: draw_slice entered\n");
1209 unlock();
1211 if (frame) {
1212 DFBCHECK (frame->Lock(frame,DSLF_WRITE|DSLF_READ,(void *)&dst,&pitch));
1213 framelocked = 1;
1214 } else {
1215 DFBCHECK (primary->Lock(primary,DSLF_WRITE,(void *)&dst,&pitch));
1216 primarylocked = 1;
1219 p=min(w,pitch);
1221 dst += y*pitch + x;
1222 dst2 = dst + pitch*height - y*pitch + y*pitch/4 - x/2;
1223 srcp = src[0];
1225 for (i=0;i<h;i++) {
1226 fast_memcpy(dst,srcp,p);
1227 dst += pitch;
1228 srcp += stride[0];
1231 if (pixel_format == DSPF_YV12) {
1233 dst = dst2;
1234 srcp = src[2];
1235 p = p/2;
1237 for (i=0;i<h/2;i++) {
1238 fast_memcpy(dst,srcp,p);
1239 dst += pitch/2;
1240 srcp += stride[2];
1243 dst = dst2 + pitch*height/4;
1244 srcp = src[1];
1246 for (i=0;i<h/2;i++) {
1247 fast_memcpy(dst,srcp,p);
1248 dst += pitch/2;
1249 srcp += stride[1];
1252 } else {
1254 dst = dst2;
1255 srcp = src[1];
1256 p = p/2;
1258 for (i=0;i<h/2;i++) {
1259 fast_memcpy(dst,srcp,p);
1260 dst += pitch/2;
1261 srcp += stride[1];
1264 dst = dst2 + pitch*height/4;
1265 srcp = src[2];
1267 for (i=0;i<h/2;i++) {
1268 fast_memcpy(dst,srcp,p);
1269 dst += pitch/2;
1270 srcp += stride[2];
1275 unlock();
1277 return 0;
1281 static uint32_t put_image(mp_image_t *mpi){
1284 // static IDirectFBSurface *tmp = NULL;
1285 // DFBSurfaceDescription dsc;
1286 // DFBRectangle rect;
1288 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: Put_image entered %i %i %i %i %i %i\n",mpi->x,mpi->y,mpi->w,mpi->h,mpi->width,mpi->height);
1290 unlock();
1292 // already out?
1293 if((mpi->flags&(MP_IMGFLAG_DIRECT|MP_IMGFLAG_DRAW_CALLBACK))) {
1294 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: Put_image - nothing to do\n");
1295 return VO_TRUE;
1298 if (mpi->flags&MP_IMGFLAG_PLANAR) {
1299 // memcpy all planes - sad but necessary
1300 int i;
1301 unsigned int pitch;
1302 uint8_t *dst;
1303 uint8_t *src;
1304 unsigned int p;
1306 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: Put_image - planar branch\n");
1307 if (frame) {
1308 DFBCHECK (frame->Lock(frame,DSLF_WRITE|DSLF_READ,(void *)&dst,&pitch));
1309 framelocked = 1;
1310 } else {
1311 DFBCHECK (primary->Lock(primary,DSLF_WRITE,(void *)&dst,&pitch));
1312 primarylocked = 1;
1315 p=min(mpi->w,pitch);
1317 src = mpi->planes[0]+mpi->y*mpi->stride[0]+mpi->x;
1319 for (i=0;i<mpi->h;i++) {
1320 fast_memcpy(dst+i*pitch,src+i*mpi->stride[0],p);
1324 if (pixel_format == DSPF_YV12) {
1326 dst += pitch*height;
1327 p = p/2;
1328 src = mpi->planes[2]+mpi->y*mpi->stride[2]+mpi->x/2;
1330 for (i=0;i<mpi->h/2;i++) {
1331 fast_memcpy(dst+i*pitch/2,src+i*mpi->stride[2],p);
1334 dst += pitch*height/4;
1335 src = mpi->planes[1]+mpi->y*mpi->stride[1]+mpi->x/2;
1337 for (i=0;i<mpi->h/2;i++) {
1338 fast_memcpy(dst+i*pitch/2,src+i*mpi->stride[1],p);
1341 } else {
1343 dst += pitch*height;
1344 p = p/2;
1345 src = mpi->planes[1]+mpi->y*mpi->stride[1]+mpi->x/2;
1347 for (i=0;i<mpi->h/2;i++) {
1348 fast_memcpy(dst+i*pitch/2,src+i*mpi->stride[1],p);
1351 dst += pitch*height/4;
1352 src = mpi->planes[2]+mpi->y*mpi->stride[2]+mpi->x/2;
1354 for (i=0;i<mpi->h/2;i++) {
1355 fast_memcpy(dst+i*pitch/2,src+i*mpi->stride[2],p);
1359 unlock();
1361 } else {
1362 // I had to disable native directfb blit because it wasn't working under some conditions :-(
1365 dsc.flags = DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_WIDTH | DSDESC_PREALLOCATED;
1366 dsc.preallocated[0].data = mpi->planes[0];
1367 dsc.preallocated[0].pitch = mpi->stride[0];
1368 dsc.width = mpi->width;
1369 dsc.height = mpi->height;
1370 dsc.pixelformat = convformat(mpi->imgfmt);
1372 DFBCHECK (dfb->CreateSurface( dfb, &dsc, &tmp));
1374 rect.x=mpi->x;
1375 rect.y=mpi->y;
1376 rect.w=mpi->w;
1377 rect.h=mpi->h;
1379 if (frame) {
1380 DFBCHECK (tmp->Blit(tmp,frame,&rect,0,0));
1381 } else {
1382 DFBCHECK (tmp->Blit(tmp,primary,&rect,xoffset,yoffset));
1384 tmp->Release(tmp);
1387 unsigned int pitch;
1388 uint8_t *dst;
1390 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: Put_image - non-planar branch\n");
1391 if (frame) {
1392 DFBCHECK (frame->Lock(frame,DSLF_WRITE,(void *)&dst,&pitch));
1393 framelocked = 1;
1394 mem2agpcpy_pic(dst,mpi->planes[0] + mpi->y * mpi->stride[0] + mpi->x * (mpi->bpp >> 3) ,mpi->w * (mpi->bpp >> 3),mpi->h,pitch,mpi->stride[0]);
1395 } else {
1396 DFBCHECK (primary->Lock(primary,DSLF_WRITE,(void *)&dst,&pitch));
1397 primarylocked = 1;
1398 mem2agpcpy_pic(dst + yoffset * pitch + xoffset * (mpi->bpp >> 3),mpi->planes[0] + mpi->y * mpi->stride[0] + mpi->x * (mpi->bpp >> 3) ,mpi->w * (mpi->bpp >> 3),mpi->h,pitch,mpi->stride[0]);
1400 unlock();
1403 return VO_TRUE;
1408 static int control(uint32_t request, void *data)
1410 switch (request) {
1411 case VOCTRL_QUERY_FORMAT:
1412 return query_format(*((uint32_t*)data));
1413 case VOCTRL_GET_IMAGE:
1414 return get_image(data);
1415 case VOCTRL_DRAW_IMAGE:
1416 return put_image(data);
1417 case VOCTRL_SET_EQUALIZER:
1419 struct voctrl_set_equalizer_args *args = data;
1420 return directfb_set_video_eq(args->name, args->value);
1422 case VOCTRL_GET_EQUALIZER:
1424 struct voctrl_get_equalizer_args *args = data;
1425 return directfb_get_video_eq(args->name, args->valueptr);
1428 return VO_NOTIMPL;
1431 // unused function
1433 static int draw_frame(uint8_t *src[])
1435 return -1;
1438 // hopefully will be removed soon
1440 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src,
1441 unsigned char *srca, int stride)
1443 void *dst;
1444 int pitch;
1446 unlock(); // isn't it silly I have to unlock surface and then lock it again :-)
1448 if (frame) {
1449 DFBCHECK (frame->Lock(frame,DSLF_WRITE|DSLF_READ,&dst,&pitch));
1450 framelocked = 1;
1451 } else {
1452 DFBCHECK (primary->Lock(primary,DSLF_WRITE,&dst,&pitch));
1453 primarylocked = 1;
1456 switch(pixel_format) {
1457 case DSPF_RGB32:
1458 case DSPF_ARGB:
1459 vo_draw_alpha_rgb32(w,h,src,srca,stride,((uint8_t *) dst)+pitch*y0 + 4*x0,pitch);
1460 break;
1462 case DSPF_RGB24:
1463 vo_draw_alpha_rgb24(w,h,src,srca,stride,((uint8_t *) dst)+pitch*y0 + 3*x0,pitch);
1464 break;
1466 case DSPF_RGB16:
1467 vo_draw_alpha_rgb16(w,h,src,srca,stride,((uint8_t *) dst)+pitch*y0 + 2*x0,pitch);
1468 break;
1469 #if DIRECTFBVERSION > DFB_VERSION(0,9,15)
1470 case DSPF_ARGB1555:
1471 #else
1472 case DSPF_RGB15:
1473 #endif
1474 vo_draw_alpha_rgb15(w,h,src,srca,stride,((uint8_t *) dst)+pitch*y0 + 2*x0,pitch);
1475 break;
1477 case DSPF_YUY2:
1478 vo_draw_alpha_yuy2(w,h,src,srca,stride,((uint8_t *) dst) + pitch*y0 + 2*x0,pitch);
1479 break;
1481 case DSPF_UYVY:
1482 vo_draw_alpha_yuy2(w,h,src,srca,stride,((uint8_t *) dst) + pitch*y0 + 2*x0 + 1,pitch);
1483 break;
1485 case DSPF_I420:
1486 case DSPF_YV12:
1487 vo_draw_alpha_yv12(w,h,src,srca,stride,((uint8_t *) dst) + pitch*y0 + 1*x0,pitch);
1488 break;
1491 unlock();
1494 static void draw_osd(void)
1496 vo_draw_text(width,height,draw_alpha);