- Timestamp:
- Dec 26, 2021, 7:52:16 AM (3 years ago)
- Branches:
- feature/cnn, feature/crepe, fix/ffmpeg5, master
- Children:
- d8e78e6
- Parents:
- ea7f48e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/io/source_avcodec.c
rea7f48e rcdfe9ce 83 83 AVCodecContext *avCodecCtx; 84 84 AVFrame *avFrame; 85 #if FF_API_INIT_PACKET 86 AVPacket *avPacket; 87 #else 85 88 AVPacket avPacket; 89 #endif 86 90 #ifdef HAVE_AVRESAMPLE 87 91 AVAudioResampleContext *avr; … … 123 127 AVCodecContext *avCodecCtx = NULL; 124 128 AVFrame *avFrame = NULL; 129 #if FF_API_INIT_PACKET 130 AVPacket *avPacket = NULL; 131 #endif 125 132 sint_t selected_stream = -1; 126 133 #if FF_API_LAVF_AVCTX 127 134 AVCodecParameters *codecpar; 128 135 #endif 136 129 137 AVCodec *codec; 130 138 uint_t i; … … 278 286 if (!avFrame) { 279 287 AUBIO_ERR("source_avcodec: Could not allocate frame for (%s)\n", s->path); 280 } 288 goto beach; 289 } 290 291 #if FF_API_INIT_PACKET 292 avPacket = av_packet_alloc(); 293 if (!avPacket) { 294 AUBIO_ERR("source_avcodec: Could not allocate packet for (%s)\n", s->path); 295 goto beach; 296 } 297 #endif 281 298 282 299 /* allocate output for avr */ … … 290 307 s->avCodecCtx = avCodecCtx; 291 308 s->avFrame = avFrame; 309 #if FF_API_INIT_PACKET 310 s->avPacket = avPacket; 311 #endif 292 312 293 313 aubio_source_avcodec_reset_resampler(s); … … 355 375 AVCodecContext *avCodecCtx = s->avCodecCtx; 356 376 AVFrame *avFrame = s->avFrame; 357 AVPacket avPacket = s->avPacket; 377 #if FF_API_INIT_PACKET 378 AVPacket *avPacket = s->avPacket; 379 #else 380 AVPacket *avPacket = &s->avPacket; 381 #endif 358 382 #ifdef HAVE_AVRESAMPLE 359 383 AVAudioResampleContext *avr = s->avr; … … 379 403 int ret = 0; 380 404 #endif 381 av_init_packet (&avPacket); 405 #ifndef FF_API_INIT_PACKET 406 av_init_packet (avPacket); 407 #endif 382 408 *read_samples = 0; 383 409 384 410 do 385 411 { 386 int err = av_read_frame (avFormatCtx, &avPacket);412 int err = av_read_frame (avFormatCtx, avPacket); 387 413 if (err == AVERROR_EOF) { 388 414 s->eof = 1; … … 397 423 goto beach; 398 424 } 399 } while (avPacket .stream_index != s->selected_stream);425 } while (avPacket->stream_index != s->selected_stream); 400 426 401 427 #if FF_API_LAVF_AVCTX 402 ret = avcodec_send_packet(avCodecCtx, &avPacket);428 ret = avcodec_send_packet(avCodecCtx, avPacket); 403 429 if (ret < 0 && ret != AVERROR_EOF) { 404 430 AUBIO_ERR("source_avcodec: error when sending packet for %s\n", s->path); … … 423 449 } 424 450 #else 425 len = avcodec_decode_audio4(avCodecCtx, avFrame, &got_frame, &avPacket);451 len = avcodec_decode_audio4(avCodecCtx, avFrame, &got_frame, avPacket); 426 452 427 453 if (len < 0) { … … 473 499 474 500 beach: 475 av_packet_unref( &avPacket);501 av_packet_unref(avPacket); 476 502 } 477 503 … … 639 665 s->avFormatCtx = NULL; 640 666 } 667 #if FF_API_INIT_PACKET 668 if (s->avPacket) { 669 av_packet_unref(s->avPacket); 670 } 671 #else 641 672 av_packet_unref(&s->avPacket); 673 #endif 642 674 return AUBIO_OK; 643 675 } … … 654 686 } 655 687 s->avFrame = NULL; 688 #if FF_API_INIT_PACKET 689 if (s->avPacket != NULL) { 690 av_packet_free( &(s->avPacket) ); 691 } 692 s->avPacket = NULL; 693 #endif 656 694 if (s->path) { 657 695 AUBIO_FREE(s->path);
Note: See TracChangeset
for help on using the changeset viewer.