Commit ca410052 authored by fbarchard@google.com's avatar fbarchard@google.com

mips version of SplitUV for nv12/21

BUG=126
TEST=rotate_test and cpu_test updated
Review URL: https://webrtc-codereview.appspot.com/879005

git-svn-id: http://libyuv.googlecode.com/svn/trunk@416 16f28f9a-4ce2-e073-06de-1de4eb20be90
parent c389e8e3
......@@ -35,6 +35,11 @@ static const int kCpuHasSSE42 = 0x100;
static const int kCpuHasAVX = 0x200;
static const int kCpuHasAVX2 = 0x400;
// These flags are only valid on MIPS processors.
static const int kCpuHasMIPS = 0x1000;
static const int kCpuHasMIPS_DSP = 0x2000;
static const int kCpuHasMIPS_DSPR2 = 0x4000;
// Internal function used to auto-init.
LIBYUV_API
int InitCpuFlags(void);
......
......@@ -153,6 +153,13 @@ extern "C" {
#define HAS_ARGBTOARGB4444ROW_NEON
#endif
// The following are available on Mips platforms
#if !defined(YUV_DISABLE_ASM) && defined(__mips__)
#if defined(__mips_dsp) && (__mips_dsp_rev >= 2)
#define HAS_SPLITUV_MIPS_DSPR2
#endif
#endif
#if defined(_MSC_VER) && !defined(__CLR_VER)
#define SIMD_ALIGNED(var) __declspec(align(16)) var
typedef __declspec(align(16)) int8 vec8[16];
......@@ -264,6 +271,7 @@ void ARGBMirrorRow_C(const uint8* src, uint8* dst, int width);
void SplitUV_SSE2(const uint8* src_uv, uint8* dst_u, uint8* dst_v, int pix);
void SplitUV_NEON(const uint8* src_uv, uint8* dst_u, uint8* dst_v, int pix);
void SplitUV_MIPS_DSPR2(const uint8* src_uv, uint8* dst_u, uint8* dst_v, int pix);
void SplitUV_C(const uint8* src_uv, uint8* dst_u, uint8* dst_v, int pix);
void CopyRow_SSE2(const uint8* src, uint8* dst, int count);
......
......@@ -79,6 +79,7 @@
'source/rotate_neon.cc',
'source/row_common.cc',
'source/row_neon.cc',
'source/row_mips.cc',
'source/row_posix.cc',
'source/row_win.cc',
'source/scale.cc',
......
......@@ -379,6 +379,10 @@ static int X420ToI420(const uint8* src_y,
IS_ALIGNED(dst_v, 16) && IS_ALIGNED(dst_stride_v, 16)) {
SplitUV = SplitUV_SSE2;
}
#elif defined(HAS_SPLITUV_MIPS_DSPR2)
if (TestCpuFlag(kCpuHasMIPS) && TestCpuFlag(kCpuHasMIPS_DSPR2)){
SplitUV = SplitUV_MIPS_DSPR2;
}
#endif
if (dst_y) {
......
......@@ -119,6 +119,25 @@ int ArmCpuCaps(const char* cpuinfo_name) {
return flags;
}
static int MipsCpuCaps(const char *search_string) {
int flags = 0;
const char *file_name = "/proc/cpuinfo";
char cpuinfo_line[256];
FILE *f = NULL;
if ((f = fopen (file_name, "r")) != NULL) {
while (fgets (cpuinfo_line, sizeof (cpuinfo_line), f) != NULL) {
if (strstr (cpuinfo_line, search_string) != NULL) {
flags |= kCpuHasMIPS_DSP;
fclose (f);
return flags;
}
}
}
/* Did not find string in the proc file, or not Linux ELF. */
return flags;
}
// CPU detect function for SIMD instruction sets.
// TODO(fbarchard): Use constant if/when valgrind says cpu_info is initialized.
LIBYUV_API
......@@ -178,9 +197,24 @@ int InitCpuFlags(void) {
if (TestEnv("LIBYUV_DISABLE_AVX2")) {
cpu_info_ &= ~kCpuHasAVX2;
}
if (TestEnv("LIBYUV_DISABLE_ASM")) {
cpu_info_ = 0;
#elif defined (__mips__) && defined(__linux__)
// linux mips parse text file for dsp detect.
cpu_info_ = MipsCpuCaps("dsp"); // set kCpuHasMIPS_DSP
#if defined(__mips_dspr2)
cpu_info_ |= kCpuHasMIPS_DSPR2;
#endif
cpu_info_ |= kCpuHasMIPS;
if (getenv("LIBYUV_DISABLE_MIPS")) {
cpu_info_ &= ~kCpuHasMIPS;
}
if (getenv("LIBYUV_DISABLE_MIPS_DSP")) {
cpu_info_ &= ~kCpuHasMIPS_DSP;
}
if (getenv("LIBYUV_DISABLE_MIPS_DSPR2")) {
cpu_info_ &= ~kCpuHasMIPS_DSPR2;
}
#elif defined(__arm__)
#if defined(__linux__) && (defined(__ARM_NEON__) || defined(LIBYUV_NEON))
// linux arm parse text file for neon detect.
......@@ -195,10 +229,10 @@ int InitCpuFlags(void) {
if (TestEnv("LIBYUV_DISABLE_NEON")) {
cpu_info_ &= ~kCpuHasNEON;
}
#endif // __arm__
if (TestEnv("LIBYUV_DISABLE_ASM")) {
cpu_info_ = 0;
}
#endif // __arm__
return cpu_info_;
}
......
This diff is collapsed.
......@@ -39,6 +39,12 @@ TEST_F(libyuvTest, TestCpuHas) {
printf("Has AVX %x\n", has_avx);
int has_avx2 = TestCpuFlag(kCpuHasAVX2);
printf("Has AVX2 %x\n", has_avx2);
int has_mips = TestCpuFlag(kCpuHasMIPS);
printf("Has MIPS %x\n", has_mips);
int has_mips_dsp = TestCpuFlag(kCpuHasMIPS_DSP);
printf("Has MIPS DSP %x\n", has_mips_dsp);
int has_mips_dspr2 = TestCpuFlag(kCpuHasMIPS_DSPR2);
printf("Has MIPS DSPR2 %x\n", has_mips_dspr2);
}
#if defined(__i386__) || defined(__x86_64__) || \
......
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