OLD | NEW |
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 922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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) { | 943 TEST_F(LibYUVPlanarTest, TestInterpolatePlane) { |
945 SIMD_ALIGNED(uint8 orig_pixels_0[1280]); | 944 SIMD_ALIGNED(uint8 orig_pixels_0[1280]); |
946 SIMD_ALIGNED(uint8 orig_pixels_1[1280]); | 945 SIMD_ALIGNED(uint8 orig_pixels_1[1280]); |
947 SIMD_ALIGNED(uint8 interpolate_pixels[1280]); | 946 SIMD_ALIGNED(uint8 interpolate_pixels[1280]); |
948 memset(orig_pixels_0, 0, sizeof(orig_pixels_0)); | 947 memset(orig_pixels_0, 0, sizeof(orig_pixels_0)); |
949 memset(orig_pixels_1, 0, sizeof(orig_pixels_1)); | 948 memset(orig_pixels_1, 0, sizeof(orig_pixels_1)); |
950 | 949 |
951 orig_pixels_0[0] = 16u; | 950 orig_pixels_0[0] = 16u; |
952 orig_pixels_0[1] = 32u; | 951 orig_pixels_0[1] = 32u; |
953 orig_pixels_0[2] = 64u; | 952 orig_pixels_0[2] = 64u; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1017 EXPECT_EQ(32u, interpolate_pixels[3]); | 1016 EXPECT_EQ(32u, interpolate_pixels[3]); |
1018 | 1017 |
1019 for (int i = 0; i < benchmark_pixels_div1280_; ++i) { | 1018 for (int i = 0; i < benchmark_pixels_div1280_; ++i) { |
1020 InterpolatePlane(&orig_pixels_0[0], 0, &orig_pixels_1[0], 0, | 1019 InterpolatePlane(&orig_pixels_0[0], 0, &orig_pixels_1[0], 0, |
1021 &interpolate_pixels[0], 0, 1280, 1, 123); | 1020 &interpolate_pixels[0], 0, 1280, 1, 123); |
1022 } | 1021 } |
1023 } | 1022 } |
1024 | 1023 |
1025 #define TESTTERP(FMT_A, BPP_A, STRIDE_A, \ | 1024 #define TESTTERP(FMT_A, BPP_A, STRIDE_A, \ |
1026 FMT_B, BPP_B, STRIDE_B, \ | 1025 FMT_B, BPP_B, STRIDE_B, \ |
1027 W1280, TERP, DIFF, N, NEG, OFF) \ | 1026 W1280, TERP, N, NEG, OFF) \ |
1028 TEST_F(LibYUVPlanarTest, ARGBInterpolate##TERP##N) { \ | 1027 TEST_F(LibYUVPlanarTest, ARGBInterpolate##TERP##N) { \ |
1029 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ | 1028 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ |
1030 const int kHeight = benchmark_height_; \ | 1029 const int kHeight = benchmark_height_; \ |
1031 const int kStrideA = (kWidth * BPP_A + STRIDE_A - 1) / STRIDE_A * STRIDE_A; \ | 1030 const int kStrideA = (kWidth * BPP_A + STRIDE_A - 1) / STRIDE_A * STRIDE_A; \ |
1032 const int kStrideB = (kWidth * BPP_B + STRIDE_B - 1) / STRIDE_B * STRIDE_B; \ | 1031 const int kStrideB = (kWidth * BPP_B + STRIDE_B - 1) / STRIDE_B * STRIDE_B; \ |
1033 align_buffer_64(src_argb_a, kStrideA * kHeight + OFF); \ | 1032 align_buffer_64(src_argb_a, kStrideA * kHeight + OFF); \ |
1034 align_buffer_64(src_argb_b, kStrideA * kHeight + OFF); \ | 1033 align_buffer_64(src_argb_b, kStrideA * kHeight + OFF); \ |
1035 align_buffer_64(dst_argb_c, kStrideB * kHeight); \ | 1034 align_buffer_64(dst_argb_c, kStrideB * kHeight); \ |
1036 align_buffer_64(dst_argb_opt, kStrideB * kHeight); \ | 1035 align_buffer_64(dst_argb_opt, kStrideB * kHeight); \ |
1037 for (int i = 0; i < kStrideA * kHeight; ++i) { \ | 1036 for (int i = 0; i < kStrideA * kHeight; ++i) { \ |
1038 src_argb_a[i + OFF] = (fastrand() & 0xff); \ | 1037 src_argb_a[i + OFF] = (fastrand() & 0xff); \ |
1039 src_argb_b[i + OFF] = (fastrand() & 0xff); \ | 1038 src_argb_b[i + OFF] = (fastrand() & 0xff); \ |
1040 } \ | 1039 } \ |
1041 MaskCpuFlags(disable_cpu_flags_); \ | 1040 MaskCpuFlags(disable_cpu_flags_); \ |
1042 ARGBInterpolate(src_argb_a + OFF, kStrideA, \ | 1041 ARGBInterpolate(src_argb_a + OFF, kStrideA, \ |
1043 src_argb_b + OFF, kStrideA, \ | 1042 src_argb_b + OFF, kStrideA, \ |
1044 dst_argb_c, kStrideB, \ | 1043 dst_argb_c, kStrideB, \ |
1045 kWidth, NEG kHeight, TERP); \ | 1044 kWidth, NEG kHeight, TERP); \ |
1046 MaskCpuFlags(benchmark_cpu_info_); \ | 1045 MaskCpuFlags(benchmark_cpu_info_); \ |
1047 for (int i = 0; i < benchmark_iterations_; ++i) { \ | 1046 for (int i = 0; i < benchmark_iterations_; ++i) { \ |
1048 ARGBInterpolate(src_argb_a + OFF, kStrideA, \ | 1047 ARGBInterpolate(src_argb_a + OFF, kStrideA, \ |
1049 src_argb_b + OFF, kStrideA, \ | 1048 src_argb_b + OFF, kStrideA, \ |
1050 dst_argb_opt, kStrideB, \ | 1049 dst_argb_opt, kStrideB, \ |
1051 kWidth, NEG kHeight, TERP); \ | 1050 kWidth, NEG kHeight, TERP); \ |
1052 } \ | 1051 } \ |
1053 int max_diff = 0; \ | |
1054 for (int i = 0; i < kStrideB * kHeight; ++i) { \ | 1052 for (int i = 0; i < kStrideB * kHeight; ++i) { \ |
1055 int abs_diff = \ | 1053 EXPECT_EQ(dst_argb_c[i], dst_argb_opt[i]); \ |
1056 abs(static_cast<int>(dst_argb_c[i]) - \ | |
1057 static_cast<int>(dst_argb_opt[i])); \ | |
1058 if (abs_diff > max_diff) { \ | |
1059 max_diff = abs_diff; \ | |
1060 } \ | |
1061 } \ | 1054 } \ |
1062 EXPECT_LE(max_diff, DIFF); \ | |
1063 free_aligned_buffer_64(src_argb_a); \ | 1055 free_aligned_buffer_64(src_argb_a); \ |
1064 free_aligned_buffer_64(src_argb_b); \ | 1056 free_aligned_buffer_64(src_argb_b); \ |
1065 free_aligned_buffer_64(dst_argb_c); \ | 1057 free_aligned_buffer_64(dst_argb_c); \ |
1066 free_aligned_buffer_64(dst_argb_opt); \ | 1058 free_aligned_buffer_64(dst_argb_opt); \ |
1067 } | 1059 } |
1068 | 1060 |
1069 #define TESTINTERPOLATE(TERP) \ | 1061 #define TESTINTERPOLATE(TERP) \ |
1070 TESTTERP(ARGB, 4, 1, ARGB, 4, 1, \ | 1062 TESTTERP(ARGB, 4, 1, ARGB, 4, 1, benchmark_width_ - 1, TERP, _Any, +, 0) \ |
1071 benchmark_width_ - 1, TERP, 1, _Any, +, 0) \ | 1063 TESTTERP(ARGB, 4, 1, ARGB, 4, 1, benchmark_width_, TERP, _Unaligned, +, 1) \ |
1072 TESTTERP(ARGB, 4, 1, ARGB, 4, 1, \ | 1064 TESTTERP(ARGB, 4, 1, ARGB, 4, 1, benchmark_width_, TERP, _Invert, -, 0) \ |
1073 benchmark_width_, TERP, 1, _Unaligned, +, 1) \ | 1065 TESTTERP(ARGB, 4, 1, ARGB, 4, 1, benchmark_width_, TERP, _Opt, +, 0) |
1074 TESTTERP(ARGB, 4, 1, ARGB, 4, 1, \ | |
1075 benchmark_width_, TERP, 1, _Invert, -, 0) \ | |
1076 TESTTERP(ARGB, 4, 1, ARGB, 4, 1, \ | |
1077 benchmark_width_, TERP, 1, _Opt, +, 0) \ | |
1078 TESTTERP(ARGB, 4, 1, ARGB, 4, 1, \ | |
1079 benchmark_width_ - 1, TERP, 1, _Any_Invert, -, 0) | |
1080 | 1066 |
1081 TESTINTERPOLATE(0) | 1067 TESTINTERPOLATE(0) |
1082 TESTINTERPOLATE(64) | 1068 TESTINTERPOLATE(64) |
1083 TESTINTERPOLATE(128) | 1069 TESTINTERPOLATE(128) |
1084 TESTINTERPOLATE(192) | 1070 TESTINTERPOLATE(192) |
1085 TESTINTERPOLATE(255) | 1071 TESTINTERPOLATE(255) |
1086 | 1072 |
1087 static int TestBlend(int width, int height, int benchmark_iterations, | 1073 static int TestBlend(int width, int height, int benchmark_iterations, |
1088 int disable_cpu_flags, int benchmark_cpu_info, | 1074 int disable_cpu_flags, int benchmark_cpu_info, |
1089 int invert, int off) { | 1075 int invert, int off) { |
(...skipping 1550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2640 | 2626 |
2641 TEST_F(LibYUVPlanarTest, SetPlane_Opt) { | 2627 TEST_F(LibYUVPlanarTest, SetPlane_Opt) { |
2642 int max_diff = TestARGBRect(benchmark_width_, benchmark_height_, | 2628 int max_diff = TestARGBRect(benchmark_width_, benchmark_height_, |
2643 benchmark_iterations_, | 2629 benchmark_iterations_, |
2644 disable_cpu_flags_, benchmark_cpu_info_, | 2630 disable_cpu_flags_, benchmark_cpu_info_, |
2645 +1, 0, 1); | 2631 +1, 0, 1); |
2646 EXPECT_EQ(0, max_diff); | 2632 EXPECT_EQ(0, max_diff); |
2647 } | 2633 } |
2648 | 2634 |
2649 } // namespace libyuv | 2635 } // namespace libyuv |
OLD | NEW |