32 const uint8_t *
src,
int srcW,
int xInc)
35 unsigned int xpos = 0;
38 static const int32_t idx32[4] = {0, 1, 2, 3};
39 static const int16_t idx16[8] = {0, 1, 2, 3, 4, 5, 6, 7};
40 static const uint8_t shuf8[16] = {
41 0, 4, 8, 12, 16, 20, 24, 28,
42 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30
46 __m128i vadd_w = __lsx_vmul_w(__lsx_vreplgr2vr_w(xInc),
49 __m128i vadd16 = __lsx_vmul_h(__lsx_vreplgr2vr_h(xInc),
51 __m128i vx4 = __lsx_vreplgr2vr_w(4 * xInc);
52 __m128i vshuf8 = __lsx_vld(shuf8, 0);
53 __m128i v128 = __lsx_vreplgr2vr_h(128);
55 for (;
i + 8 <= dstWidth && (xpos >> 16) + 32 < srcW;
i += 8, xpos += 8 * xInc) {
56 unsigned int lo = xpos & 0xFFFF;
57 unsigned int xx = xpos >> 16;
60 __m128i vc0 = __lsx_vadd_w(__lsx_vreplgr2vr_w(lo), vadd_w);
61 __m128i vc1 = __lsx_vadd_w(vc0, vx4);
64 __m128i vperm = __lsx_vshuf_b(__lsx_vsrli_w(vc1, 16),
65 __lsx_vsrli_w(vc0, 16), vshuf8);
68 __m128i valpha = __lsx_vsrli_h(__lsx_vadd_h(__lsx_vreplgr2vr_h(lo),
71 __m128i v0 = __lsx_vsllwil_hu_bu(__lsx_vshuf_b(__lsx_vld(
src + xx + 16, 0),
72 __lsx_vld(
src + xx, 0),
74 __m128i v1 = __lsx_vsllwil_hu_bu(__lsx_vshuf_b(__lsx_vld(
src + xx + 17, 0),
75 __lsx_vld(
src + xx + 1, 0),
78 __m128i w0 = __lsx_vsub_h(v128, valpha);
79 __lsx_vst(__lsx_vadd_h(__lsx_vmul_h(v0, w0), __lsx_vmul_h(v1, valpha)),
84 for (;
i < dstWidth;
i++) {
85 unsigned int xx = xpos >> 16;
86 unsigned int xalpha = (xpos & 0xFFFF) >> 9;
90 for (
i = dstWidth - 1; (
i * (
int64_t)xInc) >> 16 >= srcW - 1;
i--)
95 int dstWidth,
const uint8_t *
src1,
96 const uint8_t *
src2,
int srcW,
int xInc)
99 unsigned int xpos = 0;
102 static const int32_t idx32[4] = {0, 1, 2, 3};
103 static const int16_t idx16[8] = {0, 1, 2, 3, 4, 5, 6, 7};
104 static const uint8_t shuf8[16] = {
105 0, 4, 8, 12, 16, 20, 24, 28,
106 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30
109 __m128i vadd_w = __lsx_vmul_w(__lsx_vreplgr2vr_w(xInc),
110 __lsx_vld(idx32, 0));
111 __m128i vadd16 = __lsx_vmul_h(__lsx_vreplgr2vr_h(xInc),
112 __lsx_vld(idx16, 0));
113 __m128i vx4 = __lsx_vreplgr2vr_w(4 * xInc);
114 __m128i vshuf8 = __lsx_vld(shuf8, 0);
115 __m128i v127 = __lsx_vreplgr2vr_h(127);
117 for (;
i + 8 <= dstWidth && (xpos >> 16) + 32 < srcW;
i += 8, xpos += 8 * xInc) {
118 unsigned int lo = xpos & 0xFFFF;
119 unsigned int xx = xpos >> 16;
121 __m128i vc0 = __lsx_vadd_w(__lsx_vreplgr2vr_w(lo), vadd_w);
122 __m128i vc1 = __lsx_vadd_w(vc0, vx4);
124 __m128i vperm = __lsx_vshuf_b(__lsx_vsrli_w(vc1, 16),
125 __lsx_vsrli_w(vc0, 16), vshuf8);
127 __m128i valpha = __lsx_vsrli_h(__lsx_vadd_h(__lsx_vreplgr2vr_h(lo),
130 __m128i v10 = __lsx_vsllwil_hu_bu(__lsx_vshuf_b(__lsx_vld(
src1 + xx + 16, 0),
131 __lsx_vld(
src1 + xx, 0),
133 __m128i v11 = __lsx_vsllwil_hu_bu(__lsx_vshuf_b(__lsx_vld(
src1 + xx + 17, 0),
134 __lsx_vld(
src1 + xx + 1, 0),
136 __m128i v20 = __lsx_vsllwil_hu_bu(__lsx_vshuf_b(__lsx_vld(
src2 + xx + 16, 0),
137 __lsx_vld(
src2 + xx, 0),
139 __m128i v21 = __lsx_vsllwil_hu_bu(__lsx_vshuf_b(__lsx_vld(
src2 + xx + 17, 0),
140 __lsx_vld(
src2 + xx + 1, 0),
143 __m128i w0 = __lsx_vsub_h(v127, valpha);
144 __lsx_vst(__lsx_vadd_h(__lsx_vmul_h(v10, w0), __lsx_vmul_h(v11, valpha)),
146 __lsx_vst(__lsx_vadd_h(__lsx_vmul_h(v20, w0), __lsx_vmul_h(v21, valpha)),
151 for (;
i < dstWidth;
i++) {
152 unsigned int xx = xpos >> 16;
153 unsigned int xalpha = (xpos & 0xFFFF) >> 9;
154 dst1[
i] = (
src1[xx] * (xalpha ^ 127) +
src1[xx + 1] * xalpha);
155 dst2[
i] = (
src2[xx] * (xalpha ^ 127) +
src2[xx + 1] * xalpha);
158 for (
i = dstWidth - 1; (
i * (
int64_t)xInc) >> 16 >= srcW - 1;
i--) {
159 dst1[
i] =
src1[srcW - 1] * 128;
160 dst2[
i] =
src2[srcW - 1] * 128;
void ff_hcscale_fast_lsx(SwsInternal *c, int16_t *dst1, int16_t *dst2, int dstWidth, const uint8_t *src1, const uint8_t *src2, int srcW, int xInc)