Changeset 3873e5e


Ignore:
Timestamp:
Sep 5, 2017, 1:01:34 PM (7 years ago)
Author:
Paul Brossier <piem@piem.org>
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:
5d46eca
Parents:
60583a3
Message:

src/spectral/dct_ooura.c: further optimize by computing scaling factors once

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/spectral/dct_ooura.c

    r60583a3 r3873e5e  
    3131  smpl_t *w;
    3232  int *ip;
     33  smpl_t scalers[5];
    3334};
    3435
     
    4546  s->ip = AUBIO_ARRAY(int, 3 + (1 << (int)FLOOR(LOG(s->size/2) / LOG(2))) / 2);
    4647  s->ip[0] = 0;
     48  s->scalers[0] = 2. * SQRT(1./(4.*s->size));
     49  s->scalers[1] = 2. * SQRT(1./(2.*s->size));
     50  s->scalers[2] = 1. / s->scalers[0];
     51  s->scalers[3] = 1. / s->scalers[1];
     52  s->scalers[4] = 2. / s->size;
    4753  return s;
    4854beach:
     
    6369  aubio_ooura_ddct(s->size, -1, s->input->data, s->ip, s->w);
    6470  // apply orthonormal scaling
    65   s->input->data[0] *= 2.* SQRT(1./(4.*s->input->length));
     71  s->input->data[0] *= s->scalers[0];
    6672  for (i = 1; i < s->input->length; i++) {
    67     s->input->data[i] *= 2. * SQRT(1./(2.*s->input->length));
     73    s->input->data[i] *= s->scalers[1];
    6874  }
    6975  fvec_copy(s->input, output);
     
    7379  uint_t i = 0;
    7480  fvec_copy(input, s->input);
    75   s->input->data[0] /= 2.* SQRT(1./(4.*s->input->length));
     81  s->input->data[0] *= s->scalers[2];
    7682  for (i = 1; i < s->input->length; i++) {
    77     s->input->data[i] /= 2. * SQRT(1./(2.*s->input->length));
     83    s->input->data[i] *= s->scalers[3];
    7884  }
    7985  s->input->data[0] *= .5;
    8086  aubio_ooura_ddct(s->size, 1, s->input->data, s->ip, s->w);
    8187  for (i = 0; i < s->input->length; i++) {
    82     s->input->data[i] *= 2./s->input->length;
     88    s->input->data[i] *= s->scalers[4];
    8389  }
    8490  fvec_copy(s->input, output);
Note: See TracChangeset for help on using the changeset viewer.