cleanup: remove NULL checks before free() all over the code
[mplayer/glamo.git] / libvo / vo_directfb2.c
blob1fb557707549bc0685a6bbf9626477f92d5660ce
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.h"
37 #include "mp_msg.h"
38 #include "aspect.h"
39 #include "subopt-helper.h"
40 #include "mp_fifo.h"
42 // triple buffering
43 #define TRIPLE 1
45 static const vo_info_t info = {
46 "Direct Framebuffer Device",
47 "directfb",
48 "Jiri Svoboda Jiri.Svoboda@seznam.cz",
49 "v 2.0 (for DirectFB version >=0.9.22)"
52 const LIBVO_EXTERN(directfb)
54 /******************************
55 * vo_directfb globals *
56 ******************************/
58 #define DFBCHECK(x...) \
59 { \
60 DFBResult err = x; \
62 if (err != DFB_OK) \
63 { \
64 fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \
65 DirectFBErrorFatal( #x, err ); \
66 } \
70 * filled by preinit
73 // main DirectFB handle
74 static IDirectFB *dfb = NULL;
75 // keyboard handle
76 static IDirectFBInputDevice *keyboard = NULL;
77 // A buffer for input events.
78 static IDirectFBEventBuffer *buffer = NULL;
81 * filled during config
84 // handle of used layer
85 static IDirectFBDisplayLayer *layer = NULL;
86 // surface of used layer
87 static IDirectFBSurface *primary = NULL;
88 static int primarylocked = 0;
89 // handle of temporary surface (if used)
90 static IDirectFBSurface *frame = NULL;
91 static int framelocked = 0;
92 // flipping mode flag (layer/surface)
93 static int flipping = 0;
94 // scaling flag
95 static int stretch = 0;
96 // picture position
97 static int xoffset=0,yoffset=0;
98 // picture size
99 static int out_width=0,out_height=0;
100 // frame/primary size
101 static int width=0,height=0;
102 // frame primary format
103 DFBSurfacePixelFormat pixel_format;
105 static void (*draw_alpha_p)(int w, int h, unsigned char *src,
106 unsigned char *srca, int stride, unsigned char *dst,
107 int dstride);
110 /******************************
111 * cmd line parameteres *
112 ******************************/
114 /* command line/config file options */
115 static int layer_id = -1;
116 static int buffer_mode = 1;
117 static int use_input = 1;
118 static int field_parity = -1;
120 /******************************
121 * implementation *
122 ******************************/
124 void unlock(void) {
125 if (frame && framelocked) frame->Unlock(frame);
126 if (primary && primarylocked) primary->Unlock(primary);
129 static int get_parity(strarg_t *arg) {
130 if (strargcmp(arg, "top") == 0)
131 return 0;
132 if (strargcmp(arg, "bottom") == 0)
133 return 1;
134 return -1;
137 static int check_parity(void *arg) {
138 return get_parity(arg) != -1;
141 static int get_mode(strarg_t *arg) {
142 if (strargcmp(arg, "single") == 0)
143 return 1;
144 if (strargcmp(arg, "double") == 0)
145 return 2;
146 if (strargcmp(arg, "triple") == 0)
147 return 3;
148 return 0;
151 static int check_mode(void *arg) {
152 return get_mode(arg) != 0;
155 static int preinit(const char *arg)
157 DFBResult ret;
158 strarg_t mode_str = {0, NULL};
159 strarg_t par_str = {0, NULL};
160 strarg_t dfb_params = {0, NULL};
161 const opt_t subopts[] = {
162 {"input", OPT_ARG_BOOL, &use_input, NULL},
163 {"buffermode", OPT_ARG_STR, &mode_str, check_mode},
164 {"fieldparity", OPT_ARG_STR, &par_str, check_parity},
165 {"layer", OPT_ARG_INT, &layer_id, NULL},
166 {"dfbopts", OPT_ARG_STR, &dfb_params, NULL},
167 {NULL}
170 //mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Preinit entered\n");
172 if (dfb) return 0; // we are already initialized!
174 // set defaults
175 buffer_mode = 1 + vo_doublebuffering; // honor -double switch
176 layer_id = -1;
177 use_input = 1;
178 field_parity = -1;
179 if (subopt_parse(arg, subopts) != 0) {
180 mp_msg( MSGT_VO, MSGL_ERR,
181 "\n-vo directfb command line help:\n"
182 "Example: mplayer -vo directfb:layer=1:buffermode=single\n"
183 "\nOptions (use 'no' prefix to disable):\n"
184 " input Use DirectFB for keyboard input\n"
185 "\nOther options:\n"
186 " layer=n\n"
187 " n=0..xx Use layer with id n for output (0=primary)\n"
188 " buffermode=(single|double|triple)\n"
189 " single Use single buffering\n"
190 " double Use double buffering\n"
191 " triple Use triple buffering\n"
192 " fieldparity=(top|bottom)\n"
193 " top Top field first\n"
194 " bottom Bottom field first\n"
195 " dfbopts=<str>\n"
196 " Specify a parameter list for DirectFB\n"
197 "\n" );
198 return -1;
200 if (mode_str.len)
201 buffer_mode = get_mode(&mode_str);
202 if (par_str.len)
203 field_parity = get_parity(&par_str);
206 if (dfb_params.len > 0)
208 int argc = 2;
209 char arg0[10] = "mplayer";
210 char *arg1 = malloc(dfb_params.len + 7);
211 char* argv[3];
212 char ** a;
214 a = &argv[0];
216 strcpy(arg1, "--dfb:");
217 strncat(arg1, dfb_params.str, dfb_params.len);
219 argv[0]=arg0;
220 argv[1]=arg1;
221 argv[2]=NULL;
223 DFBCHECK (DirectFBInit (&argc,&a));
225 free(arg1);
226 } else {
228 DFBCHECK (DirectFBInit (NULL,NULL));
231 if (((directfb_major_version <= 0) &&
232 (directfb_minor_version <= 9) &&
233 (directfb_micro_version < 15)))
235 mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: Unsupported DirectFB version\n");
236 return 1;
240 * (set options)
243 // uncomment this if you do not wish to create a new VT for DirectFB
244 // DFBCHECK (DirectFBSetOption ("no-vt-switch",""));
246 // uncomment this if you want to allow VT switching
247 // DFBCHECK (DirectFBSetOption ("vt-switching",""));
249 // uncomment this if you want to hide gfx cursor (req dfb >=0.9.9)
250 DFBCHECK (DirectFBSetOption ("no-cursor",""));
252 // bg color fix
253 DFBCHECK (DirectFBSetOption ("bg-color","00000000"));
256 * (Initialize)
259 DFBCHECK (DirectFBCreate (&dfb));
262 * (Get keyboard)
265 if (use_input) {
266 ret = dfb->GetInputDevice (dfb, DIDID_KEYBOARD, &keyboard);
267 if (ret==DFB_OK) {
268 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Keyboard init OK\n");
269 } else {
270 keyboard = NULL;
271 mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: Keyboard init FAILED\n");
277 * Create an input buffer for the keyboard.
279 if (keyboard) DFBCHECK (keyboard->CreateEventBuffer (keyboard, &buffer));
281 // just to start clean ...
282 if (buffer) buffer->Reset(buffer);
284 //mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Preinit OK\n");
286 return 0;
290 DFBSurfacePixelFormat convformat(uint32_t format)
292 // add more formats !!!
293 switch (format) {
294 case IMGFMT_RGB32: return DSPF_RGB32; break;
295 case IMGFMT_BGR32: return DSPF_RGB32; break;
296 case IMGFMT_RGB24: return DSPF_RGB24; break;
297 case IMGFMT_BGR24: return DSPF_RGB24; break;
298 case IMGFMT_RGB16: return DSPF_RGB16; break;
299 case IMGFMT_BGR16: return DSPF_RGB16; break;
300 case IMGFMT_RGB15: return DSPF_ARGB1555; break;
301 case IMGFMT_BGR15: return DSPF_ARGB1555; break;
302 case IMGFMT_RGB12: return DSPF_ARGB4444; break;
303 case IMGFMT_BGR12: return DSPF_ARGB4444; break;
304 case IMGFMT_YUY2: return DSPF_YUY2; break;
305 case IMGFMT_UYVY: return DSPF_UYVY; break;
306 case IMGFMT_YV12: return DSPF_YV12; break;
307 case IMGFMT_I420: return DSPF_I420; break;
308 // case IMGFMT_IYUV: return DSPF_IYUV; break;
309 case IMGFMT_RGB8: return DSPF_RGB332; break;
310 case IMGFMT_BGR8: return DSPF_RGB332; break;
312 default: return 0;
314 return 0;
317 typedef struct enum1_s {
318 uint32_t format;
319 int scale;
320 int result;
321 unsigned int id;
322 unsigned int width;
323 unsigned int height;
324 int setsize;
325 } enum1_t;
327 DFBEnumerationResult test_format_callback( unsigned int id,
328 DFBDisplayLayerDescription desc,
329 void *data)
331 enum1_t *params =(enum1_t *)data;
332 IDirectFBDisplayLayer *layer;
333 DFBResult ret;
335 if ((layer_id == -1 )||(layer_id == id)) {
337 ret = dfb->GetDisplayLayer( dfb, id, &layer);
338 if (ret) {
339 DirectFBError( "dfb->GetDisplayLayer failed", ret );
340 return DFENUM_OK;
341 } else {
342 DFBDisplayLayerConfig dlc;
344 if (params->setsize) {
345 dlc.flags = DLCONF_WIDTH |DLCONF_HEIGHT;
346 dlc.width = params->width;
347 dlc.height = params->height;
348 layer->SetConfiguration(layer,&dlc);
352 dlc.flags = DLCONF_PIXELFORMAT;
353 dlc.pixelformat = convformat(params->format);
355 layer->SetOpacity(layer,0);
357 ret = layer->TestConfiguration(layer,&dlc,NULL);
359 layer->Release(layer);
361 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Test format - layer %i scale/pos %i\n",id,(desc.caps & DLCAPS_SCREEN_LOCATION));
363 if (ret==DFB_OK) {
364 // printf("Test OK\n");
365 if (params->result) {
366 if ((!params->scale) && (desc.caps & DLCAPS_SCREEN_LOCATION)) {
367 params->scale=1;
368 params->id=id;
369 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Test format - added layer %i scale/pos %i\n",id,(desc.caps & DLCAPS_SCREEN_LOCATION));
371 } else {
372 params->result=1;
373 params->id=id;
374 if (desc.caps & DLCAPS_SCREEN_LOCATION) params->scale=1;
375 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Test format - added layer %i scale/pos %i\n",id,(desc.caps & DLCAPS_SCREEN_LOCATION));
382 return DFENUM_OK;
385 static int query_format(uint32_t format)
387 int ret = VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_OSD; // osd should be removed the in future -> will be handled outside...
388 enum1_t params;
391 if (!convformat(format)) return 0;
392 // temporarily disable YV12
393 // if (format == IMGFMT_YV12) return 0;
394 // if (format == IMGFMT_I420) return 0;
395 if (format == IMGFMT_IYUV) return 0;
397 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Format query: %s\n",vo_format_name(format));
399 params.format=format;
400 params.scale=0;
401 params.result=0;
402 params.setsize=0;
404 DFBCHECK (dfb->EnumDisplayLayers(dfb,test_format_callback,&params));
406 if (params.result) {
407 if (params.scale) ret |=VFCAP_HWSCALE_UP|VFCAP_HWSCALE_DOWN;
408 return ret;
411 return 0;
414 typedef struct videomode_s {
415 int width;
416 int height;
417 int out_width;
418 int out_height;
419 int overx;
420 int overy;
421 int bpp;
422 } videomode_t;
425 DFBEnumerationResult video_modes_callback( int width,int height,int bpp, void *data)
427 videomode_t *params =(videomode_t *)data;
429 int overx=0,overy=0,closer=0,over=0;
430 int we_are_under=0;
432 //mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Validator entered %i %i %i\n",width,height,bpp);
434 overx=width-params->out_width;
435 overy=height-params->out_height;
437 if (!params->width) {
438 params->width=width;
439 params->height=height;
440 params->overx=overx;
441 params->overy=overy;
442 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Mode added %i %i %i\n",width,height,bpp);
445 if ((params->overy<0)||(params->overx<0)) we_are_under=1; // stored mode is smaller than req mode
446 if (abs(overx*overy)<abs(params->overx * params->overy)) closer=1; // current mode is closer to desired res
447 if ((overx>=0)&&(overy>=0)) over=1; // current mode is bigger or equaul to desired res
448 if ((closer && (over || we_are_under)) || (we_are_under && over)) {
449 params->width=width;
450 params->height=height;
451 params->overx=overx;
452 params->overy=overy;
453 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Better mode added %i %i %i\n",width,height,bpp);
456 return DFENUM_OK;
459 #define CONFIG_ERROR -1
461 static int config(uint32_t s_width, uint32_t s_height, uint32_t d_width,
462 uint32_t d_height, uint32_t flags, char *title,
463 uint32_t format)
466 * (Locals)
469 // decode flags
471 int fs = flags & VOFLAG_FULLSCREEN;
472 int vm = flags & VOFLAG_MODESWITCHING;
474 DFBSurfaceDescription dsc;
475 DFBResult ret;
476 DFBDisplayLayerConfig dlc;
477 DFBSurfaceCapabilities caps;
479 enum1_t params;
481 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config entered [%ix%i]\n",s_width,s_height);
482 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: With requested format: %s\n",vo_format_name(format));
484 // initial cleanup
485 if (frame) {
486 frame->Release(frame);
487 frame=NULL;
490 if (primary) {
491 primary->Release(primary);
492 primary=NULL;
495 if (layer) {
496 layer->Release(layer);
497 layer=NULL;
501 // vm things
503 if (vm) {
504 videomode_t params;
505 params.out_width=d_width;
506 params.out_height=d_height;
507 params.width=0;
508 params.height=0;
509 switch (format) {
510 case IMGFMT_RGB32:
511 case IMGFMT_BGR32:
512 params.bpp=32;
513 break;
514 case IMGFMT_RGB24:
515 case IMGFMT_BGR24:
516 params.bpp=24;
517 break;
518 case IMGFMT_RGB16:
519 case IMGFMT_BGR16:
520 case IMGFMT_RGB15:
521 case IMGFMT_BGR15:
522 case IMGFMT_RGB12:
523 case IMGFMT_BGR12:
524 params.bpp=16;
525 break;
526 default: params.bpp=0;
529 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config - trying to change videomode\n");
530 DFBCHECK (dfb->EnumVideoModes(dfb,video_modes_callback,&params));
531 ret=dfb->SetVideoMode(dfb,params.width,params.height,params.bpp);
532 if (ret) {
533 ret=dfb->SetVideoMode(dfb,params.width,params.height,24);
534 if (ret) {
535 ret=dfb->SetVideoMode(dfb,params.width,params.height,32);
536 if (ret) {
537 ret=dfb->SetVideoMode(dfb,params.width,params.height,16);
538 if (ret) {
539 ret=dfb->SetVideoMode(dfb,params.width,params.height,8);
544 } // vm end
546 // just to be sure clear primary layer
547 ret = dfb->GetDisplayLayer( dfb, DLID_PRIMARY, &layer);
548 if (ret==DFB_OK) {
549 ret = layer->GetSurface(layer,&primary);
550 if (ret==DFB_OK) {
551 primary->Clear(primary,0,0,0,0xff);
552 ret = primary->Flip(primary,NULL,0);
553 if (ret==DFB_OK) {
554 primary->Clear(primary,0,0,0,0xff);
556 primary->Release(primary);
558 primary=NULL;
559 layer->Release(layer);
561 layer=NULL;
563 // find best layer
565 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config - looking for suitable layer\n");
566 params.format=format;
567 params.scale=0;
568 params.result=0;
569 params.width=s_width;
570 params.height=s_height;
571 params.setsize=1;
573 DFBCHECK (dfb->EnumDisplayLayers(dfb,test_format_callback,&params));
575 if (!params.result) {
576 mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: ConfigError - no suitable layer found\n");
577 params.id = DLID_PRIMARY;
580 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config - layer %i\n",params.id);
582 // setup layer
584 DFBCHECK (dfb->GetDisplayLayer( dfb, params.id, &layer));
586 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config - switching layer to exclusive mode\n");
587 ret = layer->SetCooperativeLevel (layer, DLSCL_EXCLUSIVE);
589 if (DFB_OK != ret) {
590 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");
591 DirectFBError("MPlayer - Switch layer to exlusive mode.",ret);
593 if (params.scale) {
594 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config - changing layer configuration (size)\n");
595 dlc.flags = DLCONF_WIDTH | DLCONF_HEIGHT;
596 dlc.width = s_width;
597 dlc.height = s_height;
599 ret = layer->SetConfiguration(layer,&dlc);
601 if (ret) {
602 mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: ConfigError in layer configuration (size)\n");
603 DirectFBError("MPlayer - Layer size change.",ret);
607 // look if we need to change the pixel format of the layer
608 // and just to be sure also fetch all layer properties
609 dlc.flags = DLCONF_PIXELFORMAT | DLCONF_WIDTH | DLCONF_HEIGHT | DLCONF_OPTIONS | DLCONF_BUFFERMODE;
611 ret = layer->GetConfiguration(layer,&dlc);
613 dlc.flags = DLCONF_PIXELFORMAT | DLCONF_WIDTH | DLCONF_HEIGHT;
615 if (ret) {
616 mp_msg(MSGT_VO, MSGL_WARN,"DirectFB: Warning - could not get layer properties!\n");
617 } else {
618 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Layer reports format:%x\n",dlc.pixelformat);
621 if ((dlc.pixelformat != convformat(params.format)) || (ret != DFB_OK)) {
623 dlc.flags = DLCONF_PIXELFORMAT;
624 dlc.pixelformat = convformat(params.format);
626 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Desired pixelformat: %x\n",dlc.pixelformat);
628 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config - changing layer configuration (format)\n");
629 ret = layer->SetConfiguration(layer,&dlc);
631 if (ret) {
632 unsigned int bpp;
633 mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: ConfigError in layer configuration (format, flags=%x)\n",dlc.flags);
634 DirectFBError("MPlayer - layer pixelformat change",ret);
636 // ugly fbdev workaround - try to switch pixelformat via videomode change
637 switch (dlc.pixelformat) {
638 case DSPF_ARGB:
639 case DSPF_RGB32: bpp=32;break;
640 case DSPF_RGB24: bpp=24;break;
641 case DSPF_RGB16: bpp=16;break;
642 case DSPF_ARGB1555: bpp=15;break;
643 case DSPF_ARGB4444: bpp=12; break;
644 case DSPF_RGB332 : bpp=8;break;
647 switch (dlc.pixelformat) {
648 case DSPF_ARGB:
649 case DSPF_RGB32:
650 case DSPF_RGB24:
651 case DSPF_RGB16:
652 case DSPF_ARGB1555:
653 case DSPF_ARGB4444:
654 case DSPF_RGB332:
655 mp_msg(MSGT_VO, MSGL_V,"DirectFB: Trying to recover via videomode change (VM).\n");
656 // get size
657 dlc.flags = DLCONF_WIDTH | DLCONF_HEIGHT;
658 if (DFB_OK==layer->GetConfiguration(layer,&dlc)) {
659 // try to set videomode
660 mp_msg(MSGT_VO, MSGL_V,"DirectFB: Videomode %ix%i BPP %i\n",dlc.width,dlc.height,bpp);
661 ret = dfb->SetVideoMode(dfb,dlc.width,dlc.height,bpp);
662 if (ret) DirectFBError("MPlayer - VM - pixelformat change",ret);
666 //get current pixel format
667 dlc.flags = DLCONF_PIXELFORMAT;
668 ret = layer->GetConfiguration(layer,&dlc);
669 if (ret) {
670 DirectFBError("MPlayer - VM - Layer->GetConfiguration",ret);
671 } else {
672 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Layer now has pixelformat [%x]\n",dlc.pixelformat);
675 // check if we were succesful
676 if ((dlc.pixelformat != convformat(params.format)) || (ret != DFB_OK)) {
677 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Recovery failed!.\n");
678 return CONFIG_ERROR;
681 break;
683 default: return CONFIG_ERROR;
689 // flipping of layer
690 // try triple, double... buffering
692 dlc.flags = DLCONF_BUFFERMODE;
693 #ifdef TRIPLE
694 if (buffer_mode > 2) {
695 dlc.buffermode = DLBM_TRIPLE;
696 ret = layer->SetConfiguration( layer, &dlc );
697 } else {
698 ret=!DFB_OK;
701 if (ret!=DFB_OK) {
702 #endif
703 if (buffer_mode > 1) {
704 dlc.buffermode = DLBM_BACKVIDEO;
705 ret = layer->SetConfiguration( layer, &dlc );
706 if (ret!=DFB_OK) {
707 dlc.buffermode = DLBM_BACKSYSTEM;
708 ret = layer->SetConfiguration( layer, &dlc );
711 if (ret == DFB_OK) {
712 mp_msg(MSGT_VO, MSGL_V,"DirectFB: Double buffering is active\n");
714 #ifdef TRIPLE
715 } else {
716 mp_msg(MSGT_VO, MSGL_V,"DirectFB: Triple buffering is active\n");
718 #endif
720 if (field_parity != -1) {
721 dlc.flags = DLCONF_OPTIONS;
722 ret = layer->GetConfiguration( layer, &dlc );
723 if (ret==DFB_OK) {
724 dlc.options |= DLOP_FIELD_PARITY;
725 ret = layer->SetConfiguration( layer, &dlc );
726 if (ret==DFB_OK) {
727 layer->SetFieldParity( layer, field_parity );
731 mp_msg( MSGT_VO, MSGL_DBG2, "DirectFB: Requested field parity: ");
732 switch (field_parity) {
733 case -1:
734 mp_msg( MSGT_VO, MSGL_DBG2, "Don't care\n");
735 break;
736 case 0:
737 mp_msg( MSGT_VO, MSGL_DBG2, "Top field first\n");
738 break;
739 case 1:
740 mp_msg( MSGT_VO, MSGL_DBG2, "Bottom field first\n");
741 break;
744 // get layer surface
746 ret = layer->GetSurface(layer,&primary);
748 if (ret) {
749 mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: ConfigError - could not get surface\n");
750 return CONFIG_ERROR; // what shall we report on failure?
753 // test surface for flipping
754 DFBCHECK(primary->GetCapabilities(primary,&caps));
755 primary->Clear(primary,0,0,0,0xff);
756 flipping = 0;
757 if (caps & (DSCAPS_FLIPPING
758 #ifdef TRIPLE
759 | DSCAPS_TRIPLE
760 #endif
761 )) {
762 ret = primary->Flip(primary,NULL,0);
763 if (ret==DFB_OK) {
764 flipping = 1;
765 primary->Clear(primary,0,0,0,0xff);
766 #ifdef TRIPLE
767 // if we have 3 buffers clean once more
768 if (caps & DSCAPS_TRIPLE) {
769 primary->Flip(primary,NULL,0);
770 primary->Clear(primary,0,0,0,0xff);
771 flipping = 2;
773 #endif
777 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config - flipping = %i\n",flipping);
779 // is scale needed ? Aspect ratio and layer pos/size
782 // get surface size
783 DFBCHECK(primary->GetSize(primary,&width,&height));
785 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config - surface size = %ix%i\n",width,height);
787 aspect_save_orig(s_width,s_height);
788 aspect_save_prescale(d_width,d_height);
789 if (params.scale) {
790 aspect_save_screenres(10000,10000);
791 aspect(&out_width,&out_height,A_ZOOM);
793 ret = layer->SetScreenLocation(layer,(1-(float)out_width/10000)/2,(1-(float)out_height/10000)/2,((float)out_width/10000),((float)out_height/10000));
795 if (ret) mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: ConfigError in layer configuration (position)\n");
797 xoffset = 0;
798 yoffset = 0;
800 } else {
802 aspect_save_screenres(width,height);
804 if(fs) /* -fs */
805 aspect(&out_width,&out_height,A_ZOOM);
806 else
807 aspect(&out_width,&out_height,A_NOZOOM);
810 xoffset = (width - out_width) / 2;
811 yoffset = (height - out_height) / 2;
814 if (((s_width==out_width)&&(s_height==out_height)) || (params.scale)) {
815 stretch = 0;
816 } else {
817 stretch = 1;
821 // temporary buffer in case of not flipping or scaling
822 if ((!flipping) || stretch) {
824 DFBCHECK (primary->GetPixelFormat (primary, &dsc.pixelformat));
826 dsc.flags = DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_WIDTH;
828 dsc.width = s_width;
829 dsc.height = s_height;
831 DFBCHECK (dfb->CreateSurface( dfb, &dsc, &frame));
832 DFBCHECK(frame->GetSize(frame,&width,&height));
833 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Frame is active.\n");
836 // get format for draw_alpha - should be removed soon - osd will be rendered outside vo driver
837 if (frame) {
838 DFBCHECK (frame->GetPixelFormat(frame,&pixel_format));
839 } else {
840 DFBCHECK (primary->GetPixelFormat(primary,&pixel_format));
843 // finally turn on layer
844 layer->SetOpacity(layer,255);
846 //mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Config finished [%ix%i] - [%ix%i]\n",out_width,out_height,width,height);
848 return 0;
851 #include "osdep/keycodes.h"
853 static void check_events(void)
856 if (buffer) {
858 DFBInputEvent event;
860 //if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf ("DirectFB: Check events entered\n");
861 if (buffer->GetEvent(buffer, DFB_EVENT (&event)) == DFB_OK) {
863 if (event.type == DIET_KEYPRESS) {
864 switch (event.key_symbol) {
865 case DIKS_ESCAPE:
866 mplayer_put_key(KEY_ESC);
867 break;
868 case DIKS_PAGE_UP: mplayer_put_key(KEY_PAGE_UP);break;
869 case DIKS_PAGE_DOWN: mplayer_put_key(KEY_PAGE_DOWN);break;
870 case DIKS_CURSOR_UP: mplayer_put_key(KEY_UP);break;
871 case DIKS_CURSOR_DOWN: mplayer_put_key(KEY_DOWN);break;
872 case DIKS_CURSOR_LEFT: mplayer_put_key(KEY_LEFT);break;
873 case DIKS_CURSOR_RIGHT: mplayer_put_key(KEY_RIGHT);break;
874 case DIKS_INSERT: mplayer_put_key(KEY_INSERT);break;
875 case DIKS_DELETE: mplayer_put_key(KEY_DELETE);break;
876 case DIKS_HOME: mplayer_put_key(KEY_HOME);break;
877 case DIKS_END: mplayer_put_key(KEY_END);break;
879 default:mplayer_put_key(event.key_symbol);
883 // empty buffer, because of repeating (keyboard repeat is faster than key handling
884 // and this causes problems during seek)
885 // temporary workaround should be solved in the future
886 buffer->Reset(buffer);
889 //if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf ("DirectFB: Check events finished\n");
892 static void flip_page(void)
894 DFBSurfaceBlittingFlags flags=DSBLIT_NOFX;
896 unlock(); // unlock frame & primary
898 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: Flip page entered");
900 DFBCHECK (primary->SetBlittingFlags(primary,flags));
902 if (frame) {
903 if (stretch) {
904 DFBRectangle rect;
905 rect.x=xoffset;
906 rect.y=yoffset;
907 rect.w=out_width;
908 rect.h=out_height;
910 DFBCHECK (primary->StretchBlit(primary,frame,NULL,&rect));
912 } else {
914 DFBCHECK (primary->Blit(primary,frame,NULL,xoffset,yoffset));
920 #ifdef TRIPLE
921 switch (flipping) {
922 case 1: DFBCHECK (primary->Flip (primary, NULL, DSFLIP_WAIT));
923 break;
924 case 2: DFBCHECK (primary->Flip (primary, NULL, DSFLIP_ONSYNC));
925 break;
926 default:; // should never be reached
928 #else
929 if (flipping) {
930 DFBCHECK (primary->Flip (primary, NULL, DSFLIP_WAITFORSYNC));
932 #endif
938 static void uninit(void)
941 //mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Uninit entered\n");
943 unlock();
946 * (Release)
949 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Releasing buffer\n");
950 if (buffer) buffer->Release (buffer);
951 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Releasing keyboard\n");
952 if (keyboard) keyboard->Release (keyboard);
954 if (frame) {
955 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Releasing frame\n");
956 frame->Release (frame);
957 frame = NULL;
960 // switch off BES
961 // if (layer) layer->SetOpacity(layer,0);
963 if (layer) {
964 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Releasing layer\n");
965 layer->Release(layer);
966 layer = NULL;
969 if (primary) {
970 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Releasing primary\n");
971 primary->Release (primary);
972 primary = NULL;
976 /* mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Releasing DirectFB library\n");
978 dfb->Release (dfb);
980 //mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Uninit done.\n");
984 static uint32_t directfb_set_video_eq(char *data, int value) //data==name
987 DFBColorAdjustment ca;
988 float factor = (float)0xffff / 200.0;
990 DFBDisplayLayerDescription desc;
992 unlock();
994 if (layer) {
996 layer->GetDescription(layer,&desc);
998 ca.flags=DCAF_NONE;
1000 if (! strcmp( data,"brightness" )) {
1001 if (desc.caps & DLCAPS_BRIGHTNESS) {
1002 ca.brightness = value * factor +0x8000;
1003 ca.flags |= DCAF_BRIGHTNESS;
1004 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: SetVEq Brightness 0x%X %i\n",ca.brightness,value);
1005 } else return VO_FALSE;
1008 if (! strcmp( data,"contrast" )) {
1009 if ((desc.caps & DLCAPS_CONTRAST)) {
1010 ca.contrast = value * factor + 0x8000;
1011 ca.flags |= DCAF_CONTRAST;
1012 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: SetVEq Contrast 0x%X %i\n",ca.contrast,value);
1013 } else return VO_FALSE;
1016 if (! strcmp( data,"hue" )) {
1017 if ((desc.caps & DLCAPS_HUE)) {
1018 ca.hue = value * factor + 0x8000;
1019 ca.flags |= DCAF_HUE;
1020 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: SetVEq Hue 0x%X %i\n",ca.hue,value);
1021 } else return VO_FALSE;
1024 if (! strcmp( data,"saturation" )) {
1025 if ((desc.caps & DLCAPS_SATURATION)) {
1026 ca.saturation = value * factor + 0x8000;
1027 ca.flags |= DCAF_SATURATION;
1028 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: SetVEq Saturation 0x%X %i\n",ca.saturation,value);
1029 } else return VO_FALSE;
1032 if (ca.flags != DCAF_NONE) {
1033 layer->SetColorAdjustment(layer,&ca);
1034 return VO_TRUE;
1038 return VO_FALSE;
1042 static uint32_t directfb_get_video_eq(char *data, int *value) // data==name
1045 DFBColorAdjustment ca;
1046 float factor = 200.0 / (float)0xffff;
1048 DFBDisplayLayerDescription desc;
1050 if (layer) {
1052 unlock();
1054 layer->GetDescription(layer,&desc);
1056 layer->GetColorAdjustment(layer,&ca);
1058 if (! strcmp( data,"brightness" )) {
1059 if (desc.caps & DLCAPS_BRIGHTNESS) {
1060 *value = (int) ((ca.brightness-0x8000) * factor);
1061 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: GetVEq Brightness 0x%X %i\n",ca.brightness,*value);
1062 return VO_TRUE;
1063 } else return VO_FALSE;
1066 if (! strcmp( data,"contrast" )) {
1067 if ((desc.caps & DLCAPS_CONTRAST)) {
1068 *value = (int) ((ca.contrast-0x8000) * factor);
1069 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: GetVEq Contrast 0x%X %i\n",ca.contrast,*value);
1070 return VO_TRUE;
1071 } else return VO_FALSE;
1074 if (! strcmp( data,"hue" )) {
1075 if ((desc.caps & DLCAPS_HUE)) {
1076 *value = (int) ((ca.hue-0x8000) * factor);
1077 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: GetVEq Hue 0x%X %i\n",ca.hue,*value);
1078 return VO_TRUE;
1079 } else return VO_FALSE;
1082 if (! strcmp( data,"saturation" )) {
1083 if ((desc.caps & DLCAPS_SATURATION)) {
1084 *value = (int) ((ca.saturation-0x8000) * factor);
1085 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: GetVEq Saturation 0x%X %i\n",ca.saturation,*value);
1086 return VO_TRUE;
1087 } else return VO_FALSE;
1090 return VO_FALSE;
1093 static uint32_t get_image(mp_image_t *mpi)
1096 int err;
1097 uint8_t *dst;
1098 int pitch;
1100 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: get_image() called\n");
1101 if(mpi->flags&MP_IMGFLAG_READABLE) return VO_FALSE; // slow video ram
1102 if(mpi->type==MP_IMGTYPE_STATIC) return VO_FALSE; // it is not static
1104 // printf("width=%d vs. pitch=%d, flags=0x%X \n",mpi->width,pitch,mpi->flags);
1106 if(mpi->flags&(MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_ACCEPT_WIDTH)){
1107 // we're lucky or codec accepts stride => ok, let's go!
1109 if (frame) {
1110 err = frame->Lock(frame,DSLF_WRITE|DSLF_READ,(void *)&dst,&pitch);
1111 framelocked=1;
1112 } else {
1113 err = primary->Lock(primary,DSLF_WRITE,(void *)&dst,&pitch);
1114 primarylocked=1;
1117 if (err) {
1118 mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: DR lock failed!");
1119 return VO_FALSE;
1122 if(mpi->flags&MP_IMGFLAG_PLANAR){
1123 //YV12 format
1124 mpi->planes[0]=dst;
1125 if(mpi->flags&MP_IMGFLAG_SWAPPED){
1126 mpi->planes[1]=dst + pitch*height;
1127 mpi->planes[2]=mpi->planes[1] + pitch*height/4;
1128 } else {
1129 mpi->planes[2]=dst + pitch*height;
1130 mpi->planes[1]=mpi->planes[2] + pitch*height/4;
1132 mpi->width=width;
1133 mpi->stride[0]=pitch;
1134 mpi->stride[1]=mpi->stride[2]=pitch/2;
1135 } else {
1136 //YUY2 and RGB formats
1137 mpi->planes[0]=dst;
1138 mpi->width=width;
1139 mpi->stride[0]=pitch;
1142 // center image
1144 if (!frame) {
1145 if(mpi->flags&MP_IMGFLAG_PLANAR){
1146 mpi->planes[0]= dst + yoffset * pitch + xoffset;
1147 mpi->planes[1]+= ((yoffset * pitch) >> 2) + (xoffset >> 1);
1148 mpi->planes[2]+= ((yoffset * pitch) >> 2) + (xoffset >> 1);
1149 } else {
1150 mpi->planes[0]=dst + yoffset * pitch + xoffset * (mpi->bpp >> 3);
1154 mpi->flags|=MP_IMGFLAG_DIRECT;
1155 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: get_image() SUCCESS -> Direct Rendering ENABLED\n");
1156 return VO_TRUE;
1159 return VO_FALSE;
1162 static int draw_slice(uint8_t *src[], int stride[], int w, int h, int x, int y)
1164 int i;
1165 unsigned int pitch;
1166 uint8_t *dst;
1167 uint8_t *dst2;
1168 uint8_t *srcp;
1169 unsigned int p;
1171 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: draw_slice entered\n");
1173 unlock();
1175 if (frame) {
1176 DFBCHECK (frame->Lock(frame,DSLF_WRITE|DSLF_READ,(void *)&dst,&pitch));
1177 framelocked = 1;
1178 } else {
1179 DFBCHECK (primary->Lock(primary,DSLF_WRITE,(void *)&dst,&pitch));
1180 primarylocked = 1;
1183 p = FFMIN(w, pitch);
1185 dst += y*pitch + x;
1186 dst2 = dst + pitch*height - y*pitch + y*pitch/4 - x/2;
1187 srcp = src[0];
1189 for (i=0;i<h;i++) {
1190 fast_memcpy(dst,srcp,p);
1191 dst += pitch;
1192 srcp += stride[0];
1195 if (pixel_format == DSPF_YV12) {
1197 dst = dst2;
1198 srcp = src[2];
1199 p = p/2;
1201 for (i=0;i<h/2;i++) {
1202 fast_memcpy(dst,srcp,p);
1203 dst += pitch/2;
1204 srcp += stride[2];
1207 dst = dst2 + pitch*height/4;
1208 srcp = src[1];
1210 for (i=0;i<h/2;i++) {
1211 fast_memcpy(dst,srcp,p);
1212 dst += pitch/2;
1213 srcp += stride[1];
1216 } else {
1218 dst = dst2;
1219 srcp = src[1];
1220 p = p/2;
1222 for (i=0;i<h/2;i++) {
1223 fast_memcpy(dst,srcp,p);
1224 dst += pitch/2;
1225 srcp += stride[1];
1228 dst = dst2 + pitch*height/4;
1229 srcp = src[2];
1231 for (i=0;i<h/2;i++) {
1232 fast_memcpy(dst,srcp,p);
1233 dst += pitch/2;
1234 srcp += stride[2];
1239 unlock();
1241 return 0;
1245 static uint32_t put_image(mp_image_t *mpi){
1248 // static IDirectFBSurface *tmp = NULL;
1249 // DFBSurfaceDescription dsc;
1250 // DFBRectangle rect;
1252 // 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);
1254 unlock();
1256 // already out?
1257 if((mpi->flags&(MP_IMGFLAG_DIRECT|MP_IMGFLAG_DRAW_CALLBACK))) {
1258 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: Put_image - nothing to do\n");
1259 return VO_TRUE;
1262 if (mpi->flags&MP_IMGFLAG_PLANAR) {
1263 // memcpy all planes - sad but necessary
1264 int i;
1265 unsigned int pitch;
1266 uint8_t *dst;
1267 uint8_t *src;
1268 unsigned int p;
1270 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: Put_image - planar branch\n");
1271 if (frame) {
1272 DFBCHECK (frame->Lock(frame,DSLF_WRITE|DSLF_READ,(void *)&dst,&pitch));
1273 framelocked = 1;
1274 } else {
1275 DFBCHECK (primary->Lock(primary,DSLF_WRITE,(void *)&dst,&pitch));
1276 primarylocked = 1;
1279 p = FFMIN(mpi->w, pitch);
1281 src = mpi->planes[0]+mpi->y*mpi->stride[0]+mpi->x;
1283 for (i=0;i<mpi->h;i++) {
1284 fast_memcpy(dst+i*pitch,src+i*mpi->stride[0],p);
1288 if (pixel_format == DSPF_YV12) {
1290 dst += pitch*height;
1291 p = p/2;
1292 src = mpi->planes[2]+mpi->y*mpi->stride[2]+mpi->x/2;
1294 for (i=0;i<mpi->h/2;i++) {
1295 fast_memcpy(dst+i*pitch/2,src+i*mpi->stride[2],p);
1298 dst += pitch*height/4;
1299 src = mpi->planes[1]+mpi->y*mpi->stride[1]+mpi->x/2;
1301 for (i=0;i<mpi->h/2;i++) {
1302 fast_memcpy(dst+i*pitch/2,src+i*mpi->stride[1],p);
1305 } else {
1307 dst += pitch*height;
1308 p = p/2;
1309 src = mpi->planes[1]+mpi->y*mpi->stride[1]+mpi->x/2;
1311 for (i=0;i<mpi->h/2;i++) {
1312 fast_memcpy(dst+i*pitch/2,src+i*mpi->stride[1],p);
1315 dst += pitch*height/4;
1316 src = mpi->planes[2]+mpi->y*mpi->stride[2]+mpi->x/2;
1318 for (i=0;i<mpi->h/2;i++) {
1319 fast_memcpy(dst+i*pitch/2,src+i*mpi->stride[2],p);
1323 unlock();
1325 } else {
1326 // I had to disable native directfb blit because it wasn't working under some conditions :-(
1329 dsc.flags = DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_WIDTH | DSDESC_PREALLOCATED;
1330 dsc.preallocated[0].data = mpi->planes[0];
1331 dsc.preallocated[0].pitch = mpi->stride[0];
1332 dsc.width = mpi->width;
1333 dsc.height = mpi->height;
1334 dsc.pixelformat = convformat(mpi->imgfmt);
1336 DFBCHECK (dfb->CreateSurface( dfb, &dsc, &tmp));
1338 rect.x=mpi->x;
1339 rect.y=mpi->y;
1340 rect.w=mpi->w;
1341 rect.h=mpi->h;
1343 if (frame) {
1344 DFBCHECK (tmp->Blit(tmp,frame,&rect,0,0));
1345 } else {
1346 DFBCHECK (tmp->Blit(tmp,primary,&rect,xoffset,yoffset));
1348 tmp->Release(tmp);
1351 unsigned int pitch;
1352 uint8_t *dst;
1354 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: Put_image - non-planar branch\n");
1355 if (frame) {
1356 DFBCHECK (frame->Lock(frame,DSLF_WRITE,(void *)&dst,&pitch));
1357 framelocked = 1;
1358 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]);
1359 } else {
1360 DFBCHECK (primary->Lock(primary,DSLF_WRITE,(void *)&dst,&pitch));
1361 primarylocked = 1;
1362 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]);
1364 unlock();
1367 return VO_TRUE;
1372 static int control(uint32_t request, void *data)
1374 switch (request) {
1375 case VOCTRL_QUERY_FORMAT:
1376 return query_format(*((uint32_t*)data));
1377 case VOCTRL_GET_IMAGE:
1378 return get_image(data);
1379 case VOCTRL_DRAW_IMAGE:
1380 return put_image(data);
1381 case VOCTRL_SET_EQUALIZER:
1383 struct voctrl_set_equalizer_args *args = data;
1384 return directfb_set_video_eq(args->name, args->value);
1386 case VOCTRL_GET_EQUALIZER:
1388 struct voctrl_get_equalizer_args *args = data;
1389 return directfb_get_video_eq(args->name, args->valueptr);
1392 return VO_NOTIMPL;
1395 // unused function
1397 static int draw_frame(uint8_t *src[])
1399 return -1;
1402 // hopefully will be removed soon
1404 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src,
1405 unsigned char *srca, int stride)
1407 void *dst;
1408 int pitch;
1410 unlock(); // isn't it silly I have to unlock surface and then lock it again :-)
1412 if (frame) {
1413 DFBCHECK (frame->Lock(frame,DSLF_WRITE|DSLF_READ,&dst,&pitch));
1414 framelocked = 1;
1415 } else {
1416 DFBCHECK (primary->Lock(primary,DSLF_WRITE,&dst,&pitch));
1417 primarylocked = 1;
1420 switch(pixel_format) {
1421 case DSPF_RGB32:
1422 case DSPF_ARGB:
1423 vo_draw_alpha_rgb32(w,h,src,srca,stride,((uint8_t *) dst)+pitch*y0 + 4*x0,pitch);
1424 break;
1426 case DSPF_RGB24:
1427 vo_draw_alpha_rgb24(w,h,src,srca,stride,((uint8_t *) dst)+pitch*y0 + 3*x0,pitch);
1428 break;
1430 case DSPF_RGB16:
1431 vo_draw_alpha_rgb16(w,h,src,srca,stride,((uint8_t *) dst)+pitch*y0 + 2*x0,pitch);
1432 break;
1433 case DSPF_ARGB1555:
1434 vo_draw_alpha_rgb15(w,h,src,srca,stride,((uint8_t *) dst)+pitch*y0 + 2*x0,pitch);
1435 break;
1436 case DSPF_ARGB4444:
1437 vo_draw_alpha_rgb12(w, h, src, srca, stride,
1438 ((uint8_t *) dst) + pitch * y0 + 2 * x0,
1439 pitch);
1440 break;
1442 case DSPF_YUY2:
1443 vo_draw_alpha_yuy2(w,h,src,srca,stride,((uint8_t *) dst) + pitch*y0 + 2*x0,pitch);
1444 break;
1446 case DSPF_UYVY:
1447 vo_draw_alpha_yuy2(w,h,src,srca,stride,((uint8_t *) dst) + pitch*y0 + 2*x0 + 1,pitch);
1448 break;
1450 case DSPF_I420:
1451 case DSPF_YV12:
1452 vo_draw_alpha_yv12(w,h,src,srca,stride,((uint8_t *) dst) + pitch*y0 + 1*x0,pitch);
1453 break;
1456 unlock();
1459 static void draw_osd(void)
1461 vo_draw_text(width,height,draw_alpha);