diff options
author | Anton Khirnov <anton@khirnov.net> | 2015-04-06 20:05:37 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2015-04-29 05:52:57 +0200 |
commit | 54986d6db9116ef9704b1ce8414ffdb7f1ca127f (patch) | |
tree | 3354af123882dcd338a7f72a2d3f84e233c891c7 /libavcodec | |
parent | a6cd154463bea7eb56d28192db4c8c6d83f67fd7 (diff) | |
download | ffmpeg-54986d6db9116ef9704b1ce8414ffdb7f1ca127f.tar.gz |
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.
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/h264_slice.c | 39 |
1 files changed, 20 insertions, 19 deletions
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; |