pbutils: description: move some code into utility function

This commit is contained in:
Tim-Philipp Müller 2015-02-15 20:08:36 +00:00
parent 4e1a43d4ea
commit 6af7b70162

View file

@ -329,6 +329,25 @@ static const FormatInfo formats[] = {
{"video/x-tscc", NULL, FLAG_VIDEO, ""} {"video/x-tscc", NULL, FLAG_VIDEO, ""}
}; };
static const gchar *
pbutils_desc_get_profile_name_from_nick (const gchar * map, gsize map_len,
const gchar * nick)
{
const gchar *end = map + map_len;
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;
}
static const gchar * static const gchar *
pbutils_desc_get_mpeg4v_profile_name_from_nick (const gchar * nick) pbutils_desc_get_mpeg4v_profile_name_from_nick (const gchar * nick)
{ {
@ -352,19 +371,8 @@ pbutils_desc_get_mpeg4v_profile_name_from_nick (const gchar * nick)
"fine-granularity-scalable\000Fine Granularity Scalable\000" "fine-granularity-scalable\000Fine Granularity Scalable\000"
"basic-animated-texture\000Basic Animated Texture\000" "basic-animated-texture\000Basic Animated Texture\000"
"baseline\000Baseline Profile\000"; "baseline\000Baseline Profile\000";
const gchar *end = map + sizeof (map);
const gchar *p;
p = map; return pbutils_desc_get_profile_name_from_nick (map, sizeof (map), nick);
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;
} }
static const gchar * static const gchar *
@ -387,19 +395,8 @@ pbutils_desc_get_h264_profile_name_from_nick (const gchar * nick)
"scalable-constrained-baseline\000Scalable Constrained Baseline\000" "scalable-constrained-baseline\000Scalable Constrained Baseline\000"
"scalable-baseline\000Scalable Baseline\000" "scalable-baseline\000Scalable Baseline\000"
"scalable-high\000Scalable High\000"; "scalable-high\000Scalable High\000";
const gchar *end = map + sizeof (map);
const gchar *p;
p = map; return pbutils_desc_get_profile_name_from_nick (map, sizeof (map), nick);
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;
} }
static const gchar * static const gchar *
@ -415,19 +412,8 @@ pbutils_desc_get_h265_profile_name_from_nick (const gchar * nick)
"main-4:4:4-12\000Main 4:4:4 12\000" "main-4:4:4-12\000Main 4:4:4 12\000"
"main-4:4:4-16-intra\000Main 4:4:4 16 Intra\000" "main-4:4:4-16-intra\000Main 4:4:4 16 Intra\000"
"main-still-picture\000Main Still Picture\000"; "main-still-picture\000Main Still Picture\000";
const gchar *end = map + sizeof (map);
const gchar *p;
p = map; return pbutils_desc_get_profile_name_from_nick (map, sizeof (map), nick);
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), /* returns static descriptions and dynamic ones (such as video/x-raw),