shithub: openh264

Download patch

ref: b7fb9414c5b0d2afa23db76b58edff4b6a9e804e
parent: f1d1af0d340756cf50f6c6497371e78a2ea8446c
author: brly <info@brly.net>
date: Sun May 10 16:03:41 EDT 2015

Add detection of AVX2

--- a/codec/common/inc/cpu_core.h
+++ b/codec/common/inc/cpu_core.h
@@ -67,6 +67,7 @@
 #define WELS_CPU_MOVBE		0x00008000	/* MOVBE instruction */
 #define WELS_CPU_AES		0x00010000	/* AES instruction extensions */
 #define WELS_CPU_FMA		0x00020000	/* AVX VEX FMA instruction sets */
+#define WELS_CPU_AVX2		0x00040000	/* AVX2 */
 
 #define WELS_CPU_CACHELINE_16    0x10000000    /* CacheLine Size 16 */
 #define WELS_CPU_CACHELINE_32    0x20000000    /* CacheLine Size 32 */
--- a/codec/common/src/cpu.cpp
+++ b/codec/common/src/cpu.cpp
@@ -136,6 +136,15 @@
     uiCPU |= WELS_CPU_MOVBE;
   }
 
+  if (uiMaxCpuidLevel >= 7) {
+    uiFeatureC = 0;
+    WelsCPUId (7, &uiFeatureA, &uiFeatureB, &uiFeatureC, &uiFeatureD);
+    if ((uiCPU & WELS_CPU_AVX) && (uiFeatureB & 0x00000020)) {
+      /* AVX2 supported */
+      uiCPU |= WELS_CPU_AVX2;
+    }
+  }
+
   if (pNumberOfLogicProcessors != NULL) {
     if (uiCPU & WELS_CPU_HTT) {
       *pNumberOfLogicProcessors = (uiFeatureB & 0x00ff0000) >> 16; // feature bits: 23-16 on returned EBX