Commit Graph

713 Commits

Author SHA1 Message Date
wm4 775e08ba65 vo_opengl: fix alpha values written to the framebuffer
When blending OSD and subtitles onto the video, we write bogus alpha
values. This doesn't normally matter, because these values are normally
unused and discarded. But at least on Wayland, the alpha values are used
by the compositor and leads to transparent windows even with opaque
video on places where the OSD happens to use transparency.

(Also see github issue #338.)

Until now, the alpha basically contained garbage. The source factor
GL_SRC_ALPHA meant that alpha was multiplied with itself. Use GL_ONE
instead (which is why we have to use glBlendFuncSeparate()). This should
give correct results, even with video that has alpha. (Or at least it's
something close to correct, I haven't thought too hard how the
compositor will blend it, and in fact I couldn't manage to test it.)

If glBlendFuncSeparate() is not available, fall back to glBlendFunc(),
which does the same as the code did before this commit. Technically, we
support GL 1.1, but glBlendFuncSeparate is 1.4, and I guess we should
try not to crash if vo_opengl_old runs on a system with GL 1.1 drivers
only.
2013-11-10 03:14:38 +01:00
wm4 87ab30669c gl_hwdec_vdpau: silence warning caused by buggy GL_NV_vdpau_interop spec
VDPAU handles are integers, but for some reasons the VDPAU GL extension
expects them as void*.
2013-11-09 23:32:58 +01:00
wm4 782c8e72ff vdpau: unbreak
Obviously I didn't test commit 1b8cd01, and it just crashed. Oops.
2013-11-09 01:27:03 +01:00
wm4 1b8cd01b1a vdpau: drop dummy render function
This was supposed to handle preemption better. I still think the current
state isn't very nice, since the decoder can "accidentally" call the
previous render function after preemption (instead of calling the
reloaded function), so there might be issues. But all in all, this
dummy_render function is a bit confusing, and still not entirely
correct, so it's not worth it.
2013-11-07 22:17:35 +01:00
wm4 ce8bc1320d memcpy_pic: reformat
Besides cosmetic changes, also change memcpy_pic return type and remove
config.h include.
2013-11-06 20:27:13 +01:00
wm4 6d2c5fc99a vd_lavc: remove explicit crystalhd support
This removes "--hwdec=crystalhd".

I doubt anyone even tried to use this. But even if someone wants to
use it, the decoders can still be explicitly invoked with e.g.:

    --vd=lavc:h264_crystalhd

The only advantage our special code provided was fallback to
software decoding. (But I'm not sure how the ffmpeg crystalhd
pseudo-decoder actually behaves.)

Removing this will allow some simplifications as soon as we don't need
vdpau_old.c anymore.
2013-11-06 00:47:53 +01:00
wm4 01d12a51f1 gl_header_fixes: fix inverted condition
Could possibly leading to failing compilation on systems with headers
that miss the vdpau extension.
2013-11-05 22:39:19 +01:00
wm4 db6a4eec0a vo_opengl: support for vdpau hardware decoding
This uses vdpau OpenGL interop to convert a vdpau surface to a texture.

Note that this is a bit weak and primitive. Deinterlacing (or any other
form of vdpau postprocessing) is not supported. vo_opengl chroma scaling
and chroma sample position are not supported. Internally, the vdpau
video surfaces are converted to a RGBA surface first, because using the
video surfaces directly is too complicated. (These surfaces are always
split into separate fields, and the vo_opengl core expects progressive
frames or frames with weaved fields.)
2013-11-05 22:28:15 +01:00
wm4 5cca9143ab vdpau: move device and video surface management from vo_vdpau.c to vdpau.c
The goal is being able to use vdpau decoding independently from
vo_vdpau.c.
2013-11-05 22:13:05 +01:00
wm4 ff5a908328 vo_opengl: redo aspects of initialization, change hwdec API
Instead of checking for resolution and image format changes, always
fully reinit on any parameter change. Let init_video do all required
initializations, which simplifies things a little bit.

Change the gl_video/hardware decoding interop API slightly, so that
hwdec initialization gets the full image parameters.

Also make some cosmetic changes.
2013-11-05 22:05:23 +01:00
wm4 91472b84c2 vo_opengl/vaapi: use IMGFMT_RGB0
More correct, might make things slightly faster (probably
insignificant).
2013-11-05 22:05:23 +01:00
wm4 d6de87d1d3 video: make IMGFMT_RGB0 etc. exist even if libavutil doesn't support it
These formats are helpful for distinguishing surfaces with and without
alpha. Unfortunately, Libav and older version of FFmpeg don't support
them, so code will break. Fix this by treating these formats specially
on the mpv side, mapping them to RGBA on Libav, and unseting the alpha
bit in the mp_imgfmt_desc struct.
2013-11-05 22:05:23 +01:00
wm4 7df03a1c9e vo_xv: fix compilation of SHM not available 2013-11-05 22:05:22 +01:00
Paweł Forysiuk f330884b0a Adjust wayland defines 2013-11-04 21:28:34 +01:00
wm4 2826dcff8f vdpau: drop required/deprecated access to a libavcodec struct field
Before the bitstream_buffers field was deprecated, you had to free it,
otherwise you would leak memory.

(Although vdpau.c uses a new API, they managed to introduce a new
deprecation this quickly. This is a complaint.)

This introduces a memory leak of 12 bytes per file on every file on some
_older_ libavcodec versions. This is minor enough that I don't care.
2013-11-04 19:59:03 +01:00
wm4 bb22bee315 vo_opengl: cosmetics/fix typos 2013-11-04 19:46:28 +01:00
wm4 383d8a8b60 vo_opengl: reserve 4 texture units for video instead of 3
Video has up to 4 textures, if you include obscure formats with alpha.
This means alpha formats could always overwrite the first scaler
texture, leading to corrupted video display. This problem was recently
brought to light, when commit 571e697 started to explicitly unbind all 4
video textures, which broke rendering for non-alpha formats as well.

Fix this by reserving the correct number of texture units.
2013-11-04 19:46:15 +01:00
Stefano Pigozzi 9087500179 Merge remote-tracking branch 'origin/have_configure' 2013-11-04 08:31:58 +01:00
wm4 5b6eab01af vo_opengl: fix use of uninitialized memory
Pretty bad, although it should actually not cause any misbehavior. Comes
from the hardware decoding interop commit.
2013-11-04 01:20:11 +01:00
wm4 3813b13796 fix weird DPMS->EXT replacement 2013-11-04 00:43:27 +01:00
wm4 f7b2d644ef Merge branch 'master' into have_configure
Conflicts:
	configure
2013-11-04 00:43:06 +01:00
wm4 2d58fb3b8e vo_opengl: add support for VA-API OpenGL interop
VA-API's OpenGL/GLX interop is pretty bad and perhaps slow (renders a
X11 pixmap into a FBO, and has to go over X11, probably involves one or
more copies), and this code serves more as an example, rather than for
serious use. On the other hand, this might be work much better than
vo_vaapi, even if slightly slower.
2013-11-04 00:11:43 +01:00
wm4 571e697a7c vo_opengl: add infrastructure for hardware decoding OpenGL interop
Most hardware decoding APIs provide some OpenGL interop. This allows
using vo_opengl, without having to read the video data back from GPU.

This requires adding a backend for each hardware decoding API. (Each
backend is an entry in gl_hwdec_vaglx[].) The backends expose video data
as a set of OpenGL textures.

Add infrastructure to support this. The next commit will add support for
VA-API.
2013-11-04 00:11:07 +01:00
wm4 6f17410f88 mp_image: add helper for copying image attributes
This enw function is similar to mp_image_set_params(), but doesn't force
setting "hard" parameters like image size and format.
2013-11-03 23:55:16 +01:00
Stefano Pigozzi 37388ebb0e configure: uniform the defines to #define HAVE_xxx (0|1)
The configure followed 5 different convetions of defines because the next guy
always wanted to introduce a new better way to uniform it[1]. For an
hypothetic feature 'hurr' you could have had:

  * #define HAVE_HURR 1   / #undef HAVE_DURR
  * #define HAVE_HURR     / #undef HAVE_DURR
  * #define CONFIG_HURR 1 / #undef CONFIG_DURR
  * #define HAVE_HURR 1   / #define HAVE_DURR 0
  * #define CONFIG_HURR 1 / #define CONFIG_DURR 0

All is now uniform and uses:
  * #define HAVE_HURR 1
  * #define HAVE_DURR 0

We like definining to 0 as opposed to `undef` bcause it can help spot typos
and is very helpful when doing big reorganizations in the code.

[1]: http://xkcd.com/927/ related
2013-11-03 21:59:54 +01:00
wm4 891a2a1f47 w32: implement functionality required for window-scale
Same semantics with respect to fullscreen as x11.
2013-11-02 17:54:46 +01:00
wm4 9423a7e23e x11: make window-scale use windowed size in fullscreen mode
This is a bit more intuitive, since before, the window size was just set
to something random when setting the window-scale property during
fullscreen.
2013-11-02 17:32:03 +01:00
wm4 4d903127ad demux: rename Windows symbols
There are some Microsoft Windows symbols which are traditionally used by
the mplayer core, because it used to be convenient (avi was the big
format, using binary windows decoders made sense...). So these symbols
have the exact same definition as the Windows one, and if mplayer is
compiled on Windows, the symbols from windows.h are used.

This broke recently just because some files were shuffled around, and
the symbols defined in ms_hdr.h collided with windows.h ones. Since we
don't have windows binary decoders anymore, there's not the slightest
reason our symbols should have the same names. Rename them to reduce the
risk for collision, and to fix the recent regression.

Drop WAVEFORMATEXTENSIBLE, because it's mostly unused. ao_dsound defines
its own version if the windows headers don't define it, and ao_wasapi is
not available on systems where this symbol is missing.

Also reindent ms_hdr.h.
2013-11-02 15:14:12 +01:00
wm4 e0b6fdeb8d Fix some more -Wshadow warnings
These aren't printed with newer gcc or clang versions for some reason.

All of them seem to be about local variables shadowing global functions.
2013-11-01 17:35:38 +01:00
wm4 24897eb94c video: check profiles with hardware decoding
We had some code for checking profiles earlier, which was removed in
commits 2508f38 and adfb71b. These commits mentioned that (working) hw
decoding was sometimes prevented due to profile checking, but I can't
find the samples anymore that showed this behavior. Also, I changed my
opinion, and I think checking the profiles is something that should be
done for better fallback to software decoding behavior.

The checks roughly follow VLC's vdpau profile checks, although we do
not check codec levels. (VLC's profile checks aren't necessarily
completely correct, but they're a welcome help anyway.)

Add a --vd-lavc-check-hw-profile option, which skips the profile check.
2013-11-01 17:33:33 +01:00
wm4 dd344b43e8 Enable -Wshadow
This one really did bite me hard (see previous commit), so enable it by
default.

Fix some cases of shadowing throughout the codebase. None of these
change behavior, and all of these were correct code, and just tripped up
the warning.
2013-11-01 13:00:15 +01:00
wm4 94542abf2e command: add property to scale window size 2013-10-31 23:30:14 +01:00
wm4 b55d557822 x11: factor out normal window resize code
As preparation for resizing the window with input commands in the
following commit.

Since there are already so many functions which somehow resize the
window, add the word "highlevel" to the name of this new function.
2013-10-31 19:51:46 +01:00
wm4 7100a10127 vd_lavc: add more ifdeffery and ffmpeg cargo culting for correctness
We mixed the "old" AVFrame management functions (avcodec_alloc_frame,
avcodec_free_frame) with reference counting. This doesn't work
correctly; you must use av_frame_alloc and av_frame_free. Of course
ffmpeg doesn't warn us about the bad usage, but will just mess up
things silently. (Thanks a lot...)

While the alloc function seems to be 100% compatible, the free function
will do bad things, such as freeing memory that might still be
referenced by another frame. I didn't experience any actual bugs, but
maybe that was pure luck.
2013-10-31 18:17:14 +01:00
wm4 ee2ba635f2 dec_video: remove unused declaration of a former global variable 2013-10-31 18:17:13 +01:00
Stefano Pigozzi 55dca5b6a3 gl_common: osx: fix compilation with latest XQuartz RC
Looks the gl.h header in XQuartz is incompatible with the one in OS X 10.9.
2013-10-30 23:59:43 +01:00
wm4 50e57c346f x11: restore support for --wid=0
This stopped working when the code was changed to create a window even
if --wid is used.

It appears we can't create our own window in this case, because in X11
there is no difference between a window with the root window as parent,
and a window that is managed by the WM. So make this (kind of worthless)
special case use the root window itself.
2013-10-30 22:19:32 +01:00
wm4 7743ed2dc6 x11: remove ancient metacity hack
Tested with recent metacity; this code is not triggered anymore. The
code was added in 2003 and probably has been unused for years.
2013-10-30 22:19:31 +01:00
wm4 4b2d93f103 x11: minor cosmetics 2013-10-30 22:19:31 +01:00
wm4 884b4600a4 gl_x11: change error message when GL3 context creation fails
On systems that provide legacy OpenGL (up to 2.1), but not GL3 and
later, creating a GL3 context will fail. We then revert to legacy GL.

Apparently the error message printed when the GL3 context creation
fails is confusing. We could just silence it, but there's still a X
error ("X11 error: GLXBadFBConfig"), which would be quite hard to
filter out. For one, it would require messing with the X11 error
handler, which doesn't even carry a context pointer (for application
private data), so we don't even want to touch it. Instead, change
the error message to inform the user what's actually happening: a
fallback to an older version of OpenGL.
2013-10-28 23:54:02 +01:00
wm4 96a60e15ce x11_common: refactor of fstype code
This is completely pointless, but it still somehow bugged me.
2013-10-28 22:42:47 +01:00
Stefano Pigozzi e4d23dd01d cocoa: apply the more invasive constraining only with cmd+1/2/3
Regression from bc49957
Fixes #321
2013-10-28 09:08:08 +01:00
wm4 f2d438a1fd x11: fix border toggling
Trying to toggle the border during fullscreen (with "cycle border")
would leave the window stuck without border, and it couldn't be
restored. This was because vo_x11_decoration() always excepted to be
called when toggling the state, and thus confusing the contents of the
olddecor variable. Add got_motif_hints to hopefully prevent this.

Also, when changing the border, don't take fs in account. May break on
older/broken WMs, but all in all is in fact more robust and simpler,
because you do not need to update the border state manually when
returning from fullscreen.
2013-10-27 23:22:46 +01:00
wm4 6e1eb8add9 vo_xv: check whether image allocation succeeds 2013-10-27 17:58:06 +01:00
wm4 74e7043cc7 gl_common: suggest --vo=opengl-old if OpenGL 2.1 missing
If the caller requests at least OpenGL 2.1 (which --vo=opengl does),
but we get OpenGL 1.x, suggest using opengl-old.

Based on a patch by pfor on IRC.
2013-10-26 14:17:53 +02:00
wm4 de303d8ba4 x11_common: reduce screensaver heartbeat from 30 to 10 seconds
Apparently this fixes issues with Gnome, which has a smaller timeout.
See github issue #315.
2013-10-25 20:30:01 +02:00
Stefano Pigozzi bc49957458 cocoa: constraint the window position a little more
The intention of this is to not make the window go outside the screen when
changing dimensions from 2x to .5x.
2013-10-25 20:01:32 +02:00
Alexander Preisinger cb3327fe48 wayland: better name for mouse coordinates
I had to look up what the surf_x and surf_y members do.
That means the name is not very good. Also a comment.
2013-10-25 10:30:12 +02:00
Alexander Preisinger bef2135a44 wayland: fix fullscreen transparent border regions
The default behavior of weston changed some time ago to not fill the surface
black for fullscreen windows.

Now let mpv draw the whole screen in fullscreen mode.
2013-10-25 10:30:11 +02:00
wm4 60aea74f44 m_config: refactor option defaults handling
Keep track of the default values directly, instead of creating a new
instance of the option struct just to get the defaults.

Also get rid of the special handling of m_obj_desc.init_options.
Instead, handle it purely by the option parser. Originally, I wanted to
handle --vo=opengl-hq and --vo=direct3d_shaders with this (by making
them aliases to the real VOs with a different preset), but since --vo
=opengl-hq=help prints the wrong values (as consequence of the
simplification), I'm not doing that, and instead use something
different.
2013-10-24 22:50:13 +02:00