(61d00a474) v0.9.7.1

This commit is contained in:
Regalis
2020-03-04 13:04:10 +01:00
parent 3c50efa5c9
commit 3c09ebe02f
5086 changed files with 786063 additions and 295871 deletions
@@ -0,0 +1,29 @@
/*
* Copyright (c) 2012 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 "vpx_config.h"
#include "vp8_rtcd.h"
#include "vpx_mem/vpx_mem.h"
#if HAVE_DSPR2
void vp8_dequant_idct_add_dspr2(short *input, short *dq, unsigned char *dest,
int stride) {
int i;
for (i = 0; i < 16; ++i) {
input[i] = dq[i] * input[i];
}
vp8_short_idct4x4llm_dspr2(input, dest, stride, dest, stride);
memset(input, 0, 32);
}
#endif
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,76 @@
/*
* Copyright (c) 2012 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 "vpx_config.h"
#include "vp8_rtcd.h"
#if HAVE_DSPR2
void vp8_dequant_idct_add_y_block_dspr2(short *q, short *dq, unsigned char *dst,
int stride, char *eobs) {
int i, j;
for (i = 0; i < 4; ++i) {
for (j = 0; j < 4; ++j) {
if (*eobs++ > 1)
vp8_dequant_idct_add_dspr2(q, dq, dst, stride);
else {
vp8_dc_only_idct_add_dspr2(q[0] * dq[0], dst, stride, dst, stride);
((int *)q)[0] = 0;
}
q += 16;
dst += 4;
}
dst += 4 * stride - 16;
}
}
void vp8_dequant_idct_add_uv_block_dspr2(short *q, short *dq,
unsigned char *dst_u,
unsigned char *dst_v, int stride,
char *eobs) {
int i, j;
for (i = 0; i < 2; ++i) {
for (j = 0; j < 2; ++j) {
if (*eobs++ > 1)
vp8_dequant_idct_add_dspr2(q, dq, dst_u, stride);
else {
vp8_dc_only_idct_add_dspr2(q[0] * dq[0], dst_u, stride, dst_u, stride);
((int *)q)[0] = 0;
}
q += 16;
dst_u += 4;
}
dst_u += 4 * stride - 8;
}
for (i = 0; i < 2; ++i) {
for (j = 0; j < 2; ++j) {
if (*eobs++ > 1)
vp8_dequant_idct_add_dspr2(q, dq, dst_v, stride);
else {
vp8_dc_only_idct_add_dspr2(q[0] * dq[0], dst_v, stride, dst_v, stride);
((int *)q)[0] = 0;
}
q += 16;
dst_v += 4;
}
dst_v += 4 * stride - 8;
}
}
#endif
@@ -0,0 +1,346 @@
/*
* Copyright (c) 2012 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 "vp8_rtcd.h"
#if HAVE_DSPR2
#define CROP_WIDTH 256
/******************************************************************************
* Notes:
*
* This implementation makes use of 16 bit fixed point version of two multiply
* constants:
* 1. sqrt(2) * cos (pi/8)
* 2. sqrt(2) * sin (pi/8)
* Since the first constant is bigger than 1, to maintain the same 16 bit
* fixed point precision as the second one, we use a trick of
* x * a = x + x*(a-1)
* so
* x * sqrt(2) * cos (pi/8) = x + x * (sqrt(2) *cos(pi/8)-1).
****************************************************************************/
extern unsigned char ff_cropTbl[256 + 2 * CROP_WIDTH];
static const int cospi8sqrt2minus1 = 20091;
static const int sinpi8sqrt2 = 35468;
inline void prefetch_load_short(short *src) {
__asm__ __volatile__("pref 0, 0(%[src]) \n\t" : : [src] "r"(src));
}
void vp8_short_idct4x4llm_dspr2(short *input, unsigned char *pred_ptr,
int pred_stride, unsigned char *dst_ptr,
int dst_stride) {
int r, c;
int a1, b1, c1, d1;
short output[16];
short *ip = input;
short *op = output;
int temp1, temp2;
int shortpitch = 4;
int c2, d2;
int temp3, temp4;
unsigned char *cm = ff_cropTbl + CROP_WIDTH;
/* prepare data for load */
prefetch_load_short(ip + 8);
/* first loop is unrolled */
a1 = ip[0] + ip[8];
b1 = ip[0] - ip[8];
temp1 = (ip[4] * sinpi8sqrt2) >> 16;
temp2 = ip[12] + ((ip[12] * cospi8sqrt2minus1) >> 16);
c1 = temp1 - temp2;
temp1 = ip[4] + ((ip[4] * cospi8sqrt2minus1) >> 16);
temp2 = (ip[12] * sinpi8sqrt2) >> 16;
d1 = temp1 + temp2;
temp3 = (ip[5] * sinpi8sqrt2) >> 16;
temp4 = ip[13] + ((ip[13] * cospi8sqrt2minus1) >> 16);
c2 = temp3 - temp4;
temp3 = ip[5] + ((ip[5] * cospi8sqrt2minus1) >> 16);
temp4 = (ip[13] * sinpi8sqrt2) >> 16;
d2 = temp3 + temp4;
op[0] = a1 + d1;
op[12] = a1 - d1;
op[4] = b1 + c1;
op[8] = b1 - c1;
a1 = ip[1] + ip[9];
b1 = ip[1] - ip[9];
op[1] = a1 + d2;
op[13] = a1 - d2;
op[5] = b1 + c2;
op[9] = b1 - c2;
a1 = ip[2] + ip[10];
b1 = ip[2] - ip[10];
temp1 = (ip[6] * sinpi8sqrt2) >> 16;
temp2 = ip[14] + ((ip[14] * cospi8sqrt2minus1) >> 16);
c1 = temp1 - temp2;
temp1 = ip[6] + ((ip[6] * cospi8sqrt2minus1) >> 16);
temp2 = (ip[14] * sinpi8sqrt2) >> 16;
d1 = temp1 + temp2;
temp3 = (ip[7] * sinpi8sqrt2) >> 16;
temp4 = ip[15] + ((ip[15] * cospi8sqrt2minus1) >> 16);
c2 = temp3 - temp4;
temp3 = ip[7] + ((ip[7] * cospi8sqrt2minus1) >> 16);
temp4 = (ip[15] * sinpi8sqrt2) >> 16;
d2 = temp3 + temp4;
op[2] = a1 + d1;
op[14] = a1 - d1;
op[6] = b1 + c1;
op[10] = b1 - c1;
a1 = ip[3] + ip[11];
b1 = ip[3] - ip[11];
op[3] = a1 + d2;
op[15] = a1 - d2;
op[7] = b1 + c2;
op[11] = b1 - c2;
ip = output;
/* prepare data for load */
prefetch_load_short(ip + shortpitch);
/* second loop is unrolled */
a1 = ip[0] + ip[2];
b1 = ip[0] - ip[2];
temp1 = (ip[1] * sinpi8sqrt2) >> 16;
temp2 = ip[3] + ((ip[3] * cospi8sqrt2minus1) >> 16);
c1 = temp1 - temp2;
temp1 = ip[1] + ((ip[1] * cospi8sqrt2minus1) >> 16);
temp2 = (ip[3] * sinpi8sqrt2) >> 16;
d1 = temp1 + temp2;
temp3 = (ip[5] * sinpi8sqrt2) >> 16;
temp4 = ip[7] + ((ip[7] * cospi8sqrt2minus1) >> 16);
c2 = temp3 - temp4;
temp3 = ip[5] + ((ip[5] * cospi8sqrt2minus1) >> 16);
temp4 = (ip[7] * sinpi8sqrt2) >> 16;
d2 = temp3 + temp4;
op[0] = (a1 + d1 + 4) >> 3;
op[3] = (a1 - d1 + 4) >> 3;
op[1] = (b1 + c1 + 4) >> 3;
op[2] = (b1 - c1 + 4) >> 3;
a1 = ip[4] + ip[6];
b1 = ip[4] - ip[6];
op[4] = (a1 + d2 + 4) >> 3;
op[7] = (a1 - d2 + 4) >> 3;
op[5] = (b1 + c2 + 4) >> 3;
op[6] = (b1 - c2 + 4) >> 3;
a1 = ip[8] + ip[10];
b1 = ip[8] - ip[10];
temp1 = (ip[9] * sinpi8sqrt2) >> 16;
temp2 = ip[11] + ((ip[11] * cospi8sqrt2minus1) >> 16);
c1 = temp1 - temp2;
temp1 = ip[9] + ((ip[9] * cospi8sqrt2minus1) >> 16);
temp2 = (ip[11] * sinpi8sqrt2) >> 16;
d1 = temp1 + temp2;
temp3 = (ip[13] * sinpi8sqrt2) >> 16;
temp4 = ip[15] + ((ip[15] * cospi8sqrt2minus1) >> 16);
c2 = temp3 - temp4;
temp3 = ip[13] + ((ip[13] * cospi8sqrt2minus1) >> 16);
temp4 = (ip[15] * sinpi8sqrt2) >> 16;
d2 = temp3 + temp4;
op[8] = (a1 + d1 + 4) >> 3;
op[11] = (a1 - d1 + 4) >> 3;
op[9] = (b1 + c1 + 4) >> 3;
op[10] = (b1 - c1 + 4) >> 3;
a1 = ip[12] + ip[14];
b1 = ip[12] - ip[14];
op[12] = (a1 + d2 + 4) >> 3;
op[15] = (a1 - d2 + 4) >> 3;
op[13] = (b1 + c2 + 4) >> 3;
op[14] = (b1 - c2 + 4) >> 3;
ip = output;
for (r = 0; r < 4; ++r) {
for (c = 0; c < 4; ++c) {
short a = ip[c] + pred_ptr[c];
dst_ptr[c] = cm[a];
}
ip += 4;
dst_ptr += dst_stride;
pred_ptr += pred_stride;
}
}
void vp8_dc_only_idct_add_dspr2(short input_dc, unsigned char *pred_ptr,
int pred_stride, unsigned char *dst_ptr,
int dst_stride) {
int a1;
int i, absa1;
int t2, vector_a1, vector_a;
/* a1 = ((input_dc + 4) >> 3); */
__asm__ __volatile__(
"addi %[a1], %[input_dc], 4 \n\t"
"sra %[a1], %[a1], 3 \n\t"
: [a1] "=r"(a1)
: [input_dc] "r"(input_dc));
if (a1 < 0) {
/* use quad-byte
* input and output memory are four byte aligned
*/
__asm__ __volatile__(
"abs %[absa1], %[a1] \n\t"
"replv.qb %[vector_a1], %[absa1] \n\t"
: [absa1] "=r"(absa1), [vector_a1] "=r"(vector_a1)
: [a1] "r"(a1));
/* use (a1 - predptr[c]) instead a1 + predptr[c] */
for (i = 4; i--;) {
__asm__ __volatile__(
"lw %[t2], 0(%[pred_ptr]) \n\t"
"add %[pred_ptr], %[pred_ptr], %[pred_stride] \n\t"
"subu_s.qb %[vector_a], %[t2], %[vector_a1] \n\t"
"sw %[vector_a], 0(%[dst_ptr]) \n\t"
"add %[dst_ptr], %[dst_ptr], %[dst_stride] \n\t"
: [t2] "=&r"(t2), [vector_a] "=&r"(vector_a),
[dst_ptr] "+&r"(dst_ptr), [pred_ptr] "+&r"(pred_ptr)
: [dst_stride] "r"(dst_stride), [pred_stride] "r"(pred_stride),
[vector_a1] "r"(vector_a1));
}
} else {
/* use quad-byte
* input and output memory are four byte aligned
*/
__asm__ __volatile__("replv.qb %[vector_a1], %[a1] \n\t"
: [vector_a1] "=r"(vector_a1)
: [a1] "r"(a1));
for (i = 4; i--;) {
__asm__ __volatile__(
"lw %[t2], 0(%[pred_ptr]) \n\t"
"add %[pred_ptr], %[pred_ptr], %[pred_stride] \n\t"
"addu_s.qb %[vector_a], %[vector_a1], %[t2] \n\t"
"sw %[vector_a], 0(%[dst_ptr]) \n\t"
"add %[dst_ptr], %[dst_ptr], %[dst_stride] \n\t"
: [t2] "=&r"(t2), [vector_a] "=&r"(vector_a),
[dst_ptr] "+&r"(dst_ptr), [pred_ptr] "+&r"(pred_ptr)
: [dst_stride] "r"(dst_stride), [pred_stride] "r"(pred_stride),
[vector_a1] "r"(vector_a1));
}
}
}
void vp8_short_inv_walsh4x4_dspr2(short *input, short *mb_dqcoeff) {
short output[16];
int i;
int a1, b1, c1, d1;
int a2, b2, c2, d2;
short *ip = input;
short *op = output;
prefetch_load_short(ip);
for (i = 4; i--;) {
a1 = ip[0] + ip[12];
b1 = ip[4] + ip[8];
c1 = ip[4] - ip[8];
d1 = ip[0] - ip[12];
op[0] = a1 + b1;
op[4] = c1 + d1;
op[8] = a1 - b1;
op[12] = d1 - c1;
ip++;
op++;
}
ip = output;
op = output;
prefetch_load_short(ip);
for (i = 4; i--;) {
a1 = ip[0] + ip[3] + 3;
b1 = ip[1] + ip[2];
c1 = ip[1] - ip[2];
d1 = ip[0] - ip[3] + 3;
a2 = a1 + b1;
b2 = d1 + c1;
c2 = a1 - b1;
d2 = d1 - c1;
op[0] = a2 >> 3;
op[1] = b2 >> 3;
op[2] = c2 >> 3;
op[3] = d2 >> 3;
ip += 4;
op += 4;
}
for (i = 0; i < 16; ++i) {
mb_dqcoeff[i * 16] = output[i];
}
}
void vp8_short_inv_walsh4x4_1_dspr2(short *input, short *mb_dqcoeff) {
int a1;
a1 = ((input[0] + 3) >> 3);
__asm__ __volatile__(
"sh %[a1], 0(%[mb_dqcoeff]) \n\t"
"sh %[a1], 32(%[mb_dqcoeff]) \n\t"
"sh %[a1], 64(%[mb_dqcoeff]) \n\t"
"sh %[a1], 96(%[mb_dqcoeff]) \n\t"
"sh %[a1], 128(%[mb_dqcoeff]) \n\t"
"sh %[a1], 160(%[mb_dqcoeff]) \n\t"
"sh %[a1], 192(%[mb_dqcoeff]) \n\t"
"sh %[a1], 224(%[mb_dqcoeff]) \n\t"
"sh %[a1], 256(%[mb_dqcoeff]) \n\t"
"sh %[a1], 288(%[mb_dqcoeff]) \n\t"
"sh %[a1], 320(%[mb_dqcoeff]) \n\t"
"sh %[a1], 352(%[mb_dqcoeff]) \n\t"
"sh %[a1], 384(%[mb_dqcoeff]) \n\t"
"sh %[a1], 416(%[mb_dqcoeff]) \n\t"
"sh %[a1], 448(%[mb_dqcoeff]) \n\t"
"sh %[a1], 480(%[mb_dqcoeff]) \n\t"
:
: [a1] "r"(a1), [mb_dqcoeff] "r"(mb_dqcoeff));
}
#endif
@@ -0,0 +1,97 @@
/*
* Copyright (c) 2012 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 "vpx_config.h"
#include "vp8_rtcd.h"
#include "vpx/vpx_integer.h"
#if HAVE_DSPR2
inline void prefetch_load_int(unsigned char *src) {
__asm__ __volatile__("pref 0, 0(%[src]) \n\t" : : [src] "r"(src));
}
__inline void vp8_copy_mem16x16_dspr2(unsigned char *RESTRICT src,
int src_stride,
unsigned char *RESTRICT dst,
int dst_stride) {
int r;
unsigned int a0, a1, a2, a3;
for (r = 16; r--;) {
/* load src data in cache memory */
prefetch_load_int(src + src_stride);
/* use unaligned memory load and store */
__asm__ __volatile__(
"ulw %[a0], 0(%[src]) \n\t"
"ulw %[a1], 4(%[src]) \n\t"
"ulw %[a2], 8(%[src]) \n\t"
"ulw %[a3], 12(%[src]) \n\t"
"sw %[a0], 0(%[dst]) \n\t"
"sw %[a1], 4(%[dst]) \n\t"
"sw %[a2], 8(%[dst]) \n\t"
"sw %[a3], 12(%[dst]) \n\t"
: [a0] "=&r"(a0), [a1] "=&r"(a1), [a2] "=&r"(a2), [a3] "=&r"(a3)
: [src] "r"(src), [dst] "r"(dst));
src += src_stride;
dst += dst_stride;
}
}
__inline void vp8_copy_mem8x8_dspr2(unsigned char *RESTRICT src, int src_stride,
unsigned char *RESTRICT dst,
int dst_stride) {
int r;
unsigned int a0, a1;
/* load src data in cache memory */
prefetch_load_int(src + src_stride);
for (r = 8; r--;) {
/* use unaligned memory load and store */
__asm__ __volatile__(
"ulw %[a0], 0(%[src]) \n\t"
"ulw %[a1], 4(%[src]) \n\t"
"sw %[a0], 0(%[dst]) \n\t"
"sw %[a1], 4(%[dst]) \n\t"
: [a0] "=&r"(a0), [a1] "=&r"(a1)
: [src] "r"(src), [dst] "r"(dst));
src += src_stride;
dst += dst_stride;
}
}
__inline void vp8_copy_mem8x4_dspr2(unsigned char *RESTRICT src, int src_stride,
unsigned char *RESTRICT dst,
int dst_stride) {
int r;
unsigned int a0, a1;
/* load src data in cache memory */
prefetch_load_int(src + src_stride);
for (r = 4; r--;) {
/* use unaligned memory load and store */
__asm__ __volatile__(
"ulw %[a0], 0(%[src]) \n\t"
"ulw %[a1], 4(%[src]) \n\t"
"sw %[a0], 0(%[dst]) \n\t"
"sw %[a1], 4(%[dst]) \n\t"
: [a0] "=&r"(a0), [a1] "=&r"(a1)
: [src] "r"(src), [dst] "r"(dst));
src += src_stride;
dst += dst_stride;
}
}
#endif
@@ -0,0 +1,114 @@
/*
* Copyright (c) 2017 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 "./vp8_rtcd.h"
#include "vpx_ports/asmdefs_mmi.h"
#define COPY_MEM_16X2 \
"gsldlc1 %[ftmp0], 0x07(%[src]) \n\t" \
"gsldrc1 %[ftmp0], 0x00(%[src]) \n\t" \
"ldl %[tmp0], 0x0f(%[src]) \n\t" \
"ldr %[tmp0], 0x08(%[src]) \n\t" \
MMI_ADDU(%[src], %[src], %[src_stride]) \
"gssdlc1 %[ftmp0], 0x07(%[dst]) \n\t" \
"gssdrc1 %[ftmp0], 0x00(%[dst]) \n\t" \
"sdl %[tmp0], 0x0f(%[dst]) \n\t" \
"sdr %[tmp0], 0x08(%[dst]) \n\t" \
MMI_ADDU(%[dst], %[dst], %[dst_stride]) \
"gsldlc1 %[ftmp1], 0x07(%[src]) \n\t" \
"gsldrc1 %[ftmp1], 0x00(%[src]) \n\t" \
"ldl %[tmp1], 0x0f(%[src]) \n\t" \
"ldr %[tmp1], 0x08(%[src]) \n\t" \
MMI_ADDU(%[src], %[src], %[src_stride]) \
"gssdlc1 %[ftmp1], 0x07(%[dst]) \n\t" \
"gssdrc1 %[ftmp1], 0x00(%[dst]) \n\t" \
"sdl %[tmp1], 0x0f(%[dst]) \n\t" \
"sdr %[tmp1], 0x08(%[dst]) \n\t" \
MMI_ADDU(%[dst], %[dst], %[dst_stride])
#define COPY_MEM_8X2 \
"gsldlc1 %[ftmp0], 0x07(%[src]) \n\t" \
"gsldrc1 %[ftmp0], 0x00(%[src]) \n\t" \
MMI_ADDU(%[src], %[src], %[src_stride]) \
"ldl %[tmp0], 0x07(%[src]) \n\t" \
"ldr %[tmp0], 0x00(%[src]) \n\t" \
MMI_ADDU(%[src], %[src], %[src_stride]) \
\
"gssdlc1 %[ftmp0], 0x07(%[dst]) \n\t" \
"gssdrc1 %[ftmp0], 0x00(%[dst]) \n\t" \
MMI_ADDU(%[dst], %[dst], %[dst_stride]) \
"sdl %[tmp0], 0x07(%[dst]) \n\t" \
"sdr %[tmp0], 0x00(%[dst]) \n\t" \
MMI_ADDU(%[dst], %[dst], %[dst_stride])
void vp8_copy_mem16x16_mmi(unsigned char *src, int src_stride,
unsigned char *dst, int dst_stride) {
double ftmp[2];
uint64_t tmp[2];
uint8_t loop_count = 4;
/* clang-format off */
__asm__ volatile (
"1: \n\t"
COPY_MEM_16X2
COPY_MEM_16X2
MMI_ADDIU(%[loop_count], %[loop_count], -0x01)
"bnez %[loop_count], 1b \n\t"
: [ftmp0]"=&f"(ftmp[0]), [ftmp1]"=&f"(ftmp[1]),
[tmp0]"=&r"(tmp[0]), [tmp1]"=&r"(tmp[1]),
[loop_count]"+&r"(loop_count),
[dst]"+&r"(dst), [src]"+&r"(src)
: [src_stride]"r"((mips_reg)src_stride),
[dst_stride]"r"((mips_reg)dst_stride)
: "memory"
);
/* clang-format on */
}
void vp8_copy_mem8x8_mmi(unsigned char *src, int src_stride, unsigned char *dst,
int dst_stride) {
double ftmp[2];
uint64_t tmp[1];
uint8_t loop_count = 4;
/* clang-format off */
__asm__ volatile (
"1: \n\t"
COPY_MEM_8X2
MMI_ADDIU(%[loop_count], %[loop_count], -0x01)
"bnez %[loop_count], 1b \n\t"
: [ftmp0]"=&f"(ftmp[0]), [ftmp1]"=&f"(ftmp[1]),
[tmp0]"=&r"(tmp[0]), [loop_count]"+&r"(loop_count),
[dst]"+&r"(dst), [src]"+&r"(src)
: [src_stride]"r"((mips_reg)src_stride),
[dst_stride]"r"((mips_reg)dst_stride)
: "memory"
);
/* clang-format on */
}
void vp8_copy_mem8x4_mmi(unsigned char *src, int src_stride, unsigned char *dst,
int dst_stride) {
double ftmp[2];
uint64_t tmp[1];
/* clang-format off */
__asm__ volatile (
COPY_MEM_8X2
COPY_MEM_8X2
: [ftmp0]"=&f"(ftmp[0]), [ftmp1]"=&f"(ftmp[1]),
[tmp0]"=&r"(tmp[0]),
[dst]"+&r"(dst), [src]"+&r"(src)
: [src_stride]"r"((mips_reg)src_stride),
[dst_stride]"r"((mips_reg)dst_stride)
: "memory"
);
/* clang-format on */
}
@@ -0,0 +1,115 @@
/*
* Copyright (c) 2017 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 "./vp8_rtcd.h"
#include "vp8/common/blockd.h"
#include "vpx_mem/vpx_mem.h"
#include "vpx_ports/asmdefs_mmi.h"
void vp8_dequantize_b_mmi(BLOCKD *d, int16_t *DQC) {
double ftmp[8];
__asm__ volatile(
"gsldlc1 %[ftmp0], 0x07(%[qcoeff]) \n\t"
"gsldrc1 %[ftmp0], 0x00(%[qcoeff]) \n\t"
"gsldlc1 %[ftmp1], 0x0f(%[qcoeff]) \n\t"
"gsldrc1 %[ftmp1], 0x08(%[qcoeff]) \n\t"
"gsldlc1 %[ftmp2], 0x17(%[qcoeff]) \n\t"
"gsldrc1 %[ftmp2], 0x10(%[qcoeff]) \n\t"
"gsldlc1 %[ftmp3], 0x1f(%[qcoeff]) \n\t"
"gsldrc1 %[ftmp3], 0x18(%[qcoeff]) \n\t"
"gsldlc1 %[ftmp4], 0x07(%[DQC]) \n\t"
"gsldrc1 %[ftmp4], 0x00(%[DQC]) \n\t"
"gsldlc1 %[ftmp5], 0x0f(%[DQC]) \n\t"
"gsldrc1 %[ftmp5], 0x08(%[DQC]) \n\t"
"gsldlc1 %[ftmp6], 0x17(%[DQC]) \n\t"
"gsldrc1 %[ftmp6], 0x10(%[DQC]) \n\t"
"gsldlc1 %[ftmp7], 0x1f(%[DQC]) \n\t"
"gsldrc1 %[ftmp7], 0x18(%[DQC]) \n\t"
"pmullh %[ftmp0], %[ftmp0], %[ftmp4] \n\t"
"pmullh %[ftmp1], %[ftmp1], %[ftmp5] \n\t"
"pmullh %[ftmp2], %[ftmp2], %[ftmp6] \n\t"
"pmullh %[ftmp3], %[ftmp3], %[ftmp7] \n\t"
"gssdlc1 %[ftmp0], 0x07(%[dqcoeff]) \n\t"
"gssdrc1 %[ftmp0], 0x00(%[dqcoeff]) \n\t"
"gssdlc1 %[ftmp1], 0x0f(%[dqcoeff]) \n\t"
"gssdrc1 %[ftmp1], 0x08(%[dqcoeff]) \n\t"
"gssdlc1 %[ftmp2], 0x17(%[dqcoeff]) \n\t"
"gssdrc1 %[ftmp2], 0x10(%[dqcoeff]) \n\t"
"gssdlc1 %[ftmp3], 0x1f(%[dqcoeff]) \n\t"
"gssdrc1 %[ftmp3], 0x18(%[dqcoeff]) \n\t"
: [ftmp0] "=&f"(ftmp[0]), [ftmp1] "=&f"(ftmp[1]), [ftmp2] "=&f"(ftmp[2]),
[ftmp3] "=&f"(ftmp[3]), [ftmp4] "=&f"(ftmp[4]), [ftmp5] "=&f"(ftmp[5]),
[ftmp6] "=&f"(ftmp[6]), [ftmp7] "=&f"(ftmp[7])
: [dqcoeff] "r"(d->dqcoeff), [qcoeff] "r"(d->qcoeff), [DQC] "r"(DQC)
: "memory");
}
void vp8_dequant_idct_add_mmi(int16_t *input, int16_t *dq, unsigned char *dest,
int stride) {
double ftmp[8];
__asm__ volatile(
"gsldlc1 %[ftmp0], 0x07(%[dq]) \n\t"
"gsldrc1 %[ftmp0], 0x00(%[dq]) \n\t"
"gsldlc1 %[ftmp1], 0x0f(%[dq]) \n\t"
"gsldrc1 %[ftmp1], 0x08(%[dq]) \n\t"
"gsldlc1 %[ftmp2], 0x17(%[dq]) \n\t"
"gsldrc1 %[ftmp2], 0x10(%[dq]) \n\t"
"gsldlc1 %[ftmp3], 0x1f(%[dq]) \n\t"
"gsldrc1 %[ftmp3], 0x18(%[dq]) \n\t"
"gsldlc1 %[ftmp4], 0x07(%[input]) \n\t"
"gsldrc1 %[ftmp4], 0x00(%[input]) \n\t"
"gsldlc1 %[ftmp5], 0x0f(%[input]) \n\t"
"gsldrc1 %[ftmp5], 0x08(%[input]) \n\t"
"gsldlc1 %[ftmp6], 0x17(%[input]) \n\t"
"gsldrc1 %[ftmp6], 0x10(%[input]) \n\t"
"gsldlc1 %[ftmp7], 0x1f(%[input]) \n\t"
"gsldrc1 %[ftmp7], 0x18(%[input]) \n\t"
"pmullh %[ftmp0], %[ftmp0], %[ftmp4] \n\t"
"pmullh %[ftmp1], %[ftmp1], %[ftmp5] \n\t"
"pmullh %[ftmp2], %[ftmp2], %[ftmp6] \n\t"
"pmullh %[ftmp3], %[ftmp3], %[ftmp7] \n\t"
"gssdlc1 %[ftmp0], 0x07(%[input]) \n\t"
"gssdrc1 %[ftmp0], 0x00(%[input]) \n\t"
"gssdlc1 %[ftmp1], 0x0f(%[input]) \n\t"
"gssdrc1 %[ftmp1], 0x08(%[input]) \n\t"
"gssdlc1 %[ftmp2], 0x17(%[input]) \n\t"
"gssdrc1 %[ftmp2], 0x10(%[input]) \n\t"
"gssdlc1 %[ftmp3], 0x1f(%[input]) \n\t"
"gssdrc1 %[ftmp3], 0x18(%[input]) \n\t"
: [ftmp0] "=&f"(ftmp[0]), [ftmp1] "=&f"(ftmp[1]), [ftmp2] "=&f"(ftmp[2]),
[ftmp3] "=&f"(ftmp[3]), [ftmp4] "=&f"(ftmp[4]), [ftmp5] "=&f"(ftmp[5]),
[ftmp6] "=&f"(ftmp[6]), [ftmp7] "=&f"(ftmp[7])
: [dq] "r"(dq), [input] "r"(input)
: "memory");
vp8_short_idct4x4llm_mmi(input, dest, stride, dest, stride);
__asm__ volatile(
"xor %[ftmp0], %[ftmp0], %[ftmp0] \n\t"
"gssdlc1 %[ftmp0], 0x07(%[input]) \n\t"
"gssdrc1 %[ftmp0], 0x00(%[input]) \n\t"
"sdl $0, 0x0f(%[input]) \n\t"
"sdr $0, 0x08(%[input]) \n\t"
"gssdlc1 %[ftmp0], 0x17(%[input]) \n\t"
"gssdrc1 %[ftmp0], 0x10(%[input]) \n\t"
"sdl $0, 0x1f(%[input]) \n\t"
"sdr $0, 0x18(%[input]) \n\t"
: [ftmp0] "=&f"(ftmp[0])
: [input] "r"(input)
: "memory");
}
@@ -0,0 +1,70 @@
/*
* Copyright (c) 2017 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 "./vp8_rtcd.h"
#include "vpx_mem/vpx_mem.h"
void vp8_dequant_idct_add_y_block_mmi(int16_t *q, int16_t *dq, uint8_t *dst,
int stride, char *eobs) {
int i, j;
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
if (*eobs++ > 1) {
vp8_dequant_idct_add_mmi(q, dq, dst, stride);
} else {
vp8_dc_only_idct_add_mmi(q[0] * dq[0], dst, stride, dst, stride);
memset(q, 0, 2 * sizeof(q[0]));
}
q += 16;
dst += 4;
}
dst += 4 * stride - 16;
}
}
void vp8_dequant_idct_add_uv_block_mmi(int16_t *q, int16_t *dq, uint8_t *dst_u,
uint8_t *dst_v, int stride, char *eobs) {
int i, j;
for (i = 0; i < 2; i++) {
for (j = 0; j < 2; j++) {
if (*eobs++ > 1) {
vp8_dequant_idct_add_mmi(q, dq, dst_u, stride);
} else {
vp8_dc_only_idct_add_mmi(q[0] * dq[0], dst_u, stride, dst_u, stride);
memset(q, 0, 2 * sizeof(q[0]));
}
q += 16;
dst_u += 4;
}
dst_u += 4 * stride - 8;
}
for (i = 0; i < 2; i++) {
for (j = 0; j < 2; j++) {
if (*eobs++ > 1) {
vp8_dequant_idct_add_mmi(q, dq, dst_v, stride);
} else {
vp8_dc_only_idct_add_mmi(q[0] * dq[0], dst_v, stride, dst_v, stride);
memset(q, 0, 2 * sizeof(q[0]));
}
q += 16;
dst_v += 4;
}
dst_v += 4 * stride - 8;
}
}
@@ -0,0 +1,328 @@
/*
* Copyright (c) 2017 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 "./vp8_rtcd.h"
#include "vpx_ports/mem.h"
#include "vpx_ports/asmdefs_mmi.h"
#define TRANSPOSE_4H \
"xor %[ftmp0], %[ftmp0], %[ftmp0] \n\t" \
MMI_LI(%[tmp0], 0x93) \
"mtc1 %[tmp0], %[ftmp10] \n\t" \
"punpcklhw %[ftmp5], %[ftmp1], %[ftmp0] \n\t" \
"punpcklhw %[ftmp9], %[ftmp2], %[ftmp0] \n\t" \
"pshufh %[ftmp9], %[ftmp9], %[ftmp10] \n\t" \
"or %[ftmp5], %[ftmp5], %[ftmp9] \n\t" \
"punpckhhw %[ftmp6], %[ftmp1], %[ftmp0] \n\t" \
"punpckhhw %[ftmp9], %[ftmp2], %[ftmp0] \n\t" \
"pshufh %[ftmp9], %[ftmp9], %[ftmp10] \n\t" \
"or %[ftmp6], %[ftmp6], %[ftmp9] \n\t" \
"punpcklhw %[ftmp7], %[ftmp3], %[ftmp0] \n\t" \
"punpcklhw %[ftmp9], %[ftmp4], %[ftmp0] \n\t" \
"pshufh %[ftmp9], %[ftmp9], %[ftmp10] \n\t" \
"or %[ftmp7], %[ftmp7], %[ftmp9] \n\t" \
"punpckhhw %[ftmp8], %[ftmp3], %[ftmp0] \n\t" \
"punpckhhw %[ftmp9], %[ftmp4], %[ftmp0] \n\t" \
"pshufh %[ftmp9], %[ftmp9], %[ftmp10] \n\t" \
"or %[ftmp8], %[ftmp8], %[ftmp9] \n\t" \
"punpcklwd %[ftmp1], %[ftmp5], %[ftmp7] \n\t" \
"punpckhwd %[ftmp2], %[ftmp5], %[ftmp7] \n\t" \
"punpcklwd %[ftmp3], %[ftmp6], %[ftmp8] \n\t" \
"punpckhwd %[ftmp4], %[ftmp6], %[ftmp8] \n\t"
void vp8_short_idct4x4llm_mmi(int16_t *input, unsigned char *pred_ptr,
int pred_stride, unsigned char *dst_ptr,
int dst_stride) {
double ftmp[12];
uint32_t tmp[0];
DECLARE_ALIGNED(8, const uint64_t, ff_ph_04) = { 0x0004000400040004ULL };
DECLARE_ALIGNED(8, const uint64_t, ff_ph_4e7b) = { 0x4e7b4e7b4e7b4e7bULL };
DECLARE_ALIGNED(8, const uint64_t, ff_ph_22a3) = { 0x22a322a322a322a3ULL };
__asm__ volatile (
MMI_LI(%[tmp0], 0x02)
"mtc1 %[tmp0], %[ftmp11] \n\t"
"xor %[ftmp0], %[ftmp0], %[ftmp0] \n\t"
"gsldlc1 %[ftmp1], 0x07(%[ip]) \n\t"
"gsldrc1 %[ftmp1], 0x00(%[ip]) \n\t"
"gsldlc1 %[ftmp2], 0x0f(%[ip]) \n\t"
"gsldrc1 %[ftmp2], 0x08(%[ip]) \n\t"
"gsldlc1 %[ftmp3], 0x17(%[ip]) \n\t"
"gsldrc1 %[ftmp3], 0x10(%[ip]) \n\t"
"gsldlc1 %[ftmp4], 0x1f(%[ip]) \n\t"
"gsldrc1 %[ftmp4], 0x18(%[ip]) \n\t"
// ip[0...3] + ip[8...11]
"paddh %[ftmp5], %[ftmp1], %[ftmp3] \n\t"
// ip[0...3] - ip[8...11]
"psubh %[ftmp6], %[ftmp1], %[ftmp3] \n\t"
// (ip[12...15] * sinpi8sqrt2) >> 16
"psllh %[ftmp9], %[ftmp4], %[ftmp11] \n\t"
"pmulhh %[ftmp7], %[ftmp9], %[ff_ph_22a3] \n\t"
// (ip[ 4... 7] * sinpi8sqrt2) >> 16
"psllh %[ftmp9], %[ftmp2], %[ftmp11] \n\t"
"pmulhh %[ftmp8], %[ftmp9], %[ff_ph_22a3] \n\t"
// ip[ 4... 7] + ((ip[ 4... 7] * cospi8sqrt2minus1) >> 16)
"pmulhh %[ftmp9], %[ftmp2], %[ff_ph_4e7b] \n\t"
"paddh %[ftmp9], %[ftmp9], %[ftmp2] \n\t"
// ip[12...15] + ((ip[12...15] * cospi8sqrt2minus1) >> 16)
"pmulhh %[ftmp10], %[ftmp4], %[ff_ph_4e7b] \n\t"
"paddh %[ftmp10], %[ftmp10], %[ftmp4] \n\t"
"paddh %[ftmp1], %[ftmp5], %[ftmp7] \n\t"
"paddh %[ftmp1], %[ftmp1], %[ftmp9] \n\t"
"paddh %[ftmp2], %[ftmp6], %[ftmp8] \n\t"
"psubh %[ftmp2], %[ftmp2], %[ftmp10] \n\t"
"psubh %[ftmp3], %[ftmp6], %[ftmp8] \n\t"
"paddh %[ftmp3], %[ftmp3], %[ftmp10] \n\t"
"psubh %[ftmp4], %[ftmp5], %[ftmp7] \n\t"
"psubh %[ftmp4], %[ftmp4], %[ftmp9] \n\t"
TRANSPOSE_4H
// a
"paddh %[ftmp5], %[ftmp1], %[ftmp3] \n\t"
// b
"psubh %[ftmp6], %[ftmp1], %[ftmp3] \n\t"
// c
"psllh %[ftmp9], %[ftmp2], %[ftmp11] \n\t"
"pmulhh %[ftmp9], %[ftmp9], %[ff_ph_22a3] \n\t"
"psubh %[ftmp7], %[ftmp9], %[ftmp4] \n\t"
"pmulhh %[ftmp10], %[ftmp4], %[ff_ph_4e7b] \n\t"
"psubh %[ftmp7], %[ftmp7], %[ftmp10] \n\t"
// d
"psllh %[ftmp9], %[ftmp4], %[ftmp11] \n\t"
"pmulhh %[ftmp9], %[ftmp9], %[ff_ph_22a3] \n\t"
"paddh %[ftmp8], %[ftmp9], %[ftmp2] \n\t"
"pmulhh %[ftmp10], %[ftmp2], %[ff_ph_4e7b] \n\t"
"paddh %[ftmp8], %[ftmp8], %[ftmp10] \n\t"
MMI_LI(%[tmp0], 0x03)
"mtc1 %[tmp0], %[ftmp11] \n\t"
// a + d
"paddh %[ftmp1], %[ftmp5], %[ftmp8] \n\t"
"paddh %[ftmp1], %[ftmp1], %[ff_ph_04] \n\t"
"psrah %[ftmp1], %[ftmp1], %[ftmp11] \n\t"
// b + c
"paddh %[ftmp2], %[ftmp6], %[ftmp7] \n\t"
"paddh %[ftmp2], %[ftmp2], %[ff_ph_04] \n\t"
"psrah %[ftmp2], %[ftmp2], %[ftmp11] \n\t"
// b - c
"psubh %[ftmp3], %[ftmp6], %[ftmp7] \n\t"
"paddh %[ftmp3], %[ftmp3], %[ff_ph_04] \n\t"
"psrah %[ftmp3], %[ftmp3], %[ftmp11] \n\t"
// a - d
"psubh %[ftmp4], %[ftmp5], %[ftmp8] \n\t"
"paddh %[ftmp4], %[ftmp4], %[ff_ph_04] \n\t"
"psrah %[ftmp4], %[ftmp4], %[ftmp11] \n\t"
TRANSPOSE_4H
#if _MIPS_SIM == _ABIO32
"ulw %[tmp0], 0x00(%[pred_prt]) \n\t"
"mtc1 %[tmp0], %[ftmp5] \n\t"
#else
"gslwlc1 %[ftmp5], 0x03(%[pred_ptr]) \n\t"
"gslwrc1 %[ftmp5], 0x00(%[pred_ptr]) \n\t"
#endif
"punpcklbh %[ftmp5], %[ftmp5], %[ftmp0] \n\t"
"paddh %[ftmp1], %[ftmp1], %[ftmp5] \n\t"
"packushb %[ftmp1], %[ftmp1], %[ftmp0] \n\t"
"gsswlc1 %[ftmp1], 0x03(%[dst_ptr]) \n\t"
"gsswrc1 %[ftmp1], 0x00(%[dst_ptr]) \n\t"
MMI_ADDU(%[pred_ptr], %[pred_ptr], %[pred_stride])
MMI_ADDU(%[dst_ptr], %[dst_ptr], %[dst_stride])
#if _MIPS_SIM == _ABIO32
"ulw %[tmp0], 0x00(%[pred_prt]) \n\t"
"mtc1 %[tmp0], %[ftmp6] \n\t"
#else
"gslwlc1 %[ftmp6], 0x03(%[pred_ptr]) \n\t"
"gslwrc1 %[ftmp6], 0x00(%[pred_ptr]) \n\t"
#endif
"punpcklbh %[ftmp6], %[ftmp6], %[ftmp0] \n\t"
"paddh %[ftmp2], %[ftmp2], %[ftmp6] \n\t"
"packushb %[ftmp2], %[ftmp2], %[ftmp0] \n\t"
"gsswlc1 %[ftmp2], 0x03(%[dst_ptr]) \n\t"
"gsswrc1 %[ftmp2], 0x00(%[dst_ptr]) \n\t"
MMI_ADDU(%[pred_ptr], %[pred_ptr], %[pred_stride])
MMI_ADDU(%[dst_ptr], %[dst_ptr], %[dst_stride])
#if _MIPS_SIM == _ABIO32
"ulw %[tmp0], 0x00(%[pred_prt]) \n\t"
"mtc1 %[tmp0], %[ftmp7] \n\t"
#else
"gslwlc1 %[ftmp7], 0x03(%[pred_ptr]) \n\t"
"gslwrc1 %[ftmp7], 0x00(%[pred_ptr]) \n\t"
#endif
"punpcklbh %[ftmp7], %[ftmp7], %[ftmp0] \n\t"
"paddh %[ftmp3], %[ftmp3], %[ftmp7] \n\t"
"packushb %[ftmp3], %[ftmp3], %[ftmp0] \n\t"
"gsswlc1 %[ftmp3], 0x03(%[dst_ptr]) \n\t"
"gsswrc1 %[ftmp3], 0x00(%[dst_ptr]) \n\t"
MMI_ADDU(%[pred_ptr], %[pred_ptr], %[pred_stride])
MMI_ADDU(%[dst_ptr], %[dst_ptr], %[dst_stride])
#if _MIPS_SIM == _ABIO32
"ulw %[tmp0], 0x00(%[pred_prt]) \n\t"
"mtc1 %[tmp0], %[ftmp8] \n\t"
#else
"gslwlc1 %[ftmp8], 0x03(%[pred_ptr]) \n\t"
"gslwrc1 %[ftmp8], 0x00(%[pred_ptr]) \n\t"
#endif
"punpcklbh %[ftmp8], %[ftmp8], %[ftmp0] \n\t"
"paddh %[ftmp4], %[ftmp4], %[ftmp8] \n\t"
"packushb %[ftmp4], %[ftmp4], %[ftmp0] \n\t"
"gsswlc1 %[ftmp4], 0x03(%[dst_ptr]) \n\t"
"gsswrc1 %[ftmp4], 0x00(%[dst_ptr]) \n\t"
: [ftmp0]"=&f"(ftmp[0]), [ftmp1]"=&f"(ftmp[1]), [ftmp2]"=&f"(ftmp[2]),
[ftmp3]"=&f"(ftmp[3]), [ftmp4]"=&f"(ftmp[4]), [ftmp5]"=&f"(ftmp[5]),
[ftmp6]"=&f"(ftmp[6]), [ftmp7]"=&f"(ftmp[7]), [ftmp8]"=&f"(ftmp[8]),
[ftmp9]"=&f"(ftmp[9]), [ftmp10]"=&f"(ftmp[10]),
[ftmp11]"=&f"(ftmp[11]), [tmp0]"=&r"(tmp[0]),
[pred_ptr]"+&r"(pred_ptr), [dst_ptr]"+&r"(dst_ptr)
: [ip]"r"(input), [ff_ph_22a3]"f"(ff_ph_22a3),
[ff_ph_4e7b]"f"(ff_ph_4e7b), [ff_ph_04]"f"(ff_ph_04),
[pred_stride]"r"((mips_reg)pred_stride),
[dst_stride]"r"((mips_reg)dst_stride)
: "memory"
);
}
void vp8_dc_only_idct_add_mmi(int16_t input_dc, unsigned char *pred_ptr,
int pred_stride, unsigned char *dst_ptr,
int dst_stride) {
int a1 = ((input_dc + 4) >> 3);
double ftmp[5];
int low32;
__asm__ volatile (
"xor %[ftmp0], %[ftmp0], %[ftmp0] \n\t"
"pshufh %[a1], %[a1], %[ftmp0] \n\t"
"ulw %[low32], 0x00(%[pred_ptr]) \n\t"
"mtc1 %[low32], %[ftmp1] \n\t"
"punpcklbh %[ftmp2], %[ftmp1], %[ftmp0] \n\t"
"paddsh %[ftmp2], %[ftmp2], %[a1] \n\t"
"packushb %[ftmp1], %[ftmp2], %[ftmp0] \n\t"
"gsswlc1 %[ftmp1], 0x03(%[dst_ptr]) \n\t"
"gsswrc1 %[ftmp1], 0x00(%[dst_ptr]) \n\t"
MMI_ADDU(%[pred_ptr], %[pred_ptr], %[pred_stride])
MMI_ADDU(%[dst_ptr], %[dst_ptr], %[dst_stride])
"ulw %[low32], 0x00(%[pred_ptr]) \n\t"
"mtc1 %[low32], %[ftmp1] \n\t"
"punpcklbh %[ftmp2], %[ftmp1], %[ftmp0] \n\t"
"paddsh %[ftmp2], %[ftmp2], %[a1] \n\t"
"packushb %[ftmp1], %[ftmp2], %[ftmp0] \n\t"
"gsswlc1 %[ftmp1], 0x03(%[dst_ptr]) \n\t"
"gsswrc1 %[ftmp1], 0x00(%[dst_ptr]) \n\t"
MMI_ADDU(%[pred_ptr], %[pred_ptr], %[pred_stride])
MMI_ADDU(%[dst_ptr], %[dst_ptr], %[dst_stride])
"ulw %[low32], 0x00(%[pred_ptr]) \n\t"
"mtc1 %[low32], %[ftmp1] \n\t"
"punpcklbh %[ftmp2], %[ftmp1], %[ftmp0] \n\t"
"paddsh %[ftmp2], %[ftmp2], %[a1] \n\t"
"packushb %[ftmp1], %[ftmp2], %[ftmp0] \n\t"
"gsswlc1 %[ftmp1], 0x03(%[dst_ptr]) \n\t"
"gsswrc1 %[ftmp1], 0x00(%[dst_ptr]) \n\t"
MMI_ADDU(%[pred_ptr], %[pred_ptr], %[pred_stride])
MMI_ADDU(%[dst_ptr], %[dst_ptr], %[dst_stride])
"ulw %[low32], 0x00(%[pred_ptr]) \n\t"
"mtc1 %[low32], %[ftmp1] \n\t"
"punpcklbh %[ftmp2], %[ftmp1], %[ftmp0] \n\t"
"paddsh %[ftmp2], %[ftmp2], %[a1] \n\t"
"packushb %[ftmp1], %[ftmp2], %[ftmp0] \n\t"
"gsswlc1 %[ftmp1], 0x03(%[dst_ptr]) \n\t"
"gsswrc1 %[ftmp1], 0x00(%[dst_ptr]) \n\t"
: [ftmp0]"=&f"(ftmp[0]), [ftmp1]"=&f"(ftmp[1]), [ftmp2]"=&f"(ftmp[2]),
[ftmp3]"=&f"(ftmp[3]), [ftmp4]"=&f"(ftmp[4]), [low32]"=&r"(low32),
[dst_ptr]"+&r"(dst_ptr), [pred_ptr]"+&r"(pred_ptr)
: [dst_stride]"r"((mips_reg)dst_stride),
[pred_stride]"r"((mips_reg)pred_stride), [a1]"f"(a1)
: "memory"
);
}
void vp8_short_inv_walsh4x4_mmi(int16_t *input, int16_t *mb_dqcoeff) {
int i;
int16_t output[16];
double ftmp[12];
uint32_t tmp[1];
DECLARE_ALIGNED(8, const uint64_t, ff_ph_03) = { 0x0003000300030003ULL };
__asm__ volatile (
MMI_LI(%[tmp0], 0x03)
"xor %[ftmp0], %[ftmp0], %[ftmp0] \n\t"
"mtc1 %[tmp0], %[ftmp11] \n\t"
"gsldlc1 %[ftmp1], 0x07(%[ip]) \n\t"
"gsldrc1 %[ftmp1], 0x00(%[ip]) \n\t"
"gsldlc1 %[ftmp2], 0x0f(%[ip]) \n\t"
"gsldrc1 %[ftmp2], 0x08(%[ip]) \n\t"
"gsldlc1 %[ftmp3], 0x17(%[ip]) \n\t"
"gsldrc1 %[ftmp3], 0x10(%[ip]) \n\t"
"gsldlc1 %[ftmp4], 0x1f(%[ip]) \n\t"
"gsldrc1 %[ftmp4], 0x18(%[ip]) \n\t"
"paddh %[ftmp5], %[ftmp1], %[ftmp2] \n\t"
"psubh %[ftmp6], %[ftmp1], %[ftmp2] \n\t"
"paddh %[ftmp7], %[ftmp3], %[ftmp4] \n\t"
"psubh %[ftmp8], %[ftmp3], %[ftmp4] \n\t"
"paddh %[ftmp1], %[ftmp5], %[ftmp7] \n\t"
"psubh %[ftmp2], %[ftmp5], %[ftmp7] \n\t"
"psubh %[ftmp3], %[ftmp6], %[ftmp8] \n\t"
"paddh %[ftmp4], %[ftmp6], %[ftmp8] \n\t"
TRANSPOSE_4H
// a
"paddh %[ftmp5], %[ftmp1], %[ftmp4] \n\t"
// d
"psubh %[ftmp6], %[ftmp1], %[ftmp4] \n\t"
// b
"paddh %[ftmp7], %[ftmp2], %[ftmp3] \n\t"
// c
"psubh %[ftmp8], %[ftmp2], %[ftmp3] \n\t"
"paddh %[ftmp1], %[ftmp5], %[ftmp7] \n\t"
"paddh %[ftmp2], %[ftmp6], %[ftmp8] \n\t"
"psubh %[ftmp3], %[ftmp5], %[ftmp7] \n\t"
"psubh %[ftmp4], %[ftmp6], %[ftmp8] \n\t"
"paddh %[ftmp1], %[ftmp1], %[ff_ph_03] \n\t"
"psrah %[ftmp1], %[ftmp1], %[ftmp11] \n\t"
"paddh %[ftmp2], %[ftmp2], %[ff_ph_03] \n\t"
"psrah %[ftmp2], %[ftmp2], %[ftmp11] \n\t"
"paddh %[ftmp3], %[ftmp3], %[ff_ph_03] \n\t"
"psrah %[ftmp3], %[ftmp3], %[ftmp11] \n\t"
"paddh %[ftmp4], %[ftmp4], %[ff_ph_03] \n\t"
"psrah %[ftmp4], %[ftmp4], %[ftmp11] \n\t"
TRANSPOSE_4H
"gssdlc1 %[ftmp1], 0x07(%[op]) \n\t"
"gssdrc1 %[ftmp1], 0x00(%[op]) \n\t"
"gssdlc1 %[ftmp2], 0x0f(%[op]) \n\t"
"gssdrc1 %[ftmp2], 0x08(%[op]) \n\t"
"gssdlc1 %[ftmp3], 0x17(%[op]) \n\t"
"gssdrc1 %[ftmp3], 0x10(%[op]) \n\t"
"gssdlc1 %[ftmp4], 0x1f(%[op]) \n\t"
"gssdrc1 %[ftmp4], 0x18(%[op]) \n\t"
: [ftmp0]"=&f"(ftmp[0]), [ftmp1]"=&f"(ftmp[1]), [ftmp2]"=&f"(ftmp[2]),
[ftmp3]"=&f"(ftmp[3]), [ftmp4]"=&f"(ftmp[4]), [ftmp5]"=&f"(ftmp[5]),
[ftmp6]"=&f"(ftmp[6]), [ftmp7]"=&f"(ftmp[7]), [ftmp8]"=&f"(ftmp[8]),
[ftmp9]"=&f"(ftmp[9]), [ftmp10]"=&f"(ftmp[10]),
[ftmp11]"=&f"(ftmp[11]), [tmp0]"=&r"(tmp[0])
: [ip]"r"(input), [op]"r"(output), [ff_ph_03]"f"(ff_ph_03)
: "memory"
);
for (i = 0; i < 16; i++) {
mb_dqcoeff[i * 16] = output[i];
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,416 @@
/*
* Copyright (c) 2017 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 "vp8/common/filter.h"
#include "vpx_ports/asmdefs_mmi.h"
DECLARE_ALIGNED(8, static const int16_t, vp8_six_tap_mmi[8][6 * 8]) = {
{ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0080, 0x0080, 0x0080, 0x0080, 0x0080, 0x0080, 0x0080, 0x0080,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 },
{ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0xfffa, 0xfffa, 0xfffa, 0xfffa, 0xfffa, 0xfffa, 0xfffa, 0xfffa,
0x007b, 0x007b, 0x007b, 0x007b, 0x007b, 0x007b, 0x007b, 0x007b,
0x000c, 0x000c, 0x000c, 0x000c, 0x000c, 0x000c, 0x000c, 0x000c,
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 },
{ 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002,
0xfff5, 0xfff5, 0xfff5, 0xfff5, 0xfff5, 0xfff5, 0xfff5, 0xfff5,
0x006c, 0x006c, 0x006c, 0x006c, 0x006c, 0x006c, 0x006c, 0x006c,
0x0024, 0x0024, 0x0024, 0x0024, 0x0024, 0x0024, 0x0024, 0x0024,
0xfff8, 0xfff8, 0xfff8, 0xfff8, 0xfff8, 0xfff8, 0xfff8, 0xfff8,
0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001 },
{ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0xfff7, 0xfff7, 0xfff7, 0xfff7, 0xfff7, 0xfff7, 0xfff7, 0xfff7,
0x005d, 0x005d, 0x005d, 0x005d, 0x005d, 0x005d, 0x005d, 0x005d,
0x0032, 0x0032, 0x0032, 0x0032, 0x0032, 0x0032, 0x0032, 0x0032,
0xfffa, 0xfffa, 0xfffa, 0xfffa, 0xfffa, 0xfffa, 0xfffa, 0xfffa,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 },
{ 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003,
0xfff0, 0xfff0, 0xfff0, 0xfff0, 0xfff0, 0xfff0, 0xfff0, 0xfff0,
0x004d, 0x004d, 0x004d, 0x004d, 0x004d, 0x004d, 0x004d, 0x004d,
0x004d, 0x004d, 0x004d, 0x004d, 0x004d, 0x004d, 0x004d, 0x004d,
0xfff0, 0xfff0, 0xfff0, 0xfff0, 0xfff0, 0xfff0, 0xfff0, 0xfff0,
0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003 },
{ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0xfffa, 0xfffa, 0xfffa, 0xfffa, 0xfffa, 0xfffa, 0xfffa, 0xfffa,
0x0032, 0x0032, 0x0032, 0x0032, 0x0032, 0x0032, 0x0032, 0x0032,
0x005d, 0x005d, 0x005d, 0x005d, 0x005d, 0x005d, 0x005d, 0x005d,
0xfff7, 0xfff7, 0xfff7, 0xfff7, 0xfff7, 0xfff7, 0xfff7, 0xfff7,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 },
{ 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
0xfff8, 0xfff8, 0xfff8, 0xfff8, 0xfff8, 0xfff8, 0xfff8, 0xfff8,
0x0024, 0x0024, 0x0024, 0x0024, 0x0024, 0x0024, 0x0024, 0x0024,
0x006c, 0x006c, 0x006c, 0x006c, 0x006c, 0x006c, 0x006c, 0x006c,
0xfff5, 0xfff5, 0xfff5, 0xfff5, 0xfff5, 0xfff5, 0xfff5, 0xfff5,
0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002 },
{ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
0x000c, 0x000c, 0x000c, 0x000c, 0x000c, 0x000c, 0x000c, 0x000c,
0x007b, 0x007b, 0x007b, 0x007b, 0x007b, 0x007b, 0x007b, 0x007b,
0xfffa, 0xfffa, 0xfffa, 0xfffa, 0xfffa, 0xfffa, 0xfffa, 0xfffa,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }
};
/* Horizontal filter: pixel_step is 1, output_height and output_width are
the size of horizontal filtering output, output_height is always H + 5 */
static INLINE void vp8_filter_block1d_h6_mmi(unsigned char *src_ptr,
uint16_t *output_ptr,
unsigned int src_pixels_per_line,
unsigned int output_height,
unsigned int output_width,
const int16_t *vp8_filter) {
uint32_t tmp[1];
DECLARE_ALIGNED(8, const uint64_t, ff_ph_40) = { 0x0040004000400040ULL };
#if _MIPS_SIM == _ABIO32
register double fzero asm("$f0");
register double ftmp0 asm("$f2");
register double ftmp1 asm("$f4");
register double ftmp2 asm("$f6");
register double ftmp3 asm("$f8");
register double ftmp4 asm("$f10");
register double ftmp5 asm("$f12");
register double ftmp6 asm("$f14");
register double ftmp7 asm("$f16");
register double ftmp8 asm("$f18");
register double ftmp9 asm("$f20");
register double ftmp10 asm("$f22");
register double ftmp11 asm("$f24");
#else
register double fzero asm("$f0");
register double ftmp0 asm("$f1");
register double ftmp1 asm("$f2");
register double ftmp2 asm("$f3");
register double ftmp3 asm("$f4");
register double ftmp4 asm("$f5");
register double ftmp5 asm("$f6");
register double ftmp6 asm("$f7");
register double ftmp7 asm("$f8");
register double ftmp8 asm("$f9");
register double ftmp9 asm("$f10");
register double ftmp10 asm("$f11");
register double ftmp11 asm("$f12");
#endif // _MIPS_SIM == _ABIO32
__asm__ volatile (
"ldc1 %[ftmp0], 0x00(%[vp8_filter]) \n\t"
"ldc1 %[ftmp1], 0x10(%[vp8_filter]) \n\t"
"ldc1 %[ftmp2], 0x20(%[vp8_filter]) \n\t"
"ldc1 %[ftmp3], 0x30(%[vp8_filter]) \n\t"
"ldc1 %[ftmp4], 0x40(%[vp8_filter]) \n\t"
"ldc1 %[ftmp5], 0x50(%[vp8_filter]) \n\t"
"xor %[fzero], %[fzero], %[fzero] \n\t"
"li %[tmp0], 0x07 \n\t"
"mtc1 %[tmp0], %[ftmp7] \n\t"
"li %[tmp0], 0x08 \n\t"
"mtc1 %[tmp0], %[ftmp11] \n\t"
"1: \n\t"
"gsldlc1 %[ftmp9], 0x05(%[src_ptr]) \n\t"
"gsldrc1 %[ftmp9], -0x02(%[src_ptr]) \n\t"
"gsldlc1 %[ftmp10], 0x06(%[src_ptr]) \n\t"
"gsldrc1 %[ftmp10], -0x01(%[src_ptr]) \n\t"
"punpcklbh %[ftmp6], %[ftmp9], %[fzero] \n\t"
"pmullh %[ftmp8], %[ftmp6], %[ftmp0] \n\t"
"punpckhbh %[ftmp6], %[ftmp9], %[fzero] \n\t"
"pmullh %[ftmp6], %[ftmp6], %[ftmp4] \n\t"
"paddsh %[ftmp8], %[ftmp8], %[ftmp6] \n\t"
"punpcklbh %[ftmp6], %[ftmp10], %[fzero] \n\t"
"pmullh %[ftmp6], %[ftmp6], %[ftmp1] \n\t"
"paddsh %[ftmp8], %[ftmp8], %[ftmp6] \n\t"
"punpckhbh %[ftmp6], %[ftmp10], %[fzero] \n\t"
"pmullh %[ftmp6], %[ftmp6], %[ftmp5] \n\t"
"paddsh %[ftmp8], %[ftmp8], %[ftmp6] \n\t"
"dsrl %[ftmp10], %[ftmp10], %[ftmp11] \n\t"
"punpcklbh %[ftmp6], %[ftmp10], %[fzero] \n\t"
"pmullh %[ftmp6], %[ftmp6], %[ftmp2] \n\t"
"paddsh %[ftmp8], %[ftmp8], %[ftmp6] \n\t"
"dsrl %[ftmp10], %[ftmp10], %[ftmp11] \n\t"
"punpcklbh %[ftmp6], %[ftmp10], %[fzero] \n\t"
"pmullh %[ftmp6], %[ftmp6], %[ftmp3] \n\t"
"paddsh %[ftmp8], %[ftmp8], %[ftmp6] \n\t"
"paddsh %[ftmp8], %[ftmp8], %[ff_ph_40] \n\t"
"psrah %[ftmp8], %[ftmp8], %[ftmp7] \n\t"
"packushb %[ftmp8], %[ftmp8], %[fzero] \n\t"
"punpcklbh %[ftmp8], %[ftmp8], %[fzero] \n\t"
"gssdlc1 %[ftmp8], 0x07(%[output_ptr]) \n\t"
"gssdrc1 %[ftmp8], 0x00(%[output_ptr]) \n\t"
"addiu %[output_height], %[output_height], -0x01 \n\t"
MMI_ADDU(%[output_ptr], %[output_ptr], %[output_width])
MMI_ADDU(%[src_ptr], %[src_ptr], %[src_pixels_per_line])
"bnez %[output_height], 1b \n\t"
: [fzero]"=&f"(fzero), [ftmp0]"=&f"(ftmp0),
[ftmp1]"=&f"(ftmp1), [ftmp2]"=&f"(ftmp2),
[ftmp3]"=&f"(ftmp3), [ftmp4]"=&f"(ftmp4),
[ftmp5]"=&f"(ftmp5), [ftmp6]"=&f"(ftmp6),
[ftmp7]"=&f"(ftmp7), [ftmp8]"=&f"(ftmp8),
[ftmp9]"=&f"(ftmp9), [ftmp10]"=&f"(ftmp10),
[ftmp11]"=&f"(ftmp11), [tmp0]"=&r"(tmp[0]),
[output_ptr]"+&r"(output_ptr), [output_height]"+&r"(output_height),
[src_ptr]"+&r"(src_ptr)
: [src_pixels_per_line]"r"((mips_reg)src_pixels_per_line),
[vp8_filter]"r"(vp8_filter), [output_width]"r"(output_width),
[ff_ph_40]"f"(ff_ph_40)
: "memory"
);
}
/* Horizontal filter: pixel_step is always W */
static INLINE void vp8_filter_block1dc_v6_mmi(
uint16_t *src_ptr, unsigned char *output_ptr, unsigned int output_height,
int output_pitch, unsigned int pixels_per_line, const int16_t *vp8_filter) {
DECLARE_ALIGNED(8, const uint64_t, ff_ph_40) = { 0x0040004000400040ULL };
uint32_t tmp[1];
mips_reg addr[1];
#if _MIPS_SIM == _ABIO32
register double fzero asm("$f0");
register double ftmp0 asm("$f2");
register double ftmp1 asm("$f4");
register double ftmp2 asm("$f6");
register double ftmp3 asm("$f8");
register double ftmp4 asm("$f10");
register double ftmp5 asm("$f12");
register double ftmp6 asm("$f14");
register double ftmp7 asm("$f16");
register double ftmp8 asm("$f18");
register double ftmp9 asm("$f20");
register double ftmp10 asm("$f22");
register double ftmp11 asm("$f24");
register double ftmp12 asm("$f26");
register double ftmp13 asm("$f28");
#else
register double fzero asm("$f0");
register double ftmp0 asm("$f1");
register double ftmp1 asm("$f2");
register double ftmp2 asm("$f3");
register double ftmp3 asm("$f4");
register double ftmp4 asm("$f5");
register double ftmp5 asm("$f6");
register double ftmp6 asm("$f7");
register double ftmp7 asm("$f8");
register double ftmp8 asm("$f9");
register double ftmp9 asm("$f10");
register double ftmp10 asm("$f11");
register double ftmp11 asm("$f12");
register double ftmp12 asm("$f13");
register double ftmp13 asm("$f14");
#endif // _MIPS_SIM == _ABIO32
__asm__ volatile (
"ldc1 %[ftmp0], 0x00(%[vp8_filter]) \n\t"
"ldc1 %[ftmp1], 0x10(%[vp8_filter]) \n\t"
"ldc1 %[ftmp2], 0x20(%[vp8_filter]) \n\t"
"ldc1 %[ftmp3], 0x30(%[vp8_filter]) \n\t"
"ldc1 %[ftmp4], 0x40(%[vp8_filter]) \n\t"
"ldc1 %[ftmp5], 0x50(%[vp8_filter]) \n\t"
"xor %[fzero], %[fzero], %[fzero] \n\t"
"li %[tmp0], 0x07 \n\t"
"mtc1 %[tmp0], %[ftmp13] \n\t"
/* In order to make full use of memory load delay slot,
* Operation of memory loading and calculating has been rearranged.
*/
"1: \n\t"
"gsldlc1 %[ftmp6], 0x07(%[src_ptr]) \n\t"
"gsldrc1 %[ftmp6], 0x00(%[src_ptr]) \n\t"
MMI_ADDU(%[addr0], %[src_ptr], %[pixels_per_line])
"gsldlc1 %[ftmp7], 0x07(%[addr0]) \n\t"
"gsldrc1 %[ftmp7], 0x00(%[addr0]) \n\t"
MMI_ADDU(%[addr0], %[src_ptr], %[pixels_per_line_x2])
"gsldlc1 %[ftmp8], 0x07(%[addr0]) \n\t"
"gsldrc1 %[ftmp8], 0x00(%[addr0]) \n\t"
MMI_ADDU(%[addr0], %[src_ptr], %[pixels_per_line_x4])
"gsldlc1 %[ftmp9], 0x07(%[addr0]) \n\t"
"gsldrc1 %[ftmp9], 0x00(%[addr0]) \n\t"
MMI_ADDU(%[src_ptr], %[src_ptr], %[pixels_per_line])
MMI_ADDU(%[addr0], %[src_ptr], %[pixels_per_line_x2])
"gsldlc1 %[ftmp10], 0x07(%[addr0]) \n\t"
"gsldrc1 %[ftmp10], 0x00(%[addr0]) \n\t"
MMI_ADDU(%[addr0], %[src_ptr], %[pixels_per_line_x4])
"gsldlc1 %[ftmp11], 0x07(%[addr0]) \n\t"
"gsldrc1 %[ftmp11], 0x00(%[addr0]) \n\t"
"pmullh %[ftmp12], %[ftmp6], %[ftmp0] \n\t"
"pmullh %[ftmp7], %[ftmp7], %[ftmp1] \n\t"
"paddsh %[ftmp12], %[ftmp12], %[ftmp7] \n\t"
"pmullh %[ftmp8], %[ftmp8], %[ftmp2] \n\t"
"paddsh %[ftmp12], %[ftmp12], %[ftmp8] \n\t"
"pmullh %[ftmp9], %[ftmp9], %[ftmp4] \n\t"
"paddsh %[ftmp12], %[ftmp12], %[ftmp9] \n\t"
"pmullh %[ftmp10], %[ftmp10], %[ftmp3] \n\t"
"paddsh %[ftmp12], %[ftmp12], %[ftmp10] \n\t"
"pmullh %[ftmp11], %[ftmp11], %[ftmp5] \n\t"
"paddsh %[ftmp12], %[ftmp12], %[ftmp11] \n\t"
"paddsh %[ftmp12], %[ftmp12], %[ff_ph_40] \n\t"
"psrah %[ftmp12], %[ftmp12], %[ftmp13] \n\t"
"packushb %[ftmp12], %[ftmp12], %[fzero] \n\t"
"gsswlc1 %[ftmp12], 0x03(%[output_ptr]) \n\t"
"gsswrc1 %[ftmp12], 0x00(%[output_ptr]) \n\t"
MMI_ADDIU(%[output_height], %[output_height], -0x01)
MMI_ADDU(%[output_ptr], %[output_ptr], %[output_pitch])
"bnez %[output_height], 1b \n\t"
: [fzero]"=&f"(fzero), [ftmp0]"=&f"(ftmp0),
[ftmp1]"=&f"(ftmp1), [ftmp2]"=&f"(ftmp2),
[ftmp3]"=&f"(ftmp3), [ftmp4]"=&f"(ftmp4),
[ftmp5]"=&f"(ftmp5), [ftmp6]"=&f"(ftmp6),
[ftmp7]"=&f"(ftmp7), [ftmp8]"=&f"(ftmp8),
[ftmp9]"=&f"(ftmp9), [ftmp10]"=&f"(ftmp10),
[ftmp11]"=&f"(ftmp11), [ftmp12]"=&f"(ftmp12),
[ftmp13]"=&f"(ftmp13), [tmp0]"=&r"(tmp[0]),
[addr0]"=&r"(addr[0]), [src_ptr]"+&r"(src_ptr),
[output_ptr]"+&r"(output_ptr), [output_height]"+&r"(output_height)
: [pixels_per_line]"r"((mips_reg)pixels_per_line),
[pixels_per_line_x2]"r"((mips_reg)(pixels_per_line<<1)),
[pixels_per_line_x4]"r"((mips_reg)(pixels_per_line<<2)),
[vp8_filter]"r"(vp8_filter),
[output_pitch]"r"((mips_reg)output_pitch),
[ff_ph_40]"f"(ff_ph_40)
: "memory"
);
}
/* When xoffset == 0, vp8_filter= {0,0,128,0,0,0},
function vp8_filter_block1d_h6_mmi and vp8_filter_block1d_v6_mmi can
be simplified */
static INLINE void vp8_filter_block1d_h6_filter0_mmi(
unsigned char *src_ptr, uint16_t *output_ptr,
unsigned int src_pixels_per_line, unsigned int output_height,
unsigned int output_width) {
#if _MIPS_SIM == _ABIO32
register double fzero asm("$f0");
register double ftmp0 asm("$f2");
register double ftmp1 asm("$f4");
#else
register double fzero asm("$f0");
register double ftmp0 asm("$f1");
register double ftmp1 asm("$f2");
#endif // _MIPS_SIM == _ABIO32
__asm__ volatile (
"xor %[fzero], %[fzero], %[fzero] \n\t"
"1: \n\t"
"gsldlc1 %[ftmp0], 0x07(%[src_ptr]) \n\t"
"gsldrc1 %[ftmp0], 0x00(%[src_ptr]) \n\t"
MMI_ADDU(%[src_ptr], %[src_ptr], %[src_pixels_per_line])
"punpcklbh %[ftmp1], %[ftmp0], %[fzero] \n\t"
"gssdlc1 %[ftmp1], 0x07(%[output_ptr]) \n\t"
"gssdrc1 %[ftmp1], 0x00(%[output_ptr]) \n\t"
"addiu %[output_height], %[output_height], -0x01 \n\t"
MMI_ADDU(%[output_ptr], %[output_ptr], %[output_width])
"bnez %[output_height], 1b \n\t"
: [fzero]"=&f"(fzero), [ftmp0]"=&f"(ftmp0),
[ftmp1]"=&f"(ftmp1), [src_ptr]"+&r"(src_ptr),
[output_ptr]"+&r"(output_ptr), [output_height]"+&r"(output_height)
: [src_pixels_per_line]"r"((mips_reg)src_pixels_per_line),
[output_width]"r"(output_width)
: "memory"
);
}
static INLINE void vp8_filter_block1dc_v6_filter0_mmi(
uint16_t *src_ptr, unsigned char *output_ptr, unsigned int output_height,
int output_pitch, unsigned int pixels_per_line) {
#if _MIPS_SIM == _ABIO32
register double fzero asm("$f0");
register double ftmp0 asm("$f2");
register double ftmp1 asm("$f4");
#else
register double fzero asm("$f0");
register double ftmp0 asm("$f1");
register double ftmp1 asm("$f2");
#endif // _MIPS_SIM == _ABIO32
__asm__ volatile (
"xor %[fzero], %[fzero], %[fzero] \n\t"
"1: \n\t"
"gsldlc1 %[ftmp0], 0x07(%[src_ptr]) \n\t"
"gsldrc1 %[ftmp0], 0x00(%[src_ptr]) \n\t"
MMI_ADDU(%[src_ptr], %[src_ptr], %[pixels_per_line])
MMI_ADDIU(%[output_height], %[output_height], -0x01)
"packushb %[ftmp1], %[ftmp0], %[fzero] \n\t"
"gsswlc1 %[ftmp1], 0x03(%[output_ptr]) \n\t"
"gsswrc1 %[ftmp1], 0x00(%[output_ptr]) \n\t"
MMI_ADDU(%[output_ptr], %[output_ptr], %[output_pitch])
"bnez %[output_height], 1b \n\t"
: [fzero]"=&f"(fzero), [ftmp0]"=&f"(ftmp0),
[ftmp1]"=&f"(ftmp1), [src_ptr]"+&r"(src_ptr),
[output_ptr]"+&r"(output_ptr), [output_height]"+&r"(output_height)
: [pixels_per_line]"r"((mips_reg)pixels_per_line),
[output_pitch]"r"((mips_reg)output_pitch)
: "memory"
);
}
#define sixtapNxM(n, m) \
void vp8_sixtap_predict##n##x##m##_mmi( \
unsigned char *src_ptr, int src_pixels_per_line, int xoffset, \
int yoffset, unsigned char *dst_ptr, int dst_pitch) { \
DECLARE_ALIGNED(16, uint16_t, \
FData2[(n + 5) * (n == 16 ? 24 : (n == 8 ? 16 : n))]); \
const int16_t *HFilter, *VFilter; \
int i, loop = n / 4; \
HFilter = vp8_six_tap_mmi[xoffset]; \
VFilter = vp8_six_tap_mmi[yoffset]; \
\
if (xoffset == 0) { \
for (i = 0; i < loop; ++i) { \
vp8_filter_block1d_h6_filter0_mmi( \
src_ptr - (2 * src_pixels_per_line) + i * 4, FData2 + i * 4, \
src_pixels_per_line, m + 5, n * 2); \
} \
} else { \
for (i = 0; i < loop; ++i) { \
vp8_filter_block1d_h6_mmi(src_ptr - (2 * src_pixels_per_line) + i * 4, \
FData2 + i * 4, src_pixels_per_line, m + 5, \
n * 2, HFilter); \
} \
} \
if (yoffset == 0) { \
for (i = 0; i < loop; ++i) { \
vp8_filter_block1dc_v6_filter0_mmi( \
FData2 + n * 2 + i * 4, dst_ptr + i * 4, m, dst_pitch, n * 2); \
} \
} else { \
for (i = 0; i < loop; ++i) { \
vp8_filter_block1dc_v6_mmi(FData2 + i * 4, dst_ptr + i * 4, m, \
dst_pitch, n * 2, VFilter); \
} \
} \
}
sixtapNxM(4, 4);
sixtapNxM(8, 8);
sixtapNxM(8, 4);
sixtapNxM(16, 16);
@@ -0,0 +1,797 @@
/*
* 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 "./vp8_rtcd.h"
#include "vpx_ports/mem.h"
#include "vp8/common/filter.h"
#include "vp8/common/mips/msa/vp8_macros_msa.h"
DECLARE_ALIGNED(16, static const int8_t, vp8_bilinear_filters_msa[7][2]) = {
{ 112, 16 }, { 96, 32 }, { 80, 48 }, { 64, 64 },
{ 48, 80 }, { 32, 96 }, { 16, 112 }
};
static const uint8_t vp8_mc_filt_mask_arr[16 * 3] = {
/* 8 width cases */
0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8,
/* 4 width cases */
0, 1, 1, 2, 2, 3, 3, 4, 16, 17, 17, 18, 18, 19, 19, 20,
/* 4 width cases */
8, 9, 9, 10, 10, 11, 11, 12, 24, 25, 25, 26, 26, 27, 27, 28
};
static void common_hz_2t_4x4_msa(uint8_t *RESTRICT src, int32_t src_stride,
uint8_t *RESTRICT dst, int32_t dst_stride,
const int8_t *filter) {
v16i8 src0, src1, src2, src3, mask;
v16u8 filt0, vec0, vec1, res0, res1;
v8u16 vec2, vec3, filt;
mask = LD_SB(&vp8_mc_filt_mask_arr[16]);
filt = LD_UH(filter);
filt0 = (v16u8)__msa_splati_h((v8i16)filt, 0);
LD_SB4(src, src_stride, src0, src1, src2, src3);
VSHF_B2_UB(src0, src1, src2, src3, mask, mask, vec0, vec1);
DOTP_UB2_UH(vec0, vec1, filt0, filt0, vec2, vec3);
SRARI_H2_UH(vec2, vec3, VP8_FILTER_SHIFT);
PCKEV_B2_UB(vec2, vec2, vec3, vec3, res0, res1);
ST4x4_UB(res0, res1, 0, 1, 0, 1, dst, dst_stride);
}
static void common_hz_2t_4x8_msa(uint8_t *RESTRICT src, int32_t src_stride,
uint8_t *RESTRICT dst, int32_t dst_stride,
const int8_t *filter) {
v16u8 vec0, vec1, vec2, vec3, filt0;
v16i8 src0, src1, src2, src3, src4, src5, src6, src7, mask;
v16i8 res0, res1, res2, res3;
v8u16 vec4, vec5, vec6, vec7, filt;
mask = LD_SB(&vp8_mc_filt_mask_arr[16]);
filt = LD_UH(filter);
filt0 = (v16u8)__msa_splati_h((v8i16)filt, 0);
LD_SB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7);
VSHF_B2_UB(src0, src1, src2, src3, mask, mask, vec0, vec1);
VSHF_B2_UB(src4, src5, src6, src7, mask, mask, vec2, vec3);
DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, vec4, vec5,
vec6, vec7);
SRARI_H4_UH(vec4, vec5, vec6, vec7, VP8_FILTER_SHIFT);
PCKEV_B4_SB(vec4, vec4, vec5, vec5, vec6, vec6, vec7, vec7, res0, res1, res2,
res3);
ST4x4_UB(res0, res1, 0, 1, 0, 1, dst, dst_stride);
dst += (4 * dst_stride);
ST4x4_UB(res2, res3, 0, 1, 0, 1, dst, dst_stride);
}
static void common_hz_2t_4w_msa(uint8_t *RESTRICT src, int32_t src_stride,
uint8_t *RESTRICT dst, int32_t dst_stride,
const int8_t *filter, int32_t height) {
if (4 == height) {
common_hz_2t_4x4_msa(src, src_stride, dst, dst_stride, filter);
} else if (8 == height) {
common_hz_2t_4x8_msa(src, src_stride, dst, dst_stride, filter);
}
}
static void common_hz_2t_8x4_msa(uint8_t *RESTRICT src, int32_t src_stride,
uint8_t *RESTRICT dst, int32_t dst_stride,
const int8_t *filter) {
v16u8 filt0;
v16i8 src0, src1, src2, src3, mask;
v8u16 vec0, vec1, vec2, vec3, filt;
mask = LD_SB(&vp8_mc_filt_mask_arr[0]);
filt = LD_UH(filter);
filt0 = (v16u8)__msa_splati_h((v8i16)filt, 0);
LD_SB4(src, src_stride, src0, src1, src2, src3);
VSHF_B2_UH(src0, src0, src1, src1, mask, mask, vec0, vec1);
VSHF_B2_UH(src2, src2, src3, src3, mask, mask, vec2, vec3);
DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, vec0, vec1,
vec2, vec3);
SRARI_H4_UH(vec0, vec1, vec2, vec3, VP8_FILTER_SHIFT);
PCKEV_B2_SB(vec1, vec0, vec3, vec2, src0, src1);
ST8x4_UB(src0, src1, dst, dst_stride);
}
static void common_hz_2t_8x8mult_msa(uint8_t *RESTRICT src, int32_t src_stride,
uint8_t *RESTRICT dst, int32_t dst_stride,
const int8_t *filter, int32_t height) {
v16u8 filt0;
v16i8 src0, src1, src2, src3, mask, out0, out1;
v8u16 vec0, vec1, vec2, vec3, filt;
mask = LD_SB(&vp8_mc_filt_mask_arr[0]);
filt = LD_UH(filter);
filt0 = (v16u8)__msa_splati_h((v8i16)filt, 0);
LD_SB4(src, src_stride, src0, src1, src2, src3);
src += (4 * src_stride);
VSHF_B2_UH(src0, src0, src1, src1, mask, mask, vec0, vec1);
VSHF_B2_UH(src2, src2, src3, src3, mask, mask, vec2, vec3);
DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, vec0, vec1,
vec2, vec3);
SRARI_H4_UH(vec0, vec1, vec2, vec3, VP8_FILTER_SHIFT);
LD_SB4(src, src_stride, src0, src1, src2, src3);
src += (4 * src_stride);
PCKEV_B2_SB(vec1, vec0, vec3, vec2, out0, out1);
ST8x4_UB(out0, out1, dst, dst_stride);
dst += (4 * dst_stride);
VSHF_B2_UH(src0, src0, src1, src1, mask, mask, vec0, vec1);
VSHF_B2_UH(src2, src2, src3, src3, mask, mask, vec2, vec3);
DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, vec0, vec1,
vec2, vec3);
SRARI_H4_UH(vec0, vec1, vec2, vec3, VP8_FILTER_SHIFT);
PCKEV_B2_SB(vec1, vec0, vec3, vec2, out0, out1);
ST8x4_UB(out0, out1, dst, dst_stride);
dst += (4 * dst_stride);
if (16 == height) {
LD_SB4(src, src_stride, src0, src1, src2, src3);
src += (4 * src_stride);
VSHF_B2_UH(src0, src0, src1, src1, mask, mask, vec0, vec1);
VSHF_B2_UH(src2, src2, src3, src3, mask, mask, vec2, vec3);
DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, vec0, vec1,
vec2, vec3);
SRARI_H4_UH(vec0, vec1, vec2, vec3, VP8_FILTER_SHIFT);
LD_SB4(src, src_stride, src0, src1, src2, src3);
src += (4 * src_stride);
PCKEV_B2_SB(vec1, vec0, vec3, vec2, out0, out1);
ST8x4_UB(out0, out1, dst, dst_stride);
VSHF_B2_UH(src0, src0, src1, src1, mask, mask, vec0, vec1);
VSHF_B2_UH(src2, src2, src3, src3, mask, mask, vec2, vec3);
DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, vec0, vec1,
vec2, vec3);
SRARI_H4_UH(vec0, vec1, vec2, vec3, VP8_FILTER_SHIFT);
PCKEV_B2_SB(vec1, vec0, vec3, vec2, out0, out1);
ST8x4_UB(out0, out1, dst + 4 * dst_stride, dst_stride);
}
}
static void common_hz_2t_8w_msa(uint8_t *RESTRICT src, int32_t src_stride,
uint8_t *RESTRICT dst, int32_t dst_stride,
const int8_t *filter, int32_t height) {
if (4 == height) {
common_hz_2t_8x4_msa(src, src_stride, dst, dst_stride, filter);
} else {
common_hz_2t_8x8mult_msa(src, src_stride, dst, dst_stride, filter, height);
}
}
static void common_hz_2t_16w_msa(uint8_t *RESTRICT src, int32_t src_stride,
uint8_t *RESTRICT dst, int32_t dst_stride,
const int8_t *filter, int32_t height) {
uint32_t loop_cnt;
v16i8 src0, src1, src2, src3, src4, src5, src6, src7, mask;
v16u8 filt0, vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7;
v8u16 out0, out1, out2, out3, out4, out5, out6, out7, filt;
mask = LD_SB(&vp8_mc_filt_mask_arr[0]);
loop_cnt = (height >> 2) - 1;
filt = LD_UH(filter);
filt0 = (v16u8)__msa_splati_h((v8i16)filt, 0);
LD_SB4(src, src_stride, src0, src2, src4, src6);
LD_SB4(src + 8, src_stride, src1, src3, src5, src7);
src += (4 * src_stride);
VSHF_B2_UB(src0, src0, src1, src1, mask, mask, vec0, vec1);
VSHF_B2_UB(src2, src2, src3, src3, mask, mask, vec2, vec3);
VSHF_B2_UB(src4, src4, src5, src5, mask, mask, vec4, vec5);
VSHF_B2_UB(src6, src6, src7, src7, mask, mask, vec6, vec7);
DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, out0, out1,
out2, out3);
DOTP_UB4_UH(vec4, vec5, vec6, vec7, filt0, filt0, filt0, filt0, out4, out5,
out6, out7);
SRARI_H4_UH(out0, out1, out2, out3, VP8_FILTER_SHIFT);
SRARI_H4_UH(out4, out5, out6, out7, VP8_FILTER_SHIFT);
PCKEV_ST_SB(out0, out1, dst);
dst += dst_stride;
PCKEV_ST_SB(out2, out3, dst);
dst += dst_stride;
PCKEV_ST_SB(out4, out5, dst);
dst += dst_stride;
PCKEV_ST_SB(out6, out7, dst);
dst += dst_stride;
for (; 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);
VSHF_B2_UB(src0, src0, src1, src1, mask, mask, vec0, vec1);
VSHF_B2_UB(src2, src2, src3, src3, mask, mask, vec2, vec3);
VSHF_B2_UB(src4, src4, src5, src5, mask, mask, vec4, vec5);
VSHF_B2_UB(src6, src6, src7, src7, mask, mask, vec6, vec7);
DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, out0, out1,
out2, out3);
DOTP_UB4_UH(vec4, vec5, vec6, vec7, filt0, filt0, filt0, filt0, out4, out5,
out6, out7);
SRARI_H4_UH(out0, out1, out2, out3, VP8_FILTER_SHIFT);
SRARI_H4_UH(out4, out5, out6, out7, VP8_FILTER_SHIFT);
PCKEV_ST_SB(out0, out1, dst);
dst += dst_stride;
PCKEV_ST_SB(out2, out3, dst);
dst += dst_stride;
PCKEV_ST_SB(out4, out5, dst);
dst += dst_stride;
PCKEV_ST_SB(out6, out7, dst);
dst += dst_stride;
}
}
static void common_vt_2t_4x4_msa(uint8_t *RESTRICT src, int32_t src_stride,
uint8_t *RESTRICT dst, int32_t dst_stride,
const int8_t *filter) {
v16i8 src0, src1, src2, src3, src4;
v16i8 src10_r, src32_r, src21_r, src43_r, src2110, src4332;
v16u8 filt0;
v8i16 filt;
v8u16 tmp0, tmp1;
filt = LD_SH(filter);
filt0 = (v16u8)__msa_splati_h(filt, 0);
LD_SB5(src, src_stride, src0, src1, src2, src3, src4);
src += (5 * src_stride);
ILVR_B4_SB(src1, src0, src2, src1, src3, src2, src4, src3, src10_r, src21_r,
src32_r, src43_r);
ILVR_D2_SB(src21_r, src10_r, src43_r, src32_r, src2110, src4332);
DOTP_UB2_UH(src2110, src4332, filt0, filt0, tmp0, tmp1);
SRARI_H2_UH(tmp0, tmp1, VP8_FILTER_SHIFT);
src2110 = __msa_pckev_b((v16i8)tmp1, (v16i8)tmp0);
ST4x4_UB(src2110, src2110, 0, 1, 2, 3, dst, dst_stride);
}
static void common_vt_2t_4x8_msa(uint8_t *RESTRICT src, int32_t src_stride,
uint8_t *RESTRICT dst, int32_t dst_stride,
const int8_t *filter) {
v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8;
v16i8 src10_r, src32_r, src54_r, src76_r, src21_r, src43_r;
v16i8 src65_r, src87_r, src2110, src4332, src6554, src8776;
v8u16 tmp0, tmp1, tmp2, tmp3;
v16u8 filt0;
v8i16 filt;
filt = LD_SH(filter);
filt0 = (v16u8)__msa_splati_h(filt, 0);
LD_SB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7);
src += (8 * src_stride);
src8 = LD_SB(src);
src += src_stride;
ILVR_B4_SB(src1, src0, src2, src1, src3, src2, src4, src3, src10_r, src21_r,
src32_r, src43_r);
ILVR_B4_SB(src5, src4, src6, src5, src7, src6, src8, src7, src54_r, src65_r,
src76_r, src87_r);
ILVR_D4_SB(src21_r, src10_r, src43_r, src32_r, src65_r, src54_r, src87_r,
src76_r, src2110, src4332, src6554, src8776);
DOTP_UB4_UH(src2110, src4332, src6554, src8776, filt0, filt0, filt0, filt0,
tmp0, tmp1, tmp2, tmp3);
SRARI_H4_UH(tmp0, tmp1, tmp2, tmp3, VP8_FILTER_SHIFT);
PCKEV_B2_SB(tmp1, tmp0, tmp3, tmp2, src2110, src4332);
ST4x4_UB(src2110, src2110, 0, 1, 2, 3, dst, dst_stride);
ST4x4_UB(src4332, src4332, 0, 1, 2, 3, dst + 4 * dst_stride, dst_stride);
}
static void common_vt_2t_4w_msa(uint8_t *RESTRICT src, int32_t src_stride,
uint8_t *RESTRICT dst, int32_t dst_stride,
const int8_t *filter, int32_t height) {
if (4 == height) {
common_vt_2t_4x4_msa(src, src_stride, dst, dst_stride, filter);
} else if (8 == height) {
common_vt_2t_4x8_msa(src, src_stride, dst, dst_stride, filter);
}
}
static void common_vt_2t_8x4_msa(uint8_t *RESTRICT src, int32_t src_stride,
uint8_t *RESTRICT dst, int32_t dst_stride,
const int8_t *filter) {
v16u8 src0, src1, src2, src3, src4, vec0, vec1, vec2, vec3, filt0;
v16i8 out0, out1;
v8u16 tmp0, tmp1, tmp2, tmp3;
v8i16 filt;
filt = LD_SH(filter);
filt0 = (v16u8)__msa_splati_h(filt, 0);
LD_UB5(src, src_stride, src0, src1, src2, src3, src4);
ILVR_B2_UB(src1, src0, src2, src1, vec0, vec1);
ILVR_B2_UB(src3, src2, src4, src3, vec2, vec3);
DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, tmp0, tmp1,
tmp2, tmp3);
SRARI_H4_UH(tmp0, tmp1, tmp2, tmp3, VP8_FILTER_SHIFT);
PCKEV_B2_SB(tmp1, tmp0, tmp3, tmp2, out0, out1);
ST8x4_UB(out0, out1, dst, dst_stride);
}
static void common_vt_2t_8x8mult_msa(uint8_t *RESTRICT src, int32_t src_stride,
uint8_t *RESTRICT dst, int32_t dst_stride,
const int8_t *filter, int32_t height) {
uint32_t loop_cnt;
v16u8 src0, src1, src2, src3, src4, src5, src6, src7, src8;
v16u8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7, filt0;
v16i8 out0, out1;
v8u16 tmp0, tmp1, tmp2, tmp3;
v8i16 filt;
filt = LD_SH(filter);
filt0 = (v16u8)__msa_splati_h(filt, 0);
src0 = LD_UB(src);
src += src_stride;
for (loop_cnt = (height >> 3); loop_cnt--;) {
LD_UB8(src, src_stride, src1, src2, src3, src4, src5, src6, src7, src8);
src += (8 * src_stride);
ILVR_B4_UB(src1, src0, src2, src1, src3, src2, src4, src3, vec0, vec1, vec2,
vec3);
ILVR_B4_UB(src5, src4, src6, src5, src7, src6, src8, src7, vec4, vec5, vec6,
vec7);
DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, tmp0, tmp1,
tmp2, tmp3);
SRARI_H4_UH(tmp0, tmp1, tmp2, tmp3, VP8_FILTER_SHIFT);
PCKEV_B2_SB(tmp1, tmp0, tmp3, tmp2, out0, out1);
ST8x4_UB(out0, out1, dst, dst_stride);
dst += (4 * dst_stride);
DOTP_UB4_UH(vec4, vec5, vec6, vec7, filt0, filt0, filt0, filt0, tmp0, tmp1,
tmp2, tmp3);
SRARI_H4_UH(tmp0, tmp1, tmp2, tmp3, VP8_FILTER_SHIFT);
PCKEV_B2_SB(tmp1, tmp0, tmp3, tmp2, out0, out1);
ST8x4_UB(out0, out1, dst, dst_stride);
dst += (4 * dst_stride);
src0 = src8;
}
}
static void common_vt_2t_8w_msa(uint8_t *RESTRICT src, int32_t src_stride,
uint8_t *RESTRICT dst, int32_t dst_stride,
const int8_t *filter, int32_t height) {
if (4 == height) {
common_vt_2t_8x4_msa(src, src_stride, dst, dst_stride, filter);
} else {
common_vt_2t_8x8mult_msa(src, src_stride, dst, dst_stride, filter, height);
}
}
static void common_vt_2t_16w_msa(uint8_t *RESTRICT src, int32_t src_stride,
uint8_t *RESTRICT dst, int32_t dst_stride,
const int8_t *filter, int32_t height) {
uint32_t loop_cnt;
v16u8 src0, src1, src2, src3, src4;
v16u8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7, filt0;
v8u16 tmp0, tmp1, tmp2, tmp3;
v8i16 filt;
filt = LD_SH(filter);
filt0 = (v16u8)__msa_splati_h(filt, 0);
src0 = LD_UB(src);
src += src_stride;
for (loop_cnt = (height >> 2); loop_cnt--;) {
LD_UB4(src, src_stride, src1, src2, src3, src4);
src += (4 * src_stride);
ILVR_B2_UB(src1, src0, src2, src1, vec0, vec2);
ILVL_B2_UB(src1, src0, src2, src1, vec1, vec3);
DOTP_UB2_UH(vec0, vec1, filt0, filt0, tmp0, tmp1);
SRARI_H2_UH(tmp0, tmp1, VP8_FILTER_SHIFT);
PCKEV_ST_SB(tmp0, tmp1, dst);
dst += dst_stride;
ILVR_B2_UB(src3, src2, src4, src3, vec4, vec6);
ILVL_B2_UB(src3, src2, src4, src3, vec5, vec7);
DOTP_UB2_UH(vec2, vec3, filt0, filt0, tmp2, tmp3);
SRARI_H2_UH(tmp2, tmp3, VP8_FILTER_SHIFT);
PCKEV_ST_SB(tmp2, tmp3, dst);
dst += dst_stride;
DOTP_UB2_UH(vec4, vec5, filt0, filt0, tmp0, tmp1);
SRARI_H2_UH(tmp0, tmp1, VP8_FILTER_SHIFT);
PCKEV_ST_SB(tmp0, tmp1, dst);
dst += dst_stride;
DOTP_UB2_UH(vec6, vec7, filt0, filt0, tmp2, tmp3);
SRARI_H2_UH(tmp2, tmp3, VP8_FILTER_SHIFT);
PCKEV_ST_SB(tmp2, tmp3, dst);
dst += dst_stride;
src0 = src4;
}
}
static void common_hv_2ht_2vt_4x4_msa(uint8_t *RESTRICT src, int32_t src_stride,
uint8_t *RESTRICT dst, int32_t dst_stride,
const int8_t *filter_horiz,
const int8_t *filter_vert) {
v16i8 src0, src1, src2, src3, src4, mask;
v16u8 filt_vt, filt_hz, vec0, vec1, res0, res1;
v8u16 hz_out0, hz_out1, hz_out2, hz_out3, hz_out4, filt, tmp0, tmp1;
mask = LD_SB(&vp8_mc_filt_mask_arr[16]);
filt = LD_UH(filter_horiz);
filt_hz = (v16u8)__msa_splati_h((v8i16)filt, 0);
filt = LD_UH(filter_vert);
filt_vt = (v16u8)__msa_splati_h((v8i16)filt, 0);
LD_SB5(src, src_stride, src0, src1, src2, src3, src4);
hz_out0 = HORIZ_2TAP_FILT_UH(src0, src1, mask, filt_hz, VP8_FILTER_SHIFT);
hz_out2 = HORIZ_2TAP_FILT_UH(src2, src3, mask, filt_hz, VP8_FILTER_SHIFT);
hz_out4 = HORIZ_2TAP_FILT_UH(src4, src4, mask, filt_hz, VP8_FILTER_SHIFT);
hz_out1 = (v8u16)__msa_sldi_b((v16i8)hz_out2, (v16i8)hz_out0, 8);
hz_out3 = (v8u16)__msa_pckod_d((v2i64)hz_out4, (v2i64)hz_out2);
ILVEV_B2_UB(hz_out0, hz_out1, hz_out2, hz_out3, vec0, vec1);
DOTP_UB2_UH(vec0, vec1, filt_vt, filt_vt, tmp0, tmp1);
SRARI_H2_UH(tmp0, tmp1, VP8_FILTER_SHIFT);
PCKEV_B2_UB(tmp0, tmp0, tmp1, tmp1, res0, res1);
ST4x4_UB(res0, res1, 0, 1, 0, 1, dst, dst_stride);
}
static void common_hv_2ht_2vt_4x8_msa(uint8_t *RESTRICT src, int32_t src_stride,
uint8_t *RESTRICT dst, int32_t dst_stride,
const int8_t *filter_horiz,
const int8_t *filter_vert) {
v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8, mask;
v16i8 res0, res1, res2, res3;
v16u8 filt_hz, filt_vt, vec0, vec1, vec2, vec3;
v8u16 hz_out0, hz_out1, hz_out2, hz_out3, hz_out4, hz_out5, hz_out6;
v8u16 hz_out7, hz_out8, vec4, vec5, vec6, vec7, filt;
mask = LD_SB(&vp8_mc_filt_mask_arr[16]);
filt = LD_UH(filter_horiz);
filt_hz = (v16u8)__msa_splati_h((v8i16)filt, 0);
filt = LD_UH(filter_vert);
filt_vt = (v16u8)__msa_splati_h((v8i16)filt, 0);
LD_SB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7);
src += (8 * src_stride);
src8 = LD_SB(src);
hz_out0 = HORIZ_2TAP_FILT_UH(src0, src1, mask, filt_hz, VP8_FILTER_SHIFT);
hz_out2 = HORIZ_2TAP_FILT_UH(src2, src3, mask, filt_hz, VP8_FILTER_SHIFT);
hz_out4 = HORIZ_2TAP_FILT_UH(src4, src5, mask, filt_hz, VP8_FILTER_SHIFT);
hz_out6 = HORIZ_2TAP_FILT_UH(src6, src7, mask, filt_hz, VP8_FILTER_SHIFT);
hz_out8 = HORIZ_2TAP_FILT_UH(src8, src8, mask, filt_hz, VP8_FILTER_SHIFT);
SLDI_B3_UH(hz_out2, hz_out4, hz_out6, hz_out0, hz_out2, hz_out4, hz_out1,
hz_out3, hz_out5, 8);
hz_out7 = (v8u16)__msa_pckod_d((v2i64)hz_out8, (v2i64)hz_out6);
ILVEV_B2_UB(hz_out0, hz_out1, hz_out2, hz_out3, vec0, vec1);
ILVEV_B2_UB(hz_out4, hz_out5, hz_out6, hz_out7, vec2, vec3);
DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt_vt, filt_vt, filt_vt, filt_vt, vec4,
vec5, vec6, vec7);
SRARI_H4_UH(vec4, vec5, vec6, vec7, VP8_FILTER_SHIFT);
PCKEV_B4_SB(vec4, vec4, vec5, vec5, vec6, vec6, vec7, vec7, res0, res1, res2,
res3);
ST4x4_UB(res0, res1, 0, 1, 0, 1, dst, dst_stride);
dst += (4 * dst_stride);
ST4x4_UB(res2, res3, 0, 1, 0, 1, dst, dst_stride);
}
static void common_hv_2ht_2vt_4w_msa(uint8_t *RESTRICT src, int32_t src_stride,
uint8_t *RESTRICT dst, int32_t dst_stride,
const int8_t *filter_horiz,
const int8_t *filter_vert,
int32_t height) {
if (4 == height) {
common_hv_2ht_2vt_4x4_msa(src, src_stride, dst, dst_stride, filter_horiz,
filter_vert);
} else if (8 == height) {
common_hv_2ht_2vt_4x8_msa(src, src_stride, dst, dst_stride, filter_horiz,
filter_vert);
}
}
static void common_hv_2ht_2vt_8x4_msa(uint8_t *RESTRICT src, int32_t src_stride,
uint8_t *RESTRICT dst, int32_t dst_stride,
const int8_t *filter_horiz,
const int8_t *filter_vert) {
v16i8 src0, src1, src2, src3, src4, mask, out0, out1;
v16u8 filt_hz, filt_vt, vec0, vec1, vec2, vec3;
v8u16 hz_out0, hz_out1, tmp0, tmp1, tmp2, tmp3;
v8i16 filt;
mask = LD_SB(&vp8_mc_filt_mask_arr[0]);
filt = LD_SH(filter_horiz);
filt_hz = (v16u8)__msa_splati_h(filt, 0);
filt = LD_SH(filter_vert);
filt_vt = (v16u8)__msa_splati_h(filt, 0);
LD_SB5(src, src_stride, src0, src1, src2, src3, src4);
hz_out0 = HORIZ_2TAP_FILT_UH(src0, src0, mask, filt_hz, VP8_FILTER_SHIFT);
hz_out1 = HORIZ_2TAP_FILT_UH(src1, src1, mask, filt_hz, VP8_FILTER_SHIFT);
vec0 = (v16u8)__msa_ilvev_b((v16i8)hz_out1, (v16i8)hz_out0);
tmp0 = __msa_dotp_u_h(vec0, filt_vt);
hz_out0 = HORIZ_2TAP_FILT_UH(src2, src2, mask, filt_hz, VP8_FILTER_SHIFT);
vec1 = (v16u8)__msa_ilvev_b((v16i8)hz_out0, (v16i8)hz_out1);
tmp1 = __msa_dotp_u_h(vec1, filt_vt);
hz_out1 = HORIZ_2TAP_FILT_UH(src3, src3, mask, filt_hz, VP8_FILTER_SHIFT);
vec2 = (v16u8)__msa_ilvev_b((v16i8)hz_out1, (v16i8)hz_out0);
tmp2 = __msa_dotp_u_h(vec2, filt_vt);
hz_out0 = HORIZ_2TAP_FILT_UH(src4, src4, mask, filt_hz, VP8_FILTER_SHIFT);
vec3 = (v16u8)__msa_ilvev_b((v16i8)hz_out0, (v16i8)hz_out1);
tmp3 = __msa_dotp_u_h(vec3, filt_vt);
SRARI_H4_UH(tmp0, tmp1, tmp2, tmp3, VP8_FILTER_SHIFT);
PCKEV_B2_SB(tmp1, tmp0, tmp3, tmp2, out0, out1);
ST8x4_UB(out0, out1, dst, dst_stride);
}
static void common_hv_2ht_2vt_8x8mult_msa(
uint8_t *RESTRICT src, int32_t src_stride, uint8_t *RESTRICT dst,
int32_t dst_stride, const int8_t *filter_horiz, const int8_t *filter_vert,
int32_t height) {
uint32_t loop_cnt;
v16i8 src0, src1, src2, src3, src4, mask, out0, out1;
v16u8 filt_hz, filt_vt, vec0;
v8u16 hz_out0, hz_out1, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8;
v8i16 filt;
mask = LD_SB(&vp8_mc_filt_mask_arr[0]);
filt = LD_SH(filter_horiz);
filt_hz = (v16u8)__msa_splati_h(filt, 0);
filt = LD_SH(filter_vert);
filt_vt = (v16u8)__msa_splati_h(filt, 0);
src0 = LD_SB(src);
src += src_stride;
hz_out0 = HORIZ_2TAP_FILT_UH(src0, src0, mask, filt_hz, VP8_FILTER_SHIFT);
for (loop_cnt = (height >> 3); loop_cnt--;) {
LD_SB4(src, src_stride, src1, src2, src3, src4);
src += (4 * src_stride);
hz_out1 = HORIZ_2TAP_FILT_UH(src1, src1, mask, filt_hz, VP8_FILTER_SHIFT);
vec0 = (v16u8)__msa_ilvev_b((v16i8)hz_out1, (v16i8)hz_out0);
tmp1 = __msa_dotp_u_h(vec0, filt_vt);
hz_out0 = HORIZ_2TAP_FILT_UH(src2, src2, mask, filt_hz, VP8_FILTER_SHIFT);
vec0 = (v16u8)__msa_ilvev_b((v16i8)hz_out0, (v16i8)hz_out1);
tmp2 = __msa_dotp_u_h(vec0, filt_vt);
SRARI_H2_UH(tmp1, tmp2, VP8_FILTER_SHIFT);
hz_out1 = HORIZ_2TAP_FILT_UH(src3, src3, mask, filt_hz, VP8_FILTER_SHIFT);
vec0 = (v16u8)__msa_ilvev_b((v16i8)hz_out1, (v16i8)hz_out0);
tmp3 = __msa_dotp_u_h(vec0, filt_vt);
hz_out0 = HORIZ_2TAP_FILT_UH(src4, src4, mask, filt_hz, VP8_FILTER_SHIFT);
LD_SB4(src, src_stride, src1, src2, src3, src4);
src += (4 * src_stride);
vec0 = (v16u8)__msa_ilvev_b((v16i8)hz_out0, (v16i8)hz_out1);
tmp4 = __msa_dotp_u_h(vec0, filt_vt);
SRARI_H2_UH(tmp3, tmp4, VP8_FILTER_SHIFT);
PCKEV_B2_SB(tmp2, tmp1, tmp4, tmp3, out0, out1);
ST8x4_UB(out0, out1, dst, dst_stride);
dst += (4 * dst_stride);
hz_out1 = HORIZ_2TAP_FILT_UH(src1, src1, mask, filt_hz, VP8_FILTER_SHIFT);
vec0 = (v16u8)__msa_ilvev_b((v16i8)hz_out1, (v16i8)hz_out0);
tmp5 = __msa_dotp_u_h(vec0, filt_vt);
hz_out0 = HORIZ_2TAP_FILT_UH(src2, src2, mask, filt_hz, VP8_FILTER_SHIFT);
vec0 = (v16u8)__msa_ilvev_b((v16i8)hz_out0, (v16i8)hz_out1);
tmp6 = __msa_dotp_u_h(vec0, filt_vt);
hz_out1 = HORIZ_2TAP_FILT_UH(src3, src3, mask, filt_hz, VP8_FILTER_SHIFT);
vec0 = (v16u8)__msa_ilvev_b((v16i8)hz_out1, (v16i8)hz_out0);
tmp7 = __msa_dotp_u_h(vec0, filt_vt);
hz_out0 = HORIZ_2TAP_FILT_UH(src4, src4, mask, filt_hz, VP8_FILTER_SHIFT);
vec0 = (v16u8)__msa_ilvev_b((v16i8)hz_out0, (v16i8)hz_out1);
tmp8 = __msa_dotp_u_h(vec0, filt_vt);
SRARI_H4_UH(tmp5, tmp6, tmp7, tmp8, VP8_FILTER_SHIFT);
PCKEV_B2_SB(tmp6, tmp5, tmp8, tmp7, out0, out1);
ST8x4_UB(out0, out1, dst, dst_stride);
dst += (4 * dst_stride);
}
}
static void common_hv_2ht_2vt_8w_msa(uint8_t *RESTRICT src, int32_t src_stride,
uint8_t *RESTRICT dst, int32_t dst_stride,
const int8_t *filter_horiz,
const int8_t *filter_vert,
int32_t height) {
if (4 == height) {
common_hv_2ht_2vt_8x4_msa(src, src_stride, dst, dst_stride, filter_horiz,
filter_vert);
} else {
common_hv_2ht_2vt_8x8mult_msa(src, src_stride, dst, dst_stride,
filter_horiz, filter_vert, height);
}
}
static void common_hv_2ht_2vt_16w_msa(uint8_t *RESTRICT src, int32_t src_stride,
uint8_t *RESTRICT dst, int32_t dst_stride,
const int8_t *filter_horiz,
const int8_t *filter_vert,
int32_t height) {
uint32_t loop_cnt;
v16i8 src0, src1, src2, src3, src4, src5, src6, src7, mask;
v16u8 filt_hz, filt_vt, vec0, vec1;
v8u16 tmp1, tmp2, hz_out0, hz_out1, hz_out2, hz_out3;
v8i16 filt;
mask = LD_SB(&vp8_mc_filt_mask_arr[0]);
/* rearranging filter */
filt = LD_SH(filter_horiz);
filt_hz = (v16u8)__msa_splati_h(filt, 0);
filt = LD_SH(filter_vert);
filt_vt = (v16u8)__msa_splati_h(filt, 0);
LD_SB2(src, 8, src0, src1);
src += src_stride;
hz_out0 = HORIZ_2TAP_FILT_UH(src0, src0, mask, filt_hz, VP8_FILTER_SHIFT);
hz_out2 = HORIZ_2TAP_FILT_UH(src1, src1, mask, filt_hz, VP8_FILTER_SHIFT);
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);
hz_out1 = HORIZ_2TAP_FILT_UH(src0, src0, mask, filt_hz, VP8_FILTER_SHIFT);
hz_out3 = HORIZ_2TAP_FILT_UH(src1, src1, mask, filt_hz, VP8_FILTER_SHIFT);
ILVEV_B2_UB(hz_out0, hz_out1, hz_out2, hz_out3, vec0, vec1);
DOTP_UB2_UH(vec0, vec1, filt_vt, filt_vt, tmp1, tmp2);
SRARI_H2_UH(tmp1, tmp2, VP8_FILTER_SHIFT);
PCKEV_ST_SB(tmp1, tmp2, dst);
dst += dst_stride;
hz_out0 = HORIZ_2TAP_FILT_UH(src2, src2, mask, filt_hz, VP8_FILTER_SHIFT);
hz_out2 = HORIZ_2TAP_FILT_UH(src3, src3, mask, filt_hz, VP8_FILTER_SHIFT);
ILVEV_B2_UB(hz_out1, hz_out0, hz_out3, hz_out2, vec0, vec1);
DOTP_UB2_UH(vec0, vec1, filt_vt, filt_vt, tmp1, tmp2);
SRARI_H2_UH(tmp1, tmp2, VP8_FILTER_SHIFT);
PCKEV_ST_SB(tmp1, tmp2, dst);
dst += dst_stride;
hz_out1 = HORIZ_2TAP_FILT_UH(src4, src4, mask, filt_hz, VP8_FILTER_SHIFT);
hz_out3 = HORIZ_2TAP_FILT_UH(src5, src5, mask, filt_hz, VP8_FILTER_SHIFT);
ILVEV_B2_UB(hz_out0, hz_out1, hz_out2, hz_out3, vec0, vec1);
DOTP_UB2_UH(vec0, vec1, filt_vt, filt_vt, tmp1, tmp2);
SRARI_H2_UH(tmp1, tmp2, VP8_FILTER_SHIFT);
PCKEV_ST_SB(tmp1, tmp2, dst);
dst += dst_stride;
hz_out0 = HORIZ_2TAP_FILT_UH(src6, src6, mask, filt_hz, VP8_FILTER_SHIFT);
hz_out2 = HORIZ_2TAP_FILT_UH(src7, src7, mask, filt_hz, VP8_FILTER_SHIFT);
ILVEV_B2_UB(hz_out1, hz_out0, hz_out3, hz_out2, vec0, vec1);
DOTP_UB2_UH(vec0, vec1, filt_vt, filt_vt, tmp1, tmp2);
SRARI_H2_UH(tmp1, tmp2, VP8_FILTER_SHIFT);
PCKEV_ST_SB(tmp1, tmp2, dst);
dst += dst_stride;
}
}
void vp8_bilinear_predict4x4_msa(uint8_t *RESTRICT src, int32_t src_stride,
int32_t xoffset, int32_t yoffset,
uint8_t *RESTRICT dst, int32_t dst_stride) {
const int8_t *h_filter = vp8_bilinear_filters_msa[xoffset - 1];
const int8_t *v_filter = vp8_bilinear_filters_msa[yoffset - 1];
if (yoffset) {
if (xoffset) {
common_hv_2ht_2vt_4w_msa(src, src_stride, dst, dst_stride, h_filter,
v_filter, 4);
} else {
common_vt_2t_4w_msa(src, src_stride, dst, dst_stride, v_filter, 4);
}
} else {
if (xoffset) {
common_hz_2t_4w_msa(src, src_stride, dst, dst_stride, h_filter, 4);
} else {
uint32_t tp0, tp1, tp2, tp3;
LW4(src, src_stride, tp0, tp1, tp2, tp3);
SW4(tp0, tp1, tp2, tp3, dst, dst_stride);
}
}
}
void vp8_bilinear_predict8x4_msa(uint8_t *RESTRICT src, int32_t src_stride,
int32_t xoffset, int32_t yoffset,
uint8_t *RESTRICT dst, int32_t dst_stride) {
const int8_t *h_filter = vp8_bilinear_filters_msa[xoffset - 1];
const int8_t *v_filter = vp8_bilinear_filters_msa[yoffset - 1];
if (yoffset) {
if (xoffset) {
common_hv_2ht_2vt_8w_msa(src, src_stride, dst, dst_stride, h_filter,
v_filter, 4);
} else {
common_vt_2t_8w_msa(src, src_stride, dst, dst_stride, v_filter, 4);
}
} else {
if (xoffset) {
common_hz_2t_8w_msa(src, src_stride, dst, dst_stride, h_filter, 4);
} else {
vp8_copy_mem8x4(src, src_stride, dst, dst_stride);
}
}
}
void vp8_bilinear_predict8x8_msa(uint8_t *RESTRICT src, int32_t src_stride,
int32_t xoffset, int32_t yoffset,
uint8_t *RESTRICT dst, int32_t dst_stride) {
const int8_t *h_filter = vp8_bilinear_filters_msa[xoffset - 1];
const int8_t *v_filter = vp8_bilinear_filters_msa[yoffset - 1];
if (yoffset) {
if (xoffset) {
common_hv_2ht_2vt_8w_msa(src, src_stride, dst, dst_stride, h_filter,
v_filter, 8);
} else {
common_vt_2t_8w_msa(src, src_stride, dst, dst_stride, v_filter, 8);
}
} else {
if (xoffset) {
common_hz_2t_8w_msa(src, src_stride, dst, dst_stride, h_filter, 8);
} else {
vp8_copy_mem8x8(src, src_stride, dst, dst_stride);
}
}
}
void vp8_bilinear_predict16x16_msa(uint8_t *RESTRICT src, int32_t src_stride,
int32_t xoffset, int32_t yoffset,
uint8_t *RESTRICT dst, int32_t dst_stride) {
const int8_t *h_filter = vp8_bilinear_filters_msa[xoffset - 1];
const int8_t *v_filter = vp8_bilinear_filters_msa[yoffset - 1];
if (yoffset) {
if (xoffset) {
common_hv_2ht_2vt_16w_msa(src, src_stride, dst, dst_stride, h_filter,
v_filter, 16);
} else {
common_vt_2t_16w_msa(src, src_stride, dst, dst_stride, v_filter, 16);
}
} else {
if (xoffset) {
common_hz_2t_16w_msa(src, src_stride, dst, dst_stride, h_filter, 16);
} else {
vp8_copy_mem16x16(src, src_stride, dst, dst_stride);
}
}
}
@@ -0,0 +1,62 @@
/*
* 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 "./vp8_rtcd.h"
#include "vp8/common/mips/msa/vp8_macros_msa.h"
static void copy_8x4_msa(uint8_t *src, int32_t src_stride, uint8_t *dst,
int32_t dst_stride) {
uint64_t src0, src1, src2, src3;
LD4(src, src_stride, src0, src1, src2, src3);
SD4(src0, src1, src2, src3, dst, dst_stride);
}
static void copy_8x8_msa(uint8_t *src, int32_t src_stride, uint8_t *dst,
int32_t dst_stride) {
uint64_t src0, src1, src2, src3;
LD4(src, src_stride, src0, src1, src2, src3);
src += (4 * src_stride);
SD4(src0, src1, src2, src3, dst, dst_stride);
dst += (4 * dst_stride);
LD4(src, src_stride, src0, src1, src2, src3);
SD4(src0, src1, src2, src3, dst, dst_stride);
}
static void copy_16x16_msa(uint8_t *src, int32_t src_stride, uint8_t *dst,
int32_t dst_stride) {
v16u8 src0, src1, src2, src3, src4, src5, src6, src7;
v16u8 src8, src9, src10, src11, src12, src13, src14, src15;
LD_UB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7);
src += (8 * src_stride);
LD_UB8(src, src_stride, src8, src9, src10, src11, src12, src13, src14, src15);
ST_UB8(src0, src1, src2, src3, src4, src5, src6, src7, dst, dst_stride);
dst += (8 * dst_stride);
ST_UB8(src8, src9, src10, src11, src12, src13, src14, src15, dst, dst_stride);
}
void vp8_copy_mem16x16_msa(uint8_t *src, int32_t src_stride, uint8_t *dst,
int32_t dst_stride) {
copy_16x16_msa(src, src_stride, dst, dst_stride);
}
void vp8_copy_mem8x8_msa(uint8_t *src, int32_t src_stride, uint8_t *dst,
int32_t dst_stride) {
copy_8x8_msa(src, src_stride, dst, dst_stride);
}
void vp8_copy_mem8x4_msa(uint8_t *src, int32_t src_stride, uint8_t *dst,
int32_t dst_stride) {
copy_8x4_msa(src, src_stride, dst, dst_stride);
}
@@ -0,0 +1,406 @@
/*
* 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 "./vp8_rtcd.h"
#include "vp8/common/blockd.h"
#include "vp8/common/mips/msa/vp8_macros_msa.h"
static const int32_t cospi8sqrt2minus1 = 20091;
static const int32_t sinpi8sqrt2 = 35468;
#define TRANSPOSE_TWO_4x4_H(in0, in1, in2, in3, out0, out1, out2, out3) \
{ \
v8i16 s4_m, s5_m, s6_m, s7_m; \
\
TRANSPOSE8X4_SH_SH(in0, in1, in2, in3, s4_m, s5_m, s6_m, s7_m); \
ILVR_D2_SH(s6_m, s4_m, s7_m, s5_m, out0, out2); \
out1 = (v8i16)__msa_ilvl_d((v2i64)s6_m, (v2i64)s4_m); \
out3 = (v8i16)__msa_ilvl_d((v2i64)s7_m, (v2i64)s5_m); \
}
#define EXPAND_TO_H_MULTIPLY_SINPI8SQRT2_PCK_TO_W(in) \
({ \
v8i16 out_m; \
v8i16 zero_m = { 0 }; \
v4i32 tmp1_m, tmp2_m; \
v4i32 sinpi8_sqrt2_m = __msa_fill_w(sinpi8sqrt2); \
\
ILVRL_H2_SW(in, zero_m, tmp1_m, tmp2_m); \
tmp1_m >>= 16; \
tmp2_m >>= 16; \
tmp1_m = (tmp1_m * sinpi8_sqrt2_m) >> 16; \
tmp2_m = (tmp2_m * sinpi8_sqrt2_m) >> 16; \
out_m = __msa_pckev_h((v8i16)tmp2_m, (v8i16)tmp1_m); \
\
out_m; \
})
#define VP8_IDCT_1D_H(in0, in1, in2, in3, out0, out1, out2, out3) \
{ \
v8i16 a1_m, b1_m, c1_m, d1_m; \
v8i16 c_tmp1_m, c_tmp2_m, d_tmp1_m, d_tmp2_m; \
v8i16 const_cospi8sqrt2minus1_m; \
\
const_cospi8sqrt2minus1_m = __msa_fill_h(cospi8sqrt2minus1); \
a1_m = in0 + in2; \
b1_m = in0 - in2; \
c_tmp1_m = EXPAND_TO_H_MULTIPLY_SINPI8SQRT2_PCK_TO_W(in1); \
c_tmp2_m = __msa_mul_q_h(in3, const_cospi8sqrt2minus1_m); \
c_tmp2_m = c_tmp2_m >> 1; \
c_tmp2_m = in3 + c_tmp2_m; \
c1_m = c_tmp1_m - c_tmp2_m; \
d_tmp1_m = __msa_mul_q_h(in1, const_cospi8sqrt2minus1_m); \
d_tmp1_m = d_tmp1_m >> 1; \
d_tmp1_m = in1 + d_tmp1_m; \
d_tmp2_m = EXPAND_TO_H_MULTIPLY_SINPI8SQRT2_PCK_TO_W(in3); \
d1_m = d_tmp1_m + d_tmp2_m; \
BUTTERFLY_4(a1_m, b1_m, c1_m, d1_m, out0, out1, out2, out3); \
}
#define VP8_IDCT_1D_W(in0, in1, in2, in3, out0, out1, out2, out3) \
{ \
v4i32 a1_m, b1_m, c1_m, d1_m; \
v4i32 c_tmp1_m, c_tmp2_m, d_tmp1_m, d_tmp2_m; \
v4i32 const_cospi8sqrt2minus1_m, sinpi8_sqrt2_m; \
\
const_cospi8sqrt2minus1_m = __msa_fill_w(cospi8sqrt2minus1); \
sinpi8_sqrt2_m = __msa_fill_w(sinpi8sqrt2); \
a1_m = in0 + in2; \
b1_m = in0 - in2; \
c_tmp1_m = (in1 * sinpi8_sqrt2_m) >> 16; \
c_tmp2_m = in3 + ((in3 * const_cospi8sqrt2minus1_m) >> 16); \
c1_m = c_tmp1_m - c_tmp2_m; \
d_tmp1_m = in1 + ((in1 * const_cospi8sqrt2minus1_m) >> 16); \
d_tmp2_m = (in3 * sinpi8_sqrt2_m) >> 16; \
d1_m = d_tmp1_m + d_tmp2_m; \
BUTTERFLY_4(a1_m, b1_m, c1_m, d1_m, out0, out1, out2, out3); \
}
static void idct4x4_addblk_msa(int16_t *input, uint8_t *pred,
int32_t pred_stride, uint8_t *dest,
int32_t dest_stride) {
v8i16 input0, input1;
v4i32 in0, in1, in2, in3, hz0, hz1, hz2, hz3, vt0, vt1, vt2, vt3;
v4i32 res0, res1, res2, res3;
v16i8 zero = { 0 };
v16i8 pred0, pred1, pred2, pred3;
LD_SH2(input, 8, input0, input1);
UNPCK_SH_SW(input0, in0, in1);
UNPCK_SH_SW(input1, in2, in3);
VP8_IDCT_1D_W(in0, in1, in2, in3, hz0, hz1, hz2, hz3);
TRANSPOSE4x4_SW_SW(hz0, hz1, hz2, hz3, hz0, hz1, hz2, hz3);
VP8_IDCT_1D_W(hz0, hz1, hz2, hz3, vt0, vt1, vt2, vt3);
SRARI_W4_SW(vt0, vt1, vt2, vt3, 3);
TRANSPOSE4x4_SW_SW(vt0, vt1, vt2, vt3, vt0, vt1, vt2, vt3);
LD_SB4(pred, pred_stride, pred0, pred1, pred2, pred3);
ILVR_B4_SW(zero, pred0, zero, pred1, zero, pred2, zero, pred3, res0, res1,
res2, res3);
ILVR_H4_SW(zero, res0, zero, res1, zero, res2, zero, res3, res0, res1, res2,
res3);
ADD4(res0, vt0, res1, vt1, res2, vt2, res3, vt3, res0, res1, res2, res3);
res0 = CLIP_SW_0_255(res0);
res1 = CLIP_SW_0_255(res1);
res2 = CLIP_SW_0_255(res2);
res3 = CLIP_SW_0_255(res3);
PCKEV_B2_SW(res0, res1, res2, res3, vt0, vt1);
res0 = (v4i32)__msa_pckev_b((v16i8)vt0, (v16i8)vt1);
ST4x4_UB(res0, res0, 3, 2, 1, 0, dest, dest_stride);
}
static void idct4x4_addconst_msa(int16_t in_dc, uint8_t *pred,
int32_t pred_stride, uint8_t *dest,
int32_t dest_stride) {
v8i16 vec, res0, res1, res2, res3, dst0, dst1;
v16i8 zero = { 0 };
v16i8 pred0, pred1, pred2, pred3;
vec = __msa_fill_h(in_dc);
vec = __msa_srari_h(vec, 3);
LD_SB4(pred, pred_stride, pred0, pred1, pred2, pred3);
ILVR_B4_SH(zero, pred0, zero, pred1, zero, pred2, zero, pred3, res0, res1,
res2, res3);
ADD4(res0, vec, res1, vec, res2, vec, res3, vec, res0, res1, res2, res3);
CLIP_SH4_0_255(res0, res1, res2, res3);
PCKEV_B2_SH(res1, res0, res3, res2, dst0, dst1);
dst0 = (v8i16)__msa_pckev_w((v4i32)dst1, (v4i32)dst0);
ST4x4_UB(dst0, dst0, 0, 1, 2, 3, dest, dest_stride);
}
void vp8_short_inv_walsh4x4_msa(int16_t *input, int16_t *mb_dqcoeff) {
v8i16 input0, input1, tmp0, tmp1, tmp2, tmp3, out0, out1;
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 };
LD_SH2(input, 8, input0, input1);
input1 = (v8i16)__msa_sldi_b((v16i8)input1, (v16i8)input1, 8);
tmp0 = input0 + input1;
tmp1 = input0 - input1;
VSHF_H2_SH(tmp0, tmp1, tmp0, tmp1, mask0, mask1, tmp2, tmp3);
out0 = tmp2 + tmp3;
out1 = tmp2 - tmp3;
VSHF_H2_SH(out0, out1, out0, out1, mask2, mask3, input0, input1);
tmp0 = input0 + input1;
tmp1 = input0 - input1;
VSHF_H2_SH(tmp0, tmp1, tmp0, tmp1, mask0, mask1, tmp2, tmp3);
tmp0 = tmp2 + tmp3;
tmp1 = tmp2 - tmp3;
ADD2(tmp0, 3, tmp1, 3, out0, out1);
out0 >>= 3;
out1 >>= 3;
mb_dqcoeff[0] = __msa_copy_s_h(out0, 0);
mb_dqcoeff[16] = __msa_copy_s_h(out0, 4);
mb_dqcoeff[32] = __msa_copy_s_h(out1, 0);
mb_dqcoeff[48] = __msa_copy_s_h(out1, 4);
mb_dqcoeff[64] = __msa_copy_s_h(out0, 1);
mb_dqcoeff[80] = __msa_copy_s_h(out0, 5);
mb_dqcoeff[96] = __msa_copy_s_h(out1, 1);
mb_dqcoeff[112] = __msa_copy_s_h(out1, 5);
mb_dqcoeff[128] = __msa_copy_s_h(out0, 2);
mb_dqcoeff[144] = __msa_copy_s_h(out0, 6);
mb_dqcoeff[160] = __msa_copy_s_h(out1, 2);
mb_dqcoeff[176] = __msa_copy_s_h(out1, 6);
mb_dqcoeff[192] = __msa_copy_s_h(out0, 3);
mb_dqcoeff[208] = __msa_copy_s_h(out0, 7);
mb_dqcoeff[224] = __msa_copy_s_h(out1, 3);
mb_dqcoeff[240] = __msa_copy_s_h(out1, 7);
}
static void dequant_idct4x4_addblk_msa(int16_t *input, int16_t *dequant_input,
uint8_t *dest, int32_t dest_stride) {
v8i16 input0, input1, dequant_in0, dequant_in1, mul0, mul1;
v8i16 in0, in1, in2, in3, hz0_h, hz1_h, hz2_h, hz3_h;
v16u8 dest0, dest1, dest2, dest3;
v4i32 hz0_w, hz1_w, hz2_w, hz3_w, vt0, vt1, vt2, vt3, res0, res1, res2, res3;
v2i64 zero = { 0 };
LD_SH2(input, 8, input0, input1);
LD_SH2(dequant_input, 8, dequant_in0, dequant_in1);
MUL2(input0, dequant_in0, input1, dequant_in1, mul0, mul1);
PCKEV_D2_SH(zero, mul0, zero, mul1, in0, in2);
PCKOD_D2_SH(zero, mul0, zero, mul1, in1, in3);
VP8_IDCT_1D_H(in0, in1, in2, in3, hz0_h, hz1_h, hz2_h, hz3_h);
PCKEV_D2_SH(hz1_h, hz0_h, hz3_h, hz2_h, mul0, mul1);
UNPCK_SH_SW(mul0, hz0_w, hz1_w);
UNPCK_SH_SW(mul1, hz2_w, hz3_w);
TRANSPOSE4x4_SW_SW(hz0_w, hz1_w, hz2_w, hz3_w, hz0_w, hz1_w, hz2_w, hz3_w);
VP8_IDCT_1D_W(hz0_w, hz1_w, hz2_w, hz3_w, vt0, vt1, vt2, vt3);
SRARI_W4_SW(vt0, vt1, vt2, vt3, 3);
TRANSPOSE4x4_SW_SW(vt0, vt1, vt2, vt3, vt0, vt1, vt2, vt3);
LD_UB4(dest, dest_stride, dest0, dest1, dest2, dest3);
ILVR_B4_SW(zero, dest0, zero, dest1, zero, dest2, zero, dest3, res0, res1,
res2, res3);
ILVR_H4_SW(zero, res0, zero, res1, zero, res2, zero, res3, res0, res1, res2,
res3);
ADD4(res0, vt0, res1, vt1, res2, vt2, res3, vt3, res0, res1, res2, res3);
res0 = CLIP_SW_0_255(res0);
res1 = CLIP_SW_0_255(res1);
res2 = CLIP_SW_0_255(res2);
res3 = CLIP_SW_0_255(res3);
PCKEV_B2_SW(res0, res1, res2, res3, vt0, vt1);
res0 = (v4i32)__msa_pckev_b((v16i8)vt0, (v16i8)vt1);
ST4x4_UB(res0, res0, 3, 2, 1, 0, dest, dest_stride);
}
static void dequant_idct4x4_addblk_2x_msa(int16_t *input,
int16_t *dequant_input, uint8_t *dest,
int32_t dest_stride) {
v16u8 dest0, dest1, dest2, dest3;
v8i16 in0, in1, in2, in3, mul0, mul1, mul2, mul3, dequant_in0, dequant_in1;
v8i16 hz0, hz1, hz2, hz3, vt0, vt1, vt2, vt3, res0, res1, res2, res3;
v4i32 hz0l, hz1l, hz2l, hz3l, hz0r, hz1r, hz2r, hz3r;
v4i32 vt0l, vt1l, vt2l, vt3l, vt0r, vt1r, vt2r, vt3r;
v16i8 zero = { 0 };
LD_SH4(input, 8, in0, in1, in2, in3);
LD_SH2(dequant_input, 8, dequant_in0, dequant_in1);
MUL4(in0, dequant_in0, in1, dequant_in1, in2, dequant_in0, in3, dequant_in1,
mul0, mul1, mul2, mul3);
PCKEV_D2_SH(mul2, mul0, mul3, mul1, in0, in2);
PCKOD_D2_SH(mul2, mul0, mul3, mul1, in1, in3);
VP8_IDCT_1D_H(in0, in1, in2, in3, hz0, hz1, hz2, hz3);
TRANSPOSE_TWO_4x4_H(hz0, hz1, hz2, hz3, hz0, hz1, hz2, hz3);
UNPCK_SH_SW(hz0, hz0r, hz0l);
UNPCK_SH_SW(hz1, hz1r, hz1l);
UNPCK_SH_SW(hz2, hz2r, hz2l);
UNPCK_SH_SW(hz3, hz3r, hz3l);
VP8_IDCT_1D_W(hz0l, hz1l, hz2l, hz3l, vt0l, vt1l, vt2l, vt3l);
SRARI_W4_SW(vt0l, vt1l, vt2l, vt3l, 3);
VP8_IDCT_1D_W(hz0r, hz1r, hz2r, hz3r, vt0r, vt1r, vt2r, vt3r);
SRARI_W4_SW(vt0r, vt1r, vt2r, vt3r, 3);
PCKEV_H4_SH(vt0l, vt0r, vt1l, vt1r, vt2l, vt2r, vt3l, vt3r, vt0, vt1, vt2,
vt3);
TRANSPOSE_TWO_4x4_H(vt0, vt1, vt2, vt3, vt0, vt1, vt2, vt3);
LD_UB4(dest, dest_stride, dest0, dest1, dest2, dest3);
ILVR_B4_SH(zero, dest0, zero, dest1, zero, dest2, zero, dest3, res0, res1,
res2, res3);
ADD4(res0, vt0, res1, vt1, res2, vt2, res3, vt3, res0, res1, res2, res3);
CLIP_SH4_0_255(res0, res1, res2, res3);
PCKEV_B2_SW(res1, res0, res3, res2, vt0l, vt1l);
ST8x4_UB(vt0l, vt1l, dest, dest_stride);
__asm__ __volatile__(
"sw $zero, 0(%[input]) \n\t"
"sw $zero, 4(%[input]) \n\t"
"sw $zero, 8(%[input]) \n\t"
"sw $zero, 12(%[input]) \n\t"
"sw $zero, 16(%[input]) \n\t"
"sw $zero, 20(%[input]) \n\t"
"sw $zero, 24(%[input]) \n\t"
"sw $zero, 28(%[input]) \n\t"
"sw $zero, 32(%[input]) \n\t"
"sw $zero, 36(%[input]) \n\t"
"sw $zero, 40(%[input]) \n\t"
"sw $zero, 44(%[input]) \n\t"
"sw $zero, 48(%[input]) \n\t"
"sw $zero, 52(%[input]) \n\t"
"sw $zero, 56(%[input]) \n\t"
"sw $zero, 60(%[input]) \n\t" ::
[input] "r"(input));
}
static void dequant_idct_addconst_2x_msa(int16_t *input, int16_t *dequant_input,
uint8_t *dest, int32_t dest_stride) {
v8i16 input_dc0, input_dc1, vec, res0, res1, res2, res3;
v16u8 dest0, dest1, dest2, dest3;
v16i8 zero = { 0 };
input_dc0 = __msa_fill_h(input[0] * dequant_input[0]);
input_dc1 = __msa_fill_h(input[16] * dequant_input[0]);
SRARI_H2_SH(input_dc0, input_dc1, 3);
vec = (v8i16)__msa_pckev_d((v2i64)input_dc1, (v2i64)input_dc0);
input[0] = 0;
input[16] = 0;
LD_UB4(dest, dest_stride, dest0, dest1, dest2, dest3);
ILVR_B4_SH(zero, dest0, zero, dest1, zero, dest2, zero, dest3, res0, res1,
res2, res3);
ADD4(res0, vec, res1, vec, res2, vec, res3, vec, res0, res1, res2, res3);
CLIP_SH4_0_255(res0, res1, res2, res3);
PCKEV_B2_SH(res1, res0, res3, res2, res0, res1);
ST8x4_UB(res0, res1, dest, dest_stride);
}
void vp8_short_idct4x4llm_msa(int16_t *input, uint8_t *pred_ptr,
int32_t pred_stride, uint8_t *dst_ptr,
int32_t dst_stride) {
idct4x4_addblk_msa(input, pred_ptr, pred_stride, dst_ptr, dst_stride);
}
void vp8_dc_only_idct_add_msa(int16_t input_dc, uint8_t *pred_ptr,
int32_t pred_stride, uint8_t *dst_ptr,
int32_t dst_stride) {
idct4x4_addconst_msa(input_dc, pred_ptr, pred_stride, dst_ptr, dst_stride);
}
void vp8_dequantize_b_msa(BLOCKD *d, int16_t *DQC) {
v8i16 dqc0, dqc1, q0, q1, dq0, dq1;
LD_SH2(DQC, 8, dqc0, dqc1);
LD_SH2(d->qcoeff, 8, q0, q1);
MUL2(dqc0, q0, dqc1, q1, dq0, dq1);
ST_SH2(dq0, dq1, d->dqcoeff, 8);
}
void vp8_dequant_idct_add_msa(int16_t *input, int16_t *dq, uint8_t *dest,
int32_t stride) {
dequant_idct4x4_addblk_msa(input, dq, dest, stride);
__asm__ __volatile__(
"sw $zero, 0(%[input]) \n\t"
"sw $zero, 4(%[input]) \n\t"
"sw $zero, 8(%[input]) \n\t"
"sw $zero, 12(%[input]) \n\t"
"sw $zero, 16(%[input]) \n\t"
"sw $zero, 20(%[input]) \n\t"
"sw $zero, 24(%[input]) \n\t"
"sw $zero, 28(%[input]) \n\t"
:
: [input] "r"(input));
}
void vp8_dequant_idct_add_y_block_msa(int16_t *q, int16_t *dq, uint8_t *dst,
int32_t stride, char *eobs) {
int16_t *eobs_h = (int16_t *)eobs;
uint8_t i;
for (i = 4; i--;) {
if (eobs_h[0]) {
if (eobs_h[0] & 0xfefe) {
dequant_idct4x4_addblk_2x_msa(q, dq, dst, stride);
} else {
dequant_idct_addconst_2x_msa(q, dq, dst, stride);
}
}
q += 32;
if (eobs_h[1]) {
if (eobs_h[1] & 0xfefe) {
dequant_idct4x4_addblk_2x_msa(q, dq, dst + 8, stride);
} else {
dequant_idct_addconst_2x_msa(q, dq, dst + 8, stride);
}
}
q += 32;
dst += (4 * stride);
eobs_h += 2;
}
}
void vp8_dequant_idct_add_uv_block_msa(int16_t *q, int16_t *dq, uint8_t *dst_u,
uint8_t *dst_v, int32_t stride,
char *eobs) {
int16_t *eobs_h = (int16_t *)eobs;
if (eobs_h[0]) {
if (eobs_h[0] & 0xfefe) {
dequant_idct4x4_addblk_2x_msa(q, dq, dst_u, stride);
} else {
dequant_idct_addconst_2x_msa(q, dq, dst_u, stride);
}
}
q += 32;
dst_u += (stride * 4);
if (eobs_h[1]) {
if (eobs_h[1] & 0xfefe) {
dequant_idct4x4_addblk_2x_msa(q, dq, dst_u, stride);
} else {
dequant_idct_addconst_2x_msa(q, dq, dst_u, stride);
}
}
q += 32;
if (eobs_h[2]) {
if (eobs_h[2] & 0xfefe) {
dequant_idct4x4_addblk_2x_msa(q, dq, dst_v, stride);
} else {
dequant_idct_addconst_2x_msa(q, dq, dst_v, stride);
}
}
q += 32;
dst_v += (stride * 4);
if (eobs_h[3]) {
if (eobs_h[3] & 0xfefe) {
dequant_idct4x4_addblk_2x_msa(q, dq, dst_v, stride);
} else {
dequant_idct_addconst_2x_msa(q, dq, dst_v, stride);
}
}
}
@@ -0,0 +1,709 @@
/*
* 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 "./vp8_rtcd.h"
#include "vp8/common/loopfilter.h"
#include "vp8/common/mips/msa/vp8_macros_msa.h"
#define VP8_SIMPLE_MASK(p1, p0, q0, q1, b_limit, mask) \
{ \
v16u8 p1_a_sub_q1, p0_a_sub_q0; \
\
p0_a_sub_q0 = __msa_asub_u_b(p0, q0); \
p1_a_sub_q1 = __msa_asub_u_b(p1, q1); \
p1_a_sub_q1 = (v16u8)__msa_srli_b((v16i8)p1_a_sub_q1, 1); \
p0_a_sub_q0 = __msa_adds_u_b(p0_a_sub_q0, p0_a_sub_q0); \
mask = __msa_adds_u_b(p0_a_sub_q0, p1_a_sub_q1); \
mask = ((v16u8)mask <= b_limit); \
}
#define VP8_LPF_FILTER4_4W(p1, p0, q0, q1, mask, hev) \
{ \
v16i8 p1_m, p0_m, q0_m, q1_m, filt, q0_sub_p0, t1, t2; \
const v16i8 cnst4b = __msa_ldi_b(4); \
const v16i8 cnst3b = __msa_ldi_b(3); \
\
p1_m = (v16i8)__msa_xori_b(p1, 0x80); \
p0_m = (v16i8)__msa_xori_b(p0, 0x80); \
q0_m = (v16i8)__msa_xori_b(q0, 0x80); \
q1_m = (v16i8)__msa_xori_b(q1, 0x80); \
\
filt = __msa_subs_s_b(p1_m, q1_m); \
filt &= hev; \
q0_sub_p0 = __msa_subs_s_b(q0_m, p0_m); \
filt = __msa_adds_s_b(filt, q0_sub_p0); \
filt = __msa_adds_s_b(filt, q0_sub_p0); \
filt = __msa_adds_s_b(filt, q0_sub_p0); \
filt &= mask; \
t1 = __msa_adds_s_b(filt, cnst4b); \
t1 >>= cnst3b; \
t2 = __msa_adds_s_b(filt, cnst3b); \
t2 >>= cnst3b; \
q0_m = __msa_subs_s_b(q0_m, t1); \
q0 = __msa_xori_b((v16u8)q0_m, 0x80); \
p0_m = __msa_adds_s_b(p0_m, t2); \
p0 = __msa_xori_b((v16u8)p0_m, 0x80); \
filt = __msa_srari_b(t1, 1); \
hev = __msa_xori_b(hev, 0xff); \
filt &= hev; \
q1_m = __msa_subs_s_b(q1_m, filt); \
q1 = __msa_xori_b((v16u8)q1_m, 0x80); \
p1_m = __msa_adds_s_b(p1_m, filt); \
p1 = __msa_xori_b((v16u8)p1_m, 0x80); \
}
#define VP8_SIMPLE_FILT(p1_in, p0_in, q0_in, q1_in, mask) \
{ \
v16i8 p1_m, p0_m, q0_m, q1_m, filt, filt1, filt2; \
v16i8 q0_sub_p0; \
const v16i8 cnst4b = __msa_ldi_b(4); \
const v16i8 cnst3b = __msa_ldi_b(3); \
\
p1_m = (v16i8)__msa_xori_b(p1_in, 0x80); \
p0_m = (v16i8)__msa_xori_b(p0_in, 0x80); \
q0_m = (v16i8)__msa_xori_b(q0_in, 0x80); \
q1_m = (v16i8)__msa_xori_b(q1_in, 0x80); \
\
filt = __msa_subs_s_b(p1_m, q1_m); \
q0_sub_p0 = __msa_subs_s_b(q0_m, p0_m); \
filt = __msa_adds_s_b(filt, q0_sub_p0); \
filt = __msa_adds_s_b(filt, q0_sub_p0); \
filt = __msa_adds_s_b(filt, q0_sub_p0); \
filt &= mask; \
filt1 = __msa_adds_s_b(filt, cnst4b); \
filt1 >>= cnst3b; \
filt2 = __msa_adds_s_b(filt, cnst3b); \
filt2 >>= cnst3b; \
q0_m = __msa_subs_s_b(q0_m, filt1); \
p0_m = __msa_adds_s_b(p0_m, filt2); \
q0_in = __msa_xori_b((v16u8)q0_m, 0x80); \
p0_in = __msa_xori_b((v16u8)p0_m, 0x80); \
}
#define VP8_MBFILTER(p2, p1, p0, q0, q1, q2, mask, hev) \
{ \
v16i8 p2_m, p1_m, p0_m, q2_m, q1_m, q0_m; \
v16i8 u, filt, t1, t2, filt_sign, q0_sub_p0; \
v8i16 filt_r, filt_l, u_r, u_l; \
v8i16 temp0, temp1, temp2, temp3; \
const v16i8 cnst4b = __msa_ldi_b(4); \
const v16i8 cnst3b = __msa_ldi_b(3); \
const v8i16 cnst9h = __msa_ldi_h(9); \
const v8i16 cnst63h = __msa_ldi_h(63); \
\
p2_m = (v16i8)__msa_xori_b(p2, 0x80); \
p1_m = (v16i8)__msa_xori_b(p1, 0x80); \
p0_m = (v16i8)__msa_xori_b(p0, 0x80); \
q0_m = (v16i8)__msa_xori_b(q0, 0x80); \
q1_m = (v16i8)__msa_xori_b(q1, 0x80); \
q2_m = (v16i8)__msa_xori_b(q2, 0x80); \
\
filt = __msa_subs_s_b(p1_m, q1_m); \
q0_sub_p0 = __msa_subs_s_b(q0_m, p0_m); \
filt = __msa_adds_s_b(filt, q0_sub_p0); \
filt = __msa_adds_s_b(filt, q0_sub_p0); \
filt = __msa_adds_s_b(filt, q0_sub_p0); \
filt &= mask; \
\
t2 = filt & hev; \
hev = __msa_xori_b(hev, 0xff); \
filt &= hev; \
t1 = __msa_adds_s_b(t2, cnst4b); \
t1 >>= cnst3b; \
t2 = __msa_adds_s_b(t2, cnst3b); \
t2 >>= cnst3b; \
q0_m = __msa_subs_s_b(q0_m, t1); \
p0_m = __msa_adds_s_b(p0_m, t2); \
filt_sign = __msa_clti_s_b(filt, 0); \
ILVRL_B2_SH(filt_sign, filt, filt_r, filt_l); \
temp0 = filt_r * cnst9h; \
temp1 = temp0 + cnst63h; \
temp2 = filt_l * cnst9h; \
temp3 = temp2 + cnst63h; \
\
u_r = temp1 >> 7; \
u_r = __msa_sat_s_h(u_r, 7); \
u_l = temp3 >> 7; \
u_l = __msa_sat_s_h(u_l, 7); \
u = __msa_pckev_b((v16i8)u_l, (v16i8)u_r); \
q2_m = __msa_subs_s_b(q2_m, u); \
p2_m = __msa_adds_s_b(p2_m, u); \
q2 = __msa_xori_b((v16u8)q2_m, 0x80); \
p2 = __msa_xori_b((v16u8)p2_m, 0x80); \
\
temp1 += temp0; \
temp3 += temp2; \
\
u_r = temp1 >> 7; \
u_r = __msa_sat_s_h(u_r, 7); \
u_l = temp3 >> 7; \
u_l = __msa_sat_s_h(u_l, 7); \
u = __msa_pckev_b((v16i8)u_l, (v16i8)u_r); \
q1_m = __msa_subs_s_b(q1_m, u); \
p1_m = __msa_adds_s_b(p1_m, u); \
q1 = __msa_xori_b((v16u8)q1_m, 0x80); \
p1 = __msa_xori_b((v16u8)p1_m, 0x80); \
\
temp1 += temp0; \
temp3 += temp2; \
\
u_r = temp1 >> 7; \
u_r = __msa_sat_s_h(u_r, 7); \
u_l = temp3 >> 7; \
u_l = __msa_sat_s_h(u_l, 7); \
u = __msa_pckev_b((v16i8)u_l, (v16i8)u_r); \
q0_m = __msa_subs_s_b(q0_m, u); \
p0_m = __msa_adds_s_b(p0_m, u); \
q0 = __msa_xori_b((v16u8)q0_m, 0x80); \
p0 = __msa_xori_b((v16u8)p0_m, 0x80); \
}
#define LPF_MASK_HEV(p3_in, p2_in, p1_in, p0_in, q0_in, q1_in, q2_in, q3_in, \
limit_in, b_limit_in, thresh_in, hev_out, mask_out, \
flat_out) \
{ \
v16u8 p3_asub_p2_m, p2_asub_p1_m, p1_asub_p0_m, q1_asub_q0_m; \
v16u8 p1_asub_q1_m, p0_asub_q0_m, q3_asub_q2_m, q2_asub_q1_m; \
\
p3_asub_p2_m = __msa_asub_u_b((p3_in), (p2_in)); \
p2_asub_p1_m = __msa_asub_u_b((p2_in), (p1_in)); \
p1_asub_p0_m = __msa_asub_u_b((p1_in), (p0_in)); \
q1_asub_q0_m = __msa_asub_u_b((q1_in), (q0_in)); \
q2_asub_q1_m = __msa_asub_u_b((q2_in), (q1_in)); \
q3_asub_q2_m = __msa_asub_u_b((q3_in), (q2_in)); \
p0_asub_q0_m = __msa_asub_u_b((p0_in), (q0_in)); \
p1_asub_q1_m = __msa_asub_u_b((p1_in), (q1_in)); \
flat_out = __msa_max_u_b(p1_asub_p0_m, q1_asub_q0_m); \
hev_out = (thresh_in) < (v16u8)flat_out; \
p0_asub_q0_m = __msa_adds_u_b(p0_asub_q0_m, p0_asub_q0_m); \
p1_asub_q1_m >>= 1; \
p0_asub_q0_m = __msa_adds_u_b(p0_asub_q0_m, p1_asub_q1_m); \
mask_out = (b_limit_in) < p0_asub_q0_m; \
mask_out = __msa_max_u_b(flat_out, mask_out); \
p3_asub_p2_m = __msa_max_u_b(p3_asub_p2_m, p2_asub_p1_m); \
mask_out = __msa_max_u_b(p3_asub_p2_m, mask_out); \
q2_asub_q1_m = __msa_max_u_b(q2_asub_q1_m, q3_asub_q2_m); \
mask_out = __msa_max_u_b(q2_asub_q1_m, mask_out); \
mask_out = (limit_in) < (v16u8)mask_out; \
mask_out = __msa_xori_b(mask_out, 0xff); \
}
#define VP8_ST6x1_UB(in0, in0_idx, in1, in1_idx, pdst, stride) \
{ \
uint16_t tmp0_h; \
uint32_t tmp0_w; \
\
tmp0_w = __msa_copy_u_w((v4i32)in0, in0_idx); \
tmp0_h = __msa_copy_u_h((v8i16)in1, in1_idx); \
SW(tmp0_w, pdst); \
SH(tmp0_h, pdst + stride); \
}
static void loop_filter_horizontal_4_dual_msa(uint8_t *src, int32_t pitch,
const uint8_t *b_limit0_ptr,
const uint8_t *limit0_ptr,
const uint8_t *thresh0_ptr,
const uint8_t *b_limit1_ptr,
const uint8_t *limit1_ptr,
const uint8_t *thresh1_ptr) {
v16u8 mask, hev, flat;
v16u8 thresh0, b_limit0, limit0, thresh1, b_limit1, limit1;
v16u8 p3, p2, p1, p0, q3, q2, q1, q0;
LD_UB8((src - 4 * pitch), pitch, p3, p2, p1, p0, q0, q1, q2, q3);
thresh0 = (v16u8)__msa_fill_b(*thresh0_ptr);
thresh1 = (v16u8)__msa_fill_b(*thresh1_ptr);
thresh0 = (v16u8)__msa_ilvr_d((v2i64)thresh1, (v2i64)thresh0);
b_limit0 = (v16u8)__msa_fill_b(*b_limit0_ptr);
b_limit1 = (v16u8)__msa_fill_b(*b_limit1_ptr);
b_limit0 = (v16u8)__msa_ilvr_d((v2i64)b_limit1, (v2i64)b_limit0);
limit0 = (v16u8)__msa_fill_b(*limit0_ptr);
limit1 = (v16u8)__msa_fill_b(*limit1_ptr);
limit0 = (v16u8)__msa_ilvr_d((v2i64)limit1, (v2i64)limit0);
LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit0, b_limit0, thresh0, hev,
mask, flat);
VP8_LPF_FILTER4_4W(p1, p0, q0, q1, mask, hev);
ST_UB4(p1, p0, q0, q1, (src - 2 * pitch), pitch);
}
static void loop_filter_vertical_4_dual_msa(uint8_t *src, int32_t pitch,
const uint8_t *b_limit0_ptr,
const uint8_t *limit0_ptr,
const uint8_t *thresh0_ptr,
const uint8_t *b_limit1_ptr,
const uint8_t *limit1_ptr,
const uint8_t *thresh1_ptr) {
v16u8 mask, hev, flat;
v16u8 thresh0, b_limit0, limit0, thresh1, b_limit1, limit1;
v16u8 p3, p2, p1, p0, q3, q2, q1, q0;
v16u8 row0, row1, row2, row3, row4, row5, row6, row7;
v16u8 row8, row9, row10, row11, row12, row13, row14, row15;
v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5;
LD_UB8(src - 4, pitch, row0, row1, row2, row3, row4, row5, row6, row7);
LD_UB8(src - 4 + (8 * pitch), pitch, row8, row9, row10, row11, row12, row13,
row14, row15);
TRANSPOSE16x8_UB_UB(row0, row1, row2, row3, row4, row5, row6, row7, row8,
row9, row10, row11, row12, row13, row14, row15, p3, p2,
p1, p0, q0, q1, q2, q3);
thresh0 = (v16u8)__msa_fill_b(*thresh0_ptr);
thresh1 = (v16u8)__msa_fill_b(*thresh1_ptr);
thresh0 = (v16u8)__msa_ilvr_d((v2i64)thresh1, (v2i64)thresh0);
b_limit0 = (v16u8)__msa_fill_b(*b_limit0_ptr);
b_limit1 = (v16u8)__msa_fill_b(*b_limit1_ptr);
b_limit0 = (v16u8)__msa_ilvr_d((v2i64)b_limit1, (v2i64)b_limit0);
limit0 = (v16u8)__msa_fill_b(*limit0_ptr);
limit1 = (v16u8)__msa_fill_b(*limit1_ptr);
limit0 = (v16u8)__msa_ilvr_d((v2i64)limit1, (v2i64)limit0);
LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit0, b_limit0, thresh0, hev,
mask, flat);
VP8_LPF_FILTER4_4W(p1, p0, q0, q1, mask, hev);
ILVR_B2_SH(p0, p1, q1, q0, tmp0, tmp1);
ILVRL_H2_SH(tmp1, tmp0, tmp2, tmp3);
ILVL_B2_SH(p0, p1, q1, q0, tmp0, tmp1);
ILVRL_H2_SH(tmp1, tmp0, tmp4, tmp5);
src -= 2;
ST4x8_UB(tmp2, tmp3, src, pitch);
src += (8 * pitch);
ST4x8_UB(tmp4, tmp5, src, pitch);
}
static void mbloop_filter_horizontal_edge_y_msa(uint8_t *src, int32_t pitch,
const uint8_t b_limit_in,
const uint8_t limit_in,
const uint8_t thresh_in) {
uint8_t *temp_src;
v16u8 p3, p2, p1, p0, q3, q2, q1, q0;
v16u8 mask, hev, flat, thresh, limit, b_limit;
b_limit = (v16u8)__msa_fill_b(b_limit_in);
limit = (v16u8)__msa_fill_b(limit_in);
thresh = (v16u8)__msa_fill_b(thresh_in);
temp_src = src - (pitch << 2);
LD_UB8(temp_src, pitch, p3, p2, p1, p0, q0, q1, q2, q3);
LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh, hev,
mask, flat);
VP8_MBFILTER(p2, p1, p0, q0, q1, q2, mask, hev);
temp_src = src - 3 * pitch;
ST_UB4(p2, p1, p0, q0, temp_src, pitch);
temp_src += (4 * pitch);
ST_UB2(q1, q2, temp_src, pitch);
}
static void mbloop_filter_horizontal_edge_uv_msa(uint8_t *src_u, uint8_t *src_v,
int32_t pitch,
const uint8_t b_limit_in,
const uint8_t limit_in,
const uint8_t thresh_in) {
uint8_t *temp_src;
uint64_t p2_d, p1_d, p0_d, q0_d, q1_d, q2_d;
v16u8 p3, p2, p1, p0, q3, q2, q1, q0;
v16u8 mask, hev, flat, thresh, limit, b_limit;
v16u8 p3_u, p2_u, p1_u, p0_u, q3_u, q2_u, q1_u, q0_u;
v16u8 p3_v, p2_v, p1_v, p0_v, q3_v, q2_v, q1_v, q0_v;
b_limit = (v16u8)__msa_fill_b(b_limit_in);
limit = (v16u8)__msa_fill_b(limit_in);
thresh = (v16u8)__msa_fill_b(thresh_in);
temp_src = src_u - (pitch << 2);
LD_UB8(temp_src, pitch, p3_u, p2_u, p1_u, p0_u, q0_u, q1_u, q2_u, q3_u);
temp_src = src_v - (pitch << 2);
LD_UB8(temp_src, pitch, p3_v, p2_v, p1_v, p0_v, q0_v, q1_v, q2_v, q3_v);
ILVR_D4_UB(p3_v, p3_u, p2_v, p2_u, p1_v, p1_u, p0_v, p0_u, p3, p2, p1, p0);
ILVR_D4_UB(q0_v, q0_u, q1_v, q1_u, q2_v, q2_u, q3_v, q3_u, q0, q1, q2, q3);
LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh, hev,
mask, flat);
VP8_MBFILTER(p2, p1, p0, q0, q1, q2, mask, hev);
p2_d = __msa_copy_u_d((v2i64)p2, 0);
p1_d = __msa_copy_u_d((v2i64)p1, 0);
p0_d = __msa_copy_u_d((v2i64)p0, 0);
q0_d = __msa_copy_u_d((v2i64)q0, 0);
q1_d = __msa_copy_u_d((v2i64)q1, 0);
q2_d = __msa_copy_u_d((v2i64)q2, 0);
src_u -= (pitch * 3);
SD4(p2_d, p1_d, p0_d, q0_d, src_u, pitch);
src_u += 4 * pitch;
SD(q1_d, src_u);
src_u += pitch;
SD(q2_d, src_u);
p2_d = __msa_copy_u_d((v2i64)p2, 1);
p1_d = __msa_copy_u_d((v2i64)p1, 1);
p0_d = __msa_copy_u_d((v2i64)p0, 1);
q0_d = __msa_copy_u_d((v2i64)q0, 1);
q1_d = __msa_copy_u_d((v2i64)q1, 1);
q2_d = __msa_copy_u_d((v2i64)q2, 1);
src_v -= (pitch * 3);
SD4(p2_d, p1_d, p0_d, q0_d, src_v, pitch);
src_v += 4 * pitch;
SD(q1_d, src_v);
src_v += pitch;
SD(q2_d, src_v);
}
static void mbloop_filter_vertical_edge_y_msa(uint8_t *src, int32_t pitch,
const uint8_t b_limit_in,
const uint8_t limit_in,
const uint8_t thresh_in) {
uint8_t *temp_src;
v16u8 p3, p2, p1, p0, q3, q2, q1, q0;
v16u8 mask, hev, flat, thresh, limit, b_limit;
v16u8 row0, row1, row2, row3, row4, row5, row6, row7, row8;
v16u8 row9, row10, row11, row12, row13, row14, row15;
v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
b_limit = (v16u8)__msa_fill_b(b_limit_in);
limit = (v16u8)__msa_fill_b(limit_in);
thresh = (v16u8)__msa_fill_b(thresh_in);
temp_src = src - 4;
LD_UB8(temp_src, pitch, row0, row1, row2, row3, row4, row5, row6, row7);
temp_src += (8 * pitch);
LD_UB8(temp_src, pitch, row8, row9, row10, row11, row12, row13, row14, row15);
TRANSPOSE16x8_UB_UB(row0, row1, row2, row3, row4, row5, row6, row7, row8,
row9, row10, row11, row12, row13, row14, row15, p3, p2,
p1, p0, q0, q1, q2, q3);
LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh, hev,
mask, flat);
VP8_MBFILTER(p2, p1, p0, q0, q1, q2, mask, hev);
ILVR_B2_SH(p1, p2, q0, p0, tmp0, tmp1);
ILVRL_H2_SH(tmp1, tmp0, tmp3, tmp4);
ILVL_B2_SH(p1, p2, q0, p0, tmp0, tmp1);
ILVRL_H2_SH(tmp1, tmp0, tmp6, tmp7);
ILVRL_B2_SH(q2, q1, tmp2, tmp5);
temp_src = src - 3;
VP8_ST6x1_UB(tmp3, 0, tmp2, 0, temp_src, 4);
temp_src += pitch;
VP8_ST6x1_UB(tmp3, 1, tmp2, 1, temp_src, 4);
temp_src += pitch;
VP8_ST6x1_UB(tmp3, 2, tmp2, 2, temp_src, 4);
temp_src += pitch;
VP8_ST6x1_UB(tmp3, 3, tmp2, 3, temp_src, 4);
temp_src += pitch;
VP8_ST6x1_UB(tmp4, 0, tmp2, 4, temp_src, 4);
temp_src += pitch;
VP8_ST6x1_UB(tmp4, 1, tmp2, 5, temp_src, 4);
temp_src += pitch;
VP8_ST6x1_UB(tmp4, 2, tmp2, 6, temp_src, 4);
temp_src += pitch;
VP8_ST6x1_UB(tmp4, 3, tmp2, 7, temp_src, 4);
temp_src += pitch;
VP8_ST6x1_UB(tmp6, 0, tmp5, 0, temp_src, 4);
temp_src += pitch;
VP8_ST6x1_UB(tmp6, 1, tmp5, 1, temp_src, 4);
temp_src += pitch;
VP8_ST6x1_UB(tmp6, 2, tmp5, 2, temp_src, 4);
temp_src += pitch;
VP8_ST6x1_UB(tmp6, 3, tmp5, 3, temp_src, 4);
temp_src += pitch;
VP8_ST6x1_UB(tmp7, 0, tmp5, 4, temp_src, 4);
temp_src += pitch;
VP8_ST6x1_UB(tmp7, 1, tmp5, 5, temp_src, 4);
temp_src += pitch;
VP8_ST6x1_UB(tmp7, 2, tmp5, 6, temp_src, 4);
temp_src += pitch;
VP8_ST6x1_UB(tmp7, 3, tmp5, 7, temp_src, 4);
}
static void mbloop_filter_vertical_edge_uv_msa(uint8_t *src_u, uint8_t *src_v,
int32_t pitch,
const uint8_t b_limit_in,
const uint8_t limit_in,
const uint8_t thresh_in) {
v16u8 p3, p2, p1, p0, q3, q2, q1, q0;
v16u8 mask, hev, flat, thresh, limit, b_limit;
v16u8 row0, row1, row2, row3, row4, row5, row6, row7, row8;
v16u8 row9, row10, row11, row12, row13, row14, row15;
v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
b_limit = (v16u8)__msa_fill_b(b_limit_in);
limit = (v16u8)__msa_fill_b(limit_in);
thresh = (v16u8)__msa_fill_b(thresh_in);
LD_UB8(src_u - 4, pitch, row0, row1, row2, row3, row4, row5, row6, row7);
LD_UB8(src_v - 4, pitch, row8, row9, row10, row11, row12, row13, row14,
row15);
TRANSPOSE16x8_UB_UB(row0, row1, row2, row3, row4, row5, row6, row7, row8,
row9, row10, row11, row12, row13, row14, row15, p3, p2,
p1, p0, q0, q1, q2, q3);
LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh, hev,
mask, flat);
VP8_MBFILTER(p2, p1, p0, q0, q1, q2, mask, hev);
ILVR_B2_SH(p1, p2, q0, p0, tmp0, tmp1);
ILVRL_H2_SH(tmp1, tmp0, tmp3, tmp4);
ILVL_B2_SH(p1, p2, q0, p0, tmp0, tmp1);
ILVRL_H2_SH(tmp1, tmp0, tmp6, tmp7);
ILVRL_B2_SH(q2, q1, tmp2, tmp5);
src_u -= 3;
VP8_ST6x1_UB(tmp3, 0, tmp2, 0, src_u, 4);
src_u += pitch;
VP8_ST6x1_UB(tmp3, 1, tmp2, 1, src_u, 4);
src_u += pitch;
VP8_ST6x1_UB(tmp3, 2, tmp2, 2, src_u, 4);
src_u += pitch;
VP8_ST6x1_UB(tmp3, 3, tmp2, 3, src_u, 4);
src_u += pitch;
VP8_ST6x1_UB(tmp4, 0, tmp2, 4, src_u, 4);
src_u += pitch;
VP8_ST6x1_UB(tmp4, 1, tmp2, 5, src_u, 4);
src_u += pitch;
VP8_ST6x1_UB(tmp4, 2, tmp2, 6, src_u, 4);
src_u += pitch;
VP8_ST6x1_UB(tmp4, 3, tmp2, 7, src_u, 4);
src_v -= 3;
VP8_ST6x1_UB(tmp6, 0, tmp5, 0, src_v, 4);
src_v += pitch;
VP8_ST6x1_UB(tmp6, 1, tmp5, 1, src_v, 4);
src_v += pitch;
VP8_ST6x1_UB(tmp6, 2, tmp5, 2, src_v, 4);
src_v += pitch;
VP8_ST6x1_UB(tmp6, 3, tmp5, 3, src_v, 4);
src_v += pitch;
VP8_ST6x1_UB(tmp7, 0, tmp5, 4, src_v, 4);
src_v += pitch;
VP8_ST6x1_UB(tmp7, 1, tmp5, 5, src_v, 4);
src_v += pitch;
VP8_ST6x1_UB(tmp7, 2, tmp5, 6, src_v, 4);
src_v += pitch;
VP8_ST6x1_UB(tmp7, 3, tmp5, 7, src_v, 4);
}
void vp8_loop_filter_simple_horizontal_edge_msa(uint8_t *src, int32_t pitch,
const uint8_t *b_limit_ptr) {
v16u8 p1, p0, q1, q0;
v16u8 mask, b_limit;
b_limit = (v16u8)__msa_fill_b(*b_limit_ptr);
LD_UB4(src - (pitch << 1), pitch, p1, p0, q0, q1);
VP8_SIMPLE_MASK(p1, p0, q0, q1, b_limit, mask);
VP8_SIMPLE_FILT(p1, p0, q0, q1, mask);
ST_UB2(p0, q0, (src - pitch), pitch);
}
void vp8_loop_filter_simple_vertical_edge_msa(uint8_t *src, int32_t pitch,
const uint8_t *b_limit_ptr) {
uint8_t *temp_src;
v16u8 p1, p0, q1, q0;
v16u8 mask, b_limit;
v16u8 row0, row1, row2, row3, row4, row5, row6, row7, row8;
v16u8 row9, row10, row11, row12, row13, row14, row15;
v8i16 tmp0, tmp1;
b_limit = (v16u8)__msa_fill_b(*b_limit_ptr);
temp_src = src - 2;
LD_UB8(temp_src, pitch, row0, row1, row2, row3, row4, row5, row6, row7);
temp_src += (8 * pitch);
LD_UB8(temp_src, pitch, row8, row9, row10, row11, row12, row13, row14, row15);
TRANSPOSE16x4_UB_UB(row0, row1, row2, row3, row4, row5, row6, row7, row8,
row9, row10, row11, row12, row13, row14, row15, p1, p0,
q0, q1);
VP8_SIMPLE_MASK(p1, p0, q0, q1, b_limit, mask);
VP8_SIMPLE_FILT(p1, p0, q0, q1, mask);
ILVRL_B2_SH(q0, p0, tmp1, tmp0);
src -= 1;
ST2x4_UB(tmp1, 0, src, pitch);
src += 4 * pitch;
ST2x4_UB(tmp1, 4, src, pitch);
src += 4 * pitch;
ST2x4_UB(tmp0, 0, src, pitch);
src += 4 * pitch;
ST2x4_UB(tmp0, 4, src, pitch);
src += 4 * pitch;
}
static void loop_filter_horizontal_edge_uv_msa(uint8_t *src_u, uint8_t *src_v,
int32_t pitch,
const uint8_t b_limit_in,
const uint8_t limit_in,
const uint8_t thresh_in) {
uint64_t p1_d, p0_d, q0_d, q1_d;
v16u8 p3, p2, p1, p0, q3, q2, q1, q0;
v16u8 mask, hev, flat, thresh, limit, b_limit;
v16u8 p3_u, p2_u, p1_u, p0_u, q3_u, q2_u, q1_u, q0_u;
v16u8 p3_v, p2_v, p1_v, p0_v, q3_v, q2_v, q1_v, q0_v;
thresh = (v16u8)__msa_fill_b(thresh_in);
limit = (v16u8)__msa_fill_b(limit_in);
b_limit = (v16u8)__msa_fill_b(b_limit_in);
src_u = src_u - (pitch << 2);
LD_UB8(src_u, pitch, p3_u, p2_u, p1_u, p0_u, q0_u, q1_u, q2_u, q3_u);
src_u += (5 * pitch);
src_v = src_v - (pitch << 2);
LD_UB8(src_v, pitch, p3_v, p2_v, p1_v, p0_v, q0_v, q1_v, q2_v, q3_v);
src_v += (5 * pitch);
/* right 8 element of p3 are u pixel and
left 8 element of p3 are v pixel */
ILVR_D4_UB(p3_v, p3_u, p2_v, p2_u, p1_v, p1_u, p0_v, p0_u, p3, p2, p1, p0);
ILVR_D4_UB(q0_v, q0_u, q1_v, q1_u, q2_v, q2_u, q3_v, q3_u, q0, q1, q2, q3);
LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh, hev,
mask, flat);
VP8_LPF_FILTER4_4W(p1, p0, q0, q1, mask, hev);
p1_d = __msa_copy_u_d((v2i64)p1, 0);
p0_d = __msa_copy_u_d((v2i64)p0, 0);
q0_d = __msa_copy_u_d((v2i64)q0, 0);
q1_d = __msa_copy_u_d((v2i64)q1, 0);
SD4(q1_d, q0_d, p0_d, p1_d, src_u, (-pitch));
p1_d = __msa_copy_u_d((v2i64)p1, 1);
p0_d = __msa_copy_u_d((v2i64)p0, 1);
q0_d = __msa_copy_u_d((v2i64)q0, 1);
q1_d = __msa_copy_u_d((v2i64)q1, 1);
SD4(q1_d, q0_d, p0_d, p1_d, src_v, (-pitch));
}
static void loop_filter_vertical_edge_uv_msa(uint8_t *src_u, uint8_t *src_v,
int32_t pitch,
const uint8_t b_limit_in,
const uint8_t limit_in,
const uint8_t thresh_in) {
uint8_t *temp_src_u, *temp_src_v;
v16u8 p3, p2, p1, p0, q3, q2, q1, q0;
v16u8 mask, hev, flat, thresh, limit, b_limit;
v16u8 row0, row1, row2, row3, row4, row5, row6, row7, row8;
v16u8 row9, row10, row11, row12, row13, row14, row15;
v4i32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5;
thresh = (v16u8)__msa_fill_b(thresh_in);
limit = (v16u8)__msa_fill_b(limit_in);
b_limit = (v16u8)__msa_fill_b(b_limit_in);
LD_UB8(src_u - 4, pitch, row0, row1, row2, row3, row4, row5, row6, row7);
LD_UB8(src_v - 4, pitch, row8, row9, row10, row11, row12, row13, row14,
row15);
TRANSPOSE16x8_UB_UB(row0, row1, row2, row3, row4, row5, row6, row7, row8,
row9, row10, row11, row12, row13, row14, row15, p3, p2,
p1, p0, q0, q1, q2, q3);
LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh, hev,
mask, flat);
VP8_LPF_FILTER4_4W(p1, p0, q0, q1, mask, hev);
ILVR_B2_SW(p0, p1, q1, q0, tmp0, tmp1);
ILVRL_H2_SW(tmp1, tmp0, tmp2, tmp3);
tmp0 = (v4i32)__msa_ilvl_b((v16i8)p0, (v16i8)p1);
tmp1 = (v4i32)__msa_ilvl_b((v16i8)q1, (v16i8)q0);
ILVRL_H2_SW(tmp1, tmp0, tmp4, tmp5);
temp_src_u = src_u - 2;
ST4x4_UB(tmp2, tmp2, 0, 1, 2, 3, temp_src_u, pitch);
temp_src_u += 4 * pitch;
ST4x4_UB(tmp3, tmp3, 0, 1, 2, 3, temp_src_u, pitch);
temp_src_v = src_v - 2;
ST4x4_UB(tmp4, tmp4, 0, 1, 2, 3, temp_src_v, pitch);
temp_src_v += 4 * pitch;
ST4x4_UB(tmp5, tmp5, 0, 1, 2, 3, temp_src_v, pitch);
}
void vp8_loop_filter_mbh_msa(uint8_t *src_y, uint8_t *src_u, uint8_t *src_v,
int32_t pitch_y, int32_t pitch_u_v,
loop_filter_info *lpf_info_ptr) {
mbloop_filter_horizontal_edge_y_msa(src_y, pitch_y, *lpf_info_ptr->mblim,
*lpf_info_ptr->lim,
*lpf_info_ptr->hev_thr);
if (src_u) {
mbloop_filter_horizontal_edge_uv_msa(
src_u, src_v, pitch_u_v, *lpf_info_ptr->mblim, *lpf_info_ptr->lim,
*lpf_info_ptr->hev_thr);
}
}
void vp8_loop_filter_mbv_msa(uint8_t *src_y, uint8_t *src_u, uint8_t *src_v,
int32_t pitch_y, int32_t pitch_u_v,
loop_filter_info *lpf_info_ptr) {
mbloop_filter_vertical_edge_y_msa(src_y, pitch_y, *lpf_info_ptr->mblim,
*lpf_info_ptr->lim, *lpf_info_ptr->hev_thr);
if (src_u) {
mbloop_filter_vertical_edge_uv_msa(src_u, src_v, pitch_u_v,
*lpf_info_ptr->mblim, *lpf_info_ptr->lim,
*lpf_info_ptr->hev_thr);
}
}
void vp8_loop_filter_bh_msa(uint8_t *src_y, uint8_t *src_u, uint8_t *src_v,
int32_t pitch_y, int32_t pitch_u_v,
loop_filter_info *lpf_info_ptr) {
loop_filter_horizontal_4_dual_msa(src_y + 4 * pitch_y, pitch_y,
lpf_info_ptr->blim, lpf_info_ptr->lim,
lpf_info_ptr->hev_thr, lpf_info_ptr->blim,
lpf_info_ptr->lim, lpf_info_ptr->hev_thr);
loop_filter_horizontal_4_dual_msa(src_y + 8 * pitch_y, pitch_y,
lpf_info_ptr->blim, lpf_info_ptr->lim,
lpf_info_ptr->hev_thr, lpf_info_ptr->blim,
lpf_info_ptr->lim, lpf_info_ptr->hev_thr);
loop_filter_horizontal_4_dual_msa(src_y + 12 * pitch_y, pitch_y,
lpf_info_ptr->blim, lpf_info_ptr->lim,
lpf_info_ptr->hev_thr, lpf_info_ptr->blim,
lpf_info_ptr->lim, lpf_info_ptr->hev_thr);
if (src_u) {
loop_filter_horizontal_edge_uv_msa(
src_u + (4 * pitch_u_v), src_v + (4 * pitch_u_v), pitch_u_v,
*lpf_info_ptr->blim, *lpf_info_ptr->lim, *lpf_info_ptr->hev_thr);
}
}
void vp8_loop_filter_bv_msa(uint8_t *src_y, uint8_t *src_u, uint8_t *src_v,
int32_t pitch_y, int32_t pitch_u_v,
loop_filter_info *lpf_info_ptr) {
loop_filter_vertical_4_dual_msa(src_y + 4, pitch_y, lpf_info_ptr->blim,
lpf_info_ptr->lim, lpf_info_ptr->hev_thr,
lpf_info_ptr->blim, lpf_info_ptr->lim,
lpf_info_ptr->hev_thr);
loop_filter_vertical_4_dual_msa(src_y + 8, pitch_y, lpf_info_ptr->blim,
lpf_info_ptr->lim, lpf_info_ptr->hev_thr,
lpf_info_ptr->blim, lpf_info_ptr->lim,
lpf_info_ptr->hev_thr);
loop_filter_vertical_4_dual_msa(src_y + 12, pitch_y, lpf_info_ptr->blim,
lpf_info_ptr->lim, lpf_info_ptr->hev_thr,
lpf_info_ptr->blim, lpf_info_ptr->lim,
lpf_info_ptr->hev_thr);
if (src_u) {
loop_filter_vertical_edge_uv_msa(src_u + 4, src_v + 4, pitch_u_v,
*lpf_info_ptr->blim, *lpf_info_ptr->lim,
*lpf_info_ptr->hev_thr);
}
}
void vp8_loop_filter_bhs_msa(uint8_t *src_y, int32_t pitch_y,
const uint8_t *b_limit_ptr) {
vp8_loop_filter_simple_horizontal_edge_msa(src_y + (4 * pitch_y), pitch_y,
b_limit_ptr);
vp8_loop_filter_simple_horizontal_edge_msa(src_y + (8 * pitch_y), pitch_y,
b_limit_ptr);
vp8_loop_filter_simple_horizontal_edge_msa(src_y + (12 * pitch_y), pitch_y,
b_limit_ptr);
}
void vp8_loop_filter_bvs_msa(uint8_t *src_y, int32_t pitch_y,
const uint8_t *b_limit_ptr) {
vp8_loop_filter_simple_vertical_edge_msa(src_y + 4, pitch_y, b_limit_ptr);
vp8_loop_filter_simple_vertical_edge_msa(src_y + 8, pitch_y, b_limit_ptr);
vp8_loop_filter_simple_vertical_edge_msa(src_y + 12, pitch_y, b_limit_ptr);
}
@@ -0,0 +1,139 @@
/*
* 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 "./vp8_rtcd.h"
#include "vp8/common/postproc.h"
#include "vp8/common/mips/msa/vp8_macros_msa.h"
static void filter_by_weight8x8_msa(uint8_t *src_ptr, int32_t src_stride,
uint8_t *dst_ptr, int32_t dst_stride,
int32_t src_weight) {
int32_t dst_weight = (1 << MFQE_PRECISION) - src_weight;
int32_t row;
uint64_t src0_d, src1_d, dst0_d, dst1_d;
v16i8 src0 = { 0 };
v16i8 src1 = { 0 };
v16i8 dst0 = { 0 };
v16i8 dst1 = { 0 };
v8i16 src_wt, dst_wt, res_h_r, res_h_l, src_r, src_l, dst_r, dst_l;
src_wt = __msa_fill_h(src_weight);
dst_wt = __msa_fill_h(dst_weight);
for (row = 2; row--;) {
LD2(src_ptr, src_stride, src0_d, src1_d);
src_ptr += (2 * src_stride);
LD2(dst_ptr, dst_stride, dst0_d, dst1_d);
INSERT_D2_SB(src0_d, src1_d, src0);
INSERT_D2_SB(dst0_d, dst1_d, dst0);
LD2(src_ptr, src_stride, src0_d, src1_d);
src_ptr += (2 * src_stride);
LD2((dst_ptr + 2 * dst_stride), dst_stride, dst0_d, dst1_d);
INSERT_D2_SB(src0_d, src1_d, src1);
INSERT_D2_SB(dst0_d, dst1_d, dst1);
UNPCK_UB_SH(src0, src_r, src_l);
UNPCK_UB_SH(dst0, dst_r, dst_l);
res_h_r = (src_r * src_wt);
res_h_r += (dst_r * dst_wt);
res_h_l = (src_l * src_wt);
res_h_l += (dst_l * dst_wt);
SRARI_H2_SH(res_h_r, res_h_l, MFQE_PRECISION);
dst0 = (v16i8)__msa_pckev_b((v16i8)res_h_l, (v16i8)res_h_r);
ST8x2_UB(dst0, dst_ptr, dst_stride);
dst_ptr += (2 * dst_stride);
UNPCK_UB_SH(src1, src_r, src_l);
UNPCK_UB_SH(dst1, dst_r, dst_l);
res_h_r = (src_r * src_wt);
res_h_r += (dst_r * dst_wt);
res_h_l = (src_l * src_wt);
res_h_l += (dst_l * dst_wt);
SRARI_H2_SH(res_h_r, res_h_l, MFQE_PRECISION);
dst1 = (v16i8)__msa_pckev_b((v16i8)res_h_l, (v16i8)res_h_r);
ST8x2_UB(dst1, dst_ptr, dst_stride);
dst_ptr += (2 * dst_stride);
}
}
static void filter_by_weight16x16_msa(uint8_t *src_ptr, int32_t src_stride,
uint8_t *dst_ptr, int32_t dst_stride,
int32_t src_weight) {
int32_t dst_weight = (1 << MFQE_PRECISION) - src_weight;
int32_t row;
v16i8 src0, src1, src2, src3;
v16i8 dst0, dst1, dst2, dst3;
v8i16 src_wt, dst_wt;
v8i16 res_h_r, res_h_l;
v8i16 src_r, src_l, dst_r, dst_l;
src_wt = __msa_fill_h(src_weight);
dst_wt = __msa_fill_h(dst_weight);
for (row = 4; row--;) {
LD_SB4(src_ptr, src_stride, src0, src1, src2, src3);
src_ptr += (4 * src_stride);
LD_SB4(dst_ptr, dst_stride, dst0, dst1, dst2, dst3);
UNPCK_UB_SH(src0, src_r, src_l);
UNPCK_UB_SH(dst0, dst_r, dst_l);
res_h_r = (src_r * src_wt);
res_h_r += (dst_r * dst_wt);
res_h_l = (src_l * src_wt);
res_h_l += (dst_l * dst_wt);
SRARI_H2_SH(res_h_r, res_h_l, MFQE_PRECISION);
PCKEV_ST_SB(res_h_r, res_h_l, dst_ptr);
dst_ptr += dst_stride;
UNPCK_UB_SH(src1, src_r, src_l);
UNPCK_UB_SH(dst1, dst_r, dst_l);
res_h_r = (src_r * src_wt);
res_h_r += (dst_r * dst_wt);
res_h_l = (src_l * src_wt);
res_h_l += (dst_l * dst_wt);
SRARI_H2_SH(res_h_r, res_h_l, MFQE_PRECISION);
PCKEV_ST_SB(res_h_r, res_h_l, dst_ptr);
dst_ptr += dst_stride;
UNPCK_UB_SH(src2, src_r, src_l);
UNPCK_UB_SH(dst2, dst_r, dst_l);
res_h_r = (src_r * src_wt);
res_h_r += (dst_r * dst_wt);
res_h_l = (src_l * src_wt);
res_h_l += (dst_l * dst_wt);
SRARI_H2_SH(res_h_r, res_h_l, MFQE_PRECISION);
PCKEV_ST_SB(res_h_r, res_h_l, dst_ptr);
dst_ptr += dst_stride;
UNPCK_UB_SH(src3, src_r, src_l);
UNPCK_UB_SH(dst3, dst_r, dst_l);
res_h_r = (src_r * src_wt);
res_h_r += (dst_r * dst_wt);
res_h_l = (src_l * src_wt);
res_h_l += (dst_l * dst_wt);
SRARI_H2_SH(res_h_r, res_h_l, MFQE_PRECISION);
PCKEV_ST_SB(res_h_r, res_h_l, dst_ptr);
dst_ptr += dst_stride;
}
}
void vp8_filter_by_weight16x16_msa(uint8_t *src_ptr, int32_t src_stride,
uint8_t *dst_ptr, int32_t dst_stride,
int32_t src_weight) {
filter_by_weight16x16_msa(src_ptr, src_stride, dst_ptr, dst_stride,
src_weight);
}
void vp8_filter_by_weight8x8_msa(uint8_t *src_ptr, int32_t src_stride,
uint8_t *dst_ptr, int32_t dst_stride,
int32_t src_weight) {
filter_by_weight8x8_msa(src_ptr, src_stride, dst_ptr, dst_stride, src_weight);
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff