[x265] [PATCH] fix invalid Instruction Set provided in CLI if CPU doesn't support it

dnyaneshwar at multicorewareinc.com dnyaneshwar at multicorewareinc.com
Wed Oct 28 09:45:33 CET 2015


# HG changeset patch
# User Dnyaneshwar G <dnyaneshwar at multicorewareinc.com>
# Date 1446021877 -19800
#      Wed Oct 28 14:14:37 2015 +0530
# Node ID 975087370d14e90cd63edecb34fb4bf2feda2468
# Parent  6563218ce342c30bfd4f9bc172a1dab510e6e55b
fix invalid Instruction Set provided in CLI if CPU doesn't support it

This patch avoids crash/invalid instructions when we provide instruction sets to
be used are higher than the cpu capabilities.

For example, if our cpu supports instruction sets upto AVX and we provide
--asm "avx2" (AVX2 is higher than AVX) then it will show warning and use default
x265 detected intruction sets.

diff -r 6563218ce342 -r 975087370d14 source/common/primitives.cpp
--- a/source/common/primitives.cpp	Mon Oct 26 12:13:53 2015 +0530
+++ b/source/common/primitives.cpp	Wed Oct 28 14:14:37 2015 +0530
@@ -238,6 +238,15 @@
             primitives.cu[i].intra_pred_allangs = NULL;
 
 #if ENABLE_ASSEMBLY
+
+        if ((uint32_t)param->cpuid > X265_NS::cpu_detect())
+        {
+            if (param->logLevel >= X265_LOG_INFO)
+                x265_log(param, X265_LOG_WARNING, "Unsupported CPUID provided in CLI, so choosing x265 detected CPUID!\n");
+
+            param->cpuid = X265_NS::cpu_detect();
+        }
+
         setupInstrinsicPrimitives(primitives, param->cpuid);
         setupAssemblyPrimitives(primitives, param->cpuid);
 #endif


More information about the x265-devel mailing list