mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-13 21:28:01 +02:00
avcodec/hevc_parser: use avpriv_find_start_code in hevc_split()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
1f4088b285
commit
b3a56e60be
@ -286,21 +286,21 @@ static int hevc_parse(AVCodecParserContext *s,
|
|||||||
// Split after the parameter sets at the beginning of the stream if they exist.
|
// 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)
|
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;
|
uint32_t state = -1;
|
||||||
int has_ps = 0;
|
int has_ps = 0, nut;
|
||||||
|
|
||||||
for (i = 0; i < buf_size; i++) {
|
while (ptr < end) {
|
||||||
state = (state << 8) | buf[i];
|
ptr = avpriv_find_start_code(ptr, end, &state);
|
||||||
if (((state >> 8) & 0xFFFFFF) == START_CODE) {
|
if ((state >> 8) != START_CODE)
|
||||||
int nut = (state >> 1) & 0x3F;
|
break;
|
||||||
if (nut >= NAL_VPS && nut <= NAL_PPS)
|
nut = (state >> 1) & 0x3F;
|
||||||
has_ps = 1;
|
if (nut >= NAL_VPS && nut <= NAL_PPS)
|
||||||
else if (has_ps)
|
has_ps = 1;
|
||||||
return i - 3;
|
else if (has_ps)
|
||||||
else // no parameter set at the beginning of the stream
|
return ptr - 4 - buf;
|
||||||
return 0;
|
else // no parameter set at the beginning of the stream
|
||||||
}
|
return 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user