Changeset 813f4c7


Ignore:
Timestamp:
Dec 21, 2016, 1:00:24 AM (4 years ago)
Author:
Eduard Müller <mueller.eduard@googlemail.com>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master, sampler, yinfft+
Children:
e79943b
Parents:
1f6a9f8
git-author:
Eduard Müller <mueller.eduard@googlemail.com> (12/20/16 23:24:28)
git-committer:
Eduard Müller <mueller.eduard@googlemail.com> (12/21/16 01:00:24)
Message:

help compiler to optimize aubio_pitchyin_do
... by giving it addresses for all arrays which are referenced in inner loops

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/pitch/pitchyin.c

    r1f6a9f8 r813f4c7  
    128128}
    129129
    130 
    131130/* all the above in one */
    132131void
    133132aubio_pitchyin_do (aubio_pitchyin_t * o, const fvec_t * input, fvec_t * out)
    134133{
    135   smpl_t tol = o->tol;
    136   fvec_t *yin = o->yin;
    137   uint_t j, tau = 0;
     134  const smpl_t tol = o->tol;
     135  fvec_t* yin = o->yin;
     136  const smpl_t *input_data = input->data;
     137  const uint_t length = yin->length;
     138  smpl_t *yin_data = yin->data;
     139  uint_t j, tau;
    138140  sint_t period;
    139   smpl_t tmp = 0., tmp2 = 0.;
    140   yin->data[0] = 1.;
    141   for (tau = 1; tau < yin->length; tau++) {
    142     yin->data[tau] = 0.;
    143     for (j = 0; j < yin->length; j++) {
    144       tmp = input->data[j] - input->data[j + tau];
    145       yin->data[tau] += SQR (tmp);
     141  smpl_t tmp, tmp2 = 0.;
     142
     143  yin_data[0] = 1.;
     144  for (tau = 1; tau < length; tau++) {
     145    yin_data[tau] = 0.;
     146    for (j = 0; j < length; j++) {
     147      tmp = input_data[j] - input_data[j + tau];
     148      yin_data[tau] += SQR (tmp);
    146149    }
    147     tmp2 += yin->data[tau];
     150    tmp2 += yin_data[tau];
    148151    if (tmp2 != 0) {
    149152      yin->data[tau] *= tau / tmp2;
     
    152155    }
    153156    period = tau - 3;
    154     if (tau > 4 && (yin->data[period] < tol) &&
    155         (yin->data[period] < yin->data[period + 1])) {
     157    if (tau > 4 && (yin_data[period] < tol) &&
     158        (yin_data[period] < yin_data[period + 1])) {
    156159      out->data[0] = fvec_quadratic_peak_pos (yin, period);
    157160      goto beach;
Note: See TracChangeset for help on using the changeset viewer.