Changeset 0b947f9
- Timestamp:
- Dec 27, 2023, 6:39:35 PM (9 months ago)
- Branches:
- master
- Children:
- 53bc55c
- Parents:
- 128acfd
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/io/source_avcodec.c
r128acfd r0b947f9 264 264 /* get input specs */ 265 265 s->input_samplerate = avCodecCtx->sample_rate; 266 #ifdef AVUTIL_CHANNEL_LAYOUT_H 267 s->input_channels = avCodecCtx->ch_layout.nb_channels; 268 #else 266 269 s->input_channels = avCodecCtx->channels; 270 #endif 267 271 //AUBIO_DBG("input_samplerate: %d\n", s->input_samplerate); 268 272 //AUBIO_DBG("input_channels: %d\n", s->input_channels); … … 330 334 int err; 331 335 SwrContext *avr = swr_alloc(); 336 #ifdef AVUTIL_CHANNEL_LAYOUT_H 337 AVChannelLayout input_layout; 338 AVChannelLayout output_layout; 339 av_channel_layout_default(&input_layout, s->input_channels); 340 av_channel_layout_default(&output_layout, s->input_channels); 341 342 av_opt_set_chlayout(avr, "in_channel_layout", &input_layout, 0); 343 av_opt_set_chlayout(avr, "out_channel_layout", &output_layout, 0); 344 #else 332 345 int64_t input_layout = av_get_default_channel_layout(s->input_channels); 333 346 int64_t output_layout = av_get_default_channel_layout(s->input_channels); … … 335 348 av_opt_set_int(avr, "in_channel_layout", input_layout, 0); 336 349 av_opt_set_int(avr, "out_channel_layout", output_layout, 0); 350 #endif 337 351 av_opt_set_int(avr, "in_sample_rate", s->input_samplerate, 0); 338 352 av_opt_set_int(avr, "out_sample_rate", s->samplerate, 0); … … 371 385 int got_frame = 0; 372 386 int in_samples = avFrame->nb_samples; 387 #ifdef AVUTIL_CHANNEL_LAYOUT_H 388 int max_out_samples = AUBIO_AVCODEC_MAX_BUFFER_SIZE / avCodecCtx->ch_layout.nb_channels; 389 #else 373 390 int max_out_samples = AUBIO_AVCODEC_MAX_BUFFER_SIZE / avCodecCtx->channels; 391 #endif 374 392 int out_samples = 0; 375 393 smpl_t *output = s->output; … … 439 457 440 458 #if LIBAVUTIL_VERSION_MAJOR > 52 441 if (avFrame->channels != (sint_t)s->input_channels) { 459 #ifdef AVUTIL_CHANNEL_LAYOUT_H 460 int frame_channels = avFrame->ch_layout.nb_channels; 461 #else 462 int frame_channels = avFrame->channels; 463 #endif 464 if (frame_channels != (sint_t)s->input_channels) { 442 465 AUBIO_WRN ("source_avcodec: trying to read from %d channel(s)," 443 466 "but configured for %d; is '%s' corrupt?\n", 444 avFrame->channels, s->input_channels, s->path);467 frame_channels, s->input_channels, s->path); 445 468 goto beach; 446 469 } … … 450 473 451 474 in_samples = avFrame->nb_samples; 452 max_out_samples = AUBIO_AVCODEC_MAX_BUFFER_SIZE / avCodecCtx->channels; 475 max_out_samples = AUBIO_AVCODEC_MAX_BUFFER_SIZE; 476 if (frame_channels > 0) max_out_samples /= frame_channels; 453 477 out_samples = swr_convert( avr, 454 478 (uint8_t **)&output, max_out_samples,
Note: See TracChangeset
for help on using the changeset viewer.