avcodec/h264: finish previous slices before switching to single thread mode
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 7 Apr 2015 00:47:36 +0000 (02:47 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 7 Apr 2015 00:47:36 +0000 (02:47 +0200)
Fixes null pointer dereference
Fixes Ticket4438

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/h264.c

index 5dd187d..b4c4cd9 100644 (file)
@@ -1674,6 +1674,12 @@ again:
                     av_log(h->avctx, AV_LOG_ERROR, "decode_slice_header error\n");
                 sl->ref_count[0] = sl->ref_count[1] = sl->list_count = 0;
             } else if (err == SLICE_SINGLETHREAD) {
+                if (context_count > 1) {
+                    ret = ff_h264_execute_decode_slices(h, context_count - 1);
+                    if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
+                        goto end;
+                    context_count = 0;
+                }
                 /* Slice could not be decoded in parallel mode, restart. Note
                  * that rbsp_buffer is not transferred, but since we no longer
                  * run in parallel mode this should not be an issue. */