Changeset 986131d for src/mathutils.c
 Timestamp:
 Jul 29, 2017, 5:55:35 PM (3 years ago)
 Branches:
 feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master
 Children:
 7100895
 Parents:
 34ce715
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

src/mathutils.c
r34ce715 r986131d 25 25 #include "mathutils.h" 26 26 #include "musicutils.h" 27 28 #if defined HAVE_INTEL_IPP 29 #include <ippcore.h> 30 #include <ippvm.h> 31 #include <ipps.h> 32 #endif 27 33 28 34 /** Window types */ … … 155 161 { 156 162 smpl_t tmp = 0.0; 157 #ifndef HAVE_ACCELERATE 163 #if defined(HAVE_INTEL_IPP) 164 #if HAVE_AUBIO_DOUBLE 165 ippsMean_64f(s>data, (int)s>length, &tmp); 166 #else 167 ippsMean_32f(s>data, (int)s>length, &tmp, ippAlgHintFast); 168 #endif 169 return tmp; 170 #elif defined(HAVE_ACCELERATE) 171 aubio_vDSP_meanv(s>data, 1, &tmp, s>length); 172 return tmp; 173 #else 158 174 uint_t j; 159 175 for (j = 0; j < s>length; j++) { 160 176 tmp += s>data[j]; 161 177 } 162 return tmp / (smpl_t) (s>length); 163 #else 164 aubio_vDSP_meanv(s>data, 1, &tmp, s>length); 165 return tmp; 166 #endif /* HAVE_ACCELERATE */ 178 return tmp / (smpl_t)(s>length); 179 #endif 167 180 } 168 181 … … 171 184 { 172 185 smpl_t tmp = 0.0; 173 #ifndef HAVE_ACCELERATE 186 #if defined(HAVE_INTEL_IPP) 187 #if HAVE_AUBIO_DOUBLE 188 ippsSum_64f(s>data, (int)s>length, &tmp); 189 #else 190 ippsSum_32f(s>data, (int)s>length, &tmp, ippAlgHintFast); 191 #endif 192 #elif defined(HAVE_ACCELERATE) 193 aubio_vDSP_sve(s>data, 1, &tmp, s>length); 194 #else 174 195 uint_t j; 175 196 for (j = 0; j < s>length; j++) { 176 197 tmp += s>data[j]; 177 198 } 178 #else 179 aubio_vDSP_sve(s>data, 1, &tmp, s>length); 180 #endif /* HAVE_ACCELERATE */ 199 #endif 181 200 return tmp; 182 201 } … … 185 204 fvec_max (fvec_t * s) 186 205 { 187 #ifndef HAVE_ACCELERATE 188 uint_t j; 189 smpl_t tmp = 0.0; 190 for (j = 0; j < s>length; j++) { 206 #if defined(HAVE_INTEL_IPP) 207 smpl_t tmp = 0.; 208 #if HAVE_AUBIO_DOUBLE 209 ippsMax_64f( s>data, (int)s>length, &tmp); 210 #else 211 ippsMax_32f( s>data, (int)s>length, &tmp); 212 #endif 213 #elif defined(HAVE_ACCELERATE) 214 smpl_t tmp = 0.; 215 aubio_vDSP_maxv( s>data, 1, &tmp, s>length ); 216 #else 217 uint_t j; 218 smpl_t tmp = s>data[0]; 219 for (j = 1; j < s>length; j++) { 191 220 tmp = (tmp > s>data[j]) ? tmp : s>data[j]; 192 221 } 193 #else 222 #endif 223 return tmp; 224 } 225 226 smpl_t 227 fvec_min (fvec_t * s) 228 { 229 #if defined(HAVE_INTEL_IPP) 194 230 smpl_t tmp = 0.; 195 aubio_vDSP_maxv(s>data, 1, &tmp, s>length); 196 #endif 197 return tmp; 198 } 199 200 smpl_t 201 fvec_min (fvec_t * s) 202 { 203 #ifndef HAVE_ACCELERATE 204 uint_t j; 205 smpl_t tmp = s>data[0]; 206 for (j = 0; j < s>length; j++) { 207 tmp = (tmp < s>data[j]) ? tmp : s>data[j]; 208 } 209 #else 231 #if HAVE_AUBIO_DOUBLE 232 ippsMin_64f(s>data, (int)s>length, &tmp); 233 #else 234 ippsMin_32f(s>data, (int)s>length, &tmp); 235 #endif 236 #elif defined(HAVE_ACCELERATE) 210 237 smpl_t tmp = 0.; 211 238 aubio_vDSP_minv(s>data, 1, &tmp, s>length); 239 #else 240 uint_t j; 241 smpl_t tmp = s>data[0]; 242 for (j = 1; j < s>length; j++) { 243 tmp = (tmp < s>data[j]) ? tmp : s>data[j]; 244 } 212 245 #endif 213 246 return tmp; … … 570 603 } 571 604 605 uint_t 606 aubio_power_of_two_order (uint_t a) 607 { 608 int order = 0; 609 int temp = aubio_next_power_of_two(a); 610 while (temp >>= 1) { 611 ++order; 612 } 613 return order; 614 } 615 572 616 smpl_t 573 617 aubio_db_spl (const fvec_t * o) … … 634 678 635 679 void 680 aubio_init (void) 681 { 682 /* initialize intel IPP */ 683 #ifdef HAVE_INTEL_IPP 684 IppStatus status = ippInit(); 685 if (status != ippStsNoErr) { 686 fprintf (stderr, "Error: failed to initialize Intel IPP  status %d\n", status); 687 } 688 #endif 689 } 690 691 void 636 692 aubio_cleanup (void) 637 693 {
Note: See TracChangeset
for help on using the changeset viewer.