| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/base_paths.h" | 5 #include "base/base_paths.h" |
| 6 #include "base/cpu.h" | 6 #include "base/cpu.h" |
| 7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "media/base/djb2.h" | 10 #include "media/base/djb2.h" |
| 11 #include "media/base/simd/convert_rgb_to_yuv.h" | 11 #include "media/base/simd/convert_rgb_to_yuv.h" |
| 12 #include "media/base/simd/convert_yuv_to_rgb.h" | 12 #include "media/base/simd/convert_yuv_to_rgb.h" |
| 13 #include "media/base/simd/filter_yuv.h" | 13 #include "media/base/simd/filter_yuv.h" |
| 14 #include "media/base/simd/yuv_to_rgb_table.h" | |
| 15 #include "media/base/yuv_convert.h" | 14 #include "media/base/yuv_convert.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "ui/gfx/geometry/rect.h" | 16 #include "ui/gfx/geometry/rect.h" |
| 18 | 17 |
| 19 // Size of raw image. | 18 // Size of raw image. |
| 20 static const int kSourceWidth = 640; | 19 static const int kSourceWidth = 640; |
| 21 static const int kSourceHeight = 360; | 20 static const int kSourceHeight = 360; |
| 22 static const int kSourceYSize = kSourceWidth * kSourceHeight; | 21 static const int kSourceYSize = kSourceWidth * kSourceHeight; |
| 23 static const int kSourceUOffset = kSourceYSize; | 22 static const int kSourceUOffset = kSourceYSize; |
| 24 static const int kSourceVOffset = kSourceYSize * 5 / 4; | 23 static const int kSourceVOffset = kSourceYSize * 5 / 4; |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 media::ScaleFilter scale_filter; | 167 media::ScaleFilter scale_filter; |
| 169 uint32 rgb_hash; | 168 uint32 rgb_hash; |
| 170 }; | 169 }; |
| 171 | 170 |
| 172 class YUVScaleTest : public ::testing::TestWithParam<YUVScaleTestData> { | 171 class YUVScaleTest : public ::testing::TestWithParam<YUVScaleTestData> { |
| 173 public: | 172 public: |
| 174 YUVScaleTest() { | 173 YUVScaleTest() { |
| 175 switch (GetParam().yuv_type) { | 174 switch (GetParam().yuv_type) { |
| 176 case media::YV12: | 175 case media::YV12: |
| 177 case media::YV12J: | 176 case media::YV12J: |
| 177 case media::YV12HD: |
| 178 ReadYV12Data(&yuv_bytes_); | 178 ReadYV12Data(&yuv_bytes_); |
| 179 break; | 179 break; |
| 180 case media::YV16: | 180 case media::YV16: |
| 181 ReadYV16Data(&yuv_bytes_); | 181 ReadYV16Data(&yuv_bytes_); |
| 182 break; | 182 break; |
| 183 } | 183 } |
| 184 | 184 |
| 185 rgb_bytes_.reset(new uint8[kRGBSizeScaled]); | 185 rgb_bytes_.reset(new uint8[kRGBSizeScaled]); |
| 186 } | 186 } |
| 187 | 187 |
| 188 // Helpers for getting the proper Y, U and V plane offsets. | 188 // Helpers for getting the proper Y, U and V plane offsets. |
| 189 uint8* y_plane() { return yuv_bytes_.get(); } | 189 uint8* y_plane() { return yuv_bytes_.get(); } |
| 190 uint8* u_plane() { return yuv_bytes_.get() + kSourceYSize; } | 190 uint8* u_plane() { return yuv_bytes_.get() + kSourceYSize; } |
| 191 uint8* v_plane() { | 191 uint8* v_plane() { |
| 192 switch (GetParam().yuv_type) { | 192 switch (GetParam().yuv_type) { |
| 193 case media::YV12: | 193 case media::YV12: |
| 194 case media::YV12J: | 194 case media::YV12J: |
| 195 case media::YV12HD: |
| 195 return yuv_bytes_.get() + kSourceVOffset; | 196 return yuv_bytes_.get() + kSourceVOffset; |
| 196 case media::YV16: | 197 case media::YV16: |
| 197 return yuv_bytes_.get() + kSourceYSize * 3 / 2; | 198 return yuv_bytes_.get() + kSourceYSize * 3 / 2; |
| 198 } | 199 } |
| 199 return NULL; | 200 return NULL; |
| 200 } | 201 } |
| 201 | 202 |
| 202 scoped_ptr<uint8[]> yuv_bytes_; | 203 scoped_ptr<uint8[]> yuv_bytes_; |
| 203 scoped_ptr<uint8[]> rgb_bytes_; | 204 scoped_ptr<uint8[]> rgb_bytes_; |
| 204 }; | 205 }; |
| (...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 882 EXPECT_EQ(0, memcmp(rgb_bytes_reference.get(), | 883 EXPECT_EQ(0, memcmp(rgb_bytes_reference.get(), |
| 883 rgb_bytes_converted.get(), | 884 rgb_bytes_converted.get(), |
| 884 kWidth * kBpp)); | 885 kWidth * kBpp)); |
| 885 } | 886 } |
| 886 | 887 |
| 887 #endif // defined(ARCH_CPU_X86_64) | 888 #endif // defined(ARCH_CPU_X86_64) |
| 888 | 889 |
| 889 #endif // defined(ARCH_CPU_X86_FAMILY) | 890 #endif // defined(ARCH_CPU_X86_FAMILY) |
| 890 | 891 |
| 891 } // namespace media | 892 } // namespace media |
| OLD | NEW |