WebKit Bugzilla
Attachment 371416 Details for
Bug 198569
: [GStreamer] AVC1 decoding capabilities probing support
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-198569-20190605180141.patch (text/plain), 7.01 KB, created by
Philippe Normand
on 2019-06-05 10:01:43 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Philippe Normand
Created:
2019-06-05 10:01:43 PDT
Size:
7.01 KB
patch
obsolete
>Subversion Revision: 246109 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index cd4ccb1020151dfc87c4fd4ba1adc1c7b2982664..1295d83d519fe85986aef07778414cf3226fe242 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,26 @@ >+2019-06-05 Philippe Normand <philn@igalia.com> >+ >+ [GStreamer] AVC1 decoding capabilities probing support >+ https://bugs.webkit.org/show_bug.cgi?id=198569 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ When capabilities for an avc1 codec are requested, the registry scanner looks >+ for a compatible decoder for the given H.264 profile and level. >+ >+ This new approach can be avoided by using the WEBKIT_GST_MAX_AVC1_RESOLUTION >+ environment variable. If supplied, the decoder capabilities won't be probed and >+ the codec will be advertized as supported if it complies with the contents of >+ the environment variable. The resolutions currently handled are specifically: >+ 1080P, 720P and 480P. We don't handle framerate checking yet, so the implied >+ H.264 levels are assumed to be for 30FPS. >+ >+ * platform/graphics/gstreamer/GStreamerRegistryScanner.cpp: >+ (WebCore::GStreamerRegistryScanner::isCodecSupported const): >+ (WebCore::GStreamerRegistryScanner::areInputCapsAccepted const): >+ (WebCore::GStreamerRegistryScanner::isAVC1CodecSupported const): >+ * platform/graphics/gstreamer/GStreamerRegistryScanner.h: >+ > 2019-06-05 Truitt Savell <tsavell@apple.com> > > Unreviewed, rolling out r246052. >diff --git a/Source/WebCore/platform/graphics/gstreamer/GStreamerRegistryScanner.cpp b/Source/WebCore/platform/graphics/gstreamer/GStreamerRegistryScanner.cpp >index 8802188289ed92cb8d05f37994fcb462bcc6bc78..c33c3c56560440e393119c785797524841f88f01 100644 >--- a/Source/WebCore/platform/graphics/gstreamer/GStreamerRegistryScanner.cpp >+++ b/Source/WebCore/platform/graphics/gstreamer/GStreamerRegistryScanner.cpp >@@ -24,6 +24,7 @@ > #include "ContentType.h" > #include "GStreamerCommon.h" > #include <fnmatch.h> >+#include <gst/pbutils/codec-utils.h> > #include <wtf/PrintStream.h> > > namespace WebCore { >@@ -280,14 +281,18 @@ bool GStreamerRegistryScanner::isCodecSupported(String codec, bool shouldCheckFo > codec = codec.substring(slashIndex + 1); > > bool supported = false; >- for (const auto& item : m_codecMap) { >- if (!fnmatch(item.key.string().utf8().data(), codec.utf8().data(), 0)) { >- supported = shouldCheckForHardwareUse ? item.value : true; >- if (supported) >- break; >+ if (codec.startsWith("avc1")) >+ supported = isAVC1CodecSupported(codec); >+ else { >+ for (const auto& item : m_codecMap) { >+ if (!fnmatch(item.key.string().utf8().data(), codec.utf8().data(), 0)) { >+ supported = shouldCheckForHardwareUse ? item.value : true; >+ if (supported) >+ break; >+ } > } > } >- >+ > GST_LOG("Checked %s codec \"%s\" supported %s", shouldCheckForHardwareUse ? "hardware" : "software", codec.utf8().data(), boolForPrinting(supported)); > return supported; > } >@@ -302,6 +307,64 @@ bool GStreamerRegistryScanner::areAllCodecsSupported(const Vector<String>& codec > return true; > } > >+bool GStreamerRegistryScanner::areInputCapsAccepted(GList* factories, GRefPtr<GstCaps>&& caps) const >+{ >+ GST_DEBUG("Looking for a compatible element accepting input %" GST_PTR_FORMAT, caps.get()); >+ for (; factories; factories = g_list_next(factories)) { >+ auto* factory = reinterpret_cast<GstElementFactory*>(factories->data); >+ if (gst_element_factory_can_sink_any_caps(factory, caps.get())) { >+ GST_DEBUG("Found compatible element factory: %" GST_PTR_FORMAT, factory); >+ return true; >+ } >+ } >+ return false; >+} >+ >+bool GStreamerRegistryScanner::isAVC1CodecSupported(String& codec) const >+{ >+ auto components = codec.split('.'); >+ long int spsAsInteger = strtol(components[1].utf8().data(), nullptr, 16); >+ guint8 sps[3]; >+ sps[0] = spsAsInteger >> 16; >+ sps[1] = spsAsInteger >> 8; >+ sps[2] = spsAsInteger; >+ >+ const gchar* profile = gst_codec_utils_h264_get_profile(sps, 3); >+ const gchar* level = gst_codec_utils_h264_get_level(sps, 3); >+ GST_DEBUG("Codec %s translates to H.264 profile %s and level %s", codec.utf8().data(), profile, level); >+ >+ if (const char* maxVideoResolution = getenv("WEBKIT_GST_MAX_AVC1_RESOLUTION")) { >+ guint8 levelAsInteger = gst_codec_utils_h264_get_level_idc(level); >+ GST_DEBUG("Maximum video resolution requested: %s, supplied codec level IDC: %u", maxVideoResolution, levelAsInteger); >+ guint8 maxLevel = 0; >+ if (!strcmp(maxVideoResolution, "1080P")) >+ maxLevel = 40; >+ else if (!strcmp(maxVideoResolution, "720P")) >+ maxLevel = 31; >+ else if (!strcmp(maxVideoResolution, "480P")) >+ maxLevel = 30; >+ else >+ GST_WARNING("Invalid value for WEBKIT_GST_MAX_AVC1_RESOLUTION. Currently supported, 1080P, 720P and 480P."); >+ bool supported = maxLevel && levelAsInteger && levelAsInteger <= maxLevel; >+ GST_DEBUG("Decoding supported for codec %s: %s", codec.utf8().data(), boolForPrinting(supported)); >+ return supported; >+ } >+ >+ if (webkitGstCheckVersion(1, 17, 0)) { >+ GST_DEBUG("Checking video decoders for constrained caps"); >+ auto caps = adoptGRef(gst_caps_new_simple("video/x-h264", "level", G_TYPE_STRING, level, "profile", G_TYPE_STRING, profile, nullptr)); >+ if (areInputCapsAccepted(m_videoDecoderFactories, WTFMove(caps))) >+ return true; >+ } >+ >+ GST_DEBUG("Falling back to unconstrained caps"); >+ auto unconstrainedCaps = adoptGRef(gst_caps_new_empty_simple("video/x-h264")); >+ if (areInputCapsAccepted(m_videoDecoderFactories, WTFMove(unconstrainedCaps))) >+ return true; >+ >+ return false; >+} >+ > GStreamerRegistryScanner::RegistryLookupResult GStreamerRegistryScanner::isDecodingSupported(MediaConfiguration& configuration) const > { > bool isSupported = false; >diff --git a/Source/WebCore/platform/graphics/gstreamer/GStreamerRegistryScanner.h b/Source/WebCore/platform/graphics/gstreamer/GStreamerRegistryScanner.h >index 3810592279aadd2d2ad8ca1381f32bb7c7915554..8725ed0dc342ecdb7c96b2222902393313b00497 100644 >--- a/Source/WebCore/platform/graphics/gstreamer/GStreamerRegistryScanner.h >+++ b/Source/WebCore/platform/graphics/gstreamer/GStreamerRegistryScanner.h >@@ -21,6 +21,7 @@ > > #if USE(GSTREAMER) > >+#include "GRefPtrGStreamer.h" > #include "MediaConfiguration.h" > > #include <wtf/Forward.h> >@@ -53,6 +54,9 @@ public: > bool isCodecSupported(String codec, bool usingHardware = false) const; > bool areAllCodecsSupported(const Vector<String>& codecs, bool shouldCheckForHardwareUse = false) const; > >+ bool areInputCapsAccepted(GList* factories, GRefPtr<GstCaps>&&) const; >+ bool isAVC1CodecSupported(String& codec) const; >+ > protected: > GStreamerRegistryScanner(bool isMediaSource = false); > ~GStreamerRegistryScanner();
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 198569
:
371416
|
371492
|
371493