Signed-off-by: Derek Buitenhuis <[email protected]>
---
 libavcodec/fic.c | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/libavcodec/fic.c b/libavcodec/fic.c
index 0f9f798..b2e18cd 100644
--- a/libavcodec/fic.c
+++ b/libavcodec/fic.c
@@ -270,6 +270,12 @@ static int fic_decode_frame(AVCodecContext *avctx, void 
*data,
         return ret;
     }
 
+    ctx->final_frame = data;
+    if ((ret = ff_get_buffer(avctx, ctx->final_frame, 0)) < 0) {
+        av_log(avctx, AV_LOG_ERROR, "COuld not allocate frame buffer.\n");
+        return ret;
+    }
+
     /* Header + at least one slice (4) */
     if (avpkt->size < FIC_HEADER_SIZE + 4) {
         av_log(avctx, AV_LOG_ERROR, "Frame data is too small.\n");
@@ -386,16 +392,8 @@ static int fic_decode_frame(AVCodecContext *avctx, void 
*data,
                               NULL, nslices, sizeof(ctx->slice_data[0]))) < 0)
         return ret;
 
-    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);
-    }
-
-    /* Make sure we use a user-supplied buffer. */
-    if ((ret = ff_reget_buffer(avctx, ctx->final_frame)) < 0) {
-        av_log(avctx, AV_LOG_ERROR, "Could not make frame writable.\n");
+    if ((ret = av_frame_copy(ctx->final_frame, ctx->frame)) < 0) {
+        av_log(avctx, AV_LOG_ERROR, "Could not copy frame to final buffer.\n");
         return ret;
     }
 
@@ -407,8 +405,6 @@ static int fic_decode_frame(AVCodecContext *avctx, void 
*data,
 
 skip:
     *got_frame = 1;
-    if ((ret = av_frame_ref(data, ctx->final_frame)) < 0)
-        return ret;
 
     return avpkt->size;
 }
@@ -418,7 +414,6 @@ static av_cold int fic_decode_close(AVCodecContext *avctx)
     FICContext *ctx = avctx->priv_data;
 
     av_freep(&ctx->slice_data);
-    av_frame_free(&ctx->final_frame);
     av_frame_free(&ctx->frame);
 
     return 0;
-- 
1.9.2

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to