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