Commit Graph

43583 Commits

Author SHA1 Message Date
Niklas Haas f8df0528b5 vo_opengl: skip junk before first user shader pass
A lot of real-world shaders start off with comments explaining the usage
or license, generating lots of "empty" passes. This simply change allows
us to skip them, which silences the warning spam and prevents us from
having to store and copy around these empty passes.

It also adds a more useful failure check: Attempting to use a user
shader that doesn't define any passes at all.
2016-05-27 17:03:00 +02:00
Yen Chi Hsuan 72e94941c9 TOOLS/zsh.pl: add .f4v extension in zsh completions 2016-05-27 17:03:00 +02:00
James Ross-Gowan 84fba1df21 vo_opengl: enable color management on GLES
This requires the GL_EXT_texture_norm16 extension and works in ANGLE.
A default precision had to be set for sampler3Ds, otherwise the shaders
would fail to compile.
2016-05-27 23:02:26 +10:00
wm4 ca87e623b5 command: add playlist-pos-1 property
This has often been requested for use on OSD. I don't really like having
such "special" properties, but whatever. Hopefully this will be the only
case.

Untested because I'm too damn lazy.

Fixes #2828.
2016-05-26 18:44:01 +02:00
wm4 306c554376 vo_opengl: fix superxbr shader compilation on ES
ES shaders do not allow implicit conversion from int to float, which
is the most annoying ES anti-feature ever.
2016-05-26 08:21:10 +02:00
wm4 e5f49d9685 vo_opengl: always autoselect ANGLE as backend if available
Remove the opengl-hq option default that caused it not to autoselect
ANGLE (unlike --vo=opengl). Details see commit d5df90a2.

Back then the intention was to use ANGLE by default, since it integrates
much nicer with the Windows compositor (instead of native OpenGL, which
tends to cause crazy glitches). On the other hand, many opengl-hq
capabilities are not available with older ANGLE builds, so it didn't
make any sense to autoselect ANGLE for it.

With the GL_EXT_texture_norm16 extension recently added to ANGLE, it has
essentially reached feature parity to desktop GL for the subset we are
using. (Even the integer texture hack for high bit depth input could be
dropped now.)

It (probably) still does not support nnedi3, due to the weird way the NN
coefficients are imported. Also, it uses half-floats instead of 16 bit
fixed-point textures for technical reasons, which implies about 5 bits
of precision loss. If anyone actually manages to distinguish the two
dithering texture formats in a double-blind test, I will fix it.
2016-05-26 00:07:10 +02:00
wm4 5c9f164caf vf_vavpp: make refqueue logic field-based
Abstracts the annoying framerate-doubling behavior.

Same deal as with refqueue introduction: the code size blows up, but at
least it can be reused for other filters.
2016-05-25 23:51:24 +02:00
wm4 fc18e1df62 vf_vavpp: minor simplification 2016-05-25 23:51:24 +02:00
wm4 68191fdca7 vf_vavpp: simplify update_pipeline() usage
Calling this right at start of filter_ext() also fixes a small
regression from previous commit. The change in reference surfaces due to
the first update_pipeline() with deinterlacing enabled changed behavior
of mp_refqueue_next() and mp_refqueue_has_output(). Since
update_pipeline() was called between those, the frame output logic got
inconsistent, and the first deinterlaced frame was duplicated from the
previous non-deinterlaced frame.

Also reset the number of ref-frames when switching back to non-deint
mode.
2016-05-25 23:51:24 +02:00
wm4 5353571de0 vf_vavpp: use future instead of past PTS to determine field duration
If the deinterlacer separates fields, the framerate must be doubled.
Since we have no stable and reliably framerate anywhere, we've been
calculating it by taking the time halfway to the next frame.

vf_vavpp actually used the past frame to calculate the frame duration,
which is sort of ok, but will skip the 2nd field in a stream (since the
first frame has no past PTS). This is annoying for testing, so use the
future frame PTS instead, which means the last field of the stream will
be dropped instead.
2016-05-25 23:51:24 +02:00
wm4 15a5d33b79 vf_vavpp: move frame handling to separate file
Move the handling of the future/past frames and the associated dataflow
rules to a separate source file.

While this on its own seems rather questionable and just inflates the
code, I intend to reuse it for other filters. The logic is annoying
enough that it shouldn't be duplicated a bunch of times.

(I considered other ways of sharing this logic, such as an uber-
deinterlace filter, which would access the hardware deinterlacer via a
different API. Although that sounds like kind of the right approach,
this would have other problems, so let's not, at least for now.)
2016-05-25 23:51:24 +02:00
wm4 b9cc33de58 win32: pthread: use SRW locks by default
SRW locks are available since Windows Vista. They work essentially like
Linux futexes. In particular, they can be statically initialized, and do
not require deinitialization. This makes them ideal for implementing
PTHREAD_MUTEX_INITIALIZER.

We still need CRITICAL_SECTION for recursive mutexes.
2016-05-24 19:02:22 +02:00
wm4 8ff96f0216 hwdec_d3d11egl: call ID3D11DeviceContext::Flush
This must be called if a texture shared between D3D devices is updated.

Often enough, the shared devices will be the same device, but ANGLE
forces using shared surfaces. I suppose there is no guarantee the driver
will do the expected thing. Internally, the driver could for example not
insert the required barriers before the shared texture is used.
2016-05-24 14:30:15 +02:00
dequis d941a57bd3 vo_xv: Handle incorrect size returned by Xv(Shm)CreateImage
Fixes #320 (which is closed as 'not our problem' but eh)

Relevant xorg bug: https://bugs.freedesktop.org/show_bug.cgi?id=70931

For me this happened when (accidentally) trying to play a 8460x2812 jpg
file with mpv. Like the referenced bug, xvinfo reports "maximum XvImage
size: 8192 x 8192". So the returned XvImage is 8192x2812 and memory
corruption happens.

Only after handling this BadShmSeg X11 errors are shown.
2016-05-24 10:25:39 +02:00
wm4 6bd021e4ee manpage: adjust dxva2 description 2016-05-23 23:46:58 +02:00
wm4 e293e411b5 etc/mpv.conf: add missing comment
The config file is an example, and is not supposed to actually define
anything by default.
2016-05-23 23:41:58 +02:00
wm4 335278b86e manpage: document how hardware decoding might cause quality loss 2016-05-23 22:55:30 +02:00
wm4 c4707cdee6 vo_opengl: fix other minor namespace issues
See previous commit.
2016-05-23 21:27:18 +02:00
wm4 e76aa7e8db vo_opengl: rename glUploadTex, drop unused parameter
Rename it to get out of OpenGL's namespace. The gl_ prefix is used by
other mpv functions, but no OpenGL ones.

The "slice" parameter was never actually used, and all callers passed 0
for it.
2016-05-23 21:27:18 +02:00
wm4 66079048ea vo_opengl: unify PBO and normal OSD texture upload path
The main change is actually that e first copy to a "staging" memory
frame, and then upload this at once. The old non-PBO code called
glTexsubImage2D for each OSD sub-bitmap.

The new non-PBO code path is a bit faster now if there are many small
sub-bitmaps (on Linux/nVidia). It's also a bit simpler, so this is a
win.

(Although I don't particularly appreciate the mixed normal/PBO texture
code.)
2016-05-23 21:27:18 +02:00
wm4 049e3ccb65 vo_opengl: make ES float texture format checks stricter
Some of these checks became pointless after dropping ES 2.0 support for
extended filtering.

GL_EXT_texture_rg is part of core in ES 3.0, and we already check for
this version, so testing for the extension is redundant.

GL_OES_texture_half_float_linear is also always available, at least as
far as our needs go.

The functionality we need from GL_EXT_color_buffer_half_float is always
available in ES 3.2, and we explicitly check for ES 3.2, so reject this
extension if the ES version is new enough.
2016-05-23 21:27:18 +02:00
wm4 80d702dce8 vo_opengl: make PBOs work on GLES 3.x
For some reason, GLES has no glMapBuffer, only glMapBufferRange.

GLES 2 has no buffer mapping at all, and GL 2.1 does not always have
glMapBufferRange. On those PBOs remain unsupported (there's no reason to
care about GL 2.1 without the extension).

This doesn't actually work on ANGLE, and I have no idea why. (There are
artifacts on OSD, as if parts of the OSD data weren't copied.) It works
on desktop OpenGL and at least 1 other ES 3 implementation. Don't enable
it on ANGLE, I guess.
2016-05-23 21:27:18 +02:00
Ben Boeckel afcef4c25b docs: fix some typos 2016-05-23 21:27:18 +02:00
wm4 75f373cc46 vo_opengl: remove unused glDrawBuffer 2016-05-23 21:27:18 +02:00
wm4 cc72a4e8c3 vo_opengl: support framebuffer invalidation
Not sure how much can be gained with this, as we can't use it properly
yet. For now, this is used only before rendering, which probably does
overwhelmingly nothing.

In the future, this should be used after temporary passes, which could
possibly reduce memory usage and even memory bandwidth usage, depending
on the drivers.
2016-05-23 21:27:18 +02:00
wm4 cc4a0571fa vo_opengl: slightly improve logging of loaded extensions
Only log when actual extensions are loaded, never log anything about
builtins.
2016-05-23 21:27:18 +02:00
wm4 c06a92e09e demux_edl: adjust warnings and variable names
Don't warn against unknown sourve length if the segment length is
explicitly provided.

Rename "len" to "end_time", because that's what it actually is.
2016-05-23 15:23:27 +02:00
Ricardo Constantino 4ff2a60632 ytdl_hook: support multi-arc subtitles
While at it, pass durations of segments from ytdl if available.
2016-05-23 15:14:14 +02:00
Josh de Kock 4aa017e301 ao_opensles: remove 32bit audio
It's unsupported by android, and can cause problems when trying to play 32bit audio. Removing 32bit fixes it by forcing 16 bit or 8 bit audio.
2016-05-22 14:31:37 +02:00
maniak1349 c4e8c36071 options: --geometry: center window position after applying size
Center window position after applying W and H parameters of the --geometry
option. Passing valid X and Y values will still override the position.

Fixes #2397.
2016-05-22 14:31:37 +02:00
maniak1349 5a3c299ca1 w32_common: make VOCTRL_SET_UNFS_WINDOW_SIZE resize the window around its center
Before that position of the window top-left corner was remaining the same
when the window was scaled.

Right now VOCTRL_SET_UNFS_WINDOW_SIZE is called only by window-scale. This
change will not affect resizes made by the user (dragging window edge).

Fixes #3164.
2016-05-22 14:31:37 +02:00
maniak1349 364af7c630 w32_common: center window on original window center on resize to fit screen
Center the window on the original window center instead of the screen center
when the window has been resized due to requested window size exceeding the
size of the screen.

If user moved the window, he probably did it for the reason and he probably
don't want it to get back to the center of the screen when he is resizing it
(with window-scale for example).
2016-05-22 14:31:37 +02:00
maniak1349 981048e041 w32_common: update stored client area size on window resize
Properly update stored client area size when the window is resized in
reinit_window_state due to window size exceeding the size of the screen.

This was causing wrong behavior with window-scale - when window size was
becoming too big the window was resized but the video was not.
2016-05-22 14:31:37 +02:00
wm4 035297212a demux_mkv: better resync behavior for broken google-created webms
I've got a broken webm that fails to seek correctly with "--start=0".
The problem is that every index entry points to 1 byte before cluster
start (!!!). demux_mkv tries to resync to the next cluster, but since it
already has read 2 bytes with ebml_read_id(), it doesn't get the first
cluster, but the following one. Actually, it can be any amount of bytes
from 1-4, whatever happens to look valid at this essentially random byte
position.

Improve this by resyncing from the original position, instead of the one
after the EBML element ID has been attempted to be read.

The file shows the following headers:

| + Muxing application: google at 177
| + Writing application: google at 186

Indeed, the file was downloaded with youtube-dl. I can only guess that
Google got it completely wrong.
2016-05-21 16:39:44 +02:00
wm4 79afa347cc vo_opengl: remove non-working rgb/rgba FBO formats
Following commit 84ccebd9, the internal helpers don't allow GL_RGB and
GL_RGBA as internal formats for FBO attachments anymore.

While OpenGL itself is perfectly fine with it, I don't see much of a
reason to bother, and mixing sized and unsized internal formats is
confusing anyway.

Just remove these formats.
2016-05-20 23:21:43 +02:00
wm4 3deedef195 stream: separate posix/win32 cancellation code
This code evolved into an ifdef mess as support for cancellation on
Windows was added. Make the Windows-specific code completely separate.
It looks cleaner, and it also means that some of the posix code is not
uselessly enabled on Windows. The latter made msvcrt.dll output warnings
because it does not like -1 passed as FD to read/write. (The same would
be harmless on POSIX.)
2016-05-20 15:51:50 +02:00
Quentin Glidic f0d7437412 build: Do not link to libGL for egl-drm
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
2016-05-20 14:15:44 +02:00
wm4 e431a7bbfd vf_crop: support opaque hardware decoding formats
Cropping usually happens by adjusting the plane start pointers and the
image size. The former is obviously not possible for opaque hwaccel
formats, but the latter must work.

Since the code already takes care of aligning the top/left crop origin
to chroma alignment, simply set the crop origin to 0/0 in the hwaccel
case. Also add a message if such an adjustment happens.

Supporting this isn't worth much; the main usefulness is with debugging.
2016-05-19 22:56:11 +02:00
wm4 05b3a8cd14 vo_opengl: require at least ES 3.0 for float textures
ES 2.0 has this weird rule that not the internalformat parameter
determines the internal format, but the combination of all texture
parameters. GL_OES_texture_half_float thus does not specify e.g. a
GL_RGBA16F format, but requires passing GL_RGBA as format and
GL_HALF_FLOAT_OES as type. We won't bother with this, since ES 2.0 is a
lost cause anyway.

This also removes the OpenGL error when the code is trying to create a
f16 FBO for testing whether FBOs work.
2016-05-19 17:52:09 +02:00
wm4 561630cb01 vo_opengl: change error state handling and fix hwdec crashes on errors
gl_video_upload_image() can fail in the hardware decoding case. In this
case rendering continued "normally", which meant that pass_get_img_tex()
would kill the process with an assertion failure.

Fix this by allowing gl_video_upload_image() to fail, and exit rendering
early enough to skip code which requires an image to be present. (Maybe
this is still a bit too subtle, but better than before.)

Set an error flag, and render the blue screen we introduced for shader
errors. (For this purpose also move the rendering of it to final output,
to ensure it's visible at all.) The error flag is temporary, because the
associated failure might also be temporary, unlike shader compilation
errors.
2016-05-19 12:18:48 +02:00
wm4 4e5f1ec00e vo_opengl: d3d11egl: enable "required" GLSL extensions
ANGLE doesn't handle this very strictly. But if they change this in the
future, it shouldn't brick us.

Not quite happy with this glsl_extensions fields, but it is quite
unintrusive after all.
2016-05-19 12:02:08 +02:00
wm4 b0d3c2ede7 vo_opengl: make gl_sc_enable_extension() permanent/idempotent
No reason not to, and makes the following commit slightly simpler.

In fact, this makes the shaders more correct too. Normally, "#extension"
must come before any normal shader text, including the "precision"
directive. Not sure why this worked before. (Probably didn't.)
2016-05-19 12:01:59 +02:00
wm4 b46eaa3b43 vo_opengl: d3d11egl: enable direct nv12 sampling on ES 3.x
ANGLE was missing texture() overloads in the shader compiler for
GL_TEXTURE_EXTERNAL_OES textures. Support has been added upstream,
so we can use it now.
2016-05-19 10:43:57 +02:00
wm4 5f7bd411fb vo_opengl: remove unused field 2016-05-18 18:22:27 +02:00
wm4 0b911792ca vo_opengl: fix/simplify reinitialization on dynamic reconfiguration
With the new hooks mechanism, user shaders and such are actually loaded
before rendering starts, instead of being loaded during rendering. This
is used to cache them (instead of e.g. reparsing them every frame).

The cached state wasn't cleared correctly in some situations. Namely,
resizing didn't correctly enable/disable prescale hooks.

Reorganize how these reinitializations are handled. Get rid of
reinit_rendering(), whose meaning was pretty unclear. Call the required
functions to reset or recreate state directly wherever they are needed.
2016-05-18 17:47:10 +02:00
wm4 26b6d74484 demux_playlist: recognize m3u8 as playlist extension
Whatever. As mentioned in #3154.
2016-05-17 18:18:00 +02:00
wm4 a02d77ba0d d3d: simplify DLL loading
For some reason, the d3d9/dxva2/d3d11 DLLs are still optional. But we
don't need to try so hard to keep exact references. In fact, there's no
reason to unload them at all.

So load them once in a central place. For simplicity, the d3d9/d3d11
backends both load all DLLs. (They will error out only if the required
DLLs could not be loaded.)

In theory, we could just call LoadLibrary multiple times (without
calling FreeLibrary), but I'm slightly worried that this could be
detected as a "bug", or that the reference count could even have a low
static limit that could be hit soon.
2016-05-17 11:59:54 +02:00
wm4 39b64fb176 video: merge dxva2 source files
video/dxva2.c exported only 2 functions, both used only by
video/decode/dxva2.c.

The same was already done for d3d11.
2016-05-17 11:05:51 +02:00
wm4 9b56bbecdf vo_opengl: hwdec: remove build-dependency on dxva2
wscript builds hwdec_dxva2gldx.c if gl-dxinterop is enabled, while
video/dxva2.c depends on d3d-hwaccel. If d3d-hwaccel is disabled, then
hwdec_dxva2gldx.c will fail to link, because it uses
d3d9_surface_in_mp_image(), defined in dxva2.c.

Fix this by removing the use of this function. It has barely any value
at this point anyway. Just use the libavcodec documented way to get the
surface directly.

Fixes #3150.
2016-05-17 10:59:11 +02:00
wm4 b18a598444 ta: remove old and redundant macro 2016-05-17 10:53:14 +02:00