From a6cd154463bea7eb56d28192db4c8c6d83f67fd7 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sun, 5 Apr 2015 20:51:00 +0200 Subject: h264: move the DPB init/uninit to init_context()/free_context() Currently, the DPB is initialized in alloc_tables() and uninitialized in free_tables(), but those functions manage frame size-dependent variables, so DPB management does not logically belong in there. Since we want the init/uninit to happen exactly once per the context lifetime, init_context()/free_context() are the proper place for this code. --- libavcodec/h264_slice.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'libavcodec/h264_slice.c') diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index d5b99ae817..01cfb9d06c 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -454,6 +454,7 @@ int ff_h264_update_thread_context(AVCodecContext *dst, if (!inited) { H264SliceContext *orig_slice_ctx = h->slice_ctx; + H264Picture *orig_DPB = h->DPB; for (i = 0; i < MAX_SPS_COUNT; i++) av_freep(h->sps_buffers + i); @@ -471,6 +472,7 @@ int ff_h264_update_thread_context(AVCodecContext *dst, h->cur_pic.tf.f = &h->cur_pic.f; h->slice_ctx = orig_slice_ctx; + h->DPB = orig_DPB; memset(&h->slice_ctx[0].er, 0, sizeof(h->slice_ctx[0].er)); memset(&h->slice_ctx[0].mb, 0, sizeof(h->slice_ctx[0].mb)); @@ -478,7 +480,6 @@ int ff_h264_update_thread_context(AVCodecContext *dst, memset(&h->slice_ctx[0].mb_padding, 0, sizeof(h->slice_ctx[0].mb_padding)); h->avctx = dst; - h->DPB = NULL; h->qscale_table_pool = NULL; h->mb_type_pool = NULL; h->ref_index_pool = NULL; -- cgit v1.2.3