[FFmpeg-devel] [PATCH 8/8] avpriv_find_start_code(): reduce the number of iterations

Scott Theisen scott.the.elm at gmail.com
Tue Feb 1 23:20:56 EET 2022


by correctly starting with three new bytes on the next iteration,
instead of keeping byte p[-3] which is invalid, i.e. known to be 01
when it must be 00.
---
 libavcodec/utils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index b4c5fa5009..d485d0c96b 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -965,7 +965,7 @@ const uint8_t *avpriv_find_start_code(const uint8_t *av_restrict p,
         // i.e. p[-1] == 0 is equivalent to p[-1] < 1
 
         // UU UU 01
-        else if (p[-2] != 0) p += 2;    // we have UU YY 01, so increment by 2
+        else if (p[-2] != 0) p += 3;    // we have UU YY 01, so increment by 3
                                         // to start check over with 3 new bytes
         // UU 00 01
         else if (p[-3] != 0) p += 3;    // we have YY 00 01, so increment by 3
-- 
2.32.0



More information about the ffmpeg-devel mailing list