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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
83 num_remaining_bits_in_curr_byte_ -= bits_left; | 83 num_remaining_bits_in_curr_byte_ -= bits_left; |
84 | 84 |
85 return true; | 85 return true; |
86 } | 86 } |
87 | 87 |
88 off_t H264BitReader::NumBitsLeft() { | 88 off_t H264BitReader::NumBitsLeft() { |
89 return (num_remaining_bits_in_curr_byte_ + bytes_left_ * 8); | 89 return (num_remaining_bits_in_curr_byte_ + bytes_left_ * 8); |
90 } | 90 } |
91 | 91 |
92 bool H264BitReader::HasMoreRBSPData() { | 92 bool H264BitReader::HasMoreRBSPData() { |
93 // Make sure we have more bits, if we are at 0 bits in current byte | 93 // Make sure we have more bits, if we are at 0 bits in current byte and |
94 // and updating current byte fails, we don't have more data anyway. | 94 // updating current byte fails, we don't have more data anyway. |
95 if (num_remaining_bits_in_curr_byte_ == 0 && !UpdateCurrByte()) | 95 if (num_remaining_bits_in_curr_byte_ == 0 && !UpdateCurrByte()) |
96 return false; | 96 return false; |
97 | 97 |
98 // On last byte? | 98 // If there is no more RBSP data, then |curr_byte_| contains the stop bit and |
99 if (bytes_left_) | 99 // zero padding. Check to see if there is other data instead. |
100 // (We don't actually check for the stop bit itself, instead treating the | |
101 // invalid case of all trailing zeros identically). | |
102 if ((curr_byte_ & ((1 << (num_remaining_bits_in_curr_byte_ - 1)) - 1)) != 0) | |
100 return true; | 103 return true; |
101 | 104 |
102 // Last byte, look for stop bit; | 105 // If there are remaining non-zero bytes, then there is more data. We don't |
103 // We have more RBSP data if the last non-zero bit we find is not the | 106 // handle emulation prevention sequences because it is non-sensical to use |
104 // first available bit. | 107 // them when there is no data. (At least for PPS NAL units, which is the only |
Pawel Osciak
2016/03/01 08:56:21
I would perhaps remove the comment in parenthesis,
sandersd (OOO until July 31)
2016/03/17 19:07:51
Done.
| |
105 return (curr_byte_ & | 108 // case currently considered.) |
106 ((1 << (num_remaining_bits_in_curr_byte_ - 1)) - 1)) != 0; | 109 if (bytes_left_) { |
Pawel Osciak
2016/03/01 08:56:21
This if could be dropped?
sandersd (OOO until July 31)
2016/03/17 19:07:51
Done.
| |
110 for (off_t i = 0; i < bytes_left_; i++) { | |
111 if (data_[i] != 0) | |
112 return true; | |
113 } | |
114 } | |
115 | |
116 bytes_left_ = 0; | |
117 return false; | |
107 } | 118 } |
108 | 119 |
109 size_t H264BitReader::NumEmulationPreventionBytesRead() { | 120 size_t H264BitReader::NumEmulationPreventionBytesRead() { |
110 return emulation_prevention_bytes_; | 121 return emulation_prevention_bytes_; |
111 } | 122 } |
112 | 123 |
113 } // namespace media | 124 } // namespace media |
OLD | NEW |