mirror of
https://github.com/nyanmisaka/ffmpeg-rockchip.git
synced 2025-10-17 14:24:26 +08:00
lavc/avcodec: only allocate the encoding frame for encoders
And only when needed, i.e. for encoders using the simple API.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user