Mercurial > libavcodec.hg
comparison bitstream.h @ 2889:64231191674b libavcodec
precautionary checks
author | michael |
---|---|
date | Tue, 20 Sep 2005 18:51:12 +0000 |
parents | 5dfb90019814 |
children | 26f8974c3d66 |
comparison
equal
deleted
inserted
replaced
2888:771fae923356 | 2889:64231191674b |
---|---|
51 #endif | 51 #endif |
52 } PutBitContext; | 52 } PutBitContext; |
53 | 53 |
54 static inline void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size) | 54 static inline void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size) |
55 { | 55 { |
56 if(buffer_size < 0) | |
57 buffer= buffer_size= 0; | |
58 | |
56 s->buf = buffer; | 59 s->buf = buffer; |
57 s->buf_end = s->buf + buffer_size; | 60 s->buf_end = s->buf + buffer_size; |
58 #ifdef ALT_BITSTREAM_WRITER | 61 #ifdef ALT_BITSTREAM_WRITER |
59 s->index=0; | 62 s->index=0; |
60 ((uint32_t*)(s->buf))[0]=0; | 63 ((uint32_t*)(s->buf))[0]=0; |
670 * @param bit_size the size of the buffer in bits | 673 * @param bit_size the size of the buffer in bits |
671 */ | 674 */ |
672 static inline void init_get_bits(GetBitContext *s, | 675 static inline void init_get_bits(GetBitContext *s, |
673 const uint8_t *buffer, int bit_size) | 676 const uint8_t *buffer, int bit_size) |
674 { | 677 { |
675 const int buffer_size= (bit_size+7)>>3; | 678 int buffer_size= (bit_size+7)>>3; |
679 if(buffer_size < 0 || bit_size < 0) | |
680 buffer= buffer_size= bit_size= 0; | |
676 | 681 |
677 s->buffer= buffer; | 682 s->buffer= buffer; |
678 s->size_in_bits= bit_size; | 683 s->size_in_bits= bit_size; |
679 s->buffer_end= buffer + buffer_size; | 684 s->buffer_end= buffer + buffer_size; |
680 #ifdef ALT_BITSTREAM_READER | 685 #ifdef ALT_BITSTREAM_READER |