]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/hevcdec: decode at most one slice reporting being the first in the picture
authorJames Almer <jamrial@gmail.com>
Mon, 18 Mar 2019 20:25:58 +0000 (17:25 -0300)
committerJames Almer <jamrial@gmail.com>
Wed, 20 Mar 2019 22:53:12 +0000 (19:53 -0300)
Fixes deadlocks when decoding packets containing more than one of the aforementioned
slices when using frame threads.

Tested-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
libavcodec/hevcdec.c

index 967f8f1def560c5c113f15f58c874ffe03ec2af1..86adab0ae12765a5500053978ac1dbc5137fd191 100644 (file)
@@ -2927,6 +2927,10 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal)
         }
 
         if (s->sh.first_slice_in_pic_flag) {
+            if (s->ref) {
+                av_log(s->avctx, AV_LOG_ERROR, "Two slices reporting being the first in the same frame.\n");
+                goto fail;
+            }
             if (s->max_ra == INT_MAX) {
                 if (s->nal_unit_type == HEVC_NAL_CRA_NUT || IS_BLA(s)) {
                     s->max_ra = s->poc;