Commit Graph

1316 Commits

Author SHA1 Message Date
wm4 30860f7b10 x11: ignore mouse enter/leave events due to pointer grab
If you click on a window that doesn't have a focus, a LeaveNotify
followed by a EnterNotify event can be generated. The former will have
mode set to NotifyGrab, the latter to NotifyUngrab. This will make the
player think the mouse left the window, even though this is not the
case. Ignore these and only react to those with mode set to
NotifyNormal.

Probably fixes #1672, and some other strange issues on some WMs.
2015-03-11 11:52:33 +01:00
wm4 c7790b4526 vo: hide opengl-cb in --vo=help
Avoids stupid questions.
2015-03-10 17:17:15 +01:00
wm4 eff265c140 vo_opengl_cb: clear last video frame on uninit()
mpv_opengl_cb_render() is supposed to clear the screen with the
background color if there's no video... I think.

It didn't do this, because although uninit() requested gl_video_config()
to be called, this didn't happen, because this function checks whether
the VO is set - and it's unsert after uninit() releases the lock.

Also call the user wakeup callback in this situation, so the user
actually redraws immediately.
2015-03-10 14:16:07 +01:00
wm4 cfa44f4e90 vo_opengl: move minor helper to common code
The generic image format code should cary most of the "knowledge" about
image formats.
2015-03-09 22:47:33 +01:00
James Ross-Gowan 5f0eda7b94 w32_common: remove redundant is_maximized function
This already exists as IsMaximized in the Windows API.
2015-03-09 22:16:26 +11:00
Stefano Pigozzi 735bf48496 cocoa: fix minimized state getter 2015-03-09 12:01:55 +01:00
wm4 b7f242dfcf x11: fix VOCTRL_GET_WIN_STATE
Do not rely on the pointed-to argument to be initialized; VOCTRLs are
supposed to completely overwrite them on success (or not to touch them
on failure).

The currently only caller of VOCTRL_GET_WIN_STATE initializes the value
before calling this, so this is merely about correctness and didn't lead
to any actual bugs.
2015-03-09 11:46:16 +01:00
James Ross-Gowan a26ea50694 w32_common: support the "window-minimized" property 2015-03-09 11:46:06 +01:00
Jaime Marquínez Ferrándiz d7f04e2085 cocoa: support the "window-minimized" property
Signed-off-by: Stefano Pigozzi <stefano.pigozzi@gmail.com>
2015-03-08 22:00:47 +01:00
Stefano Pigozzi 8ec9bce2d3 cocoa: fix autohide in fullscreen 2015-03-08 15:19:17 +01:00
Stefano Pigozzi ce239f1577 cocoa: fix mouse hiding with launchpad and dock folders
Some UI elements in OS X – like Launchpad and Dock folders – are implemented
using borderless windows in background demonized applications.
When we use these elements, mpv doesn't stop to be the active application, but
the mpv window leaves keyWindow state while we use the OS controls.

This commit just keeps track of window state to update the cursor visibility
accordingly.

Fixes #513
2015-03-08 11:56:56 +01:00
torque 39537f6474 cocoa: clamp mouse position to window.
Prevents out-of-window coordinates being reported for mouse coordinates.
Previously they could be out-of-window coordinates on init or on resize.
2015-03-07 19:32:02 +01:00
torque bce753060e cocoa: update mouse coordinates when window is initialized.
Make MpvEventsView -signalMousePosition a public method so it can be
called without a compiler warning. Previously, the mouse position would
be reported as (0,0) until the cursor was moved.
2015-03-07 19:31:52 +01:00
Stefano Pigozzi 678cd30904 cocoa: don't uninit light sensor if not present 2015-03-07 19:28:00 +01:00
Martin Herkt 1bab7f69ae vo_opengl/x11: fix automatic ICC profile loading
mpv would attempt to load ICC profiles several times during VO init
even if no window is displayed. This potentially causes it to load
a profile for a different screen than it is going to be displayed
on, thereby invalidating the profile cache and rebuilding the LUT
every single time.
It would not unload a previously loaded profile when the video
window is moved to a display without an installed profile.

Fix these issues and tweak the log messages a little.
2015-03-07 13:00:06 +01:00
Stefano Pigozzi 5cddd4ccca cocoa: remove possible use after free 2015-03-07 09:13:05 +01:00
Stefano Pigozzi c66b51dab0 cocoa: fix some crashes caused by async uninit
Always keep around our private state and destroy it when we are really done in
the async uninit callback.

Fixes #1657
2015-03-07 08:54:05 +01:00
wm4 fc571e0adb vo_vaapi: fix video equalizer (second try)
The vaapi equalizer have a custom range, and can have a smaller range
than mpv's normalized video equalizer values. The result is that a vaapi
equalizer value can map to multiple mpv values, so changing a mpv value
by 1 can get "stuck". Fix by remember the mpv value, and returning it if
it still corresponds to the vaapi value.

Really fixes #1647.

(Why am I even bothering with this irredeemable crap?)
2015-03-06 12:15:03 +01:00
Niklas Haas 05bb2a9e8a
vo_opengl: make smoothmotion-threshold inclusive
This behavior makes more sense near the borders, eg.
smoothmotion-threshold=0 and smoothmotion-threshold=0.5.
2015-03-05 16:39:22 +01:00
wm4 4e3f8ccb9d vo_vaapi: round equalizer values
Probably fixes #1647 (if it's correct at all). I couldn't reproduce with
the vdpau libva driver, but a driver can use different ranges.
2015-03-05 12:49:18 +01:00
Stefano Pigozzi ae33ec2c5b vo_opengl: increase ambient light changes log level
info is a quite too annoying. increase it to verbose.
2015-03-04 20:18:14 +01:00
wm4 85bf102f54 win32: fix some more -Wparentheses warnings
Stupid compiler.

For decode_surrogate_pair(), I changed the order of evaluation; it
shouldn't matter, but this order is more readable in my opinion.
2015-03-04 17:28:41 +01:00
Stefano Pigozzi c028d782c1 vo_opengl: add gamma-auto option
This automatically sets the gamma option depending on lighting conditions
measured from the computer's ambient light sensor.

sRGB – arguably the “sibling” to BT.709 for still images – has a reference
viewing environment defined in its specification (IEC 61966-2-1:1999, see
http://www.color.org/chardata/rgb/srgb.xalter). According to this data, the
assumed ambient illuminance is 64 lux. This is the illuminance where the gamma
that results from ICC color management is correct.

On the other hand, BT.1886 formalizes that the gamma level for dim environments
to be 2.40, and Apple resources (WWDC12: 2012 Session 523: Best practices for
color management) define the BT.1886 dim at 16 lux.

So the logic we apply is:

  * >= 64lux -> 1.961 gamma
  * =< 16lux -> 2.400 gamma
  * 16lux < x < 64lux -> logaritmic rescale of lux to gamma. The human
    perception of illuminance roughly follows a logaritmic scale of lux [1].

[1]: https://msdn.microsoft.com/en-us/library/windows/desktop/dd319008%28v=vs.85%29.aspx
2015-03-04 10:06:08 +01:00
Stefano Pigozzi 89306818bb cocoa: add support for querying ambient lighting
This will be pretty useful to let mpv automatically change VO parameters based
on ambient lighting conditions.

The conversion code and polinomial equation from Apple LMU values to Lux is
taken from Firefox: their license, MPL is GPL compatible and allows
relicensing to GPL (MPL is more liberal).
2015-03-04 10:06:08 +01:00
wm4 445b3fbf82 buid: readd -Wparentheses
This warning wasn't overly helpful in the past, and warned against
perfectly fine code. But at least with recent gcc versions, this is the
warning that complains about assignments in if expressions (why???), so
we want to enable it.

Also change all the code this warning complains about for no reason.
2015-03-02 19:09:25 +01:00
wm4 4b177bd5c2 vo_direct3d: support NV12 with shaders
Semi-important, because --hwdec=dxva2 outputs NV12, and we really don't
want people to end up with the "old" StretchRect method.

Unfortunately, I couldn't actually get it to work. It seems most D3D
drivers (including the wine D3D implementation) reject D3DFMT_A8L8,
and I could not find any other 2-channel 8 bit Direct3D 9 format. It
seems newer D3D APIs have DXGI_FORMAT_R8G8_UNORM, but there's no way
to get it in D3D9.

Still pushing this; maybe it actually works on some drivers.
2015-03-02 19:09:18 +01:00
Niklas Haas a76cc1dafc
Revert "Revert recent vo_opengl related commits"
Omitted a simple, but devastasting check. Fixed the relevant commits
now.

This reverts commit 8d24e9d9b8.

diff --git a/video/out/gl_video.c b/video/out/gl_video.c
index 9c8a643..f1ea03e 100644
--- a/video/out/gl_video.c
+++ b/video/out/gl_video.c
@@ -1034,9 +1034,9 @@ static void compile_shaders(struct gl_video *p)
     shader_def_opt(&header_conv, "USE_CONV_GAMMA", use_conv_gamma);
     shader_def_opt(&header_conv, "USE_CONST_LUMA", use_const_luma);
     shader_def_opt(&header_conv, "USE_LINEAR_LIGHT_BT1886",
-                   gamma_fun == MP_CSP_TRC_BT_1886);
+                   use_linear_light && gamma_fun == MP_CSP_TRC_BT_1886);
     shader_def_opt(&header_conv, "USE_LINEAR_LIGHT_SRGB",
-                   gamma_fun == MP_CSP_TRC_SRGB);
+                   use_linear_light && gamma_fun == MP_CSP_TRC_SRGB);
     shader_def_opt(&header_conv, "USE_SIGMOID", use_sigmoid);
     if (p->opts.alpha_mode > 0 && p->has_alpha && p->plane_count > 3)
         shader_def(&header_conv, "USE_ALPHA_PLANE", "3");
2015-02-28 20:23:47 +01:00
wm4 8d24e9d9b8 Revert recent vo_opengl related commits
Breaks vo_opengl by default. I'm hot able to fix this myself, because I
have no clue about the overcomplicated color management logic. Also,
whilethis is apparently caused by commit fbacd5, the following commits
all depend on it, so revert them too.

This reverts the following commits:
 e141caa97d
 653b0dd529
 729c8b3f64
 fbacd5de31

Fixes #1636.
2015-02-28 19:29:03 +01:00
Stefano Pigozzi 03a69bac95 cocoa: remove the setNextKeyView hack
Just use makeFirstResponder on the mpv events view from client code
if you need the built in keyboard events (this is easier for dealing with view
nesting).
2015-02-28 14:55:32 +01:00
Niklas Haas fbacd5de31 csputils: add missing gamma support
We have MP_CSP_TRC defined, but it wasn't being used by practically
anything. This commit adds missing conversion logic, adds it to
mp_image, and moves the auto-guessing logic to where it should be, in
mp_image_params_guess_csp (and out of vo_opengl).

Note that this also fixes a minor bug: csp_prim was not being copied
between mp_image structs if the format was not YUV in both cases, but
this is wrong - the primaries are always relevant.
2015-02-28 01:07:35 +01:00
wm4 73c5c3df53 vo_opengl: delete 16 bit test texture
Essentially a leak, but not that bad since it's small and allocated only
once.
2015-02-27 22:13:15 +01:00
wm4 e7b7a5a476 vo_opengl: fix some comments 2015-02-27 22:01:27 +01:00
wm4 1eb533afb3 options: handle choice -> flag fallback automatically
In the past it happened quite often that flag options (yes/no) were
changed to choice options (yes/no/some more). The problem with this was
that while flag options don't need a parameter, this wasn't the case
with choice options. A hack was introduced to compensate for this:
setting M_OPT_OPTIONAL_PARAM on the option, and an empty string ("") was
added as choice, so that the choice could be used like a flag. So, for
example, "--mute" would set the choice "".

Fix this by 1. not requiring a parameter if there's a "yes" choice, and
2. redirect an empty parameter to "yes". The effect is that a choice
option with the choices ["yes", "no"] is pretty much equivalent to a
flag option.
2015-02-27 18:31:24 +01:00
Niklas Haas 0da6a7346a
vo_opengl: implement antiringing for tensor scalers
This is based on pretty much the same (somewhat naive) logic right now.
I'm not convinced that the extra logic that eg. madVR includes is worth
enough to warrant heavily confusing the logic for it.

This shouldn't slow down the logic at all in any sane shader compiler,
and indeed it doesn't on any shader compiler that I tested.

Note that this currently doesn't affect cscale at all, due to the weird
implementation details of that.
2015-02-27 04:35:15 +01:00
wm4 280c826379 vo_opengl: test FBOs only if they're going to be used
Change test_fbo() so that it checks the FBO lazily, and restructure
check_gl_features() to invoke it only if we know that a FBO will be
needed for a certain enabled feature.

This can avoid strange error messages when using --vo=opengl and the
FBO format does not work. It's also less confusing when reading the
verbose log (users might think that the FBO is actually used, etc.).
2015-02-26 10:37:31 +01:00
wm4 a2e0cd7f25 vo_xv: don't attempt to clear window before mapped
This can happen with the "no-colorkey" suboption. Then the code in
xv_draw_colorkey() can be run before vo_x11_config_vo_window(), when
vo_gc is not allocated yet.

Fixes #1629.
2015-02-26 09:26:28 +01:00
Niklas Haas 010cf183fe
vo_opengl: greatly increase smoothmotion performance
Instead of rendering and upscaling each video frame on every vsync, this
version of the algorithm only draws them once and caches the result,
so the only operation that has to run on every vsync is a cheap linear
interpolation, plus CMS/dithering.

On my machine, this is a huge speedup for 24 Hz content (on a 60 Hz
monitor), up to 120% faster. (The speedup is not quite 250% because of
the overhead that the larger FBOs and CMS provides)

In terms of the implementation, this commit basically swaps
interpolation and upscaling - upscaling is moved to inter_program, and
interpolation is moved to the final_program.

Furthermore, the main bulk of the frame rendering logic (upscaling etc.)
was moved to a separete function, which is called from
gl_video_interpolate_frame only if it's actually necessarily, and
skipped otherwise.
2015-02-24 21:52:14 +01:00
wm4 cc011415ff vo_opengl: another GLES2 issue
GLES2 randomly does not support the transpose parameter in matrix
uniform calls. So we have to do this manually. Sure it was worth to
mutilate the standard just so all these shitty SoC vendors can safe 3
lines of code.

(Obviously trying to handle all of GLES2 to GL 4.x in a single codebase
was a mistake.)
2015-02-24 13:48:09 +01:00
wm4 2c8d16d89f vo_opengl: extend ifdef against shader arrays
GLES2 shaders do not have line continuation characters. Abuse the
HAVE_ARRAYS define to exclude code which uses arrays, and which also
happens to cover all code that defines multi-line macros. (So yes, this
is a hack.)
2015-02-24 13:36:43 +01:00
Niklas Haas a759028f67
filter_kernels: rename bilinear_slow to triangle
This is essentially what it is, and it's a useful for windowing or
downscaling. For upscaling we already have bilinear, no need to cause
extra confusion between biliner and bilinear_slow.

Also made it a bit more well-behaved.
2015-02-24 03:13:37 +01:00
Niklas Haas dc3c718b37
filter_kernels: add robidoux and robidouxsharp
These are EWA-based versions of the keys B/C splines, of which mitchell
is already a member. They are slightly softer and slightly sharper than
mitchell, respectively.

Very easy to define in terms of things we already have.
2015-02-24 01:35:14 +01:00
Niklas Haas dd345afb38
filter_kernels: redefine redundant filters
mitchell, hermite and catmull_rom are all B/C splines and can share the
code which was already written for mitchell. This just redefines them in
terms of that.
2015-02-24 01:32:45 +01:00
Niklas Haas d27563cb14
filter_kernels: add ewa_lanczossharp alias
This is essentially a preconfigured version of ewa_lanczos, with the
"best" parameters for general purpose usage.
2015-02-24 00:52:17 +01:00
Niklas Haas eb70e31cc7
vo_opengl: support polar filters of any radius
We can now truly pass a radius of 3.2383154841662362 or another
real zero of the jinc function to get a better result.
2015-02-24 00:29:27 +01:00
Niklas Haas 71a20f7c98 vo_opengl: explicitly check potential candidates for polar filters
This adds a small check for candidates that could potentially be inside
the radius, but aren't necessarily. This speeds up performance by a
negligible amount on my hardware, but it's mainly a prerequisite for a
further change (using a larger true radius).
2015-02-24 00:29:24 +01:00
Niklas Haas 36011c7f6d
filter_kernels: add blur parameter to jinc
This affects all filters that use it, eg. ewa_lanczos. Setting it to
something like 0.95 can be done to make the filter a bit less blurry.
2015-02-23 19:06:18 +01:00
Niklas Haas 6765a7549b
filter_kernels: gaussian: redefine the parameter
Previously, this was based on some arbitrary range 1-100, cut off for
no particular reason, and also defined in such a way that higher values
= *less* smoothness. Since it wasn't multiplied by e in the code, the
default had to be 10*e = 28.8539...

Now, it's sane: 1.0 = default, higher = blurrier.
2015-02-23 18:20:06 +01:00
Niklas Haas a3733b53d3
filter_kernels: remove second parameter from kaiser
This filter isn't supposed to have a second parameter in the first
place, all literature only uses a single parameter alpha in both places.

The second parameter doesn't even do anything other than adding a
constant factor, which is normalized by the LUT calculation either way.
2015-02-23 18:02:52 +01:00
Niklas Haas 99dfd3368d
filter_kernels: rename ginseng to ewa_ginseng
This is done mainly for consistency, since all of the EWA filters share
similar properties and it's important to distinguish them for
documentation purposes.
2015-02-23 17:42:49 +01:00
Niklas Haas c2c96f9b10
filter_kernels: add ewa_hanning
This is suggested in a thesis by Andreas Gustafsson, and seems to
produce very a bit less ringing than lanczos at high radius.
2015-02-23 16:30:22 +01:00