stream_cue: Avoid probing empty filename in cue_find_bin()
[mplayer.git] / libvo / vo_directfb2.c
blobd21c9e37c64d6dd1b5649cb35e44c03c8692dda5
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 #include <directfb.h>
26 #include <directfb_version.h>
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <string.h>
30 #include <libavutil/common.h>
32 #include "config.h"
33 #include "video_out.h"
34 #include "video_out_internal.h"
35 #include "fastmemcpy.h"
36 #include "sub/sub.h"
37 #include "mp_msg.h"
38 #include "aspect.h"
39 #include "subopt-helper.h"
40 #include "mp_fifo.h"
41 #include "input/keycodes.h"
43 // triple buffering
44 #define TRIPLE 1
46 static const vo_info_t info = {
47 "Direct Framebuffer Device",
48 "directfb",
49 "Jiri Svoboda Jiri.Svoboda@seznam.cz",
50 "v 2.0 (for DirectFB version >=0.9.22)"
53 const LIBVO_EXTERN(directfb)
55 /******************************
56 * vo_directfb globals *
57 ******************************/
59 #define DFBCHECK(x...) \
60 { \
61 DFBResult err = x; \
63 if (err != DFB_OK) \
64 { \
65 fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \
66 DirectFBErrorFatal( #x, err ); \
67 } \
71 * filled by preinit
74 // main DirectFB handle
75 static IDirectFB *dfb = NULL;
76 // keyboard handle
77 static IDirectFBInputDevice *keyboard = NULL;
78 // A buffer for input events.
79 static IDirectFBEventBuffer *buffer = NULL;
82 * filled during config
85 // handle of used layer
86 static IDirectFBDisplayLayer *layer = NULL;
87 // surface of used layer
88 static IDirectFBSurface *primary = NULL;
89 static int primarylocked = 0;
90 // handle of temporary surface (if used)
91 static IDirectFBSurface *frame = NULL;
92 static int framelocked = 0;
93 // flipping mode flag (layer/surface)
94 static int flipping = 0;
95 // scaling flag
96 static int stretch = 0;
97 // picture position
98 static int xoffset=0,yoffset=0;
99 // picture size
100 static int out_width=0,out_height=0;
101 // frame/primary size
102 static int width=0,height=0;
103 // frame primary format
104 DFBSurfacePixelFormat pixel_format;
106 static void (*draw_alpha_p)(int w, int h, unsigned char *src,
107 unsigned char *srca, int stride, unsigned char *dst,
108 int dstride);
111 /******************************
112 * cmd line parameteres *
113 ******************************/
115 /* command line/config file options */
116 static int layer_id = -1;
117 static int buffer_mode = 1;
118 static int use_input = 1;
119 static int field_parity = -1;
121 /******************************
122 * implementation *
123 ******************************/
125 static void unlock(void)
127 if (frame && framelocked) frame->Unlock(frame);
128 if (primary && primarylocked) primary->Unlock(primary);
131 static int get_parity(strarg_t *arg) {
132 if (strargcmp(arg, "top") == 0)
133 return 0;
134 if (strargcmp(arg, "bottom") == 0)
135 return 1;
136 return -1;
139 static int check_parity(void *arg) {
140 return get_parity(arg) != -1;
143 static int get_mode(strarg_t *arg) {
144 if (strargcmp(arg, "single") == 0)
145 return 1;
146 if (strargcmp(arg, "double") == 0)
147 return 2;
148 if (strargcmp(arg, "triple") == 0)
149 return 3;
150 return 0;
153 static int check_mode(void *arg) {
154 return get_mode(arg) != 0;
157 static int preinit(const char *arg)
159 DFBResult ret;
160 strarg_t mode_str = {0, NULL};
161 strarg_t par_str = {0, NULL};
162 strarg_t dfb_params = {0, NULL};
163 const opt_t subopts[] = {
164 {"input", OPT_ARG_BOOL, &use_input, NULL},
165 {"buffermode", OPT_ARG_STR, &mode_str, check_mode},
166 {"fieldparity", OPT_ARG_STR, &par_str, check_parity},
167 {"layer", OPT_ARG_INT, &layer_id, NULL},
168 {"dfbopts", OPT_ARG_STR, &dfb_params, NULL},
169 {NULL}
172 //mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Preinit entered\n");
174 if (dfb) return 0; // we are already initialized!
176 // set defaults
177 buffer_mode = 1 + vo_doublebuffering; // honor -double switch
178 layer_id = -1;
179 use_input = 1;
180 field_parity = -1;
181 if (subopt_parse(arg, subopts) != 0) {
182 mp_msg( MSGT_VO, MSGL_ERR,
183 "\n-vo directfb command line help:\n"
184 "Example: mplayer -vo directfb:layer=1:buffermode=single\n"
185 "\nOptions (use 'no' prefix to disable):\n"
186 " input Use DirectFB for keyboard input\n"
187 "\nOther options:\n"
188 " layer=n\n"
189 " n=0..xx Use layer with id n for output (0=primary)\n"
190 " buffermode=(single|double|triple)\n"
191 " single Use single buffering\n"
192 " double Use double buffering\n"
193 " triple Use triple buffering\n"
194 " fieldparity=(top|bottom)\n"
195 " top Top field first\n"
196 " bottom Bottom field first\n"
197 " dfbopts=<str>\n"
198 " Specify a parameter list for DirectFB\n"
199 "\n" );
200 return -1;
202 if (mode_str.len)
203 buffer_mode = get_mode(&mode_str);
204 if (par_str.len)
205 field_parity = get_parity(&par_str);
208 if (dfb_params.len > 0)
210 int argc = 2;
211 char arg0[10] = "mplayer";
212 char *arg1 = malloc(dfb_params.len + 7);
213 char* argv[3];
214 char ** a;
216 a = &argv[0];
218 strcpy(arg1, "--dfb:");
219 strncat(arg1, dfb_params.str, dfb_params.len);
221 argv[0]=arg0;
222 argv[1]=arg1;
223 argv[2]=NULL;
225 DFBCHECK (DirectFBInit (&argc,&a));
227 free(arg1);
228 } else {
230 DFBCHECK (DirectFBInit (NULL,NULL));
233 if (((directfb_major_version <= 0) &&
234 (directfb_minor_version <= 9) &&
235 (directfb_micro_version < 15)))
237 mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: Unsupported DirectFB version\n");
238 return 1;
242 * (set options)
245 // uncomment this if you do not wish to create a new VT for DirectFB
246 // DFBCHECK (DirectFBSetOption ("no-vt-switch",""));
248 // uncomment this if you want to allow VT switching
249 // DFBCHECK (DirectFBSetOption ("vt-switching",""));
251 // uncomment this if you want to hide gfx cursor (req dfb >=0.9.9)
252 DFBCHECK (DirectFBSetOption ("no-cursor",""));
254 // bg color fix
255 DFBCHECK (DirectFBSetOption ("bg-color","00000000"));
258 * (Initialize)
261 DFBCHECK (DirectFBCreate (&dfb));
264 * (Get keyboard)
267 if (use_input) {
268 ret = dfb->GetInputDevice (dfb, DIDID_KEYBOARD, &keyboard);
269 if (ret==DFB_OK) {
270 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Keyboard init OK\n");
271 } else {
272 keyboard = NULL;
273 mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: Keyboard init FAILED\n");
279 * Create an input buffer for the keyboard.
281 if (keyboard) DFBCHECK (keyboard->CreateEventBuffer (keyboard, &buffer));
283 // just to start clean ...
284 if (buffer) buffer->Reset(buffer);
286 //mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Preinit OK\n");
288 return 0;
292 static DFBSurfacePixelFormat convformat(uint32_t format)
294 // add more formats !!!
295 switch (format) {
296 case IMGFMT_RGB32: return DSPF_RGB32; break;
297 case IMGFMT_BGR32: return DSPF_RGB32; break;
298 case IMGFMT_RGB24: return DSPF_RGB24; break;
299 case IMGFMT_BGR24: return DSPF_RGB24; break;
300 case IMGFMT_RGB16: return DSPF_RGB16; break;
301 case IMGFMT_BGR16: return DSPF_RGB16; break;
302 case IMGFMT_RGB15: return DSPF_ARGB1555; break;
303 case IMGFMT_BGR15: return DSPF_ARGB1555; break;
304 case IMGFMT_RGB12: return DSPF_ARGB4444; break;
305 case IMGFMT_BGR12: return DSPF_ARGB4444; break;
306 case IMGFMT_YUY2: return DSPF_YUY2; break;
307 case IMGFMT_UYVY: return DSPF_UYVY; break;
308 case IMGFMT_YV12: return DSPF_YV12; break;
309 case IMGFMT_I420: return DSPF_I420; break;
310 // case IMGFMT_IYUV: return DSPF_IYUV; break;
311 case IMGFMT_RGB8: return DSPF_RGB332; break;
312 case IMGFMT_BGR8: return DSPF_RGB332; break;
314 default: return 0;
316 return 0;
319 typedef struct enum1_s {
320 uint32_t format;
321 int scale;
322 int result;
323 unsigned int id;
324 unsigned int width;
325 unsigned int height;
326 int setsize;
327 } enum1_t;
329 static DFBEnumerationResult test_format_callback(unsigned int id,
330 DFBDisplayLayerDescription desc,
331 void *data)
333 enum1_t *params =(enum1_t *)data;
334 IDirectFBDisplayLayer *layer;
335 DFBResult ret;
337 if ((layer_id == -1 )||(layer_id == id)) {
339 ret = dfb->GetDisplayLayer( dfb, id, &layer);
340 if (ret) {
341 DirectFBError( "dfb->GetDisplayLayer failed", ret );
342 return DFENUM_OK;
343 } else {
344 DFBDisplayLayerConfig dlc;
346 if (params->setsize) {
347 dlc.flags = DLCONF_WIDTH |DLCONF_HEIGHT;
348 dlc.width = params->width;
349 dlc.height = params->height;
350 layer->SetConfiguration(layer,&dlc);
354 dlc.flags = DLCONF_PIXELFORMAT;
355 dlc.pixelformat = convformat(params->format);
357 layer->SetOpacity(layer,0);
359 ret = layer->TestConfiguration(layer,&dlc,NULL);
361 layer->Release(layer);
363 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Test format - layer %i scale/pos %i\n",id,(desc.caps & DLCAPS_SCREEN_LOCATION));
365 if (ret==DFB_OK) {
366 // printf("Test OK\n");
367 if (params->result) {
368 if ((!params->scale) && (desc.caps & DLCAPS_SCREEN_LOCATION)) {
369 params->scale=1;
370 params->id=id;
371 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Test format - added layer %i scale/pos %i\n",id,(desc.caps & DLCAPS_SCREEN_LOCATION));
373 } else {
374 params->result=1;
375 params->id=id;
376 if (desc.caps & DLCAPS_SCREEN_LOCATION) params->scale=1;
377 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Test format - added layer %i scale/pos %i\n",id,(desc.caps & DLCAPS_SCREEN_LOCATION));
384 return DFENUM_OK;
387 static int query_format(uint32_t format)
389 int ret = VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_OSD; // osd should be removed the in future -> will be handled outside...
390 enum1_t params;
393 if (!convformat(format)) return 0;
394 // temporarily disable YV12
395 // if (format == IMGFMT_YV12) return 0;
396 // if (format == IMGFMT_I420) return 0;
397 if (format == IMGFMT_IYUV) return 0;
399 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Format query: %s\n",vo_format_name(format));
401 params.format=format;
402 params.scale=0;
403 params.result=0;
404 params.setsize=0;
406 DFBCHECK (dfb->EnumDisplayLayers(dfb,test_format_callback,&params));
408 if (params.result) {
409 if (params.scale) ret |=VFCAP_HWSCALE_UP|VFCAP_HWSCALE_DOWN;
410 return ret;
413 return 0;
416 typedef struct videomode_s {
417 int width;
418 int height;
419 int out_width;
420 int out_height;
421 int overx;
422 int overy;
423 int bpp;
424 } videomode_t;
427 static DFBEnumerationResult video_modes_callback(int width, int height,
428 int bpp, void *data)
430 videomode_t *params =(videomode_t *)data;
432 int overx=0,overy=0,closer=0,over=0;
433 int we_are_under=0;
435 //mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Validator entered %i %i %i\n",width,height,bpp);
437 overx=width-params->out_width;
438 overy=height-params->out_height;
440 if (!params->width) {
441 params->width=width;
442 params->height=height;
443 params->overx=overx;
444 params->overy=overy;
445 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Mode added %i %i %i\n",width,height,bpp);
448 if ((params->overy<0)||(params->overx<0)) we_are_under=1; // stored mode is smaller than req mode
449 if (abs(overx*overy)<abs(params->overx * params->overy)) closer=1; // current mode is closer to desired res
450 if ((overx>=0)&&(overy>=0)) over=1; // current mode is bigger or equaul to desired res
451 if ((closer && (over || we_are_under)) || (we_are_under && over)) {
452 params->width=width;
453 params->height=height;
454 params->overx=overx;
455 params->overy=overy;
456 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Better mode added %i %i %i\n",width,height,bpp);
459 return DFENUM_OK;
462 #define CONFIG_ERROR -1
464 static int config(uint32_t s_width, uint32_t s_height, uint32_t d_width,
465 uint32_t d_height, uint32_t flags, char *title,
466 uint32_t format)
469 * (Locals)
472 // decode flags
474 int fs = flags & VOFLAG_FULLSCREEN;
475 int vm = flags & VOFLAG_MODESWITCHING;
477 DFBSurfaceDescription dsc;
478 DFBResult ret;
479 DFBDisplayLayerConfig dlc;
480 DFBSurfaceCapabilities caps;
482 enum1_t params;
484 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config entered [%ix%i]\n",s_width,s_height);
485 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: With requested format: %s\n",vo_format_name(format));
487 // initial cleanup
488 if (frame) {
489 frame->Release(frame);
490 frame=NULL;
493 if (primary) {
494 primary->Release(primary);
495 primary=NULL;
498 if (layer) {
499 layer->Release(layer);
500 layer=NULL;
504 // vm things
506 if (vm) {
507 videomode_t params;
508 params.out_width=d_width;
509 params.out_height=d_height;
510 params.width=0;
511 params.height=0;
512 switch (format) {
513 case IMGFMT_RGB32:
514 case IMGFMT_BGR32:
515 params.bpp=32;
516 break;
517 case IMGFMT_RGB24:
518 case IMGFMT_BGR24:
519 params.bpp=24;
520 break;
521 case IMGFMT_RGB16:
522 case IMGFMT_BGR16:
523 case IMGFMT_RGB15:
524 case IMGFMT_BGR15:
525 case IMGFMT_RGB12:
526 case IMGFMT_BGR12:
527 params.bpp=16;
528 break;
529 default: params.bpp=0;
532 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config - trying to change videomode\n");
533 DFBCHECK (dfb->EnumVideoModes(dfb,video_modes_callback,&params));
534 ret=dfb->SetVideoMode(dfb,params.width,params.height,params.bpp);
535 if (ret) {
536 ret=dfb->SetVideoMode(dfb,params.width,params.height,24);
537 if (ret) {
538 ret=dfb->SetVideoMode(dfb,params.width,params.height,32);
539 if (ret) {
540 ret=dfb->SetVideoMode(dfb,params.width,params.height,16);
541 if (ret) {
542 ret=dfb->SetVideoMode(dfb,params.width,params.height,8);
547 } // vm end
549 // just to be sure clear primary layer
550 ret = dfb->GetDisplayLayer( dfb, DLID_PRIMARY, &layer);
551 if (ret==DFB_OK) {
552 ret = layer->GetSurface(layer,&primary);
553 if (ret==DFB_OK) {
554 primary->Clear(primary,0,0,0,0xff);
555 ret = primary->Flip(primary,NULL,0);
556 if (ret==DFB_OK) {
557 primary->Clear(primary,0,0,0,0xff);
559 primary->Release(primary);
561 primary=NULL;
562 layer->Release(layer);
564 layer=NULL;
566 // find best layer
568 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config - looking for suitable layer\n");
569 params.format=format;
570 params.scale=0;
571 params.result=0;
572 params.width=s_width;
573 params.height=s_height;
574 params.setsize=1;
576 DFBCHECK (dfb->EnumDisplayLayers(dfb,test_format_callback,&params));
578 if (!params.result) {
579 mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: ConfigError - no suitable layer found\n");
580 params.id = DLID_PRIMARY;
583 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config - layer %i\n",params.id);
585 // setup layer
587 DFBCHECK (dfb->GetDisplayLayer( dfb, params.id, &layer));
589 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config - switching layer to exclusive mode\n");
590 ret = layer->SetCooperativeLevel (layer, DLSCL_EXCLUSIVE);
592 if (DFB_OK != ret) {
593 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");
594 DirectFBError("MPlayer - Switch layer to exlusive mode.",ret);
596 if (params.scale) {
597 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config - changing layer configuration (size)\n");
598 dlc.flags = DLCONF_WIDTH | DLCONF_HEIGHT;
599 dlc.width = s_width;
600 dlc.height = s_height;
602 ret = layer->SetConfiguration(layer,&dlc);
604 if (ret) {
605 mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: ConfigError in layer configuration (size)\n");
606 DirectFBError("MPlayer - Layer size change.",ret);
610 // look if we need to change the pixel format of the layer
611 // and just to be sure also fetch all layer properties
612 dlc.flags = DLCONF_PIXELFORMAT | DLCONF_WIDTH | DLCONF_HEIGHT | DLCONF_OPTIONS | DLCONF_BUFFERMODE;
614 ret = layer->GetConfiguration(layer,&dlc);
616 dlc.flags = DLCONF_PIXELFORMAT | DLCONF_WIDTH | DLCONF_HEIGHT;
618 if (ret) {
619 mp_msg(MSGT_VO, MSGL_WARN,"DirectFB: Warning - could not get layer properties!\n");
620 } else {
621 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Layer reports format:%x\n",dlc.pixelformat);
624 if ((dlc.pixelformat != convformat(params.format)) || (ret != DFB_OK)) {
626 dlc.flags = DLCONF_PIXELFORMAT;
627 dlc.pixelformat = convformat(params.format);
629 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Desired pixelformat: %x\n",dlc.pixelformat);
631 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config - changing layer configuration (format)\n");
632 ret = layer->SetConfiguration(layer,&dlc);
634 if (ret) {
635 unsigned int bpp;
636 mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: ConfigError in layer configuration (format, flags=%x)\n",dlc.flags);
637 DirectFBError("MPlayer - layer pixelformat change",ret);
639 // ugly fbdev workaround - try to switch pixelformat via videomode change
640 switch (dlc.pixelformat) {
641 case DSPF_ARGB:
642 case DSPF_RGB32: bpp=32;break;
643 case DSPF_RGB24: bpp=24;break;
644 case DSPF_RGB16: bpp=16;break;
645 case DSPF_ARGB1555: bpp=15;break;
646 case DSPF_ARGB4444: bpp=12; break;
647 case DSPF_RGB332 : bpp=8;break;
650 switch (dlc.pixelformat) {
651 case DSPF_ARGB:
652 case DSPF_RGB32:
653 case DSPF_RGB24:
654 case DSPF_RGB16:
655 case DSPF_ARGB1555:
656 case DSPF_ARGB4444:
657 case DSPF_RGB332:
658 mp_msg(MSGT_VO, MSGL_V,"DirectFB: Trying to recover via videomode change (VM).\n");
659 // get size
660 dlc.flags = DLCONF_WIDTH | DLCONF_HEIGHT;
661 if (DFB_OK==layer->GetConfiguration(layer,&dlc)) {
662 // try to set videomode
663 mp_msg(MSGT_VO, MSGL_V,"DirectFB: Videomode %ix%i BPP %i\n",dlc.width,dlc.height,bpp);
664 ret = dfb->SetVideoMode(dfb,dlc.width,dlc.height,bpp);
665 if (ret) DirectFBError("MPlayer - VM - pixelformat change",ret);
669 //get current pixel format
670 dlc.flags = DLCONF_PIXELFORMAT;
671 ret = layer->GetConfiguration(layer,&dlc);
672 if (ret) {
673 DirectFBError("MPlayer - VM - Layer->GetConfiguration",ret);
674 } else {
675 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Layer now has pixelformat [%x]\n",dlc.pixelformat);
678 // check if we were succesful
679 if ((dlc.pixelformat != convformat(params.format)) || (ret != DFB_OK)) {
680 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Recovery failed!.\n");
681 return CONFIG_ERROR;
684 break;
686 default: return CONFIG_ERROR;
692 // flipping of layer
693 // try triple, double... buffering
695 dlc.flags = DLCONF_BUFFERMODE;
696 #ifdef TRIPLE
697 if (buffer_mode > 2) {
698 dlc.buffermode = DLBM_TRIPLE;
699 ret = layer->SetConfiguration( layer, &dlc );
700 } else {
701 ret=!DFB_OK;
704 if (ret!=DFB_OK) {
705 #endif
706 if (buffer_mode > 1) {
707 dlc.buffermode = DLBM_BACKVIDEO;
708 ret = layer->SetConfiguration( layer, &dlc );
709 if (ret!=DFB_OK) {
710 dlc.buffermode = DLBM_BACKSYSTEM;
711 ret = layer->SetConfiguration( layer, &dlc );
714 if (ret == DFB_OK) {
715 mp_msg(MSGT_VO, MSGL_V,"DirectFB: Double buffering is active\n");
717 #ifdef TRIPLE
718 } else {
719 mp_msg(MSGT_VO, MSGL_V,"DirectFB: Triple buffering is active\n");
721 #endif
723 if (field_parity != -1) {
724 dlc.flags = DLCONF_OPTIONS;
725 ret = layer->GetConfiguration( layer, &dlc );
726 if (ret==DFB_OK) {
727 dlc.options |= DLOP_FIELD_PARITY;
728 ret = layer->SetConfiguration( layer, &dlc );
729 if (ret==DFB_OK) {
730 layer->SetFieldParity( layer, field_parity );
734 mp_msg( MSGT_VO, MSGL_DBG2, "DirectFB: Requested field parity: ");
735 switch (field_parity) {
736 case -1:
737 mp_msg( MSGT_VO, MSGL_DBG2, "Don't care\n");
738 break;
739 case 0:
740 mp_msg( MSGT_VO, MSGL_DBG2, "Top field first\n");
741 break;
742 case 1:
743 mp_msg( MSGT_VO, MSGL_DBG2, "Bottom field first\n");
744 break;
747 // get layer surface
749 ret = layer->GetSurface(layer,&primary);
751 if (ret) {
752 mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: ConfigError - could not get surface\n");
753 return CONFIG_ERROR; // what shall we report on failure?
756 // test surface for flipping
757 DFBCHECK(primary->GetCapabilities(primary,&caps));
758 primary->Clear(primary,0,0,0,0xff);
759 flipping = 0;
760 if (caps & (DSCAPS_FLIPPING
761 #ifdef TRIPLE
762 | DSCAPS_TRIPLE
763 #endif
764 )) {
765 ret = primary->Flip(primary,NULL,0);
766 if (ret==DFB_OK) {
767 flipping = 1;
768 primary->Clear(primary,0,0,0,0xff);
769 #ifdef TRIPLE
770 // if we have 3 buffers clean once more
771 if (caps & DSCAPS_TRIPLE) {
772 primary->Flip(primary,NULL,0);
773 primary->Clear(primary,0,0,0,0xff);
774 flipping = 2;
776 #endif
780 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config - flipping = %i\n",flipping);
782 // is scale needed ? Aspect ratio and layer pos/size
785 // get surface size
786 DFBCHECK(primary->GetSize(primary,&width,&height));
788 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config - surface size = %ix%i\n",width,height);
790 aspect_save_orig(s_width,s_height);
791 aspect_save_prescale(d_width,d_height);
792 if (params.scale) {
793 aspect_save_screenres(10000,10000);
794 aspect(&out_width,&out_height,A_ZOOM);
796 ret = layer->SetScreenLocation(layer,(1-(float)out_width/10000)/2,(1-(float)out_height/10000)/2,((float)out_width/10000),((float)out_height/10000));
798 if (ret) mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: ConfigError in layer configuration (position)\n");
800 xoffset = 0;
801 yoffset = 0;
803 } else {
805 aspect_save_screenres(width,height);
807 if(fs) /* -fs */
808 aspect(&out_width,&out_height,A_ZOOM);
809 else
810 aspect(&out_width,&out_height,A_NOZOOM);
813 xoffset = (width - out_width) / 2;
814 yoffset = (height - out_height) / 2;
817 if (((s_width==out_width)&&(s_height==out_height)) || (params.scale)) {
818 stretch = 0;
819 } else {
820 stretch = 1;
824 // temporary buffer in case of not flipping or scaling
825 if ((!flipping) || stretch) {
827 DFBCHECK (primary->GetPixelFormat (primary, &dsc.pixelformat));
829 dsc.flags = DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_WIDTH;
831 dsc.width = s_width;
832 dsc.height = s_height;
834 DFBCHECK (dfb->CreateSurface( dfb, &dsc, &frame));
835 DFBCHECK(frame->GetSize(frame,&width,&height));
836 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Frame is active.\n");
839 // get format for draw_alpha - should be removed soon - osd will be rendered outside vo driver
840 if (frame) {
841 DFBCHECK (frame->GetPixelFormat(frame,&pixel_format));
842 } else {
843 DFBCHECK (primary->GetPixelFormat(primary,&pixel_format));
846 // finally turn on layer
847 layer->SetOpacity(layer,255);
849 //mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Config finished [%ix%i] - [%ix%i]\n",out_width,out_height,width,height);
851 return 0;
854 static void check_events(void)
857 if (buffer) {
859 DFBInputEvent event;
861 //if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf ("DirectFB: Check events entered\n");
862 if (buffer->GetEvent(buffer, DFB_EVENT (&event)) == DFB_OK) {
864 if (event.type == DIET_KEYPRESS) {
865 switch (event.key_symbol) {
866 case DIKS_ESCAPE:
867 mplayer_put_key(KEY_ESC);
868 break;
869 case DIKS_PAGE_UP: mplayer_put_key(KEY_PAGE_UP);break;
870 case DIKS_PAGE_DOWN: mplayer_put_key(KEY_PAGE_DOWN);break;
871 case DIKS_CURSOR_UP: mplayer_put_key(KEY_UP);break;
872 case DIKS_CURSOR_DOWN: mplayer_put_key(KEY_DOWN);break;
873 case DIKS_CURSOR_LEFT: mplayer_put_key(KEY_LEFT);break;
874 case DIKS_CURSOR_RIGHT: mplayer_put_key(KEY_RIGHT);break;
875 case DIKS_INSERT: mplayer_put_key(KEY_INSERT);break;
876 case DIKS_DELETE: mplayer_put_key(KEY_DELETE);break;
877 case DIKS_HOME: mplayer_put_key(KEY_HOME);break;
878 case DIKS_END: mplayer_put_key(KEY_END);break;
880 default:mplayer_put_key(event.key_symbol);
884 // empty buffer, because of repeating (keyboard repeat is faster than key handling
885 // and this causes problems during seek)
886 // temporary workaround should be solved in the future
887 buffer->Reset(buffer);
890 //if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf ("DirectFB: Check events finished\n");
893 static void flip_page(void)
895 DFBSurfaceBlittingFlags flags=DSBLIT_NOFX;
897 unlock(); // unlock frame & primary
899 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: Flip page entered");
901 DFBCHECK (primary->SetBlittingFlags(primary,flags));
903 if (frame) {
904 if (stretch) {
905 DFBRectangle rect;
906 rect.x=xoffset;
907 rect.y=yoffset;
908 rect.w=out_width;
909 rect.h=out_height;
911 DFBCHECK (primary->StretchBlit(primary,frame,NULL,&rect));
913 } else {
915 DFBCHECK (primary->Blit(primary,frame,NULL,xoffset,yoffset));
921 #ifdef TRIPLE
922 switch (flipping) {
923 case 1: DFBCHECK (primary->Flip (primary, NULL, DSFLIP_WAIT));
924 break;
925 case 2: DFBCHECK (primary->Flip (primary, NULL, DSFLIP_ONSYNC));
926 break;
927 default:; // should never be reached
929 #else
930 if (flipping) {
931 DFBCHECK (primary->Flip (primary, NULL, DSFLIP_WAITFORSYNC));
933 #endif
939 static void uninit(void)
942 //mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Uninit entered\n");
944 unlock();
947 * (Release)
950 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Releasing buffer\n");
951 if (buffer) buffer->Release (buffer);
952 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Releasing keyboard\n");
953 if (keyboard) keyboard->Release (keyboard);
955 if (frame) {
956 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Releasing frame\n");
957 frame->Release (frame);
958 frame = NULL;
961 // switch off BES
962 // if (layer) layer->SetOpacity(layer,0);
964 if (layer) {
965 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Releasing layer\n");
966 layer->Release(layer);
967 layer = NULL;
970 if (primary) {
971 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Releasing primary\n");
972 primary->Release (primary);
973 primary = NULL;
977 /* mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Releasing DirectFB library\n");
979 dfb->Release (dfb);
981 //mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Uninit done.\n");
985 static uint32_t directfb_set_video_eq(const char *data, int value) //data==name
988 DFBColorAdjustment ca;
989 float factor = (float)0xffff / 200.0;
991 DFBDisplayLayerDescription desc;
993 unlock();
995 if (layer) {
997 layer->GetDescription(layer,&desc);
999 ca.flags=DCAF_NONE;
1001 if (! strcmp( data,"brightness" )) {
1002 if (desc.caps & DLCAPS_BRIGHTNESS) {
1003 ca.brightness = value * factor +0x8000;
1004 ca.flags |= DCAF_BRIGHTNESS;
1005 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: SetVEq Brightness 0x%X %i\n",ca.brightness,value);
1006 } else return VO_FALSE;
1009 if (! strcmp( data,"contrast" )) {
1010 if ((desc.caps & DLCAPS_CONTRAST)) {
1011 ca.contrast = value * factor + 0x8000;
1012 ca.flags |= DCAF_CONTRAST;
1013 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: SetVEq Contrast 0x%X %i\n",ca.contrast,value);
1014 } else return VO_FALSE;
1017 if (! strcmp( data,"hue" )) {
1018 if ((desc.caps & DLCAPS_HUE)) {
1019 ca.hue = value * factor + 0x8000;
1020 ca.flags |= DCAF_HUE;
1021 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: SetVEq Hue 0x%X %i\n",ca.hue,value);
1022 } else return VO_FALSE;
1025 if (! strcmp( data,"saturation" )) {
1026 if ((desc.caps & DLCAPS_SATURATION)) {
1027 ca.saturation = value * factor + 0x8000;
1028 ca.flags |= DCAF_SATURATION;
1029 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: SetVEq Saturation 0x%X %i\n",ca.saturation,value);
1030 } else return VO_FALSE;
1033 if (ca.flags != DCAF_NONE) {
1034 layer->SetColorAdjustment(layer,&ca);
1035 return VO_TRUE;
1039 return VO_FALSE;
1043 static uint32_t directfb_get_video_eq(const char *data, int *value) // data==name
1046 DFBColorAdjustment ca;
1047 float factor = 200.0 / (float)0xffff;
1049 DFBDisplayLayerDescription desc;
1051 if (layer) {
1053 unlock();
1055 layer->GetDescription(layer,&desc);
1057 layer->GetColorAdjustment(layer,&ca);
1059 if (! strcmp( data,"brightness" )) {
1060 if (desc.caps & DLCAPS_BRIGHTNESS) {
1061 *value = (int) ((ca.brightness-0x8000) * factor);
1062 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: GetVEq Brightness 0x%X %i\n",ca.brightness,*value);
1063 return VO_TRUE;
1064 } else return VO_FALSE;
1067 if (! strcmp( data,"contrast" )) {
1068 if ((desc.caps & DLCAPS_CONTRAST)) {
1069 *value = (int) ((ca.contrast-0x8000) * factor);
1070 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: GetVEq Contrast 0x%X %i\n",ca.contrast,*value);
1071 return VO_TRUE;
1072 } else return VO_FALSE;
1075 if (! strcmp( data,"hue" )) {
1076 if ((desc.caps & DLCAPS_HUE)) {
1077 *value = (int) ((ca.hue-0x8000) * factor);
1078 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: GetVEq Hue 0x%X %i\n",ca.hue,*value);
1079 return VO_TRUE;
1080 } else return VO_FALSE;
1083 if (! strcmp( data,"saturation" )) {
1084 if ((desc.caps & DLCAPS_SATURATION)) {
1085 *value = (int) ((ca.saturation-0x8000) * factor);
1086 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: GetVEq Saturation 0x%X %i\n",ca.saturation,*value);
1087 return VO_TRUE;
1088 } else return VO_FALSE;
1091 return VO_FALSE;
1094 static uint32_t get_image(mp_image_t *mpi)
1097 int err;
1098 uint8_t *dst;
1099 int pitch;
1101 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: get_image() called\n");
1102 if(mpi->flags&MP_IMGFLAG_READABLE) return VO_FALSE; // slow video ram
1103 if(mpi->type==MP_IMGTYPE_STATIC) return VO_FALSE; // it is not static
1105 // printf("width=%d vs. pitch=%d, flags=0x%X \n",mpi->width,pitch,mpi->flags);
1107 if(mpi->flags&(MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_ACCEPT_WIDTH)){
1108 // we're lucky or codec accepts stride => ok, let's go!
1110 if (frame) {
1111 err = frame->Lock(frame,DSLF_WRITE|DSLF_READ,(void *)&dst,&pitch);
1112 framelocked=1;
1113 } else {
1114 err = primary->Lock(primary,DSLF_WRITE,(void *)&dst,&pitch);
1115 primarylocked=1;
1118 if (err) {
1119 mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: DR lock failed!");
1120 return VO_FALSE;
1123 if(mpi->flags&MP_IMGFLAG_PLANAR){
1124 //YV12 format
1125 mpi->planes[0]=dst;
1126 if(mpi->flags&MP_IMGFLAG_SWAPPED){
1127 mpi->planes[1]=dst + pitch*height;
1128 mpi->planes[2]=mpi->planes[1] + pitch*height/4;
1129 } else {
1130 mpi->planes[2]=dst + pitch*height;
1131 mpi->planes[1]=mpi->planes[2] + pitch*height/4;
1133 mpi->width=width;
1134 mpi->stride[0]=pitch;
1135 mpi->stride[1]=mpi->stride[2]=pitch/2;
1136 } else {
1137 //YUY2 and RGB formats
1138 mpi->planes[0]=dst;
1139 mpi->width=width;
1140 mpi->stride[0]=pitch;
1143 // center image
1145 if (!frame) {
1146 if(mpi->flags&MP_IMGFLAG_PLANAR){
1147 mpi->planes[0]= dst + yoffset * pitch + xoffset;
1148 mpi->planes[1]+= ((yoffset * pitch) >> 2) + (xoffset >> 1);
1149 mpi->planes[2]+= ((yoffset * pitch) >> 2) + (xoffset >> 1);
1150 } else {
1151 mpi->planes[0]=dst + yoffset * pitch + xoffset * (mpi->bpp >> 3);
1155 mpi->flags|=MP_IMGFLAG_DIRECT;
1156 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: get_image() SUCCESS -> Direct Rendering ENABLED\n");
1157 return VO_TRUE;
1160 return VO_FALSE;
1163 static int draw_slice(uint8_t *src[], int stride[], int w, int h, int x, int y)
1165 int i;
1166 unsigned int pitch;
1167 uint8_t *dst;
1168 uint8_t *dst2;
1169 uint8_t *srcp;
1170 unsigned int p;
1172 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: draw_slice entered\n");
1174 unlock();
1176 if (frame) {
1177 DFBCHECK (frame->Lock(frame,DSLF_WRITE|DSLF_READ,(void *)&dst,&pitch));
1178 framelocked = 1;
1179 } else {
1180 DFBCHECK (primary->Lock(primary,DSLF_WRITE,(void *)&dst,&pitch));
1181 primarylocked = 1;
1184 p = FFMIN(w, pitch);
1186 dst += y*pitch + x;
1187 dst2 = dst + pitch*height - y*pitch + y*pitch/4 - x/2;
1188 srcp = src[0];
1190 for (i=0;i<h;i++) {
1191 fast_memcpy(dst,srcp,p);
1192 dst += pitch;
1193 srcp += stride[0];
1196 if (pixel_format == DSPF_YV12) {
1198 dst = dst2;
1199 srcp = src[2];
1200 p = p/2;
1202 for (i=0;i<h/2;i++) {
1203 fast_memcpy(dst,srcp,p);
1204 dst += pitch/2;
1205 srcp += stride[2];
1208 dst = dst2 + pitch*height/4;
1209 srcp = src[1];
1211 for (i=0;i<h/2;i++) {
1212 fast_memcpy(dst,srcp,p);
1213 dst += pitch/2;
1214 srcp += stride[1];
1217 } else {
1219 dst = dst2;
1220 srcp = src[1];
1221 p = p/2;
1223 for (i=0;i<h/2;i++) {
1224 fast_memcpy(dst,srcp,p);
1225 dst += pitch/2;
1226 srcp += stride[1];
1229 dst = dst2 + pitch*height/4;
1230 srcp = src[2];
1232 for (i=0;i<h/2;i++) {
1233 fast_memcpy(dst,srcp,p);
1234 dst += pitch/2;
1235 srcp += stride[2];
1240 unlock();
1242 return 0;
1246 static uint32_t put_image(mp_image_t *mpi){
1249 // static IDirectFBSurface *tmp = NULL;
1250 // DFBSurfaceDescription dsc;
1251 // DFBRectangle rect;
1253 // 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);
1255 unlock();
1257 // already out?
1258 if((mpi->flags&(MP_IMGFLAG_DIRECT|MP_IMGFLAG_DRAW_CALLBACK))) {
1259 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: Put_image - nothing to do\n");
1260 return VO_TRUE;
1263 if (mpi->flags&MP_IMGFLAG_PLANAR) {
1264 // memcpy all planes - sad but necessary
1265 int i;
1266 unsigned int pitch;
1267 uint8_t *dst;
1268 uint8_t *src;
1269 unsigned int p;
1271 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: Put_image - planar branch\n");
1272 if (frame) {
1273 DFBCHECK (frame->Lock(frame,DSLF_WRITE|DSLF_READ,(void *)&dst,&pitch));
1274 framelocked = 1;
1275 } else {
1276 DFBCHECK (primary->Lock(primary,DSLF_WRITE,(void *)&dst,&pitch));
1277 primarylocked = 1;
1280 p = FFMIN(mpi->w, pitch);
1282 src = mpi->planes[0]+mpi->y*mpi->stride[0]+mpi->x;
1284 for (i=0;i<mpi->h;i++) {
1285 fast_memcpy(dst+i*pitch,src+i*mpi->stride[0],p);
1289 if (pixel_format == DSPF_YV12) {
1291 dst += pitch*height;
1292 p = p/2;
1293 src = mpi->planes[2]+mpi->y*mpi->stride[2]+mpi->x/2;
1295 for (i=0;i<mpi->h/2;i++) {
1296 fast_memcpy(dst+i*pitch/2,src+i*mpi->stride[2],p);
1299 dst += pitch*height/4;
1300 src = mpi->planes[1]+mpi->y*mpi->stride[1]+mpi->x/2;
1302 for (i=0;i<mpi->h/2;i++) {
1303 fast_memcpy(dst+i*pitch/2,src+i*mpi->stride[1],p);
1306 } else {
1308 dst += pitch*height;
1309 p = p/2;
1310 src = mpi->planes[1]+mpi->y*mpi->stride[1]+mpi->x/2;
1312 for (i=0;i<mpi->h/2;i++) {
1313 fast_memcpy(dst+i*pitch/2,src+i*mpi->stride[1],p);
1316 dst += pitch*height/4;
1317 src = mpi->planes[2]+mpi->y*mpi->stride[2]+mpi->x/2;
1319 for (i=0;i<mpi->h/2;i++) {
1320 fast_memcpy(dst+i*pitch/2,src+i*mpi->stride[2],p);
1324 unlock();
1326 } else {
1327 // I had to disable native directfb blit because it wasn't working under some conditions :-(
1330 dsc.flags = DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_WIDTH | DSDESC_PREALLOCATED;
1331 dsc.preallocated[0].data = mpi->planes[0];
1332 dsc.preallocated[0].pitch = mpi->stride[0];
1333 dsc.width = mpi->width;
1334 dsc.height = mpi->height;
1335 dsc.pixelformat = convformat(mpi->imgfmt);
1337 DFBCHECK (dfb->CreateSurface( dfb, &dsc, &tmp));
1339 rect.x=mpi->x;
1340 rect.y=mpi->y;
1341 rect.w=mpi->w;
1342 rect.h=mpi->h;
1344 if (frame) {
1345 DFBCHECK (tmp->Blit(tmp,frame,&rect,0,0));
1346 } else {
1347 DFBCHECK (tmp->Blit(tmp,primary,&rect,xoffset,yoffset));
1349 tmp->Release(tmp);
1352 unsigned int pitch;
1353 uint8_t *dst;
1355 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: Put_image - non-planar branch\n");
1356 if (frame) {
1357 DFBCHECK (frame->Lock(frame,DSLF_WRITE,(void *)&dst,&pitch));
1358 framelocked = 1;
1359 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]);
1360 } else {
1361 DFBCHECK (primary->Lock(primary,DSLF_WRITE,(void *)&dst,&pitch));
1362 primarylocked = 1;
1363 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]);
1365 unlock();
1368 return VO_TRUE;
1373 static int control(uint32_t request, void *data)
1375 switch (request) {
1376 case VOCTRL_QUERY_FORMAT:
1377 return query_format(*((uint32_t*)data));
1378 case VOCTRL_GET_IMAGE:
1379 return get_image(data);
1380 case VOCTRL_DRAW_IMAGE:
1381 return put_image(data);
1382 case VOCTRL_SET_EQUALIZER:
1384 struct voctrl_set_equalizer_args *args = data;
1385 return directfb_set_video_eq(args->name, args->value);
1387 case VOCTRL_GET_EQUALIZER:
1389 struct voctrl_get_equalizer_args *args = data;
1390 return directfb_get_video_eq(args->name, args->valueptr);
1393 return VO_NOTIMPL;
1396 // unused function
1398 static int draw_frame(uint8_t *src[])
1400 return -1;
1403 // hopefully will be removed soon
1405 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src,
1406 unsigned char *srca, int stride)
1408 void *dst;
1409 int pitch;
1411 unlock(); // isn't it silly I have to unlock surface and then lock it again :-)
1413 if (frame) {
1414 DFBCHECK (frame->Lock(frame,DSLF_WRITE|DSLF_READ,&dst,&pitch));
1415 framelocked = 1;
1416 } else {
1417 DFBCHECK (primary->Lock(primary,DSLF_WRITE,&dst,&pitch));
1418 primarylocked = 1;
1421 switch(pixel_format) {
1422 case DSPF_RGB32:
1423 case DSPF_ARGB:
1424 vo_draw_alpha_rgb32(w,h,src,srca,stride,((uint8_t *) dst)+pitch*y0 + 4*x0,pitch);
1425 break;
1427 case DSPF_RGB24:
1428 vo_draw_alpha_rgb24(w,h,src,srca,stride,((uint8_t *) dst)+pitch*y0 + 3*x0,pitch);
1429 break;
1431 case DSPF_RGB16:
1432 vo_draw_alpha_rgb16(w,h,src,srca,stride,((uint8_t *) dst)+pitch*y0 + 2*x0,pitch);
1433 break;
1434 case DSPF_ARGB1555:
1435 vo_draw_alpha_rgb15(w,h,src,srca,stride,((uint8_t *) dst)+pitch*y0 + 2*x0,pitch);
1436 break;
1437 case DSPF_ARGB4444:
1438 vo_draw_alpha_rgb12(w, h, src, srca, stride,
1439 ((uint8_t *) dst) + pitch * y0 + 2 * x0,
1440 pitch);
1441 break;
1443 case DSPF_YUY2:
1444 vo_draw_alpha_yuy2(w,h,src,srca,stride,((uint8_t *) dst) + pitch*y0 + 2*x0,pitch);
1445 break;
1447 case DSPF_UYVY:
1448 vo_draw_alpha_yuy2(w,h,src,srca,stride,((uint8_t *) dst) + pitch*y0 + 2*x0 + 1,pitch);
1449 break;
1451 case DSPF_I420:
1452 case DSPF_YV12:
1453 vo_draw_alpha_yv12(w,h,src,srca,stride,((uint8_t *) dst) + pitch*y0 + 1*x0,pitch);
1454 break;
1457 unlock();
1460 static void draw_osd(void)
1462 vo_draw_text(width,height,draw_alpha);