[FFmpeg-cvslog] avcodec/h264: Fix for H.264 configuration parsing

Ivan git at videolan.org
Sun May 1 05:13:51 CEST 2016


ffmpeg | branch: release/2.5 | Ivan <grigoriev.ivan.a at gmail.com> | Tue Apr 12 16:32:04 2016 -0400| [2bb9f5d6074a08c9b7c1567c463e6cc3cdf2b450] | committer: 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: Michael Niedermayer <michael at niedermayer.cc>
(cherry picked from commit 3a727606c474d3d0b9efa3c900294a84bdb5e331)

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2bb9f5d6074a08c9b7c1567c463e6cc3cdf2b450
---

 libavcodec/h264.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 436a079..ba3d910 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -1821,7 +1821,7 @@ static int is_extra(const uint8_t *buf, int buf_size)
     const uint8_t *p= buf+6;
     while(cnt--){
         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;
         p += nalsize;
     }
@@ -1830,7 +1830,7 @@ static int is_extra(const uint8_t *buf, int buf_size)
         return 0;
     while(cnt--){
         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;
         p += nalsize;
     }



More information about the ffmpeg-cvslog mailing list