vah264dec: Complete profiles in decoder.

Instead of specifying all the H.264 "supported" profiles in the global
hash table (used either by decoders and encoders), just complete them
in the decoder only, since the encoder doesn't support them.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2844>
This commit is contained in:
Víctor Manuel Jáquez Leal 2022-08-05 15:54:39 +02:00
parent edf84a7119
commit 8c59ee29c2
2 changed files with 45 additions and 13 deletions

View file

@ -758,13 +758,28 @@ gst_va_h264_dec_new_sequence (GstH264Decoder * decoder, const GstH264SPS * sps,
return GST_FLOW_OK;
}
static inline void
_append_str (GValue * list, const gchar * str)
{
GValue v = G_VALUE_INIT;
g_value_init (&v, G_TYPE_STRING);
g_value_set_string (&v, str);
gst_value_list_append_value (list, &v);
g_value_unset (&v);
}
static GstCaps *
_complete_sink_caps (GstCaps * sinkcaps)
{
GstCaps *caps = gst_caps_copy (sinkcaps);
GValue val = G_VALUE_INIT;
const GValue *profiles;
GstStructure *st;
const gchar *streamformat[] = { "avc", "avc3", "byte-stream" };
gint i;
const gchar *high_synthetic[] = { "progressive-high", "constrained-high" };
guint i, j, siz;
gboolean baseline = FALSE;
g_value_init (&val, G_TYPE_STRING);
g_value_set_string (&val, "au");
@ -772,17 +787,35 @@ _complete_sink_caps (GstCaps * sinkcaps)
g_value_unset (&val);
gst_value_list_init (&val, G_N_ELEMENTS (streamformat));
for (i = 0; i < G_N_ELEMENTS (streamformat); i++) {
GValue v = G_VALUE_INIT;
g_value_init (&v, G_TYPE_STRING);
g_value_set_string (&v, streamformat[i]);
gst_value_list_append_value (&val, &v);
g_value_unset (&v);
}
for (i = 0; i < G_N_ELEMENTS (streamformat); i++)
_append_str (&val, streamformat[i]);
gst_caps_set_value (caps, "stream-format", &val);
g_value_unset (&val);
/* add synthetic profiles */
st = gst_caps_get_structure (caps, 0);
profiles = gst_structure_get_value (st, "profile");
siz = gst_value_list_get_size (profiles);
gst_value_list_init (&val, siz);
for (i = 0; i < siz; i++) {
const gchar *profile =
g_value_get_string (gst_value_list_get_value (profiles, i));
_append_str (&val, profile);
if (g_strcmp0 (profile, "high") == 0) {
for (j = 0; j < G_N_ELEMENTS (high_synthetic); j++)
_append_str (&val, high_synthetic[j]);
}
if (!baseline && ((g_strcmp0 (profile, "main") == 0)
|| g_strcmp0 (profile, "constrained-baseline") == 0)) {
_append_str (&val, "baseline");
baseline = TRUE;
}
}
gst_caps_set_value (caps, "profile", &val);
g_value_unset (&val);
return caps;
}

View file

@ -48,9 +48,8 @@ static const struct ProfileMap
"mpegversion = (int) 4, profile = (string) advanced-simple"),
P (MPEG4, Main, "main", "video/mpeg",
"mpegversion = (int) 4, profile = (string) main, "),
P (H264, Main, "main", "video/x-h264", "profile = (string) { main, baseline }"),
P (H264, High, "high", "video/x-h264",
"profile = (string) { high, progressive-high, constrained-high }"),
P (H264, Main, "main", "video/x-h264", "profile = (string) main"),
P (H264, High, "high", "video/x-h264", "profile = (string) high"),
P (VC1, Simple, "simple", "video/x-wmv",
"wmvversion = (int) 3, profile = (string) simple"),
P (VC1, Main, "main", "video/x-wmv",
@ -63,7 +62,7 @@ static const struct ProfileMap
"profile = (string) baseline"),
P (JPEG, Baseline, "", "image/jpeg", "sof-marker = (int) 0"),
P (H264, ConstrainedBaseline, "constrained-baseline", "video/x-h264",
"profile = (string) { constrained-baseline, baseline }"),
"profile = (string) constrained-baseline"),
P (VP8, Version0_3, "", "video/x-vp8", NULL),
/* Unsupported profiles by current GstH264Decoder */
/* P (H264, MultiviewHigh, "video/x-h264", */