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,
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_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;
60 // Initialize pixels in the input:
61 // block pixels to value 1,
62 // border pixels to value 10.
63 (void)vpx_memset(src_image, 10, input_size);
64 uint8_t *pixel_ptr = src_image_ptr;
65 for (int i = 0; i < block_height; ++i) {
66 for (int j = 0; j < block_width; ++j) {
69 pixel_ptr += input_stride;
72 // Initialize pixels in the output to 99.
73 (void)vpx_memset(dst_image, 99, output_size);
75 GetParam()(src_image_ptr, dst_image_ptr, input_stride,
76 output_stride, block_height, block_width,
79 static const uint8_t expected_data[block_height] = {
80 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3
83 pixel_ptr = dst_image;
84 for (int i = 0; i < block_height; ++i) {
85 for (int j = 0; j < block_width; ++j) {
86 EXPECT_EQ(expected_data[i], pixel_ptr[j])
87 << "Vp8PostProcessingFilterTest failed with invalid filter output";
89 pixel_ptr += output_stride;
96 INSTANTIATE_TEST_CASE_P(C, Vp8PostProcessingFilterTest,
97 ::testing::Values(vp8_post_proc_down_and_across_c));
100 INSTANTIATE_TEST_CASE_P(MMX, Vp8PostProcessingFilterTest,
101 ::testing::Values(vp8_post_proc_down_and_across_mmx));
105 INSTANTIATE_TEST_CASE_P(SSE2, Vp8PostProcessingFilterTest,
106 ::testing::Values(vp8_post_proc_down_and_across_xmm));