opus_cpu_feature_check only checks cpuid today and not xgetbv which can cause crashes when AVX is disabled there.
The code should also check if it's enabled using GetEnabledXStateFeatures on Windows and _xgetbv otherwise.
|
static void opus_cpu_feature_check(CPU_Feature *cpu_feature) |
|
{ |
|
unsigned int info[4]; |
|
unsigned int nIds = 0; |
|
|
|
cpuid(info, 0); |
|
nIds = info[0]; |
|
|
|
if (nIds >= 1){ |
|
cpuid(info, 1); |
|
cpu_feature->HW_SSE = (info[3] & (1 << 25)) != 0; |
|
cpu_feature->HW_SSE2 = (info[3] & (1 << 26)) != 0; |
|
cpu_feature->HW_SSE41 = (info[2] & (1 << 19)) != 0; |
|
cpu_feature->HW_AVX2 = (info[2] & (1 << 28)) != 0 && (info[2] & (1 << 12)) != 0; |
|
if (cpu_feature->HW_AVX2 && nIds >= 7) { |
|
cpuid(info, 7); |
|
cpu_feature->HW_AVX2 = cpu_feature->HW_AVX2 && (info[1] & (1 << 5)) != 0; |
|
} else { |
|
cpu_feature->HW_AVX2 = 0; |
|
} |
|
} |
|
else { |
|
cpu_feature->HW_SSE = 0; |
|
cpu_feature->HW_SSE2 = 0; |
|
cpu_feature->HW_SSE41 = 0; |
|
cpu_feature->HW_AVX2 = 0; |
|
} |
|
} |
opus_cpu_feature_checkonly checkscpuidtoday and notxgetbvwhich can cause crashes when AVX is disabled there.The code should also check if it's enabled using
GetEnabledXStateFeatureson Windows and_xgetbvotherwise.opus/celt/x86/x86cpu.c
Lines 111 to 138 in f18e26e