- Timestamp:
- Dec 6, 2013, 12:43:55 AM (11 years ago)
- 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:
- eadd8d5
- Parents:
- f3b93c6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/io/source_avcodec.c
rf3b93c6 r7760b40 58 58 uint_t read_samples; 59 59 uint_t read_index; 60 sint_t selected_stream; 60 61 }; 61 62 … … 124 125 goto beach; 125 126 } 126 //AUBIO_DBG("Taking stream %d in file %s\n", selected_stream, s->path); 127 AUBIO_DBG("Taking stream %d in file %s\n", selected_stream, s->path); 128 s->selected_stream = selected_stream; 127 129 128 130 AVCodecContext *avCodecCtx = s->avCodecCtx; … … 216 218 int16_t *output = s->output; 217 219 218 int err = av_read_frame (avFormatCtx, &avPacket); 219 if (err != 0) { 220 //AUBIO_ERR("Could not read frame for (%s)\n", s->path); 221 *read_samples = 0; 222 return; 223 } 220 do 221 { 222 int err = av_read_frame (avFormatCtx, &avPacket); 223 if (err != 0) { 224 uint8_t errorstr_len = 128; 225 char errorstr[errorstr_len]; 226 if (av_strerror (err, errorstr, errorstr_len) == 0) { 227 AUBIO_ERR("Could not read frame in %s (%s)\n", s->path, errorstr); 228 } else { 229 AUBIO_ERR("Could not read frame in %s (unknown error)\n", s->path); 230 } 231 *read_samples = 0; 232 return; 233 } 234 } while (avPacket.stream_index != s->selected_stream); 224 235 225 236 int got_frame = 0; … … 244 255 int out_plane_size = 0; //sizeof(float); //in_samples * sizeof(float); 245 256 int max_out_samples = AUBIO_AVCODEC_MIN_BUFFER_SIZE; 246 if (avresample_convert ( avr,257 uint_t out_samples = avresample_convert ( avr, 247 258 (uint8_t **)&output, out_plane_size, max_out_samples, 248 (uint8_t **)avFrame->data, in_plane_size, in_samples) < 0) { 259 (uint8_t **)avFrame->data, in_plane_size, in_samples); 260 if (out_samples < 0) { 249 261 AUBIO_ERR("Could not convert frame (%s)\n", s->path); 262 *read_samples = 0; 250 263 } 251 264 //AUBIO_ERR("Got in_plane_size %d frame for (%s)\n", in_plane_size, s->path); … … 254 267 // max_out_samples, AUBIO_AVCODEC_MIN_BUFFER_SIZE); 255 268 256 uint_t out_samples = avresample_available(avr) + (avresample_get_delay(avr)257 + in_samples) * s->samplerate / s->input_samplerate;258 269 //AUBIO_WRN("Converted %d to %d samples\n", in_samples, out_samples); 259 270 //for (i = 0; i < out_samples; i ++) {
Note: See TracChangeset
for help on using the changeset viewer.