[libvpx] Update to v1.12.0

This commit is contained in:
Andrey Volk committed 2026-07-10 19:38:46 +03:00
1 parent 287a71dc66
commit b5046d2a76
572 files changed
+52900 -29493

No files matched your search

@@ -14,7 +14,7 @@
SECTION .text
;int vp8_block_error_sse2(short *coeff_ptr, short *dcoef_ptr)
global sym(vp8_block_error_sse2) PRIVATE
globalsym(vp8_block_error_sse2)
sym(vp8_block_error_sse2):
push rbp
mov rbp, rsp
@@ -62,7 +62,7 @@ sym(vp8_block_error_sse2):
ret
;int vp8_mbblock_error_sse2_impl(short *coeff_ptr, short *dcoef_ptr, int dc);
global sym(vp8_mbblock_error_sse2_impl) PRIVATE
globalsym(vp8_mbblock_error_sse2_impl)
sym(vp8_mbblock_error_sse2_impl):
push rbp
mov rbp, rsp
@@ -132,7 +132,7 @@ sym(vp8_mbblock_error_sse2_impl):
;int vp8_mbuverror_sse2_impl(short *s_ptr, short *d_ptr);
global sym(vp8_mbuverror_sse2_impl) PRIVATE
globalsym(vp8_mbuverror_sse2_impl)
sym(vp8_mbuverror_sse2_impl):
push rbp
mov rbp, rsp
+1 -1
View File
@@ -19,7 +19,7 @@ SECTION .text
; unsigned char *dst_ptr,
; int dst_stride,
; int height);
global sym(vp8_copy32xn_sse2) PRIVATE
globalsym(vp8_copy32xn_sse2)
sym(vp8_copy32xn_sse2):
push rbp
mov rbp, rsp
+1 -1
View File
@@ -91,7 +91,7 @@ SECTION .text
; unsigned char *dst_ptr,
; int dst_stride,
; int height);
global sym(vp8_copy32xn_sse3) PRIVATE
globalsym(vp8_copy32xn_sse3)
sym(vp8_copy32xn_sse3):
STACK_FRAME_CREATE_X3
+2 -2
View File
@@ -63,7 +63,7 @@
SECTION .text
;void vp8_short_fdct4x4_sse2(short *input, short *output, int pitch)
global sym(vp8_short_fdct4x4_sse2) PRIVATE
globalsym(vp8_short_fdct4x4_sse2)
sym(vp8_short_fdct4x4_sse2):
STACK_FRAME_CREATE
@@ -168,7 +168,7 @@ sym(vp8_short_fdct4x4_sse2):
STACK_FRAME_DESTROY
;void vp8_short_fdct8x4_sse2(short *input, short *output, int pitch)
global sym(vp8_short_fdct8x4_sse2) PRIVATE
globalsym(vp8_short_fdct8x4_sse2)
sym(vp8_short_fdct8x4_sse2):
STACK_FRAME_CREATE
+1 -1
View File
@@ -14,7 +14,7 @@
SECTION .text
;void vp8_short_walsh4x4_sse2(short *input, short *output, int pitch)
global sym(vp8_short_walsh4x4_sse2) PRIVATE
globalsym(vp8_short_walsh4x4_sse2)
sym(vp8_short_walsh4x4_sse2):
push rbp
mov rbp, rsp
+57 -38
View File
@@ -11,28 +11,14 @@
#include <smmintrin.h> /* SSE4.1 */
#include "./vp8_rtcd.h"
#include "vp8/common/entropy.h" /* vp8_default_inv_zig_zag */
#include "vp8/encoder/block.h"
#define SELECT_EOB(i, z, x, y, q) \
do { \
short boost = *zbin_boost_ptr; \
/* Technically _mm_extract_epi16() returns an int: */ \
/* https://bugs.llvm.org/show_bug.cgi?id=41657 */ \
short x_z = (short)_mm_extract_epi16(x, z); \
short y_z = (short)_mm_extract_epi16(y, z); \
int cmp = (x_z < boost) | (y_z == 0); \
zbin_boost_ptr++; \
if (cmp) break; \
q = _mm_insert_epi16(q, y_z, z); \
eob = i; \
zbin_boost_ptr = b->zrun_zbin_boost; \
} while (0)
#include "vpx_ports/bitops.h" /* get_lsb */
void vp8_regular_quantize_b_sse4_1(BLOCK *b, BLOCKD *d) {
char eob = 0;
int eob = -1;
short *zbin_boost_ptr = b->zrun_zbin_boost;
__m128i zbin_boost0 = _mm_load_si128((__m128i *)(zbin_boost_ptr));
__m128i zbin_boost1 = _mm_load_si128((__m128i *)(zbin_boost_ptr + 8));
__m128i x0, x1, y0, y1, x_minus_zbin0, x_minus_zbin1, dqcoeff0, dqcoeff1;
__m128i quant_shift0 = _mm_load_si128((__m128i *)(b->quant_shift));
__m128i quant_shift1 = _mm_load_si128((__m128i *)(b->quant_shift + 8));
@@ -47,8 +33,12 @@ void vp8_regular_quantize_b_sse4_1(BLOCK *b, BLOCKD *d) {
__m128i quant1 = _mm_load_si128((__m128i *)(b->quant + 8));
__m128i dequant0 = _mm_load_si128((__m128i *)(d->dequant));
__m128i dequant1 = _mm_load_si128((__m128i *)(d->dequant + 8));
__m128i qcoeff0 = _mm_setzero_si128();
__m128i qcoeff1 = _mm_setzero_si128();
__m128i qcoeff0, qcoeff1, t0, t1, x_shuf0, x_shuf1;
uint32_t mask, ymask;
DECLARE_ALIGNED(16, static const uint8_t,
zig_zag_mask[16]) = { 0, 1, 4, 8, 5, 2, 3, 6,
9, 12, 13, 10, 7, 11, 14, 15 };
DECLARE_ALIGNED(16, uint16_t, qcoeff[16]) = { 0 };
/* Duplicate to all lanes. */
zbin_extra = _mm_shufflelo_epi16(zbin_extra, 0);
@@ -88,23 +78,52 @@ void vp8_regular_quantize_b_sse4_1(BLOCK *b, BLOCKD *d) {
y0 = _mm_sign_epi16(y0, z0);
y1 = _mm_sign_epi16(y1, z1);
/* The loop gets unrolled anyway. Avoid the vp8_default_zig_zag1d lookup. */
SELECT_EOB(1, 0, x_minus_zbin0, y0, qcoeff0);
SELECT_EOB(2, 1, x_minus_zbin0, y0, qcoeff0);
SELECT_EOB(3, 4, x_minus_zbin0, y0, qcoeff0);
SELECT_EOB(4, 0, x_minus_zbin1, y1, qcoeff1);
SELECT_EOB(5, 5, x_minus_zbin0, y0, qcoeff0);
SELECT_EOB(6, 2, x_minus_zbin0, y0, qcoeff0);
SELECT_EOB(7, 3, x_minus_zbin0, y0, qcoeff0);
SELECT_EOB(8, 6, x_minus_zbin0, y0, qcoeff0);
SELECT_EOB(9, 1, x_minus_zbin1, y1, qcoeff1);
SELECT_EOB(10, 4, x_minus_zbin1, y1, qcoeff1);
SELECT_EOB(11, 5, x_minus_zbin1, y1, qcoeff1);
SELECT_EOB(12, 2, x_minus_zbin1, y1, qcoeff1);
SELECT_EOB(13, 7, x_minus_zbin0, y0, qcoeff0);
SELECT_EOB(14, 3, x_minus_zbin1, y1, qcoeff1);
SELECT_EOB(15, 6, x_minus_zbin1, y1, qcoeff1);
SELECT_EOB(16, 7, x_minus_zbin1, y1, qcoeff1);
{
const __m128i zig_zag_i16_0 =
_mm_setr_epi8(0, 1, 2, 3, 8, 9, 14, 15, 10, 11, 4, 5, 6, 7, 12, 13);
const __m128i zig_zag_i16_1 =
_mm_setr_epi8(0, 1, 6, 7, 8, 9, 2, 3, 14, 15, 4, 5, 10, 11, 12, 13);
/* The first part of the zig zag needs a value
* from x_minus_zbin1 and vice versa. */
t1 = _mm_alignr_epi8(x_minus_zbin1, x_minus_zbin1, 2);
t0 = _mm_blend_epi16(x_minus_zbin0, t1, 0x80);
t1 = _mm_blend_epi16(t1, x_minus_zbin0, 0x80);
x_shuf0 = _mm_shuffle_epi8(t0, zig_zag_i16_0);
x_shuf1 = _mm_shuffle_epi8(t1, zig_zag_i16_1);
}
/* Check if y is nonzero and put it in zig zag order. */
t0 = _mm_packs_epi16(y0, y1);
t0 = _mm_cmpeq_epi8(t0, _mm_setzero_si128());
t0 = _mm_shuffle_epi8(t0, _mm_load_si128((const __m128i *)zig_zag_mask));
ymask = _mm_movemask_epi8(t0) ^ 0xffff;
for (;;) {
t0 = _mm_cmpgt_epi16(zbin_boost0, x_shuf0);
t1 = _mm_cmpgt_epi16(zbin_boost1, x_shuf1);
t0 = _mm_packs_epi16(t0, t1);
mask = _mm_movemask_epi8(t0);
mask = ~mask & ymask;
if (!mask) break;
/* |eob| will contain the index of the next found element where:
* boost[i - old_eob - 1] <= x[zigzag[i]] && y[zigzag[i]] != 0 */
eob = get_lsb(mask);
/* Need to clear the mask from processed elements so that
* they are no longer counted in the next iteration. */
ymask &= ~1U << eob;
/* It's safe to read ahead of this buffer if struct VP8_COMP has at
* least 32 bytes before the zrun_zbin_boost_* fields (it has 384).
* Any data read outside of the buffer is masked by the updated |ymask|. */
zbin_boost0 = _mm_loadu_si128((__m128i *)(zbin_boost_ptr - eob - 1));
zbin_boost1 = _mm_loadu_si128((__m128i *)(zbin_boost_ptr - eob + 7));
qcoeff[zig_zag_mask[eob]] = 0xffff;
}
qcoeff0 = _mm_load_si128((__m128i *)(qcoeff));
qcoeff1 = _mm_load_si128((__m128i *)(qcoeff + 8));
qcoeff0 = _mm_and_si128(qcoeff0, y0);
qcoeff1 = _mm_and_si128(qcoeff1, y1);
_mm_store_si128((__m128i *)(d->qcoeff), qcoeff0);
_mm_store_si128((__m128i *)(d->qcoeff + 8), qcoeff1);
@@ -115,5 +134,5 @@ void vp8_regular_quantize_b_sse4_1(BLOCK *b, BLOCKD *d) {
_mm_store_si128((__m128i *)(d->dqcoeff), dqcoeff0);
_mm_store_si128((__m128i *)(d->dqcoeff + 8), dqcoeff1);
*d->eob = eob;
*d->eob = eob + 1;
}
@@ -22,7 +22,7 @@ SECTION .text
; int filter_weight, | 5
; unsigned int *accumulator, | 6
; unsigned short *count) | 7
global sym(vp8_temporal_filter_apply_sse2) PRIVATE
globalsym(vp8_temporal_filter_apply_sse2)
sym(vp8_temporal_filter_apply_sse2):
push rbp
@@ -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;
}