Commit Graph

261 Commits

Author SHA1 Message Date
wm4 c7f802ee45 vo_opengl_cb: fix NULL deref
Broken in commit d6c99c85. vo_opengl_cb.c adds the corner case that
p->osd can be NULL. This make opengl-cb always crash.
2016-03-23 14:49:39 +01:00
wm4 fd3ae6c561 vo_opengl: fix blend-subtitles=video in some cases
Shader miscompilation and bad output.

Regression probably since commit 93546f0c (or one of the following
ones).

Fixes #2982.
2016-03-22 13:34:52 +01:00
wm4 d6c99c8513 vo_opengl, osd: allow osc.lua to react faster on resizes
Glitches when resizing are still possible, but are reduced. Other VOs
could support this too, but don't need to do so.

(Totally avoiding glitches would be much more effort, and probably not
worth the trouble. How about you just watch the video the player is
playing, instead of spending your time resizing the window.)
2016-03-21 22:23:41 +01:00
wm4 3353923f29 vo_opengl: GLX: try to create 3.3 core profile context
Until now, we have tried to create a GL 3.0 context. The main reason for
this is that many Mesa-based drivers did not support anything better.
But some drivers (Mesa AMD) will not report a higher OpenGL version,
because their compatibility mode is restricted. While later GL features
are reported as extensions just fine, there doesn't seem to be a way to
determine or enable higher GLSL versions.

Add some more shitty hacks to try to deal with this messed up situation,
and try to probe each interesting GL version separately (starting with
3.3, then 3.2 etc.). Other backends might suffer from similar problems,
but these will have to deal with it on their own.

Probably fixes #2938, or maybe not.
2016-03-19 19:31:17 +01:00
wm4 0d19316de2 vo_opengl: dxva2egl: ignore alpha component in the mapped video
converted_imgfmt will be used by the renderer logic to build an
appropriate shader chain. It doesn't influence the format of any
textures. Thus it doesn't matter whether the hw video surface is mapped
as RGB or RGBA. What matters is if the video actually contains alpha or
not. Since virtually all hardware decoder do not support alpha in any
way, this can be hardcoded as "no alpha".

This avoids unnecessary GPU work.
2016-03-17 14:58:49 +01:00
wm4 45db7d52a9 vo_opengl: fix operation without GL_ARB_texture_rg
This also gets rid of the kind of hard to read texture swizzle setup and
turns it into something dumber.

Assumes that we don't create any FBOs with 2 channel formats. (Only the
video source textures are handled by this commit.)
2016-03-17 12:50:26 +01:00
wm4 71642f5d23 vo_opengl: fix sharpen filter
Regression since commit 93546f0c.

Fixes #2956.
2016-03-16 19:09:52 +01:00
Kevin Mitchell d756dd8cbf vo_opengl: only open one OpenGL/DX interop handle when using dxva2
Previously, gl->DXOpenDeviceNV was called twice using dxva2 with dxinterop. AMD
drivers refused to allow this. With this commit, context_dxinterop sets its own
implementation of MPGetNativeDisplay, which can return either a
IDirect3DDevice9Ex or a dxinterop_device_HANDLE depending on the "name" request
string. hwdec_dxva2gldx then requests both of these avoiding the need to call
gl->DXOpenDeviceNV a second time.
2016-03-15 17:04:58 -07:00
Kevin Mitchell 8ff09f3217 vo_opengl: add dxva2 interop to angle backend
Like dxinterop, this uses StretchRect or RGB conversion. This is unavoidable as
long as we use the dxva2 API, as there is no way to access the raw hardware
decoded Direct3D9 surfaces.
2016-03-10 15:49:55 -08:00
wm4 0e1e4005fb vo_opengl: use the same type for cached and current uniform values
Slightly improvement over the previous commit.
2016-03-10 22:42:20 +01:00
igv 5199c2ee3a vo_opengl: cache the values of the uniform variables 2016-03-10 22:40:14 +01:00
igv 95ca308d44 vo_opengl: cache the locations of the uniform variables 2016-03-09 22:57:05 +01:00
Niklas Haas 2db1b9e474 vo_opengl: decrease default superxbr-edge-strength
The default of 1.0 was basically making half the algorithm do nothing,
since it turned off all diagonal contributions. The upstream default is
0.6, and this produces a more reasonable image.
2016-03-07 22:31:15 +01:00
Niklas Haas c68721b832 vo_opengl: improve superxbr algorithm
The values were changed to reflect an upstream change in the source for
the super-xBR implementation.

The anti-ringing code was basically not working at all, the new
algorithm _significantly_ improves the result (reduces ringing).
2016-03-07 22:31:15 +01:00
Niklas Haas 9f91bc4b75 vo_opengl: refactor superxbr algorithm
This is a fresh implementation from scratch that carries with it
significantly less baggage and verbosity from the previous (ported)
version.

The actual values for the masks and such were copied from the
current code. Behavior and performance should be unaffected.

An important difference between the old code and the new code is that
the new code always explicitly samples from the first component, rather
than being able to process multiple planes at once.

Since prescale-luma only affects luma, I deemed this unnecessary. May
change in the future, if prescale-chroma ever gets implemented. But
prescaling multiple planes would be slow to do this way. (Better would
be to generalize it to differently-sized vectors)
2016-03-07 22:31:15 +01:00
Niklas Haas a4dfc28fe1 vo_opengl: refactor plane-skipping optimizations
Instead of hard-coding the logic and planes to skip, factor this out
to a reusible function, and instead add the number of relevant
coordinates to the texture state.
2016-03-05 13:08:38 +01:00
Niklas Haas b81036524a vo_opengl: rename prescale to prescale-luma
Since prescale now literally only affects the luma plane (and the
filters are all designed for luma-only operation either way), the option
has been renamed and the documentation updated to clarify this.
2016-03-05 13:08:38 +01:00
Niklas Haas 8ac6f6acf0 vo_opengl: add macros for scaler units
There was no real point in hard-coding these all over the place,
especially since the order was sort of arbitrary and confusing.
2016-03-05 13:08:38 +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
wm4 5c20263364 vo_opengl: wayland: don't destroy NULL wl_egl_window
The wayland client API crashes intentionally when trying to free NULL
objects. (Thanks.)
2016-03-03 15:30:28 +01:00
igv b638a413c3 vo_opengl: remove redundant code 2016-02-28 17:46:16 +01:00
igv 8bafd68fff vo_opengl: set uniform variable "pixel_size" for internal shaders 2016-02-26 23:21:03 +01:00
igv 3d2fb9e9a8 vo_opengl: dxinterop: fix compatibility issue with Vista 2016-02-26 23:20:27 +01:00
wm4 f0b15ad447 vo_opengl, vo_rpi: unbreak a few things
Commit 2f562825 didn't remove the "color" declaration for these. Since
the shader header already declares it, shader compilation broke.
2016-02-24 10:23:50 +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
igv f0794d0544 vo_opengl: set uniform variable "pixel_size"
pixel_size is often used variable, also reciprocal is a costly operation
for AMD and older nVidia (prior to Kepler) GPUs.
2016-02-22 22:33:04 +01:00
igv 935c8402bc vo_opengl: set the correct size of the input image 2016-02-22 22:32:49 +01:00
James Ross-Gowan 53ef4822e8 dxva2: fix shared surface type
The WGL_NV_DX_interop spec says that a shared IDirect3DSurface9 must not
be lockable, but off-screen plain surfaces are always lockable and using
them causes Nvidia drivers to crash. Use a rendertarget for the shared
surface instead.

This also changes the name of the DX_interop handle for the rendertarget
to match the name of the DirectX object (rather than the GL one) to
match the convention used in context_dxinterop.c.
2016-02-19 00:37:21 +11:00
wm4 c01aaabb3e vo_opengl: use correct gl_target variable
p->gl_target and plane->gl_target are always the same value here, but
semantically plane->gl_target is the correct one.
2016-02-18 10:46:03 +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 d6af58c699 vo_opengl: pass the correct target to deband functions
Apple crap (namely hardware decoding interop) forces us to use rectangle
textures for input. But after that we continue with normal textures.
This was not considered for debanding, and the sampler type used for it
can be different depending on the exact render chain. Simply use the
target type of the input texture.
2016-02-18 10:41:13 +01:00
Kevin Mitchell 0d40140668 wscript: remove dxva2-dxinterop configure test
Wasn't really necessary as it was equivalent to gl-dxinterop.
2016-02-17 10:17:52 -08:00
Kevin Mitchell 2d1f42089c vo_opengl: dxinterop: add dxva2 passthrough
Use dxva2 surface to fill RGB IDirect3DSurface9 shared with opengl via
DXRegisterObjectNV.
2016-02-17 09:07:12 -08:00
Kevin Mitchell 941885b62c vo_opengl: dxinterop: improve error messages
* use mp_HRESULT_to_str/mp_LastError_to_str
* make some messages non-identical
* replace "GL" -> "OpenGL"
* change some MP_FATAL to MP_ERR that don't actually kill the vo
2016-02-17 06:59:02 -08:00
wm4 fd80fcd3f3 vo_opengl: unconfuse Coverity
It thinks that integer_conv_fbo[index] is implied to be accessed with up
to index=5. Although that is theoretical only, it has a point that this
makes no sense. Use the same constant for the array allocation, to make
it more uniform and robust.

Fixes CID 1350060.
2016-02-12 15:56:58 +01:00
Jan Ekström 4b97869e5f Enable building the opengl-cb video renderer on Android
* Add Android-specific OpenGL ES feature and checks
* Add missing GL_* symbols for Android
  (list gathered by Ilya Zhuravlev <whatever@xyz.is>)
2016-02-10 21:29:42 +01:00
wm4 9f6dfaabf9 vo_opengl: vdpau: call glVDPAUFiniNV only if initialized
This is "more correct". See #2798.
2016-02-08 13:39:33 +01:00
wm4 05ffde6599 vo_opengl: hwdec: use IDs for API, and log which backend is used
Since there can be multiple backends for a single API (vaapi can use GLX
or EGL), not logging the exact backend name is annoying. So add it. At
the same time, there is no need to duplicate the name as used by the
--hwdec options, so replace it with using the numeric hwdec API ID.
2016-02-01 20:02:52 +01:00
wm4 fb3b8e1e25 vo_opengl: do chroma merging in integer conversion stage
This is a huge win when playing yuv420p10 on ANGLE - the 2 conversion
stages for planes 1 and 2 and the chroma merging stage are all merged
into one.
2016-01-27 21:08:30 +01:00
wm4 f8bb24184b vo_opengl: add precision qualifier to usampler2D on ANGLE
GLES requires this. Some more common sampler types have default
precisions, but not usampler2D. Newer ANGLE builds verify this more
strictly than older builds, so this wasn't caught before.

Fixes #2761.
2016-01-27 21:07:57 +01:00
wm4 34bead4859 vo_opengl: replace tscale-interpolates-only with interpolation-threshold
The previous approach was too naive, and can e.g. ruin playback if
scheduling switches e.g. between 1 and 2 vsync per frame.
2016-01-27 21:07:17 +01:00
wm4 7b6e3772ab vo_opengl: support 10 bit support with ANGLE
GLES does not support high bit depth fixed point textures for unknown
reasons, so direct 10 bit input is not possible. But we can still use
integer textures, which are supported by GLES 3.0. These store integer
data just like the standard fixed point textures, except they are not
normalized on sampling. They also don't support bilinear filtering, and
require a special sampler ("usampler2D").

While these texture formats enable us to shuffle the data to the GPU,
they're rather impractical with the requirements mentioned above and our
current architecture. One problem is that most code assumes it can
always use bilinear scaling (even if bilinear is never used when using
appropriate scale/cscale options). Another is that we don't have any
concept of running a function on a texture in an uniform way.

So for now, run a simple conversion step through a FBO. The FBO will use
the rgba16f format normally, which gives enough bits for 10 bit, and
will at least gracefully degrade with higher depth input.

This is bound to be much slower than a more "direct" method, but at
least it works and is simple to implement.

The odd change of function call order in init_video() is to properly
disable "dumb mode" (no FBO use) if these texture formats are in use.
2016-01-26 21:35:23 +01:00
wm4 beb7094301 vo_opengl: actually reset use_normalized_range field
This was never reset - absolutely can't be right. If the renderer
somehow switches back to another codepath, it certainly has to be reset.
Maybe this was hard to hit, as the normalization is going to be
idempotent in simpler cases (like rendering RGBA input).

Also get rid of the "merged" variable.
2016-01-26 21:35:23 +01:00
wm4 fc3ca14ef7 vo_opengl: default to rgba16f FBOs on ANGLE
Although it has only 1 bit more precission than rgba10_a2, it was
reported to improve the visual quality.
2016-01-26 21:35:16 +01:00
wm4 521110054d vo_opengl: add tscale-interpolates-only sub-option 2016-01-25 21:46:40 +01:00
wm4 bd1fb6f9b1 vo_opengl: default scaler-resizes-only sub-option to yes
Often requested. The main argument, that prominent scalers like sharpen
change the image even if no scaling happens, disappeared anyway.
("sharpen", unsharp masking, is neither prominent nor a scaler anymore.
This is an artifact from MPlayer, which fuses unsharp masking with
bilinear scaling in order to make it single-pass, or so.)
2016-01-25 21:46:40 +01:00
wm4 7f300b4204 vo_opengl: rename custom shader entrypoint from sample to sample_pixel
"sample" is a reserved identifier at least in GLES ES. Suggestions for a
better name than "sample_pixel" are still welcome.

Fixes #2733.
2016-01-25 20:24:41 +01:00
wm4 eaf2eebb50 vo_opengl: vdpau: better handling of preemption recovery
If recovery from preemption is done successfully, continue normally.
Only fail if it's preempted during init.
2016-01-25 19:40:35 +01:00
wm4 3a015b9ec7 video: remove some useless old RGB formats
Some VOs had support for these - remove them.

Typically, these formats will have only some use in cases where using
RGB software conversion with libswscale is faster than letting the
VO/GPU do it (i.e. almost never). For the sake of testing this case,
keep IMGFMT_RGB565. This is the least messy format, because it has no
padding/alpha bits with unknown semantics.

Note that decoding to these formats still works. We'll let libswscale
repack the data to whatever the VO in use can take.
2016-01-25 10:43:35 +01:00
wm4 4c25f49236 vo_opengl: vaapi: don't expect EGL exts. to be in common ext. string 2016-01-22 19:56:10 +01:00
wm4 03b50d4bf6 vo_opengl: vaapi: reorganize platform entrypoints as table 2016-01-21 13:32:29 +01:00
wm4 68366b05f2 vo_opengl: add KMS/DRM VAAPI hardware decoding interop
Just requires glueing it together with Bloat Super Glue (tm).
2016-01-20 19:41:29 +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 8a9b64329c Relicense some non-MPlayer source files to LGPL 2.1 or later
This covers source files which were added in mplayer2 and mpv times
only, and where all code is covered by LGPL relicensing agreements.

There are probably more files to which this applies, but I'm being
conservative here.

A file named ao_sdl.c exists in MPlayer too, but the mpv one is a
complete rewrite, and was added some time after the original ao_sdl.c
was removed. The same applies to vo_sdl.c, for which the SDL2 API is
radically different in addition (MPlayer supports SDL 1.2 only).

common.c contains only code written by me. But common.h is a strange
case: although it originally was named mp_common.h and exists in MPlayer
too, by now it contains only definitions written by uau and me. The
exceptions are the CONTROL_ defines - thus not changing the license of
common.h yet.

codec_tags.c contained once large tables generated from MPlayer's
codecs.conf, but all of these tables were removed.

From demux_playlist.c I'm removing a code fragment from someone who was
not asked; this probably could be done later (see commit 15dccc37).

misc.c is a bit complicated to reason about (it was split off mplayer.c
and thus contains random functions out of this file), but actually all
functions have been added post-MPlayer. Except get_relative_time(),
which was written by uau, but looks similar to 3 different versions of
something similar in each of the Unix/win32/OSX timer source files. I'm
not sure what that means in regards to copyright, so I've just moved it
into another still-GPL source file for now.

screenshot.c once had some minor parts of MPlayer's vf_screenshot.c, but
they're all gone.
2016-01-19 18:36:06 +01:00
Dmitrij D. Czarkoff ea442fa047 mpv_talloc.h: rename from talloc.h
This change helps avoiding conflict with talloc.h from libtalloc.
2016-01-11 21:05:55 +01:00
wm4 453ea2cb6c vaapi: replace VA_STR_FOURCC 2016-01-11 20:30:36 +01:00
wm4 27bc881cd8 vo_opengl: generic semi-planar support
Should take care of the planned FFmpeg AV_PIX_FMT_P010 addition. (This
will eventually be needed when doing HEVC Main 10 decoding with DXVA2
copyback.)
2016-01-07 16:31:52 +01:00
wm4 38636345b1 vo_opengl: hwdec_vdpau: relicense under LGPL
All code was written by myself.
2016-01-07 11:22:54 +01:00
wm4 9604c45e24 vo_opengl: video.h: fix license
This is a mistake coming from commit 6ef06aa1: it accidentally changed
the license from GPL/LGPL dual to GPL only.
2016-01-07 10:48:04 +01:00
wm4 e69d1f2780 vo_opengl: hwdec_vaegl: change license to LGPL 2.1
This file claims to be based on the "MPlayer VA-API patch", but this is
untrue. Only some glue code was copied from hwdec_vaglx.c, and this glue
code was never in MPlayer or the MPlayer VA-API patch in any form, and
instead part of the mpv-original way we do hardware decoding OpenGL
interop. The EGL interop method didn't exist at the time the MPlayer
VA-API patch was created either.
2016-01-07 10:46:15 +01:00
wm4 c725f39bae vo_opengl: fix operation on GLES 2.0
GLSL in GLES 2.0 did not have line continuation in its preprocessor.
This broke shader compilation. It also broke subtitle rendering in
vo_rpi, which reuses some of the OpenGL code.

Line continuation was finally added in GLES 3.0, which is perhaps the
reason why ANGLE accepted it.
2016-01-04 16:34:16 +01:00
Bin Jin 2f4bd58f4a vo_opengl: reset nnedi3 weights properly
Fixes #2661
2016-01-03 23:33:54 +01:00
wm4 aa587580c8 vo_rpi: fix compilation
Untested, but should be fine. Broken by commit 0a0bb905.

Also fix the include statement in context_rpi.c, which caused another
compilation failure. Also untested. (Because I'm lazy.)

Fixes #2638.
2015-12-26 19:18:47 +01:00
wm4 082c23515f vo_opengl: fix operation on GLSL versions earlier than 1.30
GLSL below version 1.30 does not support mix() with a boolean
interpolation value. Use ?: instead. Untested, but probably works.
2015-12-24 14:44:46 +01:00
wm4 1a6f3c56ea vo_opengl: fall back to gcc thread local storage
gcc 4.8 does not support C11 thread local storage. This is a bit
annoying, so add a hack to use the gcc specific __thread extension if
C11 TLS is not available.

(This is used for the extremely silly mpv-internal way hwdec modules
access some platform specific handles. Disabling it simply made
hwdec_vaegl.c always fail initialization.)

Fixes #2631.
2015-12-23 17:59:35 +01:00
wm4 eac0665b8d vo_opengl: blend transparent video against tiles by default
Add a "blend-tiles" choice to the "alpha" sub-option. This is pretty
simplistic and uses the GL raster position to derive the tiles. A weird
consequence is that using --vo=opengl and --vo=opengl-hq gives different
scaling behavior (screenspace pixel size vs. source video pixel size
16x16 tiles), but it seems we don't have easy access to the original
texture coordinates. Using the rasterpos is probably simpler.

Make this option the default.
2015-12-22 23:18:46 +01:00
wm4 31c29495ca vo_opengl: x11: fix alpha windows
long is 64 bits on x86_64 on Linux, which means the check for the corner
case of computing the depth mask is wrong.

Also, X11 compositors seem to expect premultiplied alpha.
2015-12-20 13:26:25 +01:00
wm4 cd24fdcd5a vo_opengl: disable pbo by defaults for opengl-hq
Too many problems.
2015-12-19 16:26:36 +01:00
wm4 47f2f554a3 vo_opengl: handle alpha with odd bit widths too
Since alpha isn't pulled through the colormatrix (maybe it should?), we
reject alpha formats with odd sizes, such as yuva444p10.

But the awful tex_mul path in vo_opengl does this anyway (at some points
even explicitly), which means there will be a subtle difference in
handling of 16 bit yuv alpha formats. Make it consistent and always
apply the range adjustment to the alpha component. This also means odd
sizes like 10 bit are supported now.

This assumes alpha uses the same "shifted" range as the yuv color
channels for depths larger than 8 bit. I'm not sure whether this is
actually the case.
2015-12-19 16:11:34 +01:00
wm4 a0519f1d18 vo_opengl: cocoa: output premultiplied alpha
Which is apparently what is expected here. (I'm pretty sure X11
compositors want stright alpha, so 2 code paths are needed.)
2015-12-19 14:14:12 +01:00
wm4 4cc1861378 vo_opengl: prefix per-backend source files with context_ 2015-12-19 14:14:12 +01:00
wm4 6154c1d06d vo_opengl: split backend code from common.c to context.c
Now common.c only contains the code for the function loader, while
context.c contains the backend loader/dispatcher.

Not calling it "backend.c", because the central struct is called
MPGLContext.
2015-12-19 14:14:12 +01:00
wm4 32cd85bc7e vo_opengl: x11egl: retrieve framebuffer depth
This is used for dithering, although I'm not aware of anyone who got
higher than 8 bit depth support to work on Linux.

Also put this into egl_helpers.c. Since EGL is pseudo-portable at best I
have no hope that the EGL context creation code in all the backends can
be fully shared. But some self-contained functionality can definitely be
shared.
2015-12-19 14:14:12 +01:00
wm4 3394d37b4e vo_opengl: refactor how framebuffer depth is passed from backends
Store the determined framebuffer depth in struct GL instead of
MPGLContext. This means gl_video_set_output_depth() can be removed, and
also justifies adding new fields describing framebuffer/backend
properties to struct GL instead of having to add more functions just to
shovel the information around.

Keep in mind that mpgl_load_functions() will wipe struct GL, so the
new fields must be set before calling it.
2015-12-19 14:14:12 +01:00
wm4 d2baaaa7df vo_opengl: cocoa: implement alpha window support
With --vo=opengl:alpha=yes, the Cocoa backend will now render alpha
video without background.
2015-12-19 10:24:03 +01:00
wm4 58d45f7b3e vo_opengl: fix "win" backend name
Although the source file is named w32.c, the backend name was "win"
until recently. It was accidentally changed to "w32"; fix it.

Fixes #2608 (the manual is correct).
2015-12-19 08:39:14 +01:00
James Ross-Gowan d0fd68f6df vo_opengl: dxinterop: prevent crash after lost device
When a Direct3D 9Ex device fails to reset, it gets put into the lost
state, so set the lost_device flag and don't attempt to present until
the device moves out of that state. Failure to recreate the size-
dependent objects should set lost_device as well, since we shouldn't try
to present in that state.

Also, it looks like I was too eager to remove code that sets priv
members to NULL and I accidentally removed some that was needed.
2015-12-14 23:09:54 +11:00
James Ross-Gowan 8d0a6cd035 vo_opengl: dxinterop: prevent crash with 0-size window
Direct3D doesn't like 0-sized swapchain dimensions, even when those
dimensions are automatically set. Manually set them to a size that isn't
zero instead.
2015-12-14 01:11:56 +11:00
wm4 f24ba544cd vo_opengl: enable brightness/contrast controls for RGB
Why not.

Also, instead of disabling hue/saturation for RGB, just don't apply
them. (They don't make sense for conversion matrixes other than YUV, but
I can't be bothered to keep the fine-grained disabling of UI controls
either.)
2015-12-12 14:47:30 +01:00
James Ross-Gowan 3d12312806
vo_opengl: add dxinterop backend
WGL_NV_DX_interop is widely supported by Nvidia and AMD drivers. It
allows a texture to be shared between Direct3D and WGL, so that
rendering can be done with WGL and presentation can be done with
Direct3D. This should allow us to work around some persistent WGL
issues, such as dropped frames with some driver/OS combos, drivers that
buffer frames to increase performance at the cost of latency, and the
inability to disable exclusive fullscreen mode when using WGL to render
to a fullscreen window.

The addition of a DX_interop backend might also enable some cool
Direct3D-specific enhancements in the future, such as using the
GetPresentStatistics API to get accurate frame presentation timestamps.

Note that due to a driver bug, this backend is currently broken on
Intel. It will appear to work as long as the window is not resized too
often, but after a few changes of size it will be unable to share the
newly created renderbuffer with GL. See:
https://software.intel.com/en-us/forums/graphics-driver-bug-reporting/topic/562051
2015-12-11 18:29:18 +01:00
wm4 47e6ef0bdf vo_opengl: remove one more XYZ special-case
The XYZ colorspace on XYZ pixfmt is enforced in some sanitation routine.
2015-12-09 17:10:38 +01:00
Bin Jin 6d36c432ab vo_opengl: fix precision loss of fruit dithering matrix
With default setting, the matrix for fruit dithering requires 12 bits
precision (values from 0/4096 to 4095/4096). But 16-bit float
provides only 10 bits. In addition, when `dither-size-fruit=8` is
set, 16 bits are required from the texture format.

Fix this by attempting to use 16 bit integer texture first. This is
still not precise, but should be better than using a half float.
2015-12-09 00:36:48 +01:00
wm4 45ae0716be csputils: rename "yuv2rgb" functions
They're not necessarily restricted to YUV aka YCbCr.

vo_direct3d.c and demux_disc.c (DVD specific code) changes untested.
2015-12-09 00:23:36 +01:00
wm4 c5c7b239b6 csputils, vo_opengl: remove XYZ special case in color matrix retrieval
This just seems unnecessary. Refactor it a bit. There should be no
functional changes.
2015-12-09 00:16:51 +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
wm4 c138505813 vo_opengl: enable colormatrix even for RGB input
Enables brightness/contrast controls, and handles gbrp10 correctly.
2015-12-07 23:48:59 +01:00
wm4 663415b914 vo_opengl: fix issues with some obscure pixel formats
The computation of the tex_mul variable was broken in multiple ways.
This variable is used e.g. by debanding for moving expansion of 10 bit
fixed-point input to normalized range to another stage of processing.

One obvious bug was that the rgb555 pixel format was broken. This format
has component_bits=5, but obviously it's already sampled in normalized
range, and does not need expansion. The tex_mul-free code path avoids
this by not using the colormatrix. (The code was originally designed to
work around dealing with the generally complicated pixel formats by only
using the colormatrix in the YUV case.)

Another possible bug was with 10 bit input. It expanded the input by
bringing the [0,2^10) range to [0,1], and then treating the expanded
input as 16 bit input. I didn't bother to check what this actually
computed, but it's somewhat likely it was wrong anyway. Now it uses
mp_get_csp_mul(), and disables expansion when computing the YUV matrix.
2015-12-07 23:48:59 +01:00
Bin Jin c569d4f6ed vo_opengl: decrease default lookup texture size to 64
It turns out that with accurate lookup we can decrease the
default size of texture now. Do it to compensate the performance
loss introduced by the LUT_POS macro.
2015-12-07 23:48:40 +01:00
Bin Jin e6058d3dc3 vo_opengl: make LOOKUP_TEXTURE_SIZE configurable 2015-12-07 23:48:18 +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 81746a1798 win32: remove dwmapi.dll dynamic loading
All Windows versions we support have this API.
2015-12-04 16:30:53 +01:00
wm4 17507b5935 vo_opengl: require --enable-gpl3 for nnedi
There are claims that nnedi3.c doesn't constitute its own new
implementation, but is derived from existing HLSL or OpenCL shaders
distributed under the LGPLv3 license.

Until these are resolved, do the "correct" thing and require
--enable-gpl3 to build nnedi.
2015-12-03 09:32:40 +01:00
wm4 03d311823d vo_opengl: fix backend=x11 on Intel
"backend=x11" was resolved to x11_probe, which is unintentional.
2015-12-02 14:19:17 +01:00
Bin Jin 9cb7646071 vo_opengl: add credits to NNEDI3 shader
Add credits to several existing implementation of NNEDI3 shader.
2015-12-02 12:32:17 +01:00
Bin Jin 42a0f4d87b vo_opengl: enable NNEDI3 prescaler on OpenGL ES 3.0
It turns out that both UBO and intBitsToFloat() are supported in
OpenGL ES 3.0[1][2], enable them so that NNEDI3 prescaler can be used
in a wider range of backends.

Also fixes some implicit int-to-float conversions so that the shader
actually compiles on GLES.

Tested on Linux desktop (nvidia 358.16) with "es" sub-option.

[1]: https://www.khronos.org/opengles/sdk/docs/man3/html/glGetUniformBlockIndex.xhtml
[2]: https://www.khronos.org/opengles/sdk/docs/manglsl/docbook4/xhtml/intBitsToFloat.xml
2015-12-02 12:32:02 +01:00
wm4 6ff1cd5502 vo_opengl: make tscale=mitchell:tscale-clamp the default
Looks better than "oversample". tscale-clamp suggested by haasn.
2015-11-29 17:55:01 +01:00
wm4 9fc74d5acd vo_opengl: warn if interpolation is enabled, but not display-sync
Try to avoid user confusion.

Reading the global options in this place is a pretty disgusting hack,
but it's still the most robust way.
2015-11-28 20:10:01 +01:00
wm4 318e9801f2 vo_opengl: fix interpolation with display-sync
At least I hope so.

Deriving the duration from the pts was not really correct. It doesn't
include speed adjustments, and becomes completely wrong of the user e.g.
changes the playback speed by a huge amount. Pass through the accurate
duration value by adding a new vo_frame field.

The value for vsync_offset was not correct either. We don't need the
error for the next frame, but the error for the current one. This wasn't
noticed because it makes no difference in symmetric cases, like 24 fps
on 60 Hz.

I'm still not entirely confident in the correctness of this, but it sure
is an improvement.

Also, remove the MP_STATS() calls - they're not really useful to debug
anything anymore.
2015-11-28 15:45:49 +01:00
wm4 7023c383b2 vo: change vo_frame field units
This was just converting back and forth between int64_t/microseconds and
double/seconds. Remove this stupidity. The pts/duration fields are still
in microseconds, but they have no meaning in the display-sync case (also
drop printing the pts field from opengl/video.c - it's always 0).
2015-11-27 22:04:44 +01:00