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() |
11 : data_(NULL), | 11 : data_(NULL), |
12 bytes_left_(0), | 12 bytes_left_(0), |
13 curr_byte_(0), | 13 curr_byte_(0), |
14 num_remaining_bits_in_curr_byte_(0), | 14 num_remaining_bits_in_curr_byte_(0), |
15 prev_two_bytes_(0), | 15 prev_two_bytes_(0), |
16 emulation_prevention_bytes_(0) {} | 16 emulation_prevention_bytes_(0) {} |
17 | 17 |
18 H264BitReader::~H264BitReader() {} | 18 H264BitReader::~H264BitReader() {} |
19 | 19 |
20 bool H264BitReader::Initialize(const uint8* data, off_t size) { | 20 bool H264BitReader::Initialize(const uint8_t* data, off_t size) { |
21 DCHECK(data); | 21 DCHECK(data); |
22 | 22 |
23 if (size < 1) | 23 if (size < 1) |
24 return false; | 24 return false; |
25 | 25 |
26 data_ = data; | 26 data_ = data; |
27 bytes_left_ = size; | 27 bytes_left_ = size; |
28 num_remaining_bits_in_curr_byte_ = 0; | 28 num_remaining_bits_in_curr_byte_ = 0; |
29 // Initially set to 0xffff to accept all initial two-byte sequences. | 29 // Initially set to 0xffff to accept all initial two-byte sequences. |
30 prev_two_bytes_ = 0xffff; | 30 prev_two_bytes_ = 0xffff; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 // first available bit. | 104 // first available bit. |
105 return (curr_byte_ & | 105 return (curr_byte_ & |
106 ((1 << (num_remaining_bits_in_curr_byte_ - 1)) - 1)) != 0; | 106 ((1 << (num_remaining_bits_in_curr_byte_ - 1)) - 1)) != 0; |
107 } | 107 } |
108 | 108 |
109 size_t H264BitReader::NumEmulationPreventionBytesRead() { | 109 size_t H264BitReader::NumEmulationPreventionBytesRead() { |
110 return emulation_prevention_bytes_; | 110 return emulation_prevention_bytes_; |
111 } | 111 } |
112 | 112 |
113 } // namespace media | 113 } // namespace media |
OLD | NEW |