Title: [288239] trunk/Source
Revision
288239
Author
[email protected]
Date
2022-01-19 13:35:02 -0800 (Wed, 19 Jan 2022)

Log Message

Do not use pas utils outside of libpas
https://bugs.webkit.org/show_bug.cgi?id=235275

Reviewed by Darin Adler.

Source/WebCore:

We should not use any utility functions from libpas outside of bmalloc.
libpas is designed to be self-contained and used outside of WebKit.
We cannot rely on non PAS_API functions.

If we need these utilities, we should define it in WTF.

* platform/graphics/HEVCUtilities.cpp:
(WebCore::parseHEVCCodecParameters):
(WebCore::createHEVCCodecParametersString):
(WebCore::reverseBits): Deleted.

Source/WTF:

* wtf/MathExtras.h:
(WTF::reverseBits32):
(WTF::reverseBits64):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (288238 => 288239)


--- trunk/Source/WTF/ChangeLog	2022-01-19 21:30:04 UTC (rev 288238)
+++ trunk/Source/WTF/ChangeLog	2022-01-19 21:35:02 UTC (rev 288239)
@@ -1,3 +1,14 @@
+2022-01-19  Yusuke Suzuki  <[email protected]>
+
+        Do not use pas utils outside of libpas
+        https://bugs.webkit.org/show_bug.cgi?id=235275
+
+        Reviewed by Darin Adler.
+
+        * wtf/MathExtras.h:
+        (WTF::reverseBits32):
+        (WTF::reverseBits64):
+
 2022-01-19  Alex Christensen  <[email protected]>
 
         Allow experimental feature names to be hidden in WebKitAdditions

Modified: trunk/Source/WTF/wtf/MathExtras.h (288238 => 288239)


--- trunk/Source/WTF/wtf/MathExtras.h	2022-01-19 21:30:04 UTC (rev 288238)
+++ trunk/Source/WTF/wtf/MathExtras.h	2022-01-19 21:35:02 UTC (rev 288239)
@@ -753,6 +753,23 @@
     return Mod67Position[((1 + ~v) & v) % 67];
 }
 
+inline uint32_t reverseBits32(uint32_t value)
+{
+#if COMPILER(GCC_COMPATIBLE) && CPU(ARM64)
+    uint32_t result;
+    asm ("rbit %w0, %w1"
+        : "=r"(result)
+        : "r"(value));
+    return result;
+#else
+    value = ((value & 0xaaaaaaaa) >> 1) | ((value & 0x55555555) << 1);
+    value = ((value & 0xcccccccc) >> 2) | ((value & 0x33333333) << 2);
+    value = ((value & 0xf0f0f0f0) >> 4) | ((value & 0x0f0f0f0f) << 4);
+    value = ((value & 0xff00ff00) >> 8) | ((value & 0x00ff00ff) << 8);
+    return (value >> 16) | (value << 16);
+#endif
+}
+
 } // namespace WTF
 
 using WTF::shuffleVector;
@@ -760,3 +777,4 @@
 using WTF::ctz;
 using WTF::getLSBSet;
 using WTF::getMSBSet;
+using WTF::reverseBits32;

Modified: trunk/Source/WebCore/ChangeLog (288238 => 288239)


--- trunk/Source/WebCore/ChangeLog	2022-01-19 21:30:04 UTC (rev 288238)
+++ trunk/Source/WebCore/ChangeLog	2022-01-19 21:35:02 UTC (rev 288239)
@@ -1,3 +1,21 @@
+2022-01-19  Yusuke Suzuki  <[email protected]>
+
+        Do not use pas utils outside of libpas
+        https://bugs.webkit.org/show_bug.cgi?id=235275
+
+        Reviewed by Darin Adler.
+
+        We should not use any utility functions from libpas outside of bmalloc.
+        libpas is designed to be self-contained and used outside of WebKit.
+        We cannot rely on non PAS_API functions.
+
+        If we need these utilities, we should define it in WTF.
+
+        * platform/graphics/HEVCUtilities.cpp:
+        (WebCore::parseHEVCCodecParameters):
+        (WebCore::createHEVCCodecParametersString):
+        (WebCore::reverseBits): Deleted.
+
 2022-01-19  Tim Nguyen  <[email protected]>
 
         Add visibility: visible to modal dialogs in UA sheet

Modified: trunk/Source/WebCore/platform/graphics/HEVCUtilities.cpp (288238 => 288239)


--- trunk/Source/WebCore/platform/graphics/HEVCUtilities.cpp	2022-01-19 21:30:04 UTC (rev 288238)
+++ trunk/Source/WebCore/platform/graphics/HEVCUtilities.cpp	2022-01-19 21:35:02 UTC (rev 288239)
@@ -30,30 +30,13 @@
 #include "SharedBuffer.h"
 #include <_javascript_Core/DataView.h>
 #include <wtf/HexNumber.h>
+#include <wtf/MathExtras.h>
 #include <wtf/NeverDestroyed.h>
 #include <wtf/SortedArrayMap.h>
 #include <wtf/text/StringToIntegerConversion.h>
 
-#if __has_include(<bmalloc/pas_utils.h>)
-#include <bmalloc/pas_utils.h>
-#endif
-
 namespace WebCore {
 
-static inline uint32_t reverseBits(uint32_t value)
-{
-#if __has_include(<bmalloc/pas_utils.h>)
-    return pas_reverse(value);
-#else
-    // From pas_reverse():
-    value = ((value & 0xaaaaaaaa) >> 1) | ((value & 0x55555555) << 1);
-    value = ((value & 0xcccccccc) >> 2) | ((value & 0x33333333) << 2);
-    value = ((value & 0xf0f0f0f0) >> 4) | ((value & 0x0f0f0f0f) << 4);
-    value = ((value & 0xff00ff00) >> 8) | ((value & 0x00ff00ff) << 8);
-    return (value >> 16) | (value << 16);
-#endif
-}
-
 std::optional<AVCParameters> parseAVCCodecParameters(StringView codecString)
 {
     // The format of the 'avc1' codec string is specified in ISO/IEC 14496-15:2014, Annex E2.
@@ -185,7 +168,7 @@
     auto compatibilityFlags = parseInteger<uint32_t>(*nextElement, 16);
     if (!compatibilityFlags)
         return std::nullopt;
-    parameters.generalProfileCompatibilityFlags = reverseBits(*compatibilityFlags);
+    parameters.generalProfileCompatibilityFlags = reverseBits32(*compatibilityFlags);
 
     if (++nextElement == codecSplit.end())
         return std::nullopt;
@@ -231,7 +214,7 @@
     // general_profile_compatibility_flag[ 31 ] as the most significant bit, followed by, general_profile_compatibility_flag[ 30 ],
     // and down to general_profile_compatibility_flag[ 0 ] as the least significant bit, where general_profile_compatibility_flag[ i ]
     // for i in the range of 0 to 31, inclusive, are specified in ISO/IEC 23008‐2, encoded in hexadecimal (leading zeroes may be omitted)
-    auto compatFlagParameter = hex(reverseBits(parameters.generalProfileCompatibilityFlags));
+    auto compatFlagParameter = hex(reverseBits32(parameters.generalProfileCompatibilityFlags));
 
     // * each of the 6 bytes of the constraint flags, starting from the byte containing the
     // general_progressive_source_flag, each encoded as a hexadecimal number, and the encoding
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to