summaryrefslogtreecommitdiff
path: root/libavcodec/hevc_parser.c
diff options
context:
space:
mode:
authorRainer Hochecker <fernetmenta@online.de>2015-09-01 16:27:02 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2015-09-02 02:48:43 +0200
commit62bd8deef9005dbc9750e3bdc12fbf9b50392adc (patch)
tree1b4bc5fb7e9a061d8e306429c3d3b53cb86bfece /libavcodec/hevc_parser.c
parentb7baebb754f548ccd106ebcacd09ffa289382fd4 (diff)
avcodec/hevc_parser: fix split function of parser
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/hevc_parser.c')
-rw-r--r--libavcodec/hevc_parser.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/libavcodec/hevc_parser.c b/libavcodec/hevc_parser.c
index f970de5474..35cace5e3c 100644
--- a/libavcodec/hevc_parser.c
+++ b/libavcodec/hevc_parser.c
@@ -410,19 +410,30 @@ static int hevc_split(AVCodecContext *avctx, const uint8_t *buf, int buf_size)
{
const uint8_t *ptr = buf, *end = buf + buf_size;
uint32_t state = -1;
- int has_ps = 0, nut;
+ int has_vps = 0;
+ int has_sps = 0;
+ int has_pps = 0;
+ int nut;
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;
+ if (nut == NAL_VPS)
+ has_vps = 1;
+ else if (nut == NAL_SPS)
+ has_sps = 1;
+ else if (nut == NAL_PPS)
+ has_pps = 1;
+ else if ((nut != NAL_SEI_PREFIX || has_pps) &&
+ nut != NAL_AUD) {
+ if (has_vps && has_sps) {
+ while (ptr - 4 > buf && ptr[-5] == 0)
+ ptr--;
+ return ptr - 4 - buf;
+ }
+ }
}
return 0;
}