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 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1156 EXPECT_LE(max_diff, 1); | 1156 EXPECT_LE(max_diff, 1); |
1157 } | 1157 } |
1158 | 1158 |
1159 TEST_F(LibYUVPlanarTest, ARGBBlend_Opt) { | 1159 TEST_F(LibYUVPlanarTest, ARGBBlend_Opt) { |
1160 int max_diff = TestBlend(benchmark_width_, benchmark_height_, | 1160 int max_diff = TestBlend(benchmark_width_, benchmark_height_, |
1161 benchmark_iterations_, | 1161 benchmark_iterations_, |
1162 disable_cpu_flags_, benchmark_cpu_info_, +1, 0); | 1162 disable_cpu_flags_, benchmark_cpu_info_, +1, 0); |
1163 EXPECT_LE(max_diff, 1); | 1163 EXPECT_LE(max_diff, 1); |
1164 } | 1164 } |
1165 | 1165 |
| 1166 #ifdef HAS_BLENDPLANEROW_SSSE3 |
| 1167 |
| 1168 static int TestBlendPlane(int width, int height, int benchmark_iterations, |
| 1169 int invert, int off) { |
| 1170 int has_ssse3 = TestCpuFlag(kCpuHasSSSE3); |
| 1171 if (width < 1) { |
| 1172 width = 1; |
| 1173 } |
| 1174 const int kBpp = 1; |
| 1175 const int kStride = width * kBpp; |
| 1176 align_buffer_64(src_argb_a, kStride * height + off); |
| 1177 align_buffer_64(src_argb_b, kStride * height + off); |
| 1178 align_buffer_64(src_argb_alpha, kStride * height + off); |
| 1179 align_buffer_64(dst_argb_c, kStride * height); |
| 1180 align_buffer_64(dst_argb_opt, kStride * height); |
| 1181 for (int i = 0; i < kStride * height; ++i) { |
| 1182 src_argb_a[i + off] = (fastrand() & 0xff); |
| 1183 src_argb_b[i + off] = (fastrand() & 0xff); |
| 1184 src_argb_alpha[i + off] = (fastrand() & 0xff); |
| 1185 } |
| 1186 memset(dst_argb_c, 255, kStride * height); |
| 1187 memset(dst_argb_opt, 255, kStride * height); |
| 1188 |
| 1189 BlendPlaneRow_C(src_argb_a + off, |
| 1190 src_argb_b + off, |
| 1191 src_argb_alpha + off, |
| 1192 dst_argb_c, |
| 1193 width * height); |
| 1194 for (int i = 0; i < benchmark_iterations; ++i) { |
| 1195 if (has_ssse3) { |
| 1196 BlendPlaneRow_SSSE3(src_argb_a + off, |
| 1197 src_argb_b + off, |
| 1198 src_argb_alpha + off, |
| 1199 dst_argb_opt, |
| 1200 width * height); |
| 1201 } else { |
| 1202 BlendPlaneRow_C(src_argb_a + off, |
| 1203 src_argb_b + off, |
| 1204 src_argb_alpha + off, |
| 1205 dst_argb_opt, |
| 1206 width * height); |
| 1207 } |
| 1208 } |
| 1209 int max_diff = 0; |
| 1210 for (int i = 0; i < kStride * height; ++i) { |
| 1211 EXPECT_EQ(dst_argb_c[i], dst_argb_opt[i]); |
| 1212 } |
| 1213 free_aligned_buffer_64(src_argb_a); |
| 1214 free_aligned_buffer_64(src_argb_b); |
| 1215 free_aligned_buffer_64(dst_argb_c); |
| 1216 free_aligned_buffer_64(dst_argb_opt); |
| 1217 return max_diff; |
| 1218 } |
| 1219 |
| 1220 TEST_F(LibYUVPlanarTest, BlendPlane_Opt) { |
| 1221 int max_diff = TestBlendPlane(benchmark_width_, benchmark_height_, |
| 1222 benchmark_iterations_, |
| 1223 +1, 0); |
| 1224 } |
| 1225 #endif |
| 1226 |
1166 TEST_F(LibYUVPlanarTest, TestAffine) { | 1227 TEST_F(LibYUVPlanarTest, TestAffine) { |
1167 SIMD_ALIGNED(uint8 orig_pixels_0[1280][4]); | 1228 SIMD_ALIGNED(uint8 orig_pixels_0[1280][4]); |
1168 SIMD_ALIGNED(uint8 interpolate_pixels_C[1280][4]); | 1229 SIMD_ALIGNED(uint8 interpolate_pixels_C[1280][4]); |
1169 | 1230 |
1170 for (int i = 0; i < 1280; ++i) { | 1231 for (int i = 0; i < 1280; ++i) { |
1171 for (int j = 0; j < 4; ++j) { | 1232 for (int j = 0; j < 4; ++j) { |
1172 orig_pixels_0[i][j] = i; | 1233 orig_pixels_0[i][j] = i; |
1173 } | 1234 } |
1174 } | 1235 } |
1175 | 1236 |
(...skipping 1169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2345 | 2406 |
2346 TEST_F(LibYUVPlanarTest, SetPlane_Opt) { | 2407 TEST_F(LibYUVPlanarTest, SetPlane_Opt) { |
2347 int max_diff = TestARGBRect(benchmark_width_, benchmark_height_, | 2408 int max_diff = TestARGBRect(benchmark_width_, benchmark_height_, |
2348 benchmark_iterations_, | 2409 benchmark_iterations_, |
2349 disable_cpu_flags_, benchmark_cpu_info_, | 2410 disable_cpu_flags_, benchmark_cpu_info_, |
2350 +1, 0, 1); | 2411 +1, 0, 1); |
2351 EXPECT_EQ(0, max_diff); | 2412 EXPECT_EQ(0, max_diff); |
2352 } | 2413 } |
2353 | 2414 |
2354 } // namespace libyuv | 2415 } // namespace libyuv |
OLD | NEW |