Changeset ac97e80d for src


Ignore:
Timestamp:
Nov 16, 2018, 9:14:42 PM (6 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:
6551a683
Parents:
8a4ccf7
Message:

[source] [avcodec] create resampler once

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/io/source_avcodec.c

    r8a4ccf7 rac97e80d  
    9090  sint_t selected_stream;
    9191  uint_t eof;
    92   uint_t multi;
    9392};
    9493
    9594// create or re-create the context when _do or _do_multi is called
    96 void aubio_source_avcodec_reset_resampler(aubio_source_avcodec_t * s,
    97     uint_t multi);
     95void aubio_source_avcodec_reset_resampler(aubio_source_avcodec_t * s);
    9896// actually read a frame
    9997void aubio_source_avcodec_readframe(aubio_source_avcodec_t *s,
     
    285283  s->avFrame = avFrame;
    286284
    287   // default to mono output
    288   aubio_source_avcodec_reset_resampler(s, 0);
     285  aubio_source_avcodec_reset_resampler(s);
    289286
    290287  if (s->avr == NULL) goto beach;
    291288
    292289  s->eof = 0;
    293   s->multi = 0;
    294290
    295291  //av_log_set_level(AV_LOG_QUIET);
     
    304300}
    305301
    306 void aubio_source_avcodec_reset_resampler(aubio_source_avcodec_t * s,
    307     uint_t multi)
     302void aubio_source_avcodec_reset_resampler(aubio_source_avcodec_t * s)
    308303{
    309304  // create or reset resampler to/from mono/multi-channel
    310   if ( (multi != s->multi) || (s->avr == NULL) ) {
     305  if ( s->avr == NULL ) {
    311306    int err;
    312307    int64_t input_layout = av_get_default_channel_layout(s->input_channels);
     
    354349      oldavr = NULL;
    355350    }
    356     s->multi = multi;
    357351  }
    358352}
     
    495489void aubio_source_avcodec_do(aubio_source_avcodec_t * s, fvec_t * read_data,
    496490    uint_t * read) {
    497   uint_t i;
     491  uint_t i, j;
    498492  uint_t end = 0;
    499493  uint_t total_wrote = 0;
    500   // switch from multi
    501   if (s->multi == 1) aubio_source_avcodec_reset_resampler(s, 0);
    502494  while (total_wrote < s->hop_size) {
    503495    end = MIN(s->read_samples - s->read_index, s->hop_size - total_wrote);
     
    536528  uint_t end = 0;
    537529  uint_t total_wrote = 0;
    538   // switch from mono
    539   if (s->multi == 0) aubio_source_avcodec_reset_resampler(s, 1);
    540530  while (total_wrote < s->hop_size) {
    541531    end = MIN(s->read_samples - s->read_index, s->hop_size - total_wrote);
Note: See TracChangeset for help on using the changeset viewer.