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