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
commit7242d0a2e2db0d1bdb5341e075d195a2f8b2e582 (patch)
tree9713fb472dbe55567aa7c2beb241af14b7272301
parent4e75bab796a88f20915c06b726ba2f1db3d61f00 (diff)
downloadgst-omx-7242d0a2e2db0d1bdb5341e075d195a2f8b2e582.tar.gz
omxh264: factor out gst_omx_h264_utils_get_profile_from_enum()
Move the profile <-> enum mapping to one place. Make changes easier as I'm about to add extra profiles. No semantic change. https://bugzilla.gnome.org/show_bug.cgi?id=794177
-rw-r--r--omx/gstomxh264enc.c31
-rw-r--r--omx/gstomxh264utils.c49
-rw-r--r--omx/gstomxh264utils.h2
3 files changed, 42 insertions, 40 deletions
diff --git a/omx/gstomxh264enc.c b/omx/gstomxh264enc.c
index e46593a..631e31d 100644
--- a/omx/gstomxh264enc.c
+++ b/omx/gstomxh264enc.c
@@ -737,32 +737,11 @@ gst_omx_h264_enc_get_caps (GstOMXVideoEnc * enc, GstOMXPort * port,
"alignment", G_TYPE_STRING, "au", NULL);
if (err == OMX_ErrorNone) {
- switch (param.eProfile) {
- case OMX_VIDEO_AVCProfileBaseline:
- profile = "baseline";
- break;
- case OMX_VIDEO_AVCProfileMain:
- profile = "main";
- break;
- case OMX_VIDEO_AVCProfileExtended:
- profile = "extended";
- break;
- case OMX_VIDEO_AVCProfileHigh:
- profile = "high";
- break;
- case OMX_VIDEO_AVCProfileHigh10:
- profile = "high-10";
- break;
- case OMX_VIDEO_AVCProfileHigh422:
- profile = "high-4:2:2";
- break;
- case OMX_VIDEO_AVCProfileHigh444:
- profile = "high-4:4:4";
- break;
- default:
- g_assert_not_reached ();
- gst_caps_unref (caps);
- return NULL;
+ profile = gst_omx_h264_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/gstomxh264utils.c b/omx/gstomxh264utils.c
index 828cf65..5d28097 100644
--- a/omx/gstomxh264utils.c
+++ b/omx/gstomxh264utils.c
@@ -24,28 +24,49 @@
#include "gstomxh264utils.h"
+typedef struct
+{
+ const gchar *profile;
+ OMX_VIDEO_AVCPROFILETYPE e;
+} H264ProfileMapping;
+
+static const H264ProfileMapping h264_profiles[] = {
+ {"baseline", OMX_VIDEO_AVCProfileBaseline},
+ {"constrained-baseline", OMX_VIDEO_AVCProfileBaseline},
+ {"main", OMX_VIDEO_AVCProfileMain},
+ {"extended", OMX_VIDEO_AVCProfileExtended},
+ {"high", OMX_VIDEO_AVCProfileHigh},
+ {"high-10", OMX_VIDEO_AVCProfileHigh10},
+ {"high-4:2:2", OMX_VIDEO_AVCProfileHigh422},
+ {"high-4:4:4", OMX_VIDEO_AVCProfileHigh444},
+};
+
OMX_VIDEO_AVCPROFILETYPE
gst_omx_h264_utils_get_profile_from_str (const gchar * profile)
{
- if (g_str_equal (profile, "baseline")) {
- return OMX_VIDEO_AVCProfileBaseline;
- } else if (g_str_equal (profile, "main")) {
- return OMX_VIDEO_AVCProfileMain;
- } else if (g_str_equal (profile, "extended")) {
- return OMX_VIDEO_AVCProfileExtended;
- } else if (g_str_equal (profile, "high")) {
- return OMX_VIDEO_AVCProfileHigh;
- } else if (g_str_equal (profile, "high-10")) {
- return OMX_VIDEO_AVCProfileHigh10;
- } else if (g_str_equal (profile, "high-4:2:2")) {
- return OMX_VIDEO_AVCProfileHigh422;
- } else if (g_str_equal (profile, "high-4:4:4")) {
- return OMX_VIDEO_AVCProfileHigh444;
+ guint i;
+
+ for (i = 0; i < G_N_ELEMENTS (h264_profiles); i++) {
+ if (g_str_equal (profile, h264_profiles[i].profile))
+ return h264_profiles[i].e;
}
return OMX_VIDEO_AVCProfileMax;
}
+const gchar *
+gst_omx_h264_utils_get_profile_from_enum (OMX_VIDEO_AVCPROFILETYPE e)
+{
+ guint i;
+
+ for (i = 0; i < G_N_ELEMENTS (h264_profiles); i++) {
+ if (e == h264_profiles[i].e)
+ return h264_profiles[i].profile;
+ }
+
+ return NULL;
+}
+
OMX_VIDEO_AVCLEVELTYPE
gst_omx_h264_utils_get_level_from_str (const gchar * level)
{
diff --git a/omx/gstomxh264utils.h b/omx/gstomxh264utils.h
index 6300486..e5c35e4 100644
--- a/omx/gstomxh264utils.h
+++ b/omx/gstomxh264utils.h
@@ -30,5 +30,7 @@ OMX_VIDEO_AVCPROFILETYPE gst_omx_h264_utils_get_profile_from_str (const
OMX_VIDEO_AVCLEVELTYPE gst_omx_h264_utils_get_level_from_str (const gchar *
level);
+const gchar * gst_omx_h264_utils_get_profile_from_enum (OMX_VIDEO_AVCPROFILETYPE e);
+
G_END_DECLS
#endif /* __GST_OMX_H264_UTILS_H__ */