From 711a4f706d83100bfb945d620e5e95a05c40af4f Mon Sep 17 00:00:00 2001 From: Ilya Nikolaevskiy Date: Thu, 14 Oct 2021 10:48:58 +0200 Subject: [PATCH] Remove unused IXXXBuffer::PasteFrom Bug: webrtc:13262 Change-Id: Iac383ca5a30abd082eb93af8acdef40d6537ce7d Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/235202 Reviewed-by: Niels Moller Reviewed-by: Stefan Holmer Commit-Queue: Ilya Nikolaevskiy Cr-Commit-Position: refs/heads/main@{#35264} --- api/video/i010_buffer.cc | 31 ----------- api/video/i010_buffer.h | 6 --- api/video/i420_buffer.cc | 31 ----------- api/video/i420_buffer.h | 6 --- common_video/video_frame_unittest.cc | 78 ---------------------------- 5 files changed, 152 deletions(-) diff --git a/api/video/i010_buffer.cc b/api/video/i010_buffer.cc index 74d37d1b57..aeea0501cb 100644 --- a/api/video/i010_buffer.cc +++ b/api/video/i010_buffer.cc @@ -232,35 +232,4 @@ void I010Buffer::ScaleFrom(const I010BufferInterface& src) { CropAndScaleFrom(src, 0, 0, src.width(), src.height()); } -void I010Buffer::PasteFrom(const I010BufferInterface& picture, - int offset_col, - int offset_row) { - RTC_CHECK_LE(picture.width() + offset_col, width()); - RTC_CHECK_LE(picture.height() + offset_row, height()); - RTC_CHECK_GE(offset_col, 0); - RTC_CHECK_GE(offset_row, 0); - - // Pasted picture has to be aligned so subsumpled UV plane isn't corrupted. - RTC_CHECK(offset_col % 2 == 0); - RTC_CHECK(offset_row % 2 == 0); - RTC_CHECK(picture.width() % 2 == 0 || - picture.width() + offset_col == width()); - RTC_CHECK(picture.height() % 2 == 0 || - picture.height() + offset_row == height()); - - libyuv::CopyPlane_16(picture.DataY(), picture.StrideY(), - MutableDataY() + StrideY() * offset_row + offset_col, - StrideY(), picture.width(), picture.height()); - - libyuv::CopyPlane_16( - picture.DataU(), picture.StrideU(), - MutableDataU() + StrideU() * offset_row / 2 + offset_col / 2, StrideU(), - picture.width() / 2, picture.height() / 2); - - libyuv::CopyPlane_16( - picture.DataV(), picture.StrideV(), - MutableDataV() + StrideV() * offset_row / 2 + offset_col / 2, StrideV(), - picture.width() / 2, picture.height() / 2); -} - } // namespace webrtc diff --git a/api/video/i010_buffer.h b/api/video/i010_buffer.h index 776797521b..11e0879fec 100644 --- a/api/video/i010_buffer.h +++ b/api/video/i010_buffer.h @@ -66,12 +66,6 @@ class I010Buffer : public I010BufferInterface { // Scale all of `src` to the size of `this` buffer, with no cropping. void ScaleFrom(const I010BufferInterface& src); - // Pastes whole picture to canvas at (offset_row, offset_col). - // Offsets and picture dimensions must be even. - void PasteFrom(const I010BufferInterface& picture, - int offset_col, - int offset_row); - protected: I010Buffer(int width, int height, int stride_y, int stride_u, int stride_v); ~I010Buffer() override; diff --git a/api/video/i420_buffer.cc b/api/video/i420_buffer.cc index 8783a4a313..deecf1d71d 100644 --- a/api/video/i420_buffer.cc +++ b/api/video/i420_buffer.cc @@ -229,35 +229,4 @@ void I420Buffer::ScaleFrom(const I420BufferInterface& src) { CropAndScaleFrom(src, 0, 0, src.width(), src.height()); } -void I420Buffer::PasteFrom(const I420BufferInterface& picture, - int offset_col, - int offset_row) { - RTC_CHECK_LE(picture.width() + offset_col, width()); - RTC_CHECK_LE(picture.height() + offset_row, height()); - RTC_CHECK_GE(offset_col, 0); - RTC_CHECK_GE(offset_row, 0); - - // Pasted picture has to be aligned so subsumpled UV plane isn't corrupted. - RTC_CHECK(offset_col % 2 == 0); - RTC_CHECK(offset_row % 2 == 0); - RTC_CHECK(picture.width() % 2 == 0 || - picture.width() + offset_col == width()); - RTC_CHECK(picture.height() % 2 == 0 || - picture.height() + offset_row == height()); - - libyuv::CopyPlane(picture.DataY(), picture.StrideY(), - MutableDataY() + StrideY() * offset_row + offset_col, - StrideY(), picture.width(), picture.height()); - - libyuv::CopyPlane( - picture.DataU(), picture.StrideU(), - MutableDataU() + StrideU() * offset_row / 2 + offset_col / 2, StrideU(), - picture.width() / 2, picture.height() / 2); - - libyuv::CopyPlane( - picture.DataV(), picture.StrideV(), - MutableDataV() + StrideV() * offset_row / 2 + offset_col / 2, StrideV(), - picture.width() / 2, picture.height() / 2); -} - } // namespace webrtc diff --git a/api/video/i420_buffer.h b/api/video/i420_buffer.h index b60df09aba..af52c64fb4 100644 --- a/api/video/i420_buffer.h +++ b/api/video/i420_buffer.h @@ -98,12 +98,6 @@ class RTC_EXPORT I420Buffer : public I420BufferInterface { // Scale all of `src` to the size of `this` buffer, with no cropping. void ScaleFrom(const I420BufferInterface& src); - // Pastes whole picture to canvas at (offset_row, offset_col). - // Offsets and picture dimensions must be even. - void PasteFrom(const I420BufferInterface& picture, - int offset_col, - int offset_row); - protected: I420Buffer(int width, int height); I420Buffer(int width, int height, int stride_y, int stride_u, int stride_v); diff --git a/common_video/video_frame_unittest.cc b/common_video/video_frame_unittest.cc index b82c14716c..53a60e3eda 100644 --- a/common_video/video_frame_unittest.cc +++ b/common_video/video_frame_unittest.cc @@ -250,47 +250,6 @@ void CheckRotate(int width, } } -int GetU(rtc::scoped_refptr buf, int col, int row) { - if (buf->type() == VideoFrameBuffer::Type::kI420) { - return buf->GetI420() - ->DataU()[row / 2 * buf->GetI420()->StrideU() + col / 2]; - } else { - return buf->GetI010() - ->DataU()[row / 2 * buf->GetI010()->StrideU() + col / 2]; - } -} - -int GetV(rtc::scoped_refptr buf, int col, int row) { - if (buf->type() == VideoFrameBuffer::Type::kI420) { - return buf->GetI420() - ->DataV()[row / 2 * buf->GetI420()->StrideV() + col / 2]; - } else { - return buf->GetI010() - ->DataV()[row / 2 * buf->GetI010()->StrideV() + col / 2]; - } -} - -int GetY(rtc::scoped_refptr buf, int col, int row) { - if (buf->type() == VideoFrameBuffer::Type::kI420) { - return buf->GetI420()->DataY()[row * buf->GetI420()->StrideY() + col]; - } else { - return buf->GetI010()->DataY()[row * buf->GetI010()->StrideY() + col]; - } -} - -void PasteFromBuffer(PlanarYuvBuffer* canvas, - const PlanarYuvBuffer& picture, - int offset_col, - int offset_row) { - if (canvas->type() == VideoFrameBuffer::Type::kI420) { - I420Buffer* buf = static_cast(canvas); - buf->PasteFrom(*picture.GetI420(), offset_col, offset_row); - } else { - I010Buffer* buf = static_cast(canvas); - buf->PasteFrom(*picture.GetI010(), offset_col, offset_row); - } -} - } // namespace TEST(TestVideoFrame, WidthHeightValues) { @@ -476,43 +435,6 @@ TEST_P(TestPlanarYuvBuffer, CropAndScale16x9) { CheckCrop(*scaled_buffer->ToI420(), 0.0, 0.125, 1.0, 0.75); } -TEST_P(TestPlanarYuvBuffer, PastesIntoBuffer) { - const int kOffsetx = 20; - const int kOffsety = 30; - const int kPicSize = 20; - const int kWidth = 160; - const int kHeight = 80; - rtc::scoped_refptr buf = - CreateGradient(GetParam(), kWidth, kHeight); - - rtc::scoped_refptr original = - CreateGradient(GetParam(), kWidth, kHeight); - - rtc::scoped_refptr picture = - CreateGradient(GetParam(), kPicSize, kPicSize); - - rtc::scoped_refptr odd_picture = - CreateGradient(GetParam(), kPicSize + 1, kPicSize - 1); - - PasteFromBuffer(buf.get(), *picture, kOffsetx, kOffsety); - - for (int i = 0; i < kWidth; ++i) { - for (int j = 0; j < kHeight; ++j) { - bool is_inside = i >= kOffsetx && i < kOffsetx + kPicSize && - j >= kOffsety && j < kOffsety + kPicSize; - if (!is_inside) { - EXPECT_EQ(GetU(original, i, j), GetU(buf, i, j)); - EXPECT_EQ(GetV(original, i, j), GetV(buf, i, j)); - EXPECT_EQ(GetY(original, i, j), GetY(buf, i, j)); - } else { - EXPECT_EQ(GetU(picture, i - kOffsetx, j - kOffsety), GetU(buf, i, j)); - EXPECT_EQ(GetV(picture, i - kOffsetx, j - kOffsety), GetV(buf, i, j)); - EXPECT_EQ(GetY(picture, i - kOffsetx, j - kOffsety), GetY(buf, i, j)); - } - } - } -} - INSTANTIATE_TEST_SUITE_P(All, TestPlanarYuvBuffer, ::testing::Values(VideoFrameBuffer::Type::kI420,