diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2025-06-23 03:52:45 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2025-07-03 19:42:28 +0200 |
commit | d6986e1fcdb2456578d3bb5dc27bbf4a12a772a6 (patch) | |
tree | 1c361c3e546d9974be0ae55ca3443a2f44a05dca | |
parent | 5d5e922088fab4aa1329feaf9d9ad89519191f9f (diff) | |
download | ffmpeg-d6986e1fcdb2456578d3bb5dc27bbf4a12a772a6.tar.gz |
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>
-rw-r--r-- | libavcodec/fic.c | 15 |
1 files 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, }; |