Mercurial > mplayer.hg
annotate libvo/vo_directfb2.c @ 9507:b6fe3b8b6b10
sync
author | gabucino |
---|---|
date | Thu, 27 Feb 2003 14:02:38 +0000 |
parents | edfe34c5405d |
children | d3af25abde21 |
rev | line source |
---|---|
6952 | 1 /* |
2 MPlayer video driver for DirectFramebuffer device | |
3 | |
4 (C) 2002 | |
5 | |
6 Written by Jiri Svoboda <Jiri.Svoboda@seznam.cz> | |
7 | |
8 This library is free software; you can redistribute it and/or | |
9 modify it under the terms of the GNU Lesser General Public | |
10 License as published by the Free Software Foundation; either | |
11 version 2 of the License, or (at your option) any later version. | |
12 | |
13 This library is distributed in the hope that it will be useful, | |
14 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 Lesser General Public License for more details. | |
17 | |
18 You should have received a copy of the GNU Lesser General Public | |
19 License along with this library; if not, write to the | |
20 Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
21 Boston, MA 02111-1307, USA. | |
22 */ | |
23 | |
24 // directfb includes | |
25 | |
26 #include <directfb.h> | |
27 | |
28 // other things | |
29 | |
30 #include <stdio.h> | |
31 #include <stdlib.h> | |
32 #include <string.h> | |
33 #include <fcntl.h> | |
34 #include <unistd.h> | |
35 #include <errno.h> | |
36 #include <ctype.h> | |
37 #include <assert.h> | |
38 | |
39 #include <sys/mman.h> | |
40 #include <sys/ioctl.h> | |
8137
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
41 #ifdef __linux__ |
6952 | 42 #include <sys/kd.h> |
8137
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
43 #else |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
44 #include <linux/kd.h> |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
45 #endif |
6952 | 46 |
47 #include "config.h" | |
48 #include "video_out.h" | |
49 #include "video_out_internal.h" | |
50 #include "fastmemcpy.h" | |
51 #include "sub.h" | |
52 | |
53 #include "aspect.h" | |
54 | |
55 #ifndef min | |
56 #define min(x,y) (((x)<(y))?(x):(y)) | |
57 #endif | |
58 | |
59 | |
8148
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
8137
diff
changeset
|
60 static vo_info_t info = { |
6952 | 61 "Direct Framebuffer Device", |
62 "directfb", | |
63 "Jiri Svoboda Jiri.Svoboda@seznam.cz", | |
8137
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
64 "v 2.0 (for DirectFB version >=0.9.13)" |
6952 | 65 }; |
66 | |
8148
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
8137
diff
changeset
|
67 LIBVO_EXTERN(directfb) |
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
8137
diff
changeset
|
68 |
6952 | 69 extern int verbose; |
70 | |
71 /****************************** | |
72 * vo_directfb globals * | |
73 ******************************/ | |
74 | |
75 #define DFBCHECK(x...) \ | |
76 { \ | |
77 DFBResult err = x; \ | |
78 \ | |
79 if (err != DFB_OK) \ | |
80 { \ | |
81 fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \ | |
82 DirectFBErrorFatal( #x, err ); \ | |
83 } \ | |
84 } | |
85 | |
86 /* | |
87 * filled by preinit | |
88 */ | |
89 | |
90 // main DirectFB handle | |
91 static IDirectFB *dfb = NULL; | |
92 // keyboard handle | |
93 static IDirectFBInputDevice *keyboard = NULL; | |
94 // A buffer for input events. | |
95 static IDirectFBEventBuffer *buffer = NULL; | |
96 | |
97 /* | |
98 * filled during config | |
99 */ | |
100 | |
101 // handle of used layer | |
102 static IDirectFBDisplayLayer *layer = NULL; | |
103 // surface of used layer | |
104 static IDirectFBSurface *primary = NULL; | |
105 static int primarylocked = 0; | |
106 // handle of temporary surface (if used) | |
107 static IDirectFBSurface *frame = NULL; | |
108 static int framelocked = 0; | |
109 // flipping mode flag (layer/surface) | |
110 static int flipping = 0; | |
111 // scaling flag | |
112 static int stretch = 0; | |
113 // pictrure position | |
114 static int xoffset=0,yoffset=0; | |
115 // picture size | |
116 static int out_width=0,out_height=0; | |
117 // frame/primary size | |
118 static int width=0,height=0; | |
119 // frame primary format | |
120 DFBSurfacePixelFormat pixel_format; | |
121 /* | |
122 static void (*draw_alpha_p)(int w, int h, unsigned char *src, | |
123 unsigned char *srca, int stride, unsigned char *dst, | |
124 int dstride); | |
125 */ | |
126 | |
127 /****************************** | |
128 * cmd line parameteres * | |
129 ******************************/ | |
130 | |
131 /* command line/config file options */ | |
132 #ifdef HAVE_FBDEV | |
133 extern char *fb_dev_name; | |
134 #else | |
135 char *fb_dev_name; | |
136 #endif | |
8137
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
137 char *dfb_params; |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
138 int layer_id = -1; |
6952 | 139 |
140 /****************************** | |
141 * implementation * | |
142 ******************************/ | |
143 | |
144 void unlock() { | |
145 if (frame && framelocked) frame->Unlock(frame); | |
146 if (primary && primarylocked) primary->Unlock(primary); | |
147 } | |
148 | |
149 | |
150 static uint32_t preinit(const char *arg) | |
151 { | |
152 | |
153 DFBResult ret; | |
154 | |
155 if (verbose) printf("DirectFB: Preinit entered\n"); | |
156 | |
8137
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
157 if (arg) { |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
158 int tmp=-1; |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
159 if (sscanf(arg,"%i",&tmp)) { |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
160 layer_id=tmp; |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
161 if (verbose) printf("DirectFB: Layer id forced to %i\n",layer_id); |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
162 }; |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
163 } |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
164 |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
165 if (dfb_params) |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
166 { |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
167 int argc = 2; |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
168 char arg0[10] = "mplayer"; |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
169 char arg1[256] = "--dfb:"; |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
170 char* argv[3]; |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
171 char ** a; |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
172 |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
173 a = &argv[0]; |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
174 |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
175 strncat(arg1,dfb_params,249); |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
176 |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
177 argv[0]=arg0; |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
178 argv[1]=arg1; |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
179 argv[2]=NULL; |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
180 |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
181 DFBCHECK (DirectFBInit (&argc,&a)); |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
182 |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
183 } else { |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
184 |
6952 | 185 DFBCHECK (DirectFBInit (NULL,NULL)); |
8137
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
186 } |
6952 | 187 |
188 if (((directfb_major_version <= 0) && | |
189 (directfb_minor_version <= 9) && | |
190 (directfb_micro_version < 13))) | |
191 { | |
192 printf("DirectFB: Unsupported DirectFB version\n"); | |
193 return 1; | |
194 } | |
195 | |
196 /* | |
197 * (set options) | |
198 */ | |
199 | |
200 if (!fb_dev_name && !(fb_dev_name = getenv("FRAMEBUFFER"))) fb_dev_name = "/dev/fb0"; | |
201 DFBCHECK (DirectFBSetOption ("fbdev",fb_dev_name)); | |
202 | |
203 // uncomment this if you do not wish to create a new vt for DirectFB | |
204 // DFBCHECK (DirectFBSetOption ("no-vt-switch","")); | |
205 | |
206 // uncomment this if you want to allow vt switching | |
207 // DFBCHECK (DirectFBSetOption ("vt-switching","")); | |
208 | |
209 // uncomment this if you want to hide gfx cursor (req dfb >=0.9.9) | |
210 DFBCHECK (DirectFBSetOption ("no-cursor","")); | |
211 | |
212 // bg color fix | |
213 DFBCHECK (DirectFBSetOption ("bg-color","00000000")); | |
214 | |
215 /* | |
216 * (Initialize) | |
217 */ | |
218 | |
219 DFBCHECK (DirectFBCreate (&dfb)); | |
8137
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
220 if (DFB_OK != dfb->SetCooperativeLevel (dfb, DFSCL_FULLSCREEN)) { |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
221 printf("DirectFB: Warning - cannot swith to fullscreen mode"); |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
222 }; |
6952 | 223 |
224 /* | |
225 * (Get keyboard) | |
226 */ | |
227 | |
228 ret = dfb->GetInputDevice (dfb, DIDID_KEYBOARD, &keyboard); | |
229 | |
230 if (ret==DFB_OK) { | |
231 if (verbose) { | |
232 printf("DirectFB: Keyboard init OK\n"); | |
233 } | |
234 } else { | |
235 keyboard = NULL; | |
236 printf("DirectFB: Keyboard init FAILED\n"); | |
237 } | |
238 | |
239 /* | |
240 * Create an input buffer for the keyboard. | |
241 */ | |
242 if (keyboard) DFBCHECK (keyboard->CreateEventBuffer (keyboard, &buffer)); | |
243 | |
244 // just to start with clean ... | |
245 if (buffer) buffer->Reset(buffer); | |
246 | |
247 if (verbose) { | |
248 printf("DirectFB: Preinit OK\n"); | |
249 } | |
250 | |
251 return 0; | |
252 | |
253 } | |
254 | |
255 DFBSurfacePixelFormat convformat(uint32_t format) | |
256 { | |
257 // add more formats !!! | |
258 switch (format) { | |
259 case IMGFMT_RGB32: return DSPF_RGB32; break; | |
260 case IMGFMT_BGR32: return DSPF_RGB32; break; | |
261 case IMGFMT_RGB24: return DSPF_RGB24; break; | |
262 case IMGFMT_BGR24: return DSPF_RGB24; break; | |
263 case IMGFMT_RGB16: return DSPF_RGB16; break; | |
264 case IMGFMT_BGR16: return DSPF_RGB16; break; | |
8640 | 265 #if DIRECTFBVERSION > 915 |
266 case IMGFMT_RGB15: return DSPF_ARGB1555; break; | |
267 case IMGFMT_BGR15: return DSPF_ARGB1555; break; | |
268 #else | |
6952 | 269 case IMGFMT_RGB15: return DSPF_RGB15; break; |
270 case IMGFMT_BGR15: return DSPF_RGB15; break; | |
8640 | 271 #endif |
6952 | 272 case IMGFMT_YUY2: return DSPF_YUY2; break; |
273 case IMGFMT_UYVY: return DSPF_UYVY; break; | |
274 case IMGFMT_YV12: return DSPF_YV12; break; | |
275 case IMGFMT_I420: return DSPF_I420; break; | |
276 // case IMGFMT_IYUV: return DSPF_IYUV; break; | |
277 default: return 0; | |
278 } | |
279 return 0; | |
280 } | |
281 | |
282 typedef struct enum1_s { | |
283 uint32_t format; | |
284 int scale; | |
285 int result; | |
286 unsigned int id; | |
287 unsigned int width; | |
288 unsigned int height; | |
289 int setsize; | |
290 } enum1_t; | |
291 | |
292 DFBEnumerationResult test_format_callback( unsigned int id, | |
293 DFBDisplayLayerDescription desc, | |
294 void *data) | |
295 { | |
296 enum1_t *params =(enum1_t *)data; | |
297 IDirectFBDisplayLayer *layer; | |
298 DFBResult ret; | |
299 | |
8137
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
300 if ((layer_id == -1 )||(layer_id == id)) { |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
301 |
6952 | 302 ret = dfb->GetDisplayLayer( dfb, id, &layer); |
303 if (ret) { | |
304 DirectFBError( "dfb->GetDisplayLayer failed", ret ); | |
305 return DFENUM_OK; | |
306 } else { | |
307 DFBDisplayLayerConfig dlc; | |
308 | |
309 if (params->setsize) { | |
310 dlc.flags = DLCONF_WIDTH |DLCONF_HEIGHT; | |
311 dlc.width = params->width; | |
312 dlc.height = params->height; | |
313 layer->SetConfiguration(layer,&dlc); | |
314 } | |
315 | |
316 | |
317 dlc.flags = DLCONF_PIXELFORMAT; | |
318 dlc.pixelformat = convformat(params->format); | |
319 | |
320 layer->SetOpacity(layer,0); | |
321 ret = layer->TestConfiguration(layer,&dlc,NULL); | |
322 | |
323 layer->Release(layer); | |
324 | |
325 if (verbose) printf("DirectFB: Test format - layer %i scale/pos %i\n",id,(desc.caps & DLCAPS_SCREEN_LOCATION)); | |
326 | |
327 if (!ret) { | |
328 // printf("Test OK\n"); | |
329 if (params->result) { | |
330 if ((!params->scale) && (desc.caps & DLCAPS_SCREEN_LOCATION)) { | |
331 params->scale=1; | |
332 params->id=id; | |
333 if (verbose) printf("DirectFB: Test format - added layer %i scale/pos %i\n",id,(desc.caps & DLCAPS_SCREEN_LOCATION)); | |
334 | |
335 } | |
336 } else { | |
337 params->result=1; | |
338 params->id=id; | |
339 if (desc.caps & DLCAPS_SCREEN_LOCATION) params->scale=1; | |
340 if (verbose) printf("DirectFB: Test format - added layer %i scale/pos %i\n",id,(desc.caps & DLCAPS_SCREEN_LOCATION)); | |
341 }; | |
342 }; | |
343 }; | |
344 | |
8137
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
345 }; |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
346 |
6952 | 347 return DFENUM_OK; |
348 } | |
349 | |
350 static uint32_t query_format(uint32_t format) | |
351 { | |
352 int ret = VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_OSD; // osd should be removed in future -> will be handled outside... | |
353 enum1_t params; | |
354 | |
355 | |
356 if (!convformat(format)) return 0; | |
357 // temporary disable YV12 | |
358 // if (format == IMGFMT_YV12) return 0; | |
359 // if (format == IMGFMT_I420) return 0; | |
360 if (format == IMGFMT_IYUV) return 0; | |
361 | |
362 if (verbose) printf("DirectFB: Format query: %s\n",vo_format_name(format)); | |
363 | |
364 params.format=format; | |
365 params.scale=0; | |
366 params.result=0; | |
367 params.setsize=0; | |
368 | |
369 DFBCHECK (dfb->EnumDisplayLayers(dfb,test_format_callback,¶ms)); | |
370 | |
371 if (params.result) { | |
372 if (params.scale) ret |=VFCAP_HWSCALE_UP|VFCAP_HWSCALE_DOWN; | |
373 return ret; | |
374 } | |
375 | |
376 return 0; | |
377 } | |
378 | |
379 typedef struct videomode_s { | |
380 int width; | |
381 int height; | |
382 int out_width; | |
383 int out_height; | |
384 int overx; | |
385 int overy; | |
386 int bpp; | |
387 } videomode_t; | |
388 | |
389 | |
390 DFBEnumerationResult video_modes_callback( unsigned int width,unsigned int height,unsigned int bpp, void *data) | |
391 { | |
392 videomode_t *params =(videomode_t *)data; | |
393 | |
394 int overx=0,overy=0,closer=0,over=0; | |
395 int we_are_under=0; | |
396 | |
397 if (verbose) printf("DirectFB: Validator entered %i %i %i\n",width,height,bpp); | |
398 | |
399 overx=width-params->out_width; | |
400 overy=height-params->out_height; | |
401 | |
402 if (!params->width) { | |
403 params->width=width; | |
404 params->height=height; | |
405 params->overx=overx; | |
406 params->overy=overy; | |
407 if (verbose) printf("DirectFB: Mode added %i %i %i\n",width,height,bpp); | |
408 } | |
409 | |
410 if ((params->overy<0)||(params->overx<0)) we_are_under=1; // stored mode is smaller than req mode | |
411 if (abs(overx*overy)<abs(params->overx * params->overy)) closer=1; // current mode is closer to desired res | |
412 if ((overx>=0)&&(overy>=0)) over=1; // current mode is bigger or equaul to desired res | |
413 if ((closer && (over || we_are_under)) || (we_are_under && over)) { | |
414 params->width=width; | |
415 params->height=height; | |
416 params->overx=overx; | |
417 params->overy=overy; | |
418 if (verbose) printf("DirectFB: Better mode added %i %i %i\n",width,height,bpp); | |
419 }; | |
420 | |
421 return DFENUM_OK; | |
422 } | |
423 | |
424 #define CONFIG_ERROR -1 | |
425 | |
426 static uint32_t config(uint32_t s_width, uint32_t s_height, uint32_t d_width, | |
427 uint32_t d_height, uint32_t fullscreen, char *title, | |
7272 | 428 uint32_t format) |
6952 | 429 { |
430 /* | |
431 * (Locals) | |
432 */ | |
433 | |
434 // decode flags | |
435 | |
436 int fs = fullscreen & 0x01; | |
437 int vm = fullscreen & 0x02; | |
438 int zoom = fullscreen & 0x04; | |
439 int flip = fullscreen & 0x08; | |
440 | |
441 DFBSurfaceDescription dsc; | |
442 DFBResult ret; | |
443 DFBDisplayLayerConfig dlc; | |
444 DFBSurfaceCapabilities caps; | |
445 | |
446 enum1_t params; | |
447 | |
448 if (verbose) { | |
449 printf("DirectFB: Config entered [%ix%i]\n",s_width,s_height); | |
450 printf("DirectFB: With requested format: %s\n",vo_format_name(format)); | |
451 } | |
452 // initial clean-up | |
453 if (frame) { | |
454 frame->Release(frame); | |
455 frame=NULL; | |
456 } | |
457 | |
458 if (primary) { | |
459 primary->Release(primary); | |
460 primary=NULL; | |
461 } | |
462 | |
463 if (layer) { | |
464 layer->Release(layer); | |
465 layer=NULL; | |
466 } | |
467 | |
468 | |
469 // vm things | |
470 | |
471 if (vm) { | |
472 videomode_t params; | |
473 params.out_width=d_width; | |
474 params.out_height=d_height; | |
475 params.width=0; | |
476 params.height=0; | |
477 switch (format) { | |
478 case IMGFMT_RGB32: | |
479 case IMGFMT_BGR32: | |
480 params.bpp=32; | |
481 break; | |
482 case IMGFMT_RGB24: | |
483 case IMGFMT_BGR24: | |
484 params.bpp=24; | |
485 break; | |
486 case IMGFMT_RGB16: | |
487 case IMGFMT_BGR16: | |
488 case IMGFMT_RGB15: | |
489 case IMGFMT_BGR15: | |
490 params.bpp=16; | |
491 break; | |
492 default: params.bpp=0; | |
493 | |
494 } | |
495 if (verbose) printf("DirectFB: Config - videomode change\n"); | |
496 DFBCHECK (dfb->EnumVideoModes(dfb,video_modes_callback,¶ms)); | |
497 ret=dfb->SetVideoMode(dfb,params.width,params.height,params.bpp); | |
498 if (ret) { | |
499 ret=dfb->SetVideoMode(dfb,params.width,params.height,24); | |
500 if (ret) { | |
501 ret=dfb->SetVideoMode(dfb,params.width,params.height,32); | |
502 if (ret) { | |
503 ret=dfb->SetVideoMode(dfb,params.width,params.height,16); | |
504 if (ret) { | |
505 ret=dfb->SetVideoMode(dfb,params.width,params.height,8); | |
506 } | |
507 } | |
508 } | |
509 } | |
510 } // vm end | |
511 | |
512 // find best layer | |
513 | |
514 if (verbose) printf("DirectFB: Config - find suitable layer\n"); | |
515 params.format=format; | |
516 params.scale=0; | |
517 params.result=0; | |
518 params.width=s_width; | |
519 params.height=s_height; | |
520 params.setsize=1; | |
521 | |
522 DFBCHECK (dfb->EnumDisplayLayers(dfb,test_format_callback,¶ms)); | |
523 | |
524 if (!params.result) { | |
525 printf("DirectFB: ConfigError - no suitable layer found\n"); | |
526 params.id = DLID_PRIMARY; | |
527 } | |
6985
6074119e09a0
Put/get_image fixed. Deleted forgotten development comments
zdar
parents:
6952
diff
changeset
|
528 /* Uncomment following if you want to use tvout on CRTC2 (requieres patch for DirectFB from Ville Syrjala) |
6074119e09a0
Put/get_image fixed. Deleted forgotten development comments
zdar
parents:
6952
diff
changeset
|
529 params.id=2; |
6074119e09a0
Put/get_image fixed. Deleted forgotten development comments
zdar
parents:
6952
diff
changeset
|
530 params.scale=0; |
6074119e09a0
Put/get_image fixed. Deleted forgotten development comments
zdar
parents:
6952
diff
changeset
|
531 params.result=1; |
6074119e09a0
Put/get_image fixed. Deleted forgotten development comments
zdar
parents:
6952
diff
changeset
|
532 */ |
6952 | 533 if (verbose) printf("DirectFB: Config - layer %i\n",params.id); |
534 | |
535 | |
536 // try to setp-up proper configuration | |
537 | |
538 | |
539 DFBCHECK (dfb->GetDisplayLayer( dfb, params.id, &layer)); | |
540 | |
541 if (params.scale) { | |
542 if (verbose) printf("DirectFB: Config - set layer config (size)\n"); | |
543 dlc.flags = DLCONF_WIDTH | DLCONF_HEIGHT; | |
544 dlc.width = s_width; | |
545 dlc.height = s_height; | |
546 | |
547 ret = layer->SetConfiguration(layer,&dlc); | |
548 | |
549 if (ret && (params.scale || verbose)) printf("DirectFB: ConfigError in layer configuration (size)\n"); | |
550 | |
551 } | |
552 | |
553 dlc.flags = DLCONF_PIXELFORMAT; | |
554 dlc.pixelformat = convformat(params.format); | |
555 | |
556 // printf("DirectFB: Format [%x]\n",dlc.pixelformat); | |
557 | |
558 if (verbose) printf("DirectFB: Config - set layer config (format)\n"); | |
559 ret = layer->SetConfiguration(layer,&dlc); | |
560 | |
561 if (ret) { | |
562 printf("DirectFB: ConfigError in layer configuration (format)\n"); | |
563 return CONFIG_ERROR; | |
564 }; | |
565 | |
566 | |
567 // flipping of layer | |
568 | |
569 dlc.flags = DLCONF_BUFFERMODE; | |
570 dlc.buffermode = DLBM_BACKVIDEO; | |
571 ret = layer->SetConfiguration( layer, &dlc ); | |
572 if (ret!=DFB_OK) { | |
573 dlc.buffermode = DLBM_BACKSYSTEM; | |
574 ret = layer->SetConfiguration( layer, &dlc ); | |
575 } | |
576 | |
577 // get layer surface | |
578 | |
579 ret = layer->GetSurface(layer,&primary); | |
580 | |
581 if (ret) { | |
582 printf("DirectFB: ConfigError in obtaining surface\n"); | |
583 return CONFIG_ERROR; // what shall we report on fail? | |
584 } | |
585 | |
586 // test surface for flipping | |
587 DFBCHECK(primary->GetCapabilities(primary,&caps)); | |
8137
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
588 #if DIRECTFBVERSION > 913 |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
589 primary->Clear(primary,0,0,0,0); |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
590 #endif |
6952 | 591 flipping = 0; |
592 if (caps & DSCAPS_FLIPPING) { | |
593 ret = primary->Flip(primary,NULL,0); | |
594 if (ret==DFB_OK) { | |
8137
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
595 #if DIRECTFBVERSION > 913 |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
596 primary->Clear(primary,0,0,0,0); |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
597 #endif |
6952 | 598 flipping = 1; |
599 } | |
600 }; | |
601 | |
602 if (verbose) printf("DirectFB: Config - flipping = %i\n",flipping); | |
603 | |
604 // is scale needed ? Aspect ratio and layer pos/size | |
605 | |
606 | |
607 // get surface size | |
608 DFBCHECK(primary->GetSize(primary,&width,&height)); | |
609 | |
610 if (verbose) printf("DirectFB: Config - surface size = %ix%i\n",width,height); | |
611 | |
612 aspect_save_orig(s_width,s_height); | |
613 aspect_save_prescale(d_width,d_height); | |
614 if (params.scale) { | |
615 aspect_save_screenres(10000,10000); | |
616 aspect(&out_width,&out_height,A_ZOOM); | |
617 | |
618 ret = layer->SetScreenLocation(layer,(1-(float)out_width/10000)/2,(1-(float)out_height/10000)/2,((float)out_width/10000),((float)out_height/10000)); | |
619 | |
620 if (ret) printf("DirectFB: ConfigError in layer configuration (position)\n"); | |
621 | |
622 xoffset = 0; | |
623 yoffset = 0; | |
624 | |
625 } else { | |
626 | |
627 aspect_save_screenres(width,height); | |
628 | |
629 if(fs) /* -fs */ | |
630 aspect(&out_width,&out_height,A_ZOOM); | |
631 else | |
632 aspect(&out_width,&out_height,A_NOZOOM); | |
633 | |
634 | |
635 xoffset = (width - out_width) / 2; | |
636 yoffset = (height - out_height) / 2; | |
637 } | |
638 | |
639 if (((s_width==out_width)&&(s_height==out_height)) || (params.scale)) { | |
640 stretch = 0; | |
641 } else { | |
642 stretch = 1; | |
643 } | |
644 | |
645 | |
646 // temporary buffer in case of not flipping or scaling | |
647 if ((!flipping) || stretch) { | |
648 | |
649 DFBCHECK (primary->GetPixelFormat (primary, &dsc.pixelformat)); | |
650 | |
651 dsc.flags = DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_WIDTH; | |
652 | |
653 dsc.width = s_width; | |
654 dsc.height = s_height; | |
655 | |
656 DFBCHECK (dfb->CreateSurface( dfb, &dsc, &frame)); | |
657 DFBCHECK(frame->GetSize(frame,&width,&height)); | |
6985
6074119e09a0
Put/get_image fixed. Deleted forgotten development comments
zdar
parents:
6952
diff
changeset
|
658 if (verbose) printf("DirectFB: Frame is active.\n"); |
6952 | 659 } |
660 | |
661 // get format for draw_alpha - should be removed soon - osd will be rendered outside vo driver | |
662 if (frame) { | |
663 DFBCHECK (frame->GetPixelFormat(frame,&pixel_format)); | |
664 } else { | |
665 DFBCHECK (primary->GetPixelFormat(primary,&pixel_format)); | |
666 }; | |
667 | |
668 // finally turn on layer | |
669 layer->SetOpacity(layer,255); | |
670 | |
671 if (verbose) printf("DirectFB: Config finished [%ix%i] - [%ix%i]\n",out_width,out_height,width,height); | |
672 | |
673 return 0; | |
674 } | |
675 | |
676 extern void mplayer_put_key(int code); | |
677 | |
9380 | 678 #include "../osdep/keycodes.h" |
6952 | 679 |
680 static void check_events(void) | |
681 { | |
682 | |
683 if (buffer) { | |
684 | |
685 DFBInputEvent event; | |
686 | |
687 //if (verbose) printf ("DirectFB: Check events entered\n"); | |
688 if (buffer->GetEvent(buffer, DFB_EVENT (&event)) == DFB_OK) { | |
689 | |
690 if (event.type == DIET_KEYPRESS) { | |
691 switch (event.key_symbol) { | |
692 case DIKS_ESCAPE: | |
693 mplayer_put_key('q'); | |
694 break; | |
695 case DIKS_PAGE_UP: mplayer_put_key(KEY_PAGE_UP);break; | |
696 case DIKS_PAGE_DOWN: mplayer_put_key(KEY_PAGE_DOWN);break; | |
697 case DIKS_CURSOR_UP: mplayer_put_key(KEY_UP);break; | |
698 case DIKS_CURSOR_DOWN: mplayer_put_key(KEY_DOWN);break; | |
699 case DIKS_CURSOR_LEFT: mplayer_put_key(KEY_LEFT);break; | |
700 case DIKS_CURSOR_RIGHT: mplayer_put_key(KEY_RIGHT);break; | |
701 case DIKS_INSERT: mplayer_put_key(KEY_INSERT);break; | |
702 case DIKS_DELETE: mplayer_put_key(KEY_DELETE);break; | |
703 case DIKS_HOME: mplayer_put_key(KEY_HOME);break; | |
704 case DIKS_END: mplayer_put_key(KEY_END);break; | |
705 | |
706 default:mplayer_put_key(event.key_symbol); | |
707 }; | |
708 }; | |
709 }; | |
710 // empty buffer, because of repeating (keyboard repeat is faster than key handling | |
711 // and this causes problems during seek) | |
712 // temporary workabout should be solved in the future | |
713 buffer->Reset(buffer); | |
714 | |
715 } | |
716 //if (verbose) printf ("DirectFB: Check events finished\n"); | |
717 } | |
718 | |
719 static void flip_page(void) | |
720 { | |
721 DFBSurfaceBlittingFlags flags=DSBLIT_NOFX; | |
722 | |
723 unlock(); // unlock frame & primary | |
724 | |
725 // if (verbose) printf("DirectFB: Flip page entered"); | |
726 | |
727 DFBCHECK (primary->SetBlittingFlags(primary,flags)); | |
728 | |
729 if (frame) { | |
730 if (stretch) { | |
731 DFBRectangle rect; | |
732 rect.x=xoffset; | |
733 rect.y=yoffset; | |
734 rect.w=out_width; | |
735 rect.h=out_height; | |
736 | |
737 DFBCHECK (primary->StretchBlit(primary,frame,NULL,&rect)); | |
738 | |
739 } else { | |
740 | |
741 DFBCHECK (primary->Blit(primary,frame,NULL,xoffset,yoffset)); | |
742 | |
743 }; | |
744 }; | |
745 | |
746 | |
747 if (flipping) { | |
748 DFBCHECK (primary->Flip (primary, NULL, DSFLIP_WAITFORSYNC)); | |
749 } | |
750 | |
751 } | |
752 | |
753 | |
754 | |
755 static void uninit(void) | |
756 { | |
757 | |
758 if (verbose ) printf("DirectFB: Uninit entered\n"); | |
759 | |
760 unlock(); | |
761 | |
762 /* | |
763 * (Release) | |
764 */ | |
765 if (verbose ) printf("DirectFB: Release buffer\n"); | |
766 if (buffer) buffer->Release (buffer); | |
767 if (verbose ) printf("DirectFB: Release keyboard\n"); | |
768 if (keyboard) keyboard->Release (keyboard); | |
769 if (frame) { | |
770 if (verbose ) printf("DirectFB: Release frame\n"); | |
771 frame->Release (frame); | |
772 }; | |
773 | |
774 if (verbose ) printf("DirectFB: Release primary\n"); | |
775 if (primary) primary->Release (primary); | |
776 | |
777 // switch off BES | |
778 // if (layer) layer->SetOpacity(layer,0); | |
779 | |
780 if (layer) layer->Release(layer); | |
781 | |
782 if (verbose ) printf("DirectFB: Release DirectFB library\n"); | |
783 | |
784 dfb->Release (dfb); | |
785 | |
786 if (verbose ) printf("DirectFB: Uninit done.\n"); | |
787 } | |
788 | |
789 | |
790 static uint32_t directfb_set_video_eq(char *data, int value) //data==name | |
791 { | |
792 | |
793 DFBColorAdjustment ca; | |
794 float factor = (float)0xffff / 200.0; | |
795 | |
796 DFBDisplayLayerDescription desc; | |
797 | |
798 unlock(); | |
799 | |
800 if (layer) { | |
801 | |
802 layer->GetDescription(layer,&desc); | |
803 | |
804 ca.flags=DCAF_NONE; | |
805 | |
806 if (! strcmp( data,"brightness" )) { | |
807 if (desc.caps & DLCAPS_BRIGHTNESS) { | |
808 ca.brightness = value * factor +0x8000; | |
809 ca.flags |= DCAF_BRIGHTNESS; | |
810 if (verbose) printf("DirectFB: SetVEq Brightness 0x%X %i\n",ca.brightness,value); | |
811 } else return VO_FALSE; | |
812 } | |
813 | |
814 if (! strcmp( data,"contrast" )) { | |
815 if ((desc.caps & DLCAPS_CONTRAST)) { | |
816 ca.contrast = value * factor + 0x8000; | |
817 ca.flags |= DCAF_CONTRAST; | |
818 if (verbose) printf("DirectFB: SetVEq Contrast 0x%X %i\n",ca.contrast,value); | |
819 } else return VO_FALSE; | |
820 } | |
821 | |
822 if (! strcmp( data,"hue" )) { | |
823 if ((desc.caps & DLCAPS_HUE)) { | |
824 ca.hue = value * factor + 0x8000; | |
825 ca.flags |= DCAF_HUE; | |
826 if (verbose) printf("DirectFB: SetVEq Hue 0x%X %i\n",ca.hue,value); | |
827 } else return VO_FALSE; | |
828 } | |
829 | |
830 if (! strcmp( data,"saturation" )) { | |
831 if ((desc.caps & DLCAPS_SATURATION)) { | |
832 ca.saturation = value * factor + 0x8000; | |
833 ca.flags |= DCAF_SATURATION; | |
834 if (verbose) printf("DirectFB: SetVEq Saturation 0x%X %i\n",ca.saturation,value); | |
835 } else return VO_FALSE; | |
836 } | |
837 | |
838 if (ca.flags != DCAF_NONE) { | |
839 layer->SetColorAdjustment(layer,&ca); | |
840 return VO_TRUE; | |
841 } | |
842 } | |
843 | |
844 return VO_FALSE; | |
845 | |
846 } | |
847 | |
848 static uint32_t directfb_get_video_eq(char *data, int *value) // data==name | |
849 { | |
850 | |
851 DFBColorAdjustment ca; | |
852 float factor = 200.0 / (float)0xffff; | |
853 | |
854 DFBDisplayLayerDescription desc; | |
855 | |
856 if (layer) { | |
857 | |
858 unlock(); | |
859 | |
860 layer->GetDescription(layer,&desc); | |
861 | |
862 layer->GetColorAdjustment(layer,&ca); | |
863 | |
864 if (! strcmp( data,"brightness" )) { | |
865 if (desc.caps & DLCAPS_BRIGHTNESS) { | |
866 *value = (int) ((ca.brightness-0x8000) * factor); | |
867 if (verbose) printf("DirectFB: GetVEq Brightness 0x%X %i\n",ca.brightness,*value); | |
868 return VO_TRUE; | |
869 } else return VO_FALSE; | |
870 } | |
871 | |
872 if (! strcmp( data,"contrast" )) { | |
873 if ((desc.caps & DLCAPS_CONTRAST)) { | |
874 *value = (int) ((ca.contrast-0x8000) * factor); | |
875 if (verbose) printf("DirectFB: GetVEq Contrast 0x%X %i\n",ca.contrast,*value); | |
876 return VO_TRUE; | |
877 } else return VO_FALSE; | |
878 } | |
879 | |
880 if (! strcmp( data,"hue" )) { | |
881 if ((desc.caps & DLCAPS_HUE)) { | |
882 *value = (int) ((ca.hue-0x8000) * factor); | |
883 if (verbose) printf("DirectFB: GetVEq Hue 0x%X %i\n",ca.hue,*value); | |
884 return VO_TRUE; | |
885 } else return VO_FALSE; | |
886 } | |
887 | |
888 if (! strcmp( data,"saturation" )) { | |
889 if ((desc.caps & DLCAPS_SATURATION)) { | |
890 *value = (int) ((ca.saturation-0x8000) * factor); | |
891 if (verbose) printf("DirectFB: GetVEq Saturation 0x%X %i\n",ca.saturation,*value); | |
892 return VO_TRUE; | |
893 } else return VO_FALSE; | |
894 } | |
895 } | |
896 return VO_FALSE; | |
897 } | |
898 | |
899 static uint32_t get_image(mp_image_t *mpi) | |
900 { | |
901 | |
902 int err; | |
903 void *dst; | |
904 int pitch; | |
905 | |
906 // if (verbose) printf("DirectFB: get_image() called\n"); | |
907 if(mpi->flags&MP_IMGFLAG_READABLE) return VO_FALSE; // slow video ram | |
908 if(mpi->type==MP_IMGTYPE_STATIC) return VO_FALSE; // it is not static | |
909 | |
910 // printf("width=%d vs. pitch=%d, flags=0x%X \n",mpi->width,pitch,mpi->flags); | |
911 | |
6985
6074119e09a0
Put/get_image fixed. Deleted forgotten development comments
zdar
parents:
6952
diff
changeset
|
912 if((mpi->width==pitch) || |
6952 | 913 (mpi->flags&(MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_ACCEPT_WIDTH))){ |
914 // we're lucky or codec accepts stride => ok, let's go! | |
915 | |
916 if (frame) { | |
917 err = frame->Lock(frame,DSLF_WRITE,&dst,&pitch); | |
918 framelocked=1; | |
919 } else { | |
920 err = primary->Lock(primary,DSLF_WRITE,&dst,&pitch); | |
921 primarylocked=1; | |
922 } | |
923 | |
924 if (err) { | |
925 if (verbose) printf("DirectFB: DR lock failed!"); | |
926 return VO_FALSE; | |
927 }; | |
928 | |
929 if(mpi->flags&MP_IMGFLAG_PLANAR){ | |
930 //YV12 format | |
931 mpi->planes[0]=dst; | |
932 if(mpi->flags&MP_IMGFLAG_SWAPPED){ | |
933 mpi->planes[1]=dst + pitch*height; | |
934 mpi->planes[2]=mpi->planes[1] + pitch*height/4; | |
935 } else { | |
936 mpi->planes[2]=dst + pitch*height; | |
937 mpi->planes[1]=mpi->planes[2] + pitch*height/4; | |
938 } | |
6985
6074119e09a0
Put/get_image fixed. Deleted forgotten development comments
zdar
parents:
6952
diff
changeset
|
939 mpi->width=width; |
6074119e09a0
Put/get_image fixed. Deleted forgotten development comments
zdar
parents:
6952
diff
changeset
|
940 mpi->stride[0]=pitch; |
6952 | 941 mpi->stride[1]=mpi->stride[2]=pitch/2; |
942 } else { | |
943 //YUY2 and RGB formats | |
944 mpi->planes[0]=dst; | |
945 mpi->width=width; | |
946 mpi->stride[0]=pitch; | |
947 } | |
948 mpi->flags|=MP_IMGFLAG_DIRECT; | |
949 // if (verbose) printf("DirectFB: get_image() SUCCESS -> Direct Rendering ENABLED\n"); | |
950 return VO_TRUE; | |
951 | |
952 } | |
953 return VO_FALSE; | |
954 } | |
955 | |
956 static uint32_t draw_slice(uint8_t *src[], int stride[], int w, int h, int x, int y) | |
957 { | |
958 int i; | |
959 unsigned int pitch; | |
960 void *dst; | |
961 void *dst2; | |
962 void *srcp; | |
963 unsigned int p; | |
964 | |
965 unlock(); | |
966 | |
967 if (frame) { | |
968 DFBCHECK (frame->Lock(frame,DSLF_WRITE,&dst,&pitch)); | |
969 framelocked = 1; | |
970 } else { | |
971 DFBCHECK (primary->Lock(primary,DSLF_WRITE,&dst,&pitch)); | |
972 primarylocked = 1; | |
973 }; | |
974 | |
975 p=min(w,pitch); | |
976 | |
977 dst += y*pitch + x; | |
978 dst2 = dst + pitch*height - y*pitch + y*pitch/4 - x/2; | |
979 srcp = src[0]; | |
980 | |
981 for (i=0;i<h;i++) { | |
982 memcpy(dst,srcp,p); | |
983 dst += pitch; | |
984 srcp += stride[0]; | |
985 } | |
986 | |
987 if (pixel_format == DSPF_YV12) { | |
988 | |
989 dst = dst2; | |
990 srcp = src[2]; | |
991 p = p/2; | |
992 | |
993 for (i=0;i<h/2;i++) { | |
994 memcpy(dst,srcp,p); | |
995 dst += pitch/2; | |
996 srcp += stride[2]; | |
997 } | |
998 | |
999 dst = dst2 + pitch*height/4; | |
1000 srcp = src[1]; | |
1001 | |
1002 for (i=0;i<h/2;i++) { | |
1003 memcpy(dst,srcp,p); | |
1004 dst += pitch/2; | |
1005 srcp += stride[1]; | |
1006 } | |
1007 | |
1008 } else { | |
1009 | |
1010 dst = dst2; | |
1011 srcp = src[1]; | |
1012 p = p/2; | |
1013 | |
1014 for (i=0;i<h/2;i++) { | |
1015 memcpy(dst,srcp,p); | |
1016 dst += pitch/2; | |
1017 srcp += stride[1]; | |
1018 } | |
1019 | |
1020 dst = dst2 + pitch*height/4; | |
1021 srcp = src[2]; | |
1022 | |
1023 for (i=0;i<h/2;i++) { | |
1024 memcpy(dst,srcp,p); | |
1025 dst += pitch/2; | |
1026 srcp += stride[2]; | |
1027 } | |
1028 | |
1029 } | |
1030 | |
1031 unlock(); | |
1032 | |
1033 return 0; | |
1034 } | |
1035 | |
1036 | |
1037 static uint32_t put_image(mp_image_t *mpi){ | |
1038 | |
1039 | |
1040 static IDirectFBSurface *tmp = NULL; | |
1041 DFBSurfaceDescription dsc; | |
1042 DFBRectangle rect; | |
1043 | |
1044 // if (verbose) printf("DirectFB: Put_image entered %i %i %i %i %i %i\n",mpi->x,mpi->y,mpi->w,mpi->h,mpi->width,mpi->height); | |
1045 | |
1046 unlock(); | |
1047 | |
1048 // already out? | |
6985
6074119e09a0
Put/get_image fixed. Deleted forgotten development comments
zdar
parents:
6952
diff
changeset
|
1049 if((mpi->flags&(MP_IMGFLAG_DIRECT|MP_IMGFLAG_DRAW_CALLBACK))) { |
6952 | 1050 // if (verbose) printf("DirectFB: Put_image - nothing todo\n"); |
1051 return VO_TRUE; | |
1052 } | |
1053 | |
1054 if (mpi->flags&MP_IMGFLAG_PLANAR) { | |
1055 // memcpy all planes - sad but necessary | |
1056 int i; | |
1057 unsigned int pitch; | |
1058 void *dst; | |
1059 void *src; | |
1060 unsigned int p; | |
1061 | |
1062 // if (verbose) printf("DirectFB: Put_image - planar branch\n"); | |
1063 if (frame) { | |
1064 DFBCHECK (frame->Lock(frame,DSLF_WRITE,&dst,&pitch)); | |
1065 framelocked = 1; | |
1066 } else { | |
1067 DFBCHECK (primary->Lock(primary,DSLF_WRITE,&dst,&pitch)); | |
1068 primarylocked = 1; | |
1069 }; | |
1070 | |
1071 p=min(mpi->w,pitch); | |
1072 | |
1073 src = mpi->planes[0]+mpi->y*mpi->stride[0]+mpi->x; | |
1074 | |
1075 for (i=0;i<mpi->h;i++) { | |
1076 memcpy(dst+i*pitch,src+i*mpi->stride[0],p); | |
1077 } | |
1078 | |
1079 if (pixel_format == DSPF_YV12) { | |
1080 | |
1081 dst += pitch*height; | |
1082 p = p/2; | |
1083 src = mpi->planes[2]+mpi->y*mpi->stride[2]+mpi->x/2; | |
1084 | |
1085 for (i=0;i<mpi->h/2;i++) { | |
1086 memcpy(dst+i*pitch/2,src+i*mpi->stride[2],p); | |
1087 } | |
1088 | |
1089 dst += pitch*height/4; | |
1090 src = mpi->planes[1]+mpi->y*mpi->stride[1]+mpi->x/2; | |
1091 | |
1092 for (i=0;i<mpi->h/2;i++) { | |
1093 memcpy(dst+i*pitch/2,src+i*mpi->stride[1],p); | |
1094 } | |
1095 | |
1096 } else { | |
1097 | |
1098 dst += pitch*height; | |
1099 p = p/2; | |
1100 src = mpi->planes[1]+mpi->y*mpi->stride[1]+mpi->x/2; | |
1101 | |
1102 for (i=0;i<mpi->h/2;i++) { | |
1103 memcpy(dst+i*pitch/2,src+i*mpi->stride[1],p); | |
1104 } | |
1105 | |
1106 dst += pitch*height/4; | |
1107 src = mpi->planes[2]+mpi->y*mpi->stride[2]+mpi->x/2; | |
1108 | |
1109 for (i=0;i<mpi->h/2;i++) { | |
1110 memcpy(dst+i*pitch/2,src+i*mpi->stride[2],p); | |
1111 } | |
1112 | |
1113 } | |
1114 unlock(); | |
1115 | |
1116 } else { | |
1117 | |
1118 dsc.flags = DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_WIDTH | DSDESC_PREALLOCATED; | |
1119 dsc.preallocated[0].data = mpi->planes[0]; | |
1120 dsc.preallocated[0].pitch = mpi->stride[0]; | |
1121 dsc.width = mpi->width; | |
1122 dsc.height = mpi->height; | |
1123 dsc.pixelformat = convformat(mpi->imgfmt); | |
1124 | |
1125 DFBCHECK (dfb->CreateSurface( dfb, &dsc, &tmp)); | |
1126 | |
1127 rect.x=mpi->x; | |
1128 rect.y=mpi->y; | |
1129 rect.w=mpi->w; | |
1130 rect.h=mpi->h; | |
1131 | |
1132 if (frame) { | |
1133 DFBCHECK (tmp->Blit(tmp,frame,&rect,0,0)); | |
1134 } else { | |
1135 DFBCHECK (tmp->Blit(tmp,primary,&rect,xoffset,yoffset)); | |
1136 }; | |
1137 tmp->Release(tmp); | |
1138 } | |
1139 return VO_TRUE; | |
1140 } | |
1141 | |
1142 | |
1143 | |
1144 static uint32_t control(uint32_t request, void *data, ...) | |
1145 { | |
1146 switch (request) { | |
1147 case VOCTRL_QUERY_FORMAT: | |
1148 return query_format(*((uint32_t*)data)); | |
1149 case VOCTRL_GET_IMAGE: | |
1150 return get_image(data); | |
1151 case VOCTRL_DRAW_IMAGE: | |
1152 return put_image(data); | |
1153 case VOCTRL_SET_EQUALIZER: | |
1154 { | |
1155 va_list ap; | |
1156 int value; | |
1157 | |
1158 va_start(ap, data); | |
1159 value = va_arg(ap, int); | |
1160 va_end(ap); | |
1161 | |
1162 return(directfb_set_video_eq(data, value)); | |
1163 } | |
1164 case VOCTRL_GET_EQUALIZER: | |
1165 { | |
1166 va_list ap; | |
1167 int *value; | |
1168 | |
1169 va_start(ap, data); | |
1170 value = va_arg(ap, int*); | |
1171 va_end(ap); | |
1172 | |
1173 return(directfb_get_video_eq(data, value)); | |
1174 } | |
1175 }; | |
1176 return VO_NOTIMPL; | |
1177 } | |
1178 | |
1179 // unused function | |
1180 | |
1181 static uint32_t draw_frame(uint8_t *src[]) | |
1182 { | |
1183 return -1; | |
1184 } | |
1185 | |
1186 // hopefully will be removed soon | |
1187 | |
1188 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, | |
1189 unsigned char *srca, int stride) | |
1190 { | |
1191 void *dst; | |
1192 int pitch; | |
1193 | |
1194 unlock(); // isnt it silly I have to unlock surface and than lock again :-) | |
1195 | |
1196 if (frame) { | |
1197 DFBCHECK (frame->Lock(frame,DSLF_WRITE,&dst,&pitch)); | |
1198 framelocked = 1; | |
1199 } else { | |
1200 DFBCHECK (primary->Lock(primary,DSLF_WRITE,&dst,&pitch)); | |
1201 primarylocked = 1; | |
1202 }; | |
1203 | |
1204 switch(pixel_format) { | |
1205 case DSPF_RGB32: | |
1206 case DSPF_ARGB: | |
1207 vo_draw_alpha_rgb32(w,h,src,srca,stride,((uint8_t *) dst)+pitch*y0 + 4*x0,pitch); | |
1208 break; | |
1209 | |
1210 case DSPF_RGB24: | |
1211 vo_draw_alpha_rgb24(w,h,src,srca,stride,((uint8_t *) dst)+pitch*y0 + 3*x0,pitch); | |
1212 break; | |
1213 | |
1214 case DSPF_RGB16: | |
1215 vo_draw_alpha_rgb16(w,h,src,srca,stride,((uint8_t *) dst)+pitch*y0 + 2*x0,pitch); | |
1216 break; | |
8640 | 1217 #if DIRECTFBVERSION > 915 |
1218 case DSPF_ARGB1555: | |
1219 #else | |
6952 | 1220 case DSPF_RGB15: |
8640 | 1221 #endif |
6952 | 1222 vo_draw_alpha_rgb15(w,h,src,srca,stride,((uint8_t *) dst)+pitch*y0 + 2*x0,pitch); |
1223 break; | |
1224 | |
1225 case DSPF_YUY2: | |
1226 vo_draw_alpha_yuy2(w,h,src,srca,stride,((uint8_t *) dst) + pitch*y0 + 2*x0,pitch); | |
1227 break; | |
1228 | |
1229 case DSPF_UYVY: | |
1230 vo_draw_alpha_yuy2(w,h,src,srca,stride,((uint8_t *) dst) + pitch*y0 + 2*x0 + 1,pitch); | |
1231 break; | |
1232 | |
1233 case DSPF_I420: | |
1234 case DSPF_YV12: | |
1235 vo_draw_alpha_yv12(w,h,src,srca,stride,((uint8_t *) dst) + pitch*y0 + 1*x0,pitch); | |
1236 break; | |
1237 } | |
1238 | |
1239 unlock(); | |
1240 } | |
1241 | |
1242 static void draw_osd(void) | |
1243 { | |
1244 vo_draw_text(width,height,draw_alpha); | |
1245 } |