OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MEDIA_BASE_BIT_READER_CORE_H_ | 5 #ifndef MEDIA_BASE_BIT_READER_CORE_H_ |
6 #define MEDIA_BASE_BIT_READER_CORE_H_ | 6 #define MEDIA_BASE_BIT_READER_CORE_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "media/base/media_export.h" | 10 #include "media/base/media_export.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 // bits cannot be skipped (not enough bits in the stream), true otherwise. | 78 // bits cannot be skipped (not enough bits in the stream), true otherwise. |
79 // When return false, the stream will enter a state where further | 79 // When return false, the stream will enter a state where further |
80 // ReadBits/ReadFlag/SkipBits operations | 80 // ReadBits/ReadFlag/SkipBits operations |
81 // will always return false unless |num_bits| is 0. | 81 // will always return false unless |num_bits| is 0. |
82 bool SkipBits(int num_bits); | 82 bool SkipBits(int num_bits); |
83 | 83 |
84 // Returns the number of bits read so far. | 84 // Returns the number of bits read so far. |
85 int bits_read() const; | 85 int bits_read() const; |
86 | 86 |
87 private: | 87 private: |
| 88 // This function can skip any number of bits but is more efficient |
| 89 // for small numbers. Return false if the given number of bits cannot be |
| 90 // skipped (not enough bits in the stream), true otherwise. |
| 91 bool SkipBitsSmall(int num_bits); |
| 92 |
88 // Help function used by ReadBits to avoid inlining the bit reading logic. | 93 // Help function used by ReadBits to avoid inlining the bit reading logic. |
89 bool ReadBitsInternal(int num_bits, uint64* out); | 94 bool ReadBitsInternal(int num_bits, uint64* out); |
90 | 95 |
91 // Refill bit registers to have at least |min_nbits| bits available. | 96 // Refill bit registers to have at least |min_nbits| bits available. |
92 // Return true if the mininimum bit count condition is met after the refill. | 97 // Return true if the mininimum bit count condition is met after the refill. |
93 bool Refill(int min_nbits); | 98 bool Refill(int min_nbits); |
94 | 99 |
95 // Refill the current bit register from the next bit register. | 100 // Refill the current bit register from the next bit register. |
96 void RefillCurrentRegister(); | 101 void RefillCurrentRegister(); |
97 | 102 |
(...skipping 11 matching lines...) Expand all Loading... |
109 // Note: bits are consumed from MSB to LSB. | 114 // Note: bits are consumed from MSB to LSB. |
110 int nbits_next_; | 115 int nbits_next_; |
111 uint64 reg_next_; | 116 uint64 reg_next_; |
112 | 117 |
113 DISALLOW_COPY_AND_ASSIGN(BitReaderCore); | 118 DISALLOW_COPY_AND_ASSIGN(BitReaderCore); |
114 }; | 119 }; |
115 | 120 |
116 } // namespace media | 121 } // namespace media |
117 | 122 |
118 #endif // MEDIA_BASE_BIT_READER_CORE_H_ | 123 #endif // MEDIA_BASE_BIT_READER_CORE_H_ |
OLD | NEW |