From 2aae5ce0bae31f97d2506c455596150fdea49b0b Mon Sep 17 00:00:00 2001 From: igv Date: Sun, 3 Jul 2016 15:06:41 +0300 Subject: vo_opengl: make size of a cropped source image available to user shaders --- DOCS/man/options.rst | 8 +++++--- video/out/opengl/video.c | 6 ++++++ 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 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")) { -- cgit v1.2.3