Chromium Code Reviews| Index: media/filters/h264_bit_reader.cc |
| diff --git a/media/filters/h264_bit_reader.cc b/media/filters/h264_bit_reader.cc |
| index 8f7dda0324d7b05419bc26d66676074117aeb4a1..7437e1ad0185cddafd15a91d1899914a7d452c3b 100644 |
| --- a/media/filters/h264_bit_reader.cc |
| +++ b/media/filters/h264_bit_reader.cc |
| @@ -90,20 +90,31 @@ off_t H264BitReader::NumBitsLeft() { |
| } |
| bool H264BitReader::HasMoreRBSPData() { |
| - // Make sure we have more bits, if we are at 0 bits in current byte |
| - // and updating current byte fails, we don't have more data anyway. |
| + // Make sure we have more bits, if we are at 0 bits in current byte and |
| + // updating current byte fails, we don't have more data anyway. |
| if (num_remaining_bits_in_curr_byte_ == 0 && !UpdateCurrByte()) |
| return false; |
| - // On last byte? |
| - if (bytes_left_) |
| + // If there is no more RBSP data, then |curr_byte_| contains the stop bit and |
| + // zero padding. Check to see if there is other data instead. |
| + // (We don't actually check for the stop bit itself, instead treating the |
| + // invalid case of all trailing zeros identically). |
| + if ((curr_byte_ & ((1 << (num_remaining_bits_in_curr_byte_ - 1)) - 1)) != 0) |
| return true; |
| - // Last byte, look for stop bit; |
| - // We have more RBSP data if the last non-zero bit we find is not the |
| - // first available bit. |
| - return (curr_byte_ & |
| - ((1 << (num_remaining_bits_in_curr_byte_ - 1)) - 1)) != 0; |
| + // If there are remaining non-zero bytes, then there is more data. We don't |
| + // handle emulation prevention sequences because it is non-sensical to use |
| + // 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.
|
| + // case currently considered.) |
| + 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.
|
| + for (off_t i = 0; i < bytes_left_; i++) { |
| + if (data_[i] != 0) |
| + return true; |
| + } |
| + } |
| + |
| + bytes_left_ = 0; |
| + return false; |
| } |
| size_t H264BitReader::NumEmulationPreventionBytesRead() { |