| 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 "base/logging.h" | 5 #include "base/logging.h" |
| 6 #include "media/filters/h264_bit_reader.h" | 6 #include "media/filters/h264_bit_reader.h" |
| 7 | 7 |
| 8 namespace media { | 8 namespace media { |
| 9 | 9 |
| 10 H264BitReader::H264BitReader() | 10 H264BitReader::H264BitReader() |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 | 49 |
| 50 if (bytes_left_ < 1) | 50 if (bytes_left_ < 1) |
| 51 return false; | 51 return false; |
| 52 } | 52 } |
| 53 | 53 |
| 54 // Load a new byte and advance pointers. | 54 // Load a new byte and advance pointers. |
| 55 curr_byte_ = *data_++ & 0xff; | 55 curr_byte_ = *data_++ & 0xff; |
| 56 --bytes_left_; | 56 --bytes_left_; |
| 57 num_remaining_bits_in_curr_byte_ = 8; | 57 num_remaining_bits_in_curr_byte_ = 8; |
| 58 | 58 |
| 59 prev_two_bytes_ = (prev_two_bytes_ << 8) | curr_byte_; | 59 prev_two_bytes_ = ((prev_two_bytes_ & 0xff) << 8) | curr_byte_; |
| 60 | 60 |
| 61 return true; | 61 return true; |
| 62 } | 62 } |
| 63 | 63 |
| 64 // Read |num_bits| (1 to 31 inclusive) from the stream and return them | 64 // Read |num_bits| (1 to 31 inclusive) from the stream and return them |
| 65 // in |out|, with first bit in the stream as MSB in |out| at position | 65 // in |out|, with first bit in the stream as MSB in |out| at position |
| 66 // (|num_bits| - 1). | 66 // (|num_bits| - 1). |
| 67 bool H264BitReader::ReadBits(int num_bits, int* out) { | 67 bool H264BitReader::ReadBits(int num_bits, int* out) { |
| 68 int bits_left = num_bits; | 68 int bits_left = num_bits; |
| 69 *out = 0; | 69 *out = 0; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 | 113 |
| 114 bytes_left_ = 0; | 114 bytes_left_ = 0; |
| 115 return false; | 115 return false; |
| 116 } | 116 } |
| 117 | 117 |
| 118 size_t H264BitReader::NumEmulationPreventionBytesRead() { | 118 size_t H264BitReader::NumEmulationPreventionBytesRead() { |
| 119 return emulation_prevention_bytes_; | 119 return emulation_prevention_bytes_; |
| 120 } | 120 } |
| 121 | 121 |
| 122 } // namespace media | 122 } // namespace media |
| OLD | NEW |