aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil/hwcontext.c
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2016-06-26 15:14:17 -0300
committerJames Almer <jamrial@gmail.com>2016-06-26 15:14:17 -0300
commit104c357b6a3ee181e1d657df68e38c17ba2bda77 (patch)
tree8de7acbcf90609e153169a3d0c65eba46b93b15c /libavutil/hwcontext.c
parentb2a74dd629c1ab3318ba0123f8814797a4fea3a4 (diff)
parente9394ca63dab3434bc8e869de019ecd86cb604ac (diff)
downloadffmpeg-104c357b6a3ee181e1d657df68e38c17ba2bda77.tar.gz
Merge branch 'master' into release/3.1
Merged-by: James Almer <jamrial@gmail.com>
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 eeeb2880ff..1e9e91329c 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;
+}