diff options
author | zhaoxiu.zeng <zhaoxiu.zeng@gmail.com> | 2015-03-10 00:57:57 +0800 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-03-09 18:19:10 +0100 |
commit | b3a56e60be30a7bcad203b52ee43cd4c698b4bd9 (patch) | |
tree | dac90cf9d3ee8418776d0fd71f4824c02e3f9377 /libavcodec | |
parent | 1f4088b28540080ce1d42345c5614be3e1a6a197 (diff) | |
download | ffmpeg-b3a56e60be30a7bcad203b52ee43cd4c698b4bd9.tar.gz |
avcodec/hevc_parser: use avpriv_find_start_code in hevc_split()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/hevc_parser.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/libavcodec/hevc_parser.c b/libavcodec/hevc_parser.c index a6fdbb722d..70768976b6 100644 --- a/libavcodec/hevc_parser.c +++ b/libavcodec/hevc_parser.c @@ -286,21 +286,21 @@ static int hevc_parse(AVCodecParserContext *s, // Split after the parameter sets at the beginning of the stream if they exist. static int hevc_split(AVCodecContext *avctx, const uint8_t *buf, int buf_size) { - int i; + const uint8_t *ptr = buf, *end = buf + buf_size; uint32_t state = -1; - int has_ps = 0; + int has_ps = 0, nut; - for (i = 0; i < buf_size; i++) { - state = (state << 8) | buf[i]; - if (((state >> 8) & 0xFFFFFF) == START_CODE) { - int nut = (state >> 1) & 0x3F; - if (nut >= NAL_VPS && nut <= NAL_PPS) - has_ps = 1; - else if (has_ps) - return i - 3; - else // no parameter set at the beginning of the stream - return 0; - } + while (ptr < end) { + ptr = avpriv_find_start_code(ptr, end, &state); + if ((state >> 8) != START_CODE) + break; + nut = (state >> 1) & 0x3F; + if (nut >= NAL_VPS && nut <= NAL_PPS) + has_ps = 1; + else if (has_ps) + return ptr - 4 - buf; + else // no parameter set at the beginning of the stream + return 0; } return 0; } |