WebKit Bugzilla
Attachment 371493 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-20190606143658.patch (text/plain), 7.38 KB, created by
Philippe Normand
on 2019-06-06 06:36:59 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Philippe Normand
Created:
2019-06-06 06:36:59 PDT
Size:
7.38 KB
patch
obsolete
>Subversion Revision: 246150 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 3f26b0dc77ef72c420d3a6144ca65bd57e045c7b..383493348303a4e2bf1c32e348585a9b35c15463 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 advertised 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 Takashi Komori <Takashi.Komori@sony.com> > > [Curl] Report all request headers to web inspector. >diff --git a/Source/WebCore/platform/graphics/gstreamer/GStreamerRegistryScanner.cpp b/Source/WebCore/platform/graphics/gstreamer/GStreamerRegistryScanner.cpp >index 8802188289ed92cb8d05f37994fcb462bcc6bc78..693f94aedc06a45294401600bd0f15fe1243a3f1 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 { >@@ -66,7 +67,7 @@ GStreamerRegistryScanner::~GStreamerRegistryScanner() > gst_plugin_feature_list_free(m_demuxerFactories); > } > >-GStreamerRegistryScanner::RegistryLookupResult GStreamerRegistryScanner::hasElementForMediaType(GList* elementFactories, const char* capsString, bool shouldCheckHardwareClassifier) >+GStreamerRegistryScanner::RegistryLookupResult GStreamerRegistryScanner::hasElementForMediaType(GList* elementFactories, const char* capsString, bool shouldCheckHardwareClassifier) const > { > GRefPtr<GstCaps> caps = adoptGRef(gst_caps_from_string(capsString)); > GList* candidates = gst_element_factory_list_filter(elementFactories, caps.get(), GST_PAD_SINK, false); >@@ -280,11 +281,15 @@ 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, shouldCheckForHardwareUse); >+ 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; >+ } > } > } > >@@ -302,6 +307,64 @@ bool GStreamerRegistryScanner::areAllCodecsSupported(const Vector<String>& codec > return true; > } > >+bool GStreamerRegistryScanner::isAVC1CodecSupported(const String& codec, bool shouldCheckForHardwareUse) const >+{ >+ auto components = codec.split('.'); >+ long int spsAsInteger = strtol(components[1].utf8().data(), nullptr, 16); >+ uint8_t sps[3]; >+ sps[0] = spsAsInteger >> 16; >+ sps[1] = spsAsInteger >> 8; >+ sps[2] = spsAsInteger; >+ >+ const char* profile = gst_codec_utils_h264_get_profile(sps, 3); >+ const char* 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); >+ >+#define CHECK_H264_CAPS(capsString) do { \ >+ bool supported = false; \ >+ auto lookupResult = hasElementForMediaType(m_videoDecoderFactories, capsString, true); \ >+ supported = lookupResult; \ >+ if (shouldCheckForHardwareUse) \ >+ supported = lookupResult.isUsingHardware; \ >+ GST_DEBUG("%s decoding supported for codec %s: %s", shouldCheckForHardwareUse ? "Hardware" : "Software", codec.utf8().data(), boolForPrinting(supported)); \ >+ return supported; \ >+} while (0) >+ >+ if (const char* maxVideoResolution = g_getenv("WEBKIT_GST_MAX_AVC1_RESOLUTION")) { >+ uint8_t levelAsInteger = gst_codec_utils_h264_get_level_idc(level); >+ GST_DEBUG("Maximum video resolution requested: %s, supplied codec level IDC: %u", maxVideoResolution, levelAsInteger); >+ uint8_t maxLevel = 0; >+ const char* maxLevelString = ""; >+ if (!g_strcmp0(maxVideoResolution, "1080P")) { >+ maxLevel = 40; >+ maxLevelString = "4"; >+ } else if (!g_strcmp0(maxVideoResolution, "720P")) { >+ maxLevel = 31; >+ maxLevelString = "3.1"; >+ } else if (!g_strcmp0(maxVideoResolution, "480P")) { >+ maxLevel = 30; >+ maxLevelString = "3"; >+ } else { >+ g_warning("Invalid value for WEBKIT_GST_MAX_AVC1_RESOLUTION. Currently supported, 1080P, 720P and 480P."); >+ return false; >+ } >+ if (levelAsInteger > maxLevel) >+ return false; >+ CHECK_H264_CAPS(makeString("video/x-h264, level=(string)", maxLevelString).utf8().data()); >+ } >+ >+ if (webkitGstCheckVersion(1, 17, 0)) { >+ GST_DEBUG("Checking video decoders for constrained caps"); >+ CHECK_H264_CAPS(makeString("video/x-h264, level=(string)", level, ", profile=(string)", profile).utf8().data()); >+ } >+ >+ GST_DEBUG("Falling back to unconstrained caps"); >+ CHECK_H264_CAPS("video/x-h264"); >+ return false; >+ >+#undef CHECK_H264_CAPS >+} >+ > 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..ee84df5ff295596929b346cb076999c98cef3e01 100644 >--- a/Source/WebCore/platform/graphics/gstreamer/GStreamerRegistryScanner.h >+++ b/Source/WebCore/platform/graphics/gstreamer/GStreamerRegistryScanner.h >@@ -72,7 +72,9 @@ protected: > }; > void fillMimeTypeSetFromCapsMapping(Vector<GstCapsWebKitMapping>&); > >- RegistryLookupResult hasElementForMediaType(GList* elementFactories, const char* capsString, bool shouldCheckHardwareClassifier = false); >+ RegistryLookupResult hasElementForMediaType(GList* elementFactories, const char* capsString, bool shouldCheckHardwareClassifier = false) const; >+ >+ bool isAVC1CodecSupported(const String& codec, bool shouldCheckForHardwareUse) const; > > private: > bool m_isMediaSource;
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
Flags:
calvaris
:
review+
calvaris
:
commit-queue-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 198569
:
371416
|
371492
| 371493