Changeset 24c207f


Ignore:
Timestamp:
Mar 23, 2017, 3:46:07 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, sampler
Children:
ecf7572
Parents:
59be50d (diff), 91fa88d (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 gitshaversion

Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • Makefile

    r59be50d r24c207f  
    1111
    1212WAFCMD=python waf
    13 WAFURL=https://waf.io/waf-1.9.6
    1413
    1514#WAFOPTS:=
  • python/lib/moresetuptools.py

    r59be50d r24c207f  
    7575    # loof for additional packages
    7676    print("Info: looking for *optional* additional packages")
    77     packages = ['libavcodec', 'libavformat', 'libavutil', 'libavresample',
    78                 'jack',
    79                 'jack',
     77    packages = ['libavcodec', 'libavformat', 'libavutil',
     78                'libswresample', 'libavresample',
    8079                'sndfile',
    8180                #'fftw3f',
     
    8988    if 'avcodec' in ext.libraries \
    9089            and 'avformat' in ext.libraries \
    91             and 'avutil' in ext.libraries \
    92             and 'avresample' in ext.libraries:
    93         ext.define_macros += [('HAVE_LIBAV', 1)]
    94     if 'jack' in ext.libraries:
    95         ext.define_macros += [('HAVE_JACK', 1)]
     90            and 'avutil' in ext.libraries:
     91        if 'swresample' in ext.libraries:
     92            ext.define_macros += [('HAVE_SWRESAMPLE', 1)]
     93        elif 'avresample' in ext.libraries:
     94            ext.define_macros += [('HAVE_AVRESAMPLE', 1)]
     95        if 'swresample' in ext.libraries or 'avresample' in ext.libraries:
     96            ext.define_macros += [('HAVE_LIBAV', 1)]
    9697    if 'sndfile' in ext.libraries:
    9798        ext.define_macros += [('HAVE_SNDFILE', 1)]
  • scripts/build_mingw

    r59be50d r24c207f  
    11#! /bin/bash
    22
    3 # This script cross compiles aubio for windows using mingw, both for 32 and 64
    4 # bits. Built binaries will be placed in ./dist-win32 and ./dist-win64.
    5 
     3# This script cross compiles aubio for windows using mingw, four times:
     4#
     5#  - 32 and 64 bits with no external dependencies
     6#  - 32 and 64 bits against ffmpeg
     7#
    68# On debian or ubuntu, you will want to 'apt-get install gcc-mingw-w64'
    79
     
    911set -x
    1012
    11 WAFOPTS="-v --disable-avcodec --disable-samplerate --disable-jack --disable-sndfile"
     13source VERSION
     14VERSION="$AUBIO_MAJOR_VERSION.$AUBIO_MINOR_VERSION.$AUBIO_PATCH_VERSION"
     15VERSION+="$AUBIO_VERSION_STATUS"
    1216
    13 [ -d dist-win32 ] && rm -rf dist-win32
    14 [ -d dist-win64 ] && rm -rf dist-win64
     17FFMPEG_BUILDS_URL="https://ffmpeg.zeranoe.com/builds"
     18FFMPEG_DEFAULT="20170315-6c4665d"
    1519
    16 CFLAGS="-Os" \
    17   LDFLAGS="" \
    18   CC=x86_64-w64-mingw32-gcc \
    19   ./waf distclean configure build install --destdir=$PWD/dist-win64 \
    20     --testcmd="echo %s" \
    21     $WAFOPTS --with-target-platform=win64
     20# define some default CFLAGS
     21DEF_CFLAGS="-Os -I/usr/share/mingw-w64"
     22DEF_LDFLAGS=""
    2223
    23 CFLAGS="-Os" \
    24   LDFLAGS="" \
    25   CC=i686-w64-mingw32-gcc \
    26   ./waf distclean configure build install --destdir=$PWD/dist-win32 \
    27     --testcmd="echo %s" \
    28     $WAFOPTS --with-target-platform=win32
     24WAFOPTS=""
     25# disable external deps to make sure we don't try to use the host package
     26WAFOPTS+=" --disable-samplerate --disable-jack --disable-sndfile"
     27# enable ffmpeg build
     28WAFOPTS+=" --disable-avcodec"
     29# install without a prefix
     30WAFOPTS+=" --prefix=/"
     31# compile the tests, but fake running them
     32# passing this option WAFOPTS fails (escaping?), added in actual waf call below
     33#WAFOPTS+=" --testcmd='echo %s'"
     34
     35# debugging
     36#WAFOPTS+=" -v"
     37#WAFOPTS+=" -j1"
     38#WAFOPTS+=" --notests"
     39
     40function fetch_ffpmeg() {
     41  ## manually add ffmpeg (no pkg-config .pc files in bins)
     42  [ -n "$FFMPEG_VERSION" ] || FFMPEG_VERSION=$FFMPEG_DEFAULT
     43  FFMPEG_TARBALL="$PWD/ffmpeg-$FFMPEG_VERSION-$TARGET-dev.zip"
     44  FFMPEG_BINARIES="${FFMPEG_TARBALL%%.zip}"
     45  if [ ! -d "$FFMPEG_BINARIES" ]
     46  then
     47    if [ ! -f "$FFMPEG_TARBALL" ]
     48    then
     49      curl -O $FFMPEG_BUILDS_URL/$TARGET/dev/ffmpeg-$FFMPEG_VERSION-$TARGET-dev.zip
     50    else
     51      echo "using $FFMPEG_TARBALL"
     52    fi
     53    unzip -x $FFMPEG_TARBALL
     54  else
     55    echo "using $FFMPEG_BINARIES"
     56  fi
     57}
     58
     59function get_cflags() {
     60  CFLAGS="$DEF_CFLAGS"
     61  LDFLAGS="$DEF_LDFLAGS"
     62  if [ -n "$WITH_FFMEG" ]
     63  then
     64    fetch_ffpmeg
     65    CFLAGS+=" -DHAVE_LIBAV=1 -DHAVE_SWRESAMPLE=1"
     66    CFLAGS+=" -I$FFMPEG_BINARIES/include"
     67    LDFLAGS+=" -lavcodec -lavformat -lavutil -lswresample"
     68    LDFLAGS+=" -L$FFMPEG_BINARIES/lib"
     69  fi
     70}
     71
     72function build_mingw() {
     73  DESTDIR="$PWD/aubio-$VERSION-$TARGET"
     74  [ -n "$WITH_FFMEG" ] && DESTDIR+="-ffmpeg"
     75  [ -f $DESTDIR.zip ] && echo "Remove existing $DESTDIR.zip first" && exit 1
     76  [ -d $DESTDIR ] && rm -rf $DESTDIR
     77  WAFOPTS_TGT="$WAFOPTS --destdir=$DESTDIR"
     78  WAFOPTS_TGT+=" --with-target-platform=$TARGET"
     79  get_cflags
     80  CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" \
     81    ./waf distclean configure build install $WAFOPTS_TGT --testcmd='echo %s'
     82  zip -r $DESTDIR.zip `basename $DESTDIR`
     83  rm -rf $DESTDIR
     84  sha256sum $DESTDIR.zip > $DESTDIR.zip.sha256
     85}
     86
     87function build_mingw32() {
     88  TARGET=win32
     89  export CC=i686-w64-mingw32-gcc
     90  build_mingw
     91}
     92
     93function build_mingw64() {
     94  TARGET=win64
     95  export CC=x86_64-w64-mingw32-gcc
     96  build_mingw
     97}
     98
     99# fetch waf if needed
     100[ -f "waf" ] || make getwaf
     101
     102# first build without ffmpeg
     103build_mingw32
     104build_mingw64
     105
     106# then build against ffmpeg
     107WITH_FFMEG=1
     108build_mingw32
     109build_mingw64
     110
     111set +x
     112echo ""
     113echo "All done! The following files were generated:"
     114echo ""
     115ls -lart aubio*.zip*
  • scripts/get_waf.sh

    r59be50d r24c207f  
    44set -x
    55
    6 WAFURL=https://waf.io/waf-1.8.22
     6WAFURL=https://waf.io/waf-1.9.6
    77
    88( which wget > /dev/null && wget -qO waf $WAFURL ) || ( which curl > /dev/null && curl $WAFURL > waf )
  • src/io/source_avcodec.c

    r59be50d r24c207f  
    2525#include <libavcodec/avcodec.h>
    2626#include <libavformat/avformat.h>
     27#if defined(HAVE_SWRESAMPLE)
     28#include <libswresample/swresample.h>
     29#elif defined(HAVE_AVRESAMPLE)
    2730#include <libavresample/avresample.h>
     31#endif
    2832#include <libavutil/opt.h>
    2933#include <stdlib.h>
     
    6973  AVFrame *avFrame;
    7074  AVPacket avPacket;
     75#ifdef HAVE_AVRESAMPLE
    7176  AVAudioResampleContext *avr;
     77#elif defined(HAVE_SWRESAMPLE)
     78  SwrContext *avr;
     79#endif
    7280  smpl_t *output;
    7381  uint_t read_samples;
     
    277285    uint_t output_channels = multi ? s->input_channels : 1;
    278286    int64_t output_layout = av_get_default_channel_layout(output_channels);
     287#ifdef HAVE_AVRESAMPLE
    279288    AVAudioResampleContext *avr = avresample_alloc_context();
    280289    AVAudioResampleContext *oldavr = s->avr;
     290#elif defined(HAVE_SWRESAMPLE)
     291    SwrContext *avr = swr_alloc();
     292    SwrContext *oldavr = s->avr;
     293#endif /* HAVE_AVRESAMPLE || HAVE_SWRESAMPLE */
    281294
    282295    av_opt_set_int(avr, "in_channel_layout",  input_layout,           0);
     
    293306    //av_opt_set_int(avr, "out_sample_fmt",     AV_SAMPLE_FMT_FLTP,      0);
    294307    int err;
     308#ifdef HAVE_AVRESAMPLE
    295309    if ( ( err = avresample_open(avr) ) < 0) {
     310#elif defined(HAVE_SWRESAMPLE)
     311    if ( ( err = swr_init(avr) ) < 0) {
     312#endif /* HAVE_AVRESAMPLE || HAVE_SWRESAMPLE */
    296313      char errorstr[256];
    297314      av_strerror (err, errorstr, sizeof(errorstr));
     
    303320    s->avr = avr;
    304321    if (oldavr != NULL) {
     322#ifdef HAVE_AVRESAMPLE
    305323      avresample_close( oldavr );
     324#elif defined(HAVE_SWRESAMPLE)
     325      swr_close ( oldavr );
     326#endif /* HAVE_AVRESAMPLE || HAVE_SWRESAMPLE */
    306327      av_free ( oldavr );
    307328      oldavr = NULL;
     
    317338  AVPacket avPacket = s->avPacket;
    318339  av_init_packet (&avPacket);
     340#ifdef HAVE_AVRESAMPLE
    319341  AVAudioResampleContext *avr = s->avr;
     342#elif defined(HAVE_SWRESAMPLE)
     343  SwrContext *avr = s->avr;
     344#endif /* HAVE_AVRESAMPLE || HAVE_SWRESAMPLE */
    320345  smpl_t *output = s->output;
    321346  *read_samples = 0;
     
    332357      av_strerror (err, errorstr, sizeof(errorstr));
    333358      AUBIO_ERR("source_avcodec: could not read frame in %s (%s)\n", s->path, errorstr);
     359      s->eof = 1;
    334360      goto beach;
    335361    }
     
    370396  }
    371397
     398#ifdef HAVE_AVRESAMPLE
    372399  int in_linesize = 0;
    373400  av_samples_get_buffer_size(&in_linesize, avCodecCtx->channels,
     
    379406        (uint8_t **)&output, out_linesize, max_out_samples,
    380407        (uint8_t **)avFrame->data, in_linesize, in_samples);
     408#elif defined(HAVE_SWRESAMPLE)
     409  int in_samples = avFrame->nb_samples;
     410  int max_out_samples = AUBIO_AVCODEC_MAX_BUFFER_SIZE / avCodecCtx->channels;
     411  int out_samples = swr_convert( avr,
     412      (uint8_t **)&output, max_out_samples,
     413      (const uint8_t **)avFrame->data, in_samples);
     414#endif /* HAVE_AVRESAMPLE || HAVE_SWRESAMPLE */
    381415  if (out_samples <= 0) {
    382416    AUBIO_WRN("source_avcodec: no sample found while converting frame (%s)\n", s->path);
     
    390424  s->avCodecCtx = avCodecCtx;
    391425  s->avFrame = avFrame;
     426#if defined(HAVE_AVRESAMPLE) || defined(HAVE_SWRESAMPLE)
    392427  s->avr = avr;
     428#endif /* HAVE_AVRESAMPLE || HAVE_SWRESAMPLE */
    393429  s->output = output;
    394430
     
    499535  s->read_index = 0;
    500536  s->read_samples = 0;
     537#ifdef HAVE_AVRESAMPLE
    501538  // reset the AVAudioResampleContext
    502539  avresample_close(s->avr);
    503540  avresample_open(s->avr);
     541#elif defined(HAVE_SWRESAMPLE)
     542  swr_close(s->avr);
     543  swr_init(s->avr);
     544#endif
    504545  return ret;
    505546}
     
    515556uint_t aubio_source_avcodec_close(aubio_source_avcodec_t * s) {
    516557  if (s->avr != NULL) {
     558#ifdef HAVE_AVRESAMPLE
    517559    avresample_close( s->avr );
     560#elif defined(HAVE_SWRESAMPLE)
     561    swr_close ( s->avr );
     562#endif
    518563    av_free ( s->avr );
    519564  }
    520565  s->avr = NULL;
    521566  if (s->avCodecCtx != NULL) {
     567#ifndef HAVE_AUBIO_LIBAVCODEC_DEPRECATED
     568    avcodec_free_context( &s->avCodecCtx );
     569#else
    522570    avcodec_close ( s->avCodecCtx );
     571#endif
    523572  }
    524573  s->avCodecCtx = NULL;
  • src/utils/windll.c

    r59be50d r24c207f  
    4242#include "aubio.h"
    4343
    44 BOOL APIENTRY DllMain( HMODULE hModule,
     44BOOL APIENTRY DllMain( HMODULE hModule UNUSED,
    4545                       DWORD  ul_reason_for_call,
    46                        LPVOID lpReserved )
     46                       LPVOID lpReserved UNUSED)
    4747{
    4848  switch (ul_reason_for_call)
  • src/wscript_build

    r59be50d r24c207f  
    88uselib += ['AVCODEC']
    99uselib += ['AVFORMAT']
     10uselib += ['SWRESAMPLE']
    1011uselib += ['AVRESAMPLE']
    1112uselib += ['AVUTIL']
  • wscript

    r59be50d r24c207f  
    323323                args = '--cflags --libs', uselib_store = 'AVUTIL',
    324324                mandatory = ctx.options.enable_avcodec)
    325         ctx.check_cfg(package = 'libavresample', atleast_version = '1.0.1',
    326                 args = '--cflags --libs', uselib_store = 'AVRESAMPLE',
    327                 mandatory = ctx.options.enable_avcodec)
    328         if all ( 'HAVE_' + i in ctx.env
    329                 for i in ['AVCODEC', 'AVFORMAT', 'AVUTIL', 'AVRESAMPLE'] ):
     325        ctx.check_cfg(package = 'libswresample', atleast_version = '2.3.0',
     326                args = '--cflags --libs', uselib_store = 'SWRESAMPLE',
     327                mandatory = False)
     328        if 'HAVE_SWRESAMPLE' not in ctx.env:
     329            ctx.check_cfg(package = 'libavresample', atleast_version = '1.0.1',
     330                    args = '--cflags --libs', uselib_store = 'AVRESAMPLE',
     331                    mandatory = False)
     332
     333        msg_check = 'Checking for all libav libraries'
     334        if 'HAVE_AVCODEC' not in ctx.env:
     335            ctx.msg(msg_check, 'not found (missing avcodec)', color = 'YELLOW')
     336        elif 'HAVE_AVFORMAT' not in ctx.env:
     337            ctx.msg(msg_check, 'not found (missing avformat)', color = 'YELLOW')
     338        elif 'HAVE_AVUTIL' not in ctx.env:
     339            ctx.msg(msg_check, 'not found (missing avutil)', color = 'YELLOW')
     340        elif 'HAVE_SWRESAMPLE' not in ctx.env and 'HAVE_AVRESAMPLE' not in ctx.env:
     341            resample_missing = 'not found (avresample or swresample required)'
     342            ctx.msg(msg_check, resample_missing, color = 'YELLOW')
     343        else:
     344            ctx.msg(msg_check, 'yes')
     345            if 'HAVE_SWRESAMPLE' in ctx.env:
     346                ctx.define('HAVE_SWRESAMPLE', 1)
     347            elif 'HAVE_AVRESAMPLE' in ctx.env:
     348                ctx.define('HAVE_AVRESAMPLE', 1)
    330349            ctx.define('HAVE_LIBAV', 1)
    331             ctx.msg('Checking for all libav libraries', 'yes')
    332         else:
    333             ctx.msg('Checking for all libav libraries', 'not found', color = 'YELLOW')
    334350
    335351    if (ctx.options.enable_wavread != False):
Note: See TracChangeset for help on using the changeset viewer.