summaryrefslogtreecommitdiffstats
path: root/video/out
diff options
context:
space:
mode:
authorMartin Herkt <lachs0r@srsfckn.biz>2015-09-23 01:12:42 +0200
committerMartin Herkt <lachs0r@srsfckn.biz>2015-09-23 01:12:42 +0200
commitead2933792d6ad958c8ac2d50a0169c3c093ff2b (patch)
tree682e71897c514d537df387e30dc758b8e1bae044 /video/out
parent181e1377b24498f1a335a5eeecf46907edae092a (diff)
parent79f8ee2808ebdf100d1a3aba9a853f801698a2ad (diff)
downloadmpv-ead2933792d6ad958c8ac2d50a0169c3c093ff2b.tar.bz2
mpv-ead2933792d6ad958c8ac2d50a0169c3c093ff2b.tar.xz
Merge branch 'master' into release/current
Diffstat (limited to 'video/out')
-rw-r--r--video/out/opengl/cocoa.c (renamed from video/out/gl_cocoa.c)4
-rw-r--r--video/out/opengl/common.c (renamed from video/out/gl_common.c)2
-rw-r--r--video/out/opengl/common.h (renamed from video/out/gl_common.h)4
-rw-r--r--video/out/opengl/header_fixes.h (renamed from video/out/gl_header_fixes.h)0
-rw-r--r--video/out/opengl/hwdec.c (renamed from video/out/gl_hwdec.c)2
-rw-r--r--video/out/opengl/hwdec.h (renamed from video/out/gl_hwdec.h)2
-rw-r--r--video/out/opengl/hwdec_dxva2.c (renamed from video/out/gl_hwdec_dxva2.c)4
-rw-r--r--video/out/opengl/hwdec_vaglx.c (renamed from video/out/gl_hwdec_vaglx.c)4
-rw-r--r--video/out/opengl/hwdec_vda.c (renamed from video/out/gl_hwdec_vda.c)2
-rw-r--r--video/out/opengl/hwdec_vdpau.c (renamed from video/out/gl_hwdec_vdpau.c)4
-rw-r--r--video/out/opengl/lcms.c (renamed from video/out/gl_lcms.c)4
-rw-r--r--video/out/opengl/lcms.h (renamed from video/out/gl_lcms.h)0
-rw-r--r--video/out/opengl/osd.c (renamed from video/out/gl_osd.c)6
-rw-r--r--video/out/opengl/osd.h (renamed from video/out/gl_osd.h)2
-rw-r--r--video/out/opengl/rpi.c (renamed from video/out/gl_rpi.c)6
-rw-r--r--video/out/opengl/rpi.h (renamed from video/out/gl_rpi.h)0
-rw-r--r--video/out/opengl/utils.c (renamed from video/out/gl_utils.c)33
-rw-r--r--video/out/opengl/utils.h (renamed from video/out/gl_utils.h)5
-rw-r--r--video/out/opengl/video.c (renamed from video/out/gl_video.c)857
-rw-r--r--video/out/opengl/video.h (renamed from video/out/gl_video.h)38
-rw-r--r--video/out/opengl/video_shaders.c429
-rw-r--r--video/out/opengl/video_shaders.h52
-rw-r--r--video/out/opengl/w32.c (renamed from video/out/gl_w32.c)4
-rw-r--r--video/out/opengl/wayland.c (renamed from video/out/gl_wayland.c)4
-rw-r--r--video/out/opengl/x11.c (renamed from video/out/gl_x11.c)6
-rw-r--r--video/out/opengl/x11egl.c (renamed from video/out/gl_x11egl.c)4
-rw-r--r--video/out/vo_opengl.c12
-rw-r--r--video/out/vo_opengl_cb.c6
-rw-r--r--video/out/vo_rpi.c4
-rw-r--r--video/out/w32_common.c7
30 files changed, 851 insertions, 656 deletions
diff --git a/video/out/gl_cocoa.c b/video/out/opengl/cocoa.c
index d04983ee50..b3ca2854f3 100644
--- a/video/out/gl_cocoa.c
+++ b/video/out/opengl/cocoa.c
@@ -22,9 +22,9 @@
#include <OpenGL/OpenGL.h>
#include <dlfcn.h>
-#include "cocoa_common.h"
+#include "video/out/cocoa_common.h"
#include "osdep/macosx_versions.h"
-#include "gl_common.h"
+#include "common.h"
struct cgl_context {
CGLPixelFormatObj pix;
diff --git a/video/out/gl_common.c b/video/out/opengl/common.c
index 2f78f11c08..6720e13f2a 100644
--- a/video/out/gl_common.c
+++ b/video/out/opengl/common.c
@@ -39,7 +39,7 @@
#include <math.h>
#include <assert.h>
#include "talloc.h"
-#include "gl_common.h"
+#include "common.h"
#include "common/common.h"
#include "options/options.h"
#include "options/m_option.h"
diff --git a/video/out/gl_common.h b/video/out/opengl/common.h
index 50817090be..083e2ca023 100644
--- a/video/out/gl_common.h
+++ b/video/out/opengl/common.h
@@ -31,7 +31,7 @@
#include "common/msg.h"
#include "misc/bstr.h"
-#include "vo.h"
+#include "video/out/vo.h"
#include "video/csputils.h"
#include "video/mp_image.h"
@@ -47,7 +47,7 @@
#endif
#define MP_GET_GL_WORKAROUNDS
-#include "video/out/gl_header_fixes.h"
+#include "header_fixes.h"
struct GL;
typedef struct GL GL;
diff --git a/video/out/gl_header_fixes.h b/video/out/opengl/header_fixes.h
index 6a5ce6ad09..6a5ce6ad09 100644
--- a/video/out/gl_header_fixes.h
+++ b/video/out/opengl/header_fixes.h
diff --git a/video/out/gl_hwdec.c b/video/out/opengl/hwdec.c
index e5af2b70f4..ee602fa191 100644
--- a/video/out/gl_hwdec.c
+++ b/video/out/opengl/hwdec.c
@@ -27,7 +27,7 @@
#include "common/common.h"
#include "common/msg.h"
-#include "gl_hwdec.h"
+#include "hwdec.h"
extern const struct gl_hwdec_driver gl_hwdec_vaglx;
extern const struct gl_hwdec_driver gl_hwdec_vda;
diff --git a/video/out/gl_hwdec.h b/video/out/opengl/hwdec.h
index f2b3fd5787..c48ec8b164 100644
--- a/video/out/gl_hwdec.h
+++ b/video/out/opengl/hwdec.h
@@ -1,7 +1,7 @@
#ifndef MPGL_HWDEC_H_
#define MPGL_HWDEC_H_
-#include "gl_common.h"
+#include "common.h"
#include "video/hwdec.h"
struct mp_hwdec_info;
diff --git a/video/out/gl_hwdec_dxva2.c b/video/out/opengl/hwdec_dxva2.c
index 52a73de1b2..f6b3ac0e74 100644
--- a/video/out/gl_hwdec_dxva2.c
+++ b/video/out/opengl/hwdec_dxva2.c
@@ -1,7 +1,7 @@
#include "common/common.h"
-#include "gl_hwdec.h"
-#include "gl_utils.h"
+#include "hwdec.h"
+#include "utils.h"
#include "video/d3d.h"
#include "video/hwdec.h"
diff --git a/video/out/gl_hwdec_vaglx.c b/video/out/opengl/hwdec_vaglx.c
index 00fecffb31..ad7496b9be 100644
--- a/video/out/gl_hwdec_vaglx.c
+++ b/video/out/opengl/hwdec_vaglx.c
@@ -23,8 +23,8 @@
#include <GL/glx.h>
-#include "x11_common.h"
-#include "gl_hwdec.h"
+#include "video/out/x11_common.h"
+#include "hwdec.h"
#include "video/vaapi.h"
struct priv {
diff --git a/video/out/gl_hwdec_vda.c b/video/out/opengl/hwdec_vda.c
index 3fbcda0e79..271c8b7941 100644
--- a/video/out/gl_hwdec_vda.c
+++ b/video/out/opengl/hwdec_vda.c
@@ -25,7 +25,7 @@
#include <OpenGL/CGLIOSurface.h>
#include "video/mp_image_pool.h"
-#include "gl_hwdec.h"
+#include "hwdec.h"
struct vda_gl_plane_format {
GLenum gl_format;
diff --git a/video/out/gl_hwdec_vdpau.c b/video/out/opengl/hwdec_vdpau.c
index 851f79393d..ac1b7bef05 100644
--- a/video/out/gl_hwdec_vdpau.c
+++ b/video/out/opengl/hwdec_vdpau.c
@@ -20,8 +20,8 @@
#include <GL/glx.h>
-#include "gl_hwdec.h"
-#include "gl_utils.h"
+#include "hwdec.h"
+#include "utils.h"
#include "video/vdpau.h"
#include "video/vdpau_mixer.h"
diff --git a/video/out/gl_lcms.c b/video/out/opengl/lcms.c
index ec3013c553..469f2bc262 100644
--- a/video/out/gl_lcms.c
+++ b/video/out/opengl/lcms.c
@@ -33,8 +33,8 @@
#include "options/m_option.h"
#include "options/path.h"
-#include "gl_video.h"
-#include "gl_lcms.h"
+#include "video.h"
+#include "lcms.h"
#include "osdep/io.h"
diff --git a/video/out/gl_lcms.h b/video/out/opengl/lcms.h
index 5ad08b7d64..5ad08b7d64 100644
--- a/video/out/gl_lcms.h
+++ b/video/out/opengl/lcms.h
diff --git a/video/out/gl_osd.c b/video/out/opengl/osd.c
index 0307904c25..1fe84e0d8b 100644
--- a/video/out/gl_osd.c
+++ b/video/out/opengl/osd.c
@@ -24,10 +24,10 @@
#include <assert.h>
#include <libavutil/common.h>
-#include "bitmap_packer.h"
+#include "video/out/bitmap_packer.h"
-#include "gl_utils.h"
-#include "gl_osd.h"
+#include "utils.h"
+#include "osd.h"
struct osd_fmt_entry {
GLint internal_format;
diff --git a/video/out/gl_osd.h b/video/out/opengl/osd.h
index e00565aad7..bd47f71764 100644
--- a/video/out/gl_osd.h
+++ b/video/out/opengl/osd.h
@@ -4,7 +4,7 @@
#include <stdbool.h>
#include <inttypes.h>
-#include "gl_utils.h"
+#include "utils.h"
#include "sub/osd.h"
struct mpgl_osd *mpgl_osd_init(GL *gl, struct mp_log *log, struct osd_state *osd);
diff --git a/video/out/gl_rpi.c b/video/out/opengl/rpi.c
index 9109662ef2..7c486fc0b1 100644
--- a/video/out/gl_rpi.c
+++ b/video/out/opengl/rpi.c
@@ -24,10 +24,10 @@
#include <assert.h>
#include "common/common.h"
-#include "x11_common.h"
-#include "gl_common.h"
+#include "video/out/x11_common.h"
+#include "common.h"
-#include "gl_rpi.h"
+#include "rpi.h"
static void *get_proc_address(const GLubyte *name)
{
diff --git a/video/out/gl_rpi.h b/video/out/opengl/rpi.h
index e00762b632..e00762b632 100644
--- a/video/out/gl_rpi.h
+++ b/video/out/opengl/rpi.h
diff --git a/video/out/gl_utils.c b/video/out/opengl/utils.c
index 7e13f839d6..b5d33b15c3 100644
--- a/video/out/gl_utils.c
+++ b/video/out/opengl/utils.c
@@ -30,7 +30,7 @@
#include "stream/stream.h"
#include "common/common.h"
-#include "gl_utils.h"
+#include "utils.h"
// GLU has this as gluErrorString (we don't use GLU, as it is legacy-OpenGL)
static const char *gl_error_to_string(GLenum error)
@@ -578,6 +578,14 @@ void gl_sc_hadd(struct gl_shader_cache *sc, const char *text)
sc->header_text = talloc_strdup_append(sc->header_text, text);
}
+void gl_sc_haddf(struct gl_shader_cache *sc, const char *textf, ...)
+{
+ va_list ap;
+ va_start(ap, textf);
+ ta_xvasprintf_append(&sc->header_text, textf, ap);
+ va_end(ap);
+}
+
const char *gl_sc_loadfile(struct gl_shader_cache *sc, const char *path)
{
if (!path || !path[0] || !sc->global)
@@ -621,19 +629,24 @@ static struct sc_uniform *find_uniform(struct gl_shader_cache *sc,
return new;
}
+const char* mp_sampler_type(GLenum texture_target)
+{
+ switch (texture_target) {
+ case GL_TEXTURE_1D: return "sampler1D";
+ case GL_TEXTURE_2D: return "sampler2D";
+ case GL_TEXTURE_RECTANGLE: return "sampler2DRect";
+ case GL_TEXTURE_3D: return "sampler3D";
+ default: abort();
+ }
+}
+
void gl_sc_uniform_sampler(struct gl_shader_cache *sc, char *name, GLenum target,
int unit)
{
struct sc_uniform *u = find_uniform(sc, name);
u->type = UT_i;
u->size = 1;
- switch (target) {
- case GL_TEXTURE_1D: u->glsl_type = "sampler1D"; break;
- case GL_TEXTURE_2D: u->glsl_type = "sampler2D"; break;
- case GL_TEXTURE_RECTANGLE: u->glsl_type = "sampler2DRect"; break;
- case GL_TEXTURE_3D: u->glsl_type = "sampler3D"; break;
- default: abort();
- }
+ u->glsl_type = mp_sampler_type(target);
u->v.i[0] = unit;
}
@@ -877,8 +890,8 @@ void gl_sc_gen_shader_and_reset(struct gl_shader_cache *sc)
if (strcmp(e->name, "position") == 0) {
// setting raster pos. requires setting gl_Position magic variable
assert(e->num_elems == 2 && e->type == GL_FLOAT);
- ADD(vert_head, "%s vec2 position;\n", vert_in);
- ADD(vert_body, "gl_Position = vec4(position, 1.0, 1.0);\n");
+ ADD(vert_head, "%s vec2 vertex_position;\n", vert_in);
+ ADD(vert_body, "gl_Position = vec4(vertex_position, 1.0, 1.0);\n");
} else {
ADD(vert_head, "%s %s vertex_%s;\n", vert_in, glsl_type, e->name);
ADD(vert_head, "%s %s %s;\n", vert_out, glsl_type, e->name);
diff --git a/video/out/gl_utils.h b/video/out/opengl/utils.h
index 1dfca78858..75cedd6efe 100644
--- a/video/out/gl_utils.h
+++ b/video/out/opengl/utils.h
@@ -24,7 +24,7 @@
#ifndef MP_GL_UTILS_
#define MP_GL_UTILS_
-#include "gl_common.h"
+#include "common.h"
struct mp_log;
@@ -39,6 +39,8 @@ void glClearTex(GL *gl, GLenum target, GLenum format, GLenum type,
mp_image_t *glGetWindowScreenshot(GL *gl);
+const char* mp_sampler_type(GLenum texture_target);
+
// print a multi line string with line numbers (e.g. for shader sources)
// log, lev: module and log level, as in mp_msg()
void mp_log_source(struct mp_log *log, int lev, const char *src);
@@ -125,6 +127,7 @@ void gl_sc_destroy(struct gl_shader_cache *sc);
void gl_sc_add(struct gl_shader_cache *sc, const char *text);
void gl_sc_addf(struct gl_shader_cache *sc, const char *textf, ...);
void gl_sc_hadd(struct gl_shader_cache *sc, const char *text);
+void gl_sc_haddf(struct gl_shader_cache *sc, const char *textf, ...);
const char *gl_sc_loadfile(struct gl_shader_cache *sc, const char *path);
void gl_sc_uniform_sampler(struct gl_shader_cache *sc, char *name, GLenum target,
int unit);
diff --git a/video/out/gl_video.c b/video/out/opengl/video.c
index 7d27c73eb6..8d6776ce0e 100644
--- a/video/out/gl_video.c
+++ b/video/out/opengl/video.c
@@ -29,30 +29,24 @@
#include <libavutil/common.h>
#include <libavutil/lfg.h>
-#include "gl_video.h"
+#include "video.h"
#include "misc/bstr.h"
-#include "gl_common.h"
-#include "gl_utils.h"
-#include "gl_hwdec.h"
-#include "gl_osd.h"
-#include "filter_kernels.h"
-#include "aspect.h"
-#include "bitmap_packer.h"
-#include "dither.h"
-#include "vo.h"
+#include "options/m_config.h"
+#include "common.h"
+#include "utils.h"
+#include "hwdec.h"
+#include "osd.h"
+#include "video_shaders.h"
+#include "video/out/filter_kernels.h"
+#include "video/out/aspect.h"
+#include "video/out/bitmap_packer.h"
+#include "video/out/dither.h"
+#include "video/out/vo.h"
// Pixel width of 1D lookup textures.
#define LOOKUP_TEXTURE_SIZE 256
-// Texture units 0-5 are used by the video, and for free use by the passes
-#define TEXUNIT_VIDEO_NUM 6
-
-// Other texture units are reserved for specific purposes
-#define TEXUNIT_SCALERS TEXUNIT_VIDEO_NUM
-#define TEXUNIT_3DLUT (TEXUNIT_SCALERS+4)
-#define TEXUNIT_DITHER (TEXUNIT_3DLUT+1)
-
// scale/cscale arguments that map directly to shader filter routines.
// Note that the convolution filters are not included in this list.
static const char *const fixed_scale_filters[] = {
@@ -110,21 +104,6 @@ struct video_image {
struct mp_image *mpi; // original input image
};
-struct scaler {
- int index;
- struct scaler_config conf;
- double scale_factor;
- bool initialized;
- struct filter_kernel *kernel;
- GLuint gl_lut;
- GLenum gl_target;
- struct fbotex sep_fbo;
- bool insufficient;
-
- // kernel points here
- struct filter_kernel kernel_storage;
-};
-
struct fbosurface {
struct fbotex fbotex;
double pts;
@@ -179,7 +158,7 @@ struct gl_video {
struct video_image image;
struct fbotex chroma_merge_fbo;
- struct fbotex source_fbo;
+ struct fbotex chroma_deband_fbo;
struct fbotex indirect_fbo;
struct fbotex blend_subs_fbo;
struct fbosurface surfaces[FBOSURFACES_MAX];
@@ -206,7 +185,6 @@ struct gl_video {
// temporary during rendering
struct src_tex pass_tex[TEXUNIT_VIDEO_NUM];
- bool use_indirect;
bool use_linear;
bool use_normalized_range;
float user_gamma;
@@ -364,6 +342,7 @@ const struct gl_video_opts gl_video_opts_hq_def = {
.gamma = 1.0f,
.blend_subs = 0,
.pbo = 1,
+ .deband = 1,
};
static int validate_scaler_opt(struct mp_log *log, const m_option_t *opt,
@@ -373,46 +352,30 @@ static int validate_window_opt(struct mp_log *log, const m_option_t *opt,
struct bstr name, struct bstr param);
#define OPT_BASE_STRUCT struct gl_video_opts
+
+#define SCALER_OPTS(n, i) \
+ OPT_STRING_VALIDATE(n, scaler[i].kernel.name, 0, validate_scaler_opt), \
+ OPT_FLOAT(n"-param1", scaler[i].kernel.params[0], 0), \
+ OPT_FLOAT(n"-param2", scaler[i].kernel.params[1], 0), \
+ OPT_FLOAT(n"-blur", scaler[i].kernel.blur, 0), \
+ OPT_FLOAT(n"-wparam", scaler[i].window.params[0], 0), \
+ OPT_FLAG(n"-clamp", scaler[i].clamp, 0), \
+ OPT_FLOATRANGE(n"-radius", scaler[i].radius, 0, 0.5, 16.0), \
+ OPT_FLOATRANGE(n"-antiring", scaler[i].antiring, 0, 0.0, 1.0), \
+ OPT_STRING_VALIDATE(n"-window", scaler[i].window.name, 0, validate_window_opt)
+
const struct m_sub_options gl_video_conf = {
.opts = (const m_option_t[]) {
+ OPT_FLAG("dumb-mode", dumb_mode, 0),
OPT_FLOATRANGE("gamma", gamma, 0, 0.1, 2.0),
OPT_FLAG("gamma-auto", gamma_auto, 0),
OPT_CHOICE_C("target-prim", target_prim, 0, mp_csp_prim_names),
OPT_CHOICE_C("target-trc", target_trc, 0, mp_csp_trc_names),
OPT_FLAG("pbo", pbo, 0),
- OPT_STRING_VALIDATE("scale", scaler[0].kernel.name, 0, validate_scaler_opt),
- OPT_STRING_VALIDATE("dscale", scaler[1].kernel.name, 0, validate_scaler_opt),
- OPT_STRING_VALIDATE("cscale", scaler[2].kernel.name, 0, validate_scaler_opt),
- OPT_STRING_VALIDATE("tscale", scaler[3].kernel.name, 0, validate_scaler_opt),
- OPT_FLOAT("scale-param1", scaler[0].kernel.params[0], 0),
- OPT_FLOAT("scale-param2", scaler[0].kernel.params[1], 0),
- OPT_FLOAT("dscale-param1", scaler[1].kernel.params[0], 0),
- OPT_FLOAT("dscale-param2", scaler[1].kernel.params[1], 0),
- OPT_FLOAT("cscale-param1", scaler[2].kernel.params[0], 0),
- OPT_FLOAT("cscale-param2", scaler[2].kernel.params[1], 0),
- OPT_FLOAT("tscale-param1", scaler[3].kernel.params[0], 0),
- OPT_FLOAT("tscale-param2", scaler[3].kernel.params[1], 0),
- OPT_FLOAT("scale-blur", scaler[0].kernel.blur, 0),
- OPT_FLOAT("dscale-blur", scaler[1].kernel.blur, 0),
- OPT_FLOAT("cscale-blur", scaler[2].kernel.blur, 0),
- OPT_FLOAT("tscale-blur", scaler[3].kernel.blur, 0),
- OPT_STRING_VALIDATE("scale-window", scaler[0].window.name, 0, validate_window_opt),
- OPT_STRING_VALIDATE("dscale-window", scaler[1].window.name, 0, validate_window_opt),
- OPT_STRING_VALIDATE("cscale-window", scaler[2].window.name, 0, validate_window_opt),
- OPT_STRING_VALIDATE("tscale-window", scaler[3].window.name, 0, validate_window_opt),
- OPT_FLOAT("scale-wparam", scaler[0].window.params[0], 0),
- OPT_FLOAT("dscale-wparam", scaler[1].window.params[0], 0),
- OPT_FLOAT("cscale-wparam", scaler[2].window.params[0], 0),
- OPT_FLOAT("tscale-wparam", scaler[3].window.params[0], 0),
- OPT_FLOATRANGE("scale-radius", scaler[0].radius, 0, 0.5, 16.0),
- OPT_FLOATRANGE("dscale-radius", scaler[1].radius, 0, 0.5, 16.0),
- OPT_FLOATRANGE("cscale-radius", scaler[2].radius, 0, 0.5, 16.0),
- OPT_FLOATRANGE("tscale-radius", scaler[3].radius, 0, 0.5, 3.0),
- OPT_FLOATRANGE("scale-antiring", scaler[0].antiring, 0, 0.0, 1.0),
- OPT_FLOATRANGE("dscale-antiring", scaler[1].antiring, 0, 0.0, 1.0),
- OPT_FLOATRANGE("cscale-antiring", scaler[2].antiring, 0, 0.0, 1.0),
- OPT_FLOATRANGE("tscale-antiring", scaler[3].antiring, 0, 0.0, 1.0),
- OPT_FLAG("tscale-clamp", scaler[3].clamp, 0),
+ SCALER_OPTS("scale", 0),
+ SCALER_OPTS("dscale", 1),
+ SCALER_OPTS("cscale", 2),
+ SCALER_OPTS("tscale", 3),
OPT_FLAG("scaler-resizes-only", scaler_resizes_only, 0),
OPT_FLAG("linear-scaling", linear_scaling, 0),
OPT_FLAG("fancy-downscaling", fancy_downscaling, 0),
@@ -450,16 +413,18 @@ const struct m_sub_options gl_video_conf = {
({"no", 0},
{"yes", 1},
{"video", 2})),
- OPT_STRING("source-shader", source_shader, 0),
OPT_STRING("scale-shader", scale_shader, 0),
OPT_STRINGLIST("pre-shaders", pre_shaders, 0),
OPT_STRINGLIST("post-shaders", post_shaders, 0),
+ OPT_FLAG("deband", deband, 0),
+ OPT_SUBSTRUCT("deband", deband_opts, deband_conf, 0),
OPT_REMOVED("approx-gamma", "this is always enabled now"),
OPT_REMOVED("cscale-down", "chroma is never downscaled"),
OPT_REMOVED("scale-sep", "this is set automatically whenever sane"),
OPT_REMOVED("indirect", "this is set automatically whenever sane"),
OPT_REMOVED("srgb", "use target-prim=bt709:target-trc=srgb instead"),
+ OPT_REMOVED("source-shader", "use :deband to enable debanding"),
OPT_REPLACED("lscale", "scale"),
OPT_REPLACED("lscale-down", "scale-down"),
@@ -486,6 +451,7 @@ static void uninit_scaler(struct gl_video *p, struct scaler *scaler);
static void check_gl_features(struct gl_video *p);
static bool init_format(int fmt, struct gl_video *init);
static void gl_video_upload_image(struct gl_video *p, struct mp_image *mpi);
+static void assign_options(struct gl_video_opts *dst, struct gl_video_opts *src);
#define GLSL(x) gl_sc_add(p->sc, #x "\n");
#define GLSLF(...) gl_sc_addf(p->sc, __VA_ARGS__)
@@ -569,7 +535,7 @@ static void uninit_rendering(struct gl_video *p)
p->dither_texture = 0;
fbotex_uninit(&p->chroma_merge_fbo);
- fbotex_uninit(&p->source_fbo);
+ fbotex_uninit(&p->chroma_deband_fbo);
fbotex_uninit(&p->indirect_fbo);
fbotex_uninit(&p->blend_subs_fbo);
@@ -621,8 +587,8 @@ void gl_video_set_lut3d(struct gl_video *p, struct lut3d *lut3d)
reinit_rendering(p);
}
-static void pass_load_fbotex(struct gl_video *p, struct fbotex *src_fbo, int id,
- int w, int h)
+static void pass_load_fbotex(struct gl_video *p, struct fbotex *src_fbo,
+ int w, int h, int id)
{
p->pass_tex[id] = (struct src_tex){
.gl_tex = src_fbo->texture,
@@ -658,10 +624,8 @@ static void pass_set_image_textures(struct gl_video *p, struct video_image *vimg
// Make sure luma/chroma sizes are aligned.
// Example: For 4:2:0 with size 3x3, the subsampled chroma plane is 2x2
// so luma (3,3) has to align with chroma (2,2).
- chroma->m[0][0] = ls_w * (float)vimg->planes[0].w
- / vimg->planes[1].w;
- chroma->m[1][1] = ls_h * (float)vimg->planes[0].h
- / vimg->planes[1].h;
+ chroma->m[0][0] = ls_w * (float)vimg->planes[0].w / vimg->planes[1].w;
+ chroma->m[1][1] = ls_h * (float)vimg->planes[0].h / vimg->planes[1].h;
for (int n = 0; n < p->plane_count; n++) {
struct texplane *t = &vimg->planes[n];
@@ -873,7 +837,7 @@ static void finish_pass_fbo(struct gl_video *p, struct fbotex *dst_fbo,
finish_pass_direct(p, dst_fbo->fbo, dst_fbo->w, dst_fbo->h,
&(struct mp_rect){0, 0, w, h}, 0);
- pass_load_fbotex(p, dst_fbo, tex, w, h);
+ pass_load_fbotex(p, dst_fbo, w, h, tex);
}
static void uninit_scaler(struct gl_video *p, struct scaler *scaler)
@@ -1048,84 +1012,7 @@ static void reinit_scaler(struct gl_video *p, struct scaler *scaler,
debug_check_gl(p, "after initializing scaler");
}
-// Set up shared/commonly used variables
-static void sampler_prelude(struct gl_video *p, int tex_num)
-{
- GLSLF("#define tex texture%d\n", tex_num);
- GLSLF("vec2 pos = texcoord%d;\n", tex_num);
- GLSLF("vec2 size = texture_size%d;\n", tex_num);
- GLSLF("vec2 pt = vec2(1.0) / size;\n");
-}
-
-static void pass_sample_separated_get_weights(struct gl_video *p,
- struct scaler *scaler)
-{
- gl_sc_uniform_sampler(p->sc, "lut", scaler->gl_target,
- TEXUNIT_SCALERS + scaler->index);
-
- int N = scaler->kernel->size;
- if (N == 2) {
- GLSL(vec2 c1 = texture(lut, vec2(0.5, fcoord)).RG;)
- GLSL(float weights[2] = float[](c1.r, c1.g);)
- } else if (N == 6) {
- GLSL(vec4 c1 = texture(lut, vec2(0.25, fcoord));)
- GLSL(vec4 c2 = texture(lut, vec2(0.75, fcoord));)
- GLSL(float weights[6] = float[](c1.r, c1.g, c1.b, c2.r, c2.g, c2.b);)
- } else {
- GLSLF("float weights[%d];\n", N);
- for (int n = 0; n < N / 4; n++) {
- GLSLF("c = texture(lut, vec2(1.0 / %d + %d / float(%d), fcoord));\n",
- N / 2, n, N / 4);
- GLSLF("weights[%d] = c.r;\n", n * 4 + 0);
- GLSLF("weights[%d] = c.g;\n", n * 4 + 1);
- GLSLF("weights[%d] = c.b;\n", n * 4 + 2);
- GLSLF("weights[%d] = c.a;\n", n * 4 + 3);
- }
- }
-}
-
-// Handle a single pass (either vertical or horizontal). The direction is given
-// by the vector (d_x, d_y). If the vector is 0, then planar interpolation is
-// used instead (samples from texture0 through textureN)
-static void pass_sample_separated_gen(struct gl_video *p, struct scaler *scaler,
- int d_x, int d_y)
-{
- int N = scaler->kernel->size;
- bool use_ar = scaler->conf.antiring > 0;
- bool planar = d_x == 0 && d_y == 0;
- GLSL(vec4 color = vec4(0.0);)
- GLSLF("{\n");
- if (!planar) {
- GLSLF("vec2 dir = vec2(%d, %d);\n", d_x, d_y);
- GLSL(pt *= dir;)
- GLSL(float fcoord = dot(fract(pos * size - vec2(0.5)), dir);)
- GLSLF("vec2 base = pos - fcoord * pt - pt * vec2(%d);\n", N / 2 - 1);
- }
- GLSL(vec4 c;)
- if (use_ar) {
- GLSL(vec4 hi = vec4(0.0);)
- GLSL(vec4 lo = vec4(1.0);)
- }
- pass_sample_separated_get_weights(p, scaler);
- GLSLF("// scaler samples\n");
- for (int n = 0; n < N; n++) {
- if (planar) {
- GLSLF("c = texture(texture%d, texcoord%d);\n", n, n);
- } else {
- GLSLF("c = texture(tex, base + pt * vec2(%d));\n", n);
- }
- GLSLF("color += vec4(weights[%d]) * c;\n", n);
- if (use_ar && (n == N/2-1 || n == N/2)) {
- GLSL(lo = min(lo, c);)
- GLSL(hi = max(hi, c);)
- }
- }
- if (use_ar)
- GLSLF("color = mix(color, clamp(color, lo, hi), %f);\n",
- scaler->conf.antiring);
- GLSLF("}\n");
-}
-
+// Special helper for sampling from two separated stages
static void pass_sample_separated(struct gl_video *p, int src_tex,
struct scaler *scaler, int w, int h,
struct gl_transform transform)
@@ -1136,179 +1023,15 @@ static void pass_sample_separated(struct gl_video *p, int src_tex,
GLSLF("// pass 1\n");
p->pass_tex[src_tex].src.y0 = src_new.y0;
p->pass_tex[src_tex].src.y1 = src_new.y1;
- pass_sample_separated_gen(p, scaler, 0, 1);
+ pass_sample_separated_gen(p->sc, scaler, 0, 1);
int src_w = p->pass_tex[src_tex].src.x1 - p->pass_tex[src_tex].src.x0;
finish_pass_fbo(p, &scaler->sep_fbo, src_w, h, src_tex, FBOTEX_FUZZY_H);
// Restore the sample source for the second pass
- sampler_prelude(p, src_tex);
+ sampler_prelude(p->sc, src_tex);
GLSLF("// pass 2\n");
p->pass_tex[src_tex].src.x0 = src_new.x0;
p->pass_tex[src_tex].src.x1 = src_new.x1;
- pass_sample_separated_gen(p, scaler, 1, 0);
-}
-
-static void pass_sample_polar(struct gl_video *p, struct scaler *scaler)
-{
- double radius = scaler->kernel->f.radius;
- int bound = (int)ceil(radius);
- bool use_ar = scaler->conf.antiring > 0;
- GLSL(vec4 color = vec4(0.0);)
- GLSLF("{\n");
- GLSL(vec2 fcoord = fract(pos * size - vec2(0.5));)
- GLSL(vec2 base = pos - fcoord * pt;)
- GLSL(vec4 c;)
- GLSLF("float w, d, wsum = 0.0;\n");
- if (use_ar) {
- GLSL(vec4 lo = vec4(1.0);)
- GLSL(vec4 hi = vec4(0.0);)
- }
- gl_sc_uniform_sampler(p->sc, "lut", scaler->gl_target,
- TEXUNIT_SCALERS + scaler->index);
- GLSLF("// scaler samples\n");
- for (int y = 1-bound; y <= bound; y++) {
- for (int x = 1-bound; x <= bound; x++) {
- // Since we can't know the subpixel position in advance, assume a
- // worst case scenario
- int yy = y > 0 ? y-1 : y;
- int xx = x > 0 ? x-1 : x;
- double dmax = sqrt(xx*xx + yy*yy);
- // Skip samples definitely outside the radius
- if (dmax >= radius)
- continue;
- GLSLF("d = length(vec2(%d, %d) - fcoord)/%f;\n", x, y, radius);
- // Check for samples that might be skippable
- if (dmax >= radius - 1)
- GLSLF("if (d < 1.0) {\n");
- GLSL(w = texture1D(lut, d).r;)
- GLSL(wsum += w;)
- GLSLF("c = texture(tex, base + pt * vec2(%d, %d));\n", x, y);
- GLSL(color += vec4(w) * c;)