lavc/hevc: Allow arbitrary garbage in bytestream as long as at least one NAL unit...
authorMark Thompson <mrt@jkqxz.net>
Thu, 17 Mar 2016 13:41:02 +0000 (13:41 +0000)
committerMichael Niedermayer <michael@niedermayer.cc>
Sat, 19 Mar 2016 11:25:24 +0000 (12:25 +0100)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/hevc_parse.c

index 63ed84a..d557cc7 100644 (file)
@@ -232,8 +232,14 @@ int ff_hevc_split_packet(HEVCContext *s, HEVCPacket *pkt, const uint8_t *buf, in
                 ++buf;
                 --length;
                 if (length < 4) {
-                    av_log(avctx, AV_LOG_ERROR, "No start code is found.\n");
-                    return AVERROR_INVALIDDATA;
+                    if (pkt->nb_nals > 0) {
+                        // No more start codes: we discarded some irrelevant
+                        // bytes at the end of the packet.
+                        return 0;
+                    } else {
+                        av_log(avctx, AV_LOG_ERROR, "No start code is found.\n");
+                        return AVERROR_INVALIDDATA;
+                    }
                 }
             }