diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-10-27 11:29:09 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-10-27 11:29:37 +0100 |
commit | 10386710fd8eacd3ce5897d1ff4d7f14a3110028 (patch) | |
tree | 0d1a72bbb0c606a35cd8e2c3701d1ec006949ae6 /libavcodec/hevc.c | |
parent | 83d96e9a19ba1bd71b4380bad6f0947c6d4f97cc (diff) | |
parent | afa93d198aaf2cc661c4df6d4095cd030265d30a (diff) | |
download | ffmpeg-10386710fd8eacd3ce5897d1ff4d7f14a3110028.tar.gz |
Merge commit 'afa93d198aaf2cc661c4df6d4095cd030265d30a'
* commit 'afa93d198aaf2cc661c4df6d4095cd030265d30a':
hevc_parser: Set pict_type, key_frame and output_picture_number.
hevc: Search start code in decode_nal_units().
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/hevc.c')
-rw-r--r-- | libavcodec/hevc.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c index 4ea26bf825..47f3a0908e 100644 --- a/libavcodec/hevc.c +++ b/libavcodec/hevc.c @@ -2192,8 +2192,8 @@ static int decode_nal_unit(HEVCContext *s, const uint8_t *nal, int length) /* FIXME: This is adapted from ff_h264_decode_nal, avoiding duplication between these functions would be nice. */ -static int extract_rbsp(HEVCContext *s, const uint8_t *src, int length, - HEVCNAL *nal) +int ff_hevc_extract_rbsp(HEVCContext *s, const uint8_t *src, int length, + HEVCNAL *nal) { int i, si, di; uint8_t *dst; @@ -2279,7 +2279,8 @@ static int extract_rbsp(HEVCContext *s, const uint8_t *src, int length, if (!s->skipped_bytes_pos) return AVERROR(ENOMEM); } - s->skipped_bytes_pos[s->skipped_bytes-1] = di - 1; + if (s->skipped_bytes_pos) + s->skipped_bytes_pos[s->skipped_bytes-1] = di - 1; continue; } else // next start code goto nsc; @@ -2325,14 +2326,15 @@ static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length) goto fail; } } else { - if (buf[2] == 0) { - length--; - buf++; - continue; - } - if (buf[0] != 0 || buf[1] != 0 || buf[2] != 1) { - ret = AVERROR_INVALIDDATA; - goto fail; + /* search start code */ + while (buf[0] != 0 || buf[1] != 0 || buf[2] != 1) { + ++buf; + --length; + if (length < 4) { + av_log(s->avctx, AV_LOG_ERROR, "No start code is found.\n"); + ret = AVERROR_INVALIDDATA; + goto fail; + } } buf += 3; @@ -2362,7 +2364,7 @@ static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length) s->skipped_bytes_pos = s->skipped_bytes_pos_nal[s->nb_nals]; nal = &s->nals[s->nb_nals]; - consumed = extract_rbsp(s, buf, extract_length, nal); + consumed = ff_hevc_extract_rbsp(s, buf, extract_length, nal); s->skipped_bytes_nal[s->nb_nals] = s->skipped_bytes; s->skipped_bytes_pos_size_nal[s->nb_nals] = s->skipped_bytes_pos_size; |