Changeset 1dfe409 for src


Ignore:
Timestamp:
Mar 31, 2019, 11:12:40 PM (5 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/crepe, fix/ffmpeg5, master
Children:
76b6dd3
Parents:
08246ee (diff), f55630c (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.
Message:

Merge branch 'master' into feature/autosink

Location:
src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/aubio_priv.h

    r08246ee r1dfe409  
    6363#endif
    6464
     65#ifdef HAVE_ERRNO_H
     66#include <errno.h>
     67#endif
     68
    6569#ifdef HAVE_LIMITS_H
    6670#include <limits.h> // for CHAR_BIT, in C99 standard
     
    7175#endif
    7276
    73 #if defined(HAVE_ACCELERATE)
    74 #define HAVE_ATLAS 1
    75 #define HAVE_BLAS 1
    76 #include <Accelerate/Accelerate.h>
    77 #elif defined(HAVE_ATLAS_CBLAS_H)
    78 #elif defined(HAVE_BLAS)
     77#if defined(HAVE_BLAS) // --enable-blas=true
     78// check which cblas header we found
    7979#if defined(HAVE_ATLAS_CBLAS_H)
    8080#define HAVE_ATLAS 1
     
    8484#elif defined(HAVE_CBLAS_H)
    8585#include <cblas.h>
    86 #endif
    87 #endif
    88 
    89 #ifdef HAVE_ACCELERATE
     86#elif !defined(HAVE_ACCELERATE)
     87#error "HAVE_BLAS was defined, but no blas header was found"
     88#endif /* end of cblas includes */
     89#endif
     90
     91#if defined(HAVE_ACCELERATE)
     92// include accelerate framework after blas
     93#define HAVE_ATLAS 1
     94#define HAVE_BLAS 1
    9095#include <Accelerate/Accelerate.h>
     96
    9197#ifndef HAVE_AUBIO_DOUBLE
    9298#define aubio_vDSP_mmov       vDSP_mmov
     
    331337#endif
    332338
     339#ifdef HAVE_C99_VARARGS_MACROS
     340#define AUBIO_STRERR(...)            \
     341    char errorstr[256]; \
     342    AUBIO_STRERROR(errno, errorstr, sizeof(errorstr)); \
     343    AUBIO_ERR(__VA_ARGS__)
     344#else
     345#define AUBIO_STRERR(format, args...)   \
     346    char errorstr[256]; \
     347    AUBIO_STRERROR(errno, errorstr, sizeof(errorstr)); \
     348    AUBIO_ERR(format, ##args)
     349#endif
     350
    333351/* handy shortcuts */
    334352#define DB2LIN(g) (POW(10.0,(g)*0.05f))
  • src/io/sink.c

    r08246ee r1dfe409  
    216216
    217217void del_aubio_sink(aubio_sink_t * s) {
    218   AUBIO_ASSERT(s);
     218  //AUBIO_ASSERT(s);
    219219  if (s && s->s_del && s->sink)
    220220    s->s_del((void *)s->sink);
  • src/io/sink_wavwrite.c

    r08246ee r1dfe409  
    2828#include "io/sink_wavwrite.h"
    2929#include "io/ioutils.h"
    30 
    31 #include <errno.h>
    3230
    3331#define MAX_SIZE 4096
     
    168166  s->fid = fopen((const char *)s->path, "wb");
    169167  if (!s->fid) {
    170     char errorstr[256];
    171     AUBIO_STRERROR(errno, errorstr, sizeof(errorstr));
    172     AUBIO_ERR("sink_wavwrite: could not open %s (%s)\n", s->path, errorstr);
     168    AUBIO_STRERR("sink_wavwrite: could not open %s (%s)\n", s->path, errorstr);
    173169    goto beach;
    174170  }
     
    216212
    217213  // fwrite(*, *, 1, s->fid) was called 13 times, check success
    218   if (written != 13) {
    219     char errorstr[256];
    220     AUBIO_STRERROR(errno, errorstr, sizeof(errorstr));
    221     AUBIO_WRN("sink_wavwrite: writing header to %s failed, expected %d"
    222         " write but got only %d (%s)\n", s->path, 13, written, errorstr);
     214  if (written != 13 || fflush(s->fid)) {
     215    AUBIO_STRERR("sink_wavwrite: writing header to %s failed"
     216        " (wrote %d/%d, %s)\n", s->path, written, 13, errorstr);
     217    fclose(s->fid);
     218    s->fid = NULL;
    223219    return AUBIO_FAIL;
    224220  }
     
    247243
    248244  if (written_frames != write) {
    249     char errorstr[256];
    250     AUBIO_STRERROR(errno, errorstr, sizeof(errorstr));
    251     AUBIO_WRN("sink_wavwrite: trying to write %d frames to %s, but only %d"
     245    AUBIO_STRERR("sink_wavwrite: trying to write %d frames to %s, but only %d"
    252246        " could be written (%s)\n", write, s->path, written_frames, errorstr);
    253247  }
     
    298292  written += fwrite(write_little_endian(data_size, buf, 4), 4, 1, s->fid);
    299293  if (written != 2 || err != 0) {
    300     char errorstr[256];
    301     AUBIO_STRERROR(errno, errorstr, sizeof(errorstr));
    302     AUBIO_WRN("sink_wavwrite: updating header of %s failed, expected %d"
     294    AUBIO_STRERR("sink_wavwrite: updating header of %s failed, expected %d"
    303295        " write but got only %d (%s)\n", s->path, 2, written, errorstr);
    304296  }
    305297  // close file
    306298  if (fclose(s->fid)) {
    307     char errorstr[256];
    308     AUBIO_STRERROR(errno, errorstr, sizeof(errorstr));
    309     AUBIO_ERR("sink_wavwrite: Error closing file %s (%s)\n", s->path, errorstr);
     299    AUBIO_STRERR("sink_wavwrite: Error closing file %s (%s)\n", s->path, errorstr);
    310300  }
    311301  s->fid = NULL;
  • src/io/source.c

    r08246ee r1dfe409  
    139139
    140140void del_aubio_source(aubio_source_t * s) {
    141   AUBIO_ASSERT(s);
     141  //AUBIO_ASSERT(s);
    142142  if (s && s->s_del && s->source)
    143143    s->s_del((void *)s->source);
  • src/io/source_avcodec.c

    r08246ee r1dfe409  
    3131#endif
    3232#include <libavutil/opt.h>
    33 #include <stdlib.h>
    3433
    3534// determine whether we use libavformat from ffmpeg or from libav
     
    121120    uint_t samplerate, uint_t hop_size) {
    122121  aubio_source_avcodec_t * s = AUBIO_NEW(aubio_source_avcodec_t);
    123   AVFormatContext *avFormatCtx = s->avFormatCtx;
    124   AVCodecContext *avCodecCtx = s->avCodecCtx;
    125   AVFrame *avFrame = s->avFrame;
     122  AVFormatContext *avFormatCtx = NULL;
     123  AVCodecContext *avCodecCtx = NULL;
     124  AVFrame *avFrame = NULL;
    126125  sint_t selected_stream = -1;
    127126#if FF_API_LAVF_AVCTX
     
    465464      (const uint8_t **)avFrame->data, in_samples);
    466465#endif /* HAVE_AVRESAMPLE || HAVE_SWRESAMPLE */
    467   if (out_samples <= 0) {
    468     AUBIO_WRN("source_avcodec: no sample found while converting frame (%s)\n",
    469         s->path);
     466  if (out_samples < 0) {
     467    AUBIO_WRN("source_avcodec: error while resampling %s (%d)\n",
     468        s->path, out_samples);
    470469    goto beach;
    471470  }
     
    474473
    475474beach:
    476   s->avFormatCtx = avFormatCtx;
    477   s->avCodecCtx = avCodecCtx;
    478   s->avFrame = avFrame;
    479 #if defined(HAVE_AVRESAMPLE) || defined(HAVE_SWRESAMPLE)
    480   s->avr = avr;
    481 #endif /* HAVE_AVRESAMPLE || HAVE_SWRESAMPLE */
    482   s->output = output;
    483 
    484475  av_packet_unref(&avPacket);
    485476}
     
    629620#ifdef HAVE_AVRESAMPLE
    630621    avresample_close( s->avr );
     622    av_free ( s->avr );
    631623#elif defined(HAVE_SWRESAMPLE)
    632624    swr_close ( s->avr );
    633 #endif
    634     av_free ( s->avr );
     625    swr_free ( &s->avr );
     626#endif
    635627  }
    636628  s->avr = NULL;
  • src/io/source_sndfile.c

    r08246ee r1dfe409  
    175175  sf_count_t read_samples = aubio_sf_read_smpl (s->handle, s->scratch_data,
    176176      s->scratch_size);
     177  uint_t read_length = read_samples / s->input_channels;
     178
     179  /* where to store de-interleaved data */
     180  smpl_t *ptr_data;
     181
    177182  if (!s->handle) {
    178183    AUBIO_ERR("source_sndfile: could not read from %s (file was closed)\n",
     
    182187  }
    183188
    184   uint_t read_length = read_samples / s->input_channels;
    185 
    186   /* where to store de-interleaved data */
    187   smpl_t *ptr_data;
    188189#ifdef HAVE_SAMPLERATE
    189190  if (s->ratio != 1) {
     
    226227  sf_count_t read_samples = aubio_sf_read_smpl (s->handle, s->scratch_data,
    227228      s->scratch_size);
     229  uint_t read_length = read_samples / s->input_channels;
     230
     231  /* where to store de-interleaved data */
     232  smpl_t **ptr_data;
     233
    228234  if (!s->handle) {
    229235    AUBIO_ERR("source_sndfile: could not read from %s (file was closed)\n",
     
    233239  }
    234240
    235   uint_t read_length = read_samples / s->input_channels;
    236 
    237   /* where to store de-interleaved data */
    238   smpl_t **ptr_data;
    239241#ifdef HAVE_SAMPLERATE
    240242  if (s->ratio != 1) {
  • src/io/source_wavread.c

    r08246ee r1dfe409  
    2828#include "source_wavread.h"
    2929
    30 #include <errno.h>
    31 
    3230#define AUBIO_WAVREAD_BUFSIZE 1024
    3331
    34 #define SHORT_TO_FLOAT(x) (smpl_t)(x * 3.0517578125e-05)
     32//#define SHORT_TO_FLOAT(x) (smpl_t)(x * 3.0517578125e-05)
    3533
    3634struct _aubio_source_wavread_t {
     
    10199  s->fid = fopen((const char *)path, "rb");
    102100  if (!s->fid) {
    103     AUBIO_ERR("source_wavread: Failed opening %s (System error: %s)\n", s->path, strerror(errno));
     101    AUBIO_STRERR("source_wavread: Failed opening %s (%s)\n", s->path, errorstr);
    104102    goto beach;
    105103  }
     
    134132    bytes_junk += read_little_endian(buf, 4);
    135133    if (fseek(s->fid, bytes_read + bytes_junk, SEEK_SET) != 0) {
    136       AUBIO_ERR("source_wavread: Failed opening %s (could not seek past JUNK Chunk: %s)\n",
    137           s->path, strerror(errno));
     134      AUBIO_STRERR("source_wavread: Failed opening %s (could not seek past JUNK Chunk: %s)\n",
     135          s->path, errorstr);
    138136      goto beach;
    139137    }
     
    262260    bytes_junk += read_little_endian(buf, 4);
    263261    if (fseek(s->fid, bytes_read + bytes_junk, SEEK_SET) != 0) {
    264       AUBIO_ERR("source_wavread: could not seek past unknown chunk in %s (%s)\n",
    265           s->path, strerror(errno));
     262      AUBIO_STRERR("source_wavread: could not seek past unknown chunk in %s (%s)\n",
     263          s->path, errorstr);
    266264      goto beach;
    267265    }
     
    443441  ret = fseek(s->fid, s->seek_start + pos * s->blockalign, SEEK_SET);
    444442  if (ret != 0) {
    445     AUBIO_ERR("source_wavread: could not seek %s at %d (%s)\n", s->path, pos, strerror(errno));
     443    AUBIO_STRERR("source_wavread: could not seek %s at %d (%s)\n", s->path, pos, errorstr);
    446444    return AUBIO_FAIL;
    447445  }
     
    464462  }
    465463  if (fclose(s->fid)) {
    466     AUBIO_ERR("source_wavread: could not close %s (%s)\n", s->path, strerror(errno));
     464    AUBIO_STRERR("source_wavread: could not close %s (%s)\n", s->path, errorstr);
    467465    return AUBIO_FAIL;
    468466  }
Note: See TracChangeset for help on using the changeset viewer.