comparison h264.c @ 4830:5a523aee7379 libavcodec

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
author diego
date Mon, 09 Apr 2007 14:10:07 +0000
parents e3161603a048
children 861ff463ac61
comparison
equal deleted inserted replaced
4829:e3161603a048 4830:5a523aee7379
8147 if (ptr==NULL || dst_length < 0){ 8147 if (ptr==NULL || dst_length < 0){
8148 return -1; 8148 return -1;
8149 } 8149 }
8150 while(ptr[dst_length - 1] == 0 && dst_length > 0) 8150 while(ptr[dst_length - 1] == 0 && dst_length > 0)
8151 dst_length--; 8151 dst_length--;
8152 bit_length= 8*dst_length - decode_rbsp_trailing(h, ptr + dst_length - 1); 8152 bit_length= !dst_length ? 0 : (8*dst_length - decode_rbsp_trailing(h, ptr + dst_length - 1));
8153 8153
8154 if(s->avctx->debug&FF_DEBUG_STARTCODE){ 8154 if(s->avctx->debug&FF_DEBUG_STARTCODE){
8155 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); 8155 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);
8156 } 8156 }
8157 8157