| 690 | } |
| 691 | |
| 692 | av_cold int avcodec_close(AVCodecContext *avctx) |
| 693 | { |
| 694 | /* If there is a user-supplied mutex locking routine, call it. */ |
| 695 | if (ff_lockmgr_cb) { |
| 696 | if ((*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_OBTAIN)) |
| 697 | return -1; |
| 698 | } |
| 699 | |
| 700 | entangled_thread_counter++; |
| 701 | if(entangled_thread_counter != 1){ |
| 702 | av_log(avctx, AV_LOG_ERROR, "insufficient thread locking around avcodec_open/close()\n"); |
| 703 | entangled_thread_counter--; |
| 704 | return -1; |
| 705 | } |
| 706 | |
| 707 | if (HAVE_THREADS && avctx->thread_opaque) |
| 708 | avcodec_thread_free(avctx); |
| 709 | if (avctx->codec && avctx->codec->close) |
| 710 | avctx->codec->close(avctx); |
| 711 | avcodec_default_free_buffers(avctx); |
| 712 | av_freep(&avctx->priv_data); |
| 713 | if(avctx->codec && avctx->codec->encode) |
| 714 | av_freep(&avctx->extradata); |
| 715 | avctx->codec = NULL; |
| 716 | entangled_thread_counter--; |
| 717 | |
| 718 | /* Release any user-supplied mutex. */ |
| 719 | if (ff_lockmgr_cb) { |
| 720 | (*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_RELEASE); |
| 721 | } |
| 722 | return 0; |
| 723 | } |
| 724 | |
| 725 | AVCodec *avcodec_find_encoder(enum CodecID id) |
| 726 | { |
no test coverage detected