Commit Graph

2326 Commits

Author SHA1 Message Date
wm4 0b52ac8a78 win32: replace wchar_t with WCHAR
WCHAR is more portable. While at least MinGW, Cygwin, and MSVC actually
use 16 bit wchar_t, Midipix will have 32 bit wchar_t. In that context,
using WCHAR instead is more portable.

This affects only non-MinGW parts, so not all uses of wchar_t need to
be changed. For example, terminal-win.c won't be used on Midipix at
all. (Most of io.c won't either, so the search & replace here is more
than necessary, but also not harmful.)

(Midipix is not useable yet, so this is just preparation.)
2015-07-29 00:01:32 +02:00
wm4 f15e652dd4 vo_opengl: framebuffers work under GLES 2
They are not entirely full-featured in GLES 2, but they appear to
provide all we need. Thus we can enable them.
2015-07-27 23:27:49 +02:00
wm4 2cfd87ab15 vo_opengl: slightly more informative message when disabling scalers 2015-07-27 23:18:19 +02:00
wm4 51ca8a4b3e vo_rpi: determine and return display refresh rate
Reverse engineered from tvservice.c.
2015-07-27 21:09:24 +02:00
wm4 68d5e7a986 vo_opengl: minor cleanup to hwdec texture setting code
Instead of special-casing hwdec in the place where the video textures
are used, just set the textures in the image upload function. The
renderer code doesn't need to know whether hwdec interop is used at all.
2015-07-26 21:44:57 +02:00
wm4 bdc60daffa vo_opengl: remove legacy GL detection
This detected whether an OpenGL context still provided legacy OpenGL if
the OpenGL version is modern (>= 3.0). This was actually only needed for
vo_opengl_old, because it relied on legacy functions. Since it's gone,
this code isn't needed either.

(Also, the removed comment about OpenGL 3.0 was wrong: you could just
query GL_CONTEXT_FLAGS and see if the forward compatible bit was set.)
2015-07-24 23:34:43 +02:00
Niklas Haas 86a60a4dd2 vo_opengl: fix scale=oversample's threshold calculations
This resulted in wrong behavior for values of scale-param1 between 0.0
and 0.5 (not inclusive).
2015-07-23 21:53:03 +02:00
wm4 281c21b7f1 video: don't restrict --vd-lavc-threads to a maximum of 16
Only do it when the number of threads is autodetected, as more than 16
threads are still considered not recommended. (libavcodec prints a
warning.)
2015-07-23 17:17:26 +02:00
wm4 b492720c7c Revert "vo_opengl: make the size of interpolation textures exact"
This reverts commit fb8d158366.

Reallocating the FBOs on every resize is very slow. It affects resizing
the window, as well as changing the video size itself with e.g.
panscan. Since the original change was done based on a single user
complaint, but the change itself caused a lot of complaints, we decided
to just revert it.
2015-07-22 23:57:09 +02:00
wm4 e5fac76b3b vf_scale: cleanup log messages
In particular, get rid of the EUSERBROKEN message.
2015-07-20 21:16:37 +02:00
wm4 4a1657da01 vo: minor simplification for queue size handling
Instead of calling it "future frames" and adding or subtracting 1 from
it, always call it "requested frames". This simplifies it a bit.

MPContext.next_frames had 2 added to it; this was mainly to ensure a
minimum size of 2. Drop it and assume VO_MAX_REQ_FRAMES is at least 2;
together with the other changes, this can be the exact size of the
array.
2015-07-20 21:12:46 +02:00
Niklas Haas 6f7d04be21 vo_opengl: add temporal-dither-period option
This was requested multiple times by users, and it's not hard to
implement and/or maintain.
2015-07-20 19:32:58 +02:00
Niklas Haas b0d1ac93cf vo_opengl: make oversample the default for opengl-hq as well
This was supposed to have changed back when oversample was reintroduced
in 3007250. Fixes #2155.
2015-07-20 09:11:54 +02:00
wm4 47a62059a9 vf_vapoursynth: relicense to LGPL 2.1+
This was requested by someone.

All code was written by myself; some minor changes by 2 contributors who
agreed to general LGPL relicensing. 1 line of code is by someone unknown
who possibly wasn't asked (setting the "display_fps" variable), and
which can be reasonably ignored as it makes up only 0.1% of the file.
2015-07-19 00:03:20 +02:00
Niklas Haas fb8d158366 vo_opengl: make the size of interpolation textures exact
I still have no idea why this is needed, maybe some weird off-by-one
in some shitty driver? Either way, the difference for a working setup
shouldn't be too major, the most noticeable effect would be somewhat worse
performance when resizing the video during playback with interpolation
enabled using the mouse.

That's a specific enough side effect for me to not care as much about it.

Fixes #1814.
2015-07-18 18:41:12 +02:00
wm4 050c529e9a screenshot: don't write PNG colorspace tags by default
Generates too much discussion and confusion.

Fixes #2051.
2015-07-18 18:33:54 +02:00
wm4 bad3996d85 vo_opengl: cleanup frame reupload logic
There are some situations when redrawing is requested, but the current
frame was deleted. This could happen when switching e.g. hw decoding
mid-stream.

Separate uploading/drawing and fix the condition.
2015-07-17 23:26:06 +02:00
wm4 968bd3df3b vo_opengl: refactor queue configuration
Just avoid some code duplication. Also, gl_video_set_options() having a
queue size output parameter is weird at best. While I don't appreciate
that this commit suddenly requires gl_video.c to deal with vo.c directly
in a special case, it's simply the best place to put this function.
2015-07-16 22:43:40 +02:00
wm4 bb9717a630 vo: fix number of future frames
That was 2 too many.

Also fix a documentation comment.
2015-07-16 22:10:08 +02:00
wm4 15954c36ca vo_opengl: reject future images in different formats
The VO will be provided with future frames even if the format changes
mid-stream. This caused a crash if these frames were actually used (i.e.
interpolation mode was enabled).

Fixes a crash when deinterlacing is toggled during playback, and the
deinterlacer changes the stream format (as it can happen e.g. if the
decoder outputs nv12, which in turn happens with hw decoding).

(On a side note, future frames are always non-NULL. Also, the current
frame is of course always in the correct format.)
2015-07-15 14:59:26 +02:00
wm4 7ef8f457a8 vaapi: destroy derived VAImage after each use
Appears to be required by some hardware. Whatever.
2015-07-15 13:30:32 +02:00
wm4 bc68794acc vo_vaapi: drop unused field 2015-07-15 13:27:38 +02:00
wm4 50bd2807ad vaapi: don't assume vaQueryImageFormats() returns sorted list
vaQueryImageFormats() returns a randomly ordered list - so we shouldn't
assume the first format on the list which works is the best. This
effectively switches to nv12 instead of yuv420p on some drivers.

We handle this by reusing va_to_imgfmt[], and ordering it by preference.
We hardcode that GPUs prefer nv12 pver yuv420p. In theory we could do
complicated probing (allocate dummy surface + use vaDeriveImage on it,
then retrieve the FourCC) - but all things which could break assumption
in the future are not supported yet (like 10 bit or 4:4:4), so this is
fine.
2015-07-15 13:27:25 +02:00
wm4 e3e20f1431 Revert "vaapi: remove vaDeriveImage() code path"
This reverts commit d660e67be9.

Fixes #2123.
2015-07-15 13:15:58 +02:00
wm4 d1c37c0e29 vaapi: allow allocating additional surfaces during decoding
Fixes problems with --vo=opengl:interpolation. The issue here is that
vo_opengl retains more surfaces than what was preallocated for the
decoder. Until now, we just explicitly failed to decode frames for which
no additional surfaces are available. Since modern drivers usually are
fine with not "registering" surfaces before the decoder is created, just
allow allocating additional surfaces if needed.

(We also could probably recreate the HW decoder, since the HW decoder
should be stateless. But let's try to avoid raising the overall
complexity of the code.)
2015-07-15 12:37:28 +02:00
wm4 423a1a0f6c vo_opengl: simplify
After recent changes, there is no reason why gl_video_set_image() should
exist anymore. So merge it back into gl_video_upload_image().
2015-07-15 12:22:49 +02:00
Philip Langdale e1ab9b905f vf_vdpaupp: Don't crash when evaluating interlacing of NULL mpi
The interlaced frame test needs to be aware that the input mpi might be
NULL - this happens at the end of a stream when the input frames have
all been submitted but frames still need to be drained from the
decoder.
2015-07-14 11:10:04 +02:00
wm4 898855cc0d vo_opengl: reduce verbose output
Outputting the detected OpenGL features was useless and redundant with
the extension loading output.

Also, remove MPGL_CAP_3D_TEX from OpenGL(ES) 3.0. This block didn't
include the glTexImage3D function, so that was pointless and couldn't
have worked. The OpenGL 2.1 block does it correctly.
2015-07-11 20:01:28 +02:00
Philip Langdale 5776b0c940 vo_vdpau: Implement rotation support
VDPAU has explicit support for rotating surfaces, and it is far less
expensive than using the normal rotation filter (which would require
reading video frames back into system memory), it is desirable to
implement the VO rotation capability.

To do this, we need to render the video frames to an output surface,
without rotation, and then render from that surface to the final
output surface to apply the rotation. It is important that the
intermediate surface is the same size as the final one (only not
rotated) so that hqscaling can be applied if requested by the user.

(hqscaling is a mixer capability and so takes effect when the video
surface is rendered to an output surface)

Finally, we must remember to explicitly clear the final output
surface as VDPAU only auto-clears output surfaces when rendering video
surfaces.
2015-07-11 20:01:28 +02:00
Niklas Haas 3007250824
vo_opengl: reimplement tscale=oversample
Closes #2102.
2015-07-11 14:00:43 +02:00
Philip Langdale 4b0b9b515b vf_vdpaurb: Add a new filter for reading back vdpau decoded frames
Normally, vdpau decoded frames are passed directly to a suitable
vo (vo_vdpau or vo_opengl) without ever touching system memory. This
is efficient for output purposes, but prevents any of the regular
filters from being used with such frames.

This new filter implements a read-back step to pull the frames back
into system memory where they can be acted on by other filters.
Eventually the frames will be sent to the vo as if they were normal
software-decoded frames.

Note that a vdpau compatible vo must still be used to ensure that
the decoder is properly initialised.

Signed-off-by: wm4 <wm4@nowhere>
2015-07-11 10:44:34 +02:00
wm4 59b64ceb79 video: add a way to disable automatic stereo conversion
Fixes #2111.
2015-07-10 18:04:34 +02:00
wm4 140273cdec vf_stereo3d: drop internal implementation
Leave the libavfilter wrapper only.
2015-07-10 18:03:38 +02:00
wm4 707fe102b6 gl_hwdec: change wording in verbose message 2015-07-10 12:22:24 +02:00
wm4 ef7278b4fd vf_vdpaupp: don't attempt to deinterlace progressive frames 2015-07-08 15:14:38 +02:00
wm4 d2c05cb559 mp_image: fix vf_vdpaupp references
Some code called by vf_vdpaupp.c calls mp_image_new_custom_ref(), but
out of convenience doesn't reset the buffers. Make this behavior ok.
(The assert() was there to catch usage errors, but the same error could
already happen before the refcount changes were made, so the check is
not overly helpful.)

Fixes #2115.
2015-07-08 14:48:17 +02:00
wm4 db2268d5b1 vaapi: drop compatibility crap and vo_vaapi deinterlacer
Drop libva versions below 0.34.0. These are ancient, so I don't care.

Drop the vo_vaapi deinterlacer as well. With 0.34.0, VPP is always
available, and deinterlacing is done with vf_vavpp.

The vaCreateSurfaces() function changes its signature - actually it did
in 0.34.0 or so, and the <va/va_compat.h> defined a macro to make it use
the old signature.
2015-07-08 14:48:11 +02:00
wm4 4781f9e69a vf_vavpp: don't attempt to deinterlace progressive frames 2015-07-08 14:48:11 +02:00
wm4 9620e37d6a vaapi: increase number of additional surfaces
Sometime recently, hardware decoding started to fail if h264 with full
reference frames was decoded, and --vo=vaapi was used. VAAPI requires
registering all surfaces that the decoder will ever use in advance, so
if the playback chain uses more surfaces than originally allocated, we
fail and drop back to software decoding.

I'm not really sure why or when this started happening. Commit 7b9d7265
for one is not the cause - it can be reproduced with earlier commits. It
also seems to be timing dependent. Possibly it has to do with the way
vo.c retains previous surfaces, and the way they can be queued/unqueued
asynchronously.

Increasing the number of reserved additional surfaces by 1 fixes it.

(Though I have no idea where exactly all these surfaces are being used.
Or rather, _when_.)
2015-07-08 12:18:29 +02:00
wm4 25755f5fe7 vf_yadif: expose interlaced frame mode
Also remove the enabled suboption, which did nothing. (It was probably
broken at some point.)
2015-07-07 15:18:56 +02:00
wm4 92727e7332 vo_opengl_cb, vo_opengl: add option for preloading hwdec context
See manpage additions. This is mainly useful for vo_opengl_cb, but can
also be applied to vo_opengl.

On a side note, gl_hwdec_load_api() should stop using a name string, and
instead always use the IDs. This should be cleaned up another time.
2015-07-07 15:05:32 +02:00
wm4 1d29177c5c options: cleanup hwdec name mappings
Now there's a "canonical" table for mapping the names, that other code
can use, without having to rely too much on option code magic.

Also, use the central HWDEC constants, instead of magic values. (There
used to be semi-ok reasons to do this, but now it makes no sense
anymore.)
2015-07-07 15:05:32 +02:00
wm4 dc33eb56f4 vo_opengl_cb: drop frames eagerly if frames are not rendered
libmpv users might stop calling the frame render callback for stupid
reasons, at which point video frames would pile up.
2015-07-07 13:59:33 +02:00
wm4 dcd167ca37 dxva2: fix handling of cropped video
Basically, we need to make sure to allocate enough data for the pretty
dumb copy_nv12 function. (It could be avoided by making the function
less dumb, but this fix is simpler.)
2015-07-06 21:25:07 +02:00
wm4 7b9d726588 video: replace our own refcounting with libavutil's
mpv had refcounted frames before libav*, so we were not using
libavutil's facilities. Change this and drop our own code.

Since AVFrames are not actually refcounted, and only the image data
they reference, the semantics change a bit. This affects mainly
mp_image_pool, which was operating on whole images instead of buffers.
While we could work on AVBufferRefs instead (and use AVBufferPool),
this doesn't work for use with hardware decoding, which doesn't
map cleanly to FFmpeg's reference counting. But it worked out. One
weird consequence is that we still need our custom image data
allocation function (for normal image data), because AVFrame's uses
multiple buffers.

There also seems to be a timing-dependent problem with vaapi (the
pool appears to be "leaking" surfaces). I don't know if this is a new
problem, or whether the code changes just happened to cause it more
often. Raising the number of reserved surfaces seemed to fix it, but
since it appears to be timing dependent, and I couldn't find anything
wrong with the code, I'm just going to assume it's not a new bug.
2015-07-05 23:56:00 +02:00
wm4 34b223d730 mp_image: make image writeable before overwriting palette
This is an obscure but theoretically possible bug.
2015-07-05 23:55:47 +02:00
wm4 95424517a2 vo: free frames before killing VO
This caused issues with hardware decoding. The VOs by definition dictate
the lifetime of the hardware context, so no surface allocations must
survive the VO. Fixes assertions on exit with vdpau.
2015-07-04 17:27:13 +02:00
wm4 31f2cd03d0 vo: set correct frame parameters on redraw 2015-07-03 19:35:39 +02:00
wm4 561416597e client API, dxva2: add a workaround for OpenGL fullscreen issues
This is basically a hack for drivers which prevent the mpv DXVA2 decoder
glue from working if OpenGL is in fullscreen mode.

Since it doesn't add any "hard" new API to the client API, some of the
code would be required for a true zero-copy hw decoding pipeline, and
sine it isn't too much code after all, this is probably acceptable.
2015-07-03 16:38:12 +02:00
wm4 b85321d057 vo_direct3d, dxva2: use the same D3D device
Since we still read-back (and don't have hard plans on changing this),
this doesn't have much of an advantage.
2015-07-03 16:04:42 +02:00
wm4 b6dc11810b dxva2: move device creation code
Preparation for the following commit.
2015-07-03 15:42:52 +02:00
wm4 cc51dafa96 vo_opengl: log some more stuff in verbose mode 2015-07-03 15:12:42 +02:00
wm4 ff25c0ad7d vo_opengl: fix "freezes" after seeking with interpolation on
When seeking to a different position, and seeking takes long, the OSD
might get redrawn. This means that the VO will receive a request to
redraw an old frame using whatever the previous PTS was. This breaks the
interpolation logic: the old frame will be added to the queue, and then
the next frames (with lower PTS if you seeked backwards) are not drawn
as the logic assumes they're past frames.

Fix this by using the non-interpolation code path when redrawing after a
seek reset, and no "real" frame has been drawn yet.

It's a recent regression caused by the redrawing code simplification.
The old code simply sent a VOCTRL for redrawing the frame, and the VO
had to deal with retaining the old frame on its own.

This is a hack as in there's probably a better solution.

Fixes #2097.
2015-07-02 13:18:06 +02:00
wm4 53845d81f5 vo: reset frame timing when redrawing
bother vo_vdpau.c, which actually uses these times.
2015-07-02 13:03:58 +02:00
wm4 dc2b6ab6b7 vo_opengl: X11: don't leak when GL init fails 2015-07-02 00:30:13 +02:00
wm4 89713808ad vo_opengl: X11 EGL: more detailed error reporting 2015-07-02 00:28:25 +02:00
wm4 c169292902 vo_opengl: update EGL code
Use the newer internal GL backend API.
2015-07-02 00:25:30 +02:00
wm4 99bc049745 vo_opengl: remove unused GL API functions 2015-07-02 00:08:17 +02:00
wm4 6afef5839f x11: move GCs and background clearing to vo_xv
vo_xv.c is the only place where these things are used.
2015-07-01 23:55:10 +02:00
wm4 8dff03560a x11: remove clear on map
Less code, and avoids a black flash on start.

In theory it could happen that we map the window, and then don't have a
frame to draw - but mapping the window is done in the exact moment we
have a new frame to display.
2015-07-01 23:46:34 +02:00
wm4 e3d85ad46d vo: better magic value for unknown vsync interval
The value 1 is useful in some contexts, but not such a good choice
otherwise.
2015-07-01 22:38:22 +02:00
wm4 03e062d53e vo_opengl_cb: fix interpolation code path 2015-07-01 22:38:13 +02:00
Niklas Haas 8043063275 vo_opengl: fix framestepping/pausing + interpolation
This is not the most theoretically perfect solution, ideally we could
check to see if the frame in question has already been rendered
somewhere in the queue and then avoid re-rendering it, at the cost of a
few extra lines of code. But I don't think the performance trade-off is
dramatic enough here.
2015-07-01 22:38:06 +02:00
wm4 0739cfc209 vo: change internal API for drawing frames
draw_image_timed is renamed to draw_frame. struct frame_timing is
renamed to vo_frame. flip_page_timed is merged into draw_frame (the
additional parameters are part of struct vo_frame). draw_frame also
deprecates VOCTRL_REDRAW_FRAME, and replaces it with a method that
works for both VOs which can cache the current frame, and VOs which
need to redraw it anyway.

This is preparation to making the interpolation and (work in progress)
display sync code saner.

Lots of other refactoring, and also some simplifications.
2015-07-01 22:38:02 +02:00
Niklas Haas f166d12985 vo_opengl: adjust interpolation code for the new video-sync mechanism
This should make interpolation work much better in general, although
there still might be some side effects for unusual framerates (eg. 35 Hz
or 48 Hz). Most of the common framerates are tested and working fine.
(24 Hz, 30 Hz, 60 Hz)

The new code doesn't have support for oversample yet, so it's been
removed (and will most likely be reimplemented in a cleaner way if
there's enough demand). I would recommend using something like robidoux
or mitchell instead of oversample, though - they're much
smoother for the common cases.
2015-07-01 22:37:55 +02:00
wm4 c5e3613bba video: pass vsync offset to VO
For now, this is trivial (and actually redundant). The future display
sync code will make better use of it. The main point is that the new
internal API pretty much makes this transparent to the vo_opengl
interpolation code.
2015-07-01 22:37:51 +02:00
wm4 41ad9d8924 video: pass future frames to VO
Now the VO can request a number of future frames with the last parameter
of vo_set_queue_params(). This will be helpful to fix the interpolation
code.

Note that the first frame (after playback start or seeking) will usually
not have any future frames (to make seeking fast). Near the end of the
file, the number of future frames will become lower as well.
2015-07-01 22:37:46 +02:00
wm4 2e4f106ef8 video: fix panscan in vertical case
If the black bars appeared on the left/right borders, panscan=1 didn't
make the video cover the whole screen.
2015-06-29 23:46:59 +02:00
wm4 a5b96226a0 vaapi: prefer direct display over copy-back
Again. With the old OpenGL interop dropped, this probably works better
than vaapi-copy now. Last time we defaulted to vaapi-copy, because the
OpenGL interop could swap U/V planes and other stupid crap. We'll see.
2015-06-29 15:14:38 +02:00
wm4 ef3d121c9e vaapi: treat cropped decoder output slightly more correctly
Work around that FFmpeg doesn't distinguish between surface and cropped
size. The decoder always aligns the surface size to something
"convenient" (e.g. 16 for h264), and to get to the correct cropped size,
the output image's width/height is reduced. Using the cropped size
instead of the real surface size breaks the libva API in certain cases,
so we simply store and use the original size in our per-surface struct.

(If data is cropped on the left/top borders, hw decoding will simply
display these - FFmpeg doesn't let us do better.)
2015-06-29 15:13:45 +02:00
wm4 e0b1b88e83 vaapi: fix potential NULL deref on memory allocation failure 2015-06-29 15:10:17 +02:00
wm4 d660e67be9 vaapi: remove vaDeriveImage() code path
In theory, this code path avoids a copy. In practice, it never seems
to get enabled at all. But it does have potential for weird bugs or
performance issues (like being mapped from non-cacheable memory),
so kill it.
2015-06-29 15:10:07 +02:00
wm4 d98cd6609d x11: remove trailing spaces 2015-06-29 15:09:28 +02:00
Eduardo Sánchez Muñoz db3d36927d x11: Handle external fullscreen toggles
Some window managers let you change the fullscreen state of any window
using a key combination. For example, on XFWM you can use Alt+F11 and
on Compiz you can configure a key combination with the
"Extra WM actions" plugin.

With this change mpv will handle these fullscreen state changes. So, if
you enter into fullscreen mode using the WM's shortcut and then you use
mpv's fullscreen toggle, you will get back into window mode.

Merges PR #2081.

Signed-off-by: wm4 <wm4@nowhere>
2015-06-28 20:13:57 +02:00
rr- 745cc7a8cd vo_drm: make VT switching non mandatory 2015-06-28 17:11:51 +02:00
rr- fb1b8f93aa vo_drm: fix missing newlines in error messages 2015-06-28 15:22:11 +02:00
wm4 d11184a256 vo_x11: remove this video output
It only causes additional maintenance work.

Even if you wanted to have a fallback, it's probably better to use
--vo=sdl or so.
2015-06-26 17:17:34 +02:00
wm4 0906f758d3 vo_sdl: fix glaring memory leak
Who knows when this broke?
2015-06-25 09:55:24 +02:00
wm4 be882175d8 demux: merge extradata fields
MPlayer traditionally had completely separate sh_ structs for
audio/video/subs, without a good way to share fields. This meant that
fields shared across all these headers had to be duplicated. This commit
deduplicates essentially the last remaining duplicated fields.
2015-06-21 18:06:14 +02:00
wm4 2b64eee8d5 demux: rename sh_stream.format to sh_stream.codec_tag
Why not. "format" sounds too misleading for the actual importance and
meaning of this field.
2015-06-21 16:56:35 +02:00
wm4 991af7dfb1 video: reduce error message when loading hwdec backend fails
When using --hwdec=auto, about half of all systems will print:

    "[vdpau] Error when calling vdp_device_create_x11: 1"

this happens because usually mpv will be linked against both vdpau and
vaapi libs, but the drivers are not necessarily available. Then trying
to load a driver will fail. This is a normal part of probing, but the
error messages were printed anyway. Silence them by explicitly
distinguishing probing.

This pretty much goes through all the layers. We actually consider
loading hw backends for vo_opengl always "auto probed", even if a hw
backend is explicitly requested. In this case vd_lavc will print a
warning message anyway (adjust this message a bit).
2015-06-20 22:26:57 +02:00
wm4 b17b8ff7fe x11: make screensaver failure message slightly more friendly 2015-06-20 21:55:15 +02:00
wm4 da9e0988a6 win32: remove a wine hack
No particular reason, but it's still possible that it causes additional
corner cases, and it's not really needed to test this on wine (other
than testing fullscreen stuff, which should be done on a real Windows
anyway).
2015-06-20 14:32:14 +02:00
wm4 91fdfd3880 win32: prefer using internal variable for fullscreen
No particular reason, but since we already have an internal variable,
it's better than using the option struct, which will be redone sooner
or later.
2015-06-20 14:29:17 +02:00
Marcin Kurczewski 797277a233 Various spelling fixes
Signed-off-by: wm4 <wm4@nowhere>
2015-06-18 19:36:58 +02:00
wm4 e00e9d651b player: make decoding cover art more robust
When showing cover art, the decoding logic pretends that the source has
an infinite number of frames. This slightly simplifies dealing with
filter data flow. It was done by feeding the same packet repeatedly to
the decoder (each decode run produces new output).

Change this by decoding once at the video initialization. This is easier
to follow, and increases robustness in case of broken images. Usually,
we try to tolerate decoding errors, so decoding normally continues, but
in this case it would just burn the CPU for no reason.

Fixes #2056.
2015-06-18 18:39:46 +02:00
wm4 ec72feaba3 win32: use atomics for COM interface refcount 2015-06-14 17:56:24 +02:00
Marcin Kurczewski 8d6c22def4 vo_drm: fixed crashes with --profile=pseudo-gui 2015-06-13 16:18:11 +02:00
wm4 7de2411c47 vo_opengl: fix a small memory leak when loading user shaders
When gl_shader_cache was destroyed, existing user shader entries leaked
the file path string.
2015-06-09 22:42:03 +02:00
wm4 4a90b15f74 vo_opengl: fix dangling pointers with vo_cmdline
gl_video_set_options() does not acquire ownership of the opts parameter
or its contents. In case of vo_cmdline, opts will point to temporary
memory. This memory will be free'd at a later point, and p->opts will
point to free'd memory on the next reinitialization.

The fix is pretty ugly, but it's a quick bug fix. This can probably be
removed once VO sub-options are exposed as properties.

Fixes #2035.
2015-06-09 22:30:32 +02:00
wm4 f72028ddad vaapi: add missing license header
Absence of license header implies LGPL, as mentioned in the "Copyright"
file. But vaapi.h contains some code taken from the mplayer-vaapi
patch, which was under the typical MPlayer license.
2015-06-08 22:14:47 +02:00
wm4 0dfbd29828 gl_osd: fix license header
All vo_gl.c related code has been GPL+LGPL dual-licensed. The OSD code
is no exception and is also derived from vo_gl.c. Thus it should have
the same license (although I think technically speaking sub-licensing
it by removing one of the licenses is ok).
2015-06-08 22:13:00 +02:00
wm4 5dbd22e165 vo: clarify condition
This is (at least currently) redundant, but makes the code more
explicit. (This was discussed on IRC.)
2015-06-08 12:27:40 +02:00
Avi Halachmi (:avih) b694f480fe vo: restore frame-drop logic for high-fps clips
Commits 92b27be and f4ce99d removed high-fps logic to to a bug. That bug was
a missing parenthesis around everything after duration >= 0 && ... at the
removed code.

This patch restores the removed code, fixes the bug and then refactors the
code a bit.
2015-06-07 23:53:37 +02:00
wm4 92b27bec45 Revert "opengl: drop less frames when clip and display have similar fps"
This reverts commit f1746741de.

Together with the other revert, this fixes #2023 (the reason being
broken framedrop handling - it was dropping frames when it shouldn't).
2015-06-07 20:06:42 +02:00
wm4 f4ce99d082 Revert "vo: improve frame drop logic on high playback rate"
This reverts commit ffcad1a72b.
2015-06-07 20:04:49 +02:00
wm4 fb7d0c80cc vo_vdpau: add a NULL check, verify image dimensions
read_output_surface() could fail and return NULL.

Also, make sure we don't set the image to a size larger than the
allocated size. Normally this shouldn't happen, but in theory it could
in corner cases; this is for robustness.
2015-06-06 21:06:54 +02:00
wm4 2bf2254248 vo_vdpau: limit output surfaces to allowed maximum dimensions
We can't do much in this case, but at least we can not call the vdpau
API functions with too large sizes. Apparently the API considers this
undefined behavior, and random stuff might happen.
2015-06-05 22:34:16 +02:00
wm4 e0f0f6f3e9 vo_vdpau: directly get surface size from surface for screenshots
The previous code was not wrong, but I'd claim this makes the code more
robust. If a situation could happen in which the passed surface size is
incorrect, we could have passed a too small image, and
VdpOutputSurfaceGetBitsNative could have randomly overwritten memory.
2015-06-05 22:34:16 +02:00
wm4 650469d65b vo_vdpau: shorten 2 variable names
Why should I be required to type so much?
2015-06-05 22:34:16 +02:00
wm4 54b6389873 vf_sub: minor simplification 2015-06-05 18:59:13 +02:00
Niklas Haas b68627ed2b filter_kernels: distinguish between regular/EWA robidoux
This is because it turns out the regular robidoux is pretty useful for
tscale etc.
2015-06-05 17:08:39 +02:00
wm4 af58bfb62b vo_vdpau: check maximum video size
Check the maximum size of video surfaces, and refuse initialization if
the video is too large for them.

Maybe we could do something more sophisticated, like inserting a
software scaler. On the other hand, this would have a very questionable
benefit, as it would be guaranteed to be too slow.
2015-06-04 22:29:26 +02:00
wm4 ebc5237c36 vf_vavpp: provide future/past frames to driver
This was missing for extended deinterlacer.

Unfortunately, these deinterlacer still do not work. The provided future
frame (which is all the deinterlacers want) seems to be correct, though.

One minor behavioral change is that this always keeps the previous frame
for PTS computations. This could be avoided (in order to keep exactly
the same behavior as before), but it seems more elegant and should not
do any harm. (Also, if we really cared about reducing hw frame refs,
a more worthy goal is producing the field output incrementally.)
2015-06-01 01:39:30 +02:00
wm4 ebde784fab vf_vavpp: move vaMapBuffer() closer to its use
The mapped data (pointed to by the param variable) is not needed before,
so the call can be moved down. Also, this prevents that the buffer
remains mapped forever if the other vaMapBuffer() call above fails (the
cleanup code forgets to unmap the buffer - this commit makes it
unnecessary).
2015-06-01 01:34:55 +02:00
wm4 8e010a500d vf_vavpp: remove dummy loop, unindent
This used a do-while loop, which runs only once, as replacement for a
cleanup goto. While this is ok, doing a goto directly is easier to
follow and is closer to idiomatic C. But mainly remove it so that the
indentation can be reduced.
2015-06-01 01:34:00 +02:00
wm4 4c20e45561 vf_vavpp: cosmetics
Adjust coding style. Get rid of some useless consts too.
2015-06-01 01:33:37 +02:00
wm4 99bc1df84d vf_vavpp: minor simplification
Slightly easier to follow.
2015-06-01 01:32:52 +02:00
wm4 d91d24ba7e win32: fix window resize logic
Reconfiguring with the same video size should never cause the window to
resize back to the video size (if the user changed its size). This was
broken and it resized anyway.
2015-05-31 17:54:14 +02:00
wm4 3170473003 vo_opengl: output slightly more debugging info on backend probing 2015-05-30 21:25:28 +02:00
wm4 a3f7b38cbc vo: move up vo_wayland in autoprobe list
When running on Wayland, and vo_opengl is not available or rejected for
some reason, it's better to use vo_wayland instead of e.g. vo_x11.
2015-05-30 21:00:37 +02:00
Filip Milivojevic 47d841458d vf_vavpp: fix bob deinterlacing for bottom field first videos
Signed-off-by: wm4 <wm4@nowhere>
2015-05-30 14:56:04 +02:00
wm4 ed925c70c9 vf_vavpp: do not pretend to support references
We do not fill them, so we would pass random IDs to the driver. The code
was originally written to handle bob deinterlacing only, so I guess it
originally passed always 0 anyway, despite having code for reference
surface list allocation.

Also, move down the vaUnmapBuffer() call. This call actually "unmaps"
the param pointer, so accessing it after the unmap call would be
undefined behavior. The "example" in <va/vavpp.h> does this too, but
it's most likely an error.

(Additionally, not even bob deinterlacing worked correctly in my test,
sigh.)
2015-05-29 23:06:22 +02:00
wm4 ad85203d63 vf_vavpp: simplify surface list allocation 2015-05-29 23:01:44 +02:00
Marcin Kurczewski 20bc56b22d vo_drm: fix not using BUF_COUNT 2015-05-29 18:42:20 +02:00
Marcin Kurczewski 4763718728 vo_drm: fix centering with regard to stride 2015-05-29 18:42:04 +02:00
wm4 d3894290ec vaapi: remove direct mapping non-sense
This must have been some non-sense in the original vaapi mplayer patch.
While I still have no good idea what this "direct mapping" business is
about, it appears to be pretty much pointless. Nothing can hold
additional "real" surface references (due to how the API and mpv/lavc
refcounting work), so removing the additional surfaces won't break
anything. It still could be that this was for achieving additional
buffering (not reusing surfaces as soon), but we buffer some additional
data anyway. Plus, the original intention of the vaapi mplayer code was
probably increasing surface count just by 1 or 2, not actually doubling
it, and/or it was a "trick" to get to the maximum count of 21 when h264
is in use.

gstreamer-vaapi uses "ref_frames + SCRATCH_SURFACES_COUNT" here, with
SCRATCH_SURFACES_COUNT defined to 4. It doesn't appear to check the
overlay attributes at all in the decoder.

In any case, remove this non-sense.
2015-05-29 16:28:55 +02:00
wm4 9fe6a8c5f5 vd_lavc: fix a hw decoding fallback case
On hw decoder reinit failure we did not actually always return a sw
format, because the first format (fmt[0]) is not always a sw format.
This broke some cases of fallback. We must go through the trouble to
determine the first actual sw format.
2015-05-29 14:17:51 +02:00
wm4 6a5cbe7802 vdpau: do not attempt to allocate surfaces while preempted
This reduces spam while preempted a bit.

The remaining message, "hardware accelerator failed to decode picture"
on every frame, can not be prevented because it's hardcoded in
libavcodec.
2015-05-29 13:48:18 +02:00
wm4 c4757ad17c vo_opengl: avoid broken shader if hwdec fails to provide textures
If gl_hwdec_driver.map_image fails, all textures will be set to 0. This
in turn makes pass_prepare_src_tex() skip generation of the texture
uniforms, which leads to a shader compilation error, as e.g. texture0 is
not defined but expected to exist and accessed.

Set the textures to an invalid non-0 ID instead. OpenGL can deal with
it.
2015-05-28 21:56:45 +02:00
wm4 6f5a10542c vdpau: add support for the "new" libavcodec vdpau API
Yet another of these dozens of hwaccel changes. This time, libavcodec
provides utility functions, which initialize the vdpau decoder and map
codec profiles. So a lot of work the API user had to do falls away.

This also will give us support for high bit depth profiles, and possibly
HEVC once libavcodec supports it.
2015-05-28 21:56:13 +02:00
wm4 0699a6c598 video: rename vdpau.c to vdpau_old.c
vdpau.c will be used for new code.
2015-05-28 21:56:09 +02:00
wm4 a9b1e72ef2 vd_lavc: allocate hw surfaces using the coded size
...instead of relying on the hw decoding API to align it for us. The old
method could in theory have gone wrong if the video is cropped by an
amount large enough to step over several blocks.
2015-05-28 21:55:16 +02:00
wm4 e632e37ab8 vdpau: retrieve mixer parameters directly from the hw surface
Always configure the vdpau mixer based on the current surface sent to
it. Before this, we just hardcoded the chroma type, and the surface size
was essentially a guess.

Calling VdpVideoSurfaceGetParameters() on every surface is a bit
suspicious, but it appears it's a cheap function (just requiring some
locks and a table lookup). This way we avoid creating another
complicated mechanism to carry around the actual surface parameters
with a mp_image/AVFrame.
2015-05-28 21:54:02 +02:00
wm4 939132cbd9 vd_lavc: merge two functions
There's not much of a reason to keep get_surface_hwdec() and
get_buffer2_hwdec() separate. Actually, the way the mpi->AVFrame
referencing is done makes this confusing. The separation is probably
an artifact of the pre-libavcodec-refcounting compatibility glue.
2015-05-28 21:53:37 +02:00
wm4 a2eb0ab076 vd_lavc: make hardware decoding fallback less violent
Most of hardware decoding is initialized lazily. When the first packet
is parsed, libavcodec will call get_format() to check whether hw or sw
decoding is wanted. Until now, we've returned AV_PIX_FMT_NONE from
get_format() if hw decoder initialization failed. This caused the
avcodec_decode_video2() call to fail, which in turn let us trigger the
fallback. We didn't return a sw format from get_format(), because we
didn't want to continue decoding at all. (The reason being that full
reinitialization is more robust when continuing sw decoding.)

This has some disadvantages. libavcodec vomited some unwanted error
messages. Sometimes the failures are more severe, like it happened with
HEVC. In this case, the error code path simply acted up in a way that
was extremely inconvenient (and had to be fixed by myself). In general,
libavcodec is not designed to fallback this way.

Make it a bit less violent from the API usage point of view. Return a sw
format if hw decoder initialization fails. In this case, we let
get_buffer2() call avcodec_default_get_buffer2() as well. libavcodec is
allowed to perform its own sw fallback. But once the decode function
returns, we do the full reinitialization we wanted to do.

The result is that the fallback is more robust, and doesn't trigger any
decoder error codepaths or messages either. Change our own fallback
message to a warning, since there are no other messages with error
severity anymore.
2015-05-28 21:52:04 +02:00
Marcin Kurczewski ce0bf9692f vo_drm: Expose mode ID option to users 2015-05-28 21:51:49 +02:00
Marcin Kurczewski eea625736f vo_drm: Fix resolution not restored after exiting 2015-05-28 21:51:49 +02:00
Marcin Kurczewski 5a1ef9d8db vo_drm: Fix stride problem for certain devices 2015-05-28 21:51:48 +02:00
wm4 acc4102ba2 vo_opengl: rename use_full_range to use_normalized_range
As suggested by haasn. The term "full range" makes it sound like it has
to do with TV vs. PC range, which is not the case at all.
2015-05-27 17:40:58 +02:00
Niklas Haas b65c548b7d vo_opengl: fix source-shader + XYZ input 2015-05-27 11:32:42 +02:00
Niklas Haas 22af0dce0d vo_opengl: CMS no longer implies linear scaling
They're completely orthogonal concepts, merged in the past due to
convenience and ease of implementing it in the old #ifdef hell renderer.

Especially after the CMS stuff was generalized by 634b4a, this was a
trivial change to implement and also means color management will be much
higher quality when enabled with vo=opengl (which had quantization
issues in the past due to the 8 bit FBO format and upscaling), since it
can be done in a single pass now.
2015-05-27 11:24:12 +02:00
Niklas Haas 13d4ee6d1c vo_opengl: icc-profile overrides icc-profile-auto
Signed-off-by: wm4 <wm4@nowhere>
2015-05-27 11:23:16 +02:00
Niklas Haas 4d6b9550fe
vo_opengl: add support for custom shaders 2015-05-27 11:09:41 +02:00
wm4 449cdfc0ff vd_lavc: report actually used hwdec API
Instead of the requested one, which can be just "auto", and which is
rather useless.
2015-05-25 21:43:20 +02:00
wm4 3fc3357d54 vf_dlopen: declare as deprecated
Mostly to see whether someone uses it, and if a better solution can be
worked out. (It's simple enough to be supported forever.)
2015-05-25 21:13:54 +02:00
Stefano Pigozzi 34875413fa cocoa: don't load hardcoded icon if running from bundle
Makes ricers happy.
2015-05-25 08:58:32 +02:00
wm4 0d0444fed0 vo_null: add framerate emulation 2015-05-24 23:27:18 +02:00
Niklas Haas fa7b22c687 vo_opengl: switch to new OpenGL backend API for icc-profile-auto
The current code just segfaults.
2015-05-22 21:56:16 +02:00
wm4 292266f268 vo_opengl: vda: make it work anywhere
A rather dumb hack to copy the problematic rectangle textures (mandated
by VDA) into 2D ones.

(This isn't done yet for OpenGL 3.0+. We need to make sure the
performance isn't reduced too much by it.)
2015-05-21 20:27:22 +02:00
wm4 af667643a0 video: do not align source position to 2
vo_direct3d still seems to require this (tested on Windows 8.1 with
Intel graphics). Do it in vo_direct3d instead of messing with all VOs.
2015-05-21 19:27:54 +02:00
wm4 cf023e1f3a vo_opengl: remove npot option
Completely useless.
2015-05-21 19:27:47 +02:00
wm4 8724e3e2dd vo_xv: make number of buffers configurable 2015-05-20 23:07:47 +02:00
wm4 be9bf4cc7c x11: never forcefully terminate xdg-screensaver process
It sometimes happens on exit, and it's probably a bad idea. If the
process hangs on exit (possibly due to stupid hardcoded timeouts it's
doing), mpv will also hang now, unfortunately.
2015-05-18 22:25:59 +02:00
wm4 a4f3df5970 x11: attempt to make initial fullscreening more reliable
It appears some WMs have a problem with out method of setting initial
fullscreen mode. We assume that if the window's _NET_WM_STATE includes
_NET_WM_STATE_FULLSCREEN before mapping the window, the WM will show it
as fullscreen at mapped. EWMH doesn't say anything that this should
work, although one could argue that it's implied.

In any case, since it's not standard behavior without at least some
doubt, it's probably a good idea to try the "old" method as well.
Fortunately, it should be idempotent.

See #1937, #1920.
2015-05-15 13:50:44 +02:00
wm4 06bfa9309d vf_vapoursynth: reject unaligned video sizes
Leads to some nice memory corruption otherwise.
2015-05-15 13:41:19 +02:00
wm4 372b85b9d2 vo: remove suspicious line
pts can never be 0 or negative. If there is no frame, some code below
catches this case by checking hasframe.
2015-05-15 13:40:43 +02:00
Michael Vetter 9251fa125f Remove trailing whitespaces 2015-05-15 11:02:44 +02:00
wm4 a2235b0280 dxva2: support HEVC
This is pretty much copy&pasted from Libav commit
a7e0380497306d9723dec8440a4c52e8bf0263cf.

Note that if FFmpeg was not compiled with HEVC DXVA2 support or your
video drivers do not support HEVC, the player will not fallback and
just fail decoding any video. This is because libavcodec appears not
to return an error in this case. The situation is made worse by the
fact that MSYS2 is on an ancient MinGW-w64 release, which does not
have the required headers for HEVC DXVA2 support.
2015-05-14 17:44:48 +02:00
wm4 bad932e8ed vo_opengl: hardcode rquested GL version in backends
The requested version field didn't make much sense anymore, and was even
partially ignored by some backends.
2015-05-14 13:07:00 +02:00