- Timestamp:
- Apr 10, 2017, 3:26:06 PM (8 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, sampler
- Children:
- b678858
- Parents:
- 5bd9a2b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/io/source_avcodec.c
r5bd9a2b r808c8525 289 289 // create or reset resampler to/from mono/multi-channel 290 290 if ( (multi != s->multi) || (s->avr == NULL) ) { 291 int err; 291 292 int64_t input_layout = av_get_default_channel_layout(s->input_channels); 292 293 uint_t output_channels = multi ? s->input_channels : 1; … … 312 313 // TODO: use planar? 313 314 //av_opt_set_int(avr, "out_sample_fmt", AV_SAMPLE_FMT_FLTP, 0); 314 int err;315 315 #ifdef HAVE_AVRESAMPLE 316 316 if ( ( err = avresample_open(avr) ) < 0) { … … 349 349 SwrContext *avr = s->avr; 350 350 #endif /* HAVE_AVRESAMPLE || HAVE_SWRESAMPLE */ 351 int got_frame = 0; 352 int ret = 0; 353 #ifdef HAVE_AVRESAMPLE 354 int in_linesize = 0; 355 int in_samples = avFrame->nb_samples; 356 int out_linesize = 0; 357 int max_out_samples = AUBIO_AVCODEC_MAX_BUFFER_SIZE; 358 int out_samples = 0; 359 #elif defined(HAVE_SWRESAMPLE) 360 int in_samples = avFrame->nb_samples; 361 int max_out_samples = AUBIO_AVCODEC_MAX_BUFFER_SIZE / avCodecCtx->channels; 362 int out_samples = 0; 363 #endif /* HAVE_AVRESAMPLE || HAVE_SWRESAMPLE */ 351 364 smpl_t *output = s->output; 352 365 av_init_packet (&avPacket); … … 369 382 } while (avPacket.stream_index != s->selected_stream); 370 383 371 int got_frame = 0;372 384 #if FF_API_LAVF_AVCTX 373 intret = avcodec_send_packet(avCodecCtx, &avPacket);385 ret = avcodec_send_packet(avCodecCtx, &avPacket); 374 386 if (ret < 0 && ret != AVERROR_EOF) { 375 387 AUBIO_ERR("source_avcodec: error when sending packet for %s\n", s->path); … … 405 417 406 418 #ifdef HAVE_AVRESAMPLE 407 in t in_linesize = 0;419 in_linesize = 0; 408 420 av_samples_get_buffer_size(&in_linesize, avCodecCtx->channels, 409 421 avFrame->nb_samples, avCodecCtx->sample_fmt, 1); 410 in t in_samples = avFrame->nb_samples;411 intout_linesize = 0;412 intmax_out_samples = AUBIO_AVCODEC_MAX_BUFFER_SIZE;413 intout_samples = avresample_convert ( avr,422 in_samples = avFrame->nb_samples; 423 out_linesize = 0; 424 max_out_samples = AUBIO_AVCODEC_MAX_BUFFER_SIZE; 425 out_samples = avresample_convert ( avr, 414 426 (uint8_t **)&output, out_linesize, max_out_samples, 415 427 (uint8_t **)avFrame->data, in_linesize, in_samples); 416 428 #elif defined(HAVE_SWRESAMPLE) 417 in t in_samples = avFrame->nb_samples;418 intmax_out_samples = AUBIO_AVCODEC_MAX_BUFFER_SIZE / avCodecCtx->channels;419 intout_samples = swr_convert( avr,429 in_samples = avFrame->nb_samples; 430 max_out_samples = AUBIO_AVCODEC_MAX_BUFFER_SIZE / avCodecCtx->channels; 431 out_samples = swr_convert( avr, 420 432 (uint8_t **)&output, max_out_samples, 421 433 (const uint8_t **)avFrame->data, in_samples);
Note: See TracChangeset
for help on using the changeset viewer.