diff mbox

[FFmpeg-devel] avcodec/hevcdec: decode at most one slice reporting being the first in the picture

Message ID 20190318203153.9220-1-jamrial@gmail.com
State Accepted
Commit 70c8c8a818f39bc262565ec29fae2baffb3e1660
Headers show

Commit Message

James Almer March 18, 2019, 8:31 p.m. UTC
Fixes deadlocks when decoding packets containing more than one of the aforementioned
slices when using frame threads.

Signed-off-by: James Almer <jamrial@gmail.com>
---
See the discussion in the http://ffmpeg.org/pipermail/ffmpeg-devel/2019-March/241192.html
thread.

Alternative fixes that don't discard the second slice in this scenario welcome.

 libavcodec/hevcdec.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Derek Buitenhuis March 20, 2019, 2:41 p.m. UTC | #1
On 18/03/2019 20:31, James Almer wrote:
> Fixes deadlocks when decoding packets containing more than one of the aforementioned
> slices when using frame threads.
> 
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---

If there are no other comments / objections, could this be pushed?

- Derek
James Almer March 20, 2019, 10:55 p.m. UTC | #2
On 3/20/2019 11:41 AM, Derek Buitenhuis wrote:
> On 18/03/2019 20:31, James Almer wrote:
>> Fixes deadlocks when decoding packets containing more than one of the aforementioned
>> slices when using frame threads.
>>
>> Signed-off-by: James Almer <jamrial@gmail.com>
>> ---
> 
> If there are no other comments / objections, could this be pushed?
> 
> - Derek

Pushed. It can always be reverted and a better fix committed.
diff mbox

Patch

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 967f8f1def..86adab0ae1 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -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;