[FFmpeg-devel] [PATCH 2/2] avcodec/vc1: simplify vc1_split()

zhaoxiu.zeng zhaoxiu.zeng at gmail.com
Thu Feb 12 17:03:21 CET 2015


>From 1a89b725e31e7567ade7563fc67ebc5d80a7c20c Mon Sep 17 00:00:00 2001
From: Zeng Zhaoxiu <zhaoxiu.zeng at gmail.com>
Date: Thu, 12 Feb 2015 23:30:08 +0800
Subject: [PATCH 2/2] avcodec/vc1: simplify vc1_split()

Signed-off-by: Zeng Zhaoxiu <zhaoxiu.zeng at gmail.com>
---
 libavcodec/vc1_parser.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/libavcodec/vc1_parser.c b/libavcodec/vc1_parser.c
index 3a2308e..748c6bb 100644
--- a/libavcodec/vc1_parser.c
+++ b/libavcodec/vc1_parser.c
@@ -29,6 +29,7 @@
 #include "parser.h"
 #include "vc1.h"
 #include "get_bits.h"
+#include "internal.h"
 
 /** The maximum number of bytes of a sequence, entry point or
  *  frame header whose values we pay any attention to */
@@ -250,20 +251,18 @@ static int vc1_parse(AVCodecParserContext *s,
 static int vc1_split(AVCodecContext *avctx,
                            const uint8_t *buf, int buf_size)
 {
-    int i;
-    uint32_t state= -1;
-    int charged=0;
+    uint32_t state = -1;
+    int charged = 0;
+    const uint8_t *ptr = buf, *end = buf + buf_size;
 
-    for(i=0; i<buf_size; i++){
-        state= (state<<8) | buf[i];
-        if(IS_MARKER(state)){
-            if(state == VC1_CODE_SEQHDR || state == VC1_CODE_ENTRYPOINT){
-                charged=1;
-            }else if(charged){
-                return i-3;
-            }
-        }
+    while (ptr < end) {
+        ptr = avpriv_find_start_code(ptr, end, &state);
+        if (state == VC1_CODE_SEQHDR || state == VC1_CODE_ENTRYPOINT)
+            charged = 1;
+        else if (charged && IS_MARKER(state))
+            return ptr - 4 - buf;
     }
+
     return 0;
 }
 
-- 
2.1.0



More information about the ffmpeg-devel mailing list