Demote method EncodedImage::capacity() to private.
Bug: webrtc:9378 Change-Id: I83be267334fc778aff4eb2ad128d3ed693f755ff Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/185007 Commit-Queue: Niels Moller <nisse@webrtc.org> Reviewed-by: Philip Eliasson <philipel@webrtc.org> Cr-Commit-Position: refs/heads/master@{#32177}
This commit is contained in:
@ -128,11 +128,6 @@ class RTC_EXPORT EncodedImage {
|
||||
RTC_DCHECK_LE(new_size, new_size == 0 ? 0 : capacity());
|
||||
size_ = new_size;
|
||||
}
|
||||
// TODO(nisse): Delete, provide only read-only access to the buffer.
|
||||
size_t capacity() const {
|
||||
return buffer_ ? capacity_ : (encoded_data_ ? encoded_data_->size() : 0);
|
||||
}
|
||||
|
||||
void SetEncodedData(
|
||||
rtc::scoped_refptr<EncodedImageBufferInterface> encoded_data) {
|
||||
encoded_data_ = encoded_data;
|
||||
@ -196,6 +191,10 @@ class RTC_EXPORT EncodedImage {
|
||||
} timing_;
|
||||
|
||||
private:
|
||||
size_t capacity() const {
|
||||
return buffer_ ? capacity_ : (encoded_data_ ? encoded_data_->size() : 0);
|
||||
}
|
||||
|
||||
// TODO(bugs.webrtc.org/9378): We're transitioning to always owning the
|
||||
// encoded data.
|
||||
rtc::scoped_refptr<EncodedImageBufferInterface> encoded_data_;
|
||||
|
@ -1484,7 +1484,6 @@ int VP9EncoderImpl::GetEncodedLayerFrame(const vpx_codec_cx_pkt* pkt) {
|
||||
encoded_image_._frameType = VideoFrameType::kVideoFrameKey;
|
||||
force_key_frame_ = false;
|
||||
}
|
||||
RTC_DCHECK_LE(encoded_image_.size(), encoded_image_.capacity());
|
||||
|
||||
codec_specific_ = {};
|
||||
absl::optional<int> spatial_index;
|
||||
|
@ -98,15 +98,16 @@ VCMFrameBufferEnum VCMFrameBuffer::InsertPacket(const VCMPacket& packet,
|
||||
}
|
||||
}
|
||||
|
||||
size_t oldSize = encoded_image_buffer_ ? encoded_image_buffer_->size() : 0;
|
||||
uint32_t requiredSizeBytes =
|
||||
size() + packet.sizeBytes +
|
||||
(packet.insertStartCode ? kH264StartCodeLengthBytes : 0);
|
||||
if (requiredSizeBytes > capacity()) {
|
||||
if (requiredSizeBytes > oldSize) {
|
||||
const uint8_t* prevBuffer = data();
|
||||
const uint32_t increments =
|
||||
requiredSizeBytes / kBufferIncStepSizeBytes +
|
||||
(requiredSizeBytes % kBufferIncStepSizeBytes > 0);
|
||||
const uint32_t newSize = capacity() + increments * kBufferIncStepSizeBytes;
|
||||
const uint32_t newSize = oldSize + increments * kBufferIncStepSizeBytes;
|
||||
if (newSize > kMaxJBFrameSizeBytes) {
|
||||
RTC_LOG(LS_ERROR) << "Failed to insert packet due to frame being too "
|
||||
"big.";
|
||||
|
@ -83,7 +83,7 @@ class SimulcastTestFixtureImpl::TestEncodedImageCallback
|
||||
if (encoded_image._frameType == VideoFrameType::kVideoFrameKey) {
|
||||
// TODO(nisse): Why not size() ?
|
||||
encoded_key_frame_.SetEncodedData(
|
||||
EncodedImageBuffer::Create(encoded_image.capacity()));
|
||||
EncodedImageBuffer::Create(encoded_image.size()));
|
||||
encoded_key_frame_.set_size(encoded_image.size());
|
||||
encoded_key_frame_._frameType = VideoFrameType::kVideoFrameKey;
|
||||
encoded_key_frame_._completeFrame = encoded_image._completeFrame;
|
||||
@ -91,7 +91,7 @@ class SimulcastTestFixtureImpl::TestEncodedImageCallback
|
||||
encoded_image.size());
|
||||
} else {
|
||||
encoded_frame_.SetEncodedData(
|
||||
EncodedImageBuffer::Create(encoded_image.capacity()));
|
||||
EncodedImageBuffer::Create(encoded_image.size()));
|
||||
encoded_frame_.set_size(encoded_image.size());
|
||||
memcpy(encoded_frame_.data(), encoded_image.data(),
|
||||
encoded_image.size());
|
||||
@ -873,9 +873,8 @@ void SimulcastTestFixtureImpl::TestDecodeWidthHeightSet() {
|
||||
EXPECT_EQ(encoded_image._frameType, VideoFrameType::kVideoFrameKey);
|
||||
|
||||
size_t index = encoded_image.SpatialIndex().value_or(0);
|
||||
// TODO(nisse): Why not size()
|
||||
encoded_frame[index].SetEncodedData(
|
||||
EncodedImageBuffer::Create(encoded_image.capacity()));
|
||||
EncodedImageBuffer::Create(encoded_image.size()));
|
||||
encoded_frame[index].set_size(encoded_image.size());
|
||||
encoded_frame[index]._frameType = encoded_image._frameType;
|
||||
encoded_frame[index]._completeFrame = encoded_image._completeFrame;
|
||||
|
@ -49,7 +49,6 @@ TEST(SingleProcessEncodedImageDataInjector, InjectExtractDiscardFalse) {
|
||||
EXPECT_EQ(out.id, 512);
|
||||
EXPECT_FALSE(out.discard);
|
||||
EXPECT_EQ(out.image.size(), 10ul);
|
||||
EXPECT_EQ(out.image.capacity(), 10ul);
|
||||
EXPECT_EQ(out.image.SpatialLayerFrameSize(0).value_or(0), 0ul);
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
EXPECT_EQ(out.image.data()[i], i + 1);
|
||||
@ -68,7 +67,6 @@ TEST(SingleProcessEncodedImageDataInjector, InjectExtractDiscardTrue) {
|
||||
EXPECT_EQ(out.id, 512);
|
||||
EXPECT_TRUE(out.discard);
|
||||
EXPECT_EQ(out.image.size(), 0ul);
|
||||
EXPECT_EQ(out.image.capacity(), 10ul);
|
||||
EXPECT_EQ(out.image.SpatialLayerFrameSize(0).value_or(0), 0ul);
|
||||
}
|
||||
|
||||
@ -86,7 +84,6 @@ TEST(SingleProcessEncodedImageDataInjector, InjectWithUnsetSpatialLayerSizes) {
|
||||
EXPECT_EQ(out.id, 512);
|
||||
EXPECT_FALSE(out.discard);
|
||||
EXPECT_EQ(out.image.size(), 10ul);
|
||||
EXPECT_EQ(out.image.capacity(), 10ul);
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
EXPECT_EQ(out.image.data()[i], i + 1);
|
||||
}
|
||||
@ -113,7 +110,6 @@ TEST(SingleProcessEncodedImageDataInjector, InjectWithZeroSpatialLayerSizes) {
|
||||
EXPECT_EQ(out.id, 512);
|
||||
EXPECT_FALSE(out.discard);
|
||||
EXPECT_EQ(out.image.size(), 10ul);
|
||||
EXPECT_EQ(out.image.capacity(), 10ul);
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
EXPECT_EQ(out.image.data()[i], i + 1);
|
||||
}
|
||||
@ -149,7 +145,6 @@ TEST(SingleProcessEncodedImageDataInjector, Inject3Extract3) {
|
||||
EXPECT_EQ(out1.id, 510);
|
||||
EXPECT_FALSE(out1.discard);
|
||||
EXPECT_EQ(out1.image.size(), 10ul);
|
||||
EXPECT_EQ(out1.image.capacity(), 10ul);
|
||||
EXPECT_EQ(out1.image.SpatialLayerFrameSize(0).value_or(0), 0ul);
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
EXPECT_EQ(out1.image.data()[i], i + 1);
|
||||
@ -157,12 +152,10 @@ TEST(SingleProcessEncodedImageDataInjector, Inject3Extract3) {
|
||||
EXPECT_EQ(out2.id, 520);
|
||||
EXPECT_TRUE(out2.discard);
|
||||
EXPECT_EQ(out2.image.size(), 0ul);
|
||||
EXPECT_EQ(out2.image.capacity(), 10ul);
|
||||
EXPECT_EQ(out2.image.SpatialLayerFrameSize(0).value_or(0), 0ul);
|
||||
EXPECT_EQ(out3.id, 520);
|
||||
EXPECT_FALSE(out3.discard);
|
||||
EXPECT_EQ(out3.image.size(), 10ul);
|
||||
EXPECT_EQ(out3.image.capacity(), 10ul);
|
||||
EXPECT_EQ(out3.image.SpatialLayerFrameSize(0).value_or(0), 0ul);
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
EXPECT_EQ(out3.image.data()[i], i + 21);
|
||||
@ -207,7 +200,6 @@ TEST(SingleProcessEncodedImageDataInjector, InjectExtractFromConcatenated) {
|
||||
EXPECT_EQ(out.id, 512);
|
||||
EXPECT_FALSE(out.discard);
|
||||
EXPECT_EQ(out.image.size(), 2 * 10ul);
|
||||
EXPECT_EQ(out.image.capacity(), 3 * 10ul);
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
EXPECT_EQ(out.image.data()[i], i + 1);
|
||||
EXPECT_EQ(out.image.data()[i + 10], i + 21);
|
||||
@ -258,7 +250,6 @@ TEST(SingleProcessEncodedImageDataInjector,
|
||||
EXPECT_EQ(out.id, 512);
|
||||
EXPECT_TRUE(out.discard);
|
||||
EXPECT_EQ(out.image.size(), 0ul);
|
||||
EXPECT_EQ(out.image.capacity(), 3 * 10ul);
|
||||
EXPECT_EQ(out.image.SpatialIndex().value_or(0), 2);
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
EXPECT_EQ(out.image.SpatialLayerFrameSize(i).value_or(0), 0ul);
|
||||
@ -279,7 +270,6 @@ TEST(SingleProcessEncodedImageDataInjector, InjectOnceExtractTwice) {
|
||||
EXPECT_EQ(out.id, 512);
|
||||
EXPECT_FALSE(out.discard);
|
||||
EXPECT_EQ(out.image.size(), 10ul);
|
||||
EXPECT_EQ(out.image.capacity(), 10ul);
|
||||
EXPECT_EQ(out.image.SpatialLayerFrameSize(0).value_or(0), 0ul);
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
EXPECT_EQ(out.image.data()[i], i + 1);
|
||||
@ -291,7 +281,6 @@ TEST(SingleProcessEncodedImageDataInjector, InjectOnceExtractTwice) {
|
||||
EXPECT_EQ(out.id, 512);
|
||||
EXPECT_FALSE(out.discard);
|
||||
EXPECT_EQ(out.image.size(), 10ul);
|
||||
EXPECT_EQ(out.image.capacity(), 10ul);
|
||||
EXPECT_EQ(out.image.SpatialLayerFrameSize(0).value_or(0), 0ul);
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
EXPECT_EQ(out.image.data()[i], i + 1);
|
||||
|
Reference in New Issue
Block a user