[FFmpeg-cvslog] avcodec/extract_extradata_bsf: use the parsing code from vc1_split()

James Almer git at videolan.org
Sun Mar 26 04:39:43 EEST 2017


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Fri Mar 24 18:26:03 2017 -0300| [173fdc4dea1351a8de5e04a324ad7f0fcb1563ea] | committer: James Almer

avcodec/extract_extradata_bsf: use the parsing code from vc1_split()

It's a simplifaction of the same code, originally commited as b4b9a64bdb6.

Reviewed-by: Michael Niedermayer <michael at niedermayer.cc>
Signed-off-by: James Almer <jamrial at gmail.com>

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

 libavcodec/extract_extradata_bsf.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/libavcodec/extract_extradata_bsf.c b/libavcodec/extract_extradata_bsf.c
index d909ee6..447afb9 100644
--- a/libavcodec/extract_extradata_bsf.c
+++ b/libavcodec/extract_extradata_bsf.c
@@ -137,20 +137,16 @@ static int extract_extradata_vc1(AVBSFContext *ctx, AVPacket *pkt,
                                  uint8_t **data, int *size)
 {
     ExtractExtradataContext *s = ctx->priv_data;
+    const uint8_t *ptr = pkt->data, *end = pkt->data + pkt->size;
     uint32_t state = UINT32_MAX;
     int has_extradata = 0, extradata_size = 0;
-    int i;
 
-    for (i = 0; i < pkt->size; i++) {
-        state = (state << 8) | pkt->data[i];
-        if (IS_MARKER(state)) {
-            if (state == VC1_CODE_SEQHDR || state == VC1_CODE_ENTRYPOINT) {
-                has_extradata = 1;
-            } else if (has_extradata) {
-                extradata_size = i - 3;
-                break;
-            }
-        }
+    while (ptr < end) {
+        ptr = avpriv_find_start_code(ptr, end, &state);
+        if (state == VC1_CODE_SEQHDR || state == VC1_CODE_ENTRYPOINT) {
+            has_extradata = 1;
+        } else if (has_extradata && IS_MARKER(state))
+            extradata_size = ptr - 4 - pkt->data;
     }
 
     if (extradata_size) {



More information about the ffmpeg-cvslog mailing list