ref: 813f4c7d89544d2c71518e0e121bdadfe339d3e2
parent: 1f6a9f84fbe06965c588944d1e1de17544c2f923
author: Eduard Müller <[email protected]>
date: Tue Dec 20 18:24:28 EST 2016
help compiler to optimize aubio_pitchyin_do ... by giving it addresses for all arrays which are referenced in inner loops
--- a/src/pitch/pitchyin.c
+++ b/src/pitch/pitchyin.c
@@ -127,24 +127,27 @@
return 0;
}
-
/* all the above in one */
void
aubio_pitchyin_do (aubio_pitchyin_t * o, const fvec_t * input, fvec_t * out)
{
- smpl_t tol = o->tol;
- fvec_t *yin = o->yin;
- uint_t j, tau = 0;
+ const smpl_t tol = o->tol;
+ fvec_t* yin = o->yin;
+ const smpl_t *input_data = input->data;
+ const uint_t length = yin->length;
+ smpl_t *yin_data = yin->data;
+ uint_t j, tau;
sint_t period;
- smpl_t tmp = 0., tmp2 = 0.;
- yin->data[0] = 1.;
- for (tau = 1; tau < yin->length; tau++) {
- yin->data[tau] = 0.;
- for (j = 0; j < yin->length; j++) {
- tmp = input->data[j] - input->data[j + tau];
- yin->data[tau] += SQR (tmp);
+ smpl_t tmp, tmp2 = 0.;
+
+ yin_data[0] = 1.;
+ for (tau = 1; tau < length; tau++) {
+ yin_data[tau] = 0.;
+ for (j = 0; j < length; j++) {
+ tmp = input_data[j] - input_data[j + tau];
+ yin_data[tau] += SQR (tmp);
}
- tmp2 += yin->data[tau];
+ tmp2 += yin_data[tau];
if (tmp2 != 0) {
yin->data[tau] *= tau / tmp2;
} else {
@@ -151,8 +154,8 @@
yin->data[tau] = 1.;
}
period = tau - 3;
- if (tau > 4 && (yin->data[period] < tol) &&
- (yin->data[period] < yin->data[period + 1])) {
+ if (tau > 4 && (yin_data[period] < tol) &&
+ (yin_data[period] < yin_data[period + 1])) {
out->data[0] = fvec_quadratic_peak_pos (yin, period);
goto beach;
}