diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2015-04-29 12:48:39 +0300 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-04-29 12:48:39 +0300 |
commit | cd63252f1ff61d894a1c3a59fee7d1e49dbfdeb4 (patch) | |
tree | 55dbcca36fb0ff5debc922d1ac185d4b6f1dcf5b /libavcodec/h264.c | |
parent | e8a460672f7e9aec129a7cfa01345857b1565a15 (diff) | |
parent | a6cd154463bea7eb56d28192db4c8c6d83f67fd7 (diff) |
Merge commit 'a6cd154463bea7eb56d28192db4c8c6d83f67fd7'
* commit 'a6cd154463bea7eb56d28192db4c8c6d83f67fd7':
h264: move the DPB init/uninit to init_context()/free_context()
Conflicts:
libavcodec/h264.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/h264.c')
-rw-r--r-- | libavcodec/h264.c | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c index bf82500ca2..e2a2aec0be 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -375,15 +375,6 @@ void ff_h264_free_tables(H264Context *h, int free_rbsp) av_buffer_pool_uninit(&h->motion_val_pool); av_buffer_pool_uninit(&h->ref_index_pool); - if (free_rbsp && h->DPB) { - for (i = 0; i < H264_MAX_PICTURE_COUNT; i++) - ff_h264_unref_picture(h, &h->DPB[i]); - memset(h->delayed_pic, 0, sizeof(h->delayed_pic)); - av_freep(&h->DPB); - } - - h->cur_pic_ptr = NULL; - for (i = 0; i < h->nb_slice_ctx; i++) { H264SliceContext *sl = &h->slice_ctx[i]; @@ -413,7 +404,7 @@ int ff_h264_alloc_tables(H264Context *h) { const int big_mb_num = h->mb_stride * (h->mb_height + 1); const int row_mb_num = 2*h->mb_stride*FFMAX(h->avctx->thread_count, 1); - int x, y, i; + int x, y; FF_ALLOCZ_ARRAY_OR_GOTO(h->avctx, h->intra4x4_pred_mode, row_mb_num, 8 * sizeof(uint8_t), fail) @@ -459,15 +450,6 @@ int ff_h264_alloc_tables(H264Context *h) if (!h->dequant4_coeff[0]) ff_h264_init_dequant_tables(h); - if (!h->DPB) { - h->DPB = av_mallocz_array(H264_MAX_PICTURE_COUNT, sizeof(*h->DPB)); - if (!h->DPB) - goto fail; - for (i = 0; i < H264_MAX_PICTURE_COUNT; i++) - av_frame_unref(&h->DPB[i].f); - av_frame_unref(&h->cur_pic.f); - } - return 0; fail: @@ -644,6 +626,13 @@ 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); + for (i = 0; i < h->nb_slice_ctx; i++) h->slice_ctx[i].h264 = h; @@ -1914,6 +1903,15 @@ av_cold void ff_h264_free_context(H264Context *h) ff_h264_free_tables(h, 1); // FIXME cleanup init stuff perhaps + if (h->DPB) { + for (i = 0; i < H264_MAX_PICTURE_COUNT; i++) + ff_h264_unref_picture(h, &h->DPB[i]); + memset(h->delayed_pic, 0, sizeof(h->delayed_pic)); + av_freep(&h->DPB); + } + + h->cur_pic_ptr = NULL; + av_freep(&h->slice_ctx); h->nb_slice_ctx = 0; |