2009-02-08 03:27:30 +00:00
|
|
|
/*
|
|
|
|
* This file is part of MPlayer.
|
|
|
|
*
|
|
|
|
* MPlayer is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* MPlayer is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with MPlayer; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2010-06-13 10:42:32 +00:00
|
|
|
*
|
|
|
|
* You can alternatively redistribute this file and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2009-02-08 03:27:30 +00:00
|
|
|
*/
|
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2005-09-14 22:08:04 +00:00
|
|
|
#include <math.h>
|
video, options: implement better YUV->RGB conversion control
Rewrite control of the colorspace and input/output level parameters
used in YUV-RGB conversions, replacing VO-specific suboptions with new
common options and adding configuration support to more cases.
Add new option --colormatrix which selects the colorspace the original
video is assumed to have in YUV->RGB conversions. The default
behavior changes from assuming BT.601 to colorspace autoselection
between BT.601 and BT.709 using a simple heuristic based on video
size. Add new options --colormatrix-input-range and
--colormatrix-output-range which select input YUV and output RGB range.
Disable the previously existing VO-specific colorspace and level
conversion suboptions in vo_gl and vo_vdpau. Remove the
"yuv_colorspace" property and replace it with one named "colormatrix"
and semantics matching the new option. Add new properties matching the
options for level conversion.
Colorspace selection is currently supported by vo_gl, vo_vdpau, vo_xv
and vf_scale, and all can change it at runtime (previously only
vo_vdpau and vo_xv could). vo_vdpau now uses the same conversion
matrix generation as vo_gl instead of libvdpau functionality; the main
functional difference is that the "contrast" equalizer control behaves
somewhat differently (it scales the Y component around 1/2 instead of
around 0, so that contrast 0 makes the image gray rather than black).
vo_xv does not support level conversion. vf_scale supports range
setting for input, but always outputs full-range RGB.
The value of the slave properties is the policy setting used for
conversions. This means they can be set to any value regardless of
whether the current VO supports that value or whether there currently
even is any video. Possibly separate properties could be added to
query the conversion actually used at the moment, if any.
Because the colorspace and level settings are now set with a single
VF/VO control call, the return value of that is no longer used to
signal whether all the settings are actually supported. Instead code
should set all the details it can support, and ignore the rest. The
core will use GET_YUV_COLORSPACE to check which colorspace details
have been set and which not. In other words, the return value for
SET_YUV_COLORSPACE only signals whether any kind of YUV colorspace
conversion handling exists at all, and VOs have to take care to return
the actual state with GET_YUV_COLORSPACE instead.
To be changed in later commits: add missing option documentation.
2011-10-15 21:50:21 +00:00
|
|
|
#include <stdbool.h>
|
VO, sub: refactor
Remove VFCTRL_DRAW_OSD, VFCAP_EOSD_FILTER, VFCAP_EOSD_RGBA, VFCAP_EOSD,
VOCTRL_DRAW_EOSD, VOCTRL_GET_EOSD_RES, VOCTRL_QUERY_EOSD_FORMAT.
Remove draw_osd_with_eosd(), which rendered the OSD by calling
VOCTRL_DRAW_EOSD. Change VOs to call osd_draw() directly, which takes
a callback as argument. (This basically works like the old OSD API,
except multiple OSD bitmap formats are supported and caching is
possible.)
Remove all mentions of "eosd". It's simply "osd" now.
Make OSD size per-OSD-object, as they can be different when using
vf_sub. Include display_par/video_par in resolution change detection.
Fix the issue with margin borders in vo_corevideo.
2012-10-19 17:25:18 +00:00
|
|
|
#include <assert.h>
|
2001-02-24 20:28:24 +00:00
|
|
|
|
|
|
|
#include "config.h"
|
2011-09-25 09:18:07 +00:00
|
|
|
#include "talloc.h"
|
2005-08-14 19:24:49 +00:00
|
|
|
#include "mp_msg.h"
|
2004-12-31 14:58:49 +00:00
|
|
|
#include "subopt-helper.h"
|
2001-02-24 20:28:24 +00:00
|
|
|
#include "video_out.h"
|
2011-09-25 09:18:07 +00:00
|
|
|
#include "libmpcodecs/vfcap.h"
|
|
|
|
#include "libmpcodecs/mp_image.h"
|
|
|
|
#include "geometry.h"
|
2011-01-26 17:40:52 +00:00
|
|
|
#include "sub/sub.h"
|
2001-02-24 20:28:24 +00:00
|
|
|
|
2004-10-17 13:28:22 +00:00
|
|
|
#include "gl_common.h"
|
2012-10-04 00:29:54 +00:00
|
|
|
#include "gl_osd.h"
|
2001-10-03 17:27:13 +00:00
|
|
|
#include "aspect.h"
|
2008-05-10 12:21:37 +00:00
|
|
|
#include "fastmemcpy.h"
|
2001-03-03 21:46:39 +00:00
|
|
|
|
2011-09-25 09:18:07 +00:00
|
|
|
//for gl_priv.use_yuv
|
2009-12-19 20:48:23 +00:00
|
|
|
#define MASK_ALL_YUV (~(1 << YUV_CONVERSION_NONE))
|
2010-05-09 21:25:38 +00:00
|
|
|
#define MASK_NOT_COMBINERS (~((1 << YUV_CONVERSION_NONE) | (1 << YUV_CONVERSION_COMBINERS)))
|
2009-12-19 20:48:23 +00:00
|
|
|
#define MASK_GAMMA_SUPPORT (MASK_NOT_COMBINERS & ~(1 << YUV_CONVERSION_FRAGMENT))
|
2011-09-25 09:18:07 +00:00
|
|
|
|
|
|
|
struct gl_priv {
|
|
|
|
MPGLContext *glctx;
|
|
|
|
GL *gl;
|
|
|
|
|
2012-10-02 23:54:13 +00:00
|
|
|
int allow_sw;
|
|
|
|
|
2011-09-25 09:18:07 +00:00
|
|
|
int use_osd;
|
|
|
|
int scaled_osd;
|
2012-10-04 00:29:54 +00:00
|
|
|
struct mpgl_osd *osd;
|
2011-09-25 09:18:07 +00:00
|
|
|
int osd_color;
|
|
|
|
|
|
|
|
int use_ycbcr;
|
|
|
|
int use_yuv;
|
|
|
|
struct mp_csp_details colorspace;
|
|
|
|
int is_yuv;
|
|
|
|
int lscale;
|
|
|
|
int cscale;
|
|
|
|
float filter_strength;
|
2011-08-26 18:51:51 +00:00
|
|
|
float noise_strength;
|
2011-09-25 09:18:07 +00:00
|
|
|
int yuvconvtype;
|
|
|
|
int use_rectangle;
|
|
|
|
int err_shown;
|
|
|
|
uint32_t image_width;
|
|
|
|
uint32_t image_height;
|
|
|
|
uint32_t image_format;
|
|
|
|
int many_fmts;
|
2011-11-08 19:21:00 +00:00
|
|
|
int have_texture_rg;
|
2011-09-25 09:18:07 +00:00
|
|
|
int ati_hack;
|
|
|
|
int force_pbo;
|
|
|
|
int use_glFinish;
|
|
|
|
int swap_interval;
|
|
|
|
GLenum target;
|
|
|
|
GLint texfmt;
|
|
|
|
GLenum gl_format;
|
|
|
|
GLenum gl_type;
|
|
|
|
GLuint buffer;
|
|
|
|
GLuint buffer_uv[2];
|
|
|
|
int buffersize;
|
|
|
|
int buffersize_uv;
|
|
|
|
void *bufferptr;
|
|
|
|
void *bufferptr_uv[2];
|
|
|
|
GLuint fragprog;
|
|
|
|
GLuint default_texs[22];
|
|
|
|
char *custom_prog;
|
|
|
|
char *custom_tex;
|
|
|
|
int custom_tlin;
|
|
|
|
int custom_trect;
|
|
|
|
int mipmap_gen;
|
|
|
|
int stereo_mode;
|
|
|
|
|
|
|
|
struct mp_csp_equalizer video_eq;
|
|
|
|
|
|
|
|
int texture_width;
|
|
|
|
int texture_height;
|
|
|
|
int mpi_flipped;
|
|
|
|
int vo_flipped;
|
|
|
|
int ass_border_x, ass_border_y;
|
|
|
|
|
|
|
|
unsigned int slice_height;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void resize(struct vo *vo, int x, int y)
|
|
|
|
{
|
|
|
|
struct gl_priv *p = vo->priv;
|
|
|
|
GL *gl = p->gl;
|
|
|
|
|
|
|
|
mp_msg(MSGT_VO, MSGL_V, "[gl] Resize: %dx%d\n", x, y);
|
|
|
|
if (WinID >= 0) {
|
|
|
|
int left = 0, top = 0, w = x, h = y;
|
|
|
|
geometry(&left, &top, &w, &h, vo->dwidth, vo->dheight);
|
|
|
|
top = y - h - top;
|
|
|
|
gl->Viewport(left, top, w, h);
|
|
|
|
} else
|
|
|
|
gl->Viewport(0, 0, x, y);
|
|
|
|
|
|
|
|
gl->MatrixMode(GL_PROJECTION);
|
|
|
|
gl->LoadIdentity();
|
|
|
|
p->ass_border_x = p->ass_border_y = 0;
|
2011-09-29 17:01:41 +00:00
|
|
|
if (aspect_scaling()) {
|
2011-09-25 09:18:07 +00:00
|
|
|
int new_w, new_h;
|
|
|
|
GLdouble scale_x, scale_y;
|
|
|
|
aspect(vo, &new_w, &new_h, A_WINZOOM);
|
|
|
|
panscan_calc_windowed(vo);
|
|
|
|
new_w += vo->panscan_x;
|
|
|
|
new_h += vo->panscan_y;
|
|
|
|
scale_x = (GLdouble)new_w / (GLdouble)x;
|
|
|
|
scale_y = (GLdouble)new_h / (GLdouble)y;
|
|
|
|
gl->Scaled(scale_x, scale_y, 1);
|
|
|
|
p->ass_border_x = (vo->dwidth - new_w) / 2;
|
|
|
|
p->ass_border_y = (vo->dheight - new_h) / 2;
|
|
|
|
}
|
|
|
|
gl->Ortho(0, p->image_width, p->image_height, 0, -1, 1);
|
|
|
|
|
|
|
|
gl->MatrixMode(GL_MODELVIEW);
|
|
|
|
gl->LoadIdentity();
|
|
|
|
|
|
|
|
gl->Clear(GL_COLOR_BUFFER_BIT);
|
2011-12-05 04:36:20 +00:00
|
|
|
vo->want_redraw = true;
|
2001-02-24 20:28:24 +00:00
|
|
|
}
|
|
|
|
|
2011-09-25 09:18:07 +00:00
|
|
|
static void texSize(struct vo *vo, int w, int h, int *texw, int *texh)
|
|
|
|
{
|
|
|
|
struct gl_priv *p = vo->priv;
|
|
|
|
|
|
|
|
if (p->use_rectangle) {
|
|
|
|
*texw = w;
|
|
|
|
*texh = h;
|
|
|
|
} else {
|
|
|
|
*texw = 32;
|
|
|
|
while (*texw < w)
|
|
|
|
*texw *= 2;
|
|
|
|
*texh = 32;
|
|
|
|
while (*texh < h)
|
|
|
|
*texh *= 2;
|
|
|
|
}
|
2011-10-23 20:51:00 +00:00
|
|
|
if (p->ati_hack)
|
2011-09-25 09:18:07 +00:00
|
|
|
*texw = (*texw + 511) & ~511;
|
2005-07-26 10:16:18 +00:00
|
|
|
}
|
|
|
|
|
2005-09-25 16:41:28 +00:00
|
|
|
//! maximum size of custom fragment program
|
2005-09-14 22:08:04 +00:00
|
|
|
#define MAX_CUSTOM_PROG_SIZE (1024 * 1024)
|
2011-09-25 09:18:07 +00:00
|
|
|
static void update_yuvconv(struct vo *vo)
|
|
|
|
{
|
|
|
|
struct gl_priv *p = vo->priv;
|
|
|
|
GL *gl = p->gl;
|
|
|
|
|
|
|
|
int xs, ys, depth;
|
|
|
|
struct mp_csp_params cparams = { .colorspace = p->colorspace };
|
|
|
|
mp_csp_copy_equalizer_values(&cparams, &p->video_eq);
|
|
|
|
gl_conversion_params_t params = {
|
|
|
|
p->target, p->yuvconvtype, cparams,
|
2011-08-26 18:51:51 +00:00
|
|
|
p->texture_width, p->texture_height, 0, 0, p->filter_strength,
|
|
|
|
p->noise_strength
|
2011-09-25 09:18:07 +00:00
|
|
|
};
|
|
|
|
mp_get_chroma_shift(p->image_format, &xs, &ys, &depth);
|
|
|
|
params.chrom_texw = params.texw >> xs;
|
|
|
|
params.chrom_texh = params.texh >> ys;
|
2012-03-08 03:25:33 +00:00
|
|
|
params.csp_params.input_bits = depth;
|
|
|
|
params.csp_params.texture_bits = depth+7 & ~7;
|
2011-09-25 09:18:07 +00:00
|
|
|
glSetupYUVConversion(gl, ¶ms);
|
|
|
|
if (p->custom_prog) {
|
|
|
|
FILE *f = fopen(p->custom_prog, "rb");
|
|
|
|
if (!f) {
|
|
|
|
mp_msg(MSGT_VO, MSGL_WARN,
|
|
|
|
"[gl] Could not read customprog %s\n", p->custom_prog);
|
|
|
|
} else {
|
|
|
|
char *prog = calloc(1, MAX_CUSTOM_PROG_SIZE + 1);
|
|
|
|
fread(prog, 1, MAX_CUSTOM_PROG_SIZE, f);
|
|
|
|
fclose(f);
|
|
|
|
loadGPUProgram(gl, GL_FRAGMENT_PROGRAM, prog);
|
|
|
|
free(prog);
|
|
|
|
}
|
|
|
|
gl->ProgramEnvParameter4f(GL_FRAGMENT_PROGRAM, 0,
|
|
|
|
1.0 / p->texture_width,
|
|
|
|
1.0 / p->texture_height,
|
|
|
|
p->texture_width, p->texture_height);
|
2005-09-14 22:08:04 +00:00
|
|
|
}
|
2011-09-25 09:18:07 +00:00
|
|
|
if (p->custom_tex) {
|
|
|
|
FILE *f = fopen(p->custom_tex, "rb");
|
|
|
|
if (!f) {
|
|
|
|
mp_msg(MSGT_VO, MSGL_WARN,
|
|
|
|
"[gl] Could not read customtex %s\n", p->custom_tex);
|
|
|
|
} else {
|
|
|
|
int width, height, maxval;
|
|
|
|
gl->ActiveTexture(GL_TEXTURE3);
|
|
|
|
if (glCreatePPMTex(gl, p->custom_trect ? GL_TEXTURE_RECTANGLE : GL_TEXTURE_2D,
|
|
|
|
0, p->custom_tlin ? GL_LINEAR : GL_NEAREST,
|
|
|
|
f, &width, &height, &maxval)) {
|
|
|
|
gl->ProgramEnvParameter4f(GL_FRAGMENT_PROGRAM, 1,
|
|
|
|
1.0 / width, 1.0 / height,
|
|
|
|
width, height);
|
|
|
|
} else
|
|
|
|
mp_msg(MSGT_VO, MSGL_WARN,
|
|
|
|
"[gl] Error parsing customtex %s\n", p->custom_tex);
|
|
|
|
fclose(f);
|
|
|
|
gl->ActiveTexture(GL_TEXTURE0);
|
|
|
|
}
|
2005-09-25 16:31:58 +00:00
|
|
|
}
|
2005-09-14 22:08:04 +00:00
|
|
|
}
|
|
|
|
|
VO, sub: refactor
Remove VFCTRL_DRAW_OSD, VFCAP_EOSD_FILTER, VFCAP_EOSD_RGBA, VFCAP_EOSD,
VOCTRL_DRAW_EOSD, VOCTRL_GET_EOSD_RES, VOCTRL_QUERY_EOSD_FORMAT.
Remove draw_osd_with_eosd(), which rendered the OSD by calling
VOCTRL_DRAW_EOSD. Change VOs to call osd_draw() directly, which takes
a callback as argument. (This basically works like the old OSD API,
except multiple OSD bitmap formats are supported and caching is
possible.)
Remove all mentions of "eosd". It's simply "osd" now.
Make OSD size per-OSD-object, as they can be different when using
vf_sub. Include display_par/video_par in resolution change detection.
Fix the issue with margin borders in vo_corevideo.
2012-10-19 17:25:18 +00:00
|
|
|
static void draw_osd(struct vo *vo, struct osd_state *osd)
|
2011-09-25 09:18:07 +00:00
|
|
|
{
|
|
|
|
struct gl_priv *p = vo->priv;
|
|
|
|
GL *gl = p->gl;
|
VO, sub: refactor
Remove VFCTRL_DRAW_OSD, VFCAP_EOSD_FILTER, VFCAP_EOSD_RGBA, VFCAP_EOSD,
VOCTRL_DRAW_EOSD, VOCTRL_GET_EOSD_RES, VOCTRL_QUERY_EOSD_FORMAT.
Remove draw_osd_with_eosd(), which rendered the OSD by calling
VOCTRL_DRAW_EOSD. Change VOs to call osd_draw() directly, which takes
a callback as argument. (This basically works like the old OSD API,
except multiple OSD bitmap formats are supported and caching is
possible.)
Remove all mentions of "eosd". It's simply "osd" now.
Make OSD size per-OSD-object, as they can be different when using
vf_sub. Include display_par/video_par in resolution change detection.
Fix the issue with margin borders in vo_corevideo.
2012-10-19 17:25:18 +00:00
|
|
|
assert(p->osd);
|
|
|
|
|
|
|
|
if (!p->use_osd)
|
|
|
|
return;
|
2011-09-25 09:18:07 +00:00
|
|
|
|
2012-10-04 00:29:54 +00:00
|
|
|
if (!p->scaled_osd) {
|
|
|
|
gl->MatrixMode(GL_PROJECTION);
|
|
|
|
gl->PushMatrix();
|
|
|
|
gl->LoadIdentity();
|
|
|
|
gl->Ortho(0, vo->dwidth, vo->dheight, 0, -1, 1);
|
|
|
|
}
|
VO, sub: refactor
Remove VFCTRL_DRAW_OSD, VFCAP_EOSD_FILTER, VFCAP_EOSD_RGBA, VFCAP_EOSD,
VOCTRL_DRAW_EOSD, VOCTRL_GET_EOSD_RES, VOCTRL_QUERY_EOSD_FORMAT.
Remove draw_osd_with_eosd(), which rendered the OSD by calling
VOCTRL_DRAW_EOSD. Change VOs to call osd_draw() directly, which takes
a callback as argument. (This basically works like the old OSD API,
except multiple OSD bitmap formats are supported and caching is
possible.)
Remove all mentions of "eosd". It's simply "osd" now.
Make OSD size per-OSD-object, as they can be different when using
vf_sub. Include display_par/video_par in resolution change detection.
Fix the issue with margin borders in vo_corevideo.
2012-10-19 17:25:18 +00:00
|
|
|
|
2012-10-04 00:29:54 +00:00
|
|
|
gl->Color4ub((p->osd_color >> 16) & 0xff, (p->osd_color >> 8) & 0xff,
|
|
|
|
p->osd_color & 0xff, 0xff - (p->osd_color >> 24));
|
VO, sub: refactor
Remove VFCTRL_DRAW_OSD, VFCAP_EOSD_FILTER, VFCAP_EOSD_RGBA, VFCAP_EOSD,
VOCTRL_DRAW_EOSD, VOCTRL_GET_EOSD_RES, VOCTRL_QUERY_EOSD_FORMAT.
Remove draw_osd_with_eosd(), which rendered the OSD by calling
VOCTRL_DRAW_EOSD. Change VOs to call osd_draw() directly, which takes
a callback as argument. (This basically works like the old OSD API,
except multiple OSD bitmap formats are supported and caching is
possible.)
Remove all mentions of "eosd". It's simply "osd" now.
Make OSD size per-OSD-object, as they can be different when using
vf_sub. Include display_par/video_par in resolution change detection.
Fix the issue with margin borders in vo_corevideo.
2012-10-19 17:25:18 +00:00
|
|
|
|
|
|
|
struct mp_osd_res res = {
|
|
|
|
.w = vo->dwidth,
|
|
|
|
.h = vo->dheight,
|
|
|
|
.display_par = vo->monitor_par,
|
|
|
|
.video_par = vo->aspdat.par,
|
|
|
|
};
|
|
|
|
if (p->scaled_osd) {
|
|
|
|
res.w = p->image_width;
|
|
|
|
res.h = p->image_height;
|
|
|
|
} else if (aspect_scaling()) {
|
|
|
|
res.ml = res.mr = p->ass_border_x;
|
|
|
|
res.mt = res.mb = p->ass_border_y;
|
|
|
|
}
|
|
|
|
|
|
|
|
mpgl_osd_draw_legacy(p->osd, osd, res);
|
|
|
|
|
2012-10-04 00:29:54 +00:00
|
|
|
if (!p->scaled_osd)
|
|
|
|
gl->PopMatrix();
|
2006-08-28 20:17:42 +00:00
|
|
|
}
|
|
|
|
|
2005-09-09 14:47:54 +00:00
|
|
|
/**
|
|
|
|
* \brief uninitialize OpenGL context, freeing textures, buffers etc.
|
|
|
|
*/
|
2011-09-25 09:18:07 +00:00
|
|
|
static void uninitGl(struct vo *vo)
|
|
|
|
{
|
|
|
|
struct gl_priv *p = vo->priv;
|
|
|
|
GL *gl = p->gl;
|
|
|
|
|
2012-10-02 23:54:13 +00:00
|
|
|
if (!gl)
|
|
|
|
return;
|
|
|
|
|
2011-09-25 09:18:07 +00:00
|
|
|
int i = 0;
|
|
|
|
if (gl->DeletePrograms && p->fragprog)
|
|
|
|
gl->DeletePrograms(1, &p->fragprog);
|
|
|
|
p->fragprog = 0;
|
|
|
|
while (p->default_texs[i] != 0)
|
|
|
|
i++;
|
|
|
|
if (i)
|
|
|
|
gl->DeleteTextures(i, p->default_texs);
|
|
|
|
p->default_texs[0] = 0;
|
2012-10-04 00:29:54 +00:00
|
|
|
if (p->osd)
|
|
|
|
mpgl_osd_destroy(p->osd);
|
|
|
|
p->osd = NULL;
|
2011-09-25 09:18:07 +00:00
|
|
|
p->buffer = 0;
|
|
|
|
p->buffersize = 0;
|
|
|
|
p->bufferptr = NULL;
|
|
|
|
if (gl->DeleteBuffers && p->buffer_uv[0])
|
|
|
|
gl->DeleteBuffers(2, p->buffer_uv);
|
|
|
|
p->buffer_uv[0] = p->buffer_uv[1] = 0;
|
|
|
|
p->buffersize_uv = 0;
|
|
|
|
p->bufferptr_uv[0] = p->bufferptr_uv[1] = 0;
|
|
|
|
p->err_shown = 0;
|
2005-09-09 14:47:54 +00:00
|
|
|
}
|
|
|
|
|
2011-09-25 09:18:07 +00:00
|
|
|
static void autodetectGlExtensions(struct vo *vo)
|
|
|
|
{
|
|
|
|
struct gl_priv *p = vo->priv;
|
|
|
|
GL *gl = p->gl;
|
|
|
|
|
|
|
|
const char *extensions = gl->GetString(GL_EXTENSIONS);
|
|
|
|
const char *vendor = gl->GetString(GL_VENDOR);
|
|
|
|
const char *version = gl->GetString(GL_VERSION);
|
|
|
|
const char *renderer = gl->GetString(GL_RENDERER);
|
|
|
|
int is_ati = vendor && strstr(vendor, "ATI") != NULL;
|
|
|
|
int ati_broken_pbo = 0;
|
|
|
|
mp_msg(MSGT_VO, MSGL_V, "[gl] Running on OpenGL '%s' by '%s', version '%s'\n",
|
|
|
|
renderer, vendor, version);
|
|
|
|
if (is_ati && strncmp(version, "2.1.", 4) == 0) {
|
|
|
|
int ver = atoi(version + 4);
|
|
|
|
mp_msg(MSGT_VO, MSGL_V, "[gl] Detected ATI driver version: %i\n", ver);
|
|
|
|
ati_broken_pbo = ver && ver < 8395;
|
|
|
|
}
|
|
|
|
if (p->ati_hack == -1)
|
|
|
|
p->ati_hack = ati_broken_pbo;
|
|
|
|
if (p->force_pbo == -1) {
|
|
|
|
p->force_pbo = 0;
|
|
|
|
if (extensions && strstr(extensions, "_pixel_buffer_object"))
|
|
|
|
p->force_pbo = is_ati;
|
|
|
|
}
|
2011-11-08 19:21:00 +00:00
|
|
|
p->have_texture_rg = extensions && strstr(extensions, "GL_ARB_texture_rg");
|
2011-09-25 09:18:07 +00:00
|
|
|
if (p->use_rectangle == -1) {
|
|
|
|
p->use_rectangle = 0;
|
|
|
|
if (extensions) {
|
2010-05-24 17:36:23 +00:00
|
|
|
// if (strstr(extensions, "_texture_non_power_of_two"))
|
2011-09-25 09:18:07 +00:00
|
|
|
if (strstr(extensions, "_texture_rectangle"))
|
|
|
|
p->use_rectangle = renderer
|
|
|
|
&& strstr(renderer, "Mesa DRI R200") ? 1 : 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (p->use_osd == -1)
|
|
|
|
p->use_osd = gl->BindTexture != NULL;
|
|
|
|
if (p->use_yuv == -1)
|
|
|
|
p->use_yuv = glAutodetectYUVConversion(gl);
|
|
|
|
|
|
|
|
int eq_caps = 0;
|
|
|
|
int yuv_mask = (1 << p->use_yuv);
|
|
|
|
if (!(yuv_mask & MASK_NOT_COMBINERS)) {
|
|
|
|
// combiners
|
|
|
|
eq_caps = (1 << MP_CSP_EQ_HUE) | (1 << MP_CSP_EQ_SATURATION);
|
|
|
|
} else if (yuv_mask & MASK_ALL_YUV) {
|
|
|
|
eq_caps = MP_CSP_EQ_CAPS_COLORMATRIX;
|
|
|
|
if (yuv_mask & MASK_GAMMA_SUPPORT)
|
|
|
|
eq_caps |= MP_CSP_EQ_CAPS_GAMMA;
|
2010-05-24 17:36:23 +00:00
|
|
|
}
|
2011-09-25 09:18:07 +00:00
|
|
|
p->video_eq.capabilities = eq_caps;
|
|
|
|
|
|
|
|
if (is_ati && (p->lscale == 1 || p->lscale == 2 || p->cscale == 1 || p->cscale == 2))
|
|
|
|
mp_msg(MSGT_VO, MSGL_WARN, "[gl] Selected scaling mode may be broken on"
|
|
|
|
" ATI cards.\n"
|
|
|
|
"Tell _them_ to fix GL_REPEAT if you have issues.\n");
|
|
|
|
mp_msg(MSGT_VO, MSGL_V, "[gl] Settings after autodetection: ati-hack = %i, "
|
|
|
|
"force-pbo = %i, rectangle = %i, yuv = %i\n",
|
|
|
|
p->ati_hack, p->force_pbo, p->use_rectangle, p->use_yuv);
|
2008-12-10 16:39:45 +00:00
|
|
|
}
|
|
|
|
|
2011-09-25 09:18:07 +00:00
|
|
|
static GLint get_scale_type(struct vo *vo, int chroma)
|
|
|
|
{
|
|
|
|
struct gl_priv *p = vo->priv;
|
|
|
|
|
|
|
|
int nearest = (chroma ? p->cscale : p->lscale) & 64;
|
|
|
|
if (nearest)
|
|
|
|
return p->mipmap_gen ? GL_NEAREST_MIPMAP_NEAREST : GL_NEAREST;
|
|
|
|
return p->mipmap_gen ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR;
|
2010-07-15 18:57:57 +00:00
|
|
|
}
|
|
|
|
|
2011-10-23 22:08:57 +00:00
|
|
|
// Return the high byte of the value that represents white in chroma (U/V)
|
|
|
|
static int get_chroma_clear_val(int bit_depth)
|
|
|
|
{
|
|
|
|
return 1 << (bit_depth - 1 & 7);
|
|
|
|
}
|
|
|
|
|
2004-11-01 20:24:37 +00:00
|
|
|
/**
|
|
|
|
* \brief Initialize a (new or reused) OpenGL context.
|
2005-09-09 14:47:54 +00:00
|
|
|
* set global gl-related variables to their default values
|
2004-11-01 20:24:37 +00:00
|
|
|
*/
|
2011-09-25 09:18:07 +00:00
|
|
|
static int initGl(struct vo *vo, uint32_t d_width, uint32_t d_height)
|
|
|
|
{
|
|
|
|
struct gl_priv *p = vo->priv;
|
|
|
|
GL *gl = p->gl;
|
|
|
|
|
|
|
|
GLint scale_type = get_scale_type(vo, 0);
|
|
|
|
autodetectGlExtensions(vo);
|
|
|
|
p->target = p->use_rectangle == 1 ? GL_TEXTURE_RECTANGLE : GL_TEXTURE_2D;
|
|
|
|
p->yuvconvtype = SET_YUV_CONVERSION(p->use_yuv) |
|
|
|
|
SET_YUV_LUM_SCALER(p->lscale) |
|
|
|
|
SET_YUV_CHROM_SCALER(p->cscale);
|
|
|
|
|
|
|
|
texSize(vo, p->image_width, p->image_height,
|
|
|
|
&p->texture_width, &p->texture_height);
|
|
|
|
|
|
|
|
gl->Disable(GL_BLEND);
|
|
|
|
gl->Disable(GL_DEPTH_TEST);
|
|
|
|
gl->DepthMask(GL_FALSE);
|
|
|
|
gl->Disable(GL_CULL_FACE);
|
|
|
|
gl->Enable(p->target);
|
2012-10-03 14:50:13 +00:00
|
|
|
gl->DrawBuffer(GL_BACK);
|
2011-09-25 09:18:07 +00:00
|
|
|
gl->TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
|
|
|
|
|
|
|
mp_msg(MSGT_VO, MSGL_V, "[gl] Creating %dx%d texture...\n",
|
|
|
|
p->texture_width, p->texture_height);
|
|
|
|
|
|
|
|
glCreateClearTex(gl, p->target, p->texfmt, p->gl_format,
|
|
|
|
p->gl_type, scale_type,
|
|
|
|
p->texture_width, p->texture_height, 0);
|
|
|
|
|
|
|
|
if (p->mipmap_gen)
|
|
|
|
gl->TexParameteri(p->target, GL_GENERATE_MIPMAP, GL_TRUE);
|
|
|
|
|
|
|
|
if (p->is_yuv) {
|
|
|
|
int i;
|
|
|
|
int xs, ys, depth;
|
|
|
|
scale_type = get_scale_type(vo, 1);
|
|
|
|
mp_get_chroma_shift(p->image_format, &xs, &ys, &depth);
|
2011-10-23 22:08:57 +00:00
|
|
|
int clear = get_chroma_clear_val(depth);
|
2011-09-25 09:18:07 +00:00
|
|
|
gl->GenTextures(21, p->default_texs);
|
|
|
|
p->default_texs[21] = 0;
|
|
|
|
for (i = 0; i < 7; i++) {
|
|
|
|
gl->ActiveTexture(GL_TEXTURE1 + i);
|
|
|
|
gl->BindTexture(GL_TEXTURE_2D, p->default_texs[i]);
|
|
|
|
gl->BindTexture(GL_TEXTURE_RECTANGLE, p->default_texs[i + 7]);
|
|
|
|
gl->BindTexture(GL_TEXTURE_3D, p->default_texs[i + 14]);
|
|
|
|
}
|
|
|
|
gl->ActiveTexture(GL_TEXTURE1);
|
|
|
|
glCreateClearTex(gl, p->target, p->texfmt, p->gl_format,
|
|
|
|
p->gl_type, scale_type,
|
|
|
|
p->texture_width >> xs, p->texture_height >> ys,
|
2011-10-23 22:08:57 +00:00
|
|
|
clear);
|
2011-09-25 09:18:07 +00:00
|
|
|
if (p->mipmap_gen)
|
|
|
|
gl->TexParameteri(p->target, GL_GENERATE_MIPMAP, GL_TRUE);
|
|
|
|
gl->ActiveTexture(GL_TEXTURE2);
|
|
|
|
glCreateClearTex(gl, p->target, p->texfmt, p->gl_format,
|
|
|
|
p->gl_type, scale_type,
|
|
|
|
p->texture_width >> xs, p->texture_height >> ys,
|
2011-10-23 22:08:57 +00:00
|
|
|
clear);
|
2011-09-25 09:18:07 +00:00
|
|
|
if (p->mipmap_gen)
|
|
|
|
gl->TexParameteri(p->target, GL_GENERATE_MIPMAP, GL_TRUE);
|
|
|
|
gl->ActiveTexture(GL_TEXTURE0);
|
|
|
|
gl->BindTexture(p->target, 0);
|
2006-07-01 10:58:32 +00:00
|
|
|
}
|
2011-09-25 09:18:07 +00:00
|
|
|
if (p->is_yuv || p->custom_prog) {
|
|
|
|
if ((MASK_NOT_COMBINERS & (1 << p->use_yuv)) || p->custom_prog) {
|
|
|
|
if (!gl->GenPrograms || !gl->BindProgram)
|
|
|
|
mp_msg(MSGT_VO, MSGL_ERR,
|
|
|
|
"[gl] fragment program functions missing!\n");
|
|
|
|
else {
|
|
|
|
gl->GenPrograms(1, &p->fragprog);
|
|
|
|
gl->BindProgram(GL_FRAGMENT_PROGRAM, p->fragprog);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
update_yuvconv(vo);
|
2005-09-14 22:08:04 +00:00
|
|
|
}
|
2004-11-01 20:24:37 +00:00
|
|
|
|
2012-10-04 00:29:54 +00:00
|
|
|
p->osd = mpgl_osd_init(gl, true);
|
|
|
|
p->osd->scaled = p->scaled_osd;
|
2011-10-29 17:38:33 +00:00
|
|
|
|
2011-09-25 09:18:07 +00:00
|
|
|
resize(vo, d_width, d_height);
|
2004-11-01 20:24:37 +00:00
|
|
|
|
2011-09-25 09:18:07 +00:00
|
|
|
gl->ClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
|
|
|
gl->Clear(GL_COLOR_BUFFER_BIT);
|
|
|
|
if (gl->SwapInterval && p->swap_interval >= 0)
|
|
|
|
gl->SwapInterval(p->swap_interval);
|
|
|
|
return 1;
|
2004-11-01 20:24:37 +00:00
|
|
|
}
|
|
|
|
|
2012-10-02 23:54:13 +00:00
|
|
|
static bool create_window(struct vo *vo, uint32_t d_width, uint32_t d_height,
|
|
|
|
uint32_t flags)
|
2001-02-24 20:28:24 +00:00
|
|
|
{
|
2011-09-25 09:18:07 +00:00
|
|
|
struct gl_priv *p = vo->priv;
|
|
|
|
|
|
|
|
if (p->stereo_mode == GL_3D_QUADBUFFER)
|
|
|
|
flags |= VOFLAG_STEREO;
|
|
|
|
|
2012-10-02 23:54:13 +00:00
|
|
|
int mpgl_caps = MPGL_CAP_GL_LEGACY;
|
|
|
|
if (!p->allow_sw)
|
|
|
|
mpgl_caps |= MPGL_CAP_NO_SW;
|
|
|
|
return mpgl_create_window(p->glctx, mpgl_caps, d_width, d_height, flags);
|
2010-02-02 20:37:48 +00:00
|
|
|
}
|
|
|
|
|
2011-09-25 09:18:07 +00:00
|
|
|
static int config(struct vo *vo, uint32_t width, uint32_t height,
|
|
|
|
uint32_t d_width, uint32_t d_height, uint32_t flags,
|
2011-12-06 19:23:54 +00:00
|
|
|
uint32_t format)
|
2001-02-24 20:28:24 +00:00
|
|
|
{
|
2011-09-25 09:18:07 +00:00
|
|
|
struct gl_priv *p = vo->priv;
|
2006-08-28 20:38:31 +00:00
|
|
|
|
2011-09-25 09:18:07 +00:00
|
|
|
int xs, ys;
|
|
|
|
p->image_height = height;
|
|
|
|
p->image_width = width;
|
|
|
|
p->image_format = format;
|
|
|
|
p->is_yuv = mp_get_chroma_shift(p->image_format, &xs, &ys, NULL) > 0;
|
|
|
|
p->is_yuv |= (xs << 8) | (ys << 16);
|
2011-11-08 19:21:00 +00:00
|
|
|
glFindFormat(format, p->have_texture_rg, NULL, &p->texfmt, &p->gl_format,
|
|
|
|
&p->gl_type);
|
2011-09-25 09:18:07 +00:00
|
|
|
|
|
|
|
p->vo_flipped = !!(flags & VOFLAG_FLIPPING);
|
|
|
|
|
|
|
|
if (vo->config_count)
|
|
|
|
uninitGl(vo);
|
2012-10-02 23:54:13 +00:00
|
|
|
|
|
|
|
if (!create_window(vo, d_width, d_height, flags))
|
2011-09-25 09:18:07 +00:00
|
|
|
return -1;
|
2012-10-02 23:54:13 +00:00
|
|
|
|
2011-09-25 09:18:07 +00:00
|
|
|
initGl(vo, vo->dwidth, vo->dheight);
|
2004-11-01 20:24:37 +00:00
|
|
|
|
2011-09-25 09:18:07 +00:00
|
|
|
return 0;
|
2001-02-24 20:28:24 +00:00
|
|
|
}
|
|
|
|
|
2011-09-25 09:18:07 +00:00
|
|
|
static void check_events(struct vo *vo)
|
2001-02-24 20:28:24 +00:00
|
|
|
{
|
2011-09-25 09:18:07 +00:00
|
|
|
struct gl_priv *p = vo->priv;
|
|
|
|
|
|
|
|
int e = p->glctx->check_events(vo);
|
|
|
|
if (e & VO_EVENT_REINIT) {
|
|
|
|
uninitGl(vo);
|
|
|
|
initGl(vo, vo->dwidth, vo->dheight);
|
2010-04-25 10:44:53 +00:00
|
|
|
}
|
2011-09-25 09:18:07 +00:00
|
|
|
if (e & VO_EVENT_RESIZE)
|
|
|
|
resize(vo, vo->dwidth, vo->dheight);
|
2011-12-05 04:36:20 +00:00
|
|
|
if (e & VO_EVENT_EXPOSE)
|
|
|
|
vo->want_redraw = true;
|
2001-03-03 21:46:39 +00:00
|
|
|
}
|
|
|
|
|
2011-09-25 09:18:07 +00:00
|
|
|
static void do_render(struct vo *vo)
|
|
|
|
{
|
|
|
|
struct gl_priv *p = vo->priv;
|
|
|
|
GL *gl = p->gl;
|
|
|
|
|
2009-12-27 14:31:13 +00:00
|
|
|
// Enable(GL_TEXTURE_2D);
|
|
|
|
// BindTexture(GL_TEXTURE_2D, texture_id);
|
|
|
|
|
2011-08-20 11:29:23 +00:00
|
|
|
gl->Color4f(1, 1, 1, 1);
|
2011-09-25 09:18:07 +00:00
|
|
|
if (p->is_yuv || p->custom_prog)
|
|
|
|
glEnableYUVConversion(gl, p->target, p->yuvconvtype);
|
|
|
|
if (p->stereo_mode) {
|
|
|
|
glEnable3DLeft(gl, p->stereo_mode);
|
|
|
|
glDrawTex(gl, 0, 0, p->image_width, p->image_height,
|
|
|
|
0, 0, p->image_width >> 1, p->image_height,
|
|
|
|
p->texture_width, p->texture_height,
|
|
|
|
p->use_rectangle == 1, p->is_yuv,
|
|
|
|
p->mpi_flipped ^ p->vo_flipped);
|
|
|
|
glEnable3DRight(gl, p->stereo_mode);
|
|
|
|
glDrawTex(gl, 0, 0, p->image_width, p->image_height,
|
|
|
|
p->image_width >> 1, 0, p->image_width >> 1,
|
|
|
|
p->image_height, p->texture_width, p->texture_height,
|
|
|
|
p->use_rectangle == 1, p->is_yuv,
|
|
|
|
p->mpi_flipped ^ p->vo_flipped);
|
|
|
|
glDisable3D(gl, p->stereo_mode);
|
|
|
|
} else {
|
|
|
|
glDrawTex(gl, 0, 0, p->image_width, p->image_height,
|
|
|
|
0, 0, p->image_width, p->image_height,
|
|
|
|
p->texture_width, p->texture_height,
|
|
|
|
p->use_rectangle == 1, p->is_yuv,
|
|
|
|
p->mpi_flipped ^ p->vo_flipped);
|
|
|
|
}
|
|
|
|
if (p->is_yuv || p->custom_prog)
|
|
|
|
glDisableYUVConversion(gl, p->target, p->yuvconvtype);
|
2009-12-27 14:31:13 +00:00
|
|
|
}
|
|
|
|
|
2011-09-25 09:18:07 +00:00
|
|
|
static void flip_page(struct vo *vo)
|
|
|
|
{
|
|
|
|
struct gl_priv *p = vo->priv;
|
|
|
|
GL *gl = p->gl;
|
|
|
|
|
2012-10-03 14:50:13 +00:00
|
|
|
if (p->use_glFinish)
|
|
|
|
gl->Finish();
|
|
|
|
p->glctx->swapGlBuffers(p->glctx);
|
|
|
|
if (aspect_scaling())
|
|
|
|
gl->Clear(GL_COLOR_BUFFER_BIT);
|
2001-02-24 20:28:24 +00:00
|
|
|
}
|
|
|
|
|
2011-09-25 09:18:07 +00:00
|
|
|
static int draw_slice(struct vo *vo, uint8_t *src[], int stride[], int w, int h,
|
|
|
|
int x, int y)
|
2001-02-24 20:28:24 +00:00
|
|
|
{
|
2011-09-25 09:18:07 +00:00
|
|
|
struct gl_priv *p = vo->priv;
|
|
|
|
GL *gl = p->gl;
|
|
|
|
|
|
|
|
p->mpi_flipped = stride[0] < 0;
|
|
|
|
glUploadTex(gl, p->target, p->gl_format, p->gl_type, src[0], stride[0],
|
|
|
|
x, y, w, h, p->slice_height);
|
|
|
|
if (p->is_yuv) {
|
|
|
|
int xs, ys;
|
|
|
|
mp_get_chroma_shift(p->image_format, &xs, &ys, NULL);
|
|
|
|
gl->ActiveTexture(GL_TEXTURE1);
|
|
|
|
glUploadTex(gl, p->target, p->gl_format, p->gl_type, src[1], stride[1],
|
|
|
|
x >> xs, y >> ys, w >> xs, h >> ys, p->slice_height);
|
|
|
|
gl->ActiveTexture(GL_TEXTURE2);
|
|
|
|
glUploadTex(gl, p->target, p->gl_format, p->gl_type, src[2], stride[2],
|
|
|
|
x >> xs, y >> ys, w >> xs, h >> ys, p->slice_height);
|
|
|
|
gl->ActiveTexture(GL_TEXTURE0);
|
|
|
|
}
|
|
|
|
return 0;
|
2001-02-24 20:28:24 +00:00
|
|
|
}
|
|
|
|
|
2011-09-25 09:18:07 +00:00
|
|
|
static uint32_t get_image(struct vo *vo, mp_image_t *mpi)
|
|
|
|
{
|
|
|
|
struct gl_priv *p = vo->priv;
|
|
|
|
GL *gl = p->gl;
|
|
|
|
|
|
|
|
int needed_size;
|
|
|
|
if (!gl->GenBuffers || !gl->BindBuffer || !gl->BufferData || !gl->MapBuffer) {
|
|
|
|
if (!p->err_shown)
|
|
|
|
mp_msg(MSGT_VO, MSGL_ERR, "[gl] extensions missing for dr\n"
|
|
|
|
"Expect a _major_ speed penalty\n");
|
|
|
|
p->err_shown = 1;
|
|
|
|
return VO_FALSE;
|
|
|
|
}
|
|
|
|
if (mpi->flags & MP_IMGFLAG_READABLE)
|
|
|
|
return VO_FALSE;
|
|
|
|
if (mpi->type != MP_IMGTYPE_STATIC && mpi->type != MP_IMGTYPE_TEMP &&
|
|
|
|
(mpi->type != MP_IMGTYPE_NUMBERED || mpi->number))
|
|
|
|
return VO_FALSE;
|
2011-10-23 20:51:00 +00:00
|
|
|
if (p->ati_hack) {
|
2011-09-25 09:18:07 +00:00
|
|
|
mpi->width = p->texture_width;
|
|
|
|
mpi->height = p->texture_height;
|
2008-12-05 22:16:45 +00:00
|
|
|
}
|
2011-09-25 09:18:07 +00:00
|
|
|
mpi->stride[0] = mpi->width * mpi->bpp / 8;
|
|
|
|
needed_size = mpi->stride[0] * mpi->height;
|
2011-10-23 20:51:00 +00:00
|
|
|
if (!p->buffer)
|
|
|
|
gl->GenBuffers(1, &p->buffer);
|
|
|
|
gl->BindBuffer(GL_PIXEL_UNPACK_BUFFER, p->buffer);
|
|
|
|
if (needed_size > p->buffersize) {
|
|
|
|
p->buffersize = needed_size;
|
|
|
|
gl->BufferData(GL_PIXEL_UNPACK_BUFFER, p->buffersize,
|
|
|
|
NULL, GL_DYNAMIC_DRAW);
|
2008-12-05 22:35:24 +00:00
|
|
|
}
|
2011-10-23 20:51:00 +00:00
|
|
|
if (!p->bufferptr)
|
|
|
|
p->bufferptr = gl->MapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);
|
|
|
|
mpi->planes[0] = p->bufferptr;
|
|
|
|
gl->BindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
|
2011-09-25 09:18:07 +00:00
|
|
|
if (!mpi->planes[0]) {
|
|
|
|
if (!p->err_shown)
|
|
|
|
mp_msg(MSGT_VO, MSGL_ERR, "[gl] could not acquire buffer for dr\n"
|
|
|
|
"Expect a _major_ speed penalty\n");
|
|
|
|
p->err_shown = 1;
|
|
|
|
return VO_FALSE;
|
2008-11-24 11:04:50 +00:00
|
|
|
}
|
2011-09-25 09:18:07 +00:00
|
|
|
if (p->is_yuv) {
|
|
|
|
// planar YUV
|
|
|
|
int xs, ys, component_bits;
|
|
|
|
mp_get_chroma_shift(p->image_format, &xs, &ys, &component_bits);
|
|
|
|
int bp = (component_bits + 7) / 8;
|
|
|
|
mpi->flags |= MP_IMGFLAG_COMMON_STRIDE | MP_IMGFLAG_COMMON_PLANE;
|
|
|
|
mpi->stride[0] = mpi->width * bp;
|
|
|
|
mpi->planes[1] = mpi->planes[0] + mpi->stride[0] * mpi->height;
|
|
|
|
mpi->stride[1] = (mpi->width >> xs) * bp;
|
|
|
|
mpi->planes[2] = mpi->planes[1] + mpi->stride[1] * (mpi->height >> ys);
|
|
|
|
mpi->stride[2] = (mpi->width >> xs) * bp;
|
2011-10-23 20:51:00 +00:00
|
|
|
if (p->ati_hack) {
|
2011-09-25 09:18:07 +00:00
|
|
|
mpi->flags &= ~MP_IMGFLAG_COMMON_PLANE;
|
|
|
|
if (!p->buffer_uv[0])
|
|
|
|
gl->GenBuffers(2, p->buffer_uv);
|
2011-10-23 22:08:57 +00:00
|
|
|
int buffer_size = mpi->stride[1] * mpi->height;
|
|
|
|
if (buffer_size > p->buffersize_uv) {
|
2011-09-25 09:18:07 +00:00
|
|
|
gl->BindBuffer(GL_PIXEL_UNPACK_BUFFER, p->buffer_uv[0]);
|
2011-10-23 22:08:57 +00:00
|
|
|
gl->BufferData(GL_PIXEL_UNPACK_BUFFER, buffer_size, NULL,
|
|
|
|
GL_DYNAMIC_DRAW);
|
2011-09-25 09:18:07 +00:00
|
|
|
gl->BindBuffer(GL_PIXEL_UNPACK_BUFFER, p->buffer_uv[1]);
|
2011-10-23 22:08:57 +00:00
|
|
|
gl->BufferData(GL_PIXEL_UNPACK_BUFFER, buffer_size, NULL,
|
|
|
|
GL_DYNAMIC_DRAW);
|
|
|
|
p->buffersize_uv = buffer_size;
|
2011-09-25 09:18:07 +00:00
|
|
|
}
|
|
|
|
if (!p->bufferptr_uv[0]) {
|
|
|
|
gl->BindBuffer(GL_PIXEL_UNPACK_BUFFER, p->buffer_uv[0]);
|
|
|
|
p->bufferptr_uv[0] = gl->MapBuffer(GL_PIXEL_UNPACK_BUFFER,
|
2011-10-23 22:08:57 +00:00
|
|
|
GL_WRITE_ONLY);
|
2011-09-25 09:18:07 +00:00
|
|
|
gl->BindBuffer(GL_PIXEL_UNPACK_BUFFER, p->buffer_uv[1]);
|
|
|
|
p->bufferptr_uv[1] = gl->MapBuffer(GL_PIXEL_UNPACK_BUFFER,
|
2011-10-23 22:08:57 +00:00
|
|
|
GL_WRITE_ONLY);
|
2011-09-25 09:18:07 +00:00
|
|
|
}
|
|
|
|
mpi->planes[1] = p->bufferptr_uv[0];
|
|
|
|
mpi->planes[2] = p->bufferptr_uv[1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mpi->flags |= MP_IMGFLAG_DIRECT;
|
|
|
|
return VO_TRUE;
|
2005-07-26 10:16:18 +00:00
|
|
|
}
|
|
|
|
|
2011-09-25 09:18:07 +00:00
|
|
|
static void clear_border(struct vo *vo, uint8_t *dst, int start, int stride,
|
|
|
|
int height, int full_height, int value)
|
|
|
|
{
|
|
|
|
int right_border = stride - start;
|
|
|
|
int bottom_border = full_height - height;
|
|
|
|
while (height > 0) {
|
2011-10-23 22:08:57 +00:00
|
|
|
if (right_border > 0)
|
|
|
|
memset(dst + start, value, right_border);
|
2011-09-25 09:18:07 +00:00
|
|
|
dst += stride;
|
|
|
|
height--;
|
|
|
|
}
|
|
|
|
if (bottom_border > 0)
|
|
|
|
memset(dst, value, stride * bottom_border);
|
2008-12-27 13:00:03 +00:00
|
|
|
}
|
|
|
|
|
2011-09-25 09:18:07 +00:00
|
|
|
static uint32_t draw_image(struct vo *vo, mp_image_t *mpi)
|
|
|
|
{
|
|
|
|
struct gl_priv *p = vo->priv;
|
|
|
|
GL *gl = p->gl;
|
|
|
|
|
|
|
|
int slice = p->slice_height;
|
|
|
|
int stride[3];
|
|
|
|
unsigned char *planes[3];
|
|
|
|
mp_image_t mpi2 = *mpi;
|
|
|
|
int w = mpi->w, h = mpi->h;
|
|
|
|
if (mpi->flags & MP_IMGFLAG_DRAW_CALLBACK)
|
|
|
|
goto skip_upload;
|
|
|
|
mpi2.flags = 0;
|
|
|
|
mpi2.type = MP_IMGTYPE_TEMP;
|
|
|
|
mpi2.width = mpi2.w;
|
|
|
|
mpi2.height = mpi2.h;
|
|
|
|
if (p->force_pbo && !(mpi->flags & MP_IMGFLAG_DIRECT) && !p->bufferptr
|
|
|
|
&& get_image(vo, &mpi2) == VO_TRUE)
|
|
|
|
{
|
2011-10-23 22:08:57 +00:00
|
|
|
int bp = mpi->bpp / 8;
|
2011-09-25 09:18:07 +00:00
|
|
|
int xs, ys, component_bits;
|
|
|
|
mp_get_chroma_shift(p->image_format, &xs, &ys, &component_bits);
|
|
|
|
if (p->is_yuv)
|
2011-10-23 22:08:57 +00:00
|
|
|
bp = (component_bits + 7) / 8;
|
|
|
|
memcpy_pic(mpi2.planes[0], mpi->planes[0], mpi->w * bp, mpi->h,
|
2011-09-25 09:18:07 +00:00
|
|
|
mpi2.stride[0], mpi->stride[0]);
|
2011-10-23 22:08:57 +00:00
|
|
|
int uv_bytes = (mpi->w >> xs) * bp;
|
2011-09-25 09:18:07 +00:00
|
|
|
if (p->is_yuv) {
|
2011-10-23 22:08:57 +00:00
|
|
|
memcpy_pic(mpi2.planes[1], mpi->planes[1], uv_bytes, mpi->h >> ys,
|
|
|
|
mpi2.stride[1], mpi->stride[1]);
|
|
|
|
memcpy_pic(mpi2.planes[2], mpi->planes[2], uv_bytes, mpi->h >> ys,
|
|
|
|
mpi2.stride[2], mpi->stride[2]);
|
2011-09-25 09:18:07 +00:00
|
|
|
}
|
|
|
|
if (p->ati_hack) {
|
|
|
|
// since we have to do a full upload we need to clear the borders
|
2011-10-23 22:08:57 +00:00
|
|
|
clear_border(vo, mpi2.planes[0], mpi->w * bp, mpi2.stride[0],
|
2011-09-25 09:18:07 +00:00
|
|
|
mpi->h, mpi2.height, 0);
|
|
|
|
if (p->is_yuv) {
|
2011-10-23 22:08:57 +00:00
|
|
|
int clear = get_chroma_clear_val(component_bits);
|
|
|
|
clear_border(vo, mpi2.planes[1], uv_bytes, mpi2.stride[1],
|
|
|
|
mpi->h >> ys, mpi2.height >> ys, clear);
|
|
|
|
clear_border(vo, mpi2.planes[2], uv_bytes, mpi2.stride[2],
|
|
|
|
mpi->h >> ys, mpi2.height >> ys, clear);
|
2011-09-25 09:18:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
mpi = &mpi2;
|
2008-12-27 13:00:03 +00:00
|
|
|
}
|
2011-09-25 09:18:07 +00:00
|
|
|
stride[0] = mpi->stride[0];
|
|
|
|
stride[1] = mpi->stride[1];
|
|
|
|
stride[2] = mpi->stride[2];
|
|
|
|
planes[0] = mpi->planes[0];
|
|
|
|
planes[1] = mpi->planes[1];
|
|
|
|
planes[2] = mpi->planes[2];
|
|
|
|
p->mpi_flipped = stride[0] < 0;
|
|
|
|
if (mpi->flags & MP_IMGFLAG_DIRECT) {
|
2011-10-23 20:51:00 +00:00
|
|
|
intptr_t base = (intptr_t)planes[0];
|
|
|
|
if (p->ati_hack) {
|
2011-09-25 09:18:07 +00:00
|
|
|
w = p->texture_width;
|
2011-10-23 20:51:00 +00:00
|
|
|
h = p->texture_height;
|
2011-09-25 09:18:07 +00:00
|
|
|
}
|
2011-10-23 20:51:00 +00:00
|
|
|
if (p->mpi_flipped)
|
|
|
|
base += (mpi->h - 1) * stride[0];
|
|
|
|
planes[0] -= base;
|
|
|
|
planes[1] -= base;
|
|
|
|
planes[2] -= base;
|
|
|
|
gl->BindBuffer(GL_PIXEL_UNPACK_BUFFER, p->buffer);
|
|
|
|
gl->UnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
|
|
|
|
p->bufferptr = NULL;
|
|
|
|
if (!(mpi->flags & MP_IMGFLAG_COMMON_PLANE))
|
|
|
|
planes[0] = planes[1] = planes[2] = NULL;
|
2011-09-25 09:18:07 +00:00
|
|
|
slice = 0; // always "upload" full texture
|
2008-12-06 06:18:57 +00:00
|
|
|
}
|
2011-09-25 09:18:07 +00:00
|
|
|
glUploadTex(gl, p->target, p->gl_format, p->gl_type, planes[0],
|
2012-02-24 14:25:22 +00:00
|
|
|
stride[0], 0, 0, w, h, slice);
|
2011-09-25 09:18:07 +00:00
|
|
|
if (p->is_yuv) {
|
|
|
|
int xs, ys;
|
|
|
|
mp_get_chroma_shift(p->image_format, &xs, &ys, NULL);
|
|
|
|
if ((mpi->flags & MP_IMGFLAG_DIRECT) && !(mpi->flags & MP_IMGFLAG_COMMON_PLANE)) {
|
|
|
|
gl->BindBuffer(GL_PIXEL_UNPACK_BUFFER, p->buffer_uv[0]);
|
|
|
|
gl->UnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
|
|
|
|
p->bufferptr_uv[0] = NULL;
|
|
|
|
}
|
|
|
|
gl->ActiveTexture(GL_TEXTURE1);
|
|
|
|
glUploadTex(gl, p->target, p->gl_format, p->gl_type, planes[1],
|
2012-02-24 14:25:22 +00:00
|
|
|
stride[1], 0, 0, w >> xs, h >> ys, slice);
|
2011-09-25 09:18:07 +00:00
|
|
|
if ((mpi->flags & MP_IMGFLAG_DIRECT) && !(mpi->flags & MP_IMGFLAG_COMMON_PLANE)) {
|
|
|
|
gl->BindBuffer(GL_PIXEL_UNPACK_BUFFER, p->buffer_uv[1]);
|
|
|
|
gl->UnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
|
|
|
|
p->bufferptr_uv[1] = NULL;
|
|
|
|
}
|
|
|
|
gl->ActiveTexture(GL_TEXTURE2);
|
|
|
|
glUploadTex(gl, p->target, p->gl_format, p->gl_type, planes[2],
|
2012-02-24 14:25:22 +00:00
|
|
|
stride[2], 0, 0, w >> xs, h >> ys, slice);
|
2011-09-25 09:18:07 +00:00
|
|
|
gl->ActiveTexture(GL_TEXTURE0);
|
2008-11-24 11:04:50 +00:00
|
|
|
}
|
2011-09-25 09:18:07 +00:00
|
|
|
if (mpi->flags & MP_IMGFLAG_DIRECT) {
|
2011-10-23 20:51:00 +00:00
|
|
|
gl->BindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
|
2008-11-24 11:04:50 +00:00
|
|
|
}
|
2008-05-25 11:26:09 +00:00
|
|
|
skip_upload:
|
2012-10-03 14:50:13 +00:00
|
|
|
do_render(vo);
|
2011-09-25 09:18:07 +00:00
|
|
|
return VO_TRUE;
|
2005-07-25 19:11:14 +00:00
|
|
|
}
|
2001-02-24 20:28:24 +00:00
|
|
|
|
2011-10-06 18:46:01 +00:00
|
|
|
static mp_image_t *get_screenshot(struct vo *vo)
|
|
|
|
{
|
|
|
|
struct gl_priv *p = vo->priv;
|
|
|
|
GL *gl = p->gl;
|
|
|
|
|
|
|
|
mp_image_t *image = alloc_mpi(p->texture_width, p->texture_height,
|
|
|
|
p->image_format);
|
|
|
|
|
|
|
|
glDownloadTex(gl, p->target, p->gl_format, p->gl_type, image->planes[0],
|
|
|
|
image->stride[0]);
|
|
|
|
|
|
|
|
if (p->is_yuv) {
|
|
|
|
gl->ActiveTexture(GL_TEXTURE1);
|
|
|
|
glDownloadTex(gl, p->target, p->gl_format, p->gl_type, image->planes[1],
|
|
|
|
image->stride[1]);
|
|
|
|
gl->ActiveTexture(GL_TEXTURE2);
|
|
|
|
glDownloadTex(gl, p->target, p->gl_format, p->gl_type, image->planes[2],
|
|
|
|
image->stride[2]);
|
|
|
|
gl->ActiveTexture(GL_TEXTURE0);
|
|
|
|
}
|
|
|
|
|
|
|
|
image->width = p->image_width;
|
|
|
|
image->height = p->image_height;
|
|
|
|
|
2012-10-20 17:31:44 +00:00
|
|
|
image->w = vo->aspdat.prew;
|
|
|
|
image->h = vo->aspdat.preh;
|
2011-10-06 18:46:01 +00:00
|
|
|
|
2012-10-26 17:29:47 +00:00
|
|
|
mp_image_set_colorspace_details(image, &p->colorspace);
|
|
|
|
|
2011-10-06 18:46:01 +00:00
|
|
|
return image;
|
|
|
|
}
|
|
|
|
|
2011-09-25 09:18:07 +00:00
|
|
|
static int query_format(struct vo *vo, uint32_t format)
|
2001-02-24 20:28:24 +00:00
|
|
|
{
|
2011-09-25 09:18:07 +00:00
|
|
|
struct gl_priv *p = vo->priv;
|
2001-02-24 20:28:24 +00:00
|
|
|
|
2011-05-10 17:51:39 +00:00
|
|
|
int depth;
|
2011-09-25 09:18:07 +00:00
|
|
|
int caps = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_FLIP |
|
2005-07-25 19:11:14 +00:00
|
|
|
VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN | VFCAP_ACCEPT_STRIDE;
|
2011-09-25 09:18:07 +00:00
|
|
|
if (p->use_osd)
|
VO, sub: refactor
Remove VFCTRL_DRAW_OSD, VFCAP_EOSD_FILTER, VFCAP_EOSD_RGBA, VFCAP_EOSD,
VOCTRL_DRAW_EOSD, VOCTRL_GET_EOSD_RES, VOCTRL_QUERY_EOSD_FORMAT.
Remove draw_osd_with_eosd(), which rendered the OSD by calling
VOCTRL_DRAW_EOSD. Change VOs to call osd_draw() directly, which takes
a callback as argument. (This basically works like the old OSD API,
except multiple OSD bitmap formats are supported and caching is
possible.)
Remove all mentions of "eosd". It's simply "osd" now.
Make OSD size per-OSD-object, as they can be different when using
vf_sub. Include display_par/video_par in resolution change detection.
Fix the issue with margin borders in vo_corevideo.
2012-10-19 17:25:18 +00:00
|
|
|
caps |= VFCAP_OSD;
|
2008-12-03 09:27:19 +00:00
|
|
|
if (format == IMGFMT_RGB24 || format == IMGFMT_RGBA)
|
2004-10-08 19:53:11 +00:00
|
|
|
return caps;
|
2011-09-25 09:18:07 +00:00
|
|
|
if (p->use_yuv && mp_get_chroma_shift(format, NULL, NULL, &depth) &&
|
|
|
|
(depth == 8 || depth == 16 || glYUVLargeRange(p->use_yuv)) &&
|
2009-12-31 22:53:25 +00:00
|
|
|
(IMGFMT_IS_YUVP16_NE(format) || !IMGFMT_IS_YUVP16(format)))
|
2005-09-14 22:08:04 +00:00
|
|
|
return caps;
|
2006-08-08 14:56:12 +00:00
|
|
|
// HACK, otherwise we get only b&w with some filters (e.g. -vf eq)
|
|
|
|
// ideally MPlayer should be fixed instead not to use Y800 when it has the choice
|
2011-09-25 09:18:07 +00:00
|
|
|
if (!p->use_yuv && (format == IMGFMT_Y8 || format == IMGFMT_Y800))
|
2006-08-08 14:56:12 +00:00
|
|
|
return 0;
|
2011-09-25 09:18:07 +00:00
|
|
|
if (!p->use_ycbcr && (format == IMGFMT_UYVY || format == IMGFMT_YVYU))
|
2008-12-05 15:36:54 +00:00
|
|
|
return 0;
|
2011-09-25 09:18:07 +00:00
|
|
|
if (p->many_fmts &&
|
2011-11-08 19:21:00 +00:00
|
|
|
glFindFormat(format, p->have_texture_rg, NULL, NULL, NULL, NULL))
|
2004-10-08 19:53:11 +00:00
|
|
|
return caps;
|
2001-02-24 20:28:24 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-09-25 09:18:07 +00:00
|
|
|
static void uninit(struct vo *vo)
|
2001-02-24 20:28:24 +00:00
|
|
|
{
|
2011-09-25 09:18:07 +00:00
|
|
|
struct gl_priv *p = vo->priv;
|
|
|
|
|
2012-10-02 23:54:13 +00:00
|
|
|
uninitGl(vo);
|
2011-09-25 09:18:07 +00:00
|
|
|
free(p->custom_prog);
|
|
|
|
p->custom_prog = NULL;
|
|
|
|
free(p->custom_tex);
|
|
|
|
p->custom_tex = NULL;
|
2012-10-02 23:54:13 +00:00
|
|
|
mpgl_uninit(p->glctx);
|
2011-09-25 09:18:07 +00:00
|
|
|
p->glctx = NULL;
|
|
|
|
p->gl = NULL;
|
2001-02-24 20:28:24 +00:00
|
|
|
}
|
2002-01-26 16:01:26 +00:00
|
|
|
|
2011-12-18 19:02:31 +00:00
|
|
|
static int backend_valid(void *arg)
|
|
|
|
{
|
|
|
|
return mpgl_find_backend(*(const char **)arg) >= 0;
|
|
|
|
}
|
|
|
|
|
2012-04-23 22:48:14 +00:00
|
|
|
static int preinit(struct vo *vo, const char *arg)
|
2002-01-26 16:01:26 +00:00
|
|
|
{
|
2011-09-25 09:18:07 +00:00
|
|
|
struct gl_priv *p = talloc_zero(vo, struct gl_priv);
|
|
|
|
vo->priv = p;
|
|
|
|
|
|
|
|
*p = (struct gl_priv) {
|
|
|
|
.many_fmts = 1,
|
|
|
|
.use_osd = -1,
|
|
|
|
.use_yuv = -1,
|
|
|
|
.colorspace = MP_CSP_DETAILS_DEFAULTS,
|
|
|
|
.filter_strength = 0.5,
|
|
|
|
.use_rectangle = -1,
|
|
|
|
.ati_hack = -1,
|
|
|
|
.force_pbo = -1,
|
2012-07-29 17:04:27 +00:00
|
|
|
.swap_interval = vo_vsync,
|
2011-09-25 09:18:07 +00:00
|
|
|
.custom_prog = NULL,
|
|
|
|
.custom_tex = NULL,
|
|
|
|
.custom_tlin = 1,
|
|
|
|
.osd_color = 0xffffff,
|
|
|
|
};
|
|
|
|
|
2012-04-23 22:48:14 +00:00
|
|
|
char *backend_arg = NULL;
|
|
|
|
|
2011-09-25 09:18:07 +00:00
|
|
|
//essentially unused; for legacy warnings only
|
|
|
|
int user_colorspace = 0;
|
|
|
|
int levelconv = -1;
|
2011-09-29 17:01:41 +00:00
|
|
|
int aspect = -1;
|
2011-09-25 09:18:07 +00:00
|
|
|
|
|
|
|
const opt_t subopts[] = {
|
|
|
|
{"manyfmts", OPT_ARG_BOOL, &p->many_fmts, NULL},
|
|
|
|
{"osd", OPT_ARG_BOOL, &p->use_osd, NULL},
|
|
|
|
{"scaled-osd", OPT_ARG_BOOL, &p->scaled_osd, NULL},
|
|
|
|
{"ycbcr", OPT_ARG_BOOL, &p->use_ycbcr, NULL},
|
|
|
|
{"slice-height", OPT_ARG_INT, &p->slice_height, int_non_neg},
|
|
|
|
{"rectangle", OPT_ARG_INT, &p->use_rectangle,int_non_neg},
|
|
|
|
{"yuv", OPT_ARG_INT, &p->use_yuv, int_non_neg},
|
|
|
|
{"lscale", OPT_ARG_INT, &p->lscale, int_non_neg},
|
|
|
|
{"cscale", OPT_ARG_INT, &p->cscale, int_non_neg},
|
|
|
|
{"filter-strength", OPT_ARG_FLOAT, &p->filter_strength, NULL},
|
2011-08-26 18:51:51 +00:00
|
|
|
{"noise-strength", OPT_ARG_FLOAT, &p->noise_strength, NULL},
|
2011-09-25 09:18:07 +00:00
|
|
|
{"ati-hack", OPT_ARG_BOOL, &p->ati_hack, NULL},
|
|
|
|
{"force-pbo", OPT_ARG_BOOL, &p->force_pbo, NULL},
|
|
|
|
{"glfinish", OPT_ARG_BOOL, &p->use_glFinish, NULL},
|
|
|
|
{"swapinterval", OPT_ARG_INT, &p->swap_interval,NULL},
|
|
|
|
{"customprog", OPT_ARG_MSTRZ,&p->custom_prog, NULL},
|
|
|
|
{"customtex", OPT_ARG_MSTRZ,&p->custom_tex, NULL},
|
|
|
|
{"customtlin", OPT_ARG_BOOL, &p->custom_tlin, NULL},
|
|
|
|
{"customtrect", OPT_ARG_BOOL, &p->custom_trect, NULL},
|
|
|
|
{"mipmapgen", OPT_ARG_BOOL, &p->mipmap_gen, NULL},
|
|
|
|
{"osdcolor", OPT_ARG_INT, &p->osd_color, NULL},
|
|
|
|
{"stereo", OPT_ARG_INT, &p->stereo_mode, NULL},
|
2012-10-02 23:54:13 +00:00
|
|
|
{"sw", OPT_ARG_BOOL, &p->allow_sw, NULL},
|
2011-12-18 19:02:31 +00:00
|
|
|
{"backend", OPT_ARG_MSTRZ,&backend_arg, backend_valid},
|
2011-09-29 17:01:41 +00:00
|
|
|
// Removed options.
|
|
|
|
// They are only parsed to notify the user about the replacements.
|
|
|
|
{"aspect", OPT_ARG_BOOL, &aspect, NULL},
|
|
|
|
{"colorspace", OPT_ARG_INT, &user_colorspace, NULL},
|
|
|
|
{"levelconv", OPT_ARG_INT, &levelconv, NULL},
|
2011-09-25 09:18:07 +00:00
|
|
|
{NULL}
|
|
|
|
};
|
|
|
|
|
2004-12-31 14:58:49 +00:00
|
|
|
if (subopt_parse(arg, subopts) != 0) {
|
2011-09-25 09:18:07 +00:00
|
|
|
mp_msg(MSGT_VO, MSGL_FATAL,
|
2012-09-23 14:10:00 +00:00
|
|
|
"\n-vo opengl_old command line help:\n"
|
2012-10-11 00:04:08 +00:00
|
|
|
"Example: mpv -vo opengl_old:slice-height=4\n"
|
2011-09-25 09:18:07 +00:00
|
|
|
"\nOptions:\n"
|
|
|
|
" nomanyfmts\n"
|
|
|
|
" Disable extended color formats for OpenGL 1.2 and later\n"
|
|
|
|
" slice-height=<0-...>\n"
|
|
|
|
" Slice size for texture transfer, 0 for whole image\n"
|
|
|
|
" noosd\n"
|
|
|
|
" Do not use OpenGL OSD code\n"
|
|
|
|
" scaled-osd\n"
|
|
|
|
" Render OSD at movie resolution and scale it\n"
|
|
|
|
" rectangle=<0,1,2>\n"
|
|
|
|
" 0: use power-of-two textures\n"
|
|
|
|
" 1: use texture_rectangle\n"
|
|
|
|
" 2: use texture_non_power_of_two\n"
|
|
|
|
" ati-hack\n"
|
|
|
|
" Workaround ATI bug with PBOs\n"
|
|
|
|
" force-pbo\n"
|
|
|
|
" Force use of PBO even if this involves an extra memcpy\n"
|
|
|
|
" glfinish\n"
|
|
|
|
" Call glFinish() before swapping buffers\n"
|
|
|
|
" swapinterval=<n>\n"
|
|
|
|
" Interval in displayed frames between to buffer swaps.\n"
|
|
|
|
" 1 is equivalent to enable VSYNC, 0 to disable VSYNC.\n"
|
|
|
|
" Requires GLX_SGI_swap_control support to work.\n"
|
|
|
|
" ycbcr\n"
|
|
|
|
" also try to use the GL_MESA_ycbcr_texture extension\n"
|
|
|
|
" yuv=<n>\n"
|
|
|
|
" 0: use software YUV to RGB conversion.\n"
|
2011-10-23 22:43:12 +00:00
|
|
|
" 1: deprecated, will use yuv=2 (used to be nVidia register combiners).\n"
|
2011-09-25 09:18:07 +00:00
|
|
|
" 2: use fragment program.\n"
|
|
|
|
" 3: use fragment program with gamma correction.\n"
|
|
|
|
" 4: use fragment program with gamma correction via lookup.\n"
|
|
|
|
" 5: use ATI-specific method (for older cards).\n"
|
|
|
|
" 6: use lookup via 3D texture.\n"
|
|
|
|
" lscale=<n>\n"
|
|
|
|
" 0: use standard bilinear scaling for luma.\n"
|
|
|
|
" 1: use improved bicubic scaling for luma.\n"
|
|
|
|
" 2: use cubic in X, linear in Y direction scaling for luma.\n"
|
|
|
|
" 3: as 1 but without using a lookup texture.\n"
|
|
|
|
" 4: experimental unsharp masking (sharpening).\n"
|
|
|
|
" 5: experimental unsharp masking (sharpening) with larger radius.\n"
|
|
|
|
" cscale=<n>\n"
|
|
|
|
" as lscale but for chroma (2x slower with little visible effect).\n"
|
|
|
|
" filter-strength=<value>\n"
|
|
|
|
" set the effect strength for some lscale/cscale filters\n"
|
2011-08-26 18:51:51 +00:00
|
|
|
" noise-strength=<value>\n"
|
|
|
|
" set how much noise to add. 1.0 is suitable for dithering to 6 bit.\n"
|
2011-09-25 09:18:07 +00:00
|
|
|
" customprog=<filename>\n"
|
|
|
|
" use a custom YUV conversion program\n"
|
|
|
|
" customtex=<filename>\n"
|
|
|
|
" use a custom YUV conversion lookup texture\n"
|
|
|
|
" nocustomtlin\n"
|
|
|
|
" use GL_NEAREST scaling for customtex texture\n"
|
|
|
|
" customtrect\n"
|
|
|
|
" use texture_rectangle for customtex texture\n"
|
|
|
|
" mipmapgen\n"
|
|
|
|
" generate mipmaps for the video image (use with TXB in customprog)\n"
|
|
|
|
" osdcolor=<0xAARRGGBB>\n"
|
|
|
|
" use the given color for the OSD\n"
|
|
|
|
" stereo=<n>\n"
|
|
|
|
" 0: normal display\n"
|
|
|
|
" 1: side-by-side to red-cyan stereo\n"
|
|
|
|
" 2: side-by-side to green-magenta stereo\n"
|
|
|
|
" 3: side-by-side to quadbuffer stereo\n"
|
2012-04-23 22:48:14 +00:00
|
|
|
" sw\n"
|
|
|
|
" allow using a software renderer, if such is detected\n"
|
2011-12-18 19:02:31 +00:00
|
|
|
" backend=<sys>\n"
|
|
|
|
" auto: auto-select (default)\n"
|
|
|
|
" cocoa: Cocoa/OSX\n"
|
|
|
|
" win: Win32/WGL\n"
|
|
|
|
" x11: X11/GLX\n"
|
2011-09-25 09:18:07 +00:00
|
|
|
"\n");
|
|
|
|
return -1;
|
2004-04-15 18:19:39 +00:00
|
|
|
}
|
video, options: implement better YUV->RGB conversion control
Rewrite control of the colorspace and input/output level parameters
used in YUV-RGB conversions, replacing VO-specific suboptions with new
common options and adding configuration support to more cases.
Add new option --colormatrix which selects the colorspace the original
video is assumed to have in YUV->RGB conversions. The default
behavior changes from assuming BT.601 to colorspace autoselection
between BT.601 and BT.709 using a simple heuristic based on video
size. Add new options --colormatrix-input-range and
--colormatrix-output-range which select input YUV and output RGB range.
Disable the previously existing VO-specific colorspace and level
conversion suboptions in vo_gl and vo_vdpau. Remove the
"yuv_colorspace" property and replace it with one named "colormatrix"
and semantics matching the new option. Add new properties matching the
options for level conversion.
Colorspace selection is currently supported by vo_gl, vo_vdpau, vo_xv
and vf_scale, and all can change it at runtime (previously only
vo_vdpau and vo_xv could). vo_vdpau now uses the same conversion
matrix generation as vo_gl instead of libvdpau functionality; the main
functional difference is that the "contrast" equalizer control behaves
somewhat differently (it scales the Y component around 1/2 instead of
around 0, so that contrast 0 makes the image gray rather than black).
vo_xv does not support level conversion. vf_scale supports range
setting for input, but always outputs full-range RGB.
The value of the slave properties is the policy setting used for
conversions. This means they can be set to any value regardless of
whether the current VO supports that value or whether there currently
even is any video. Possibly separate properties could be added to
query the conversion actually used at the moment, if any.
Because the colorspace and level settings are now set with a single
VF/VO control call, the return value of that is no longer used to
signal whether all the settings are actually supported. Instead code
should set all the details it can support, and ignore the rest. The
core will use GET_YUV_COLORSPACE to check which colorspace details
have been set and which not. In other words, the return value for
SET_YUV_COLORSPACE only signals whether any kind of YUV colorspace
conversion handling exists at all, and VOs have to take care to return
the actual state with GET_YUV_COLORSPACE instead.
To be changed in later commits: add missing option documentation.
2011-10-15 21:50:21 +00:00
|
|
|
if (user_colorspace != 0 || levelconv != -1) {
|
2011-09-25 09:18:07 +00:00
|
|
|
mp_msg(MSGT_VO, MSGL_ERR, "[gl] \"colorspace\" and \"levelconv\" "
|
|
|
|
"suboptions have been removed. Use options --colormatrix and"
|
|
|
|
" --colormatrix-input-range/--colormatrix-output-range instead.\n");
|
|
|
|
return -1;
|
video, options: implement better YUV->RGB conversion control
Rewrite control of the colorspace and input/output level parameters
used in YUV-RGB conversions, replacing VO-specific suboptions with new
common options and adding configuration support to more cases.
Add new option --colormatrix which selects the colorspace the original
video is assumed to have in YUV->RGB conversions. The default
behavior changes from assuming BT.601 to colorspace autoselection
between BT.601 and BT.709 using a simple heuristic based on video
size. Add new options --colormatrix-input-range and
--colormatrix-output-range which select input YUV and output RGB range.
Disable the previously existing VO-specific colorspace and level
conversion suboptions in vo_gl and vo_vdpau. Remove the
"yuv_colorspace" property and replace it with one named "colormatrix"
and semantics matching the new option. Add new properties matching the
options for level conversion.
Colorspace selection is currently supported by vo_gl, vo_vdpau, vo_xv
and vf_scale, and all can change it at runtime (previously only
vo_vdpau and vo_xv could). vo_vdpau now uses the same conversion
matrix generation as vo_gl instead of libvdpau functionality; the main
functional difference is that the "contrast" equalizer control behaves
somewhat differently (it scales the Y component around 1/2 instead of
around 0, so that contrast 0 makes the image gray rather than black).
vo_xv does not support level conversion. vf_scale supports range
setting for input, but always outputs full-range RGB.
The value of the slave properties is the policy setting used for
conversions. This means they can be set to any value regardless of
whether the current VO supports that value or whether there currently
even is any video. Possibly separate properties could be added to
query the conversion actually used at the moment, if any.
Because the colorspace and level settings are now set with a single
VF/VO control call, the return value of that is no longer used to
signal whether all the settings are actually supported. Instead code
should set all the details it can support, and ignore the rest. The
core will use GET_YUV_COLORSPACE to check which colorspace details
have been set and which not. In other words, the return value for
SET_YUV_COLORSPACE only signals whether any kind of YUV colorspace
conversion handling exists at all, and VOs have to take care to return
the actual state with GET_YUV_COLORSPACE instead.
To be changed in later commits: add missing option documentation.
2011-10-15 21:50:21 +00:00
|
|
|
}
|
2011-09-29 17:01:41 +00:00
|
|
|
if (aspect != -1) {
|
|
|
|
mp_msg(MSGT_VO, MSGL_ERR, "[gl] \"noaspect\" suboption has been "
|
|
|
|
"removed. Use --noaspect instead.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
2011-10-23 22:43:12 +00:00
|
|
|
if (p->use_yuv == 1) {
|
|
|
|
mp_msg(MSGT_VO, MSGL_WARN, "[gl] yuv=1 (nVidia register combiners) have"
|
|
|
|
" been removed, using yuv=2 instead.\n");
|
|
|
|
p->use_yuv = 2;
|
|
|
|
}
|
2011-12-18 19:02:31 +00:00
|
|
|
|
|
|
|
int backend = backend_arg ? mpgl_find_backend(backend_arg) : GLTYPE_AUTO;
|
|
|
|
free(backend_arg);
|
|
|
|
|
2012-10-02 23:54:13 +00:00
|
|
|
p->glctx = mpgl_init(backend, vo);
|
2011-09-25 09:18:07 +00:00
|
|
|
if (!p->glctx)
|
2010-02-02 20:37:48 +00:00
|
|
|
goto err_out;
|
2011-09-25 09:18:07 +00:00
|
|
|
p->gl = p->glctx->gl;
|
2011-09-29 20:20:46 +00:00
|
|
|
|
2012-10-02 23:54:13 +00:00
|
|
|
if (p->use_yuv == -1) {
|
|
|
|
if (!create_window(vo, 320, 200, VOFLAG_HIDDEN))
|
2011-09-25 09:18:07 +00:00
|
|
|
goto err_out;
|
|
|
|
autodetectGlExtensions(vo);
|
|
|
|
// We created a window to test whether the GL context supports hardware
|
|
|
|
// acceleration and so on. Destroy that window to make sure all state
|
|
|
|
// associated with it is lost.
|
2012-10-02 23:54:13 +00:00
|
|
|
uninitGl(vo);
|
|
|
|
if (!mpgl_destroy_window(p->glctx))
|
2011-09-25 09:18:07 +00:00
|
|
|
goto err_out;
|
2010-02-02 20:37:48 +00:00
|
|
|
}
|
2011-09-25 09:18:07 +00:00
|
|
|
if (p->many_fmts)
|
|
|
|
mp_msg(MSGT_VO, MSGL_INFO, "[gl] using extended formats. "
|
2010-02-05 07:12:05 +00:00
|
|
|
"Use -vo gl:nomanyfmts if playback fails.\n");
|
|
|
|
mp_msg(MSGT_VO, MSGL_V, "[gl] Using %d as slice height "
|
2011-09-25 09:18:07 +00:00
|
|
|
"(0 means image height).\n", p->slice_height);
|
2002-10-17 09:49:25 +00:00
|
|
|
|
2002-02-17 08:24:43 +00:00
|
|
|
return 0;
|
2010-02-02 20:37:48 +00:00
|
|
|
|
|
|
|
err_out:
|
2011-09-25 09:18:07 +00:00
|
|
|
uninit(vo);
|
2010-02-02 20:37:48 +00:00
|
|
|
return -1;
|
2002-01-26 16:01:26 +00:00
|
|
|
}
|
|
|
|
|
2011-09-25 09:18:07 +00:00
|
|
|
static int control(struct vo *vo, uint32_t request, void *data)
|
2002-01-26 16:01:26 +00:00
|
|
|
{
|
2011-09-25 09:18:07 +00:00
|
|
|
struct gl_priv *p = vo->priv;
|
|
|
|
|
|
|
|
switch (request) {
|
|
|
|
case VOCTRL_QUERY_FORMAT:
|
|
|
|
return query_format(vo, *(uint32_t *)data);
|
|
|
|
case VOCTRL_DRAW_IMAGE:
|
|
|
|
return draw_image(vo, data);
|
|
|
|
case VOCTRL_ONTOP:
|
2011-10-24 02:51:24 +00:00
|
|
|
if (!p->glctx->ontop)
|
|
|
|
break;
|
2011-09-25 09:18:07 +00:00
|
|
|
p->glctx->ontop(vo);
|
|
|
|
return VO_TRUE;
|
|
|
|
case VOCTRL_FULLSCREEN:
|
|
|
|
p->glctx->fullscreen(vo);
|
|
|
|
resize(vo, vo->dwidth, vo->dheight);
|
|
|
|
return VO_TRUE;
|
|
|
|
case VOCTRL_BORDER:
|
2011-10-24 02:51:24 +00:00
|
|
|
if (!p->glctx->border)
|
|
|
|
break;
|
2011-09-25 09:18:07 +00:00
|
|
|
p->glctx->border(vo);
|
|
|
|
resize(vo, vo->dwidth, vo->dheight);
|
|
|
|
return VO_TRUE;
|
|
|
|
case VOCTRL_GET_PANSCAN:
|
|
|
|
return VO_TRUE;
|
|
|
|
case VOCTRL_SET_PANSCAN:
|
|
|
|
resize(vo, vo->dwidth, vo->dheight);
|
|
|
|
return VO_TRUE;
|
|
|
|
case VOCTRL_GET_EQUALIZER:
|
|
|
|
if (p->is_yuv) {
|
|
|
|
struct voctrl_get_equalizer_args *args = data;
|
|
|
|
return mp_csp_equalizer_get(&p->video_eq, args->name, args->valueptr)
|
|
|
|
>= 0 ? VO_TRUE : VO_NOTIMPL;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case VOCTRL_SET_EQUALIZER:
|
|
|
|
if (p->is_yuv) {
|
|
|
|
struct voctrl_set_equalizer_args *args = data;
|
|
|
|
if (mp_csp_equalizer_set(&p->video_eq, args->name, args->value) < 0)
|
|
|
|
return VO_NOTIMPL;
|
|
|
|
update_yuvconv(vo);
|
2011-12-05 04:36:20 +00:00
|
|
|
vo->want_redraw = true;
|
2011-09-25 09:18:07 +00:00
|
|
|
return VO_TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case VOCTRL_SET_YUV_COLORSPACE: {
|
|
|
|
bool supports_csp = (1 << p->use_yuv) & MASK_NOT_COMBINERS;
|
|
|
|
if (vo->config_count && supports_csp) {
|
|
|
|
p->colorspace = *(struct mp_csp_details *)data;
|
|
|
|
update_yuvconv(vo);
|
2011-12-05 04:36:20 +00:00
|
|
|
vo->want_redraw = true;
|
2011-09-25 09:18:07 +00:00
|
|
|
}
|
|
|
|
return VO_TRUE;
|
2005-09-14 22:08:04 +00:00
|
|
|
}
|
2011-09-25 09:18:07 +00:00
|
|
|
case VOCTRL_GET_YUV_COLORSPACE:
|
|
|
|
*(struct mp_csp_details *)data = p->colorspace;
|
|
|
|
return VO_TRUE;
|
|
|
|
case VOCTRL_UPDATE_SCREENINFO:
|
2011-10-24 02:51:24 +00:00
|
|
|
if (!p->glctx->update_xinerama_info)
|
|
|
|
break;
|
2011-09-25 09:18:07 +00:00
|
|
|
p->glctx->update_xinerama_info(vo);
|
|
|
|
return VO_TRUE;
|
2011-12-05 03:24:18 +00:00
|
|
|
case VOCTRL_REDRAW_FRAME:
|
2012-10-03 14:50:13 +00:00
|
|
|
do_render(vo);
|
2011-12-05 03:24:18 +00:00
|
|
|
return true;
|
2012-09-16 18:53:04 +00:00
|
|
|
case VOCTRL_PAUSE:
|
|
|
|
if (!p->glctx->pause)
|
|
|
|
break;
|
|
|
|
p->glctx->pause(vo);
|
|
|
|
return VO_TRUE;
|
|
|
|
case VOCTRL_RESUME:
|
|
|
|
if (!p->glctx->resume)
|
|
|
|
break;
|
|
|
|
p->glctx->resume(vo);
|
|
|
|
return VO_TRUE;
|
2011-10-06 18:46:01 +00:00
|
|
|
case VOCTRL_SCREENSHOT: {
|
|
|
|
struct voctrl_screenshot_args *args = data;
|
|
|
|
if (args->full_window)
|
2012-10-21 14:25:42 +00:00
|
|
|
args->out_image = glGetWindowScreenshot(p->gl);
|
2011-10-06 18:46:01 +00:00
|
|
|
else
|
|
|
|
args->out_image = get_screenshot(vo);
|
|
|
|
return true;
|
|
|
|
}
|
video, options: implement better YUV->RGB conversion control
Rewrite control of the colorspace and input/output level parameters
used in YUV-RGB conversions, replacing VO-specific suboptions with new
common options and adding configuration support to more cases.
Add new option --colormatrix which selects the colorspace the original
video is assumed to have in YUV->RGB conversions. The default
behavior changes from assuming BT.601 to colorspace autoselection
between BT.601 and BT.709 using a simple heuristic based on video
size. Add new options --colormatrix-input-range and
--colormatrix-output-range which select input YUV and output RGB range.
Disable the previously existing VO-specific colorspace and level
conversion suboptions in vo_gl and vo_vdpau. Remove the
"yuv_colorspace" property and replace it with one named "colormatrix"
and semantics matching the new option. Add new properties matching the
options for level conversion.
Colorspace selection is currently supported by vo_gl, vo_vdpau, vo_xv
and vf_scale, and all can change it at runtime (previously only
vo_vdpau and vo_xv could). vo_vdpau now uses the same conversion
matrix generation as vo_gl instead of libvdpau functionality; the main
functional difference is that the "contrast" equalizer control behaves
somewhat differently (it scales the Y component around 1/2 instead of
around 0, so that contrast 0 makes the image gray rather than black).
vo_xv does not support level conversion. vf_scale supports range
setting for input, but always outputs full-range RGB.
The value of the slave properties is the policy setting used for
conversions. This means they can be set to any value regardless of
whether the current VO supports that value or whether there currently
even is any video. Possibly separate properties could be added to
query the conversion actually used at the moment, if any.
Because the colorspace and level settings are now set with a single
VF/VO control call, the return value of that is no longer used to
signal whether all the settings are actually supported. Instead code
should set all the details it can support, and ignore the rest. The
core will use GET_YUV_COLORSPACE to check which colorspace details
have been set and which not. In other words, the return value for
SET_YUV_COLORSPACE only signals whether any kind of YUV colorspace
conversion handling exists at all, and VOs have to take care to return
the actual state with GET_YUV_COLORSPACE instead.
To be changed in later commits: add missing option documentation.
2011-10-15 21:50:21 +00:00
|
|
|
}
|
2011-09-25 09:18:07 +00:00
|
|
|
return VO_NOTIMPL;
|
2002-01-26 16:01:26 +00:00
|
|
|
}
|
2011-09-25 09:18:07 +00:00
|
|
|
|
2012-09-23 14:10:00 +00:00
|
|
|
const struct vo_driver video_out_opengl_old = {
|
2011-09-25 09:18:07 +00:00
|
|
|
.is_new = true,
|
|
|
|
.info = &(const vo_info_t) {
|
|
|
|
"OpenGL",
|
2012-09-23 14:10:00 +00:00
|
|
|
"opengl-old",
|
2011-09-25 09:18:07 +00:00
|
|
|
"Reimar Doeffinger <Reimar.Doeffinger@gmx.de>",
|
|
|
|
""
|
|
|
|
},
|
2012-04-23 22:48:14 +00:00
|
|
|
.preinit = preinit,
|
2011-09-25 09:18:07 +00:00
|
|
|
.config = config,
|
|
|
|
.control = control,
|
|
|
|
.draw_slice = draw_slice,
|
VO, sub: refactor
Remove VFCTRL_DRAW_OSD, VFCAP_EOSD_FILTER, VFCAP_EOSD_RGBA, VFCAP_EOSD,
VOCTRL_DRAW_EOSD, VOCTRL_GET_EOSD_RES, VOCTRL_QUERY_EOSD_FORMAT.
Remove draw_osd_with_eosd(), which rendered the OSD by calling
VOCTRL_DRAW_EOSD. Change VOs to call osd_draw() directly, which takes
a callback as argument. (This basically works like the old OSD API,
except multiple OSD bitmap formats are supported and caching is
possible.)
Remove all mentions of "eosd". It's simply "osd" now.
Make OSD size per-OSD-object, as they can be different when using
vf_sub. Include display_par/video_par in resolution change detection.
Fix the issue with margin borders in vo_corevideo.
2012-10-19 17:25:18 +00:00
|
|
|
.draw_osd = draw_osd,
|
2011-09-25 09:18:07 +00:00
|
|
|
.flip_page = flip_page,
|
|
|
|
.check_events = check_events,
|
|
|
|
.uninit = uninit,
|
|
|
|
};
|