diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index 10f4d77380..9cbe8d2966 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -1086,6 +1086,7 @@ static int h264_slice_header_init(H264Context *h) nb_slices = max_slices; } h->slice_context_count = nb_slices; + h->max_contexts = FFMIN(h->max_contexts, nb_slices); if (!HAVE_THREADS || !(h->avctx->active_thread_type & FF_THREAD_SLICE)) { ret = ff_h264_slice_context_init(h, &h->slice_ctx[0]);