[FFmpeg-cvslog] 4xm: fold last_picture lazy allocation in decode_p_frame

Luca Barbato git at videolan.org
Thu Jun 13 12:16:57 CEST 2013


ffmpeg | branch: master | Luca Barbato <lu_zero at gentoo.org> | Wed Jun  5 20:30:48 2013 +0200| [50ec1db62d977b6e864f315a53c1c580a6d7efa4] | committer: Luca Barbato

4xm: fold last_picture lazy allocation in decode_p_frame

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

 libavcodec/4xm.c |   20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c
index 1002762..b09d19f 100644
--- a/libavcodec/4xm.c
+++ b/libavcodec/4xm.c
@@ -394,6 +394,17 @@ static int decode_p_frame(FourXContext *f, AVFrame *frame,
     uint16_t *src;
     unsigned int bitstream_size, bytestream_size, wordstream_size, extra,
                  bytestream_offset, wordstream_offset;
+    int ret;
+
+    if (!f->last_picture->data[0]) {
+        if ((ret = ff_get_buffer(f->avctx, f->last_picture,
+                                 AV_GET_BUFFER_FLAG_REF)) < 0) {
+            av_log(f->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
+            return ret;
+        }
+        memset(f->last_picture->data[0], 0,
+               f->avctx->height * FFABS(f->last_picture->linesize[0]));
+    }
 
     src = (uint16_t *)f->last_picture->data[0];
 
@@ -842,15 +853,6 @@ static int decode_frame(AVCodecContext *avctx, void *data,
         if ((ret = decode_i_frame(f, picture, buf, frame_size)) < 0)
             return ret;
     } else if (frame_4cc == AV_RL32("pfrm") || frame_4cc == AV_RL32("pfr2")) {
-        if (!f->last_picture->data[0]) {
-            if ((ret = ff_get_buffer(avctx, f->last_picture,
-                                     AV_GET_BUFFER_FLAG_REF)) < 0) {
-                av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
-                return ret;
-            }
-            memset(f->last_picture->data[0], 0, avctx->height * FFABS(f->last_picture->linesize[0]));
-        }
-
         picture->pict_type = AV_PICTURE_TYPE_P;
         if ((ret = decode_p_frame(f, picture, buf, frame_size)) < 0)
             return ret;



More information about the ffmpeg-cvslog mailing list