Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(873)

Side by Side Diff: celt/arm/armcpu.c

Issue 107243004: Updating Opus to release 1.1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/opus
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « celt/arm/armcpu.h ('k') | celt/arm/armopts.s.in » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Copyright (c) 2010 Xiph.Org Foundation 1 /* Copyright (c) 2010 Xiph.Org Foundation
2 * Copyright (c) 2013 Parrot */ 2 * Copyright (c) 2013 Parrot */
3 /* 3 /*
4 Redistribution and use in source and binary forms, with or without 4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions 5 modification, are permitted provided that the following conditions
6 are met: 6 are met:
7 7
8 - Redistributions of source code must retain the above copyright 8 - Redistributions of source code must retain the above copyright
9 notice, this list of conditions and the following disclaimer. 9 notice, this list of conditions and the following disclaimer.
10 10
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #define OPUS_CPU_ARM_EDSP (1<<1) 42 #define OPUS_CPU_ARM_EDSP (1<<1)
43 #define OPUS_CPU_ARM_MEDIA (1<<2) 43 #define OPUS_CPU_ARM_MEDIA (1<<2)
44 #define OPUS_CPU_ARM_NEON (1<<3) 44 #define OPUS_CPU_ARM_NEON (1<<3)
45 45
46 #if defined(_MSC_VER) 46 #if defined(_MSC_VER)
47 /*For GetExceptionCode() and EXCEPTION_ILLEGAL_INSTRUCTION.*/ 47 /*For GetExceptionCode() and EXCEPTION_ILLEGAL_INSTRUCTION.*/
48 # define WIN32_LEAN_AND_MEAN 48 # define WIN32_LEAN_AND_MEAN
49 # define WIN32_EXTRA_LEAN 49 # define WIN32_EXTRA_LEAN
50 # include <windows.h> 50 # include <windows.h>
51 51
52 static inline opus_uint32 opus_cpu_capabilities(void){ 52 static OPUS_INLINE opus_uint32 opus_cpu_capabilities(void){
53 opus_uint32 flags; 53 opus_uint32 flags;
54 flags=0; 54 flags=0;
55 /* MSVC has no inline __asm support for ARM, but it does let you __emit 55 /* MSVC has no OPUS_INLINE __asm support for ARM, but it does let you __emit
56 * instructions via their assembled hex code. 56 * instructions via their assembled hex code.
57 * All of these instructions should be essentially nops. */ 57 * All of these instructions should be essentially nops. */
58 # if defined(ARMv5E_ASM) 58 # if defined(OPUS_ARM_MAY_HAVE_EDSP)
59 __try{ 59 __try{
60 /*PLD [r13]*/ 60 /*PLD [r13]*/
61 __emit(0xF5DDF000); 61 __emit(0xF5DDF000);
62 flags|=OPUS_CPU_ARM_EDSP; 62 flags|=OPUS_CPU_ARM_EDSP;
63 } 63 }
64 __except(GetExceptionCode()==EXCEPTION_ILLEGAL_INSTRUCTION){ 64 __except(GetExceptionCode()==EXCEPTION_ILLEGAL_INSTRUCTION){
65 /*Ignore exception.*/ 65 /*Ignore exception.*/
66 } 66 }
67 # if defined(ARMv6E_ASM) 67 # if defined(OPUS_ARM_MAY_HAVE_MEDIA)
68 __try{ 68 __try{
69 /*SHADD8 r3,r3,r3*/ 69 /*SHADD8 r3,r3,r3*/
70 __emit(0xE6333F93); 70 __emit(0xE6333F93);
71 flags|=OPUS_CPU_ARM_MEDIA; 71 flags|=OPUS_CPU_ARM_MEDIA;
72 } 72 }
73 __except(GetExceptionCode()==EXCEPTION_ILLEGAL_INSTRUCTION){ 73 __except(GetExceptionCode()==EXCEPTION_ILLEGAL_INSTRUCTION){
74 /*Ignore exception.*/ 74 /*Ignore exception.*/
75 } 75 }
76 # if defined(ARM_HAVE_NEON) 76 # if defined(OPUS_ARM_MAY_HAVE_NEON)
77 __try{ 77 __try{
78 /*VORR q0,q0,q0*/ 78 /*VORR q0,q0,q0*/
79 __emit(0xF2200150); 79 __emit(0xF2200150);
80 flags|=OPUS_CPU_ARM_NEON; 80 flags|=OPUS_CPU_ARM_NEON;
81 } 81 }
82 __except(GetExceptionCode()==EXCEPTION_ILLEGAL_INSTRUCTION){ 82 __except(GetExceptionCode()==EXCEPTION_ILLEGAL_INSTRUCTION){
83 /*Ignore exception.*/ 83 /*Ignore exception.*/
84 } 84 }
85 # endif 85 # endif
86 # endif 86 # endif
(...skipping 13 matching lines...) Expand all
100 cpuinfo = fopen("/proc/cpuinfo", "r"); 100 cpuinfo = fopen("/proc/cpuinfo", "r");
101 101
102 if(cpuinfo != NULL) 102 if(cpuinfo != NULL)
103 { 103 {
104 /* 512 should be enough for anybody (it's even enough for all the flags that 104 /* 512 should be enough for anybody (it's even enough for all the flags that
105 * x86 has accumulated... so far). */ 105 * x86 has accumulated... so far). */
106 char buf[512]; 106 char buf[512];
107 107
108 while(fgets(buf, 512, cpuinfo) != NULL) 108 while(fgets(buf, 512, cpuinfo) != NULL)
109 { 109 {
110 # if defined(OPUS_ARM_MAY_HAVE_EDSP) || defined(OPUS_ARM_MAY_HAVE_NEON)
110 /* Search for edsp and neon flag */ 111 /* Search for edsp and neon flag */
111 if(memcmp(buf, "Features", 8) == 0) 112 if(memcmp(buf, "Features", 8) == 0)
112 { 113 {
113 char *p; 114 char *p;
115 # if defined(OPUS_ARM_MAY_HAVE_EDSP)
114 p = strstr(buf, " edsp"); 116 p = strstr(buf, " edsp");
115 if(p != NULL && (p[5] == ' ' || p[5] == '\n')) 117 if(p != NULL && (p[5] == ' ' || p[5] == '\n'))
116 flags |= OPUS_CPU_ARM_EDSP; 118 flags |= OPUS_CPU_ARM_EDSP;
119 # endif
117 120
121 # if defined(OPUS_ARM_MAY_HAVE_NEON)
118 p = strstr(buf, " neon"); 122 p = strstr(buf, " neon");
119 if(p != NULL && (p[5] == ' ' || p[5] == '\n')) 123 if(p != NULL && (p[5] == ' ' || p[5] == '\n'))
120 flags |= OPUS_CPU_ARM_NEON; 124 flags |= OPUS_CPU_ARM_NEON;
125 # endif
121 } 126 }
127 # endif
122 128
129 # if defined(OPUS_ARM_MAY_HAVE_MEDIA)
123 /* Search for media capabilities (>= ARMv6) */ 130 /* Search for media capabilities (>= ARMv6) */
124 if(memcmp(buf, "CPU architecture:", 17) == 0) 131 if(memcmp(buf, "CPU architecture:", 17) == 0)
125 { 132 {
126 int version; 133 int version;
127 version = atoi(buf+17); 134 version = atoi(buf+17);
128 135
129 if(version >= 6) 136 if(version >= 6)
130 flags |= OPUS_CPU_ARM_MEDIA; 137 flags |= OPUS_CPU_ARM_MEDIA;
131 } 138 }
139 # endif
132 } 140 }
133 141
134 fclose(cpuinfo); 142 fclose(cpuinfo);
135 } 143 }
136 return flags; 144 return flags;
137 } 145 }
138 #else 146 #else
139 /* The feature registers which can tell us what the processor supports are 147 /* The feature registers which can tell us what the processor supports are
140 * accessible in priveleged modes only, so we can't have a general user-space 148 * accessible in priveleged modes only, so we can't have a general user-space
141 * detection method like on x86.*/ 149 * detection method like on x86.*/
(...skipping 15 matching lines...) Expand all
157 arch++; 165 arch++;
158 166
159 if(!(flags & OPUS_CPU_ARM_NEON)) 167 if(!(flags & OPUS_CPU_ARM_NEON))
160 return arch; 168 return arch;
161 arch++; 169 arch++;
162 170
163 return arch; 171 return arch;
164 } 172 }
165 173
166 #endif 174 #endif
OLDNEW
« no previous file with comments | « celt/arm/armcpu.h ('k') | celt/arm/armopts.s.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698