[FFmpeg-cvslog] avcodec/h264: simplify find_start_code()

Michael Niedermayer git at videolan.org
Sat Nov 1 21:04:58 CET 2014


ffmpeg | branch: release/1.2 | Michael Niedermayer <michaelni at gmx.at> | Mon Oct 27 04:24:20 2014 +0100| [aa9d70587150a004947e5cac9953e47f7eea87fa] | committer: Carl Eugen Hoyos

avcodec/h264: simplify find_start_code()

this also uses avpriv_find_start_code(), though no speed change is expected as
the area searched is generally small

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
(cherry picked from commit 3b678da5e386c138316954e867d595f946666051)

Conflicts:

	libavcodec/h264.h

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=aa9d70587150a004947e5cac9953e47f7eea87fa
---

 libavcodec/h264.h |   16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/libavcodec/h264.h b/libavcodec/h264.h
index dbbfba2..ab7ee5b 100644
--- a/libavcodec/h264.h
+++ b/libavcodec/h264.h
@@ -36,6 +36,7 @@
 #include "h264dsp.h"
 #include "h264pred.h"
 #include "h264qpel.h"
+#include "internal.h" // for avpriv_find_start_code()
 #include "rectangle.h"
 
 #define MAX_SPS_COUNT          32
@@ -972,20 +973,11 @@ static av_always_inline int get_dct8x8_allowed(H264Context *h)
 static inline int find_start_code(const uint8_t *buf, int buf_size,
                            int buf_index, int next_avc)
 {
-    // start code prefix search
-    for (; buf_index + 3 < next_avc; buf_index++)
-        // This should always succeed in the first iteration.
-        if (buf[buf_index]     == 0 &&
-            buf[buf_index + 1] == 0 &&
-            buf[buf_index + 2] == 1)
-            break;
+    uint32_t state = -1;
 
-    buf_index += 3;
+    buf_index = avpriv_find_start_code(buf + buf_index, buf + next_avc + 1, &state) - buf - 1;
 
-    if (buf_index >= buf_size)
-        return buf_size;
-
-    return buf_index;
+    return FFMIN(buf_index, buf_size);
 }
 
 static inline int get_avc_nalsize(H264Context *h, const uint8_t *buf,



More information about the ffmpeg-cvslog mailing list