diff options
Diffstat (limited to 'video/hwdec.c')
-rw-r--r-- | video/hwdec.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/video/hwdec.c b/video/hwdec.c index 04f7d46d9a..5d4073ad64 100644 --- a/video/hwdec.c +++ b/video/hwdec.c @@ -1,6 +1,8 @@ #include <pthread.h> #include <assert.h> +#include <libavutil/hwcontext.h> + #include "config.h" #include "hwdec.h" @@ -47,6 +49,26 @@ struct mp_hwdec_ctx *hwdec_devices_get(struct mp_hwdec_devices *devs, return res; } +struct AVBufferRef *hwdec_devices_get_lavc(struct mp_hwdec_devices *devs, + int av_hwdevice_type) +{ + AVBufferRef *res = NULL; + pthread_mutex_lock(&devs->lock); + for (int n = 0; n < devs->num_hwctxs; n++) { + struct mp_hwdec_ctx *dev = devs->hwctxs[n]; + if (dev->av_device_ref) { + AVHWDeviceContext *hwctx = (void *)dev->av_device_ref->data; + if (hwctx->type == av_hwdevice_type) { + if (dev->av_device_ref) + res = av_buffer_ref(dev->av_device_ref); + break; + } + } + } + pthread_mutex_unlock(&devs->lock); + return res; +} + struct mp_hwdec_ctx *hwdec_devices_get_first(struct mp_hwdec_devices *devs) { pthread_mutex_lock(&devs->lock); |