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 "test/register_state_check.h"
11 #include "third_party/googletest/src/include/gtest/gtest.h"
13 #include "vpx_config.h"
15 #include "vpx/vpx_integer.h"
16 #include "vpx_mem/vpx_mem.h"
19 typedef void (*post_proc_func_t)(unsigned char *src_ptr,
20 unsigned char *dst_ptr,
21 int src_pixels_per_line,
22 int dst_pixels_per_line,
24 unsigned char *flimit,
29 class Vp8PostProcessingFilterTest
30 : public ::testing::TestWithParam<post_proc_func_t> {};
32 // Test routine for the VP8 post-processing function
33 // vp8_post_proc_down_and_across_mb_row_c.
35 TEST_P(Vp8PostProcessingFilterTest, FilterOutputCheck) {
36 // Size of the underlying data block that will be filtered.
37 const int block_width = 16;
38 const int block_height = 16;
40 // 5-tap filter needs 2 padding rows above and below the block in the input.
41 const int input_width = block_width;
42 const int input_height = block_height + 4;
43 const int input_stride = input_width;
44 const int input_size = input_width * input_height;
46 // Filter extends output block by 8 samples at left and right edges.
47 const int output_width = block_width + 16;
48 const int output_height = block_height;
49 const int output_stride = output_width;
50 const int output_size = output_width * output_height;
52 uint8_t *const src_image =
53 reinterpret_cast<uint8_t*>(vpx_calloc(input_size, 1));
54 uint8_t *const dst_image =
55 reinterpret_cast<uint8_t*>(vpx_calloc(output_size, 1));
57 // Pointers to top-left pixel of block in the input and output images.
58 uint8_t *const src_image_ptr = src_image + (input_stride << 1);
59 uint8_t *const dst_image_ptr = dst_image + 8;
60 uint8_t *const flimits = reinterpret_cast<uint8_t *>(vpx_memalign(16, block_width));
61 (void)vpx_memset(flimits, 255, block_width);
63 // Initialize pixels in the input:
64 // block pixels to value 1,
65 // border pixels to value 10.
66 (void)vpx_memset(src_image, 10, input_size);
67 uint8_t *pixel_ptr = src_image_ptr;
68 for (int i = 0; i < block_height; ++i) {
69 for (int j = 0; j < block_width; ++j) {
72 pixel_ptr += input_stride;
75 // Initialize pixels in the output to 99.
76 (void)vpx_memset(dst_image, 99, output_size);
78 REGISTER_STATE_CHECK(GetParam()(src_image_ptr, dst_image_ptr, input_stride,
79 output_stride, block_width, flimits, 16));
81 static const uint8_t expected_data[block_height] = {
82 4, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 4
85 pixel_ptr = dst_image_ptr;
86 for (int i = 0; i < block_height; ++i) {
87 for (int j = 0; j < block_width; ++j) {
88 EXPECT_EQ(expected_data[i], pixel_ptr[j])
89 << "Vp8PostProcessingFilterTest failed with invalid filter output";
91 pixel_ptr += output_stride;
99 INSTANTIATE_TEST_CASE_P(C, Vp8PostProcessingFilterTest,
100 ::testing::Values(vp8_post_proc_down_and_across_mb_row_c));
103 INSTANTIATE_TEST_CASE_P(SSE2, Vp8PostProcessingFilterTest,
104 ::testing::Values(vp8_post_proc_down_and_across_mb_row_sse2));