You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-07-11 14:30:22 +02:00
avcodec/msrleenc: Check frame allocations/references
Also allocate the AVFrame during init and use av_frame_replace() to replace it later. Reviewed-by: Tomas Härdin <git@haerdin.se> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
@ -37,7 +37,13 @@ typedef struct MSRLEContext {
|
|||||||
|
|
||||||
static av_cold int msrle_encode_init(AVCodecContext *avctx)
|
static av_cold int msrle_encode_init(AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
|
MSRLEContext *s = avctx->priv_data;
|
||||||
|
|
||||||
avctx->bits_per_coded_sample = 8;
|
avctx->bits_per_coded_sample = 8;
|
||||||
|
s->last_frame = av_frame_alloc();
|
||||||
|
if (!s->last_frame)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,13 +271,7 @@ static int msrle_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
s->curframe = 0;
|
s->curframe = 0;
|
||||||
*got_packet = 1;
|
*got_packet = 1;
|
||||||
|
|
||||||
if (!s->last_frame)
|
return av_frame_replace(s->last_frame, pict);
|
||||||
s->last_frame = av_frame_alloc();
|
|
||||||
else
|
|
||||||
av_frame_unref(s->last_frame);
|
|
||||||
|
|
||||||
av_frame_ref(s->last_frame, pict);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int msrle_encode_close(AVCodecContext *avctx)
|
static int msrle_encode_close(AVCodecContext *avctx)
|
||||||
|
Reference in New Issue
Block a user