OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2010 The WebM 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 <string.h> | 11 #include <string.h> |
12 #include "test/acm_random.h" | 12 #include "test/acm_random.h" |
13 #include "test/register_state_check.h" | 13 #include "test/register_state_check.h" |
14 #include "test/util.h" | 14 #include "test/util.h" |
15 #include "third_party/googletest/src/include/gtest/gtest.h" | 15 #include "third_party/googletest/src/include/gtest/gtest.h" |
16 | 16 |
17 #include "./vpx_config.h" | 17 #include "./vpx_config.h" |
18 #include "./vp9_rtcd.h" | 18 #include "./vp9_rtcd.h" |
19 #include "vp9/common/vp9_filter.h" | 19 #include "vp9/common/vp9_filter.h" |
20 #include "vpx_mem/vpx_mem.h" | 20 #include "vpx_mem/vpx_mem.h" |
21 #include "vpx_ports/mem.h" | 21 #include "vpx_ports/mem.h" |
22 | 22 |
23 namespace { | 23 namespace { |
24 typedef void (*convolve_fn_t)(const uint8_t *src, ptrdiff_t src_stride, | 24 typedef void (*ConvolveFunc)(const uint8_t *src, ptrdiff_t src_stride, |
25 uint8_t *dst, ptrdiff_t dst_stride, | 25 uint8_t *dst, ptrdiff_t dst_stride, |
26 const int16_t *filter_x, int filter_x_stride, | 26 const int16_t *filter_x, int filter_x_stride, |
27 const int16_t *filter_y, int filter_y_stride, | 27 const int16_t *filter_y, int filter_y_stride, |
28 int w, int h); | 28 int w, int h); |
29 | 29 |
30 struct ConvolveFunctions { | 30 struct ConvolveFunctions { |
31 ConvolveFunctions(convolve_fn_t h8, convolve_fn_t h8_avg, | 31 ConvolveFunctions(ConvolveFunc h8, ConvolveFunc h8_avg, |
32 convolve_fn_t v8, convolve_fn_t v8_avg, | 32 ConvolveFunc v8, ConvolveFunc v8_avg, |
33 convolve_fn_t hv8, convolve_fn_t hv8_avg) | 33 ConvolveFunc hv8, ConvolveFunc hv8_avg) |
34 : h8_(h8), v8_(v8), hv8_(hv8), h8_avg_(h8_avg), v8_avg_(v8_avg), | 34 : h8_(h8), v8_(v8), hv8_(hv8), h8_avg_(h8_avg), v8_avg_(v8_avg), |
35 hv8_avg_(hv8_avg) {} | 35 hv8_avg_(hv8_avg) {} |
36 | 36 |
37 convolve_fn_t h8_; | 37 ConvolveFunc h8_; |
38 convolve_fn_t v8_; | 38 ConvolveFunc v8_; |
39 convolve_fn_t hv8_; | 39 ConvolveFunc hv8_; |
40 convolve_fn_t h8_avg_; | 40 ConvolveFunc h8_avg_; |
41 convolve_fn_t v8_avg_; | 41 ConvolveFunc v8_avg_; |
42 convolve_fn_t hv8_avg_; | 42 ConvolveFunc hv8_avg_; |
43 }; | 43 }; |
44 | 44 |
45 typedef std::tr1::tuple<int, int, const ConvolveFunctions*> convolve_param_t; | 45 typedef std::tr1::tuple<int, int, const ConvolveFunctions *> ConvolveParam; |
46 | 46 |
47 // Reference 8-tap subpixel filter, slightly modified to fit into this test. | 47 // Reference 8-tap subpixel filter, slightly modified to fit into this test. |
48 #define VP9_FILTER_WEIGHT 128 | 48 #define VP9_FILTER_WEIGHT 128 |
49 #define VP9_FILTER_SHIFT 7 | 49 #define VP9_FILTER_SHIFT 7 |
50 uint8_t clip_pixel(int x) { | 50 uint8_t clip_pixel(int x) { |
51 return x < 0 ? 0 : | 51 return x < 0 ? 0 : |
52 x > 255 ? 255 : | 52 x > 255 ? 255 : |
53 x; | 53 x; |
54 } | 54 } |
55 | 55 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 uint8_t tmp[64 * 64]; | 162 uint8_t tmp[64 * 64]; |
163 | 163 |
164 assert(output_width <= 64); | 164 assert(output_width <= 64); |
165 assert(output_height <= 64); | 165 assert(output_height <= 64); |
166 filter_block2d_8_c(src_ptr, src_stride, HFilter, VFilter, tmp, 64, | 166 filter_block2d_8_c(src_ptr, src_stride, HFilter, VFilter, tmp, 64, |
167 output_width, output_height); | 167 output_width, output_height); |
168 block2d_average_c(tmp, 64, dst_ptr, dst_stride, | 168 block2d_average_c(tmp, 64, dst_ptr, dst_stride, |
169 output_width, output_height); | 169 output_width, output_height); |
170 } | 170 } |
171 | 171 |
172 class ConvolveTest : public ::testing::TestWithParam<convolve_param_t> { | 172 class ConvolveTest : public ::testing::TestWithParam<ConvolveParam> { |
173 public: | 173 public: |
174 static void SetUpTestCase() { | 174 static void SetUpTestCase() { |
175 // Force input_ to be unaligned, output to be 16 byte aligned. | 175 // Force input_ to be unaligned, output to be 16 byte aligned. |
176 input_ = reinterpret_cast<uint8_t*>( | 176 input_ = reinterpret_cast<uint8_t*>( |
177 vpx_memalign(kDataAlignment, kInputBufferSize + 1)) + 1; | 177 vpx_memalign(kDataAlignment, kInputBufferSize + 1)) + 1; |
178 output_ = reinterpret_cast<uint8_t*>( | 178 output_ = reinterpret_cast<uint8_t*>( |
179 vpx_memalign(kDataAlignment, kOutputBufferSize)); | 179 vpx_memalign(kDataAlignment, kOutputBufferSize)); |
180 } | 180 } |
181 | 181 |
182 static void TearDownTestCase() { | 182 static void TearDownTestCase() { |
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 make_tuple(8, 16, &convolve8_dspr2), | 726 make_tuple(8, 16, &convolve8_dspr2), |
727 make_tuple(16, 16, &convolve8_dspr2), | 727 make_tuple(16, 16, &convolve8_dspr2), |
728 make_tuple(32, 16, &convolve8_dspr2), | 728 make_tuple(32, 16, &convolve8_dspr2), |
729 make_tuple(16, 32, &convolve8_dspr2), | 729 make_tuple(16, 32, &convolve8_dspr2), |
730 make_tuple(32, 32, &convolve8_dspr2), | 730 make_tuple(32, 32, &convolve8_dspr2), |
731 make_tuple(64, 32, &convolve8_dspr2), | 731 make_tuple(64, 32, &convolve8_dspr2), |
732 make_tuple(32, 64, &convolve8_dspr2), | 732 make_tuple(32, 64, &convolve8_dspr2), |
733 make_tuple(64, 64, &convolve8_dspr2))); | 733 make_tuple(64, 64, &convolve8_dspr2))); |
734 #endif | 734 #endif |
735 } // namespace | 735 } // namespace |
OLD | NEW |