1
0
mirror of https://github.com/mpv-player/mpv synced 2025-03-11 08:37:59 +00:00
mpv/video/decode
wm4 7aa070e1cb vdpau: crappy hack to allow initializing hw decoding after preemption
If vo_opengl is used, and vo_opengl already created the vdpau interop
(for whatever reasons), and then preemption happens, and then you try to
enable hw decoding, it failed. The reason was that preemption recovery
is not run at any point before libavcodec accesses the vdpau device.

The actual impact was that with libmpv + opengl-cb use, hardware
decoding was permanently broken after display mode switching (something
that caused the display to get preempted at least with older drivers).
With mpv CLI, you can for example enable hw decoding during playback,
then disable it, VT switch to console, switch back to X, and try to
enable hw decoding again.

This is mostly because libav* does not deal with preemption, and NVIDIA
driver preemption behavior being horrible garbage. In addition to being
misdesigned API, the preemption callback is not called before you try to
access vdpau API, and then only with _some_ accesses.

In summary, the preemption callback was never called, neither before nor
after libavcodec tried to init the decoder. So we have to get
mp_vdpau_handle_preemption() called before libavcodec accesses it. This
in turn will do a dummy API access which usually triggers the preemption
callback immediately (with NVIDIA's drivers).

In addition, we have to update the AVHWDeviceContext's device. In theory
it could change (in practice it usually seems to use handle "0").
Creating a new device would cause chaos, as we don't have a concept of
switching the device context on the fly. So we simply update it
directly. I'm fairly sure this violates the libav* API, but it's the
best we can do.
2017-05-19 15:24:38 +02:00
..
d3d.c d3d11: change mp_image plane pointer semantics 2017-05-04 01:13:03 +02:00
d3d.h d3d: implement screenshots for --hwdec=d3d11va 2016-06-28 20:38:53 +02:00
dec_video.c dec_video, dec_audio: remove redundant NULL-checks 2017-02-20 13:58:18 +01:00
dec_video.h player: add experimental stream recording feature 2017-02-07 17:05:17 +01:00
hw_cuda.c cuda: add new way to set cuda context on cuvid codecs 2017-05-05 00:48:53 +02:00
hw_d3d11va.c d3d: fix build with Libav 2017-05-04 02:12:10 +02:00
hw_dxva2.c d3d: fix build with Libav 2017-05-04 02:12:10 +02:00
hw_videotoolbox.c hw_videotoolbox: allow using native decoder output format 2017-03-02 11:49:12 +01:00
lavc.h cuda: add new way to set cuda context on cuvid codecs 2017-05-05 00:48:53 +02:00
vd_lavc.c vdpau: crappy hack to allow initializing hw decoding after preemption 2017-05-19 15:24:38 +02:00
vd.h video: make decoder EOF reporting explicit 2017-01-11 11:02:57 +01:00