diff options
author | Shivraj Patil <shivraj.patil@imgtec.com> | 2015-06-29 18:27:15 +0300 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-07-07 15:35:15 +0300 |
commit | d12f76ffbb1b68d3c8a2859b7a095080ba985fa2 (patch) | |
tree | b770a2fb5efe144fbe65756ac8da582fedee3bd8 | |
parent | 9c95734e1c0f1a086d1c71b65c29355ef6f7785d (diff) |
avcodec/mips: MSA (MIPS-SIMD-Arch) optimizations for idctdsp functions
This patch adds MSA (MIPS-SIMD-Arch) optimizations for idctdsp functions in new file idctdsp_msa.c and simple_idct_msa.c
Signed-off-by: Shivraj Patil <shivraj.patil@imgtec.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavcodec/idctdsp.c | 2 | ||||
-rw-r--r-- | libavcodec/idctdsp.h | 2 | ||||
-rw-r--r-- | libavcodec/mips/Makefile | 3 | ||||
-rw-r--r-- | libavcodec/mips/idctdsp_init_mips.c | 49 | ||||
-rw-r--r-- | libavcodec/mips/idctdsp_mips.h | 42 | ||||
-rw-r--r-- | libavcodec/mips/idctdsp_msa.c | 149 | ||||
-rw-r--r-- | libavcodec/mips/simple_idct_msa.c | 573 | ||||
-rw-r--r-- | libavutil/mips/generic_macros_msa.h | 37 |
8 files changed, 857 insertions, 0 deletions
diff --git a/libavcodec/idctdsp.c b/libavcodec/idctdsp.c index ae804d999a..63e9b5216b 100644 --- a/libavcodec/idctdsp.c +++ b/libavcodec/idctdsp.c @@ -305,6 +305,8 @@ av_cold void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx) ff_idctdsp_init_ppc(c, avctx, high_bit_depth); if (ARCH_X86) ff_idctdsp_init_x86(c, avctx, high_bit_depth); + if (ARCH_MIPS) + ff_idctdsp_init_mips(c, avctx, high_bit_depth); ff_put_pixels_clamped = c->put_pixels_clamped; ff_add_pixels_clamped = c->add_pixels_clamped; diff --git a/libavcodec/idctdsp.h b/libavcodec/idctdsp.h index 538b71669c..b180a6762a 100644 --- a/libavcodec/idctdsp.h +++ b/libavcodec/idctdsp.h @@ -108,5 +108,7 @@ void ff_idctdsp_init_ppc(IDCTDSPContext *c, AVCodecContext *avctx, unsigned high_bit_depth); void ff_idctdsp_init_x86(IDCTDSPContext *c, AVCodecContext *avctx, unsigned high_bit_depth); +void ff_idctdsp_init_mips(IDCTDSPContext *c, AVCodecContext *avctx, + unsigned high_bit_depth); #endif /* AVCODEC_IDCTDSP_H */ diff --git a/libavcodec/mips/Makefile b/libavcodec/mips/Makefile index 695ee36b02..5569a03684 100644 --- a/libavcodec/mips/Makefile +++ b/libavcodec/mips/Makefile @@ -29,6 +29,7 @@ OBJS-$(CONFIG_QPELDSP) += mips/qpeldsp_init_mips.o OBJS-$(CONFIG_HPELDSP) += mips/hpeldsp_init_mips.o OBJS-$(CONFIG_BLOCKDSP) += mips/blockdsp_init_mips.o OBJS-$(CONFIG_PIXBLOCKDSP) += mips/pixblockdsp_init_mips.o +OBJS-$(CONFIG_IDCTDSP) += mips/idctdsp_init_mips.o OBJS-$(CONFIG_MPEGVIDEO) += mips/mpegvideo_init_mips.o OBJS-$(CONFIG_MPEGVIDEOENC) += mips/mpegvideoencdsp_init_mips.o OBJS-$(CONFIG_ME_CMP) += mips/me_cmp_init_mips.o @@ -50,6 +51,8 @@ MSA-OBJS-$(CONFIG_QPELDSP) += mips/qpeldsp_msa.o MSA-OBJS-$(CONFIG_HPELDSP) += mips/hpeldsp_msa.o MSA-OBJS-$(CONFIG_BLOCKDSP) += mips/blockdsp_msa.o MSA-OBJS-$(CONFIG_PIXBLOCKDSP) += mips/pixblockdsp_msa.o +MSA-OBJS-$(CONFIG_IDCTDSP) += mips/idctdsp_msa.o \ + mips/simple_idct_msa.o MSA-OBJS-$(CONFIG_MPEGVIDEO) += mips/mpegvideo_msa.o MSA-OBJS-$(CONFIG_MPEGVIDEOENC) += mips/mpegvideoencdsp_msa.o MSA-OBJS-$(CONFIG_ME_CMP) += mips/me_cmp_msa.o diff --git a/libavcodec/mips/idctdsp_init_mips.c b/libavcodec/mips/idctdsp_init_mips.c new file mode 100644 index 0000000000..c964340869 --- /dev/null +++ b/libavcodec/mips/idctdsp_init_mips.c @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2015 Manojkumar Bhosale (Manojkumar.Bhosale@imgtec.com) + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "idctdsp_mips.h" + +#if HAVE_MSA +static av_cold void idctdsp_init_msa(IDCTDSPContext *c, AVCodecContext *avctx, + unsigned high_bit_depth) +{ + if ((avctx->lowres != 1) && (avctx->lowres != 2) && (avctx->lowres != 3) && + (avctx->bits_per_raw_sample != 10) && + (avctx->bits_per_raw_sample != 12) && + (avctx->idct_algo == FF_IDCT_AUTO)) { + c->idct_put = ff_simple_idct_put_msa; + c->idct_add = ff_simple_idct_add_msa; + c->idct = ff_simple_idct_msa; + c->perm_type = FF_IDCT_PERM_NONE; + } + + c->put_pixels_clamped = ff_put_pixels_clamped_msa; + c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_msa; + c->add_pixels_clamped = ff_add_pixels_clamped_msa; +} +#endif // #if HAVE_MSA + +void ff_idctdsp_init_mips(IDCTDSPContext *c, AVCodecContext *avctx, + unsigned high_bit_depth) +{ +#if HAVE_MSA + idctdsp_init_msa(c, avctx, high_bit_depth); +#endif // #if HAVE_MSA +} diff --git a/libavcodec/mips/idctdsp_mips.h b/libavcodec/mips/idctdsp_mips.h new file mode 100644 index 0000000000..191652e62b --- /dev/null +++ b/libavcodec/mips/idctdsp_mips.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2015 Manojkumar Bhosale (Manojkumar.Bhosale@imgtec.com) + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_MIPS_IDCTDSP_MIPS_H +#define AVCODEC_MIPS_IDCTDSP_MIPS_H + +#include "../mpegvideo.h" + +void ff_put_pixels_clamped_msa(const int16_t *block, + uint8_t *av_restrict pixels, + ptrdiff_t line_size); +void ff_put_signed_pixels_clamped_msa(const int16_t *block, + uint8_t *av_restrict pixels, + ptrdiff_t line_size); +void ff_add_pixels_clamped_msa(const int16_t *block, + uint8_t *av_restrict pixels, + ptrdiff_t line_size); +void ff_j_rev_dct_msa(int16_t *data); +void ff_jref_idct_put_msa(uint8_t *dest, int32_t stride, int16_t *block); +void ff_jref_idct_add_msa(uint8_t *dest, int32_t stride, int16_t *block); +void ff_simple_idct_msa(int16_t *block); +void ff_simple_idct_put_msa(uint8_t *dest, int32_t stride_dst, int16_t *block); +void ff_simple_idct_add_msa(uint8_t *dest, int32_t stride_dst, int16_t *block); + +#endif // #ifndef AVCODEC_MIPS_IDCTDSP_MIPS_H diff --git a/libavcodec/mips/idctdsp_msa.c b/libavcodec/mips/idctdsp_msa.c new file mode 100644 index 0000000000..b29e420556 --- /dev/null +++ b/libavcodec/mips/idctdsp_msa.c @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2015 Manojkumar Bhosale (Manojkumar.Bhosale@imgtec.com) + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/mips/generic_macros_msa.h" +#include "idctdsp_mips.h" + +static void put_pixels_clamped_msa(const int16_t *block, uint8_t *pixels, + int32_t stride) +{ + uint64_t in0_d, in1_d, in2_d, in3_d, in4_d, in5_d, in6_d, in7_d; + v8i16 in0, in1, in2, in3, in4, in5, in6, in7; + + LD_SH8(block, 8, in0, in1, in2, in3, in4, in5, in6, in7); + CLIP_SH4_0_255(in0, in1, in2, in3); + CLIP_SH4_0_255(in4, in5, in6, in7); + PCKEV_B4_SH(in0, in0, in1, in1, in2, in2, in3, in3, in0, in1, in2, in3); + PCKEV_B4_SH(in4, in4, in5, in5, in6, in6, in7, in7, in4, in5, in6, in7); + + in0_d = __msa_copy_u_d((v2i64) in0, 0); + in1_d = __msa_copy_u_d((v2i64) in1, 0); + in2_d = __msa_copy_u_d((v2i64) in2, 0); + in3_d = __msa_copy_u_d((v2i64) in3, 0); + in4_d = __msa_copy_u_d((v2i64) in4, 0); + in5_d = __msa_copy_u_d((v2i64) in5, 0); + in6_d = __msa_copy_u_d((v2i64) in6, 0); + in7_d = __msa_copy_u_d((v2i64) in7, 0); + SD4(in0_d, in1_d, in2_d, in3_d, pixels, stride); + pixels += 4 * stride; + SD4(in4_d, in5_d, in6_d, in7_d, pixels, stride); +} + +static void put_signed_pixels_clamped_msa(const int16_t *block, uint8_t *pixels, + int32_t stride) +{ + uint64_t in0_d, in1_d, in2_d, in3_d, in4_d, in5_d, in6_d, in7_d; + v8i16 in0, in1, in2, in3, in4, in5, in6, in7; + + LD_SH8(block, 8, in0, in1, in2, in3, in4, in5, in6, in7); + + in0 += 128; + in1 += 128; + in2 += 128; + in3 += 128; + in4 += 128; + in5 += 128; + in6 += 128; + in7 += 128; + + CLIP_SH4_0_255(in0, in1, in2, in3); + CLIP_SH4_0_255(in4, in5, in6, in7); + PCKEV_B4_SH(in0, in0, in1, in1, in2, in2, in3, in3, in0, in1, in2, in3); + PCKEV_B4_SH(in4, in4, in5, in5, in6, in6, in7, in7, in4, in5, in6, in7); + + in0_d = __msa_copy_u_d((v2i64) in0, 0); + in1_d = __msa_copy_u_d((v2i64) in1, 0); + in2_d = __msa_copy_u_d((v2i64) in2, 0); + in3_d = __msa_copy_u_d((v2i64) in3, 0); + in4_d = __msa_copy_u_d((v2i64) in4, 0); + in5_d = __msa_copy_u_d((v2i64) in5, 0); + in6_d = __msa_copy_u_d((v2i64) in6, 0); + in7_d = __msa_copy_u_d((v2i64) in7, 0); + SD4(in0_d, in1_d, in2_d, in3_d, pixels, stride); + pixels += 4 * stride; + SD4(in4_d, in5_d, in6_d, in7_d, pixels, stride); +} + +static void add_pixels_clamped_msa(const int16_t *block, uint8_t *pixels, + int32_t stride) +{ + uint64_t in0_d, in1_d, in2_d, in3_d, in4_d, in5_d, in6_d, in7_d; + v8i16 in0, in1, in2, in3, in4, in5, in6, in7; + v16u8 pix_in0, pix_in1, pix_in2, pix_in3; + v16u8 pix_in4, pix_in5, pix_in6, pix_in7; + v8u16 pix0, pix1, pix2, pix3, pix4, pix5, pix6, pix7; + v8i16 zero = { 0 }; + + LD_SH8(block, 8, in0, in1, in2, in3, in4, in5, in6, in7); + LD_UB8(pixels, stride, pix_in0, pix_in1, pix_in2, + pix_in3, pix_in4, pix_in5, pix_in6, pix_in7); + + ILVR_B4_UH(zero, pix_in0, zero, pix_in1, zero, pix_in2, zero, pix_in3, + pix0, pix1, pix2, pix3); + ILVR_B4_UH(zero, pix_in4, zero, pix_in5, zero, pix_in6, zero, pix_in7, + pix4, pix5, pix6, pix7); + + in0 += (v8i16) pix0; + in1 += (v8i16) pix1; + in2 += (v8i16) pix2; + in3 += (v8i16) pix3; + in4 += (v8i16) pix4; + in5 += (v8i16) pix5; + in6 += (v8i16) pix6; + in7 += (v8i16) pix7; + + CLIP_SH4_0_255(in0, in1, in2, in3); + CLIP_SH4_0_255(in4, in5, in6, in7); + PCKEV_B4_SH(in0, in0, in1, in1, in2, in2, in3, in3, in0, in1, in2, in3); + PCKEV_B4_SH(in4, in4, in5, in5, in6, in6, in7, in7, in4, in5, in6, in7); + + in0_d = __msa_copy_u_d((v2i64) in0, 0); + in1_d = __msa_copy_u_d((v2i64) in1, 0); + in2_d = __msa_copy_u_d((v2i64) in2, 0); + in3_d = __msa_copy_u_d((v2i64) in3, 0); + in4_d = __msa_copy_u_d((v2i64) in4, 0); + in5_d = __msa_copy_u_d((v2i64) in5, 0); + in6_d = __msa_copy_u_d((v2i64) in6, 0); + in7_d = __msa_copy_u_d((v2i64) in7, 0); + SD4(in0_d, in1_d, in2_d, in3_d, pixels, stride); + pixels += 4 * stride; + SD4(in4_d, in5_d, in6_d, in7_d, pixels, stride); +} + +void ff_put_pixels_clamped_msa(const int16_t *block, + uint8_t *av_restrict pixels, + ptrdiff_t line_size) +{ + put_pixels_clamped_msa(block, pixels, line_size); +} + +void ff_put_signed_pixels_clamped_msa(const int16_t *block, + uint8_t *av_restrict pixels, + ptrdiff_t line_size) +{ + put_signed_pixels_clamped_msa(block, pixels, line_size); +} + +void ff_add_pixels_clamped_msa(const int16_t *block, + uint8_t *av_restrict pixels, + ptrdiff_t line_size) +{ + add_pixels_clamped_msa(block, pixels, line_size); +} diff --git a/libavcodec/mips/simple_idct_msa.c b/libavcodec/mips/simple_idct_msa.c new file mode 100644 index 0000000000..bd8b31012f --- /dev/null +++ b/libavcodec/mips/simple_idct_msa.c @@ -0,0 +1,573 @@ +/* + * Copyright (c) 2015 Parag Salasakar (Parag.Salasakar@imgtec.com) + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/mips/generic_macros_msa.h" +#include "idctdsp_mips.h" + +static void simple_idct_msa(int16_t *block) +{ + int32_t const_val; + v8i16 weights = { 0, 22725, 21407, 19266, 16383, 12873, 8867, 4520 }; + v8i16 in0, in1, in2, in3, in4, in5, in6, in7; + v8i16 w1, w3, w5, w7; + v8i16 const0, const1, const2, const3, const4, const5, const6, const7; + v4i32 temp0_r, temp1_r, temp2_r, temp3_r; + v4i32 temp0_l, temp1_l, temp2_l, temp3_l; + v4i32 a0_r, a1_r, a2_r, a3_r, a0_l, a1_l, a2_l, a3_l; + v4i32 b0_r, b1_r, b2_r, b3_r, b0_l, b1_l, b2_l, b3_l; + v4i32 w2, w4, w6; + v8i16 select_vec, temp; + v8i16 zero = { 0 }; + v4i32 const_val0 = __msa_ldi_w(1); + v4i32 const_val1 = __msa_ldi_w(1); + + LD_SH8(block, 8, in0, in1, in2, in3, in4, in5, in6, in7); + const_val0 <<= 10; + const_val = 16383 * ((1 << 19) / 16383); + const_val1 = __msa_insert_w(const_val0, 0, const_val); + const_val1 = __msa_splati_w(const_val1, 0); + TRANSPOSE8x8_SH_SH(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + select_vec = in1 | in2 | in3 | in4 | in5 | in6 | in7; + select_vec = __msa_clti_u_h((v8u16) select_vec, 1); + UNPCK_SH_SW(in0, a0_r, a0_l); + UNPCK_SH_SW(in2, temp3_r, temp3_l); + temp = in0 << 3; + w2 = (v4i32) __msa_splati_h(weights, 2); + w2 = (v4i32) __msa_ilvr_h(zero, (v8i16) w2); + w4 = (v4i32) __msa_splati_h(weights, 4); + w4 = (v4i32) __msa_ilvr_h(zero, (v8i16) w4); + w6 = (v4i32) __msa_splati_h(weights, 6); + w6 = (v4i32) __msa_ilvr_h(zero, (v8i16) w6); + MUL2(a0_r, w4, a0_l, w4, a0_r, a0_l); + ADD2(a0_r, const_val0, a0_l, const_val0, temp0_r, temp0_l); + MUL4(w2, temp3_r, w2, temp3_l, w6, temp3_r, w6, temp3_l, + temp1_r, temp1_l, temp2_r, temp2_l); + BUTTERFLY_8(temp0_r, temp0_l, temp0_r, temp0_l, + temp2_l, temp2_r, temp1_l, temp1_r, + a0_r, a0_l, a1_r, a1_l, a2_l, a2_r, a3_l, a3_r); + UNPCK_SH_SW(in4, temp0_r, temp0_l); + UNPCK_SH_SW(in6, temp3_r, temp3_l); + MUL2(temp0_r, w4, temp0_l, w4, temp0_r, temp0_l); + MUL4(w2, temp3_r, w2, temp3_l, w6, temp3_r, w6, temp3_l, + temp2_r, temp2_l, temp1_r, temp1_l); + ADD2(a0_r, temp0_r, a0_l, temp0_l, a0_r, a0_l); + SUB4(a1_r, temp0_r, a1_l, temp0_l, a2_r, temp0_r, a2_l, temp0_l, + a1_r, a1_l, a2_r, a2_l); + ADD4(a3_r, temp0_r, a3_l, temp0_l, a0_r, temp1_r, a0_l, temp1_l, + a3_r, a3_l, a0_r, a0_l); + SUB2(a1_r, temp2_r, a1_l, temp2_l, a1_r, a1_l); + ADD2(a2_r, temp2_r, a2_l, temp2_l, a2_r, a2_l); + SUB2(a3_r, temp1_r, a3_l, temp1_l, a3_r, a3_l); + ILVRL_H2_SW(in1, in3, b3_r, b3_l); + SPLATI_H4_SH(weights, 1, 3, 5, 7, w1, w3, w5, w7); + ILVRL_H2_SW(in5, in7, temp0_r, temp0_l); + ILVR_H4_SH(w1, w3, w3, -w7, w5, -w1, w7, -w5, + const0, const1, const2, const3); + ILVR_H2_SH(w5, w7, w7, w3, const4, const6); + const5 = __msa_ilvod_h(-w1, -w5); + const7 = __msa_ilvod_h(w3, -w1); + DOTP_SH4_SW(b3_r, b3_r, b3_r, b3_r, const0, const1, const2, const3, + b0_r, b1_r, b2_r, b3_r); + DPADD_SH4_SW(temp0_r, temp0_r, temp0_r, temp0_r, + const4, const5, const6, const7, b0_r, b1_r, b2_r, b3_r); + DOTP_SH4_SW(b3_l, b3_l, b3_l, b3_l, const0, const1, const2, const3, + b0_l, b1_l, b2_l, b3_l); + DPADD_SH4_SW(temp0_l, temp0_l, temp0_l, temp0_l, + const4, const5, const6, const7, b0_l, b1_l, b2_l, b3_l); + BUTTERFLY_16(a0_r, a0_l, a1_r, a1_l, a2_r, a2_l, a3_r, a3_l, + b3_l, b3_r, b2_l, b2_r, b1_l, b1_r, b0_l, b0_r, + temp0_r, temp0_l, temp1_r, temp1_l, + temp2_r, temp2_l, temp3_r, temp3_l, + a3_l, a3_r, a2_l, a2_r, a1_l, a1_r, a0_l, a0_r); + SRA_4V(temp0_r, temp0_l, temp1_r, temp1_l, 11); + SRA_4V(temp2_r, temp2_l, temp3_r, temp3_l, 11); + PCKEV_H4_SW(temp0_l, temp0_r, temp1_l, temp1_r, + temp2_l, temp2_r, temp3_l, temp3_r, + temp0_r, temp1_r, temp2_r, temp3_r); + in0 = (v8i16) __msa_bmnz_v((v16u8) temp0_r, (v16u8) temp, + (v16u8) select_vec); + in1 = (v8i16) __msa_bmnz_v((v16u8) temp1_r, (v16u8) temp, + (v16u8) select_vec); + in2 = (v8i16) __msa_bmnz_v((v16u8) temp2_r, (v16u8) temp, + (v16u8) select_vec); + in3 = (v8i16) __msa_bmnz_v((v16u8) temp3_r, (v16u8) temp, + (v16u8) select_vec); + SRA_4V(a3_r, a3_l, a2_r, a2_l, 11); + SRA_4V(a1_r, a1_l, a0_r, a0_l, 11); + PCKEV_H4_SW(a0_l, a0_r, a1_l, a1_r, a2_l, a2_r, a3_l, a3_r, + a0_r, a1_r, a2_r, a3_r); + in4 = (v8i16) __msa_bmnz_v((v16u8) a3_r, (v16u8) temp, (v16u8) select_vec); + in5 = (v8i16) __msa_bmnz_v((v16u8) a2_r, (v16u8) temp, (v16u8) select_vec); + in6 = (v8i16) __msa_bmnz_v((v16u8) a1_r, (v16u8) temp, (v16u8) select_vec); + in7 = (v8i16) __msa_bmnz_v((v16u8) a0_r, (v16u8) temp, (v16u8) select_vec); + TRANSPOSE8x8_SH_SH(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + + UNPCK_SH_SW(in0, a0_r, a0_l); + UNPCK_SH_SW(in2, temp3_r, temp3_l); + w2 = (v4i32) __msa_splati_h(weights, 2); + w2 = (v4i32) __msa_ilvr_h(zero, (v8i16) w2); + w4 = (v4i32) __msa_splati_h(weights, 4); + w4 = (v4i32) __msa_ilvr_h(zero, (v8i16) w4); + w6 = (v4i32) __msa_splati_h(weights, 6); + w6 = (v4i32) __msa_ilvr_h(zero, (v8i16) w6); + MUL2(a0_r, w4, a0_l, w4, a0_r, a0_l); + ADD2(a0_r, const_val1, a0_l, const_val1, temp0_r, temp0_l); + MUL4(w2, temp3_r, w2, temp3_l, w6, temp3_r, w6, temp3_l, + temp1_r, temp1_l, temp2_r, temp2_l); + BUTTERFLY_8(temp0_r, temp0_l, temp0_r, temp0_l, + temp2_l, temp2_r, temp1_l, temp1_r, + a0_r, a0_l, a1_r, a1_l, a2_l, a2_r, a3_l, a3_r); + UNPCK_SH_SW(in4, temp0_r, temp0_l); + UNPCK_SH_SW(in6, temp3_r, temp3_l); + MUL2(temp0_r, w4, temp0_l, w4, temp0_r, temp0_l); + MUL4(w2, temp3_r, w2, temp3_l, w6, temp3_r, w6, temp3_l, + temp2_r, temp2_l, temp1_r, temp1_l); + ADD2(a0_r, temp0_r, a0_l, temp0_l, a0_r, a0_l); + SUB4(a1_r, temp0_r, a1_l, temp0_l, a2_r, temp0_r, a2_l, temp0_l, + a1_r, a1_l, a2_r, a2_l); + ADD4(a3_r, temp0_r, a3_l, temp0_l, a0_r, temp1_r, a0_l, temp1_l, + a3_r, a3_l, a0_r, a0_l); + SUB2(a1_r, temp2_r, a1_l, temp2_l, a1_r, a1_l); + ADD2(a2_r, temp2_r, a2_l, temp2_l, a2_r, a2_l); + SUB2(a3_r, temp1_r, a3_l, temp1_l, a3_r, a3_l); + ILVRL_H2_SW(in1, in3, b3_r, b3_l); + SPLATI_H4_SH(weights, 1, 3, 5, 7, w1, w3, w5, w7); + ILVR_H4_SH(w1, w3, w3, -w7, w5, -w1, w7, -w5, + const0, const1, const2, const3); + DOTP_SH4_SW(b3_r, b3_r, b3_r, b3_r, const0, const1, const2, const3, + b0_r, b1_r, b2_r, b3_r); + DOTP_SH4_SW(b3_l, b3_l, b3_l, b3_l, const0, const1, const2, const3, + b0_l, b1_l, b2_l, b3_l); + ILVRL_H2_SW(in5, in7, temp0_r, temp0_l); + ILVR_H2_SH(w5, w7, w7, w3, const4, const6); + const5 = __msa_ilvod_h(-w1, -w5); + const7 = __msa_ilvod_h(w3, -w1); + DPADD_SH4_SW(temp0_r, temp0_r, temp0_r, temp0_r, + const4, const5, const6, const7, b0_r, b1_r, b2_r, b3_r); + DPADD_SH4_SW(temp0_l, temp0_l, temp0_l, temp0_l, + const4, const5, const6, const7, b0_l, b1_l, b2_l, b3_l); + BUTTERFLY_16(a0_r, a0_l, a1_r, a1_l, a2_r, a2_l, a3_r, a3_l, + b3_l, b3_r, b2_l, b2_r, b1_l, b1_r, b0_l, b0_r, + temp0_r, temp0_l, temp1_r, temp1_l, + temp2_r, temp2_l, temp3_r, temp3_l, + a3_l, a3_r, a2_l, a2_r, a1_l, a1_r, a0_l, a0_r); + SRA_4V(temp0_r, temp0_l, temp1_r, temp1_l, 20); + SRA_4V(temp2_r, temp2_l, temp3_r, temp3_l, 20); + PCKEV_H4_SW(temp0_l, temp0_r, temp1_l, temp1_r, temp2_l, temp2_r, + temp3_l, temp3_r, temp0_r, temp1_r, temp2_r, temp3_r); + SRA_4V(a3_r, a3_l, a2_r, a2_l, 20); + SRA_4V(a1_r, a1_l, a0_r, a0_l, 20); + PCKEV_H4_SW(a0_l, a0_r, a1_l, a1_r, a2_l, a2_r, a3_l, a3_r, + a0_r, a1_r, a2_r, a3_r); + ST_SW8(temp0_r, temp1_r, temp2_r, temp3_r, a3_r, a2_r, a1_r, a0_r, + block, 8); +} + +static void simple_idct_put_msa(uint8_t *dst, int32_t dst_stride, + int16_t *block) +{ + int32_t const_val; + uint64_t tmp0, tmp1, tmp2, tmp3; + v8i16 weights = { 0, 22725, 21407, 19266, 16383, 12873, 8867, 4520 }; + v8i16 in0, in1, in2, in3, in4, in5, in6, in7; + v8i16 w1, w3, w5, w7; + v8i16 const0, const1, const2, const3, const4, const5, const6, const7; + v4i32 temp0_r, temp1_r, temp2_r, temp3_r; + v4i32 temp0_l, temp1_l, temp2_l, temp3_l; + v4i32 a0_r, a1_r, a2_r, a3_r, a0_l, a1_l, a2_l, a3_l; + v4i32 b0_r, b1_r, b2_r, b3_r, b0_l, b1_l, b2_l, b3_l; + v4i32 w2, w4, w6; + v8i16 select_vec, temp; + v8i16 zero = { 0 }; + v4i32 const_val0 = __msa_ldi_w(1); + v4i32 const_val1 = __msa_ldi_w(1); + + LD_SH8(block, 8, in0, in1, in2, in3, in4, in5, in6, in7); + const_val0 <<= 10; + const_val = 16383 * ((1 << 19) / 16383); + const_val1 = __msa_insert_w(const_val0, 0, const_val); + const_val1 = __msa_splati_w(const_val1, 0); + TRANSPOSE8x8_SH_SH(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + select_vec = in1 | in2 | in3 | in4 | in5 | in6 | in7; + select_vec = __msa_clti_u_h((v8u16) select_vec, 1); + UNPCK_SH_SW(in0, a0_r, a0_l); + UNPCK_SH_SW(in2, temp3_r, temp3_l); + temp = in0 << 3; + w2 = (v4i32) __msa_splati_h(weights, 2); + w2 = (v4i32) __msa_ilvr_h(zero, (v8i16) w2); + w4 = (v4i32) __msa_splati_h(weights, 4); + w4 = (v4i32) __msa_ilvr_h(zero, (v8i16) w4); + w6 = (v4i32) __msa_splati_h(weights, 6); + w6 = (v4i32) __msa_ilvr_h(zero, (v8i16) w6); + MUL2(a0_r, w4, a0_l, w4, a0_r, a0_l); + ADD2(a0_r, const_val0, a0_l, const_val0, temp0_r, temp0_l); + MUL2(w2, temp3_r, w2, temp3_l, temp1_r, temp1_l); + MUL2(w6, temp3_r, w6, temp3_l, temp2_r, temp2_l); + BUTTERFLY_8(temp0_r, temp0_l, temp0_r, temp0_l, + temp2_l, temp2_r, temp1_l, temp1_r, + a0_r, a0_l, a1_r, a1_l, a2_l, a2_r, a3_l, a3_r); + UNPCK_SH_SW(in4, temp0_r, temp0_l); + UNPCK_SH_SW(in6, temp3_r, temp3_l); + MUL2(temp0_r, w4, temp0_l, w4, temp0_r, temp0_l); + MUL2(w2, temp3_r, w2, temp3_l, temp2_r, temp2_l); + MUL2(w6, temp3_r, w6, temp3_l, temp1_r, temp1_l); + ADD2(a0_r, temp0_r, a0_l, temp0_l, a0_r, a0_l); + SUB2(a1_r, temp0_r, a1_l, temp0_l, a1_r, a1_l); + SUB2(a2_r, temp0_r, a2_l, temp0_l, a2_r, a2_l); + ADD2(a3_r, temp0_r, a3_l, temp0_l, a3_r, a3_l); + ADD2(a0_r, temp1_r, a0_l, temp1_l, a0_r, a0_l); + SUB2(a1_r, temp2_r, a1_l, temp2_l, a1_r, a1_l); + ADD2(a2_r, temp2_r, a2_l, temp2_l, a2_r, a2_l); + SUB2(a3_r, temp1_r, a3_l, temp1_l, a3_r, a3_l); + ILVRL_H2_SW(in1, in3, b3_r, b3_l); + SPLATI_H4_SH(weights, 1, 3, 5, 7, w1, w3, w5, w7); + ILVRL_H2_SW(in5, in7, temp0_r, temp0_l); + ILVR_H4_SH(w1, w3, w3, -w7, w5, -w1, w7, -w5, + const0, const1, const2, const3); + ILVR_H2_SH(w5, w7, w7, w3, const4, const6); + const5 = __msa_ilvod_h(-w1, -w5); + const7 = __msa_ilvod_h(w3, -w1); + DOTP_SH4_SW(b3_r, b3_r, b3_r, b3_r, const0, const1, const2, const3, + b0_r, b1_r, b2_r, b3_r); + DPADD_SH4_SW(temp0_r, temp0_r, temp0_r, temp0_r, + const4, const5, const6, const7, b0_r, b1_r, b2_r, b3_r); + DOTP_SH4_SW(b3_l, b3_l, b3_l, b3_l, const0, const1, const2, const3, + b0_l, b1_l, b2_l, b3_l); + DPADD_SH4_SW(temp0_l, temp0_l, temp0_l, temp0_l, + const4, const5, const6, const7, b0_l, b1_l, b2_l, b3_l); + BUTTERFLY_16(a0_r, a0_l, a1_r, a1_l, a2_r, a2_l, a3_r, a3_l, + b3_l, b3_r, b2_l, b2_r, b1_l, b1_r, b0_l, b0_r, + temp0_r, temp0_l, temp1_r, temp1_l, + temp2_r, temp2_l, temp3_r, temp3_l, + a3_l, a3_r, a2_l, a2_r, a1_l, a1_r, a0_l, a0_r); + SRA_4V(temp0_r, temp0_l, temp1_r, temp1_l, 11); + SRA_4V(temp2_r, temp2_l, temp3_r, temp3_l, 11); + PCKEV_H4_SW(temp0_l, temp0_r, temp1_l, temp1_r, + temp2_l, temp2_r, temp3_l, temp3_r, + temp0_r, temp1_r, temp2_r, temp3_r); + in0 = (v8i16) __msa_bmnz_v((v16u8) temp0_r, (v16u8) temp, + (v16u8) select_vec); + in1 = (v8i16) __msa_bmnz_v((v16u8) temp1_r, (v16u8) temp, + (v16u8) select_vec); + in2 = (v8i16) __msa_bmnz_v((v16u8) temp2_r, (v16u8) temp, + (v16u8) select_vec); + in3 = (v8i16) __msa_bmnz_v((v16u8) temp3_r, (v16u8) temp, + (v16u8) select_vec); + SRA_4V(a3_r, a3_l, a2_r, a2_l, 11); + SRA_4V(a1_r, a1_l, a0_r, a0_l, 11); + PCKEV_H4_SW(a0_l, a0_r, a1_l, a1_r, a2_l, a2_r, a3_l, a3_r, + a0_r, a1_r, a2_r, a3_r); + in4 = (v8i16) __msa_bmnz_v((v16u8) a3_r, (v16u8) temp, (v16u8) select_vec); + in5 = (v8i16) __msa_bmnz_v((v16u8) a2_r, (v16u8) temp, (v16u8) select_vec); + in6 = (v8i16) __msa_bmnz_v((v16u8) a1_r, (v16u8) temp, (v16u8) select_vec); + in7 = (v8i16) __msa_bmnz_v((v16u8) a0_r, (v16u8) temp, (v16u8) select_vec); + TRANSPOSE8x8_SH_SH(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + UNPCK_SH_SW(in0, a0_r, a0_l); + UNPCK_SH_SW(in2, temp3_r, temp3_l); + w2 = (v4i32) __msa_splati_h(weights, 2); + w2 = (v4i32) __msa_ilvr_h(zero, (v8i16) w2); + w4 = (v4i32) __msa_splati_h(weights, 4); + w4 = (v4i32) __msa_ilvr_h(zero, (v8i16) w4); + w6 = (v4i32) __msa_splati_h(weights, 6); + w6 = (v4i32) __msa_ilvr_h(zero, (v8i16) w6); + MUL2(a0_r, w4, a0_l, w4, a0_r, a0_l); + ADD2(a0_r, const_val1, a0_l, const_val1, temp0_r, temp0_l); + MUL2(w2, temp3_r, w2, temp3_l, temp1_r, temp1_l); + MUL2(w6, temp3_r, w6, temp3_l, temp2_r, temp2_l); + BUTTERFLY_8(temp0_r, temp0_l, temp0_r, temp0_l, + temp2_l, temp2_r, temp1_l, temp1_r, + a0_r, a0_l, a1_r, a1_l, a2_l, a2_r, a3_l, a3_r); + UNPCK_SH_SW(in4, temp0_r, temp0_l); + UNPCK_SH_SW(in6, temp3_r, temp3_l); + MUL2(temp0_r, w4, temp0_l, w4, temp0_r, temp0_l); + MUL2(w2, temp3_r, w2, temp3_l, temp2_r, temp2_l); + MUL2(w6, temp3_r, w6, temp3_l, temp1_r, temp1_l); + ADD2(a0_r, temp0_r, a0_l, temp0_l, a0_r, a0_l); + SUB2(a1_r, temp0_r, a1_l, temp0_l, a1_r, a1_l); + SUB2(a2_r, temp0_r, a2_l, temp0_l, a2_r, a2_l); + ADD2(a3_r, temp0_r, a3_l, temp0_l, a3_r, a3_l); + ADD2(a0_r, temp1_r, a0_l, temp1_l, a0_r, a0_l); + SUB2(a1_r, temp2_r, a1_l, temp2_l, a1_r, a1_l); + ADD2(a2_r, temp2_r, a2_l, temp2_l, a2_r, a2_l); + SUB2(a3_r, temp1_r, a3_l, temp1_l, a3_r, a3_l); + ILVRL_H2_SW(in1, in3, b3_r, b3_l); + SPLATI_H4_SH(weights, 1, 3, 5, 7, w1, w3, w5, w7); + ILVR_H4_SH(w1, w3, w3, -w7, w5, -w1, w7, -w5, + const0, const1, const2, const3); + DOTP_SH4_SW(b3_r, b3_r, b3_r, b3_r, const0, const1, const2, const3, + b0_r, b1_r, b2_r, b3_r); + DOTP_SH4_SW(b3_l, b3_l, b3_l, b3_l, const0, const1, const2, const3, + b0_l, b1_l, b2_l, b3_l); + ILVRL_H2_SW(in5, in7, temp0_r, temp0_l); + ILVR_H2_SH(w5, w7, w7, w3, const4, const6); + const5 = __msa_ilvod_h(-w1, -w5); + const7 = __msa_ilvod_h(w3, -w1); + DPADD_SH4_SW(temp0_r, temp0_r, temp0_r, temp0_r, + const4, const5, const6, const7, b0_r, b1_r, b2_r, b3_r); + DPADD_SH4_SW(temp0_l, temp0_l, temp0_l, temp0_l, + const4, const5, const6, const7, b0_l, b1_l, b2_l, b3_l); + BUTTERFLY_16(a0_r, a0_l, a1_r, a1_l, a2_r, a2_l, a3_r, a3_l, + b3_l, b3_r, b2_l, b2_r, b1_l, b1_r, b0_l, b0_r, + temp0_r, temp0_l, temp1_r, temp1_l, + temp2_r, temp2_l, temp3_r, temp3_l, + a3_l, a3_r, a2_l, a2_r, a1_l, a1_r, a0_l, a0_r); + SRA_4V(temp0_r, temp0_l, temp1_r, temp1_l, 20); + SRA_4V(temp2_r, temp2_l, temp3_r, temp3_l, 20); + SRA_4V(a3_r, a3_l, a2_r, a2_l, 20); + SRA_4V(a1_r, a1_l, a0_r, a0_l, 20); + PCKEV_H4_SW(temp0_l, temp0_r, temp1_l, temp1_r, temp2_l, temp2_r, + temp3_l, temp3_r, temp0_r, temp1_r, temp2_r, temp3_r); + PCKEV_H4_SW(a0_l, a0_r, a1_l, a1_r, a2_l, a2_r, a3_l, a3_r, + a0_r, a1_r, a2_r, a3_r); + temp0_r = (v4i32) CLIP_SH_0_255(temp0_r); + temp1_r = (v4i32) CLIP_SH_0_255(temp1_r); + temp2_r = (v4i32) CLIP_SH_0_255(temp2_r); + temp3_r = (v4i32) CLIP_SH_0_255(temp3_r); + PCKEV_B4_SW(temp0_r, temp0_r, temp1_r, temp1_r, + temp2_r, temp2_r, temp3_r, temp3_r, + temp0_r, temp1_r, temp2_r, temp3_r); + tmp0 = __msa_copy_u_d((v2i64) temp0_r, 1); + tmp1 = __msa_copy_u_d((v2i64) temp1_r, 1); + tmp2 = __msa_copy_u_d((v2i64) temp2_r, 1); + tmp3 = __msa_copy_u_d((v2i64) temp3_r, 1); + SD4(tmp0, tmp1, tmp2, tmp3, dst, dst_stride); + dst += 4 * dst_stride; + a0_r = (v4i32) CLIP_SH_0_255(a0_r); + a1_r = (v4i32) CLIP_SH_0_255(a1_r); + a2_r = (v4i32) CLIP_SH_0_255(a2_r); + a3_r = (v4i32) CLIP_SH_0_255(a3_r); + PCKEV_B4_SW(a0_r, a0_r, a1_r, a1_r, + a2_r, a2_r, a3_r, a3_r, a0_r, a1_r, a2_r, a3_r); + tmp3 = __msa_copy_u_d((v2i64) a0_r, 1); + tmp2 = __msa_copy_u_d((v2i64) a1_r, 1); + tmp1 = __msa_copy_u_d((v2i64) a2_r, 1); + tmp0 = __msa_copy_u_d((v2i64) a3_r, 1); + SD4(tmp0, tmp1, tmp2, tmp3, dst, dst_stride); + dst += 4 * dst_stride; +} + +static void simple_idct_add_msa(uint8_t *dst, int32_t dst_stride, + int16_t *block) +{ + int32_t const_val; + uint64_t tmp0, tmp1, tmp2, tmp3; + v8i16 weights = { 0, 22725, 21407, 19266, 16383, 12873, 8867, 4520 }; + v8i16 in0, in1, in2, in3, in4, in5, in6, in7; + v8i16 w1, w3, w5, w7; + v8i16 const0, const1, const2, const3, const4, const5, const6, const7; + v4i32 temp0_r, temp1_r, temp2_r, temp3_r; + v4i32 temp4_r, temp5_r, temp6_r, temp7_r, temp8_r; + v4i32 temp0_l, temp1_l, temp2_l, temp3_l; + v4i32 temp4_l, temp5_l, temp6_l, temp7_l, temp8_l; + v4i32 a0_r, a1_r, a2_r, a3_r, a0_l, a1_l, a2_l, a3_l; + v4i32 b0_r, b1_r, b2_r, b3_r, b0_l, b1_l, b2_l, b3_l; + v4i32 w2, w4, w6; + v8i16 select_vec, temp; + v8i16 zero = { 0 }; + v4i32 const_val0 = __msa_ldi_w(1); + v4i32 const_val1 = __msa_ldi_w(1); + + const_val0 <<= 10; + const_val = 16383 * ((1 << 19) / 16383); + const_val1 = __msa_insert_w(const_val0, 0, const_val); + const_val1 = __msa_splati_w(const_val1, 0); + LD_SH8(block, 8, in0, in1, in2, in3, in4, in5, in6, in7); + TRANSPOSE8x8_SH_SH(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + + select_vec = in1 | in2 | in3 | in4 | in5 | in6 | in7; + select_vec = __msa_clti_u_h((v8u16) select_vec, 1); + UNPCK_SH_SW(in0, a0_r, a0_l); + UNPCK_SH_SW(in2, temp3_r, temp3_l); + ILVRL_H2_SW(in1, in3, b3_r, b3_l); + UNPCK_SH_SW(in4, temp4_r, temp4_l); + UNPCK_SH_SW(in6, temp7_r, temp7_l); + ILVRL_H2_SW(in5, in7, temp8_r, temp8_l); + temp = in0 << 3; + SPLATI_H4_SH(weights, 1, 3, 5, 7, w1, w3, w5, w7); + ILVR_H4_SH(w1, w3, w3, -w7, w5, -w1, w7, -w5, + const0, const1, const2, const3); + ILVR_H2_SH(w5, w7, w7, w3, const4, const6); + const5 = __msa_ilvod_h(-w1, -w5); + const7 = __msa_ilvod_h(w3, -w1); + DOTP_SH4_SW(b3_r, b3_r, b3_r, b3_r, const0, const1, const2, const3, + b0_r, b1_r, b2_r, b3_r); + DPADD_SH4_SW(temp8_r, temp8_r, temp8_r, temp8_r, + const4, const5, const6, const7, b0_r, b1_r, b2_r, b3_r); + DOTP_SH4_SW(b3_l, b3_l, b3_l, b3_l, const0, const1, const2, const3, + b0_l, b1_l, b2_l, b3_l); + DPADD_SH4_SW(temp8_l, temp8_l, temp8_l, temp8_l, + const4, const5, const6, const7, b0_l, b1_l, b2_l, b3_l); + w2 = (v4i32) __msa_splati_h(weights, 2); + w2 = (v4i32) __msa_ilvr_h(zero, (v8i16) w2); + w4 = (v4i32) __msa_splati_h(weights, 4); + w4 = (v4i32) __msa_ilvr_h(zero, (v8i16) w4); + w6 = (v4i32) __msa_splati_h(weights, 6); + w6 = (v4i32) __msa_ilvr_h(zero, (v8i16) w6); + MUL2(a0_r, w4, a0_l, w4, a0_r, a0_l); + ADD2(a0_r, const_val0, a0_l, const_val0, temp0_r, temp0_l); + MUL2(w2, temp3_r, w2, temp3_l, temp1_r, temp1_l); + MUL2(w6, temp3_r, w6, temp3_l, temp2_r, temp2_l); + BUTTERFLY_8(temp0_r, temp0_l, temp0_r, temp0_l, + temp2_l, temp2_r, temp1_l, temp1_r, + a0_r, a0_l, a1_r, a1_l, a2_l, a2_r, a3_l, a3_r); + MUL2(temp4_r, w4, temp4_l, w4, temp4_r, temp4_l); + MUL2(temp7_r, w2, temp7_l, w2, temp6_r, temp6_l); + MUL2(temp7_r, w6, temp7_l, w6, temp5_r, temp5_l); + ADD2(a0_r, temp4_r, a0_l, temp4_l, a0_r, a0_l); + SUB2(a1_r, temp4_r, a1_l, temp4_l, a1_r, a1_l); + SUB2(a2_r, temp4_r, a2_l, temp4_l, a2_r, a2_l); + ADD2(a3_r, temp4_r, a3_l, temp4_l, a3_r, a3_l); + ADD2(a0_r, temp5_r, a0_l, temp5_l, a0_r, a0_l); + SUB2(a1_r, temp6_r, a1_l, temp6_l, a1_r, a1_l); + ADD2(a2_r, temp6_r, a2_l, temp6_l, a2_r, a2_l); + SUB2(a3_r, temp5_r, a3_l, temp5_l, a3_r, a3_l); + BUTTERFLY_16(a0_r, a0_l, a1_r, a1_l, a2_r, a2_l, a3_r, a3_l, + b3_l, b3_r, b2_l, b2_r, b1_l, b1_r, b0_l, b0_r, + temp0_r, temp0_l, temp1_r, temp1_l, + temp2_r, temp2_l, temp3_r, temp3_l, + a3_l, a3_r, a2_l, a2_r, a1_l, a1_r, a0_l, a0_r); + SRA_4V(temp0_r, temp0_l, temp1_r, temp1_l, 11); + SRA_4V(temp2_r, temp2_l, temp3_r, temp3_l, 11); + PCKEV_H4_SW(temp0_l, temp0_r, temp1_l, temp1_r, + temp2_l, temp2_r, temp3_l, temp3_r, + temp0_r, temp1_r, temp2_r, temp3_r); + in0 = (v8i16) __msa_bmnz_v((v16u8) temp0_r, (v16u8) temp, + (v16u8) select_vec); + in1 = (v8i16) __msa_bmnz_v((v16u8) temp1_r, (v16u8) temp, + (v16u8) select_vec); + in2 = (v8i16) __msa_bmnz_v((v16u8) temp2_r, (v16u8) temp, + (v16u8) select_vec); + in3 = (v8i16) __msa_bmnz_v((v16u8) temp3_r, (v16u8) temp, + (v16u8) select_vec); + SRA_4V(a3_r, a3_l, a2_r, a2_l, 11); + SRA_4V(a1_r, a1_l, a0_r, a0_l, 11); + PCKEV_H4_SW(a0_l, a0_r, a1_l, a1_r, a2_l, a2_r, a3_l, a3_r, + a0_r, a1_r, a2_r, a3_r); + in4 = (v8i16) __msa_bmnz_v((v16u8) a3_r, (v16u8) temp, (v16u8) select_vec); + in5 = (v8i16) __msa_bmnz_v((v16u8) a2_r, (v16u8) temp, (v16u8) select_vec); + in6 = (v8i16) __msa_bmnz_v((v16u8) a1_r, (v16u8) temp, (v16u8) select_vec); + in7 = (v8i16) __msa_bmnz_v((v16u8) a0_r, (v16u8) temp, (v16u8) select_vec); + TRANSPOSE8x8_SH_SH(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + + UNPCK_SH_SW(in0, a0_r, a0_l); + UNPCK_SH_SW(in2, temp3_r, temp3_l); + MUL2(a0_r, w4, a0_l, w4, a0_r, a0_l); + ADD2(a0_r, const_val1, a0_l, const_val1, temp0_r, temp0_l); + MUL2(w2, temp3_r, w2, temp3_l, temp1_r, temp1_l); + MUL2(w6, temp3_r, w6, temp3_l, temp2_r, temp2_l); + BUTTERFLY_8(temp0_r, temp0_l, temp0_r, temp0_l, + temp2_l, temp2_r, temp1_l, temp1_r, + a0_r, a0_l, a1_r, a1_l, a2_l, a2_r, a3_l, a3_r); + UNPCK_SH_SW(in4, temp0_r, temp0_l); + UNPCK_SH_SW(in6, temp3_r, temp3_l); + MUL2(temp0_r, w4, temp0_l, w4, temp0_r, temp0_l); + MUL2(w2, temp3_r, w2, temp3_l, temp2_r, temp2_l); + MUL2(w6, temp3_r, w6, temp3_l, temp1_r, temp1_l); + ADD2(a0_r, temp0_r, a0_l, temp0_l, a0_r, a0_l); + SUB2(a1_r, temp0_r, a1_l, temp0_l, a1_r, a1_l); + SUB2(a2_r, temp0_r, a2_l, temp0_l, a2_r, a2_l); + ADD2(a3_r, temp0_r, a3_l, temp0_l, a3_r, a3_l); + ADD2(a0_r, temp1_r, a0_l, temp1_l, a0_r, a0_l); + SUB2(a1_r, temp2_r, a1_l, temp2_l, a1_r, a1_l); + ADD2(a2_r, temp2_r, a2_l, temp2_l, a2_r, a2_l); + SUB2(a3_r, temp1_r, a3_l, temp1_l, a3_r, a3_l); + ILVRL_H2_SW(in1, in3, b3_r, b3_l); + ILVRL_H2_SW(in5, in7, temp0_r, temp0_l); + DOTP_SH4_SW(b3_r, b3_r, b3_r, b3_r, const0, const1, const2, const3, + b0_r, b1_r, b2_r, b3_r); + DOTP_SH4_SW(b3_l, b3_l, b3_l, b3_l, const0, const1, const2, const3, + b0_l, b1_l, b2_l, b3_l); + DPADD_SH4_SW(temp0_r, temp0_r, temp0_r, temp0_r, + const4, const5, const6, const7, b0_r, b1_r, b2_r, b3_r); + DPADD_SH4_SW(temp0_l, temp0_l, temp0_l, temp0_l, + const4, const5, const6, const7, b0_l, b1_l, b2_l, b3_l); + BUTTERFLY_16(a0_r, a0_l, a1_r, a1_l, a2_r, a2_l, a3_r, a3_l, + b3_l, b3_r, b2_l, b2_r, b1_l, b1_r, b0_l, b0_r, + temp0_r, temp0_l, temp1_r, temp1_l, + temp2_r, temp2_l, temp3_r, temp3_l, + a3_l, a3_r, a2_l, a2_r, a1_l, a1_r, a0_l, a0_r); + SRA_4V(temp0_r, temp0_l, temp1_r, temp1_l, 20); + SRA_4V(temp2_r, temp2_l, temp3_r, temp3_l, 20); + LD_SH4(dst, dst_stride, in0, in1, in2, in3); + PCKEV_H4_SW(temp0_l, temp0_r, temp1_l, temp1_r, temp2_l, temp2_r, + temp3_l, temp3_r, temp0_r, temp1_r, temp2_r, temp3_r); + ILVR_B4_SW(zero, in0, zero, in1, zero, in2, zero, in3, + temp0_l, temp1_l, temp2_l, temp3_l); + temp0_r = (v4i32) ((v8i16) (temp0_r) + (v8i16) (temp0_l)); + temp1_r = (v4i32) ((v8i16) (temp1_r) + (v8i16) (temp1_l)); + temp2_r = (v4i32) ((v8i16) (temp2_r) + (v8i16) (temp2_l)); + temp3_r = (v4i32) ((v8i16) (temp3_r) + (v8i16) (temp3_l)); + temp0_r = (v4i32) CLIP_SH_0_255(temp0_r); + temp1_r = (v4i32) CLIP_SH_0_255(temp1_r); + temp2_r = (v4i32) CLIP_SH_0_255(temp2_r); + temp3_r = (v4i32) CLIP_SH_0_255(temp3_r); + PCKEV_B4_SW(temp0_r, temp0_r, temp1_r, temp1_r, + temp2_r, temp2_r, temp3_r, temp3_r, + temp0_r, temp1_r, temp2_r, temp3_r); + tmp0 = __msa_copy_u_d((v2i64) temp0_r, 1); + tmp1 = __msa_copy_u_d((v2i64) temp1_r, 1); + tmp2 = __msa_copy_u_d((v2i64) temp2_r, 1); + tmp3 = __msa_copy_u_d((v2i64) temp3_r, 1); + SD4(tmp0, tmp1, tmp2, tmp3, dst, dst_stride); + + SRA_4V(a3_r, a3_l, a2_r, a2_l, 20); + SRA_4V(a1_r, a1_l, a0_r, a0_l, 20); + LD_SH4(dst + 4 * dst_stride, dst_stride, in4, in5, in6, in7); + PCKEV_H4_SW(a0_l, a0_r, a1_l, a1_r, a2_l, a2_r, a3_l, a3_r, + a0_r, a1_r, a2_r, a3_r); + ILVR_B4_SW(zero, in4, zero, in5, zero, in6, zero, in7, + a3_l, a2_l, a1_l, a0_l); + a3_r = (v4i32) ((v8i16) (a3_r) + (v8i16) (a3_l)); + a2_r = (v4i32) ((v8i16) (a2_r) + (v8i16) (a2_l)); + a1_r = (v4i32) ((v8i16) (a1_r) + (v8i16) (a1_l)); + a0_r = (v4i32) ((v8i16) (a0_r) + (v8i16) (a0_l)); + a3_r = (v4i32) CLIP_SH_0_255(a3_r); + a2_r = (v4i32) CLIP_SH_0_255(a2_r); + a1_r = (v4i32) CLIP_SH_0_255(a1_r); + a0_r = (v4i32) CLIP_SH_0_255(a0_r); + PCKEV_B4_SW(a0_r, a0_r, a1_r, a1_r, + a2_r, a2_r, a3_r, a3_r, a0_r, a1_r, a2_r, a3_r); + tmp0 = __msa_copy_u_d((v2i64) a3_r, 1); + tmp1 = __msa_copy_u_d((v2i64) a2_r, 1); + tmp2 = __msa_copy_u_d((v2i64) a1_r, 1); + tmp3 = __msa_copy_u_d((v2i64) a0_r, 1); + SD4(tmp0, tmp1, tmp2, tmp3, dst + 4 * dst_stride, dst_stride); +} + +void ff_simple_idct_msa(int16_t *block) +{ + simple_idct_msa(block); +} + +void ff_simple_idct_put_msa(uint8_t *dst, int32_t dst_stride, int16_t *block) +{ + simple_idct_put_msa(dst, dst_stride, block); +} + +void ff_simple_idct_add_msa(uint8_t *dst, int32_t dst_stride, int16_t *block) +{ + simple_idct_add_msa(dst, dst_stride, block); +} diff --git a/libavutil/mips/generic_macros_msa.h b/libavutil/mips/generic_macros_msa.h index d6a2573403..6e5598056e 100644 --- a/libavutil/mips/generic_macros_msa.h +++ b/libavutil/mips/generic_macros_msa.h @@ -507,6 +507,14 @@ ST_SW(in0, (pdst)); \ ST_SW(in1, (pdst) + stride); \ } +#define ST_SW8(in0, in1, in2, in3, in4, in5, in6, in7, \ + pdst, stride) \ +{ \ + ST_SW2(in0, in1, (pdst), stride); \ + ST_SW2(in2, in3, (pdst) + 2 * stride, stride); \ + ST_SW2(in4, in5, (pdst) + 4 * stride, stride); \ + ST_SW2(in6, in7, (pdst) + 6 * stride, stride); \ +} /* Description : Store as 2x4 byte block to destination memory from input vector Arguments : Inputs - in, stidx, pdst, stride @@ -2382,6 +2390,35 @@ out7 = in0 - in7; \ } +/* Description : Butterfly of 16 input vectors + Arguments : Inputs - in0 ... in15 + Outputs - out0 .. out15 + Details : Butterfly operation +*/ +#define BUTTERFLY_16(in0, in1, in2, in3, in4, in5, in6, in7, \ + in8, in9, in10, in11, in12, in13, in14, in15, \ + out0, out1, out2, out3, out4, out5, out6, out7, \ + out8, out9, out10, out11, out12, out13, out14, out15) \ +{ \ + out0 = in0 + in15; \ + out1 = in1 + in14; \ + out2 = in2 + in13; \ + out3 = in3 + in12; \ + out4 = in4 + in11; \ + out5 = in5 + in10; \ + out6 = in6 + in9; \ + out7 = in7 + in8; \ + \ + out8 = in7 - in8; \ + out9 = in6 - in9; \ + out10 = in5 - in10; \ + out11 = in4 - in11; \ + out12 = in3 - in12; \ + out13 = in2 - in13; \ + out14 = in1 - in14; \ + out15 = in0 - in15; \ +} + /* Description : Transposes input 4x4 byte block Arguments : Inputs - in0, in1, in2, in3 (input 4x4 byte block) Outputs - out0, out1, out2, out3 (output 4x4 byte block) |