History

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).

Andreas Rheinhardt committed 1 year ago

Commit d6986e11 parent 5d5e9221 file · +8 −7Browse files

Showing the changes to libavcodec (1 of 1 file). Show all

Unified · Split

libavcodec/fic.c+8−7
@@ -297,7 +297,7 @@ static int fic_decode_frame(AVCodecContext *avctx, AVFrame *rframe, · 296 unmodified lines
297297
298298 /* Is it a skip frame? */
299299 if (src[17]) {
300− if (!ctx->final_frame) {
300+ if (!ctx->final_frame->data[0]) {
301301 av_log(avctx, AV_LOG_WARNING, "Initial frame is skipped\n");
302302 return AVERROR_INVALIDDATA;
303303 }
@@ -416,12 +416,9 @@ static int fic_decode_frame(AVCodecContext *avctx, AVFrame *rframe, · 112 unmodified lines
416416 break;
417417 }
418418 }
419− av_frame_free(&ctx->final_frame);
420− ctx->final_frame = av_frame_clone(ctx->frame);
421− if (!ctx->final_frame) {
422− av_log(avctx, AV_LOG_ERROR, "Could not clone frame buffer.\n");
423− return AVERROR(ENOMEM);
424− }
419+ ret = av_frame_replace(ctx->final_frame, ctx->frame);
420+ if (ret < 0)
421+ return ret;
425422
426423 /* Make sure we use a user-supplied buffer. */
427424 if ((ret = ff_reget_buffer(avctx, ctx->final_frame, 0)) < 0) {
@@ -468,6 +465,9 @@ static av_cold int fic_decode_init(AVCodecContext *avctx) · 40 unmodified lines
468465 ctx->frame = av_frame_alloc();
469466 if (!ctx->frame)
470467 return AVERROR(ENOMEM);
468+ ctx->final_frame = av_frame_alloc();
469+ if (!ctx->final_frame)
470+ return AVERROR(ENOMEM);
471471
472472 return 0;
473473 }
@@ -495,4 +495,5 @@ const FFCodec ff_fic_decoder = { · 21 unmodified lines
495495 .close = fic_decode_close,
496496 .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS,
497497 .p.priv_class = &fic_decoder_class,
498+ .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
498499 };

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t