diff options
author | Shivraj Patil <shivraj.patil@imgtec.com> | 2015-06-02 14:08:12 +0530 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-06-03 21:30:21 +0200 |
commit | aef34ab95048aade062d4c669ea272e0f08b81a4 (patch) | |
tree | 804823e94bc461b9622f3578b41c913c2a4161cd /libavcodec | |
parent | c96c73b0b0520fc734554d34b4693ca7af4edd02 (diff) | |
download | ffmpeg-aef34ab95048aade062d4c669ea272e0f08b81a4.tar.gz |
avcodec/mips: MSA (MIPS-SIMD-Arch) optimizations for HEVC uni mc epel functions
This patch adds MSA (MIPS-SIMD-Arch) optimizations for HEVC uni mc epel functions.
Adds new generic macros (needed for this patch) in libavutil/mips/generic_macros_msa.h
Signed-off-by: Shivraj Patil <shivraj.patil@imgtec.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/mips/hevc_mc_uni_msa.c | 2175 | ||||
-rw-r--r-- | libavcodec/mips/hevcdsp_init_mips.c | 30 | ||||
-rw-r--r-- | libavcodec/mips/hevcdsp_mips.h | 30 |
3 files changed, 2235 insertions, 0 deletions
diff --git a/libavcodec/mips/hevc_mc_uni_msa.c b/libavcodec/mips/hevc_mc_uni_msa.c index 09179d2ba3..7d02ce82fa 100644 --- a/libavcodec/mips/hevc_mc_uni_msa.c +++ b/libavcodec/mips/hevc_mc_uni_msa.c @@ -319,6 +319,44 @@ uint8_t mc_filt_mask_arr[16 * 3] = { res7_m, out0, out1, out2, out3); \ } +#define FILT_4TAP_DPADD_S_H(vec0, vec1, filt0, filt1) \ +( { \ + v8i16 tmp0; \ + \ + tmp0 = __msa_dotp_s_h((v16i8) vec0, (v16i8) filt0); \ + tmp0 = __msa_dpadd_s_h(tmp0, (v16i8) vec1, (v16i8) filt1); \ + \ + tmp0; \ +} ) + +#define HORIZ_4TAP_4WID_4VECS_FILT(src0, src1, src2, src3, \ + mask0, mask1, filt0, filt1, \ + out0, out1) \ +{ \ + v16i8 vec0_m, vec1_m, vec2_m, vec3_m; \ + \ + VSHF_B2_SB(src0, src1, src2, src3, mask0, mask0, vec0_m, vec1_m); \ + DOTP_SB2_SH(vec0_m, vec1_m, filt0, filt0, out0, out1); \ + VSHF_B2_SB(src0, src1, src2, src3, mask1, mask1, vec2_m, vec3_m); \ + DPADD_SB2_SH(vec2_m, vec3_m, filt1, filt1, out0, out1); \ +} + +#define HORIZ_4TAP_8WID_4VECS_FILT(src0, src1, src2, src3, \ + mask0, mask1, filt0, filt1, \ + out0, out1, out2, out3) \ +{ \ + v16i8 vec0_m, vec1_m, vec2_m, vec3_m; \ + \ + VSHF_B2_SB(src0, src0, src1, src1, mask0, mask0, vec0_m, vec1_m); \ + VSHF_B2_SB(src2, src2, src3, src3, mask0, mask0, vec2_m, vec3_m); \ + DOTP_SB4_SH(vec0_m, vec1_m, vec2_m, vec3_m, filt0, filt0, filt0, filt0, \ + out0, out1, out2, out3); \ + VSHF_B2_SB(src0, src0, src1, src1, mask1, mask1, vec0_m, vec1_m); \ + VSHF_B2_SB(src2, src2, src3, src3, mask1, mask1, vec2_m, vec3_m); \ + DPADD_SB4_SH(vec0_m, vec1_m, vec2_m, vec3_m, filt1, filt1, filt1, filt1, \ + out0, out1, out2, out3); \ +} + static void common_hz_8t_4x4_msa(uint8_t *src, int32_t src_stride, uint8_t *dst, int32_t dst_stride, const int8_t *filter, uint8_t rnd_val) @@ -1696,6 +1734,2119 @@ static void hevc_hv_uni_8t_64w_msa(uint8_t *src, filter_x, filter_y, height, 64); } +static void common_hz_4t_4x2_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, uint8_t rnd_val) +{ + v16i8 filt0, filt1, src0, src1, mask0, mask1, vec0, vec1; + v16u8 out; + v8i16 filt, res0; + v8i16 rnd_vec; + + mask0 = LD_SB(&mc_filt_mask_arr[16]); + src -= 1; + rnd_vec = __msa_fill_h(rnd_val); + + /* rearranging filter */ + filt = LD_SH(filter); + SPLATI_H2_SB(filt, 0, 1, filt0, filt1); + + mask1 = mask0 + 2; + + LD_SB2(src, src_stride, src0, src1); + XORI_B2_128_SB(src0, src1); + VSHF_B2_SB(src0, src1, src0, src1, mask0, mask1, vec0, vec1); + res0 = FILT_4TAP_DPADD_S_H(vec0, vec1, filt0, filt1); + res0 = __msa_srar_h(res0, rnd_vec); + res0 = __msa_sat_s_h(res0, 7); + out = PCKEV_XORI128_UB(res0, res0); + ST4x2_UB(out, dst, dst_stride); +} + +static void common_hz_4t_4x4_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, uint8_t rnd_val) +{ + v16i8 src0, src1, src2, src3, filt0, filt1, mask0, mask1; + v8i16 filt, out0, out1; + v16u8 out; + v8i16 rnd_vec; + + mask0 = LD_SB(&mc_filt_mask_arr[16]); + src -= 1; + rnd_vec = __msa_fill_h(rnd_val); + + /* rearranging filter */ + filt = LD_SH(filter); + SPLATI_H2_SB(filt, 0, 1, filt0, filt1); + + mask1 = mask0 + 2; + + LD_SB4(src, src_stride, src0, src1, src2, src3); + XORI_B4_128_SB(src0, src1, src2, src3); + HORIZ_4TAP_4WID_4VECS_FILT(src0, src1, src2, src3, mask0, mask1, + filt0, filt1, out0, out1); + SRAR_H2_SH(out0, out1, rnd_vec); + SAT_SH2_SH(out0, out1, 7); + out = PCKEV_XORI128_UB(out0, out1); + ST4x4_UB(out, out, 0, 1, 2, 3, dst, dst_stride); +} + +static void common_hz_4t_4x8_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, uint8_t rnd_val) +{ + v16i8 src0, src1, src2, src3, filt0, filt1, mask0, mask1; + v16u8 out; + v8i16 filt, out0, out1, out2, out3; + v8i16 rnd_vec; + + mask0 = LD_SB(&mc_filt_mask_arr[16]); + src -= 1; + rnd_vec = __msa_fill_h(rnd_val); + + /* rearranging filter */ + filt = LD_SH(filter); + SPLATI_H2_SB(filt, 0, 1, filt0, filt1); + + mask1 = mask0 + 2; + + LD_SB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + XORI_B4_128_SB(src0, src1, src2, src3); + HORIZ_4TAP_4WID_4VECS_FILT(src0, src1, src2, src3, mask0, mask1, + filt0, filt1, out0, out1); + LD_SB4(src, src_stride, src0, src1, src2, src3); + XORI_B4_128_SB(src0, src1, src2, src3); + HORIZ_4TAP_4WID_4VECS_FILT(src0, src1, src2, src3, mask0, mask1, + filt0, filt1, out2, out3); + SRAR_H4_SH(out0, out1, out2, out3, rnd_vec); + SAT_SH4_SH(out0, out1, out2, out3, 7); + out = PCKEV_XORI128_UB(out0, out1); + ST4x4_UB(out, out, 0, 1, 2, 3, dst, dst_stride); + dst += (4 * dst_stride); + out = PCKEV_XORI128_UB(out2, out3); + ST4x4_UB(out, out, 0, 1, 2, 3, dst, dst_stride); +} + +static void common_hz_4t_4x16_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, uint8_t rnd_val) +{ + v16i8 src0, src1, src2, src3, src4, src5, src6, src7; + v16i8 filt0, filt1, mask0, mask1; + v16u8 out; + v8i16 filt, out0, out1, out2, out3; + v8i16 rnd_vec; + + mask0 = LD_SB(&mc_filt_mask_arr[16]); + src -= 1; + rnd_vec = __msa_fill_h(rnd_val); + + /* rearranging filter */ + filt = LD_SH(filter); + SPLATI_H2_SB(filt, 0, 1, filt0, filt1); + + mask1 = mask0 + 2; + + LD_SB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7); + src += (8 * src_stride); + XORI_B8_128_SB(src0, src1, src2, src3, src4, src5, src6, src7); + HORIZ_4TAP_4WID_4VECS_FILT(src0, src1, src2, src3, mask0, mask1, + filt0, filt1, out0, out1); + HORIZ_4TAP_4WID_4VECS_FILT(src4, src5, src6, src7, mask0, mask1, + filt0, filt1, out2, out3); + SRAR_H4_SH(out0, out1, out2, out3, rnd_vec); + SAT_SH4_SH(out0, out1, out2, out3, 7); + out = PCKEV_XORI128_UB(out0, out1); + ST4x4_UB(out, out, 0, 1, 2, 3, dst, dst_stride); + dst += (4 * dst_stride); + out = PCKEV_XORI128_UB(out2, out3); + ST4x4_UB(out, out, 0, 1, 2, 3, dst, dst_stride); + dst += (4 * dst_stride); + + LD_SB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7); + src += (8 * src_stride); + XORI_B8_128_SB(src0, src1, src2, src3, src4, src5, src6, src7); + HORIZ_4TAP_4WID_4VECS_FILT(src0, src1, src2, src3, mask0, mask1, + filt0, filt1, out0, out1); + HORIZ_4TAP_4WID_4VECS_FILT(src4, src5, src6, src7, mask0, mask1, + filt0, filt1, out2, out3); + SRAR_H4_SH(out0, out1, out2, out3, rnd_vec); + SAT_SH4_SH(out0, out1, out2, out3, 7); + out = PCKEV_XORI128_UB(out0, out1); + ST4x4_UB(out, out, 0, 1, 2, 3, dst, dst_stride); + dst += (4 * dst_stride); + out = PCKEV_XORI128_UB(out2, out3); + ST4x4_UB(out, out, 0, 1, 2, 3, dst, dst_stride); +} + +static void common_hz_4t_4w_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, int32_t height, + uint8_t rnd_val) +{ + if (2 == height) { + common_hz_4t_4x2_msa(src, src_stride, dst, dst_stride, filter, rnd_val); + } else if (4 == height) { + common_hz_4t_4x4_msa(src, src_stride, dst, dst_stride, filter, rnd_val); + } else if (8 == height) { + common_hz_4t_4x8_msa(src, src_stride, dst, dst_stride, filter, rnd_val); + } else if (16 == height) { + common_hz_4t_4x16_msa(src, src_stride, dst, dst_stride, filter, + rnd_val); + } +} + +static void common_hz_4t_6w_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, int32_t height, + uint8_t rnd_val) +{ + uint32_t loop_cnt; + v16i8 src0, src1, src2, src3, filt0, filt1, mask0, mask1; + v16u8 out4, out5; + v8i16 filt, out0, out1, out2, out3; + v8i16 rnd_vec; + + mask0 = LD_SB(&mc_filt_mask_arr[0]); + src -= 1; + rnd_vec = __msa_fill_h(rnd_val); + + /* rearranging filter */ + filt = LD_SH(filter); + SPLATI_H2_SB(filt, 0, 1, filt0, filt1); + + mask1 = mask0 + 2; + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + XORI_B4_128_SB(src0, src1, src2, src3); + HORIZ_4TAP_8WID_4VECS_FILT(src0, src1, src2, src3, mask0, mask1, filt0, + filt1, out0, out1, out2, out3); + SRAR_H4_SH(out0, out1, out2, out3, rnd_vec); + SAT_SH4_SH(out0, out1, out2, out3, 7); + + out4 = PCKEV_XORI128_UB(out0, out1); + out5 = PCKEV_XORI128_UB(out2, out3); + ST6x4_UB(out4, out5, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +static void common_hz_4t_8x2mult_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, int32_t height, + uint8_t rnd_val) +{ + uint32_t loop_cnt; + v16i8 src0, src1, filt0, filt1, mask0, mask1; + v16u8 out; + v8i16 filt, vec0, vec1, vec2, vec3; + v8i16 rnd_vec; + + mask0 = LD_SB(&mc_filt_mask_arr[0]); + src -= 1; + rnd_vec = __msa_fill_h(rnd_val); + + filt = LD_SH(filter); + SPLATI_H2_SB(filt, 0, 1, filt0, filt1); + + mask1 = mask0 + 2; + + for (loop_cnt = (height >> 1); loop_cnt--;) { + LD_SB2(src, src_stride, src0, src1); + src += (2 * src_stride); + + XORI_B2_128_SB(src0, src1); + VSHF_B2_SH(src0, src0, src1, src1, mask0, mask0, vec0, vec1); + DOTP_SB2_SH(vec0, vec1, filt0, filt0, vec0, vec1); + VSHF_B2_SH(src0, src0, src1, src1, mask1, mask1, vec2, vec3); + DPADD_SB2_SH(vec2, vec3, filt1, filt1, vec0, vec1); + SRAR_H2_SH(vec0, vec1, rnd_vec); + SAT_SH2_SH(vec0, vec1, 7); + out = PCKEV_XORI128_UB(vec0, vec1); + ST8x2_UB(out, dst, dst_stride); + dst += (2 * dst_stride); + } +} + +static void common_hz_4t_8x4mult_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, int32_t height, + uint8_t rnd_val) +{ + uint32_t loop_cnt; + v16i8 src0, src1, src2, src3, filt0, filt1, mask0, mask1; + v16u8 tmp0, tmp1; + v8i16 filt, out0, out1, out2, out3; + v8i16 rnd_vec; + + mask0 = LD_SB(&mc_filt_mask_arr[0]); + src -= 1; + rnd_vec = __msa_fill_h(rnd_val); + + /* rearranging filter */ + filt = LD_SH(filter); + SPLATI_H2_SB(filt, 0, 1, filt0, filt1); + + mask1 = mask0 + 2; + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + XORI_B4_128_SB(src0, src1, src2, src3); + HORIZ_4TAP_8WID_4VECS_FILT(src0, src1, src2, src3, mask0, mask1, filt0, + filt1, out0, out1, out2, out3); + SRAR_H4_SH(out0, out1, out2, out3, rnd_vec); + SAT_SH4_SH(out0, out1, out2, out3, 7); + tmp0 = PCKEV_XORI128_UB(out0, out1); + tmp1 = PCKEV_XORI128_UB(out2, out3); + ST8x4_UB(tmp0, tmp1, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +static void common_hz_4t_8w_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, int32_t height, + uint8_t rnd_val) +{ + if ((2 == height) || (6 == height)) { + common_hz_4t_8x2mult_msa(src, src_stride, dst, dst_stride, filter, + height, rnd_val); + } else { + common_hz_4t_8x4mult_msa(src, src_stride, dst, dst_stride, filter, + height, rnd_val); + } +} + +static void common_hz_4t_12w_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, int32_t height, + uint8_t rnd_val) +{ + uint32_t loop_cnt; + v16i8 src0, src1, src2, src3, filt0, filt1, mask0, mask1, mask2, mask3; + v16i8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7, vec8, vec9; + v16i8 vec10, vec11; + v16u8 tmp0, tmp1; + v8i16 filt, out0, out1, out2, out3, out4, out5; + v8i16 rnd_vec; + + mask0 = LD_SB(&mc_filt_mask_arr[0]); + mask2 = LD_SB(&mc_filt_mask_arr[32]); + + src -= 1; + + /* rearranging filter */ + filt = LD_SH(filter); + SPLATI_H2_SB(filt, 0, 1, filt0, filt1); + + mask1 = mask0 + 2; + mask3 = mask2 + 2; + + rnd_vec = __msa_fill_h(rnd_val); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + XORI_B4_128_SB(src0, src1, src2, src3); + VSHF_B2_SB(src0, src0, src1, src1, mask0, mask0, vec4, vec5); + VSHF_B2_SB(src2, src2, src3, src3, mask0, mask0, vec6, vec7); + VSHF_B2_SB(src0, src1, src2, src3, mask2, mask2, vec0, vec1); + DOTP_SB4_SH(vec4, vec5, vec6, vec7, filt0, filt0, filt0, filt0, + out2, out3, out4, out5); + DOTP_SB2_SH(vec0, vec1, filt0, filt0, out0, out1); + VSHF_B2_SB(src0, src0, src1, src1, mask1, mask1, vec8, vec9); + VSHF_B2_SB(src2, src2, src3, src3, mask1, mask1, vec10, vec11); + VSHF_B2_SB(src0, src1, src2, src3, mask3, mask3, vec2, vec3); + DPADD_SB4_SH(vec8, vec9, vec10, vec11, filt1, filt1, filt1, filt1, + out2, out3, out4, out5); + DPADD_SB2_SH(vec2, vec3, filt1, filt1, out0, out1); + SRAR_H4_SH(out0, out1, out2, out3, rnd_vec); + SRAR_H2_SH(out4, out5, rnd_vec); + SAT_SH4_SH(out0, out1, out2, out3, 7); + SAT_SH2_SH(out4, out5, 7); + tmp0 = PCKEV_XORI128_UB(out2, out3); + tmp1 = PCKEV_XORI128_UB(out4, out5); + ST8x4_UB(tmp0, tmp1, dst, dst_stride); + tmp0 = PCKEV_XORI128_UB(out0, out1); + ST4x4_UB(tmp0, tmp0, 0, 1, 2, 3, dst + 8, dst_stride); + dst += (4 * dst_stride); + } +} + +static void common_hz_4t_16w_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, int32_t height, + uint8_t rnd_val) +{ + uint32_t loop_cnt; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7; + v16i8 filt0, filt1, mask0, mask1; + v8i16 filt, out0, out1, out2, out3, out4, out5, out6, out7; + v16u8 out; + v8i16 rnd_vec; + + mask0 = LD_SB(&mc_filt_mask_arr[0]); + src -= 1; + rnd_vec = __msa_fill_h(rnd_val); + + /* rearranging filter */ + filt = LD_SH(filter); + SPLATI_H2_SB(filt, 0, 1, filt0, filt1); + + mask1 = mask0 + 2; + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src0, src2, src4, src6); + LD_SB4(src + 8, src_stride, src1, src3, src5, src7); + src += (4 * src_stride); + + XORI_B8_128_SB(src0, src1, src2, src3, src4, src5, src6, src7); + HORIZ_4TAP_8WID_4VECS_FILT(src0, src1, src2, src3, mask0, mask1, filt0, + filt1, out0, out1, out2, out3); + HORIZ_4TAP_8WID_4VECS_FILT(src4, src5, src6, src7, mask0, mask1, filt0, + filt1, out4, out5, out6, out7); + SRAR_H4_SH(out0, out1, out2, out3, rnd_vec); + SRAR_H4_SH(out4, out5, out6, out7, rnd_vec); + SAT_SH4_SH(out0, out1, out2, out3, 7); + SAT_SH4_SH(out4, out5, out6, out7, 7); + out = PCKEV_XORI128_UB(out0, out1); + ST_UB(out, dst); + dst += dst_stride; + out = PCKEV_XORI128_UB(out2, out3); + ST_UB(out, dst); + dst += dst_stride; + out = PCKEV_XORI128_UB(out4, out5); + ST_UB(out, dst); + dst += dst_stride; + out = PCKEV_XORI128_UB(out6, out7); + ST_UB(out, dst); + dst += dst_stride; + } +} + +static void common_hz_4t_24w_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, int32_t height, + uint8_t rnd_val) +{ + uint8_t *dst1 = dst + 16; + uint32_t loop_cnt; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7; + v16i8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; + v16i8 filt0, filt1, mask0, mask1, mask00, mask11; + v8i16 filt, out0, out1, out2, out3; + v16u8 tmp0, tmp1; + v8i16 rnd_vec; + + mask0 = LD_SB(&mc_filt_mask_arr[0]); + src -= 1; + rnd_vec = __msa_fill_h(rnd_val); + + /* rearranging filter */ + filt = LD_SH(filter); + SPLATI_H2_SB(filt, 0, 1, filt0, filt1); + + mask1 = mask0 + 2; + mask00 = mask0 + 8; + mask11 = mask0 + 10; + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src0, src2, src4, src6); + LD_SB4(src + 16, src_stride, src1, src3, src5, src7); + src += (4 * src_stride); + + XORI_B8_128_SB(src0, src1, src2, src3, src4, src5, src6, src7); + VSHF_B2_SB(src0, src0, src0, src1, mask0, mask00, vec0, vec1); + VSHF_B2_SB(src2, src2, src2, src3, mask0, mask00, vec2, vec3); + VSHF_B2_SB(src0, src0, src0, src1, mask1, mask11, vec4, vec5); + VSHF_B2_SB(src2, src2, src2, src3, mask1, mask11, vec6, vec7); + DOTP_SB4_SH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, + out0, out1, out2, out3); + DPADD_SB4_SH(vec4, vec5, vec6, vec7, filt1, filt1, filt1, filt1, + out0, out1, out2, out3); + SRAR_H4_SH(out0, out1, out2, out3, rnd_vec); + SAT_SH4_SH(out0, out1, out2, out3, 7); + tmp0 = PCKEV_XORI128_UB(out0, out1); + ST_UB(tmp0, dst); + dst += dst_stride; + tmp0 = PCKEV_XORI128_UB(out2, out3); + ST_UB(tmp0, dst); + dst += dst_stride; + + VSHF_B2_SB(src4, src4, src4, src5, mask0, mask00, vec0, vec1); + VSHF_B2_SB(src6, src6, src6, src7, mask0, mask00, vec2, vec3); + VSHF_B2_SB(src4, src4, src4, src5, mask1, mask11, vec4, vec5); + VSHF_B2_SB(src6, src6, src6, src7, mask1, mask11, vec6, vec7); + DOTP_SB4_SH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, + out0, out1, out2, out3); + DPADD_SB4_SH(vec4, vec5, vec6, vec7, filt1, filt1, filt1, filt1, + out0, out1, out2, out3); + SRAR_H4_SH(out0, out1, out2, out3, rnd_vec); + SAT_SH4_SH(out0, out1, out2, out3, 7); + tmp0 = PCKEV_XORI128_UB(out0, out1); + ST_UB(tmp0, dst); + dst += dst_stride; + tmp0 = PCKEV_XORI128_UB(out2, out3); + ST_UB(tmp0, dst); + dst += dst_stride; + + /* 8 width */ + VSHF_B2_SB(src1, src1, src3, src3, mask0, mask0, vec0, vec1); + VSHF_B2_SB(src5, src5, src7, src7, mask0, mask0, vec2, vec3); + VSHF_B2_SB(src1, src1, src3, src3, mask1, mask1, vec4, vec5); + VSHF_B2_SB(src5, src5, src7, src7, mask1, mask1, vec6, vec7); + + DOTP_SB4_SH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, + out0, out1, out2, out3); + DPADD_SB4_SH(vec4, vec5, vec6, vec7, filt1, filt1, filt1, filt1, + out0, out1, out2, out3); + + SRAR_H4_SH(out0, out1, out2, out3, rnd_vec); + SAT_SH4_SH(out0, out1, out2, out3, 7); + tmp0 = PCKEV_XORI128_UB(out0, out1); + tmp1 = PCKEV_XORI128_UB(out2, out3); + ST8x4_UB(tmp0, tmp1, dst1, dst_stride); + dst1 += (4 * dst_stride); + } +} + +static void common_hz_4t_32w_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, int32_t height, + uint8_t rnd_val) +{ + uint32_t loop_cnt; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7; + v16i8 filt0, filt1, mask0, mask1; + v16u8 out; + v8i16 filt, out0, out1, out2, out3, out4, out5, out6, out7; + v8i16 rnd_vec; + + mask0 = LD_SB(&mc_filt_mask_arr[0]); + src -= 1; + rnd_vec = __msa_fill_h(rnd_val); + + /* rearranging filter */ + filt = LD_SH(filter); + SPLATI_H2_SB(filt, 0, 1, filt0, filt1); + + mask1 = mask0 + 2; + + for (loop_cnt = (height >> 1); loop_cnt--;) { + src0 = LD_SB(src); + src2 = LD_SB(src + 16); + src3 = LD_SB(src + 24); + src += src_stride; + src4 = LD_SB(src); + src6 = LD_SB(src + 16); + src7 = LD_SB(src + 24); + SLDI_B2_SB(src2, src6, src0, src4, src1, src5, 8); + src += src_stride; + + XORI_B8_128_SB(src0, src1, src2, src3, src4, src5, src6, src7); + HORIZ_4TAP_8WID_4VECS_FILT(src0, src1, src2, src3, mask0, mask1, + filt0, filt1, out0, out1, out2, out3); + HORIZ_4TAP_8WID_4VECS_FILT(src4, src5, src6, src7, mask0, mask1, + filt0, filt1, out4, out5, out6, out7); + SRAR_H4_SH(out0, out1, out2, out3, rnd_vec); + SRAR_H4_SH(out4, out5, out6, out7, rnd_vec); + SAT_SH4_SH(out0, out1, out2, out3, 7); + SAT_SH4_SH(out4, out5, out6, out7, 7); + out = PCKEV_XORI128_UB(out0, out1); + ST_UB(out, dst); + out = PCKEV_XORI128_UB(out2, out3); + ST_UB(out, dst + 16); + dst += dst_stride; + out = PCKEV_XORI128_UB(out4, out5); + ST_UB(out, dst); + out = PCKEV_XORI128_UB(out6, out7); + ST_UB(out, dst + 16); + dst += dst_stride; + } +} + +static void common_vt_4t_4x2_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, uint8_t rnd_val) +{ + v16i8 src0, src1, src2, src3, src4, src10_r, src32_r, src21_r, src43_r; + v16i8 src2110, src4332, filt0, filt1; + v16u8 out; + v8i16 filt, out10; + v8i16 rnd_vec; + + src -= src_stride; + rnd_vec = __msa_fill_h(rnd_val); + + filt = LD_SH(filter); + SPLATI_H2_SB(filt, 0, 1, filt0, filt1); + + LD_SB3(src, src_stride, src0, src1, src2); + src += (3 * src_stride); + + ILVR_B2_SB(src1, src0, src2, src1, src10_r, src21_r); + src2110 = (v16i8) __msa_ilvr_d((v2i64) src21_r, (v2i64) src10_r); + src2110 = (v16i8) __msa_xori_b((v16u8) src2110, 128); + LD_SB2(src, src_stride, src3, src4); + ILVR_B2_SB(src3, src2, src4, src3, src32_r, src43_r); + src4332 = (v16i8) __msa_ilvr_d((v2i64) src43_r, (v2i64) src32_r); + src4332 = (v16i8) __msa_xori_b((v16u8) src4332, 128); + out10 = FILT_4TAP_DPADD_S_H(src2110, src4332, filt0, filt1); + out10 = __msa_srar_h(out10, rnd_vec); + out10 = __msa_sat_s_h(out10, 7); + out = PCKEV_XORI128_UB(out10, out10); + ST4x2_UB(out, dst, dst_stride); +} + +static void common_vt_4t_4x4multiple_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, int32_t height, + uint8_t rnd_val) +{ + uint32_t loop_cnt; + v16i8 src0, src1, src2, src3, src4, src5; + v16i8 src10_r, src32_r, src54_r, src21_r, src43_r, src65_r; + v16i8 src2110, src4332, filt0, filt1; + v8i16 filt, out10, out32; + v16u8 out; + v8i16 rnd_vec; + + src -= src_stride; + rnd_vec = __msa_fill_h(rnd_val); + + filt = LD_SH(filter); + SPLATI_H2_SB(filt, 0, 1, filt0, filt1); + + LD_SB3(src, src_stride, src0, src1, src2); + src += (3 * src_stride); + + ILVR_B2_SB(src1, src0, src2, src1, src10_r, src21_r); + + src2110 = (v16i8) __msa_ilvr_d((v2i64) src21_r, (v2i64) src10_r); + src2110 = (v16i8) __msa_xori_b((v16u8) src2110, 128); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB3(src, src_stride, src3, src4, src5); + src += (3 * src_stride); + ILVR_B2_SB(src3, src2, src4, src3, src32_r, src43_r); + src4332 = (v16i8) __msa_ilvr_d((v2i64) src43_r, (v2i64) src32_r); + src4332 = (v16i8) __msa_xori_b((v16u8) src4332, 128); + out10 = FILT_4TAP_DPADD_S_H(src2110, src4332, filt0, filt1); + + src2 = LD_SB(src); + src += (src_stride); + ILVR_B2_SB(src5, src4, src2, src5, src54_r, src65_r); + src2110 = (v16i8) __msa_ilvr_d((v2i64) src65_r, (v2i64) src54_r); + src2110 = (v16i8) __msa_xori_b((v16u8) src2110, 128); + out32 = FILT_4TAP_DPADD_S_H(src4332, src2110, filt0, filt1); + SRAR_H2_SH(out10, out32, rnd_vec); + SAT_SH2_SH(out10, out32, 7); + out = PCKEV_XORI128_UB(out10, out32); + ST4x4_UB(out, out, 0, 1, 2, 3, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +static void common_vt_4t_4w_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, int32_t height, + uint8_t rnd_val) +{ + if (2 == height) { + common_vt_4t_4x2_msa(src, src_stride, dst, dst_stride, filter, rnd_val); + } else { + common_vt_4t_4x4multiple_msa(src, src_stride, dst, dst_stride, filter, + height, rnd_val); + } +} + +static void common_vt_4t_6w_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, int32_t height, + uint8_t rnd_val) +{ + uint32_t loop_cnt; + v16u8 src0, src1, src2, src3, vec0, vec1, vec2, vec3, out0, out1; + v8i16 vec01, vec12, vec23, vec30, tmp0, tmp1, tmp2, tmp3; + v8i16 filt, filt0, filt1; + v8i16 rnd_vec; + + src -= src_stride; + rnd_vec = __msa_fill_h(rnd_val); + + /* rearranging filter_y */ + filt = LD_SH(filter); + SPLATI_H2_SH(filt, 0, 1, filt0, filt1); + + LD_UB3(src, src_stride, src0, src1, src2); + src += (3 * src_stride); + + vec0 = (v16u8) __msa_xori_b((v16u8) src0, 128); + vec1 = (v16u8) __msa_xori_b((v16u8) src1, 128); + vec2 = (v16u8) __msa_xori_b((v16u8) src2, 128); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_UB4(src, src_stride, src3, src0, src1, src2); + src += (4 * src_stride); + + vec3 = (v16u8) __msa_xori_b((v16u8) src3, 128); + ILVR_B2_SH(vec1, vec0, vec3, vec2, vec01, vec23); + tmp0 = FILT_4TAP_DPADD_S_H(vec01, vec23, filt0, filt1); + + vec0 = __msa_xori_b((v16u8) src0, 128); + ILVR_B2_SH(vec2, vec1, vec0, vec3, vec12, vec30); + tmp1 = FILT_4TAP_DPADD_S_H(vec12, vec30, filt0, filt1); + + vec1 = __msa_xori_b((v16u8) src1, 128); + vec01 = (v8i16) __msa_ilvr_b((v16i8) vec1, (v16i8) vec0); + tmp2 = FILT_4TAP_DPADD_S_H(vec23, vec01, filt0, filt1); + + vec2 = __msa_xori_b((v16u8) src2, 128); + vec12 = (v8i16) __msa_ilvr_b((v16i8) vec2, (v16i8) vec1); + tmp3 = FILT_4TAP_DPADD_S_H(vec30, vec12, filt0, filt1); + + SRAR_H4_SH(tmp0, tmp1, tmp2, tmp3, rnd_vec); + SAT_SH4_SH(tmp0, tmp1, tmp2, tmp3, 7); + out0 = PCKEV_XORI128_UB(tmp0, tmp1); + out1 = PCKEV_XORI128_UB(tmp2, tmp3); + ST6x4_UB(out0, out1, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +static void common_vt_4t_8x2_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, uint8_t rnd_val) +{ + v16i8 src0, src1, src2, src3, src4; + v8i16 src01, src12, src23, src34, tmp0, tmp1, filt, filt0, filt1; + v16u8 out; + v8i16 rnd_vec; + + src -= src_stride; + rnd_vec = __msa_fill_h(rnd_val); + + /* rearranging filter_y */ + filt = LD_SH(filter); + SPLATI_H2_SH(filt, 0, 1, filt0, filt1); + + LD_SB5(src, src_stride, src0, src1, src2, src3, src4); + XORI_B5_128_SB(src0, src1, src2, src3, src4); + ILVR_B2_SH(src1, src0, src3, src2, src01, src23); + tmp0 = FILT_4TAP_DPADD_S_H(src01, src23, filt0, filt1); + ILVR_B2_SH(src2, src1, src4, src3, src12, src34); + tmp1 = FILT_4TAP_DPADD_S_H(src12, src34, filt0, filt1); + SRAR_H2_SH(tmp0, tmp1, rnd_vec); + SAT_SH2_SH(tmp0, tmp1, 7); + out = PCKEV_XORI128_UB(tmp0, tmp1); + ST8x2_UB(out, dst, dst_stride); +} + +static void common_vt_4t_8x6_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, uint8_t rnd_val) +{ + uint32_t loop_cnt; + uint64_t out0, out1, out2; + v16i8 src0, src1, src2, src3, src4, src5; + v8i16 vec0, vec1, vec2, vec3, vec4, tmp0, tmp1, tmp2; + v8i16 filt, filt0, filt1; + v8i16 rnd_vec; + + src -= src_stride; + rnd_vec = __msa_fill_h(rnd_val); + + /* rearranging filter_y */ + filt = LD_SH(filter); + SPLATI_H2_SH(filt, 0, 1, filt0, filt1); + + LD_SB3(src, src_stride, src0, src1, src2); + src += (3 * src_stride); + + XORI_B3_128_SB(src0, src1, src2); + ILVR_B2_SH(src1, src0, src2, src1, vec0, vec2); + + for (loop_cnt = 2; loop_cnt--;) { + LD_SB3(src, src_stride, src3, src4, src5); + src += (3 * src_stride); + + XORI_B3_128_SB(src3, src4, src5); + ILVR_B3_SH(src3, src2, src4, src3, src5, src4, vec1, vec3, vec4); + tmp0 = FILT_4TAP_DPADD_S_H(vec0, vec1, filt0, filt1); + tmp1 = FILT_4TAP_DPADD_S_H(vec2, vec3, filt0, filt1); + tmp2 = FILT_4TAP_DPADD_S_H(vec1, vec4, filt0, filt1); + SRAR_H3_SH(tmp0, tmp1, tmp2, rnd_vec); + SAT_SH3_SH(tmp0, tmp1, tmp2, 7); + PCKEV_B2_SH(tmp1, tmp0, tmp2, tmp2, tmp0, tmp2); + XORI_B2_128_SH(tmp0, tmp2); + + out0 = __msa_copy_u_d((v2i64) tmp0, 0); + out1 = __msa_copy_u_d((v2i64) tmp0, 1); + out2 = __msa_copy_u_d((v2i64) tmp2, 0); + SD(out0, dst); + dst += dst_stride; + SD(out1, dst); + dst += dst_stride; + SD(out2, dst); + dst += dst_stride; + + src2 = src5; + vec0 = vec3; + vec2 = vec4; + } +} + +static void common_vt_4t_8x4mult_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, int32_t height, + uint8_t rnd_val) +{ + uint32_t loop_cnt; + v16i8 src0, src1, src2, src7, src8, src9, src10; + v16i8 src10_r, src72_r, src98_r, src21_r, src87_r, src109_r, filt0, filt1; + v16u8 tmp0, tmp1; + v8i16 filt, out0_r, out1_r, out2_r, out3_r; + v8i16 rnd_vec; + + src -= src_stride; + rnd_vec = __msa_fill_h(rnd_val); + + filt = LD_SH(filter); + SPLATI_H2_SB(filt, 0, 1, filt0, filt1); + + LD_SB3(src, src_stride, src0, src1, src2); + src += (3 * src_stride); + + XORI_B3_128_SB(src0, src1, src2); + ILVR_B2_SB(src1, src0, src2, src1, src10_r, src21_r); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src7, src8, src9, src10); + src += (4 * src_stride); + + XORI_B4_128_SB(src7, src8, src9, src10); + ILVR_B4_SB(src7, src2, src8, src7, src9, src8, src10, src9, + src72_r, src87_r, src98_r, src109_r); + out0_r = FILT_4TAP_DPADD_S_H(src10_r, src72_r, filt0, filt1); + out1_r = FILT_4TAP_DPADD_S_H(src21_r, src87_r, filt0, filt1); + out2_r = FILT_4TAP_DPADD_S_H(src72_r, src98_r, filt0, filt1); + out3_r = FILT_4TAP_DPADD_S_H(src87_r, src109_r, filt0, filt1); + SRAR_H4_SH(out0_r, out1_r, out2_r, out3_r, rnd_vec); + SAT_SH4_SH(out0_r, out1_r, out2_r, out3_r, 7); + tmp0 = PCKEV_XORI128_UB(out0_r, out1_r); + tmp1 = PCKEV_XORI128_UB(out2_r, out3_r); + ST8x4_UB(tmp0, tmp1, dst, dst_stride); + dst += (4 * dst_stride); + + src10_r = src98_r; + src21_r = src109_r; + src2 = src10; + } +} + +static void common_vt_4t_8w_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, int32_t height, + uint8_t rnd_val) +{ + if (2 == height) { + common_vt_4t_8x2_msa(src, src_stride, dst, dst_stride, filter, rnd_val); + } else if (6 == height) { + common_vt_4t_8x6_msa(src, src_stride, dst, dst_stride, filter, rnd_val); + } else { + common_vt_4t_8x4mult_msa(src, src_stride, dst, dst_stride, + filter, height, rnd_val); + } +} + +static void common_vt_4t_12w_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, int32_t height, + uint8_t rnd_val) +{ + uint32_t loop_cnt; + v16i8 src0, src1, src2, src3, src4, src5, src6; + v16i8 vec0, vec1, vec2, vec3, vec4, vec5; + v16u8 out0, out1; + v8i16 src10, src21, src32, src43, src54, src65, src87, src109, src1211; + v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, filt, filt0, filt1; + v4u32 mask = { 2, 6, 2, 6 }; + v8i16 rnd_vec; + + /* rearranging filter_y */ + filt = LD_SH(filter); + SPLATI_H2_SH(filt, 0, 1, filt0, filt1); + + rnd_vec = __msa_fill_h(rnd_val); + + src -= src_stride; + + LD_SB3(src, src_stride, src0, src1, src2); + src += (3 * src_stride); + + XORI_B3_128_SB(src0, src1, src2); + VSHF_W2_SB(src0, src1, src1, src2, mask, mask, vec0, vec1); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src3, src4, src5, src6); + src += (4 * src_stride); + + XORI_B4_128_SB(src3, src4, src5, src6); + ILVR_B2_SH(src1, src0, src3, src2, src10, src32); + VSHF_W2_SB(src2, src3, src3, src4, mask, mask, vec2, vec3); + VSHF_W2_SB(src4, src5, src5, src6, mask, mask, vec4, vec5); + tmp0 = FILT_4TAP_DPADD_S_H(src10, src32, filt0, filt1); + ILVR_B4_SH(src2, src1, src4, src3, src5, src4, src6, src5, + src21, src43, src54, src65); + tmp1 = FILT_4TAP_DPADD_S_H(src21, src43, filt0, filt1); + tmp2 = FILT_4TAP_DPADD_S_H(src32, src54, filt0, filt1); + tmp3 = FILT_4TAP_DPADD_S_H(src43, src65, filt0, filt1); + ILVR_B3_SH(vec1, vec0, vec3, vec2, vec5, vec4, src87, src109, src1211); + tmp4 = FILT_4TAP_DPADD_S_H(src87, src109, filt0, filt1); + tmp5 = FILT_4TAP_DPADD_S_H(src109, src1211, filt0, filt1); + SRAR_H4_SH(tmp0, tmp1, tmp2, tmp3, rnd_vec); + SRAR_H2_SH(tmp4, tmp5, rnd_vec); + SAT_SH4_SH(tmp0, tmp1, tmp2, tmp3, 7); + SAT_SH2_SH(tmp4, tmp5, 7); + out0 = PCKEV_XORI128_UB(tmp0, tmp1); + out1 = PCKEV_XORI128_UB(tmp2, tmp3); + ST8x4_UB(out0, out1, dst, dst_stride); + out0 = PCKEV_XORI128_UB(tmp4, tmp5); + ST4x4_UB(out0, out0, 0, 1, 2, 3, dst + 8, dst_stride); + dst += (4 * dst_stride); + + src0 = src4; + src1 = src5; + src2 = src6; + vec0 = vec4; + vec1 = vec5; + src2 = src6; + } +} + +static void common_vt_4t_16w_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, int32_t height, + uint8_t rnd_val) +{ + uint32_t loop_cnt; + v16i8 src0, src1, src2, src3, src4, src5, src6; + v16i8 src10_r, src32_r, src54_r, src21_r, src43_r, src65_r, src10_l; + v16i8 src32_l, src54_l, src21_l, src43_l, src65_l, filt0, filt1; + v16u8 tmp0, tmp1, tmp2, tmp3; + v8i16 filt, out0_r, out1_r, out2_r, out3_r, out0_l, out1_l, out2_l, out3_l; + v8i16 rnd_vec; + + src -= src_stride; + rnd_vec = __msa_fill_h(rnd_val); + + filt = LD_SH(filter); + SPLATI_H2_SB(filt, 0, 1, filt0, filt1); + + LD_SB3(src, src_stride, src0, src1, src2); + src += (3 * src_stride); + + XORI_B3_128_SB(src0, src1, src2); + ILVR_B2_SB(src1, src0, src2, src1, src10_r, src21_r); + ILVL_B2_SB(src1, src0, src2, src1, src10_l, src21_l); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src3, src4, src5, src6); + src += (4 * src_stride); + + XORI_B4_128_SB(src3, src4, src5, src6); + ILVR_B4_SB(src3, src2, src4, src3, src5, src4, src6, src5, + src32_r, src43_r, src54_r, src65_r); + ILVL_B4_SB(src3, src2, src4, src3, src5, src4, src6, src5, + src32_l, src43_l, src54_l, src65_l); + out0_r = FILT_4TAP_DPADD_S_H(src10_r, src32_r, filt0, filt1); + out1_r = FILT_4TAP_DPADD_S_H(src21_r, src43_r, filt0, filt1); + out2_r = FILT_4TAP_DPADD_S_H(src32_r, src54_r, filt0, filt1); + out3_r = FILT_4TAP_DPADD_S_H(src43_r, src65_r, filt0, filt1); + out0_l = FILT_4TAP_DPADD_S_H(src10_l, src32_l, filt0, filt1); + out1_l = FILT_4TAP_DPADD_S_H(src21_l, src43_l, filt0, filt1); + out2_l = FILT_4TAP_DPADD_S_H(src32_l, src54_l, filt0, filt1); + out3_l = FILT_4TAP_DPADD_S_H(src43_l, src65_l, filt0, filt1); + SRAR_H4_SH(out0_r, out1_r, out2_r, out3_r, rnd_vec); + SRAR_H4_SH(out0_l, out1_l, out2_l, out3_l, rnd_vec); + SAT_SH4_SH(out0_r, out1_r, out2_r, out3_r, 7); + SAT_SH4_SH(out0_l, out1_l, out2_l, out3_l, 7); + PCKEV_B4_UB(out0_l, out0_r, out1_l, out1_r, out2_l, out2_r, out3_l, + out3_r, tmp0, tmp1, tmp2, tmp3); + XORI_B4_128_UB(tmp0, tmp1, tmp2, tmp3); + ST_UB4(tmp0, tmp1, tmp2, tmp3, dst, dst_stride); + dst += (4 * dst_stride); + + src10_r = src54_r; + src21_r = src65_r; + src10_l = src54_l; + src21_l = src65_l; + src2 = src6; + } +} + +static void common_vt_4t_24w_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, int32_t height, + uint8_t rnd_val) +{ + uint32_t loop_cnt; + uint64_t out0, out1; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, src10; + v16i8 src11, filt0, filt1; + v16i8 src10_r, src32_r, src76_r, src98_r, src21_r, src43_r, src87_r; + v16i8 src109_r, src10_l, src32_l, src21_l, src43_l; + v16u8 out; + v8i16 filt, out0_r, out1_r, out2_r, out3_r, out0_l, out1_l; + v8i16 rnd_vec; + + src -= src_stride; + + filt = LD_SH(filter); + SPLATI_H2_SB(filt, 0, 1, filt0, filt1); + + rnd_vec = __msa_fill_h(rnd_val); + + /* 16 width */ + LD_SB3(src, src_stride, src0, src1, src2); + XORI_B3_128_SB(src0, src1, src2); + ILVR_B2_SB(src1, src0, src2, src1, src10_r, src21_r); + ILVL_B2_SB(src1, src0, src2, src1, src10_l, src21_l); + + /* 8 width */ + LD_SB3(src + 16, src_stride, src6, src7, src8); + src += (3 * src_stride); + XORI_B3_128_SB(src6, src7, src8); + ILVR_B2_SB(src7, src6, src8, src7, src76_r, src87_r); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + /* 16 width */ + LD_SB2(src, src_stride, src3, src4); + XORI_B2_128_SB(src3, src4); + ILVR_B2_SB(src3, src2, src4, src3, src32_r, src43_r); + ILVL_B2_SB(src3, src2, src4, src3, src32_l, src43_l); + + /* 8 width */ + LD_SB2(src + 16, src_stride, src9, src10); + src += (2 * src_stride); + XORI_B2_128_SB(src9, src10); + ILVR_B2_SB(src9, src8, src10, src9, src98_r, src109_r); + + /* 16 width */ + out0_r = FILT_4TAP_DPADD_S_H(src10_r, src32_r, filt0, filt1); + out0_l = FILT_4TAP_DPADD_S_H(src10_l, src32_l, filt0, filt1); + out1_r = FILT_4TAP_DPADD_S_H(src21_r, src43_r, filt0, filt1); + out1_l = FILT_4TAP_DPADD_S_H(src21_l, src43_l, filt0, filt1); + + /* 8 width */ + out2_r = FILT_4TAP_DPADD_S_H(src76_r, src98_r, filt0, filt1); + out3_r = FILT_4TAP_DPADD_S_H(src87_r, src109_r, filt0, filt1); + + /* 16 + 8 width */ + SRAR_H4_SH(out0_r, out1_r, out2_r, out3_r, rnd_vec); + SRAR_H2_SH(out0_l, out1_l, rnd_vec); + SAT_SH4_SH(out0_r, out1_r, out2_r, out3_r, 7); + SAT_SH2_SH(out0_l, out1_l, 7); + out = PCKEV_XORI128_UB(out0_r, out0_l); + ST_UB(out, dst); + PCKEV_B2_SH(out2_r, out2_r, out3_r, out3_r, out2_r, out3_r); + XORI_B2_128_SH(out2_r, out3_r); + out0 = __msa_copy_u_d((v2i64) out2_r, 0); + out1 = __msa_copy_u_d((v2i64) out3_r, 0); + SD(out0, dst + 16); + dst += dst_stride; + out = PCKEV_XORI128_UB(out1_r, out1_l); + ST_UB(out, dst); + SD(out1, dst + 16); + dst += dst_stride; + + /* 16 width */ + LD_SB2(src, src_stride, src5, src2); + XORI_B2_128_SB(src5, src2); + ILVR_B2_SB(src5, src4, src2, src5, src10_r, src21_r); + ILVL_B2_SB(src5, src4, src2, src5, src10_l, src21_l); + + /* 8 width */ + LD_SB2(src + 16, src_stride, src11, src8); + src += (2 * src_stride); + XORI_B2_128_SB(src11, src8); + ILVR_B2_SB(src11, src10, src8, src11, src76_r, src87_r); + + /* 16 width */ + out0_r = FILT_4TAP_DPADD_S_H(src32_r, src10_r, filt0, filt1); + out0_l = FILT_4TAP_DPADD_S_H(src32_l, src10_l, filt0, filt1); + out1_r = FILT_4TAP_DPADD_S_H(src43_r, src21_r, filt0, filt1); + out1_l = FILT_4TAP_DPADD_S_H(src43_l, src21_l, filt0, filt1); + + /* 8 width */ + out2_r = FILT_4TAP_DPADD_S_H(src98_r, src76_r, filt0, filt1); + out3_r = FILT_4TAP_DPADD_S_H(src109_r, src87_r, filt0, filt1); + + /* 16 + 8 width */ + SRAR_H4_SH(out0_r, out1_r, out2_r, out3_r, rnd_vec); + SRAR_H2_SH(out0_l, out1_l, rnd_vec); + SAT_SH4_SH(out0_r, out1_r, out2_r, out3_r, 7); + SAT_SH2_SH(out0_l, out1_l, 7); + out = PCKEV_XORI128_UB(out0_r, out0_l); + ST_UB(out, dst); + out = PCKEV_XORI128_UB(out2_r, out2_r); + ST8x1_UB(out, dst + 16); + dst += dst_stride; + out = PCKEV_XORI128_UB(out1_r, out1_l); + ST_UB(out, dst); + out = PCKEV_XORI128_UB(out3_r, out3_r); + ST8x1_UB(out, dst + 16); + dst += dst_stride; + } +} + +static void common_vt_4t_32w_mult_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, int32_t height, + uint8_t rnd_val, int32_t width) +{ + uint32_t loop_cnt, cnt; + uint8_t *dst_tmp, *src_tmp; + v16i8 src0, src1, src2, src3, src4, src6, src7, src8, src9, src10; + v16i8 src10_r, src32_r, src76_r, src98_r; + v16i8 src21_r, src43_r, src87_r, src109_r; + v8i16 out0_r, out1_r, out2_r, out3_r, out0_l, out1_l, out2_l, out3_l; + v16i8 src10_l, src32_l, src76_l, src98_l; + v16i8 src21_l, src43_l, src87_l, src109_l; + v8i16 filt; + v16i8 filt0, filt1; + v8i16 rnd_vec; + v16u8 out; + + src -= src_stride; + rnd_vec = __msa_fill_h(rnd_val); + + filt = LD_SH(filter); + SPLATI_H2_SB(filt, 0, 1, filt0, filt1); + + for (cnt = (width >> 5); cnt--;) { + dst_tmp = dst; + src_tmp = src; + + /* 16 width */ + LD_SB3(src_tmp, src_stride, src0, src1, src2); + XORI_B3_128_SB(src0, src1, src2); + + ILVR_B2_SB(src1, src0, src2, src1, src10_r, src21_r); + ILVL_B2_SB(src1, src0, src2, src1, src10_l, src21_l); + + /* next 16 width */ + LD_SB3(src_tmp + 16, src_stride, src6, src7, src8); + src_tmp += (3 * src_stride); + + XORI_B3_128_SB(src6, src7, src8); + ILVR_B2_SB(src7, src6, src8, src7, src76_r, src87_r); + ILVL_B2_SB(src7, src6, src8, src7, src76_l, src87_l); + + for (loop_cnt = (height >> 1); loop_cnt--;) { + /* 16 width */ + LD_SB2(src_tmp, src_stride, src3, src4); + XORI_B2_128_SB(src3, src4); + ILVR_B2_SB(src3, src2, src4, src3, src32_r, src43_r); + ILVL_B2_SB(src3, src2, src4, src3, src32_l, src43_l); + + /* 16 width */ + out0_r = FILT_4TAP_DPADD_S_H(src10_r, src32_r, filt0, filt1); + out0_l = FILT_4TAP_DPADD_S_H(src10_l, src32_l, filt0, filt1); + out1_r = FILT_4TAP_DPADD_S_H(src21_r, src43_r, filt0, filt1); + out1_l = FILT_4TAP_DPADD_S_H(src21_l, src43_l, filt0, filt1); + + /* 16 width */ + SRAR_H4_SH(out0_r, out1_r, out0_l, out1_l, rnd_vec); + SAT_SH4_SH(out0_r, out1_r, out0_l, out1_l, 7); + out = PCKEV_XORI128_UB(out0_r, out0_l); + ST_UB(out, dst_tmp); + out = PCKEV_XORI128_UB(out1_r, out1_l); + ST_UB(out, dst_tmp + dst_stride); + + src10_r = src32_r; + src21_r = src43_r; + src10_l = src32_l; + src21_l = src43_l; + src2 = src4; + + /* next 16 width */ + LD_SB2(src_tmp + 16, src_stride, src9, src10); + src_tmp += (2 * src_stride); + XORI_B2_128_SB(src9, src10); + ILVR_B2_SB(src9, src8, src10, src9, src98_r, src109_r); + ILVL_B2_SB(src9, src8, src10, src9, src98_l, src109_l); + + /* next 16 width */ + out2_r = FILT_4TAP_DPADD_S_H(src76_r, src98_r, filt0, filt1); + out2_l = FILT_4TAP_DPADD_S_H(src76_l, src98_l, filt0, filt1); + out3_r = FILT_4TAP_DPADD_S_H(src87_r, src109_r, filt0, filt1); + out3_l = FILT_4TAP_DPADD_S_H(src87_l, src109_l, filt0, filt1); + + /* next 16 width */ + SRAR_H4_SH(out2_r, out3_r, out2_l, out3_l, rnd_vec); + SAT_SH4_SH(out2_r, out3_r, out2_l, out3_l, 7); + out = PCKEV_XORI128_UB(out2_r, out2_l); + ST_UB(out, dst_tmp + 16); + out = PCKEV_XORI128_UB(out3_r, out3_l); + ST_UB(out, dst_tmp + 16 + dst_stride); + + dst_tmp += 2 * dst_stride; + + src76_r = src98_r; + src87_r = src109_r; + src76_l = src98_l; + src87_l = src109_l; + src8 = src10; + } + + src += 32; + dst += 32; + } +} + +static void common_vt_4t_32w_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, int32_t height, + uint8_t rnd_val) +{ + common_vt_4t_32w_mult_msa(src, src_stride, dst, dst_stride, + filter, height, rnd_val, 32); +} + +static void hevc_hv_uni_4t_4x2_msa(uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + const int8_t *filter_x, + const int8_t *filter_y, + int32_t height) +{ + v16i8 src0, src1, src2, src3, src4; + v8i16 filt0, filt1; + v4i32 filt_h0, filt_h1; + v16i8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16i8 mask1; + v8i16 filter_vec, const_vec; + v16i8 vec0, vec1, vec2, vec3, vec4, vec5; + v8i16 dst0, dst1, dst2, dst3, dst4; + v4i32 dst0_r, dst1_r; + v8i16 dst10_r, dst32_r, dst21_r, dst43_r; + + src -= (src_stride + 1); + + filter_vec = LD_SH(filter_x); + SPLATI_H2_SH(filter_vec, 0, 1, filt0, filt1); + + filter_vec = LD_SH(filter_y); + vec0 = __msa_clti_s_b((v16i8) filter_vec, 0); + filter_vec = (v8i16) __msa_ilvr_b(vec0, (v16i8) filter_vec); + + SPLATI_W2_SW(filter_vec, 0, filt_h0, filt_h1); + + mask1 = mask0 + 2; + + const_vec = __msa_ldi_h(128); + const_vec <<= 6; + + LD_SB3(src, src_stride, src0, src1, src2); + src += (3 * src_stride); + + XORI_B3_128_SB(src0, src1, src2); + + VSHF_B2_SB(src0, src0, src0, src0, mask0, mask1, vec0, vec1); + VSHF_B2_SB(src1, src1, src1, src1, mask0, mask1, vec2, vec3); + VSHF_B2_SB(src2, src2, src2, src2, mask0, mask1, vec4, vec5); + + dst0 = const_vec; + DPADD_SB2_SH(vec0, vec1, filt0, filt1, dst0, dst0); + dst1 = const_vec; + DPADD_SB2_SH(vec2, vec3, filt0, filt1, dst1, dst1); + dst2 = const_vec; + DPADD_SB2_SH(vec4, vec5, filt0, filt1, dst2, dst2); + + ILVR_H2_SH(dst1, dst0, dst2, dst1, dst10_r, dst21_r); + LD_SB2(src, src_stride, src3, src4); + XORI_B2_128_SB(src3, src4); + + /* row 3 */ + VSHF_B2_SB(src3, src3, src3, src3, mask0, mask1, vec0, vec1); + dst3 = const_vec; + DPADD_SB2_SH(vec0, vec1, filt0, filt1, dst3, dst3); + + dst32_r = __msa_ilvr_h(dst3, dst2); + dst0_r = HEVC_FILT_4TAP(dst10_r, dst32_r, filt_h0, filt_h1); + dst0_r >>= 6; + + /* row 4 */ + VSHF_B2_SB(src4, src4, src4, src4, mask0, mask1, vec0, vec1); + dst4 = const_vec; + DPADD_SB2_SH(vec0, vec1, filt0, filt1, dst4, dst4); + + dst43_r = __msa_ilvr_h(dst4, dst3); + dst1_r = HEVC_FILT_4TAP(dst21_r, dst43_r, filt_h0, filt_h1); + dst1_r >>= 6; + + dst0_r = (v4i32) __msa_pckev_h((v8i16) dst1_r, (v8i16) dst0_r); + dst0_r = (v4i32) __msa_srari_h((v8i16) dst0_r, 6); + dst0_r = (v4i32) CLIP_SH_0_255(dst0_r); + dst0_r = (v4i32) __msa_pckev_b((v16i8) dst0_r, (v16i8) dst0_r); + + ST4x2_UB(dst0_r, dst, dst_stride); +} + +static void hevc_hv_uni_4t_4x4_msa(uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + const int8_t *filter_x, + const int8_t *filter_y, + int32_t height) +{ + v16i8 src0, src1, src2, src3, src4, src5, src6; + v8i16 filt0, filt1; + v4i32 filt_h0, filt_h1; + v16i8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16i8 mask1; + v8i16 filter_vec, const_vec; + v16i8 vec0, vec1, vec2, vec3, vec4, vec5; + v8i16 dst0, dst1, dst2, dst3, dst4, dst5; + v4i32 dst0_r, dst1_r, dst2_r, dst3_r; + v8i16 out0_r, out1_r; + v8i16 dst10_r, dst32_r, dst21_r, dst43_r; + + src -= (src_stride + 1); + + filter_vec = LD_SH(filter_x); + SPLATI_H2_SH(filter_vec, 0, 1, filt0, filt1); + + filter_vec = LD_SH(filter_y); + vec0 = __msa_clti_s_b((v16i8) filter_vec, 0); + filter_vec = (v8i16) __msa_ilvr_b(vec0, (v16i8) filter_vec); + + SPLATI_W2_SW(filter_vec, 0, filt_h0, filt_h1); + + mask1 = mask0 + 2; + + const_vec = __msa_ldi_h(128); + const_vec <<= 6; + + LD_SB3(src, src_stride, src0, src1, src2); + src += (3 * src_stride); + + XORI_B3_128_SB(src0, src1, src2); + + VSHF_B2_SB(src0, src0, src0, src0, mask0, mask1, vec0, vec1); + VSHF_B2_SB(src1, src1, src1, src1, mask0, mask1, vec2, vec3); + VSHF_B2_SB(src2, src2, src2, src2, mask0, mask1, vec4, vec5); + + dst0 = const_vec; + DPADD_SB2_SH(vec0, vec1, filt0, filt1, dst0, dst0); + dst1 = const_vec; + DPADD_SB2_SH(vec2, vec3, filt0, filt1, dst1, dst1); + dst2 = const_vec; + DPADD_SB2_SH(vec4, vec5, filt0, filt1, dst2, dst2); + + ILVR_H2_SH(dst1, dst0, dst2, dst1, dst10_r, dst21_r); + LD_SB4(src, src_stride, src3, src4, src5, src6); + XORI_B4_128_SB(src3, src4, src5, src6); + + /* row 3 */ + VSHF_B2_SB(src3, src3, src3, src3, mask0, mask1, vec0, vec1); + dst3 = const_vec; + DPADD_SB2_SH(vec0, vec1, filt0, filt1, dst3, dst3); + + dst32_r = __msa_ilvr_h(dst3, dst2); + dst0_r = HEVC_FILT_4TAP(dst10_r, dst32_r, filt_h0, filt_h1); + dst0_r >>= 6; + + /* row 4 */ + VSHF_B2_SB(src4, src4, src4, src4, mask0, mask1, vec0, vec1); + dst4 = const_vec; + DPADD_SB2_SH(vec0, vec1, filt0, filt1, dst4, dst4); + + dst43_r = __msa_ilvr_h(dst4, dst3); + dst1_r = HEVC_FILT_4TAP(dst21_r, dst43_r, filt_h0, filt_h1); + dst1_r >>= 6; + + /* row 5 */ + VSHF_B2_SB(src5, src5, src5, src5, mask0, mask1, vec0, vec1); + dst5 = const_vec; + DPADD_SB2_SH(vec0, vec1, filt0, filt1, dst5, dst5); + + dst10_r = __msa_ilvr_h(dst5, dst4); + dst2_r = HEVC_FILT_4TAP(dst32_r, dst10_r, filt_h0, filt_h1); + dst2_r >>= 6; + + /* row 6 */ + VSHF_B2_SB(src6, src6, src6, src6, mask0, mask1, vec0, vec1); + dst2 = const_vec; + DPADD_SB2_SH(vec0, vec1, filt0, filt1, dst2, dst2); + + dst21_r = __msa_ilvr_h(dst2, dst5); + dst3_r = HEVC_FILT_4TAP(dst43_r, dst21_r, filt_h0, filt_h1); + dst3_r >>= 6; + + PCKEV_H2_SH(dst1_r, dst0_r, dst3_r, dst2_r, out0_r, out1_r); + SRARI_H2_SH(out0_r, out1_r, 6); + CLIP_SH2_0_255(out0_r, out1_r); + out0_r = (v8i16) __msa_pckev_b((v16i8) out1_r, (v16i8) out0_r); + + ST4x4_UB(out0_r, out0_r, 0, 1, 2, 3, dst, dst_stride); +} + +static void hevc_hv_uni_4t_4multx8mult_msa(uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + const int8_t *filter_x, + const int8_t *filter_y, + int32_t height) +{ + uint32_t loop_cnt; + v16i8 src0, src1, src2, src3, src4, src5; + v16i8 src6, src7, src8, src9, src10; + v8i16 filt0, filt1; + v4i32 filt_h0, filt_h1; + v16i8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16i8 mask1; + v8i16 filter_vec, const_vec; + v16i8 vec0, vec1, vec2, vec3, vec4, vec5; + v8i16 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7, dst8, dst9; + v4i32 dst0_r, dst1_r, dst2_r, dst3_r, dst4_r, dst5_r, dst6_r, dst7_r; + v8i16 dst10_r, dst32_r, dst54_r, dst76_r; + v8i16 dst21_r, dst43_r, dst65_r, dst87_r; + v8i16 out0_r, out1_r, out2_r, out3_r; + + src -= (src_stride + 1); + + filter_vec = LD_SH(filter_x); + SPLATI_H2_SH(filter_vec, 0, 1, filt0, filt1); + + filter_vec = LD_SH(filter_y); + vec0 = __msa_clti_s_b((v16i8) filter_vec, 0); + filter_vec = (v8i16) __msa_ilvr_b(vec0, (v16i8) filter_vec); + + SPLATI_W2_SW(filter_vec, 0, filt_h0, filt_h1); + + mask1 = mask0 + 2; + + const_vec = __msa_ldi_h(128); + const_vec <<= 6; + + LD_SB3(src, src_stride, src0, src1, src2); + src += (3 * src_stride); + + XORI_B3_128_SB(src0, src1, src2); + + VSHF_B2_SB(src0, src0, src0, src0, mask0, mask1, vec0, vec1); + VSHF_B2_SB(src1, src1, src1, src1, mask0, mask1, vec2, vec3); + VSHF_B2_SB(src2, src2, src2, src2, mask0, mask1, vec4, vec5); + + dst0 = const_vec; + DPADD_SB2_SH(vec0, vec1, filt0, filt1, dst0, dst0); + dst1 = const_vec; + DPADD_SB2_SH(vec2, vec3, filt0, filt1, dst1, dst1); + dst2 = const_vec; + DPADD_SB2_SH(vec4, vec5, filt0, filt1, dst2, dst2); + + ILVR_H2_SH(dst1, dst0, dst2, dst1, dst10_r, dst21_r); + + for (loop_cnt = height >> 3; loop_cnt--;) { + LD_SB8(src, src_stride, + src3, src4, src5, src6, src7, src8, src9, src10); + src += (8 * src_stride); + + XORI_B8_128_SB(src3, src4, src5, src6, src7, src8, src9, src10); + + /* row 3 */ + VSHF_B2_SB(src3, src3, src3, src3, mask0, mask1, vec0, vec1); + dst3 = const_vec; + DPADD_SB2_SH(vec0, vec1, filt0, filt1, dst3, dst3); + + dst32_r = __msa_ilvr_h(dst3, dst2); + dst0_r = HEVC_FILT_4TAP(dst10_r, dst32_r, filt_h0, filt_h1); + dst0_r >>= 6; + + /* row 4 */ + VSHF_B2_SB(src4, src4, src4, src4, mask0, mask1, vec0, vec1); + dst4 = const_vec; + DPADD_SB2_SH(vec0, vec1, filt0, filt1, dst4, dst4); + + dst43_r = __msa_ilvr_h(dst4, dst3); + dst1_r = HEVC_FILT_4TAP(dst21_r, dst43_r, filt_h0, filt_h1); + dst1_r >>= 6; + + /* row 5 */ + VSHF_B2_SB(src5, src5, src5, src5, mask0, mask1, vec0, vec1); + dst5 = const_vec; + DPADD_SB2_SH(vec0, vec1, filt0, filt1, dst5, dst5); + + dst54_r = __msa_ilvr_h(dst5, dst4); + dst2_r = HEVC_FILT_4TAP(dst32_r, dst54_r, filt_h0, filt_h1); + dst2_r >>= 6; + + /* row 6 */ + VSHF_B2_SB(src6, src6, src6, src6, mask0, mask1, vec0, vec1); + dst6 = const_vec; + DPADD_SB2_SH(vec0, vec1, filt0, filt1, dst6, dst6); + + dst65_r = __msa_ilvr_h(dst6, dst5); + dst3_r = HEVC_FILT_4TAP(dst43_r, dst65_r, filt_h0, filt_h1); + dst3_r >>= 6; + + /* row 7 */ + VSHF_B2_SB(src7, src7, src7, src7, mask0, mask1, vec0, vec1); + dst7 = const_vec; + DPADD_SB2_SH(vec0, vec1, filt0, filt1, dst7, dst7); + + dst76_r = __msa_ilvr_h(dst7, dst6); + dst4_r = HEVC_FILT_4TAP(dst54_r, dst76_r, filt_h0, filt_h1); + dst4_r >>= 6; + + /* row 8 */ + VSHF_B2_SB(src8, src8, src8, src8, mask0, mask1, vec0, vec1); + dst8 = const_vec; + DPADD_SB2_SH(vec0, vec1, filt0, filt1, dst8, dst8); + + dst87_r = __msa_ilvr_h(dst8, dst7); + dst5_r = HEVC_FILT_4TAP(dst65_r, dst87_r, filt_h0, filt_h1); + dst5_r >>= 6; + + /* row 9 */ + VSHF_B2_SB(src9, src9, src9, src9, mask0, mask1, vec0, vec1); + dst9 = const_vec; + DPADD_SB2_SH(vec0, vec1, filt0, filt1, dst9, dst9); + + dst10_r = __msa_ilvr_h(dst9, dst8); + dst6_r = HEVC_FILT_4TAP(dst76_r, dst10_r, filt_h0, filt_h1); + dst6_r >>= 6; + + /* row 10 */ + VSHF_B2_SB(src10, src10, src10, src10, mask0, mask1, vec0, vec1); + dst2 = const_vec; + DPADD_SB2_SH(vec0, vec1, filt0, filt1, dst2, dst2); + + dst21_r = __msa_ilvr_h(dst2, dst9); + dst7_r = HEVC_FILT_4TAP(dst87_r, dst21_r, filt_h0, filt_h1); + dst7_r >>= 6; + + PCKEV_H4_SH(dst1_r, dst0_r, dst3_r, dst2_r, + dst5_r, dst4_r, dst7_r, dst6_r, + out0_r, out1_r, out2_r, out3_r); + + SRARI_H4_SH(out0_r, out1_r, out2_r, out3_r, 6); + CLIP_SH4_0_255(out0_r, out1_r, out2_r, out3_r); + + PCKEV_B2_SH(out1_r, out0_r, out3_r, out2_r, out0_r, out1_r); + ST4x8_UB(out0_r, out1_r, dst, dst_stride); + dst += (8 * dst_stride); + } +} + +static void hevc_hv_uni_4t_4w_msa(uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + const int8_t *filter_x, + const int8_t *filter_y, + int32_t height) +{ + if (2 == height) { + hevc_hv_uni_4t_4x2_msa(src, src_stride, dst, dst_stride, + filter_x, filter_y, height); + } else if (4 == height) { + hevc_hv_uni_4t_4x4_msa(src, src_stride, dst, dst_stride, + filter_x, filter_y, height); + } else if (0 == (height % 8)) { + hevc_hv_uni_4t_4multx8mult_msa(src, src_stride, dst, dst_stride, + filter_x, filter_y, height); + } +} + +static void hevc_hv_uni_4t_6w_msa(uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + const int8_t *filter_x, + const int8_t *filter_y, + int32_t height) +{ + uint32_t loop_cnt; + v16i8 src0, src1, src2, src3, src4, src5, src6; + v8i16 filt0, filt1; + v4i32 filt_h0, filt_h1; + v16i8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16i8 mask1; + v8i16 filter_vec, const_vec; + v16i8 vec0, vec1, vec2, vec3, vec4, vec5; + v8i16 dst0, dst1, dst2, dst3, dst4, dst5; + v4i32 dst0_r, dst0_l, dst1_r, dst1_l, dst2_r, dst2_l, dst3_r, dst3_l; + v8i16 dst10_r, dst32_r, dst21_r, dst43_r; + v8i16 dst10_l, dst32_l, dst21_l, dst43_l; + v8i16 out0_r, out1_r, out2_r, out3_r; + + src -= (src_stride + 1); + + filter_vec = LD_SH(filter_x); + SPLATI_H2_SH(filter_vec, 0, 1, filt0, filt1); + + filter_vec = LD_SH(filter_y); + vec0 = __msa_clti_s_b((v16i8) filter_vec, 0); + filter_vec = (v8i16) __msa_ilvr_b(vec0, (v16i8) filter_vec); + + SPLATI_W2_SW(filter_vec, 0, filt_h0, filt_h1); + + mask1 = mask0 + 2; + + const_vec = __msa_ldi_h(128); + const_vec <<= 6; + + LD_SB3(src, src_stride, src0, src1, src2); + src += (3 * src_stride); + + XORI_B3_128_SB(src0, src1, src2); + + VSHF_B2_SB(src0, src0, src0, src0, mask0, mask1, vec0, vec1); + VSHF_B2_SB(src1, src1, src1, src1, mask0, mask1, vec2, vec3); + VSHF_B2_SB(src2, src2, src2, src2, mask0, mask1, vec4, vec5); + + dst0 = const_vec; + DPADD_SB2_SH(vec0, vec1, filt0, filt1, dst0, dst0); + dst1 = const_vec; + DPADD_SB2_SH(vec2, vec3, filt0, filt1, dst1, dst1); + dst2 = const_vec; + DPADD_SB2_SH(vec4, vec5, filt0, filt1, dst2, dst2); + + ILVRL_H2_SH(dst1, dst0, dst10_r, dst10_l); + ILVRL_H2_SH(dst2, dst1, dst21_r, dst21_l); + + for (loop_cnt = height >> 2; loop_cnt--;) { + LD_SB4(src, src_stride, src3, src4, src5, src6); + src += (4 * src_stride); + + XORI_B4_128_SB(src3, src4, src5, src6); + + /* row 3 */ + VSHF_B2_SB(src3, src3, src3, src3, mask0, mask1, vec0, vec1); + dst3 = const_vec; + DPADD_SB2_SH(vec0, vec1, filt0, filt1, dst3, dst3); + + ILVRL_H2_SH(dst3, dst2, dst32_r, dst32_l); + dst0_r = HEVC_FILT_4TAP(dst10_r, dst32_r, filt_h0, filt_h1); + dst0_l = HEVC_FILT_4TAP(dst10_l, dst32_l, filt_h0, filt_h1); + dst0_r >>= 6; + dst0_l >>= 6; + + /* row 4 */ + VSHF_B2_SB(src4, src4, src4, src4, mask0, mask1, vec0, vec1); + dst4 = const_vec; + DPADD_SB2_SH(vec0, vec1, filt0, filt1, dst4, dst4); + + ILVRL_H2_SH(dst4, dst3, dst43_r, dst43_l); + dst1_r = HEVC_FILT_4TAP(dst21_r, dst43_r, filt_h0, filt_h1); + dst1_l = HEVC_FILT_4TAP(dst21_l, dst43_l, filt_h0, filt_h1); + dst1_r >>= 6; + dst1_l >>= 6; + + /* row 5 */ + VSHF_B2_SB(src5, src5, src5, src5, mask0, mask1, vec0, vec1); + dst5 = const_vec; + DPADD_SB2_SH(vec0, vec1, filt0, filt1, dst5, dst5); + + ILVRL_H2_SH(dst5, dst4, dst10_r, dst10_l); + dst2_r = HEVC_FILT_4TAP(dst32_r, dst10_r, filt_h0, filt_h1); + dst2_l = HEVC_FILT_4TAP(dst32_l, dst10_l, filt_h0, filt_h1); + + dst2_r >>= 6; + dst2_l >>= 6; + + /* row 6 */ + VSHF_B2_SB(src6, src6, src6, src6, mask0, mask1, vec0, vec1); + dst2 = const_vec; + DPADD_SB2_SH(vec0, vec1, filt0, filt1, dst2, dst2); + + ILVRL_H2_SH(dst2, dst5, dst21_r, dst21_l); + dst3_r = HEVC_FILT_4TAP(dst43_r, dst21_r, filt_h0, filt_h1); + dst3_l = HEVC_FILT_4TAP(dst43_l, dst21_l, filt_h0, filt_h1); + + dst3_r >>= 6; + dst3_l >>= 6; + + PCKEV_H4_SH(dst0_l, dst0_r, dst1_l, dst1_r, + dst2_l, dst2_r, dst3_l, dst3_r, + out0_r, out1_r, out2_r, out3_r); + + SRARI_H4_SH(out0_r, out1_r, out2_r, out3_r, 6); + CLIP_SH4_0_255(out0_r, out1_r, out2_r, out3_r); + + PCKEV_B2_SH(out1_r, out0_r, out3_r, out2_r, out0_r, out1_r); + ST6x4_UB(out0_r, out1_r, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +static void hevc_hv_uni_4t_8x2_msa(uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + const int8_t *filter_x, + const int8_t *filter_y, + int32_t height) +{ + v16i8 src0, src1, src2, src3, src4; + v8i16 filt0, filt1; + v4i32 filt_h0, filt_h1; + v16i8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16i8 mask1; + v8i16 filter_vec, const_vec; + v16i8 vec0, vec1, vec2, vec3, vec4, vec5; + v8i16 dst0, dst1, dst2, dst3, dst4; + v4i32 dst0_r, dst0_l, dst1_r, dst1_l; + v8i16 dst10_r, dst32_r, dst21_r, dst43_r; + v8i16 dst10_l, dst32_l, dst21_l, dst43_l; + v8i16 out0_r, out1_r; + + src -= (src_stride + 1); + + filter_vec = LD_SH(filter_x); + SPLATI_H2_SH(filter_vec, 0, 1, filt0, filt1); + + filter_vec = LD_SH(filter_y); + vec0 = __msa_clti_s_b((v16i8) filter_vec, 0); + filter_vec = (v8i16) __msa_ilvr_b(vec0, (v16i8) filter_vec); + + SPLATI_W2_SW(filter_vec, 0, filt_h0, filt_h1); + + mask1 = mask0 + 2; + + const_vec = __msa_ldi_h(128); + const_vec <<= 6; + + LD_SB3(src, src_stride, src0, src1, src2); + src += (3 * src_stride); + + XORI_B3_128_SB(src0, src1, src2); + + VSHF_B2_SB(src0, src0, src0, src0, mask0, mask1, vec0, vec1); + VSHF_B2_SB(src1, src1, src1, src1, mask0, mask1, vec2, vec3); + VSHF_B2_SB(src2, src2, src2, src2, mask0, mask1, vec4, vec5); + + dst0 = const_vec; + DPADD_SB2_SH(vec0, vec1, filt0, filt1, dst0, dst0); + dst1 = const_vec; + DPADD_SB2_SH(vec2, vec3, filt0, filt1, dst1, dst1); + dst2 = const_vec; + DPADD_SB2_SH(vec4, vec5, filt0, filt1, dst2, dst2); + + ILVRL_H2_SH(dst1, dst0, dst10_r, dst10_l); + ILVRL_H2_SH(dst2, dst1, dst21_r, dst21_l); + + LD_SB2(src, src_stride, src3, src4); + XORI_B2_128_SB(src3, src4); + + /* row 3 */ + VSHF_B2_SB(src3, src3, src3, src3, mask0, mask1, vec0, vec1); + dst3 = const_vec; + DPADD_SB2_SH(vec0, vec1, filt0, filt1, dst3, dst3); + + ILVRL_H2_SH(dst3, dst2, dst32_r, dst32_l); + dst0_r = HEVC_FILT_4TAP(dst10_r, dst32_r, filt_h0, filt_h1); + dst0_l = HEVC_FILT_4TAP(dst10_l, dst32_l, filt_h0, filt_h1); + dst0_r >>= 6; + dst0_l >>= 6; + + /* row 4 */ + VSHF_B2_SB(src4, src4, src4, src4, mask0, mask1, vec0, vec1); + dst4 = const_vec; + DPADD_SB2_SH(vec0, vec1, filt0, filt1, dst4, dst4); + + ILVRL_H2_SH(dst4, dst3, dst43_r, dst43_l); + dst1_r = HEVC_FILT_4TAP(dst21_r, dst43_r, filt_h0, filt_h1); + dst1_l = HEVC_FILT_4TAP(dst21_l, dst43_l, filt_h0, filt_h1); + dst1_r >>= 6; + dst1_l >>= 6; + + PCKEV_H2_SH(dst0_l, dst0_r, dst1_l, dst1_r, out0_r, out1_r); + SRARI_H2_SH(out0_r, out1_r, 6); + CLIP_SH2_0_255(out0_r, out1_r); + out0_r = (v8i16) __msa_pckev_b((v16i8) out1_r, (v16i8) out0_r); + + ST8x2_UB(out0_r, dst, dst_stride); +} + +static void hevc_hv_uni_4t_8x6_msa(uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + const int8_t *filter_x, + const int8_t *filter_y, + int32_t height) +{ + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8; + v8i16 filt0, filt1; + v4i32 filt_h0, filt_h1; + v16i8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16i8 mask1; + v8i16 filter_vec, const_vec; + v16i8 vec0, vec1, vec2, vec3, vec4, vec5; + v8i16 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7, dst8; + v4i32 dst0_r, dst0_l, dst1_r, dst1_l, dst2_r, dst2_l, dst3_r, dst3_l; + v4i32 dst4_r, dst4_l, dst5_r, dst5_l; + v8i16 dst10_r, dst32_r, dst10_l, dst32_l; + v8i16 dst21_r, dst43_r, dst21_l, dst43_l; + v8i16 dst54_r, dst54_l, dst65_r, dst65_l; + v8i16 dst76_r, dst76_l, dst87_r, dst87_l; + v8i16 out0_r, out1_r, out2_r, out3_r, out4_r, out5_r; + + src -= (src_stride + 1); + + filter_vec = LD_SH(filter_x); + SPLATI_H2_SH(filter_vec, 0, 1, filt0, filt1); + + filter_vec = LD_SH(filter_y); + vec0 = __msa_clti_s_b((v16i8) filter_vec, 0); + filter_vec = (v8i16) __msa_ilvr_b(vec0, (v16i8) filter_vec); + + SPLATI_W2_SW(filter_vec, 0, filt_h0, filt_h1); + + mask1 = mask0 + 2; + + const_vec = __msa_ldi_h(128); + const_vec <<= 6; + + LD_SB3(src, src_stride, src0, src1, src2); + src += (3 * src_stride); + + XORI_B3_128_SB(src0, src1, src2); + + VSHF_B2_SB(src0, src0, src0, src0, mask0, mask1, vec0, vec1); + VSHF_B2_SB(src1, src1, src1, src1, mask0, mask1, vec2, vec3); + VSHF_B2_SB(src2, src2, src2, src2, mask0, mask1, vec4, vec5); + + dst0 = const_vec; + DPADD_SB2_SH(vec0, vec1, filt0, filt1, dst0, dst0); + dst1 = const_vec; + DPADD_SB2_SH(vec2, vec3, filt0, filt1, dst1, dst1); + dst2 = const_vec; + DPADD_SB2_SH(vec4, vec5, filt0, filt1, dst2, dst2); + + ILVRL_H2_SH(dst1, dst0, dst10_r, dst10_l); + ILVRL_H2_SH(dst2, dst1, dst21_r, dst21_l); + + LD_SB2(src, src_stride, src3, src4); + src += (2 * src_stride); + + XORI_B2_128_SB(src3, src4); + + /* row 3 */ + VSHF_B2_SB(src3, src3, src3, src3, mask0, mask1, vec0, vec1); + dst3 = const_vec; + DPADD_SB2_SH(vec0, vec1, filt0, filt1, dst3, dst3); + + ILVRL_H2_SH(dst3, dst2, dst32_r, dst32_l); + dst0_r = HEVC_FILT_4TAP(dst10_r, dst32_r, filt_h0, filt_h1); + dst0_l = HEVC_FILT_4TAP(dst10_l, dst32_l, filt_h0, filt_h1); + + dst0_r >>= 6; + dst0_l >>= 6; + + /* row 4 */ + VSHF_B2_SB(src4, src4, src4, src4, mask0, mask1, vec0, vec1); + dst4 = const_vec; + DPADD_SB2_SH(vec0, vec1, filt0, filt1, dst4, dst4); + + ILVRL_H2_SH(dst4, dst3, dst43_r, dst43_l); + dst1_r = HEVC_FILT_4TAP(dst21_r, dst43_r, filt_h0, filt_h1); + dst1_l = HEVC_FILT_4TAP(dst21_l, dst43_l, filt_h0, filt_h1); + dst1_r >>= 6; + dst1_l >>= 6; + + LD_SB2(src, src_stride, src5, src6); + src += (2 * src_stride); + + XORI_B2_128_SB(src5, src6); + + /* row 5 */ + VSHF_B2_SB(src5, src5, src5, src5, mask0, mask1, vec0, vec1); + dst5 = const_vec; + DPADD_SB2_SH(vec0, vec1, filt0, filt1, dst5, dst5); + + ILVRL_H2_SH(dst5, dst4, dst54_r, dst54_l); + dst2_r = HEVC_FILT_4TAP(dst32_r, dst54_r, filt_h0, filt_h1); + dst2_l = HEVC_FILT_4TAP(dst32_l, dst54_l, filt_h0, filt_h1); + dst2_r >>= 6; + dst2_l >>= 6; + + /* row 6 */ + VSHF_B2_SB(src6, src6, src6, src6, mask0, mask1, vec0, vec1); + dst6 = const_vec; + DPADD_SB2_SH(vec0, vec1, filt0, filt1, dst6, dst6); + + ILVRL_H2_SH(dst6, dst5, dst65_r, dst65_l); + dst3_r = HEVC_FILT_4TAP(dst43_r, dst65_r, filt_h0, filt_h1); + dst3_l = HEVC_FILT_4TAP(dst43_l, dst65_l, filt_h0, filt_h1); + dst3_r >>= 6; + dst3_l >>= 6; + + LD_SB2(src, src_stride, src7, src8); + src += (2 * src_stride); + + XORI_B2_128_SB(src7, src8); + + /* row 7 */ + VSHF_B2_SB(src7, src7, src7, src7, mask0, mask1, vec0, vec1); + dst7 = const_vec; + DPADD_SB2_SH(vec0, vec1, filt0, filt1, dst7, dst7); + + ILVRL_H2_SH(dst7, dst6, dst76_r, dst76_l); + dst4_r = HEVC_FILT_4TAP(dst54_r, dst76_r, filt_h0, filt_h1); + dst4_l = HEVC_FILT_4TAP(dst54_l, dst76_l, filt_h0, filt_h1); + + dst4_r >>= 6; + dst4_l >>= 6; + + /* row 8 */ + VSHF_B2_SB(src8, src8, src8, src8, mask0, mask1, vec0, vec1); + dst8 = const_vec; + DPADD_SB2_SH(vec0, vec1, filt0, filt1, dst8, dst8); + + ILVRL_H2_SH(dst8, dst7, dst87_r, dst87_l); + dst5_r = HEVC_FILT_4TAP(dst65_r, dst87_r, filt_h0, filt_h1); + dst5_l = HEVC_FILT_4TAP(dst65_l, dst87_l, filt_h0, filt_h1); + dst5_r >>= 6; + dst5_l >>= 6; + + PCKEV_H4_SH(dst0_l, dst0_r, dst1_l, dst1_r, + dst2_l, dst2_r, dst3_l, dst3_r, out0_r, out1_r, out2_r, out3_r); + PCKEV_H2_SH(dst4_l, dst4_r, dst5_l, dst5_r, out4_r, out5_r); + SRARI_H4_SH(out0_r, out1_r, out2_r, out3_r, 6); + SRARI_H2_SH(out4_r, out5_r, 6); + CLIP_SH4_0_255(out0_r, out1_r, out2_r, out3_r); + CLIP_SH2_0_255(out4_r, out5_r); + + PCKEV_B2_SH(out1_r, out0_r, out3_r, out2_r, out0_r, out1_r); + out2_r = (v8i16) __msa_pckev_b((v16i8) out5_r, (v16i8) out4_r); + + ST8x4_UB(out0_r, out1_r, dst, dst_stride); + dst += (4 * dst_stride); + ST8x2_UB(out2_r, dst, dst_stride); +} + +static void hevc_hv_uni_4t_8w_mult_msa(uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + const int8_t *filter_x, + const int8_t *filter_y, + int32_t height, + int32_t width) +{ + uint32_t loop_cnt, cnt; + uint8_t *src_tmp; + uint8_t *dst_tmp; + v16i8 src0, src1, src2, src3, src4, src5, src6; + v8i16 filt0, filt1; + v4i32 filt_h0, filt_h1; + v16i8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16i8 mask1; + v8i16 filter_vec, const_vec; + v16i8 vec0, vec1, vec2, vec3, vec4, vec5; + v8i16 dst0, dst1, dst2, dst3, dst4, dst5; + v4i32 dst0_r, dst0_l, dst1_r, dst1_l, dst2_r, dst2_l, dst3_r, dst3_l; + v8i16 dst10_r, dst32_r, dst21_r, dst43_r; + v8i16 dst10_l, dst32_l, dst21_l, dst43_l; + v8i16 out0_r, out1_r, out2_r, out3_r; + + src -= (src_stride + 1); + + filter_vec = LD_SH(filter_x); + SPLATI_H2_SH(filter_vec, 0, 1, filt0, filt1); + + filter_vec = LD_SH(filter_y); + vec0 = __msa_clti_s_b((v16i8) filter_vec, 0); + filter_vec = (v8i16) __msa_ilvr_b(vec0, (v16i8) filter_vec); + + SPLATI_W2_SW(filter_vec, 0, filt_h0, filt_h1); + + mask1 = mask0 + 2; + + const_vec = __msa_ldi_h(128); + const_vec <<= 6; + + for (cnt = width >> 3; cnt--;) { + src_tmp = src; + dst_tmp = dst; + + LD_SB3(src_tmp, src_stride, src0, src1, src2); + src_tmp += (3 * src_stride); + + XORI_B3_128_SB(src0, src1, src2); + + VSHF_B2_SB(src0, src0, src0, src0, mask0, mask1, vec0, vec1); + VSHF_B2_SB(src1, src1, src1, src1, mask0, mask1, vec2, vec3); + VSHF_B2_SB(src2, src2, src2, src2, mask0, mask1, vec4, vec5); + + dst0 = const_vec; + DPADD_SB2_SH(vec0, vec1, filt0, filt1, dst0, dst0); + dst1 = const_vec; + DPADD_SB2_SH(vec2, vec3, filt0, filt1, dst1, dst1); + dst2 = const_vec; + DPADD_SB2_SH(vec4, vec5, filt0, filt1, dst2, dst2); + + ILVRL_H2_SH(dst1, dst0, dst10_r, dst10_l); + ILVRL_H2_SH(dst2, dst1, dst21_r, dst21_l); + + for (loop_cnt = height >> 2; loop_cnt--;) { + LD_SB4(src_tmp, src_stride, src3, src4, src5, src6); + src_tmp += (4 * src_stride); + + XORI_B4_128_SB(src3, src4, src5, src6); + + /* row 3 */ + VSHF_B2_SB(src3, src3, src3, src3, mask0, mask1, vec0, vec1); + dst3 = const_vec; + DPADD_SB2_SH(vec0, vec1, filt0, filt1, dst3, dst3); + + ILVRL_H2_SH(dst3, dst2, dst32_r, dst32_l); + dst0_r = HEVC_FILT_4TAP(dst10_r, dst32_r, filt_h0, filt_h1); + dst0_l = HEVC_FILT_4TAP(dst10_l, dst32_l, filt_h0, filt_h1); + + dst0_r >>= 6; + dst0_l >>= 6; + + /* row 4 */ + VSHF_B2_SB(src4, src4, src4, src4, mask0, mask1, vec0, vec1); + dst4 = const_vec; + DPADD_SB2_SH(vec0, vec1, filt0, filt1, dst4, dst4); + + ILVRL_H2_SH(dst4, dst3, dst43_r, dst43_l); + dst1_r = HEVC_FILT_4TAP(dst21_r, dst43_r, filt_h0, filt_h1); + dst1_l = HEVC_FILT_4TAP(dst21_l, dst43_l, filt_h0, filt_h1); + dst1_r >>= 6; + dst1_l >>= 6; + + /* row 5 */ + VSHF_B2_SB(src5, src5, src5, src5, mask0, mask1, vec0, vec1); + dst5 = const_vec; + DPADD_SB2_SH(vec0, vec1, filt0, filt1, dst5, dst5); + + ILVRL_H2_SH(dst5, dst4, dst10_r, dst10_l); + dst2_r = HEVC_FILT_4TAP(dst32_r, dst10_r, filt_h0, filt_h1); + dst2_l = HEVC_FILT_4TAP(dst32_l, dst10_l, filt_h0, filt_h1); + + dst2_r >>= 6; + dst2_l >>= 6; + + /* row 6 */ + VSHF_B2_SB(src6, src6, src6, src6, mask0, mask1, vec0, vec1); + dst2 = const_vec; + DPADD_SB2_SH(vec0, vec1, filt0, filt1, dst2, dst2); + + ILVRL_H2_SH(dst2, dst5, dst21_r, dst21_l); + dst3_r = HEVC_FILT_4TAP(dst43_r, dst21_r, filt_h0, filt_h1); + dst3_l = HEVC_FILT_4TAP(dst43_l, dst21_l, filt_h0, filt_h1); + + dst3_r >>= 6; + dst3_l >>= 6; + + PCKEV_H4_SH(dst0_l, dst0_r, dst1_l, dst1_r, + dst2_l, dst2_r, dst3_l, dst3_r, + out0_r, out1_r, out2_r, out3_r); + + SRARI_H4_SH(out0_r, out1_r, out2_r, out3_r, 6); + CLIP_SH4_0_255(out0_r, out1_r, out2_r, out3_r); + + PCKEV_B2_SH(out1_r, out0_r, out3_r, out2_r, out0_r, out1_r); + ST8x4_UB(out0_r, out1_r, dst_tmp, dst_stride); + dst_tmp += (4 * dst_stride); + } + + src += 8; + dst += 8; + } +} + +static void hevc_hv_uni_4t_8w_msa(uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + const int8_t *filter_x, + const int8_t *filter_y, + int32_t height) +{ + if (2 == height) { + hevc_hv_uni_4t_8x2_msa(src, src_stride, dst, dst_stride, + filter_x, filter_y, height); + } else if (6 == height) { + hevc_hv_uni_4t_8x6_msa(src, src_stride, dst, dst_stride, + filter_x, filter_y, height); + } else if (0 == (height % 4)) { + hevc_hv_uni_4t_8w_mult_msa(src, src_stride, dst, dst_stride, + filter_x, filter_y, height, 8); + } +} + +static void hevc_hv_uni_4t_12w_msa(uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + const int8_t *filter_x, + const int8_t *filter_y, + int32_t height) +{ + hevc_hv_uni_4t_8w_mult_msa(src, src_stride, dst, dst_stride, + filter_x, filter_y, height, 8); + + hevc_hv_uni_4t_4w_msa(src + 8, src_stride, dst + 8, dst_stride, + filter_x, filter_y, height); +} + +static void hevc_hv_uni_4t_16w_msa(uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + const int8_t *filter_x, + const int8_t *filter_y, + int32_t height) +{ + hevc_hv_uni_4t_8w_mult_msa(src, src_stride, dst, dst_stride, + filter_x, filter_y, height, 16); +} + +static void hevc_hv_uni_4t_24w_msa(uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + const int8_t *filter_x, + const int8_t *filter_y, + int32_t height) +{ + hevc_hv_uni_4t_8w_mult_msa(src, src_stride, dst, dst_stride, + filter_x, filter_y, height, 24); +} + +static void hevc_hv_uni_4t_32w_msa(uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + const int8_t *filter_x, + const int8_t *filter_y, + int32_t height) +{ + hevc_hv_uni_4t_8w_mult_msa(src, src_stride, dst, dst_stride, + filter_x, filter_y, height, 32); +} + #define UNI_MC_COPY(WIDTH) \ void ff_hevc_put_hevc_uni_pel_pixels##WIDTH##_8_msa(uint8_t *dst, \ ptrdiff_t dst_stride, \ @@ -1755,6 +3906,22 @@ UNI_MC(qpel, v, 32, 8, vt, my); UNI_MC(qpel, v, 48, 8, vt, my); UNI_MC(qpel, v, 64, 8, vt, my); +UNI_MC(epel, h, 4, 4, hz, mx); +UNI_MC(epel, h, 6, 4, hz, mx); +UNI_MC(epel, h, 8, 4, hz, mx); +UNI_MC(epel, h, 12, 4, hz, mx); +UNI_MC(epel, h, 16, 4, hz, mx); +UNI_MC(epel, h, 24, 4, hz, mx); +UNI_MC(epel, h, 32, 4, hz, mx); + +UNI_MC(epel, v, 4, 4, vt, my); +UNI_MC(epel, v, 6, 4, vt, my); +UNI_MC(epel, v, 8, 4, vt, my); +UNI_MC(epel, v, 12, 4, vt, my); +UNI_MC(epel, v, 16, 4, vt, my); +UNI_MC(epel, v, 24, 4, vt, my); +UNI_MC(epel, v, 32, 4, vt, my); + #undef UNI_MC #define UNI_MC_HV(PEL, DIR, WIDTH, TAP, DIR1) \ @@ -1786,4 +3953,12 @@ UNI_MC_HV(qpel, hv, 32, 8, hv); UNI_MC_HV(qpel, hv, 48, 8, hv); UNI_MC_HV(qpel, hv, 64, 8, hv); +UNI_MC_HV(epel, hv, 4, 4, hv); +UNI_MC_HV(epel, hv, 6, 4, hv); +UNI_MC_HV(epel, hv, 8, 4, hv); +UNI_MC_HV(epel, hv, 12, 4, hv); +UNI_MC_HV(epel, hv, 16, 4, hv); +UNI_MC_HV(epel, hv, 24, 4, hv); +UNI_MC_HV(epel, hv, 32, 4, hv); + #undef UNI_MC_HV diff --git a/libavcodec/mips/hevcdsp_init_mips.c b/libavcodec/mips/hevcdsp_init_mips.c index 837c0460d1..acf6c0d29e 100644 --- a/libavcodec/mips/hevcdsp_init_mips.c +++ b/libavcodec/mips/hevcdsp_init_mips.c @@ -129,6 +129,36 @@ static av_cold void hevc_dsp_init_msa(HEVCDSPContext *c, c->put_hevc_qpel_uni[8][1][1] = ff_hevc_put_hevc_uni_qpel_hv48_8_msa; c->put_hevc_qpel_uni[9][1][1] = ff_hevc_put_hevc_uni_qpel_hv64_8_msa; + c->put_hevc_epel_uni[3][0][0] = ff_hevc_put_hevc_uni_pel_pixels8_8_msa; + c->put_hevc_epel_uni[4][0][0] = ff_hevc_put_hevc_uni_pel_pixels12_8_msa; + c->put_hevc_epel_uni[5][0][0] = ff_hevc_put_hevc_uni_pel_pixels16_8_msa; + c->put_hevc_epel_uni[6][0][0] = ff_hevc_put_hevc_uni_pel_pixels24_8_msa; + c->put_hevc_epel_uni[7][0][0] = ff_hevc_put_hevc_uni_pel_pixels32_8_msa; + + c->put_hevc_epel_uni[1][0][1] = ff_hevc_put_hevc_uni_epel_h4_8_msa; + c->put_hevc_epel_uni[2][0][1] = ff_hevc_put_hevc_uni_epel_h6_8_msa; + c->put_hevc_epel_uni[3][0][1] = ff_hevc_put_hevc_uni_epel_h8_8_msa; + c->put_hevc_epel_uni[4][0][1] = ff_hevc_put_hevc_uni_epel_h12_8_msa; + c->put_hevc_epel_uni[5][0][1] = ff_hevc_put_hevc_uni_epel_h16_8_msa; + c->put_hevc_epel_uni[6][0][1] = ff_hevc_put_hevc_uni_epel_h24_8_msa; + c->put_hevc_epel_uni[7][0][1] = ff_hevc_put_hevc_uni_epel_h32_8_msa; + + c->put_hevc_epel_uni[1][1][0] = ff_hevc_put_hevc_uni_epel_v4_8_msa; + c->put_hevc_epel_uni[2][1][0] = ff_hevc_put_hevc_uni_epel_v6_8_msa; + c->put_hevc_epel_uni[3][1][0] = ff_hevc_put_hevc_uni_epel_v8_8_msa; + c->put_hevc_epel_uni[4][1][0] = ff_hevc_put_hevc_uni_epel_v12_8_msa; + c->put_hevc_epel_uni[5][1][0] = ff_hevc_put_hevc_uni_epel_v16_8_msa; + c->put_hevc_epel_uni[6][1][0] = ff_hevc_put_hevc_uni_epel_v24_8_msa; + c->put_hevc_epel_uni[7][1][0] = ff_hevc_put_hevc_uni_epel_v32_8_msa; + + c->put_hevc_epel_uni[1][1][1] = ff_hevc_put_hevc_uni_epel_hv4_8_msa; + c->put_hevc_epel_uni[2][1][1] = ff_hevc_put_hevc_uni_epel_hv6_8_msa; + c->put_hevc_epel_uni[3][1][1] = ff_hevc_put_hevc_uni_epel_hv8_8_msa; + c->put_hevc_epel_uni[4][1][1] = ff_hevc_put_hevc_uni_epel_hv12_8_msa; + c->put_hevc_epel_uni[5][1][1] = ff_hevc_put_hevc_uni_epel_hv16_8_msa; + c->put_hevc_epel_uni[6][1][1] = ff_hevc_put_hevc_uni_epel_hv24_8_msa; + c->put_hevc_epel_uni[7][1][1] = ff_hevc_put_hevc_uni_epel_hv32_8_msa; + c->put_hevc_qpel_uni_w[1][0][0] = ff_hevc_put_hevc_uni_w_pel_pixels4_8_msa; c->put_hevc_qpel_uni_w[3][0][0] = diff --git a/libavcodec/mips/hevcdsp_mips.h b/libavcodec/mips/hevcdsp_mips.h index 389f025fa4..6019e3bd14 100644 --- a/libavcodec/mips/hevcdsp_mips.h +++ b/libavcodec/mips/hevcdsp_mips.h @@ -145,6 +145,36 @@ UNI_MC(qpel, hv, 32); UNI_MC(qpel, hv, 48); UNI_MC(qpel, hv, 64); +UNI_MC(epel, h, 4); +UNI_MC(epel, h, 6); +UNI_MC(epel, h, 8); +UNI_MC(epel, h, 12); +UNI_MC(epel, h, 16); +UNI_MC(epel, h, 24); +UNI_MC(epel, h, 32); +UNI_MC(epel, h, 48); +UNI_MC(epel, h, 64); + +UNI_MC(epel, v, 4); +UNI_MC(epel, v, 6); +UNI_MC(epel, v, 8); +UNI_MC(epel, v, 12); +UNI_MC(epel, v, 16); +UNI_MC(epel, v, 24); +UNI_MC(epel, v, 32); +UNI_MC(epel, v, 48); +UNI_MC(epel, v, 64); + +UNI_MC(epel, hv, 4); +UNI_MC(epel, hv, 6); +UNI_MC(epel, hv, 8); +UNI_MC(epel, hv, 12); +UNI_MC(epel, hv, 16); +UNI_MC(epel, hv, 24); +UNI_MC(epel, hv, 32); +UNI_MC(epel, hv, 48); +UNI_MC(epel, hv, 64); + #undef UNI_MC #define UNI_W_MC(PEL, DIR, WIDTH) \ |