diff options
author | Martin Storsjö <martin@martin.st> | 2013-03-25 12:42:57 +0200 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2013-03-26 09:48:12 +0200 |
commit | 75644335b907919057960716508477239c26fed4 (patch) | |
tree | c5caa37705a00b1ecd01ac603d04e349844b58af /libavcodec/utils.c | |
parent | 613a37eca4c7b8eefceaa3e0231c23ad090ca94f (diff) | |
download | ffmpeg-75644335b907919057960716508477239c26fed4.tar.gz |
lavc: Move start code finding to utils.c
This allows dropping the mpegvideo dependency from a number of
components.
This also fixes standalone building of the h264 parser, which
was broken in 64e438697.
Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavcodec/utils.c')
-rw-r--r-- | libavcodec/utils.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c index e18f42d99a..d8ebda61dc 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -39,6 +39,7 @@ #include "avcodec.h" #include "dsputil.h" #include "libavutil/opt.h" +#include "mpegvideo.h" #include "thread.h" #include "internal.h" #include "bytestream.h" @@ -2197,3 +2198,36 @@ int avcodec_is_open(AVCodecContext *s) { return !!s->internal; } + +const uint8_t *avpriv_mpv_find_start_code(const uint8_t *restrict p, + const uint8_t *end, + uint32_t * restrict state) +{ + int i; + + assert(p <= end); + if (p >= end) + return end; + + for (i = 0; i < 3; i++) { + uint32_t tmp = *state << 8; + *state = tmp + *(p++); + if (tmp == 0x100 || p == end) + return p; + } + + while (p < end) { + if (p[-1] > 1 ) p += 3; + else if (p[-2] ) p += 2; + else if (p[-3]|(p[-1]-1)) p++; + else { + p++; + break; + } + } + + p = FFMIN(p, end) - 4; + *state = AV_RB32(p); + + return p + 4; +} |