---
libavutil/hwcontext.c | 11 +++++++++++
libavutil/hwcontext.h | 8 ++++++++
2 files changed, 19 insertions(+)
diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c
index 1f9442622..e3484c78c 100644
--- a/libavutil/hwcontext.c
+++ b/libavutil/hwcontext.c
@@ -18,6 +18,7 @@
#include "config.h"
+#include "avstring.h"
#include "buffer.h"
#include "common.h"
#include "hwcontext.h"
@@ -47,6 +48,16 @@ static const HWContextType * const hw_table[] = {
NULL,
};
+enum AVHWDeviceType av_hwdevice_find_type_by_name(const char *name)
+{
+ int i;
+ for (i = 0; hw_table[i]; i++) {
+ if (!av_strcasecmp(hw_table[i]->name, name))
+ return hw_table[i]->type;
+ }
+ return -1;
+}
+
static const AVClass hwdevice_ctx_class = {
.class_name = "AVHWDeviceContext",
.item_name = av_default_item_name,
diff --git a/libavutil/hwcontext.h b/libavutil/hwcontext.h
index a31799267..98f9172ee 100644
--- a/libavutil/hwcontext.h
+++ b/libavutil/hwcontext.h
@@ -223,6 +223,14 @@ typedef struct AVHWFramesContext {
} AVHWFramesContext;
/**
+ * Look up an AVHWDeviceType by name.
+ *
+ * @param name String name of the device type (case-insensitive).
+ * @return The type from enum AVHWDeviceType, or -1 on failure.
+ */
+enum AVHWDeviceType av_hwdevice_find_type_by_name(const char *name);
+
+/**
* Allocate an AVHWDeviceContext for a given pixel format.
*
* @return a reference to the newly created AVHWDeviceContext on success or
NULL
--
2.11.0
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel