Mercurial > mplayer.hg
annotate libvo/vo_directfb2.c @ 8556:ecff1745d189
Document things from the start.
Inspired by a patch from Thomas Jarosch <tomj@simonv.com>.
author | diego |
---|---|
date | Tue, 24 Dec 2002 18:41:20 +0000 |
parents | 5b39e79af5fe |
children | 554e6aa7da5f |
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; | |
265 case IMGFMT_RGB15: return DSPF_RGB15; break; | |
266 case IMGFMT_BGR15: return DSPF_RGB15; break; | |
267 case IMGFMT_YUY2: return DSPF_YUY2; break; | |
268 case IMGFMT_UYVY: return DSPF_UYVY; break; | |
269 case IMGFMT_YV12: return DSPF_YV12; break; | |
270 case IMGFMT_I420: return DSPF_I420; break; | |
271 // case IMGFMT_IYUV: return DSPF_IYUV; break; | |
272 default: return 0; | |
273 } | |
274 return 0; | |
275 } | |
276 | |
277 typedef struct enum1_s { | |
278 uint32_t format; | |
279 int scale; | |
280 int result; | |
281 unsigned int id; | |
282 unsigned int width; | |
283 unsigned int height; | |
284 int setsize; | |
285 } enum1_t; | |
286 | |
287 DFBEnumerationResult test_format_callback( unsigned int id, | |
288 DFBDisplayLayerDescription desc, | |
289 void *data) | |
290 { | |
291 enum1_t *params =(enum1_t *)data; | |
292 IDirectFBDisplayLayer *layer; | |
293 DFBResult ret; | |
294 | |
8137
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
295 if ((layer_id == -1 )||(layer_id == id)) { |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
296 |
6952 | 297 ret = dfb->GetDisplayLayer( dfb, id, &layer); |
298 if (ret) { | |
299 DirectFBError( "dfb->GetDisplayLayer failed", ret ); | |
300 return DFENUM_OK; | |
301 } else { | |
302 DFBDisplayLayerConfig dlc; | |
303 | |
304 if (params->setsize) { | |
305 dlc.flags = DLCONF_WIDTH |DLCONF_HEIGHT; | |
306 dlc.width = params->width; | |
307 dlc.height = params->height; | |
308 layer->SetConfiguration(layer,&dlc); | |
309 } | |
310 | |
311 | |
312 dlc.flags = DLCONF_PIXELFORMAT; | |
313 dlc.pixelformat = convformat(params->format); | |
314 | |
315 layer->SetOpacity(layer,0); | |
316 ret = layer->TestConfiguration(layer,&dlc,NULL); | |
317 | |
318 layer->Release(layer); | |
319 | |
320 if (verbose) printf("DirectFB: Test format - layer %i scale/pos %i\n",id,(desc.caps & DLCAPS_SCREEN_LOCATION)); | |
321 | |
322 if (!ret) { | |
323 // printf("Test OK\n"); | |
324 if (params->result) { | |
325 if ((!params->scale) && (desc.caps & DLCAPS_SCREEN_LOCATION)) { | |
326 params->scale=1; | |
327 params->id=id; | |
328 if (verbose) printf("DirectFB: Test format - added layer %i scale/pos %i\n",id,(desc.caps & DLCAPS_SCREEN_LOCATION)); | |
329 | |
330 } | |
331 } else { | |
332 params->result=1; | |
333 params->id=id; | |
334 if (desc.caps & DLCAPS_SCREEN_LOCATION) params->scale=1; | |
335 if (verbose) printf("DirectFB: Test format - added layer %i scale/pos %i\n",id,(desc.caps & DLCAPS_SCREEN_LOCATION)); | |
336 }; | |
337 }; | |
338 }; | |
339 | |
8137
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
340 }; |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
341 |
6952 | 342 return DFENUM_OK; |
343 } | |
344 | |
345 static uint32_t query_format(uint32_t format) | |
346 { | |
347 int ret = VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_OSD; // osd should be removed in future -> will be handled outside... | |
348 enum1_t params; | |
349 | |
350 | |
351 if (!convformat(format)) return 0; | |
352 // temporary disable YV12 | |
353 // if (format == IMGFMT_YV12) return 0; | |
354 // if (format == IMGFMT_I420) return 0; | |
355 if (format == IMGFMT_IYUV) return 0; | |
356 | |
357 if (verbose) printf("DirectFB: Format query: %s\n",vo_format_name(format)); | |
358 | |
359 params.format=format; | |
360 params.scale=0; | |
361 params.result=0; | |
362 params.setsize=0; | |
363 | |
364 DFBCHECK (dfb->EnumDisplayLayers(dfb,test_format_callback,¶ms)); | |
365 | |
366 if (params.result) { | |
367 if (params.scale) ret |=VFCAP_HWSCALE_UP|VFCAP_HWSCALE_DOWN; | |
368 return ret; | |
369 } | |
370 | |
371 return 0; | |
372 } | |
373 | |
374 typedef struct videomode_s { | |
375 int width; | |
376 int height; | |
377 int out_width; | |
378 int out_height; | |
379 int overx; | |
380 int overy; | |
381 int bpp; | |
382 } videomode_t; | |
383 | |
384 | |
385 DFBEnumerationResult video_modes_callback( unsigned int width,unsigned int height,unsigned int bpp, void *data) | |
386 { | |
387 videomode_t *params =(videomode_t *)data; | |
388 | |
389 int overx=0,overy=0,closer=0,over=0; | |
390 int we_are_under=0; | |
391 | |
392 if (verbose) printf("DirectFB: Validator entered %i %i %i\n",width,height,bpp); | |
393 | |
394 overx=width-params->out_width; | |
395 overy=height-params->out_height; | |
396 | |
397 if (!params->width) { | |
398 params->width=width; | |
399 params->height=height; | |
400 params->overx=overx; | |
401 params->overy=overy; | |
402 if (verbose) printf("DirectFB: Mode added %i %i %i\n",width,height,bpp); | |
403 } | |
404 | |
405 if ((params->overy<0)||(params->overx<0)) we_are_under=1; // stored mode is smaller than req mode | |
406 if (abs(overx*overy)<abs(params->overx * params->overy)) closer=1; // current mode is closer to desired res | |
407 if ((overx>=0)&&(overy>=0)) over=1; // current mode is bigger or equaul to desired res | |
408 if ((closer && (over || we_are_under)) || (we_are_under && over)) { | |
409 params->width=width; | |
410 params->height=height; | |
411 params->overx=overx; | |
412 params->overy=overy; | |
413 if (verbose) printf("DirectFB: Better mode added %i %i %i\n",width,height,bpp); | |
414 }; | |
415 | |
416 return DFENUM_OK; | |
417 } | |
418 | |
419 #define CONFIG_ERROR -1 | |
420 | |
421 static uint32_t config(uint32_t s_width, uint32_t s_height, uint32_t d_width, | |
422 uint32_t d_height, uint32_t fullscreen, char *title, | |
7272 | 423 uint32_t format) |
6952 | 424 { |
425 /* | |
426 * (Locals) | |
427 */ | |
428 | |
429 // decode flags | |
430 | |
431 int fs = fullscreen & 0x01; | |
432 int vm = fullscreen & 0x02; | |
433 int zoom = fullscreen & 0x04; | |
434 int flip = fullscreen & 0x08; | |
435 | |
436 DFBSurfaceDescription dsc; | |
437 DFBResult ret; | |
438 DFBDisplayLayerConfig dlc; | |
439 DFBSurfaceCapabilities caps; | |
440 | |
441 enum1_t params; | |
442 | |
443 if (verbose) { | |
444 printf("DirectFB: Config entered [%ix%i]\n",s_width,s_height); | |
445 printf("DirectFB: With requested format: %s\n",vo_format_name(format)); | |
446 } | |
447 // initial clean-up | |
448 if (frame) { | |
449 frame->Release(frame); | |
450 frame=NULL; | |
451 } | |
452 | |
453 if (primary) { | |
454 primary->Release(primary); | |
455 primary=NULL; | |
456 } | |
457 | |
458 if (layer) { | |
459 layer->Release(layer); | |
460 layer=NULL; | |
461 } | |
462 | |
463 | |
464 // vm things | |
465 | |
466 if (vm) { | |
467 videomode_t params; | |
468 params.out_width=d_width; | |
469 params.out_height=d_height; | |
470 params.width=0; | |
471 params.height=0; | |
472 switch (format) { | |
473 case IMGFMT_RGB32: | |
474 case IMGFMT_BGR32: | |
475 params.bpp=32; | |
476 break; | |
477 case IMGFMT_RGB24: | |
478 case IMGFMT_BGR24: | |
479 params.bpp=24; | |
480 break; | |
481 case IMGFMT_RGB16: | |
482 case IMGFMT_BGR16: | |
483 case IMGFMT_RGB15: | |
484 case IMGFMT_BGR15: | |
485 params.bpp=16; | |
486 break; | |
487 default: params.bpp=0; | |
488 | |
489 } | |
490 if (verbose) printf("DirectFB: Config - videomode change\n"); | |
491 DFBCHECK (dfb->EnumVideoModes(dfb,video_modes_callback,¶ms)); | |
492 ret=dfb->SetVideoMode(dfb,params.width,params.height,params.bpp); | |
493 if (ret) { | |
494 ret=dfb->SetVideoMode(dfb,params.width,params.height,24); | |
495 if (ret) { | |
496 ret=dfb->SetVideoMode(dfb,params.width,params.height,32); | |
497 if (ret) { | |
498 ret=dfb->SetVideoMode(dfb,params.width,params.height,16); | |
499 if (ret) { | |
500 ret=dfb->SetVideoMode(dfb,params.width,params.height,8); | |
501 } | |
502 } | |
503 } | |
504 } | |
505 } // vm end | |
506 | |
507 // find best layer | |
508 | |
509 if (verbose) printf("DirectFB: Config - find suitable layer\n"); | |
510 params.format=format; | |
511 params.scale=0; | |
512 params.result=0; | |
513 params.width=s_width; | |
514 params.height=s_height; | |
515 params.setsize=1; | |
516 | |
517 DFBCHECK (dfb->EnumDisplayLayers(dfb,test_format_callback,¶ms)); | |
518 | |
519 if (!params.result) { | |
520 printf("DirectFB: ConfigError - no suitable layer found\n"); | |
521 params.id = DLID_PRIMARY; | |
522 } | |
6985
6074119e09a0
Put/get_image fixed. Deleted forgotten development comments
zdar
parents:
6952
diff
changeset
|
523 /* 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
|
524 params.id=2; |
6074119e09a0
Put/get_image fixed. Deleted forgotten development comments
zdar
parents:
6952
diff
changeset
|
525 params.scale=0; |
6074119e09a0
Put/get_image fixed. Deleted forgotten development comments
zdar
parents:
6952
diff
changeset
|
526 params.result=1; |
6074119e09a0
Put/get_image fixed. Deleted forgotten development comments
zdar
parents:
6952
diff
changeset
|
527 */ |
6952 | 528 if (verbose) printf("DirectFB: Config - layer %i\n",params.id); |
529 | |
530 | |
531 // try to setp-up proper configuration | |
532 | |
533 | |
534 DFBCHECK (dfb->GetDisplayLayer( dfb, params.id, &layer)); | |
535 | |
536 if (params.scale) { | |
537 if (verbose) printf("DirectFB: Config - set layer config (size)\n"); | |
538 dlc.flags = DLCONF_WIDTH | DLCONF_HEIGHT; | |
539 dlc.width = s_width; | |
540 dlc.height = s_height; | |
541 | |
542 ret = layer->SetConfiguration(layer,&dlc); | |
543 | |
544 if (ret && (params.scale || verbose)) printf("DirectFB: ConfigError in layer configuration (size)\n"); | |
545 | |
546 } | |
547 | |
548 dlc.flags = DLCONF_PIXELFORMAT; | |
549 dlc.pixelformat = convformat(params.format); | |
550 | |
551 // printf("DirectFB: Format [%x]\n",dlc.pixelformat); | |
552 | |
553 if (verbose) printf("DirectFB: Config - set layer config (format)\n"); | |
554 ret = layer->SetConfiguration(layer,&dlc); | |
555 | |
556 if (ret) { | |
557 printf("DirectFB: ConfigError in layer configuration (format)\n"); | |
558 return CONFIG_ERROR; | |
559 }; | |
560 | |
561 | |
562 // flipping of layer | |
563 | |
564 dlc.flags = DLCONF_BUFFERMODE; | |
565 dlc.buffermode = DLBM_BACKVIDEO; | |
566 ret = layer->SetConfiguration( layer, &dlc ); | |
567 if (ret!=DFB_OK) { | |
568 dlc.buffermode = DLBM_BACKSYSTEM; | |
569 ret = layer->SetConfiguration( layer, &dlc ); | |
570 } | |
571 | |
572 // get layer surface | |
573 | |
574 ret = layer->GetSurface(layer,&primary); | |
575 | |
576 if (ret) { | |
577 printf("DirectFB: ConfigError in obtaining surface\n"); | |
578 return CONFIG_ERROR; // what shall we report on fail? | |
579 } | |
580 | |
581 // test surface for flipping | |
582 DFBCHECK(primary->GetCapabilities(primary,&caps)); | |
8137
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
583 #if DIRECTFBVERSION > 913 |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
584 primary->Clear(primary,0,0,0,0); |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
585 #endif |
6952 | 586 flipping = 0; |
587 if (caps & DSCAPS_FLIPPING) { | |
588 ret = primary->Flip(primary,NULL,0); | |
589 if (ret==DFB_OK) { | |
8137
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
590 #if DIRECTFBVERSION > 913 |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
591 primary->Clear(primary,0,0,0,0); |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
592 #endif |
6952 | 593 flipping = 1; |
594 } | |
595 }; | |
596 | |
597 if (verbose) printf("DirectFB: Config - flipping = %i\n",flipping); | |
598 | |
599 // is scale needed ? Aspect ratio and layer pos/size | |
600 | |
601 | |
602 // get surface size | |
603 DFBCHECK(primary->GetSize(primary,&width,&height)); | |
604 | |
605 if (verbose) printf("DirectFB: Config - surface size = %ix%i\n",width,height); | |
606 | |
607 aspect_save_orig(s_width,s_height); | |
608 aspect_save_prescale(d_width,d_height); | |
609 if (params.scale) { | |
610 aspect_save_screenres(10000,10000); | |
611 aspect(&out_width,&out_height,A_ZOOM); | |
612 | |
613 ret = layer->SetScreenLocation(layer,(1-(float)out_width/10000)/2,(1-(float)out_height/10000)/2,((float)out_width/10000),((float)out_height/10000)); | |
614 | |
615 if (ret) printf("DirectFB: ConfigError in layer configuration (position)\n"); | |
616 | |
617 xoffset = 0; | |
618 yoffset = 0; | |
619 | |
620 } else { | |
621 | |
622 aspect_save_screenres(width,height); | |
623 | |
624 if(fs) /* -fs */ | |
625 aspect(&out_width,&out_height,A_ZOOM); | |
626 else | |
627 aspect(&out_width,&out_height,A_NOZOOM); | |
628 | |
629 | |
630 xoffset = (width - out_width) / 2; | |
631 yoffset = (height - out_height) / 2; | |
632 } | |
633 | |
634 if (((s_width==out_width)&&(s_height==out_height)) || (params.scale)) { | |
635 stretch = 0; | |
636 } else { | |
637 stretch = 1; | |
638 } | |
639 | |
640 | |
641 // temporary buffer in case of not flipping or scaling | |
642 if ((!flipping) || stretch) { | |
643 | |
644 DFBCHECK (primary->GetPixelFormat (primary, &dsc.pixelformat)); | |
645 | |
646 dsc.flags = DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_WIDTH; | |
647 | |
648 dsc.width = s_width; | |
649 dsc.height = s_height; | |
650 | |
651 DFBCHECK (dfb->CreateSurface( dfb, &dsc, &frame)); | |
652 DFBCHECK(frame->GetSize(frame,&width,&height)); | |
6985
6074119e09a0
Put/get_image fixed. Deleted forgotten development comments
zdar
parents:
6952
diff
changeset
|
653 if (verbose) printf("DirectFB: Frame is active.\n"); |
6952 | 654 } |
655 | |
656 // get format for draw_alpha - should be removed soon - osd will be rendered outside vo driver | |
657 if (frame) { | |
658 DFBCHECK (frame->GetPixelFormat(frame,&pixel_format)); | |
659 } else { | |
660 DFBCHECK (primary->GetPixelFormat(primary,&pixel_format)); | |
661 }; | |
662 | |
663 // finally turn on layer | |
664 layer->SetOpacity(layer,255); | |
665 | |
666 if (verbose) printf("DirectFB: Config finished [%ix%i] - [%ix%i]\n",out_width,out_height,width,height); | |
667 | |
668 return 0; | |
669 } | |
670 | |
671 extern void mplayer_put_key(int code); | |
672 | |
673 #include "../linux/keycodes.h" | |
674 | |
675 static void check_events(void) | |
676 { | |
677 | |
678 if (buffer) { | |
679 | |
680 DFBInputEvent event; | |
681 | |
682 //if (verbose) printf ("DirectFB: Check events entered\n"); | |
683 if (buffer->GetEvent(buffer, DFB_EVENT (&event)) == DFB_OK) { | |
684 | |
685 if (event.type == DIET_KEYPRESS) { | |
686 switch (event.key_symbol) { | |
687 case DIKS_ESCAPE: | |
688 mplayer_put_key('q'); | |
689 break; | |
690 case DIKS_PAGE_UP: mplayer_put_key(KEY_PAGE_UP);break; | |
691 case DIKS_PAGE_DOWN: mplayer_put_key(KEY_PAGE_DOWN);break; | |
692 case DIKS_CURSOR_UP: mplayer_put_key(KEY_UP);break; | |
693 case DIKS_CURSOR_DOWN: mplayer_put_key(KEY_DOWN);break; | |
694 case DIKS_CURSOR_LEFT: mplayer_put_key(KEY_LEFT);break; | |
695 case DIKS_CURSOR_RIGHT: mplayer_put_key(KEY_RIGHT);break; | |
696 case DIKS_INSERT: mplayer_put_key(KEY_INSERT);break; | |
697 case DIKS_DELETE: mplayer_put_key(KEY_DELETE);break; | |
698 case DIKS_HOME: mplayer_put_key(KEY_HOME);break; | |
699 case DIKS_END: mplayer_put_key(KEY_END);break; | |
700 | |
701 default:mplayer_put_key(event.key_symbol); | |
702 }; | |
703 }; | |
704 }; | |
705 // empty buffer, because of repeating (keyboard repeat is faster than key handling | |
706 // and this causes problems during seek) | |
707 // temporary workabout should be solved in the future | |
708 buffer->Reset(buffer); | |
709 | |
710 } | |
711 //if (verbose) printf ("DirectFB: Check events finished\n"); | |
712 } | |
713 | |
714 static void flip_page(void) | |
715 { | |
716 DFBSurfaceBlittingFlags flags=DSBLIT_NOFX; | |
717 | |
718 unlock(); // unlock frame & primary | |
719 | |
720 // if (verbose) printf("DirectFB: Flip page entered"); | |
721 | |
722 DFBCHECK (primary->SetBlittingFlags(primary,flags)); | |
723 | |
724 if (frame) { | |
725 if (stretch) { | |
726 DFBRectangle rect; | |
727 rect.x=xoffset; | |
728 rect.y=yoffset; | |
729 rect.w=out_width; | |
730 rect.h=out_height; | |
731 | |
732 DFBCHECK (primary->StretchBlit(primary,frame,NULL,&rect)); | |
733 | |
734 } else { | |
735 | |
736 DFBCHECK (primary->Blit(primary,frame,NULL,xoffset,yoffset)); | |
737 | |
738 }; | |
739 }; | |
740 | |
741 | |
742 if (flipping) { | |
743 DFBCHECK (primary->Flip (primary, NULL, DSFLIP_WAITFORSYNC)); | |
744 } | |
745 | |
746 } | |
747 | |
748 | |
749 | |
750 static void uninit(void) | |
751 { | |
752 | |
753 if (verbose ) printf("DirectFB: Uninit entered\n"); | |
754 | |
755 unlock(); | |
756 | |
757 /* | |
758 * (Release) | |
759 */ | |
760 if (verbose ) printf("DirectFB: Release buffer\n"); | |
761 if (buffer) buffer->Release (buffer); | |
762 if (verbose ) printf("DirectFB: Release keyboard\n"); | |
763 if (keyboard) keyboard->Release (keyboard); | |
764 if (frame) { | |
765 if (verbose ) printf("DirectFB: Release frame\n"); | |
766 frame->Release (frame); | |
767 }; | |
768 | |
769 if (verbose ) printf("DirectFB: Release primary\n"); | |
770 if (primary) primary->Release (primary); | |
771 | |
772 // switch off BES | |
773 // if (layer) layer->SetOpacity(layer,0); | |
774 | |
775 if (layer) layer->Release(layer); | |
776 | |
777 if (verbose ) printf("DirectFB: Release DirectFB library\n"); | |
778 | |
779 dfb->Release (dfb); | |
780 | |
781 if (verbose ) printf("DirectFB: Uninit done.\n"); | |
782 } | |
783 | |
784 | |
785 static uint32_t directfb_set_video_eq(char *data, int value) //data==name | |
786 { | |
787 | |
788 DFBColorAdjustment ca; | |
789 float factor = (float)0xffff / 200.0; | |
790 | |
791 DFBDisplayLayerDescription desc; | |
792 | |
793 unlock(); | |
794 | |
795 if (layer) { | |
796 | |
797 layer->GetDescription(layer,&desc); | |
798 | |
799 ca.flags=DCAF_NONE; | |
800 | |
801 if (! strcmp( data,"brightness" )) { | |
802 if (desc.caps & DLCAPS_BRIGHTNESS) { | |
803 ca.brightness = value * factor +0x8000; | |
804 ca.flags |= DCAF_BRIGHTNESS; | |
805 if (verbose) printf("DirectFB: SetVEq Brightness 0x%X %i\n",ca.brightness,value); | |
806 } else return VO_FALSE; | |
807 } | |
808 | |
809 if (! strcmp( data,"contrast" )) { | |
810 if ((desc.caps & DLCAPS_CONTRAST)) { | |
811 ca.contrast = value * factor + 0x8000; | |
812 ca.flags |= DCAF_CONTRAST; | |
813 if (verbose) printf("DirectFB: SetVEq Contrast 0x%X %i\n",ca.contrast,value); | |
814 } else return VO_FALSE; | |
815 } | |
816 | |
817 if (! strcmp( data,"hue" )) { | |
818 if ((desc.caps & DLCAPS_HUE)) { | |
819 ca.hue = value * factor + 0x8000; | |
820 ca.flags |= DCAF_HUE; | |
821 if (verbose) printf("DirectFB: SetVEq Hue 0x%X %i\n",ca.hue,value); | |
822 } else return VO_FALSE; | |
823 } | |
824 | |
825 if (! strcmp( data,"saturation" )) { | |
826 if ((desc.caps & DLCAPS_SATURATION)) { | |
827 ca.saturation = value * factor + 0x8000; | |
828 ca.flags |= DCAF_SATURATION; | |
829 if (verbose) printf("DirectFB: SetVEq Saturation 0x%X %i\n",ca.saturation,value); | |
830 } else return VO_FALSE; | |
831 } | |
832 | |
833 if (ca.flags != DCAF_NONE) { | |
834 layer->SetColorAdjustment(layer,&ca); | |
835 return VO_TRUE; | |
836 } | |
837 } | |
838 | |
839 return VO_FALSE; | |
840 | |
841 } | |
842 | |
843 static uint32_t directfb_get_video_eq(char *data, int *value) // data==name | |
844 { | |
845 | |
846 DFBColorAdjustment ca; | |
847 float factor = 200.0 / (float)0xffff; | |
848 | |
849 DFBDisplayLayerDescription desc; | |
850 | |
851 if (layer) { | |
852 | |
853 unlock(); | |
854 | |
855 layer->GetDescription(layer,&desc); | |
856 | |
857 layer->GetColorAdjustment(layer,&ca); | |
858 | |
859 if (! strcmp( data,"brightness" )) { | |
860 if (desc.caps & DLCAPS_BRIGHTNESS) { | |
861 *value = (int) ((ca.brightness-0x8000) * factor); | |
862 if (verbose) printf("DirectFB: GetVEq Brightness 0x%X %i\n",ca.brightness,*value); | |
863 return VO_TRUE; | |
864 } else return VO_FALSE; | |
865 } | |
866 | |
867 if (! strcmp( data,"contrast" )) { | |
868 if ((desc.caps & DLCAPS_CONTRAST)) { | |
869 *value = (int) ((ca.contrast-0x8000) * factor); | |
870 if (verbose) printf("DirectFB: GetVEq Contrast 0x%X %i\n",ca.contrast,*value); | |
871 return VO_TRUE; | |
872 } else return VO_FALSE; | |
873 } | |
874 | |
875 if (! strcmp( data,"hue" )) { | |
876 if ((desc.caps & DLCAPS_HUE)) { | |
877 *value = (int) ((ca.hue-0x8000) * factor); | |
878 if (verbose) printf("DirectFB: GetVEq Hue 0x%X %i\n",ca.hue,*value); | |
879 return VO_TRUE; | |
880 } else return VO_FALSE; | |
881 } | |
882 | |
883 if (! strcmp( data,"saturation" )) { | |
884 if ((desc.caps & DLCAPS_SATURATION)) { | |
885 *value = (int) ((ca.saturation-0x8000) * factor); | |
886 if (verbose) printf("DirectFB: GetVEq Saturation 0x%X %i\n",ca.saturation,*value); | |
887 return VO_TRUE; | |
888 } else return VO_FALSE; | |
889 } | |
890 } | |
891 return VO_FALSE; | |
892 } | |
893 | |
894 static uint32_t get_image(mp_image_t *mpi) | |
895 { | |
896 | |
897 int err; | |
898 void *dst; | |
899 int pitch; | |
900 | |
901 // if (verbose) printf("DirectFB: get_image() called\n"); | |
902 if(mpi->flags&MP_IMGFLAG_READABLE) return VO_FALSE; // slow video ram | |
903 if(mpi->type==MP_IMGTYPE_STATIC) return VO_FALSE; // it is not static | |
904 | |
905 // printf("width=%d vs. pitch=%d, flags=0x%X \n",mpi->width,pitch,mpi->flags); | |
906 | |
6985
6074119e09a0
Put/get_image fixed. Deleted forgotten development comments
zdar
parents:
6952
diff
changeset
|
907 if((mpi->width==pitch) || |
6952 | 908 (mpi->flags&(MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_ACCEPT_WIDTH))){ |
909 // we're lucky or codec accepts stride => ok, let's go! | |
910 | |
911 if (frame) { | |
912 err = frame->Lock(frame,DSLF_WRITE,&dst,&pitch); | |
913 framelocked=1; | |
914 } else { | |
915 err = primary->Lock(primary,DSLF_WRITE,&dst,&pitch); | |
916 primarylocked=1; | |
917 } | |
918 | |
919 if (err) { | |
920 if (verbose) printf("DirectFB: DR lock failed!"); | |
921 return VO_FALSE; | |
922 }; | |
923 | |
924 if(mpi->flags&MP_IMGFLAG_PLANAR){ | |
925 //YV12 format | |
926 mpi->planes[0]=dst; | |
927 if(mpi->flags&MP_IMGFLAG_SWAPPED){ | |
928 mpi->planes[1]=dst + pitch*height; | |
929 mpi->planes[2]=mpi->planes[1] + pitch*height/4; | |
930 } else { | |
931 mpi->planes[2]=dst + pitch*height; | |
932 mpi->planes[1]=mpi->planes[2] + pitch*height/4; | |
933 } | |
6985
6074119e09a0
Put/get_image fixed. Deleted forgotten development comments
zdar
parents:
6952
diff
changeset
|
934 mpi->width=width; |
6074119e09a0
Put/get_image fixed. Deleted forgotten development comments
zdar
parents:
6952
diff
changeset
|
935 mpi->stride[0]=pitch; |
6952 | 936 mpi->stride[1]=mpi->stride[2]=pitch/2; |
937 } else { | |
938 //YUY2 and RGB formats | |
939 mpi->planes[0]=dst; | |
940 mpi->width=width; | |
941 mpi->stride[0]=pitch; | |
942 } | |
943 mpi->flags|=MP_IMGFLAG_DIRECT; | |
944 // if (verbose) printf("DirectFB: get_image() SUCCESS -> Direct Rendering ENABLED\n"); | |
945 return VO_TRUE; | |
946 | |
947 } | |
948 return VO_FALSE; | |
949 } | |
950 | |
951 static uint32_t draw_slice(uint8_t *src[], int stride[], int w, int h, int x, int y) | |
952 { | |
953 int i; | |
954 unsigned int pitch; | |
955 void *dst; | |
956 void *dst2; | |
957 void *srcp; | |
958 unsigned int p; | |
959 | |
960 unlock(); | |
961 | |
962 if (frame) { | |
963 DFBCHECK (frame->Lock(frame,DSLF_WRITE,&dst,&pitch)); | |
964 framelocked = 1; | |
965 } else { | |
966 DFBCHECK (primary->Lock(primary,DSLF_WRITE,&dst,&pitch)); | |
967 primarylocked = 1; | |
968 }; | |
969 | |
970 p=min(w,pitch); | |
971 | |
972 dst += y*pitch + x; | |
973 dst2 = dst + pitch*height - y*pitch + y*pitch/4 - x/2; | |
974 srcp = src[0]; | |
975 | |
976 for (i=0;i<h;i++) { | |
977 memcpy(dst,srcp,p); | |
978 dst += pitch; | |
979 srcp += stride[0]; | |
980 } | |
981 | |
982 if (pixel_format == DSPF_YV12) { | |
983 | |
984 dst = dst2; | |
985 srcp = src[2]; | |
986 p = p/2; | |
987 | |
988 for (i=0;i<h/2;i++) { | |
989 memcpy(dst,srcp,p); | |
990 dst += pitch/2; | |
991 srcp += stride[2]; | |
992 } | |
993 | |
994 dst = dst2 + pitch*height/4; | |
995 srcp = src[1]; | |
996 | |
997 for (i=0;i<h/2;i++) { | |
998 memcpy(dst,srcp,p); | |
999 dst += pitch/2; | |
1000 srcp += stride[1]; | |
1001 } | |
1002 | |
1003 } else { | |
1004 | |
1005 dst = dst2; | |
1006 srcp = src[1]; | |
1007 p = p/2; | |
1008 | |
1009 for (i=0;i<h/2;i++) { | |
1010 memcpy(dst,srcp,p); | |
1011 dst += pitch/2; | |
1012 srcp += stride[1]; | |
1013 } | |
1014 | |
1015 dst = dst2 + pitch*height/4; | |
1016 srcp = src[2]; | |
1017 | |
1018 for (i=0;i<h/2;i++) { | |
1019 memcpy(dst,srcp,p); | |
1020 dst += pitch/2; | |
1021 srcp += stride[2]; | |
1022 } | |
1023 | |
1024 } | |
1025 | |
1026 unlock(); | |
1027 | |
1028 return 0; | |
1029 } | |
1030 | |
1031 | |
1032 static uint32_t put_image(mp_image_t *mpi){ | |
1033 | |
1034 | |
1035 static IDirectFBSurface *tmp = NULL; | |
1036 DFBSurfaceDescription dsc; | |
1037 DFBRectangle rect; | |
1038 | |
1039 // 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); | |
1040 | |
1041 unlock(); | |
1042 | |
1043 // already out? | |
6985
6074119e09a0
Put/get_image fixed. Deleted forgotten development comments
zdar
parents:
6952
diff
changeset
|
1044 if((mpi->flags&(MP_IMGFLAG_DIRECT|MP_IMGFLAG_DRAW_CALLBACK))) { |
6952 | 1045 // if (verbose) printf("DirectFB: Put_image - nothing todo\n"); |
1046 return VO_TRUE; | |
1047 } | |
1048 | |
1049 if (mpi->flags&MP_IMGFLAG_PLANAR) { | |
1050 // memcpy all planes - sad but necessary | |
1051 int i; | |
1052 unsigned int pitch; | |
1053 void *dst; | |
1054 void *src; | |
1055 unsigned int p; | |
1056 | |
1057 // if (verbose) printf("DirectFB: Put_image - planar branch\n"); | |
1058 if (frame) { | |
1059 DFBCHECK (frame->Lock(frame,DSLF_WRITE,&dst,&pitch)); | |
1060 framelocked = 1; | |
1061 } else { | |
1062 DFBCHECK (primary->Lock(primary,DSLF_WRITE,&dst,&pitch)); | |
1063 primarylocked = 1; | |
1064 }; | |
1065 | |
1066 p=min(mpi->w,pitch); | |
1067 | |
1068 src = mpi->planes[0]+mpi->y*mpi->stride[0]+mpi->x; | |
1069 | |
1070 for (i=0;i<mpi->h;i++) { | |
1071 memcpy(dst+i*pitch,src+i*mpi->stride[0],p); | |
1072 } | |
1073 | |
1074 if (pixel_format == DSPF_YV12) { | |
1075 | |
1076 dst += pitch*height; | |
1077 p = p/2; | |
1078 src = mpi->planes[2]+mpi->y*mpi->stride[2]+mpi->x/2; | |
1079 | |
1080 for (i=0;i<mpi->h/2;i++) { | |
1081 memcpy(dst+i*pitch/2,src+i*mpi->stride[2],p); | |
1082 } | |
1083 | |
1084 dst += pitch*height/4; | |
1085 src = mpi->planes[1]+mpi->y*mpi->stride[1]+mpi->x/2; | |
1086 | |
1087 for (i=0;i<mpi->h/2;i++) { | |
1088 memcpy(dst+i*pitch/2,src+i*mpi->stride[1],p); | |
1089 } | |
1090 | |
1091 } else { | |
1092 | |
1093 dst += pitch*height; | |
1094 p = p/2; | |
1095 src = mpi->planes[1]+mpi->y*mpi->stride[1]+mpi->x/2; | |
1096 | |
1097 for (i=0;i<mpi->h/2;i++) { | |
1098 memcpy(dst+i*pitch/2,src+i*mpi->stride[1],p); | |
1099 } | |
1100 | |
1101 dst += pitch*height/4; | |
1102 src = mpi->planes[2]+mpi->y*mpi->stride[2]+mpi->x/2; | |
1103 | |
1104 for (i=0;i<mpi->h/2;i++) { | |
1105 memcpy(dst+i*pitch/2,src+i*mpi->stride[2],p); | |
1106 } | |
1107 | |
1108 } | |
1109 unlock(); | |
1110 | |
1111 } else { | |
1112 | |
1113 dsc.flags = DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_WIDTH | DSDESC_PREALLOCATED; | |
1114 dsc.preallocated[0].data = mpi->planes[0]; | |
1115 dsc.preallocated[0].pitch = mpi->stride[0]; | |
1116 dsc.width = mpi->width; | |
1117 dsc.height = mpi->height; | |
1118 dsc.pixelformat = convformat(mpi->imgfmt); | |
1119 | |
1120 DFBCHECK (dfb->CreateSurface( dfb, &dsc, &tmp)); | |
1121 | |
1122 rect.x=mpi->x; | |
1123 rect.y=mpi->y; | |
1124 rect.w=mpi->w; | |
1125 rect.h=mpi->h; | |
1126 | |
1127 if (frame) { | |
1128 DFBCHECK (tmp->Blit(tmp,frame,&rect,0,0)); | |
1129 } else { | |
1130 DFBCHECK (tmp->Blit(tmp,primary,&rect,xoffset,yoffset)); | |
1131 }; | |
1132 tmp->Release(tmp); | |
1133 } | |
1134 return VO_TRUE; | |
1135 } | |
1136 | |
1137 | |
1138 | |
1139 static uint32_t control(uint32_t request, void *data, ...) | |
1140 { | |
1141 switch (request) { | |
1142 case VOCTRL_QUERY_FORMAT: | |
1143 return query_format(*((uint32_t*)data)); | |
1144 case VOCTRL_GET_IMAGE: | |
1145 return get_image(data); | |
1146 case VOCTRL_DRAW_IMAGE: | |
1147 return put_image(data); | |
1148 case VOCTRL_SET_EQUALIZER: | |
1149 { | |
1150 va_list ap; | |
1151 int value; | |
1152 | |
1153 va_start(ap, data); | |
1154 value = va_arg(ap, int); | |
1155 va_end(ap); | |
1156 | |
1157 return(directfb_set_video_eq(data, value)); | |
1158 } | |
1159 case VOCTRL_GET_EQUALIZER: | |
1160 { | |
1161 va_list ap; | |
1162 int *value; | |
1163 | |
1164 va_start(ap, data); | |
1165 value = va_arg(ap, int*); | |
1166 va_end(ap); | |
1167 | |
1168 return(directfb_get_video_eq(data, value)); | |
1169 } | |
1170 }; | |
1171 return VO_NOTIMPL; | |
1172 } | |
1173 | |
1174 // unused function | |
1175 | |
1176 static uint32_t draw_frame(uint8_t *src[]) | |
1177 { | |
1178 return -1; | |
1179 } | |
1180 | |
1181 // hopefully will be removed soon | |
1182 | |
1183 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, | |
1184 unsigned char *srca, int stride) | |
1185 { | |
1186 void *dst; | |
1187 int pitch; | |
1188 | |
1189 unlock(); // isnt it silly I have to unlock surface and than lock again :-) | |
1190 | |
1191 if (frame) { | |
1192 DFBCHECK (frame->Lock(frame,DSLF_WRITE,&dst,&pitch)); | |
1193 framelocked = 1; | |
1194 } else { | |
1195 DFBCHECK (primary->Lock(primary,DSLF_WRITE,&dst,&pitch)); | |
1196 primarylocked = 1; | |
1197 }; | |
1198 | |
1199 switch(pixel_format) { | |
1200 case DSPF_RGB32: | |
1201 case DSPF_ARGB: | |
1202 vo_draw_alpha_rgb32(w,h,src,srca,stride,((uint8_t *) dst)+pitch*y0 + 4*x0,pitch); | |
1203 break; | |
1204 | |
1205 case DSPF_RGB24: | |
1206 vo_draw_alpha_rgb24(w,h,src,srca,stride,((uint8_t *) dst)+pitch*y0 + 3*x0,pitch); | |
1207 break; | |
1208 | |
1209 case DSPF_RGB16: | |
1210 vo_draw_alpha_rgb16(w,h,src,srca,stride,((uint8_t *) dst)+pitch*y0 + 2*x0,pitch); | |
1211 break; | |
1212 | |
1213 case DSPF_RGB15: | |
1214 vo_draw_alpha_rgb15(w,h,src,srca,stride,((uint8_t *) dst)+pitch*y0 + 2*x0,pitch); | |
1215 break; | |
1216 | |
1217 case DSPF_YUY2: | |
1218 vo_draw_alpha_yuy2(w,h,src,srca,stride,((uint8_t *) dst) + pitch*y0 + 2*x0,pitch); | |
1219 break; | |
1220 | |
1221 case DSPF_UYVY: | |
1222 vo_draw_alpha_yuy2(w,h,src,srca,stride,((uint8_t *) dst) + pitch*y0 + 2*x0 + 1,pitch); | |
1223 break; | |
1224 | |
1225 case DSPF_I420: | |
1226 case DSPF_YV12: | |
1227 vo_draw_alpha_yv12(w,h,src,srca,stride,((uint8_t *) dst) + pitch*y0 + 1*x0,pitch); | |
1228 break; | |
1229 } | |
1230 | |
1231 unlock(); | |
1232 } | |
1233 | |
1234 static void draw_osd(void) | |
1235 { | |
1236 vo_draw_text(width,height,draw_alpha); | |
1237 } |