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 2063 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2074 } | 2074 } |
2075 | 2075 |
2076 for (int i = 0; i < 1280; ++i) { | 2076 for (int i = 0; i < 1280; ++i) { |
2077 EXPECT_EQ(dst_pixels_c[i][0], dst_pixels_opt[i][0]); | 2077 EXPECT_EQ(dst_pixels_c[i][0], dst_pixels_opt[i][0]); |
2078 EXPECT_EQ(dst_pixels_c[i][1], dst_pixels_opt[i][1]); | 2078 EXPECT_EQ(dst_pixels_c[i][1], dst_pixels_opt[i][1]); |
2079 EXPECT_EQ(dst_pixels_c[i][2], dst_pixels_opt[i][2]); | 2079 EXPECT_EQ(dst_pixels_c[i][2], dst_pixels_opt[i][2]); |
2080 EXPECT_EQ(dst_pixels_c[i][3], dst_pixels_opt[i][3]); | 2080 EXPECT_EQ(dst_pixels_c[i][3], dst_pixels_opt[i][3]); |
2081 } | 2081 } |
2082 } | 2082 } |
2083 | 2083 |
| 2084 TEST_F(LibYUVPlanarTest, TestHalfFloatPlane) { |
| 2085 int i, j; |
| 2086 const int y_plane_size = benchmark_width_ * benchmark_height_ * 2; |
| 2087 |
| 2088 align_buffer_page_end(orig_y, y_plane_size); |
| 2089 align_buffer_page_end(dst_c, y_plane_size); |
| 2090 align_buffer_page_end(dst_opt, y_plane_size); |
| 2091 MemRandomize(orig_y, y_plane_size); |
| 2092 memset(dst_c, 0, y_plane_size); |
| 2093 memset(dst_opt, 1, y_plane_size); |
| 2094 |
| 2095 // Disable all optimizations. |
| 2096 MaskCpuFlags(disable_cpu_flags_); |
| 2097 double c_time = get_time(); |
| 2098 for (j = 0; j < benchmark_iterations_; j++) { |
| 2099 HalfFloatPlane((uint16*)orig_y, benchmark_width_ * 2, |
| 2100 (uint16*)dst_c, benchmark_width_ * 2, |
| 2101 1.0f / 4096.0f, benchmark_width_, benchmark_height_); |
| 2102 } |
| 2103 c_time = (get_time() - c_time) / benchmark_iterations_; |
| 2104 |
| 2105 // Enable optimizations. |
| 2106 MaskCpuFlags(benchmark_cpu_info_); |
| 2107 double opt_time = get_time(); |
| 2108 for (j = 0; j < benchmark_iterations_; j++) { |
| 2109 HalfFloatPlane((uint16*)orig_y, benchmark_width_ * 2, |
| 2110 (uint16*)dst_opt, benchmark_width_ * 2, |
| 2111 1.0f / 4096.0f, benchmark_width_, benchmark_height_); |
| 2112 } |
| 2113 opt_time = (get_time() - opt_time) / benchmark_iterations_; |
| 2114 |
| 2115 for (i = 0; i < y_plane_size; ++i) { |
| 2116 EXPECT_EQ(dst_c[i], dst_opt[i]); |
| 2117 } |
| 2118 |
| 2119 free_aligned_buffer_page_end(orig_y); |
| 2120 free_aligned_buffer_page_end(dst_c); |
| 2121 free_aligned_buffer_page_end(dst_opt); |
| 2122 } |
| 2123 |
2084 TEST_F(LibYUVPlanarTest, TestARGBLumaColorTable) { | 2124 TEST_F(LibYUVPlanarTest, TestARGBLumaColorTable) { |
2085 SIMD_ALIGNED(uint8 orig_pixels[1280][4]); | 2125 SIMD_ALIGNED(uint8 orig_pixels[1280][4]); |
2086 SIMD_ALIGNED(uint8 dst_pixels_opt[1280][4]); | 2126 SIMD_ALIGNED(uint8 dst_pixels_opt[1280][4]); |
2087 SIMD_ALIGNED(uint8 dst_pixels_c[1280][4]); | 2127 SIMD_ALIGNED(uint8 dst_pixels_c[1280][4]); |
2088 memset(orig_pixels, 0, sizeof(orig_pixels)); | 2128 memset(orig_pixels, 0, sizeof(orig_pixels)); |
2089 | 2129 |
2090 align_buffer_page_end(lumacolortable, 32768); | 2130 align_buffer_page_end(lumacolortable, 32768); |
2091 int v = 0; | 2131 int v = 0; |
2092 for (int i = 0; i < 32768; ++i) { | 2132 for (int i = 0; i < 32768; ++i) { |
2093 lumacolortable[i] = v; | 2133 lumacolortable[i] = v; |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2447 } | 2487 } |
2448 | 2488 |
2449 free_aligned_buffer_page_end(src_pixels); | 2489 free_aligned_buffer_page_end(src_pixels); |
2450 free_aligned_buffer_page_end(tmp_pixels_u); | 2490 free_aligned_buffer_page_end(tmp_pixels_u); |
2451 free_aligned_buffer_page_end(tmp_pixels_v); | 2491 free_aligned_buffer_page_end(tmp_pixels_v); |
2452 free_aligned_buffer_page_end(dst_pixels_opt); | 2492 free_aligned_buffer_page_end(dst_pixels_opt); |
2453 free_aligned_buffer_page_end(dst_pixels_c); | 2493 free_aligned_buffer_page_end(dst_pixels_c); |
2454 } | 2494 } |
2455 | 2495 |
2456 } // namespace libyuv | 2496 } // namespace libyuv |
OLD | NEW |