2 * Copyright (c) 2012 The WebM project authors. All Rights Reserved.
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
10 #include "third_party/googletest/src/include/gtest/gtest.h"
12 #include "vpx_config.h"
14 #include "vpx/vpx_integer.h"
15 #include "vpx_mem/vpx_mem.h"
18 typedef void (*post_proc_func_t)(unsigned char *src_ptr,
19 unsigned char *dst_ptr,
20 int src_pixels_per_line,
21 int dst_pixels_per_line,
23 unsigned char *flimit,
28 class Vp8PostProcessingFilterTest
29 : public ::testing::TestWithParam<post_proc_func_t> {};
31 // Test routine for the VP8 post-processing function
32 // vp8_post_proc_down_and_across_mb_row_c.
34 TEST_P(Vp8PostProcessingFilterTest, FilterOutputCheck) {
35 // Size of the underlying data block that will be filtered.
36 const int block_width = 16;
37 const int block_height = 16;
39 // 5-tap filter needs 2 padding rows above and below the block in the input.
40 const int input_width = block_width;
41 const int input_height = block_height + 4;
42 const int input_stride = input_width;
43 const int input_size = input_width * input_height;
45 // Filter extends output block by 8 samples at left and right edges.
46 const int output_width = block_width + 16;
47 const int output_height = block_height;
48 const int output_stride = output_width;
49 const int output_size = output_width * output_height;
51 uint8_t *const src_image =
52 reinterpret_cast<uint8_t*>(vpx_calloc(input_size, 1));
53 uint8_t *const dst_image =
54 reinterpret_cast<uint8_t*>(vpx_calloc(output_size, 1));
56 // Pointers to top-left pixel of block in the input and output images.
57 uint8_t *const src_image_ptr = src_image + (input_stride << 1);
58 uint8_t *const dst_image_ptr = dst_image + 8;
59 uint8_t *const flimits = reinterpret_cast<uint8_t *>(vpx_memalign(16, block_width));
60 (void)vpx_memset(flimits, 255, block_width);
62 // Initialize pixels in the input:
63 // block pixels to value 1,
64 // border pixels to value 10.
65 (void)vpx_memset(src_image, 10, input_size);
66 uint8_t *pixel_ptr = src_image_ptr;
67 for (int i = 0; i < block_height; ++i) {
68 for (int j = 0; j < block_width; ++j) {
71 pixel_ptr += input_stride;
74 // Initialize pixels in the output to 99.
75 (void)vpx_memset(dst_image, 99, output_size);
77 GetParam()(src_image_ptr, dst_image_ptr, input_stride,
78 output_stride, block_width, flimits, 16);
80 static const uint8_t expected_data[block_height] = {
81 4, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 4
84 pixel_ptr = dst_image_ptr;
85 for (int i = 0; i < block_height; ++i) {
86 for (int j = 0; j < block_width; ++j) {
87 EXPECT_EQ(expected_data[i], pixel_ptr[j])
88 << "Vp8PostProcessingFilterTest failed with invalid filter output";
90 pixel_ptr += output_stride;
98 INSTANTIATE_TEST_CASE_P(C, Vp8PostProcessingFilterTest,
99 ::testing::Values(vp8_post_proc_down_and_across_mb_row_c));
102 INSTANTIATE_TEST_CASE_P(SSE2, Vp8PostProcessingFilterTest,
103 ::testing::Values(vp8_post_proc_down_and_across_mb_row_sse2));