diff --git a/libavcodec/aic.c b/libavcodec/aic.c
index f8b0f60354..b4b5089228 100644
--- a/libavcodec/aic.c
+++ b/libavcodec/aic.c
@@ -27,10 +27,10 @@
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
 #include "golomb.h"
 #include "idctdsp.h"
-#include "thread.h"
 #include "unary.h"
 
 #define AIC_HDR_SIZE    24
@@ -408,7 +408,7 @@ static int aic_decode_frame(AVCodecContext *avctx, AVFrame *frame,
         return ret;
     }
 
-    if ((ret = ff_thread_get_buffer(avctx, ctx->frame, 0)) < 0)
+    if ((ret = ff_get_buffer(avctx, ctx->frame, 0)) < 0)
         return ret;
 
     bytestream2_init(&gb, buf + AIC_HDR_SIZE,
diff --git a/libavcodec/alac.c b/libavcodec/alac.c
index 538d1e5984..601d95a7f9 100644
--- a/libavcodec/alac.c
+++ b/libavcodec/alac.c
@@ -53,7 +53,7 @@
 #include "get_bits.h"
 #include "bytestream.h"
 #include "codec_internal.h"
-#include "thread.h"
+#include "decode.h"
 #include "unary.h"
 #include "mathops.h"
 #include "alac_data.h"
@@ -274,7 +274,7 @@ static int decode_element(AVCodecContext *avctx, AVFrame *frame, int ch_index,
     if (!alac->nb_samples) {
         /* get output buffer */
         frame->nb_samples = output_samples;
-        if ((ret = ff_thread_get_buffer(avctx, frame, 0)) < 0)
+        if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
             return ret;
     } else if (output_samples != alac->nb_samples) {
         av_log(avctx, AV_LOG_ERROR, "sample count mismatch: %"PRIu32" != %d\n",
diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index bbb5634773..98ef1e1935 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -899,7 +899,7 @@ static int av1_frame_alloc(AVCodecContext *avctx, AV1Frame *f)
         return ret;
     }
 
-    if ((ret = ff_thread_get_buffer(avctx, f->f, AV_GET_BUFFER_FLAG_REF)) < 0)
+    if ((ret = ff_get_buffer(avctx, f->f, AV_GET_BUFFER_FLAG_REF)) < 0)
         goto fail;
 
     frame = f->f;
diff --git a/libavcodec/avcodec_internal.h b/libavcodec/avcodec_internal.h
index e7a229dee9..48fc813a73 100644
--- a/libavcodec/avcodec_internal.h
+++ b/libavcodec/avcodec_internal.h
@@ -58,6 +58,19 @@ struct AVCodecInternal *ff_encode_internal_alloc(void);
 
 void ff_codec_close(struct AVCodecContext *avctx);
 
+/**
+ * Wrapper around AVCodecContext.get_buffer2(), called from pthread_frame when
+ * frame threading is active, from the ff_get_buffer() otherwise.
+ */
+int ff_decode_get_buffer(struct AVCodecContext *avctx, struct AVFrame *frame,
+                         int flags);
+/**
+ * Wrapper around ff_decode_get_buffer() that will be called when frame
+ * threading is active.
+ */
+int ff_thread_get_buffer(struct AVCodecContext *avctx, struct AVFrame *frame,
+                         int flags);
+
 int ff_thread_init(struct AVCodecContext *s);
 void ff_thread_free(struct AVCodecContext *s);
 
diff --git a/libavcodec/bitpacked_dec.c b/libavcodec/bitpacked_dec.c
index 54c008bd86..4bd59b7d12 100644
--- a/libavcodec/bitpacked_dec.c
+++ b/libavcodec/bitpacked_dec.c
@@ -29,7 +29,7 @@
 #include "avcodec.h"
 #include "codec_internal.h"
 #include "libavutil/imgutils.h"
-#include "thread.h"
+#include "decode.h"
 
 struct BitpackedContext {
     int (*decode)(AVCodecContext *avctx, AVFrame *frame,
@@ -68,7 +68,7 @@ static int bitpacked_decode_yuv422p10(AVCodecContext *avctx, AVFrame *frame,
     uint16_t *y, *u, *v;
     int ret, i, j;
 
-    ret = ff_thread_get_buffer(avctx, frame, 0);
+    ret = ff_get_buffer(avctx, frame, 0);
     if (ret < 0)
         return ret;
 
diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c
index 42d7dcc3f6..14301b829f 100644
--- a/libavcodec/cfhd.c
+++ b/libavcodec/cfhd.c
@@ -682,7 +682,7 @@ static int cfhd_decode(AVCodecContext *avctx, AVFrame *pic,
             }
             pic->width = pic->height = 0;
 
-            if ((ret = ff_thread_get_buffer(avctx, pic, 0)) < 0)
+            if ((ret = ff_get_buffer(avctx, pic, 0)) < 0)
                 return ret;
 
             s->coded_width = 0;
@@ -692,7 +692,7 @@ static int cfhd_decode(AVCodecContext *avctx, AVFrame *pic,
         } else if (tag == FrameIndex && data == 1 && s->sample_type == 1 && s->frame_type == 2) {
             pic->width = pic->height = 0;
 
-            if ((ret = ff_thread_get_buffer(avctx, pic, 0)) < 0)
+            if ((ret = ff_get_buffer(avctx, pic, 0)) < 0)
                 return ret;
             s->coded_width = 0;
             s->coded_height = 0;
diff --git a/libavcodec/cllc.c b/libavcodec/cllc.c
index 0c6ae13d08..2c5dbcf53d 100644
--- a/libavcodec/cllc.c
+++ b/libavcodec/cllc.c
@@ -28,7 +28,7 @@
 #include "get_bits.h"
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "thread.h"
+#include "decode.h"
 
 #define VLC_BITS 7
 #define VLC_DEPTH 2
@@ -422,7 +422,7 @@ static int cllc_decode_frame(AVCodecContext *avctx, AVFrame *pic,
         avctx->pix_fmt             = AV_PIX_FMT_YUV422P;
         avctx->bits_per_raw_sample = 8;
 
-        if ((ret = ff_thread_get_buffer(avctx, pic, 0)) < 0)
+        if ((ret = ff_get_buffer(avctx, pic, 0)) < 0)
             return ret;
 
         ret = decode_yuv_frame(ctx, &gb, pic);
@@ -435,7 +435,7 @@ static int cllc_decode_frame(AVCodecContext *avctx, AVFrame *pic,
         avctx->pix_fmt             = AV_PIX_FMT_RGB24;
         avctx->bits_per_raw_sample = 8;
 
-        if ((ret = ff_thread_get_buffer(avctx, pic, 0)) < 0)
+        if ((ret = ff_get_buffer(avctx, pic, 0)) < 0)
             return ret;
 
         ret = decode_rgb24_frame(ctx, &gb, pic);
@@ -447,7 +447,7 @@ static int cllc_decode_frame(AVCodecContext *avctx, AVFrame *pic,
         avctx->pix_fmt             = AV_PIX_FMT_ARGB;
         avctx->bits_per_raw_sample = 8;
 
-        if ((ret = ff_thread_get_buffer(avctx, pic, 0)) < 0)
+        if ((ret = ff_get_buffer(avctx, pic, 0)) < 0)
             return ret;
 
         ret = decode_argb_frame(ctx, &gb, pic);
diff --git a/libavcodec/cri.c b/libavcodec/cri.c
index 990e52ac99..c54fb67cec 100644
--- a/libavcodec/cri.c
+++ b/libavcodec/cri.c
@@ -319,7 +319,7 @@ skip:
     if (avctx->skip_frame >= AVDISCARD_ALL)
         return avpkt->size;
 
-    if ((ret = ff_thread_get_buffer(avctx, p, 0)) < 0)
+    if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
         return ret;
 
     avctx->bits_per_raw_sample = bps;
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 4168cf6f2d..cdbbfd8ee2 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1565,7 +1565,7 @@ int ff_attach_decode_data(AVFrame *frame)
     return 0;
 }
 
-int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
+int ff_decode_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
 {
     const FFHWAccel *hwaccel = ffhwaccel(avctx->hwaccel);
     int override_dimensions = 1;
@@ -1637,6 +1637,17 @@ fail:
     return ret;
 }
 
+int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
+{
+#if HAVE_THREADS
+    if (avctx->active_thread_type & FF_THREAD_FRAME)
+        return ff_thread_get_buffer(avctx, frame, flags);
+#endif
+    av_assert0(!(avctx->active_thread_type & FF_THREAD_FRAME));
+
+    return ff_decode_get_buffer(avctx, frame, flags);
+}
+
 static int reget_buffer_internal(AVCodecContext *avctx, AVFrame *frame, int flags)
 {
     AVFrame *tmp;
diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c
index 703d0e341c..8e2bed5d83 100644
--- a/libavcodec/dnxhddec.c
+++ b/libavcodec/dnxhddec.c
@@ -652,7 +652,7 @@ decode_coding_unit:
         return ret;
 
     if (first_field) {
-        if ((ret = ff_thread_get_buffer(avctx, picture, 0)) < 0)
+        if ((ret = ff_get_buffer(avctx, picture, 0)) < 0)
             return ret;
         picture->pict_type = AV_PICTURE_TYPE_I;
         picture->flags |= AV_FRAME_FLAG_KEY;
diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c
index f66a5f1a05..d6ecdda32b 100644
--- a/libavcodec/dvdec.c
+++ b/libavcodec/dvdec.c
@@ -668,7 +668,7 @@ static int dvvideo_decode_frame(AVCodecContext *avctx, AVFrame *frame,
         ff_set_sar(avctx, s->sys->sar[is16_9]);
     }
 
-    if ((ret = ff_thread_get_buffer(avctx, frame, 0)) < 0)
+    if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
         return ret;
 
     /* Determine the codec's field order from the packet */
diff --git a/libavcodec/dxtory.c b/libavcodec/dxtory.c
index f36420cdd9..2526b8e7b9 100644
--- a/libavcodec/dxtory.c
+++ b/libavcodec/dxtory.c
@@ -29,9 +29,9 @@
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
 #include "unary.h"
-#include "thread.h"
 
 static int64_t get_raw_size(enum AVPixelFormat fmt, int width, int height)
 {
@@ -103,7 +103,7 @@ static int dxtory_decode_v1_rgb(AVCodecContext *avctx, AVFrame *pic,
     }
 
     avctx->pix_fmt = id;
-    if ((ret = ff_thread_get_buffer(avctx, pic, 0)) < 0)
+    if ((ret = ff_get_buffer(avctx, pic, 0)) < 0)
         return ret;
 
     do_vflip(avctx, pic, vflipped);
@@ -136,7 +136,7 @@ static int dxtory_decode_v1_410(AVCodecContext *avctx, AVFrame *pic,
     }
 
     avctx->pix_fmt = AV_PIX_FMT_YUV410P;
-    if ((ret = ff_thread_get_buffer(avctx, pic, 0)) < 0)
+    if ((ret = ff_get_buffer(avctx, pic, 0)) < 0)
         return ret;
 
     do_vflip(avctx, pic, vflipped);
@@ -231,7 +231,7 @@ static int dxtory_decode_v1_420(AVCodecContext *avctx, AVFrame *pic,
     }
 
     avctx->pix_fmt = AV_PIX_FMT_YUV420P;
-    if ((ret = ff_thread_get_buffer(avctx, pic, 0)) < 0)
+    if ((ret = ff_get_buffer(avctx, pic, 0)) < 0)
         return ret;
 
     do_vflip(avctx, pic, vflipped);
@@ -301,7 +301,7 @@ static int dxtory_decode_v1_444(AVCodecContext *avctx, AVFrame *pic,
     }
 
     avctx->pix_fmt = AV_PIX_FMT_YUV444P;
-    if ((ret = ff_thread_get_buffer(avctx, pic, 0)) < 0)
+    if ((ret = ff_get_buffer(avctx, pic, 0)) < 0)
         return ret;
 
     do_vflip(avctx, pic, vflipped);
@@ -452,7 +452,7 @@ static int dxtory_decode_v2(AVCodecContext *avctx, AVFrame *pic,
         return AVERROR_INVALIDDATA;
 
     avctx->pix_fmt = fmt;
-    if ((ret = ff_thread_get_buffer(avctx, pic, 0)) < 0)
+    if ((ret = ff_get_buffer(avctx, pic, 0)) < 0)
         return ret;
 
     do_vflip(avctx, pic, vflipped);
diff --git a/libavcodec/dxv.c b/libavcodec/dxv.c
index b5553a0c86..b4043553e9 100644
--- a/libavcodec/dxv.c
+++ b/libavcodec/dxv.c
@@ -28,10 +28,10 @@
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "dxv.h"
 #include "lzf.h"
 #include "texturedsp.h"
-#include "thread.h"
 
 typedef struct DXVContext {
     TextureDSPContext texdsp;
@@ -1000,7 +1000,7 @@ static int dxv_decode(AVCodecContext *avctx, AVFrame *frame,
     if (ret < 0)
         return ret;
 
-    ret = ff_thread_get_buffer(avctx, frame, 0);
+    ret = ff_get_buffer(avctx, frame, 0);
     if (ret < 0)
         return ret;
 
diff --git a/libavcodec/exr.c b/libavcodec/exr.c
index 5711fbbdcd..900e090c9a 100644
--- a/libavcodec/exr.c
+++ b/libavcodec/exr.c
@@ -2151,7 +2151,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *picture,
         s->scan_lines_per_block;
     }
 
-    if ((ret = ff_thread_get_buffer(avctx, picture, 0)) < 0)
+    if ((ret = ff_get_buffer(avctx, picture, 0)) < 0)
         return ret;
 
     if (bytestream2_get_bytes_left(gb)/8 < nb_blocks)
diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c
index ed2de14d0a..bbdf6eab82 100644
--- a/libavcodec/flacdec.c
+++ b/libavcodec/flacdec.c
@@ -40,12 +40,12 @@
 #include "codec_internal.h"
 #include "get_bits.h"
 #include "bytestream.h"
+#include "decode.h"
 #include "golomb.h"
 #include "flac.h"
 #include "flacdata.h"
 #include "flacdsp.h"
 #include "flac_parse.h"
-#include "thread.h"
 #include "unary.h"
 
 
@@ -776,7 +776,7 @@ static int flac_decode_frame(AVCodecContext *avctx, AVFrame *frame,
 
     /* get output buffer */
     frame->nb_samples = s->blocksize;
-    if ((ret = ff_thread_get_buffer(avctx, frame, 0)) < 0)
+    if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
         return ret;
 
     if (s->stream_info.bps == 32 && s->ch_mode > 0) {
diff --git a/libavcodec/fraps.c b/libavcodec/fraps.c
index bed244e4e9..6be0eecba4 100644
--- a/libavcodec/fraps.c
+++ b/libavcodec/fraps.c
@@ -41,7 +41,7 @@
 #include "bytestream.h"
 #include "bswapdsp.h"
 #include "codec_internal.h"
-#include "thread.h"
+#include "decode.h"
 
 #define FPS_TAG MKTAG('F', 'P', 'S', 'x')
 #define VLC_BITS 11
@@ -222,7 +222,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *f,
                                      : AVCOL_RANGE_JPEG;
     avctx->colorspace = version & 1 ? AVCOL_SPC_UNSPECIFIED : AVCOL_SPC_BT709;
 
-    if ((ret = ff_thread_get_buffer(avctx, f, 0)) < 0)
+    if ((ret = ff_get_buffer(avctx, f, 0)) < 0)
         return ret;
 
     switch (version) {
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index e9a404e41b..fc2c36485b 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -200,7 +200,7 @@ static int alloc_picture(H264Context *h, H264Picture *pic)
         pic->f_grain->format = pic->f->format;
         pic->f_grain->width = pic->f->width;
         pic->f_grain->height = pic->f->height;
-        ret = ff_thread_get_buffer(h->avctx, pic->f_grain, 0);
+        ret = ff_get_buffer(h->avctx, pic->f_grain, 0);
         if (ret < 0)
             goto fail;
     }
diff --git a/libavcodec/hapdec.c b/libavcodec/hapdec.c
index 6066cb814c..9134069dcf 100644
--- a/libavcodec/hapdec.c
+++ b/libavcodec/hapdec.c
@@ -38,10 +38,10 @@
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "hap.h"
 #include "snappy.h"
 #include "texturedsp.h"
-#include "thread.h"
 
 static int hap_parse_decode_instructions(HapContext *ctx, int size)
 {
@@ -271,7 +271,7 @@ static int hap_decode(AVCodecContext *avctx, AVFrame *frame,
     }
 
     /* Get the output frame ready to receive data */
-    ret = ff_thread_get_buffer(avctx, frame, 0);
+    ret = ff_get_buffer(avctx, frame, 0);
     if (ret < 0)
         return ret;
 
diff --git a/libavcodec/hdrdec.c b/libavcodec/hdrdec.c
index 9b6395bb6d..04838f259b 100644
--- a/libavcodec/hdrdec.c
+++ b/libavcodec/hdrdec.c
@@ -134,7 +134,7 @@ static int hdr_decode_frame(AVCodecContext *avctx, AVFrame *p,
     if (avctx->skip_frame >= AVDISCARD_ALL)
         return avpkt->size;
 
-    if ((ret = ff_thread_get_buffer(avctx, p, 0)) < 0)
+    if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
         return ret;
 
     for (int y = 0; y < height; y++) {
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 76aa6b4588..bbc7683da6 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -2901,7 +2901,7 @@ static int hevc_frame_start(HEVCContext *s)
         s->ref->frame_grain->format = s->ref->frame->format;
         s->ref->frame_grain->width = s->ref->frame->width;
         s->ref->frame_grain->height = s->ref->frame->height;
-        if ((ret = ff_thread_get_buffer(s->avctx, s->ref->frame_grain, 0)) < 0)
+        if ((ret = ff_get_buffer(s->avctx, s->ref->frame_grain, 0)) < 0)
             goto fail;
     }
 
diff --git a/libavcodec/hqx.c b/libavcodec/hqx.c
index 51099aa684..8398a79349 100644
--- a/libavcodec/hqx.c
+++ b/libavcodec/hqx.c
@@ -26,8 +26,8 @@
 #include "avcodec.h"
 #include "canopus.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
-#include "thread.h"
 
 #include "hqx.h"
 #include "hqxdsp.h"
@@ -498,7 +498,7 @@ static int hqx_decode_frame(AVCodecContext *avctx, AVFrame *frame,
         return AVERROR_INVALIDDATA;
     }
 
-    ret = ff_thread_get_buffer(avctx, frame, 0);
+    ret = ff_get_buffer(avctx, frame, 0);
     if (ret < 0)
         return ret;
 
diff --git a/libavcodec/huffyuvdec.c b/libavcodec/huffyuvdec.c
index ce6d4d4c59..34f152f8ee 100644
--- a/libavcodec/huffyuvdec.c
+++ b/libavcodec/huffyuvdec.c
@@ -37,11 +37,11 @@
 #include "avcodec.h"
 #include "bswapdsp.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
 #include "huffyuv.h"
 #include "huffyuvdsp.h"
 #include "lossless_videodsp.h"
-#include "thread.h"
 #include "libavutil/emms.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/pixdesc.h"
@@ -1244,7 +1244,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *p,
     s->bdsp.bswap_buf((uint32_t *) s->bitstream_buffer,
                       (const uint32_t *) buf, buf_size / 4);
 
-    if ((ret = ff_thread_get_buffer(avctx, p, 0)) < 0)
+    if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
         return ret;
 
     if (s->context) {
diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 1afc6b1e2d..6ba5954409 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -2495,7 +2495,7 @@ static int jpeg2000_decode_frame(AVCodecContext *avctx, AVFrame *picture,
     }
 
     /* get picture buffer */
-    if ((ret = ff_thread_get_buffer(avctx, picture, 0)) < 0)
+    if ((ret = ff_get_buffer(avctx, picture, 0)) < 0)
         goto end;
     picture->pict_type = AV_PICTURE_TYPE_I;
     picture->flags |= AV_FRAME_FLAG_KEY;
diff --git a/libavcodec/lagarith.c b/libavcodec/lagarith.c
index 75b557e518..7831106ef3 100644
--- a/libavcodec/lagarith.c
+++ b/libavcodec/lagarith.c
@@ -31,11 +31,11 @@
 
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
 #include "mathops.h"
 #include "lagarithrac.h"
 #include "lossless_videodsp.h"
-#include "thread.h"
 
 #define VLC_BITS 7
 
@@ -590,7 +590,7 @@ static int lag_decode_frame(AVCodecContext *avctx, AVFrame *p,
                 planes = 4;
             }
 
-        if ((ret = ff_thread_get_buffer(avctx, p, 0)) < 0)
+        if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
             return ret;
 
         if (frametype == FRAME_SOLID_RGBA) {
@@ -614,7 +614,7 @@ static int lag_decode_frame(AVCodecContext *avctx, AVFrame *p,
             avctx->pix_fmt = AV_PIX_FMT_GBRAP;
         }
 
-        if ((ret = ff_thread_get_buffer(avctx, p,0)) < 0)
+        if ((ret = ff_get_buffer(avctx, p,0)) < 0)
             return ret;
 
         for (i = 0; i < avctx->height; i++) {
@@ -635,7 +635,7 @@ static int lag_decode_frame(AVCodecContext *avctx, AVFrame *p,
         if (frametype == FRAME_ARITH_RGB24 || frametype == FRAME_U_RGB24)
             avctx->pix_fmt = AV_PIX_FMT_GBRP;
 
-        if ((ret = ff_thread_get_buffer(avctx, p, 0)) < 0)
+        if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
             return ret;
 
         offs[0] = offset_bv;
@@ -671,7 +671,7 @@ static int lag_decode_frame(AVCodecContext *avctx, AVFrame *p,
     case FRAME_ARITH_YUY2:
         avctx->pix_fmt = AV_PIX_FMT_YUV422P;
 
-        if ((ret = ff_thread_get_buffer(avctx, p, 0)) < 0)
+        if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
             return ret;
 
         if (offset_ry >= buf_size ||
@@ -699,7 +699,7 @@ static int lag_decode_frame(AVCodecContext *avctx, AVFrame *p,
     case FRAME_ARITH_YV12:
         avctx->pix_fmt = AV_PIX_FMT_YUV420P;
 
-        if ((ret = ff_thread_get_buffer(avctx, p, 0)) < 0)
+        if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
             return ret;
 
         if (offset_ry >= buf_size ||
diff --git a/libavcodec/lcldec.c b/libavcodec/lcldec.c
index b4304618e4..1a52f46fc4 100644
--- a/libavcodec/lcldec.c
+++ b/libavcodec/lcldec.c
@@ -47,8 +47,8 @@
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "lcl.h"
-#include "thread.h"
 
 #if CONFIG_ZLIB_DECODER
 #include "zlib_wrapper.h"
@@ -180,7 +180,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
     unsigned int len = buf_size;
     int linesize, offset;
 
-    if ((ret = ff_thread_get_buffer(avctx, frame, 0)) < 0)
+    if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
         return ret;
 
     outptr = frame->data[0]; // Output image pointer
diff --git a/libavcodec/magicyuv.c b/libavcodec/magicyuv.c
index 3f6348b531..06fdf9e39f 100644
--- a/libavcodec/magicyuv.c
+++ b/libavcodec/magicyuv.c
@@ -654,7 +654,7 @@ static int magy_decode_frame(AVCodecContext *avctx, AVFrame *p,
     p->pict_type = AV_PICTURE_TYPE_I;
     p->flags |= AV_FRAME_FLAG_KEY;
 
-    if ((ret = ff_thread_get_buffer(avctx, p, 0)) < 0)
+    if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
         return ret;
 
     s->buf = avpkt->data;
diff --git a/libavcodec/mdec.c b/libavcodec/mdec.c
index c4904216b8..2855ae7514 100644
--- a/libavcodec/mdec.c
+++ b/libavcodec/mdec.c
@@ -33,10 +33,10 @@
 #include "blockdsp.h"
 #include "bswapdsp.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "idctdsp.h"
 #include "mpeg12data.h"
 #include "mpeg12dec.h"
-#include "thread.h"
 
 typedef struct MDECContext {
     AVCodecContext *avctx;
@@ -174,7 +174,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
     int buf_size          = avpkt->size;
     int ret;
 
-    if ((ret = ff_thread_get_buffer(avctx, frame, 0)) < 0)
+    if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
         return ret;
     frame->pict_type = AV_PICTURE_TYPE_I;
     frame->flags |= AV_FRAME_FLAG_KEY;
diff --git a/libavcodec/notchlc.c b/libavcodec/notchlc.c
index 0feb0918f0..ab540362af 100644
--- a/libavcodec/notchlc.c
+++ b/libavcodec/notchlc.c
@@ -221,7 +221,7 @@ static int decode_blocks(AVCodecContext *avctx, AVFrame *p,
         return AVERROR_INVALIDDATA;
     s->uv_count_offset = s->y_data_offset - s->a_data_offset;
 
-    if ((ret = ff_thread_get_buffer(avctx, p, 0)) < 0)
+    if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
         return ret;
 
     rgb = *gb;
diff --git a/libavcodec/photocd.c b/libavcodec/photocd.c
index 07e8d460bd..f7d3638273 100644
--- a/libavcodec/photocd.c
+++ b/libavcodec/photocd.c
@@ -328,7 +328,7 @@ static int photocd_decode_frame(AVCodecContext *avctx, AVFrame *p,
     if (avctx->skip_frame >= AVDISCARD_ALL)
         return avpkt->size;
 
-    if ((ret = ff_thread_get_buffer(avctx, p, 0)) < 0)
+    if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
         return ret;
 
     p->pict_type = AV_PICTURE_TYPE_I;
diff --git a/libavcodec/pixlet.c b/libavcodec/pixlet.c
index 6e925308b8..b015352eda 100644
--- a/libavcodec/pixlet.c
+++ b/libavcodec/pixlet.c
@@ -670,7 +670,7 @@ static int pixlet_decode_frame(AVCodecContext *avctx, AVFrame *p,
     p->flags |= AV_FRAME_FLAG_KEY;
     p->color_range = AVCOL_RANGE_JPEG;
 
-    ret = ff_thread_get_buffer(avctx, p, 0);
+    ret = ff_get_buffer(avctx, p, 0);
     if (ret < 0)
         return ret;
 
diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
index de50e6a5b6..ef342327d0 100644
--- a/libavcodec/pngdec.c
+++ b/libavcodec/pngdec.c
@@ -876,7 +876,7 @@ static int decode_idat_chunk(AVCodecContext *avctx, PNGDecContext *s,
         ff_thread_release_ext_buffer(&s->picture);
         if (s->dispose_op == APNG_DISPOSE_OP_PREVIOUS) {
             /* We only need a buffer for the current picture. */
-            ret = ff_thread_get_buffer(avctx, p, 0);
+            ret = ff_get_buffer(avctx, p, 0);
             if (ret < 0)
                 return ret;
         } else if (s->dispose_op == APNG_DISPOSE_OP_BACKGROUND) {
@@ -886,7 +886,7 @@ static int decode_idat_chunk(AVCodecContext *avctx, PNGDecContext *s,
                                            AV_GET_BUFFER_FLAG_REF);
             if (ret < 0)
                 return ret;
-            ret = ff_thread_get_buffer(avctx, p, 0);
+            ret = ff_get_buffer(avctx, p, 0);
             if (ret < 0)
                 return ret;
         } else {
diff --git a/libavcodec/proresdec2.c b/libavcodec/proresdec2.c
index 3a5b753430..2e7ddbfd22 100644
--- a/libavcodec/proresdec2.c
+++ b/libavcodec/proresdec2.c
@@ -800,7 +800,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
     buf += frame_hdr_size;
     buf_size -= frame_hdr_size;
 
-    if ((ret = ff_thread_get_buffer(avctx, frame, 0)) < 0)
+    if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
         return ret;
     ff_thread_finish_setup(avctx);
 
diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index fd356bd190..dd25d99fbb 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -939,9 +939,6 @@ static int thread_get_buffer_internal(AVCodecContext *avctx, AVFrame *f, int fla
     PerThreadContext *p;
     int err;
 
-    if (!(avctx->active_thread_type & FF_THREAD_FRAME))
-        return ff_get_buffer(avctx, f, flags);
-
     p = avctx->internal->thread_ctx;
     if (atomic_load(&p->state) != STATE_SETTING_UP &&
         ffcodec(avctx->codec)->update_thread_context) {
@@ -950,7 +947,7 @@ static int thread_get_buffer_internal(AVCodecContext *avctx, AVFrame *f, int fla
     }
 
     pthread_mutex_lock(&p->parent->buffer_mutex);
-    err = ff_get_buffer(avctx, f, flags);
+    err = ff_decode_get_buffer(avctx, f, flags);
 
     pthread_mutex_unlock(&p->parent->buffer_mutex);
 
@@ -976,7 +973,7 @@ int ff_thread_get_ext_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
      * This currently affects non-MPEG-4 mpegvideo codecs and and VP7.
      * The following check will always be true for them. */
     if (!(avctx->active_thread_type & FF_THREAD_FRAME))
-        return ff_get_buffer(avctx, f->f, flags);
+        return ff_decode_get_buffer(avctx, f->f, flags);
 
     if (ffcodec(avctx->codec)->caps_internal & FF_CODEC_CAP_ALLOCATE_PROGRESS) {
         f->progress = ff_refstruct_allocz(sizeof(*f->progress));
diff --git a/libavcodec/qoidec.c b/libavcodec/qoidec.c
index 37bc2084c0..f591b2f5a4 100644
--- a/libavcodec/qoidec.c
+++ b/libavcodec/qoidec.c
@@ -63,7 +63,7 @@ static int qoi_decode_frame(AVCodecContext *avctx, AVFrame *p,
     if (avctx->skip_frame >= AVDISCARD_ALL)
         return avpkt->size;
 
-    if ((ret = ff_thread_get_buffer(avctx, p, 0)) < 0)
+    if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
         return ret;
 
     dst = p->data[0];
diff --git a/libavcodec/rtv1.c b/libavcodec/rtv1.c
index 06afe9e873..79926eb65f 100644
--- a/libavcodec/rtv1.c
+++ b/libavcodec/rtv1.c
@@ -120,7 +120,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *p,
     avctx->width  = width;
     avctx->height = height;
 
-    if ((ret = ff_thread_get_buffer(avctx, p, 0)) < 0)
+    if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
         return ret;
 
     dst = p->data[0] + p->linesize[0] * (avctx->coded_height - 1);
diff --git a/libavcodec/sheervideo.c b/libavcodec/sheervideo.c
index 660e2661a4..f78d826884 100644
--- a/libavcodec/sheervideo.c
+++ b/libavcodec/sheervideo.c
@@ -25,8 +25,8 @@
 #include "libavutil/intreadwrite.h"
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
-#include "thread.h"
 #include "sheervideodata.h"
 
 typedef struct SheerVideoContext {
@@ -1975,7 +1975,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *p,
     p->pict_type = AV_PICTURE_TYPE_I;
     p->flags |= AV_FRAME_FLAG_KEY;
 
-    if ((ret = ff_thread_get_buffer(avctx, p, 0)) < 0)
+    if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
         return ret;
 
     if ((ret = init_get_bits8(&gb, avpkt->data + 20, avpkt->size - 20)) < 0)
diff --git a/libavcodec/takdec.c b/libavcodec/takdec.c
index 5cbc2de6bd..76c03f5834 100644
--- a/libavcodec/takdec.c
+++ b/libavcodec/takdec.c
@@ -32,12 +32,13 @@
 #define CACHED_BITSTREAM_READER !ARCH_X86_32
 #define BITSTREAM_READER_LE
 #include "audiodsp.h"
-#include "thread.h"
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "unary.h"
 #include "tak.h"
 #include "takdsp.h"
+#include "thread.h"
 
 #define MAX_SUBFRAMES     8                         ///< max number of subframes per channel
 #define MAX_PREDICTORS  256
@@ -742,7 +743,7 @@ static int tak_decode_frame(AVCodecContext *avctx, AVFrame *frame,
                                              : s->ti.frame_samples;
 
     frame->nb_samples = s->nb_samples;
-    if ((ret = ff_thread_get_buffer(avctx, frame, 0)) < 0)
+    if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
         return ret;
     ff_thread_finish_setup(avctx);
 
diff --git a/libavcodec/thread.h b/libavcodec/thread.h
index 4272fd87d4..5a00b32619 100644
--- a/libavcodec/thread.h
+++ b/libavcodec/thread.h
@@ -43,16 +43,6 @@ int ff_thread_can_start_frame(AVCodecContext *avctx);
  */
 void ff_thread_finish_setup(AVCodecContext *avctx);
 
-/**
- * Wrapper around get_buffer() for frame-multithreaded codecs.
- * Call this function instead of ff_get_buffer(f).
- * Cannot be called after the codec has called ff_thread_finish_setup().
- *
- * @param avctx The current context.
- * @param f The frame to write into.
- */
-int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f, int flags);
-
 int ff_slice_thread_execute_with_mainfunc(AVCodecContext *avctx,
         int (*action_func2)(AVCodecContext *c, void *arg, int jobnr, int threadnr),
         int (*main_func)(AVCodecContext *c), void *arg, int *ret, int job_count);
diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index cb4d378753..e52b61bb33 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -1214,7 +1214,7 @@ static int init_image(TiffContext *s, AVFrame *frame)
     if (s->avctx->skip_frame >= AVDISCARD_ALL)
         return 0;
 
-    if ((ret = ff_thread_get_buffer(s->avctx, frame, 0)) < 0)
+    if ((ret = ff_get_buffer(s->avctx, frame, 0)) < 0)
         return ret;
     if (s->avctx->pix_fmt == AV_PIX_FMT_PAL8) {
         if (!create_gray_palette)
diff --git a/libavcodec/tta.c b/libavcodec/tta.c
index 7763ed7ffc..62b746c123 100644
--- a/libavcodec/tta.c
+++ b/libavcodec/tta.c
@@ -39,8 +39,8 @@
 #include "ttadsp.h"
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
-#include "thread.h"
 #include "unary.h"
 
 #define FORMAT_SIMPLE    1
@@ -247,7 +247,7 @@ static int tta_decode_frame(AVCodecContext *avctx, AVFrame *frame,
 
     /* get output buffer */
     frame->nb_samples = framelen;
-    if ((ret = ff_thread_get_buffer(avctx, frame, 0)) < 0)
+    if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
         return ret;
 
     // decode directly to output buffer for 24-bit sample format
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index e91a5d6d2e..9b230d9989 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -884,11 +884,6 @@ int ff_thread_replace_frame(ThreadFrame *dst, const ThreadFrame *src)
 
 #if !HAVE_THREADS
 
-int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f, int flags)
-{
-    return ff_get_buffer(avctx, f, flags);
-}
-
 int ff_thread_get_ext_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
 {
     f->owner[0] = f->owner[1] = avctx;
diff --git a/libavcodec/utvideodec.c b/libavcodec/utvideodec.c
index ce5d00f7af..5133bcdbb5 100644
--- a/libavcodec/utvideodec.c
+++ b/libavcodec/utvideodec.c
@@ -36,9 +36,9 @@
 #include "bswapdsp.h"
 #include "bytestream.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
 #include "lossless_videodsp.h"
-#include "thread.h"
 #include "utvideo.h"
 #include "utvideodsp.h"
 
@@ -589,7 +589,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
     int ret;
     GetByteContext gb;
 
-    if ((ret = ff_thread_get_buffer(avctx, frame, 0)) < 0)
+    if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
         return ret;
 
     /* parse plane structure to get frame flags and validate slice offsets */
diff --git a/libavcodec/v210dec.c b/libavcodec/v210dec.c
index d80fb4e7c6..85f5039fa4 100644
--- a/libavcodec/v210dec.c
+++ b/libavcodec/v210dec.c
@@ -23,13 +23,13 @@
 
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "v210dec.h"
 #include "v210dec_init.h"
 #include "libavutil/bswap.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/internal.h"
 #include "libavutil/intreadwrite.h"
-#include "thread.h"
 
 typedef struct ThreadData {
     AVFrame *frame;
@@ -183,7 +183,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *pic,
         ff_v210dec_init(s);
     }
 
-    if ((ret = ff_thread_get_buffer(avctx, pic, 0)) < 0)
+    if ((ret = ff_get_buffer(avctx, pic, 0)) < 0)
         return ret;
 
     pic->pict_type = AV_PICTURE_TYPE_I;
diff --git a/libavcodec/v410dec.c b/libavcodec/v410dec.c
index 35e4a8ae03..e4f25fab88 100644
--- a/libavcodec/v410dec.c
+++ b/libavcodec/v410dec.c
@@ -24,7 +24,7 @@
 #include "libavutil/intreadwrite.h"
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "thread.h"
+#include "decode.h"
 
 typedef struct ThreadData {
     AVFrame *frame;
@@ -99,7 +99,7 @@ static int v410_decode_frame(AVCodecContext *avctx, AVFrame *pic,
         return AVERROR(EINVAL);
     }
 
-    if ((ret = ff_thread_get_buffer(avctx, pic, 0)) < 0)
+    if ((ret = ff_get_buffer(avctx, pic, 0)) < 0)
         return ret;
 
     pic->flags |= AV_FRAME_FLAG_KEY;
diff --git a/libavcodec/vaapi_av1.c b/libavcodec/vaapi_av1.c
index 1f9a6071ba..3f3b661789 100644
--- a/libavcodec/vaapi_av1.c
+++ b/libavcodec/vaapi_av1.c
@@ -23,7 +23,7 @@
 #include "vaapi_decode.h"
 #include "internal.h"
 #include "av1dec.h"
-#include "thread.h"
+#include "decode.h"
 
 typedef struct VAAPIAV1FrameRef {
     AVFrame *frame;
@@ -127,7 +127,7 @@ static int vaapi_av1_start_frame(AVCodecContext *avctx,
     if (apply_grain) {
         if (ctx->tmp_frame->buf[0])
             av_frame_unref(ctx->tmp_frame);
-        err = ff_thread_get_buffer(avctx, ctx->tmp_frame, AV_GET_BUFFER_FLAG_REF);
+        err = ff_get_buffer(avctx, ctx->tmp_frame, AV_GET_BUFFER_FLAG_REF);
         if (err < 0)
             goto fail;
         pic->output_surface = ff_vaapi_get_surface_id(ctx->tmp_frame);
diff --git a/libavcodec/vble.c b/libavcodec/vble.c
index 7711bf1bb1..4d4f126d36 100644
--- a/libavcodec/vble.c
+++ b/libavcodec/vble.c
@@ -29,10 +29,10 @@
 #define BITSTREAM_READER_LE
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
 #include "lossless_videodsp.h"
 #include "mathops.h"
-#include "thread.h"
 
 typedef struct VBLEContext {
     AVCodecContext *avctx;
@@ -131,7 +131,7 @@ static int vble_decode_frame(AVCodecContext *avctx, AVFrame *pic,
     }
 
     /* Allocate buffer */
-    if ((ret = ff_thread_get_buffer(avctx, pic, 0)) < 0)
+    if ((ret = ff_get_buffer(avctx, pic, 0)) < 0)
         return ret;
 
     /* Set flags */
diff --git a/libavcodec/vmixdec.c b/libavcodec/vmixdec.c
index d6b6e3557f..4fceb6d5e2 100644
--- a/libavcodec/vmixdec.c
+++ b/libavcodec/vmixdec.c
@@ -280,7 +280,7 @@ static int decode_frame(AVCodecContext *avctx,
         offset += slice_size + 4;
     }
 
-    ret = ff_thread_get_buffer(avctx, frame, 0);
+    ret = ff_get_buffer(avctx, frame, 0);
     if (ret < 0)
         return ret;
 
diff --git a/libavcodec/vvc/vvc_refs.c b/libavcodec/vvc/vvc_refs.c
index 99f2dcf3ec..de5f582006 100644
--- a/libavcodec/vvc/vvc_refs.c
+++ b/libavcodec/vvc/vvc_refs.c
@@ -24,7 +24,7 @@
 
 #include "libavutil/thread.h"
 #include "libavcodec/refstruct.h"
-#include "libavcodec/thread.h"
+#include "libavcodec/decode.h"
 
 #include "vvc_refs.h"
 
@@ -118,7 +118,7 @@ static VVCFrame *alloc_frame(VVCContext *s, VVCFrameContext *fc)
         if (frame->frame->buf[0])
             continue;
 
-        ret = ff_thread_get_buffer(s->avctx, frame->frame, AV_GET_BUFFER_FLAG_REF);
+        ret = ff_get_buffer(s->avctx, frame->frame, AV_GET_BUFFER_FLAG_REF);
         if (ret < 0)
             return NULL;
 
diff --git a/libavcodec/wbmpdec.c b/libavcodec/wbmpdec.c
index 3b5753abcd..7d3a32bb13 100644
--- a/libavcodec/wbmpdec.c
+++ b/libavcodec/wbmpdec.c
@@ -66,7 +66,7 @@ static int wbmp_decode_frame(AVCodecContext *avctx, AVFrame *p,
         return ret;
 
     avctx->pix_fmt = AV_PIX_FMT_MONOBLACK;
-    if ((ret = ff_thread_get_buffer(avctx, p, 0)) < 0)
+    if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
         return ret;
 
     if (p->linesize[0] == (width + 7) / 8)
diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index 9308ea2b69..45e7344965 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -570,7 +570,7 @@ static int decode_entropy_coded_image(WebPContext *s, enum ImageRole role,
     img->frame->height = h;
 
     if (role == IMAGE_ROLE_ARGB && !img->is_alpha_primary) {
-        ret = ff_thread_get_buffer(s->avctx, img->frame, 0);
+        ret = ff_get_buffer(s->avctx, img->frame, 0);
     } else
         ret = av_frame_get_buffer(img->frame, 1);
     if (ret < 0)
diff --git a/libavcodec/ylc.c b/libavcodec/ylc.c
index b03df31556..8c2503fb01 100644
--- a/libavcodec/ylc.c
+++ b/libavcodec/ylc.c
@@ -28,8 +28,8 @@
 #include "avcodec.h"
 #include "bswapdsp.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
-#include "thread.h"
 #include "unary.h"
 
 typedef struct YLCContext {
@@ -300,7 +300,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *p,
     if (toffset >= boffset || boffset >= avpkt->size)
         return AVERROR_INVALIDDATA;
 
-    if ((ret = ff_thread_get_buffer(avctx, p, 0)) < 0)
+    if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
         return ret;
 
     av_fast_malloc(&s->buffer, &s->buffer_size,
