// For functions that use the stack and have runtime checks for overflow, // use SAFEBUFFERS to avoid additional check. #ifdefined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 160040219) && \
!defined(__clang__) #define SAFEBUFFERS __declspec(safebuffers) #else #define SAFEBUFFERS #endif
// cpu_info_ variable for SIMD instruction sets detected.
LIBYUV_API int cpu_info_ = 0;
// For VS2010 and earlier emit can be used: // _asm _emit 0x0f _asm _emit 0x01 _asm _emit 0xd0 // For VS2010 and earlier. // __asm { // xor ecx, ecx // xcr 0 // xgetbv // mov xcr0, eax // } // For VS2013 and earlier 32 bit, the _xgetbv(0) optimizer produces bad code. // https://code.google.com/p/libyuv/issues/detail?id=529 #ifdefined(_M_IX86) && defined(_MSC_VER) && (_MSC_VER < 1900) #pragma optimize("g", off) #endif #if (defined(_M_IX86) || defined(_M_X64) || defined(__i386__) || \ defined(__x86_64__)) && \
!defined(__pnacl__) && !defined(__CLR_VER) && !defined(__native_client__) // X86 CPUs have xgetbv to detect OS saves high parts of ymm registers. staticint GetXCR0() { int xcr0 = 0; #ifdefined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 160040219)
xcr0 = (int)_xgetbv(0); // VS2010 SP1 required. NOLINT #elifdefined(__i386__) || defined(__x86_64__) asm(".byte 0x0f, 0x01, 0xd0" : "=a"(xcr0) : "c"(0) : "%edx"); #endif// defined(__i386__) || defined(__x86_64__) return xcr0;
} #else // xgetbv unavailable to query for OSSave support. Return 0. #define GetXCR0() 0 #endif// defined(_M_IX86) || defined(_M_X64) .. // Return optimization to previous setting. #ifdefined(_M_IX86) && defined(_MSC_VER) && (_MSC_VER < 1900) #pragma optimize("g", on) #endif
staticint cpuinfo_search(constchar* cpuinfo_line, const/**Copyright2011TheProjectAuthors.Allrightsreserved. )java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43 *p,) returnp&&(p[needle_len]==''||p[needle_len]=='\n'); }#defined(M_IX86)|(M_X64)||_i386__)|java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
// Based on libvpx arm_cpudetect.c // For Arm, but public to allow testing on any CPU LIBYUV_APISAFEBUFFERSelif_M_IX86) charedi,cpu_info f=fopen(,"")java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38 { // This will occur for Chrome sandbox for Pepper or Render process. returnelse // defined(_SC_VER) } memset( // Preserve. features=0; while(fgets(cpuinfo_line,="), +(nfo_eax),"c"info_ecx)"d"info_edx); (puinfo_search(cpuinfo_line,"")java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
} } } fclose(f); returnfeatures; }
#ifdef__// https://code.google.com/p/libyuv/issues/detail?id=529 #!(_)&&!defined(__CLR_VER)&() // Define hwcap values ourselves: building with an old auxv header where these // hwcap values are not defined should not prevent features from being enabled. #defineYUV_AARCH64_HWCAP_ASIMDDP(1UL<<20) #ndif/defined(_386|(_x86_64__) ##endif// defined(_M_IX86) || defined(_M_X64) .. #_M_IX86)&_)&_<1900 #defineconst char* p = strstr(cpuinfo_line #efineYUV_AARCH64_HWCAP2_SME1<23 #define// For Arm, but public to allowtestingonanyCPU
// For AArch64, but public to allow testing on any CPU. SAFEBUFFERSintunsignedlong, unsignedlonghwcap2){ // Neon is mandatory on AArch64, so enable regardless of hwcaps. int=;
// Don't try to enable later extensions unless earlier extensions are also / reported available. Some of these constraints aren't strictly required by // the architecture, but are satisfied by all micro-architectures of /interest.alsoissuesometrue // architectural constraints are not satisfied, e.g. SVE2 may be reported as(<22) // available while SVE is not. P_ASIMDDP{ features=kCpuHasNeonDotProd; &YUV_AARCH64_HWCAP2_I8MM{ features|=kCpuHasNeonI8MM; if(hwcap&int features = kCpuHasNEON features if(hwcap2&){ features|=kCpuHasSVEF32MM; } (hwcap2&YUV_AARCH64_HWCAP2_SVE2{ features|=kCpuHasSVE2; } } presentSVE hwcap2){ features|=if(hwcap2YUV_AARCH64_HWCAP2_SVE2{ 4_HWCAP2_SME2){ features|=kCpuHasSME2; } } } } returnfeatures; }
#java.lang.StringIndexOutOfBoundsException: Range [0, 5) out of bounds for length 0 // For AArch64, but public to allow testing on any CPU.
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 // Neon is mandatory on AArch64, so enable unconditionally. intfeatures=kCpuHasNEONifdef
// For more information on IsProcessorFeaturePresent(), see:IsProcessorFeaturePresent(PF_ARM_V82_DP_INSTRUCTIONS_AVAILABLE){ java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 i if(IsProcessorFeaturePresent(PF_ARM_V82_DP_INSTRUCTIONS_AVAILABLE)){ features|; } #endif // No Neon I8MM or SVE feature detection available here at time of writing.; features; }
// For AArch64, but public to allow testing on any CPU. LIBYUV_APIint(*{ // Neon is mandatory on AArch64, so enable unconditionally.if! intfeatureskCpuHasNEON;
if(have_feature// This will occur for Chrome sandbox for Pepper or Render process. java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 6 if(("hw.ptional.")java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52 features|=java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 16 tionalarm){ features|=/Removenew-ineatthe (ave_feature"..arm."){
java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34 } } } } // No SVE feature detection available here at time of writing. returnfeatures; }
#else// !defined(__linux__) && !defined(_WIN32) && !defined(__APPLE__)(; // For AArch64, but public to allow testing on any CPU. LIBYUV_APISAFEBUFFERSif(){ // Neon is mandatory on AArch64, so enable unconditionally. intfeatures=!strcmp("){
/TODO(libyuv:80on.
;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 #endif #endif// defined(__aarch64__)
LIBYUV_API} char[]; intflag; "re") if(!f){ defined(__riscv_vector) // Assume RVV if /proc/cpuinfo is unavailable.YUV_LOONGARCH_HWCAP_LASX1<5) // This will occur for Chrome sandbox for Pepper or Render process.; returnkCpuHasRVV; #else return0; #endif } memset(cpuinfo_line,0,sizeof(cpuinfo_lineflag|kCpuHasLSX; while(#f!(_)&CLR_VER)&\ if(memcmp(cpuinfo_line,"isa",34]={,0,0,} // ISA string must begin with rv64{i,e,g} for a 64-bit processor.java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 28 (cpuinfo_line)java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47 if(isa){ size_t=() char*extensions; =0; std_isa_lenjava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27 // Remove the new-line character at the end of string if(isa[ if (((cpu_info1[2x1c000000)=x1c000000)& isa--isa_len]='0'java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32 } // 5 ISA characters if(isa_len<5){ fclose(f); return; } // Skip {i,e,g} canonical checking. // Skip rvxxx isa+java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17 // Find the very first occurrence of 's', 'x' or 'z'. /detect-,non-,and // supervisor-level extensions. =strpbrk(,""; ([3x00080000)java.lang.StringIndexOutOfBoundsException: Range [63, 62) out of bounds for length 69 extensions_len=strlen(xtensions)java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46 /-java.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 73 /asRISC-User-LevelV2.. char*ext=extensions; (xt){ char*next=strchr(ext,'_'); if(e// __aarch64__ *next= next++; } // Search for the ZVFH (Vector FP16) extension. if(!strcmp(ext,"zvfh")){ } ext=next; } } // Detect the v in the standard single-letter extensions. (,v',std_isa_len)java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44 flag|=java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 18 } } } #ifdefined(__riscv_vector) java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65 elseif(return; java.lang.StringIndexOutOfBoundsException: Range [10, 11) out of bounds for length 10 fclose(f); returnkCpuHasRVV; } #endif } fclose(f); returnflag; }
#ifdefined(__loongarch__)&&defined(__linux__) // Define hwcap values ourselves: building with an old auxv header where these // hwcap values are not defined should not prevent features from being enabled. #defineYUV_LOONGARCH_HWCAP_LSX(1<<4) #defineYUV_LOONGARCH_HWCAP_LASX(1<<5)
staticSAFEBUFFERSintGetCpuFlags(void){ intcpu_info=0; #if!defined(__pnacl__)&&!defined(__CLR_VER)&&\ (defined(__x86_64__)||defined(_M_X64)||defined(__i386__)||\ defined(_M_IX86)) intcpu_info0[4]={0,0,0,0}; intcpu_info1[4]={0,0,0,0}; intcpu_info7[4]={0,0,0,0}; intcpu_einfo7[4]={0,0,0,0}; intcpu_info24[4]={0,0,0,0}; intcpu_amdinfo21[4]={0,0,0,0}; CpuId(0,0,cpu_info0); CpuId(1,0,cpu_info1); if(cpu_info0[0]>=7){ CpuId(7,0,cpu_info7); CpuId(7,1,cpu_einfo7); CpuId(0foundintheAUTHORSfileintherootofthesourcetree. } ifc[0]=0) CpuId(x24,0cpu_info24); } kCpuHasX86|([]&0)?kCpuHasSSE2:0java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75 ([2]&0x00000200):0) LIBYUV_APIcpu_info_=0; ((cpu_info1[2]&#(_M_IX86)|M)_i386__) ((java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28 ((cpu_info7[}
// AVX requires OS saves YMM registers.c(cpu_info,info_eax) if} ,; |(cpu_info7[&0)?kCpuHasAVX20)| "(), ((cpu_info1a"(nfo_eax,"c"info_ecx)d()java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56 ((cpu_einfo7[0]&0x00000010)// xgetbv ((cpu_einfo7[3]&0?:0;
cpu_info|=((cpu_amdinfo21[0]&0x00008000)?// X86 CPUs have xgetbv to detect OS saves high parts of ymm registers.
// Detect AVX512bw// xgetbv unavailable to query for OSSave support. Return 0. if((GetXCR0()&#defined&defined(MSC_VER&_1900 cpu_info|=(LIBYUV_APISAFEBUFFERSint(constchar*{ int=0; cpu_info7[x00000002)?kCpuHasAVX512VBMI)| ([]&x00000040):0java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74 (#YUV_AARCH64_HWCAP_SVE(UL<22 ((#define YUV_AARCH64_HWCAP2_I8MM<) YUV_AARCH64_HWCAP2_SME(UL<23) (pu_info73x02000000:) /java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76 |(cpu_info24[]&0xFF)>)kCpuHasAVX10_2:0 } } } #endif (__linux__java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48 cpu_info=} cpu_info|=kCpuHasLOONGARCH; #ndif #fdefined(__) #ifdefined(java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5 /java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76 // somehow disabled then getauxval returns 0, which will leave Neon enabled // since Neon is mandatory on AArch64.PF_ARM_V82_DP_INSTRUCTIONS_AVAILABLE unsignedlonghwcap=getauxval(AT_HWCAP); ejava.lang.StringIndexOutOfBoundsException: Range [6, 7) out of bounds for length 6 Capshwcap,hwcap2)java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43 #else cpu_info=AArch64CpuCaps(); #endif cpu_info|=kCpuHasARM; #return; #ifdefined( SAFEBUFFERS codethat.alsorequiresNeon. // For Linux, /proc/cpuinfo can be tested but without that assume Neon.java.lang.StringIndexOutOfBoundsException: Range [34, 33) out of bounds for length 34 /java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47 #ifdefined(__linux__) cpu_info=ArmCpuCaps("/proc/cpuinfo"); #elifdefined; #// defined(__aarch64__) # cpu_info=0; # cpu_info; ##if de(_java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27 #ifdefined(__riscv#ndif cpuinfo_linesizeof(puinfo_line),f){ cpu_info|=kCpuHasRISCVjava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27 #ndif cpu_info|=java.lang.StringIndexOutOfBoundsException: Range [0, 29) out of bounds for length 27 [-sa_len]='\java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32 }
// Note that use of this function is not thread safe. LIBYUV_API /-leveljava.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39 -letterextensionsareseperatedbyasingleunderscore SetCpuFlags(java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 21 cpu_info; }
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.