- Timestamp:
- Mar 23, 2017, 3:46:07 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:
- ecf7572
- Parents:
- 59be50d (diff), 91fa88d (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
r59be50d r24c207f 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> … … 69 73 AVFrame *avFrame; 70 74 AVPacket avPacket; 75 #ifdef HAVE_AVRESAMPLE 71 76 AVAudioResampleContext *avr; 77 #elif defined(HAVE_SWRESAMPLE) 78 SwrContext *avr; 79 #endif 72 80 smpl_t *output; 73 81 uint_t read_samples; … … 277 285 uint_t output_channels = multi ? s->input_channels : 1; 278 286 int64_t output_layout = av_get_default_channel_layout(output_channels); 287 #ifdef HAVE_AVRESAMPLE 279 288 AVAudioResampleContext *avr = avresample_alloc_context(); 280 289 AVAudioResampleContext *oldavr = s->avr; 290 #elif defined(HAVE_SWRESAMPLE) 291 SwrContext *avr = swr_alloc(); 292 SwrContext *oldavr = s->avr; 293 #endif /* HAVE_AVRESAMPLE || HAVE_SWRESAMPLE */ 281 294 282 295 av_opt_set_int(avr, "in_channel_layout", input_layout, 0); … … 293 306 //av_opt_set_int(avr, "out_sample_fmt", AV_SAMPLE_FMT_FLTP, 0); 294 307 int err; 308 #ifdef HAVE_AVRESAMPLE 295 309 if ( ( err = avresample_open(avr) ) < 0) { 310 #elif defined(HAVE_SWRESAMPLE) 311 if ( ( err = swr_init(avr) ) < 0) { 312 #endif /* HAVE_AVRESAMPLE || HAVE_SWRESAMPLE */ 296 313 char errorstr[256]; 297 314 av_strerror (err, errorstr, sizeof(errorstr)); … … 303 320 s->avr = avr; 304 321 if (oldavr != NULL) { 322 #ifdef HAVE_AVRESAMPLE 305 323 avresample_close( oldavr ); 324 #elif defined(HAVE_SWRESAMPLE) 325 swr_close ( oldavr ); 326 #endif /* HAVE_AVRESAMPLE || HAVE_SWRESAMPLE */ 306 327 av_free ( oldavr ); 307 328 oldavr = NULL; … … 317 338 AVPacket avPacket = s->avPacket; 318 339 av_init_packet (&avPacket); 340 #ifdef HAVE_AVRESAMPLE 319 341 AVAudioResampleContext *avr = s->avr; 342 #elif defined(HAVE_SWRESAMPLE) 343 SwrContext *avr = s->avr; 344 #endif /* HAVE_AVRESAMPLE || HAVE_SWRESAMPLE */ 320 345 smpl_t *output = s->output; 321 346 *read_samples = 0; … … 332 357 av_strerror (err, errorstr, sizeof(errorstr)); 333 358 AUBIO_ERR("source_avcodec: could not read frame in %s (%s)\n", s->path, errorstr); 359 s->eof = 1; 334 360 goto beach; 335 361 } … … 370 396 } 371 397 398 #ifdef HAVE_AVRESAMPLE 372 399 int in_linesize = 0; 373 400 av_samples_get_buffer_size(&in_linesize, avCodecCtx->channels, … … 379 406 (uint8_t **)&output, out_linesize, max_out_samples, 380 407 (uint8_t **)avFrame->data, in_linesize, in_samples); 408 #elif defined(HAVE_SWRESAMPLE) 409 int in_samples = avFrame->nb_samples; 410 int max_out_samples = AUBIO_AVCODEC_MAX_BUFFER_SIZE / avCodecCtx->channels; 411 int out_samples = swr_convert( avr, 412 (uint8_t **)&output, max_out_samples, 413 (const uint8_t **)avFrame->data, in_samples); 414 #endif /* HAVE_AVRESAMPLE || HAVE_SWRESAMPLE */ 381 415 if (out_samples <= 0) { 382 416 AUBIO_WRN("source_avcodec: no sample found while converting frame (%s)\n", s->path); … … 390 424 s->avCodecCtx = avCodecCtx; 391 425 s->avFrame = avFrame; 426 #if defined(HAVE_AVRESAMPLE) || defined(HAVE_SWRESAMPLE) 392 427 s->avr = avr; 428 #endif /* HAVE_AVRESAMPLE || HAVE_SWRESAMPLE */ 393 429 s->output = output; 394 430 … … 499 535 s->read_index = 0; 500 536 s->read_samples = 0; 537 #ifdef HAVE_AVRESAMPLE 501 538 // reset the AVAudioResampleContext 502 539 avresample_close(s->avr); 503 540 avresample_open(s->avr); 541 #elif defined(HAVE_SWRESAMPLE) 542 swr_close(s->avr); 543 swr_init(s->avr); 544 #endif 504 545 return ret; 505 546 } … … 515 556 uint_t aubio_source_avcodec_close(aubio_source_avcodec_t * s) { 516 557 if (s->avr != NULL) { 558 #ifdef HAVE_AVRESAMPLE 517 559 avresample_close( s->avr ); 560 #elif defined(HAVE_SWRESAMPLE) 561 swr_close ( s->avr ); 562 #endif 518 563 av_free ( s->avr ); 519 564 } 520 565 s->avr = NULL; 521 566 if (s->avCodecCtx != NULL) { 567 #ifndef HAVE_AUBIO_LIBAVCODEC_DEPRECATED 568 avcodec_free_context( &s->avCodecCtx ); 569 #else 522 570 avcodec_close ( s->avCodecCtx ); 571 #endif 523 572 } 524 573 s->avCodecCtx = NULL; -
src/utils/windll.c
r59be50d r24c207f 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
r59be50d r24c207f 8 8 uselib += ['AVCODEC'] 9 9 uselib += ['AVFORMAT'] 10 uselib += ['SWRESAMPLE'] 10 11 uselib += ['AVRESAMPLE'] 11 12 uselib += ['AVUTIL']
Note: See TracChangeset
for help on using the changeset viewer.