summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorigv <igv@mail.com>2016-07-03 15:06:41 +0300
committerwm4 <wm4@nowhere>2017-03-25 13:39:15 +0100
commit2aae5ce0bae31f97d2506c455596150fdea49b0b (patch)
treedf4b2c4ac5537f08324aeccf56d61668bd243740
parentfebeff8feee81db26b6d896a3d63c77d3ec9807f (diff)
downloadmpv-2aae5ce0bae31f97d2506c455596150fdea49b0b.tar.bz2
mpv-2aae5ce0bae31f97d2506c455596150fdea49b0b.tar.xz
vo_opengl: make size of a cropped source image available to user shaders
-rw-r--r--DOCS/man/options.rst8
-rw-r--r--video/out/opengl/video.c6
2 files changed, 11 insertions, 3 deletions
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index 61a5f61a37..2a56097f77 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -4141,9 +4141,11 @@ The following video options are currently all specific to ``--vo=opengl`` and
Specifies the size of the resulting texture for this pass. ``szexpr``
refers to an expression in RPN (reverse polish notation), using the
operators + - * / > < !, floating point literals, and references to
- sizes of existing texture and OUTPUT (such as MAIN.width or
- CHROMA.height). By default, these are set to HOOKED.w and HOOKED.h,
- respectively.
+ sizes of existing texture (such as MAIN.width or CHROMA.height),
+ OUTPUT, or NATIVE_CROPPED (size of an input texture cropped after
+ pan-and-scan, video-align-x/y, video-pan-x/y, etc. and possibly
+ prescaled). By default, these are set to HOOKED.w and HOOKED.h,
+ espectively.
WHEN <szexpr>
Specifies a condition that needs to be true (non-zero) for the shader
diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c
index 49b99e90b5..b9764063c0 100644
--- a/video/out/opengl/video.c
+++ b/video/out/opengl/video.c
@@ -1509,6 +1509,12 @@ static bool szexp_lookup(void *priv, struct bstr var, float size[2])
struct szexp_ctx *ctx = priv;
struct gl_video *p = ctx->p;
+ if (bstr_equals0(var, "NATIVE_CROPPED")) {
+ size[0] = (p->src_rect.x1 - p->src_rect.x0) * p->texture_offset.m[0][0];
+ size[1] = (p->src_rect.y1 - p->src_rect.y0) * p->texture_offset.m[1][1];
+ return true;
+ }
+
// The size of OUTPUT is determined. It could be useful for certain
// user shaders to skip passes.
if (bstr_equals0(var, "OUTPUT")) {