va: Add the profile string name into the profile_map.

We also add a helper function of gst_va_profile_from_name to get
the VA profile value by its profile string name.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1051>
This commit is contained in:
He Junyan 2021-10-21 22:56:23 +08:00 committed by Víctor Manuel Jáquez Leal
parent e0b6c6678b
commit 57d50a941f
2 changed files with 59 additions and 37 deletions

View file

@ -29,62 +29,68 @@ static const struct ProfileMap
{ {
VAProfile profile; VAProfile profile;
GstVaCodecs codec; GstVaCodecs codec;
const gchar *va_name;
const gchar *name; const gchar *name;
const gchar *media_type; const gchar *media_type;
const gchar *caps_str; const gchar *caps_str;
} profile_map[] = { } profile_map[] = {
#define P(codec, name, media_type, caps_str) { \ #define P(codec, va_name, name, media_type, caps_str) { \
G_PASTE (G_PASTE (VAProfile, codec), name), codec, \ G_PASTE (G_PASTE (VAProfile, codec), va_name), codec, \
G_STRINGIFY (G_PASTE (G_PASTE (VAProfile, codec), name)), \ G_STRINGIFY (G_PASTE (G_PASTE (VAProfile, codec), va_name)), \
media_type, caps_str } name, media_type, caps_str }
P (MPEG2, Simple, "video/mpeg", P (MPEG2, Simple, "simple", "video/mpeg",
"mpegversion = (int) 2, profile = (string) simple"), "mpegversion = (int) 2, profile = (string) simple"),
P (MPEG2, Main, "video/mpeg", P (MPEG2, Main, "main", "video/mpeg",
"mpegversion = (int) 2, profile = (string) main"), "mpegversion = (int) 2, profile = (string) main"),
P (MPEG4, Simple, "video/mpeg", P (MPEG4, Simple, "simple", "video/mpeg",
"mpegversion = (int) 4, profile = (string) simple"), "mpegversion = (int) 4, profile = (string) simple"),
P (MPEG4, AdvancedSimple, "video/mpeg", P (MPEG4, AdvancedSimple, "advanced-simple", "video/mpeg",
"mpegversion = (int) 4, profile = (string) advanced-simple"), "mpegversion = (int) 4, profile = (string) advanced-simple"),
P (MPEG4, Main, "video/mpeg", P (MPEG4, Main, "main", "video/mpeg",
"mpegversion = (int) 4, profile = (string) main, "), "mpegversion = (int) 4, profile = (string) main, "),
P (H264, Main, "video/x-h264", "profile = (string) { main, baseline }"), P (H264, Main, "main", "video/x-h264", "profile = (string) { main, baseline }"),
P (H264, High, "video/x-h264", P (H264, High, "high", "video/x-h264",
"profile = (string) { high, progressive-high, constrained-high }"), "profile = (string) { high, progressive-high, constrained-high }"),
P (VC1, Simple, "video/x-wmv", P (VC1, Simple, "simple", "video/x-wmv",
"wmvversion = (int) 3, profile = (string) simple"), "wmvversion = (int) 3, profile = (string) simple"),
P (VC1, Main, "video/x-wmv", P (VC1, Main, "main", "video/x-wmv",
"wmvversion = (int) 3, profile = (string) main"), "wmvversion = (int) 3, profile = (string) main"),
P (VC1, Advanced, "video/x-wmv", P (VC1, Advanced, "advanced", "video/x-wmv",
"wmvversion = (int) 3, format = (string) WVC1, " "wmvversion = (int) 3, format = (string) WVC1, "
"profile = (string) advanced"), "profile = (string) advanced"),
P (H263, Baseline, "video/x-h263", P (H263, Baseline, "baseline", "video/x-h263",
"variant = (string) itu, h263version = (string) h263, " "variant = (string) itu, h263version = (string) h263, "
"profile = (string) baseline"), "profile = (string) baseline"),
P (JPEG, Baseline, "image/jpeg", NULL), P (JPEG, Baseline, "", "image/jpeg", NULL),
P (H264, ConstrainedBaseline, "video/x-h264", P (H264, ConstrainedBaseline, "constrained-baseline", "video/x-h264",
"profile = (string) { constrained-baseline, baseline }"), "profile = (string) { constrained-baseline, baseline }"),
P (VP8, Version0_3, "video/x-vp8", NULL), P (VP8, Version0_3, "", "video/x-vp8", NULL),
/* Unsupported profiles by current GstH264Decoder */ /* Unsupported profiles by current GstH264Decoder */
/* P (H264, MultiviewHigh, "video/x-h264", */ /* P (H264, MultiviewHigh, "video/x-h264", */
/* "profile = (string) { multiview-high, stereo-high }"), */ /* "profile = (string) { multiview-high, stereo-high }"), */
/* P (H264, StereoHigh, "video/x-h264", */ /* P (H264, StereoHigh, "video/x-h264", */
/* "profile = (string) { multiview-high, stereo-high }"), */ /* "profile = (string) { multiview-high, stereo-high }"), */
P (HEVC, Main, "video/x-h265", "profile = (string) main"), P (HEVC, Main, "main", "video/x-h265", "profile = (string) main"),
P (HEVC, Main10, "video/x-h265", "profile = (string) main-10"), P (HEVC, Main10, "main-10", "video/x-h265", "profile = (string) main-10"),
P (VP9, Profile0, "video/x-vp9", "profile = (string) 0"), P (VP9, Profile0, "0", "video/x-vp9", "profile = (string) 0"),
P (VP9, Profile1, "video/x-vp9", "profile = (string) 1"), P (VP9, Profile1, "1", "video/x-vp9", "profile = (string) 1"),
P (VP9, Profile2, "video/x-vp9", "profile = (string) 2"), P (VP9, Profile2, "2", "video/x-vp9", "profile = (string) 2"),
P (VP9, Profile3, "video/x-vp9", "profile = (string) 3"), P (VP9, Profile3, "3", "video/x-vp9", "profile = (string) 3"),
P (HEVC, Main12, "video/x-h265", "profile = (string) main-12"), P (HEVC, Main12, "main-12", "video/x-h265", "profile = (string) main-12"),
P (HEVC, Main422_10, "video/x-h265", "profile = (string) main-422-10"), P (HEVC, Main422_10, "main-422-10", "video/x-h265",
P (HEVC, Main422_12, "video/x-h265", "profile = (string) main-422-12"), "profile = (string) main-422-10"),
P (HEVC, Main444, "video/x-h265", "profile = (string) main-444"), P (HEVC, Main422_12, "main-422-12", "video/x-h265",
P (HEVC, Main444_10, "video/x-h265", "profile = (string) main-444-10"), "profile = (string) main-422-12"),
P (HEVC, Main444_12, "video/x-h265", "profile = (string) main-444-12"), P (HEVC, Main444, "main-444", "video/x-h265", "profile = (string) main-444"),
P (HEVC, SccMain, "video/x-h265", "profile = (string) screen-extended-main"), P (HEVC, Main444_10, "main-444-10", "video/x-h265",
P (HEVC, SccMain10, "video/x-h265", "profile = (string) main-444-10"),
P (HEVC, Main444_12, "main-444-12", "video/x-h265",
"profile = (string) main-444-12"),
P (HEVC, SccMain, "screen-extended-main", "video/x-h265",
"profile = (string) screen-extended-main"),
P (HEVC, SccMain10, "screen-extended-main-10", "video/x-h265",
"profile = (string) screen-extended-main-10"), "profile = (string) screen-extended-main-10"),
P (HEVC, SccMain444, "video/x-h265", P (HEVC, SccMain444, "screen-extended-main-444", "video/x-h265",
"profile = (string) screen-extended-main-444"), "profile = (string) screen-extended-main-444"),
#if VA_CHECK_VERSION(1,7,0) #if VA_CHECK_VERSION(1,7,0)
/* Spec A.2: /* Spec A.2:
@ -103,11 +109,11 @@ static const struct ProfileMap
So far, all va decoders can support "0" when they support "1", So far, all va decoders can support "0" when they support "1",
we just map "0" to "main" and "1" to "high". */ we just map "0" to "main" and "1" to "high". */
P (AV1, Profile0, "video/x-av1", "profile = (string) main"), P (AV1, Profile0, "main", "video/x-av1", "profile = (string) main"),
P (AV1, Profile1, "video/x-av1", "profile = (string) high"), P (AV1, Profile1, "high", "video/x-av1", "profile = (string) high"),
#endif #endif
#if VA_CHECK_VERSION(1, 8, 0) #if VA_CHECK_VERSION(1, 8, 0)
P (HEVC, SccMain444_10, "video/x-h265", P (HEVC, SccMain444_10, "screen-extended-main-444-10", "video/x-h265",
"profile = (string) screen-extended-main-444-10"), "profile = (string) screen-extended-main-444-10"),
#endif #endif
#undef P #undef P
@ -138,7 +144,21 @@ const gchar *
gst_va_profile_name (VAProfile profile) gst_va_profile_name (VAProfile profile)
{ {
const struct ProfileMap *map = get_profile_map (profile); const struct ProfileMap *map = get_profile_map (profile);
return map ? map->name : NULL; return map ? map->va_name : NULL;
}
VAProfile
gst_va_profile_from_name (GstVaCodecs codec, const gchar * name)
{
int i;
for (i = 0; i < G_N_ELEMENTS (profile_map); i++) {
if (profile_map[i].codec == codec &&
g_strcmp0 (profile_map[i].name, name) == 0)
return profile_map[i].profile;
}
return VAProfileNone;
} }
GstCaps * GstCaps *

View file

@ -42,5 +42,7 @@ typedef enum
guint32 gst_va_profile_codec (VAProfile profile); guint32 gst_va_profile_codec (VAProfile profile);
GstCaps * gst_va_profile_caps (VAProfile profile); GstCaps * gst_va_profile_caps (VAProfile profile);
const gchar * gst_va_profile_name (VAProfile profile); const gchar * gst_va_profile_name (VAProfile profile);
VAProfile gst_va_profile_from_name (GstVaCodecs codec,
const gchar * name);
G_END_DECLS G_END_DECLS