summaryrefslogtreecommitdiff
path: root/gst-libs
diff options
context:
space:
mode:
authorHe Junyan <junyan.he@intel.com>2020-07-06 23:35:12 +0800
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>2020-07-29 15:41:40 +0000
commited55dd8df1dd0dbed1f20e0c5dd96f68e0bf2ddf (patch)
treeaad8eb4f97f7733b329605acdb2ddefa7edd096f /gst-libs
parent6022d97edfd71e3a7cb391464f0275fde88a63ec (diff)
downloadgstreamer-vaapi-ed55dd8df1dd0dbed1f20e0c5dd96f68e0bf2ddf.tar.gz
libs: utils: vpx: Add utils vpx to handle VP8/9 misc things.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/188>
Diffstat (limited to 'gst-libs')
-rw-r--r--gst-libs/gst/vaapi/gstvaapiutils_vpx.c88
-rw-r--r--gst-libs/gst/vaapi/gstvaapiutils_vpx.h40
-rw-r--r--gst-libs/gst/vaapi/meson.build2
3 files changed, 130 insertions, 0 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapiutils_vpx.c b/gst-libs/gst/vaapi/gstvaapiutils_vpx.c
new file mode 100644
index 00000000..2882c2f0
--- /dev/null
+++ b/gst-libs/gst/vaapi/gstvaapiutils_vpx.c
@@ -0,0 +1,88 @@
+/*
+ * gstvaapiutils_vpx.c - vpx related utilities
+ *
+ * Copyright (C) 2020 Intel Corporation
+ * Author: He Junyan <junyan.he@intel.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#include "gstvaapiutils_vpx.h"
+
+struct map
+{
+ guint value;
+ const gchar *name;
+};
+
+/* Profile string map */
+static const struct map gst_vaapi_vp9_profile_map[] = {
+ /* *INDENT-OFF* */
+ { GST_VAAPI_PROFILE_VP9_0, "0" },
+ { GST_VAAPI_PROFILE_VP9_1, "1" },
+ { GST_VAAPI_PROFILE_VP9_2, "2" },
+ { GST_VAAPI_PROFILE_VP9_3, "3" },
+ { 0, NULL }
+ /* *INDENT-ON* */
+};
+
+/* Lookup name in map */
+static const struct map *
+map_lookup_name (const struct map *m, const gchar * name)
+{
+ g_return_val_if_fail (m != NULL, NULL);
+
+ if (!name)
+ return NULL;
+
+ for (; m->name != NULL; m++) {
+ if (strcmp (m->name, name) == 0)
+ return m;
+ }
+ return NULL;
+}
+
+/* Lookup value in map */
+static const struct map *
+map_lookup_value (const struct map *m, guint value)
+{
+ g_return_val_if_fail (m != NULL, NULL);
+
+ for (; m->name != NULL; m++) {
+ if (m->value == value)
+ return m;
+ }
+ return NULL;
+}
+
+/** Returns GstVaapiProfile from a string representation */
+GstVaapiProfile
+gst_vaapi_utils_vp9_get_profile_from_string (const gchar * str)
+{
+ const struct map *const m = map_lookup_name (gst_vaapi_vp9_profile_map, str);
+
+ return m ? (GstVaapiProfile) m->value : GST_VAAPI_PROFILE_UNKNOWN;
+}
+
+/** Returns a string representation for the supplied VP9 profile */
+const gchar *
+gst_vaapi_utils_vp9_get_profile_string (GstVaapiProfile profile)
+{
+ const struct map *const m =
+ map_lookup_value (gst_vaapi_vp9_profile_map, profile);
+
+ return m ? m->name : NULL;
+}
diff --git a/gst-libs/gst/vaapi/gstvaapiutils_vpx.h b/gst-libs/gst/vaapi/gstvaapiutils_vpx.h
new file mode 100644
index 00000000..a83510ce
--- /dev/null
+++ b/gst-libs/gst/vaapi/gstvaapiutils_vpx.h
@@ -0,0 +1,40 @@
+/*
+ * gstvaapiutils_vpx.h - vpx related utilities
+ *
+ * Copyright (C) 2020 Intel Corporation
+ * Author: He Junyan <junyan.he@intel.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef GST_VAAPI_UTILS_VPX_H
+#define GST_VAAPI_UTILS_VPX_H
+
+#include <gst/vaapi/gstvaapiprofile.h>
+
+G_BEGIN_DECLS
+
+/** Returns GstVaapiProfile from a string representation */
+GstVaapiProfile
+gst_vaapi_utils_vp9_get_profile_from_string (const gchar * str);
+
+/** Returns a string representation for the supplied VP9 profile */
+const gchar *
+gst_vaapi_utils_vp9_get_profile_string (GstVaapiProfile profile);
+
+G_END_DECLS
+
+#endif /* GST_VAAPI_UTILS_VPX_H */
diff --git a/gst-libs/gst/vaapi/meson.build b/gst-libs/gst/vaapi/meson.build
index bcf261fd..527414f1 100644
--- a/gst-libs/gst/vaapi/meson.build
+++ b/gst-libs/gst/vaapi/meson.build
@@ -36,6 +36,7 @@ gstlibvaapi_sources = [
'gstvaapiutils_h265.c',
'gstvaapiutils_h26x.c',
'gstvaapiutils_mpeg2.c',
+ 'gstvaapiutils_vpx.c',
'gstvaapivalue.c',
'gstvaapivideopool.c',
'gstvaapiwindow.c',
@@ -71,6 +72,7 @@ gstlibvaapi_headers = [
'gstvaapiutils_h264.h',
'gstvaapiutils_h265.h',
'gstvaapiutils_mpeg2.h',
+ 'gstvaapiutils_vpx.h',
'gstvaapivalue.h',
'gstvaapivideopool.h',
'gstvaapiwindow.h',