summaryrefslogtreecommitdiff
path: root/vp8
diff options
context:
space:
mode:
authorJohann Koenig <johannkoenig@google.com>2021-11-18 07:13:09 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2021-11-18 07:13:09 +0000
commit6627a7c35b53e676fe89da0ea22b47b125342e98 (patch)
tree1dd63279b10fd174c5e47857fbb08f4cb87bf86a /vp8
parent52cfa1ca3546eec937bb4aa9d5fb157c58b907ad (diff)
parent87ce2bc3e3266e670e0da71d7915c3c40e948c15 (diff)
downloadlibvpx-6627a7c35b53e676fe89da0ea22b47b125342e98.tar.gz
Merge "replaced bsr() with get_msb() from bitops.h" into main
Diffstat (limited to 'vp8')
-rw-r--r--vp8/encoder/x86/vp8_quantize_ssse3.c33
1 files changed, 6 insertions, 27 deletions
diff --git a/vp8/encoder/x86/vp8_quantize_ssse3.c b/vp8/encoder/x86/vp8_quantize_ssse3.c
index 147c30cc3..f6df146f0 100644
--- a/vp8/encoder/x86/vp8_quantize_ssse3.c
+++ b/vp8/encoder/x86/vp8_quantize_ssse3.c
@@ -12,31 +12,7 @@
#include "./vp8_rtcd.h"
#include "vp8/encoder/block.h"
-
-/* bitscan reverse (bsr) */
-#if defined(_MSC_VER)
-#include <intrin.h>
-#pragma intrinsic(_BitScanReverse)
-static int bsr(int mask) {
- unsigned long eob;
- _BitScanReverse(&eob, mask);
- eob++;
- if (mask == 0) eob = 0;
- return eob;
-}
-#else
-static int bsr(int mask) {
- int eob;
-#if defined(__GNUC__) && __GNUC__
- __asm__ __volatile__("bsr %1, %0" : "=r"(eob) : "r"(mask) : "flags");
-#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
- asm volatile("bsr %1, %0" : "=r"(eob) : "r"(mask) : "flags");
-#endif
- eob++;
- if (mask == 0) eob = 0;
- return eob;
-}
-#endif
+#include "vpx_ports/bitops.h" /* get_msb */
void vp8_fast_quantize_b_ssse3(BLOCK *b, BLOCKD *d) {
int eob, mask;
@@ -108,7 +84,10 @@ void vp8_fast_quantize_b_ssse3(BLOCK *b, BLOCKD *d) {
mask = _mm_movemask_epi8(x);
- eob = bsr(mask);
+ /* x2 is needed to increase the result from non-zero masks by 1,
+ * +1 is needed to mask undefined behavior for a null argument,
+ * the result of get_msb(1) is 0 */
+ eob = get_msb(mask * 2 + 1);
- *d->eob = 0xFF & eob;
+ *d->eob = eob;
}