X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fparser.c;h=83019e74ebdae0930112c57f312aaa3d77ad0b58;hb=088dfd3ff15eba342863c74be53f7ca614957966;hp=aa25481ebc46ab44e281ba927ee00a6b510942a9;hpb=0afc26d330e6eff6221431bb93c69ed6bc6cc737;p=ffmpeg diff --git a/libavcodec/parser.c b/libavcodec/parser.c index aa25481ebc4..83019e74ebd 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; }