[FFmpeg-cvslog] lavc: use AVFrame API properly in ff_reget_buffer()

Anton Khirnov git at videolan.org
Mon Feb 24 10:47:04 CET 2014


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Tue Feb 11 14:59:00 2014 +0100| [8feac29cc46270cc89d6016340e7bac780877131] | committer: Anton Khirnov

lavc: use AVFrame API properly in ff_reget_buffer()

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8feac29cc46270cc89d6016340e7bac780877131
---

 libavcodec/utils.c |   16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index b2b11ef..c88b346 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -754,7 +754,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 
 int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame)
 {
-    AVFrame tmp;
+    AVFrame *tmp;
     int ret;
 
     av_assert0(avctx->codec_type == AVMEDIA_TYPE_VIDEO);
@@ -768,18 +768,20 @@ int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame)
         return 0;
     }
 
-    av_frame_move_ref(&tmp, frame);
+    tmp = av_frame_alloc();
+    if (!tmp)
+        return AVERROR(ENOMEM);
+
+    av_frame_move_ref(tmp, frame);
 
     ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF);
     if (ret < 0) {
-        av_frame_unref(&tmp);
+        av_frame_free(&tmp);
         return ret;
     }
 
-    av_image_copy(frame->data, frame->linesize, tmp.data, tmp.linesize,
-                  frame->format, frame->width, frame->height);
-
-    av_frame_unref(&tmp);
+    av_frame_copy(frame, tmp);
+    av_frame_free(&tmp);
 
     return 0;
 }



More information about the ffmpeg-cvslog mailing list