Changeset 813ced8 for src


Ignore:
Timestamp:
Nov 26, 2018, 4:30:14 PM (13 months ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master
Children:
5c3061e
Parents:
fe6a9a23
Message:

[dct] fail plain creation if size <= 0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/spectral/dct_plain.c

    rfe6a9a23 r813ced8  
    3232};
    3333
     34void del_aubio_dct_plain (aubio_dct_plain_t *s);
     35
    3436aubio_dct_plain_t * new_aubio_dct_plain (uint_t size) {
    3537  aubio_dct_plain_t * s = AUBIO_NEW(aubio_dct_plain_t);
     
    3840  if (aubio_is_power_of_two (size) == 1 && size > 16) {
    3941    AUBIO_WRN("dct_plain: using plain dct but size %d is a power of two\n", size);
     42  }
     43  if ((sint_t)size <= 0) {
     44    AUBIO_ERR("dct_plain: can only create with size > 0, requested %d\n",
     45        size);
     46    goto failure;
    4047  }
    4148
     
    6976  }
    7077  return s;
     78failure:
     79  del_aubio_dct_plain(s);
     80  return NULL;
    7181}
    7282
    7383void del_aubio_dct_plain (aubio_dct_plain_t *s) {
    74   del_fmat(s->dct_coeffs);
    75   del_fmat(s->idct_coeffs);
     84  if (s->dct_coeffs)
     85    del_fmat(s->dct_coeffs);
     86  if (s->idct_coeffs)
     87    del_fmat(s->idct_coeffs);
    7688  AUBIO_FREE(s);
    7789}
     
    7991void aubio_dct_plain_do(aubio_dct_plain_t *s, const fvec_t *input, fvec_t *output) {
    8092  if (input->length != output->length || input->length != s->size) {
    81     AUBIO_WRN("dct_plain: using input length %d, but output length = %d and size = %d",
     93    AUBIO_WRN("dct_plain: using input length %d, but output length = %d and size = %d\n",
    8294        input->length, output->length, s->size);
    8395  }
     
    8799void aubio_dct_plain_rdo(aubio_dct_plain_t *s, const fvec_t *input, fvec_t *output) {
    88100  if (input->length != output->length || input->length != s->size) {
    89     AUBIO_WRN("dct_plain: using input length %d, but output length = %d and size = %d",
     101    AUBIO_WRN("dct_plain: using input length %d, but output length = %d and size = %d\n",
    90102        input->length, output->length, s->size);
    91103  }
Note: See TracChangeset for help on using the changeset viewer.