Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1321)

Side by Side Diff: unit_test/planar_test.cc

Issue 1479593002: Interpolate plane initial implementation. (Closed) Base URL: https://chromium.googlesource.com/libyuv/libyuv@master
Patch Set: unittest added for interpolate plane Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « source/planar_functions.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 The LibYuv Project Authors. All rights reserved. 2 * Copyright 2011 The LibYuv Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 EXPECT_EQ(5u, shade_pixels[0][1]); 852 EXPECT_EQ(5u, shade_pixels[0][1]);
853 EXPECT_EQ(5u, shade_pixels[0][2]); 853 EXPECT_EQ(5u, shade_pixels[0][2]);
854 EXPECT_EQ(5u, shade_pixels[0][3]); 854 EXPECT_EQ(5u, shade_pixels[0][3]);
855 855
856 for (int i = 0; i < benchmark_pixels_div1280_; ++i) { 856 for (int i = 0; i < benchmark_pixels_div1280_; ++i) {
857 ARGBShade(&orig_pixels[0][0], 0, &shade_pixels[0][0], 0, 1280, 1, 857 ARGBShade(&orig_pixels[0][0], 0, &shade_pixels[0][0], 0, 1280, 1,
858 0x80808080); 858 0x80808080);
859 } 859 }
860 } 860 }
861 861
862 TEST_F(LibYUVPlanarTest, TestInterpolate) { 862 TEST_F(LibYUVPlanarTest, TestARGBInterpolate) {
863 SIMD_ALIGNED(uint8 orig_pixels_0[1280][4]); 863 SIMD_ALIGNED(uint8 orig_pixels_0[1280][4]);
864 SIMD_ALIGNED(uint8 orig_pixels_1[1280][4]); 864 SIMD_ALIGNED(uint8 orig_pixels_1[1280][4]);
865 SIMD_ALIGNED(uint8 interpolate_pixels[1280][4]); 865 SIMD_ALIGNED(uint8 interpolate_pixels[1280][4]);
866 memset(orig_pixels_0, 0, sizeof(orig_pixels_0)); 866 memset(orig_pixels_0, 0, sizeof(orig_pixels_0));
867 memset(orig_pixels_1, 0, sizeof(orig_pixels_1)); 867 memset(orig_pixels_1, 0, sizeof(orig_pixels_1));
868 868
869 orig_pixels_0[0][0] = 16u; 869 orig_pixels_0[0][0] = 16u;
870 orig_pixels_0[0][1] = 32u; 870 orig_pixels_0[0][1] = 32u;
871 orig_pixels_0[0][2] = 64u; 871 orig_pixels_0[0][2] = 64u;
872 orig_pixels_0[0][3] = 128u; 872 orig_pixels_0[0][3] = 128u;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 EXPECT_EQ(8u, interpolate_pixels[0][1]); 933 EXPECT_EQ(8u, interpolate_pixels[0][1]);
934 EXPECT_EQ(16u, interpolate_pixels[0][2]); 934 EXPECT_EQ(16u, interpolate_pixels[0][2]);
935 EXPECT_EQ(32u, interpolate_pixels[0][3]); 935 EXPECT_EQ(32u, interpolate_pixels[0][3]);
936 936
937 for (int i = 0; i < benchmark_pixels_div1280_; ++i) { 937 for (int i = 0; i < benchmark_pixels_div1280_; ++i) {
938 ARGBInterpolate(&orig_pixels_0[0][0], 0, &orig_pixels_1[0][0], 0, 938 ARGBInterpolate(&orig_pixels_0[0][0], 0, &orig_pixels_1[0][0], 0,
939 &interpolate_pixels[0][0], 0, 1280, 1, 128); 939 &interpolate_pixels[0][0], 0, 1280, 1, 128);
940 } 940 }
941 } 941 }
942 942
943
944 TEST_F(LibYUVPlanarTest, TestInterpolatePlane) {
945 SIMD_ALIGNED(uint8 orig_pixels_0[1280]);
946 SIMD_ALIGNED(uint8 orig_pixels_1[1280]);
947 SIMD_ALIGNED(uint8 interpolate_pixels[1280]);
948 memset(orig_pixels_0, 0, sizeof(orig_pixels_0));
949 memset(orig_pixels_1, 0, sizeof(orig_pixels_1));
950
951 orig_pixels_0[0] = 16u;
952 orig_pixels_0[1] = 32u;
953 orig_pixels_0[2] = 64u;
954 orig_pixels_0[3] = 128u;
955 orig_pixels_0[4] = 0u;
956 orig_pixels_0[5] = 0u;
957 orig_pixels_0[6] = 0u;
958 orig_pixels_0[7] = 255u;
959 orig_pixels_0[8] = 0u;
960 orig_pixels_0[9] = 0u;
961 orig_pixels_0[10] = 0u;
962 orig_pixels_0[11] = 0u;
963 orig_pixels_0[12] = 0u;
964 orig_pixels_0[13] = 0u;
965 orig_pixels_0[14] = 0u;
966 orig_pixels_0[15] = 0u;
967
968 orig_pixels_1[0] = 0u;
969 orig_pixels_1[1] = 0u;
970 orig_pixels_1[2] = 0u;
971 orig_pixels_1[3] = 0u;
972 orig_pixels_1[4] = 0u;
973 orig_pixels_1[5] = 0u;
974 orig_pixels_1[6] = 0u;
975 orig_pixels_1[7] = 0u;
976 orig_pixels_1[8] = 0u;
977 orig_pixels_1[9] = 0u;
978 orig_pixels_1[10] = 0u;
979 orig_pixels_1[11] = 0u;
980 orig_pixels_1[12] = 255u;
981 orig_pixels_1[13] = 255u;
982 orig_pixels_1[14] = 255u;
983 orig_pixels_1[15] = 255u;
984
985 InterpolatePlane(&orig_pixels_0[0], 0, &orig_pixels_1[0], 0,
986 &interpolate_pixels[0], 0, 16, 1, 128);
987 EXPECT_EQ(8u, interpolate_pixels[0]);
988 EXPECT_EQ(16u, interpolate_pixels[1]);
989 EXPECT_EQ(32u, interpolate_pixels[2]);
990 EXPECT_EQ(64u, interpolate_pixels[3]);
991 EXPECT_EQ(0u, interpolate_pixels[4]);
992 EXPECT_EQ(0u, interpolate_pixels[5]);
993 EXPECT_EQ(0u, interpolate_pixels[6]);
994 EXPECT_NEAR(128u, interpolate_pixels[7], 1); // C = 127, SSE = 128.
995 EXPECT_EQ(0u, interpolate_pixels[8]);
996 EXPECT_EQ(0u, interpolate_pixels[9]);
997 EXPECT_EQ(0u, interpolate_pixels[10]);
998 EXPECT_EQ(0u, interpolate_pixels[11]);
999 EXPECT_NEAR(128u, interpolate_pixels[12], 1);
1000 EXPECT_NEAR(128u, interpolate_pixels[13], 1);
1001 EXPECT_NEAR(128u, interpolate_pixels[14], 1);
1002 EXPECT_NEAR(128u, interpolate_pixels[15], 1);
1003
1004 InterpolatePlane(&orig_pixels_0[0], 0, &orig_pixels_1[0], 0,
1005 &interpolate_pixels[0], 0, 16, 1, 0);
1006 EXPECT_EQ(16u, interpolate_pixels[0]);
1007 EXPECT_EQ(32u, interpolate_pixels[1]);
1008 EXPECT_EQ(64u, interpolate_pixels[2]);
1009 EXPECT_EQ(128u, interpolate_pixels[3]);
1010
1011 InterpolatePlane(&orig_pixels_0[0], 0, &orig_pixels_1[0], 0,
1012 &interpolate_pixels[0], 0, 16, 1, 192);
1013
1014 EXPECT_EQ(4u, interpolate_pixels[0]);
1015 EXPECT_EQ(8u, interpolate_pixels[1]);
1016 EXPECT_EQ(16u,interpolate_pixels[2]);
1017 EXPECT_EQ(32u, interpolate_pixels[3]);
1018
1019 for (int i = 0; i < benchmark_pixels_div1280_; ++i) {
1020 InterpolatePlane(&orig_pixels_0[0], 0, &orig_pixels_1[0], 0,
1021 &interpolate_pixels[0], 0, 1280, 1, 128);
1022 }
1023 }
1024
943 #define TESTTERP(FMT_A, BPP_A, STRIDE_A, \ 1025 #define TESTTERP(FMT_A, BPP_A, STRIDE_A, \
944 FMT_B, BPP_B, STRIDE_B, \ 1026 FMT_B, BPP_B, STRIDE_B, \
945 W1280, TERP, DIFF, N, NEG, OFF) \ 1027 W1280, TERP, DIFF, N, NEG, OFF) \
946 TEST_F(LibYUVPlanarTest, ARGBInterpolate##TERP##N) { \ 1028 TEST_F(LibYUVPlanarTest, ARGBInterpolate##TERP##N) { \
947 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ 1029 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \
948 const int kHeight = benchmark_height_; \ 1030 const int kHeight = benchmark_height_; \
949 const int kStrideA = (kWidth * BPP_A + STRIDE_A - 1) / STRIDE_A * STRIDE_A; \ 1031 const int kStrideA = (kWidth * BPP_A + STRIDE_A - 1) / STRIDE_A * STRIDE_A; \
950 const int kStrideB = (kWidth * BPP_B + STRIDE_B - 1) / STRIDE_B * STRIDE_B; \ 1032 const int kStrideB = (kWidth * BPP_B + STRIDE_B - 1) / STRIDE_B * STRIDE_B; \
951 align_buffer_64(src_argb_a, kStrideA * kHeight + OFF); \ 1033 align_buffer_64(src_argb_a, kStrideA * kHeight + OFF); \
952 align_buffer_64(src_argb_b, kStrideA * kHeight + OFF); \ 1034 align_buffer_64(src_argb_b, kStrideA * kHeight + OFF); \
(...skipping 1310 matching lines...) Expand 10 before | Expand all | Expand 10 after
2263 2345
2264 TEST_F(LibYUVPlanarTest, SetPlane_Opt) { 2346 TEST_F(LibYUVPlanarTest, SetPlane_Opt) {
2265 int max_diff = TestARGBRect(benchmark_width_, benchmark_height_, 2347 int max_diff = TestARGBRect(benchmark_width_, benchmark_height_,
2266 benchmark_iterations_, 2348 benchmark_iterations_,
2267 disable_cpu_flags_, benchmark_cpu_info_, 2349 disable_cpu_flags_, benchmark_cpu_info_,
2268 +1, 0, 1); 2350 +1, 0, 1);
2269 EXPECT_EQ(0, max_diff); 2351 EXPECT_EQ(0, max_diff);
2270 } 2352 }
2271 2353
2272 } // namespace libyuv 2354 } // namespace libyuv
OLDNEW
« no previous file with comments | « source/planar_functions.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698