Commit Graph

18 Commits

Author SHA1 Message Date
wm4 71642f5d23 vo_opengl: fix sharpen filter
Regression since commit 93546f0c.

Fixes #2956.
2016-03-16 19:09:52 +01:00
Niklas Haas 93546f0c2f vo_opengl: refactor pass_read_video and texture binding
This is a pretty major rewrite of the internal texture binding
mechanic, which makes it more flexible.

In general, the difference between the old and current approaches is
that now, all texture description is held in a struct img_tex and only
explicitly bound with pass_bind. (Once bound, a texture unit is assumed
to be set in stone and no longer tied to the img_tex)

This approach makes the code inside pass_read_video significantly more
flexible and cuts down on the number of weird special cases and
spaghetti logic.

It also has some improvements, e.g. cutting down greatly on the number
of unnecessary conversion passes inside pass_read_video (which was
previously mostly done to cope with the fact that the alternative would
have resulted in a combinatorial explosion of code complexity).

Some other notable changes (and potential improvements):

- texture expansion is now *always* handled in pass_read_video, and the
  colormatrix never does this anymore. (Which means the code could
  probably be removed from the colormatrix generation logic, modulo some
  other VOs)

- struct fbo_tex now stores both its "physical" and "logical"
  (configured) size, which cuts down on the amount of width/height
  baggage on some function calls

- vo_opengl can now technically support textures with different bit
  depths (e.g. 10 bit luma, 8 bit chroma) - but the APIs it queries
  inside img_format.c doesn't export this (nor does ffmpeg support it,
  really) so the status quo of using the same tex_mul for all planes is
  kept.

- dumb_mode is now only needed because of the indirect_fbo being in the
  main rendering pipeline. If we reintroduce p->use_indirect and thread
  a transform through the entire program this could be skipped where
  unnecessary, allowing for the removal of dumb_mode. But I'm not sure
  how to do this in a clean way. (Which is part of why it got introduced
  to begin with)

- It would be trivial to resurrect source-shader now (it would just be
  one extra 'if' inside pass_read_video).
2016-03-05 13:08:38 +01:00
igv 8bafd68fff vo_opengl: set uniform variable "pixel_size" for internal shaders 2016-02-26 23:21:03 +01:00
Niklas Haas 2f562825e0 vo_opengl: declare vec4 color inside fragment shader stub
Why was this done so stupidly, with so many complicated special cases,
before? Declare it once so the shader bits don't have to figure out where
and when to do so themselves.
2016-02-23 20:58:15 +01:00
wm4 57c31f4130 vo_opengl: don't use normalized coords for debanding rectangle textures
Fixes #2831.
2016-02-18 10:42:26 +01:00
wm4 e4ec0f42e4 Change GPL/LGPL dual-licensed files to LGPL
Do this to make the license situation less confusing.

This change should be of no consequence, since LGPL is compatible with
GPL anyway, and making it LGPL-only does not restrict the use with GPL
code.

Additionally, the wording implies that this is allowed, and that we can
just remove the GPL part.
2016-01-19 18:36:34 +01:00
wm4 0d7d935e88 vo_opengl: fix shader compilation regression
The recent LUT adjustment changes broke interpolation.

The concatenation of the shader stages is a bit messy, and it seems like
sampler_prelude is not a good place to add this macro. Always add the
macro to every shader instead. (While this doesn't seem too elegant,
this isn't too inelegant either, and goes these problems out of the
way.)
2015-12-08 03:18:47 +01:00
Bin Jin c1a96de41c vo_opengl: Fix minor LUT sampling error
Define a macro to correct the coordinate for lookup texture. Cache
the corrected coordinate for 1D filter and use mix() to minimize the
performance impact.
2015-12-07 23:48:15 +01:00
Bin Jin 19b0b1df51 vo_opengl: improve boundary check for polar filters
If the sampling point is placed diagonally, the radius difference
could be as large as sqrt(2.0). And a loosened check with (radius - 1)
would potentially include pixels out of the range.

Fix the check to handle those corner case properly to avoid
unnecessary texture lookup and improve the performance a bit.
2015-12-05 23:53:17 +01:00
wm4 1a8b06f67e vo_opengl: make 1D textures completely optional
Polar scalers use 1D textures, because they're slightly faster on some
GPUs than 2D textures. But 2D textures work too, so add support for
them.

Allows using these scalers with ANGLE.
2015-11-19 21:20:40 +01:00
wm4 92d06f43fa vo_opengl: fix some more GLES shader issues
Just like commit f9a2fc59. There are probably some more such cases.
The vec2 constructor calls are probably fine, but don't bother with
confusing inconsistencies.
2015-11-19 21:19:04 +01:00
Niklas Haas eb66038d4f vo_opengl: make the default debanding settings less excessive
It's great that the new algorithm supports multiple placebo iterations
and all, but it's really not necessary and hurts performance in the
general case for the sake of the 0.1% that actually pause the screen
and look for minute differences.

Signed-off-by: wm4 <wm4@nowhere>
2015-10-21 11:32:31 +02:00
wm4 a2a2cdb5bc vo_opengl: cosmetics: coding style 2015-09-30 23:05:42 +02:00
wm4 cb1c072534 vo_opengl: remove sharpen scalers, add sharpen sub-option
This turns the old scalers (inherited from MPlayer) into a pre-
processing step (after color conversion and before scaling). The code
for the "sharpen5" scaler is reused for this.

The main reason MPlayer implemented this as scalers was perhaps because
FBOs were too expensive, and making it a scaler allowed to implement
this in 1 pass. But unsharp masking is not really a scaler, and I would
guess the result is more like combining bilinear scaling and unsharp
masking.
2015-09-23 22:43:27 +02:00
wm4 c17ff1703a vo_opengl: move deband_opts declaration to where it's used
At least one thing the current option code can do right.
2015-09-23 22:21:59 +02:00
wm4 a8eae12af5 vo_opengl: fix shader compilation with debanding and OSX hwdec
2 things are being stupid here: Apple for requiring rectangle textures
with their IOSurface interop for no reason, and OpenGL having a
different sampler type for rectangle textures.
2015-09-10 20:53:47 +02:00
Niklas Haas 97363e176d vo_opengl: implement debanding (and remove source-shader)
The removal of source-shader is a side effect, since this effectively
replaces it - and the video-reading code has been significantly
restructured to make more sense and be more readable.

This means users no longer have to constantly download and maintain a
separate deband.glsl installation alongside mpv, which was the only real
use case for source-shader that we found either way.
2015-09-09 19:19:23 +02:00
Niklas Haas eb56807b41 vo_opengl: move self-contained shader routines to a separate file
This is mostly to cut down somewhat on the amount of code bloat in
video.c by moving out helper functions (including scaler kernels and
color management routines) to a separate file.

It would certainly be possible to move out more functions (eg. dithering
or CMS code) with some extra effort/refactoring, but this is a start.

Signed-off-by: wm4 <wm4@nowhere>
2015-09-09 18:17:44 +02:00