Commit Graph

2496 Commits

Author SHA1 Message Date
wm4 1143f2877a d3d11: change mp_image plane pointer semantics
Until now, the texture pointer was stored in plane 1, and the texture
array index was in plane 2. Move this down to plane 0 and plane 1. This
is to align it to the new WIP D3D11 decoding API in Libav, where we
decided that there is no reason to avoid setting plane 0, and that it
would be less weird to start at plane 0.
2017-05-04 01:13:03 +02:00
wm4 2eaa43e5da vo_opengl: another attempt at removing the overlay correctly
This reverts commit 142b2f23d4, and replaces it with another try. The
previous attempt removed the overlay on every rendering, because the
normal rendering path actually unrefs the mp_image. Consequently,
unmap_current_image() was completely inappropriate for removing the
overlay.
2017-05-02 17:10:26 +02:00
wm4 142b2f23d4 vo_opengl: make sure overlays are removed on gl_video_config()
This should make vo_opengl_cb uninit remove the frame, even if the
renderer and OpenGL state remains active.
2017-04-29 15:09:40 +02:00
wm4 010c7d4992 vo_opengl: context_drm_egl: remove unnecessary include
Could be broken after the previous commit removed finding the GL include
dir.
2017-04-26 17:43:23 +02:00
wm4 f59371de21 video: drop vaapi/vdpau hw decoding support with FFmpeg 3.2
This drops support for the old libavcodec APIs. Now FFmpeg 3.3 or FFmpeg
git is required. Libav has no release with the new APIs yet, so for
Libav git as of a few weeks or months ago or so is required if you want
to use Libav.

Not much actually changes in hwdec_vaegl.c - some code is removed, but
the reindentation inflates the diff.
2017-04-23 16:07:03 +02:00
wm4 927afa311d build: make various x11 protocol extension libs mandatory
Reduces the ifdeffery, which is good and will avoid silent breakages, or
weird behavior if a lib is omitted.

Also reorder the x11_common.c include statements.
2017-04-21 07:30:03 +02:00
wm4 4d1eab6e55 vo_opengl: fix crash by coping temporal_dither_period for dumb mode too
Specifically, this field must never be 0 (and the option can naturally
not be 0 in any way, unless it wasn't initialized correctly).
2017-04-21 07:16:26 +02:00
Akemi f7637db377 cocoa: fix retrieval of unfs window size while animating
due to the System inherent fullscreen animation the option and the
actual fullscreen state can be out of sync, leading to a wrongly
reported unfs window size in the time of the animation.

just always fall back to the window size, we keep track of, when we
either are in fullscreen or are currently switching to it.

Fixes #4323
2017-04-17 02:45:26 +02:00
wm4 bba08e38ff vo_opengl: move X11 backends before Wayland
Wayland is still too amateurish, and multiple features don't work,
including critical ones. There is no solution in sight, so prefer X11.
(Which seems to mostly work ok via xwayland.)

Once all problems are solved, the defaults can be switched back.
2017-04-16 02:35:12 +02:00
wm4 7b84297699 vo_opengl: minor cosmetics 2017-04-14 17:35:27 +02:00
wm4 759ac6cc93 vo_opengl: add option for caching shaders on disk
Mostly because of ANGLE (sadly).

The implementation became unpleasantly big, but at least it's relatively
self-contained.

I'm not sure to what degree shaders from different drivers are
compatible as in whether a driver would randomly misbehave if it's fed
a binary created by another driver. The useless binayFormat parameter
won't help it, as they can probably easily clash. As usual, OpenGL is
pretty shit here.
2017-04-08 16:43:56 +02:00
wm4 e7940ddbf3 vo_opengl: fix a confused comment 2017-04-08 16:43:56 +02:00
wm4 71caa0b79b vo_opengl: remove two unused symbols 2017-04-08 16:43:56 +02:00
wm4 eb83ee4a4a vo_opengl: add our own copy of OpenGL headers
gl_headers.h is basically header_fixes.h done consequently. It contains
all OpenGL defines (and some typedefs) we need. We don't include GL
headers provided by the system anymore.

Some care has to be taken by certain windowing APIs including all of
gl.h anyway. Then the definitions could clash. Fortunately, redefining
preprocessor symbols to the same content is allowed and ignored. Also,
redefining typedefs to the same thing is allowed in C11. Apparently the
latter is not allowed in C99, so there is an imperfect attempt to avoid
the typedefs if required API symbols are apparently present already.

The nost risky part about this are the standard typedefs and GLAPIENTRY.
The latter is different only on win32 (and at least consistently so).
The typedefs are mostly based on stdint.h typedefs, which khrplatform.h
clumsily emulates on platforms which don't have it. The biggest
difference is that we define GLsizeiptr directly to ptrdiff_t, instead
of checking for the _WIN64 symbol and defining it to long or long long.

This also typedefs GLsync to __GLsync, just like the khronos headers.
Although symbols prefixed with __ are implementation reserved, khronos
also violates this rule, and having the same definition as khronos will
avoid problems on duplicate definitions.

We can simplify the build scripts too. The ios-gl check seems a bit
wrong now (what we really want to test for is EAGLContext), but I can't
test and thus can't improve it.

cuda_dynamic.h redefined two GL symbols; just include the new headers
directly instead.
2017-04-07 15:09:27 +02:00
wm4 c9d3a79187 vo_opengl: add a generic EGL function loader function
This is pretty trivial, but also quite annoying due to details like
mismatching eglGetProcAddress() function signature (most callers just
cast the function pointer), and ARM/Linux hacks. So move them all to one
place.
2017-04-06 14:50:19 +02:00
wm4 4e6867c771 vo_opengl: fix windows build if GLES3 is detected
With the recent GLES3 header detection, and if ANGLE is in the search
path, the ANGLE headers will be used over the desktop GL ones. It
appears the ANGLE headers do not include <windows.h>, which leads to the
dxinterop code to fail building. Oops.

Fix this by including <windows.h> is dxinterop is compiled in.
2017-04-06 13:19:59 +02:00
wm4 ebecf9c2d6 vo_opengl: header_fixes.h: merge IOS GLES block
It appears we expect IOS to provide GLES 3. The IOS block contains all
symbols from the GLES block. Weirdly not all, so it's possible that some
symbols will be redefined, which is annoying, but harmless. I don't have
an iOS setup to test, otherwise it's likely that a modification of the
IOS include statements would take care of this.
2017-04-06 08:40:17 +02:00
wm4 755ce9dac5 build: replace android-gl check with a standard GLES3 check
There's no reason to make it Android specific, as it uses standard
include paths.
2017-04-06 08:35:47 +02:00
James Ross-Gowan 0e4531440d w32_common: refactor mouse button handling
Previously, the shared behaviour for each mouse-button message lived at
the bottom of the WndProc. Move it into handle_mouse_down/up functions
(similar to the handle_key_down/up functions.) This makes the WndProc
slightly less complicated. There should be no change in behaviour.
2017-04-04 13:24:57 +10:00
wm4 1c0bd59bc2 vo_opengl: use 16 bit textures with angle
Regression due to 03fe506. It accidentally changed the default value if
glGetTexLevelParameteriv() is not available, which is the case with
ANGLE.
2017-04-03 18:12:42 +02:00
James Ross-Gowan 16ff72cc14 w32_common: fix undefined behaviour when toggling fullscreen
The old code called reinit_window_state() from the VO thread, which is
not safe. Instead of calling reinit_window_state() when
VO_EVENT_FULLSCREEN_STATE is captured, it should be called when sending
the event from the Win32 thread instead.
2017-04-02 00:41:49 +11:00
Akemi c083a7f53e cocoa: fix retrieval of unfs window size
there are two minor bugs. mpv could try to retrieve the size when in
fullscreen and would get the fullscreen size. to fix that we keep track
of the window size before going into fullscreen.

the second small bug is when using HiDPI resolution and the
--hidpi-window-scale option. we actually want the OSD to show the proper
window scale depending on the hidpi settings. before when resizing the
window to double the size it could show "window-scale: 1.0" or
"window-scale: 0.5" when resizing to normal size. now it considers the
backing scale factor and the hidpi option to return a logical correct
window size.
2017-03-26 20:41:20 +02:00
Akemi 5e066670d0 cocoa: fix first responder when borderless window is used
this fixes a weird behaviour when a borderless window's style mask is
set to a none-borderless style mask. this can happen when cycling the
border or just toggling fullscreen. what happens is that the first
responder is reset to the NSWindow instead of being kept, the events
view in our case. this happens without the usual resignFirstResponder,
becomeFirstResponder routine.

this is a small workaround that overrides the setStyleMask method. it
keeps the first responder from before the style mask change and resets
this first responder after the new style mask was applied.
2017-03-26 20:38:26 +02:00
Akemi 063ca8f0fe osx: fix key input in certain circumstances
for a reason i can just assume some key events can vanish from the
event chain and mpv seems unresponsive.

after quite some testing i could confirm that the events are present at
the first entry point of the event chain, the sendEvent method of the
Application, and that they vanish at a point afterwards. now we use
that entry point to grab keyDown and keyUp events. we also stop
propagating those key events to prevent the no key input' error sound.
if we ever need the key events somewhere down the event chain we need
to start propagating them again. though this is not necessary currently.
2017-03-26 20:38:26 +02:00
James Ross-Gowan 439e2b43c3 vo_opengl: angle: add --angle-flip to set the present model
DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL might be buggy on some hardware.
Additionaly DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL might be supported on some
Windows 7 systems with the platform update, but it might have poor
performance. In these cases, the user might want to disable the use of
DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL swap chains with --angle-flip=no.
2017-03-26 21:50:01 +11:00
James Ross-Gowan dbec486add droptarget: fix style and refactor
This makes the code more closely match mpv's style. Specifically, it
changes some names from camelCase to snake_case, removes some Hungarian
notation, replaces direct vtbl access with COM macros, makes use of the
SAFE_RELEASE macro, moves some declarations closer to their first use,
and fixes the brace style, as well as a few other things.

This also makes the IDropTargetVtbl static and it fixes the buggy
QueryInterface implementation.
2017-03-26 00:41:16 +11:00
James Ross-Gowan 0af8ec08f8 w32_common: move the IDropTarget impl to a separate file
This was mostly self-contained, so its removal makes w32_common.c a bit
easier to read. Also, because it was self contained and its author has
agreed to LGPL relicencing, the new file has the LGPL licence header.
2017-03-26 00:41:16 +11:00
igv 16e8ecb031 vo_opengl: replace uniform variable image_size with input_size
input_size can be the size of a cropped image

Signed-off-by: wm4 <wm4@nowhere>
2017-03-25 13:40:04 +01:00
igv 6b8dadd7c1 vo_opengl: add tex_offset uniform variable to user shaders 2017-03-25 13:39:21 +01:00
igv 2aae5ce0ba vo_opengl: make size of a cropped source image available to user shaders 2017-03-25 13:39:15 +01:00
wm4 ab555c42ec vo_x11: fix an unused variable warning 2017-03-24 15:31:10 +01:00
rr- 8de7ba6dfd vo_x11: reduce flickering on playlist navigation
The delay between call to .resize, which cleared the buffer, and
actually rendering the first video frame, was significant, resulting in
short flicker on navigation and resizing. This was especially visible
when zooming and navigating between images.

Now the clearing is scheduled to happen just before the rendering, which
looks to be good enough even without double buffering.
2017-03-24 14:09:02 +01:00
wm4 b0cbda84ed vo_opengl: add a backend start_frame callback for context_vdpau
Might be useful for other backends too. For context_vdpau, resize
handling, presentation, and handling the mapping state becomes somewhat
less awkward.
2017-03-20 13:37:47 +01:00
wm4 8fb9cc2534 vo_opengl: read framebuffer depth from actual FBO used for rendering
In some cases, such as when using the libmpv opengl-cb API, or with
certain vo_opengl backends, the main framebuffer is never accessed.
Instead, rendering is done to a FBO that acts as back buffer. This meant
an incorrect/broken bit depth could be used for dithering.

Change it to read the framebuffer depth lazily on the first render call.

Also move the main FBO field out of the GL struct to MPGLContext,
because the renderer's init function does not need to access it anymore.
2017-03-20 13:31:28 +01:00
wm4 03fe50651b vo_opengl: move some init_gl code to utility functions 2017-03-20 13:20:35 +01:00
wm4 7e4a73c8e4 vo_opengl: add a --opengl-es=force2 option
Useful for testing. Unfortunately, the nVidia EGL driver ignores this,
and returns a GLES 3.2 context anyway (which it is allowed to do). Might
still be useable with ANGLE, which will really give you a GLES 2 context
if you ask for it.
2017-03-20 04:57:51 +01:00
wm4 f8861f681f vo_opengl: properly respect dither option if dumb mode is used
When dumb mode is used (the "simple" rendering path), respect the dither
options. Options should never be ignored (except in GLESv2 mode); either
they should be respected in dumb mode, or they should disable dumb mode.
In this case, the former applies.
2017-03-20 04:46:18 +01:00
wm4 84bf6aabf0 vo_opengl: context_vdpau: resize output surfaces lazily
This actually fixes the dreaded errors during resizing. It works pretty
much like before, except each surface is reallocated before it's used.
It implies surfaces with the old size remain in the presentation queue
and will be displayed.
2017-03-19 09:26:10 +01:00
wm4 d2dc29f221 vo_opengl: context_vdpau: minor fixes
Don't assume 0 is an invalid object handle. vdpau with its weird API
design makes all objects indexes, with 0 being a perfectly valid and
common value. You need to use VDP_INVALID_HANDLE, which is not 0.

Don't crash if init fails at vdpau initialization. It's because
mp_vdpau_destroy(NULL) crashes. Simplify it.

Destroy output surface backed FBO before output surface. Also, strictly
bookkeep the map/unmap calls (and unmap surfaces before destroying the
FBO/texture). I can't see a change in the weird errors when resizing the
window, but I guess it's slightly more correct.

Add the GL_WRITE_DISCARD_NV symbol to header_fixes.h, because we might
fail compilation with headers that do not contain the vdpau extension
(well, probably doesn't matter).
2017-03-19 09:03:13 +01:00
wm4 03933f3564 vo_opengl: fix some undefined behavior
The gl_timer_last_us() function could access samples[-1]. Fix by
coercing to unsigned, so the % will put it into index [0,max). The
real value returned in this corner case doesn't mean too much, I
guess.
2017-03-18 20:22:50 +01:00
wm4 c3248369ac vo_opengl: add experimental vdpauglx backend
As the manpage says, this has no value other than adding bugs.

It uses code based on context_x11.c, and basically does very stripped
down context creation (no alpha support etc.). It uses vdpau for
display, and maps vdpau output surfaces as FBOs to render into them.

This might be good to experiment with asynchronous presentation. For
now, it presents synchronously, with a 4 frame delay (which should whack
off A/V sync). The forced 4 frame delay is probably also why interaction
feels slower.

There are some weird vdpau errors on resizing and uninit. No idea what
causes them.
2017-03-18 17:43:57 +01:00
wm4 be8c9485b6 vo_opengl: add log field to MGLContext
Should have done this 1000 years ago. Now GL backends can use mp_log
macros directly on the MPGLContext, instead of doing stupid things like
for example MP_WARN(ctx->vo, ...).
2017-03-18 17:40:57 +01:00
Rostislav Pehlivanov d276a01ac3 wayland_common: organize and correctly map mouse buttons
The function tried to do something clever but ignored the fact that
the middle button followed the left button rather than the right.

Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
2017-03-17 06:25:32 +00:00
Akemi 076116a0e5 cocoa: set background of the title bar from black to white
due to the see-through nature of the title bar and our standard black
window background, the title bar appears dark grey opposed to the
expected light grey.

we change the window background to white but at the same time set the
background of the enclosed view to black. that way the title bar has a
white background and the background of our video stays black in all
cases. this prevents white flashing in some cases when the video is
resized with too heavy render settings.
2017-03-09 18:02:36 +01:00
Akemi 7bddd3fb4c cocoa: fix autofit options on HiDPI resolutions without HiDPI scaling
Fixes #4194
2017-03-09 17:57:07 +01:00
Philip Sequeira a2a5fa4545 options: add M_OPT_FILE to some more file options
(Helps shell completion.)
2017-03-06 15:41:06 +01:00
Nicholas J. Kain e226041355 filter_kernels: Keep f.radius in terms of dest/filter coords.
The existing code modifies f.radius so that it is in terms of the
filter sample radius (in the source coordinate space) and has
some small errors because of this behavior.

This commit changes f.radius so that it is always in terms of
the filter function radius (in the destination coordinate space).

The sample radius can always be derived by multiplying f.radius
by filter_scale, which is the new, more descriptive name for the
previous inv_scale.
2017-03-06 03:31:40 +00:00
Nicholas J. Kain 69cc9f2a2c filter_kernels: Apply blur/taper before culling radius.
Modifications to the input coordinates should all be performed
before the final range check against the filter boundaries.

However, in the existing code, the blur/taper is applied after the
filter radius check is performed.  Thus, effectively the filter radius
cutoff is applied to only-downscaling-metric-modified coordinates, not
the final coordinates.

Correct this issue and restructure the returns a bit to make it
more obvious what is being done.
2017-03-06 03:31:35 +00:00
Akemi 4fe199c6a0 cocoa: improve calculation of new window position on a different screen
forcibly moving a window from one screen to another is supposed to put
it in a position that looks relative the same as on the old screen, as
in bottom, top, left and right margin look the same, without changing
the window size. in some situations the old code moved the window off
screen or on top of the menu bar so it ended up at a somewhat random
position. the new code fixes some edge cases but is probably not
completely correct since the priority is to make sure that the window
ends up on the right screen.
2017-02-28 00:01:15 +01:00
Akemi 9d549e6837 cocoa: only move window into screen bounds when changing screens
when forcibly moving windows to a different screen with --screen or
--fs-screen we need to move the window into the screen bounds if the
window is out of bounds, otherwise it can end up on the wrong screen.
previously it always recalculated the bounds and moved the window when
toggling fullscreen, now it only does the bound calculation when
changing screens.

Fixes #4178
2017-02-27 23:57:44 +01:00