annotate libvo/vo_matrixview.c @ 32997:e2382d88fb7f

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