From 8c59ee29c278eb1e6bf7d22f2bc9aa67938b47f4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Fri, 5 Aug 2022 15:54:39 +0200 Subject: [PATCH] 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: --- subprojects/gst-plugins-bad/sys/va/gstvah264dec.c | 49 +++++++++++++++++++---- subprojects/gst-plugins-bad/sys/va/gstvaprofile.c | 7 ++-- 2 files changed, 44 insertions(+), 12 deletions(-) diff --git a/subprojects/gst-plugins-bad/sys/va/gstvah264dec.c b/subprojects/gst-plugins-bad/sys/va/gstvah264dec.c index cf7d55c..d7d229c 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvah264dec.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvah264dec.c @@ -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,15 +787,33 @@ _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; + 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); - 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); + /* 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, "stream-format", &val); + gst_caps_set_value (caps, "profile", &val); g_value_unset (&val); return caps; diff --git a/subprojects/gst-plugins-bad/sys/va/gstvaprofile.c b/subprojects/gst-plugins-bad/sys/va/gstvaprofile.c index bf6fee7..67dca99 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvaprofile.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvaprofile.c @@ -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", */ -- 2.7.4