- Timestamp:
- Mar 17, 2017, 10:59:51 AM (8 years ago)
- Branches:
- sampler
- Children:
- f8bdcb2
- Parents:
- bff692e (diff), c7d444a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/io/source_avcodec.c
rbff692e rbad88364 25 25 #include <libavcodec/avcodec.h> 26 26 #include <libavformat/avformat.h> 27 #if defined(HAVE_SWRESAMPLE) 28 #include <libswresample/swresample.h> 29 #elif defined(HAVE_AVRESAMPLE) 27 30 #include <libavresample/avresample.h> 31 #endif 28 32 #include <libavutil/opt.h> 29 33 #include <stdlib.h> … … 77 81 AVFrame *avFrame; 78 82 AVPacket avPacket; 83 #ifdef HAVE_AVRESAMPLE 79 84 AVAudioResampleContext *avr; 85 #elif defined(HAVE_SWRESAMPLE) 86 SwrContext *avr; 87 #endif 80 88 smpl_t *output; 81 89 uint_t read_samples; … … 309 317 uint_t output_channels = multi ? s->input_channels : 1; 310 318 int64_t output_layout = av_get_default_channel_layout(output_channels); 319 #ifdef HAVE_AVRESAMPLE 311 320 AVAudioResampleContext *avr = avresample_alloc_context(); 312 321 AVAudioResampleContext *oldavr = s->avr; 322 #elif defined(HAVE_SWRESAMPLE) 323 SwrContext *avr = swr_alloc(); 324 SwrContext *oldavr = s->avr; 325 #endif /* HAVE_AVRESAMPLE || HAVE_SWRESAMPLE */ 313 326 314 327 av_opt_set_int(avr, "in_channel_layout", input_layout, 0); … … 325 338 //av_opt_set_int(avr, "out_sample_fmt", AV_SAMPLE_FMT_FLTP, 0); 326 339 int err; 340 #ifdef HAVE_AVRESAMPLE 327 341 if ( ( err = avresample_open(avr) ) < 0) { 342 #elif defined(HAVE_SWRESAMPLE) 343 if ( ( err = swr_init(avr) ) < 0) { 344 #endif /* HAVE_AVRESAMPLE || HAVE_SWRESAMPLE */ 328 345 char errorstr[256]; 329 346 av_strerror (err, errorstr, sizeof(errorstr)); … … 335 352 s->avr = avr; 336 353 if (oldavr != NULL) { 354 #ifdef HAVE_AVRESAMPLE 337 355 avresample_close( oldavr ); 356 #elif defined(HAVE_SWRESAMPLE) 357 swr_close ( oldavr ); 358 #endif /* HAVE_AVRESAMPLE || HAVE_SWRESAMPLE */ 338 359 av_free ( oldavr ); 339 360 oldavr = NULL; … … 349 370 AVPacket avPacket = s->avPacket; 350 371 av_init_packet (&avPacket); 372 #ifdef HAVE_AVRESAMPLE 351 373 AVAudioResampleContext *avr = s->avr; 374 #elif defined(HAVE_SWRESAMPLE) 375 SwrContext *avr = s->avr; 376 #endif /* HAVE_AVRESAMPLE || HAVE_SWRESAMPLE */ 352 377 smpl_t *output = s->output; 353 378 *read_samples = 0; … … 402 427 } 403 428 429 #ifdef HAVE_AVRESAMPLE 404 430 int in_linesize = 0; 405 431 av_samples_get_buffer_size(&in_linesize, avCodecCtx->channels, … … 411 437 (uint8_t **)&output, out_linesize, max_out_samples, 412 438 (uint8_t **)avFrame->data, in_linesize, in_samples); 439 #elif defined(HAVE_SWRESAMPLE) 440 int in_samples = avFrame->nb_samples; 441 int max_out_samples = AUBIO_AVCODEC_MAX_BUFFER_SIZE / avCodecCtx->channels; 442 int out_samples = swr_convert( avr, 443 (uint8_t **)&output, max_out_samples, 444 (const uint8_t **)avFrame->data, in_samples); 445 #endif /* HAVE_AVRESAMPLE || HAVE_SWRESAMPLE */ 413 446 if (out_samples <= 0) { 414 447 AUBIO_WRN("source_avcodec: no sample found while converting frame (%s)\n", s->path); … … 422 455 s->avCodecCtx = avCodecCtx; 423 456 s->avFrame = avFrame; 457 #if defined(HAVE_AVRESAMPLE) || defined(HAVE_SWRESAMPLE) 424 458 s->avr = avr; 459 #endif /* HAVE_AVRESAMPLE || HAVE_SWRESAMPLE */ 425 460 s->output = output; 426 461 … … 531 566 s->read_index = 0; 532 567 s->read_samples = 0; 568 #ifdef HAVE_AVRESAMPLE 533 569 // reset the AVAudioResampleContext 534 570 avresample_close(s->avr); 535 571 avresample_open(s->avr); 572 #elif defined(HAVE_SWRESAMPLE) 573 swr_close(s->avr); 574 swr_init(s->avr); 575 #endif 536 576 return ret; 537 577 } … … 547 587 uint_t aubio_source_avcodec_close(aubio_source_avcodec_t * s) { 548 588 if (s->avr != NULL) { 589 #ifdef HAVE_AVRESAMPLE 549 590 avresample_close( s->avr ); 591 #elif defined(HAVE_SWRESAMPLE) 592 swr_close ( s->avr ); 593 #endif 550 594 av_free ( s->avr ); 551 595 } -
src/utils/windll.c
rbff692e rbad88364 42 42 #include "aubio.h" 43 43 44 BOOL APIENTRY DllMain( HMODULE hModule ,44 BOOL APIENTRY DllMain( HMODULE hModule UNUSED, 45 45 DWORD ul_reason_for_call, 46 LPVOID lpReserved )46 LPVOID lpReserved UNUSED) 47 47 { 48 48 switch (ul_reason_for_call) -
src/wscript_build
rbff692e rbad88364 9 9 uselib += ['AVCODEC'] 10 10 uselib += ['AVFORMAT'] 11 uselib += ['SWRESAMPLE'] 11 12 uselib += ['AVRESAMPLE'] 12 13 uselib += ['AVUTIL']
Note: See TracChangeset
for help on using the changeset viewer.