[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

+161
View File
@@ -0,0 +1,161 @@
/*
* Copyright (c) 2022 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include <stdint.h>
#include "./vp8_rtcd.h"
#include "vpx_util/loongson_intrinsics.h"
#define LSX_TRANSPOSE4x4_H(_in0, _in1, _in2, _in3, _out0, _out1, _out2, _out3) \
{ \
__m128i _s0, _s1, _s2, _s3, _t0, _t1, _t2, _t3; \
\
DUP2_ARG2(__lsx_vilvl_h, _in2, _in0, _in3, _in1, _s0, _s1); \
DUP2_ARG2(__lsx_vilvh_h, _in2, _in0, _in3, _in1, _s2, _s3); \
_t0 = __lsx_vilvl_h(_s1, _s0); \
_t1 = __lsx_vilvh_h(_s1, _s0); \
_t2 = __lsx_vilvl_h(_s3, _s2); \
_t3 = __lsx_vilvh_h(_s3, _s2); \
DUP2_ARG2(__lsx_vpickev_d, _t2, _t0, _t3, _t1, _out0, _out2); \
DUP2_ARG2(__lsx_vpickod_d, _t2, _t0, _t3, _t1, _out1, _out3); \
}
#define SET_DOTP_VALUES(coeff, val0, val1, val2, const1, const2) \
{ \
__m128i tmp0_m, tmp1_m, tmp2_m; \
\
tmp0_m = __lsx_vreplvei_h(coeff, val0); \
DUP2_ARG2(__lsx_vreplvei_h, coeff, val1, coeff, val2, tmp1_m, tmp2_m); \
DUP2_ARG2(__lsx_vpackev_h, tmp1_m, tmp0_m, tmp0_m, tmp2_m, const1, \
const2); \
}
#define RET_1_IF_NZERO_H(_in) \
({ \
__m128i tmp_m; \
__m128i one_m = __lsx_vldi(0x401); \
__m128i max_m = __lsx_vldi(0xFF); \
\
tmp_m = __lsx_vseqi_h(_in, 0); \
tmp_m = __lsx_vxor_v(tmp_m, max_m); \
tmp_m = __lsx_vand_v(tmp_m, one_m); \
\
tmp_m; \
})
void vp8_short_fdct4x4_lsx(int16_t *input, int16_t *output, int32_t pitch) {
__m128i in0, in1, in2, in3;
__m128i tmp0, tmp1, tmp2, tmp3, const0, const1;
__m128i coeff = { 0x38a4eb1814e808a9, 0x659061a82ee01d4c };
__m128i out0, out1, out2, out3;
__m128i zero = __lsx_vldi(0);
int32_t pitch2 = pitch << 1;
int32_t pitch3 = pitch2 + pitch;
in0 = __lsx_vld(input, 0);
DUP2_ARG2(__lsx_vldx, input, pitch, input, pitch2, in1, in2);
in3 = __lsx_vldx(input, pitch3);
LSX_TRANSPOSE4x4_H(in0, in1, in2, in3, in0, in1, in2, in3);
LSX_BUTTERFLY_4_H(in0, in1, in2, in3, tmp0, tmp1, in1, in3);
DUP4_ARG2(__lsx_vslli_h, tmp0, 3, tmp1, 3, in1, 3, in3, 3, tmp0, tmp1, in1,
in3);
in0 = __lsx_vadd_h(tmp0, tmp1);
in2 = __lsx_vsub_h(tmp0, tmp1);
SET_DOTP_VALUES(coeff, 0, 1, 2, const0, const1);
tmp0 = __lsx_vilvl_h(in3, in1);
in1 = __lsx_vreplvei_h(coeff, 3);
out0 = __lsx_vpackev_h(zero, in1);
coeff = __lsx_vilvl_h(zero, coeff);
out1 = __lsx_vreplvei_w(coeff, 0);
DUP2_ARG3(__lsx_vdp2add_w_h, out0, tmp0, const0, out1, tmp0, const1, out0,
out1);
DUP2_ARG3(__lsx_vsrani_h_w, out0, out0, 12, out1, out1, 12, in1, in3);
LSX_TRANSPOSE4x4_H(in0, in1, in2, in3, in0, in1, in2, in3);
LSX_BUTTERFLY_4_H(in0, in1, in2, in3, tmp0, tmp1, in1, in3);
tmp2 = __lsx_vadd_h(tmp0, tmp1);
tmp3 = __lsx_vsub_h(tmp0, tmp1);
DUP2_ARG2(__lsx_vaddi_hu, tmp2, 7, tmp3, 7, in0, in2);
DUP2_ARG2(__lsx_vsrai_h, in0, 4, in2, 4, in0, in2);
DUP2_ARG2(__lsx_vilvl_h, zero, in0, zero, in2, out0, out2);
tmp1 = RET_1_IF_NZERO_H(in3);
DUP2_ARG2(__lsx_vilvl_h, zero, tmp1, in3, in1, tmp1, tmp0);
DUP2_ARG2(__lsx_vreplvei_w, coeff, 2, coeff, 3, out3, out1);
out3 = __lsx_vadd_w(out3, out1);
out1 = __lsx_vreplvei_w(coeff, 1);
DUP2_ARG3(__lsx_vdp2add_w_h, out1, tmp0, const0, out3, tmp0, const1, out1,
out3);
DUP2_ARG2(__lsx_vsrai_w, out1, 16, out3, 16, out1, out3);
out1 = __lsx_vadd_w(out1, tmp1);
DUP2_ARG2(__lsx_vpickev_h, out1, out0, out3, out2, in0, in2);
__lsx_vst(in0, output, 0);
__lsx_vst(in2, output, 16);
}
void vp8_short_fdct8x4_lsx(int16_t *input, int16_t *output, int32_t pitch) {
__m128i in0, in1, in2, in3, temp0, temp1, tmp0, tmp1;
__m128i const0, const1, const2, vec0_w, vec1_w, vec2_w, vec3_w;
__m128i coeff = { 0x38a4eb1814e808a9, 0x659061a82ee01d4c };
__m128i zero = __lsx_vldi(0);
int32_t pitch2 = pitch << 1;
int32_t pitch3 = pitch2 + pitch;
in0 = __lsx_vld(input, 0);
DUP2_ARG2(__lsx_vldx, input, pitch, input, pitch2, in1, in2);
in3 = __lsx_vldx(input, pitch3);
LSX_TRANSPOSE4x4_H(in0, in1, in2, in3, in0, in1, in2, in3);
LSX_BUTTERFLY_4_H(in0, in1, in2, in3, temp0, temp1, in1, in3);
DUP4_ARG2(__lsx_vslli_h, temp0, 3, temp1, 3, in1, 3, in3, 3, temp0, temp1,
in1, in3);
in0 = __lsx_vadd_h(temp0, temp1);
in2 = __lsx_vsub_h(temp0, temp1);
SET_DOTP_VALUES(coeff, 0, 1, 2, const1, const2);
temp0 = __lsx_vreplvei_h(coeff, 3);
vec1_w = __lsx_vpackev_h(zero, temp0);
coeff = __lsx_vilvh_h(zero, coeff);
vec3_w = __lsx_vreplvei_w(coeff, 0);
tmp1 = __lsx_vilvl_h(in3, in1);
tmp0 = __lsx_vilvh_h(in3, in1);
vec0_w = vec1_w;
vec2_w = vec3_w;
DUP4_ARG3(__lsx_vdp2add_w_h, vec0_w, tmp1, const1, vec1_w, tmp0, const1,
vec2_w, tmp1, const2, vec3_w, tmp0, const2, vec0_w, vec1_w, vec2_w,
vec3_w);
DUP2_ARG3(__lsx_vsrani_h_w, vec1_w, vec0_w, 12, vec3_w, vec2_w, 12, in1, in3);
LSX_TRANSPOSE4x4_H(in0, in1, in2, in3, in0, in1, in2, in3);
LSX_BUTTERFLY_4_H(in0, in1, in2, in3, temp0, temp1, in1, in3);
in0 = __lsx_vadd_h(temp0, temp1);
in0 = __lsx_vaddi_hu(in0, 7);
in2 = __lsx_vsub_h(temp0, temp1);
in2 = __lsx_vaddi_hu(in2, 7);
in0 = __lsx_vsrai_h(in0, 4);
in2 = __lsx_vsrai_h(in2, 4);
DUP2_ARG2(__lsx_vreplvei_w, coeff, 2, coeff, 3, vec3_w, vec1_w);
vec3_w = __lsx_vadd_w(vec3_w, vec1_w);
vec1_w = __lsx_vreplvei_w(coeff, 1);
const0 = RET_1_IF_NZERO_H(in3);
tmp1 = __lsx_vilvl_h(in3, in1);
tmp0 = __lsx_vilvh_h(in3, in1);
vec0_w = vec1_w;
vec2_w = vec3_w;
DUP4_ARG3(__lsx_vdp2add_w_h, vec0_w, tmp1, const1, vec1_w, tmp0, const1,
vec2_w, tmp1, const2, vec3_w, tmp0, const2, vec0_w, vec1_w, vec2_w,
vec3_w);
DUP2_ARG3(__lsx_vsrani_h_w, vec1_w, vec0_w, 16, vec3_w, vec2_w, 16, in1, in3);
in1 = __lsx_vadd_h(in1, const0);
DUP2_ARG2(__lsx_vpickev_d, in1, in0, in3, in2, temp0, temp1);
__lsx_vst(temp0, output, 0);
__lsx_vst(temp1, output, 16);
DUP2_ARG2(__lsx_vpickod_d, in1, in0, in3, in2, in0, in2);
__lsx_vst(in0, output, 32);
__lsx_vst(in2, output, 48);
}
@@ -0,0 +1,82 @@
/*
* Copyright (c) 2022 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "./vp8_rtcd.h"
#include "vpx_util/loongson_intrinsics.h"
#include "vp8/encoder/block.h"
int32_t vp8_block_error_lsx(int16_t *coeff_ptr, int16_t *dq_coeff_ptr) {
int32_t err = 0;
__m128i dq_coeff0, dq_coeff1, coeff0, coeff1;
__m128i reg0, reg1, reg2, reg3, error;
DUP4_ARG2(__lsx_vld, coeff_ptr, 0, coeff_ptr, 16, dq_coeff_ptr, 0,
dq_coeff_ptr, 16, coeff0, coeff1, dq_coeff0, dq_coeff1);
DUP2_ARG2(__lsx_vsubwev_w_h, coeff0, dq_coeff0, coeff1, dq_coeff1, reg0,
reg2);
DUP2_ARG2(__lsx_vsubwod_w_h, coeff0, dq_coeff0, coeff1, dq_coeff1, reg1,
reg3);
error = __lsx_vmul_w(reg0, reg0);
DUP2_ARG3(__lsx_vmadd_w, error, reg1, reg1, error, reg2, reg2, error, error);
error = __lsx_vmadd_w(error, reg3, reg3);
error = __lsx_vhaddw_d_w(error, error);
err = __lsx_vpickve2gr_w(error, 0);
err += __lsx_vpickve2gr_w(error, 2);
return err;
}
int32_t vp8_mbblock_error_lsx(MACROBLOCK *mb, int32_t dc) {
BLOCK *be;
BLOCKD *bd;
int16_t *coeff, *dq_coeff;
int32_t err = 0;
uint32_t loop_cnt;
__m128i src0, src1, src2, src3;
__m128i tmp0, tmp1, tmp2, tmp3;
__m128i reg0, reg1, reg2, reg3, reg4, reg5, reg6, reg7, error;
__m128i mask0 = __lsx_vldi(0xFF);
__m128i zero = __lsx_vldi(0);
if (dc == 1) {
mask0 = __lsx_vinsgr2vr_w(mask0, 0, 0);
}
for (loop_cnt = 0; loop_cnt < 8; loop_cnt++) {
int32_t loop_tmp = loop_cnt << 1;
be = &mb->block[loop_tmp];
bd = &mb->e_mbd.block[loop_tmp];
coeff = be->coeff;
dq_coeff = bd->dqcoeff;
DUP4_ARG2(__lsx_vld, coeff, 0, coeff, 16, dq_coeff, 0, dq_coeff, 16, src0,
src1, tmp0, tmp1);
be = &mb->block[loop_tmp + 1];
bd = &mb->e_mbd.block[loop_tmp + 1];
coeff = be->coeff;
dq_coeff = bd->dqcoeff;
DUP4_ARG2(__lsx_vld, coeff, 0, coeff, 16, dq_coeff, 0, dq_coeff, 16, src2,
src3, tmp2, tmp3);
DUP4_ARG2(__lsx_vsubwev_w_h, src0, tmp0, src1, tmp1, src2, tmp2, src3, tmp3,
reg0, reg2, reg4, reg6);
DUP4_ARG2(__lsx_vsubwod_w_h, src0, tmp0, src1, tmp1, src2, tmp2, src3, tmp3,
reg1, reg3, reg5, reg7);
DUP2_ARG3(__lsx_vbitsel_v, zero, reg0, mask0, zero, reg4, mask0, reg0,
reg4);
error = __lsx_vmul_w(reg0, reg0);
DUP4_ARG3(__lsx_vmadd_w, error, reg1, reg1, error, reg2, reg2, error, reg3,
reg3, error, reg4, reg4, error, error, error, error);
DUP2_ARG3(__lsx_vmadd_w, error, reg5, reg5, error, reg6, reg6, error,
error);
error = __lsx_vmadd_w(error, reg7, reg7);
error = __lsx_vhaddw_d_w(error, error);
error = __lsx_vhaddw_q_d(error, error);
err += __lsx_vpickve2gr_w(error, 0);
}
return err;
}
@@ -0,0 +1,145 @@
/*
* Copyright (c) 2022 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include <stdint.h>
#include "./vp8_rtcd.h"
#include "vpx_util/loongson_intrinsics.h"
#include "vp8/encoder/block.h"
#define BOOST_QUANT1(_in0, _in1, _in2, _ui) \
{ \
if (boost_temp[0] <= __lsx_vpickve2gr_h(_in0, _ui)) { \
if (__lsx_vpickve2gr_h(_in1, _ui)) { \
eob = _ui; \
boost_temp = zbin_boost; \
} else { \
boost_temp++; \
} \
} else { \
_in2 = __lsx_vinsgr2vr_h(_in2, 0, _ui); \
boost_temp++; \
} \
}
#define BOOST_QUANT2(_in0, _in1, _in2, _ui) \
{ \
if (boost_temp[0] <= __lsx_vpickve2gr_h(_in0, _ui)) { \
if (__lsx_vpickve2gr_h(_in1, _ui)) { \
eob = _ui + 8; \
boost_temp = zbin_boost; \
} else { \
boost_temp++; \
} \
} else { \
_in2 = __lsx_vinsgr2vr_h(_in2, 0, _ui); \
boost_temp++; \
} \
}
static int8_t exact_regular_quantize_b_lsx(
int16_t *zbin_boost, int16_t *coeff_ptr, int16_t *zbin, int16_t *round,
int16_t *quant, int16_t *quant_shift, int16_t *de_quant, int16_t zbin_oq_in,
int16_t *q_coeff, int16_t *dq_coeff) {
int32_t eob;
int16_t *boost_temp = zbin_boost;
__m128i inv_zig_zag = { 0x0C07040206050100, 0x0F0E0A090D0B0803 };
__m128i sign_z0, sign_z1, q_coeff0, q_coeff1;
__m128i z_bin0, z_bin1, zbin_o_q, x0, x1, sign_x0, sign_x1, de_quant0,
de_quant1;
__m128i z0, z1, round0, round1, quant0, quant2;
__m128i inv_zig_zag0, inv_zig_zag1;
__m128i zigzag_mask0 = { 0x0008000400010000, 0x0006000300020005 };
__m128i zigzag_mask1 = { 0x000A000D000C0009, 0X000F000E000B0007 };
__m128i tmp0, tmp1, tmp2, tmp3;
__m128i zero = __lsx_vldi(0);
zbin_o_q = __lsx_vreplgr2vr_h(zbin_oq_in);
inv_zig_zag0 = __lsx_vilvl_b(zero, inv_zig_zag);
inv_zig_zag1 = __lsx_vilvh_b(zero, inv_zig_zag);
eob = -1;
DUP4_ARG2(__lsx_vld, coeff_ptr, 0, coeff_ptr, 16, round, 0, round, 16, tmp0,
tmp1, tmp2, tmp3);
DUP4_ARG3(__lsx_vshuf_h, zigzag_mask0, tmp1, tmp0, zigzag_mask1, tmp1, tmp0,
zigzag_mask0, tmp3, tmp2, zigzag_mask1, tmp3, tmp2, z0, z1, round0,
round1);
DUP4_ARG2(__lsx_vld, quant, 0, quant, 16, zbin, 0, zbin, 16, tmp0, tmp1, tmp2,
tmp3);
DUP4_ARG3(__lsx_vshuf_h, zigzag_mask0, tmp1, tmp0, zigzag_mask1, tmp1, tmp0,
zigzag_mask0, tmp3, tmp2, zigzag_mask1, tmp3, tmp2, quant0, quant2,
z_bin0, z_bin1);
DUP2_ARG2(__lsx_vsrai_h, z0, 15, z1, 15, sign_z0, sign_z1);
DUP2_ARG2(__lsx_vadda_h, z0, zero, z1, zero, x0, x1);
DUP2_ARG2(__lsx_vsub_h, x0, z_bin0, x1, z_bin1, z_bin0, z_bin1);
DUP2_ARG2(__lsx_vsub_h, z_bin0, zbin_o_q, z_bin1, zbin_o_q, z_bin0, z_bin1);
DUP2_ARG2(__lsx_vmulwev_w_h, quant0, round0, quant2, round1, tmp0, tmp2);
DUP2_ARG2(__lsx_vmulwod_w_h, quant0, round0, quant2, round1, tmp1, tmp3);
DUP2_ARG3(__lsx_vmaddwev_w_h, tmp0, quant0, x0, tmp2, quant2, x1, tmp0, tmp2);
DUP2_ARG3(__lsx_vmaddwod_w_h, tmp1, quant0, x0, tmp3, quant2, x1, tmp1, tmp3);
DUP2_ARG2(__lsx_vpackod_h, tmp1, tmp0, tmp3, tmp2, q_coeff0, q_coeff1);
DUP2_ARG2(__lsx_vld, quant_shift, 0, quant_shift, 16, tmp1, tmp3);
DUP2_ARG3(__lsx_vshuf_h, zigzag_mask0, tmp3, tmp1, zigzag_mask1, tmp3, tmp1,
quant0, quant2);
DUP2_ARG2(__lsx_vadd_h, x0, round0, x1, round1, x0, x1);
DUP2_ARG2(__lsx_vmulwev_w_h, quant0, q_coeff0, quant2, q_coeff1, tmp0, tmp2);
DUP2_ARG2(__lsx_vmulwod_w_h, quant0, q_coeff0, quant2, q_coeff1, tmp1, tmp3);
DUP2_ARG3(__lsx_vmaddwev_w_h, tmp0, quant0, x0, tmp2, quant2, x1, tmp0, tmp2);
DUP2_ARG3(__lsx_vmaddwod_w_h, tmp1, quant0, x0, tmp3, quant2, x1, tmp1, tmp3);
DUP2_ARG2(__lsx_vpackod_h, tmp1, tmp0, tmp3, tmp2, x0, x1);
DUP2_ARG2(__lsx_vxor_v, x0, sign_z0, x1, sign_z1, sign_x0, sign_x1);
DUP2_ARG2(__lsx_vsub_h, sign_x0, sign_z0, sign_x1, sign_z1, sign_x0, sign_x1);
BOOST_QUANT1(z_bin0, x0, sign_x0, 0);
BOOST_QUANT1(z_bin0, x0, sign_x0, 1);
BOOST_QUANT1(z_bin0, x0, sign_x0, 2);
BOOST_QUANT1(z_bin0, x0, sign_x0, 3);
BOOST_QUANT1(z_bin0, x0, sign_x0, 4);
BOOST_QUANT1(z_bin0, x0, sign_x0, 5);
BOOST_QUANT1(z_bin0, x0, sign_x0, 6);
BOOST_QUANT1(z_bin0, x0, sign_x0, 7);
BOOST_QUANT2(z_bin1, x1, sign_x1, 0);
BOOST_QUANT2(z_bin1, x1, sign_x1, 1);
BOOST_QUANT2(z_bin1, x1, sign_x1, 2);
BOOST_QUANT2(z_bin1, x1, sign_x1, 3);
BOOST_QUANT2(z_bin1, x1, sign_x1, 4);
BOOST_QUANT2(z_bin1, x1, sign_x1, 5);
BOOST_QUANT2(z_bin1, x1, sign_x1, 6);
BOOST_QUANT2(z_bin1, x1, sign_x1, 7);
DUP2_ARG2(__lsx_vld, de_quant, 0, de_quant, 16, de_quant0, de_quant1);
DUP2_ARG3(__lsx_vshuf_h, inv_zig_zag0, sign_x1, sign_x0, inv_zig_zag1,
sign_x1, sign_x0, q_coeff0, q_coeff1);
DUP2_ARG2(__lsx_vmul_h, de_quant0, q_coeff0, de_quant1, q_coeff1, de_quant0,
de_quant1);
__lsx_vst(q_coeff0, q_coeff, 0);
__lsx_vst(q_coeff1, q_coeff, 16);
__lsx_vst(de_quant0, dq_coeff, 0);
__lsx_vst(de_quant1, dq_coeff, 16);
return (int8_t)(eob + 1);
}
void vp8_regular_quantize_b_lsx(BLOCK *b, BLOCKD *d) {
int16_t *zbin_boost_ptr = b->zrun_zbin_boost;
int16_t *coeff_ptr = b->coeff;
int16_t *zbin_ptr = b->zbin;
int16_t *round_ptr = b->round;
int16_t *quant_ptr = b->quant;
int16_t *quant_shift_ptr = b->quant_shift;
int16_t *qcoeff_ptr = d->qcoeff;
int16_t *dqcoeff_ptr = d->dqcoeff;
int16_t *dequant_ptr = d->dequant;
int16_t zbin_oq_value = b->zbin_extra;
*d->eob = exact_regular_quantize_b_lsx(
zbin_boost_ptr, coeff_ptr, zbin_ptr, round_ptr, quant_ptr,
quant_shift_ptr, dequant_ptr, zbin_oq_value, qcoeff_ptr, dqcoeff_ptr);
}