Remove unused IXXXBuffer::PasteFrom
Bug: webrtc:13262 Change-Id: Iac383ca5a30abd082eb93af8acdef40d6537ce7d Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/235202 Reviewed-by: Niels Moller <nisse@webrtc.org> Reviewed-by: Stefan Holmer <stefan@webrtc.org> Commit-Queue: Ilya Nikolaevskiy <ilnik@webrtc.org> Cr-Commit-Position: refs/heads/main@{#35264}
This commit is contained in:
parent
519c15de2b
commit
711a4f706d
@ -232,35 +232,4 @@ void I010Buffer::ScaleFrom(const I010BufferInterface& src) {
|
|||||||
CropAndScaleFrom(src, 0, 0, src.width(), src.height());
|
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
|
} // namespace webrtc
|
||||||
|
|||||||
@ -66,12 +66,6 @@ class I010Buffer : public I010BufferInterface {
|
|||||||
// Scale all of `src` to the size of `this` buffer, with no cropping.
|
// Scale all of `src` to the size of `this` buffer, with no cropping.
|
||||||
void ScaleFrom(const I010BufferInterface& src);
|
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:
|
protected:
|
||||||
I010Buffer(int width, int height, int stride_y, int stride_u, int stride_v);
|
I010Buffer(int width, int height, int stride_y, int stride_u, int stride_v);
|
||||||
~I010Buffer() override;
|
~I010Buffer() override;
|
||||||
|
|||||||
@ -229,35 +229,4 @@ void I420Buffer::ScaleFrom(const I420BufferInterface& src) {
|
|||||||
CropAndScaleFrom(src, 0, 0, src.width(), src.height());
|
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
|
} // namespace webrtc
|
||||||
|
|||||||
@ -98,12 +98,6 @@ class RTC_EXPORT I420Buffer : public I420BufferInterface {
|
|||||||
// Scale all of `src` to the size of `this` buffer, with no cropping.
|
// Scale all of `src` to the size of `this` buffer, with no cropping.
|
||||||
void ScaleFrom(const I420BufferInterface& src);
|
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:
|
protected:
|
||||||
I420Buffer(int width, int height);
|
I420Buffer(int width, int height);
|
||||||
I420Buffer(int width, int height, int stride_y, int stride_u, int stride_v);
|
I420Buffer(int width, int height, int stride_y, int stride_u, int stride_v);
|
||||||
|
|||||||
@ -250,47 +250,6 @@ void CheckRotate(int width,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetU(rtc::scoped_refptr<PlanarYuvBuffer> 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<PlanarYuvBuffer> 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<PlanarYuvBuffer> 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<I420Buffer*>(canvas);
|
|
||||||
buf->PasteFrom(*picture.GetI420(), offset_col, offset_row);
|
|
||||||
} else {
|
|
||||||
I010Buffer* buf = static_cast<I010Buffer*>(canvas);
|
|
||||||
buf->PasteFrom(*picture.GetI010(), offset_col, offset_row);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
TEST(TestVideoFrame, WidthHeightValues) {
|
TEST(TestVideoFrame, WidthHeightValues) {
|
||||||
@ -476,43 +435,6 @@ TEST_P(TestPlanarYuvBuffer, CropAndScale16x9) {
|
|||||||
CheckCrop(*scaled_buffer->ToI420(), 0.0, 0.125, 1.0, 0.75);
|
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<PlanarYuvBuffer> buf =
|
|
||||||
CreateGradient(GetParam(), kWidth, kHeight);
|
|
||||||
|
|
||||||
rtc::scoped_refptr<PlanarYuvBuffer> original =
|
|
||||||
CreateGradient(GetParam(), kWidth, kHeight);
|
|
||||||
|
|
||||||
rtc::scoped_refptr<PlanarYuvBuffer> picture =
|
|
||||||
CreateGradient(GetParam(), kPicSize, kPicSize);
|
|
||||||
|
|
||||||
rtc::scoped_refptr<PlanarYuvBuffer> 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,
|
INSTANTIATE_TEST_SUITE_P(All,
|
||||||
TestPlanarYuvBuffer,
|
TestPlanarYuvBuffer,
|
||||||
::testing::Values(VideoFrameBuffer::Type::kI420,
|
::testing::Values(VideoFrameBuffer::Type::kI420,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user