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

Luca Barbato git at videolan.org
Tue Aug 27 15:59:04 CEST 2013


ffmpeg | branch: release/1.1 | Luca Barbato <lu_zero at gentoo.org> | Wed Jun  5 20:30:48 2013 +0200| [dac0d4f354fe5ae93910cc6b30df9b992cca6be0] | committer: Luca Barbato

4xm: fold last_picture lazy allocation in decode_p_frame

(cherry picked from commit 50ec1db62d977b6e864f315a53c1c580a6d7efa4)

Signed-off-by: Luca Barbato <lu_zero at gentoo.org>

Conflicts:
	libavcodec/4xm.c

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

 libavcodec/4xm.c |   18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c
index f0e1b48..ceaacee 100644
--- a/libavcodec/4xm.c
+++ b/libavcodec/4xm.c
@@ -395,6 +395,16 @@ static int decode_p_frame(FourXContext *f, const uint8_t *buf, int length)
     const int stride =             f->current_picture.linesize[0] >> 1;
     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)) < 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]));
+    }
 
     if (f->version > 1) {
         extra           = 20;
@@ -852,14 +862,6 @@ static int decode_frame(AVCodecContext *avctx, void *data,
         if (decode_i_frame(f, buf, frame_size) < 0)
             return -1;
     } else if (frame_4cc == AV_RL32("pfrm") || frame_4cc == AV_RL32("pfr2")) {
-        if (!f->last_picture.data[0]) {
-            f->last_picture.reference = 1;
-            if (ff_get_buffer(avctx, &f->last_picture) < 0) {
-                av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
-                return -1;
-            }
-            memset(f->last_picture.data[0], 0, avctx->height * FFABS(f->last_picture.linesize[0]));
-        }
 
         p->pict_type = AV_PICTURE_TYPE_P;
         if (decode_p_frame(f, buf, frame_size) < 0)



More information about the ffmpeg-cvslog mailing list