Mercurial > mplayer.hg
annotate libvo/vo_directfb2.c @ 18889:e60c8c7399d2
get_path as const, patch by Stefan Huehner, stefan AT huehner-org
author | reynaldo |
---|---|
date | Mon, 03 Jul 2006 23:27:37 +0000 |
parents | 3bf0d70b4c7f |
children | 36589811e5d0 |
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 | |
8137
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
34 #ifdef __linux__ |
6952 | 35 #include <sys/kd.h> |
8137
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
36 #else |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
37 #include <linux/kd.h> |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
38 #endif |
6952 | 39 |
40 #include "config.h" | |
41 #include "video_out.h" | |
42 #include "video_out_internal.h" | |
43 #include "fastmemcpy.h" | |
44 #include "sub.h" | |
9937 | 45 #include "mp_msg.h" |
6952 | 46 #include "aspect.h" |
15750 | 47 #include "subopt-helper.h" |
6952 | 48 |
49 #ifndef min | |
50 #define min(x,y) (((x)<(y))?(x):(y)) | |
51 #endif | |
10004
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
52 |
9937 | 53 #if DIRECTFBVERSION > 917 |
54 // triple buffering | |
55 #define TRIPLE 1 | |
56 #endif | |
10004
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
57 |
8148
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
8137
diff
changeset
|
58 static vo_info_t info = { |
6952 | 59 "Direct Framebuffer Device", |
60 "directfb", | |
61 "Jiri Svoboda Jiri.Svoboda@seznam.cz", | |
8137
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
62 "v 2.0 (for DirectFB version >=0.9.13)" |
6952 | 63 }; |
64 | |
8148
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
8137
diff
changeset
|
65 LIBVO_EXTERN(directfb) |
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
8137
diff
changeset
|
66 |
6952 | 67 /****************************** |
68 * vo_directfb globals * | |
69 ******************************/ | |
70 | |
71 #define DFBCHECK(x...) \ | |
72 { \ | |
73 DFBResult err = x; \ | |
74 \ | |
75 if (err != DFB_OK) \ | |
76 { \ | |
77 fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \ | |
78 DirectFBErrorFatal( #x, err ); \ | |
79 } \ | |
80 } | |
81 | |
82 /* | |
83 * filled by preinit | |
84 */ | |
85 | |
86 // main DirectFB handle | |
87 static IDirectFB *dfb = NULL; | |
88 // keyboard handle | |
89 static IDirectFBInputDevice *keyboard = NULL; | |
90 // A buffer for input events. | |
91 static IDirectFBEventBuffer *buffer = NULL; | |
92 | |
93 /* | |
94 * filled during config | |
95 */ | |
96 | |
97 // handle of used layer | |
98 static IDirectFBDisplayLayer *layer = NULL; | |
99 // surface of used layer | |
100 static IDirectFBSurface *primary = NULL; | |
101 static int primarylocked = 0; | |
102 // handle of temporary surface (if used) | |
103 static IDirectFBSurface *frame = NULL; | |
104 static int framelocked = 0; | |
105 // flipping mode flag (layer/surface) | |
106 static int flipping = 0; | |
11972
cda09732375e
removed usage of fb_dev_name, imported field parity reporting from dfbmga, fixed vsync handling in triple buffering mode
zdar
parents:
11000
diff
changeset
|
107 // tvnorm |
cda09732375e
removed usage of fb_dev_name, imported field parity reporting from dfbmga, fixed vsync handling in triple buffering mode
zdar
parents:
11000
diff
changeset
|
108 static int tvnorm = -1; |
6952 | 109 // scaling flag |
110 static int stretch = 0; | |
111 // pictrure position | |
112 static int xoffset=0,yoffset=0; | |
113 // picture size | |
114 static int out_width=0,out_height=0; | |
115 // frame/primary size | |
116 static int width=0,height=0; | |
117 // frame primary format | |
118 DFBSurfacePixelFormat pixel_format; | |
119 /* | |
120 static void (*draw_alpha_p)(int w, int h, unsigned char *src, | |
121 unsigned char *srca, int stride, unsigned char *dst, | |
122 int dstride); | |
123 */ | |
124 | |
125 /****************************** | |
126 * cmd line parameteres * | |
127 ******************************/ | |
128 | |
129 /* command line/config file options */ | |
10004
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
130 static int layer_id = -1; |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
131 static int buffer_mode = 1; |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
132 static int use_input = 1; |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
133 static int field_parity = -1; |
6952 | 134 |
135 /****************************** | |
136 * implementation * | |
137 ******************************/ | |
138 | |
139 void unlock() { | |
140 if (frame && framelocked) frame->Unlock(frame); | |
141 if (primary && primarylocked) primary->Unlock(primary); | |
142 } | |
143 | |
15750 | 144 static int get_parity(strarg_t *arg) { |
145 if (strargcmp(arg, "top") == 0) | |
146 return 0; | |
147 if (strargcmp(arg, "bottom") == 0) | |
148 return 1; | |
149 return -1; | |
150 } | |
151 | |
152 static int check_parity(void *arg) { | |
153 return get_parity(arg) != -1; | |
154 } | |
155 | |
156 static int get_mode(strarg_t *arg) { | |
157 if (strargcmp(arg, "single") == 0) | |
158 return 1; | |
159 if (strargcmp(arg, "double") == 0) | |
160 return 2; | |
161 if (strargcmp(arg, "triple") == 0) | |
162 return 3; | |
163 return 0; | |
164 } | |
165 | |
166 static int check_mode(void *arg) { | |
167 return get_mode(arg) != 0; | |
168 } | |
6952 | 169 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15750
diff
changeset
|
170 static int preinit(const char *arg) |
6952 | 171 { |
10004
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
172 DFBResult ret; |
15750 | 173 strarg_t mode_str = {0, NULL}; |
174 strarg_t par_str = {0, NULL}; | |
175 strarg_t dfb_params = {0, NULL}; | |
176 opt_t subopts[] = { | |
177 {"input", OPT_ARG_BOOL, &use_input, NULL}, | |
178 {"buffermode", OPT_ARG_STR, &mode_str, check_mode}, | |
179 {"fieldparity", OPT_ARG_STR, &par_str, check_parity}, | |
180 {"layer", OPT_ARG_INT, &layer_id, NULL}, | |
181 {"dfbopts", OPT_ARG_STR, &dfb_params, NULL}, | |
182 {NULL} | |
183 }; | |
6952 | 184 |
10004
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
185 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Preinit entered\n"); |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
186 |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
187 if (dfb) return 0; // we are already inited! |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
188 |
15750 | 189 // set defaults |
10004
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
190 buffer_mode = 1 + vo_doublebuffering; // honor -double switch |
15750 | 191 layer_id = -1; |
192 use_input = 1; | |
193 field_parity = -1; | |
194 if (subopt_parse(arg, subopts) != 0) { | |
10004
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
195 mp_msg( MSGT_VO, MSGL_ERR, |
11982 | 196 "\n-vo directfb command line help:\n" |
10004
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
197 "Example: mplayer -vo directfb:layer=1:buffermode=single\n" |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
198 "\nOptions (use 'no' prefix to disable):\n" |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
199 " input Use DirectFB for keyboard input\n" |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
200 "\nOther options:\n" |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
201 " layer=n\n" |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
202 " n=0..xx Use layer with id n for output (0=primary)\n" |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
203 " buffermode=(single|double|triple)\n" |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
204 " single Use single buffering\n" |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
205 " double Use double buffering\n" |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
206 " triple Use triple buffering\n" |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
207 " fieldparity=(top|bottom)\n" |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
208 " top Top field first\n" |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
209 " bottom Bottom field first\n" |
15750 | 210 " dfbopts=<str>\n" |
211 " Specify a parameter list for DirectFB\n" | |
10004
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
212 "\n" ); |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
213 return -1; |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
214 } |
15750 | 215 if (mode_str.len) |
216 buffer_mode = get_mode(&mode_str); | |
217 if (par_str.len) | |
218 field_parity = get_parity(&par_str); | |
10004
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
219 |
8137
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
220 |
15750 | 221 if (dfb_params.len > 0) |
8137
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
222 { |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
223 int argc = 2; |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
224 char arg0[10] = "mplayer"; |
18878 | 225 char *arg1 = malloc(dfb_params.len + 7); |
8137
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
226 char* argv[3]; |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
227 char ** a; |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
228 |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
229 a = &argv[0]; |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
230 |
15750 | 231 strcpy(arg1, "--dfb:"); |
232 strncat(arg1, dfb_params.str, dfb_params.len); | |
8137
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
233 |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
234 argv[0]=arg0; |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
235 argv[1]=arg1; |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
236 argv[2]=NULL; |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
237 |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
238 DFBCHECK (DirectFBInit (&argc,&a)); |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
239 |
15750 | 240 free(arg1); |
8137
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
241 } else { |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
242 |
6952 | 243 DFBCHECK (DirectFBInit (NULL,NULL)); |
8137
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
244 } |
6952 | 245 |
246 if (((directfb_major_version <= 0) && | |
247 (directfb_minor_version <= 9) && | |
248 (directfb_micro_version < 13))) | |
249 { | |
9937 | 250 mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: Unsupported DirectFB version\n"); |
6952 | 251 return 1; |
252 } | |
253 | |
254 /* | |
255 * (set options) | |
256 */ | |
257 | |
258 // uncomment this if you do not wish to create a new vt for DirectFB | |
259 // DFBCHECK (DirectFBSetOption ("no-vt-switch","")); | |
260 | |
261 // uncomment this if you want to allow vt switching | |
262 // DFBCHECK (DirectFBSetOption ("vt-switching","")); | |
263 | |
264 // uncomment this if you want to hide gfx cursor (req dfb >=0.9.9) | |
11972
cda09732375e
removed usage of fb_dev_name, imported field parity reporting from dfbmga, fixed vsync handling in triple buffering mode
zdar
parents:
11000
diff
changeset
|
265 DFBCHECK (DirectFBSetOption ("no-cursor","")); |
6952 | 266 |
267 // bg color fix | |
268 DFBCHECK (DirectFBSetOption ("bg-color","00000000")); | |
269 | |
270 /* | |
271 * (Initialize) | |
272 */ | |
273 | |
274 DFBCHECK (DirectFBCreate (&dfb)); | |
275 | |
9937 | 276 #if DIRECTFBVERSION < 917 |
9538
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
277 if (DFB_OK != dfb->SetCooperativeLevel (dfb, DFSCL_FULLSCREEN)) { |
9937 | 278 mp_msg(MSGT_VO, MSGL_WARN,"DirectFB: Warning - cannot swith to fullscreen mode"); |
9538
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
279 }; |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
280 #endif |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
281 |
6952 | 282 /* |
283 * (Get keyboard) | |
284 */ | |
10004
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
285 |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
286 if (use_input) { |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
287 ret = dfb->GetInputDevice (dfb, DIDID_KEYBOARD, &keyboard); |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
288 if (ret==DFB_OK) { |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
289 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Keyboard init OK\n"); |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
290 } else { |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
291 keyboard = NULL; |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
292 mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: Keyboard init FAILED\n"); |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
293 } |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
294 } |
6952 | 295 |
296 | |
297 /* | |
298 * Create an input buffer for the keyboard. | |
299 */ | |
300 if (keyboard) DFBCHECK (keyboard->CreateEventBuffer (keyboard, &buffer)); | |
301 | |
302 // just to start with clean ... | |
303 if (buffer) buffer->Reset(buffer); | |
304 | |
9937 | 305 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Preinit OK\n"); |
6952 | 306 |
307 return 0; | |
308 | |
309 } | |
310 | |
311 DFBSurfacePixelFormat convformat(uint32_t format) | |
312 { | |
313 // add more formats !!! | |
314 switch (format) { | |
315 case IMGFMT_RGB32: return DSPF_RGB32; break; | |
316 case IMGFMT_BGR32: return DSPF_RGB32; break; | |
317 case IMGFMT_RGB24: return DSPF_RGB24; break; | |
318 case IMGFMT_BGR24: return DSPF_RGB24; break; | |
319 case IMGFMT_RGB16: return DSPF_RGB16; break; | |
320 case IMGFMT_BGR16: return DSPF_RGB16; break; | |
8640 | 321 #if DIRECTFBVERSION > 915 |
322 case IMGFMT_RGB15: return DSPF_ARGB1555; break; | |
323 case IMGFMT_BGR15: return DSPF_ARGB1555; break; | |
324 #else | |
6952 | 325 case IMGFMT_RGB15: return DSPF_RGB15; break; |
326 case IMGFMT_BGR15: return DSPF_RGB15; break; | |
8640 | 327 #endif |
6952 | 328 case IMGFMT_YUY2: return DSPF_YUY2; break; |
329 case IMGFMT_UYVY: return DSPF_UYVY; break; | |
330 case IMGFMT_YV12: return DSPF_YV12; break; | |
331 case IMGFMT_I420: return DSPF_I420; break; | |
332 // case IMGFMT_IYUV: return DSPF_IYUV; break; | |
9538
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
333 case IMGFMT_RGB8: return DSPF_RGB332; break; |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
334 case IMGFMT_BGR8: return DSPF_RGB332; break; |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
335 |
6952 | 336 default: return 0; |
337 } | |
338 return 0; | |
339 } | |
340 | |
341 typedef struct enum1_s { | |
342 uint32_t format; | |
343 int scale; | |
344 int result; | |
345 unsigned int id; | |
346 unsigned int width; | |
347 unsigned int height; | |
348 int setsize; | |
349 } enum1_t; | |
350 | |
351 DFBEnumerationResult test_format_callback( unsigned int id, | |
352 DFBDisplayLayerDescription desc, | |
353 void *data) | |
354 { | |
355 enum1_t *params =(enum1_t *)data; | |
356 IDirectFBDisplayLayer *layer; | |
357 DFBResult ret; | |
358 | |
8137
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
359 if ((layer_id == -1 )||(layer_id == id)) { |
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
360 |
6952 | 361 ret = dfb->GetDisplayLayer( dfb, id, &layer); |
362 if (ret) { | |
363 DirectFBError( "dfb->GetDisplayLayer failed", ret ); | |
364 return DFENUM_OK; | |
365 } else { | |
366 DFBDisplayLayerConfig dlc; | |
9538
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
367 |
6952 | 368 if (params->setsize) { |
369 dlc.flags = DLCONF_WIDTH |DLCONF_HEIGHT; | |
370 dlc.width = params->width; | |
371 dlc.height = params->height; | |
372 layer->SetConfiguration(layer,&dlc); | |
373 } | |
374 | |
375 | |
376 dlc.flags = DLCONF_PIXELFORMAT; | |
377 dlc.pixelformat = convformat(params->format); | |
9515 | 378 |
379 layer->SetOpacity(layer,0); | |
6952 | 380 |
381 ret = layer->TestConfiguration(layer,&dlc,NULL); | |
382 | |
383 layer->Release(layer); | |
384 | |
9937 | 385 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Test format - layer %i scale/pos %i\n",id,(desc.caps & DLCAPS_SCREEN_LOCATION)); |
6952 | 386 |
9515 | 387 if (ret==DFB_OK) { |
6952 | 388 // printf("Test OK\n"); |
389 if (params->result) { | |
390 if ((!params->scale) && (desc.caps & DLCAPS_SCREEN_LOCATION)) { | |
391 params->scale=1; | |
392 params->id=id; | |
9937 | 393 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Test format - added layer %i scale/pos %i\n",id,(desc.caps & DLCAPS_SCREEN_LOCATION)); |
6952 | 394 } |
395 } else { | |
396 params->result=1; | |
397 params->id=id; | |
398 if (desc.caps & DLCAPS_SCREEN_LOCATION) params->scale=1; | |
9937 | 399 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Test format - added layer %i scale/pos %i\n",id,(desc.caps & DLCAPS_SCREEN_LOCATION)); |
6952 | 400 }; |
401 }; | |
402 }; | |
403 | |
8137
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
404 }; |
9515 | 405 |
6952 | 406 return DFENUM_OK; |
407 } | |
408 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15750
diff
changeset
|
409 static int query_format(uint32_t format) |
6952 | 410 { |
411 int ret = VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_OSD; // osd should be removed in future -> will be handled outside... | |
412 enum1_t params; | |
413 | |
414 | |
415 if (!convformat(format)) return 0; | |
416 // temporary disable YV12 | |
417 // if (format == IMGFMT_YV12) return 0; | |
418 // if (format == IMGFMT_I420) return 0; | |
419 if (format == IMGFMT_IYUV) return 0; | |
420 | |
9937 | 421 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Format query: %s\n",vo_format_name(format)); |
6952 | 422 |
423 params.format=format; | |
424 params.scale=0; | |
425 params.result=0; | |
426 params.setsize=0; | |
427 | |
428 DFBCHECK (dfb->EnumDisplayLayers(dfb,test_format_callback,¶ms)); | |
429 | |
430 if (params.result) { | |
431 if (params.scale) ret |=VFCAP_HWSCALE_UP|VFCAP_HWSCALE_DOWN; | |
432 return ret; | |
433 } | |
434 | |
435 return 0; | |
436 } | |
437 | |
438 typedef struct videomode_s { | |
439 int width; | |
440 int height; | |
441 int out_width; | |
442 int out_height; | |
443 int overx; | |
444 int overy; | |
445 int bpp; | |
446 } videomode_t; | |
447 | |
448 | |
449 DFBEnumerationResult video_modes_callback( unsigned int width,unsigned int height,unsigned int bpp, void *data) | |
450 { | |
451 videomode_t *params =(videomode_t *)data; | |
452 | |
453 int overx=0,overy=0,closer=0,over=0; | |
454 int we_are_under=0; | |
455 | |
9937 | 456 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Validator entered %i %i %i\n",width,height,bpp); |
6952 | 457 |
458 overx=width-params->out_width; | |
459 overy=height-params->out_height; | |
460 | |
461 if (!params->width) { | |
462 params->width=width; | |
463 params->height=height; | |
464 params->overx=overx; | |
465 params->overy=overy; | |
9937 | 466 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Mode added %i %i %i\n",width,height,bpp); |
6952 | 467 } |
468 | |
469 if ((params->overy<0)||(params->overx<0)) we_are_under=1; // stored mode is smaller than req mode | |
470 if (abs(overx*overy)<abs(params->overx * params->overy)) closer=1; // current mode is closer to desired res | |
471 if ((overx>=0)&&(overy>=0)) over=1; // current mode is bigger or equaul to desired res | |
472 if ((closer && (over || we_are_under)) || (we_are_under && over)) { | |
473 params->width=width; | |
474 params->height=height; | |
475 params->overx=overx; | |
476 params->overy=overy; | |
9937 | 477 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Better mode added %i %i %i\n",width,height,bpp); |
6952 | 478 }; |
479 | |
480 return DFENUM_OK; | |
481 } | |
482 | |
483 #define CONFIG_ERROR -1 | |
484 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15750
diff
changeset
|
485 static int config(uint32_t s_width, uint32_t s_height, uint32_t d_width, |
15212
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
13787
diff
changeset
|
486 uint32_t d_height, uint32_t flags, char *title, |
7272 | 487 uint32_t format) |
6952 | 488 { |
489 /* | |
490 * (Locals) | |
491 */ | |
492 | |
493 // decode flags | |
494 | |
15212
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
13787
diff
changeset
|
495 int fs = flags & VOFLAG_FULLSCREEN; |
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
13787
diff
changeset
|
496 int vm = flags & VOFLAG_MODESWITCHING; |
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
13787
diff
changeset
|
497 int zoom = flags & VOFLAG_SWSCALE; |
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
13787
diff
changeset
|
498 int flip = flags & VOFLAG_FLIPPING; |
6952 | 499 |
500 DFBSurfaceDescription dsc; | |
501 DFBResult ret; | |
502 DFBDisplayLayerConfig dlc; | |
503 DFBSurfaceCapabilities caps; | |
504 | |
505 enum1_t params; | |
506 | |
9937 | 507 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Config entered [%ix%i]\n",s_width,s_height); |
508 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: With requested format: %s\n",vo_format_name(format)); | |
509 | |
6952 | 510 // initial clean-up |
511 if (frame) { | |
512 frame->Release(frame); | |
513 frame=NULL; | |
514 } | |
515 | |
516 if (primary) { | |
517 primary->Release(primary); | |
518 primary=NULL; | |
519 } | |
520 | |
521 if (layer) { | |
522 layer->Release(layer); | |
523 layer=NULL; | |
524 } | |
525 | |
526 | |
527 // vm things | |
528 | |
529 if (vm) { | |
530 videomode_t params; | |
531 params.out_width=d_width; | |
532 params.out_height=d_height; | |
533 params.width=0; | |
534 params.height=0; | |
535 switch (format) { | |
9515 | 536 case IMGFMT_RGB32: |
537 case IMGFMT_BGR32: | |
6952 | 538 params.bpp=32; |
539 break; | |
9515 | 540 case IMGFMT_RGB24: |
541 case IMGFMT_BGR24: | |
6952 | 542 params.bpp=24; |
543 break; | |
544 case IMGFMT_RGB16: | |
545 case IMGFMT_BGR16: | |
546 case IMGFMT_RGB15: | |
547 case IMGFMT_BGR15: | |
548 params.bpp=16; | |
549 break; | |
9515 | 550 default: params.bpp=0; |
551 | |
552 } | |
9937 | 553 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Config - trying to change videomode\n"); |
6952 | 554 DFBCHECK (dfb->EnumVideoModes(dfb,video_modes_callback,¶ms)); |
555 ret=dfb->SetVideoMode(dfb,params.width,params.height,params.bpp); | |
556 if (ret) { | |
557 ret=dfb->SetVideoMode(dfb,params.width,params.height,24); | |
558 if (ret) { | |
559 ret=dfb->SetVideoMode(dfb,params.width,params.height,32); | |
560 if (ret) { | |
561 ret=dfb->SetVideoMode(dfb,params.width,params.height,16); | |
562 if (ret) { | |
563 ret=dfb->SetVideoMode(dfb,params.width,params.height,8); | |
564 } | |
565 } | |
566 } | |
567 } | |
568 } // vm end | |
569 | |
10840
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
570 // just for sure clear primary layer |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
571 #if DIRECTFBVERSION > 913 |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
572 ret = dfb->GetDisplayLayer( dfb, DLID_PRIMARY, &layer); |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
573 if (ret==DFB_OK) { |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
574 ret = layer->GetSurface(layer,&primary); |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
575 if (ret==DFB_OK) { |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
576 primary->Clear(primary,0,0,0,0xff); |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
577 ret = primary->Flip(primary,NULL,0); |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
578 if (ret==DFB_OK) { |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
579 primary->Clear(primary,0,0,0,0xff); |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
580 } |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
581 primary->Release(primary); |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
582 } |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
583 primary=NULL; |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
584 layer->Release(layer); |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
585 } |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
586 layer=NULL; |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
587 #endif |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
588 |
6952 | 589 // find best layer |
590 | |
9937 | 591 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Config - looking for suitable layer\n"); |
6952 | 592 params.format=format; |
593 params.scale=0; | |
594 params.result=0; | |
595 params.width=s_width; | |
596 params.height=s_height; | |
597 params.setsize=1; | |
598 | |
599 DFBCHECK (dfb->EnumDisplayLayers(dfb,test_format_callback,¶ms)); | |
600 | |
601 if (!params.result) { | |
9937 | 602 mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: ConfigError - no suitable layer found\n"); |
6952 | 603 params.id = DLID_PRIMARY; |
9515 | 604 } |
9538
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
605 |
9937 | 606 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Config - layer %i\n",params.id); |
6952 | 607 |
9538
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
608 // setup layer |
6952 | 609 |
610 DFBCHECK (dfb->GetDisplayLayer( dfb, params.id, &layer)); | |
9538
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
611 |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
612 #if DIRECTFBVERSION > 916 |
11972
cda09732375e
removed usage of fb_dev_name, imported field parity reporting from dfbmga, fixed vsync handling in triple buffering mode
zdar
parents:
11000
diff
changeset
|
613 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Config - switching layer to exclusive mode\n"); |
9538
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
614 ret = layer->SetCooperativeLevel (layer, DLSCL_EXCLUSIVE); |
6952 | 615 |
9538
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
616 if (DFB_OK != ret) { |
9937 | 617 mp_msg(MSGT_VO, MSGL_WARN,"DirectFB: Warning - cannot swith layer to exclusive mode. This could cause\nproblems. You may need to select correct pixel format manually!\n"); |
9538
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
618 DirectFBError("MPlayer - Switch layer to exlusive mode.",ret); |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
619 }; |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
620 #endif |
6952 | 621 if (params.scale) { |
9937 | 622 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Config - changing layer configuration (size)\n"); |
6952 | 623 dlc.flags = DLCONF_WIDTH | DLCONF_HEIGHT; |
624 dlc.width = s_width; | |
625 dlc.height = s_height; | |
9515 | 626 |
6952 | 627 ret = layer->SetConfiguration(layer,&dlc); |
9515 | 628 |
9538
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
629 if (ret) { |
9937 | 630 mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: ConfigError in layer configuration (size)\n"); |
9538
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
631 DirectFBError("MPlayer - Layer size change.",ret); |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
632 }; |
6952 | 633 } |
634 | |
9515 | 635 // look if we need to change pixel fromat of layer |
636 // and just for sure fetch also all layer propreties | |
637 dlc.flags = DLCONF_PIXELFORMAT | DLCONF_WIDTH | DLCONF_HEIGHT | DLCONF_OPTIONS | DLCONF_BUFFERMODE; | |
9538
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
638 |
9515 | 639 ret = layer->GetConfiguration(layer,&dlc); |
640 | |
641 dlc.flags = DLCONF_PIXELFORMAT | DLCONF_WIDTH | DLCONF_HEIGHT; | |
642 | |
643 if (ret) { | |
9937 | 644 mp_msg(MSGT_VO, MSGL_WARN,"DirectFB: Warning - could not get layer properties!\n"); |
645 } else { | |
646 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Layer reports format:%x\n",dlc.pixelformat); | |
9515 | 647 } |
6952 | 648 |
9515 | 649 if ((dlc.pixelformat != convformat(params.format)) || (ret != DFB_OK)) { |
650 | |
651 dlc.flags = DLCONF_PIXELFORMAT; | |
652 dlc.pixelformat = convformat(params.format); | |
653 | |
9937 | 654 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Desired pixelformat: %x\n",dlc.pixelformat); |
9515 | 655 |
9937 | 656 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Config - changing layer configuration (format)\n"); |
9515 | 657 ret = layer->SetConfiguration(layer,&dlc); |
658 | |
659 if (ret) { | |
9538
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
660 unsigned int bpp; |
9937 | 661 mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: ConfigError in layer configuration (format, flags=%x)\n",dlc.flags); |
9538
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
662 DirectFBError("MPlayer - layer pixelformat change",ret); |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
663 |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
664 // ugly fbdev workabout - try to switch pixelformat via videomode change |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
665 switch (dlc.pixelformat) { |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
666 case DSPF_ARGB: |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
667 case DSPF_RGB32: bpp=32;break; |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
668 case DSPF_RGB24: bpp=24;break; |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
669 case DSPF_RGB16: bpp=16;break; |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
670 #if DIRECTFBVERSION > 915 |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
671 case DSPF_ARGB1555: bpp=15;break; |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
672 #else |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
673 case DSPF_RGB15: bpp=15;break; |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
674 #endif |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
675 case DSPF_RGB332 : bpp=8;break; |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
676 } |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
677 |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
678 switch (dlc.pixelformat) { |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
679 case DSPF_ARGB: |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
680 case DSPF_RGB32: |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
681 case DSPF_RGB24: |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
682 case DSPF_RGB16: |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
683 #if DIRECTFBVERSION > 915 |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
684 case DSPF_ARGB1555: |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
685 #else |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
686 case DSPF_RGB15: |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
687 #endif |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
688 case DSPF_RGB332: |
9937 | 689 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Trying to recover via videomode change (VM).\n"); |
9538
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
690 // get size |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
691 dlc.flags = DLCONF_WIDTH | DLCONF_HEIGHT; |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
692 if (DFB_OK==layer->GetConfiguration(layer,&dlc)) { |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
693 // try to set videomode |
9937 | 694 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Videomode %ix%i BPP %i\n",dlc.width,dlc.height,bpp); |
9538
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
695 ret = dfb->SetVideoMode(dfb,dlc.width,dlc.height,bpp); |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
696 if (ret) DirectFBError("MPlayer - VM - pixelformat change",ret); |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
697 |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
698 }; |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
699 |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
700 //get current pixel format |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
701 dlc.flags = DLCONF_PIXELFORMAT; |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
702 ret = layer->GetConfiguration(layer,&dlc); |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
703 if (ret) { |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
704 DirectFBError("MPlayer - VM - Layer->GetConfiguration",ret); |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
705 } else { |
9937 | 706 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Layer has now pixelformat [%x]\n",dlc.pixelformat); |
9538
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
707 }; |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
708 |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
709 // check if we were succesfull |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
710 if ((dlc.pixelformat != convformat(params.format)) || (ret != DFB_OK)) { |
9937 | 711 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Recovery failed!.\n"); |
9538
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
712 return CONFIG_ERROR; |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
713 } |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
714 |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
715 break; |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
716 |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
717 default: return CONFIG_ERROR; |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
718 |
7b1907aa1422
Some 10l and better layer handling (to comply with DFB 0.9.17)
zdar
parents:
9515
diff
changeset
|
719 }; |
9515 | 720 }; |
6952 | 721 }; |
722 | |
723 // flipping of layer | |
10004
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
724 // try triple, \double... buffering |
6952 | 725 |
726 dlc.flags = DLCONF_BUFFERMODE; | |
9937 | 727 #ifdef TRIPLE |
10004
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
728 if (buffer_mode > 2) { |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
729 dlc.buffermode = DLBM_TRIPLE; |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
730 ret = layer->SetConfiguration( layer, &dlc ); |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
731 } else { |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
732 ret=!DFB_OK; |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
733 } |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
734 |
9937 | 735 if (ret!=DFB_OK) { |
736 #endif | |
10004
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
737 if (buffer_mode > 1) { |
9937 | 738 dlc.buffermode = DLBM_BACKVIDEO; |
739 ret = layer->SetConfiguration( layer, &dlc ); | |
740 if (ret!=DFB_OK) { | |
741 dlc.buffermode = DLBM_BACKSYSTEM; | |
742 ret = layer->SetConfiguration( layer, &dlc ); | |
6952 | 743 } |
9937 | 744 } |
745 if (ret == DFB_OK) { | |
746 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Double buffering is active\n"); | |
747 } | |
748 #ifdef TRIPLE | |
749 } else { | |
750 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Triple buffering is active\n"); | |
751 } | |
752 #endif | |
6952 | 753 |
10004
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
754 #if DIRECTFBVERSION > 916 |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
755 if (field_parity != -1) { |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
756 dlc.flags = DLCONF_OPTIONS; |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
757 ret = layer->GetConfiguration( layer, &dlc ); |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
758 if (ret==DFB_OK) { |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
759 dlc.options |= DLOP_FIELD_PARITY; |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
760 ret = layer->SetConfiguration( layer, &dlc ); |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
761 if (ret==DFB_OK) { |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
762 layer->SetFieldParity( layer, field_parity ); |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
763 } |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
764 } |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
765 } |
11972
cda09732375e
removed usage of fb_dev_name, imported field parity reporting from dfbmga, fixed vsync handling in triple buffering mode
zdar
parents:
11000
diff
changeset
|
766 mp_msg( MSGT_VO, MSGL_INFO, "DirectFB: Requested field parity: "); |
cda09732375e
removed usage of fb_dev_name, imported field parity reporting from dfbmga, fixed vsync handling in triple buffering mode
zdar
parents:
11000
diff
changeset
|
767 switch (field_parity) { |
cda09732375e
removed usage of fb_dev_name, imported field parity reporting from dfbmga, fixed vsync handling in triple buffering mode
zdar
parents:
11000
diff
changeset
|
768 case -1: |
cda09732375e
removed usage of fb_dev_name, imported field parity reporting from dfbmga, fixed vsync handling in triple buffering mode
zdar
parents:
11000
diff
changeset
|
769 mp_msg( MSGT_VO, MSGL_INFO, "Don't care\n"); |
cda09732375e
removed usage of fb_dev_name, imported field parity reporting from dfbmga, fixed vsync handling in triple buffering mode
zdar
parents:
11000
diff
changeset
|
770 break; |
cda09732375e
removed usage of fb_dev_name, imported field parity reporting from dfbmga, fixed vsync handling in triple buffering mode
zdar
parents:
11000
diff
changeset
|
771 case 0: |
cda09732375e
removed usage of fb_dev_name, imported field parity reporting from dfbmga, fixed vsync handling in triple buffering mode
zdar
parents:
11000
diff
changeset
|
772 mp_msg( MSGT_VO, MSGL_INFO, "Top field first\n"); |
cda09732375e
removed usage of fb_dev_name, imported field parity reporting from dfbmga, fixed vsync handling in triple buffering mode
zdar
parents:
11000
diff
changeset
|
773 break; |
cda09732375e
removed usage of fb_dev_name, imported field parity reporting from dfbmga, fixed vsync handling in triple buffering mode
zdar
parents:
11000
diff
changeset
|
774 case 1: |
cda09732375e
removed usage of fb_dev_name, imported field parity reporting from dfbmga, fixed vsync handling in triple buffering mode
zdar
parents:
11000
diff
changeset
|
775 mp_msg( MSGT_VO, MSGL_INFO, "Bottom field first\n"); |
cda09732375e
removed usage of fb_dev_name, imported field parity reporting from dfbmga, fixed vsync handling in triple buffering mode
zdar
parents:
11000
diff
changeset
|
776 break; |
cda09732375e
removed usage of fb_dev_name, imported field parity reporting from dfbmga, fixed vsync handling in triple buffering mode
zdar
parents:
11000
diff
changeset
|
777 } |
cda09732375e
removed usage of fb_dev_name, imported field parity reporting from dfbmga, fixed vsync handling in triple buffering mode
zdar
parents:
11000
diff
changeset
|
778 |
10004
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
779 #endif |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
780 |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
781 |
6952 | 782 // get layer surface |
783 | |
784 ret = layer->GetSurface(layer,&primary); | |
785 | |
786 if (ret) { | |
9937 | 787 mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: ConfigError - could not get surface\n"); |
6952 | 788 return CONFIG_ERROR; // what shall we report on fail? |
789 } | |
790 | |
791 // test surface for flipping | |
792 DFBCHECK(primary->GetCapabilities(primary,&caps)); | |
8137
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
793 #if DIRECTFBVERSION > 913 |
9937 | 794 primary->Clear(primary,0,0,0,0xff); |
8137
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
795 #endif |
6952 | 796 flipping = 0; |
10004
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
797 if (caps & (DSCAPS_FLIPPING |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
798 #ifdef TRIPLE |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
799 | DSCAPS_TRIPLE |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
800 #endif |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
801 )) { |
6952 | 802 ret = primary->Flip(primary,NULL,0); |
803 if (ret==DFB_OK) { | |
11972
cda09732375e
removed usage of fb_dev_name, imported field parity reporting from dfbmga, fixed vsync handling in triple buffering mode
zdar
parents:
11000
diff
changeset
|
804 flipping = 1; |
8137
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
805 #if DIRECTFBVERSION > 913 |
9937 | 806 primary->Clear(primary,0,0,0,0xff); |
807 #ifdef TRIPLE | |
808 // if we have 3 buffers clean once more | |
809 if (caps & DSCAPS_TRIPLE) { | |
810 primary->Flip(primary,NULL,0); | |
811 primary->Clear(primary,0,0,0,0xff); | |
11972
cda09732375e
removed usage of fb_dev_name, imported field parity reporting from dfbmga, fixed vsync handling in triple buffering mode
zdar
parents:
11000
diff
changeset
|
812 flipping = 2; |
9937 | 813 } |
814 #endif | |
8137
530d1c5f0c78
Switch containing options for DirectFB library was renamed to dfbopts.
arpi
parents:
7272
diff
changeset
|
815 #endif |
6952 | 816 } |
817 }; | |
818 | |
9937 | 819 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Config - flipping = %i\n",flipping); |
6952 | 820 |
821 // is scale needed ? Aspect ratio and layer pos/size | |
822 | |
823 | |
824 // get surface size | |
825 DFBCHECK(primary->GetSize(primary,&width,&height)); | |
826 | |
9937 | 827 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Config - surface size = %ix%i\n",width,height); |
6952 | 828 |
829 aspect_save_orig(s_width,s_height); | |
830 aspect_save_prescale(d_width,d_height); | |
831 if (params.scale) { | |
832 aspect_save_screenres(10000,10000); | |
833 aspect(&out_width,&out_height,A_ZOOM); | |
834 | |
835 ret = layer->SetScreenLocation(layer,(1-(float)out_width/10000)/2,(1-(float)out_height/10000)/2,((float)out_width/10000),((float)out_height/10000)); | |
836 | |
9937 | 837 if (ret) mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: ConfigError in layer configuration (position)\n"); |
6952 | 838 |
839 xoffset = 0; | |
840 yoffset = 0; | |
841 | |
842 } else { | |
843 | |
844 aspect_save_screenres(width,height); | |
845 | |
846 if(fs) /* -fs */ | |
847 aspect(&out_width,&out_height,A_ZOOM); | |
848 else | |
849 aspect(&out_width,&out_height,A_NOZOOM); | |
850 | |
851 | |
852 xoffset = (width - out_width) / 2; | |
853 yoffset = (height - out_height) / 2; | |
854 } | |
855 | |
856 if (((s_width==out_width)&&(s_height==out_height)) || (params.scale)) { | |
857 stretch = 0; | |
858 } else { | |
859 stretch = 1; | |
860 } | |
861 | |
862 | |
863 // temporary buffer in case of not flipping or scaling | |
864 if ((!flipping) || stretch) { | |
865 | |
866 DFBCHECK (primary->GetPixelFormat (primary, &dsc.pixelformat)); | |
867 | |
868 dsc.flags = DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_WIDTH; | |
869 | |
870 dsc.width = s_width; | |
871 dsc.height = s_height; | |
872 | |
873 DFBCHECK (dfb->CreateSurface( dfb, &dsc, &frame)); | |
874 DFBCHECK(frame->GetSize(frame,&width,&height)); | |
9937 | 875 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Frame is active.\n"); |
6952 | 876 } |
877 | |
878 // get format for draw_alpha - should be removed soon - osd will be rendered outside vo driver | |
879 if (frame) { | |
880 DFBCHECK (frame->GetPixelFormat(frame,&pixel_format)); | |
881 } else { | |
882 DFBCHECK (primary->GetPixelFormat(primary,&pixel_format)); | |
883 }; | |
884 | |
885 // finally turn on layer | |
886 layer->SetOpacity(layer,255); | |
887 | |
9937 | 888 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Config finished [%ix%i] - [%ix%i]\n",out_width,out_height,width,height); |
6952 | 889 |
890 return 0; | |
891 } | |
892 | |
893 extern void mplayer_put_key(int code); | |
894 | |
13787
e047e70a9767
Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents:
11982
diff
changeset
|
895 #include "osdep/keycodes.h" |
6952 | 896 |
897 static void check_events(void) | |
898 { | |
899 | |
900 if (buffer) { | |
901 | |
902 DFBInputEvent event; | |
903 | |
17969
843e0427b5b9
Change 'if(verbose)' to the more appropriate mp_msg_test.
diego
parents:
16892
diff
changeset
|
904 //if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf ("DirectFB: Check events entered\n"); |
6952 | 905 if (buffer->GetEvent(buffer, DFB_EVENT (&event)) == DFB_OK) { |
906 | |
907 if (event.type == DIET_KEYPRESS) { | |
908 switch (event.key_symbol) { | |
909 case DIKS_ESCAPE: | |
16892
3470c810527b
libvo input cleanup: remove the dependency on libinput,
albeu
parents:
16171
diff
changeset
|
910 mplayer_put_key(KEY_ESC); |
6952 | 911 break; |
912 case DIKS_PAGE_UP: mplayer_put_key(KEY_PAGE_UP);break; | |
913 case DIKS_PAGE_DOWN: mplayer_put_key(KEY_PAGE_DOWN);break; | |
914 case DIKS_CURSOR_UP: mplayer_put_key(KEY_UP);break; | |
915 case DIKS_CURSOR_DOWN: mplayer_put_key(KEY_DOWN);break; | |
916 case DIKS_CURSOR_LEFT: mplayer_put_key(KEY_LEFT);break; | |
917 case DIKS_CURSOR_RIGHT: mplayer_put_key(KEY_RIGHT);break; | |
918 case DIKS_INSERT: mplayer_put_key(KEY_INSERT);break; | |
919 case DIKS_DELETE: mplayer_put_key(KEY_DELETE);break; | |
920 case DIKS_HOME: mplayer_put_key(KEY_HOME);break; | |
921 case DIKS_END: mplayer_put_key(KEY_END);break; | |
922 | |
923 default:mplayer_put_key(event.key_symbol); | |
924 }; | |
925 }; | |
926 }; | |
927 // empty buffer, because of repeating (keyboard repeat is faster than key handling | |
928 // and this causes problems during seek) | |
929 // temporary workabout should be solved in the future | |
930 buffer->Reset(buffer); | |
931 | |
932 } | |
17969
843e0427b5b9
Change 'if(verbose)' to the more appropriate mp_msg_test.
diego
parents:
16892
diff
changeset
|
933 //if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf ("DirectFB: Check events finished\n"); |
6952 | 934 } |
935 | |
936 static void flip_page(void) | |
937 { | |
938 DFBSurfaceBlittingFlags flags=DSBLIT_NOFX; | |
939 | |
940 unlock(); // unlock frame & primary | |
941 | |
17969
843e0427b5b9
Change 'if(verbose)' to the more appropriate mp_msg_test.
diego
parents:
16892
diff
changeset
|
942 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: Flip page entered"); |
6952 | 943 |
944 DFBCHECK (primary->SetBlittingFlags(primary,flags)); | |
945 | |
946 if (frame) { | |
947 if (stretch) { | |
948 DFBRectangle rect; | |
949 rect.x=xoffset; | |
950 rect.y=yoffset; | |
951 rect.w=out_width; | |
952 rect.h=out_height; | |
953 | |
954 DFBCHECK (primary->StretchBlit(primary,frame,NULL,&rect)); | |
955 | |
956 } else { | |
957 | |
958 DFBCHECK (primary->Blit(primary,frame,NULL,xoffset,yoffset)); | |
959 | |
960 }; | |
961 }; | |
962 | |
963 | |
11972
cda09732375e
removed usage of fb_dev_name, imported field parity reporting from dfbmga, fixed vsync handling in triple buffering mode
zdar
parents:
11000
diff
changeset
|
964 #ifdef TRIPLE |
cda09732375e
removed usage of fb_dev_name, imported field parity reporting from dfbmga, fixed vsync handling in triple buffering mode
zdar
parents:
11000
diff
changeset
|
965 switch (flipping) { |
cda09732375e
removed usage of fb_dev_name, imported field parity reporting from dfbmga, fixed vsync handling in triple buffering mode
zdar
parents:
11000
diff
changeset
|
966 case 1: DFBCHECK (primary->Flip (primary, NULL, DSFLIP_WAIT)); |
cda09732375e
removed usage of fb_dev_name, imported field parity reporting from dfbmga, fixed vsync handling in triple buffering mode
zdar
parents:
11000
diff
changeset
|
967 break; |
cda09732375e
removed usage of fb_dev_name, imported field parity reporting from dfbmga, fixed vsync handling in triple buffering mode
zdar
parents:
11000
diff
changeset
|
968 case 2: DFBCHECK (primary->Flip (primary, NULL, DSFLIP_ONSYNC)); |
cda09732375e
removed usage of fb_dev_name, imported field parity reporting from dfbmga, fixed vsync handling in triple buffering mode
zdar
parents:
11000
diff
changeset
|
969 break; |
cda09732375e
removed usage of fb_dev_name, imported field parity reporting from dfbmga, fixed vsync handling in triple buffering mode
zdar
parents:
11000
diff
changeset
|
970 default:; // should never reach here |
cda09732375e
removed usage of fb_dev_name, imported field parity reporting from dfbmga, fixed vsync handling in triple buffering mode
zdar
parents:
11000
diff
changeset
|
971 } |
cda09732375e
removed usage of fb_dev_name, imported field parity reporting from dfbmga, fixed vsync handling in triple buffering mode
zdar
parents:
11000
diff
changeset
|
972 #else |
6952 | 973 if (flipping) { |
974 DFBCHECK (primary->Flip (primary, NULL, DSFLIP_WAITFORSYNC)); | |
975 } | |
11972
cda09732375e
removed usage of fb_dev_name, imported field parity reporting from dfbmga, fixed vsync handling in triple buffering mode
zdar
parents:
11000
diff
changeset
|
976 #endif |
6952 | 977 |
978 } | |
979 | |
980 | |
981 | |
982 static void uninit(void) | |
983 { | |
984 | |
9937 | 985 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Uninit entered\n"); |
6952 | 986 |
987 unlock(); | |
988 | |
989 /* | |
990 * (Release) | |
991 */ | |
10004
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
992 /* |
9937 | 993 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Releasing buffer\n"); |
6952 | 994 if (buffer) buffer->Release (buffer); |
9937 | 995 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Releasing keyboard\n"); |
6952 | 996 if (keyboard) keyboard->Release (keyboard); |
10004
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
997 */ |
6952 | 998 if (frame) { |
9937 | 999 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Releasing frame\n"); |
6952 | 1000 frame->Release (frame); |
10004
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
1001 frame = NULL; |
6952 | 1002 }; |
1003 | |
1004 // switch off BES | |
1005 // if (layer) layer->SetOpacity(layer,0); | |
1006 | |
10004
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
1007 if (layer) { |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
1008 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Releasing layer\n"); |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
1009 layer->Release(layer); |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
1010 layer = NULL; |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
1011 } |
6952 | 1012 |
10004
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
1013 if (primary) { |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
1014 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Releasing primary\n"); |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
1015 primary->Release (primary); |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
1016 primary = NULL; |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
1017 } |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
1018 |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
1019 |
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
1020 /* mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Releasing DirectFB library\n"); |
6952 | 1021 |
1022 dfb->Release (dfb); | |
10004
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
1023 */ |
9937 | 1024 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Uninit done.\n"); |
6952 | 1025 } |
1026 | |
1027 | |
1028 static uint32_t directfb_set_video_eq(char *data, int value) //data==name | |
1029 { | |
1030 | |
1031 DFBColorAdjustment ca; | |
1032 float factor = (float)0xffff / 200.0; | |
1033 | |
1034 DFBDisplayLayerDescription desc; | |
1035 | |
1036 unlock(); | |
1037 | |
1038 if (layer) { | |
1039 | |
1040 layer->GetDescription(layer,&desc); | |
1041 | |
1042 ca.flags=DCAF_NONE; | |
1043 | |
1044 if (! strcmp( data,"brightness" )) { | |
1045 if (desc.caps & DLCAPS_BRIGHTNESS) { | |
1046 ca.brightness = value * factor +0x8000; | |
1047 ca.flags |= DCAF_BRIGHTNESS; | |
9937 | 1048 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: SetVEq Brightness 0x%X %i\n",ca.brightness,value); |
6952 | 1049 } else return VO_FALSE; |
1050 } | |
1051 | |
1052 if (! strcmp( data,"contrast" )) { | |
1053 if ((desc.caps & DLCAPS_CONTRAST)) { | |
1054 ca.contrast = value * factor + 0x8000; | |
1055 ca.flags |= DCAF_CONTRAST; | |
9937 | 1056 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: SetVEq Contrast 0x%X %i\n",ca.contrast,value); |
6952 | 1057 } else return VO_FALSE; |
1058 } | |
1059 | |
1060 if (! strcmp( data,"hue" )) { | |
1061 if ((desc.caps & DLCAPS_HUE)) { | |
1062 ca.hue = value * factor + 0x8000; | |
1063 ca.flags |= DCAF_HUE; | |
9937 | 1064 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: SetVEq Hue 0x%X %i\n",ca.hue,value); |
6952 | 1065 } else return VO_FALSE; |
1066 } | |
1067 | |
1068 if (! strcmp( data,"saturation" )) { | |
1069 if ((desc.caps & DLCAPS_SATURATION)) { | |
1070 ca.saturation = value * factor + 0x8000; | |
1071 ca.flags |= DCAF_SATURATION; | |
9937 | 1072 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: SetVEq Saturation 0x%X %i\n",ca.saturation,value); |
6952 | 1073 } else return VO_FALSE; |
1074 } | |
1075 | |
1076 if (ca.flags != DCAF_NONE) { | |
1077 layer->SetColorAdjustment(layer,&ca); | |
1078 return VO_TRUE; | |
1079 } | |
1080 } | |
1081 | |
1082 return VO_FALSE; | |
1083 | |
1084 } | |
1085 | |
1086 static uint32_t directfb_get_video_eq(char *data, int *value) // data==name | |
1087 { | |
1088 | |
1089 DFBColorAdjustment ca; | |
1090 float factor = 200.0 / (float)0xffff; | |
1091 | |
1092 DFBDisplayLayerDescription desc; | |
1093 | |
1094 if (layer) { | |
1095 | |
1096 unlock(); | |
1097 | |
1098 layer->GetDescription(layer,&desc); | |
1099 | |
1100 layer->GetColorAdjustment(layer,&ca); | |
1101 | |
1102 if (! strcmp( data,"brightness" )) { | |
1103 if (desc.caps & DLCAPS_BRIGHTNESS) { | |
1104 *value = (int) ((ca.brightness-0x8000) * factor); | |
9937 | 1105 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: GetVEq Brightness 0x%X %i\n",ca.brightness,*value); |
6952 | 1106 return VO_TRUE; |
1107 } else return VO_FALSE; | |
1108 } | |
1109 | |
1110 if (! strcmp( data,"contrast" )) { | |
1111 if ((desc.caps & DLCAPS_CONTRAST)) { | |
1112 *value = (int) ((ca.contrast-0x8000) * factor); | |
9937 | 1113 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: GetVEq Contrast 0x%X %i\n",ca.contrast,*value); |
6952 | 1114 return VO_TRUE; |
1115 } else return VO_FALSE; | |
1116 } | |
1117 | |
1118 if (! strcmp( data,"hue" )) { | |
1119 if ((desc.caps & DLCAPS_HUE)) { | |
1120 *value = (int) ((ca.hue-0x8000) * factor); | |
9937 | 1121 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: GetVEq Hue 0x%X %i\n",ca.hue,*value); |
6952 | 1122 return VO_TRUE; |
1123 } else return VO_FALSE; | |
1124 } | |
1125 | |
1126 if (! strcmp( data,"saturation" )) { | |
1127 if ((desc.caps & DLCAPS_SATURATION)) { | |
1128 *value = (int) ((ca.saturation-0x8000) * factor); | |
9937 | 1129 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: GetVEq Saturation 0x%X %i\n",ca.saturation,*value); |
6952 | 1130 return VO_TRUE; |
1131 } else return VO_FALSE; | |
1132 } | |
1133 } | |
1134 return VO_FALSE; | |
1135 } | |
1136 | |
1137 static uint32_t get_image(mp_image_t *mpi) | |
1138 { | |
1139 | |
1140 int err; | |
1141 void *dst; | |
1142 int pitch; | |
1143 | |
17969
843e0427b5b9
Change 'if(verbose)' to the more appropriate mp_msg_test.
diego
parents:
16892
diff
changeset
|
1144 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: get_image() called\n"); |
9937 | 1145 if(mpi->flags&MP_IMGFLAG_READABLE) return VO_FALSE; // slow video ram |
6952 | 1146 if(mpi->type==MP_IMGTYPE_STATIC) return VO_FALSE; // it is not static |
1147 | |
1148 // printf("width=%d vs. pitch=%d, flags=0x%X \n",mpi->width,pitch,mpi->flags); | |
1149 | |
6985
6074119e09a0
Put/get_image fixed. Deleted forgotten development comments
zdar
parents:
6952
diff
changeset
|
1150 if((mpi->width==pitch) || |
6952 | 1151 (mpi->flags&(MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_ACCEPT_WIDTH))){ |
1152 // we're lucky or codec accepts stride => ok, let's go! | |
1153 | |
1154 if (frame) { | |
10004
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
1155 err = frame->Lock(frame,DSLF_WRITE|DSLF_READ,&dst,&pitch); |
6952 | 1156 framelocked=1; |
1157 } else { | |
1158 err = primary->Lock(primary,DSLF_WRITE,&dst,&pitch); | |
1159 primarylocked=1; | |
1160 } | |
1161 | |
1162 if (err) { | |
9937 | 1163 mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: DR lock failed!"); |
6952 | 1164 return VO_FALSE; |
1165 }; | |
1166 | |
1167 if(mpi->flags&MP_IMGFLAG_PLANAR){ | |
1168 //YV12 format | |
1169 mpi->planes[0]=dst; | |
1170 if(mpi->flags&MP_IMGFLAG_SWAPPED){ | |
1171 mpi->planes[1]=dst + pitch*height; | |
1172 mpi->planes[2]=mpi->planes[1] + pitch*height/4; | |
1173 } else { | |
1174 mpi->planes[2]=dst + pitch*height; | |
1175 mpi->planes[1]=mpi->planes[2] + pitch*height/4; | |
1176 } | |
6985
6074119e09a0
Put/get_image fixed. Deleted forgotten development comments
zdar
parents:
6952
diff
changeset
|
1177 mpi->width=width; |
6074119e09a0
Put/get_image fixed. Deleted forgotten development comments
zdar
parents:
6952
diff
changeset
|
1178 mpi->stride[0]=pitch; |
6952 | 1179 mpi->stride[1]=mpi->stride[2]=pitch/2; |
1180 } else { | |
1181 //YUY2 and RGB formats | |
1182 mpi->planes[0]=dst; | |
1183 mpi->width=width; | |
1184 mpi->stride[0]=pitch; | |
1185 } | |
10840
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
1186 |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
1187 // center image |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
1188 |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
1189 if (!frame) { |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
1190 if(mpi->flags&MP_IMGFLAG_PLANAR){ |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
1191 mpi->planes[0]= dst + yoffset * pitch + xoffset; |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
1192 mpi->planes[1]+= (yoffset * pitch) >> 2 + xoffset >> 1; |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
1193 mpi->planes[2]+= (yoffset * pitch) >> 2 + xoffset >> 1; |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
1194 } else { |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
1195 mpi->planes[0]=dst + yoffset * pitch + xoffset * (mpi->bpp >> 3); |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
1196 } |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
1197 } |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
1198 |
6952 | 1199 mpi->flags|=MP_IMGFLAG_DIRECT; |
17969
843e0427b5b9
Change 'if(verbose)' to the more appropriate mp_msg_test.
diego
parents:
16892
diff
changeset
|
1200 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: get_image() SUCCESS -> Direct Rendering ENABLED\n"); |
6952 | 1201 return VO_TRUE; |
1202 | |
1203 } | |
1204 return VO_FALSE; | |
1205 } | |
1206 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15750
diff
changeset
|
1207 static int draw_slice(uint8_t *src[], int stride[], int w, int h, int x, int y) |
6952 | 1208 { |
1209 int i; | |
1210 unsigned int pitch; | |
1211 void *dst; | |
1212 void *dst2; | |
1213 void *srcp; | |
1214 unsigned int p; | |
1215 | |
17969
843e0427b5b9
Change 'if(verbose)' to the more appropriate mp_msg_test.
diego
parents:
16892
diff
changeset
|
1216 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: draw_slice entered\n"); |
10840
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
1217 |
6952 | 1218 unlock(); |
1219 | |
1220 if (frame) { | |
10004
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
1221 DFBCHECK (frame->Lock(frame,DSLF_WRITE|DSLF_READ,&dst,&pitch)); |
6952 | 1222 framelocked = 1; |
1223 } else { | |
1224 DFBCHECK (primary->Lock(primary,DSLF_WRITE,&dst,&pitch)); | |
1225 primarylocked = 1; | |
1226 }; | |
1227 | |
1228 p=min(w,pitch); | |
1229 | |
1230 dst += y*pitch + x; | |
1231 dst2 = dst + pitch*height - y*pitch + y*pitch/4 - x/2; | |
1232 srcp = src[0]; | |
1233 | |
1234 for (i=0;i<h;i++) { | |
1235 memcpy(dst,srcp,p); | |
1236 dst += pitch; | |
1237 srcp += stride[0]; | |
1238 } | |
1239 | |
1240 if (pixel_format == DSPF_YV12) { | |
1241 | |
1242 dst = dst2; | |
1243 srcp = src[2]; | |
1244 p = p/2; | |
1245 | |
1246 for (i=0;i<h/2;i++) { | |
1247 memcpy(dst,srcp,p); | |
1248 dst += pitch/2; | |
1249 srcp += stride[2]; | |
1250 } | |
1251 | |
1252 dst = dst2 + pitch*height/4; | |
1253 srcp = src[1]; | |
1254 | |
1255 for (i=0;i<h/2;i++) { | |
1256 memcpy(dst,srcp,p); | |
1257 dst += pitch/2; | |
1258 srcp += stride[1]; | |
1259 } | |
1260 | |
1261 } else { | |
1262 | |
1263 dst = dst2; | |
1264 srcp = src[1]; | |
1265 p = p/2; | |
1266 | |
1267 for (i=0;i<h/2;i++) { | |
1268 memcpy(dst,srcp,p); | |
1269 dst += pitch/2; | |
1270 srcp += stride[1]; | |
1271 } | |
1272 | |
1273 dst = dst2 + pitch*height/4; | |
1274 srcp = src[2]; | |
1275 | |
1276 for (i=0;i<h/2;i++) { | |
1277 memcpy(dst,srcp,p); | |
1278 dst += pitch/2; | |
1279 srcp += stride[2]; | |
1280 } | |
1281 | |
1282 } | |
1283 | |
1284 unlock(); | |
1285 | |
1286 return 0; | |
1287 } | |
1288 | |
1289 | |
1290 static uint32_t put_image(mp_image_t *mpi){ | |
1291 | |
1292 | |
1293 static IDirectFBSurface *tmp = NULL; | |
1294 DFBSurfaceDescription dsc; | |
1295 DFBRectangle rect; | |
1296 | |
17969
843e0427b5b9
Change 'if(verbose)' to the more appropriate mp_msg_test.
diego
parents:
16892
diff
changeset
|
1297 // 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); |
6952 | 1298 |
1299 unlock(); | |
1300 | |
1301 // already out? | |
6985
6074119e09a0
Put/get_image fixed. Deleted forgotten development comments
zdar
parents:
6952
diff
changeset
|
1302 if((mpi->flags&(MP_IMGFLAG_DIRECT|MP_IMGFLAG_DRAW_CALLBACK))) { |
17969
843e0427b5b9
Change 'if(verbose)' to the more appropriate mp_msg_test.
diego
parents:
16892
diff
changeset
|
1303 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: Put_image - nothing todo\n"); |
6952 | 1304 return VO_TRUE; |
1305 } | |
1306 | |
1307 if (mpi->flags&MP_IMGFLAG_PLANAR) { | |
1308 // memcpy all planes - sad but necessary | |
1309 int i; | |
1310 unsigned int pitch; | |
1311 void *dst; | |
1312 void *src; | |
1313 unsigned int p; | |
1314 | |
17969
843e0427b5b9
Change 'if(verbose)' to the more appropriate mp_msg_test.
diego
parents:
16892
diff
changeset
|
1315 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: Put_image - planar branch\n"); |
6952 | 1316 if (frame) { |
10004
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
1317 DFBCHECK (frame->Lock(frame,DSLF_WRITE|DSLF_READ,&dst,&pitch)); |
6952 | 1318 framelocked = 1; |
1319 } else { | |
1320 DFBCHECK (primary->Lock(primary,DSLF_WRITE,&dst,&pitch)); | |
1321 primarylocked = 1; | |
1322 }; | |
1323 | |
1324 p=min(mpi->w,pitch); | |
1325 | |
1326 src = mpi->planes[0]+mpi->y*mpi->stride[0]+mpi->x; | |
1327 | |
1328 for (i=0;i<mpi->h;i++) { | |
1329 memcpy(dst+i*pitch,src+i*mpi->stride[0],p); | |
1330 } | |
1331 | |
10840
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
1332 |
6952 | 1333 if (pixel_format == DSPF_YV12) { |
1334 | |
1335 dst += pitch*height; | |
1336 p = p/2; | |
1337 src = mpi->planes[2]+mpi->y*mpi->stride[2]+mpi->x/2; | |
1338 | |
1339 for (i=0;i<mpi->h/2;i++) { | |
1340 memcpy(dst+i*pitch/2,src+i*mpi->stride[2],p); | |
1341 } | |
1342 | |
1343 dst += pitch*height/4; | |
1344 src = mpi->planes[1]+mpi->y*mpi->stride[1]+mpi->x/2; | |
1345 | |
1346 for (i=0;i<mpi->h/2;i++) { | |
1347 memcpy(dst+i*pitch/2,src+i*mpi->stride[1],p); | |
1348 } | |
1349 | |
1350 } else { | |
1351 | |
1352 dst += pitch*height; | |
1353 p = p/2; | |
1354 src = mpi->planes[1]+mpi->y*mpi->stride[1]+mpi->x/2; | |
1355 | |
1356 for (i=0;i<mpi->h/2;i++) { | |
1357 memcpy(dst+i*pitch/2,src+i*mpi->stride[1],p); | |
1358 } | |
1359 | |
1360 dst += pitch*height/4; | |
1361 src = mpi->planes[2]+mpi->y*mpi->stride[2]+mpi->x/2; | |
1362 | |
1363 for (i=0;i<mpi->h/2;i++) { | |
1364 memcpy(dst+i*pitch/2,src+i*mpi->stride[2],p); | |
1365 } | |
1366 | |
1367 } | |
1368 unlock(); | |
1369 | |
1370 } else { | |
10840
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
1371 // I had to disable native directfb blit because it wasn't working under some conditions :-( |
6952 | 1372 |
10840
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
1373 /* |
6952 | 1374 dsc.flags = DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_WIDTH | DSDESC_PREALLOCATED; |
1375 dsc.preallocated[0].data = mpi->planes[0]; | |
1376 dsc.preallocated[0].pitch = mpi->stride[0]; | |
1377 dsc.width = mpi->width; | |
1378 dsc.height = mpi->height; | |
1379 dsc.pixelformat = convformat(mpi->imgfmt); | |
1380 | |
1381 DFBCHECK (dfb->CreateSurface( dfb, &dsc, &tmp)); | |
1382 | |
1383 rect.x=mpi->x; | |
1384 rect.y=mpi->y; | |
1385 rect.w=mpi->w; | |
1386 rect.h=mpi->h; | |
1387 | |
1388 if (frame) { | |
1389 DFBCHECK (tmp->Blit(tmp,frame,&rect,0,0)); | |
1390 } else { | |
1391 DFBCHECK (tmp->Blit(tmp,primary,&rect,xoffset,yoffset)); | |
1392 }; | |
1393 tmp->Release(tmp); | |
10840
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
1394 */ |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
1395 |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
1396 unsigned int pitch; |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
1397 void *dst; |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
1398 |
17969
843e0427b5b9
Change 'if(verbose)' to the more appropriate mp_msg_test.
diego
parents:
16892
diff
changeset
|
1399 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: Put_image - non planar branch\n"); |
10840
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
1400 if (frame) { |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
1401 DFBCHECK (frame->Lock(frame,DSLF_WRITE,&dst,&pitch)); |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
1402 framelocked = 1; |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
1403 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]); |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
1404 } else { |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
1405 DFBCHECK (primary->Lock(primary,DSLF_WRITE,&dst,&pitch)); |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
1406 primarylocked = 1; |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
1407 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]); |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
1408 }; |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
1409 unlock(); |
10f45897d653
Config fixed, changed put_image to use memcpy instead of native blits (for compatibility reasons), always clear primary layer (to have always black background) and try to center image.
zdar
parents:
10618
diff
changeset
|
1410 |
6952 | 1411 } |
1412 return VO_TRUE; | |
1413 } | |
1414 | |
1415 | |
1416 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15750
diff
changeset
|
1417 static int control(uint32_t request, void *data, ...) |
6952 | 1418 { |
1419 switch (request) { | |
1420 case VOCTRL_QUERY_FORMAT: | |
1421 return query_format(*((uint32_t*)data)); | |
1422 case VOCTRL_GET_IMAGE: | |
1423 return get_image(data); | |
1424 case VOCTRL_DRAW_IMAGE: | |
1425 return put_image(data); | |
1426 case VOCTRL_SET_EQUALIZER: | |
1427 { | |
1428 va_list ap; | |
1429 int value; | |
1430 | |
1431 va_start(ap, data); | |
1432 value = va_arg(ap, int); | |
1433 va_end(ap); | |
1434 | |
1435 return(directfb_set_video_eq(data, value)); | |
1436 } | |
1437 case VOCTRL_GET_EQUALIZER: | |
1438 { | |
1439 va_list ap; | |
1440 int *value; | |
1441 | |
1442 va_start(ap, data); | |
1443 value = va_arg(ap, int*); | |
1444 va_end(ap); | |
1445 | |
1446 return(directfb_get_video_eq(data, value)); | |
1447 } | |
1448 }; | |
1449 return VO_NOTIMPL; | |
1450 } | |
1451 | |
1452 // unused function | |
1453 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15750
diff
changeset
|
1454 static int draw_frame(uint8_t *src[]) |
6952 | 1455 { |
1456 return -1; | |
1457 } | |
1458 | |
1459 // hopefully will be removed soon | |
1460 | |
1461 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, | |
1462 unsigned char *srca, int stride) | |
1463 { | |
1464 void *dst; | |
1465 int pitch; | |
1466 | |
11000 | 1467 unlock(); // isn't it silly I have to unlock surface and then lock it again :-) |
6952 | 1468 |
1469 if (frame) { | |
10004
c889e7f9391a
triple buffering support, configuration/option system changed,some minor bugs fixed
zdar
parents:
9937
diff
changeset
|
1470 DFBCHECK (frame->Lock(frame,DSLF_WRITE|DSLF_READ,&dst,&pitch)); |
6952 | 1471 framelocked = 1; |
1472 } else { | |
1473 DFBCHECK (primary->Lock(primary,DSLF_WRITE,&dst,&pitch)); | |
1474 primarylocked = 1; | |
1475 }; | |
1476 | |
1477 switch(pixel_format) { | |
1478 case DSPF_RGB32: | |
1479 case DSPF_ARGB: | |
1480 vo_draw_alpha_rgb32(w,h,src,srca,stride,((uint8_t *) dst)+pitch*y0 + 4*x0,pitch); | |
1481 break; | |
1482 | |
1483 case DSPF_RGB24: | |
1484 vo_draw_alpha_rgb24(w,h,src,srca,stride,((uint8_t *) dst)+pitch*y0 + 3*x0,pitch); | |
1485 break; | |
1486 | |
1487 case DSPF_RGB16: | |
1488 vo_draw_alpha_rgb16(w,h,src,srca,stride,((uint8_t *) dst)+pitch*y0 + 2*x0,pitch); | |
1489 break; | |
8640 | 1490 #if DIRECTFBVERSION > 915 |
1491 case DSPF_ARGB1555: | |
1492 #else | |
6952 | 1493 case DSPF_RGB15: |
8640 | 1494 #endif |
6952 | 1495 vo_draw_alpha_rgb15(w,h,src,srca,stride,((uint8_t *) dst)+pitch*y0 + 2*x0,pitch); |
1496 break; | |
1497 | |
1498 case DSPF_YUY2: | |
1499 vo_draw_alpha_yuy2(w,h,src,srca,stride,((uint8_t *) dst) + pitch*y0 + 2*x0,pitch); | |
1500 break; | |
1501 | |
1502 case DSPF_UYVY: | |
1503 vo_draw_alpha_yuy2(w,h,src,srca,stride,((uint8_t *) dst) + pitch*y0 + 2*x0 + 1,pitch); | |
1504 break; | |
1505 | |
1506 case DSPF_I420: | |
1507 case DSPF_YV12: | |
1508 vo_draw_alpha_yv12(w,h,src,srca,stride,((uint8_t *) dst) + pitch*y0 + 1*x0,pitch); | |
1509 break; | |
1510 } | |
1511 | |
1512 unlock(); | |
1513 } | |
1514 | |
1515 static void draw_osd(void) | |
1516 { | |
1517 vo_draw_text(width,height,draw_alpha); | |
1518 } |