mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-09 00:45:56 +00:00
h265parser: Add simple GstH265Profile/string public utilites
It makes more simplifies the conversion between GstH265Profile and string.
This commit is contained in:
parent
0e013fe539
commit
3f2240498b
3 changed files with 118 additions and 99 deletions
|
@ -251,6 +251,63 @@ gst_h265_parse_nalu_header (GstH265NalUnit * nalu)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
struct h265_profile_string
|
||||
{
|
||||
GstH265Profile profile;
|
||||
const gchar *name;
|
||||
};
|
||||
|
||||
static const struct h265_profile_string h265_profiles[] = {
|
||||
/* keep in sync with definition in the header */
|
||||
{GST_H265_PROFILE_MAIN, "main"},
|
||||
{GST_H265_PROFILE_MAIN_10, "main-10"},
|
||||
{GST_H265_PROFILE_MAIN_STILL_PICTURE, "main-still-picture"},
|
||||
{GST_H265_PROFILE_MONOCHROME, "monochrome"},
|
||||
{GST_H265_PROFILE_MONOCHROME_12, "monochrome-12"},
|
||||
{GST_H265_PROFILE_MONOCHROME_16, "monochrome-16"},
|
||||
{GST_H265_PROFILE_MAIN_12, "main-12"},
|
||||
{GST_H265_PROFILE_MAIN_422_10, "main-422-10"},
|
||||
{GST_H265_PROFILE_MAIN_422_12, "main-422-12"},
|
||||
{GST_H265_PROFILE_MAIN_444, "main-444"},
|
||||
{GST_H265_PROFILE_MAIN_444_10, "main-444-10"},
|
||||
{GST_H265_PROFILE_MAIN_444_12, "main-444-12"},
|
||||
{GST_H265_PROFILE_MAIN_INTRA, "main-intra"},
|
||||
{GST_H265_PROFILE_MAIN_10_INTRA, "main-10-intra"},
|
||||
{GST_H265_PROFILE_MAIN_12_INTRA, "main-12-intra"},
|
||||
{GST_H265_PROFILE_MAIN_422_10_INTRA, "main-422-10-intra"},
|
||||
{GST_H265_PROFILE_MAIN_422_12_INTRA, "main-422-12-intra"},
|
||||
{GST_H265_PROFILE_MAIN_444_INTRA, "main-444-intra"},
|
||||
{GST_H265_PROFILE_MAIN_444_10_INTRA, "main-444-10-intra"},
|
||||
{GST_H265_PROFILE_MAIN_444_12_INTRA, "main-444-12-intra"},
|
||||
{GST_H265_PROFILE_MAIN_444_16_INTRA, "main-444-16-intra"},
|
||||
{GST_H265_PROFILE_MAIN_444_STILL_PICTURE, "main-444-still-picture"},
|
||||
{GST_H265_PROFILE_MAIN_444_16_STILL_PICTURE, "main-444-16-still-picture"},
|
||||
{GST_H265_PROFILE_MONOCHROME_10, "monochrome-10"},
|
||||
{GST_H265_PROFILE_HIGH_THROUGHPUT_444, "high-throughput-444"},
|
||||
{GST_H265_PROFILE_HIGH_THROUGHPUT_444_10, "high-throughput-444-10"},
|
||||
{GST_H265_PROFILE_HIGH_THROUGHPUT_444_14, "high-throughput-444-14"},
|
||||
{GST_H265_PROFILE_HIGH_THROUGHPUT_444_16_INTRA,
|
||||
"high-throughput-444-16-intra"},
|
||||
{GST_H265_PROFILE_SCREEN_EXTENDED_MAIN, "screen-extended-main"},
|
||||
{GST_H265_PROFILE_SCREEN_EXTENDED_MAIN_10, "screen-extended-main-10"},
|
||||
{GST_H265_PROFILE_SCREEN_EXTENDED_MAIN_444, "screen-extended-main-444"},
|
||||
{GST_H265_PROFILE_SCREEN_EXTENDED_MAIN_444_10, "screen-extended-main-444-10"},
|
||||
{GST_H265_PROFILE_SCREEN_EXTENDED_HIGH_THROUGHPUT_444,
|
||||
"screen-extended-high-throughput-444"},
|
||||
{GST_H265_PROFILE_SCREEN_EXTENDED_HIGH_THROUGHPUT_444_10,
|
||||
"screen-extended-high-throughput-444-10"},
|
||||
{GST_H265_PROFILE_SCREEN_EXTENDED_HIGH_THROUGHPUT_444_14,
|
||||
"screen-extended-high-throughput-444-14"},
|
||||
{GST_H265_PROFILE_MULTIVIEW_MAIN, "multiview-main"},
|
||||
{GST_H265_PROFILE_SCALABLE_MAIN, "scalable-main"},
|
||||
{GST_H265_PROFILE_SCALABLE_MAIN_10, "scalable-main-10"},
|
||||
{GST_H265_PROFILE_SCALABLE_MONOCHROME, "scalable-monochrome"},
|
||||
{GST_H265_PROFILE_SCALABLE_MONOCHROME_12, "scalable-monochrome-12"},
|
||||
{GST_H265_PROFILE_SCALABLE_MONOCHROME_16, "scalable-monochrome-16"},
|
||||
{GST_H265_PROFILE_SCALABLE_MAIN_444, "scalable-main-444"},
|
||||
{GST_H265_PROFILE_3D_MAIN, "3d-main"},
|
||||
};
|
||||
|
||||
/****** Parsing functions *****/
|
||||
|
||||
static gboolean
|
||||
|
@ -3234,3 +3291,56 @@ gst_h265_profile_tier_level_get_profile (GstH265ProfileTierLevel * ptl)
|
|||
|
||||
return get_format_range_extension_profile (ptl);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_h265_profile_to_string:
|
||||
* @profile: a #GstH265Profile
|
||||
*
|
||||
* Returns the descriptive name for the #GstH265Profile.
|
||||
*
|
||||
* Returns: (nullable): the name for @profile or %NULL on error
|
||||
*
|
||||
* Since: 1.18
|
||||
*/
|
||||
const gchar *
|
||||
gst_h265_profile_to_string (GstH265Profile profile)
|
||||
{
|
||||
guint i;
|
||||
|
||||
if (profile == GST_H265_PROFILE_INVALID || profile == GST_H265_PROFILE_MAX)
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (h265_profiles); i++) {
|
||||
if (profile == h265_profiles[i].profile)
|
||||
return h265_profiles[i].name;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_h265_profile_from_string:
|
||||
* @string: the descriptive name for #GstH265Profile
|
||||
*
|
||||
* Returns a #GstH265Profile for the @string.
|
||||
*
|
||||
* Returns: the #GstH265Profile of @string or %GST_H265_PROFILE_INVALID on error
|
||||
*
|
||||
* Since: 1.18
|
||||
*/
|
||||
GstH265Profile
|
||||
gst_h265_profile_from_string (const gchar * string)
|
||||
{
|
||||
guint i;
|
||||
|
||||
if (string == NULL)
|
||||
return GST_H265_PROFILE_INVALID;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (h265_profiles); i++) {
|
||||
if (g_strcmp0 (string, h265_profiles[i].name) == 0) {
|
||||
return h265_profiles[i].profile;
|
||||
}
|
||||
}
|
||||
|
||||
return GST_H265_PROFILE_INVALID;
|
||||
}
|
||||
|
|
|
@ -1558,5 +1558,11 @@ void gst_h265_quant_matrix_8x8_get_raster_from_uprightdiagonal (guint8 out_qu
|
|||
GST_CODEC_PARSERS_API
|
||||
GstH265Profile gst_h265_profile_tier_level_get_profile (GstH265ProfileTierLevel * ptl);
|
||||
|
||||
GST_CODEC_PARSERS_API
|
||||
const gchar * gst_h265_profile_to_string (GstH265Profile profile);
|
||||
|
||||
GST_CODEC_PARSERS_API
|
||||
GstH265Profile gst_h265_profile_from_string (const gchar * string);
|
||||
|
||||
G_END_DECLS
|
||||
#endif
|
||||
|
|
|
@ -1565,103 +1565,6 @@ digit_to_string (guint digit)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static const gchar *
|
||||
get_profile_string (GstH265Profile profile)
|
||||
{
|
||||
switch (profile) {
|
||||
case GST_H265_PROFILE_MAIN:
|
||||
return "main";
|
||||
case GST_H265_PROFILE_MAIN_10:
|
||||
return "main-10";
|
||||
case GST_H265_PROFILE_MAIN_STILL_PICTURE:
|
||||
return "main-still-picture";
|
||||
case GST_H265_PROFILE_MONOCHROME:
|
||||
return "monochrome";
|
||||
case GST_H265_PROFILE_MONOCHROME_10:
|
||||
return "monochrome-10";
|
||||
case GST_H265_PROFILE_MONOCHROME_12:
|
||||
return "monochrome-12";
|
||||
case GST_H265_PROFILE_MONOCHROME_16:
|
||||
return "monochrome-16";
|
||||
case GST_H265_PROFILE_MAIN_12:
|
||||
return "main-12";
|
||||
case GST_H265_PROFILE_MAIN_422_10:
|
||||
return "main-422-10";
|
||||
case GST_H265_PROFILE_MAIN_422_12:
|
||||
return "main-422-12";
|
||||
case GST_H265_PROFILE_MAIN_444:
|
||||
return "main-444";
|
||||
case GST_H265_PROFILE_MAIN_444_10:
|
||||
return "main-444-10";
|
||||
case GST_H265_PROFILE_MAIN_444_12:
|
||||
return "main-444-12";
|
||||
case GST_H265_PROFILE_MAIN_INTRA:
|
||||
return "main-intra";
|
||||
case GST_H265_PROFILE_MAIN_10_INTRA:
|
||||
return "main-10-intra";
|
||||
case GST_H265_PROFILE_MAIN_12_INTRA:
|
||||
return "main-12-intra";
|
||||
case GST_H265_PROFILE_MAIN_422_10_INTRA:
|
||||
return "main-422-10-intra";
|
||||
case GST_H265_PROFILE_MAIN_422_12_INTRA:
|
||||
return "main-422-12-intra";
|
||||
case GST_H265_PROFILE_MAIN_444_INTRA:
|
||||
return "main-444-intra";
|
||||
case GST_H265_PROFILE_MAIN_444_10_INTRA:
|
||||
return "main-444-10-intra";
|
||||
case GST_H265_PROFILE_MAIN_444_12_INTRA:
|
||||
return "main-444-12-intra";
|
||||
case GST_H265_PROFILE_MAIN_444_16_INTRA:
|
||||
return "main-444-16-intra";
|
||||
case GST_H265_PROFILE_MAIN_444_STILL_PICTURE:
|
||||
return "main-444-still-picture";
|
||||
case GST_H265_PROFILE_MAIN_444_16_STILL_PICTURE:
|
||||
return "main-444-16-still-picture";
|
||||
case GST_H265_PROFILE_HIGH_THROUGHPUT_444:
|
||||
return "high-throughput-444";
|
||||
case GST_H265_PROFILE_HIGH_THROUGHPUT_444_10:
|
||||
return "high-throughput-444-10";
|
||||
case GST_H265_PROFILE_HIGH_THROUGHPUT_444_14:
|
||||
return "high-throughput-444-14";
|
||||
case GST_H265_PROFILE_HIGH_THROUGHPUT_444_16_INTRA:
|
||||
return "high-throughput-444-16-intra";
|
||||
case GST_H265_PROFILE_SCREEN_EXTENDED_MAIN:
|
||||
return "screen-extended-main";
|
||||
case GST_H265_PROFILE_SCREEN_EXTENDED_MAIN_10:
|
||||
return "screen-extended-main-10";
|
||||
case GST_H265_PROFILE_SCREEN_EXTENDED_MAIN_444:
|
||||
return "screen-extended-main-444";
|
||||
case GST_H265_PROFILE_SCREEN_EXTENDED_MAIN_444_10:
|
||||
return "screen-extended-main-444-10";
|
||||
case GST_H265_PROFILE_SCREEN_EXTENDED_HIGH_THROUGHPUT_444:
|
||||
return "screen-extended-high-throughput-444";
|
||||
case GST_H265_PROFILE_SCREEN_EXTENDED_HIGH_THROUGHPUT_444_10:
|
||||
return "screen-extended-high-throughput-444-10";
|
||||
case GST_H265_PROFILE_SCREEN_EXTENDED_HIGH_THROUGHPUT_444_14:
|
||||
return "screen-extended-high-throughput-444-14";
|
||||
case GST_H265_PROFILE_MULTIVIEW_MAIN:
|
||||
return "multiview-main";
|
||||
case GST_H265_PROFILE_SCALABLE_MAIN:
|
||||
return "scalable-main";
|
||||
case GST_H265_PROFILE_SCALABLE_MAIN_10:
|
||||
return "scalable-main-10";
|
||||
case GST_H265_PROFILE_SCALABLE_MONOCHROME:
|
||||
return "scalable-monochrome";
|
||||
case GST_H265_PROFILE_SCALABLE_MONOCHROME_12:
|
||||
return "scalable-monochrome-12";
|
||||
case GST_H265_PROFILE_SCALABLE_MONOCHROME_16:
|
||||
return "scalable-monochrome-16";
|
||||
case GST_H265_PROFILE_SCALABLE_MAIN_444:
|
||||
return "scalable-main-444";
|
||||
case GST_H265_PROFILE_3D_MAIN:
|
||||
return "3d-main";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const gchar *
|
||||
get_tier_string (guint8 tier_flag)
|
||||
{
|
||||
|
@ -1912,7 +1815,7 @@ get_compatible_profile_caps (GstH265SPS * sps, GstH265Profile profile)
|
|||
|
||||
for (i = GST_H265_PROFILE_MAIN; i < GST_H265_PROFILE_MAX; i++) {
|
||||
if ((profiles & profile_to_flag (i)) == profile_to_flag (i)) {
|
||||
profile_str = get_profile_string (i);
|
||||
profile_str = gst_h265_profile_to_string (i);
|
||||
|
||||
if (G_UNLIKELY (profile_str == NULL)) {
|
||||
GST_FIXME ("Unhandled profile index %d", i);
|
||||
|
@ -2225,7 +2128,7 @@ gst_h265_parse_update_src_caps (GstH265Parse * h265parse, GstCaps * caps)
|
|||
GstH265Profile p;
|
||||
|
||||
p = gst_h265_profile_tier_level_get_profile (&sps->profile_tier_level);
|
||||
profile = get_profile_string (p);
|
||||
profile = gst_h265_profile_to_string (p);
|
||||
if (profile != NULL)
|
||||
gst_caps_set_simple (caps, "profile", G_TYPE_STRING, profile, NULL);
|
||||
|
||||
|
|
Loading…
Reference in a new issue