diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index b65fdeb5e3203f93d290e79d1f109bff92ac3a1b..2b18b06f6999f1539e04e0e99a8cf9c4de296ee4 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -2727,7 +2727,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
             || s->avctx->bits_per_raw_sample != h->sps.bit_depth_luma
             || h->cur_chroma_format_idc != h->sps.chroma_format_idc
             || av_cmp_q(h->sps.sar, s->avctx->sample_aspect_ratio))) {
-        if(h != h0) {
+        if(h != h0 || (s->avctx->active_thread_type & FF_THREAD_FRAME)) {
             av_log_missing_feature(s->avctx, "Width/height/bit depth/chroma idc changing with threads is", 0);
             return -1;   // width / height changed during parallelized decoding
         }