static int TTransform(const uint8_t* in, const uint16_t* w) { int sum; uint32_t in0_m, in1_m, in2_m, in3_m; v16i8 src0; v8i16 in0, in1, tmp0, tmp1, tmp2, tmp3; v4i32 dst0, dst1; const v16i8 zero = { 0 }; const v8i16 mask0 = { 0, 1, 2, 3, 8, 9, 10, 11 }; const v8i16 mask1 = { 4, 5, 6, 7, 12, 13, 14, 15 }; const v8i16 mask2 = { 0, 4, 8, 12, 1, 5, 9, 13 }; const v8i16 mask3 = { 3, 7, 11, 15, 2, 6, 10, 14 }; LW4(in, BPS, in0_m, in1_m, in2_m, in3_m); INSERT_W4_SB(in0_m, in1_m, in2_m, in3_m, src0); ILVRL_B2_SH(zero, src0, tmp0, tmp1); VSHF_H2_SH(tmp0, tmp1, tmp0, tmp1, mask2, mask3, in0, in1); ADDSUB2(in0, in1, tmp0, tmp1); VSHF_H2_SH(tmp0, tmp1, tmp0, tmp1, mask0, mask1, tmp2, tmp3); ADDSUB2(tmp2, tmp3, tmp0, tmp1); VSHF_H2_SH(tmp0, tmp1, tmp0, tmp1, mask2, mask3, in0, in1); ADDSUB2(in0, in1, tmp0, tmp1); VSHF_H2_SH(tmp0, tmp1, tmp0, tmp1, mask0, mask1, tmp2, tmp3); ADDSUB2(tmp2, tmp3, tmp0, tmp1); tmp0 = __msa_add_a_h(tmp0, (v8i16)zero); tmp1 = __msa_add_a_h(tmp1, (v8i16)zero); LD_SH2(w, 8, tmp2, tmp3); DOTP_SH2_SW(tmp0, tmp1, tmp2, tmp3, dst0, dst1); dst0 = dst0 + dst1; sum = HADD_SW_S32(dst0); return sum; }
static void CollectHistogram(const uint8_t* ref, const uint8_t* pred, int start_block, int end_block, VP8Histogram* const histo) { int j; int distribution[MAX_COEFF_THRESH + 1] = { 0 }; for (j = start_block; j < end_block; ++j) { int16_t out[16]; VP8FTransform(ref + VP8DspScan[j], pred + VP8DspScan[j], out); { int k; v8i16 coeff0, coeff1; const v8i16 zero = { 0 }; const v8i16 max_coeff_thr = __msa_ldi_h(MAX_COEFF_THRESH); LD_SH2(&out[0], 8, coeff0, coeff1); coeff0 = __msa_add_a_h(coeff0, zero); coeff1 = __msa_add_a_h(coeff1, zero); SRAI_H2_SH(coeff0, coeff1, 3); coeff0 = __msa_min_s_h(coeff0, max_coeff_thr); coeff1 = __msa_min_s_h(coeff1, max_coeff_thr); ST_SH2(coeff0, coeff1, &out[0], 8); for (k = 0; k < 16; ++k) { ++distribution[out[k]]; } } } VP8SetHistogramData(distribution, histo); }