Rename EncodedImage::_size to capacity_, make private.

Also adds a set_buffer method, as the only public setter for capacity_.

Bug: webrtc:9378
Change-Id: If0257c6d00bc8690f0428a3edc20b6da6dfa7119
Reviewed-on: https://webrtc-review.googlesource.com/c/112134
Commit-Queue: Niels Moller <nisse@webrtc.org>
Reviewed-by: Philip Eliasson <philipel@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25962}
This commit is contained in:
Niels Möller
2018-12-10 09:07:28 +01:00
committed by Commit Bot
parent 42e7033e09
commit a6fd5e4587
2 changed files with 7 additions and 7 deletions

View File

@ -31,8 +31,8 @@ EncodedImage::EncodedImage() : EncodedImage(nullptr, 0, 0) {}
EncodedImage::EncodedImage(const EncodedImage&) = default; EncodedImage::EncodedImage(const EncodedImage&) = default;
EncodedImage::EncodedImage(uint8_t* buffer, size_t length, size_t size) EncodedImage::EncodedImage(uint8_t* buffer, size_t length, size_t capacity)
: _buffer(buffer), _length(length), _size(size) {} : _buffer(buffer), _length(length), capacity_(capacity) {}
void EncodedImage::SetEncodeTime(int64_t encode_start_ms, void EncodedImage::SetEncodeTime(int64_t encode_start_ms,
int64_t encode_finish_ms) { int64_t encode_finish_ms) {

View File

@ -38,7 +38,7 @@ class RTC_EXPORT EncodedImage {
EncodedImage(); EncodedImage();
EncodedImage(const EncodedImage&); EncodedImage(const EncodedImage&);
EncodedImage(uint8_t* buffer, size_t length, size_t size); EncodedImage(uint8_t* buffer, size_t length, size_t capacity);
// TODO(nisse): Change style to timestamp(), set_timestamp(), for consistency // TODO(nisse): Change style to timestamp(), set_timestamp(), for consistency
// with the VideoFrame class. // with the VideoFrame class.
@ -69,14 +69,14 @@ class RTC_EXPORT EncodedImage {
size_t size() const { return _length; } size_t size() const { return _length; }
void set_size(size_t new_size) { void set_size(size_t new_size) {
RTC_DCHECK_LE(new_size, _size); RTC_DCHECK_LE(new_size, capacity_);
_length = new_size; _length = new_size;
} }
size_t capacity() const { return _size; } size_t capacity() const { return capacity_; }
void set_buffer(uint8_t* buffer, size_t capacity) { void set_buffer(uint8_t* buffer, size_t capacity) {
_buffer = buffer; _buffer = buffer;
_size = capacity; capacity_ = capacity;
} }
uint32_t _encodedWidth = 0; uint32_t _encodedWidth = 0;
@ -88,7 +88,6 @@ class RTC_EXPORT EncodedImage {
uint8_t* _buffer; uint8_t* _buffer;
// TODO(bugs.webrtc.org/9378): Rename to size_, capacity_ and make private. // TODO(bugs.webrtc.org/9378): Rename to size_, capacity_ and make private.
size_t _length; size_t _length;
size_t _size;
VideoRotation rotation_ = kVideoRotation_0; VideoRotation rotation_ = kVideoRotation_0;
VideoContentType content_type_ = VideoContentType::UNSPECIFIED; VideoContentType content_type_ = VideoContentType::UNSPECIFIED;
bool _completeFrame = false; bool _completeFrame = false;
@ -112,6 +111,7 @@ class RTC_EXPORT EncodedImage {
} timing_; } timing_;
private: private:
size_t capacity_; // Allocated size of _buffer.
uint32_t timestamp_rtp_ = 0; uint32_t timestamp_rtp_ = 0;
absl::optional<int> spatial_index_; absl::optional<int> spatial_index_;
absl::optional<webrtc::ColorSpace> color_space_; absl::optional<webrtc::ColorSpace> color_space_;