avcodec/encode: restructure the old encode API

Following the same logic as 061a0c14bb, this commit turns the old encode API
into a wrapper for the new one.

Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
James Almer 2020-06-09 18:35:00 -03:00
parent 827d6fe73d
commit 93016f5d1d
3 changed files with 116 additions and 263 deletions

View file

@ -585,15 +585,16 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
avci->to_free = av_frame_alloc();
avci->compat_decode_frame = av_frame_alloc();
avci->compat_encode_packet = av_packet_alloc();
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->to_free || !avci->compat_decode_frame ||
if (!avci->compat_decode_frame || !avci->compat_encode_packet ||
!avci->buffer_frame || !avci->buffer_pkt ||
!avci->es.in_frame || !avci->ds.in_pkt ||
!avci->last_pkt_props) {
!avci->to_free || !avci->last_pkt_props) {
ret = AVERROR(ENOMEM);
goto free_and_end;
}
@ -1043,6 +1044,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
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);
av_packet_free(&avci->buffer_pkt);
av_packet_free(&avci->last_pkt_props);
@ -1082,6 +1084,7 @@ void avcodec_flush_buffers(AVCodecContext *avctx)
avci->nb_draining_errors = 0;
av_frame_unref(avci->buffer_frame);
av_frame_unref(avci->compat_decode_frame);
av_packet_unref(avci->compat_encode_packet);
av_packet_unref(avci->buffer_pkt);
av_frame_unref(avci->es.in_frame);
@ -1142,6 +1145,7 @@ av_cold int avcodec_close(AVCodecContext *avctx)
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);
av_packet_free(&avctx->internal->buffer_pkt);
av_packet_free(&avctx->internal->last_pkt_props);