| OLD | NEW |
| 1 // Copyright 2011 Google Inc. All Rights Reserved. | 1 // Copyright 2011 Google Inc. All Rights Reserved. |
| 2 // | 2 // |
| 3 // Use of this source code is governed by a BSD-style license | 3 // Use of this source code is governed by a BSD-style license |
| 4 // that can be found in the COPYING file in the root of the source | 4 // that can be found in the COPYING file in the root of the source |
| 5 // tree. An additional intellectual property rights grant can be found | 5 // tree. An additional intellectual property rights grant can be found |
| 6 // in the file PATENTS. All contributing project authors may | 6 // in the file PATENTS. All contributing project authors may |
| 7 // be found in the AUTHORS file in the root of the source tree. | 7 // be found in the AUTHORS file in the root of the source tree. |
| 8 // ----------------------------------------------------------------------------- | 8 // ----------------------------------------------------------------------------- |
| 9 // | 9 // |
| 10 // Bit writing and boolean coder | 10 // Bit writing and boolean coder |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 int VP8PutBitUniform(VP8BitWriter* const bw, int bit); | 47 int VP8PutBitUniform(VP8BitWriter* const bw, int bit); |
| 48 void VP8PutBits(VP8BitWriter* const bw, uint32_t value, int nb_bits); | 48 void VP8PutBits(VP8BitWriter* const bw, uint32_t value, int nb_bits); |
| 49 void VP8PutSignedBits(VP8BitWriter* const bw, int value, int nb_bits); | 49 void VP8PutSignedBits(VP8BitWriter* const bw, int value, int nb_bits); |
| 50 | 50 |
| 51 // Appends some bytes to the internal buffer. Data is copied. | 51 // Appends some bytes to the internal buffer. Data is copied. |
| 52 int VP8BitWriterAppend(VP8BitWriter* const bw, | 52 int VP8BitWriterAppend(VP8BitWriter* const bw, |
| 53 const uint8_t* data, size_t size); | 53 const uint8_t* data, size_t size); |
| 54 | 54 |
| 55 // return approximate write position (in bits) | 55 // return approximate write position (in bits) |
| 56 static WEBP_INLINE uint64_t VP8BitWriterPos(const VP8BitWriter* const bw) { | 56 static WEBP_INLINE uint64_t VP8BitWriterPos(const VP8BitWriter* const bw) { |
| 57 return (uint64_t)(bw->pos_ + bw->run_) * 8 + 8 + bw->nb_bits_; | 57 const uint64_t nb_bits = 8 + bw->nb_bits_; // bw->nb_bits_ is <= 0, note |
| 58 return (bw->pos_ + bw->run_) * 8 + nb_bits; |
| 58 } | 59 } |
| 59 | 60 |
| 60 // Returns a pointer to the internal buffer. | 61 // Returns a pointer to the internal buffer. |
| 61 static WEBP_INLINE uint8_t* VP8BitWriterBuf(const VP8BitWriter* const bw) { | 62 static WEBP_INLINE uint8_t* VP8BitWriterBuf(const VP8BitWriter* const bw) { |
| 62 return bw->buf_; | 63 return bw->buf_; |
| 63 } | 64 } |
| 64 // Returns the size of the internal buffer. | 65 // Returns the size of the internal buffer. |
| 65 static WEBP_INLINE size_t VP8BitWriterSize(const VP8BitWriter* const bw) { | 66 static WEBP_INLINE size_t VP8BitWriterSize(const VP8BitWriter* const bw) { |
| 66 return bw->pos_; | 67 return bw->pos_; |
| 67 } | 68 } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 } | 137 } |
| 137 } | 138 } |
| 138 | 139 |
| 139 //------------------------------------------------------------------------------ | 140 //------------------------------------------------------------------------------ |
| 140 | 141 |
| 141 #ifdef __cplusplus | 142 #ifdef __cplusplus |
| 142 } // extern "C" | 143 } // extern "C" |
| 143 #endif | 144 #endif |
| 144 | 145 |
| 145 #endif /* WEBP_UTILS_BIT_WRITER_H_ */ | 146 #endif /* WEBP_UTILS_BIT_WRITER_H_ */ |
| OLD | NEW |