Mercurial > mplayer.hg
annotate libvo/vo_matrixview.c @ 36015:73652b504ee1
Rephrase positively.
Additionally, add #include for PATH_MAX.
author | ib |
---|---|
date | Sun, 31 Mar 2013 03:57:53 +0000 |
parents | 389d43c448b3 |
children | 673719da1a92 |
rev | line source |
---|---|
30140 | 1 /* |
2 * MatrixView video output driver for MPlayer | |
3 * | |
4 * by Pigeon <pigeon at pigeond.net> | |
5 * | |
6 * Based on MatrixView the screensaver from http://rss-glx.sf.net/ | |
7 * | |
8 * This file is part of MPlayer. | |
9 * | |
10 * MPlayer is free software; you can redistribute it and/or modify | |
11 * it under the terms of the GNU General Public License as published by | |
12 * the Free Software Foundation; either version 2 of the License, or | |
13 * (at your option) any later version. | |
14 * | |
15 * MPlayer is distributed in the hope that it will be useful, | |
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 * GNU General Public License for more details. | |
19 * | |
20 * You should have received a copy of the GNU General Public License along | |
21 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
23 */ | |
24 | |
25 #include "config.h" | |
26 | |
27 #include <stdint.h> | |
35903 | 28 #include <strings.h> |
30140 | 29 |
30 #include "mp_msg.h" | |
31 #include "subopt-helper.h" | |
32 #include "video_out.h" | |
33 #include "video_out_internal.h" | |
33301
899d817e56fc
Implement control() VOCTRL_SET/GET_EQUALIZER using a vf_equalize struct,
iive
parents:
30925
diff
changeset
|
34 #include "libmpcodecs/vf.h" |
30140 | 35 #include "gl_common.h" |
36 #include "libswscale/swscale.h" | |
37 #include "libmpcodecs/vf_scale.h" | |
38 #include "osdep/timer.h" | |
39 | |
40 #include "matrixview.h" | |
41 | |
30153 | 42 static const vo_info_t info = { |
30140 | 43 "MatrixView (OpenGL)", |
44 "matrixview", | |
45 "Pigeon <pigeon@pigeond.net>", | |
46 "Based on MatrixView from rss-glx.sf.net" | |
47 }; | |
48 | |
30925
f8939d5b14b5
Mark some more LIBVO_EXTERN declarations as const where possible.
reimar
parents:
30633
diff
changeset
|
49 const LIBVO_EXTERN(matrixview) |
30140 | 50 |
51 static MPGLContext glctx; | |
52 | |
53 #ifdef CONFIG_GL_X11 | |
54 static int wsGLXAttrib[] = { | |
55 GLX_RGBA, | |
56 GLX_RED_SIZE,1, | |
57 GLX_GREEN_SIZE,1, | |
58 GLX_BLUE_SIZE,1, | |
59 GLX_DEPTH_SIZE,1, | |
60 GLX_DOUBLEBUFFER, | |
61 None | |
62 }; | |
63 #endif | |
64 | |
65 static int int_pause; | |
66 static int eq_contrast; | |
67 static int eq_brightness; | |
68 static uint32_t image_width; | |
69 static uint32_t image_height; | |
70 static uint32_t image_format; | |
71 static struct SwsContext *sws; | |
72 | |
73 static uint8_t *map_image[MP_MAX_PLANES]; | |
74 static int map_stride[MP_MAX_PLANES]; | |
75 | |
76 #define DEFAULT_MATRIX_ROWS 96 | |
77 #define DEFAULT_MATRIX_COLS 128 | |
78 static int matrix_rows; | |
79 static int matrix_cols; | |
80 | |
81 #define DEFAULT_CONTRAST 0.90f | |
82 #define CONTRAST_MULTIPLIER 0.02f | |
83 | |
84 #define DEFAULT_BRIGHTNESS 1.0f | |
85 #define BRIGHTNESS_MULTIPLIER 0.02f | |
86 | |
87 | |
88 static void contrast_set(int value) | |
89 { | |
90 float contrast = value * CONTRAST_MULTIPLIER + DEFAULT_CONTRAST; | |
91 eq_contrast = value; | |
30153 | 92 if (contrast < 0) |
93 contrast = 0; | |
30140 | 94 matrixview_contrast_set(contrast); |
95 } | |
96 | |
97 | |
98 static void brightness_set(int value) | |
99 { | |
100 float brightness = value * BRIGHTNESS_MULTIPLIER + DEFAULT_BRIGHTNESS; | |
101 eq_brightness = value; | |
30153 | 102 if (brightness < 0) |
103 brightness = 0; | |
30140 | 104 matrixview_brightness_set(brightness); |
105 } | |
106 | |
107 | |
30153 | 108 static int config(uint32_t width, uint32_t height, |
109 uint32_t d_width, uint32_t d_height, | |
110 uint32_t flags, char *title, uint32_t format) | |
30140 | 111 { |
112 image_height = height; | |
30153 | 113 image_width = width; |
30140 | 114 image_format = format; |
115 | |
116 int_pause = 0; | |
117 | |
118 #ifdef CONFIG_GL_WIN32 | |
30153 | 119 if (glctx.type == GLTYPE_W32 && !vo_w32_config(d_width, d_height, flags)) |
120 return -1; | |
30140 | 121 #endif |
122 #ifdef CONFIG_GL_X11 | |
30153 | 123 if (glctx.type == GLTYPE_X11) { |
124 XVisualInfo *vinfo=glXChooseVisual( mDisplay,mScreen,wsGLXAttrib ); | |
125 if (vinfo == NULL) { | |
126 mp_msg(MSGT_VO, MSGL_ERR, "[matrixview] no GLX support present\n"); | |
127 return -1; | |
128 } | |
129 mp_msg(MSGT_VO, MSGL_V, "[matrixview] GLX chose visual with ID 0x%x\n", | |
130 (int)vinfo->visualid); | |
131 | |
132 vo_x11_create_vo_window(vinfo, vo_dx, vo_dy, d_width, d_height, flags, | |
133 XCreateColormap(mDisplay, mRootWin, | |
134 vinfo->visual, AllocNone), | |
135 "matrixview", title); | |
30140 | 136 } |
137 #endif /* CONFIG_GL_WIN32 */ | |
138 if (glctx.setGlWindow(&glctx) == SET_WINDOW_FAILED) | |
139 return -1; | |
140 | |
30153 | 141 if (sws) |
30140 | 142 sws_freeContext(sws); |
143 | |
30153 | 144 sws = sws_getContextFromCmdLine(image_width, image_height, image_format, |
145 matrix_cols, matrix_rows, IMGFMT_Y8); | |
30140 | 146 if (!sws) { |
147 mp_msg(MSGT_VO, MSGL_ERR, "[matrixview] Cannot create SwsContext context\n"); | |
148 return -1; | |
149 } | |
150 | |
30153 | 151 if (!map_image[0]) |
30140 | 152 map_image[0] = calloc(matrix_cols, matrix_rows); |
153 | |
154 map_stride[0] = matrix_cols; | |
155 | |
156 matrixview_init(vo_dwidth, vo_dheight); | |
157 matrixview_matrix_resize(matrix_cols, matrix_rows); | |
158 | |
159 contrast_set(eq_contrast); | |
160 brightness_set(eq_brightness); | |
161 matrixview_reshape(vo_dwidth, vo_dheight); | |
162 return 0; | |
163 } | |
164 | |
165 | |
166 static void check_events(void) | |
167 { | |
30153 | 168 int e = glctx.check_events(); |
169 if (e & VO_EVENT_RESIZE) { | |
30140 | 170 matrixview_reshape(vo_dwidth, vo_dheight); |
171 } | |
30153 | 172 if (e & VO_EVENT_EXPOSE && int_pause) |
173 flip_page(); | |
30140 | 174 } |
175 | |
176 | |
177 static void draw_osd(void) | |
178 { | |
179 return; | |
180 } | |
181 | |
182 | |
183 static void flip_page(void) | |
184 { | |
185 matrixview_draw(vo_dwidth, vo_dheight, GetTimer(), 0.0, map_image[0]); | |
186 glctx.swapGlBuffers(&glctx); | |
187 } | |
188 | |
189 | |
190 | |
191 static int draw_slice(uint8_t *src[], int stride[], int w, int h, int x, int y) | |
192 { | |
193 sws_scale(sws, src, stride, y, h, map_image, map_stride); | |
194 return 0; | |
195 } | |
196 | |
197 | |
198 static int draw_frame(uint8_t *src[]) | |
199 { | |
200 return 0; | |
201 } | |
202 | |
203 | |
204 static int query_format(uint32_t format) | |
205 { | |
206 int caps = VFCAP_CSP_SUPPORTED | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN | VFCAP_ACCEPT_STRIDE; | |
207 | |
30153 | 208 switch (format) { |
209 case IMGFMT_YV12: | |
210 case IMGFMT_BGR32: | |
211 case IMGFMT_BGR24: | |
212 case IMGFMT_BGR16: | |
213 case IMGFMT_BGR15: | |
214 case IMGFMT_RGB32: | |
215 case IMGFMT_RGB24: | |
216 return caps; | |
217 default: | |
218 break; | |
30140 | 219 } |
220 | |
221 return 0; | |
222 } | |
223 | |
224 | |
225 static void uninit(void) | |
226 { | |
30153 | 227 if (!vo_config_count) |
228 return; | |
30140 | 229 uninit_mpglcontext(&glctx); |
230 free(map_image[0]); | |
231 map_image[0] = NULL; | |
232 sws_freeContext(sws); | |
233 sws = NULL; | |
234 } | |
235 | |
236 | |
237 static const opt_t subopts[] = | |
238 { | |
30153 | 239 { "rows", OPT_ARG_INT, &matrix_rows, int_pos }, |
240 { "cols", OPT_ARG_INT, &matrix_cols, int_pos }, | |
30140 | 241 { NULL } |
242 }; | |
243 | |
244 | |
245 static int preinit(const char *arg) | |
246 { | |
247 enum MPGLType gltype = GLTYPE_X11; | |
248 #ifdef CONFIG_GL_WIN32 | |
249 gltype = GLTYPE_W32; | |
250 #endif | |
30153 | 251 if (!init_mpglcontext(&glctx, gltype)) |
252 return -1; | |
30140 | 253 |
254 matrix_rows = DEFAULT_MATRIX_ROWS; | |
255 matrix_cols = DEFAULT_MATRIX_COLS; | |
256 | |
30153 | 257 if (subopt_parse(arg, subopts) != 0) { |
30140 | 258 mp_msg(MSGT_VO, MSGL_FATAL, |
259 "\n-vo matrixview command line help:\n" | |
260 "Example: mplayer -vo matrixview:cols=320:rows=240\n" | |
261 "\n" | |
262 "Options:\n" | |
263 "\n" | |
264 " cols=<12-320>\n" | |
265 " Specify the number of columns of the matrix view, default %d\n" | |
266 "\n" | |
267 " rows=<12-240>\n" | |
268 " Specify the number of rows of the matrix view, default %d\n" | |
269 "\n" | |
270 , | |
271 DEFAULT_MATRIX_COLS, DEFAULT_MATRIX_ROWS | |
272 ); | |
273 return -1; | |
274 } | |
275 | |
276 return 0; | |
277 } | |
278 | |
279 | |
33305
ddb45e9443ec
Remove the variable arguments from the libvo control() functions.
iive
parents:
33301
diff
changeset
|
280 static int control(uint32_t request, void *data) |
30140 | 281 { |
282 switch (request) { | |
283 case VOCTRL_PAUSE: | |
284 case VOCTRL_RESUME: | |
285 int_pause = (request == VOCTRL_PAUSE); | |
286 return VO_TRUE; | |
287 case VOCTRL_QUERY_FORMAT: | |
288 return query_format(*(uint32_t*)data); | |
289 case VOCTRL_ONTOP: | |
290 glctx.ontop(); | |
291 return VO_TRUE; | |
292 case VOCTRL_FULLSCREEN: | |
293 glctx.fullscreen(); | |
294 matrixview_reshape(vo_dwidth, vo_dheight); | |
295 return VO_TRUE; | |
296 case VOCTRL_BORDER: | |
297 glctx.border(); | |
298 return VO_TRUE; | |
299 case VOCTRL_GET_EQUALIZER: | |
300 { | |
33301
899d817e56fc
Implement control() VOCTRL_SET/GET_EQUALIZER using a vf_equalize struct,
iive
parents:
30925
diff
changeset
|
301 vf_equalizer_t *eq=data; |
899d817e56fc
Implement control() VOCTRL_SET/GET_EQUALIZER using a vf_equalize struct,
iive
parents:
30925
diff
changeset
|
302 |
899d817e56fc
Implement control() VOCTRL_SET/GET_EQUALIZER using a vf_equalize struct,
iive
parents:
30925
diff
changeset
|
303 if (strcasecmp(eq->item, "contrast") == 0) { |
899d817e56fc
Implement control() VOCTRL_SET/GET_EQUALIZER using a vf_equalize struct,
iive
parents:
30925
diff
changeset
|
304 eq->value = eq_contrast; |
899d817e56fc
Implement control() VOCTRL_SET/GET_EQUALIZER using a vf_equalize struct,
iive
parents:
30925
diff
changeset
|
305 } else if (strcasecmp(eq->item, "brightness") == 0) { |
899d817e56fc
Implement control() VOCTRL_SET/GET_EQUALIZER using a vf_equalize struct,
iive
parents:
30925
diff
changeset
|
306 eq->value = eq_brightness; |
30140 | 307 } |
308 } | |
309 return VO_TRUE; | |
310 case VOCTRL_SET_EQUALIZER: | |
311 { | |
33301
899d817e56fc
Implement control() VOCTRL_SET/GET_EQUALIZER using a vf_equalize struct,
iive
parents:
30925
diff
changeset
|
312 vf_equalizer_t *eq=data; |
899d817e56fc
Implement control() VOCTRL_SET/GET_EQUALIZER using a vf_equalize struct,
iive
parents:
30925
diff
changeset
|
313 if (strcasecmp(eq->item, "contrast") == 0) { |
899d817e56fc
Implement control() VOCTRL_SET/GET_EQUALIZER using a vf_equalize struct,
iive
parents:
30925
diff
changeset
|
314 contrast_set(eq->value); |
899d817e56fc
Implement control() VOCTRL_SET/GET_EQUALIZER using a vf_equalize struct,
iive
parents:
30925
diff
changeset
|
315 } else if (strcasecmp(eq->item, "brightness") == 0) { |
899d817e56fc
Implement control() VOCTRL_SET/GET_EQUALIZER using a vf_equalize struct,
iive
parents:
30925
diff
changeset
|
316 brightness_set(eq->value); |
30140 | 317 } |
318 } | |
319 return VO_TRUE; | |
320 case VOCTRL_UPDATE_SCREENINFO: | |
321 glctx.update_xinerama_info(); | |
322 return VO_TRUE; | |
323 } | |
324 return VO_NOTIMPL; | |
325 } |