Changeset bad88364 for src


Ignore:
Timestamp:
Mar 17, 2017, 10:59:51 AM (8 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
sampler
Children:
f8bdcb2
Parents:
bff692e (diff), c7d444a (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 sampler

Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/io/source_avcodec.c

    rbff692e rbad88364  
    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>
     
    7781  AVFrame *avFrame;
    7882  AVPacket avPacket;
     83#ifdef HAVE_AVRESAMPLE
    7984  AVAudioResampleContext *avr;
     85#elif defined(HAVE_SWRESAMPLE)
     86  SwrContext *avr;
     87#endif
    8088  smpl_t *output;
    8189  uint_t read_samples;
     
    309317    uint_t output_channels = multi ? s->input_channels : 1;
    310318    int64_t output_layout = av_get_default_channel_layout(output_channels);
     319#ifdef HAVE_AVRESAMPLE
    311320    AVAudioResampleContext *avr = avresample_alloc_context();
    312321    AVAudioResampleContext *oldavr = s->avr;
     322#elif defined(HAVE_SWRESAMPLE)
     323    SwrContext *avr = swr_alloc();
     324    SwrContext *oldavr = s->avr;
     325#endif /* HAVE_AVRESAMPLE || HAVE_SWRESAMPLE */
    313326
    314327    av_opt_set_int(avr, "in_channel_layout",  input_layout,           0);
     
    325338    //av_opt_set_int(avr, "out_sample_fmt",     AV_SAMPLE_FMT_FLTP,      0);
    326339    int err;
     340#ifdef HAVE_AVRESAMPLE
    327341    if ( ( err = avresample_open(avr) ) < 0) {
     342#elif defined(HAVE_SWRESAMPLE)
     343    if ( ( err = swr_init(avr) ) < 0) {
     344#endif /* HAVE_AVRESAMPLE || HAVE_SWRESAMPLE */
    328345      char errorstr[256];
    329346      av_strerror (err, errorstr, sizeof(errorstr));
     
    335352    s->avr = avr;
    336353    if (oldavr != NULL) {
     354#ifdef HAVE_AVRESAMPLE
    337355      avresample_close( oldavr );
     356#elif defined(HAVE_SWRESAMPLE)
     357      swr_close ( oldavr );
     358#endif /* HAVE_AVRESAMPLE || HAVE_SWRESAMPLE */
    338359      av_free ( oldavr );
    339360      oldavr = NULL;
     
    349370  AVPacket avPacket = s->avPacket;
    350371  av_init_packet (&avPacket);
     372#ifdef HAVE_AVRESAMPLE
    351373  AVAudioResampleContext *avr = s->avr;
     374#elif defined(HAVE_SWRESAMPLE)
     375  SwrContext *avr = s->avr;
     376#endif /* HAVE_AVRESAMPLE || HAVE_SWRESAMPLE */
    352377  smpl_t *output = s->output;
    353378  *read_samples = 0;
     
    402427  }
    403428
     429#ifdef HAVE_AVRESAMPLE
    404430  int in_linesize = 0;
    405431  av_samples_get_buffer_size(&in_linesize, avCodecCtx->channels,
     
    411437        (uint8_t **)&output, out_linesize, max_out_samples,
    412438        (uint8_t **)avFrame->data, in_linesize, in_samples);
     439#elif defined(HAVE_SWRESAMPLE)
     440  int in_samples = avFrame->nb_samples;
     441  int max_out_samples = AUBIO_AVCODEC_MAX_BUFFER_SIZE / avCodecCtx->channels;
     442  int out_samples = swr_convert( avr,
     443      (uint8_t **)&output, max_out_samples,
     444      (const uint8_t **)avFrame->data, in_samples);
     445#endif /* HAVE_AVRESAMPLE || HAVE_SWRESAMPLE */
    413446  if (out_samples <= 0) {
    414447    AUBIO_WRN("source_avcodec: no sample found while converting frame (%s)\n", s->path);
     
    422455  s->avCodecCtx = avCodecCtx;
    423456  s->avFrame = avFrame;
     457#if defined(HAVE_AVRESAMPLE) || defined(HAVE_SWRESAMPLE)
    424458  s->avr = avr;
     459#endif /* HAVE_AVRESAMPLE || HAVE_SWRESAMPLE */
    425460  s->output = output;
    426461
     
    531566  s->read_index = 0;
    532567  s->read_samples = 0;
     568#ifdef HAVE_AVRESAMPLE
    533569  // reset the AVAudioResampleContext
    534570  avresample_close(s->avr);
    535571  avresample_open(s->avr);
     572#elif defined(HAVE_SWRESAMPLE)
     573  swr_close(s->avr);
     574  swr_init(s->avr);
     575#endif
    536576  return ret;
    537577}
     
    547587uint_t aubio_source_avcodec_close(aubio_source_avcodec_t * s) {
    548588  if (s->avr != NULL) {
     589#ifdef HAVE_AVRESAMPLE
    549590    avresample_close( s->avr );
     591#elif defined(HAVE_SWRESAMPLE)
     592    swr_close ( s->avr );
     593#endif
    550594    av_free ( s->avr );
    551595  }
  • src/utils/windll.c

    rbff692e rbad88364  
    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

    rbff692e rbad88364  
    99uselib += ['AVCODEC']
    1010uselib += ['AVFORMAT']
     11uselib += ['SWRESAMPLE']
    1112uselib += ['AVRESAMPLE']
    1213uselib += ['AVUTIL']
Note: See TracChangeset for help on using the changeset viewer.