[SCM] libav/experimental: When dst_length == 0 bit_length has to be 0, too, but the current code still calls decode_rbsp_trailing() and therefore bit_length might get negative. Although the remaining code is able to handle a negative bit_length, avoid the calculation at all by setting bit_length to 0 for dst_length == 0. patch by Reinhard Nissl, rnissl gmx de

siretart at users.alioth.debian.org siretart at users.alioth.debian.org
Sun Jun 30 15:58:46 UTC 2013


The following commit has been merged in the experimental branch:
commit ad1ea1f1552d3fff4a6a77ced099305e4378ad84
Author: Reinhard Nissl <rnissl at gmx.de>
Date:   Mon Apr 9 14:10:07 2007 +0000

    When dst_length == 0 bit_length has to be 0, too, but the current code still
    calls decode_rbsp_trailing() and therefore bit_length might get negative.
    Although the remaining code is able to handle a negative bit_length, avoid
    the calculation at all by setting bit_length to 0 for dst_length == 0.
    patch by Reinhard Nissl, rnissl gmx de
    
    Originally committed as revision 8690 to svn://svn.ffmpeg.org/ffmpeg/trunk

diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 8675572..4fcdb75 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -8149,7 +8149,7 @@ static int decode_nal_units(H264Context *h, uint8_t *buf, int buf_size){
         }
         while(ptr[dst_length - 1] == 0 && dst_length > 0)
             dst_length--;
-        bit_length= 8*dst_length - decode_rbsp_trailing(h, ptr + dst_length - 1);
+        bit_length= !dst_length ? 0 : (8*dst_length - decode_rbsp_trailing(h, ptr + dst_length - 1));
 
         if(s->avctx->debug&FF_DEBUG_STARTCODE){
             av_log(h->s.avctx, AV_LOG_DEBUG, "NAL %d at %d/%d length %d\n", h->nal_unit_type, buf_index, buf_size, dst_length);

-- 
Libav/FFmpeg packaging



More information about the pkg-multimedia-commits mailing list