Merge svn changes up to r28204
[mplayer/glamo.git] / libvo / vo_gl.c
blob4178daff9c38e84b00ac280916bf53ac636ee5ec
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <math.h>
6 #include "config.h"
7 #include "mp_msg.h"
8 #include "subopt-helper.h"
9 #include "video_out.h"
10 #include "video_out_internal.h"
11 #include "font_load.h"
12 #include "sub.h"
14 #include "gl_common.h"
15 #include "aspect.h"
16 #ifdef CONFIG_GUI
17 #include "gui/interface.h"
18 #endif
19 #include "fastmemcpy.h"
20 #include "libass/ass.h"
21 #include "libass/ass_mp.h"
23 static const vo_info_t info =
25 "X11 (OpenGL)",
26 "gl",
27 "Arpad Gereoffy <arpi@esp-team.scene.hu>",
31 const LIBVO_EXTERN(gl)
33 #ifdef GL_WIN32
34 static int gl_vinfo = 0;
35 static HGLRC gl_context = 0;
36 #define update_xinerama_info w32_update_xinerama_info
37 #define vo_init vo_w32_init
38 #define vo_window vo_w32_window
39 #else
40 static XVisualInfo *gl_vinfo = NULL;
41 static GLXContext gl_context = 0;
42 static int wsGLXAttrib[] = { GLX_RGBA,
43 GLX_RED_SIZE,1,
44 GLX_GREEN_SIZE,1,
45 GLX_BLUE_SIZE,1,
46 GLX_DOUBLEBUFFER,
47 None };
48 #endif
50 static int use_osd;
51 static int scaled_osd;
52 //! How many parts the OSD may consist of at most
53 #define MAX_OSD_PARTS 20
54 //! Textures for OSD
55 static GLuint osdtex[MAX_OSD_PARTS];
56 #ifndef FAST_OSD
57 //! Alpha textures for OSD
58 static GLuint osdatex[MAX_OSD_PARTS];
59 #endif
60 static GLuint *eosdtex;
61 static GLuint largeeosdtex[2];
62 //! Display lists that draw the OSD parts
63 static GLuint osdDispList[MAX_OSD_PARTS];
64 #ifndef FAST_OSD
65 static GLuint osdaDispList[MAX_OSD_PARTS];
66 #endif
67 static GLuint eosdDispList;
68 //! How many parts the OSD currently consists of
69 static int osdtexCnt;
70 static int eosdtexCnt;
71 static int osd_color;
73 static int use_aspect;
74 static int use_ycbcr;
75 static int use_yuv;
76 static int lscale;
77 static int cscale;
78 static float filter_strength;
79 static int yuvconvtype;
80 static int use_rectangle;
81 static int err_shown;
82 static uint32_t image_width;
83 static uint32_t image_height;
84 static uint32_t image_format;
85 static int many_fmts;
86 static int ati_hack;
87 static int force_pbo;
88 static int mesa_buffer;
89 static int use_glFinish;
90 static int swap_interval;
91 static GLenum gl_target;
92 static GLint gl_texfmt;
93 static GLenum gl_format;
94 static GLenum gl_type;
95 static GLuint gl_buffer;
96 static GLuint gl_buffer_uv[2];
97 static int gl_buffersize;
98 static int gl_buffersize_uv;
99 static void *gl_bufferptr;
100 static void *gl_bufferptr_uv[2];
101 static int mesa_buffersize;
102 static void *mesa_bufferptr;
103 static GLuint fragprog;
104 static GLuint default_texs[22];
105 static char *custom_prog;
106 static char *custom_tex;
107 static int custom_tlin;
108 static int custom_trect;
110 static int int_pause;
111 static int eq_bri = 0;
112 static int eq_cont = 0;
113 static int eq_sat = 0;
114 static int eq_hue = 0;
115 static int eq_rgamma = 0;
116 static int eq_ggamma = 0;
117 static int eq_bgamma = 0;
119 static int texture_width;
120 static int texture_height;
121 static int mpi_flipped;
122 static int vo_flipped;
123 static int ass_border_x, ass_border_y;
125 static unsigned int slice_height = 1;
127 static void redraw(void);
129 static void resize(int x,int y){
130 mp_msg(MSGT_VO, MSGL_V, "[gl] Resize: %dx%d\n",x,y);
131 if (WinID >= 0) {
132 int top = 0, left = 0, w = x, h = y;
133 geometry(&top, &left, &w, &h, vo_screenwidth, vo_screenheight);
134 glViewport(top, left, w, h);
135 } else
136 glViewport( 0, 0, x, y );
138 glMatrixMode(GL_PROJECTION);
139 glLoadIdentity();
140 if (vo_fs && use_aspect) {
141 int new_w, new_h;
142 GLdouble scale_x, scale_y;
143 aspect(&new_w, &new_h, A_ZOOM);
144 panscan_calc();
145 new_w += vo_panscan_x;
146 new_h += vo_panscan_y;
147 scale_x = (GLdouble)new_w / (GLdouble)x;
148 scale_y = (GLdouble)new_h / (GLdouble)y;
149 glScaled(scale_x, scale_y, 1);
150 ass_border_x = (vo_screenwidth - new_w) / 2;
151 ass_border_y = (vo_screenheight - new_h) / 2;
153 glOrtho(0, image_width, image_height, 0, -1,1);
155 glMatrixMode(GL_MODELVIEW);
156 glLoadIdentity();
158 if (!scaled_osd) {
159 #ifdef CONFIG_FREETYPE
160 // adjust font size to display size
161 force_load_font = 1;
162 #endif
163 vo_osd_changed(OSDTYPE_OSD);
165 glClear(GL_COLOR_BUFFER_BIT);
166 redraw();
169 static void texSize(int w, int h, int *texw, int *texh) {
170 if (use_rectangle) {
171 *texw = w; *texh = h;
172 } else {
173 *texw = 32;
174 while (*texw < w)
175 *texw *= 2;
176 *texh = 32;
177 while (*texh < h)
178 *texh *= 2;
180 if (mesa_buffer) *texw = (*texw + 63) & ~63;
181 else if (ati_hack) *texw = (*texw + 511) & ~511;
184 //! maximum size of custom fragment program
185 #define MAX_CUSTOM_PROG_SIZE (1024 * 1024)
186 static void update_yuvconv(void) {
187 float bri = eq_bri / 100.0;
188 float cont = (eq_cont + 100) / 100.0;
189 float hue = eq_hue / 100.0 * 3.1415927;
190 float sat = (eq_sat + 100) / 100.0;
191 float rgamma = exp(log(8.0) * eq_rgamma / 100.0);
192 float ggamma = exp(log(8.0) * eq_ggamma / 100.0);
193 float bgamma = exp(log(8.0) * eq_bgamma / 100.0);
194 gl_conversion_params_t params = {gl_target, yuvconvtype,
195 bri, cont, hue, sat, rgamma, ggamma, bgamma,
196 texture_width, texture_height, filter_strength};
197 glSetupYUVConversion(&params);
198 if (custom_prog) {
199 FILE *f = fopen(custom_prog, "r");
200 if (!f)
201 mp_msg(MSGT_VO, MSGL_WARN,
202 "[gl] Could not read customprog %s\n", custom_prog);
203 else {
204 char *prog = calloc(1, MAX_CUSTOM_PROG_SIZE + 1);
205 fread(prog, 1, MAX_CUSTOM_PROG_SIZE, f);
206 fclose(f);
207 loadGPUProgram(GL_FRAGMENT_PROGRAM, prog);
208 free(prog);
210 ProgramEnvParameter4f(GL_FRAGMENT_PROGRAM, 0,
211 1.0 / texture_width, 1.0 / texture_height,
212 texture_width, texture_height);
214 if (custom_tex) {
215 FILE *f = fopen(custom_tex, "r");
216 if (!f)
217 mp_msg(MSGT_VO, MSGL_WARN,
218 "[gl] Could not read customtex %s\n", custom_tex);
219 else {
220 int width, height, maxval;
221 ActiveTexture(GL_TEXTURE3);
222 if (glCreatePPMTex(custom_trect?GL_TEXTURE_RECTANGLE:GL_TEXTURE_2D, 0,
223 custom_tlin?GL_LINEAR:GL_NEAREST,
224 f, &width, &height, &maxval))
225 ProgramEnvParameter4f(GL_FRAGMENT_PROGRAM, 1,
226 1.0 / width, 1.0 / height, width, height);
227 else
228 mp_msg(MSGT_VO, MSGL_WARN,
229 "[gl] Error parsing customtex %s\n", custom_tex);
230 fclose(f);
231 ActiveTexture(GL_TEXTURE0);
237 * \brief remove all OSD textures and display-lists, thus clearing it.
239 static void clearOSD(void) {
240 int i;
241 if (!osdtexCnt)
242 return;
243 glDeleteTextures(osdtexCnt, osdtex);
244 #ifndef FAST_OSD
245 glDeleteTextures(osdtexCnt, osdatex);
246 for (i = 0; i < osdtexCnt; i++)
247 glDeleteLists(osdaDispList[i], 1);
248 #endif
249 for (i = 0; i < osdtexCnt; i++)
250 glDeleteLists(osdDispList[i], 1);
251 osdtexCnt = 0;
255 * \brief remove textures, display list and free memory used by EOSD
257 static void clearEOSD(void) {
258 if (eosdDispList)
259 glDeleteLists(eosdDispList, 1);
260 eosdDispList = 0;
261 if (eosdtexCnt)
262 glDeleteTextures(eosdtexCnt, eosdtex);
263 eosdtexCnt = 0;
264 free(eosdtex);
265 eosdtex = NULL;
269 * \brief construct display list from ass image list
270 * \param img image list to create OSD from.
271 * A value of NULL has the same effect as clearEOSD()
273 static void genEOSD(mp_eosd_images_t *imgs) {
274 int sx, sy;
275 int tinytexcur = 0;
276 int smalltexcur = 0;
277 GLuint *curtex;
278 GLint scale_type = scaled_osd ? GL_LINEAR : GL_NEAREST;
279 ass_image_t *img = imgs->imgs;
280 ass_image_t *i;
282 if (imgs->changed == 0) // there are elements, but they are unchanged
283 return;
284 if (img && imgs->changed == 1) // there are elements, but they just moved
285 goto skip_upload;
287 clearEOSD();
288 if (!img)
289 return;
290 if (!largeeosdtex[0]) {
291 glGenTextures(2, largeeosdtex);
292 BindTexture(gl_target, largeeosdtex[0]);
293 glCreateClearTex(gl_target, GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE, scale_type, 512, 512, 0);
294 BindTexture(gl_target, largeeosdtex[1]);
295 glCreateClearTex(gl_target, GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE, scale_type, 512, 512, 0);
297 for (i = img; i; i = i->next)
299 if (i->w <= 0 || i->h <= 0 || i->stride < i->w)
300 continue;
301 if (i->w < 16 && i->h < 16 && tinytexcur < 1024)
302 tinytexcur++;
303 else if (i->w < 32 && i->h < 32 && smalltexcur < 256)
304 smalltexcur++;
305 else
306 eosdtexCnt++;
308 mp_msg(MSGT_VO, MSGL_DBG2, "EOSD counts (tiny, small, all): %i, %i, %i\n",
309 tinytexcur, smalltexcur, eosdtexCnt);
310 if (eosdtexCnt) {
311 eosdtex = calloc(eosdtexCnt, sizeof(GLuint));
312 glGenTextures(eosdtexCnt, eosdtex);
314 tinytexcur = smalltexcur = 0;
315 for (i = img, curtex = eosdtex; i; i = i->next) {
316 int x = 0, y = 0;
317 if (i->w <= 0 || i->h <= 0 || i->stride < i->w) {
318 mp_msg(MSGT_VO, MSGL_V, "Invalid dimensions OSD for part!\n");
319 continue;
321 if (i->w < 16 && i->h < 16 && tinytexcur < 1024) {
322 x = (tinytexcur & 31) << 4;
323 y = (tinytexcur >> 5) << 4;
324 BindTexture(gl_target, largeeosdtex[0]);
325 tinytexcur++;
326 } else if (i->w < 32 && i->h < 32 && smalltexcur < 256) {
327 x = (smalltexcur & 15) << 5;
328 y = (smalltexcur >> 4) << 5;
329 BindTexture(gl_target, largeeosdtex[1]);
330 smalltexcur++;
331 } else {
332 texSize(i->w, i->h, &sx, &sy);
333 BindTexture(gl_target, *curtex++);
334 glCreateClearTex(gl_target, GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE, scale_type, sx, sy, 0);
336 glUploadTex(gl_target, GL_ALPHA, GL_UNSIGNED_BYTE, i->bitmap, i->stride,
337 x, y, i->w, i->h, 0);
339 eosdDispList = glGenLists(1);
340 skip_upload:
341 glNewList(eosdDispList, GL_COMPILE);
342 tinytexcur = smalltexcur = 0;
343 for (i = img, curtex = eosdtex; i; i = i->next) {
344 int x = 0, y = 0;
345 if (i->w <= 0 || i->h <= 0 || i->stride < i->w)
346 continue;
347 glColor4ub(i->color >> 24, (i->color >> 16) & 0xff, (i->color >> 8) & 0xff, 255 - (i->color & 0xff));
348 if (i->w < 16 && i->h < 16 && tinytexcur < 1024) {
349 x = (tinytexcur & 31) << 4;
350 y = (tinytexcur >> 5) << 4;
351 sx = sy = 512;
352 BindTexture(gl_target, largeeosdtex[0]);
353 tinytexcur++;
354 } else if (i->w < 32 && i->h < 32 && smalltexcur < 256) {
355 x = (smalltexcur & 15) << 5;
356 y = (smalltexcur >> 4) << 5;
357 sx = sy = 512;
358 BindTexture(gl_target, largeeosdtex[1]);
359 smalltexcur++;
360 } else {
361 texSize(i->w, i->h, &sx, &sy);
362 BindTexture(gl_target, *curtex++);
364 glDrawTex(i->dst_x, i->dst_y, i->w, i->h, x, y, i->w, i->h, sx, sy, use_rectangle == 1, 0, 0);
366 glEndList();
367 BindTexture(gl_target, 0);
371 * \brief uninitialize OpenGL context, freeing textures, buffers etc.
373 static void uninitGl(void) {
374 int i = 0;
375 if (DeletePrograms && fragprog)
376 DeletePrograms(1, &fragprog);
377 fragprog = 0;
378 while (default_texs[i] != 0)
379 i++;
380 if (i)
381 glDeleteTextures(i, default_texs);
382 default_texs[0] = 0;
383 clearOSD();
384 clearEOSD();
385 if (largeeosdtex[0])
386 glDeleteTextures(2, largeeosdtex);
387 largeeosdtex[0] = 0;
388 if (DeleteBuffers && gl_buffer)
389 DeleteBuffers(1, &gl_buffer);
390 gl_buffer = 0; gl_buffersize = 0;
391 gl_bufferptr = NULL;
392 if (DeleteBuffers && gl_buffer_uv[0])
393 DeleteBuffers(2, gl_buffer_uv);
394 gl_buffer_uv[0] = gl_buffer_uv[1] = 0; gl_buffersize_uv = 0;
395 gl_bufferptr_uv[0] = gl_bufferptr_uv[1] = 0;
396 #ifndef GL_WIN32
397 if (mesa_bufferptr)
398 FreeMemoryMESA(mDisplay, mScreen, mesa_bufferptr);
399 #endif
400 mesa_bufferptr = NULL;
401 err_shown = 0;
404 static void autodetectGlExtensions(void) {
405 const char *extensions = glGetString(GL_EXTENSIONS);
406 const char *vendor = glGetString(GL_VENDOR);
407 int is_ati = strstr(vendor, "ATI") != NULL;
408 if (ati_hack == -1) ati_hack = is_ati;
409 if (force_pbo == -1) force_pbo = strstr(extensions, "_pixel_buffer_object") ? is_ati : 0;
410 if (use_rectangle == -1) use_rectangle = strstr(extensions, "_texture_non_power_of_two") ? 0 : 0;
411 if (is_ati && (lscale == 1 || lscale == 2 || cscale == 1 || cscale == 2))
412 mp_msg(MSGT_VO, MSGL_WARN, "Selected scaling mode may be broken on ATI cards.\n"
413 "Tell _them_ to fix GL_REPEAT if you have issues.\n");
417 * \brief Initialize a (new or reused) OpenGL context.
418 * set global gl-related variables to their default values
420 static int initGl(uint32_t d_width, uint32_t d_height) {
421 autodetectGlExtensions();
422 texSize(image_width, image_height, &texture_width, &texture_height);
424 glDisable(GL_BLEND);
425 glDisable(GL_DEPTH_TEST);
426 glDepthMask(GL_FALSE);
427 glDisable(GL_CULL_FACE);
428 glEnable(gl_target);
429 glDrawBuffer(vo_doublebuffering?GL_BACK:GL_FRONT);
430 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
432 mp_msg(MSGT_VO, MSGL_V, "[gl] Creating %dx%d texture...\n",
433 texture_width, texture_height);
435 if (image_format == IMGFMT_YV12) {
436 int i;
437 glGenTextures(21, default_texs);
438 default_texs[21] = 0;
439 for (i = 0; i < 7; i++) {
440 ActiveTexture(GL_TEXTURE1 + i);
441 BindTexture(GL_TEXTURE_2D, default_texs[i]);
442 BindTexture(GL_TEXTURE_RECTANGLE, default_texs[i + 7]);
443 BindTexture(GL_TEXTURE_3D, default_texs[i + 14]);
445 ActiveTexture(GL_TEXTURE1);
446 glCreateClearTex(gl_target, gl_texfmt, gl_format, gl_type, GL_LINEAR,
447 texture_width / 2, texture_height / 2, 128);
448 ActiveTexture(GL_TEXTURE2);
449 glCreateClearTex(gl_target, gl_texfmt, gl_format, gl_type, GL_LINEAR,
450 texture_width / 2, texture_height / 2, 128);
451 switch (use_yuv) {
452 case YUV_CONVERSION_FRAGMENT_LOOKUP:
453 case YUV_CONVERSION_FRAGMENT_POW:
454 case YUV_CONVERSION_FRAGMENT:
455 if (!GenPrograms || !BindProgram) {
456 mp_msg(MSGT_VO, MSGL_ERR, "[gl] fragment program functions missing!\n");
457 break;
459 GenPrograms(1, &fragprog);
460 BindProgram(GL_FRAGMENT_PROGRAM, fragprog);
461 break;
463 ActiveTexture(GL_TEXTURE0);
464 BindTexture(gl_target, 0);
465 update_yuvconv();
467 glCreateClearTex(gl_target, gl_texfmt, gl_format, gl_type, GL_LINEAR,
468 texture_width, texture_height, 0);
470 resize(d_width, d_height);
472 glClearColor( 0.0f,0.0f,0.0f,0.0f );
473 glClear( GL_COLOR_BUFFER_BIT );
474 if (SwapInterval && swap_interval >= 0)
475 SwapInterval(swap_interval);
476 return 1;
479 /* connect to server, create and map window,
480 * allocate colors and (shared) memory
482 static int
483 config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format)
485 image_height = height;
486 image_width = width;
487 image_format = format;
488 glFindFormat(format, NULL, &gl_texfmt, &gl_format, &gl_type);
490 int_pause = 0;
491 vo_flipped = !!(flags & VOFLAG_FLIPPING);
493 #ifdef CONFIG_GUI
494 if (use_gui) {
495 // GUI creates and manages window for us
496 guiGetEvent(guiSetShVideo, 0);
497 #ifndef GL_WIN32
498 goto glconfig;
499 #endif
501 #endif
502 #ifdef GL_WIN32
503 if (!vo_w32_config(d_width, d_height, flags))
504 return -1;
505 #else
507 XVisualInfo *vinfo=glXChooseVisual( mDisplay,mScreen,wsGLXAttrib );
508 if (vinfo == NULL)
510 mp_msg(MSGT_VO, MSGL_ERR, "[gl] no GLX support present\n");
511 return -1;
514 vo_x11_create_vo_window(vinfo, vo_dx, vo_dy, d_width, d_height, flags,
515 XCreateColormap(mDisplay, mRootWin, vinfo->visual, AllocNone),
516 "gl", title);
518 #endif
520 glconfig:
521 if (vo_config_count)
522 uninitGl();
523 setGlWindow(&gl_vinfo, &gl_context, vo_window);
524 initGl(vo_dwidth, vo_dheight);
526 return 0;
529 static void check_events(void)
531 int e=vo_check_events();
532 if(e&VO_EVENT_RESIZE) resize(vo_dwidth,vo_dheight);
533 if(e&VO_EVENT_EXPOSE && int_pause) redraw();
537 * Creates the textures and the display list needed for displaying
538 * an OSD part.
539 * Callback function for vo_draw_text().
541 static void create_osd_texture(int x0, int y0, int w, int h,
542 unsigned char *src, unsigned char *srca,
543 int stride)
545 // initialize to 8 to avoid special-casing on alignment
546 int sx = 8, sy = 8;
547 GLint scale_type = scaled_osd ? GL_LINEAR : GL_NEAREST;
549 if (w <= 0 || h <= 0 || stride < w) {
550 mp_msg(MSGT_VO, MSGL_V, "Invalid dimensions OSD for part!\n");
551 return;
553 texSize(w, h, &sx, &sy);
555 if (osdtexCnt >= MAX_OSD_PARTS) {
556 mp_msg(MSGT_VO, MSGL_ERR, "Too many OSD parts, contact the developers!\n");
557 return;
560 // create Textures for OSD part
561 glGenTextures(1, &osdtex[osdtexCnt]);
562 BindTexture(gl_target, osdtex[osdtexCnt]);
563 glCreateClearTex(gl_target, GL_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE, scale_type, sx, sy, 0);
564 glUploadTex(gl_target, GL_LUMINANCE, GL_UNSIGNED_BYTE, src, stride,
565 0, 0, w, h, 0);
567 #ifndef FAST_OSD
568 glGenTextures(1, &osdatex[osdtexCnt]);
569 BindTexture(gl_target, osdatex[osdtexCnt]);
570 glCreateClearTex(gl_target, GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE, scale_type, sx, sy, 0);
572 int i;
573 char *tmp = malloc(stride * h);
574 // convert alpha from weird MPlayer scale.
575 // in-place is not possible since it is reused for future OSDs
576 for (i = h * stride - 1; i >= 0; i--)
577 tmp[i] = -srca[i];
578 glUploadTex(gl_target, GL_ALPHA, GL_UNSIGNED_BYTE, tmp, stride,
579 0, 0, w, h, 0);
580 free(tmp);
582 #endif
584 BindTexture(gl_target, 0);
586 // Create a list for rendering this OSD part
587 #ifndef FAST_OSD
588 osdaDispList[osdtexCnt] = glGenLists(1);
589 glNewList(osdaDispList[osdtexCnt], GL_COMPILE);
590 // render alpha
591 BindTexture(gl_target, osdatex[osdtexCnt]);
592 glDrawTex(x0, y0, w, h, 0, 0, w, h, sx, sy, use_rectangle == 1, 0, 0);
593 glEndList();
594 #endif
595 osdDispList[osdtexCnt] = glGenLists(1);
596 glNewList(osdDispList[osdtexCnt], GL_COMPILE);
597 // render OSD
598 BindTexture(gl_target, osdtex[osdtexCnt]);
599 glDrawTex(x0, y0, w, h, 0, 0, w, h, sx, sy, use_rectangle == 1, 0, 0);
600 glEndList();
602 osdtexCnt++;
605 static void do_render_osd(void);
607 static void draw_osd(void)
609 if (!use_osd) return;
610 if (vo_osd_changed(0)) {
611 int osd_h, osd_w;
612 clearOSD();
613 osd_w = scaled_osd ? image_width : vo_dwidth;
614 osd_h = scaled_osd ? image_height : vo_dheight;
615 vo_draw_text(osd_w, osd_h, create_osd_texture);
617 if (vo_doublebuffering) do_render_osd();
620 static void do_render(void) {
621 // glEnable(GL_TEXTURE_2D);
622 // glBindTexture(GL_TEXTURE_2D, texture_id);
624 glColor3f(1,1,1);
625 if (image_format == IMGFMT_YV12)
626 glEnableYUVConversion(gl_target, yuvconvtype);
627 glDrawTex(0, 0, image_width, image_height,
628 0, 0, image_width, image_height,
629 texture_width, texture_height,
630 use_rectangle == 1, image_format == IMGFMT_YV12,
631 mpi_flipped ^ vo_flipped);
632 if (image_format == IMGFMT_YV12)
633 glDisableYUVConversion(gl_target, yuvconvtype);
636 static void do_render_osd(void) {
637 if (osdtexCnt > 0 || eosdDispList) {
638 // set special rendering parameters
639 if (!scaled_osd) {
640 glMatrixMode(GL_PROJECTION);
641 glPushMatrix();
642 glLoadIdentity();
643 glOrtho(0, vo_dwidth, vo_dheight, 0, -1, 1);
645 glEnable(GL_BLEND);
646 if (eosdDispList) {
647 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
648 glCallList(eosdDispList);
650 if (osdtexCnt > 0) {
651 glColor4ub((osd_color >> 16) & 0xff, (osd_color >> 8) & 0xff, osd_color & 0xff, 0xff - (osd_color >> 24));
652 // draw OSD
653 #ifndef FAST_OSD
654 glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_ALPHA);
655 glCallLists(osdtexCnt, GL_UNSIGNED_INT, osdaDispList);
656 #endif
657 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
658 glCallLists(osdtexCnt, GL_UNSIGNED_INT, osdDispList);
660 // set rendering parameters back to defaults
661 glDisable(GL_BLEND);
662 if (!scaled_osd)
663 glPopMatrix();
664 BindTexture(gl_target, 0);
668 static void flip_page(void) {
669 if (vo_doublebuffering) {
670 if (use_glFinish) glFinish();
671 swapGlBuffers();
672 if (vo_fs && use_aspect)
673 glClear(GL_COLOR_BUFFER_BIT);
674 } else {
675 do_render();
676 do_render_osd();
677 if (use_glFinish) glFinish();
678 else glFlush();
682 static void redraw(void) {
683 if (vo_doublebuffering) { do_render(); do_render_osd(); }
684 flip_page();
687 //static inline uint32_t draw_slice_x11(uint8_t *src[], uint32_t slice_num)
688 static int draw_slice(uint8_t *src[], int stride[], int w,int h,int x,int y)
690 mpi_flipped = stride[0] < 0;
691 glUploadTex(gl_target, gl_format, gl_type, src[0], stride[0],
692 x, y, w, h, slice_height);
693 if (image_format == IMGFMT_YV12) {
694 ActiveTexture(GL_TEXTURE1);
695 glUploadTex(gl_target, gl_format, gl_type, src[1], stride[1],
696 x / 2, y / 2, w / 2, h / 2, slice_height);
697 ActiveTexture(GL_TEXTURE2);
698 glUploadTex(gl_target, gl_format, gl_type, src[2], stride[2],
699 x / 2, y / 2, w / 2, h / 2, slice_height);
700 ActiveTexture(GL_TEXTURE0);
702 return 0;
705 static uint32_t get_image(mp_image_t *mpi) {
706 int needed_size;
707 if (!GenBuffers || !BindBuffer || !BufferData || !MapBuffer) {
708 if (!err_shown)
709 mp_msg(MSGT_VO, MSGL_ERR, "[gl] extensions missing for dr\n"
710 "Expect a _major_ speed penalty\n");
711 err_shown = 1;
712 return VO_FALSE;
714 if (mpi->flags & MP_IMGFLAG_READABLE) return VO_FALSE;
715 if (mesa_buffer) mpi->width = texture_width;
716 else if (ati_hack) {
717 mpi->width = texture_width;
718 mpi->height = texture_height;
720 mpi->stride[0] = mpi->width * mpi->bpp / 8;
721 needed_size = mpi->stride[0] * mpi->height;
722 if (mesa_buffer) {
723 #ifndef GL_WIN32
724 if (mesa_bufferptr && needed_size > mesa_buffersize) {
725 FreeMemoryMESA(mDisplay, mScreen, mesa_bufferptr);
726 mesa_bufferptr = NULL;
728 if (!mesa_bufferptr)
729 mesa_bufferptr = AllocateMemoryMESA(mDisplay, mScreen, needed_size, 0, 0, 0);
730 mesa_buffersize = needed_size;
731 #endif
732 mpi->planes[0] = mesa_bufferptr;
733 } else {
734 if (!gl_buffer)
735 GenBuffers(1, &gl_buffer);
736 BindBuffer(GL_PIXEL_UNPACK_BUFFER, gl_buffer);
737 if (needed_size > gl_buffersize) {
738 gl_buffersize = needed_size;
739 BufferData(GL_PIXEL_UNPACK_BUFFER, gl_buffersize,
740 NULL, GL_DYNAMIC_DRAW);
742 if (!gl_bufferptr)
743 gl_bufferptr = MapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);
744 mpi->planes[0] = gl_bufferptr;
745 BindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
747 if (!mpi->planes[0]) {
748 if (!err_shown)
749 mp_msg(MSGT_VO, MSGL_ERR, "[gl] could not acquire buffer for dr\n"
750 "Expect a _major_ speed penalty\n");
751 err_shown = 1;
752 return VO_FALSE;
754 if (mpi->imgfmt == IMGFMT_YV12) {
755 // YV12
756 mpi->flags |= MP_IMGFLAG_COMMON_STRIDE | MP_IMGFLAG_COMMON_PLANE;
757 mpi->stride[0] = mpi->width;
758 mpi->planes[1] = mpi->planes[0] + mpi->stride[0] * mpi->height;
759 mpi->stride[1] = mpi->width >> 1;
760 mpi->planes[2] = mpi->planes[1] + mpi->stride[1] * (mpi->height >> 1);
761 mpi->stride[2] = mpi->width >> 1;
762 if (ati_hack && !mesa_buffer) {
763 mpi->flags &= ~MP_IMGFLAG_COMMON_PLANE;
764 if (!gl_buffer_uv[0]) GenBuffers(2, gl_buffer_uv);
765 if (mpi->stride[1] * mpi->height > gl_buffersize_uv) {
766 BindBuffer(GL_PIXEL_UNPACK_BUFFER, gl_buffer_uv[0]);
767 BufferData(GL_PIXEL_UNPACK_BUFFER, mpi->stride[1] * mpi->height,
768 NULL, GL_DYNAMIC_DRAW);
769 BindBuffer(GL_PIXEL_UNPACK_BUFFER, gl_buffer_uv[1]);
770 BufferData(GL_PIXEL_UNPACK_BUFFER, mpi->stride[1] * mpi->height,
771 NULL, GL_DYNAMIC_DRAW);
772 gl_buffersize_uv = mpi->stride[1] * mpi->height;
774 if (!gl_bufferptr_uv[0]) {
775 BindBuffer(GL_PIXEL_UNPACK_BUFFER, gl_buffer_uv[0]);
776 gl_bufferptr_uv[0] = MapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);
777 BindBuffer(GL_PIXEL_UNPACK_BUFFER, gl_buffer_uv[1]);
778 gl_bufferptr_uv[1] = MapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);
780 mpi->planes[1] = gl_bufferptr_uv[0];
781 mpi->planes[2] = gl_bufferptr_uv[1];
784 mpi->flags |= MP_IMGFLAG_DIRECT;
785 return VO_TRUE;
788 static void clear_border(uint8_t *dst, int start, int stride, int height, int full_height, int value) {
789 int right_border = stride - start;
790 int bottom_border = full_height - height;
791 while (height > 0) {
792 memset(dst + start, value, right_border);
793 dst += stride;
794 height--;
796 if (bottom_border > 0)
797 memset(dst, value, stride * bottom_border);
800 static uint32_t draw_image(mp_image_t *mpi) {
801 int slice = slice_height;
802 int stride[3];
803 unsigned char *planes[3];
804 mp_image_t mpi2 = *mpi;
805 int w = mpi->w, h = mpi->h;
806 if (mpi->flags & MP_IMGFLAG_DRAW_CALLBACK)
807 goto skip_upload;
808 mpi2.flags = 0; mpi2.type = MP_IMGTYPE_TEMP;
809 mpi2.width = mpi2.w; mpi2.height = mpi2.h;
810 if (force_pbo && !(mpi->flags & MP_IMGFLAG_DIRECT) && !gl_bufferptr && get_image(&mpi2) == VO_TRUE) {
811 int bpp = mpi->imgfmt == IMGFMT_YV12 ? 8 : mpi->bpp;
812 memcpy_pic(mpi2.planes[0], mpi->planes[0], mpi->w * bpp / 8, mpi->h, mpi2.stride[0], mpi->stride[0]);
813 if (mpi->imgfmt == IMGFMT_YV12) {
814 memcpy_pic(mpi2.planes[1], mpi->planes[1], mpi->w >> 1, mpi->h >> 1, mpi2.stride[1], mpi->stride[1]);
815 memcpy_pic(mpi2.planes[2], mpi->planes[2], mpi->w >> 1, mpi->h >> 1, mpi2.stride[2], mpi->stride[2]);
817 if (ati_hack) { // since we have to do a full upload we need to clear the borders
818 clear_border(mpi2.planes[0], mpi->w * bpp / 8, mpi2.stride[0], mpi->h, mpi2.height, 0);
819 if (mpi->imgfmt == IMGFMT_YV12) {
820 clear_border(mpi2.planes[1], mpi->w >> 1, mpi2.stride[1], mpi->h >> 1, mpi2.height >> 1, 128);
821 clear_border(mpi2.planes[2], mpi->w >> 1, mpi2.stride[2], mpi->h >> 1, mpi2.height >> 1, 128);
824 mpi = &mpi2;
826 stride[0] = mpi->stride[0]; stride[1] = mpi->stride[1]; stride[2] = mpi->stride[2];
827 planes[0] = mpi->planes[0]; planes[1] = mpi->planes[1]; planes[2] = mpi->planes[2];
828 mpi_flipped = stride[0] < 0;
829 if (mpi->flags & MP_IMGFLAG_DIRECT) {
830 if (mesa_buffer) {
831 glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, 1);
832 w = texture_width;
833 } else {
834 intptr_t base = (intptr_t)planes[0];
835 if (ati_hack) { w = texture_width; h = texture_height; }
836 if (mpi_flipped)
837 base += (mpi->h - 1) * stride[0];
838 planes[0] -= base;
839 planes[1] -= base;
840 planes[2] -= base;
841 BindBuffer(GL_PIXEL_UNPACK_BUFFER, gl_buffer);
842 UnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
843 gl_bufferptr = NULL;
844 if (!(mpi->flags & MP_IMGFLAG_COMMON_PLANE))
845 planes[0] = planes[1] = planes[2] = NULL;
847 slice = 0; // always "upload" full texture
849 glUploadTex(gl_target, gl_format, gl_type, planes[0], stride[0],
850 mpi->x, mpi->y, w, h, slice);
851 if (mpi->imgfmt == IMGFMT_YV12) {
852 if ((mpi->flags & MP_IMGFLAG_DIRECT) && !(mpi->flags & MP_IMGFLAG_COMMON_PLANE)) {
853 BindBuffer(GL_PIXEL_UNPACK_BUFFER, gl_buffer_uv[0]);
854 UnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
855 gl_bufferptr_uv[0] = NULL;
857 ActiveTexture(GL_TEXTURE1);
858 glUploadTex(gl_target, gl_format, gl_type, planes[1], stride[1],
859 mpi->x / 2, mpi->y / 2, w / 2, h / 2, slice);
860 if ((mpi->flags & MP_IMGFLAG_DIRECT) && !(mpi->flags & MP_IMGFLAG_COMMON_PLANE)) {
861 BindBuffer(GL_PIXEL_UNPACK_BUFFER, gl_buffer_uv[1]);
862 UnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
863 gl_bufferptr_uv[1] = NULL;
865 ActiveTexture(GL_TEXTURE2);
866 glUploadTex(gl_target, gl_format, gl_type, planes[2], stride[2],
867 mpi->x / 2, mpi->y / 2, w / 2, h / 2, slice);
868 ActiveTexture(GL_TEXTURE0);
870 if (mpi->flags & MP_IMGFLAG_DIRECT) {
871 if (mesa_buffer) glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, 0);
872 else BindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
874 skip_upload:
875 if (vo_doublebuffering) do_render();
876 return VO_TRUE;
879 static int
880 draw_frame(uint8_t *src[])
882 return VO_ERROR;
885 static int
886 query_format(uint32_t format)
888 int caps = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW |
889 VFCAP_FLIP |
890 VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN | VFCAP_ACCEPT_STRIDE;
891 if (use_osd)
892 caps |= VFCAP_OSD | VFCAP_EOSD | (scaled_osd ? 0 : VFCAP_EOSD_UNSCALED);
893 if (format == IMGFMT_RGB24 || format == IMGFMT_RGBA)
894 return caps;
895 if (use_yuv && format == IMGFMT_YV12)
896 return caps;
897 // HACK, otherwise we get only b&w with some filters (e.g. -vf eq)
898 // ideally MPlayer should be fixed instead not to use Y800 when it has the choice
899 if (!use_yuv && (format == IMGFMT_Y8 || format == IMGFMT_Y800))
900 return 0;
901 if (!use_ycbcr && (format == IMGFMT_UYVY || format == IMGFMT_YUY2))
902 return 0;
903 if (many_fmts &&
904 glFindFormat(format, NULL, NULL, NULL, NULL))
905 return caps;
906 return 0;
910 static void
911 uninit(void)
913 if (!vo_config_count) return;
914 uninitGl();
915 releaseGlContext(&gl_vinfo, &gl_context);
916 if (custom_prog) free(custom_prog);
917 custom_prog = NULL;
918 if (custom_tex) free(custom_tex);
919 custom_tex = NULL;
920 vo_uninit();
923 static opt_t subopts[] = {
924 {"manyfmts", OPT_ARG_BOOL, &many_fmts, NULL},
925 {"osd", OPT_ARG_BOOL, &use_osd, NULL},
926 {"scaled-osd", OPT_ARG_BOOL, &scaled_osd, NULL},
927 {"aspect", OPT_ARG_BOOL, &use_aspect, NULL},
928 {"ycbcr", OPT_ARG_BOOL, &use_ycbcr, NULL},
929 {"slice-height", OPT_ARG_INT, &slice_height, (opt_test_f)int_non_neg},
930 {"rectangle", OPT_ARG_INT, &use_rectangle,(opt_test_f)int_non_neg},
931 {"yuv", OPT_ARG_INT, &use_yuv, (opt_test_f)int_non_neg},
932 {"lscale", OPT_ARG_INT, &lscale, (opt_test_f)int_non_neg},
933 {"cscale", OPT_ARG_INT, &cscale, (opt_test_f)int_non_neg},
934 {"filter-strength", OPT_ARG_FLOAT, &filter_strength, NULL},
935 {"ati-hack", OPT_ARG_BOOL, &ati_hack, NULL},
936 {"force-pbo", OPT_ARG_BOOL, &force_pbo, NULL},
937 {"mesa-buffer", OPT_ARG_BOOL, &mesa_buffer, NULL},
938 {"glfinish", OPT_ARG_BOOL, &use_glFinish, NULL},
939 {"swapinterval", OPT_ARG_INT, &swap_interval,NULL},
940 {"customprog", OPT_ARG_MSTRZ,&custom_prog, NULL},
941 {"customtex", OPT_ARG_MSTRZ,&custom_tex, NULL},
942 {"customtlin", OPT_ARG_BOOL, &custom_tlin, NULL},
943 {"customtrect", OPT_ARG_BOOL, &custom_trect, NULL},
944 {"osdcolor", OPT_ARG_INT, &osd_color, NULL},
945 {NULL}
948 static int preinit(const char *arg)
950 // set defaults
951 many_fmts = 1;
952 use_osd = 1;
953 scaled_osd = 0;
954 use_aspect = 1;
955 use_ycbcr = 0;
956 use_yuv = 0;
957 lscale = 0;
958 cscale = 0;
959 filter_strength = 0.5;
960 use_rectangle = -1;
961 use_glFinish = 0;
962 ati_hack = -1;
963 force_pbo = -1;
964 mesa_buffer = 0;
965 swap_interval = 1;
966 slice_height = 0;
967 custom_prog = NULL;
968 custom_tex = NULL;
969 custom_tlin = 1;
970 custom_trect = 0;
971 osd_color = 0xffffff;
972 if (subopt_parse(arg, subopts) != 0) {
973 mp_msg(MSGT_VO, MSGL_FATAL,
974 "\n-vo gl command line help:\n"
975 "Example: mplayer -vo gl:slice-height=4\n"
976 "\nOptions:\n"
977 " nomanyfmts\n"
978 " Disable extended color formats for OpenGL 1.2 and later\n"
979 " slice-height=<0-...>\n"
980 " Slice size for texture transfer, 0 for whole image\n"
981 " noosd\n"
982 " Do not use OpenGL OSD code\n"
983 " scaled-osd\n"
984 " Render OSD at movie resolution and scale it\n"
985 " noaspect\n"
986 " Do not do aspect scaling\n"
987 " rectangle=<0,1,2>\n"
988 " 0: use power-of-two textures\n"
989 " 1: use texture_rectangle\n"
990 " 2: use texture_non_power_of_two\n"
991 " ati-hack\n"
992 " Workaround ATI bug with PBOs\n"
993 " force-pbo\n"
994 " Force use of PBO even if this involves an extra memcpy\n"
995 " glfinish\n"
996 " Call glFinish() before swapping buffers\n"
997 " swapinterval=<n>\n"
998 " Interval in displayed frames between to buffer swaps.\n"
999 " 1 is equivalent to enable VSYNC, 0 to disable VSYNC.\n"
1000 " Requires GLX_SGI_swap_control support to work.\n"
1001 " yuv=<n>\n"
1002 " 0: use software YUV to RGB conversion.\n"
1003 " 1: use register combiners (nVidia only, for older cards).\n"
1004 " 2: use fragment program.\n"
1005 " 3: use fragment program with gamma correction.\n"
1006 " 4: use fragment program with gamma correction via lookup.\n"
1007 " 5: use ATI-specific method (for older cards).\n"
1008 " 6: use lookup via 3D texture.\n"
1009 " lscale=<n>\n"
1010 " 0: use standard bilinear scaling for luma.\n"
1011 " 1: use improved bicubic scaling for luma.\n"
1012 " 2: use cubic in X, linear in Y direction scaling for luma.\n"
1013 " 3: as 1 but without using a lookup texture.\n"
1014 " 4: experimental unsharp masking (sharpening).\n"
1015 " 5: experimental unsharp masking (sharpening) with larger radius.\n"
1016 " cscale=<n>\n"
1017 " as lscale but for chroma (2x slower with little visible effect).\n"
1018 " filter-strength=<value>\n"
1019 " set the effect strength for some lscale/cscale filters\n"
1020 " customprog=<filename>\n"
1021 " use a custom YUV conversion program\n"
1022 " customtex=<filename>\n"
1023 " use a custom YUV conversion lookup texture\n"
1024 " nocustomtlin\n"
1025 " use GL_NEAREST scaling for customtex texture\n"
1026 " customtrect\n"
1027 " use texture_rectangle for customtex texture\n"
1028 " osdcolor=<0xAARRGGBB>\n"
1029 " use the given color for the OSD\n"
1030 " ycbcr\n"
1031 " also try to use the GL_MESA_ycbcr_texture extension\n"
1032 "\n" );
1033 return -1;
1035 if (use_rectangle == 1)
1036 gl_target = GL_TEXTURE_RECTANGLE;
1037 else
1038 gl_target = GL_TEXTURE_2D;
1039 yuvconvtype = use_yuv | lscale << YUV_LUM_SCALER_SHIFT | cscale << YUV_CHROM_SCALER_SHIFT;
1040 if (many_fmts)
1041 mp_msg(MSGT_VO, MSGL_INFO, "[gl] using extended formats. "
1042 "Use -vo gl:nomanyfmts if playback fails.\n");
1043 mp_msg(MSGT_VO, MSGL_V, "[gl] Using %d as slice height "
1044 "(0 means image height).\n", slice_height);
1045 if (!vo_init()) return -1; // Can't open X11
1047 return 0;
1050 #define MASK_ALL_YUV (~(1 << YUV_CONVERSION_NONE))
1051 #define MASK_NOT_COMBINERS (~((1 << YUV_CONVERSION_NONE) | (1 << YUV_CONVERSION_COMBINERS) | (1 << YUV_CONVERSION_COMBINERS_ATI)))
1052 #define MASK_GAMMA_SUPPORT (MASK_NOT_COMBINERS & ~(1 << YUV_CONVERSION_FRAGMENT))
1054 static const struct {
1055 const char *name;
1056 int *value;
1057 int supportmask;
1058 } eq_map[] = {
1059 {"brightness", &eq_bri, MASK_NOT_COMBINERS},
1060 {"contrast", &eq_cont, MASK_NOT_COMBINERS},
1061 {"saturation", &eq_sat, MASK_ALL_YUV },
1062 {"hue", &eq_hue, MASK_ALL_YUV },
1063 {"gamma", &eq_rgamma, MASK_GAMMA_SUPPORT},
1064 {"red_gamma", &eq_rgamma, MASK_GAMMA_SUPPORT},
1065 {"green_gamma", &eq_ggamma, MASK_GAMMA_SUPPORT},
1066 {"blue_gamma", &eq_bgamma, MASK_GAMMA_SUPPORT},
1067 {NULL, NULL, 0 }
1070 static int control(uint32_t request, void *data)
1072 switch (request) {
1073 case VOCTRL_PAUSE:
1074 case VOCTRL_RESUME:
1075 int_pause = (request == VOCTRL_PAUSE);
1076 return VO_TRUE;
1077 case VOCTRL_QUERY_FORMAT:
1078 return query_format(*(uint32_t*)data);
1079 case VOCTRL_GET_IMAGE:
1080 return get_image(data);
1081 case VOCTRL_DRAW_IMAGE:
1082 return draw_image(data);
1083 case VOCTRL_DRAW_EOSD:
1084 if (!data)
1085 return VO_FALSE;
1086 genEOSD(data);
1087 return VO_TRUE;
1088 case VOCTRL_GET_EOSD_RES:
1090 mp_eosd_res_t *r = data;
1091 r->mt = r->mb = r->ml = r->mr = 0;
1092 if (scaled_osd) {r->w = image_width; r->h = image_height;}
1093 else if (vo_fs) {
1094 r->w = vo_screenwidth; r->h = vo_screenheight;
1095 r->ml = r->mr = ass_border_x;
1096 r->mt = r->mb = ass_border_y;
1097 } else {
1098 r->w = vo_dwidth; r->h = vo_dheight;
1101 return VO_TRUE;
1102 case VOCTRL_GUISUPPORT:
1103 return VO_TRUE;
1104 case VOCTRL_ONTOP:
1105 vo_gl_ontop();
1106 return VO_TRUE;
1107 case VOCTRL_FULLSCREEN:
1108 vo_fullscreen();
1109 resize(vo_dwidth, vo_dheight);
1110 return VO_TRUE;
1111 case VOCTRL_BORDER:
1112 vo_gl_border(global_vo);
1113 resize(vo_dwidth, vo_dheight);
1114 return VO_TRUE;
1115 case VOCTRL_GET_PANSCAN:
1116 if (!use_aspect) return VO_NOTIMPL;
1117 return VO_TRUE;
1118 case VOCTRL_SET_PANSCAN:
1119 if (!use_aspect) return VO_NOTIMPL;
1120 resize(vo_dwidth, vo_dheight);
1121 return VO_TRUE;
1122 case VOCTRL_GET_EQUALIZER:
1123 if (image_format == IMGFMT_YV12) {
1124 struct voctrl_get_equalizer_args *args = data;
1125 int i;
1126 for (i = 0; eq_map[i].name; i++)
1127 if (strcmp(args->name, eq_map[i].name) == 0) break;
1128 if (!(eq_map[i].supportmask & (1 << use_yuv)))
1129 break;
1130 *args->valueptr = *eq_map[i].value;
1131 return VO_TRUE;
1133 break;
1134 case VOCTRL_SET_EQUALIZER:
1135 if (image_format == IMGFMT_YV12) {
1136 struct voctrl_set_equalizer_args *args = data;
1137 int i;
1138 for (i = 0; eq_map[i].name; i++)
1139 if (strcmp(args->name, eq_map[i].name) == 0) break;
1140 if (!(eq_map[i].supportmask & (1 << use_yuv)))
1141 break;
1142 *eq_map[i].value = args->value;
1143 update_yuvconv();
1144 return VO_TRUE;
1146 break;
1147 case VOCTRL_UPDATE_SCREENINFO:
1148 update_xinerama_info();
1149 return VO_TRUE;
1151 return VO_NOTIMPL;