| 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 "media/filters/h264_bitstream_buffer.h" | 5 #include "media/filters/h264_bitstream_buffer.h" |
| 6 | 6 |
| 7 #include "base/sys_byteorder.h" | 7 #include "base/sys_byteorder.h" |
| 8 | 8 |
| 9 namespace media { | 9 namespace media { |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 pos_ = 0; | 25 pos_ = 0; |
| 26 reg_ = 0; | 26 reg_ = 0; |
| 27 | 27 |
| 28 Grow(); | 28 Grow(); |
| 29 | 29 |
| 30 bits_left_in_reg_ = kRegBitSize; | 30 bits_left_in_reg_ = kRegBitSize; |
| 31 } | 31 } |
| 32 | 32 |
| 33 void H264BitstreamBuffer::Grow() { | 33 void H264BitstreamBuffer::Grow() { |
| 34 data_ = static_cast<uint8_t*>(realloc(data_, capacity_ + kGrowBytes)); | 34 data_ = static_cast<uint8_t*>(realloc(data_, capacity_ + kGrowBytes)); |
| 35 CHECK(data_) << "Failed growing the buffer"; | 35 // Failed growing the buffer |
| 36 CHECK(data_); |
| 36 capacity_ += kGrowBytes; | 37 capacity_ += kGrowBytes; |
| 37 } | 38 } |
| 38 | 39 |
| 39 void H264BitstreamBuffer::FlushReg() { | 40 void H264BitstreamBuffer::FlushReg() { |
| 40 // Flush all bytes that have at least one bit cached, but not more | 41 // Flush all bytes that have at least one bit cached, but not more |
| 41 // (on Flush(), reg_ may not be full). | 42 // (on Flush(), reg_ may not be full). |
| 42 size_t bits_in_reg = kRegBitSize - bits_left_in_reg_; | 43 size_t bits_in_reg = kRegBitSize - bits_left_in_reg_; |
| 43 if (bits_in_reg == 0) | 44 if (bits_in_reg == 0) |
| 44 return; | 45 return; |
| 45 | 46 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 } | 144 } |
| 144 | 145 |
| 145 uint8_t* H264BitstreamBuffer::data() { | 146 uint8_t* H264BitstreamBuffer::data() { |
| 146 DCHECK(data_); | 147 DCHECK(data_); |
| 147 DCHECK_FINISHED(); | 148 DCHECK_FINISHED(); |
| 148 | 149 |
| 149 return data_; | 150 return data_; |
| 150 } | 151 } |
| 151 | 152 |
| 152 } // namespace media | 153 } // namespace media |
| OLD | NEW |