summaryrefslogtreecommitdiff
path: root/libavcodec/encode.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2022-03-23 14:17:57 +0100
committerAnton Khirnov <anton@khirnov.net>2022-04-13 12:14:08 +0200
commit1c01dca14471774b93a418127555d85ceb641333 (patch)
treea5a9037d3ae9b1abe19e6655f86c58fe2d61dd03 /libavcodec/encode.c
parent7efa6418b83ae123770c6930f492edb87cd19274 (diff)
lavc/avcodec: only allocate the encoding frame for encoders
And only when needed, i.e. for encoders using the simple API.
Diffstat (limited to 'libavcodec/encode.c')
-rw-r--r--libavcodec/encode.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 3891ebcc91..305b732b1c 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -412,6 +412,7 @@ int attribute_align_arg avcodec_receive_packet(AVCodecContext *avctx, AVPacket *
int ff_encode_preinit(AVCodecContext *avctx)
{
+ AVCodecInternal *avci = avctx->internal;
int i;
if (avctx->time_base.num <= 0 || avctx->time_base.den <= 0) {
@@ -563,5 +564,11 @@ FF_ENABLE_DEPRECATION_WARNINGS
if (avctx->codec_descriptor->props & AV_CODEC_PROP_INTRA_ONLY)
avctx->internal->intra_only_flag = AV_PKT_FLAG_KEY;
+ if (ffcodec(avctx->codec)->cb.encode) {
+ avci->es.in_frame = av_frame_alloc();
+ if (!avci->es.in_frame)
+ return AVERROR(ENOMEM);
+ }
+
return 0;
}