summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2018-03-06 10:45:14 +0100
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2018-04-25 09:20:02 +0200
commitf9922a1a561e71504bc85155cf81d81078b7db42 (patch)
tree5da66447240bfcc0cd6ee829235a0ff677ecd7e4
parentdc0ed29a62248c42b7488da8f3bb1d04b2430d8c (diff)
downloadgst-omx-f9922a1a561e71504bc85155cf81d81078b7db42.tar.gz
omxh265: factor out gst_omx_h265_utils_get_profile_from_enum()
Move the profile <-> enum mapping to one place. Make changes easier as I'm about to add some profiles. No semantic change. https://bugzilla.gnome.org/show_bug.cgi?id=794177
-rw-r--r--omx/gstomxh265enc.c27
-rw-r--r--omx/gstomxh265utils.c51
-rw-r--r--omx/gstomxh265utils.h2
3 files changed, 45 insertions, 35 deletions
diff --git a/omx/gstomxh265enc.c b/omx/gstomxh265enc.c
index 6076435..e099431 100644
--- a/omx/gstomxh265enc.c
+++ b/omx/gstomxh265enc.c
@@ -556,28 +556,11 @@ gst_omx_h265_enc_get_caps (GstOMXVideoEnc * enc, GstOMXPort * port,
"alignment", G_TYPE_STRING, "au", NULL);
if (err == OMX_ErrorNone) {
- switch (param.eProfile) {
- case OMX_VIDEO_HEVCProfileMain:
- profile = "main";
- break;
- case OMX_VIDEO_HEVCProfileMain10:
- profile = "main-10";
- break;
-#ifdef USE_OMX_TARGET_ZYNQ_USCALE_PLUS
- case OMX_ALG_VIDEO_HEVCProfileMainStill:
- profile = "main-still-picture";
- break;
- case OMX_ALG_VIDEO_HEVCProfileMain422:
- profile = "main-422";
- break;
- case OMX_ALG_VIDEO_HEVCProfileMain422_10:
- profile = "main-422-10";
- break;
-#endif
- default:
- g_assert_not_reached ();
- gst_caps_unref (caps);
- return NULL;
+ profile = gst_omx_h265_utils_get_profile_from_enum (param.eProfile);
+ if (!profile) {
+ g_assert_not_reached ();
+ gst_caps_unref (caps);
+ return NULL;
}
switch (param.eLevel) {
diff --git a/omx/gstomxh265utils.c b/omx/gstomxh265utils.c
index 5141bc4..c45d4d9 100644
--- a/omx/gstomxh265utils.c
+++ b/omx/gstomxh265utils.c
@@ -25,26 +25,51 @@
#include "gstomxh265utils.h"
-OMX_VIDEO_HEVCPROFILETYPE
-gst_omx_h265_utils_get_profile_from_str (const gchar * profile)
+typedef struct
{
- if (g_str_equal (profile, "main")) {
- return OMX_VIDEO_HEVCProfileMain;
- } else if (g_str_equal (profile, "main-10")) {
- return OMX_VIDEO_HEVCProfileMain10;
+ const gchar *profile;
+ OMX_VIDEO_HEVCPROFILETYPE e;
+} H265ProfileMapping;
+
+static const H265ProfileMapping h265_profiles[] = {
+ {"main", OMX_VIDEO_HEVCProfileMain},
+ {"main-10", OMX_VIDEO_HEVCProfileMain10},
#ifdef USE_OMX_TARGET_ZYNQ_USCALE_PLUS
- } else if (g_str_equal (profile, "main-still-picture")) {
- return (OMX_VIDEO_HEVCPROFILETYPE) OMX_ALG_VIDEO_HEVCProfileMainStill;
- } else if (g_str_equal (profile, "main-422")) {
- /* Not standard: 8 bits variation of main-422-10 */
- return (OMX_VIDEO_HEVCPROFILETYPE) OMX_ALG_VIDEO_HEVCProfileMain422;
- } else if (g_str_equal (profile, "main-422-10")) {
- return (OMX_VIDEO_HEVCPROFILETYPE) OMX_ALG_VIDEO_HEVCProfileMain422_10;
+ {"main-still-picture",
+ (OMX_VIDEO_HEVCPROFILETYPE) OMX_ALG_VIDEO_HEVCProfileMainStill},
+ /* Not standard: 8 bits variation of main-422-10 */
+ {"main-422", (OMX_VIDEO_HEVCPROFILETYPE) OMX_ALG_VIDEO_HEVCProfileMain422},
+ {"main-422-10",
+ (OMX_VIDEO_HEVCPROFILETYPE) OMX_ALG_VIDEO_HEVCProfileMain422_10},
#endif
+};
+
+OMX_VIDEO_HEVCPROFILETYPE
+gst_omx_h265_utils_get_profile_from_str (const gchar * profile)
+{
+ guint i;
+
+ for (i = 0; i < G_N_ELEMENTS (h265_profiles); i++) {
+ if (g_str_equal (profile, h265_profiles[i].profile))
+ return h265_profiles[i].e;
}
+
return OMX_VIDEO_HEVCProfileUnknown;
}
+const gchar *
+gst_omx_h265_utils_get_profile_from_enum (OMX_VIDEO_HEVCPROFILETYPE e)
+{
+ guint i;
+
+ for (i = 0; i < G_N_ELEMENTS (h265_profiles); i++) {
+ if (e == h265_profiles[i].e)
+ return h265_profiles[i].profile;
+ }
+
+ return NULL;
+}
+
OMX_VIDEO_HEVCLEVELTYPE
gst_omx_h265_utils_get_level_from_str (const gchar * level, const gchar * tier)
{
diff --git a/omx/gstomxh265utils.h b/omx/gstomxh265utils.h
index 15b7d2a..1987a32 100644
--- a/omx/gstomxh265utils.h
+++ b/omx/gstomxh265utils.h
@@ -31,5 +31,7 @@ OMX_VIDEO_HEVCPROFILETYPE gst_omx_h265_utils_get_profile_from_str (const
OMX_VIDEO_HEVCLEVELTYPE gst_omx_h265_utils_get_level_from_str (const gchar *
level, const gchar * tier);
+const gchar * gst_omx_h265_utils_get_profile_from_enum (OMX_VIDEO_HEVCPROFILETYPE e);
+
G_END_DECLS
#endif /* __GST_OMX_H265_UTILS_H__ */