diff --git a/configure b/configure
index d552d5e150..30b598dcc6 100755
--- a/configure
+++ b/configure
@@ -6857,11 +6857,7 @@ check_stripflags -x
 
 enabled neon_clobber_test &&
     check_ldflags -Wl,--wrap,avcodec_open2              \
-                  -Wl,--wrap,avcodec_decode_audio4      \
-                  -Wl,--wrap,avcodec_decode_video2      \
                   -Wl,--wrap,avcodec_decode_subtitle2   \
-                  -Wl,--wrap,avcodec_encode_audio2      \
-                  -Wl,--wrap,avcodec_encode_video2      \
                   -Wl,--wrap,avcodec_encode_subtitle    \
                   -Wl,--wrap,avcodec_send_packet        \
                   -Wl,--wrap,avcodec_receive_packet     \
@@ -6873,11 +6869,7 @@ enabled neon_clobber_test &&
 
 enabled xmm_clobber_test &&
     check_ldflags -Wl,--wrap,avcodec_open2              \
-                  -Wl,--wrap,avcodec_decode_audio4      \
-                  -Wl,--wrap,avcodec_decode_video2      \
                   -Wl,--wrap,avcodec_decode_subtitle2   \
-                  -Wl,--wrap,avcodec_encode_audio2      \
-                  -Wl,--wrap,avcodec_encode_video2      \
                   -Wl,--wrap,avcodec_encode_subtitle    \
                   -Wl,--wrap,avcodec_send_packet        \
                   -Wl,--wrap,avcodec_receive_packet     \
diff --git a/libavcodec/aarch64/neontest.c b/libavcodec/aarch64/neontest.c
index a4fc5a0e2f..ed84b6e073 100644
--- a/libavcodec/aarch64/neontest.c
+++ b/libavcodec/aarch64/neontest.c
@@ -29,41 +29,6 @@ wrap(avcodec_open2(AVCodecContext *avctx,
     testneonclobbers(avcodec_open2, avctx, codec, options);
 }
 
-#if FF_API_OLD_ENCDEC
-wrap(avcodec_decode_audio4(AVCodecContext *avctx,
-                           AVFrame *frame,
-                           int *got_frame_ptr,
-                           AVPacket *avpkt))
-{
-    testneonclobbers(avcodec_decode_audio4, avctx, frame,
-                     got_frame_ptr, avpkt);
-}
-
-wrap(avcodec_decode_video2(AVCodecContext *avctx,
-                           AVFrame *picture,
-                           int *got_picture_ptr,
-                           AVPacket *avpkt))
-{
-    testneonclobbers(avcodec_decode_video2, avctx, picture,
-                     got_picture_ptr, avpkt);
-}
-
-wrap(avcodec_encode_audio2(AVCodecContext *avctx,
-                           AVPacket *avpkt,
-                           const AVFrame *frame,
-                           int *got_packet_ptr))
-{
-    testneonclobbers(avcodec_encode_audio2, avctx, avpkt, frame,
-                     got_packet_ptr);
-}
-
-wrap(avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt,
-                           const AVFrame *frame, int *got_packet_ptr))
-{
-    testneonclobbers(avcodec_encode_video2, avctx, avpkt, frame, got_packet_ptr);
-}
-#endif
-
 wrap(avcodec_decode_subtitle2(AVCodecContext *avctx,
                               AVSubtitle *sub,
                               int *got_sub_ptr,
diff --git a/libavcodec/arm/neontest.c b/libavcodec/arm/neontest.c
index d1ede4955c..df64c6f778 100644
--- a/libavcodec/arm/neontest.c
+++ b/libavcodec/arm/neontest.c
@@ -29,41 +29,6 @@ wrap(avcodec_open2(AVCodecContext *avctx,
     testneonclobbers(avcodec_open2, avctx, codec, options);
 }
 
-#if FF_API_OLD_ENCDEC
-wrap(avcodec_decode_audio4(AVCodecContext *avctx,
-                           AVFrame *frame,
-                           int *got_frame_ptr,
-                           AVPacket *avpkt))
-{
-    testneonclobbers(avcodec_decode_audio4, avctx, frame,
-                     got_frame_ptr, avpkt);
-}
-
-wrap(avcodec_decode_video2(AVCodecContext *avctx,
-                           AVFrame *picture,
-                           int *got_picture_ptr,
-                           AVPacket *avpkt))
-{
-    testneonclobbers(avcodec_decode_video2, avctx, picture,
-                     got_picture_ptr, avpkt);
-}
-
-wrap(avcodec_encode_audio2(AVCodecContext *avctx,
-                           AVPacket *avpkt,
-                           const AVFrame *frame,
-                           int *got_packet_ptr))
-{
-    testneonclobbers(avcodec_encode_audio2, avctx, avpkt, frame,
-                     got_packet_ptr);
-}
-
-wrap(avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt,
-                           const AVFrame *frame, int *got_packet_ptr))
-{
-    testneonclobbers(avcodec_encode_video2, avctx, avpkt, frame, got_packet_ptr);
-}
-#endif
-
 wrap(avcodec_decode_subtitle2(AVCodecContext *avctx,
                               AVSubtitle *sub,
                               int *got_sub_ptr,
diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index 62556301ce..4c6be665ff 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -181,15 +181,6 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
     }
     avctx->internal = avci;
 
-#if FF_API_OLD_ENCDEC
-    avci->to_free = av_frame_alloc();
-    avci->compat_decode_frame = av_frame_alloc();
-    avci->compat_encode_packet = av_packet_alloc();
-    if (!avci->to_free || !avci->compat_decode_frame || !avci->compat_encode_packet) {
-        ret = AVERROR(ENOMEM);
-        goto free_and_end;
-    }
-#endif
     avci->buffer_frame = av_frame_alloc();
     avci->buffer_pkt = av_packet_alloc();
     avci->es.in_frame = av_frame_alloc();
@@ -408,11 +399,6 @@ free_and_end:
     av_freep(&avctx->priv_data);
     av_freep(&avctx->subtitle_header);
 
-#if FF_API_OLD_ENCDEC
-    av_frame_free(&avci->to_free);
-    av_frame_free(&avci->compat_decode_frame);
-    av_packet_free(&avci->compat_encode_packet);
-#endif
     av_frame_free(&avci->buffer_frame);
     av_packet_free(&avci->buffer_pkt);
     av_packet_free(&avci->last_pkt_props);
@@ -452,10 +438,6 @@ void avcodec_flush_buffers(AVCodecContext *avctx)
     avci->draining_done = 0;
     avci->nb_draining_errors = 0;
     av_frame_unref(avci->buffer_frame);
-#if FF_API_OLD_ENCDEC
-    av_frame_unref(avci->compat_decode_frame);
-    av_packet_unref(avci->compat_encode_packet);
-#endif
     av_packet_unref(avci->buffer_pkt);
 
     av_packet_unref(avci->last_pkt_props);
@@ -480,13 +462,6 @@ void avcodec_flush_buffers(AVCodecContext *avctx)
 
     if (av_codec_is_decoder(avctx->codec))
         av_bsf_flush(avci->bsf);
-
-#if FF_API_OLD_ENCDEC
-FF_DISABLE_DEPRECATION_WARNINGS
-    if (!avctx->refcounted_frames)
-        av_frame_unref(avci->to_free);
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
 }
 
 void avsubtitle_free(AVSubtitle *sub)
@@ -528,11 +503,6 @@ av_cold int avcodec_close(AVCodecContext *avctx)
             avctx->codec->close(avctx);
         avci->byte_buffer_size = 0;
         av_freep(&avci->byte_buffer);
-#if FF_API_OLD_ENCDEC
-        av_frame_free(&avci->to_free);
-        av_frame_free(&avci->compat_decode_frame);
-        av_packet_free(&avci->compat_encode_packet);
-#endif
         av_frame_free(&avci->buffer_frame);
         av_packet_free(&avci->buffer_pkt);
         av_packet_unref(avci->last_pkt_props);
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 144f299d46..bb5e8490ca 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -155,29 +155,6 @@
  * at least will not fail with AVERROR(EAGAIN). In general, no codec will
  * permit unlimited buffering of input or output.
  *
- * This API replaces the following legacy functions:
- * - avcodec_decode_video2() and avcodec_decode_audio4():
- *   Use avcodec_send_packet() to feed input to the decoder, then use
- *   avcodec_receive_frame() to receive decoded frames after each packet.
- *   Unlike with the old video decoding API, multiple frames might result from
- *   a packet. For audio, splitting the input packet into frames by partially
- *   decoding packets becomes transparent to the API user. You never need to
- *   feed an AVPacket to the API twice (unless it is rejected with AVERROR(EAGAIN) - then
- *   no data was read from the packet).
- *   Additionally, sending a flush/draining packet is required only once.
- * - avcodec_encode_video2()/avcodec_encode_audio2():
- *   Use avcodec_send_frame() to feed input to the encoder, then use
- *   avcodec_receive_packet() to receive encoded packets.
- *   Providing user-allocated buffers for avcodec_receive_packet() is not
- *   possible.
- * - The new API does not handle subtitles yet.
- *
- * Mixing new and old function calls on the same AVCodecContext is not allowed,
- * and will result in undefined behavior.
- *
- * Some codecs might require using the new API; using the old API will return
- * an error when calling it. All codecs support the new API.
- *
  * A codec is not allowed to return AVERROR(EAGAIN) for both sending and receiving. This
  * would be an invalid state, which could put the codec user into an endless
  * loop. The API has no concept of time either: it cannot happen that trying to
@@ -685,7 +662,7 @@ typedef struct AVCodecContext {
      * picture width / height.
      *
      * @note Those fields may not match the values of the last
-     * AVFrame output by avcodec_decode_video2 due frame
+     * AVFrame output by avcodec_receive_frame() due frame
      * reordering.
      *
      * - encoding: MUST be set by user.
@@ -1275,24 +1252,6 @@ typedef struct AVCodecContext {
      */
     int (*get_buffer2)(struct AVCodecContext *s, AVFrame *frame, int flags);
 
-#if FF_API_OLD_ENCDEC
-    /**
-     * If non-zero, the decoded audio and video frames returned from
-     * avcodec_decode_video2() and avcodec_decode_audio4() are reference-counted
-     * and are valid indefinitely. The caller must free them with
-     * av_frame_unref() when they are not needed anymore.
-     * Otherwise, the decoded frames must not be freed by the caller and are
-     * only valid until the next decode call.
-     *
-     * This is always automatically enabled if avcodec_receive_frame() is used.
-     *
-     * - encoding: unused
-     * - decoding: set by the caller before avcodec_open2().
-     */
-    attribute_deprecated
-    int refcounted_frames;
-#endif
-
     /* - encoding parameters */
     float qcompress;  ///< amount of qscale change between easy & hard scenes (0.0-1.0)
     float qblur;      ///< amount of qscale smoothing over time (0.0-1.0)
@@ -2644,115 +2603,6 @@ int avcodec_enum_to_chroma_pos(int *xpos, int *ypos, enum AVChromaLocation pos);
  */
 enum AVChromaLocation avcodec_chroma_pos_to_enum(int xpos, int ypos);
 
-#if FF_API_OLD_ENCDEC
-/**
- * Decode the audio frame of size avpkt->size from avpkt->data into frame.
- *
- * Some decoders may support multiple frames in a single AVPacket. Such
- * decoders would then just decode the first frame and the return value would be
- * less than the packet size. In this case, avcodec_decode_audio4 has to be
- * called again with an AVPacket containing the remaining data in order to
- * decode the second frame, etc...  Even if no frames are returned, the packet
- * needs to be fed to the decoder with remaining data until it is completely
- * consumed or an error occurs.
- *
- * Some decoders (those marked with AV_CODEC_CAP_DELAY) have a delay between input
- * and output. This means that for some packets they will not immediately
- * produce decoded output and need to be flushed at the end of decoding to get
- * all the decoded data. Flushing is done by calling this function with packets
- * with avpkt->data set to NULL and avpkt->size set to 0 until it stops
- * returning samples. It is safe to flush even those decoders that are not
- * marked with AV_CODEC_CAP_DELAY, then no samples will be returned.
- *
- * @warning The input buffer, avpkt->data must be AV_INPUT_BUFFER_PADDING_SIZE
- *          larger than the actual read bytes because some optimized bitstream
- *          readers read 32 or 64 bits at once and could read over the end.
- *
- * @note The AVCodecContext MUST have been opened with @ref avcodec_open2()
- * before packets may be fed to the decoder.
- *
- * @param      avctx the codec context
- * @param[out] frame The AVFrame in which to store decoded audio samples.
- *                   The decoder will allocate a buffer for the decoded frame by
- *                   calling the AVCodecContext.get_buffer2() callback.
- *                   When AVCodecContext.refcounted_frames is set to 1, the frame is
- *                   reference counted and the returned reference belongs to the
- *                   caller. The caller must release the frame using av_frame_unref()
- *                   when the frame is no longer needed. The caller may safely write
- *                   to the frame if av_frame_is_writable() returns 1.
- *                   When AVCodecContext.refcounted_frames is set to 0, the returned
- *                   reference belongs to the decoder and is valid only until the
- *                   next call to this function or until closing or flushing the
- *                   decoder. The caller may not write to it.
- * @param[out] got_frame_ptr Zero if no frame could be decoded, otherwise it is
- *                           non-zero. Note that this field being set to zero
- *                           does not mean that an error has occurred. For
- *                           decoders with AV_CODEC_CAP_DELAY set, no given decode
- *                           call is guaranteed to produce a frame.
- * @param[in]  avpkt The input AVPacket containing the input buffer.
- *                   At least avpkt->data and avpkt->size should be set. Some
- *                   decoders might also require additional fields to be set.
- * @return A negative error code is returned if an error occurred during
- *         decoding, otherwise the number of bytes consumed from the input
- *         AVPacket is returned.
- *
-* @deprecated Use avcodec_send_packet() and avcodec_receive_frame().
- */
-attribute_deprecated
-int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame,
-                          int *got_frame_ptr, const AVPacket *avpkt);
-
-/**
- * Decode the video frame of size avpkt->size from avpkt->data into picture.
- * Some decoders may support multiple frames in a single AVPacket, such
- * decoders would then just decode the first frame.
- *
- * @warning The input buffer must be AV_INPUT_BUFFER_PADDING_SIZE larger than
- * the actual read bytes because some optimized bitstream readers read 32 or 64
- * bits at once and could read over the end.
- *
- * @warning The end of the input buffer buf should be set to 0 to ensure that
- * no overreading happens for damaged MPEG streams.
- *
- * @note Codecs which have the AV_CODEC_CAP_DELAY capability set have a delay
- * between input and output, these need to be fed with avpkt->data=NULL,
- * avpkt->size=0 at the end to return the remaining frames.
- *
- * @note The AVCodecContext MUST have been opened with @ref avcodec_open2()
- * before packets may be fed to the decoder.
- *
- * @param avctx the codec context
- * @param[out] picture The AVFrame in which the decoded video frame will be stored.
- *             Use av_frame_alloc() to get an AVFrame. The codec will
- *             allocate memory for the actual bitmap by calling the
- *             AVCodecContext.get_buffer2() callback.
- *             When AVCodecContext.refcounted_frames is set to 1, the frame is
- *             reference counted and the returned reference belongs to the
- *             caller. The caller must release the frame using av_frame_unref()
- *             when the frame is no longer needed. The caller may safely write
- *             to the frame if av_frame_is_writable() returns 1.
- *             When AVCodecContext.refcounted_frames is set to 0, the returned
- *             reference belongs to the decoder and is valid only until the
- *             next call to this function or until closing or flushing the
- *             decoder. The caller may not write to it.
- *
- * @param[in] avpkt The input AVPacket containing the input buffer.
- *            You can create such packet with av_init_packet() and by then setting
- *            data and size, some decoders might in addition need other fields like
- *            flags&AV_PKT_FLAG_KEY. All decoders are designed to use the least
- *            fields possible.
- * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero.
- * @return On error a negative value is returned, otherwise the number of bytes
- * used or zero if no frame could be decompressed.
- *
- * @deprecated Use avcodec_send_packet() and avcodec_receive_frame().
- */
-attribute_deprecated
-int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
-                         int *got_picture_ptr,
-                         const AVPacket *avpkt);
-#endif
-
 /**
  * Decode a subtitle message.
  * Return a negative value on error, otherwise return the number of bytes used.
@@ -2796,10 +2646,6 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
  *          larger than the actual read bytes because some optimized bitstream
  *          readers read 32 or 64 bits at once and could read over the end.
  *
- * @warning Do not mix this API with the legacy API (like avcodec_decode_video2())
- *          on the same AVCodecContext. It will return unexpected results now
- *          or in future libavcodec versions.
- *
  * @note The AVCodecContext MUST have been opened with @ref avcodec_open2()
  *       before packets may be fed to the decoder.
  *
@@ -3265,95 +3111,6 @@ void av_parser_close(AVCodecParserContext *s);
  * @{
  */
 
-#if FF_API_OLD_ENCDEC
-/**
- * Encode a frame of audio.
- *
- * Takes input samples from frame and writes the next output packet, if
- * available, to avpkt. The output packet does not necessarily contain data for
- * the most recent frame, as encoders can delay, split, and combine input frames
- * internally as needed.
- *
- * @param avctx     codec context
- * @param avpkt     output AVPacket.
- *                  The user can supply an output buffer by setting
- *                  avpkt->data and avpkt->size prior to calling the
- *                  function, but if the size of the user-provided data is not
- *                  large enough, encoding will fail. If avpkt->data and
- *                  avpkt->size are set, avpkt->destruct must also be set. All
- *                  other AVPacket fields will be reset by the encoder using
- *                  av_init_packet(). If avpkt->data is NULL, the encoder will
- *                  allocate it. The encoder will set avpkt->size to the size
- *                  of the output packet.
- *
- *                  If this function fails or produces no output, avpkt will be
- *                  freed using av_packet_unref().
- * @param[in] frame AVFrame containing the raw audio data to be encoded.
- *                  May be NULL when flushing an encoder that has the
- *                  AV_CODEC_CAP_DELAY capability set.
- *                  If AV_CODEC_CAP_VARIABLE_FRAME_SIZE is set, then each frame
- *                  can have any number of samples.
- *                  If it is not set, frame->nb_samples must be equal to
- *                  avctx->frame_size for all frames except the last.
- *                  The final frame may be smaller than avctx->frame_size.
- * @param[out] got_packet_ptr This field is set to 1 by libavcodec if the
- *                            output packet is non-empty, and to 0 if it is
- *                            empty. If the function returns an error, the
- *                            packet can be assumed to be invalid, and the
- *                            value of got_packet_ptr is undefined and should
- *                            not be used.
- * @return          0 on success, negative error code on failure
- *
- * @deprecated use avcodec_send_frame()/avcodec_receive_packet() instead.
- *             If allowed and required, set AVCodecContext.get_encode_buffer to
- *             a custom function to pass user supplied output buffers.
- */
-attribute_deprecated
-int avcodec_encode_audio2(AVCodecContext *avctx, AVPacket *avpkt,
-                          const AVFrame *frame, int *got_packet_ptr);
-
-/**
- * Encode a frame of video.
- *
- * Takes input raw video data from frame and writes the next output packet, if
- * available, to avpkt. The output packet does not necessarily contain data for
- * the most recent frame, as encoders can delay and reorder input frames
- * internally as needed.
- *
- * @param avctx     codec context
- * @param avpkt     output AVPacket.
- *                  The user can supply an output buffer by setting
- *                  avpkt->data and avpkt->size prior to calling the
- *                  function, but if the size of the user-provided data is not
- *                  large enough, encoding will fail. All other AVPacket fields
- *                  will be reset by the encoder using av_init_packet(). If
- *                  avpkt->data is NULL, the encoder will allocate it.
- *                  The encoder will set avpkt->size to the size of the
- *                  output packet. The returned data (if any) belongs to the
- *                  caller, he is responsible for freeing it.
- *
- *                  If this function fails or produces no output, avpkt will be
- *                  freed using av_packet_unref().
- * @param[in] frame AVFrame containing the raw video data to be encoded.
- *                  May be NULL when flushing an encoder that has the
- *                  AV_CODEC_CAP_DELAY capability set.
- * @param[out] got_packet_ptr This field is set to 1 by libavcodec if the
- *                            output packet is non-empty, and to 0 if it is
- *                            empty. If the function returns an error, the
- *                            packet can be assumed to be invalid, and the
- *                            value of got_packet_ptr is undefined and should
- *                            not be used.
- * @return          0 on success, negative error code on failure
- *
- * @deprecated use avcodec_send_frame()/avcodec_receive_packet() instead.
- *             If allowed and required, set AVCodecContext.get_encode_buffer to
- *             a custom function to pass user supplied output buffers.
- */
-attribute_deprecated
-int avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt,
-                          const AVFrame *frame, int *got_packet_ptr);
-#endif
-
 int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
                             const AVSubtitle *sub);
 
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 0078f00607..dbc3f0110b 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -241,11 +241,6 @@ int ff_decode_get_packet(AVCodecContext *avctx, AVPacket *pkt)
     if (ret < 0)
         goto finish;
 
-#if FF_API_OLD_ENCDEC
-    if (avctx->codec->receive_frame)
-        avci->compat_decode_consumed += pkt->size;
-#endif
-
     return 0;
 finish:
     av_packet_unref(pkt);
@@ -490,10 +485,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
         }
     }
 
-#if FF_API_OLD_ENCDEC
-    avci->compat_decode_consumed += ret;
-#endif
-
     if (ret >= pkt->size || ret < 0) {
         av_packet_unref(pkt);
         av_packet_unref(avci->last_pkt_props);
@@ -716,152 +707,6 @@ int attribute_align_arg avcodec_receive_frame(AVCodecContext *avctx, AVFrame *fr
     return 0;
 }
 
-#if FF_API_OLD_ENCDEC
-FF_DISABLE_DEPRECATION_WARNINGS
-static int unrefcount_frame(AVCodecInternal *avci, AVFrame *frame)
-{
-    int ret;
-
-    /* move the original frame to our backup */
-    av_frame_unref(avci->to_free);
-    av_frame_move_ref(avci->to_free, frame);
-
-    /* now copy everything except the AVBufferRefs back
-     * note that we make a COPY of the side data, so calling av_frame_free() on
-     * the caller's frame will work properly */
-    ret = av_frame_copy_props(frame, avci->to_free);
-    if (ret < 0)
-        return ret;
-
-    memcpy(frame->data,     avci->to_free->data,     sizeof(frame->data));
-    memcpy(frame->linesize, avci->to_free->linesize, sizeof(frame->linesize));
-    if (avci->to_free->extended_data != avci->to_free->data) {
-        int planes = avci->to_free->channels;
-        int size   = planes * sizeof(*frame->extended_data);
-
-        if (!size) {
-            av_frame_unref(frame);
-            return AVERROR_BUG;
-        }
-
-        frame->extended_data = av_malloc(size);
-        if (!frame->extended_data) {
-            av_frame_unref(frame);
-            return AVERROR(ENOMEM);
-        }
-        memcpy(frame->extended_data, avci->to_free->extended_data,
-               size);
-    } else
-        frame->extended_data = frame->data;
-
-    frame->format         = avci->to_free->format;
-    frame->width          = avci->to_free->width;
-    frame->height         = avci->to_free->height;
-    frame->channel_layout = avci->to_free->channel_layout;
-    frame->nb_samples     = avci->to_free->nb_samples;
-    frame->channels       = avci->to_free->channels;
-
-    return 0;
-}
-
-static int compat_decode(AVCodecContext *avctx, AVFrame *frame,
-                         int *got_frame, const AVPacket *pkt)
-{
-    AVCodecInternal *avci = avctx->internal;
-    int ret = 0;
-
-    av_assert0(avci->compat_decode_consumed == 0);
-
-    if (avci->draining_done && pkt && pkt->size != 0) {
-        av_log(avctx, AV_LOG_WARNING, "Got unexpected packet after EOF\n");
-        avcodec_flush_buffers(avctx);
-    }
-
-    *got_frame = 0;
-
-    if (avci->compat_decode_partial_size > 0 &&
-        avci->compat_decode_partial_size != pkt->size) {
-        av_log(avctx, AV_LOG_ERROR,
-               "Got unexpected packet size after a partial decode\n");
-        ret = AVERROR(EINVAL);
-        goto finish;
-    }
-
-    if (!avci->compat_decode_partial_size) {
-        ret = avcodec_send_packet(avctx, pkt);
-        if (ret == AVERROR_EOF)
-            ret = 0;
-        else if (ret == AVERROR(EAGAIN)) {
-            /* we fully drain all the output in each decode call, so this should not
-             * ever happen */
-            ret = AVERROR_BUG;
-            goto finish;
-        } else if (ret < 0)
-            goto finish;
-    }
-
-    while (ret >= 0) {
-        ret = avcodec_receive_frame(avctx, frame);
-        if (ret < 0) {
-            if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
-                ret = 0;
-            goto finish;
-        }
-
-        if (frame != avci->compat_decode_frame) {
-            if (!avctx->refcounted_frames) {
-                ret = unrefcount_frame(avci, frame);
-                if (ret < 0)
-                    goto finish;
-            }
-
-            *got_frame = 1;
-            frame = avci->compat_decode_frame;
-        } else {
-            if (!avci->compat_decode_warned) {
-                av_log(avctx, AV_LOG_WARNING, "The deprecated avcodec_decode_* "
-                       "API cannot return all the frames for this decoder. "
-                       "Some frames will be dropped. Update your code to the "
-                       "new decoding API to fix this.\n");
-                avci->compat_decode_warned = 1;
-            }
-        }
-
-        if (avci->draining || (!avctx->codec->bsfs && avci->compat_decode_consumed < pkt->size))
-            break;
-    }
-
-finish:
-    if (ret == 0) {
-        /* if there are any bsfs then assume full packet is always consumed */
-        if (avctx->codec->bsfs)
-            ret = pkt->size;
-        else
-            ret = FFMIN(avci->compat_decode_consumed, pkt->size);
-    }
-    avci->compat_decode_consumed = 0;
-    avci->compat_decode_partial_size = (ret >= 0) ? pkt->size - ret : 0;
-
-    return ret;
-}
-
-int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
-                                              int *got_picture_ptr,
-                                              const AVPacket *avpkt)
-{
-    return compat_decode(avctx, picture, got_picture_ptr, avpkt);
-}
-
-int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx,
-                                              AVFrame *frame,
-                                              int *got_frame_ptr,
-                                              const AVPacket *avpkt)
-{
-    return compat_decode(avctx, frame, got_frame_ptr, avpkt);
-}
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-
 static void get_subtitle_defaults(AVSubtitle *sub)
 {
     memset(sub, 0, sizeof(*sub));
diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index cb4821066c..ba084d1f76 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -413,117 +413,6 @@ int attribute_align_arg avcodec_receive_packet(AVCodecContext *avctx, AVPacket *
     return 0;
 }
 
-#if FF_API_OLD_ENCDEC
-static int compat_encode(AVCodecContext *avctx, AVPacket *avpkt,
-                         int *got_packet, const AVFrame *frame)
-{
-    AVCodecInternal *avci = avctx->internal;
-    AVPacket user_pkt;
-    int ret;
-
-    *got_packet = 0;
-
-    if (frame && avctx->codec->type == AVMEDIA_TYPE_VIDEO) {
-        if (frame->format == AV_PIX_FMT_NONE)
-            av_log(avctx, AV_LOG_WARNING, "AVFrame.format is not set\n");
-        if (frame->width == 0 || frame->height == 0)
-            av_log(avctx, AV_LOG_WARNING, "AVFrame.width or height is not set\n");
-    }
-
-    if (avctx->codec->capabilities & AV_CODEC_CAP_DR1) {
-        av_log(avctx, AV_LOG_WARNING, "The deprecated avcodec_encode_* API does not support "
-                                      "AV_CODEC_CAP_DR1 encoders\n");
-        return AVERROR(ENOSYS);
-    }
-
-    ret = avcodec_send_frame(avctx, frame);
-    if (ret == AVERROR_EOF)
-        ret = 0;
-    else if (ret == AVERROR(EAGAIN)) {
-        /* we fully drain all the output in each encode call, so this should not
-         * ever happen */
-        return AVERROR_BUG;
-    } else if (ret < 0)
-        return ret;
-
-    av_packet_move_ref(&user_pkt, avpkt);
-    while (ret >= 0) {
-        ret = avcodec_receive_packet(avctx, avpkt);
-        if (ret < 0) {
-            if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
-                ret = 0;
-            goto finish;
-        }
-
-        if (avpkt != avci->compat_encode_packet) {
-            if (avpkt->data && user_pkt.data) {
-                if (user_pkt.size >= avpkt->size) {
-                    memcpy(user_pkt.data, avpkt->data, avpkt->size);
-                    av_buffer_unref(&avpkt->buf);
-                    avpkt->buf  = user_pkt.buf;
-                    avpkt->data = user_pkt.data;
-FF_DISABLE_DEPRECATION_WARNINGS
-                    av_init_packet(&user_pkt);
-FF_ENABLE_DEPRECATION_WARNINGS
-                } else {
-                    av_log(avctx, AV_LOG_ERROR, "Provided packet is too small, needs to be %d\n", avpkt->size);
-                    av_packet_unref(avpkt);
-                    ret = AVERROR(EINVAL);
-                    goto finish;
-                }
-            }
-
-            *got_packet = 1;
-            avpkt = avci->compat_encode_packet;
-        } else {
-            if (!avci->compat_decode_warned) {
-                av_log(avctx, AV_LOG_WARNING, "The deprecated avcodec_encode_* "
-                       "API cannot return all the packets for this encoder. "
-                       "Some packets will be dropped. Update your code to the "
-                       "new encoding API to fix this.\n");
-                avci->compat_decode_warned = 1;
-                av_packet_unref(avpkt);
-            }
-        }
-
-        if (avci->draining)
-            break;
-    }
-
-finish:
-    if (ret < 0)
-        av_packet_unref(&user_pkt);
-
-    return ret;
-}
-
-int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
-                                              AVPacket *avpkt,
-                                              const AVFrame *frame,
-                                              int *got_packet_ptr)
-{
-    int ret = compat_encode(avctx, avpkt, got_packet_ptr, frame);
-
-    if (ret < 0)
-        av_packet_unref(avpkt);
-
-    return ret;
-}
-
-int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx,
-                                              AVPacket *avpkt,
-                                              const AVFrame *frame,
-                                              int *got_packet_ptr)
-{
-    int ret = compat_encode(avctx, avpkt, got_packet_ptr, frame);
-
-    if (ret < 0)
-        av_packet_unref(avpkt);
-
-    return ret;
-}
-#endif
-
 int ff_encode_preinit(AVCodecContext *avctx)
 {
     int i;
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index b57b996816..b101f20c40 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -136,10 +136,6 @@ typedef struct AVCodecInternal {
      */
     int last_audio_frame;
 
-#if FF_API_OLD_ENCDEC
-    AVFrame *to_free;
-#endif
-
     AVBufferRef *pool;
 
     void *thread_ctx;
@@ -186,18 +182,6 @@ typedef struct AVCodecInternal {
     AVFrame *buffer_frame;
     int draining_done;
 
-#if FF_API_OLD_ENCDEC
-    int compat_decode_warned;
-    /* this variable is set by the decoder internals to signal to the old
-     * API compat wrappers the amount of data consumed from the last packet */
-    size_t compat_decode_consumed;
-    /* when a partial packet has been consumed, this stores the remaining size
-     * of the packet (that should be submitted in the next decode call */
-    size_t compat_decode_partial_size;
-    AVFrame *compat_decode_frame;
-    AVPacket *compat_encode_packet;
-#endif
-
     int showed_multi_packet_warning;
 
     int skip_samples_multiplier;
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 75e343838a..546d9c7929 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -137,7 +137,7 @@ typedef struct MpegEncContext {
     Picture **input_picture;   ///< next pictures on display order for encoding
     Picture **reordered_input_picture; ///< pointer to the next pictures in coded order for encoding
 
-    int64_t user_specified_pts; ///< last non-zero pts from AVFrame which was passed into avcodec_encode_video2()
+    int64_t user_specified_pts; ///< last non-zero pts from AVFrame which was passed into avcodec_send_frame()
     /**
      * pts difference between the first and second input frame, used for
      * calculating dts of the first frame when there's a delay */
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index 6ad54c2d67..ed428b1310 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -368,9 +368,6 @@ static const AVOption avcodec_options[] = {
 {"ignore",      NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_SUB_CHARENC_MODE_IGNORE},      INT_MIN, INT_MAX, S|D, "sub_charenc_mode"},
 {"sub_text_format", "set decoded text subtitle format", OFFSET(sub_text_format), AV_OPT_TYPE_INT, {.i64 = FF_SUB_TEXT_FMT_ASS}, 0, 1, S|D, "sub_text_format"},
 {"ass",              NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_SUB_TEXT_FMT_ASS},              INT_MIN, INT_MAX, S|D, "sub_text_format"},
-#if FF_API_OLD_ENCDEC
-{"refcounted_frames", NULL, OFFSET(refcounted_frames), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, A|V|D },
-#endif
 {"apply_cropping", NULL, OFFSET(apply_cropping), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, V | D },
 {"skip_alpha", "Skip processing alpha", OFFSET(skip_alpha), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, V|D },
 {"field_order", "Field order", OFFSET(field_order), AV_OPT_TYPE_INT, {.i64 = AV_FIELD_UNKNOWN }, 0, 5, V|D|E, "field_order" },
diff --git a/libavcodec/thread.h b/libavcodec/thread.h
index 413196269f..d7d2ddd8f1 100644
--- a/libavcodec/thread.h
+++ b/libavcodec/thread.h
@@ -52,10 +52,10 @@ void ff_thread_flush(AVCodecContext *avctx);
  * Returns the next available frame in picture. *got_picture_ptr
  * will be 0 if none is available.
  * The return value on success is the size of the consumed packet for
- * compatibility with avcodec_decode_video2(). This means the decoder
+ * compatibility with AVCodec.decode. This means the decoder
  * has to consume the full packet.
  *
- * Parameters are the same as avcodec_decode_video2().
+ * Parameters are the same as AVCodec.decode.
  */
 int ff_thread_decode_frame(AVCodecContext *avctx, AVFrame *picture,
                            int *got_picture_ptr, AVPacket *avpkt);
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 9e3181e810..75fde1f8c7 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -60,9 +60,6 @@
 #ifndef FF_API_UNUSED_CODEC_CAPS
 #define FF_API_UNUSED_CODEC_CAPS   (LIBAVCODEC_VERSION_MAJOR < 59)
 #endif
-#ifndef FF_API_OLD_ENCDEC
-#define FF_API_OLD_ENCDEC          (LIBAVCODEC_VERSION_MAJOR < 59)
-#endif
 #ifndef FF_API_THREAD_SAFE_CALLBACKS
 #define FF_API_THREAD_SAFE_CALLBACKS (LIBAVCODEC_VERSION_MAJOR < 60)
 #endif
diff --git a/libavcodec/x86/w64xmmtest.c b/libavcodec/x86/w64xmmtest.c
index d0782b9408..00b1a394d7 100644
--- a/libavcodec/x86/w64xmmtest.c
+++ b/libavcodec/x86/w64xmmtest.c
@@ -29,41 +29,6 @@ wrap(avcodec_open2(AVCodecContext *avctx,
     testxmmclobbers(avcodec_open2, avctx, codec, options);
 }
 
-#if FF_API_OLD_ENCDEC
-wrap(avcodec_decode_audio4(AVCodecContext *avctx,
-                           AVFrame *frame,
-                           int *got_frame_ptr,
-                           AVPacket *avpkt))
-{
-    testxmmclobbers(avcodec_decode_audio4, avctx, frame,
-                    got_frame_ptr, avpkt);
-}
-
-wrap(avcodec_decode_video2(AVCodecContext *avctx,
-                           AVFrame *picture,
-                           int *got_picture_ptr,
-                           AVPacket *avpkt))
-{
-    testxmmclobbers(avcodec_decode_video2, avctx, picture,
-                    got_picture_ptr, avpkt);
-}
-
-wrap(avcodec_encode_audio2(AVCodecContext *avctx,
-                           AVPacket *avpkt,
-                           const AVFrame *frame,
-                           int *got_packet_ptr))
-{
-    testxmmclobbers(avcodec_encode_audio2, avctx, avpkt, frame,
-                    got_packet_ptr);
-}
-
-wrap(avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt,
-                           const AVFrame *frame, int *got_packet_ptr))
-{
-    testxmmclobbers(avcodec_encode_video2, avctx, avpkt, frame, got_packet_ptr);
-}
-#endif
-
 wrap(avcodec_decode_subtitle2(AVCodecContext *avctx,
                               AVSubtitle *sub,
                               int *got_sub_ptr,
