summaryrefslogtreecommitdiffstats
path: root/libass/ass_utils.c
diff options
context:
space:
mode:
author11rcombs <rodger.combs@gmail.com>2014-01-25 16:55:21 -0600
committer11rcombs <rodger.combs@gmail.com>2014-01-25 19:09:16 -0600
commit31bc8ba5cc9850cd77cba84e0932d11cd5607e5f (patch)
tree5615a98c8a79c910843352423f4df84a564507d7 /libass/ass_utils.c
parent5dd56af2f97419ce5a72d1dab2e9c19b34c1dd57 (diff)
downloadlibass-31bc8ba5cc9850cd77cba84e0932d11cd5607e5f.tar.bz2
libass-31bc8ba5cc9850cd77cba84e0932d11cd5607e5f.tar.xz
Added x86 ASM functions
Diffstat (limited to 'libass/ass_utils.c')
-rw-r--r--libass/ass_utils.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/libass/ass_utils.c b/libass/ass_utils.c
index 2a95ddc..549eb9b 100644
--- a/libass/ass_utils.c
+++ b/libass/ass_utils.c
@@ -29,6 +29,42 @@
#include "ass.h"
#include "ass_utils.h"
+#if (defined(__i386__) || defined(__x86_64__)) && CONFIG_ASM
+
+#include "x86/cpuid.h"
+
+int has_sse2()
+{
+ uint32_t eax = 1, ebx, ecx, edx;
+ ass_get_cpuid(&eax, &ebx, &ecx, &edx);
+ return (!!(edx & (1 << 26)));
+}
+
+int has_avx()
+{
+ uint32_t eax = 1, ebx, ecx, edx;
+ ass_get_cpuid(&eax, &ebx, &ecx, &edx);
+ if(!(ecx & (1 << 27))){
+ return 0;
+ }
+ uint32_t misc = ecx;
+ eax = 0;
+ ass_get_cpuid(&eax, &ebx, &ecx, &edx);
+ if((ecx & (0x2 | 0x4)) != (0x2 | 0x4)){
+ return 0;
+ }
+ return (!!(misc & (1 << 28)));
+}
+
+int has_avx2()
+{
+ uint32_t eax = 7, ebx, ecx, edx;
+ ass_get_cpuid(&eax, &ebx, &ecx, &edx);
+ return (!!(ebx & (1 << 5))) && has_avx();
+}
+
+#endif // ASM
+
int mystrtoi(char **p, int *res)
{
double temp_res;