123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731 |
- /*
- * Copyright (c) 2015 The WebM project authors. All Rights Reserved.
- *
- * Use of this source code is governed by a BSD-style license
- * that can be found in the LICENSE file in the root of the source
- * tree. An additional intellectual property rights grant can be found
- * in the file PATENTS. All contributing project authors may
- * be found in the AUTHORS file in the root of the source tree.
- */
- #include <stdlib.h>
- #include "./vpx_config.h"
- #include "./vpx_dsp_rtcd.h"
- #include "vpx_dsp/mips/macros_msa.h"
- uint32_t vpx_avg_8x8_msa(const uint8_t *src, int32_t src_stride) {
- uint32_t sum_out;
- v16u8 src0, src1, src2, src3, src4, src5, src6, src7;
- v8u16 sum0, sum1, sum2, sum3, sum4, sum5, sum6, sum7;
- v4u32 sum = { 0 };
- LD_UB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7);
- HADD_UB4_UH(src0, src1, src2, src3, sum0, sum1, sum2, sum3);
- HADD_UB4_UH(src4, src5, src6, src7, sum4, sum5, sum6, sum7);
- ADD4(sum0, sum1, sum2, sum3, sum4, sum5, sum6, sum7, sum0, sum2, sum4, sum6);
- ADD2(sum0, sum2, sum4, sum6, sum0, sum4);
- sum0 += sum4;
- sum = __msa_hadd_u_w(sum0, sum0);
- sum0 = (v8u16)__msa_pckev_h((v8i16)sum, (v8i16)sum);
- sum = __msa_hadd_u_w(sum0, sum0);
- sum = (v4u32)__msa_srari_w((v4i32)sum, 6);
- sum_out = __msa_copy_u_w((v4i32)sum, 0);
- return sum_out;
- }
- uint32_t vpx_avg_4x4_msa(const uint8_t *src, int32_t src_stride) {
- uint32_t sum_out;
- uint32_t src0, src1, src2, src3;
- v16u8 vec = { 0 };
- v8u16 sum0;
- v4u32 sum1;
- v2u64 sum2;
- LW4(src, src_stride, src0, src1, src2, src3);
- INSERT_W4_UB(src0, src1, src2, src3, vec);
- sum0 = __msa_hadd_u_h(vec, vec);
- sum1 = __msa_hadd_u_w(sum0, sum0);
- sum0 = (v8u16)__msa_pckev_h((v8i16)sum1, (v8i16)sum1);
- sum1 = __msa_hadd_u_w(sum0, sum0);
- sum2 = __msa_hadd_u_d(sum1, sum1);
- sum1 = (v4u32)__msa_srari_w((v4i32)sum2, 4);
- sum_out = __msa_copy_u_w((v4i32)sum1, 0);
- return sum_out;
- }
- #if !CONFIG_VP9_HIGHBITDEPTH
- void vpx_hadamard_8x8_msa(const int16_t *src, ptrdiff_t src_stride,
- int16_t *dst) {
- v8i16 src0, src1, src2, src3, src4, src5, src6, src7;
- v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
- LD_SH8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7);
- BUTTERFLY_8(src0, src2, src4, src6, src7, src5, src3, src1, tmp0, tmp2, tmp4,
- tmp6, tmp7, tmp5, tmp3, tmp1);
- BUTTERFLY_8(tmp0, tmp1, tmp4, tmp5, tmp7, tmp6, tmp3, tmp2, src0, src1, src4,
- src5, src7, src6, src3, src2);
- BUTTERFLY_8(src0, src1, src2, src3, src7, src6, src5, src4, tmp0, tmp7, tmp3,
- tmp4, tmp5, tmp1, tmp6, tmp2);
- TRANSPOSE8x8_SH_SH(tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, src0, src1,
- src2, src3, src4, src5, src6, src7);
- BUTTERFLY_8(src0, src2, src4, src6, src7, src5, src3, src1, tmp0, tmp2, tmp4,
- tmp6, tmp7, tmp5, tmp3, tmp1);
- BUTTERFLY_8(tmp0, tmp1, tmp4, tmp5, tmp7, tmp6, tmp3, tmp2, src0, src1, src4,
- src5, src7, src6, src3, src2);
- BUTTERFLY_8(src0, src1, src2, src3, src7, src6, src5, src4, tmp0, tmp7, tmp3,
- tmp4, tmp5, tmp1, tmp6, tmp2);
- TRANSPOSE8x8_SH_SH(tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, src0, src1,
- src2, src3, src4, src5, src6, src7);
- ST_SH8(src0, src1, src2, src3, src4, src5, src6, src7, dst, 8);
- }
- void vpx_hadamard_16x16_msa(const int16_t *src, ptrdiff_t src_stride,
- int16_t *dst) {
- v8i16 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, src10;
- v8i16 src11, src12, src13, src14, src15, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5;
- v8i16 tmp6, tmp7, tmp8, tmp9, tmp10, tmp11, tmp12, tmp13, tmp14, tmp15;
- v8i16 res0, res1, res2, res3, res4, res5, res6, res7;
- LD_SH2(src, 8, src0, src8);
- src += src_stride;
- LD_SH2(src, 8, src1, src9);
- src += src_stride;
- LD_SH2(src, 8, src2, src10);
- src += src_stride;
- LD_SH2(src, 8, src3, src11);
- src += src_stride;
- LD_SH2(src, 8, src4, src12);
- src += src_stride;
- LD_SH2(src, 8, src5, src13);
- src += src_stride;
- LD_SH2(src, 8, src6, src14);
- src += src_stride;
- LD_SH2(src, 8, src7, src15);
- src += src_stride;
- BUTTERFLY_8(src0, src2, src4, src6, src7, src5, src3, src1, tmp0, tmp2, tmp4,
- tmp6, tmp7, tmp5, tmp3, tmp1);
- BUTTERFLY_8(src8, src10, src12, src14, src15, src13, src11, src9, tmp8, tmp10,
- tmp12, tmp14, tmp15, tmp13, tmp11, tmp9);
- BUTTERFLY_8(tmp0, tmp1, tmp4, tmp5, tmp7, tmp6, tmp3, tmp2, src0, src1, src4,
- src5, src7, src6, src3, src2);
- BUTTERFLY_8(src0, src1, src2, src3, src7, src6, src5, src4, tmp0, tmp7, tmp3,
- tmp4, tmp5, tmp1, tmp6, tmp2);
- TRANSPOSE8x8_SH_SH(tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, src0, src1,
- src2, src3, src4, src5, src6, src7);
- BUTTERFLY_8(src0, src2, src4, src6, src7, src5, src3, src1, tmp0, tmp2, tmp4,
- tmp6, tmp7, tmp5, tmp3, tmp1);
- BUTTERFLY_8(tmp0, tmp1, tmp4, tmp5, tmp7, tmp6, tmp3, tmp2, src0, src1, src4,
- src5, src7, src6, src3, src2);
- BUTTERFLY_8(src0, src1, src2, src3, src7, src6, src5, src4, tmp0, tmp7, tmp3,
- tmp4, tmp5, tmp1, tmp6, tmp2);
- TRANSPOSE8x8_SH_SH(tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, src0, src1,
- src2, src11, src4, src5, src6, src7);
- ST_SH8(src0, src1, src2, src11, src4, src5, src6, src7, dst, 8);
- BUTTERFLY_8(tmp8, tmp9, tmp12, tmp13, tmp15, tmp14, tmp11, tmp10, src8, src9,
- src12, src13, src15, src14, src11, src10);
- BUTTERFLY_8(src8, src9, src10, src11, src15, src14, src13, src12, tmp8, tmp15,
- tmp11, tmp12, tmp13, tmp9, tmp14, tmp10);
- TRANSPOSE8x8_SH_SH(tmp8, tmp9, tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, src8,
- src9, src10, src11, src12, src13, src14, src15);
- BUTTERFLY_8(src8, src10, src12, src14, src15, src13, src11, src9, tmp8, tmp10,
- tmp12, tmp14, tmp15, tmp13, tmp11, tmp9);
- BUTTERFLY_8(tmp8, tmp9, tmp12, tmp13, tmp15, tmp14, tmp11, tmp10, src8, src9,
- src12, src13, src15, src14, src11, src10);
- BUTTERFLY_8(src8, src9, src10, src11, src15, src14, src13, src12, tmp8, tmp15,
- tmp11, tmp12, tmp13, tmp9, tmp14, tmp10);
- TRANSPOSE8x8_SH_SH(tmp8, tmp9, tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, res0,
- res1, res2, res3, res4, res5, res6, res7);
- LD_SH2(src, 8, src0, src8);
- src += src_stride;
- LD_SH2(src, 8, src1, src9);
- src += src_stride;
- LD_SH2(src, 8, src2, src10);
- src += src_stride;
- LD_SH2(src, 8, src3, src11);
- src += src_stride;
- ST_SH8(res0, res1, res2, res3, res4, res5, res6, res7, dst + 64, 8);
- LD_SH2(src, 8, src4, src12);
- src += src_stride;
- LD_SH2(src, 8, src5, src13);
- src += src_stride;
- LD_SH2(src, 8, src6, src14);
- src += src_stride;
- LD_SH2(src, 8, src7, src15);
- src += src_stride;
- BUTTERFLY_8(src0, src2, src4, src6, src7, src5, src3, src1, tmp0, tmp2, tmp4,
- tmp6, tmp7, tmp5, tmp3, tmp1);
- BUTTERFLY_8(src8, src10, src12, src14, src15, src13, src11, src9, tmp8, tmp10,
- tmp12, tmp14, tmp15, tmp13, tmp11, tmp9);
- BUTTERFLY_8(tmp0, tmp1, tmp4, tmp5, tmp7, tmp6, tmp3, tmp2, src0, src1, src4,
- src5, src7, src6, src3, src2);
- BUTTERFLY_8(src0, src1, src2, src3, src7, src6, src5, src4, tmp0, tmp7, tmp3,
- tmp4, tmp5, tmp1, tmp6, tmp2);
- TRANSPOSE8x8_SH_SH(tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, src0, src1,
- src2, src3, src4, src5, src6, src7);
- BUTTERFLY_8(src0, src2, src4, src6, src7, src5, src3, src1, tmp0, tmp2, tmp4,
- tmp6, tmp7, tmp5, tmp3, tmp1);
- BUTTERFLY_8(tmp0, tmp1, tmp4, tmp5, tmp7, tmp6, tmp3, tmp2, src0, src1, src4,
- src5, src7, src6, src3, src2);
- BUTTERFLY_8(src0, src1, src2, src3, src7, src6, src5, src4, tmp0, tmp7, tmp3,
- tmp4, tmp5, tmp1, tmp6, tmp2);
- TRANSPOSE8x8_SH_SH(tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, src0, src1,
- src2, src3, src4, src5, src6, src7);
- ST_SH8(src0, src1, src2, src3, src4, src5, src6, src7, dst + 2 * 64, 8);
- BUTTERFLY_8(tmp8, tmp9, tmp12, tmp13, tmp15, tmp14, tmp11, tmp10, src8, src9,
- src12, src13, src15, src14, src11, src10);
- BUTTERFLY_8(src8, src9, src10, src11, src15, src14, src13, src12, tmp8, tmp15,
- tmp11, tmp12, tmp13, tmp9, tmp14, tmp10);
- TRANSPOSE8x8_SH_SH(tmp8, tmp9, tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, src8,
- src9, src10, src11, src12, src13, src14, src15);
- BUTTERFLY_8(src8, src10, src12, src14, src15, src13, src11, src9, tmp8, tmp10,
- tmp12, tmp14, tmp15, tmp13, tmp11, tmp9);
- BUTTERFLY_8(tmp8, tmp9, tmp12, tmp13, tmp15, tmp14, tmp11, tmp10, src8, src9,
- src12, src13, src15, src14, src11, src10);
- BUTTERFLY_8(src8, src9, src10, src11, src15, src14, src13, src12, tmp8, tmp15,
- tmp11, tmp12, tmp13, tmp9, tmp14, tmp10);
- TRANSPOSE8x8_SH_SH(tmp8, tmp9, tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, res0,
- res1, res2, res3, res4, res5, res6, res7);
- ST_SH8(res0, res1, res2, res3, res4, res5, res6, res7, dst + 3 * 64, 8);
- LD_SH4(dst, 64, src0, src1, src2, src3);
- LD_SH4(dst + 8, 64, src4, src5, src6, src7);
- BUTTERFLY_8(src0, src2, src4, src6, src7, src5, src3, src1, tmp0, tmp2, tmp4,
- tmp6, tmp7, tmp5, tmp3, tmp1);
- SRA_4V(tmp0, tmp1, tmp2, tmp3, 1);
- SRA_4V(tmp4, tmp5, tmp6, tmp7, 1);
- BUTTERFLY_8(tmp0, tmp1, tmp4, tmp5, tmp7, tmp6, tmp3, tmp2, src0, src1, src4,
- src5, src7, src6, src3, src2);
- ST_SH4(src0, src1, src2, src3, dst, 64);
- ST_SH4(src4, src5, src6, src7, dst + 8, 64);
- dst += 16;
- LD_SH4(dst, 64, src0, src1, src2, src3);
- LD_SH4(dst + 8, 64, src4, src5, src6, src7);
- BUTTERFLY_8(src0, src2, src4, src6, src7, src5, src3, src1, tmp0, tmp2, tmp4,
- tmp6, tmp7, tmp5, tmp3, tmp1);
- SRA_4V(tmp0, tmp1, tmp2, tmp3, 1);
- SRA_4V(tmp4, tmp5, tmp6, tmp7, 1);
- BUTTERFLY_8(tmp0, tmp1, tmp4, tmp5, tmp7, tmp6, tmp3, tmp2, src0, src1, src4,
- src5, src7, src6, src3, src2);
- ST_SH4(src0, src1, src2, src3, dst, 64);
- ST_SH4(src4, src5, src6, src7, dst + 8, 64);
- dst += 16;
- LD_SH4(dst, 64, src0, src1, src2, src3);
- LD_SH4(dst + 8, 64, src4, src5, src6, src7);
- BUTTERFLY_8(src0, src2, src4, src6, src7, src5, src3, src1, tmp0, tmp2, tmp4,
- tmp6, tmp7, tmp5, tmp3, tmp1);
- SRA_4V(tmp0, tmp1, tmp2, tmp3, 1);
- SRA_4V(tmp4, tmp5, tmp6, tmp7, 1);
- BUTTERFLY_8(tmp0, tmp1, tmp4, tmp5, tmp7, tmp6, tmp3, tmp2, src0, src1, src4,
- src5, src7, src6, src3, src2);
- ST_SH4(src0, src1, src2, src3, dst, 64);
- ST_SH4(src4, src5, src6, src7, dst + 8, 64);
- dst += 16;
- LD_SH4(dst, 64, src0, src1, src2, src3);
- LD_SH4(dst + 8, 64, src4, src5, src6, src7);
- BUTTERFLY_8(src0, src2, src4, src6, src7, src5, src3, src1, tmp0, tmp2, tmp4,
- tmp6, tmp7, tmp5, tmp3, tmp1);
- SRA_4V(tmp0, tmp1, tmp2, tmp3, 1);
- SRA_4V(tmp4, tmp5, tmp6, tmp7, 1);
- BUTTERFLY_8(tmp0, tmp1, tmp4, tmp5, tmp7, tmp6, tmp3, tmp2, src0, src1, src4,
- src5, src7, src6, src3, src2);
- ST_SH4(src0, src1, src2, src3, dst, 64);
- ST_SH4(src4, src5, src6, src7, dst + 8, 64);
- }
- int vpx_satd_msa(const int16_t *data, int length) {
- int i, satd;
- v8i16 src0, src1, src2, src3, src4, src5, src6, src7;
- v8i16 src8, src9, src10, src11, src12, src13, src14, src15;
- v8i16 zero = { 0 };
- v8u16 tmp0_h, tmp1_h, tmp2_h, tmp3_h, tmp4_h, tmp5_h, tmp6_h, tmp7_h;
- v4u32 tmp0_w = { 0 };
- if (16 == length) {
- LD_SH2(data, 8, src0, src1);
- tmp0_h = (v8u16)__msa_asub_s_h(src0, zero);
- tmp1_h = (v8u16)__msa_asub_s_h(src1, zero);
- tmp0_w = __msa_hadd_u_w(tmp0_h, tmp0_h);
- tmp0_w += __msa_hadd_u_w(tmp1_h, tmp1_h);
- satd = HADD_UW_U32(tmp0_w);
- } else if (64 == length) {
- LD_SH8(data, 8, src0, src1, src2, src3, src4, src5, src6, src7);
- tmp0_h = (v8u16)__msa_asub_s_h(src0, zero);
- tmp1_h = (v8u16)__msa_asub_s_h(src1, zero);
- tmp2_h = (v8u16)__msa_asub_s_h(src2, zero);
- tmp3_h = (v8u16)__msa_asub_s_h(src3, zero);
- tmp4_h = (v8u16)__msa_asub_s_h(src4, zero);
- tmp5_h = (v8u16)__msa_asub_s_h(src5, zero);
- tmp6_h = (v8u16)__msa_asub_s_h(src6, zero);
- tmp7_h = (v8u16)__msa_asub_s_h(src7, zero);
- tmp0_w = __msa_hadd_u_w(tmp0_h, tmp0_h);
- tmp0_w += __msa_hadd_u_w(tmp1_h, tmp1_h);
- tmp0_w += __msa_hadd_u_w(tmp2_h, tmp2_h);
- tmp0_w += __msa_hadd_u_w(tmp3_h, tmp3_h);
- tmp0_w += __msa_hadd_u_w(tmp4_h, tmp4_h);
- tmp0_w += __msa_hadd_u_w(tmp5_h, tmp5_h);
- tmp0_w += __msa_hadd_u_w(tmp6_h, tmp6_h);
- tmp0_w += __msa_hadd_u_w(tmp7_h, tmp7_h);
- satd = HADD_UW_U32(tmp0_w);
- } else if (256 == length) {
- for (i = 0; i < 2; ++i) {
- LD_SH8(data, 8, src0, src1, src2, src3, src4, src5, src6, src7);
- data += 8 * 8;
- LD_SH8(data, 8, src8, src9, src10, src11, src12, src13, src14, src15);
- data += 8 * 8;
- tmp0_h = (v8u16)__msa_asub_s_h(src0, zero);
- tmp1_h = (v8u16)__msa_asub_s_h(src1, zero);
- tmp2_h = (v8u16)__msa_asub_s_h(src2, zero);
- tmp3_h = (v8u16)__msa_asub_s_h(src3, zero);
- tmp4_h = (v8u16)__msa_asub_s_h(src4, zero);
- tmp5_h = (v8u16)__msa_asub_s_h(src5, zero);
- tmp6_h = (v8u16)__msa_asub_s_h(src6, zero);
- tmp7_h = (v8u16)__msa_asub_s_h(src7, zero);
- tmp0_w += __msa_hadd_u_w(tmp0_h, tmp0_h);
- tmp0_w += __msa_hadd_u_w(tmp1_h, tmp1_h);
- tmp0_w += __msa_hadd_u_w(tmp2_h, tmp2_h);
- tmp0_w += __msa_hadd_u_w(tmp3_h, tmp3_h);
- tmp0_w += __msa_hadd_u_w(tmp4_h, tmp4_h);
- tmp0_w += __msa_hadd_u_w(tmp5_h, tmp5_h);
- tmp0_w += __msa_hadd_u_w(tmp6_h, tmp6_h);
- tmp0_w += __msa_hadd_u_w(tmp7_h, tmp7_h);
- tmp0_h = (v8u16)__msa_asub_s_h(src8, zero);
- tmp1_h = (v8u16)__msa_asub_s_h(src9, zero);
- tmp2_h = (v8u16)__msa_asub_s_h(src10, zero);
- tmp3_h = (v8u16)__msa_asub_s_h(src11, zero);
- tmp4_h = (v8u16)__msa_asub_s_h(src12, zero);
- tmp5_h = (v8u16)__msa_asub_s_h(src13, zero);
- tmp6_h = (v8u16)__msa_asub_s_h(src14, zero);
- tmp7_h = (v8u16)__msa_asub_s_h(src15, zero);
- tmp0_w += __msa_hadd_u_w(tmp0_h, tmp0_h);
- tmp0_w += __msa_hadd_u_w(tmp1_h, tmp1_h);
- tmp0_w += __msa_hadd_u_w(tmp2_h, tmp2_h);
- tmp0_w += __msa_hadd_u_w(tmp3_h, tmp3_h);
- tmp0_w += __msa_hadd_u_w(tmp4_h, tmp4_h);
- tmp0_w += __msa_hadd_u_w(tmp5_h, tmp5_h);
- tmp0_w += __msa_hadd_u_w(tmp6_h, tmp6_h);
- tmp0_w += __msa_hadd_u_w(tmp7_h, tmp7_h);
- }
- satd = HADD_UW_U32(tmp0_w);
- } else if (1024 == length) {
- for (i = 0; i < 8; ++i) {
- LD_SH8(data, 8, src0, src1, src2, src3, src4, src5, src6, src7);
- data += 8 * 8;
- LD_SH8(data, 8, src8, src9, src10, src11, src12, src13, src14, src15);
- data += 8 * 8;
- tmp0_h = (v8u16)__msa_asub_s_h(src0, zero);
- tmp1_h = (v8u16)__msa_asub_s_h(src1, zero);
- tmp2_h = (v8u16)__msa_asub_s_h(src2, zero);
- tmp3_h = (v8u16)__msa_asub_s_h(src3, zero);
- tmp4_h = (v8u16)__msa_asub_s_h(src4, zero);
- tmp5_h = (v8u16)__msa_asub_s_h(src5, zero);
- tmp6_h = (v8u16)__msa_asub_s_h(src6, zero);
- tmp7_h = (v8u16)__msa_asub_s_h(src7, zero);
- tmp0_w += __msa_hadd_u_w(tmp0_h, tmp0_h);
- tmp0_w += __msa_hadd_u_w(tmp1_h, tmp1_h);
- tmp0_w += __msa_hadd_u_w(tmp2_h, tmp2_h);
- tmp0_w += __msa_hadd_u_w(tmp3_h, tmp3_h);
- tmp0_w += __msa_hadd_u_w(tmp4_h, tmp4_h);
- tmp0_w += __msa_hadd_u_w(tmp5_h, tmp5_h);
- tmp0_w += __msa_hadd_u_w(tmp6_h, tmp6_h);
- tmp0_w += __msa_hadd_u_w(tmp7_h, tmp7_h);
- tmp0_h = (v8u16)__msa_asub_s_h(src8, zero);
- tmp1_h = (v8u16)__msa_asub_s_h(src9, zero);
- tmp2_h = (v8u16)__msa_asub_s_h(src10, zero);
- tmp3_h = (v8u16)__msa_asub_s_h(src11, zero);
- tmp4_h = (v8u16)__msa_asub_s_h(src12, zero);
- tmp5_h = (v8u16)__msa_asub_s_h(src13, zero);
- tmp6_h = (v8u16)__msa_asub_s_h(src14, zero);
- tmp7_h = (v8u16)__msa_asub_s_h(src15, zero);
- tmp0_w += __msa_hadd_u_w(tmp0_h, tmp0_h);
- tmp0_w += __msa_hadd_u_w(tmp1_h, tmp1_h);
- tmp0_w += __msa_hadd_u_w(tmp2_h, tmp2_h);
- tmp0_w += __msa_hadd_u_w(tmp3_h, tmp3_h);
- tmp0_w += __msa_hadd_u_w(tmp4_h, tmp4_h);
- tmp0_w += __msa_hadd_u_w(tmp5_h, tmp5_h);
- tmp0_w += __msa_hadd_u_w(tmp6_h, tmp6_h);
- tmp0_w += __msa_hadd_u_w(tmp7_h, tmp7_h);
- }
- satd = HADD_UW_U32(tmp0_w);
- } else {
- satd = 0;
- for (i = 0; i < length; ++i) {
- satd += abs(data[i]);
- }
- }
- return satd;
- }
- #endif // !CONFIG_VP9_HIGHBITDEPTH
- void vpx_int_pro_row_msa(int16_t hbuf[16], const uint8_t *ref,
- const int ref_stride, const int height) {
- int i;
- v16u8 ref0, ref1, ref2, ref3, ref4, ref5, ref6, ref7;
- v8i16 hbuf_r = { 0 };
- v8i16 hbuf_l = { 0 };
- v8i16 ref0_r, ref0_l, ref1_r, ref1_l, ref2_r, ref2_l, ref3_r, ref3_l;
- v8i16 ref4_r, ref4_l, ref5_r, ref5_l, ref6_r, ref6_l, ref7_r, ref7_l;
- if (16 == height) {
- for (i = 2; i--;) {
- LD_UB8(ref, ref_stride, ref0, ref1, ref2, ref3, ref4, ref5, ref6, ref7);
- ref += 8 * ref_stride;
- UNPCK_UB_SH(ref0, ref0_r, ref0_l);
- UNPCK_UB_SH(ref1, ref1_r, ref1_l);
- UNPCK_UB_SH(ref2, ref2_r, ref2_l);
- UNPCK_UB_SH(ref3, ref3_r, ref3_l);
- UNPCK_UB_SH(ref4, ref4_r, ref4_l);
- UNPCK_UB_SH(ref5, ref5_r, ref5_l);
- UNPCK_UB_SH(ref6, ref6_r, ref6_l);
- UNPCK_UB_SH(ref7, ref7_r, ref7_l);
- ADD4(hbuf_r, ref0_r, hbuf_l, ref0_l, hbuf_r, ref1_r, hbuf_l, ref1_l,
- hbuf_r, hbuf_l, hbuf_r, hbuf_l);
- ADD4(hbuf_r, ref2_r, hbuf_l, ref2_l, hbuf_r, ref3_r, hbuf_l, ref3_l,
- hbuf_r, hbuf_l, hbuf_r, hbuf_l);
- ADD4(hbuf_r, ref4_r, hbuf_l, ref4_l, hbuf_r, ref5_r, hbuf_l, ref5_l,
- hbuf_r, hbuf_l, hbuf_r, hbuf_l);
- ADD4(hbuf_r, ref6_r, hbuf_l, ref6_l, hbuf_r, ref7_r, hbuf_l, ref7_l,
- hbuf_r, hbuf_l, hbuf_r, hbuf_l);
- }
- SRA_2V(hbuf_r, hbuf_l, 3);
- ST_SH2(hbuf_r, hbuf_l, hbuf, 8);
- } else if (32 == height) {
- for (i = 2; i--;) {
- LD_UB8(ref, ref_stride, ref0, ref1, ref2, ref3, ref4, ref5, ref6, ref7);
- ref += 8 * ref_stride;
- UNPCK_UB_SH(ref0, ref0_r, ref0_l);
- UNPCK_UB_SH(ref1, ref1_r, ref1_l);
- UNPCK_UB_SH(ref2, ref2_r, ref2_l);
- UNPCK_UB_SH(ref3, ref3_r, ref3_l);
- UNPCK_UB_SH(ref4, ref4_r, ref4_l);
- UNPCK_UB_SH(ref5, ref5_r, ref5_l);
- UNPCK_UB_SH(ref6, ref6_r, ref6_l);
- UNPCK_UB_SH(ref7, ref7_r, ref7_l);
- ADD4(hbuf_r, ref0_r, hbuf_l, ref0_l, hbuf_r, ref1_r, hbuf_l, ref1_l,
- hbuf_r, hbuf_l, hbuf_r, hbuf_l);
- ADD4(hbuf_r, ref2_r, hbuf_l, ref2_l, hbuf_r, ref3_r, hbuf_l, ref3_l,
- hbuf_r, hbuf_l, hbuf_r, hbuf_l);
- ADD4(hbuf_r, ref4_r, hbuf_l, ref4_l, hbuf_r, ref5_r, hbuf_l, ref5_l,
- hbuf_r, hbuf_l, hbuf_r, hbuf_l);
- ADD4(hbuf_r, ref6_r, hbuf_l, ref6_l, hbuf_r, ref7_r, hbuf_l, ref7_l,
- hbuf_r, hbuf_l, hbuf_r, hbuf_l);
- LD_UB8(ref, ref_stride, ref0, ref1, ref2, ref3, ref4, ref5, ref6, ref7);
- ref += 8 * ref_stride;
- UNPCK_UB_SH(ref0, ref0_r, ref0_l);
- UNPCK_UB_SH(ref1, ref1_r, ref1_l);
- UNPCK_UB_SH(ref2, ref2_r, ref2_l);
- UNPCK_UB_SH(ref3, ref3_r, ref3_l);
- UNPCK_UB_SH(ref4, ref4_r, ref4_l);
- UNPCK_UB_SH(ref5, ref5_r, ref5_l);
- UNPCK_UB_SH(ref6, ref6_r, ref6_l);
- UNPCK_UB_SH(ref7, ref7_r, ref7_l);
- ADD4(hbuf_r, ref0_r, hbuf_l, ref0_l, hbuf_r, ref1_r, hbuf_l, ref1_l,
- hbuf_r, hbuf_l, hbuf_r, hbuf_l);
- ADD4(hbuf_r, ref2_r, hbuf_l, ref2_l, hbuf_r, ref3_r, hbuf_l, ref3_l,
- hbuf_r, hbuf_l, hbuf_r, hbuf_l);
- ADD4(hbuf_r, ref4_r, hbuf_l, ref4_l, hbuf_r, ref5_r, hbuf_l, ref5_l,
- hbuf_r, hbuf_l, hbuf_r, hbuf_l);
- ADD4(hbuf_r, ref6_r, hbuf_l, ref6_l, hbuf_r, ref7_r, hbuf_l, ref7_l,
- hbuf_r, hbuf_l, hbuf_r, hbuf_l);
- }
- SRA_2V(hbuf_r, hbuf_l, 4);
- ST_SH2(hbuf_r, hbuf_l, hbuf, 8);
- } else if (64 == height) {
- for (i = 4; i--;) {
- LD_UB8(ref, ref_stride, ref0, ref1, ref2, ref3, ref4, ref5, ref6, ref7);
- ref += 8 * ref_stride;
- UNPCK_UB_SH(ref0, ref0_r, ref0_l);
- UNPCK_UB_SH(ref1, ref1_r, ref1_l);
- UNPCK_UB_SH(ref2, ref2_r, ref2_l);
- UNPCK_UB_SH(ref3, ref3_r, ref3_l);
- UNPCK_UB_SH(ref4, ref4_r, ref4_l);
- UNPCK_UB_SH(ref5, ref5_r, ref5_l);
- UNPCK_UB_SH(ref6, ref6_r, ref6_l);
- UNPCK_UB_SH(ref7, ref7_r, ref7_l);
- ADD4(hbuf_r, ref0_r, hbuf_l, ref0_l, hbuf_r, ref1_r, hbuf_l, ref1_l,
- hbuf_r, hbuf_l, hbuf_r, hbuf_l);
- ADD4(hbuf_r, ref2_r, hbuf_l, ref2_l, hbuf_r, ref3_r, hbuf_l, ref3_l,
- hbuf_r, hbuf_l, hbuf_r, hbuf_l);
- ADD4(hbuf_r, ref4_r, hbuf_l, ref4_l, hbuf_r, ref5_r, hbuf_l, ref5_l,
- hbuf_r, hbuf_l, hbuf_r, hbuf_l);
- ADD4(hbuf_r, ref6_r, hbuf_l, ref6_l, hbuf_r, ref7_r, hbuf_l, ref7_l,
- hbuf_r, hbuf_l, hbuf_r, hbuf_l);
- LD_UB8(ref, ref_stride, ref0, ref1, ref2, ref3, ref4, ref5, ref6, ref7);
- ref += 8 * ref_stride;
- UNPCK_UB_SH(ref0, ref0_r, ref0_l);
- UNPCK_UB_SH(ref1, ref1_r, ref1_l);
- UNPCK_UB_SH(ref2, ref2_r, ref2_l);
- UNPCK_UB_SH(ref3, ref3_r, ref3_l);
- UNPCK_UB_SH(ref4, ref4_r, ref4_l);
- UNPCK_UB_SH(ref5, ref5_r, ref5_l);
- UNPCK_UB_SH(ref6, ref6_r, ref6_l);
- UNPCK_UB_SH(ref7, ref7_r, ref7_l);
- ADD4(hbuf_r, ref0_r, hbuf_l, ref0_l, hbuf_r, ref1_r, hbuf_l, ref1_l,
- hbuf_r, hbuf_l, hbuf_r, hbuf_l);
- ADD4(hbuf_r, ref2_r, hbuf_l, ref2_l, hbuf_r, ref3_r, hbuf_l, ref3_l,
- hbuf_r, hbuf_l, hbuf_r, hbuf_l);
- ADD4(hbuf_r, ref4_r, hbuf_l, ref4_l, hbuf_r, ref5_r, hbuf_l, ref5_l,
- hbuf_r, hbuf_l, hbuf_r, hbuf_l);
- ADD4(hbuf_r, ref6_r, hbuf_l, ref6_l, hbuf_r, ref7_r, hbuf_l, ref7_l,
- hbuf_r, hbuf_l, hbuf_r, hbuf_l);
- }
- SRA_2V(hbuf_r, hbuf_l, 5);
- ST_SH2(hbuf_r, hbuf_l, hbuf, 8);
- } else {
- const int norm_factor = height >> 1;
- int cnt;
- for (cnt = 0; cnt < 16; cnt++) {
- hbuf[cnt] = 0;
- }
- for (i = 0; i < height; ++i) {
- for (cnt = 0; cnt < 16; cnt++) {
- hbuf[cnt] += ref[cnt];
- }
- ref += ref_stride;
- }
- for (cnt = 0; cnt < 16; cnt++) {
- hbuf[cnt] /= norm_factor;
- }
- }
- }
- int16_t vpx_int_pro_col_msa(const uint8_t *ref, const int width) {
- int16_t sum;
- v16u8 ref0, ref1, ref2, ref3;
- v8u16 ref0_h;
- if (16 == width) {
- ref0 = LD_UB(ref);
- ref0_h = __msa_hadd_u_h(ref0, ref0);
- sum = HADD_UH_U32(ref0_h);
- } else if (32 == width) {
- LD_UB2(ref, 16, ref0, ref1);
- ref0_h = __msa_hadd_u_h(ref0, ref0);
- ref0_h += __msa_hadd_u_h(ref1, ref1);
- sum = HADD_UH_U32(ref0_h);
- } else if (64 == width) {
- LD_UB4(ref, 16, ref0, ref1, ref2, ref3);
- ref0_h = __msa_hadd_u_h(ref0, ref0);
- ref0_h += __msa_hadd_u_h(ref1, ref1);
- ref0_h += __msa_hadd_u_h(ref2, ref2);
- ref0_h += __msa_hadd_u_h(ref3, ref3);
- sum = HADD_UH_U32(ref0_h);
- } else {
- int idx;
- sum = 0;
- for (idx = 0; idx < width; ++idx) {
- sum += ref[idx];
- }
- }
- return sum;
- }
- int vpx_vector_var_msa(const int16_t *ref, const int16_t *src, const int bwl) {
- int sse, mean, var;
- v8i16 src0, src1, src2, src3, src4, src5, src6, src7, ref0, ref1, ref2;
- v8i16 ref3, ref4, ref5, ref6, ref7, src_l0_m, src_l1_m, src_l2_m, src_l3_m;
- v8i16 src_l4_m, src_l5_m, src_l6_m, src_l7_m;
- v4i32 res_l0_m, res_l1_m, res_l2_m, res_l3_m, res_l4_m, res_l5_m, res_l6_m;
- v4i32 res_l7_m, mean_v;
- v2i64 sse_v;
- if (2 == bwl) {
- LD_SH2(src, 8, src0, src1);
- LD_SH2(ref, 8, ref0, ref1);
- ILVRL_H2_SH(src0, ref0, src_l0_m, src_l1_m);
- ILVRL_H2_SH(src1, ref1, src_l2_m, src_l3_m);
- HSUB_UH2_SW(src_l0_m, src_l1_m, res_l0_m, res_l1_m);
- HSUB_UH2_SW(src_l2_m, src_l3_m, res_l2_m, res_l3_m);
- sse_v = __msa_dotp_s_d(res_l0_m, res_l0_m);
- sse_v = __msa_dpadd_s_d(sse_v, res_l1_m, res_l1_m);
- DPADD_SD2_SD(res_l2_m, res_l3_m, sse_v, sse_v);
- mean_v = res_l0_m + res_l1_m;
- mean_v += res_l2_m + res_l3_m;
- sse_v += __msa_splati_d(sse_v, 1);
- sse = __msa_copy_s_w((v4i32)sse_v, 0);
- mean = HADD_SW_S32(mean_v);
- } else if (3 == bwl) {
- LD_SH4(src, 8, src0, src1, src2, src3);
- LD_SH4(ref, 8, ref0, ref1, ref2, ref3);
- ILVRL_H2_SH(src0, ref0, src_l0_m, src_l1_m);
- ILVRL_H2_SH(src1, ref1, src_l2_m, src_l3_m);
- ILVRL_H2_SH(src2, ref2, src_l4_m, src_l5_m);
- ILVRL_H2_SH(src3, ref3, src_l6_m, src_l7_m);
- HSUB_UH2_SW(src_l0_m, src_l1_m, res_l0_m, res_l1_m);
- HSUB_UH2_SW(src_l2_m, src_l3_m, res_l2_m, res_l3_m);
- HSUB_UH2_SW(src_l4_m, src_l5_m, res_l4_m, res_l5_m);
- HSUB_UH2_SW(src_l6_m, src_l7_m, res_l6_m, res_l7_m);
- sse_v = __msa_dotp_s_d(res_l0_m, res_l0_m);
- sse_v = __msa_dpadd_s_d(sse_v, res_l1_m, res_l1_m);
- DPADD_SD2_SD(res_l2_m, res_l3_m, sse_v, sse_v);
- DPADD_SD2_SD(res_l4_m, res_l5_m, sse_v, sse_v);
- DPADD_SD2_SD(res_l6_m, res_l7_m, sse_v, sse_v);
- mean_v = res_l0_m + res_l1_m;
- mean_v += res_l2_m + res_l3_m;
- mean_v += res_l4_m + res_l5_m;
- mean_v += res_l6_m + res_l7_m;
- sse_v += __msa_splati_d(sse_v, 1);
- sse = __msa_copy_s_w((v4i32)sse_v, 0);
- mean = HADD_SW_S32(mean_v);
- } else if (4 == bwl) {
- LD_SH8(src, 8, src0, src1, src2, src3, src4, src5, src6, src7);
- LD_SH8(ref, 8, ref0, ref1, ref2, ref3, ref4, ref5, ref6, ref7);
- ILVRL_H2_SH(src0, ref0, src_l0_m, src_l1_m);
- ILVRL_H2_SH(src1, ref1, src_l2_m, src_l3_m);
- ILVRL_H2_SH(src2, ref2, src_l4_m, src_l5_m);
- ILVRL_H2_SH(src3, ref3, src_l6_m, src_l7_m);
- HSUB_UH2_SW(src_l0_m, src_l1_m, res_l0_m, res_l1_m);
- HSUB_UH2_SW(src_l2_m, src_l3_m, res_l2_m, res_l3_m);
- HSUB_UH2_SW(src_l4_m, src_l5_m, res_l4_m, res_l5_m);
- HSUB_UH2_SW(src_l6_m, src_l7_m, res_l6_m, res_l7_m);
- sse_v = __msa_dotp_s_d(res_l0_m, res_l0_m);
- sse_v = __msa_dpadd_s_d(sse_v, res_l1_m, res_l1_m);
- DPADD_SD2_SD(res_l2_m, res_l3_m, sse_v, sse_v);
- DPADD_SD2_SD(res_l4_m, res_l5_m, sse_v, sse_v);
- DPADD_SD2_SD(res_l6_m, res_l7_m, sse_v, sse_v);
- mean_v = res_l0_m + res_l1_m;
- mean_v += res_l2_m + res_l3_m;
- mean_v += res_l4_m + res_l5_m;
- mean_v += res_l6_m + res_l7_m;
- ILVRL_H2_SH(src4, ref4, src_l0_m, src_l1_m);
- ILVRL_H2_SH(src5, ref5, src_l2_m, src_l3_m);
- ILVRL_H2_SH(src6, ref6, src_l4_m, src_l5_m);
- ILVRL_H2_SH(src7, ref7, src_l6_m, src_l7_m);
- HSUB_UH2_SW(src_l0_m, src_l1_m, res_l0_m, res_l1_m);
- HSUB_UH2_SW(src_l2_m, src_l3_m, res_l2_m, res_l3_m);
- HSUB_UH2_SW(src_l4_m, src_l5_m, res_l4_m, res_l5_m);
- HSUB_UH2_SW(src_l6_m, src_l7_m, res_l6_m, res_l7_m);
- DPADD_SD2_SD(res_l0_m, res_l1_m, sse_v, sse_v);
- DPADD_SD2_SD(res_l2_m, res_l3_m, sse_v, sse_v);
- DPADD_SD2_SD(res_l4_m, res_l5_m, sse_v, sse_v);
- DPADD_SD2_SD(res_l6_m, res_l7_m, sse_v, sse_v);
- mean_v += res_l0_m + res_l1_m;
- mean_v += res_l2_m + res_l3_m;
- mean_v += res_l4_m + res_l5_m;
- mean_v += res_l6_m + res_l7_m;
- sse_v += __msa_splati_d(sse_v, 1);
- sse = __msa_copy_s_w((v4i32)sse_v, 0);
- mean = HADD_SW_S32(mean_v);
- } else {
- int i;
- const int width = 4 << bwl;
- sse = 0;
- mean = 0;
- for (i = 0; i < width; ++i) {
- const int diff = ref[i] - src[i];
- mean += diff;
- sse += diff * diff;
- }
- }
- var = sse - ((mean * mean) >> (bwl + 2));
- return var;
- }
- void vpx_minmax_8x8_msa(const uint8_t *s, int p, const uint8_t *d, int dp,
- int *min, int *max) {
- v16u8 s0, s1, s2, s3, s4, s5, s6, s7, d0, d1, d2, d3, d4, d5, d6, d7;
- v16u8 diff0, diff1, diff2, diff3, min0, min1, max0, max1;
- LD_UB8(s, p, s0, s1, s2, s3, s4, s5, s6, s7);
- LD_UB8(d, dp, d0, d1, d2, d3, d4, d5, d6, d7);
- PCKEV_D4_UB(s1, s0, s3, s2, s5, s4, s7, s6, s0, s1, s2, s3);
- PCKEV_D4_UB(d1, d0, d3, d2, d5, d4, d7, d6, d0, d1, d2, d3);
- diff0 = __msa_asub_u_b(s0, d0);
- diff1 = __msa_asub_u_b(s1, d1);
- diff2 = __msa_asub_u_b(s2, d2);
- diff3 = __msa_asub_u_b(s3, d3);
- min0 = __msa_min_u_b(diff0, diff1);
- min1 = __msa_min_u_b(diff2, diff3);
- min0 = __msa_min_u_b(min0, min1);
- max0 = __msa_max_u_b(diff0, diff1);
- max1 = __msa_max_u_b(diff2, diff3);
- max0 = __msa_max_u_b(max0, max1);
- min1 = (v16u8)__msa_sldi_b((v16i8)min1, (v16i8)min0, 8);
- min0 = __msa_min_u_b(min0, min1);
- max1 = (v16u8)__msa_sldi_b((v16i8)max1, (v16i8)max0, 8);
- max0 = __msa_max_u_b(max0, max1);
- min1 = (v16u8)__msa_sldi_b((v16i8)min1, (v16i8)min0, 4);
- min0 = __msa_min_u_b(min0, min1);
- max1 = (v16u8)__msa_sldi_b((v16i8)max1, (v16i8)max0, 4);
- max0 = __msa_max_u_b(max0, max1);
- min1 = (v16u8)__msa_sldi_b((v16i8)min1, (v16i8)min0, 2);
- min0 = __msa_min_u_b(min0, min1);
- max1 = (v16u8)__msa_sldi_b((v16i8)max1, (v16i8)max0, 2);
- max0 = __msa_max_u_b(max0, max1);
- min1 = (v16u8)__msa_sldi_b((v16i8)min1, (v16i8)min0, 1);
- min0 = __msa_min_u_b(min0, min1);
- max1 = (v16u8)__msa_sldi_b((v16i8)max1, (v16i8)max0, 1);
- max0 = __msa_max_u_b(max0, max1);
- *min = min0[0];
- *max = max0[0];
- }
|