[FFmpeg-cvslog] avcodec/fic: Avoid implicit av_frame_free()+av_frame_alloc()
Andreas Rheinhardt
git at videolan.org
Thu Jul 3 21:17:02 EEST 2025
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Mon Jun 23 03:52:45 2025 +0200| [d6986e1fcdb2456578d3bb5dc27bbf4a12a772a6] | committer: Andreas Rheinhardt
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 at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d6986e1fcdb2456578d3bb5dc27bbf4a12a772a6
---
libavcodec/fic.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/libavcodec/fic.c b/libavcodec/fic.c
index a40fe1f27b..bf7b2ead2b 100644
--- a/libavcodec/fic.c
+++ b/libavcodec/fic.c
@@ -297,7 +297,7 @@ static int fic_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
/* Is it a skip frame? */
if (src[17]) {
- if (!ctx->final_frame) {
+ if (!ctx->final_frame->data[0]) {
av_log(avctx, AV_LOG_WARNING, "Initial frame is skipped\n");
return AVERROR_INVALIDDATA;
}
@@ -416,12 +416,9 @@ static int fic_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
break;
}
}
- av_frame_free(&ctx->final_frame);
- ctx->final_frame = av_frame_clone(ctx->frame);
- if (!ctx->final_frame) {
- av_log(avctx, AV_LOG_ERROR, "Could not clone frame buffer.\n");
- return AVERROR(ENOMEM);
- }
+ ret = av_frame_replace(ctx->final_frame, ctx->frame);
+ if (ret < 0)
+ return ret;
/* Make sure we use a user-supplied buffer. */
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();
if (!ctx->frame)
return AVERROR(ENOMEM);
+ ctx->final_frame = av_frame_alloc();
+ if (!ctx->final_frame)
+ return AVERROR(ENOMEM);
return 0;
}
@@ -495,4 +495,5 @@ const FFCodec ff_fic_decoder = {
.close = fic_decode_close,
.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS,
.p.priv_class = &fic_decoder_class,
+ .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
};
More information about the ffmpeg-cvslog
mailing list