Commit Graph

186 Commits

Author SHA1 Message Date
wm4 885c6a2610 Fix some cppcheck / scan-build warnings
These were found by the cppcheck and scan-build static analyzers. Most
of these aren't interesting (the 2 previous commits fix some interesting
cases found by these analyzers), and they don't nearly fix all warnings.
(Most of the unfixed warnings are spam, things MPlayer never cared
about, or false positives.)
2013-05-06 23:11:11 +02:00
wm4 872aefaa15 vo_opengl: XYZ input support
Useful for the j2k decoder.

Matrix taken from http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
(XYZ to sRGB, whitepoint D65)

Gamma conversion follows what libswscale does (2.6 in, 2.2 out).

If linear RGB is used internally for scaling, the gamma conversion
will be undone by setting the exponent to 1. Unfortunately, the two
gamma values don't compensate each others exactly (2.2 vs. 1/0.45=2.22...),
so output is a little bit incorrect in sRGB or color-managed mode. But
for now try hard to match libswscale output, which may or may not be
correct.
2013-05-04 01:32:50 +02:00
wm4 767cbb77ed gl_video: use GL_SRGB only if it's really RGB
Use the proper RGB flag instead of !YUV. Currently, this doesn't change
anything, because only RGB and YUV formats are supported.
2013-05-04 01:31:46 +02:00
Alexander Preisinger f8c13d6b66 wayland: fix wrong poll comment, check for errors
We only print an error message when POLLERR or POLLHUP occurrs, as the
something did go horribly wrong and the server will either deal with it or
crash.

Also add POLLOUT to the events.
2013-05-02 23:24:14 +02:00
Alexander Preisinger 68d4cc4536 wayland: avoid iterating over all outputs
If we use the output itself as user data we don't have to iterate over all
outputs when the handle_mode event comes.
2013-05-02 21:01:19 +02:00
Alexander Preisinger 57e0a84715 wayland: remove unused stuff 2013-05-02 21:01:19 +02:00
Alexander Preisinger c0b8c35e3b wayland: use new function xkb_keymap_from_buffer
Bump xkbcommon version and use the new xkb_keymap_from_buffer. This is more
secure, because the from_string expects a 0 terminated string, but this cannot
be guaranteed with mmap.
2013-05-02 21:01:19 +02:00
Alexander Preisinger 3899e594ea wayland: remove input modifier variable
This variable was never used anywhere.
2013-05-01 15:46:01 +02:00
Alexander Preisinger db0c3d79f8 wayland: use GetTimerMS for hiding mouse cursor
This commit remove a lot of linux specific code, like epoll. It also reduces
the complexity of the code. Instead of epoll we use poll which makes the
wayland backend more portable to other platforms.
2013-05-01 15:41:33 +02:00
Alexander Preisinger 048c68e5c2 wayland: use mpv internal key auto-repeat handling
This removes a good chunk of code trying to recreate key repeat.
Because the wayland protocol and xkbcommon don't have an interface for
auto-repeating pressed keys.
2013-05-01 13:41:07 +02:00
Stefano Pigozzi 7a42df8712 cocoa_common: fix window sizing
The code was attempting to get the ceiling of the double. Too bad NSSize has
floats inside of it and the int cast is nowhere to be seen. This caused
rounding errors by one pixel in the window size.
2013-04-28 09:55:06 +02:00
wm4 d853abafc3 x11: use mpv internal key auto-repeat handling if possible
Block X11's native key repeat, and use mpv's key repeat handling in
input.c instead.

No configure check for XKB. Even though it's an extension, it has been
part of most (all?) xlibs since 1996. If XKB appears to be missing,
just refuse enabling x11.

This is a potentially controversial change. mpv will use its own key
repeat rate, instead of X11's. This should be better, because seeking
will have a standardized "speed" (seek events per seconds when keeping
a seek key held down). It will also allow disabling key repears for
certain commands, though this is not done anywhere yet.

The new behavior can be disabled with the --native-keyrepeat option.
2013-04-24 18:07:01 +02:00
wm4 355b980a72 vo_opengl_old: remove nomanyfmts warning
The VO warns by default that the nomanyfmts option should be used if
video display fails. This is almost completely useless, but people
keep asking what it means.
2013-04-23 14:18:23 +02:00
wm4 465ccd2c93 x11_common: minor simplification 2013-04-21 00:39:54 +02:00
Stefano Pigozzi 9a6e6b2fc2 cocoa_common: keep aspect ratio when clipping window
With commit 33ffc283 resizing to double size would cause the window to lose
aspect ratio. This commit fixes this bug.
2013-04-17 21:22:22 +02:00
Stefano Pigozzi 22d53fb97c change reverse DNS strings to io.mpv.*
fixes #60
2013-04-16 23:34:58 +02:00
Stefano Pigozzi 33ffc28373 cocoa_common: refactor centered resize
This refactor makes the code easier to understand. Also corrects a bug that
caused the window to move to the left when the new size was bigger than the
visible frame.
2013-04-16 22:51:01 +02:00
Alexander Preisinger 8f1168b73f wayland: use vo flags for enabling alpha support
I missed the VOFLAG for enabling alpha support
2013-04-02 21:10:22 +02:00
Alexander Preisinger 39116ecf31 wayland: enable alpha support
It is now possible to show images and videos with alpha information correctly.
This was disalbed before, because there was a bug that made black parts of
videos also transparent.
2013-04-02 20:50:54 +02:00
Stefano Pigozzi e31567fe41 gl_video: remove double const qualifier
This fixes a warning when compiling with clang.
2013-03-30 20:42:11 +01:00
wm4 d39b131bde gl_video: add some missing includes
On most platforms, they are recursively included, but not all.
2013-03-30 04:01:17 +01:00
wm4 624fe1736e gl_lcms: fix compilation when lcms2 is not available 2013-03-30 03:29:54 +01:00
wm4 b617863c24 gl_video: actually fix shader compilation on OSX
The previous attempt was missing some code paths, so there were still
shaders generated that triggered the shader compilation error. Fix it
instead by special handling USE_CONV in the shader.

By the way, the shader compiler did not accept:

    #if defined(USE_CONV) && (USE_CONV == ...)

In my opinion this should be perfectly fine, but it gives the same
error as before. So test USE_CONV separately with #ifndef.
2013-03-28 23:52:40 +01:00
wm4 5d8b50bda8 gl_video: fix OSX by not using undefined name in GLSL "#if"
The OSX shader compiler was giving this error:

    ERROR: 0:235: '' : syntax error incorrect preprocessor directive

on this line:

    [235] #if USE_CONV == CONV_PLANAR

USE_CONV was undefined in some cases. The expected behavior is that the
shader preprocessor interprets this as branch not taken (AFAIK exactly
as in C), which is probably what the standard would dictate. This is
possible an OSX bug. But admittedly, I'm not sure whether this is really
standard behavior (in C or GLSL), and doing this is extremely weird at
best, so make sure that USE_CONV is always defined.

Should fix behavior on OSX.
2013-03-28 23:30:54 +01:00
wm4 6232fa26b3 gl_header_fixes: add GL_RGBA32F
Should fix compilation on OSX 10.8.3 and maybe other platforms.
2013-03-28 22:55:56 +01:00
wm4 2585baa649 gl_video: use choice option type for dither-depth suboption
Replaces the numeric magic values -1 and 0 with "no" and "auto". The
numeric values are still allowed for compatibility.
2013-03-28 21:46:18 +01:00
wm4 8d7858dd9d vo: rename vo_draw_image to vo_queue_image 2013-03-28 21:46:18 +01:00
wm4 7f64a1fde9 vo: remove two unused symbols 2013-03-28 21:46:18 +01:00
wm4 a0e2f7113b gl_video: add some alpha FBO formats 2013-03-28 21:46:17 +01:00
wm4 8099cbe9dd vo_opengl: add alpha output
Allows playing video with alpha information on X11, as long as the video
contains alpha and the window manager does compositing. See vo.rst.

Whether a window can be transparent is decided by the choice of the X
Visual used for window creation. Unfortunately, there's no direct way to
request such a Visual through the GLX or the X API, and use of the
XRender extension is required to find out whether a Visual implies a
framebuffer with alpha used by XRender (see for example [1]). Instead of
depending on the XRender wrapper library (which would require annoying
configure checks, even though XRender is virtually always supported),
use a simple heuristics to find out whether a Visual has alpha. Since
getting it wrong just means an optional feature will not work as
expected, we consider this ok.

[1] http://stackoverflow.com/questions/4052940/how-to-make-an-opengl-
rendering-context-with-transparent-background/9215724#9215724
2013-03-28 21:46:17 +01:00
wm4 69c4baad91 gl_video: always upload all planes
When displaying YUV with alpha plane (an extremely rare special case),
we didn't upload the alpha plane, because we don't do anything with it.
This actually created some annoying special cases, so upload the alpha
planes as well, even if they're unused.
2013-03-28 21:46:17 +01:00
wm4 4221417875 gl_video: support NV21 too 2013-03-28 21:46:17 +01:00
wm4 120d6bf57c gl_video: add support for NV12
There's really no reason for this, but it feels nice being able to
support a weird pixel format.
2013-03-28 21:46:17 +01:00
wm4 1df2edda3a gl_video: make it possible for planes to have different formats
Preparation for NV12 support.

Also adds support for IMGFMT_YA8.
2013-03-28 21:46:17 +01:00
wm4 47d8fd0713 gl_video: move video image fields into a struct
This is a bit cleaner. Also don't repeat the chroma shift calculations
over and over, but store the image size instead, which is simpler and
will give us a chance to fix display of non-mod-2 image sizes.
2013-03-28 21:46:17 +01:00
wm4 6ef06aa145 vo_opengl: split into multiple files, convert to new option API
gl_video.c contains all rendering code, gl_lcms.c the .icc loader and
creation of 3D LUT (and all LittleCMS specific code). vo_opengl.c is
reduced to interfacing between the various parts.
2013-03-28 21:46:17 +01:00
wm4 16e951c2cd gl_common: split into platform specific files
Do this instead of stuffing all x11/cocoa/win32/wayland specific code
into gl_common.c. The cocoa specific parts could probably go directly
into cocoa_common.m, possibly same with wayland.

Also redo how the list of backends is managed. Get rid of the GLTYPE_
constants. Instead of having a big switch() on GLTYPE_, each backend
entry has a function pointer to setup the MPGLContext callback (e.g.
mpgl_set_backend_x11()).
2013-03-28 21:46:17 +01:00
Kovensky 4be6ff5ee3 w32_common: Cygwin64 fixes
Good news: MPV worked fine even without the fixes, but pointer size
mismatch warnings aren't the nicest things to leave lying around.

Fix macro that assumed HWND is uint32_t-sized.

Win64 is also a special butterfly and is an LLP64 platform on amd64
CPUs, while all the other amd64 platforms are LP64. Cygwin decided to go
with the other platforms, and thus sizeof(long) != sizeof(int), and in
cygwin's windows headers LONG is int-sized. Fix an mp_msg that assumed
LONG is long.
2013-03-23 21:04:59 +01:00
Alexander Preisinger 1fc58386d1 wayland: fully support cursor autohide options
I missed the special cases in the previous commits.
2013-03-23 12:58:34 +01:00
wm4 e4be357bce w32_common: reset internal display size to the window size
vo->dwidth/dheight are overwritten by vo.c at this point (which is not
nice, but it's how things are currently).
2013-03-19 23:36:43 +01:00
wm4 594ad5acc2 video: deal with 0x0 window size
If this happens, don't set a NaN aspect ratio.
2013-03-19 23:34:50 +01:00
wm4 ea03cc6712 x11_common: remove assumption that video is always centered
The vo_x11_clearwindow_part() function assumed that the video is always
centered. Replace it with a new vo_x11_clear_background() function
instead, which essentially does the same as the old function. It takes
the video rectangle instead of just the video size, and doesn't have to
make the assumption that the video rectangle is centered.

Also make vo_x11 use it (seems advantageous).
2013-03-17 23:01:33 +01:00
wm4 79d35b8f01 video: enable panscan calculations even in windowed mode
This was probably enabled to guarantee that panscan is always reset in
windowed mode. However, the window size should be exactly the video size
in windowed mode, unless in cases where the user forcibly changed the
window size (e.g. --geometry). In the former case, panscan will have no
influence at all, and in the latter case we want it to have influence.
2013-03-17 22:12:16 +01:00
wm4 f86deec58b video: apply --no-keepaspect even on fullscreen
If that's what the user asked for, there's no reason to introduce
special cases to ignore it on fullscreen.

The old behavior is perhaps accidentally due to the fact that aspect
calculations used to be disabled in windowed mode, rather than a
deliberate decision.
2013-03-17 22:07:13 +01:00
wm4 b049ffb330 video: remove rounding of display size to multiples of 2
The code that is changed is responsible for scaling the video size to
display size, so that the resulting video rectangle is letter-boxed
inside the display window. This is before panscan calculations, which
can actually enlarge the video and make it larger than the display size
again. (src_dst_split_scaling() in vo.c takes cares of clipping the
video size to window size.)

I'm not sure why this rounding is done, as using panscan controls can
introduce odd sizes again. The rounding has been part of the code since
the initial commit. On the other hand, this rounding can slightly
influence the aspect ratio of the displayed image to the worse. It
forces the image to be scaled by an additional pixel, without actually
correcting the display size into the other direction.

Although video sizes are usually at least aligned on 2 (and often more),
odd sizes can still happen when playing e.g. anamorphic DVDs.

Remove the additional rounding.

(Note that we still round the _source_ image position and size when the
displayed image is larger than the screen, e.g. when panscan is used.
This is needed by some VOs so that the image source rectangle starts on
full chroma pixels. Maybe this rounding should be moved to the
respective VOs, which includes at least vo_direct3d.)
2013-03-17 22:07:13 +01:00
wm4 1ae1939742 video: remove aspect.h includes from files which don't need it 2013-03-17 22:07:13 +01:00
wm4 4b87cb39a3 video: simplify aspect calculation stuff
Remove lots of weird logic and dead code.

The only difference is that when specifying a monitor aspect ratio, it
will always upscale and never downscale.
2013-03-17 22:07:13 +01:00
wm4 59960baa7f vo_xv: minor simplifications
The draw_osd change is a bit tricky: I guess originally, there was some
intention not to second-guess the generic aspect code, but the result is
the same and the code is more confusing.
2013-03-17 19:07:30 +01:00
wm4 36f5d800d5 vo_x11: accept all swscale formats
There's no reason why there should be a separate vf_scale stage.
2013-03-17 19:07:29 +01:00
wm4 5b6da6e286 vo_corevideo: use generic aspect ratio code
The rescaling is rather silly. vo_get_src_dst_rects() doesn't return an
uncropped image, so the texture coordinates have to be recalculated,
which looks more complicated, but is actually what the other OpenGL VOs
also do.

Tested and fixed by Stefano Pigozzi.
2013-03-17 19:07:29 +01:00