Browse Source

h264: avoid stuck buffer pointer in decode_nal_units

When decode_nal_units() previously encountered a NAL_END_SEQUENCE,
and there are some junk bytes left in the input buffer, but no start codes,
buf_index gets stuck 3 bytes before the end of the buffer.

This can trigger an infinite loop in the caller code, eg. in
try_decode_trame(), as avcodec_decode_video() then keeps returning zeroes,
with 3 bytes of the input packet still available.

With this change, the remaining bytes are skipped so the whole packet gets
consumed.

CC:libav-stable@libav.org

Signed-off-by: Jindřich Makovička <makovick@gmail.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
(cherry picked from commit 1a8c6917f6)

Conflicts:

	libavcodec/h264.c
tags/n0.10.6
Jindřich Makovička Reinhard Tartler 13 years ago
parent
commit
9822e3aa52
1 changed files with 5 additions and 1 deletions
  1. +5
    -1
      libavcodec/h264.c

+ 5
- 1
libavcodec/h264.c View File

@@ -3875,7 +3875,11 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){
break;
}

if(buf_index+3 >= buf_size) break;

if (buf_index + 3 >= buf_size) {
buf_index = buf_size;
break;
}

buf_index+=3;
if(buf_index >= next_avc) continue;


Loading…
Cancel
Save