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