summaryrefslogtreecommitdiff
path: root/libavcodec/utils.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2021-01-25 12:03:44 +0100
committerAnton Khirnov <anton@khirnov.net>2021-01-26 17:05:58 +0100
commit9e30859cb60b915f237581e3ce91b0d31592edc0 (patch)
tree273bc816c6712a7a32a16b4354d5880412ea2575 /libavcodec/utils.c
parent25f4304ebbf96c7ae2952d72b04ad244f8d96334 (diff)
lavc: shedule old encoding/decoding API for removal
It has been deprecated for 4 years and certain new codecs do not work with it. Also include AVCodecContext.refcounted_frames, as it has no effect with the new API.
Diffstat (limited to 'libavcodec/utils.c')
-rw-r--r--libavcodec/utils.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index aeb9c6de72..a1ae9cab18 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -580,18 +580,23 @@ 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();
avci->ds.in_pkt = av_packet_alloc();
avci->last_pkt_props = av_packet_alloc();
- if (!avci->compat_decode_frame || !avci->compat_encode_packet ||
- !avci->buffer_frame || !avci->buffer_pkt ||
+ if (!avci->buffer_frame || !avci->buffer_pkt ||
!avci->es.in_frame || !avci->ds.in_pkt ||
- !avci->to_free || !avci->last_pkt_props) {
+ !avci->last_pkt_props) {
ret = AVERROR(ENOMEM);
goto free_and_end;
}
@@ -1065,10 +1070,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
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_frame_free(&avci->buffer_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);
@@ -1106,8 +1113,10 @@ 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);
@@ -1128,8 +1137,12 @@ 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)
@@ -1169,10 +1182,12 @@ av_cold int avcodec_close(AVCodecContext *avctx)
avctx->codec->close(avctx);
avctx->internal->byte_buffer_size = 0;
av_freep(&avctx->internal->byte_buffer);
+#if FF_API_OLD_ENCDEC
av_frame_free(&avctx->internal->to_free);
av_frame_free(&avctx->internal->compat_decode_frame);
- av_frame_free(&avctx->internal->buffer_frame);
av_packet_free(&avctx->internal->compat_encode_packet);
+#endif
+ av_frame_free(&avctx->internal->buffer_frame);
av_packet_free(&avctx->internal->buffer_pkt);
av_packet_free(&avctx->internal->last_pkt_props);
avpriv_packet_list_free(&avctx->internal->pkt_props,