aboutsummaryrefslogtreecommitdiff
path: root/unit_test
diff options
context:
space:
mode:
authorFrank Barchard <fbarchard@chromium.org>2022-06-07 09:06:38 +0000
committerlibyuv LUCI CQ <libyuv-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-06-07 09:16:05 +0000
commitd011314f14738e0751dcb269c1d989c4dcbaad7b (patch)
treeba4ac530c7714d19e51bd8490da51c9ad2f9bb87 /unit_test
parent60254a1d846a93a4d7559009004cdd91bcc04d82 (diff)
downloadlibyuv-d011314f14738e0751dcb269c1d989c4dcbaad7b.tar.gz
Revert "I210ToI420, InterpolatePlane_16, and ScalePlane Vertical-only asan fix"
This reverts commit 60254a1d846a93a4d7559009004cdd91bcc04d82. Reason for revert: breaks PaintCanvasVideoRendererTest.HighBitDepth Original change's description: > I210ToI420, InterpolatePlane_16, and ScalePlane Vertical-only asan fix > > - Add I210ToI420 to convert 10 bit 4:2:2 YUV to 4:2:0 8 bit > - Add NEON InterpolateRow_16 for fast 10 bit scaling > - When scaling up, set step to interpolate toward height - 1 to avoid buffer overread > - When scaling down, center the 2 rows used for source to achieve filtering. > - CopyPlane check for 0 size and return > > Bug: libyuv:931, b/228605787, b/233233302, b/233634772, b/234558395, b/234340482 > Change-Id: I63e8580710a57812b683c2fe40583ac5a179c4f1 > Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/3687552 > Reviewed-by: Mirko Bonadei <mbonadei@chromium.org> > Reviewed-by: richard winterton <rrwinterton@gmail.com> Bug: libyuv:931, b/228605787, b/233233302, b/233634772, b/234558395, b/234340482 Change-Id: Icc05bb340db0e7fe864061fb501d0a861c764116 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/3692886 Reviewed-by: Frank Barchard <fbarchard@chromium.org> Commit-Queue: Mirko Bonadei <mbonadei@chromium.org> Reviewed-by: Mirko Bonadei <mbonadei@chromium.org>
Diffstat (limited to 'unit_test')
-rw-r--r--unit_test/convert_test.cc10
-rw-r--r--unit_test/planar_test.cc129
-rw-r--r--unit_test/scale_test.cc53
3 files changed, 11 insertions, 181 deletions
diff --git a/unit_test/convert_test.cc b/unit_test/convert_test.cc
index c2d95220..185c5aa4 100644
--- a/unit_test/convert_test.cc
+++ b/unit_test/convert_test.cc
@@ -178,7 +178,6 @@ TESTPLANARTOP(I210, uint16_t, 2, 2, 1, I010, uint16_t, 2, 2, 2, 10)
TESTPLANARTOP(I412, uint16_t, 2, 1, 1, I012, uint16_t, 2, 2, 2, 12)
TESTPLANARTOP(I212, uint16_t, 2, 2, 1, I012, uint16_t, 2, 2, 2, 12)
TESTPLANARTOP(I010, uint16_t, 2, 2, 2, I420, uint8_t, 1, 2, 2, 10)
-TESTPLANARTOP(I210, uint16_t, 2, 2, 1, I420, uint8_t, 1, 2, 2, 10)
TESTPLANARTOP(I210, uint16_t, 2, 2, 1, I422, uint8_t, 1, 2, 1, 10)
TESTPLANARTOP(I410, uint16_t, 2, 1, 1, I444, uint8_t, 1, 1, 1, 10)
TESTPLANARTOP(I012, uint16_t, 2, 2, 2, I420, uint8_t, 1, 2, 2, 12)
@@ -2271,8 +2270,7 @@ TEST_F(LibYUVConvertTest, TestMJPGToNV12_420) {
free_aligned_buffer_page_end(dst_vu);
}
-// TODO(fbarchard): Improve test to compare against I422, not checksum
-TEST_F(LibYUVConvertTest, DISABLED_TestMJPGToNV21_422) {
+TEST_F(LibYUVConvertTest, TestMJPGToNV21_422) {
int width = 0;
int height = 0;
int ret = MJPGSize(kTest3Jpg, kTest3JpgLen, &width, &height);
@@ -2296,13 +2294,13 @@ TEST_F(LibYUVConvertTest, DISABLED_TestMJPGToNV21_422) {
uint32_t dst_y_hash = HashDjb2(dst_y, width * height, 5381);
uint32_t dst_uv_hash = HashDjb2(dst_uv, half_width * half_height * 2, 5381);
EXPECT_EQ(dst_y_hash, 2682851208u);
- EXPECT_EQ(dst_uv_hash, 493520167u);
+ EXPECT_EQ(dst_uv_hash, 3543430771u);
free_aligned_buffer_page_end(dst_y);
free_aligned_buffer_page_end(dst_uv);
}
-TEST_F(LibYUVConvertTest, DISABLED_TestMJPGToNV12_422) {
+TEST_F(LibYUVConvertTest, TestMJPGToNV12_422) {
int width = 0;
int height = 0;
int ret = MJPGSize(kTest3Jpg, kTest3JpgLen, &width, &height);
@@ -2329,7 +2327,7 @@ TEST_F(LibYUVConvertTest, DISABLED_TestMJPGToNV12_422) {
half_height);
uint32_t dst_vu_hash = HashDjb2(dst_vu, half_width * half_height * 2, 5381);
EXPECT_EQ(dst_y_hash, 2682851208u);
- EXPECT_EQ(dst_vu_hash, 493520167u);
+ EXPECT_EQ(dst_vu_hash, 3543430771u);
free_aligned_buffer_page_end(dst_y);
free_aligned_buffer_page_end(dst_uv);
diff --git a/unit_test/planar_test.cc b/unit_test/planar_test.cc
index 42166d0d..8f5a33cb 100644
--- a/unit_test/planar_test.cc
+++ b/unit_test/planar_test.cc
@@ -1080,87 +1080,6 @@ TEST_F(LibYUVPlanarTest, TestInterpolatePlane) {
}
}
-TEST_F(LibYUVPlanarTest, TestInterpolatePlane_16) {
- SIMD_ALIGNED(uint16_t orig_pixels_0[1280]);
- SIMD_ALIGNED(uint16_t orig_pixels_1[1280]);
- SIMD_ALIGNED(uint16_t interpolate_pixels[1280]);
- memset(orig_pixels_0, 0, sizeof(orig_pixels_0));
- memset(orig_pixels_1, 0, sizeof(orig_pixels_1));
-
- orig_pixels_0[0] = 16u;
- orig_pixels_0[1] = 32u;
- orig_pixels_0[2] = 64u;
- orig_pixels_0[3] = 128u;
- orig_pixels_0[4] = 0u;
- orig_pixels_0[5] = 0u;
- orig_pixels_0[6] = 0u;
- orig_pixels_0[7] = 255u;
- orig_pixels_0[8] = 0u;
- orig_pixels_0[9] = 0u;
- orig_pixels_0[10] = 0u;
- orig_pixels_0[11] = 0u;
- orig_pixels_0[12] = 0u;
- orig_pixels_0[13] = 0u;
- orig_pixels_0[14] = 0u;
- orig_pixels_0[15] = 0u;
-
- orig_pixels_1[0] = 0u;
- orig_pixels_1[1] = 0u;
- orig_pixels_1[2] = 0u;
- orig_pixels_1[3] = 0u;
- orig_pixels_1[4] = 0u;
- orig_pixels_1[5] = 0u;
- orig_pixels_1[6] = 0u;
- orig_pixels_1[7] = 0u;
- orig_pixels_1[8] = 0u;
- orig_pixels_1[9] = 0u;
- orig_pixels_1[10] = 0u;
- orig_pixels_1[11] = 0u;
- orig_pixels_1[12] = 255u;
- orig_pixels_1[13] = 255u;
- orig_pixels_1[14] = 255u;
- orig_pixels_1[15] = 255u;
-
- InterpolatePlane_16(&orig_pixels_0[0], 0, &orig_pixels_1[0], 0,
- &interpolate_pixels[0], 0, 16, 1, 128);
- EXPECT_EQ(8u, interpolate_pixels[0]);
- EXPECT_EQ(16u, interpolate_pixels[1]);
- EXPECT_EQ(32u, interpolate_pixels[2]);
- EXPECT_EQ(64u, interpolate_pixels[3]);
- EXPECT_EQ(0u, interpolate_pixels[4]);
- EXPECT_EQ(0u, interpolate_pixels[5]);
- EXPECT_EQ(0u, interpolate_pixels[6]);
- EXPECT_EQ(128u, interpolate_pixels[7]);
- EXPECT_EQ(0u, interpolate_pixels[8]);
- EXPECT_EQ(0u, interpolate_pixels[9]);
- EXPECT_EQ(0u, interpolate_pixels[10]);
- EXPECT_EQ(0u, interpolate_pixels[11]);
- EXPECT_EQ(128u, interpolate_pixels[12]);
- EXPECT_EQ(128u, interpolate_pixels[13]);
- EXPECT_EQ(128u, interpolate_pixels[14]);
- EXPECT_EQ(128u, interpolate_pixels[15]);
-
- InterpolatePlane_16(&orig_pixels_0[0], 0, &orig_pixels_1[0], 0,
- &interpolate_pixels[0], 0, 16, 1, 0);
- EXPECT_EQ(16u, interpolate_pixels[0]);
- EXPECT_EQ(32u, interpolate_pixels[1]);
- EXPECT_EQ(64u, interpolate_pixels[2]);
- EXPECT_EQ(128u, interpolate_pixels[3]);
-
- InterpolatePlane_16(&orig_pixels_0[0], 0, &orig_pixels_1[0], 0,
- &interpolate_pixels[0], 0, 16, 1, 192);
-
- EXPECT_EQ(4u, interpolate_pixels[0]);
- EXPECT_EQ(8u, interpolate_pixels[1]);
- EXPECT_EQ(16u, interpolate_pixels[2]);
- EXPECT_EQ(32u, interpolate_pixels[3]);
-
- for (int i = 0; i < benchmark_pixels_div1280_; ++i) {
- InterpolatePlane_16(&orig_pixels_0[0], 0, &orig_pixels_1[0], 0,
- &interpolate_pixels[0], 0, 1280, 1, 123);
- }
-}
-
#define TESTTERP(FMT_A, BPP_A, STRIDE_A, FMT_B, BPP_B, STRIDE_B, W1280, TERP, \
N, NEG, OFF) \
TEST_F(LibYUVPlanarTest, ARGBInterpolate##TERP##N) { \
@@ -1565,43 +1484,9 @@ TEST_F(LibYUVPlanarTest, TestCopyPlane) {
EXPECT_EQ(0, err);
}
-TEST_F(LibYUVPlanarTest, CopyPlane_Opt) {
- int i;
- int y_plane_size = benchmark_width_ * benchmark_height_;
- align_buffer_page_end(orig_y, y_plane_size);
- align_buffer_page_end(dst_c, y_plane_size);
- align_buffer_page_end(dst_opt, y_plane_size);
-
- MemRandomize(orig_y, y_plane_size);
- memset(dst_c, 1, y_plane_size);
- memset(dst_opt, 2, y_plane_size);
-
- // Disable all optimizations.
- MaskCpuFlags(disable_cpu_flags_);
- for (i = 0; i < benchmark_iterations_; i++) {
- CopyPlane(orig_y, benchmark_width_, dst_c, benchmark_width_,
- benchmark_width_, benchmark_height_);
- }
-
- // Enable optimizations.
- MaskCpuFlags(benchmark_cpu_info_);
- for (i = 0; i < benchmark_iterations_; i++) {
- CopyPlane(orig_y, benchmark_width_, dst_opt, benchmark_width_,
- benchmark_width_, benchmark_height_);
- }
-
- for (i = 0; i < y_plane_size; ++i) {
- EXPECT_EQ(dst_c[i], dst_opt[i]);
- }
-
- free_aligned_buffer_page_end(orig_y);
- free_aligned_buffer_page_end(dst_c);
- free_aligned_buffer_page_end(dst_opt);
-}
-
-TEST_F(LibYUVPlanarTest, TestCopyPlaneZero) {
- // Test to verify copying a rect with a zero height or width does
- // not touch destination memory.
+TEST_F(LibYUVPlanarTest, TestCopyPlaneZeroDimensionRegressionTest) {
+ // Regression test to verify copying a rect with a zero height or width does
+ // not lead to memory corruption.
uint8_t src = 42;
uint8_t dst = 0;
@@ -3624,8 +3509,8 @@ TEST_F(LibYUVPlanarTest, YUY2ToY) {
memset(dst_pixels_y_c, 1, kPixels);
MaskCpuFlags(disable_cpu_flags_);
- YUY2ToY(src_pixels_y, benchmark_width_ * 2, dst_pixels_y_c, benchmark_width_,
- benchmark_width_, benchmark_height_);
+ YUY2ToY(src_pixels_y, benchmark_width_ * 2, dst_pixels_y_c,
+ benchmark_width_, benchmark_width_, benchmark_height_);
MaskCpuFlags(benchmark_cpu_info_);
for (int i = 0; i < benchmark_iterations_; ++i) {
@@ -3653,8 +3538,8 @@ TEST_F(LibYUVPlanarTest, UYVYToY) {
memset(dst_pixels_y_c, 1, kPixels);
MaskCpuFlags(disable_cpu_flags_);
- UYVYToY(src_pixels_y, benchmark_width_ * 2, dst_pixels_y_c, benchmark_width_,
- benchmark_width_, benchmark_height_);
+ UYVYToY(src_pixels_y, benchmark_width_ * 2, dst_pixels_y_c,
+ benchmark_width_, benchmark_width_, benchmark_height_);
MaskCpuFlags(benchmark_cpu_info_);
for (int i = 0; i < benchmark_iterations_; ++i) {
diff --git a/unit_test/scale_test.cc b/unit_test/scale_test.cc
index 81c839f4..1fb3b2f0 100644
--- a/unit_test/scale_test.cc
+++ b/unit_test/scale_test.cc
@@ -1545,57 +1545,4 @@ TEST_F(LibYUVScaleTest, PlaneTestRotate_Box) {
free_aligned_buffer_page_end(orig_pixels);
}
-TEST_F(LibYUVScaleTest, PlaneTest1_Box) {
- align_buffer_page_end(orig_pixels, 3);
- align_buffer_page_end(dst_pixels, 3);
-
- // Pad the 1x1 byte image with invalid values before and after in case libyuv
- // reads outside the memory boundaries.
- orig_pixels[0] = 0;
- orig_pixels[1] = 1; // scale this pixel
- orig_pixels[2] = 2;
- dst_pixels[0] = 3;
- dst_pixels[1] = 3;
- dst_pixels[2] = 3;
-
- libyuv::ScalePlane(orig_pixels + 1, /* src_stride= */ 1, /* src_width= */ 1,
- /* src_height= */ 1, dst_pixels, /* dst_stride= */ 1,
- /* dst_width= */ 1, /* dst_height= */ 2,
- libyuv::kFilterBox);
-
- EXPECT_EQ(dst_pixels[0], 1);
- EXPECT_EQ(dst_pixels[1], 1);
- EXPECT_EQ(dst_pixels[2], 3);
-
- free_aligned_buffer_page_end(dst_pixels);
- free_aligned_buffer_page_end(orig_pixels);
-}
-
-TEST_F(LibYUVScaleTest, PlaneTest1_16_Box) {
- align_buffer_page_end(orig_pixels_alloc, 3 * 2);
- align_buffer_page_end(dst_pixels_alloc, 3 * 2);
- uint16_t* orig_pixels = (uint16_t*)orig_pixels_alloc;
- uint16_t* dst_pixels = (uint16_t*)dst_pixels_alloc;
-
- // Pad the 1x1 byte image with invalid values before and after in case libyuv
- // reads outside the memory boundaries.
- orig_pixels[0] = 0;
- orig_pixels[1] = 1; // scale this pixel
- orig_pixels[2] = 2;
- dst_pixels[0] = 3;
- dst_pixels[1] = 3;
- dst_pixels[2] = 3;
-
- libyuv::ScalePlane_16(
- orig_pixels + 1, /* src_stride= */ 1, /* src_width= */ 1,
- /* src_height= */ 1, dst_pixels, /* dst_stride= */ 1,
- /* dst_width= */ 1, /* dst_height= */ 2, libyuv::kFilterNone);
-
- EXPECT_EQ(dst_pixels[0], 1);
- EXPECT_EQ(dst_pixels[1], 1);
- EXPECT_EQ(dst_pixels[2], 3);
-
- free_aligned_buffer_page_end(dst_pixels_alloc);
- free_aligned_buffer_page_end(orig_pixels_alloc);
-}
} // namespace libyuv