[FFmpeg-cvslog] h264: embed the DPB in the context

Anton Khirnov git at videolan.org
Wed Apr 29 15:36:35 CEST 2015


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Sun Apr 12 21:08:34 2015 +0200| [7a4f74eed51f914e9bbfebaffd4a92ac6791f819] | committer: Anton Khirnov

h264: embed the DPB in the context

It now has a fixed size and is initialized only once, so there is no
point in allocating it separately.

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

 libavcodec/h264.c |   15 ++++-----------
 libavcodec/h264.h |    2 +-
 2 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 20de325..2756edb 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -590,9 +590,6 @@ static int h264_init_context(AVCodecContext *avctx, H264Context *h)
         return AVERROR(ENOMEM);
     }
 
-    h->DPB = av_mallocz_array(H264_MAX_PICTURE_COUNT, sizeof(*h->DPB));
-    if (!h->DPB)
-        return AVERROR(ENOMEM);
     for (i = 0; i < H264_MAX_PICTURE_COUNT; i++)
         av_frame_unref(&h->DPB[i].f);
     av_frame_unref(&h->cur_pic.f);
@@ -1052,9 +1049,8 @@ static void flush_dpb(AVCodecContext *avctx)
 
     ff_h264_flush_change(h);
 
-    if (h->DPB)
-        for (i = 0; i < H264_MAX_PICTURE_COUNT; i++)
-            ff_h264_unref_picture(h, &h->DPB[i]);
+    for (i = 0; i < H264_MAX_PICTURE_COUNT; i++)
+        ff_h264_unref_picture(h, &h->DPB[i]);
     h->cur_pic_ptr = NULL;
     ff_h264_unref_picture(h, &h->cur_pic);
 
@@ -1698,11 +1694,8 @@ av_cold void ff_h264_free_context(H264Context *h)
 
     ff_h264_free_tables(h);
 
-    if (h->DPB) {
-        for (i = 0; i < H264_MAX_PICTURE_COUNT; i++)
-            ff_h264_unref_picture(h, &h->DPB[i]);
-        av_freep(&h->DPB);
-    }
+    for (i = 0; i < H264_MAX_PICTURE_COUNT; i++)
+        ff_h264_unref_picture(h, &h->DPB[i]);
 
     h->cur_pic_ptr = NULL;
 
diff --git a/libavcodec/h264.h b/libavcodec/h264.h
index ca26e61..635c4a4 100644
--- a/libavcodec/h264.h
+++ b/libavcodec/h264.h
@@ -468,7 +468,7 @@ typedef struct H264Context {
     H264QpelContext h264qpel;
     GetBitContext gb;
 
-    H264Picture *DPB;
+    H264Picture DPB[H264_MAX_PICTURE_COUNT];
     H264Picture *cur_pic_ptr;
     H264Picture cur_pic;
 



More information about the ffmpeg-cvslog mailing list