mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-05-17 15:08:09 +08:00
avcodec/svq1enc: Allocate buffers during init
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
@ -594,6 +594,15 @@ static av_cold int svq1_encode_init(AVCodecContext *avctx)
|
||||
if (!s->current_picture || !s->last_picture) {
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
ret = ff_encode_alloc_frame(avctx, s->current_picture);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
ret = ff_encode_alloc_frame(avctx, s->last_picture);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
s->scratchbuf = av_malloc_array(s->current_picture->linesize[0], 16 * 3);
|
||||
if (!s->scratchbuf)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
s->frame_width = avctx->width;
|
||||
s->frame_height = avctx->height;
|
||||
@ -644,22 +653,6 @@ static int svq1_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (!s->current_picture->data[0]) {
|
||||
if ((ret = ff_encode_alloc_frame(avctx, s->current_picture)) < 0) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
if (!s->last_picture->data[0]) {
|
||||
ret = ff_encode_alloc_frame(avctx, s->last_picture);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
if (!s->scratchbuf) {
|
||||
s->scratchbuf = av_malloc_array(s->current_picture->linesize[0], 16 * 3);
|
||||
if (!s->scratchbuf)
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
FFSWAP(AVFrame*, s->current_picture, s->last_picture);
|
||||
|
||||
if (avctx->gop_size && (avctx->frame_num % avctx->gop_size))
|
||||
|
Reference in New Issue
Block a user