Changeset d75e2d5


Ignore:
Timestamp:
Dec 5, 2013, 3:20:12 PM (10 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, pitchshift, sampler, timestretch, yinfft+
Children:
f3b93c6
Parents:
75eb182
Message:

src/io/source_avcodec.c: simplify, improve comments

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/io/source_avcodec.c

    r75eb182 rd75e2d5  
    7474  s->path = path;
    7575
    76   // try opening the file and get some info about it
    7776  // register all formats and codecs
    7877  av_register_all();
    7978
    80   // open file
     79  // try opening the file and get some info about it
    8180  AVFormatContext *avFormatCtx = s->avFormatCtx;
    8281  avFormatCtx = NULL;
     
    110109  //av_dump_format(avFormatCtx, 0, s->path, 0);
    111110
     111  // look for the first audio stream, printing a warning if more than one is found
    112112  uint_t i;
    113113  sint_t selected_stream = -1;
     
    125125    goto beach;
    126126  }
    127 
    128127  //AUBIO_DBG("Taking stream %d in file %s\n", selected_stream, s->path);
    129128
     
    220219  int16_t *output = s->output;
    221220
    222   uint_t i;
    223221  int err = av_read_frame (avFormatCtx, &avPacket);
    224222  if (err != 0) {
     
    279277  uint_t i;
    280278  //AUBIO_DBG("entering 'do' with %d, %d\n", s->read_samples, s->read_index);
    281   // begin reading
    282   if (s->read_samples == 0) {
    283     uint_t avcodec_read = 0;
    284     aubio_source_avcodec_readframe(s, &avcodec_read);
    285     s->read_samples += avcodec_read;
    286     s->read_index = 0;
    287   }
    288279  if (s->read_samples < s->hop_size) {
    289280    // write the end of the buffer to the beginning of read_data
     
    292283      read_data->data[i] = SHORT_TO_FLOAT(s->output[i + s->read_index]);
    293284    }
    294     s->read_samples = 0;
    295     s->read_index = 0;
    296285    // get more data
    297286    uint_t avcodec_read = 0;
    298287    aubio_source_avcodec_readframe(s, &avcodec_read);
    299     s->read_samples += avcodec_read;
     288    s->read_samples = avcodec_read;
    300289    s->read_index = 0;
    301290    // write the beginning of the buffer to the end of read_data
     
    312301      }
    313302    }
    314     s->read_index += partial;
    315     s->read_samples -= partial;
     303    s->read_index += end - partial;
     304    s->read_samples -= end - partial;
    316305    *read = end;
    317306  } else {
Note: See TracChangeset for help on using the changeset viewer.