Commit 3a727606 authored by Ivan's avatar Ivan Committed by Michael Niedermayer

avcodec/h264: Fix for H.264 configuration parsing

Sometimes video fails to decode if H.264 configuration changes mid stream.
The reason is that configuration parser assumes that nal_ref_idc is equal to 11b
while actually some codecs but 01b there. The H.264 spec is somewhat
vague about this but it looks like it allows any non-zero nal_ref_idc for sps/pps.
Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent b63ba3a5
...@@ -1781,7 +1781,7 @@ static int is_extra(const uint8_t *buf, int buf_size) ...@@ -1781,7 +1781,7 @@ static int is_extra(const uint8_t *buf, int buf_size)
const uint8_t *p= buf+6; const uint8_t *p= buf+6;
while(cnt--){ while(cnt--){
int nalsize= AV_RB16(p) + 2; int nalsize= AV_RB16(p) + 2;
if(nalsize > buf_size - (p-buf) || p[2]!=0x67) if(nalsize > buf_size - (p-buf) || (p[2] & 0x9F) != 7)
return 0; return 0;
p += nalsize; p += nalsize;
} }
...@@ -1790,7 +1790,7 @@ static int is_extra(const uint8_t *buf, int buf_size) ...@@ -1790,7 +1790,7 @@ static int is_extra(const uint8_t *buf, int buf_size)
return 0; return 0;
while(cnt--){ while(cnt--){
int nalsize= AV_RB16(p) + 2; int nalsize= AV_RB16(p) + 2;
if(nalsize > buf_size - (p-buf) || p[2]!=0x68) if(nalsize > buf_size - (p-buf) || (p[2] & 0x9F) != 8)
return 0; return 0;
p += nalsize; p += nalsize;
} }
......
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