summaryrefslogtreecommitdiffstats
path: root/libavutil/hwcontext.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2016-05-19 15:59:25 +0200
committerAnton Khirnov <anton@khirnov.net>2016-05-26 15:40:32 +0200
commit1c9e8616c535ef496e7ee8a5cbc5e9e972a6977d (patch)
tree74ffeb8565c23be6646efe416bf7bbd79a020fcc /libavutil/hwcontext.c
parent24b5cff01bbac4e08acfd6d19c499e880988f520 (diff)
downloadffmpeg-streaming-1c9e8616c535ef496e7ee8a5cbc5e9e972a6977d.zip
ffmpeg-streaming-1c9e8616c535ef496e7ee8a5cbc5e9e972a6977d.tar.gz
hwcontext: add a function for opening devices
Diffstat (limited to 'libavutil/hwcontext.c')
-rw-r--r--libavutil/hwcontext.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c
index 2ddae90..3028b67 100644
--- a/libavutil/hwcontext.c
+++ b/libavutil/hwcontext.c
@@ -452,3 +452,39 @@ void av_hwframe_constraints_free(AVHWFramesConstraints **constraints)
}
av_freep(constraints);
}
+
+int av_hwdevice_ctx_create(AVBufferRef **pdevice_ref, enum AVHWDeviceType type,
+ const char *device, AVDictionary *opts, int flags)
+{
+ AVBufferRef *device_ref = NULL;
+ AVHWDeviceContext *device_ctx;
+ int ret = 0;
+
+ device_ref = av_hwdevice_ctx_alloc(type);
+ if (!device_ref) {
+ ret = AVERROR(ENOMEM);
+ goto fail;
+ }
+ device_ctx = (AVHWDeviceContext*)device_ref->data;
+
+ if (!device_ctx->internal->hw_type->device_create) {
+ ret = AVERROR(ENOSYS);
+ goto fail;
+ }
+
+ ret = device_ctx->internal->hw_type->device_create(device_ctx, device,
+ opts, flags);
+ if (ret < 0)
+ goto fail;
+
+ ret = av_hwdevice_ctx_init(device_ref);
+ if (ret < 0)
+ goto fail;
+
+ *pdevice_ref = device_ref;
+ return 0;
+fail:
+ av_buffer_unref(&device_ref);
+ *pdevice_ref = NULL;
+ return ret;
+}
OpenPOWER on IntegriCloud