[vlc-commits] packetizer: return annexb startcode up to end

Francois Cartegnie git at videolan.org
Thu Apr 12 10:45:56 CEST 2018


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Apr 11 18:29:22 2018 +0200| [42ab152c79863ef76f73abd5b4f89a26f1106a5a] | committer: Francois Cartegnie

packetizer: return annexb startcode up to end

fixes glitches on streams when startcode ends a packet
(mpegvideo + ps, probably others)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=42ab152c79863ef76f73abd5b4f89a26f1106a5a
---

 modules/packetizer/startcode_helper.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/modules/packetizer/startcode_helper.h b/modules/packetizer/startcode_helper.h
index 04d79a280b..136c384247 100644
--- a/modules/packetizer/startcode_helper.h
+++ b/modules/packetizer/startcode_helper.h
@@ -52,7 +52,7 @@ static inline const uint8_t * startcode_FindAnnexB_SSE2( const uint8_t *p, const
     /* First align to 16 */
     /* Skipping this step and doing unaligned loads isn't faster */
     const uint8_t *alignedend = p + 16 - ((intptr_t)p & 15);
-    for (end -= 3; p < alignedend && p < end; p++) {
+    for (end -= 3; p < alignedend && p <= end; p++) {
         if (p[0] == 0 && p[1] == 0 && p[2] == 1)
             return p;
     }
@@ -99,7 +99,7 @@ static inline const uint8_t * startcode_FindAnnexB_SSE2( const uint8_t *p, const
         }
     }
 
-    for (; p < end; p++) {
+    for (; p <= end; p++) {
         if (p[0] == 0 && p[1] == 0 && p[2] == 1)
             return p;
     }
@@ -121,7 +121,7 @@ static inline const uint8_t * startcode_FindAnnexB( const uint8_t *p, const uint
 #endif
     const uint8_t *a = p + 4 - ((intptr_t)p & 3);
 
-    for (end -= 3; p < a && p < end; p++) {
+    for (end -= 3; p < a && p <= end; p++) {
         if (p[0] == 0 && p[1] == 0 && p[2] == 1)
             return p;
     }
@@ -135,7 +135,7 @@ static inline const uint8_t * startcode_FindAnnexB( const uint8_t *p, const uint
         }
     }
 
-    for (end += 3; p < end; p++) {
+    for (end += 3; p <= end; p++) {
         if (p[0] == 0 && p[1] == 0 && p[2] == 1)
             return p;
     }



More information about the vlc-commits mailing list