diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 94df4b78551fa9040f48a6dbc9d8aba8cc4b950a..8e813d0dbbe2d5637ad94b340d5b83a668e96ff6 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -2671,33 +2671,22 @@ av_cold int ff_codec_close_recursive(AVCodecContext *avctx)
 {
     int ret = 0;
 
-    ff_unlock_avcodec();
-
     ret = avcodec_close(avctx);
 
-    ff_lock_avcodec(NULL);
     return ret;
 }
 
 av_cold int avcodec_close(AVCodecContext *avctx)
 {
-    int ret;
-
     if (!avctx)
         return 0;
 
-    ret = ff_lock_avcodec(avctx);
-    if (ret < 0)
-        return ret;
-
     if (avcodec_is_open(avctx)) {
         FramePool *pool = avctx->internal->pool;
         int i;
         if (CONFIG_FRAME_THREAD_ENCODER &&
             avctx->internal->frame_thread_encoder && avctx->thread_count > 1) {
-            ff_unlock_avcodec();
             ff_frame_thread_encoder_free(avctx);
-            ff_lock_avcodec(avctx);
         }
         if (HAVE_THREADS && avctx->internal->thread_ctx)
             ff_thread_free(avctx);
@@ -2727,7 +2716,6 @@ av_cold int avcodec_close(AVCodecContext *avctx)
     avctx->codec = NULL;
     avctx->active_thread_type = 0;
 
-    ff_unlock_avcodec();
     return 0;
 }