 Chromium Code Reviews
 Chromium Code Reviews Issue 2378753004:
  Add MSA optimized I422ToYUY2Row, I422ToUYVYRow functions  (Closed)
    
  
    Issue 2378753004:
  Add MSA optimized I422ToYUY2Row, I422ToUYVYRow functions  (Closed) 
  | OLD | NEW | 
|---|---|
| 1 /* | 1 /* | 
| 2 * Copyright 2011 The LibYuv Project Authors. All rights reserved. | 2 * Copyright 2011 The LibYuv Project Authors. All rights reserved. | 
| 3 * | 3 * | 
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license | 
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source | 
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found | 
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may | 
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. | 
| 9 */ | 9 */ | 
| 10 | 10 | 
| 11 #include "libyuv/cpu_id.h" | 11 #include "libyuv/cpu_id.h" | 
| 12 | 12 | 
| 13 #if defined(_MSC_VER) | 13 #if defined(_MSC_VER) | 
| 14 #include <intrin.h> // For __cpuidex() | 14 #include <intrin.h> // For __cpuidex() | 
| 15 #endif | 15 #endif | 
| 16 #if !defined(__pnacl__) && !defined(__CLR_VER) && \ | 16 #if !defined(__pnacl__) && !defined(__CLR_VER) && \ | 
| 17 !defined(__native_client__) && (defined(_M_IX86) || defined(_M_X64)) && \ | 17 !defined(__native_client__) && (defined(_M_IX86) || defined(_M_X64)) && \ | 
| 18 defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 160040219) | 18 defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 160040219) | 
| 19 #include <immintrin.h> // For _xgetbv() | 19 #include <immintrin.h> // For _xgetbv() | 
| 20 #endif | 20 #endif | 
| 21 | 21 | 
| 22 #if !defined(__native_client__) | 22 #if !defined(__native_client__) | 
| 23 #include <stdlib.h> // For getenv() | 23 #include <stdlib.h> // For getenv() | 
| 24 #endif | 24 #endif | 
| 25 | 25 | 
| 26 // For ArmCpuCaps() but unittested on all platforms | 26 // For ArmCpuCaps() but unittested on all platforms | 
| 27 #include <stdio.h> | 27 #include <stdio.h> | 
| 28 #include <string.h> | 28 #include <string.h> | 
| 29 | 29 | 
| 30 #if defined(__mips__) | |
| 31 #include <sys/auxv.h> // For getauxval | |
| 32 #endif | |
| 33 | |
| 30 #include "libyuv/basic_types.h" // For CPU_X86 | 34 #include "libyuv/basic_types.h" // For CPU_X86 | 
| 31 | 35 | 
| 32 #ifdef __cplusplus | 36 #ifdef __cplusplus | 
| 33 namespace libyuv { | 37 namespace libyuv { | 
| 34 extern "C" { | 38 extern "C" { | 
| 35 #endif | 39 #endif | 
| 36 | 40 | 
| 37 // For functions that use the stack and have runtime checks for overflow, | 41 // For functions that use the stack and have runtime checks for overflow, | 
| 38 // use SAFEBUFFERS to avoid additional check. | 42 // use SAFEBUFFERS to avoid additional check. | 
| 39 #if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 160040219) && \ | 43 #if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 160040219) && \ | 
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 154 if (p && (p[6] == ' ' || p[6] == '\n')) { | 158 if (p && (p[6] == ' ' || p[6] == '\n')) { | 
| 155 fclose(f); | 159 fclose(f); | 
| 156 return kCpuHasNEON; | 160 return kCpuHasNEON; | 
| 157 } | 161 } | 
| 158 } | 162 } | 
| 159 } | 163 } | 
| 160 fclose(f); | 164 fclose(f); | 
| 161 return 0; | 165 return 0; | 
| 162 } | 166 } | 
| 163 | 167 | 
| 168 #if defined(__mips__) | |
| 169 #define HWCAP_MIPS_R6 (1 << 0) | |
| 
fbarchard1
2016/09/29 17:10:43
R6 not used?
 
manojkumar.bhosale
2016/09/30 09:00:29
No, not now as R5, R6 both returns MSA HWCAPS so R
 | |
| 170 #define HWCAP_MIPS_MSA (1 << 1) | |
| 171 #endif | |
| 172 | |
| 164 LIBYUV_API SAFEBUFFERS | 173 LIBYUV_API SAFEBUFFERS | 
| 165 int MipsCpuCaps(const char* cpuinfo_name, const char ase[]) { | 174 int MipsCpuCaps(const char* cpuinfo_name, const char ase[]) { | 
| 166 char cpuinfo_line[512]; | 175 char cpuinfo_line[512]; | 
| 167 int len = (int)strlen(ase); | 176 int len = (int)strlen(ase); | 
| 177 int hwcap = 0; | |
| 168 FILE* f = fopen(cpuinfo_name, "r"); | 178 FILE* f = fopen(cpuinfo_name, "r"); | 
| 169 if (!f) { | 179 if (!f) { | 
| 170 // ase enabled if /proc/cpuinfo is unavailable. | 180 hwcap = getauxval(AT_HWCAP); | 
| 
fbarchard1
2016/09/29 17:10:43
this function is also unavailable in sandbox?
pref
 
manojkumar.bhosale
2016/09/30 09:00:29
OK. will split that in new CL
 | |
| 171 if (strcmp(ase, " msa") == 0) { | 181 if (hwcap & HWCAP_MIPS_MSA) { | 
| 172 return kCpuHasMSA; | 182 return kCpuHasMSA; | 
| 173 } | 183 } | 
| 184 | |
| 185 // dspr2 enabled if /proc/cpuinfo is unavailable. | |
| 174 if (strcmp(ase, " dspr2") == 0) { | 186 if (strcmp(ase, " dspr2") == 0) { | 
| 175 return kCpuHasDSPR2; | 187 return kCpuHasDSPR2; | 
| 176 } | 188 } | 
| 177 } | 189 } | 
| 178 while (fgets(cpuinfo_line, sizeof(cpuinfo_line) - 1, f)) { | 190 while (fgets(cpuinfo_line, sizeof(cpuinfo_line) - 1, f)) { | 
| 179 if (memcmp(cpuinfo_line, "ASEs implemented", 16) == 0) { | 191 if (memcmp(cpuinfo_line, "ASEs implemented", 16) == 0) { | 
| 180 char* p = strstr(cpuinfo_line, ase); | 192 char* p = strstr(cpuinfo_line, ase); | 
| 181 if (p && (p[len] == ' ' || p[len] == '\n')) { | 193 if (p && (p[len] == ' ' || p[len] == '\n')) { | 
| 182 fclose(f); | 194 fclose(f); | 
| 183 if (strcmp(ase, " msa") == 0) { | 195 hwcap = getauxval(AT_HWCAP); | 
| 
fbarchard1
2016/09/29 17:10:43
this is mixed into string parsing code?  
getauxva
 
manojkumar.bhosale
2016/09/30 09:00:29
Removed cpuid code from this CL
 | |
| 196 if (hwcap & HWCAP_MIPS_MSA) { | |
| 184 return kCpuHasMSA; | 197 return kCpuHasMSA; | 
| 185 } | 198 } | 
| 186 if (strcmp(ase, " dspr2") == 0) { | 199 if (strcmp(ase, " dspr2") == 0) { | 
| 187 return kCpuHasDSPR2; | 200 return kCpuHasDSPR2; | 
| 188 } | 201 } | 
| 189 } | 202 } | 
| 190 } | 203 } | 
| 191 } | 204 } | 
| 192 fclose(f); | 205 fclose(f); | 
| 193 return 0; | 206 return 0; | 
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 329 // Note that use of this function is not thread safe. | 342 // Note that use of this function is not thread safe. | 
| 330 LIBYUV_API | 343 LIBYUV_API | 
| 331 void MaskCpuFlags(int enable_flags) { | 344 void MaskCpuFlags(int enable_flags) { | 
| 332 cpu_info_ = InitCpuFlags() & enable_flags; | 345 cpu_info_ = InitCpuFlags() & enable_flags; | 
| 333 } | 346 } | 
| 334 | 347 | 
| 335 #ifdef __cplusplus | 348 #ifdef __cplusplus | 
| 336 } // extern "C" | 349 } // extern "C" | 
| 337 } // namespace libyuv | 350 } // namespace libyuv | 
| 338 #endif | 351 #endif | 
| OLD | NEW |