| Index: webrtc/common_video/h264/h264_common.cc
|
| diff --git a/webrtc/common_video/h264/h264_common.cc b/webrtc/common_video/h264/h264_common.cc
|
| index a9cc6a25e62882e8619ed627aeb9cefee67e248f..b9e7d6757e4784694c703122f352b2575eeab298 100644
|
| --- a/webrtc/common_video/h264/h264_common.cc
|
| +++ b/webrtc/common_video/h264/h264_common.cc
|
| @@ -60,26 +60,27 @@ NaluType ParseNaluType(uint8_t data) {
|
| return static_cast<NaluType>(data & kNaluTypeMask);
|
| }
|
|
|
| -std::unique_ptr<rtc::Buffer> ParseRbsp(const uint8_t* data, size_t length) {
|
| - std::unique_ptr<rtc::Buffer> rbsp_buffer(new rtc::Buffer(0, length));
|
| - const char* sps_bytes = reinterpret_cast<const char*>(data);
|
| +std::vector<uint8_t> ParseRbsp(const uint8_t* data, size_t length) {
|
| + std::vector<uint8_t> out;
|
| + out.reserve(length);
|
| +
|
| for (size_t i = 0; i < length;) {
|
| // Be careful about over/underflow here. byte_length_ - 3 can underflow, and
|
| // i + 3 can overflow, but byte_length_ - i can't, because i < byte_length_
|
| // above, and that expression will produce the number of bytes left in
|
| // the stream including the byte at i.
|
| - if (length - i >= 3 && data[i] == 0 && data[i + 1] == 0 &&
|
| - data[i + 2] == 3) {
|
| - // Two rbsp bytes + the emulation byte.
|
| - rbsp_buffer->AppendData(sps_bytes + i, 2);
|
| - i += 3;
|
| + if (length - i >= 3 && !data[i] && !data[i + 1] && data[i + 2] == 3) {
|
| + // Two rbsp bytes.
|
| + out.push_back(data[i++]);
|
| + out.push_back(data[i++]);
|
| + // Skip the emulation byte.
|
| + i++;
|
| } else {
|
| // Single rbsp byte.
|
| - rbsp_buffer->AppendData(sps_bytes[i]);
|
| - ++i;
|
| + out.push_back(data[i++]);
|
| }
|
| }
|
| - return rbsp_buffer;
|
| + return out;
|
| }
|
|
|
| void WriteRbsp(const uint8_t* bytes, size_t length, rtc::Buffer* destination) {
|
|
|