2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #include "subopt-helper.h"
27 #include "video_out.h"
28 #include "video_out_internal.h"
29 #include "font_load.h"
32 #include "gl_common.h"
34 #include "fastmemcpy.h"
37 static const vo_info_t info
=
41 "Arpad Gereoffy <arpi@esp-team.scene.hu>",
45 const LIBVO_EXTERN(gl
)
48 static int wsGLXAttrib
[] = { GLX_RGBA
,
55 static MPGLContext glctx
;
58 static int scaled_osd
;
59 //! How many parts the OSD may consist of at most
60 #define MAX_OSD_PARTS 20
62 static GLuint osdtex
[MAX_OSD_PARTS
];
64 //! Alpha textures for OSD
65 static GLuint osdatex
[MAX_OSD_PARTS
];
67 static GLuint
*eosdtex
;
68 #define LARGE_EOSD_TEX_SIZE 512
69 #define TINYTEX_SIZE 16
70 #define TINYTEX_COLS (LARGE_EOSD_TEX_SIZE/TINYTEX_SIZE)
71 #define TINYTEX_MAX (TINYTEX_COLS*TINYTEX_COLS)
72 #define SMALLTEX_SIZE 32
73 #define SMALLTEX_COLS (LARGE_EOSD_TEX_SIZE/SMALLTEX_SIZE)
74 #define SMALLTEX_MAX (SMALLTEX_COLS*SMALLTEX_COLS)
75 static GLuint largeeosdtex
[2];
76 //! Display lists that draw the OSD parts
77 static GLuint osdDispList
[MAX_OSD_PARTS
];
79 static GLuint osdaDispList
[MAX_OSD_PARTS
];
81 static GLuint eosdDispList
;
82 //! How many parts the OSD currently consists of
84 static int eosdtexCnt
;
87 static int use_aspect
;
92 static float filter_strength
;
93 static int yuvconvtype
;
94 static int use_rectangle
;
96 static uint32_t image_width
;
97 static uint32_t image_height
;
98 static uint32_t image_format
;
101 static int force_pbo
;
102 static int mesa_buffer
;
103 static int use_glFinish
;
104 static int swap_interval
;
105 static GLenum gl_target
;
106 static GLint gl_texfmt
;
107 static GLenum gl_format
;
108 static GLenum gl_type
;
109 static GLuint gl_buffer
;
110 static GLuint gl_buffer_uv
[2];
111 static int gl_buffersize
;
112 static int gl_buffersize_uv
;
113 static void *gl_bufferptr
;
114 static void *gl_bufferptr_uv
[2];
115 static int mesa_buffersize
;
116 static void *mesa_bufferptr
;
117 static GLuint fragprog
;
118 static GLuint default_texs
[22];
119 static char *custom_prog
;
120 static char *custom_tex
;
121 static int custom_tlin
;
122 static int custom_trect
;
124 static int int_pause
;
125 static int eq_bri
= 0;
126 static int eq_cont
= 0;
127 static int eq_sat
= 0;
128 static int eq_hue
= 0;
129 static int eq_rgamma
= 0;
130 static int eq_ggamma
= 0;
131 static int eq_bgamma
= 0;
133 static int texture_width
;
134 static int texture_height
;
135 static int mpi_flipped
;
136 static int vo_flipped
;
137 static int ass_border_x
, ass_border_y
;
139 static unsigned int slice_height
= 1;
141 static void redraw(void);
143 static void resize(int x
,int y
){
144 mp_msg(MSGT_VO
, MSGL_V
, "[gl] Resize: %dx%d\n",x
,y
);
146 int top
= 0, left
= 0, w
= x
, h
= y
;
147 geometry(&top
, &left
, &w
, &h
, vo_screenwidth
, vo_screenheight
);
148 Viewport(top
, left
, w
, h
);
150 Viewport( 0, 0, x
, y
);
152 MatrixMode(GL_PROJECTION
);
154 ass_border_x
= ass_border_y
= 0;
155 if (aspect_scaling() && use_aspect
) {
157 GLdouble scale_x
, scale_y
;
158 aspect(&new_w
, &new_h
, A_WINZOOM
);
159 panscan_calc_windowed();
160 new_w
+= vo_panscan_x
;
161 new_h
+= vo_panscan_y
;
162 scale_x
= (GLdouble
)new_w
/ (GLdouble
)x
;
163 scale_y
= (GLdouble
)new_h
/ (GLdouble
)y
;
164 Scaled(scale_x
, scale_y
, 1);
165 ass_border_x
= (vo_dwidth
- new_w
) / 2;
166 ass_border_y
= (vo_dheight
- new_h
) / 2;
168 Ortho(0, image_width
, image_height
, 0, -1,1);
170 MatrixMode(GL_MODELVIEW
);
174 #ifdef CONFIG_FREETYPE
175 // adjust font size to display size
178 vo_osd_changed(OSDTYPE_OSD
);
180 Clear(GL_COLOR_BUFFER_BIT
);
184 static void texSize(int w
, int h
, int *texw
, int *texh
) {
186 *texw
= w
; *texh
= h
;
195 if (mesa_buffer
) *texw
= (*texw
+ 63) & ~63;
196 else if (ati_hack
) *texw
= (*texw
+ 511) & ~511;
199 //! maximum size of custom fragment program
200 #define MAX_CUSTOM_PROG_SIZE (1024 * 1024)
201 static void update_yuvconv(void) {
202 float bri
= eq_bri
/ 100.0;
203 float cont
= (eq_cont
+ 100) / 100.0;
204 float hue
= eq_hue
/ 100.0 * 3.1415927;
205 float sat
= (eq_sat
+ 100) / 100.0;
206 float rgamma
= exp(log(8.0) * eq_rgamma
/ 100.0);
207 float ggamma
= exp(log(8.0) * eq_ggamma
/ 100.0);
208 float bgamma
= exp(log(8.0) * eq_bgamma
/ 100.0);
209 gl_conversion_params_t params
= {gl_target
, yuvconvtype
,
210 bri
, cont
, hue
, sat
, rgamma
, ggamma
, bgamma
,
211 texture_width
, texture_height
, filter_strength
};
212 glSetupYUVConversion(¶ms
);
214 FILE *f
= fopen(custom_prog
, "r");
216 mp_msg(MSGT_VO
, MSGL_WARN
,
217 "[gl] Could not read customprog %s\n", custom_prog
);
219 char *prog
= calloc(1, MAX_CUSTOM_PROG_SIZE
+ 1);
220 fread(prog
, 1, MAX_CUSTOM_PROG_SIZE
, f
);
222 loadGPUProgram(GL_FRAGMENT_PROGRAM
, prog
);
225 ProgramEnvParameter4f(GL_FRAGMENT_PROGRAM
, 0,
226 1.0 / texture_width
, 1.0 / texture_height
,
227 texture_width
, texture_height
);
230 FILE *f
= fopen(custom_tex
, "r");
232 mp_msg(MSGT_VO
, MSGL_WARN
,
233 "[gl] Could not read customtex %s\n", custom_tex
);
235 int width
, height
, maxval
;
236 ActiveTexture(GL_TEXTURE3
);
237 if (glCreatePPMTex(custom_trect
?GL_TEXTURE_RECTANGLE
:GL_TEXTURE_2D
, 0,
238 custom_tlin
?GL_LINEAR
:GL_NEAREST
,
239 f
, &width
, &height
, &maxval
))
240 ProgramEnvParameter4f(GL_FRAGMENT_PROGRAM
, 1,
241 1.0 / width
, 1.0 / height
, width
, height
);
243 mp_msg(MSGT_VO
, MSGL_WARN
,
244 "[gl] Error parsing customtex %s\n", custom_tex
);
246 ActiveTexture(GL_TEXTURE0
);
252 * \brief remove all OSD textures and display-lists, thus clearing it.
254 static void clearOSD(void) {
258 DeleteTextures(osdtexCnt
, osdtex
);
260 DeleteTextures(osdtexCnt
, osdatex
);
261 for (i
= 0; i
< osdtexCnt
; i
++)
262 DeleteLists(osdaDispList
[i
], 1);
264 for (i
= 0; i
< osdtexCnt
; i
++)
265 DeleteLists(osdDispList
[i
], 1);
270 * \brief remove textures, display list and free memory used by EOSD
272 static void clearEOSD(void) {
274 DeleteLists(eosdDispList
, 1);
277 DeleteTextures(eosdtexCnt
, eosdtex
);
283 static void do_render_osd(int);
285 static inline int is_tinytex(ASS_Image
*i
, int tinytexcur
) {
286 return i
->w
< TINYTEX_SIZE
&& i
->h
< TINYTEX_SIZE
&& tinytexcur
< TINYTEX_MAX
;
289 static inline int is_smalltex(ASS_Image
*i
, int smalltexcur
) {
290 return i
->w
< SMALLTEX_SIZE
&& i
->h
< SMALLTEX_SIZE
&& smalltexcur
< SMALLTEX_MAX
;
293 static inline void tinytex_pos(int tinytexcur
, int *x
, int *y
) {
294 *x
= (tinytexcur
% TINYTEX_COLS
) * TINYTEX_SIZE
;
295 *y
= (tinytexcur
/ TINYTEX_COLS
) * TINYTEX_SIZE
;
298 static inline void smalltex_pos(int smalltexcur
, int *x
, int *y
) {
299 *x
= (smalltexcur
% SMALLTEX_COLS
) * SMALLTEX_SIZE
;
300 *y
= (smalltexcur
/ SMALLTEX_COLS
) * SMALLTEX_SIZE
;
304 * \brief construct display list from ass image list
305 * \param img image list to create OSD from.
306 * A value of NULL has the same effect as clearEOSD()
308 static void genEOSD(mp_eosd_images_t
*imgs
) {
313 GLint scale_type
= scaled_osd
? GL_LINEAR
: GL_NEAREST
;
314 ASS_Image
*img
= imgs
->imgs
;
317 if (imgs
->changed
== 0) // there are elements, but they are unchanged
319 if (img
&& imgs
->changed
== 1) // there are elements, but they just moved
325 if (!largeeosdtex
[0]) {
326 glGenTextures(2, largeeosdtex
);
327 BindTexture(gl_target
, largeeosdtex
[0]);
328 glCreateClearTex(gl_target
, GL_ALPHA
, GL_ALPHA
, GL_UNSIGNED_BYTE
, scale_type
, LARGE_EOSD_TEX_SIZE
, LARGE_EOSD_TEX_SIZE
, 0);
329 BindTexture(gl_target
, largeeosdtex
[1]);
330 glCreateClearTex(gl_target
, GL_ALPHA
, GL_ALPHA
, GL_UNSIGNED_BYTE
, scale_type
, LARGE_EOSD_TEX_SIZE
, LARGE_EOSD_TEX_SIZE
, 0);
332 for (i
= img
; i
; i
= i
->next
)
334 if (i
->w
<= 0 || i
->h
<= 0 || i
->stride
< i
->w
)
336 if (is_tinytex(i
, tinytexcur
))
338 else if (is_smalltex(i
, smalltexcur
))
343 mp_msg(MSGT_VO
, MSGL_DBG2
, "EOSD counts (tiny, small, all): %i, %i, %i\n",
344 tinytexcur
, smalltexcur
, eosdtexCnt
);
346 eosdtex
= calloc(eosdtexCnt
, sizeof(GLuint
));
347 glGenTextures(eosdtexCnt
, eosdtex
);
349 tinytexcur
= smalltexcur
= 0;
350 for (i
= img
, curtex
= eosdtex
; i
; i
= i
->next
) {
352 if (i
->w
<= 0 || i
->h
<= 0 || i
->stride
< i
->w
) {
353 mp_msg(MSGT_VO
, MSGL_V
, "Invalid dimensions OSD for part!\n");
356 if (is_tinytex(i
, tinytexcur
)) {
357 tinytex_pos(tinytexcur
, &x
, &y
);
358 BindTexture(gl_target
, largeeosdtex
[0]);
360 } else if (is_smalltex(i
, smalltexcur
)) {
361 smalltex_pos(smalltexcur
, &x
, &y
);
362 BindTexture(gl_target
, largeeosdtex
[1]);
365 texSize(i
->w
, i
->h
, &sx
, &sy
);
366 BindTexture(gl_target
, *curtex
++);
367 glCreateClearTex(gl_target
, GL_ALPHA
, GL_ALPHA
, GL_UNSIGNED_BYTE
, scale_type
, sx
, sy
, 0);
369 glUploadTex(gl_target
, GL_ALPHA
, GL_UNSIGNED_BYTE
, i
->bitmap
, i
->stride
,
370 x
, y
, i
->w
, i
->h
, 0);
372 eosdDispList
= GenLists(1);
374 NewList(eosdDispList
, GL_COMPILE
);
375 tinytexcur
= smalltexcur
= 0;
376 for (i
= img
, curtex
= eosdtex
; i
; i
= i
->next
) {
378 if (i
->w
<= 0 || i
->h
<= 0 || i
->stride
< i
->w
)
380 Color4ub(i
->color
>> 24, (i
->color
>> 16) & 0xff, (i
->color
>> 8) & 0xff, 255 - (i
->color
& 0xff));
381 if (is_tinytex(i
, tinytexcur
)) {
382 tinytex_pos(tinytexcur
, &x
, &y
);
383 sx
= sy
= LARGE_EOSD_TEX_SIZE
;
384 BindTexture(gl_target
, largeeosdtex
[0]);
386 } else if (is_smalltex(i
, smalltexcur
)) {
387 smalltex_pos(smalltexcur
, &x
, &y
);
388 sx
= sy
= LARGE_EOSD_TEX_SIZE
;
389 BindTexture(gl_target
, largeeosdtex
[1]);
392 texSize(i
->w
, i
->h
, &sx
, &sy
);
393 BindTexture(gl_target
, *curtex
++);
395 glDrawTex(i
->dst_x
, i
->dst_y
, i
->w
, i
->h
, x
, y
, i
->w
, i
->h
, sx
, sy
, use_rectangle
== 1, 0, 0);
398 BindTexture(gl_target
, 0);
402 * \brief uninitialize OpenGL context, freeing textures, buffers etc.
404 static void uninitGl(void) {
406 if (DeletePrograms
&& fragprog
)
407 DeletePrograms(1, &fragprog
);
409 while (default_texs
[i
] != 0)
412 DeleteTextures(i
, default_texs
);
417 DeleteTextures(2, largeeosdtex
);
419 if (DeleteBuffers
&& gl_buffer
)
420 DeleteBuffers(1, &gl_buffer
);
421 gl_buffer
= 0; gl_buffersize
= 0;
423 if (DeleteBuffers
&& gl_buffer_uv
[0])
424 DeleteBuffers(2, gl_buffer_uv
);
425 gl_buffer_uv
[0] = gl_buffer_uv
[1] = 0; gl_buffersize_uv
= 0;
426 gl_bufferptr_uv
[0] = gl_bufferptr_uv
[1] = 0;
429 FreeMemoryMESA(mDisplay
, mScreen
, mesa_bufferptr
);
431 mesa_bufferptr
= NULL
;
435 static void autodetectGlExtensions(void) {
436 const char *extensions
= GetString(GL_EXTENSIONS
);
437 const char *vendor
= GetString(GL_VENDOR
);
438 const char *version
= GetString(GL_VERSION
);
439 int is_ati
= strstr(vendor
, "ATI") != NULL
;
440 int ati_broken_pbo
= 0;
441 if (is_ati
&& strncmp(version
, "2.1.", 4) == 0) {
442 int ver
= atoi(version
+ 4);
443 mp_msg(MSGT_VO
, MSGL_V
, "[gl] Detected ATI driver version: %i\n", ver
);
444 ati_broken_pbo
= ver
&& ver
< 8395;
446 if (ati_hack
== -1) ati_hack
= ati_broken_pbo
;
447 if (force_pbo
== -1) force_pbo
= strstr(extensions
, "_pixel_buffer_object") ? is_ati
: 0;
448 if (use_rectangle
== -1) use_rectangle
= strstr(extensions
, "_texture_non_power_of_two") ? 0 : 0;
449 if (is_ati
&& (lscale
== 1 || lscale
== 2 || cscale
== 1 || cscale
== 2))
450 mp_msg(MSGT_VO
, MSGL_WARN
, "[gl] Selected scaling mode may be broken on ATI cards.\n"
451 "Tell _them_ to fix GL_REPEAT if you have issues.\n");
452 mp_msg(MSGT_VO
, MSGL_V
, "[gl] Settings after autodetection: ati-hack = %i, force-pbo = %i, rectangle = %i\n",
453 ati_hack
, force_pbo
, use_rectangle
);
457 * \brief Initialize a (new or reused) OpenGL context.
458 * set global gl-related variables to their default values
460 static int initGl(uint32_t d_width
, uint32_t d_height
) {
461 autodetectGlExtensions();
462 texSize(image_width
, image_height
, &texture_width
, &texture_height
);
465 Disable(GL_DEPTH_TEST
);
467 Disable(GL_CULL_FACE
);
469 DrawBuffer(vo_doublebuffering
?GL_BACK
:GL_FRONT
);
470 TexEnvi(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, GL_MODULATE
);
472 mp_msg(MSGT_VO
, MSGL_V
, "[gl] Creating %dx%d texture...\n",
473 texture_width
, texture_height
);
475 if (image_format
== IMGFMT_YV12
) {
477 GenTextures(21, default_texs
);
478 default_texs
[21] = 0;
479 for (i
= 0; i
< 7; i
++) {
480 ActiveTexture(GL_TEXTURE1
+ i
);
481 BindTexture(GL_TEXTURE_2D
, default_texs
[i
]);
482 BindTexture(GL_TEXTURE_RECTANGLE
, default_texs
[i
+ 7]);
483 BindTexture(GL_TEXTURE_3D
, default_texs
[i
+ 14]);
485 ActiveTexture(GL_TEXTURE1
);
486 glCreateClearTex(gl_target
, gl_texfmt
, gl_format
, gl_type
, GL_LINEAR
,
487 texture_width
/ 2, texture_height
/ 2, 128);
488 ActiveTexture(GL_TEXTURE2
);
489 glCreateClearTex(gl_target
, gl_texfmt
, gl_format
, gl_type
, GL_LINEAR
,
490 texture_width
/ 2, texture_height
/ 2, 128);
492 case YUV_CONVERSION_FRAGMENT_LOOKUP
:
493 case YUV_CONVERSION_FRAGMENT_POW
:
494 case YUV_CONVERSION_FRAGMENT
:
495 if (!GenPrograms
|| !BindProgram
) {
496 mp_msg(MSGT_VO
, MSGL_ERR
, "[gl] fragment program functions missing!\n");
499 GenPrograms(1, &fragprog
);
500 BindProgram(GL_FRAGMENT_PROGRAM
, fragprog
);
503 ActiveTexture(GL_TEXTURE0
);
504 BindTexture(gl_target
, 0);
507 glCreateClearTex(gl_target
, gl_texfmt
, gl_format
, gl_type
, GL_LINEAR
,
508 texture_width
, texture_height
, 0);
510 resize(d_width
, d_height
);
512 ClearColor( 0.0f
,0.0f
,0.0f
,0.0f
);
513 Clear( GL_COLOR_BUFFER_BIT
);
514 if (SwapInterval
&& swap_interval
>= 0)
515 SwapInterval(swap_interval
);
519 /* connect to server, create and map window,
520 * allocate colors and (shared) memory
523 config(uint32_t width
, uint32_t height
, uint32_t d_width
, uint32_t d_height
, uint32_t flags
, char *title
, uint32_t format
)
525 image_height
= height
;
527 image_format
= format
;
528 glFindFormat(format
, NULL
, &gl_texfmt
, &gl_format
, &gl_type
);
530 vo_flipped
= !!(flags
& VOFLAG_FLIPPING
);
533 if (glctx
.type
== GLTYPE_W32
&& !vo_w32_config(d_width
, d_height
, flags
))
537 if (glctx
.type
== GLTYPE_X11
) {
538 XVisualInfo
*vinfo
=glXChooseVisual( mDisplay
,mScreen
,wsGLXAttrib
);
541 mp_msg(MSGT_VO
, MSGL_ERR
, "[gl] no GLX support present\n");
544 mp_msg(MSGT_VO
, MSGL_V
, "[gl] GLX chose visual with ID 0x%x\n", (int)vinfo
->visualid
);
546 vo_x11_create_vo_window(vinfo
, vo_dx
, vo_dy
, d_width
, d_height
, flags
,
547 XCreateColormap(mDisplay
, mRootWin
, vinfo
->visual
, AllocNone
),
555 if (glctx
.setGlWindow(&glctx
) == SET_WINDOW_FAILED
)
557 if (mesa_buffer
&& !AllocateMemoryMESA
) {
558 mp_msg(MSGT_VO
, MSGL_ERR
, "Can not enable mesa-buffer because AllocateMemoryMESA was not found\n");
561 initGl(vo_dwidth
, vo_dheight
);
566 static void check_events(void)
568 int e
=glctx
.check_events();
569 if(e
&VO_EVENT_RESIZE
) resize(vo_dwidth
,vo_dheight
);
570 if(e
&VO_EVENT_EXPOSE
&& int_pause
) redraw();
574 * Creates the textures and the display list needed for displaying
576 * Callback function for vo_draw_text().
578 static void create_osd_texture(int x0
, int y0
, int w
, int h
,
579 unsigned char *src
, unsigned char *srca
,
582 // initialize to 8 to avoid special-casing on alignment
584 GLint scale_type
= scaled_osd
? GL_LINEAR
: GL_NEAREST
;
586 if (w
<= 0 || h
<= 0 || stride
< w
) {
587 mp_msg(MSGT_VO
, MSGL_V
, "Invalid dimensions OSD for part!\n");
590 texSize(w
, h
, &sx
, &sy
);
592 if (osdtexCnt
>= MAX_OSD_PARTS
) {
593 mp_msg(MSGT_VO
, MSGL_ERR
, "Too many OSD parts, contact the developers!\n");
597 // create Textures for OSD part
598 GenTextures(1, &osdtex
[osdtexCnt
]);
599 BindTexture(gl_target
, osdtex
[osdtexCnt
]);
600 glCreateClearTex(gl_target
, GL_LUMINANCE
, GL_LUMINANCE
, GL_UNSIGNED_BYTE
, scale_type
, sx
, sy
, 0);
601 glUploadTex(gl_target
, GL_LUMINANCE
, GL_UNSIGNED_BYTE
, src
, stride
,
605 GenTextures(1, &osdatex
[osdtexCnt
]);
606 BindTexture(gl_target
, osdatex
[osdtexCnt
]);
607 glCreateClearTex(gl_target
, GL_ALPHA
, GL_ALPHA
, GL_UNSIGNED_BYTE
, scale_type
, sx
, sy
, 0);
610 char *tmp
= malloc(stride
* h
);
611 // convert alpha from weird MPlayer scale.
612 // in-place is not possible since it is reused for future OSDs
613 for (i
= h
* stride
- 1; i
>= 0; i
--)
615 glUploadTex(gl_target
, GL_ALPHA
, GL_UNSIGNED_BYTE
, tmp
, stride
,
621 BindTexture(gl_target
, 0);
623 // Create a list for rendering this OSD part
625 osdaDispList
[osdtexCnt
] = GenLists(1);
626 NewList(osdaDispList
[osdtexCnt
], GL_COMPILE
);
628 BindTexture(gl_target
, osdatex
[osdtexCnt
]);
629 glDrawTex(x0
, y0
, w
, h
, 0, 0, w
, h
, sx
, sy
, use_rectangle
== 1, 0, 0);
632 osdDispList
[osdtexCnt
] = GenLists(1);
633 NewList(osdDispList
[osdtexCnt
], GL_COMPILE
);
635 BindTexture(gl_target
, osdtex
[osdtexCnt
]);
636 glDrawTex(x0
, y0
, w
, h
, 0, 0, w
, h
, sx
, sy
, use_rectangle
== 1, 0, 0);
642 static void draw_osd(void)
644 if (!use_osd
) return;
645 if (vo_osd_changed(0)) {
648 osd_w
= scaled_osd
? image_width
: vo_dwidth
;
649 osd_h
= scaled_osd
? image_height
: vo_dheight
;
650 vo_draw_text_ext(osd_w
, osd_h
, ass_border_x
, ass_border_y
, ass_border_x
, ass_border_y
,
651 image_width
, image_height
, create_osd_texture
);
653 if (vo_doublebuffering
) do_render_osd(1);
656 static void do_render(void) {
657 // Enable(GL_TEXTURE_2D);
658 // BindTexture(GL_TEXTURE_2D, texture_id);
661 if (image_format
== IMGFMT_YV12
)
662 glEnableYUVConversion(gl_target
, yuvconvtype
);
663 glDrawTex(0, 0, image_width
, image_height
,
664 0, 0, image_width
, image_height
,
665 texture_width
, texture_height
,
666 use_rectangle
== 1, image_format
== IMGFMT_YV12
,
667 mpi_flipped
^ vo_flipped
);
668 if (image_format
== IMGFMT_YV12
)
669 glDisableYUVConversion(gl_target
, yuvconvtype
);
673 * \param type bit 0: render OSD, bit 1: render EOSD
675 static void do_render_osd(int type
) {
676 if (((type
& 1) && osdtexCnt
> 0) || ((type
& 2) && eosdDispList
)) {
677 // set special rendering parameters
679 MatrixMode(GL_PROJECTION
);
682 Ortho(0, vo_dwidth
, vo_dheight
, 0, -1, 1);
685 if ((type
& 2) && eosdDispList
) {
686 BlendFunc(GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
687 CallList(eosdDispList
);
689 if ((type
& 1) && osdtexCnt
> 0) {
690 Color4ub((osd_color
>> 16) & 0xff, (osd_color
>> 8) & 0xff, osd_color
& 0xff, 0xff - (osd_color
>> 24));
693 BlendFunc(GL_ZERO
, GL_ONE_MINUS_SRC_ALPHA
);
694 CallLists(osdtexCnt
, GL_UNSIGNED_INT
, osdaDispList
);
696 BlendFunc(GL_SRC_ALPHA
, GL_ONE
);
697 CallLists(osdtexCnt
, GL_UNSIGNED_INT
, osdDispList
);
699 // set rendering parameters back to defaults
703 BindTexture(gl_target
, 0);
707 static void flip_page(void) {
708 if (vo_doublebuffering
) {
709 if (use_glFinish
) Finish();
710 glctx
.swapGlBuffers(&glctx
);
711 if (aspect_scaling() && use_aspect
)
712 Clear(GL_COLOR_BUFFER_BIT
);
716 if (use_glFinish
) Finish();
721 static void redraw(void) {
722 if (vo_doublebuffering
) { do_render(); do_render_osd(3); }
726 //static inline uint32_t draw_slice_x11(uint8_t *src[], uint32_t slice_num)
727 static int draw_slice(uint8_t *src
[], int stride
[], int w
,int h
,int x
,int y
)
729 mpi_flipped
= stride
[0] < 0;
730 glUploadTex(gl_target
, gl_format
, gl_type
, src
[0], stride
[0],
731 x
, y
, w
, h
, slice_height
);
732 if (image_format
== IMGFMT_YV12
) {
733 ActiveTexture(GL_TEXTURE1
);
734 glUploadTex(gl_target
, gl_format
, gl_type
, src
[1], stride
[1],
735 x
/ 2, y
/ 2, w
/ 2, h
/ 2, slice_height
);
736 ActiveTexture(GL_TEXTURE2
);
737 glUploadTex(gl_target
, gl_format
, gl_type
, src
[2], stride
[2],
738 x
/ 2, y
/ 2, w
/ 2, h
/ 2, slice_height
);
739 ActiveTexture(GL_TEXTURE0
);
744 static uint32_t get_image(mp_image_t
*mpi
) {
746 if (!GenBuffers
|| !BindBuffer
|| !BufferData
|| !MapBuffer
) {
748 mp_msg(MSGT_VO
, MSGL_ERR
, "[gl] extensions missing for dr\n"
749 "Expect a _major_ speed penalty\n");
753 if (mpi
->flags
& MP_IMGFLAG_READABLE
) return VO_FALSE
;
754 if (mpi
->type
!= MP_IMGTYPE_STATIC
&& mpi
->type
!= MP_IMGTYPE_TEMP
&&
755 (mpi
->type
!= MP_IMGTYPE_NUMBERED
|| mpi
->number
))
757 if (mesa_buffer
) mpi
->width
= texture_width
;
759 mpi
->width
= texture_width
;
760 mpi
->height
= texture_height
;
762 mpi
->stride
[0] = mpi
->width
* mpi
->bpp
/ 8;
763 needed_size
= mpi
->stride
[0] * mpi
->height
;
766 if (mesa_bufferptr
&& needed_size
> mesa_buffersize
) {
767 FreeMemoryMESA(mDisplay
, mScreen
, mesa_bufferptr
);
768 mesa_bufferptr
= NULL
;
771 mesa_bufferptr
= AllocateMemoryMESA(mDisplay
, mScreen
, needed_size
, 0, 1.0, 1.0);
772 mesa_buffersize
= needed_size
;
774 mpi
->planes
[0] = mesa_bufferptr
;
777 GenBuffers(1, &gl_buffer
);
778 BindBuffer(GL_PIXEL_UNPACK_BUFFER
, gl_buffer
);
779 if (needed_size
> gl_buffersize
) {
780 gl_buffersize
= needed_size
;
781 BufferData(GL_PIXEL_UNPACK_BUFFER
, gl_buffersize
,
782 NULL
, GL_DYNAMIC_DRAW
);
785 gl_bufferptr
= MapBuffer(GL_PIXEL_UNPACK_BUFFER
, GL_WRITE_ONLY
);
786 mpi
->planes
[0] = gl_bufferptr
;
787 BindBuffer(GL_PIXEL_UNPACK_BUFFER
, 0);
789 if (!mpi
->planes
[0]) {
791 mp_msg(MSGT_VO
, MSGL_ERR
, "[gl] could not acquire buffer for dr\n"
792 "Expect a _major_ speed penalty\n");
796 if (mpi
->imgfmt
== IMGFMT_YV12
) {
798 mpi
->flags
|= MP_IMGFLAG_COMMON_STRIDE
| MP_IMGFLAG_COMMON_PLANE
;
799 mpi
->stride
[0] = mpi
->width
;
800 mpi
->planes
[1] = mpi
->planes
[0] + mpi
->stride
[0] * mpi
->height
;
801 mpi
->stride
[1] = mpi
->width
>> 1;
802 mpi
->planes
[2] = mpi
->planes
[1] + mpi
->stride
[1] * (mpi
->height
>> 1);
803 mpi
->stride
[2] = mpi
->width
>> 1;
804 if (ati_hack
&& !mesa_buffer
) {
805 mpi
->flags
&= ~MP_IMGFLAG_COMMON_PLANE
;
806 if (!gl_buffer_uv
[0]) GenBuffers(2, gl_buffer_uv
);
807 if (mpi
->stride
[1] * mpi
->height
> gl_buffersize_uv
) {
808 BindBuffer(GL_PIXEL_UNPACK_BUFFER
, gl_buffer_uv
[0]);
809 BufferData(GL_PIXEL_UNPACK_BUFFER
, mpi
->stride
[1] * mpi
->height
,
810 NULL
, GL_DYNAMIC_DRAW
);
811 BindBuffer(GL_PIXEL_UNPACK_BUFFER
, gl_buffer_uv
[1]);
812 BufferData(GL_PIXEL_UNPACK_BUFFER
, mpi
->stride
[1] * mpi
->height
,
813 NULL
, GL_DYNAMIC_DRAW
);
814 gl_buffersize_uv
= mpi
->stride
[1] * mpi
->height
;
816 if (!gl_bufferptr_uv
[0]) {
817 BindBuffer(GL_PIXEL_UNPACK_BUFFER
, gl_buffer_uv
[0]);
818 gl_bufferptr_uv
[0] = MapBuffer(GL_PIXEL_UNPACK_BUFFER
, GL_WRITE_ONLY
);
819 BindBuffer(GL_PIXEL_UNPACK_BUFFER
, gl_buffer_uv
[1]);
820 gl_bufferptr_uv
[1] = MapBuffer(GL_PIXEL_UNPACK_BUFFER
, GL_WRITE_ONLY
);
822 mpi
->planes
[1] = gl_bufferptr_uv
[0];
823 mpi
->planes
[2] = gl_bufferptr_uv
[1];
826 mpi
->flags
|= MP_IMGFLAG_DIRECT
;
830 static void clear_border(uint8_t *dst
, int start
, int stride
, int height
, int full_height
, int value
) {
831 int right_border
= stride
- start
;
832 int bottom_border
= full_height
- height
;
834 memset(dst
+ start
, value
, right_border
);
838 if (bottom_border
> 0)
839 memset(dst
, value
, stride
* bottom_border
);
842 static uint32_t draw_image(mp_image_t
*mpi
) {
843 int slice
= slice_height
;
845 unsigned char *planes
[3];
846 mp_image_t mpi2
= *mpi
;
847 int w
= mpi
->w
, h
= mpi
->h
;
848 if (mpi
->flags
& MP_IMGFLAG_DRAW_CALLBACK
)
850 mpi2
.flags
= 0; mpi2
.type
= MP_IMGTYPE_TEMP
;
851 mpi2
.width
= mpi2
.w
; mpi2
.height
= mpi2
.h
;
852 if (force_pbo
&& !(mpi
->flags
& MP_IMGFLAG_DIRECT
) && !gl_bufferptr
&& get_image(&mpi2
) == VO_TRUE
) {
853 int bpp
= mpi
->imgfmt
== IMGFMT_YV12
? 8 : mpi
->bpp
;
854 memcpy_pic(mpi2
.planes
[0], mpi
->planes
[0], mpi
->w
* bpp
/ 8, mpi
->h
, mpi2
.stride
[0], mpi
->stride
[0]);
855 if (mpi
->imgfmt
== IMGFMT_YV12
) {
856 memcpy_pic(mpi2
.planes
[1], mpi
->planes
[1], mpi
->w
>> 1, mpi
->h
>> 1, mpi2
.stride
[1], mpi
->stride
[1]);
857 memcpy_pic(mpi2
.planes
[2], mpi
->planes
[2], mpi
->w
>> 1, mpi
->h
>> 1, mpi2
.stride
[2], mpi
->stride
[2]);
859 if (ati_hack
) { // since we have to do a full upload we need to clear the borders
860 clear_border(mpi2
.planes
[0], mpi
->w
* bpp
/ 8, mpi2
.stride
[0], mpi
->h
, mpi2
.height
, 0);
861 if (mpi
->imgfmt
== IMGFMT_YV12
) {
862 clear_border(mpi2
.planes
[1], mpi
->w
>> 1, mpi2
.stride
[1], mpi
->h
>> 1, mpi2
.height
>> 1, 128);
863 clear_border(mpi2
.planes
[2], mpi
->w
>> 1, mpi2
.stride
[2], mpi
->h
>> 1, mpi2
.height
>> 1, 128);
868 stride
[0] = mpi
->stride
[0]; stride
[1] = mpi
->stride
[1]; stride
[2] = mpi
->stride
[2];
869 planes
[0] = mpi
->planes
[0]; planes
[1] = mpi
->planes
[1]; planes
[2] = mpi
->planes
[2];
870 mpi_flipped
= stride
[0] < 0;
871 if (mpi
->flags
& MP_IMGFLAG_DIRECT
) {
873 PixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE
, 1);
876 intptr_t base
= (intptr_t)planes
[0];
877 if (ati_hack
) { w
= texture_width
; h
= texture_height
; }
879 base
+= (mpi
->h
- 1) * stride
[0];
883 BindBuffer(GL_PIXEL_UNPACK_BUFFER
, gl_buffer
);
884 UnmapBuffer(GL_PIXEL_UNPACK_BUFFER
);
886 if (!(mpi
->flags
& MP_IMGFLAG_COMMON_PLANE
))
887 planes
[0] = planes
[1] = planes
[2] = NULL
;
889 slice
= 0; // always "upload" full texture
891 glUploadTex(gl_target
, gl_format
, gl_type
, planes
[0], stride
[0],
892 mpi
->x
, mpi
->y
, w
, h
, slice
);
893 if (mpi
->imgfmt
== IMGFMT_YV12
) {
894 if ((mpi
->flags
& MP_IMGFLAG_DIRECT
) && !(mpi
->flags
& MP_IMGFLAG_COMMON_PLANE
)) {
895 BindBuffer(GL_PIXEL_UNPACK_BUFFER
, gl_buffer_uv
[0]);
896 UnmapBuffer(GL_PIXEL_UNPACK_BUFFER
);
897 gl_bufferptr_uv
[0] = NULL
;
899 ActiveTexture(GL_TEXTURE1
);
900 glUploadTex(gl_target
, gl_format
, gl_type
, planes
[1], stride
[1],
901 mpi
->x
/ 2, mpi
->y
/ 2, w
/ 2, h
/ 2, slice
);
902 if ((mpi
->flags
& MP_IMGFLAG_DIRECT
) && !(mpi
->flags
& MP_IMGFLAG_COMMON_PLANE
)) {
903 BindBuffer(GL_PIXEL_UNPACK_BUFFER
, gl_buffer_uv
[1]);
904 UnmapBuffer(GL_PIXEL_UNPACK_BUFFER
);
905 gl_bufferptr_uv
[1] = NULL
;
907 ActiveTexture(GL_TEXTURE2
);
908 glUploadTex(gl_target
, gl_format
, gl_type
, planes
[2], stride
[2],
909 mpi
->x
/ 2, mpi
->y
/ 2, w
/ 2, h
/ 2, slice
);
910 ActiveTexture(GL_TEXTURE0
);
912 if (mpi
->flags
& MP_IMGFLAG_DIRECT
) {
913 if (mesa_buffer
) PixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE
, 0);
914 else BindBuffer(GL_PIXEL_UNPACK_BUFFER
, 0);
917 if (vo_doublebuffering
) do_render();
922 draw_frame(uint8_t *src
[])
928 query_format(uint32_t format
)
930 int caps
= VFCAP_CSP_SUPPORTED
| VFCAP_CSP_SUPPORTED_BY_HW
|
932 VFCAP_HWSCALE_UP
| VFCAP_HWSCALE_DOWN
| VFCAP_ACCEPT_STRIDE
;
934 caps
|= VFCAP_OSD
| VFCAP_EOSD
| (scaled_osd
? 0 : VFCAP_EOSD_UNSCALED
);
935 if (format
== IMGFMT_RGB24
|| format
== IMGFMT_RGBA
)
937 if (use_yuv
&& format
== IMGFMT_YV12
)
939 // HACK, otherwise we get only b&w with some filters (e.g. -vf eq)
940 // ideally MPlayer should be fixed instead not to use Y800 when it has the choice
941 if (!use_yuv
&& (format
== IMGFMT_Y8
|| format
== IMGFMT_Y800
))
943 if (!use_ycbcr
&& (format
== IMGFMT_UYVY
|| format
== IMGFMT_YUY2
))
946 glFindFormat(format
, NULL
, NULL
, NULL
, NULL
))
955 if (!vo_config_count
) return;
957 if (custom_prog
) free(custom_prog
);
959 if (custom_tex
) free(custom_tex
);
961 uninit_mpglcontext(&glctx
);
964 static const opt_t subopts
[] = {
965 {"manyfmts", OPT_ARG_BOOL
, &many_fmts
, NULL
},
966 {"osd", OPT_ARG_BOOL
, &use_osd
, NULL
},
967 {"scaled-osd", OPT_ARG_BOOL
, &scaled_osd
, NULL
},
968 {"aspect", OPT_ARG_BOOL
, &use_aspect
, NULL
},
969 {"ycbcr", OPT_ARG_BOOL
, &use_ycbcr
, NULL
},
970 {"slice-height", OPT_ARG_INT
, &slice_height
, (opt_test_f
)int_non_neg
},
971 {"rectangle", OPT_ARG_INT
, &use_rectangle
,(opt_test_f
)int_non_neg
},
972 {"yuv", OPT_ARG_INT
, &use_yuv
, (opt_test_f
)int_non_neg
},
973 {"lscale", OPT_ARG_INT
, &lscale
, (opt_test_f
)int_non_neg
},
974 {"cscale", OPT_ARG_INT
, &cscale
, (opt_test_f
)int_non_neg
},
975 {"filter-strength", OPT_ARG_FLOAT
, &filter_strength
, NULL
},
976 {"ati-hack", OPT_ARG_BOOL
, &ati_hack
, NULL
},
977 {"force-pbo", OPT_ARG_BOOL
, &force_pbo
, NULL
},
978 {"mesa-buffer", OPT_ARG_BOOL
, &mesa_buffer
, NULL
},
979 {"glfinish", OPT_ARG_BOOL
, &use_glFinish
, NULL
},
980 {"swapinterval", OPT_ARG_INT
, &swap_interval
,NULL
},
981 {"customprog", OPT_ARG_MSTRZ
,&custom_prog
, NULL
},
982 {"customtex", OPT_ARG_MSTRZ
,&custom_tex
, NULL
},
983 {"customtlin", OPT_ARG_BOOL
, &custom_tlin
, NULL
},
984 {"customtrect", OPT_ARG_BOOL
, &custom_trect
, NULL
},
985 {"osdcolor", OPT_ARG_INT
, &osd_color
, NULL
},
989 static int preinit(const char *arg
)
991 enum MPGLType gltype
= GLTYPE_X11
;
1004 filter_strength
= 0.5;
1016 osd_color
= 0xffffff;
1017 if (subopt_parse(arg
, subopts
) != 0) {
1018 mp_msg(MSGT_VO
, MSGL_FATAL
,
1019 "\n-vo gl command line help:\n"
1020 "Example: mplayer -vo gl:slice-height=4\n"
1023 " Disable extended color formats for OpenGL 1.2 and later\n"
1024 " slice-height=<0-...>\n"
1025 " Slice size for texture transfer, 0 for whole image\n"
1027 " Do not use OpenGL OSD code\n"
1029 " Render OSD at movie resolution and scale it\n"
1031 " Do not do aspect scaling\n"
1032 " rectangle=<0,1,2>\n"
1033 " 0: use power-of-two textures\n"
1034 " 1: use texture_rectangle\n"
1035 " 2: use texture_non_power_of_two\n"
1037 " Workaround ATI bug with PBOs\n"
1039 " Force use of PBO even if this involves an extra memcpy\n"
1041 " Call glFinish() before swapping buffers\n"
1042 " swapinterval=<n>\n"
1043 " Interval in displayed frames between to buffer swaps.\n"
1044 " 1 is equivalent to enable VSYNC, 0 to disable VSYNC.\n"
1045 " Requires GLX_SGI_swap_control support to work.\n"
1047 " 0: use software YUV to RGB conversion.\n"
1048 " 1: use register combiners (nVidia only, for older cards).\n"
1049 " 2: use fragment program.\n"
1050 " 3: use fragment program with gamma correction.\n"
1051 " 4: use fragment program with gamma correction via lookup.\n"
1052 " 5: use ATI-specific method (for older cards).\n"
1053 " 6: use lookup via 3D texture.\n"
1055 " 0: use standard bilinear scaling for luma.\n"
1056 " 1: use improved bicubic scaling for luma.\n"
1057 " 2: use cubic in X, linear in Y direction scaling for luma.\n"
1058 " 3: as 1 but without using a lookup texture.\n"
1059 " 4: experimental unsharp masking (sharpening).\n"
1060 " 5: experimental unsharp masking (sharpening) with larger radius.\n"
1062 " as lscale but for chroma (2x slower with little visible effect).\n"
1063 " filter-strength=<value>\n"
1064 " set the effect strength for some lscale/cscale filters\n"
1065 " customprog=<filename>\n"
1066 " use a custom YUV conversion program\n"
1067 " customtex=<filename>\n"
1068 " use a custom YUV conversion lookup texture\n"
1070 " use GL_NEAREST scaling for customtex texture\n"
1072 " use texture_rectangle for customtex texture\n"
1073 " osdcolor=<0xAARRGGBB>\n"
1074 " use the given color for the OSD\n"
1076 " also try to use the GL_MESA_ycbcr_texture extension\n"
1080 if (use_rectangle
== 1)
1081 gl_target
= GL_TEXTURE_RECTANGLE
;
1083 gl_target
= GL_TEXTURE_2D
;
1084 yuvconvtype
= use_yuv
| lscale
<< YUV_LUM_SCALER_SHIFT
| cscale
<< YUV_CHROM_SCALER_SHIFT
;
1086 mp_msg(MSGT_VO
, MSGL_INFO
, "[gl] using extended formats. "
1087 "Use -vo gl:nomanyfmts if playback fails.\n");
1088 mp_msg(MSGT_VO
, MSGL_V
, "[gl] Using %d as slice height "
1089 "(0 means image height).\n", slice_height
);
1090 if (!init_mpglcontext(&glctx
, gltype
)) return -1;
1095 #define MASK_ALL_YUV (~(1 << YUV_CONVERSION_NONE))
1096 #define MASK_NOT_COMBINERS (~((1 << YUV_CONVERSION_NONE) | (1 << YUV_CONVERSION_COMBINERS) | (1 << YUV_CONVERSION_COMBINERS_ATI)))
1097 #define MASK_GAMMA_SUPPORT (MASK_NOT_COMBINERS & ~(1 << YUV_CONVERSION_FRAGMENT))
1099 static const struct {
1104 {"brightness", &eq_bri
, MASK_NOT_COMBINERS
},
1105 {"contrast", &eq_cont
, MASK_NOT_COMBINERS
},
1106 {"saturation", &eq_sat
, MASK_ALL_YUV
},
1107 {"hue", &eq_hue
, MASK_ALL_YUV
},
1108 {"gamma", &eq_rgamma
, MASK_GAMMA_SUPPORT
},
1109 {"red_gamma", &eq_rgamma
, MASK_GAMMA_SUPPORT
},
1110 {"green_gamma", &eq_ggamma
, MASK_GAMMA_SUPPORT
},
1111 {"blue_gamma", &eq_bgamma
, MASK_GAMMA_SUPPORT
},
1115 static int control(uint32_t request
, void *data
)
1120 int_pause
= (request
== VOCTRL_PAUSE
);
1122 case VOCTRL_QUERY_FORMAT
:
1123 return query_format(*(uint32_t*)data
);
1124 case VOCTRL_GET_IMAGE
:
1125 return get_image(data
);
1126 case VOCTRL_DRAW_IMAGE
:
1127 return draw_image(data
);
1128 case VOCTRL_DRAW_EOSD
:
1132 if (vo_doublebuffering
) do_render_osd(2);
1134 case VOCTRL_GET_EOSD_RES
:
1136 mp_eosd_res_t
*r
= data
;
1137 r
->w
= vo_dwidth
; r
->h
= vo_dheight
;
1138 r
->mt
= r
->mb
= r
->ml
= r
->mr
= 0;
1139 if (scaled_osd
) {r
->w
= image_width
; r
->h
= image_height
;}
1140 else if (aspect_scaling()) {
1141 r
->ml
= r
->mr
= ass_border_x
;
1142 r
->mt
= r
->mb
= ass_border_y
;
1149 case VOCTRL_FULLSCREEN
:
1151 resize(vo_dwidth
, vo_dheight
);
1155 resize(vo_dwidth
, vo_dheight
);
1157 case VOCTRL_GET_PANSCAN
:
1158 if (!use_aspect
) return VO_NOTIMPL
;
1160 case VOCTRL_SET_PANSCAN
:
1161 if (!use_aspect
) return VO_NOTIMPL
;
1162 resize(vo_dwidth
, vo_dheight
);
1164 case VOCTRL_GET_EQUALIZER
:
1165 if (image_format
== IMGFMT_YV12
) {
1166 struct voctrl_get_equalizer_args
*args
= data
;
1168 for (i
= 0; eq_map
[i
].name
; i
++)
1169 if (strcmp(args
->name
, eq_map
[i
].name
) == 0) break;
1170 if (!(eq_map
[i
].supportmask
& (1 << use_yuv
)))
1172 *args
->valueptr
= *eq_map
[i
].value
;
1176 case VOCTRL_SET_EQUALIZER
:
1177 if (image_format
== IMGFMT_YV12
) {
1178 struct voctrl_set_equalizer_args
*args
= data
;
1180 for (i
= 0; eq_map
[i
].name
; i
++)
1181 if (strcmp(args
->name
, eq_map
[i
].name
) == 0) break;
1182 if (!(eq_map
[i
].supportmask
& (1 << use_yuv
)))
1184 *eq_map
[i
].value
= args
->value
;
1189 case VOCTRL_UPDATE_SCREENINFO
:
1190 glctx
.update_xinerama_info();
1192 case VOCTRL_REDRAW_OSD
:
1193 if (vo_doublebuffering
)
1196 if (vo_doublebuffering
)