From 54986d6db9116ef9704b1ce8414ffdb7f1ca127f Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 6 Apr 2015 20:05:37 +0200 Subject: h264: move context reinit lower down in update_thread_context() It uses some fields from the SPS, which is not yet set where the reinit is called currently. --- libavcodec/h264_slice.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) (limited to 'libavcodec/h264_slice.c') diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index 01cfb9d06c..864ee980ef 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -414,7 +414,7 @@ int ff_h264_update_thread_context(AVCodecContext *dst, { H264Context *h = dst->priv_data, *h1 = src->priv_data; int inited = h->context_initialized, err = 0; - int context_reinitialized = 0; + int need_reinit = 0; int i, ret; if (dst == src || !h1->context_initialized) @@ -433,23 +433,7 @@ int ff_h264_update_thread_context(AVCodecContext *dst, * bit depth in h264_set_parameter_from_sps() uses it and sets it to * the current value */ h->avctx->bits_per_raw_sample = h->sps.bit_depth_luma; - - h->width = h1->width; - h->height = h1->height; - h->mb_height = h1->mb_height; - h->mb_width = h1->mb_width; - h->mb_num = h1->mb_num; - h->mb_stride = h1->mb_stride; - h->b_stride = h1->b_stride; - - if ((err = h264_slice_header_init(h, 1)) < 0) { - av_log(h->avctx, AV_LOG_ERROR, "h264_slice_header_init() failed"); - return err; - } - context_reinitialized = 1; - - /* copy block_offset since frame_start may not be called */ - memcpy(h->block_offset, h1->block_offset, sizeof(h->block_offset)); + need_reinit = 1; } if (!inited) { @@ -571,8 +555,25 @@ int ff_h264_update_thread_context(AVCodecContext *dst, h->last_slice_type = h1->last_slice_type; - if (context_reinitialized) + if (need_reinit) { + h->width = h1->width; + h->height = h1->height; + h->mb_height = h1->mb_height; + h->mb_width = h1->mb_width; + h->mb_num = h1->mb_num; + h->mb_stride = h1->mb_stride; + h->b_stride = h1->b_stride; + + if ((err = h264_slice_header_init(h, 1)) < 0) { + av_log(h->avctx, AV_LOG_ERROR, "h264_slice_header_init() failed"); + return err; + } + + /* copy block_offset since frame_start may not be called */ + memcpy(h->block_offset, h1->block_offset, sizeof(h->block_offset)); + ff_h264_set_parameter_from_sps(h); + } if (!h->cur_pic_ptr) return 0; -- cgit v1.2.3