avcodec/hevcdec: decode at most one slice reporting being the first in the picture release/3.0
authorJames Almer <jamrial@gmail.com>
Mon, 18 Mar 2019 20:25:58 +0000 (17:25 -0300)
committerJames Almer <jamrial@gmail.com>
Thu, 21 Mar 2019 01:23:12 +0000 (22:23 -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>
(cherry picked from commit 70c8c8a818f39bc262565ec29fae2baffb3e1660)

libavcodec/hevc.c

index 2046267..7ece31f 100644 (file)
@@ -2781,6 +2781,10 @@ static int decode_nal_unit(HEVCContext *s, const HEVCNAL *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;
+            }
             ret = hevc_frame_start(s);
             if (ret < 0)
                 return ret;