matroskademux, qtdemux: minor code cleanup in avc_level_idc_to_string()

Do the same with slightly fewer LOC.
This commit is contained in:
Tim-Philipp Müller 2010-04-12 14:50:46 +01:00
parent 5cd3896142
commit a155deaabf
2 changed files with 10 additions and 28 deletions

View file

@ -5869,25 +5869,16 @@ avc_profile_idc_to_string (guint profile_idc, guint constraint_set_flags)
static gchar * static gchar *
avc_level_idc_to_string (guint level_idc, guint constraint_set_flags) avc_level_idc_to_string (guint level_idc, guint constraint_set_flags)
{ {
const gchar *level = NULL;
gchar buf[4];
gint csf3; gint csf3;
csf3 = (constraint_set_flags & 0x10) >> 4; csf3 = (constraint_set_flags & 0x10) >> 4;
if (level_idc == 11 && csf3) if (level_idc == 11 && csf3)
level = "1b"; return g_strdup ("1b");
else { else if (level_idc % 10 == 0)
/* Level is (level_idc / 10) */ return g_strdup_printf ("%u", level_idc / 10);
if (level_idc % 10 == 0)
g_sprintf (buf, "%u", level_idc / 10);
else else
g_sprintf (buf, "%u.%u", level_idc / 10, level_idc % 10); return g_strdup_printf ("%u.%u", level_idc / 10, level_idc % 10);
level = buf;
}
return g_strdup (level);
} }
static void static void

View file

@ -5073,25 +5073,16 @@ avc_profile_idc_to_string (guint profile_idc, guint constraint_set_flags)
static gchar * static gchar *
avc_level_idc_to_string (guint level_idc, guint constraint_set_flags) avc_level_idc_to_string (guint level_idc, guint constraint_set_flags)
{ {
const gchar *level = NULL;
gchar buf[4];
gint csf3; gint csf3;
csf3 = (constraint_set_flags & 0x10) >> 4; csf3 = (constraint_set_flags & 0x10) >> 4;
if (level_idc == 11 && csf3) if (level_idc == 11 && csf3)
level = "1b"; return g_strdup ("1b");
else { else if (level_idc % 10 == 0)
/* Level is (level_idc / 10) */ return g_strdup_printf ("%u", level_idc / 10);
if (level_idc % 10 == 0)
g_sprintf (buf, "%u", level_idc / 10);
else else
g_sprintf (buf, "%u.%u", level_idc / 10, level_idc % 10); return g_strdup_printf ("%u.%u", level_idc / 10, level_idc % 10);
level = buf;
}
return g_strdup (level);
} }
static void static void