| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 The LibYuv Project Authors. All rights reserved. | 2 * Copyright 2015 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 |
| 11 #include <stdlib.h> | 11 #include <stdlib.h> |
| 12 | 12 |
| 13 #include "libyuv/basic_types.h" |
| 13 #include "libyuv/convert.h" | 14 #include "libyuv/convert.h" |
| 14 #include "libyuv/convert_argb.h" | 15 #include "libyuv/convert_argb.h" |
| 15 #include "libyuv/convert_from.h" | 16 #include "libyuv/convert_from.h" |
| 16 #include "libyuv/convert_from_argb.h" | 17 #include "libyuv/convert_from_argb.h" |
| 17 #include "libyuv/cpu_id.h" | 18 #include "libyuv/cpu_id.h" |
| 18 #include "libyuv/row.h" // For Sobel | |
| 19 #include "../unit_test/unit_test.h" | 19 #include "../unit_test/unit_test.h" |
| 20 | 20 |
| 21 namespace libyuv { | 21 namespace libyuv { |
| 22 | 22 |
| 23 // TODO(fbarchard): Port high accuracy YUV to RGB to Neon. | 23 // TODO(fbarchard): Port high accuracy YUV to RGB to Neon. |
| 24 #if !defined(LIBYUV_DISABLE_NEON) && \ | 24 #if !defined(LIBYUV_DISABLE_NEON) && \ |
| 25 (defined(__aarch64__) || defined(__ARM_NEON__) || defined(LIBYUV_NEON)) | 25 (defined(__aarch64__) || defined(__ARM_NEON__) || defined(LIBYUV_NEON)) |
| 26 #define ERROR_R 1 | 26 #define ERROR_R 1 |
| 27 #define ERROR_G 1 | 27 #define ERROR_G 1 |
| 28 #define ERROR_B 3 | 28 #define ERROR_B 3 |
| 29 #define ERROR_FULL 6 | 29 #define ERROR_FULL 6 |
| 30 #define ERROR_J420 5 | 30 #define ERROR_J420 5 |
| 31 #else | 31 #else |
| 32 #define ERROR_R 1 | 32 #define ERROR_R 1 |
| 33 #define ERROR_G 1 | 33 #define ERROR_G 1 |
| 34 #define ERROR_B 3 | 34 #define ERROR_B 3 |
| 35 #define ERROR_FULL 5 | 35 #define ERROR_FULL 5 |
| 36 #define ERROR_J420 3 | 36 #define ERROR_J420 3 |
| 37 #endif | 37 #endif |
| 38 | 38 |
| 39 #define TESTCS(TESTNAME, YUVTOARGB, ARGBTOYUV, HS1, HS, HN, DIFF) \ | 39 #define TESTCS(TESTNAME, YUVTOARGB, ARGBTOYUV, HS1, HS, HN, DIFF) \ |
| 40 TEST_F(LibYUVColorTest, TESTNAME) { \ | 40 TEST_F(LibYUVColorTest, TESTNAME) { \ |
| 41 const int kPixels = benchmark_width_ * benchmark_height_; \ | 41 const int kPixels = benchmark_width_ * benchmark_height_; \ |
| 42 const int kHalfPixels = ((benchmark_width_ + 1) / 2) * \ | 42 const int kHalfPixels = ((benchmark_width_ + 1) / 2) * \ |
| 43 ((benchmark_height_ + HS1) / HS); \ | 43 ((benchmark_height_ + HS1) / HS); \ |
| 44 align_buffer_64(orig_y, kPixels); \ | 44 align_buffer_page_end(orig_y, kPixels); \ |
| 45 align_buffer_64(orig_u, kHalfPixels); \ | 45 align_buffer_page_end(orig_u, kHalfPixels); \ |
| 46 align_buffer_64(orig_v, kHalfPixels); \ | 46 align_buffer_page_end(orig_v, kHalfPixels); \ |
| 47 align_buffer_64(orig_pixels, kPixels * 4); \ | 47 align_buffer_page_end(orig_pixels, kPixels * 4); \ |
| 48 align_buffer_64(temp_y, kPixels); \ | 48 align_buffer_page_end(temp_y, kPixels); \ |
| 49 align_buffer_64(temp_u, kHalfPixels); \ | 49 align_buffer_page_end(temp_u, kHalfPixels); \ |
| 50 align_buffer_64(temp_v, kHalfPixels); \ | 50 align_buffer_page_end(temp_v, kHalfPixels); \ |
| 51 align_buffer_64(dst_pixels_opt, kPixels * 4); \ | 51 align_buffer_page_end(dst_pixels_opt, kPixels * 4); \ |
| 52 align_buffer_64(dst_pixels_c, kPixels * 4); \ | 52 align_buffer_page_end(dst_pixels_c, kPixels * 4); \ |
| 53 \ | 53 \ |
| 54 MemRandomize(orig_pixels, kPixels * 4); \ | 54 MemRandomize(orig_pixels, kPixels * 4); \ |
| 55 MemRandomize(orig_y, kPixels); \ | 55 MemRandomize(orig_y, kPixels); \ |
| 56 MemRandomize(orig_u, kHalfPixels); \ | 56 MemRandomize(orig_u, kHalfPixels); \ |
| 57 MemRandomize(orig_v, kHalfPixels); \ | 57 MemRandomize(orig_v, kHalfPixels); \ |
| 58 MemRandomize(temp_y, kPixels); \ | 58 MemRandomize(temp_y, kPixels); \ |
| 59 MemRandomize(temp_u, kHalfPixels); \ | 59 MemRandomize(temp_u, kHalfPixels); \ |
| 60 MemRandomize(temp_v, kHalfPixels); \ | 60 MemRandomize(temp_v, kHalfPixels); \ |
| 61 MemRandomize(dst_pixels_opt, kPixels * 4); \ | 61 MemRandomize(dst_pixels_opt, kPixels * 4); \ |
| 62 MemRandomize(dst_pixels_c, kPixels * 4); \ | 62 MemRandomize(dst_pixels_c, kPixels * 4); \ |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 /* Test C and SIMD match. */ \ | 125 /* Test C and SIMD match. */ \ |
| 126 for (int i = 0; i < kPixels * 4; ++i) { \ | 126 for (int i = 0; i < kPixels * 4; ++i) { \ |
| 127 EXPECT_EQ(dst_pixels_c[i], dst_pixels_opt[i]); \ | 127 EXPECT_EQ(dst_pixels_c[i], dst_pixels_opt[i]); \ |
| 128 } \ | 128 } \ |
| 129 /* Test SIMD is close to original. */ \ | 129 /* Test SIMD is close to original. */ \ |
| 130 for (int i = 0; i < kPixels * 4; ++i) { \ | 130 for (int i = 0; i < kPixels * 4; ++i) { \ |
| 131 EXPECT_NEAR(static_cast<int>(orig_pixels[i]), \ | 131 EXPECT_NEAR(static_cast<int>(orig_pixels[i]), \ |
| 132 static_cast<int>(dst_pixels_opt[i]), DIFF); \ | 132 static_cast<int>(dst_pixels_opt[i]), DIFF); \ |
| 133 } \ | 133 } \ |
| 134 \ | 134 \ |
| 135 free_aligned_buffer_64(orig_pixels); \ | 135 free_aligned_buffer_page_end(orig_pixels); \ |
| 136 free_aligned_buffer_64(orig_y); \ | 136 free_aligned_buffer_page_end(orig_y); \ |
| 137 free_aligned_buffer_64(orig_u); \ | 137 free_aligned_buffer_page_end(orig_u); \ |
| 138 free_aligned_buffer_64(orig_v); \ | 138 free_aligned_buffer_page_end(orig_v); \ |
| 139 free_aligned_buffer_64(temp_y); \ | 139 free_aligned_buffer_page_end(temp_y); \ |
| 140 free_aligned_buffer_64(temp_u); \ | 140 free_aligned_buffer_page_end(temp_u); \ |
| 141 free_aligned_buffer_64(temp_v); \ | 141 free_aligned_buffer_page_end(temp_v); \ |
| 142 free_aligned_buffer_64(dst_pixels_opt); \ | 142 free_aligned_buffer_page_end(dst_pixels_opt); \ |
| 143 free_aligned_buffer_64(dst_pixels_c); \ | 143 free_aligned_buffer_page_end(dst_pixels_c); \ |
| 144 } \ | 144 } \ |
| 145 | 145 |
| 146 TESTCS(TestI420, I420ToARGB, ARGBToI420, 1, 2, benchmark_width_, ERROR_FULL) | 146 TESTCS(TestI420, I420ToARGB, ARGBToI420, 1, 2, benchmark_width_, ERROR_FULL) |
| 147 TESTCS(TestI422, I422ToARGB, ARGBToI422, 0, 1, 0, ERROR_FULL) | 147 TESTCS(TestI422, I422ToARGB, ARGBToI422, 0, 1, 0, ERROR_FULL) |
| 148 TESTCS(TestJ420, J420ToARGB, ARGBToJ420, 1, 2, benchmark_width_, ERROR_J420) | 148 TESTCS(TestJ420, J420ToARGB, ARGBToJ420, 1, 2, benchmark_width_, ERROR_J420) |
| 149 TESTCS(TestJ422, J422ToARGB, ARGBToJ422, 0, 1, 0, 3) | 149 TESTCS(TestJ422, J422ToARGB, ARGBToJ422, 0, 1, 0, 3) |
| 150 | 150 |
| 151 static void YUVToRGB(int y, int u, int v, int* r, int* g, int* b) { | 151 static void YUVToRGB(int y, int u, int v, int* r, int* g, int* b) { |
| 152 const int kWidth = 16; | 152 const int kWidth = 16; |
| 153 const int kHeight = 1; | 153 const int kHeight = 1; |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 EXPECT_EQ(r0, r1); | 561 EXPECT_EQ(r0, r1); |
| 562 EXPECT_EQ(g0, g1); | 562 EXPECT_EQ(g0, g1); |
| 563 EXPECT_EQ(b0, b1); | 563 EXPECT_EQ(b0, b1); |
| 564 EXPECT_EQ(r0, r2); | 564 EXPECT_EQ(r0, r2); |
| 565 EXPECT_EQ(g0, g2); | 565 EXPECT_EQ(g0, g2); |
| 566 EXPECT_EQ(b0, b2); | 566 EXPECT_EQ(b0, b2); |
| 567 } | 567 } |
| 568 } | 568 } |
| 569 | 569 |
| 570 } // namespace libyuv | 570 } // namespace libyuv |
| OLD | NEW |