Commit Graph

41980 Commits

Author SHA1 Message Date
wm4 0ae8aebb89 video: refactor GPU memcpy usage
Make the GPU memcpy from the dxva2 code generally useful to other parts
of the player.

We need to check at configure time whether SSE intrinsics work at all.
(At least in this form, they won't work on clang, for example. It also
won't work on non-x86.)

Introduce a mp_image_copy_gpu(), and make the dxva2 code use it. Do some
awkward stuff to share the existing code used by mp_image_copy(). I'm
hoping that FFmpeg will sooner or later provide a function like this, so
we can remove most of this again. (There is a patch, bit it's stuck in
limbo since forever.)

All this is used by the following commit.
2015-09-25 19:18:16 +02:00
Philip Langdale 361040f9d9 vd_lavc: Fix recovery from vdpau preemption
Flushing buffers, and thereby triggering decoder reinitialisation
needs to happen before attempting, and failing, to decode.
2015-09-25 17:29:44 +02:00
wm4 d2281935b3 vo_rpi, wayland: fix build
Broken by commit d47dff3f. If something is going to include EGL.h,
header_fixes.h has to know. This definitely affected vo_rpi, and
probably affects wayland builds (with x11egl didabled) as well.
2015-09-25 16:02:15 +02:00
wm4 0a6c334b59 vo_opengl: vaapi: undo vaAcquireBufferHandle() correctly on error
Checking and resetting the VAImage.buf field is non-sense, even if it
happened to work out in the normal case. buf is actually freed when
vaDestroyImage() is called (not quite intuitive), and we need an extra
field to know whether vaReleaseBufferHandle() has to be called.
2015-09-25 12:14:19 +02:00
wm4 38b747bb67 vaapi: cosmetics, minor fixes
Printing "Using vaDeriveImage()" every frame is too verbose, so raise
the log level.

mp_image strides are in int and not unsigned int; fix this. It's not
like it actually matters, though.

Finish a comment.
2015-09-25 12:10:43 +02:00
wm4 993bee38ca vo_opengl: vaapi: handle YV12 correctly
This specific FourCC has its planes swapped compared to FFmpeg yuv420p.
2015-09-25 12:07:20 +02:00
wm4 0b87bf9b72 vo_opengl: vaapi: document DRM fourcc upstream defines
Add the upstream symbolic names as comments. Normally, these should be
defined in libdrm's drm_fourcc.h header. But DRM_FORMAT_R8 and
DRM_FORMAT_GR88 are not defined anywhere, except in the kernel userland
headers of Linux 4.3 (!). We don't want mpv to depend on bleeding-edge
Linux kernel headers, so this will have to do.

Also, just for completeness, add fourccs for the 3 and 4 channel
formats. I didn't manage to test them, though.
2015-09-25 12:03:36 +02:00
wm4 456366b63b vo_opengl: vaapi: use dummy image to determine plane layout
Reduces the amount of hardcoded assumptions about the layout
drastically. (Now adding yuv420 support would be just adjusting an if,
if you ignore the other problems, such as determining the hw format at
all early enough.)
2015-09-25 10:22:10 +02:00
wm4 ec356d3efe vo_opengl: vaapi: remove unnecessary loop
Not sure what I was thinking.
2015-09-25 10:03:17 +02:00
wm4 5786d07450 vo_opengl: vaapi: fix cleanup
Don't call eglDestroyImageKHR() on the same ID possibly more than once.

Clear the image reference on termination, or we would leak up to 1 image
per VO recreation.
2015-09-25 10:02:54 +02:00
wm4 8d8a2045bd vo_opengl: support new VAAPI EGL interop
Should work much better than the old GLX interop code. Requires Mesa 11,
and explicitly selecting the X11 EGL backend with:

    --vo=opengl:backend=x11egl

Should it turn out that the new interop works well, we will try to
autodetect EGL by default.

This code still uses some bad assumptions, like expecting surfaces to be
in NV12. (This is probably ok, because virtually all HW will use this
format. But we should at least check this on init or so, instead of
failing to render an image if our assumption doesn't hold up.)

This repo was a lot of help: https://github.com/gbeauchesne/ffvademo
The kodi code was also helpful (the magic FourCC it uses for
EGL_LINUX_DRM_FOURCC_EXT are nowhere documented, and
EGL_IMAGE_INTERNAL_FORMAT_EXT as used in ffvademo does
not actually exist).

(This is the 3rd VAAPI GL interop that was implemented in this player.)
2015-09-25 00:26:19 +02:00
wm4 0e9cfa6b64 vo_opengl: add mechanism to retrieve Display from EGL context
The VAAPI EGL interop code will need access to the X11 Display. While
GLX could return it from the current GLX context, EGL has no such
mechanism. (At least no standard one supported by all implementations.)
So mpv makes up such a mechanism.

For internal purposes, this is very rather awkward solution, but it's
needed for libmpv anyway.
2015-09-25 00:20:11 +02:00
wm4 d47dff3faa vo_opengl: load certain EGL extensions needed for VAAPI EGL interop
These extensions use a bunch of EGL types, so we need to include the EGL
headers in common.h to use our GL function loader with this.

In the future, we should probably require presence of the EGL headers to
reduce the hacks. This might be not so simple at least with OSX, so for
now this has to do.
2015-09-25 00:19:58 +02:00
wm4 b81d9c79a8 vo_opengl: enable X11 EGL backend by default
Originally, this was disabled, because it was useless and I was afraid
it could possibly break autodetection and proper fallback.
2015-09-24 23:56:55 +02:00
wm4 57831d52dc vo_opengl: actually set hardware decoder mapped texture format
Surfaces used by hardware decoding formats can be mapped exactly like a
specific software pixel format, e.g. RGBA or NV12. p->image_params is
supposed to be set to this format, but it wasn't.

(How did this ever work?)

Also, setting params->imgfmt in the hwdec interop drivers is pointless
and redundant. (Change them to asserts, because why not.)
2015-09-24 23:48:57 +02:00
wm4 b14c9eb748 client API: rename GL_MP_D3D_interfaces
This is a pseudo-OpenGL extension for letting libmpv query native
windowing system handles from the API user. (It uses the OpenGL
extension mechanism because I'm lazy. In theory it would be nicer to let
the user pass them with mpv_opengl_cb_init_gl(), but this would require
a more intrusive API change to extend its argument list.)

The naming of the extension and associated function was unnecessarily
Windows specific (using "D3D"), even though it would work just fine for
other platforms. So deprecate the old names and introduce new ones. The
old ones still work.
2015-09-24 21:07:37 +02:00
wm4 cb1c072534 vo_opengl: remove sharpen scalers, add sharpen sub-option
This turns the old scalers (inherited from MPlayer) into a pre-
processing step (after color conversion and before scaling). The code
for the "sharpen5" scaler is reused for this.

The main reason MPlayer implemented this as scalers was perhaps because
FBOs were too expensive, and making it a scaler allowed to implement
this in 1 pass. But unsharp masking is not really a scaler, and I would
guess the result is more like combining bilinear scaling and unsharp
masking.
2015-09-23 22:43:27 +02:00
wm4 c17ff1703a vo_opengl: move deband_opts declaration to where it's used
At least one thing the current option code can do right.
2015-09-23 22:21:59 +02:00
wm4 65ad85790a vo_opengl: remove unsued chroma_location field
This was redundant to forcing the value with vf_format, so the vo_opengl
sub-option was removed. This field is just a leftover.
2015-09-23 22:16:36 +02:00
wm4 17cd6798a6 vo_opengl: move shader file caching to video.c
It's just about loading and cachign small files, not does not
necessarily have anything to do with shaders. Move it to video.c where
it's used.
2015-09-23 22:13:03 +02:00
wm4 d8d4e18835 player: fix another --force-window bug
Will this shit ever actually work?

Fixes #2339.
2015-09-23 22:03:11 +02:00
wm4 009dfbe3b6 vd_lavc: do not abort hardware decoding on errors
Usually, libavcodec ignores errors reported by the hardware decoding
API, so it's not like we can actually escape if the hardware is somehow
acting up.

For normal fallback purposes, or if parts of the hw decoding API which
we actually check fails, we do this by setting and checking the
hwdec_failed flag anyway.
2015-09-23 20:37:47 +02:00
wm4 2ed9370bd6 vf_vavpp: allocate output surfaces with the same size as input
This can happen if the hw decoder allocates padded surfaces (e.g.
mod16), but the VPP output surface was allocated with the exact size.
Apparently VPP requires matching input and output sizes, or it will add
artifacts. In this case, it added mirrored pixels to the bottom few
pixels.

Note that the previous commit should have fixed this. But it didn't
work, while this commit does.

Fixes #2320.
2015-09-23 14:20:50 +02:00
wm4 e0c005cb75 va_vavpp: set input/output processing region
If not set, VPP will use the whole surface. This is a problem if the
surfaces are padded, and especially if the surfaces are padded by
different amounts.

This is an attempt to fix #2320, but it appears to do nothing at all.
2015-09-23 14:20:50 +02:00
wm4 4d6c1be7b6 vd_lavc: minor cleanup to hwdec fallback code
The comment was largely outdated, and described the old situation when
we used a "violent" fallback by making get_buffer2 fail completely.

Also, for the case when the hw decoder initialization succeeded (in
get_format), but get_buffer2 for some reason requests something
unexpected, we also can fallback more gracefully and in the same way.
2015-09-23 14:20:50 +02:00
Martin Herkt 79f8ee2808
DOCS: update client API changes for release 2015-09-23 01:12:15 +02:00
Martin Herkt e3e6c1939f
DOCS: update release policy 2015-09-23 01:07:52 +02:00
wm4 4d747400bb win32: allow multiple windows at the same time
Window classes are process-wide (or at least DLL-wide), so you can't
have 2 classes with the same name. Our code attempted to do this when
for example 2 libmpv instances were created within the same process.
This failed, because RegisterWindowEx() fails if the class already
exists.

Fix this by ignoring RegisterWindowEx() errors. If the class can really
not be registered, we will fail on CreateWindowEx() instead. Of course
we also can't unregister the class, as another thread might be using it.
Windows will free the class automatically if the DLL is unloaded or the
process terminates.

Fixes #2319 (hopefully).
2015-09-22 21:54:43 +02:00
wm4 8838c4a5b1 build: allow disabling vapoursynth completely
It's possible to build vf_vapoursynth with either the Python or Lua
backend (or both or none). The check for the vapoursynth core itself was
hidden away and couldn't be disabled, which would link mpv with
vapoursynth even if all backends were disabled.

Rearrange the checks so that the core will be disabled if no backend is
found (or both are disabled). This duplicates the check for
vapoursynth.pc, but since it's trivial, this is not that bad.
2015-09-22 11:46:57 +02:00
wm4 a75e933dac player: fix excessive CPU usage in audio-only mode
Caused by one of the --force-window commits. The unconditional
uninit_video_out() call (which normally should be idempotent) raised
sporadic MPV_EVENT_VIDEO_RECONFIG events. This is ok, except for the
fact that clients (like a Lua script or libmpv users) would cause the
event loop to run again after receiving it, triggering a feedback loop.
Fix it by sending the events really only on a change.
2015-09-22 11:19:39 +02:00
wm4 ab7ac46bcc player: some more --force-window fixes
Sigh... After the recent changes, another regression appeared. This
time, the VO window wasn't cleared when changing from video to a non-
video file (such as audio-only with no cover art). Fix this by properly
taking the handle_force_window() bool parameter into account.

Also, the info message could be printed twice, which is harmless but
ugly. So just remove the message.

Also, do some more minor cleanups (like fixing the comment, which was
completely outdated).
2015-09-21 21:22:20 +02:00
wm4 7a19eb490e player: do not destroy VO prematurely when initializing playback
If --force-window wasn't used, this would destroy the VO while a file
is still being loaded, resulting in flicker and other interruptions
when switching from one playlist entry to another. Recent regression.

The condition used here is pretty tricky, but it boils down to that it
should trigger either in idle mode, or when loading has been fully done
(at these points we definitely know whether the VO will be needed).
2015-09-20 23:13:27 +02:00
wm4 8782354e6d player: rename and move find_subfiles.c
This was in sub/, because the code used to be specific to subtitles. It
was extended to automatically load external audio files too, and moving
the file and renaming it was long overdue.
2015-09-20 18:05:06 +02:00
wm4 f287ccf017 player: add opus to list of external audio file extensions
Fixes #2336.
2015-09-20 18:00:21 +02:00
wm4 2f4e01e772 player: make force-window in auto-profiles actually work
The previous commit was incomplete (and I didn't notice due to a broken
test procedure).

The annoying part is that actually creating the VO was separate; redo
this and merge the code for this into handle_force_window() as well.
This will also make implementing proper reaction to runtime option
changes easier. (Only the part for actually listening to option changes
is missing.)
2015-09-20 17:58:02 +02:00
wm4 9d2bc9a4ac player: make force-window=immediate work in auto-profiles
This is a bad hack; the correct way to handle this would be implementing
profiles differently, and then listen to option changes and act on them
dynamically.
2015-09-20 17:05:14 +02:00
wm4 3586e6ceeb vf_yadif: add hack for Libav compatibility
Libav accepts slightly different options compared to FFmpeg. Sigh...

This was "broken" in 25755f5f. Fixes #2335.
2015-09-20 15:36:52 +02:00
wm4 21e5e4da4b audio/filter: remove reentrancy flag
This flag was used by some filters and made sure none of these filters
were inserted twice. This triggers only if the user explicitly tries to
add multiple filters (and not e.g. due to auto-insertion), so at best
this warned the user from doing something potentially pointless. At
worst, it blocked some (mildly) legitimate use-cases. Get rid of it.

Also see #2322.
2015-09-20 14:44:44 +02:00
Philip Sequeira bad743aed5 TOOLS/zsh.pl: only check the actual exit code when calling mpv
Ignore the other bits of $?. Apparently they can be set even if the
command succeeded.
2015-09-20 14:21:03 +02:00
Philip Langdale 126367bb09 vf_vdpaurb: query_format is still required
I took this out because I thought the filter chain would auto-negotiate
using nv12 without the explicit hint, and it does in the basic case
with no intermediate filter, but once you start adding filters, it
can end up negotiating a different format and then failing.
2015-09-18 07:33:15 -07:00
Philip Langdale 1e53308d65 vf_vdpaurb: Pass through non-hardware-decoded content
Today, vdpaurb will fail if it's used with non-hardware-decoded
content. This created work for the user as they have to explicitly
add or not add it, depending on the content.

As an improvement, we can make vdpaurb pass through any frames
that aren't hardware decoded, so that it can always be present in the
filter chain, if desired.
2015-09-15 21:53:53 -07:00
wm4 fea1e09a9c manpage: add a note about libavfilter 2015-09-11 23:48:47 +02:00
wm4 7020908691 video/filter: remove some vf_lavfi wrappers
I see no point in keeping these around. Keeping wrappers for some select
libavfilter filters just because MPlayer had these filters is not a good
reason.

Ultimately, all real filtering work should go to libavfilter, and users
should get used to using vf_lavfi directly. We might even not require
the awful double-nested syntax for using libavfilter one day.

vf_rotate, vf_yadif, vf_stereo3d are kept because mpv uses them
internally. (They all extend the lavfi filters or change their
defaults.) vf_mirror is kept for symmetry with vf_flip. vf_gradfun and
vf_pullup are probably semi-popular, so I'll remove them not yet - only
after some more discussion.
2015-09-11 23:47:00 +02:00
wm4 876e93d8b7 vf_lavfi: cosmetics: fix coding style 2015-09-11 23:05:14 +02:00
wm4 4e0e24c3c2 af_lavfi: implement af-metadata property
Works like vf-metadata. Unfortunately requires some code duplication
(even though it's not much).

Fixes #2311.
2015-09-11 23:04:02 +02:00
wm4 f095e86b61 af: use generic statuc codes
The reason MPlayer traditionally duplicated them all over the place is
that it wanted every component to be a self-contained library (e.g.
audio filters were in "libaf"). But this is not necessarily helpful, and
this change makes the following commit a bit simpler.
2015-09-11 23:03:04 +02:00
wm4 c2ee824c26 player: prefer logical current directory path
The "PWD" enviornment variable is described by POSIX. We don't go to
length to verify its contents, but just trust it.

This affects the logic for resuming playback.
2015-09-11 23:01:12 +02:00
wm4 d96f6edf49 vf: vf_stereo3d depends on libavfilter 2015-09-11 18:03:16 +02:00
wm4 e76f503fff ao_lavc: minor simplification 2015-09-11 09:01:49 +02:00
Kevin Mitchell 1557d2d470 ao_alsa: use sample format determination code 2015-09-10 23:58:09 -07:00