Commit 7c64163f authored by Manojkumar Bhosale's avatar Manojkumar Bhosale

Add MSA optimized RAW/RGB/ARGB to ARGB/Y/UV row functions

R=fbarchard@google.com
BUG=libyuv:634

Performance Gain (vs C vectorized)
ARGB1555ToARGBRow_MSA     - 1.85
ARGB1555ToARGBRow_Any_MSA - 1.82
RGB565ToARGBRow_MSA       - 2.14
RGB565ToARGBRow_Any_MSA   - 2.08
RGB24ToARGBRow_MSA        - 8.57
RGB24ToARGBRow_Any_MSA    - 7.42
RAWToARGBRow_MSA          - 8.57
RAWToARGBRow_Any_MSA      - 7.42
ARGB1555ToYRow_MSA        - 2.60
ARGB1555ToYRow_Any_MSA    - 2.47
RGB565ToYRow_MSA          - 2.45
RGB565ToYRow_Any_MSA      - 2.33
RGB24ToYRow_MSA           - 2.23
RGB24ToYRow_Any_MSA       - 2.01
RAWToYRow_MSA             - 2.25
RAWToYRow_Any_MSA         - 2.02
ARGB1555ToUVRow_MSA       - 1.40
ARGB1555ToUVRow_Any_MSA   - 1.37
RGB565ToUVRow_MSA         - 1.68
RGB565ToUVRow_Any_MSA     - 1.63
RGB24ToUVRow_MSA          - 3.02
RGB24ToUVRow_Any_MSA      - 2.87
RAWToUVRow_MSA            - 3.04
RAWToUVRow_Any_MSA        - 2.85

Performance Gain (vs C non-vectorized)
ARGB1555ToARGBRow_MSA     - 4.66
ARGB1555ToARGBRow_Any_MSA - 4.45
RGB565ToARGBRow_MSA       - 5.58
RGB565ToARGBRow_Any_MSA   - 5.34
RGB24ToARGBRow_MSA        - 8.57
RGB24ToARGBRow_Any_MSA    - 7.42
RAWToARGBRow_MSA          - 8.57
RAWToARGBRow_Any_MSA      - 7.42
ARGB1555ToYRow_MSA        - 6.38
ARGB1555ToYRow_Any_MSA    - 5.98
RGB565ToYRow_MSA          - 6.42
RGB565ToYRow_Any_MSA      - 6.05
RGB24ToYRow_MSA           - 7.87
RGB24ToYRow_Any_MSA       - 7.01
RAWToYRow_MSA             - 7.98
RAWToYRow_Any_MSA         - 7.01
ARGB1555ToUVRow_MSA       - 5.39
ARGB1555ToUVRow_Any_MSA   - 5.06
RGB565ToUVRow_MSA         - 6.39
RGB565ToUVRow_Any_MSA     - 5.90
RGB24ToUVRow_MSA          - 3.04
RGB24ToUVRow_Any_MSA      - 2.87
RAWToUVRow_MSA            - 3.04
RAWToUVRow_Any_MSA        - 2.88

Review-Url: https://codereview.chromium.org/2600713002 .
parent cb115594
......@@ -416,6 +416,18 @@ extern "C" {
#define HAS_ARGBSHADEROW_MSA
#define HAS_ARGBGRAYROW_MSA
#define HAS_ARGBSEPIAROW_MSA
#define HAS_ARGB1555TOARGBROW_MSA
#define HAS_RGB565TOARGBROW_MSA
#define HAS_RGB24TOARGBROW_MSA
#define HAS_RAWTOARGBROW_MSA
#define HAS_ARGB1555TOYROW_MSA
#define HAS_RGB565TOYROW_MSA
#define HAS_RGB24TOYROW_MSA
#define HAS_RAWTOYROW_MSA
#define HAS_ARGB1555TOUVROW_MSA
#define HAS_RGB565TOUVROW_MSA
#define HAS_RGB24TOUVROW_MSA
#define HAS_RAWTOUVROW_MSA
#endif
#if defined(_MSC_VER) && !defined(__CLR_VER) && !defined(__clang__)
......@@ -822,6 +834,26 @@ void ARGB4444ToUVRow_NEON(const uint8* src_argb4444,
uint8* dst_u,
uint8* dst_v,
int width);
void RGB24ToUVRow_MSA(const uint8* src_rgb24,
int src_stride_rgb24,
uint8* dst_u,
uint8* dst_v,
int width);
void RAWToUVRow_MSA(const uint8* src_raw,
int src_stride_raw,
uint8* dst_u,
uint8* dst_v,
int width);
void RGB565ToUVRow_MSA(const uint8* src_rgb565,
int src_stride_rgb565,
uint8* dst_u,
uint8* dst_v,
int width);
void ARGB1555ToUVRow_MSA(const uint8* src_argb1555,
int src_stride_argb1555,
uint8* dst_u,
uint8* dst_v,
int width);
void BGRAToYRow_NEON(const uint8* src_bgra, uint8* dst_y, int width);
void ABGRToYRow_NEON(const uint8* src_abgr, uint8* dst_y, int width);
void RGBAToYRow_NEON(const uint8* src_rgba, uint8* dst_y, int width);
......@@ -830,6 +862,10 @@ void RAWToYRow_NEON(const uint8* src_raw, uint8* dst_y, int width);
void RGB565ToYRow_NEON(const uint8* src_rgb565, uint8* dst_y, int width);
void ARGB1555ToYRow_NEON(const uint8* src_argb1555, uint8* dst_y, int width);
void ARGB4444ToYRow_NEON(const uint8* src_argb4444, uint8* dst_y, int width);
void RGB24ToYRow_MSA(const uint8* src_rgb24, uint8* dst_y, int width);
void RAWToYRow_MSA(const uint8* src_raw, uint8* dst_y, int width);
void RGB565ToYRow_MSA(const uint8* src_rgb565, uint8* dst_y, int width);
void ARGB1555ToYRow_MSA(const uint8* src_argb1555, uint8* dst_y, int width);
void BGRAToUVRow_DSPR2(const uint8* src_bgra,
int src_stride_bgra,
uint8* dst_u,
......@@ -890,6 +926,10 @@ void ARGB4444ToYRow_Any_NEON(const uint8* src_argb4444,
uint8* dst_y,
int width);
void ARGBToYRow_Any_MSA(const uint8* src_argb, uint8* dst_y, int width);
void RGB24ToYRow_Any_MSA(const uint8* src_rgb24, uint8* dst_y, int width);
void RAWToYRow_Any_MSA(const uint8* src_raw, uint8* dst_y, int width);
void RGB565ToYRow_Any_MSA(const uint8* src_rgb565, uint8* dst_y, int width);
void ARGB1555ToYRow_Any_MSA(const uint8* src_argb1555, uint8* dst_y, int width);
void ARGBToUVRow_AVX2(const uint8* src_argb,
int src_stride_argb,
......@@ -1024,6 +1064,26 @@ void ARGB4444ToUVRow_Any_NEON(const uint8* src_argb4444,
uint8* dst_u,
uint8* dst_v,
int width);
void RGB24ToUVRow_Any_MSA(const uint8* src_rgb24,
int src_stride_rgb24,
uint8* dst_u,
uint8* dst_v,
int width);
void RAWToUVRow_Any_MSA(const uint8* src_raw,
int src_stride_raw,
uint8* dst_u,
uint8* dst_v,
int width);
void RGB565ToUVRow_Any_MSA(const uint8* src_rgb565,
int src_stride_rgb565,
uint8* dst_u,
uint8* dst_v,
int width);
void ARGB1555ToUVRow_Any_MSA(const uint8* src_argb1555,
int src_stride_argb1555,
uint8* dst_u,
uint8* dst_v,
int width);
void BGRAToUVRow_Any_DSPR2(const uint8* src_bgra,
int src_stride_bgra,
uint8* dst_u,
......@@ -1341,12 +1401,18 @@ void ARGB4444ToARGBRow_AVX2(const uint8* src_argb4444,
int width);
void RGB24ToARGBRow_NEON(const uint8* src_rgb24, uint8* dst_argb, int width);
void RGB24ToARGBRow_MSA(const uint8* src_rgb24, uint8* dst_argb, int width);
void RAWToARGBRow_NEON(const uint8* src_raw, uint8* dst_argb, int width);
void RAWToARGBRow_MSA(const uint8* src_raw, uint8* dst_argb, int width);
void RAWToRGB24Row_NEON(const uint8* src_raw, uint8* dst_rgb24, int width);
void RGB565ToARGBRow_NEON(const uint8* src_rgb565, uint8* dst_argb, int width);
void RGB565ToARGBRow_MSA(const uint8* src_rgb565, uint8* dst_argb, int width);
void ARGB1555ToARGBRow_NEON(const uint8* src_argb1555,
uint8* dst_argb,
int width);
void ARGB1555ToARGBRow_MSA(const uint8* src_argb1555,
uint8* dst_argb,
int width);
void ARGB4444ToARGBRow_NEON(const uint8* src_argb4444,
uint8* dst_argb,
int width);
......@@ -1396,14 +1462,22 @@ void ARGB4444ToARGBRow_Any_AVX2(const uint8* src_argb4444,
void RGB24ToARGBRow_Any_NEON(const uint8* src_rgb24,
uint8* dst_argb,
int width);
void RGB24ToARGBRow_Any_MSA(const uint8* src_rgb24, uint8* dst_argb, int width);
void RAWToARGBRow_Any_NEON(const uint8* src_raw, uint8* dst_argb, int width);
void RAWToARGBRow_Any_MSA(const uint8* src_raw, uint8* dst_argb, int width);
void RAWToRGB24Row_Any_NEON(const uint8* src_raw, uint8* dst_rgb24, int width);
void RGB565ToARGBRow_Any_NEON(const uint8* src_rgb565,
uint8* dst_argb,
int width);
void RGB565ToARGBRow_Any_MSA(const uint8* src_rgb565,
uint8* dst_argb,
int width);
void ARGB1555ToARGBRow_Any_NEON(const uint8* src_argb1555,
uint8* dst_argb,
int width);
void ARGB1555ToARGBRow_Any_MSA(const uint8* src_argb1555,
uint8* dst_argb,
int width);
void ARGB4444ToARGBRow_Any_NEON(const uint8* src_argb4444,
uint8* dst_argb,
int width);
......
......@@ -896,7 +896,7 @@ int RGB24ToI420(const uint8* src_rgb24,
int width,
int height) {
int y;
#if defined(HAS_RGB24TOYROW_NEON)
#if (defined(HAS_RGB24TOYROW_NEON) || defined(HAS_RGB24TOYROW_MSA))
void (*RGB24ToUVRow)(const uint8* src_rgb24, int src_stride_rgb24,
uint8* dst_u, uint8* dst_v, int width) = RGB24ToUVRow_C;
void (*RGB24ToYRow)(const uint8* src_rgb24, uint8* dst_y, int width) =
......@@ -931,6 +931,15 @@ int RGB24ToI420(const uint8* src_rgb24,
}
}
}
#elif defined(HAS_RGB24TOYROW_MSA)
if (TestCpuFlag(kCpuHasMSA)) {
RGB24ToUVRow = RGB24ToUVRow_Any_MSA;
RGB24ToYRow = RGB24ToYRow_Any_MSA;
if (IS_ALIGNED(width, 16)) {
RGB24ToYRow = RGB24ToYRow_MSA;
RGB24ToUVRow = RGB24ToUVRow_MSA;
}
}
// Other platforms do intermediate conversion from RGB24 to ARGB.
#else
#if defined(HAS_RGB24TOARGBROW_SSSE3)
......@@ -968,16 +977,16 @@ int RGB24ToI420(const uint8* src_rgb24,
#endif
for (y = 0; y < height - 1; y += 2) {
#if defined(HAS_RGB24TOYROW_NEON)
#if (defined(HAS_RGB24TOYROW_NEON) || defined(HAS_RGB24TOYROW_MSA))
RGB24ToUVRow(src_rgb24, src_stride_rgb24, dst_u, dst_v, width);
RGB24ToYRow(src_rgb24, dst_y, width);
RGB24ToYRow(src_rgb24 + src_stride_rgb24, dst_y + dst_stride_y, width);
#else
RGB24ToARGBRow(src_rgb24, row, width);
RGB24ToARGBRow(src_rgb24 + src_stride_rgb24, row + kRowSize, width);
ARGBToUVRow(row, kRowSize, dst_u, dst_v, width);
ARGBToYRow(row, dst_y, width);
ARGBToYRow(row + kRowSize, dst_y + dst_stride_y, width);
RGB24ToARGBRow(src_rgb24, row, width);
RGB24ToARGBRow(src_rgb24 + src_stride_rgb24, row + kRowSize, width);
ARGBToUVRow(row, kRowSize, dst_u, dst_v, width);
ARGBToYRow(row, dst_y, width);
ARGBToYRow(row + kRowSize, dst_y + dst_stride_y, width);
#endif
src_rgb24 += src_stride_rgb24 * 2;
dst_y += dst_stride_y * 2;
......@@ -985,16 +994,16 @@ int RGB24ToI420(const uint8* src_rgb24,
dst_v += dst_stride_v;
}
if (height & 1) {
#if defined(HAS_RGB24TOYROW_NEON)
#if (defined(HAS_RGB24TOYROW_NEON) || defined(HAS_RGB24TOYROW_MSA))
RGB24ToUVRow(src_rgb24, 0, dst_u, dst_v, width);
RGB24ToYRow(src_rgb24, dst_y, width);
#else
RGB24ToARGBRow(src_rgb24, row, width);
ARGBToUVRow(row, 0, dst_u, dst_v, width);
ARGBToYRow(row, dst_y, width);
RGB24ToARGBRow(src_rgb24, row, width);
ARGBToUVRow(row, 0, dst_u, dst_v, width);
ARGBToYRow(row, dst_y, width);
#endif
}
#if !defined(HAS_RGB24TOYROW_NEON)
#if !(defined(HAS_RGB24TOYROW_NEON) || defined(HAS_RGB24TOYROW_MSA))
free_aligned_buffer_64(row);
}
#endif
......@@ -1014,18 +1023,18 @@ int RAWToI420(const uint8* src_raw,
int width,
int height) {
int y;
#if defined(HAS_RAWTOYROW_NEON)
#if (defined(HAS_RAWTOYROW_NEON) || defined(HAS_RAWTOYROW_MSA))
void (*RAWToUVRow)(const uint8* src_raw, int src_stride_raw, uint8* dst_u,
uint8* dst_v, int width) = RAWToUVRow_C;
void (*RAWToYRow)(const uint8* src_raw, uint8* dst_y, int width) =
RAWToYRow_C;
#else
void (*RAWToARGBRow)(const uint8* src_rgb, uint8* dst_argb, int width) =
RAWToARGBRow_C;
void (*ARGBToUVRow)(const uint8* src_argb0, int src_stride_argb,
uint8* dst_u, uint8* dst_v, int width) = ARGBToUVRow_C;
void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int width) =
ARGBToYRow_C;
void (*RAWToARGBRow)(const uint8* src_rgb, uint8* dst_argb, int width) =
RAWToARGBRow_C;
void (*ARGBToUVRow)(const uint8* src_argb0, int src_stride_argb, uint8* dst_u,
uint8* dst_v, int width) = ARGBToUVRow_C;
void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int width) =
ARGBToYRow_C;
#endif
if (!src_raw || !dst_y || !dst_u || !dst_v || width <= 0 || height == 0) {
return -1;
......@@ -1049,6 +1058,15 @@ int RAWToI420(const uint8* src_raw,
}
}
}
#elif defined(HAS_RAWTOYROW_MSA)
if (TestCpuFlag(kCpuHasMSA)) {
RAWToUVRow = RAWToUVRow_Any_MSA;
RAWToYRow = RAWToYRow_Any_MSA;
if (IS_ALIGNED(width, 16)) {
RAWToYRow = RAWToYRow_MSA;
RAWToUVRow = RAWToUVRow_MSA;
}
}
// Other platforms do intermediate conversion from RAW to ARGB.
#else
#if defined(HAS_RAWTOARGBROW_SSSE3)
......@@ -1094,16 +1112,16 @@ int RAWToI420(const uint8* src_raw,
#endif
for (y = 0; y < height - 1; y += 2) {
#if defined(HAS_RAWTOYROW_NEON)
#if (defined(HAS_RAWTOYROW_NEON) || defined(HAS_RAWTOYROW_MSA))
RAWToUVRow(src_raw, src_stride_raw, dst_u, dst_v, width);
RAWToYRow(src_raw, dst_y, width);
RAWToYRow(src_raw + src_stride_raw, dst_y + dst_stride_y, width);
#else
RAWToARGBRow(src_raw, row, width);
RAWToARGBRow(src_raw + src_stride_raw, row + kRowSize, width);
ARGBToUVRow(row, kRowSize, dst_u, dst_v, width);
ARGBToYRow(row, dst_y, width);
ARGBToYRow(row + kRowSize, dst_y + dst_stride_y, width);
RAWToARGBRow(src_raw, row, width);
RAWToARGBRow(src_raw + src_stride_raw, row + kRowSize, width);
ARGBToUVRow(row, kRowSize, dst_u, dst_v, width);
ARGBToYRow(row, dst_y, width);
ARGBToYRow(row + kRowSize, dst_y + dst_stride_y, width);
#endif
src_raw += src_stride_raw * 2;
dst_y += dst_stride_y * 2;
......@@ -1111,16 +1129,16 @@ int RAWToI420(const uint8* src_raw,
dst_v += dst_stride_v;
}
if (height & 1) {
#if defined(HAS_RAWTOYROW_NEON)
#if (defined(HAS_RAWTOYROW_NEON) || defined(HAS_RAWTOYROW_MSA))
RAWToUVRow(src_raw, 0, dst_u, dst_v, width);
RAWToYRow(src_raw, dst_y, width);
#else
RAWToARGBRow(src_raw, row, width);
ARGBToUVRow(row, 0, dst_u, dst_v, width);
ARGBToYRow(row, dst_y, width);
RAWToARGBRow(src_raw, row, width);
ARGBToUVRow(row, 0, dst_u, dst_v, width);
ARGBToYRow(row, dst_y, width);
#endif
}
#if !defined(HAS_RAWTOYROW_NEON)
#if !(defined(HAS_RAWTOYROW_NEON) || defined(HAS_RAWTOYROW_MSA))
free_aligned_buffer_64(row);
}
#endif
......@@ -1140,20 +1158,19 @@ int RGB565ToI420(const uint8* src_rgb565,
int width,
int height) {
int y;
#if defined(HAS_RGB565TOYROW_NEON)
#if (defined(HAS_RGB565TOYROW_NEON) || defined(HAS_RGB565TOYROW_MSA))
void (*RGB565ToUVRow)(const uint8* src_rgb565, int src_stride_rgb565,
uint8* dst_u, uint8* dst_v, int width) =
RGB565ToUVRow_C;
void (*RGB565ToYRow)(const uint8* src_rgb565, uint8* dst_y, int width) =
RGB565ToYRow_C;
#else
void (*RGB565ToARGBRow)(const uint8* src_rgb, uint8* dst_argb,
int width) = RGB565ToARGBRow_C;
void (*ARGBToUVRow)(const uint8* src_argb0, int src_stride_argb,
uint8* dst_u, uint8* dst_v, int width) =
ARGBToUVRow_C;
void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int width) =
ARGBToYRow_C;
void (*RGB565ToARGBRow)(const uint8* src_rgb, uint8* dst_argb, int width) =
RGB565ToARGBRow_C;
void (*ARGBToUVRow)(const uint8* src_argb0, int src_stride_argb, uint8* dst_u,
uint8* dst_v, int width) = ARGBToUVRow_C;
void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int width) =
ARGBToYRow_C;
#endif
if (!src_rgb565 || !dst_y || !dst_u || !dst_v || width <= 0 || height == 0) {
return -1;
......@@ -1177,6 +1194,15 @@ int RGB565ToI420(const uint8* src_rgb565,
}
}
}
#elif defined(HAS_RGB565TOYROW_MSA)
if (TestCpuFlag(kCpuHasMSA)) {
RGB565ToUVRow = RGB565ToUVRow_Any_MSA;
RGB565ToYRow = RGB565ToYRow_Any_MSA;
if (IS_ALIGNED(width, 16)) {
RGB565ToYRow = RGB565ToYRow_MSA;
RGB565ToUVRow = RGB565ToUVRow_MSA;
}
}
// Other platforms do intermediate conversion from RGB565 to ARGB.
#else
#if defined(HAS_RGB565TOARGBROW_SSE2)
......@@ -1230,17 +1256,16 @@ int RGB565ToI420(const uint8* src_rgb565,
#endif
for (y = 0; y < height - 1; y += 2) {
#if defined(HAS_RGB565TOYROW_NEON)
#if (defined(HAS_RGB565TOYROW_NEON) || defined(HAS_RGB565TOYROW_MSA))
RGB565ToUVRow(src_rgb565, src_stride_rgb565, dst_u, dst_v, width);
RGB565ToYRow(src_rgb565, dst_y, width);
RGB565ToYRow(src_rgb565 + src_stride_rgb565, dst_y + dst_stride_y, width);
#else
RGB565ToARGBRow(src_rgb565, row, width);
RGB565ToARGBRow(src_rgb565 + src_stride_rgb565, row + kRowSize,
width);
ARGBToUVRow(row, kRowSize, dst_u, dst_v, width);
ARGBToYRow(row, dst_y, width);
ARGBToYRow(row + kRowSize, dst_y + dst_stride_y, width);
RGB565ToARGBRow(src_rgb565, row, width);
RGB565ToARGBRow(src_rgb565 + src_stride_rgb565, row + kRowSize, width);
ARGBToUVRow(row, kRowSize, dst_u, dst_v, width);
ARGBToYRow(row, dst_y, width);
ARGBToYRow(row + kRowSize, dst_y + dst_stride_y, width);
#endif
src_rgb565 += src_stride_rgb565 * 2;
dst_y += dst_stride_y * 2;
......@@ -1248,16 +1273,16 @@ int RGB565ToI420(const uint8* src_rgb565,
dst_v += dst_stride_v;
}
if (height & 1) {
#if defined(HAS_RGB565TOYROW_NEON)
#if (defined(HAS_RGB565TOYROW_NEON) || defined(HAS_RGB565TOYROW_MSA))
RGB565ToUVRow(src_rgb565, 0, dst_u, dst_v, width);
RGB565ToYRow(src_rgb565, dst_y, width);
#else
RGB565ToARGBRow(src_rgb565, row, width);
ARGBToUVRow(row, 0, dst_u, dst_v, width);
ARGBToYRow(row, dst_y, width);
RGB565ToARGBRow(src_rgb565, row, width);
ARGBToUVRow(row, 0, dst_u, dst_v, width);
ARGBToYRow(row, dst_y, width);
#endif
}
#if !defined(HAS_RGB565TOYROW_NEON)
#if !(defined(HAS_RGB565TOYROW_NEON) || defined(HAS_RGB565TOYROW_MSA))
free_aligned_buffer_64(row);
}
#endif
......@@ -1277,20 +1302,19 @@ int ARGB1555ToI420(const uint8* src_argb1555,
int width,
int height) {
int y;
#if defined(HAS_ARGB1555TOYROW_NEON)
#if (defined(HAS_ARGB1555TOYROW_NEON) || defined(HAS_ARGB1555TOYROW_MSA))
void (*ARGB1555ToUVRow)(const uint8* src_argb1555, int src_stride_argb1555,
uint8* dst_u, uint8* dst_v, int width) =
ARGB1555ToUVRow_C;
void (*ARGB1555ToYRow)(const uint8* src_argb1555, uint8* dst_y, int width) =
ARGB1555ToYRow_C;
#else
void (*ARGB1555ToARGBRow)(const uint8* src_rgb, uint8* dst_argb,
int width) = ARGB1555ToARGBRow_C;
void (*ARGBToUVRow)(const uint8* src_argb0, int src_stride_argb,
uint8* dst_u, uint8* dst_v, int width) =
ARGBToUVRow_C;
void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int width) =
ARGBToYRow_C;
void (*ARGB1555ToARGBRow)(const uint8* src_rgb, uint8* dst_argb, int width) =
ARGB1555ToARGBRow_C;
void (*ARGBToUVRow)(const uint8* src_argb0, int src_stride_argb, uint8* dst_u,
uint8* dst_v, int width) = ARGBToUVRow_C;
void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int width) =
ARGBToYRow_C;
#endif
if (!src_argb1555 || !dst_y || !dst_u || !dst_v || width <= 0 ||
height == 0) {
......@@ -1315,6 +1339,15 @@ int ARGB1555ToI420(const uint8* src_argb1555,
}
}
}
#elif defined(HAS_ARGB1555TOYROW_MSA)
if (TestCpuFlag(kCpuHasMSA)) {
ARGB1555ToUVRow = ARGB1555ToUVRow_Any_MSA;
ARGB1555ToYRow = ARGB1555ToYRow_Any_MSA;
if (IS_ALIGNED(width, 16)) {
ARGB1555ToYRow = ARGB1555ToYRow_MSA;
ARGB1555ToUVRow = ARGB1555ToUVRow_MSA;
}
}
// Other platforms do intermediate conversion from ARGB1555 to ARGB.
#else
#if defined(HAS_ARGB1555TOARGBROW_SSE2)
......@@ -1360,18 +1393,18 @@ int ARGB1555ToI420(const uint8* src_argb1555,
#endif
for (y = 0; y < height - 1; y += 2) {
#if defined(HAS_ARGB1555TOYROW_NEON)
#if (defined(HAS_ARGB1555TOYROW_NEON) || defined(HAS_ARGB1555TOYROW_MSA))
ARGB1555ToUVRow(src_argb1555, src_stride_argb1555, dst_u, dst_v, width);
ARGB1555ToYRow(src_argb1555, dst_y, width);
ARGB1555ToYRow(src_argb1555 + src_stride_argb1555, dst_y + dst_stride_y,
width);
#else
ARGB1555ToARGBRow(src_argb1555, row, width);
ARGB1555ToARGBRow(src_argb1555 + src_stride_argb1555,
row + kRowSize, width);
ARGBToUVRow(row, kRowSize, dst_u, dst_v, width);
ARGBToYRow(row, dst_y, width);
ARGBToYRow(row + kRowSize, dst_y + dst_stride_y, width);
ARGB1555ToARGBRow(src_argb1555, row, width);
ARGB1555ToARGBRow(src_argb1555 + src_stride_argb1555, row + kRowSize,
width);
ARGBToUVRow(row, kRowSize, dst_u, dst_v, width);
ARGBToYRow(row, dst_y, width);
ARGBToYRow(row + kRowSize, dst_y + dst_stride_y, width);
#endif
src_argb1555 += src_stride_argb1555 * 2;
dst_y += dst_stride_y * 2;
......@@ -1379,16 +1412,16 @@ int ARGB1555ToI420(const uint8* src_argb1555,
dst_v += dst_stride_v;
}
if (height & 1) {
#if defined(HAS_ARGB1555TOYROW_NEON)
#if (defined(HAS_ARGB1555TOYROW_NEON) || defined(HAS_ARGB1555TOYROW_MSA))
ARGB1555ToUVRow(src_argb1555, 0, dst_u, dst_v, width);
ARGB1555ToYRow(src_argb1555, dst_y, width);
#else
ARGB1555ToARGBRow(src_argb1555, row, width);
ARGBToUVRow(row, 0, dst_u, dst_v, width);
ARGBToYRow(row, dst_y, width);
ARGB1555ToARGBRow(src_argb1555, row, width);
ARGBToUVRow(row, 0, dst_u, dst_v, width);
ARGBToYRow(row, dst_y, width);
#endif
}
#if !defined(HAS_ARGB1555TOYROW_NEON)
#if !(defined(HAS_ARGB1555TOYROW_NEON) || defined(HAS_ARGB1555TOYROW_MSA))
free_aligned_buffer_64(row);
}
#endif
......@@ -1415,13 +1448,12 @@ int ARGB4444ToI420(const uint8* src_argb4444,
void (*ARGB4444ToYRow)(const uint8* src_argb4444, uint8* dst_y, int width) =
ARGB4444ToYRow_C;
#else
void (*ARGB4444ToARGBRow)(const uint8* src_rgb, uint8* dst_argb,
int width) = ARGB4444ToARGBRow_C;
void (*ARGBToUVRow)(const uint8* src_argb0, int src_stride_argb,
uint8* dst_u, uint8* dst_v, int width) =
ARGBToUVRow_C;
void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int width) =
ARGBToYRow_C;
void (*ARGB4444ToARGBRow)(const uint8* src_rgb, uint8* dst_argb, int width) =
ARGB4444ToARGBRow_C;
void (*ARGBToUVRow)(const uint8* src_argb0, int src_stride_argb, uint8* dst_u,
uint8* dst_v, int width) = ARGBToUVRow_C;
void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int width) =
ARGBToYRow_C;
#endif
if (!src_argb4444 || !dst_y || !dst_u || !dst_v || width <= 0 ||
height == 0) {
......@@ -1449,65 +1481,65 @@ int ARGB4444ToI420(const uint8* src_argb4444,
// Other platforms do intermediate conversion from ARGB4444 to ARGB.
#else
#if defined(HAS_ARGB4444TOARGBROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2)) {
ARGB4444ToARGBRow = ARGB4444ToARGBRow_Any_SSE2;
if (IS_ALIGNED(width, 8)) {
ARGB4444ToARGBRow = ARGB4444ToARGBRow_SSE2;
}
}
if (TestCpuFlag(kCpuHasSSE2)) {
ARGB4444ToARGBRow = ARGB4444ToARGBRow_Any_SSE2;
if (IS_ALIGNED(width, 8)) {
ARGB4444ToARGBRow = ARGB4444ToARGBRow_SSE2;
}
}
#endif
#if defined(HAS_ARGB4444TOARGBROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
ARGB4444ToARGBRow = ARGB4444ToARGBRow_Any_AVX2;
if (IS_ALIGNED(width, 16)) {
ARGB4444ToARGBRow = ARGB4444ToARGBRow_AVX2;
}
}
if (TestCpuFlag(kCpuHasAVX2)) {
ARGB4444ToARGBRow = ARGB4444ToARGBRow_Any_AVX2;
if (IS_ALIGNED(width, 16)) {
ARGB4444ToARGBRow = ARGB4444ToARGBRow_AVX2;
}
}
#endif
#if defined(HAS_ARGB4444TOARGBROW_MSA)
if (TestCpuFlag(kCpuHasMSA)) {
ARGB4444ToARGBRow = ARGB4444ToARGBRow_Any_MSA;
if (IS_ALIGNED(width, 16)) {
ARGB4444ToARGBRow = ARGB4444ToARGBRow_MSA;
}
}
if (TestCpuFlag(kCpuHasMSA)) {
ARGB4444ToARGBRow = ARGB4444ToARGBRow_Any_MSA;
if (IS_ALIGNED(width, 16)) {
ARGB4444ToARGBRow = ARGB4444ToARGBRow_MSA;
}
}
#endif
#if defined(HAS_ARGBTOYROW_SSSE3) && defined(HAS_ARGBTOUVROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3)) {
ARGBToUVRow = ARGBToUVRow_Any_SSSE3;
ARGBToYRow = ARGBToYRow_Any_SSSE3;
if (IS_ALIGNED(width, 16)) {
ARGBToUVRow = ARGBToUVRow_SSSE3;
ARGBToYRow = ARGBToYRow_SSSE3;
}
}
if (TestCpuFlag(kCpuHasSSSE3)) {
ARGBToUVRow = ARGBToUVRow_Any_SSSE3;
ARGBToYRow = ARGBToYRow_Any_SSSE3;
if (IS_ALIGNED(width, 16)) {
ARGBToUVRow = ARGBToUVRow_SSSE3;
ARGBToYRow = ARGBToYRow_SSSE3;
}
}
#endif
#if defined(HAS_ARGBTOYROW_AVX2) && defined(HAS_ARGBTOUVROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
ARGBToUVRow = ARGBToUVRow_Any_AVX2;
ARGBToYRow = ARGBToYRow_Any_AVX2;
if (IS_ALIGNED(width, 32)) {
ARGBToUVRow = ARGBToUVRow_AVX2;
ARGBToYRow = ARGBToYRow_AVX2;
}
}
if (TestCpuFlag(kCpuHasAVX2)) {
ARGBToUVRow = ARGBToUVRow_Any_AVX2;
ARGBToYRow = ARGBToYRow_Any_AVX2;
if (IS_ALIGNED(width, 32)) {
ARGBToUVRow = ARGBToUVRow_AVX2;
ARGBToYRow = ARGBToYRow_AVX2;
}
}
#endif
#if defined(HAS_ARGBTOYROW_MSA)
if (TestCpuFlag(kCpuHasMSA)) {
ARGBToUVRow = ARGBToUVRow_Any_MSA;
ARGBToYRow = ARGBToYRow_Any_MSA;
if (IS_ALIGNED(width, 16)) {
ARGBToYRow = ARGBToYRow_MSA;
if (IS_ALIGNED(width, 32)) {
ARGBToUVRow = ARGBToUVRow_MSA;
}
}
}
if (TestCpuFlag(kCpuHasMSA)) {
ARGBToUVRow = ARGBToUVRow_Any_MSA;
ARGBToYRow = ARGBToYRow_Any_MSA;
if (IS_ALIGNED(width, 16)) {
ARGBToYRow = ARGBToYRow_MSA;
if (IS_ALIGNED(width, 32)) {
ARGBToUVRow = ARGBToUVRow_MSA;
}
}
}
#endif
{
// Allocate 2 rows of ARGB.
const int kRowSize = (width * 4 + 31) & ~31;
align_buffer_64(row, kRowSize * 2);
{
// Allocate 2 rows of ARGB.
const int kRowSize = (width * 4 + 31) & ~31;
align_buffer_64(row, kRowSize * 2);
#endif
for (y = 0; y < height - 1; y += 2) {
......@@ -1517,12 +1549,12 @@ int ARGB4444ToI420(const uint8* src_argb4444,
ARGB4444ToYRow(src_argb4444 + src_stride_argb4444, dst_y + dst_stride_y,
width);
#else
ARGB4444ToARGBRow(src_argb4444, row, width);
ARGB4444ToARGBRow(src_argb4444 + src_stride_argb4444,
row + kRowSize, width);
ARGBToUVRow(row, kRowSize, dst_u, dst_v, width);
ARGBToYRow(row, dst_y, width);
ARGBToYRow(row + kRowSize, dst_y + dst_stride_y, width);
ARGB4444ToARGBRow(src_argb4444, row, width);
ARGB4444ToARGBRow(src_argb4444 + src_stride_argb4444, row + kRowSize,
width);
ARGBToUVRow(row, kRowSize, dst_u, dst_v, width);
ARGBToYRow(row, dst_y, width);
ARGBToYRow(row + kRowSize, dst_y + dst_stride_y, width);
#endif
src_argb4444 += src_stride_argb4444 * 2;
dst_y += dst_stride_y * 2;
......@@ -1534,9 +1566,9 @@ int ARGB4444ToI420(const uint8* src_argb4444,
ARGB4444ToUVRow(src_argb4444, 0, dst_u, dst_v, width);
ARGB4444ToYRow(src_argb4444, dst_y, width);
#else
ARGB4444ToARGBRow(src_argb4444, row, width);
ARGBToUVRow(row, 0, dst_u, dst_v, width);
ARGBToYRow(row, dst_y, width);
ARGB4444ToARGBRow(src_argb4444, row, width);
ARGBToUVRow(row, 0, dst_u, dst_v, width);
ARGBToYRow(row, dst_y, width);
#endif
}
#if !defined(HAS_ARGB4444TOYROW_NEON)
......
......@@ -962,6 +962,14 @@ int RGB24ToARGB(const uint8* src_rgb24,
}
}
#endif
#if defined(HAS_RGB24TOARGBROW_MSA)
if (TestCpuFlag(kCpuHasMSA)) {
RGB24ToARGBRow = RGB24ToARGBRow_Any_MSA;
if (IS_ALIGNED(width, 16)) {
RGB24ToARGBRow = RGB24ToARGBRow_MSA;
}
}
#endif
for (y = 0; y < height; ++y) {
RGB24ToARGBRow(src_rgb24, dst_argb, width);
......@@ -1021,6 +1029,14 @@ int RAWToARGB(const uint8* src_raw,
}
}
#endif
#if defined(HAS_RAWTOARGBROW_MSA)
if (TestCpuFlag(kCpuHasMSA)) {
RAWToARGBRow = RAWToARGBRow_Any_MSA;
if (IS_ALIGNED(width, 16)) {
RAWToARGBRow = RAWToARGBRow_MSA;
}
}
#endif
for (y = 0; y < height; ++y) {
RAWToARGBRow(src_raw, dst_argb, width);
......@@ -1088,6 +1104,14 @@ int RGB565ToARGB(const uint8* src_rgb565,
}
}
#endif
#if defined(HAS_RGB565TOARGBROW_MSA)
if (TestCpuFlag(kCpuHasMSA)) {
RGB565ToARGBRow = RGB565ToARGBRow_Any_MSA;
if (IS_ALIGNED(width, 16)) {
RGB565ToARGBRow = RGB565ToARGBRow_MSA;
}
}
#endif
for (y = 0; y < height; ++y) {
RGB565ToARGBRow(src_rgb565, dst_argb, width);
......@@ -1155,6 +1179,14 @@ int ARGB1555ToARGB(const uint8* src_argb1555,
}
}
#endif
#if defined(HAS_ARGB1555TOARGBROW_MSA)
if (TestCpuFlag(kCpuHasMSA)) {
ARGB1555ToARGBRow = ARGB1555ToARGBRow_Any_MSA;
if (IS_ALIGNED(width, 16)) {
ARGB1555ToARGBRow = ARGB1555ToARGBRow_MSA;
}
}
#endif
for (y = 0; y < height; ++y) {
ARGB1555ToARGBRow(src_argb1555, dst_argb, width);
......
......@@ -454,15 +454,27 @@ ANY11(RGBAToYRow_Any_NEON, RGBAToYRow_NEON, 0, 4, 1, 7)
#ifdef HAS_RGB24TOYROW_NEON
ANY11(RGB24ToYRow_Any_NEON, RGB24ToYRow_NEON, 0, 3, 1, 7)
#endif
#ifdef HAS_RGB24TOYROW_MSA
ANY11(RGB24ToYRow_Any_MSA, RGB24ToYRow_MSA, 0, 3, 1, 15)
#endif
#ifdef HAS_RAWTOYROW_NEON
ANY11(RAWToYRow_Any_NEON, RAWToYRow_NEON, 0, 3, 1, 7)
#endif
#ifdef HAS_RAWTOYROW_MSA
ANY11(RAWToYRow_Any_MSA, RAWToYRow_MSA, 0, 3, 1, 15)
#endif
#ifdef HAS_RGB565TOYROW_NEON
ANY11(RGB565ToYRow_Any_NEON, RGB565ToYRow_NEON, 0, 2, 1, 7)
#endif
#ifdef HAS_RGB565TOYROW_MSA
ANY11(RGB565ToYRow_Any_MSA, RGB565ToYRow_MSA, 0, 2, 1, 15)
#endif
#ifdef HAS_ARGB1555TOYROW_NEON
ANY11(ARGB1555ToYRow_Any_NEON, ARGB1555ToYRow_NEON, 0, 2, 1, 7)
#endif
#ifdef HAS_ARGB1555TOYROW_MSA
ANY11(ARGB1555ToYRow_Any_MSA, ARGB1555ToYRow_MSA, 0, 2, 1, 15)
#endif
#ifdef HAS_ARGB4444TOYROW_NEON
ANY11(ARGB4444ToYRow_Any_NEON, ARGB4444ToYRow_NEON, 0, 2, 1, 7)
#endif
......@@ -481,15 +493,27 @@ ANY11(UYVYToYRow_Any_MSA, UYVYToYRow_MSA, 1, 4, 1, 31)
#ifdef HAS_RGB24TOARGBROW_NEON
ANY11(RGB24ToARGBRow_Any_NEON, RGB24ToARGBRow_NEON, 0, 3, 4, 7)
#endif
#ifdef HAS_RGB24TOARGBROW_MSA
ANY11(RGB24ToARGBRow_Any_MSA, RGB24ToARGBRow_MSA, 0, 3, 4, 15)
#endif
#ifdef HAS_RAWTOARGBROW_NEON
ANY11(RAWToARGBRow_Any_NEON, RAWToARGBRow_NEON, 0, 3, 4, 7)
#endif
#ifdef HAS_RAWTOARGBROW_MSA
ANY11(RAWToARGBRow_Any_MSA, RAWToARGBRow_MSA, 0, 3, 4, 15)
#endif
#ifdef HAS_RGB565TOARGBROW_NEON
ANY11(RGB565ToARGBRow_Any_NEON, RGB565ToARGBRow_NEON, 0, 2, 4, 7)
#endif
#ifdef HAS_RGB565TOARGBROW_MSA
ANY11(RGB565ToARGBRow_Any_MSA, RGB565ToARGBRow_MSA, 0, 2, 4, 15)
#endif
#ifdef HAS_ARGB1555TOARGBROW_NEON
ANY11(ARGB1555ToARGBRow_Any_NEON, ARGB1555ToARGBRow_NEON, 0, 2, 4, 7)
#endif
#ifdef HAS_ARGB1555TOARGBROW_MSA
ANY11(ARGB1555ToARGBRow_Any_MSA, ARGB1555ToARGBRow_MSA, 0, 2, 4, 15)
#endif
#ifdef HAS_ARGB4444TOARGBROW_NEON
ANY11(ARGB4444ToARGBRow_Any_NEON, ARGB4444ToARGBRow_NEON, 0, 2, 4, 7)
#endif
......@@ -922,15 +946,27 @@ ANY12S(RGBAToUVRow_Any_NEON, RGBAToUVRow_NEON, 0, 4, 15)
#ifdef HAS_RGB24TOUVROW_NEON
ANY12S(RGB24ToUVRow_Any_NEON, RGB24ToUVRow_NEON, 0, 3, 15)
#endif
#ifdef HAS_RGB24TOUVROW_MSA
ANY12S(RGB24ToUVRow_Any_MSA, RGB24ToUVRow_MSA, 0, 3, 15)
#endif
#ifdef HAS_RAWTOUVROW_NEON
ANY12S(RAWToUVRow_Any_NEON, RAWToUVRow_NEON, 0, 3, 15)
#endif
#ifdef HAS_RAWTOUVROW_MSA
ANY12S(RAWToUVRow_Any_MSA, RAWToUVRow_MSA, 0, 3, 15)
#endif
#ifdef HAS_RGB565TOUVROW_NEON
ANY12S(RGB565ToUVRow_Any_NEON, RGB565ToUVRow_NEON, 0, 2, 15)
#endif
#ifdef HAS_RGB565TOUVROW_MSA
ANY12S(RGB565ToUVRow_Any_MSA, RGB565ToUVRow_MSA, 0, 2, 15)
#endif
#ifdef HAS_ARGB1555TOUVROW_NEON
ANY12S(ARGB1555ToUVRow_Any_NEON, ARGB1555ToUVRow_NEON, 0, 2, 15)
#endif
#ifdef HAS_ARGB1555TOUVROW_MSA
ANY12S(ARGB1555ToUVRow_Any_MSA, ARGB1555ToUVRow_MSA, 0, 2, 15)
#endif
#ifdef HAS_ARGB4444TOUVROW_NEON
ANY12S(ARGB4444ToUVRow_Any_NEON, ARGB4444ToUVRow_NEON, 0, 2, 15)
#endif
......
......@@ -1305,6 +1305,724 @@ void ARGB4444ToARGBRow_MSA(const uint8* src_argb4444,
}
}
void ARGB1555ToARGBRow_MSA(const uint8* src_argb1555,
uint8* dst_argb,
int width) {
int x;
v8u16 src0, src1;
v8u16 vec0, vec1, vec2, vec3, vec4, vec5;
v16u8 reg0, reg1, reg2, reg3, reg4, reg5, reg6;
v16u8 dst0, dst1, dst2, dst3;
v8u16 const_0x1F = (v8u16)__msa_ldi_h(0x1F);
for (x = 0; x < width; x += 16) {
src0 = (v8u16)__msa_ld_h((v8u16*)src_argb1555, 0);
src1 = (v8u16)__msa_ld_h((v8u16*)src_argb1555, 16);
vec0 = src0 & const_0x1F;
vec1 = src1 & const_0x1F;
src0 = (v8u16)__msa_srli_h((v8i16)src0, 5);
src1 = (v8u16)__msa_srli_h((v8i16)src1, 5);
vec2 = src0 & const_0x1F;
vec3 = src1 & const_0x1F;
src0 = (v8u16)__msa_srli_h((v8i16)src0, 5);
src1 = (v8u16)__msa_srli_h((v8i16)src1, 5);
vec4 = src0 & const_0x1F;
vec5 = src1 & const_0x1F;
src0 = (v8u16)__msa_srli_h((v8i16)src0, 5);
src1 = (v8u16)__msa_srli_h((v8i16)src1, 5);
reg0 = (v16u8)__msa_pckev_b((v16i8)vec1, (v16i8)vec0);
reg1 = (v16u8)__msa_pckev_b((v16i8)vec3, (v16i8)vec2);
reg2 = (v16u8)__msa_pckev_b((v16i8)vec5, (v16i8)vec4);
reg3 = (v16u8)__msa_pckev_b((v16i8)src1, (v16i8)src0);
reg4 = (v16u8)__msa_slli_b((v16i8)reg0, 3);
reg5 = (v16u8)__msa_slli_b((v16i8)reg1, 3);
reg6 = (v16u8)__msa_slli_b((v16i8)reg2, 3);
reg4 |= (v16u8)__msa_srai_b((v16i8)reg0, 2);
reg5 |= (v16u8)__msa_srai_b((v16i8)reg1, 2);
reg6 |= (v16u8)__msa_srai_b((v16i8)reg2, 2);
reg3 = -reg3;
reg0 = (v16u8)__msa_ilvr_b((v16i8)reg6, (v16i8)reg4);
reg1 = (v16u8)__msa_ilvl_b((v16i8)reg6, (v16i8)reg4);
reg2 = (v16u8)__msa_ilvr_b((v16i8)reg3, (v16i8)reg5);
reg3 = (v16u8)__msa_ilvl_b((v16i8)reg3, (v16i8)reg5);
dst0 = (v16u8)__msa_ilvr_b((v16i8)reg2, (v16i8)reg0);
dst1 = (v16u8)__msa_ilvl_b((v16i8)reg2, (v16i8)reg0);
dst2 = (v16u8)__msa_ilvr_b((v16i8)reg3, (v16i8)reg1);
dst3 = (v16u8)__msa_ilvl_b((v16i8)reg3, (v16i8)reg1);
ST_UB4(dst0, dst1, dst2, dst3, dst_argb, 16);
src_argb1555 += 32;
dst_argb += 64;
}
}
void RGB565ToARGBRow_MSA(const uint8* src_rgb565, uint8* dst_argb, int width) {
int x;
v8u16 src0, src1, vec0, vec1, vec2, vec3, vec4, vec5;
v8u16 reg0, reg1, reg2, reg3, reg4, reg5;
v16u8 res0, res1, res2, res3, dst0, dst1, dst2, dst3;
v16u8 const_0xFF = (v16u8)__msa_ldi_b(0xFF);
v8u16 const_0x1F = (v8u16)__msa_ldi_h(0x1F);
v8u16 const_0x7E0 = (v8u16)__msa_fill_h(0x7E0);
v8u16 const_0xF800 = (v8u16)__msa_fill_h(0xF800);
for (x = 0; x < width; x += 16) {
src0 = (v8u16)__msa_ld_h((v8u16*)src_rgb565, 0);
src1 = (v8u16)__msa_ld_h((v8u16*)src_rgb565, 16);
vec0 = src0 & const_0x1F;
vec1 = src0 & const_0x7E0;
vec2 = src0 & const_0xF800;
vec3 = src1 & const_0x1F;
vec4 = src1 & const_0x7E0;
vec5 = src1 & const_0xF800;
reg0 = (v8u16)__msa_slli_h((v8i16)vec0, 3);
reg1 = (v8u16)__msa_srli_h((v8i16)vec1, 3);
reg2 = (v8u16)__msa_srli_h((v8i16)vec2, 8);
reg3 = (v8u16)__msa_slli_h((v8i16)vec3, 3);
reg4 = (v8u16)__msa_srli_h((v8i16)vec4, 3);
reg5 = (v8u16)__msa_srli_h((v8i16)vec5, 8);
reg0 |= (v8u16)__msa_srli_h((v8i16)vec0, 2);
reg1 |= (v8u16)__msa_srli_h((v8i16)vec1, 9);
reg2 |= (v8u16)__msa_srli_h((v8i16)vec2, 13);
reg3 |= (v8u16)__msa_srli_h((v8i16)vec3, 2);
reg4 |= (v8u16)__msa_srli_h((v8i16)vec4, 9);
reg5 |= (v8u16)__msa_srli_h((v8i16)vec5, 13);
res0 = (v16u8)__msa_ilvev_b((v16i8)reg2, (v16i8)reg0);
res1 = (v16u8)__msa_ilvev_b((v16i8)const_0xFF, (v16i8)reg1);
res2 = (v16u8)__msa_ilvev_b((v16i8)reg5, (v16i8)reg3);
res3 = (v16u8)__msa_ilvev_b((v16i8)const_0xFF, (v16i8)reg4);
dst0 = (v16u8)__msa_ilvr_b((v16i8)res1, (v16i8)res0);
dst1 = (v16u8)__msa_ilvl_b((v16i8)res1, (v16i8)res0);
dst2 = (v16u8)__msa_ilvr_b((v16i8)res3, (v16i8)res2);
dst3 = (v16u8)__msa_ilvl_b((v16i8)res3, (v16i8)res2);
ST_UB4(dst0, dst1, dst2, dst3, dst_argb, 16);
src_rgb565 += 32;
dst_argb += 64;
}
}
void RGB24ToARGBRow_MSA(const uint8* src_rgb24, uint8* dst_argb, int width) {
int x;
v16u8 src0, src1, src2;
v16u8 vec0, vec1, vec2;
v16u8 dst0, dst1, dst2, dst3;
v16u8 const_0xFF = (v16u8)__msa_ldi_b(0xFF);
v16i8 shuffler = {0, 1, 2, 16, 3, 4, 5, 17, 6, 7, 8, 18, 9, 10, 11, 19};
for (x = 0; x < width; x += 16) {
src0 = (v16u8)__msa_ld_b((v16i8*)src_rgb24, 0);
src1 = (v16u8)__msa_ld_b((v16i8*)src_rgb24, 16);
src2 = (v16u8)__msa_ld_b((v16i8*)src_rgb24, 32);
vec0 = (v16u8)__msa_sldi_b((v16i8)src1, (v16i8)src0, 12);
vec1 = (v16u8)__msa_sldi_b((v16i8)src2, (v16i8)src1, 8);
vec2 = (v16u8)__msa_sldi_b((v16i8)src2, (v16i8)src2, 4);
dst0 = (v16u8)__msa_vshf_b(shuffler, (v16i8)const_0xFF, (v16i8)src0);
dst1 = (v16u8)__msa_vshf_b(shuffler, (v16i8)const_0xFF, (v16i8)vec0);
dst2 = (v16u8)__msa_vshf_b(shuffler, (v16i8)const_0xFF, (v16i8)vec1);
dst3 = (v16u8)__msa_vshf_b(shuffler, (v16i8)const_0xFF, (v16i8)vec2);
ST_UB4(dst0, dst1, dst2, dst3, dst_argb, 16);
src_rgb24 += 48;
dst_argb += 64;
}
}
void RAWToARGBRow_MSA(const uint8* src_raw, uint8* dst_argb, int width) {
int x;
v16u8 src0, src1, src2;
v16u8 vec0, vec1, vec2;
v16u8 dst0, dst1, dst2, dst3;
v16u8 const_0xFF = (v16u8)__msa_ldi_b(0xFF);
v16i8 mask = {2, 1, 0, 16, 5, 4, 3, 17, 8, 7, 6, 18, 11, 10, 9, 19};
for (x = 0; x < width; x += 16) {
src0 = (v16u8)__msa_ld_b((v16i8*)src_raw, 0);
src1 = (v16u8)__msa_ld_b((v16i8*)src_raw, 16);
src2 = (v16u8)__msa_ld_b((v16i8*)src_raw, 32);
vec0 = (v16u8)__msa_sldi_b((v16i8)src1, (v16i8)src0, 12);
vec1 = (v16u8)__msa_sldi_b((v16i8)src2, (v16i8)src1, 8);
vec2 = (v16u8)__msa_sldi_b((v16i8)src2, (v16i8)src2, 4);
dst0 = (v16u8)__msa_vshf_b(mask, (v16i8)const_0xFF, (v16i8)src0);
dst1 = (v16u8)__msa_vshf_b(mask, (v16i8)const_0xFF, (v16i8)vec0);
dst2 = (v16u8)__msa_vshf_b(mask, (v16i8)const_0xFF, (v16i8)vec1);
dst3 = (v16u8)__msa_vshf_b(mask, (v16i8)const_0xFF, (v16i8)vec2);
ST_UB4(dst0, dst1, dst2, dst3, dst_argb, 16);
src_raw += 48;
dst_argb += 64;
}
}
void ARGB1555ToYRow_MSA(const uint8* src_argb1555, uint8* dst_y, int width) {
int x;
v8u16 src0, src1, vec0, vec1, vec2, vec3, vec4, vec5;
v8u16 reg0, reg1, reg2, reg3, reg4, reg5;
v16u8 dst0;
v8u16 const_0x19 = (v8u16)__msa_ldi_h(0x19);
v8u16 const_0x81 = (v8u16)__msa_ldi_h(0x81);
v8u16 const_0x42 = (v8u16)__msa_ldi_h(0x42);
v8u16 const_0x1F = (v8u16)__msa_ldi_h(0x1F);
v8u16 const_0x1080 = (v8u16)__msa_fill_h(0x1080);
for (x = 0; x < width; x += 16) {
src0 = (v8u16)__msa_ld_b((v8i16*)src_argb1555, 0);
src1 = (v8u16)__msa_ld_b((v8i16*)src_argb1555, 16);
vec0 = src0 & const_0x1F;
vec1 = src1 & const_0x1F;
src0 = (v8u16)__msa_srai_h((v8i16)src0, 5);
src1 = (v8u16)__msa_srai_h((v8i16)src1, 5);
vec2 = src0 & const_0x1F;
vec3 = src1 & const_0x1F;
src0 = (v8u16)__msa_srai_h((v8i16)src0, 5);
src1 = (v8u16)__msa_srai_h((v8i16)src1, 5);
vec4 = src0 & const_0x1F;
vec5 = src1 & const_0x1F;
reg0 = (v8u16)__msa_slli_h((v8i16)vec0, 3);
reg1 = (v8u16)__msa_slli_h((v8i16)vec1, 3);
reg0 |= (v8u16)__msa_srai_h((v8i16)vec0, 2);
reg1 |= (v8u16)__msa_srai_h((v8i16)vec1, 2);
reg2 = (v8u16)__msa_slli_h((v8i16)vec2, 3);
reg3 = (v8u16)__msa_slli_h((v8i16)vec3, 3);
reg2 |= (v8u16)__msa_srai_h((v8i16)vec2, 2);
reg3 |= (v8u16)__msa_srai_h((v8i16)vec3, 2);
reg4 = (v8u16)__msa_slli_h((v8i16)vec4, 3);
reg5 = (v8u16)__msa_slli_h((v8i16)vec5, 3);
reg4 |= (v8u16)__msa_srai_h((v8i16)vec4, 2);
reg5 |= (v8u16)__msa_srai_h((v8i16)vec5, 2);
reg0 *= const_0x19;
reg1 *= const_0x19;
reg2 *= const_0x81;
reg3 *= const_0x81;
reg4 *= const_0x42;
reg5 *= const_0x42;
reg0 += reg2;
reg1 += reg3;
reg0 += reg4;
reg1 += reg5;
reg0 += const_0x1080;
reg1 += const_0x1080;
reg0 = (v8u16)__msa_srai_h((v8i16)reg0, 8);
reg1 = (v8u16)__msa_srai_h((v8i16)reg1, 8);
dst0 = (v16u8)__msa_pckev_b((v16i8)reg1, (v16i8)reg0);
ST_UB(dst0, dst_y);
src_argb1555 += 32;
dst_y += 16;
}
}
void RGB565ToYRow_MSA(const uint8* src_rgb565, uint8* dst_y, int width) {
int x;
v8u16 src0, src1, vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7;
v8u16 reg0, reg1, reg2, reg3, reg4, reg5;
v4u32 res0, res1, res2, res3;
v16u8 dst0;
v4u32 const_0x810019 = (v4u32)__msa_fill_w(0x810019);
v4u32 const_0x010042 = (v4u32)__msa_fill_w(0x010042);
v8i16 const_0x1080 = __msa_fill_h(0x1080);
v8u16 const_0x1F = (v8u16)__msa_ldi_h(0x1F);
v8u16 const_0x7E0 = (v8u16)__msa_fill_h(0x7E0);
v8u16 const_0xF800 = (v8u16)__msa_fill_h(0xF800);
for (x = 0; x < width; x += 16) {
src0 = (v8u16)__msa_ld_b((v8i16*)src_rgb565, 0);
src1 = (v8u16)__msa_ld_b((v8i16*)src_rgb565, 16);
vec0 = src0 & const_0x1F;
vec1 = src0 & const_0x7E0;
vec2 = src0 & const_0xF800;
vec3 = src1 & const_0x1F;
vec4 = src1 & const_0x7E0;
vec5 = src1 & const_0xF800;
reg0 = (v8u16)__msa_slli_h((v8i16)vec0, 3);
reg1 = (v8u16)__msa_srli_h((v8i16)vec1, 3);
reg2 = (v8u16)__msa_srli_h((v8i16)vec2, 8);
reg3 = (v8u16)__msa_slli_h((v8i16)vec3, 3);
reg4 = (v8u16)__msa_srli_h((v8i16)vec4, 3);
reg5 = (v8u16)__msa_srli_h((v8i16)vec5, 8);
reg0 |= (v8u16)__msa_srli_h((v8i16)vec0, 2);
reg1 |= (v8u16)__msa_srli_h((v8i16)vec1, 9);
reg2 |= (v8u16)__msa_srli_h((v8i16)vec2, 13);
reg3 |= (v8u16)__msa_srli_h((v8i16)vec3, 2);
reg4 |= (v8u16)__msa_srli_h((v8i16)vec4, 9);
reg5 |= (v8u16)__msa_srli_h((v8i16)vec5, 13);
vec0 = (v8u16)__msa_ilvr_h((v8i16)reg1, (v8i16)reg0);
vec1 = (v8u16)__msa_ilvl_h((v8i16)reg1, (v8i16)reg0);
vec2 = (v8u16)__msa_ilvr_h((v8i16)reg4, (v8i16)reg3);
vec3 = (v8u16)__msa_ilvl_h((v8i16)reg4, (v8i16)reg3);
vec4 = (v8u16)__msa_ilvr_h(const_0x1080, (v8i16)reg2);
vec5 = (v8u16)__msa_ilvl_h(const_0x1080, (v8i16)reg2);
vec6 = (v8u16)__msa_ilvr_h(const_0x1080, (v8i16)reg5);
vec7 = (v8u16)__msa_ilvl_h(const_0x1080, (v8i16)reg5);
res0 = __msa_dotp_u_w(vec0, (v8u16)const_0x810019);
res1 = __msa_dotp_u_w(vec1, (v8u16)const_0x810019);
res2 = __msa_dotp_u_w(vec2, (v8u16)const_0x810019);
res3 = __msa_dotp_u_w(vec3, (v8u16)const_0x810019);
res0 = __msa_dpadd_u_w(res0, vec4, (v8u16)const_0x010042);
res1 = __msa_dpadd_u_w(res1, vec5, (v8u16)const_0x010042);
res2 = __msa_dpadd_u_w(res2, vec6, (v8u16)const_0x010042);
res3 = __msa_dpadd_u_w(res3, vec7, (v8u16)const_0x010042);
res0 = (v4u32)__msa_srai_w((v4i32)res0, 8);
res1 = (v4u32)__msa_srai_w((v4i32)res1, 8);
res2 = (v4u32)__msa_srai_w((v4i32)res2, 8);
res3 = (v4u32)__msa_srai_w((v4i32)res3, 8);
vec0 = (v8u16)__msa_pckev_h((v8i16)res1, (v8i16)res0);
vec1 = (v8u16)__msa_pckev_h((v8i16)res3, (v8i16)res2);
dst0 = (v16u8)__msa_pckev_b((v16i8)vec1, (v16i8)vec0);
ST_UB(dst0, dst_y);
src_rgb565 += 32;
dst_y += 16;
}
}
void RGB24ToYRow_MSA(const uint8* src_argb0, uint8* dst_y, int width) {
int x;
v16u8 src0, src1, src2, reg0, reg1, reg2, reg3, dst0;
v8u16 vec0, vec1, vec2, vec3;
v8u16 const_0x8119 = (v8u16)__msa_fill_h(0x8119);
v8u16 const_0x42 = (v8u16)__msa_fill_h(0x42);
v8u16 const_0x1080 = (v8u16)__msa_fill_h(0x1080);
v16i8 mask0 = {0, 1, 2, 3, 3, 4, 5, 6, 6, 7, 8, 9, 9, 10, 11, 12};
v16i8 mask1 = {12, 13, 14, 15, 15, 16, 17, 18,
18, 19, 20, 21, 21, 22, 23, 24};
v16i8 mask2 = {8, 9, 10, 11, 11, 12, 13, 14, 14, 15, 16, 17, 17, 18, 19, 20};
v16i8 mask3 = {4, 5, 6, 7, 7, 8, 9, 10, 10, 11, 12, 13, 13, 14, 15, 16};
v16i8 zero = {0};
for (x = 0; x < width; x += 16) {
src0 = (v16u8)__msa_ld_b((v16i8*)src_argb0, 0);
src1 = (v16u8)__msa_ld_b((v16i8*)src_argb0, 16);
src2 = (v16u8)__msa_ld_b((v16i8*)src_argb0, 32);
reg0 = (v16u8)__msa_vshf_b(mask0, zero, (v16i8)src0);
reg1 = (v16u8)__msa_vshf_b(mask1, (v16i8)src1, (v16i8)src0);
reg2 = (v16u8)__msa_vshf_b(mask2, (v16i8)src2, (v16i8)src1);
reg3 = (v16u8)__msa_vshf_b(mask3, zero, (v16i8)src2);
vec0 = (v8u16)__msa_pckev_h((v8i16)reg1, (v8i16)reg0);
vec1 = (v8u16)__msa_pckev_h((v8i16)reg3, (v8i16)reg2);
vec2 = (v8u16)__msa_pckod_h((v8i16)reg1, (v8i16)reg0);
vec3 = (v8u16)__msa_pckod_h((v8i16)reg3, (v8i16)reg2);
vec0 = __msa_dotp_u_h((v16u8)vec0, (v16u8)const_0x8119);
vec1 = __msa_dotp_u_h((v16u8)vec1, (v16u8)const_0x8119);
vec0 = __msa_dpadd_u_h(vec0, (v16u8)vec2, (v16u8)const_0x42);
vec1 = __msa_dpadd_u_h(vec1, (v16u8)vec3, (v16u8)const_0x42);
vec0 += const_0x1080;
vec1 += const_0x1080;
vec0 = (v8u16)__msa_srai_h((v8i16)vec0, 8);
vec1 = (v8u16)__msa_srai_h((v8i16)vec1, 8);
dst0 = (v16u8)__msa_pckev_b((v16i8)vec1, (v16i8)vec0);
ST_UB(dst0, dst_y);
src_argb0 += 48;
dst_y += 16;
}
}
void RAWToYRow_MSA(const uint8* src_argb0, uint8* dst_y, int width) {
int x;
v16u8 src0, src1, src2, reg0, reg1, reg2, reg3, dst0;
v8u16 vec0, vec1, vec2, vec3;
v8u16 const_0x8142 = (v8u16)__msa_fill_h(0x8142);
v8u16 const_0x19 = (v8u16)__msa_fill_h(0x19);
v8u16 const_0x1080 = (v8u16)__msa_fill_h(0x1080);
v16i8 mask0 = {0, 1, 2, 3, 3, 4, 5, 6, 6, 7, 8, 9, 9, 10, 11, 12};
v16i8 mask1 = {12, 13, 14, 15, 15, 16, 17, 18,
18, 19, 20, 21, 21, 22, 23, 24};
v16i8 mask2 = {8, 9, 10, 11, 11, 12, 13, 14, 14, 15, 16, 17, 17, 18, 19, 20};
v16i8 mask3 = {4, 5, 6, 7, 7, 8, 9, 10, 10, 11, 12, 13, 13, 14, 15, 16};
v16i8 zero = {0};
for (x = 0; x < width; x += 16) {
src0 = (v16u8)__msa_ld_b((v16i8*)src_argb0, 0);
src1 = (v16u8)__msa_ld_b((v16i8*)src_argb0, 16);
src2 = (v16u8)__msa_ld_b((v16i8*)src_argb0, 32);
reg0 = (v16u8)__msa_vshf_b(mask0, zero, (v16i8)src0);
reg1 = (v16u8)__msa_vshf_b(mask1, (v16i8)src1, (v16i8)src0);
reg2 = (v16u8)__msa_vshf_b(mask2, (v16i8)src2, (v16i8)src1);
reg3 = (v16u8)__msa_vshf_b(mask3, zero, (v16i8)src2);
vec0 = (v8u16)__msa_pckev_h((v8i16)reg1, (v8i16)reg0);
vec1 = (v8u16)__msa_pckev_h((v8i16)reg3, (v8i16)reg2);
vec2 = (v8u16)__msa_pckod_h((v8i16)reg1, (v8i16)reg0);
vec3 = (v8u16)__msa_pckod_h((v8i16)reg3, (v8i16)reg2);
vec0 = __msa_dotp_u_h((v16u8)vec0, (v16u8)const_0x8142);
vec1 = __msa_dotp_u_h((v16u8)vec1, (v16u8)const_0x8142);
vec0 = __msa_dpadd_u_h(vec0, (v16u8)vec2, (v16u8)const_0x19);
vec1 = __msa_dpadd_u_h(vec1, (v16u8)vec3, (v16u8)const_0x19);
vec0 += const_0x1080;
vec1 += const_0x1080;
vec0 = (v8u16)__msa_srai_h((v8i16)vec0, 8);
vec1 = (v8u16)__msa_srai_h((v8i16)vec1, 8);
dst0 = (v16u8)__msa_pckev_b((v16i8)vec1, (v16i8)vec0);
ST_UB(dst0, dst_y);
src_argb0 += 48;
dst_y += 16;
}
}
void ARGB1555ToUVRow_MSA(const uint8* src_argb1555,
int src_stride_argb1555,
uint8* dst_u,
uint8* dst_v,
int width) {
int x;
const uint16* s = (const uint16*)src_argb1555;
const uint16* t = (const uint16*)(src_argb1555 + src_stride_argb1555);
int64_t res0, res1;
v8u16 src0, src1, src2, src3, reg0, reg1, reg2, reg3;
v8u16 vec0, vec1, vec2, vec3, vec4, vec5, vec6;
v16u8 dst0;
v8u16 const_0x70 = (v8u16)__msa_ldi_h(0x70);
v8u16 const_0x4A = (v8u16)__msa_ldi_h(0x4A);
v8u16 const_0x26 = (v8u16)__msa_ldi_h(0x26);
v8u16 const_0x5E = (v8u16)__msa_ldi_h(0x5E);
v8u16 const_0x12 = (v8u16)__msa_ldi_h(0x12);
v8u16 const_0x8080 = (v8u16)__msa_fill_h(0x8080);
v8u16 const_0x1F = (v8u16)__msa_ldi_h(0x1F);
for (x = 0; x < width; x += 16) {
src0 = (v8u16)__msa_ld_b((v8i16*)s, 0);
src1 = (v8u16)__msa_ld_b((v8i16*)s, 16);
src2 = (v8u16)__msa_ld_b((v8i16*)t, 0);
src3 = (v8u16)__msa_ld_b((v8i16*)t, 16);
vec0 = src0 & const_0x1F;
vec1 = src1 & const_0x1F;
vec0 += src2 & const_0x1F;
vec1 += src3 & const_0x1F;
vec0 = (v8u16)__msa_pckev_b((v16i8)vec1, (v16i8)vec0);
src0 = (v8u16)__msa_srai_h((v8i16)src0, 5);
src1 = (v8u16)__msa_srai_h((v8i16)src1, 5);
src2 = (v8u16)__msa_srai_h((v8i16)src2, 5);
src3 = (v8u16)__msa_srai_h((v8i16)src3, 5);
vec2 = src0 & const_0x1F;
vec3 = src1 & const_0x1F;
vec2 += src2 & const_0x1F;
vec3 += src3 & const_0x1F;
vec2 = (v8u16)__msa_pckev_b((v16i8)vec3, (v16i8)vec2);
src0 = (v8u16)__msa_srai_h((v8i16)src0, 5);
src1 = (v8u16)__msa_srai_h((v8i16)src1, 5);
src2 = (v8u16)__msa_srai_h((v8i16)src2, 5);
src3 = (v8u16)__msa_srai_h((v8i16)src3, 5);
vec4 = src0 & const_0x1F;
vec5 = src1 & const_0x1F;
vec4 += src2 & const_0x1F;
vec5 += src3 & const_0x1F;
vec4 = (v8u16)__msa_pckev_b((v16i8)vec5, (v16i8)vec4);
vec0 = __msa_hadd_u_h((v16u8)vec0, (v16u8)vec0);
vec2 = __msa_hadd_u_h((v16u8)vec2, (v16u8)vec2);
vec4 = __msa_hadd_u_h((v16u8)vec4, (v16u8)vec4);
vec6 = (v8u16)__msa_slli_h((v8i16)vec0, 1);
vec6 |= (v8u16)__msa_srai_h((v8i16)vec0, 6);
vec0 = (v8u16)__msa_slli_h((v8i16)vec2, 1);
vec0 |= (v8u16)__msa_srai_h((v8i16)vec2, 6);
vec2 = (v8u16)__msa_slli_h((v8i16)vec4, 1);
vec2 |= (v8u16)__msa_srai_h((v8i16)vec4, 6);
reg0 = vec6 * const_0x70;
reg1 = vec0 * const_0x4A;
reg2 = vec2 * const_0x70;
reg3 = vec0 * const_0x5E;
reg0 += const_0x8080;
reg1 += vec2 * const_0x26;
reg2 += const_0x8080;
reg3 += vec6 * const_0x12;
reg0 -= reg1;
reg2 -= reg3;
reg0 = (v8u16)__msa_srai_h((v8i16)reg0, 8);
reg2 = (v8u16)__msa_srai_h((v8i16)reg2, 8);
dst0 = (v16u8)__msa_pckev_b((v16i8)reg2, (v16i8)reg0);
res0 = __msa_copy_u_d((v2i64)dst0, 0);
res1 = __msa_copy_u_d((v2i64)dst0, 1);
SD(res0, dst_u);
SD(res1, dst_v);
s += 16;
t += 16;
dst_u += 8;
dst_v += 8;
}
}
void RGB565ToUVRow_MSA(const uint8* src_rgb565,
int src_stride_rgb565,
uint8* dst_u,
uint8* dst_v,
int width) {
int x;
const uint16* s = (const uint16*)src_rgb565;
const uint16* t = (const uint16*)(src_rgb565 + src_stride_rgb565);
int64_t res0, res1;
v8u16 src0, src1, src2, src3, reg0, reg1, reg2, reg3;
v8u16 vec0, vec1, vec2, vec3, vec4, vec5;
v16u8 dst0;
v8u16 const_0x70 = (v8u16)__msa_ldi_h(0x70);
v8u16 const_0x4A = (v8u16)__msa_ldi_h(0x4A);
v8u16 const_0x26 = (v8u16)__msa_ldi_h(0x26);
v8u16 const_0x5E = (v8u16)__msa_ldi_h(0x5E);
v8u16 const_0x12 = (v8u16)__msa_ldi_h(0x12);
v8u16 const_32896 = (v8u16)__msa_fill_h(0x8080);
v8u16 const_0x1F = (v8u16)__msa_ldi_h(0x1F);
v8u16 const_0x3F = (v8u16)__msa_fill_h(0x3F);
for (x = 0; x < width; x += 16) {
src0 = (v8u16)__msa_ld_b((v8i16*)s, 0);
src1 = (v8u16)__msa_ld_b((v8i16*)s, 16);
src2 = (v8u16)__msa_ld_b((v8i16*)t, 0);
src3 = (v8u16)__msa_ld_b((v8i16*)t, 16);
vec0 = src0 & const_0x1F;
vec1 = src1 & const_0x1F;
vec0 += src2 & const_0x1F;
vec1 += src3 & const_0x1F;
vec0 = (v8u16)__msa_pckev_b((v16i8)vec1, (v16i8)vec0);
src0 = (v8u16)__msa_srai_h((v8i16)src0, 5);
src1 = (v8u16)__msa_srai_h((v8i16)src1, 5);
src2 = (v8u16)__msa_srai_h((v8i16)src2, 5);
src3 = (v8u16)__msa_srai_h((v8i16)src3, 5);
vec2 = src0 & const_0x3F;
vec3 = src1 & const_0x3F;
vec2 += src2 & const_0x3F;
vec3 += src3 & const_0x3F;
vec1 = (v8u16)__msa_pckev_b((v16i8)vec3, (v16i8)vec2);
src0 = (v8u16)__msa_srai_h((v8i16)src0, 6);
src1 = (v8u16)__msa_srai_h((v8i16)src1, 6);
src2 = (v8u16)__msa_srai_h((v8i16)src2, 6);
src3 = (v8u16)__msa_srai_h((v8i16)src3, 6);
vec4 = src0 & const_0x1F;
vec5 = src1 & const_0x1F;
vec4 += src2 & const_0x1F;
vec5 += src3 & const_0x1F;
vec2 = (v8u16)__msa_pckev_b((v16i8)vec5, (v16i8)vec4);
vec0 = __msa_hadd_u_h((v16u8)vec0, (v16u8)vec0);
vec1 = __msa_hadd_u_h((v16u8)vec1, (v16u8)vec1);
vec2 = __msa_hadd_u_h((v16u8)vec2, (v16u8)vec2);
vec3 = (v8u16)__msa_slli_h((v8i16)vec0, 1);
vec3 |= (v8u16)__msa_srai_h((v8i16)vec0, 6);
vec4 = (v8u16)__msa_slli_h((v8i16)vec2, 1);
vec4 |= (v8u16)__msa_srai_h((v8i16)vec2, 6);
reg0 = vec3 * const_0x70;
reg1 = vec1 * const_0x4A;
reg2 = vec4 * const_0x70;
reg3 = vec1 * const_0x5E;
reg0 += const_32896;
reg1 += vec4 * const_0x26;
reg2 += const_32896;
reg3 += vec3 * const_0x12;
reg0 -= reg1;
reg2 -= reg3;
reg0 = (v8u16)__msa_srai_h((v8i16)reg0, 8);
reg2 = (v8u16)__msa_srai_h((v8i16)reg2, 8);
dst0 = (v16u8)__msa_pckev_b((v16i8)reg2, (v16i8)reg0);
res0 = __msa_copy_u_d((v2i64)dst0, 0);
res1 = __msa_copy_u_d((v2i64)dst0, 1);
SD(res0, dst_u);
SD(res1, dst_v);
s += 16;
t += 16;
dst_u += 8;
dst_v += 8;
}
}
void RGB24ToUVRow_MSA(const uint8* src_rgb0,
int src_stride_rgb,
uint8* dst_u,
uint8* dst_v,
int width) {
int x;
const uint8* s = src_rgb0;
const uint8* t = src_rgb0 + src_stride_rgb;
int64 res0, res1;
v16u8 src0, src1, src2, src3, src4, src5, src6, src7;
v16u8 inp0, inp1, inp2, inp3, inp4, inp5;
v8u16 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7;
v8i16 reg0, reg1, reg2, reg3;
v16u8 dst0;
v8u16 const_0x70 = (v8u16)__msa_fill_h(0x70);
v8u16 const_0x4A = (v8u16)__msa_fill_h(0x4A);
v8u16 const_0x26 = (v8u16)__msa_fill_h(0x26);
v8u16 const_0x5E = (v8u16)__msa_fill_h(0x5E);
v8u16 const_0x12 = (v8u16)__msa_fill_h(0x12);
v8u16 const_0x8080 = (v8u16)__msa_fill_h(0x8080);
v16i8 mask = {0, 1, 2, 16, 3, 4, 5, 17, 6, 7, 8, 18, 9, 10, 11, 19};
v16i8 zero = {0};
for (x = 0; x < width; x += 16) {
inp0 = (v16u8)__msa_ld_b((v16i8*)s, 0);
inp1 = (v16u8)__msa_ld_b((v16i8*)s, 16);
inp2 = (v16u8)__msa_ld_b((v16i8*)s, 32);
inp3 = (v16u8)__msa_ld_b((v16i8*)t, 0);
inp4 = (v16u8)__msa_ld_b((v16i8*)t, 16);
inp5 = (v16u8)__msa_ld_b((v16i8*)t, 32);
src1 = (v16u8)__msa_sldi_b((v16i8)inp1, (v16i8)inp0, 12);
src5 = (v16u8)__msa_sldi_b((v16i8)inp4, (v16i8)inp3, 12);
src2 = (v16u8)__msa_sldi_b((v16i8)inp2, (v16i8)inp1, 8);
src6 = (v16u8)__msa_sldi_b((v16i8)inp5, (v16i8)inp4, 8);
src3 = (v16u8)__msa_sldi_b((v16i8)inp2, (v16i8)inp2, 4);
src7 = (v16u8)__msa_sldi_b((v16i8)inp5, (v16i8)inp5, 4);
src0 = (v16u8)__msa_vshf_b(mask, (v16i8)zero, (v16i8)inp0);
src1 = (v16u8)__msa_vshf_b(mask, (v16i8)zero, (v16i8)src1);
src2 = (v16u8)__msa_vshf_b(mask, (v16i8)zero, (v16i8)src2);
src3 = (v16u8)__msa_vshf_b(mask, (v16i8)zero, (v16i8)src3);
src4 = (v16u8)__msa_vshf_b(mask, (v16i8)zero, (v16i8)inp3);
src5 = (v16u8)__msa_vshf_b(mask, (v16i8)zero, (v16i8)src5);
src6 = (v16u8)__msa_vshf_b(mask, (v16i8)zero, (v16i8)src6);
src7 = (v16u8)__msa_vshf_b(mask, (v16i8)zero, (v16i8)src7);
vec0 = (v8u16)__msa_ilvr_b((v16i8)src4, (v16i8)src0);
vec1 = (v8u16)__msa_ilvl_b((v16i8)src4, (v16i8)src0);
vec2 = (v8u16)__msa_ilvr_b((v16i8)src5, (v16i8)src1);
vec3 = (v8u16)__msa_ilvl_b((v16i8)src5, (v16i8)src1);
vec4 = (v8u16)__msa_ilvr_b((v16i8)src6, (v16i8)src2);
vec5 = (v8u16)__msa_ilvl_b((v16i8)src6, (v16i8)src2);
vec6 = (v8u16)__msa_ilvr_b((v16i8)src7, (v16i8)src3);
vec7 = (v8u16)__msa_ilvl_b((v16i8)src7, (v16i8)src3);
vec0 = (v8u16)__msa_hadd_u_h((v16u8)vec0, (v16u8)vec0);
vec1 = (v8u16)__msa_hadd_u_h((v16u8)vec1, (v16u8)vec1);
vec2 = (v8u16)__msa_hadd_u_h((v16u8)vec2, (v16u8)vec2);
vec3 = (v8u16)__msa_hadd_u_h((v16u8)vec3, (v16u8)vec3);
vec4 = (v8u16)__msa_hadd_u_h((v16u8)vec4, (v16u8)vec4);
vec5 = (v8u16)__msa_hadd_u_h((v16u8)vec5, (v16u8)vec5);
vec6 = (v8u16)__msa_hadd_u_h((v16u8)vec6, (v16u8)vec6);
vec7 = (v8u16)__msa_hadd_u_h((v16u8)vec7, (v16u8)vec7);
reg0 = (v8i16)__msa_pckev_d((v2i64)vec1, (v2i64)vec0);
reg1 = (v8i16)__msa_pckev_d((v2i64)vec3, (v2i64)vec2);
reg2 = (v8i16)__msa_pckev_d((v2i64)vec5, (v2i64)vec4);
reg3 = (v8i16)__msa_pckev_d((v2i64)vec7, (v2i64)vec6);
reg0 += (v8i16)__msa_pckod_d((v2i64)vec1, (v2i64)vec0);
reg1 += (v8i16)__msa_pckod_d((v2i64)vec3, (v2i64)vec2);
reg2 += (v8i16)__msa_pckod_d((v2i64)vec5, (v2i64)vec4);
reg3 += (v8i16)__msa_pckod_d((v2i64)vec7, (v2i64)vec6);
reg0 = __msa_srai_h((v8i16)reg0, 2);
reg1 = __msa_srai_h((v8i16)reg1, 2);
reg2 = __msa_srai_h((v8i16)reg2, 2);
reg3 = __msa_srai_h((v8i16)reg3, 2);
vec4 = (v8u16)__msa_pckev_h(reg1, reg0);
vec5 = (v8u16)__msa_pckev_h(reg3, reg2);
vec6 = (v8u16)__msa_pckod_h(reg1, reg0);
vec7 = (v8u16)__msa_pckod_h(reg3, reg2);
vec0 = (v8u16)__msa_pckev_h((v8i16)vec5, (v8i16)vec4);
vec1 = (v8u16)__msa_pckev_h((v8i16)vec7, (v8i16)vec6);
vec2 = (v8u16)__msa_pckod_h((v8i16)vec5, (v8i16)vec4);
vec3 = vec0 * const_0x70;
vec4 = vec1 * const_0x4A;
vec5 = vec2 * const_0x26;
vec2 *= const_0x70;
vec1 *= const_0x5E;
vec0 *= const_0x12;
reg0 = __msa_subv_h((v8i16)vec3, (v8i16)vec4);
reg1 = __msa_subv_h((v8i16)const_0x8080, (v8i16)vec5);
reg2 = __msa_subv_h((v8i16)vec2, (v8i16)vec1);
reg3 = __msa_subv_h((v8i16)const_0x8080, (v8i16)vec0);
reg0 += reg1;
reg2 += reg3;
reg0 = __msa_srai_h(reg0, 8);
reg2 = __msa_srai_h(reg2, 8);
dst0 = (v16u8)__msa_pckev_b((v16i8)reg2, (v16i8)reg0);
res0 = __msa_copy_u_d((v2i64)dst0, 0);
res1 = __msa_copy_u_d((v2i64)dst0, 1);
SD(res0, dst_u);
SD(res1, dst_v);
t += 48;
s += 48;
dst_u += 8;
dst_v += 8;
}
}
void RAWToUVRow_MSA(const uint8* src_rgb0,
int src_stride_rgb,
uint8* dst_u,
uint8* dst_v,
int width) {
int x;
const uint8* s = src_rgb0;
const uint8* t = src_rgb0 + src_stride_rgb;
int64 res0, res1;
v16u8 inp0, inp1, inp2, inp3, inp4, inp5;
v16u8 src0, src1, src2, src3, src4, src5, src6, src7;
v8u16 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7;
v8i16 reg0, reg1, reg2, reg3;
v16u8 dst0;
v8u16 const_0x70 = (v8u16)__msa_fill_h(0x70);
v8u16 const_0x4A = (v8u16)__msa_fill_h(0x4A);
v8u16 const_0x26 = (v8u16)__msa_fill_h(0x26);
v8u16 const_0x5E = (v8u16)__msa_fill_h(0x5E);
v8u16 const_0x12 = (v8u16)__msa_fill_h(0x12);
v8u16 const_0x8080 = (v8u16)__msa_fill_h(0x8080);
v16i8 mask = {0, 1, 2, 16, 3, 4, 5, 17, 6, 7, 8, 18, 9, 10, 11, 19};
v16i8 zero = {0};
for (x = 0; x < width; x += 16) {
inp0 = (v16u8)__msa_ld_b((v16i8*)s, 0);
inp1 = (v16u8)__msa_ld_b((v16i8*)s, 16);
inp2 = (v16u8)__msa_ld_b((v16i8*)s, 32);
inp3 = (v16u8)__msa_ld_b((v16i8*)t, 0);
inp4 = (v16u8)__msa_ld_b((v16i8*)t, 16);
inp5 = (v16u8)__msa_ld_b((v16i8*)t, 32);
src1 = (v16u8)__msa_sldi_b((v16i8)inp1, (v16i8)inp0, 12);
src5 = (v16u8)__msa_sldi_b((v16i8)inp4, (v16i8)inp3, 12);
src2 = (v16u8)__msa_sldi_b((v16i8)inp2, (v16i8)inp1, 8);
src6 = (v16u8)__msa_sldi_b((v16i8)inp5, (v16i8)inp4, 8);
src3 = (v16u8)__msa_sldi_b((v16i8)inp2, (v16i8)inp2, 4);
src7 = (v16u8)__msa_sldi_b((v16i8)inp5, (v16i8)inp5, 4);
src0 = (v16u8)__msa_vshf_b(mask, (v16i8)zero, (v16i8)inp0);
src1 = (v16u8)__msa_vshf_b(mask, (v16i8)zero, (v16i8)src1);
src2 = (v16u8)__msa_vshf_b(mask, (v16i8)zero, (v16i8)src2);
src3 = (v16u8)__msa_vshf_b(mask, (v16i8)zero, (v16i8)src3);
src4 = (v16u8)__msa_vshf_b(mask, (v16i8)zero, (v16i8)inp3);
src5 = (v16u8)__msa_vshf_b(mask, (v16i8)zero, (v16i8)src5);
src6 = (v16u8)__msa_vshf_b(mask, (v16i8)zero, (v16i8)src6);
src7 = (v16u8)__msa_vshf_b(mask, (v16i8)zero, (v16i8)src7);
vec0 = (v8u16)__msa_ilvr_b((v16i8)src4, (v16i8)src0);
vec1 = (v8u16)__msa_ilvl_b((v16i8)src4, (v16i8)src0);
vec2 = (v8u16)__msa_ilvr_b((v16i8)src5, (v16i8)src1);
vec3 = (v8u16)__msa_ilvl_b((v16i8)src5, (v16i8)src1);
vec4 = (v8u16)__msa_ilvr_b((v16i8)src6, (v16i8)src2);
vec5 = (v8u16)__msa_ilvl_b((v16i8)src6, (v16i8)src2);
vec6 = (v8u16)__msa_ilvr_b((v16i8)src7, (v16i8)src3);
vec7 = (v8u16)__msa_ilvl_b((v16i8)src7, (v16i8)src3);
vec0 = (v8u16)__msa_hadd_u_h((v16u8)vec0, (v16u8)vec0);
vec1 = (v8u16)__msa_hadd_u_h((v16u8)vec1, (v16u8)vec1);
vec2 = (v8u16)__msa_hadd_u_h((v16u8)vec2, (v16u8)vec2);
vec3 = (v8u16)__msa_hadd_u_h((v16u8)vec3, (v16u8)vec3);
vec4 = (v8u16)__msa_hadd_u_h((v16u8)vec4, (v16u8)vec4);
vec5 = (v8u16)__msa_hadd_u_h((v16u8)vec5, (v16u8)vec5);
vec6 = (v8u16)__msa_hadd_u_h((v16u8)vec6, (v16u8)vec6);
vec7 = (v8u16)__msa_hadd_u_h((v16u8)vec7, (v16u8)vec7);
reg0 = (v8i16)__msa_pckev_d((v2i64)vec1, (v2i64)vec0);
reg1 = (v8i16)__msa_pckev_d((v2i64)vec3, (v2i64)vec2);
reg2 = (v8i16)__msa_pckev_d((v2i64)vec5, (v2i64)vec4);
reg3 = (v8i16)__msa_pckev_d((v2i64)vec7, (v2i64)vec6);
reg0 += (v8i16)__msa_pckod_d((v2i64)vec1, (v2i64)vec0);
reg1 += (v8i16)__msa_pckod_d((v2i64)vec3, (v2i64)vec2);
reg2 += (v8i16)__msa_pckod_d((v2i64)vec5, (v2i64)vec4);
reg3 += (v8i16)__msa_pckod_d((v2i64)vec7, (v2i64)vec6);
reg0 = __msa_srai_h(reg0, 2);
reg1 = __msa_srai_h(reg1, 2);
reg2 = __msa_srai_h(reg2, 2);
reg3 = __msa_srai_h(reg3, 2);
vec4 = (v8u16)__msa_pckev_h((v8i16)reg1, (v8i16)reg0);
vec5 = (v8u16)__msa_pckev_h((v8i16)reg3, (v8i16)reg2);
vec6 = (v8u16)__msa_pckod_h((v8i16)reg1, (v8i16)reg0);
vec7 = (v8u16)__msa_pckod_h((v8i16)reg3, (v8i16)reg2);
vec0 = (v8u16)__msa_pckod_h((v8i16)vec5, (v8i16)vec4);
vec1 = (v8u16)__msa_pckev_h((v8i16)vec7, (v8i16)vec6);
vec2 = (v8u16)__msa_pckev_h((v8i16)vec5, (v8i16)vec4);
vec3 = vec0 * const_0x70;
vec4 = vec1 * const_0x4A;
vec5 = vec2 * const_0x26;
vec2 *= const_0x70;
vec1 *= const_0x5E;
vec0 *= const_0x12;
reg0 = __msa_subv_h((v8i16)vec3, (v8i16)vec4);
reg1 = __msa_subv_h((v8i16)const_0x8080, (v8i16)vec5);
reg2 = __msa_subv_h((v8i16)vec2, (v8i16)vec1);
reg3 = __msa_subv_h((v8i16)const_0x8080, (v8i16)vec0);
reg0 += reg1;
reg2 += reg3;
reg0 = __msa_srai_h(reg0, 8);
reg2 = __msa_srai_h(reg2, 8);
dst0 = (v16u8)__msa_pckev_b((v16i8)reg2, (v16i8)reg0);
res0 = __msa_copy_u_d((v2i64)dst0, 0);
res1 = __msa_copy_u_d((v2i64)dst0, 1);
SD(res0, dst_u);
SD(res1, dst_v);
t += 48;
s += 48;
dst_u += 8;
dst_v += 8;
}
}
#ifdef __cplusplus
} // extern "C"
} // namespace libyuv
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment