summaryrefslogtreecommitdiff
path: root/libavcodec/parser.c
diff options
context:
space:
mode:
authorZhaoxiu Zeng <zhaoxiu.zeng@gmail.com>2015-02-13 13:50:23 +0800
committerMichael Niedermayer <michaelni@gmx.at>2015-02-14 14:54:39 +0100
commit3b5ad8fbf77a679279c382e3c677af2d45340472 (patch)
tree61c135ce20d4c0755ac5efdd610497c1e720c044 /libavcodec/parser.c
parentba22295e76f0cc97f6dcce32bc3ade9ad3ab822f (diff)
avcodec/parser: optimize ff_mpeg4video_split()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/parser.c')
-rw-r--r--libavcodec/parser.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/libavcodec/parser.c b/libavcodec/parser.c
index aa25481ebc..83019e74eb 100644
--- a/libavcodec/parser.c
+++ b/libavcodec/parser.c
@@ -28,6 +28,7 @@
#include "libavutil/mem.h"
#include "parser.h"
+#include "internal.h"
static AVCodecParser *av_first_parser = NULL;
@@ -308,13 +309,14 @@ void ff_parse_close(AVCodecParserContext *s)
int ff_mpeg4video_split(AVCodecContext *avctx, const uint8_t *buf, int buf_size)
{
- int i;
uint32_t state = -1;
+ const uint8_t *ptr = buf, *end = buf + buf_size;
- for (i = 0; i < buf_size; i++) {
- state = state << 8 | buf[i];
+ while (ptr < end) {
+ ptr = avpriv_find_start_code(ptr, end, &state);
if (state == 0x1B3 || state == 0x1B6)
- return i - 3;
+ return ptr - 4 - buf;
}
+
return 0;
}