Commit 62bd8dee authored by Rainer Hochecker's avatar Rainer Hochecker Committed by Michael Niedermayer

avcodec/hevc_parser: fix split function of parser

Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent b7baebb7
...@@ -410,19 +410,30 @@ static int hevc_split(AVCodecContext *avctx, const uint8_t *buf, int buf_size) ...@@ -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; const uint8_t *ptr = buf, *end = buf + buf_size;
uint32_t state = -1; 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) { while (ptr < end) {
ptr = avpriv_find_start_code(ptr, end, &state); ptr = avpriv_find_start_code(ptr, end, &state);
if ((state >> 8) != START_CODE) if ((state >> 8) != START_CODE)
break; break;
nut = (state >> 1) & 0x3F; nut = (state >> 1) & 0x3F;
if (nut >= NAL_VPS && nut <= NAL_PPS) if (nut == NAL_VPS)
has_ps = 1; has_vps = 1;
else if (has_ps) 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 ptr - 4 - buf;
else // no parameter set at the beginning of the stream }
return 0; }
} }
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment