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