Convert all webrtc code to not access EncodedImage::_size directly.
Read using capacity() method, write using set_buffer() method. This is a preparation for making the member private, and renaming it to capacity_. Bug: webrtc:9378 Change-Id: I2f96679d052a83fe81be40301bd9863c87074640 Reviewed-on: https://webrtc-review.googlesource.com/c/113520 Reviewed-by: Philip Eliasson <philipel@webrtc.org> Reviewed-by: Erik Språng <sprang@webrtc.org> Commit-Queue: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25934}
This commit is contained in:
@ -152,16 +152,17 @@ void VCMEncodedFrame::CopyCodecSpecific(const RTPVideoHeader* header) {
|
||||
}
|
||||
|
||||
void VCMEncodedFrame::VerifyAndAllocate(size_t minimumSize) {
|
||||
if (minimumSize > _size) {
|
||||
size_t old_capacity = capacity();
|
||||
if (minimumSize > old_capacity) {
|
||||
// create buffer of sufficient size
|
||||
uint8_t* newBuffer = new uint8_t[minimumSize];
|
||||
if (_buffer) {
|
||||
uint8_t* old_buffer = _buffer;
|
||||
|
||||
set_buffer(new uint8_t[minimumSize], minimumSize);
|
||||
if (old_buffer) {
|
||||
// copy old data
|
||||
memcpy(newBuffer, _buffer, _size);
|
||||
delete[] _buffer;
|
||||
memcpy(_buffer, old_buffer, old_capacity);
|
||||
delete[] old_buffer;
|
||||
}
|
||||
_buffer = newBuffer;
|
||||
_size = minimumSize;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user