1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-04 22:03:09 +02:00

avcodec/fic: Avoid implicit av_frame_free()+av_frame_alloc()

Use av_frame_replace() instead. Also remove the error message:
It was highly misleading (as if av_frame_clone() duplicated
the AVFrame data buffers instead of just creating a new reference).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt
2025-06-23 03:52:45 +02:00
parent 5d5e922088
commit d6986e1fcd

View File

@ -297,7 +297,7 @@ static int fic_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
/* Is it a skip frame? */ /* Is it a skip frame? */
if (src[17]) { if (src[17]) {
if (!ctx->final_frame) { if (!ctx->final_frame->data[0]) {
av_log(avctx, AV_LOG_WARNING, "Initial frame is skipped\n"); av_log(avctx, AV_LOG_WARNING, "Initial frame is skipped\n");
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
@ -416,12 +416,9 @@ static int fic_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
break; break;
} }
} }
av_frame_free(&ctx->final_frame); ret = av_frame_replace(ctx->final_frame, ctx->frame);
ctx->final_frame = av_frame_clone(ctx->frame); if (ret < 0)
if (!ctx->final_frame) { return ret;
av_log(avctx, AV_LOG_ERROR, "Could not clone frame buffer.\n");
return AVERROR(ENOMEM);
}
/* Make sure we use a user-supplied buffer. */ /* Make sure we use a user-supplied buffer. */
if ((ret = ff_reget_buffer(avctx, ctx->final_frame, 0)) < 0) { if ((ret = ff_reget_buffer(avctx, ctx->final_frame, 0)) < 0) {
@ -468,6 +465,9 @@ static av_cold int fic_decode_init(AVCodecContext *avctx)
ctx->frame = av_frame_alloc(); ctx->frame = av_frame_alloc();
if (!ctx->frame) if (!ctx->frame)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
ctx->final_frame = av_frame_alloc();
if (!ctx->final_frame)
return AVERROR(ENOMEM);
return 0; return 0;
} }
@ -495,4 +495,5 @@ const FFCodec ff_fic_decoder = {
.close = fic_decode_close, .close = fic_decode_close,
.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS,
.p.priv_class = &fic_decoder_class, .p.priv_class = &fic_decoder_class,
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
}; };