| 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 #include "media/base/bit_reader_core.h" | 5 #include "media/base/bit_reader_core.h" |
| 6 | 6 |
| 7 #include <base/port.h> | 7 #include <base/port.h> |
| 8 #include <base/sys_byteorder.h> | 8 #include <base/sys_byteorder.h> |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 int BitReaderCore::PeekBitsMsbAligned(int num_bits, uint64* out) { | 45 int BitReaderCore::PeekBitsMsbAligned(int num_bits, uint64* out) { |
| 46 // Try to have at least |num_bits| in the bit register. | 46 // Try to have at least |num_bits| in the bit register. |
| 47 if (nbits_ < num_bits) | 47 if (nbits_ < num_bits) |
| 48 Refill(num_bits); | 48 Refill(num_bits); |
| 49 | 49 |
| 50 *out = reg_; | 50 *out = reg_; |
| 51 return nbits_; | 51 return nbits_; |
| 52 } | 52 } |
| 53 | 53 |
| 54 bool BitReaderCore::SkipBits(int num_bits) { | 54 bool BitReaderCore::SkipBits(int num_bits) { |
| 55 // TODO(dalecurtis): Rewrite to be efficient, see http://crbug.com/376450 |
| 55 DCHECK_GE(num_bits, 0); | 56 DCHECK_GE(num_bits, 0); |
| 56 DVLOG_IF(0, num_bits > 100) | 57 DVLOG_IF(1, num_bits > 100) |
| 57 << "BitReader::SkipBits inefficient for large skips"; | 58 << "BitReader::SkipBits inefficient for large skips"; |
| 58 | 59 |
| 59 uint64 dummy; | 60 uint64 dummy; |
| 60 while (num_bits >= kRegWidthInBits) { | 61 while (num_bits >= kRegWidthInBits) { |
| 61 if (!ReadBitsInternal(kRegWidthInBits, &dummy)) | 62 if (!ReadBitsInternal(kRegWidthInBits, &dummy)) |
| 62 return false; | 63 return false; |
| 63 num_bits -= kRegWidthInBits; | 64 num_bits -= kRegWidthInBits; |
| 64 } | 65 } |
| 65 return ReadBitsInternal(num_bits, &dummy); | 66 return ReadBitsInternal(num_bits, &dummy); |
| 66 } | 67 } |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 nbits_next_ = 0; | 151 nbits_next_ = 0; |
| 151 return; | 152 return; |
| 152 } | 153 } |
| 153 | 154 |
| 154 nbits_ += free_nbits; | 155 nbits_ += free_nbits; |
| 155 reg_next_ <<= free_nbits; | 156 reg_next_ <<= free_nbits; |
| 156 nbits_next_ -= free_nbits; | 157 nbits_next_ -= free_nbits; |
| 157 } | 158 } |
| 158 | 159 |
| 159 } // namespace media | 160 } // namespace media |
| OLD | NEW |