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