summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.com>2015-02-15 18:14:18 +0000
committerTim-Philipp Müller <tim@centricular.com>2015-02-15 18:50:43 +0000
commit1d528459bed7fcafabab9471eef98429442e941d (patch)
tree02fb793825afb8b596ec0d310e4dadedd569b755
parent0aa81614accf1c4f7f804418ce0243e72824be52 (diff)
pbutils: descriptions: add H.264 profile to description if available
https://bugzilla.gnome.org/show_bug.cgi?id=673976
-rw-r--r--gst-libs/gst/pbutils/descriptions.c44
-rw-r--r--tests/check/libs/pbutils.c2
2 files changed, 45 insertions, 1 deletions
diff --git a/gst-libs/gst/pbutils/descriptions.c b/gst-libs/gst/pbutils/descriptions.c
index b34ae980a..837712e3d 100644
--- a/gst-libs/gst/pbutils/descriptions.c
+++ b/gst-libs/gst/pbutils/descriptions.c
@@ -329,6 +329,41 @@ static const FormatInfo formats[] = {
{"video/x-tscc", NULL, FLAG_VIDEO, ""}
};
+static const gchar *
+pbutils_desc_get_h264_profile_name_from_nick (const gchar * nick)
+{
+ const gchar map[] = "baseline\000Baseline\000"
+ "constrained-baseline\000Constrained Baseline\000"
+ "main\000Main\000"
+ "extended\000Extended\000"
+ "high\000High\000"
+ "high-10-intra\000High 10 Intra\000"
+ "high-10\000High 10\000"
+ "high-4:2:2-intra\000High 4:2:2 Intra\000"
+ "high-4:2:2\000High 4:2:2\000"
+ "high-4:4:4-intra\000High 4:4:4 Intra\000"
+ "high-4:4:4\000High 4:4:4\000"
+ "cavlc-4:4:4-intra\000CAVLC 4:4:4 Intra\000"
+ "multiview-high\000Multiview High\000"
+ "stereo-high\000Stereo High\000"
+ "scalable-constrained-baseline\000Scalable Constrained Baseline\000"
+ "scalable-baseline\000Scalable Baseline\000"
+ "scalable-high\000Scalable High\000";
+ const gchar *end = map + sizeof (map);
+ const gchar *p;
+
+ p = map;
+ while (*p != '\0' && p < end) {
+ guint len = strlen (p);
+
+ if (strcmp (p, nick) == 0)
+ return p + len + 1;
+ p += len + 1;
+ p += strlen (p) + 1;
+ }
+ return NULL;
+}
+
/* returns static descriptions and dynamic ones (such as video/x-raw),
* or NULL if caps aren't known at all */
static gchar *
@@ -432,6 +467,7 @@ format_info_get_desc (const FormatInfo * info, const GstCaps * caps)
return g_strdup (ret);
} else if (strcmp (info->type, "video/x-h264") == 0) {
const gchar *variant, *ret;
+ const gchar *profile;
variant = gst_structure_get_string (s, "variant");
if (variant == NULL)
@@ -446,7 +482,13 @@ format_info_get_desc (const FormatInfo * info, const GstCaps * caps)
GST_WARNING ("Unknown H264 variant '%s'", variant);
ret = "H.264";
}
- return g_strdup (ret);
+ /* profile */
+ profile = gst_structure_get_string (s, "profile");
+ if (profile != NULL)
+ profile = pbutils_desc_get_h264_profile_name_from_nick (profile);
+ if (profile == NULL)
+ return g_strdup (ret);
+ return g_strdup_printf ("%s (%s Profile)", ret, profile);
} else if (strcmp (info->type, "video/x-h265") == 0) {
/* TODO: Any variants? */
return g_strdup ("H.265");
diff --git a/tests/check/libs/pbutils.c b/tests/check/libs/pbutils.c
index 45a7ef554..ad7ec9617 100644
--- a/tests/check/libs/pbutils.c
+++ b/tests/check/libs/pbutils.c
@@ -337,6 +337,8 @@ static const gchar *caps_strings[] = {
"video/x-h264, variant=(string)videosoft",
"video/x-h264, variant=(string)foobar",
"video/x-h264",
+ "video/x-h264, profile=(string)foobar",
+ "video/x-h264, profile=(string)high-4:4:4-intra",
"video/x-h263, variant=(string)itu",
"video/x-h263, variant=(string)lead",
"video/x-h263, variant=(string)microsoft",