Hi,

See attached; fixes ticket #5344.

Thanks,

- Mark
>From fbc76e59225d2a6a0609119ca682d4886874705b Mon Sep 17 00:00:00 2001
From: Mark Thompson <m...@jkqxz.net>
Date: Wed, 16 Mar 2016 20:26:39 +0000
Subject: [PATCH] lavc/hevc: Allow arbitrarily many trailing_zero_8bits after a
 NAL unit in bytestream format.

---
 libavcodec/hevc_parse.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/libavcodec/hevc_parse.c b/libavcodec/hevc_parse.c
index 63ed84a..8c629ff 100644
--- a/libavcodec/hevc_parse.c
+++ b/libavcodec/hevc_parse.c
@@ -227,6 +227,20 @@ int ff_hevc_split_packet(HEVCContext *s, HEVCPacket *pkt, const uint8_t *buf, in
                 return AVERROR_INVALIDDATA;
             }
         } else {
+            if (pkt->nals > 0) {
+                // Discard arbtrarily many trailing_zero_8bits before the
+                // start code of the next NAL unit.
+                while (buf[0] == 0 && buf[1] == 0 && buf[2] == 0) {
+                    ++buf;
+                    --length;
+                    if (length < 4)
+                        break;
+                }
+                if (length < 4) {
+                    // There are only zeroes left, so no more NAL units here.
+                    break;
+                }
+            }
             /* search start code */
             while (buf[0] != 0 || buf[1] != 0 || buf[2] != 1) {
                 ++buf;
-- 
2.7.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to