OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 if ((unsigned_val & 1) == 0) { | 195 if ((unsigned_val & 1) == 0) { |
196 *val = -static_cast<int32_t>(unsigned_val / 2); | 196 *val = -static_cast<int32_t>(unsigned_val / 2); |
197 } else { | 197 } else { |
198 *val = (unsigned_val + 1) / 2; | 198 *val = (unsigned_val + 1) / 2; |
199 } | 199 } |
200 return true; | 200 return true; |
201 } | 201 } |
202 | 202 |
203 void BitBuffer::GetCurrentOffset( | 203 void BitBuffer::GetCurrentOffset( |
204 size_t* out_byte_offset, size_t* out_bit_offset) { | 204 size_t* out_byte_offset, size_t* out_bit_offset) { |
205 RTC_CHECK(out_byte_offset != NULL); | 205 RTC_CHECK(out_byte_offset != nullptr); |
206 RTC_CHECK(out_bit_offset != NULL); | 206 RTC_CHECK(out_bit_offset != nullptr); |
207 *out_byte_offset = byte_offset_; | 207 *out_byte_offset = byte_offset_; |
208 *out_bit_offset = bit_offset_; | 208 *out_bit_offset = bit_offset_; |
209 } | 209 } |
210 | 210 |
211 bool BitBuffer::Seek(size_t byte_offset, size_t bit_offset) { | 211 bool BitBuffer::Seek(size_t byte_offset, size_t bit_offset) { |
212 if (byte_offset > byte_count_ || bit_offset > 7 || | 212 if (byte_offset > byte_count_ || bit_offset > 7 || |
213 (byte_offset == byte_count_ && bit_offset > 0)) { | 213 (byte_offset == byte_count_ && bit_offset > 0)) { |
214 return false; | 214 return false; |
215 } | 215 } |
216 byte_offset_ = byte_offset; | 216 byte_offset_ = byte_offset; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 return WriteExponentialGolomb((signed_val * 2) - 1); | 301 return WriteExponentialGolomb((signed_val * 2) - 1); |
302 } else { | 302 } else { |
303 if (val == std::numeric_limits<int32_t>::min()) | 303 if (val == std::numeric_limits<int32_t>::min()) |
304 return false; // Not supported, would cause overflow. | 304 return false; // Not supported, would cause overflow. |
305 uint32_t signed_val = -val; | 305 uint32_t signed_val = -val; |
306 return WriteExponentialGolomb(signed_val * 2); | 306 return WriteExponentialGolomb(signed_val * 2); |
307 } | 307 } |
308 } | 308 } |
309 | 309 |
310 } // namespace rtc | 310 } // namespace rtc |
OLD | NEW |