Changeset 81b3910 for src/mathutils.c
- Timestamp:
- Oct 1, 2017, 12:50:15 PM (6 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master
- Children:
- a6b5bf1
- Parents:
- 16c12a1 (diff), faeec7c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mathutils.c
r16c12a1 r81b3910 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 */ … … 160 166 { 161 167 smpl_t tmp = 0.0; 162 #ifndef HAVE_ACCELERATE 168 #if defined(HAVE_INTEL_IPP) 169 #if HAVE_AUBIO_DOUBLE 170 ippsMean_64f(s->data, (int)s->length, &tmp); 171 #else 172 ippsMean_32f(s->data, (int)s->length, &tmp, ippAlgHintFast); 173 #endif 174 return tmp; 175 #elif defined(HAVE_ACCELERATE) 176 aubio_vDSP_meanv(s->data, 1, &tmp, s->length); 177 return tmp; 178 #else 163 179 uint_t j; 164 180 for (j = 0; j < s->length; j++) { 165 181 tmp += s->data[j]; 166 182 } 167 return tmp / (smpl_t) (s->length); 168 #else 169 aubio_vDSP_meanv(s->data, 1, &tmp, s->length); 170 return tmp; 171 #endif /* HAVE_ACCELERATE */ 183 return tmp / (smpl_t)(s->length); 184 #endif 172 185 } 173 186 … … 176 189 { 177 190 smpl_t tmp = 0.0; 178 #ifndef HAVE_ACCELERATE 191 #if defined(HAVE_INTEL_IPP) 192 #if HAVE_AUBIO_DOUBLE 193 ippsSum_64f(s->data, (int)s->length, &tmp); 194 #else 195 ippsSum_32f(s->data, (int)s->length, &tmp, ippAlgHintFast); 196 #endif 197 #elif defined(HAVE_ACCELERATE) 198 aubio_vDSP_sve(s->data, 1, &tmp, s->length); 199 #else 179 200 uint_t j; 180 201 for (j = 0; j < s->length; j++) { 181 202 tmp += s->data[j]; 182 203 } 183 #else 184 aubio_vDSP_sve(s->data, 1, &tmp, s->length); 185 #endif /* HAVE_ACCELERATE */ 204 #endif 186 205 return tmp; 187 206 } … … 190 209 fvec_max (fvec_t * s) 191 210 { 192 #ifndef HAVE_ACCELERATE 193 uint_t j; 194 smpl_t tmp = 0.0; 195 for (j = 0; j < s->length; j++) { 211 #if defined(HAVE_INTEL_IPP) 212 smpl_t tmp = 0.; 213 #if HAVE_AUBIO_DOUBLE 214 ippsMax_64f( s->data, (int)s->length, &tmp); 215 #else 216 ippsMax_32f( s->data, (int)s->length, &tmp); 217 #endif 218 #elif defined(HAVE_ACCELERATE) 219 smpl_t tmp = 0.; 220 aubio_vDSP_maxv( s->data, 1, &tmp, s->length ); 221 #else 222 uint_t j; 223 smpl_t tmp = s->data[0]; 224 for (j = 1; j < s->length; j++) { 196 225 tmp = (tmp > s->data[j]) ? tmp : s->data[j]; 197 226 } 198 #else 227 #endif 228 return tmp; 229 } 230 231 smpl_t 232 fvec_min (fvec_t * s) 233 { 234 #if defined(HAVE_INTEL_IPP) 199 235 smpl_t tmp = 0.; 200 aubio_vDSP_maxv(s->data, 1, &tmp, s->length); 201 #endif 202 return tmp; 203 } 204 205 smpl_t 206 fvec_min (fvec_t * s) 207 { 208 #ifndef HAVE_ACCELERATE 209 uint_t j; 210 smpl_t tmp = s->data[0]; 211 for (j = 0; j < s->length; j++) { 212 tmp = (tmp < s->data[j]) ? tmp : s->data[j]; 213 } 214 #else 236 #if HAVE_AUBIO_DOUBLE 237 ippsMin_64f(s->data, (int)s->length, &tmp); 238 #else 239 ippsMin_32f(s->data, (int)s->length, &tmp); 240 #endif 241 #elif defined(HAVE_ACCELERATE) 215 242 smpl_t tmp = 0.; 216 243 aubio_vDSP_minv(s->data, 1, &tmp, s->length); 244 #else 245 uint_t j; 246 smpl_t tmp = s->data[0]; 247 for (j = 1; j < s->length; j++) { 248 tmp = (tmp < s->data[j]) ? tmp : s->data[j]; 249 } 217 250 #endif 218 251 return tmp; … … 575 608 } 576 609 610 uint_t 611 aubio_power_of_two_order (uint_t a) 612 { 613 int order = 0; 614 int temp = aubio_next_power_of_two(a); 615 while (temp >>= 1) { 616 ++order; 617 } 618 return order; 619 } 620 577 621 smpl_t 578 622 aubio_db_spl (const fvec_t * o) … … 639 683 640 684 void 685 aubio_init (void) 686 { 687 /* initialize intel IPP */ 688 #ifdef HAVE_INTEL_IPP 689 IppStatus status = ippInit(); 690 if (status != ippStsNoErr) { 691 fprintf (stderr, "Error: failed to initialize Intel IPP - status %d\n", status); 692 } 693 #endif 694 } 695 696 void 641 697 aubio_cleanup (void) 642 698 {
Note: See TracChangeset
for help on using the changeset viewer.