diff options
author | wm4 <wm4@nowhere> | 2017-12-02 04:27:02 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2017-12-02 04:53:51 +0100 |
commit | 23a9efd124042e7c97f8317bcd8ae5903d039ef7 (patch) | |
tree | 8af4a34bd494abe51608d3648de612d5af920314 /video/vdpau.c | |
parent | 0780d3832997056b581cdecb29e605132fae9417 (diff) | |
download | mpv-23a9efd124042e7c97f8317bcd8ae5903d039ef7.tar.bz2 mpv-23a9efd124042e7c97f8317bcd8ae5903d039ef7.tar.xz |
vd_lavc, vdpau, vaapi: restore emulated API avoidance
This code is for trying to avoid using an emulation layer when using
auto probing, so that we end up using the actual API the drivers
provide. It was destroyed in the recent refactor.
Diffstat (limited to 'video/vdpau.c')
-rw-r--r-- | video/vdpau.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/video/vdpau.c b/video/vdpau.c index 1785702fdb..d751849ec3 100644 --- a/video/vdpau.c +++ b/video/vdpau.c @@ -537,6 +537,26 @@ bool mp_vdpau_guess_if_emulated(struct mp_vdpau_ctx *ctx) return vdp_st == VDP_STATUS_OK && info && strstr(info, "VAAPI"); } +// (This clearly works only for contexts wrapped by our code.) +struct mp_vdpau_ctx *mp_vdpau_get_ctx_from_av(AVBufferRef *hw_device_ctx) +{ + AVHWDeviceContext *hwctx = (void *)hw_device_ctx->data; + + if (hwctx->free != free_device_ref) + return NULL; // not ours + + return hwctx->user_opaque; +} + +static bool is_emulated(struct AVBufferRef *hw_device_ctx) +{ + struct mp_vdpau_ctx *ctx = mp_vdpau_get_ctx_from_av(hw_device_ctx); + if (!ctx) + return false; + + return mp_vdpau_guess_if_emulated(ctx); +} + static struct AVBufferRef *vdpau_create_standalone(struct mpv_global *global, struct mp_log *log, struct hwcontext_create_dev_params *params) { @@ -555,11 +575,11 @@ static struct AVBufferRef *vdpau_create_standalone(struct mpv_global *global, vdp->hwctx.emulated = mp_vdpau_guess_if_emulated(vdp); vdp->close_display = true; - mp_warn(log, "idk\n"); return vdp->hwctx.av_device_ref; } const struct hwcontext_fns hwcontext_fns_vdpau = { .av_hwdevice_type = AV_HWDEVICE_TYPE_VDPAU, .create_dev = vdpau_create_standalone, + .is_emulated = is_emulated, }; |