Commit Graph

1145 Commits

Author SHA1 Message Date
wm4 342298fd1a wayland: fix unchecked malloc usage
Found by cppcheck.

Actually untested. (This is the file drag&drop code, I don't even know
which wayland clients support this.)
2014-05-11 16:41:17 +02:00
wm4 26b00ffe8a x11: fix potentially unaligned access in icon loader
Tried to load a 32 bit value by dereferencing a uint32_t pointer, but
the pointer is not guaranteed to be aligned, not even in practice.
2014-05-10 10:44:16 +02:00
wm4 fc385baf02 encode: fix PTS unit mismatch
This used MP_NOPTS_VALUE to compare with ffmpeg-style int64_t PTS
values. This probably happened to work, because both constants use the
same value.
2014-05-10 10:44:16 +02:00
wm4 bc9a86c392 vdpau: make mp_vdpau_ctx thread-safe
Preparation so that various things related to video can run in different
threads. One part to this is making the video surface pool safe.

Another issue is the preemption mechanism, which continues to give us
endless pain. In theory, it's probably impossible to handle preemption
100% correctly and race-condition free, unless _every_ API user in the
same process uses a central, shared mutex to protect every vdpau API
call. Otherwise, it could happen that one thread recovering from
preemption allocates a vdpau object, and then another thread (which
hasn't recovered yet) happens to free the object for some reason. This
is because objects are referenced by integer IDs, and vdpau will reuse
IDs invalidated by preemption after preemption.

Since this is unreasonable, we're as lazy as possible when it comes to
handling preemption. We don't do any locking around the mp_vdpau_ctx
fields that are normally immutable, and only can change when recovering
from preemption. In practice, this will work, because it doesn't matter
whether not-yet-recovered components use the old or new vdpau function
pointers or device ID. Code calls mp_vdpau_handle_preemption() anyway to
check for the preemption event and possibly to recover, and that
function acquires the lock protecting the preemption state.

Another possible source of potential grandiose fuckup is the fact that
the vdpau library is in fact only a tiny wrapper, and the real driver
lives in a shared object dlopen()ed by the wrapper. The wrapper also
calls dlclose() on the loaded shared object in some situations. One
possible danger is that failing to recreate a vdpau device could trigger
a dlclose() call, and that glibc might unload it. Currently, glibc
implements full unloading of shared objects on the last dlclose() call,
and if that happens, calls to function pointers pointing into the shared
object would obviously crash. Fortunately, it seems the existing vdpau
wrapper won't trigger this case and never unloads the driver once it's
successfully loaded.

To make it short, vdpau preemption opens up endless depths of WTFs.

Another issue is that any participating thread might do the preemption
recovery (whichever comes first). This is easier to implement. The
implication is that we need threadsafe xlib. We just hope and pray that
this will actually work. This also means that once vdpau code is
actually involved in a multithreaded scenario, we have to add
XInitThreads() to the X11 code.
2014-05-10 10:44:16 +02:00
wm4 280e7e171a vdpau: remove some code
There's no reason why we should treat the preemption case differently
here.
2014-05-10 10:44:16 +02:00
wm4 0e1491346e vo_vdpau, vo_opengl: handle vdpau preemption differently
Use the newly provided mp_vdpau_handle_preemption() function, instead of
accessing mp_vdpau_ctx fields directly. Will probably make multithreaded
access to the vdpau context easier.

Mostly unrelated to the actual changes, I've noticed that using hw
decoding with vo_opengl sometimes leads to segfaults inside of nvidia's
libGL when doing the following:

1. use hw decoding + vo_opengl
2. switch to console (will preempt on nvidia systems)
3. switch back to X (mpv will recover, switches to sw decoding)
4. enable hw decoding again
5. exit mpv

Then it segfaults when mpv finally calls exit(). I'll just blame nvidia,
although it seems likely that something in the gl_hwdec_vdpau.c
preemption handling triggers corner cases in nvidia's code.
2014-05-10 10:44:16 +02:00
wm4 203be26588 vdpau: handle display preemption during decoding
This was broken for some time, and it didn't recover correctly.

Redo decoder display preemption. Instead of trying to reinitialize the
hw decoder, simply fallback to software decoding. I consider display
preemption a bug in the vdpau API, so being able to _somehow_ recover
playback is good enough.

The approach taking here will probably also make it easier to handle
multithreading.
2014-05-10 10:44:16 +02:00
wm4 6e83864823 w32_common: fix typo
Also, reset rc completely, instead of assuming things.
2014-05-10 10:44:15 +02:00
wm4 f3362e22eb player: remove VO from seeking code path
Until recently, the VO was an unavoidable part of the seeking code path.
This was because vdpau deinterlacing could double the framerate, and hr-
seek and framestepping etc. all had to "see" the additional frames. But
we've removed the frame doubling from the vdpau VO and moved it into a
video filter (vf_vdpaupp), and there's no reason left why the VO should
participate in seeking.

Instead of queuing frames to the VO during seek and skipping them
afterwards, drop the frames early.

This actually might make seeking with vo_vdpau and software decoding
faster, although I haven't measured it.
2014-05-07 21:50:16 +02:00
wm4 ca343d82a6 video/out: remove unused config() parameters
This was cleaned up yesterday.
2014-05-07 21:34:05 +02:00
wm4 5704958573 vo: remove old stuff 2014-05-06 23:20:33 +02:00
wm4 f0ee4e8766 vo_wayland: always assume resize on reconfigure
It doesn't look like vo_wayland_config() necessarily sets this flag, so
it seems safer to trigger an explicit resize. This accounts for the case
when playing a new file with different size than the one before.
2014-05-06 23:18:57 +02:00
wm4 b51664c04a wayland: don't use VOCTRL_UPDATE_SCREENINFO
Not very tested. Appears to work.
2014-05-06 23:16:18 +02:00
wm4 41b1ed7b2e win32: don't use VOCTRL_UPDATE_SCREENINFO
Not very tested. At least it compiles.
2014-05-06 23:04:33 +02:00
wm4 836893fed9 cocoa: don't use VOCTRL_UPDATE_SCREENINFO 2014-05-06 22:00:17 +02:00
wm4 f4bbd4c1df vo_sdl: don't use VOCTRL_UPDATE_SCREENINFO 2014-05-06 20:35:19 +02:00
wm4 5eaefaa98a x11: don't use VOCTRL_UPDATE_SCREENINFO
See previous commit.
2014-05-06 20:24:35 +02:00
wm4 feb1f8f18f video/out: separate out code to compute window size
Currently, vo_reconfig() calculates the requested window size and sets
the vo->dwidth/dheight fields _if_ VOCTRL_UPDATE_SCREENINFO is
implemented by the VO or the windowing backend. The window size can be
different from the display size if e.g. the --geometry option is used.
It will also set the vo->dx/dy fields and read vo->xinerama_x/y.

It turned out that this is very backwards and actually requires the
windowing backends to workaround these things. There's also
MPOpts.screenwidth/screenheight, which used to map to actual options,
but is now used only to communicate the screen size to the vo.c code
calculating the window size and position.

Change this by making the window geometry calculations available as
separate functions. This commit doesn't change any VO code yet, and just
emulates the old way using the new functions. VO code will remove its
usage of VOCTRL_UPDATE_SCREENINFO and use the new functions directly.
2014-05-06 20:22:32 +02:00
wm4 587f42b56c Fix bogus copyright text
This file was copied from gl_hwdec_vaglx.c to have a basic skeleton, but
no actual code is left from it.
2014-05-06 20:14:53 +02:00
wm4 7267588a98 vo: fix previous commit
Commit 433161 actually broke vo_opengl (and maybe others), because
config_ok is not necessarily set correctly yet _during_ reconfig. So a
vo_get_src_dst_rects() call during reconfig did nothing.
2014-05-06 01:04:51 +02:00
wm4 4331617bce vo: don't crash when changing panscan before first configuration
When the VO was not initialized with vo_reconfig(), or if the last
vo_reconfig() failed, changing panscan would cause a crash due to
vo_get_src_dst_rects() dereferencing vo->params (NULL if not
configured).

Just do nothing if that happens, as there is no video that could be
displayed anyway.
2014-05-06 00:33:59 +02:00
wm4 143cf79a96 vo: get rid of config_count field
Doesn't really seem to be much of use. Get rid of the remaining uses of
it.

Concerning vo_opengl_old, it seems uninitGl() works fine even if called
before initialization.
2014-05-06 00:21:15 +02:00
wm4 70ffbbe927 vf: print for which filter initialization failed 2014-05-04 16:07:43 +02:00
wm4 f5a564d417 vf_vdpaupp: make code clarity improvements
This shouldn't change anything functionally, except that it buffers 1
frame less in the first-field deinterlacing mode.
2014-05-04 11:03:21 +02:00
wm4 a7fe47e495 vdpau: deduplicate video surface upload code
This was a minor code duplication between vf_vdpaupp.c and vo_vdpau.c.

(In theory, we could always require using vf_vdpaupp with vo_vdpau, but
I think it's better if vo_vdpau can work standalone.)
2014-05-04 10:51:14 +02:00
Martin Herkt 48bd03dd91 options: remove deprecated --identify
Also remove MSGL_SMODE and friends.

Note: The indent in options.rst was added to work around a bug in
ReportLab that causes the PDF manual build to fail.
2014-05-04 02:46:11 +02:00
Martin Herkt 81c076b2f8 options: remove obsolete --fsmode-dontuse 2014-05-04 02:46:11 +02:00
Martin Herkt b54c963258 options: rename video-related options/properties
Renamed options:
--aspect    → --video-aspect
--fstype    → --x11-fstype
--native-fs → --fs-missioncontrol
--name      → --x11-name

Renamed properties:
aspect → video-aspect
2014-05-04 02:46:11 +02:00
wm4 bc07c86da5 vf_vapoursynth: fix aspect ratio passed to vapoursynth
This was recently either changed or clarified in vapoursynth.

Pass the aspect ratio as pixel aspect to VS.
2014-05-03 15:17:13 +02:00
wm4 33a945cc7e video: removed unused stuff 2014-05-02 14:48:52 +02:00
wm4 eb9d203946 video: change everything
Change how the video decoding loop works. The structure should now be a
bit easier to follow. The interactions on format changes are (probably)
simpler. This also aligns the decoding loop with future planned changes,
such as moving various things to separate threads.
2014-05-02 01:09:58 +02:00
wm4 50ebcf1a43 video: handle colorspace and aspect overrides separately
Now the video filter code handles these explicitly, which should
increase robustness (or at least find bugs earlier).
2014-05-02 01:09:55 +02:00
wm4 f4eaceee0f vf: sanitize filter input, instead of overriding it
vf_fix_img_params() takes care of overwriting image parameters that are
normally not set correctly by filters. But this makes no sense for input
images. So instead, check that the input is correct.

It still has to be done for the first input image, because that's used
to handle some overrides (see video_reconfig_filters()).
2014-05-02 01:09:03 +02:00
wm4 4049532501 vf: add alternate functions for retrieving filter output
These replace vf_read_output_frame(), although we still emulate that
function. This change is preparation for another commit (and this is
basically just to reduce the diff and signal/noise ratio in that
commit).
2014-05-02 01:08:06 +02:00
wm4 9243249a0e vf: expose input parameters; clear parameters on failure
Preparation (and simplification) for following commits.
2014-05-02 01:08:05 +02:00
wm4 2a9b1d19ba vf: mark auto-inserted conversion filters in verbose output
Nota that this flag is not set for other auto-inserted filters (like
deinterlacing or rotation).
2014-05-02 01:08:05 +02:00
wm4 ffde8083f6 vf_lavfi: reinit after libavfilter EOF
Basically, if we feed the filter a new image even after the EOF state
has been reached (e.g. because the input stream "recovered"), we want
the filter to restart, instead of returning an error forever.
2014-05-02 01:08:05 +02:00
wm4 bd230a8d47 vo: verify format of queued image
Currently, only the configured format is accepted, so assert that the
playback core code (which handles format changes) is correct.
2014-05-02 01:08:05 +02:00
wm4 a014a2402d video: fix screenshots with anamorphic video
(Again.)

This was caused by mp_image_set_params() not properly copying d_w/d_h,
because mp_image_set_size() resets them.
2014-05-02 01:08:05 +02:00
wm4 50538c0ea2 vf_vdpaupp: always provide past and future fields
Some non-deinterlacing filters (potentially denoising) also use
additional frames for filtering. The vdpau docs suggest providing at
least 1 future and 2 past _fields_, which means we need to provide 1
past frame (the future field is already the other field of the current
field, and both fields are in the same frame).

We can easily achieve this by buffering an additional frame in the non-
deint case.
2014-05-02 01:08:05 +02:00
wm4 586ea206da vo_vdpau: keep colorspace flags
Since vdpau_mixer.c initializes the YUV conversion using the mp_image
flags, these images should have all flags set properly.
2014-05-02 01:08:05 +02:00
wm4 6775487a46 video: move video frame queue from vo_vdpau.c to vo.c
Remove the special casing of vo_vdpau vs. other VOs. Replace the
complicated interaction between vo.c and vo_vdpau.c with a simple queue
in vo.c. VOs other than vdpau are handled by setting the length of the
queue to 1 (this is essentially what waiting_mpi was).

Note that vo_vdpau.c seems to have buffered only 1 or 2 frames into the
future, while the remaining 3 or 4 frames were past frames. So the new
code buffers 2 frames (vo_vdpau.c requests this queue length by setting
vo->max_video_queue to 2). It should probably be investigated why
vo_vdpau.c kept so many past frames.

The field vo->redrawing is removed. I'm not really sure what that would
be needed for; it seems pointless.

Future directions include making the interface between playloop and VO
simpler, as well as making rendering a frame a single operation, as
opposed to the weird 3-step sequence of rendering, drawing OSD, and
flipping.
2014-05-02 01:08:05 +02:00
wm4 d6dc8642ae vo_vdpau: always use mp_image for internal buffer queue 2014-05-02 01:08:05 +02:00
wm4 90a039a599 command, vo_vdpau: respect vdpau deint sub-option
This is a horrible hack to keep compatibility with the vo_vdpau deint
sub-option.
2014-05-02 01:08:05 +02:00
wm4 1efb5fd465 vf_vdpaupp: allow toggling deinterlace
Basically makes the 'D' key work again. (But only if the filter is
already inserted.)
2014-05-02 01:08:04 +02:00
wm4 ffbf6037cb vo_vdpau: apply vo_vdpau postprocessing options
The previous commits changed vo_vdpau so that these options are set by
vf_vdpaupp, and the corresponding vo_vdpau were ignored. But for
compatibility, keep the "old" options working.

The value of this is questionable - maybe the vo_vdpau options should
just be removed. For now, at least demonstrate that it's possible.

The "deint" suboption still doesn't work, because the framerate doubling
logic required for some deint modes was moved to vf_vdpaupp. This
requires more elaborate workarounds.
2014-05-02 01:08:04 +02:00
wm4 fd63f2f037 vdpau_mixer: allow overriding frame opts
So a caller can override the filter options dictated by vf_vdpaupp.
2014-05-02 01:08:04 +02:00
wm4 ec28a281b9 vo_vdpau: support vf_vdpaupp
This is slightly incomplete: the mixer options, such as sharpen and
especially deinterlacing, are ignored. This also breaks automatic
enabling of interlacing with 'D' or --deinterlace. These issues will be
fixed later in the following commits.

Note that we keep all the custom vdpau queue stuff. This will also be
simplified later.
2014-05-02 01:08:04 +02:00
wm4 d8385091a6 vo_opengl: make it work with vf_vdpaupp
This uses mp_vdpau_mixer_render(). The benefit is that it makes vdpau
deinterlacing just work. One additional minor advantage is that the
video mixer creation code is factored out (although that is a double-
edged sword).
2014-05-02 01:08:04 +02:00
wm4 073ee146ea vf_vdpaupp: allow non-vdpau input
So you can use vdpau deinterlacing without using vdpau hardware
decoding.

vf_vavpp does something similar.
2014-05-02 01:08:04 +02:00