summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-01-20 21:15:04 +0100
committerwm4 <wm4@nowhere>2015-01-20 21:15:04 +0100
commit724f722d7f284076e717d59c8565b7ed27dadae3 (patch)
treeb388e76fa14ba356a4cd96d842ad0617a9c4568f
parent21322a016e74ddf20cffaab5d621db1cf694eaa5 (diff)
downloadmpv-724f722d7f284076e717d59c8565b7ed27dadae3.tar.bz2
mpv-724f722d7f284076e717d59c8565b7ed27dadae3.tar.xz
vo_opengl_old: remove this VO
At this point, there is probably no hardware left that doesn't do OpenGL 2.1, and at the same time is fast enough to handle video.
-rw-r--r--DOCS/man/vo.rst181
-rw-r--r--old-makefile4
-rw-r--r--video/out/gl_common.c2
-rw-r--r--video/out/pnm_loader.c97
-rw-r--r--video/out/pnm_loader.h52
-rw-r--r--video/out/vo.c4
-rw-r--r--video/out/vo_opengl_old.c2167
-rw-r--r--wscript_build.py2
8 files changed, 2 insertions, 2507 deletions
diff --git a/DOCS/man/vo.rst b/DOCS/man/vo.rst
index d56dec4caf..4d97a281c0 100644
--- a/DOCS/man/vo.rst
+++ b/DOCS/man/vo.rst
@@ -278,8 +278,7 @@ Available video output drivers are:
``opengl-hq`` to use this driver with defaults set to high quality
rendering.
- Requires at least OpenGL 2.1 and the ``GL_ARB_texture_rg`` extension. For
- older drivers, ``opengl-old`` may work.
+ Requires at least OpenGL 2.1.
Some features are available with OpenGL 3 capable graphics drivers only
(or if the necessary extensions are available).
@@ -624,184 +623,6 @@ Available video output drivers are:
float texture support, and some OS X setups being very slow with ``rgb16``
but fast with ``rgb32f``.
-``opengl-old``
- OpenGL video output driver, old version. Video size must be smaller
- than the maximum texture size of your OpenGL implementation. Intended to
- work even with the most basic OpenGL implementations, but also makes use
- of newer extensions which allow support for more color spaces.
-
- The code performs very few checks, so if a feature does not work, this
- might be because it is not supported by your card and/or OpenGL
- implementation, even if you do not get any error message. Use ``glxinfo``
- or a similar tool to display the supported OpenGL extensions.
-
- .. note:: This driver is for compatibility with old systems.
-
- ``(no-)ati-hack``
- ATI drivers may give a corrupted image when PBOs are used (when using
- ``force-pbo``). This option fixes this, at the expense of using a bit
- more memory.
- ``(no-)force-pbo``
- Always uses PBOs to transfer textures even if this involves an extra
- copy. Currently this gives a little extra speed with NVIDIA drivers
- and a lot more speed with ATI drivers. May need the ``ati-hack``
- suboption to work correctly.
- ``(no-)scaled-osd``
- Scales the OSD and subtitles instead of rendering them at display size
- (default: disabled).
- ``rectangle=<0,1,2>``
- Select usage of rectangular textures, which saves video RAM, but often
- is slower (default: 0).
-
- 0
- Use power-of-two textures (default).
- 1
- Use the ``GL_ARB_texture_rectangle`` extension.
- 2
- Use the ``GL_ARB_texture_non_power_of_two`` extension. In some
- cases only supported in software and thus very slow.
-
- ``swapinterval=<n>``
- Minimum interval between two buffer swaps, counted in displayed frames
- (default: 1). 1 is equivalent to enabling VSYNC, 0 to disabling VSYNC.
- Values below 0 will leave it at the system default. This limits the
- framerate to (horizontal refresh rate / n). Requires
- ``GLX_SGI_swap_control`` support to work. With some (most/all?)
- implementations this only works in fullscreen mode.
- ``ycbcr``
- Use the ``GL_MESA_ycbcr_texture`` extension to convert YUV to RGB. In
- most cases this is probably slower than doing software conversion to
- RGB.
- ``yuv=<n>``
- Select the type of YUV to RGB conversion. The default is
- auto-detection deciding between values 0 and 2.
-
- 0
- Use software conversion. Compatible with all OpenGL versions.
- Provides brightness, contrast and saturation control.
- 1
- Same as 2. This used to use NVIDIA-specific extensions, which
- did not provide any advantages over using fragment programs, except
- possibly on very ancient graphics cards. It produced a gray-ish
- output, which is why it has been removed.
- 2
- Use a fragment program. Needs the ``GL_ARB_fragment_program``
- extension and at least three texture units. Provides brightness,
- contrast, saturation and hue control.
- 3
- Use a fragment program using the ``POW`` instruction. Needs the
- ``GL_ARB_fragment_program`` extension and at least three texture
- units. Provides brightness, contrast, saturation, hue and gamma
- control. Gamma can also be set independently for red, green and
- blue. Method 4 is usually faster.
- 4
- Use a fragment program with additional lookup. Needs the
- ``GL_ARB_fragment_program`` extension and at least four texture
- units. Provides brightness, contrast, saturation, hue and gamma
- control. Gamma can also be set independently for red, green and
- blue.
- 5
- Removed. Used ATI-specific method (for older cards).
- 6
- Use a 3D texture to do conversion via lookup. Needs the
- ``GL_ARB_fragment_program extension`` and at least four texture
- units. Extremely slow (software emulation) on some (all?) ATI
- cards since it uses a texture with border pixels. Provides
- brightness, contrast, saturation, hue and gamma control. Gamma can
- also be set independently for red, green and blue. Speed depends
- more on GPU memory bandwidth than other methods.
-
- ``lscale=<n>``
- Select the scaling function to use for luminance scaling. Only valid
- for yuv modes 2, 3, 4 and 6.
-
- 0
- Use simple linear filtering (default).
- 1
- Use bicubic B-spline filtering (better quality). Needs one
- additional texture unit. Older cards will not be able to handle
- this for chroma at least in fullscreen mode.
- 2
- Use cubic filtering in horizontal, linear filtering in vertical
- direction. Works on a few more cards than method 1.
- 3
- Same as 1 but does not use a lookup texture. Might be faster on
- some cards.
- 4
- Use experimental unsharp masking with 3x3 support and a default
- strength of 0.5 (see ``filter-strength``).
- 5
- Use experimental unsharp masking with 5x5 support and a default
- strength of 0.5 (see ``filter-strength``).
-
- ``cscale=<n>``
- Select the scaling function to use for chrominance scaling. For
- details see ``lscale``.
- ``filter-strength=<value>``
- Set the effect strength for the ``lscale``/``cscale`` filters that
- support it.
- ``stereo=<value>``
- Select a method for stereo display. You may have to use
- ``--video-aspect`` to fix the aspect value. Experimental, do not expect
- too much from it.
-
- 0
- Normal 2D display
- 1
- Convert side by side input to full-color red-cyan stereo.
- 2
- Convert side by side input to full-color green-magenta stereo.
- 3
- Convert side by side input to quad buffered stereo. Only supported
- by very few OpenGL cards.
-
- The following options are only useful if writing your own fragment programs.
-
- ``customprog=<filename>``
- Load a custom fragment program from ``<filename>``.
- ``customtex=<filename>``
- Load a custom "gamma ramp" texture from ``<filename>``. This can be used
- in combination with ``yuv=4`` or with the ``customprog`` option.
- ``(no-)customtlin``
- If enabled (default) use ``GL_LINEAR`` interpolation, otherwise use
- ``GL_NEAREST`` for customtex texture.
- ``(no-)customtrect``
- If enabled, use ``texture_rectangle`` for the ``customtex`` texture.
- Default is disabled.
- ``(no-)mipmapgen``
- If enabled, mipmaps for the video are automatically generated. This
- should be useful together with the ``customprog`` and the ``TXB``
- instruction to implement blur filters with a large radius. For most
- OpenGL implementations, this is very slow for any non-RGB formats.
- Default is disabled.
-
- Normally there is no reason to use the following options; they mostly
- exist for testing purposes.
-
- ``(no-)glfinish``
- Call ``glFinish()`` before swapping buffers. Slower but in some cases
- more correct output (default: disabled).
- ``(no-)manyfmts``
- Enables support for more (RGB and BGR) color formats (default: enabled).
- Needs OpenGL version >= 1.2.
- ``slice-height=<0-...>``
- Number of lines copied to texture in one piece (default: 0). 0 for
- whole image.
- ``sw``
- Continue even if a software renderer is detected.
-
- ``backend=<sys>``
- auto
- auto-select (default)
- cocoa
- Cocoa/OS X
- win
- Win32/WGL
- x11
- X11/GLX
- wayland
- Wayland/EGL
-
``sdl``
SDL 2.0+ Render video output driver, depending on system with or without
hardware acceleration. Should work on all platforms supported by SDL 2.0.
diff --git a/old-makefile b/old-makefile
index b3c97babe3..2d899ca7e2 100644
--- a/old-makefile
+++ b/old-makefile
@@ -63,9 +63,7 @@ SOURCES-$(GL) += video/out/gl_common.c video/out/gl_osd.c \
video/out/vo_opengl.c video/out/gl_lcms.c \
video/out/gl_video.c video/out/dither.c \
video/out/gl_hwdec.c \
- video/out/vo_opengl_cb.c \
- video/out/vo_opengl_old.c \
- video/out/pnm_loader.c
+ video/out/vo_opengl_cb.c
SOURCES-$(ENCODING) += video/out/vo_lavc.c audio/out/ao_lavc.c \
common/encode_lavc.c
diff --git a/video/out/gl_common.c b/video/out/gl_common.c
index dcfaf32398..3eeef29ea5 100644
--- a/video/out/gl_common.c
+++ b/video/out/gl_common.c
@@ -960,8 +960,6 @@ MPGLContext *mpgl_init(struct vo *vo, const char *backend_name,
if (gl_flavor >= 210 && !(ctx->gl->mpgl_caps & MPGL_CAP_GL21)) {
MP_WARN(ctx->vo, "At least OpenGL 2.1 required.\n");
- if (!vo->probing && (ctx->gl->mpgl_caps & MPGL_CAP_GL_LEGACY))
- MP_WARN(ctx->vo, "Try with: --vo=opengl-old\n");
goto cleanup;
} else if (gl_flavor < 210 && !(ctx->gl->mpgl_caps & MPGL_CAP_GL_LEGACY)) {
MP_WARN(ctx->vo, "OpenGL context creation failed!\n");
diff --git a/video/out/pnm_loader.c b/video/out/pnm_loader.c
deleted file mode 100644
index 70afe0fa23..0000000000
--- a/video/out/pnm_loader.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * PNM image files loader
- *
- * copyleft (C) 2005-2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
- *
- * 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.
- *
- * 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.
- */
-
-/**
- * \file pnm_loader.c
- * \brief PNM image files loader
- */
-
-#include <stdlib.h>
-#include <stdint.h>
-#include <stdio.h>
-#include "misc/ctype.h"
-#include "pnm_loader.h"
-
-/**
- * \brief skips whitespace and comments
- * \param f file to read from
- */
-static void ppm_skip(FILE *f) {
- int c, comment = 0;
- do {
- c = fgetc(f);
- if (c == '#')
- comment = 1;
- if (c == '\n')
- comment = 0;
- } while (c != EOF && (mp_isspace(c) || comment));
- if (c != EOF)
- ungetc(c, f);
-}
-
-#define MAXDIM (16 * 1024)
-
-uint8_t *read_pnm(FILE *f, int *width, int *height,
- int *bytes_per_pixel, int *maxval) {
- uint8_t *data;
- int type;
- unsigned w, h, m, val, bpp;
- *width = *height = *bytes_per_pixel = *maxval = 0;
- ppm_skip(f);
- if (fgetc(f) != 'P')
- return NULL;
- type = fgetc(f);
- if (type != '5' && type != '6')
- return NULL;
- ppm_skip(f);
- if (fscanf(f, "%u", &w) != 1)
- return NULL;
- ppm_skip(f);
- if (fscanf(f, "%u", &h) != 1)
- return NULL;
- ppm_skip(f);
- if (fscanf(f, "%u", &m) != 1)
- return NULL;
- val = fgetc(f);
- if (!mp_isspace(val))
- return NULL;
- if (w > MAXDIM || h > MAXDIM)
- return NULL;
- bpp = (m > 255) ? 2 : 1;
- if (type == '6')
- bpp *= 3;
- data = malloc(w * h * bpp);
- if (fread(data, w * bpp, h, f) != h) {
- free(data);
- return NULL;
- }
- *width = w;
- *height = h;
- *bytes_per_pixel = bpp;
- *maxval = m;
- return data;
-}
diff --git a/video/out/pnm_loader.h b/video/out/pnm_loader.h
deleted file mode 100644
index e00cce2e63..0000000000
--- a/video/out/pnm_loader.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * PNM image files loader
- *
- * 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.
- *
- * 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.
- */
-
-#ifndef MPLAYER_PNM_LOADER_H
-#define MPLAYER_PNM_LOADER_H
-
-#include <stdio.h>
-#include <stdint.h>
-
-/**
- * Read a "portable anymap" image.
- * Supports raw PGM (P5) and PNM (P6).
- *
- * @param[in] f input stream.
- * @param[out] width width of the loaded image.
- * @param[out] height height of the loaded image.
- * @param[out] bytes_per_pixel format of the loaded image.
- * @param[out] maxval maximum pixel value; possible values are:
- * 1 for 8 bits gray,
- * 2 for 16 bits gray,
- * 3 for 8 bits per component RGB,
- * 6 for 16 bits per component RGB.
- * @return a newly allocated array of
- * width*height*bytes_per_pixel bytes,
- * or NULL in case of error.
- */
-uint8_t *read_pnm(FILE *f, int *width, int *height,
- int *bytes_per_pixel, int *maxval);
-
-#endif /* MPLAYER_PNM_LOADER_H */
diff --git a/video/out/vo.c b/video/out/vo.c
index 251f32e6af..53a32a72ed 100644
--- a/video/out/vo.c
+++ b/video/out/vo.c
@@ -54,7 +54,6 @@ extern const struct vo_driver video_out_vdpau;
extern const struct vo_driver video_out_xv;
extern const struct vo_driver video_out_opengl;
extern const struct vo_driver video_out_opengl_hq;
-extern const struct vo_driver video_out_opengl_old;
extern const struct vo_driver video_out_opengl_cb;
extern const struct vo_driver video_out_null;
extern const struct vo_driver video_out_image;
@@ -84,9 +83,6 @@ const struct vo_driver *const video_out_drivers[] =
#if HAVE_SDL2
&video_out_sdl,
#endif
-#if HAVE_GL
- &video_out_opengl_old,
-#endif
#if HAVE_VAAPI
&video_out_vaapi,
#endif
diff --git a/video/out/vo_opengl_old.c b/video/out/vo_opengl_old.c
deleted file mode 100644
index f39f5709cf..0000000000
--- a/video/out/vo_opengl_old.c
+++ /dev/null
@@ -1,2167 +0,0 @@
-/*
- * This file is part of MPlayer.
- *
- * Original author: Reimar Doeffinger <Reimar.Doeffinger@gmx.de>
- *
- * 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.
- *
- * 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.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-#include <stdbool.h>
-#include <assert.h>
-
-#include "config.h"
-#include "talloc.h"
-#include "common/msg.h"
-#include "misc/ctype.h"
-#include "options/m_option.h"
-#include "vo.h"
-#include "video/vfcap.h"
-#include "video/mp_image.h"
-#include "sub/osd.h"
-
-#include "gl_common.h"
-#include "gl_osd.h"
-#include "video/memcpy_pic.h"
-#include "pnm_loader.h"
-
-//for gl_priv.use_yuv
-#define MASK_ALL_YUV (~(1 << YUV_CONVERSION_NONE))
-#define MASK_NOT_COMBINERS (~((1 << YUV_CONVERSION_NONE) | (1 << YUV_CONVERSION_COMBINERS)))
-#define MASK_GAMMA_SUPPORT (MASK_NOT_COMBINERS & ~(1 << YUV_CONVERSION_FRAGMENT))
-
-struct gl_priv {
- MPGLContext *glctx;
- GL *gl;
-
- int allow_sw;
-
- int scaled_osd;
- struct mpgl_osd *osd;
- int osd_color;
- double osd_pts;
-
- int use_ycbcr;
- int use_yuv;
- int is_yuv;
- int lscale;
- int cscale;
- float filter_strength;
- float noise_strength;
- int yuvconvtype;
- int use_rectangle;
- int err_shown;
- uint32_t image_width;
- uint32_t image_height;
- uint32_t image_format;
- int many_fmts;
- int have_texture_rg;
- int max_tex_component_size;
- 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;
- char *backend_arg;
-
- struct mp_csp_equalizer video_eq;
-
- int texture_width;
- int texture_height;
- int mpi_flipped;
- int vo_flipped;
-
- struct mp_rect src_rect; // displayed part of the source video
- struct mp_rect dst_rect; // video rectangle on output window
- struct mp_osd_res osd_res;
-
- int slice_height;
-};
-
-static int glFindFormat(uint32_t format, int have_texture_rg, int *bpp,
- GLint *gl_texfmt, GLenum *gl_format, GLenum *gl_type);
-static void glCreateClearTex(GL *gl, GLenum target, GLenum fmt, GLenum format,
- GLenum type, GLint filter, int w, int h,
- unsigned char val);
-static int glCreatePPMTex(GL *gl, GLenum target, GLenum fmt, GLint filter,
- FILE *f, int *width, int *height, int *maxval);
-static void glDrawTex(GL *gl, GLfloat x, GLfloat y, GLfloat w, GLfloat h,
- GLfloat tx, GLfloat ty, GLfloat tw, GLfloat th,
- int sx, int sy, int rect_tex, int is_yv12, int flip);
-static int loadGPUProgram(struct vo *vo, GL *gl, GLenum target, char *prog);
-//! do not use YUV conversion, this should always stay 0
-#define YUV_CONVERSION_NONE 0
-//! use nVidia specific register combiners for YUV conversion
-//! implementation has been removed
-#define YUV_CONVERSION_COMBINERS 1
-//! use a fragment program for YUV conversion
-#define YUV_CONVERSION_FRAGMENT 2
-//! use a fragment program for YUV conversion with gamma using POW
-#define YUV_CONVERSION_FRAGMENT_POW 3
-//! use a fragment program with additional table lookup for YUV conversion
-#define YUV_CONVERSION_FRAGMENT_LOOKUP 4
-//! use ATI specific register combiners ("fragment program")
-#define YUV_CONVERSION_COMBINERS_ATI 5
-//! use a fragment program with 3D table lookup for YUV conversion
-#define YUV_CONVERSION_FRAGMENT_LOOKUP3D 6
-//! use ATI specific "text" register combiners ("fragment program")
-#define YUV_CONVERSION_TEXT_FRAGMENT 7
-//! use normal bilinear scaling for textures
-#define YUV_SCALER_BILIN 0
-//! use higher quality bicubic scaling for textures
-#define YUV_SCALER_BICUB 1
-//! use cubic scaling in X and normal linear scaling in Y direction
-#define YUV_SCALER_BICUB_X 2
-//! use cubic scaling without additional lookup texture
-#define YUV_SCALER_BICUB_NOTEX 3
-#define YUV_SCALER_UNSHARP 4
-#define YUV_SCALER_UNSHARP2 5
-//! mask for conversion type
-#define YUV_CONVERSION_MASK 0xF
-//! mask for scaler type
-#define YUV_SCALER_MASK 0xF
-//! shift value for luminance scaler type
-#define YUV_LUM_SCALER_SHIFT 8
-//! shift value for chrominance scaler type
-#define YUV_CHROM_SCALER_SHIFT 12
-//! extract conversion out of type
-#define YUV_CONVERSION(t) ((t) & YUV_CONVERSION_MASK)
-//! extract luminance scaler out of type
-#define YUV_LUM_SCALER(t) (((t) >> YUV_LUM_SCALER_SHIFT) & YUV_SCALER_MASK)
-//! extract chrominance scaler out of type
-#define YUV_CHROM_SCALER(t) (((t) >> YUV_CHROM_SCALER_SHIFT) & YUV_SCALER_MASK)
-#define SET_YUV_CONVERSION(c) ((c) & YUV_CONVERSION_MASK)
-#define SET_YUV_LUM_SCALER(s) (((s) & YUV_SCALER_MASK) << YUV_LUM_SCALER_SHIFT)
-#define SET_YUV_CHROM_SCALER(s) (((s) & YUV_SCALER_MASK) << YUV_CHROM_SCALER_SHIFT)
-//! returns whether the yuv conversion supports large brightness range etc.
-static inline int glYUVLargeRange(int conv)
-{
- switch (conv) {
- case YUV_CONVERSION_NONE:
- case YUV_CONVERSION_FRAGMENT_LOOKUP3D:
- case YUV_CONVERSION_TEXT_FRAGMENT:
- return 0;
- }
- return 1;
-}
-typedef struct {
- GLenum target;
- int type;
- struct mp_csp_params csp_params;
- int texw;
- int texh;
- int chrom_texw;
- int chrom_texh;
- float filter_strength;
- float noise_strength;
-} gl_conversion_params_t;
-
-static int glAutodetectYUVConversion(GL *gl);
-static void glSetupYUVConversion(struct vo *vo, GL *gl,
- gl_conversion_params_t *params);
-static void glEnableYUVConversion(GL *gl, GLenum target, int type);
-static void glDisableYUVConversion(GL *gl, GLenum target, int type);
-
-
-#define GL_3D_RED_CYAN 1
-#define GL_3D_GREEN_MAGENTA 2
-#define GL_3D_QUADBUFFER 3
-
-static void glEnable3DLeft(GL *gl, int type)
-{
- GLint buffer;
- switch (type) {
- case GL_3D_RED_CYAN:
- gl->ColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE);
- break;
- case GL_3D_GREEN_MAGENTA:
- gl->ColorMask(GL_FALSE, GL_TRUE, GL_FALSE, GL_FALSE);
- break;
- case GL_3D_QUADBUFFER:
- gl->GetIntegerv(GL_DRAW_BUFFER, &buffer);
- switch (buffer) {
- case GL_FRONT:
- case GL_FRONT_LEFT:
- case GL_FRONT_RIGHT:
- buffer = GL_FRONT_LEFT;
- break;
- case GL_BACK:
- case GL_BACK_LEFT:
- case GL_BACK_RIGHT:
- buffer = GL_BACK_LEFT;
- break;
- }
- gl->DrawBuffer(buffer);
- break;
- }
-}
-
-static void glEnable3DRight(GL *gl, int type)
-{
- GLint buffer;
- switch (type) {
- case GL_3D_RED_CYAN:
- gl->ColorMask(GL_FALSE, GL_TRUE, GL_TRUE, GL_FALSE);
- break;
- case GL_3D_GREEN_MAGENTA:
- gl->ColorMask(GL_TRUE, GL_FALSE, GL_TRUE, GL_FALSE);
- break;
- case GL_3D_QUADBUFFER:
- gl->GetIntegerv(GL_DRAW_BUFFER, &buffer);
- switch (buffer) {
- case GL_FRONT:
- case GL_FRONT_LEFT:
- case GL_FRONT_RIGHT:
- buffer = GL_FRONT_RIGHT;
- break;
- case GL_BACK:
- case GL_BACK_LEFT:
- case GL_BACK_RIGHT:
- buffer = GL_BACK_RIGHT;
- break;
- }
- gl->DrawBuffer(buffer);
- break;
- }
-}
-
-static void glDisable3D(GL *gl, int type)
-{
- GLint buffer;
- switch (type) {
- case GL_3D_RED_CYAN:
- case GL_3D_GREEN_MAGENTA:
- gl->ColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
- break;
- case GL_3D_QUADBUFFER:
- gl->DrawBuffer(GL_BACK);
- gl->GetIntegerv(GL_DRAW_BUFFER, &buffer);
- switch (buffer) {
- case GL_FRONT:
- case GL_FRONT_LEFT:
- case GL_FRONT_RIGHT:
- buffer = GL_FRONT;
- break;
- case GL_BACK:
- case GL_BACK_LEFT:
- case GL_BACK_RIGHT:
- buffer = GL_BACK;
- break;
- }
- gl->DrawBuffer(buffer);
- break;
- }
-}
-
-//! always return this format as internal texture format in glFindFormat
-#define TEXTUREFORMAT_ALWAYS GL_RGB8
-#undef TEXTUREFORMAT_ALWAYS
-
-/**
- * \brief find the OpenGL settings coresponding to format.
- *
- * All parameters may be NULL.
- * \param fmt MPlayer format to analyze.
- * \param dummy reserved
- * \param gl_texfmt [OUT] internal texture format that fits the
- * image format, not necessarily the best for performance.
- * \param gl_format [OUT] OpenGL format for this image format.
- * \param gl_type [OUT] OpenGL type for this image format.
- * \return 1 if format is supported by OpenGL, 0 if not.
- * \ingroup gltexture
- */
-static int glFindFormat(uint32_t fmt, int have_texture_rg, int *dummy,
- GLint *gl_texfmt, GLenum *gl_format, GLenum *gl_type)
-{
- int supported = 1;
- GLenum dummy2;
- GLint dummy3;
- if (!gl_texfmt)
- gl_texfmt = &dummy3;
- if (!gl_format)
- gl_format = &dummy2;
- if (!gl_type)
- gl_type = &dummy2;
-
- struct mp_imgfmt_desc desc = mp_imgfmt_get_desc(fmt);
- if (desc.flags & MP_IMGFLAG_YUV_P) {
- // reduce the possible cases a bit
- if (desc.plane_bits > 8)
- fmt = IMGFMT_420P16;
- else
- fmt = IMGFMT_420P;
- }
-
- *gl_texfmt = 3;
- switch (fmt) {
- case IMGFMT_RGB48:
- *gl_format = GL_RGB;
- *gl_type = GL_UNSIGNED_SHORT;
- break;
- case IMGFMT_RGB24:
- *gl_format = GL_RGB;
- *gl_type = GL_UNSIGNED_BYTE;
- break;
- case IMGFMT_RGBA:
- *gl_texfmt = 4;
- *gl_format = GL_RGBA;
- *gl_type = GL_UNSIGNED_BYTE;
- break;
- case IMGFMT_420P16:
- supported = 0; // no native YUV support
- *gl_texfmt = have_texture_rg ? GL_R16 : GL_LUMINANCE16;
- *gl_format = have_texture_rg ? GL_RED : GL_LUMINANCE;
- *gl_type = GL_UNSIGNED_SHORT;
- break;
- case IMGFMT_420P:
- supported = 0; // no native YV12 support
- case IMGFMT_Y8:
- *gl_texfmt = 1;
- *gl_format = GL_LUMINANCE;
- *gl_type = GL_UNSIGNED_BYTE;
- break;
- case IMGFMT_UYVY:
- *gl_texfmt = GL_YCBCR_MESA;
- *gl_format = GL_YCBCR_MESA;
- *gl_type = fmt == IMGFMT_UYVY ? GL_UNSIGNED_SHORT_8_8 : GL_UNSIGNED_SHORT_8_8_REV;
- break;
-#if 0
- // we do not support palettized formats, although the format the
- // swscale produces works
- case IMGFMT_RGB8:
- *gl_format = GL_RGB;
- *gl_type = GL_UNSIGNED_BYTE_2_3_3_REV;
- break;
-#endif
- case IMGFMT_BGR555:
- *gl_format = GL_RGBA;
- *gl_type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
- break;
- case IMGFMT_BGR565:
- *gl_format = GL_RGB;
- *gl_type = GL_UNSIGNED_SHORT_5_6_5_REV;
- break;
-#if 0
- case IMGFMT_BGR8:
- // special case as red and blue have a different number of bits.
- // GL_BGR and GL_UNSIGNED_BYTE_3_3_2 isn't supported at least
- // by nVidia drivers, and in addition would give more bits to
- // blue than to red, which isn't wanted
- *gl_format = GL_RGB;
- *gl_type = GL_UNSIGNED_BYTE_3_3_2;
- break;
-#endif
- case IMGFMT_RGB555:
- *gl_format = GL_BGRA;
- *gl_type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
- break;
- case IMGFMT_RGB565:
- *gl_format = GL_RGB;
- *gl_type = GL_UNSIGNED_SHORT_5_6_5;
- break;
- case IMGFMT_BGR24:
- *gl_format = GL_BGR;
- *gl_type = GL_UNSIGNED_BYTE;
- break;
- case IMGFMT_BGRA:
- *gl_texfmt = 4;
- *gl_format = GL_BGRA;
- *gl_type = GL_UNSIGNED_BYTE;
- break;
- default:
- *gl_texfmt = 4;
- *gl_format = GL_RGBA;
- *gl_type = GL_UNSIGNED_BYTE;
- supported = 0;
- }
-#ifdef TEXTUREFORMAT_ALWAYS
- *gl_texfmt = TEXTUREFORMAT_ALWAYS;
-#endif
- return supported;
-}
-
-/**
- * \brief create a texture and set some defaults
- * \param target texture taget, usually GL_TEXTURE_2D
- * \param fmt internal texture format
- * \param format texture host data format
- * \param type texture host data type
- * \param filter filter used for scaling, e.g. GL_LINEAR
- * \param w texture width
- * \param h texture height
- * \param val luminance value to fill texture with
- * \ingroup gltexture
- */
-static void glCreateClearTex(GL *gl, GLenum target, GLenum fmt, GLenum format,
- GLenum type, GLint filter, int w, int h,
- unsigned char val)
-{
- GLfloat fval = (GLfloat)val / 255.0;
- GLfloat border[4] = {
- fval, fval, fval, fval
- };
- int stride;
- char *init;
- if (w == 0)
- w = 1;
- if (h == 0)
- h = 1;
- stride = w * glFmt2bpp(format, type);
- if (!stride)
- return;
- init = malloc(stride * h);
- memset(init, val, stride * h);
- glAdjustAlignment(gl, stride);
- gl->PixelStorei(GL_UNPACK_ROW_LENGTH, w);
- gl->TexImage2D(target, 0, fmt, w, h, 0, format, type, init);
- gl->TexParameterf(target, GL_TEXTURE_PRIORITY, 1.0);
- gl->TexParameteri(target, GL_TEXTURE_MIN_FILTER, filter);
- gl->TexParameteri(target, GL_TEXTURE_MAG_FILTER, filter);
- gl->TexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- gl->TexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- // Border texels should not be used with CLAMP_TO_EDGE
- // We set a sane default anyway.
- gl->TexParameterfv(target, GL_TEXTURE_BORDER_COLOR, border);
- free(init);
-}
-
-static GLint detect_hqtexfmt(GL *gl)
-{
- const char *extensions = (const char *)gl->GetString(GL_EXTENSIONS);
- if (strstr(extensions, "_texture_float"))
- return GL_RGB32F;
- else if (strstr(extensions, "NV_float_buffer"))
- return GL_FLOAT_RGB32_NV;
- return GL_RGB16;
-}
-
-/**
- * \brief creates a texture from a PPM file
- * \param target texture taget, usually GL_TEXTURE_2D
- * \param fmt internal texture format, 0 for default
- * \param filter filter used for scaling, e.g. GL_LINEAR
- * \param f file to read PPM from
- * \param width [out] width of texture
- * \param height [out] height of texture
- * \param maxval [out] maxval value from PPM file
- * \return 0 on error, 1 otherwise
- * \ingroup gltexture
- */
-static int glCreatePPMTex(GL *gl, GLenum target, GLenum fmt, GLint filter,
- FILE *f, int *width, int *height, int *maxval)
-{
- int w, h, m, bpp;
- GLenum type;
- uint8_t *data = read_pnm(f, &w, &h, &bpp, &m);
- GLint hqtexfmt = detect_hqtexfmt(gl);
- if (!data || (bpp != 3 && bpp != 6)) {
- free(data);
- return 0;
- }
- if (!fmt) {
- fmt = bpp == 6 ? hqtexfmt : 3;
- if (fmt == GL_FLOAT_RGB32_NV && target != GL_TEXTURE_RECTANGLE)
- fmt = GL_RGB16;
- }
- type = bpp == 6 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_BYTE;
- glCreateClearTex(gl, target, fmt, GL_RGB, type, filter, w, h, 0);
- glUploadTex(gl, target, GL_RGB, type,
- data, w * bpp, 0, 0, w, h, 0);
- free(data);
- if (width)
- *width = w;
- if (height)
- *height = h;
- if (maxval)
- *maxval =