1/*
2 *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3 *
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.
9 */
10
11#include "vpx_config.h"
12#include "vp8/encoder/variance.h"
13#include "vp8/common/filter.h"
14#include "vp8/common/arm/bilinearfilter_arm.h"
15
16#if HAVE_ARMV6
17
18unsigned int vp8_sub_pixel_variance8x8_armv6
19(
20    const unsigned char  *src_ptr,
21    int  src_pixels_per_line,
22    int  xoffset,
23    int  yoffset,
24    const unsigned char *dst_ptr,
25    int dst_pixels_per_line,
26    unsigned int *sse
27)
28{
29    unsigned short first_pass[10*8];
30    unsigned char  second_pass[8*8];
31    const short *HFilter, *VFilter;
32
33    HFilter = vp8_bilinear_filters[xoffset];
34    VFilter = vp8_bilinear_filters[yoffset];
35
36    vp8_filter_block2d_bil_first_pass_armv6(src_ptr, first_pass,
37                                            src_pixels_per_line,
38                                            9, 8, HFilter);
39    vp8_filter_block2d_bil_second_pass_armv6(first_pass, second_pass,
40                                             8, 8, 8, VFilter);
41
42    return vp8_variance8x8_armv6(second_pass, 8, dst_ptr,
43                                   dst_pixels_per_line, sse);
44}
45
46unsigned int vp8_sub_pixel_variance16x16_armv6
47(
48    const unsigned char  *src_ptr,
49    int  src_pixels_per_line,
50    int  xoffset,
51    int  yoffset,
52    const unsigned char *dst_ptr,
53    int dst_pixels_per_line,
54    unsigned int *sse
55)
56{
57    unsigned short first_pass[36*16];
58    unsigned char  second_pass[20*16];
59    const short *HFilter, *VFilter;
60    unsigned int var;
61
62    if (xoffset == 4 && yoffset == 0)
63    {
64        var = vp8_variance_halfpixvar16x16_h_armv6(src_ptr, src_pixels_per_line,
65                                                   dst_ptr, dst_pixels_per_line, sse);
66    }
67    else if (xoffset == 0 && yoffset == 4)
68    {
69        var = vp8_variance_halfpixvar16x16_v_armv6(src_ptr, src_pixels_per_line,
70                                                   dst_ptr, dst_pixels_per_line, sse);
71    }
72    else if (xoffset == 4 && yoffset == 4)
73    {
74        var = vp8_variance_halfpixvar16x16_hv_armv6(src_ptr, src_pixels_per_line,
75                                                   dst_ptr, dst_pixels_per_line, sse);
76    }
77    else
78    {
79        HFilter = vp8_bilinear_filters[xoffset];
80        VFilter = vp8_bilinear_filters[yoffset];
81
82        vp8_filter_block2d_bil_first_pass_armv6(src_ptr, first_pass,
83                                                src_pixels_per_line,
84                                                17, 16, HFilter);
85        vp8_filter_block2d_bil_second_pass_armv6(first_pass, second_pass,
86                                                 16, 16, 16, VFilter);
87
88        var = vp8_variance16x16_armv6(second_pass, 16, dst_ptr,
89                                       dst_pixels_per_line, sse);
90    }
91    return var;
92}
93
94#endif /* HAVE_ARMV6 */
95
96
97#if HAVE_ARMV7
98
99unsigned int vp8_sub_pixel_variance16x16_neon
100(
101    const unsigned char  *src_ptr,
102    int  src_pixels_per_line,
103    int  xoffset,
104    int  yoffset,
105    const unsigned char *dst_ptr,
106    int dst_pixels_per_line,
107    unsigned int *sse
108)
109{
110  if (xoffset == 4 && yoffset == 0)
111    return vp8_variance_halfpixvar16x16_h_neon(src_ptr, src_pixels_per_line, dst_ptr, dst_pixels_per_line, sse);
112  else if (xoffset == 0 && yoffset == 4)
113    return vp8_variance_halfpixvar16x16_v_neon(src_ptr, src_pixels_per_line, dst_ptr, dst_pixels_per_line, sse);
114  else if (xoffset == 4 && yoffset == 4)
115    return vp8_variance_halfpixvar16x16_hv_neon(src_ptr, src_pixels_per_line, dst_ptr, dst_pixels_per_line, sse);
116  else
117    return vp8_sub_pixel_variance16x16_neon_func(src_ptr, src_pixels_per_line, xoffset, yoffset, dst_ptr, dst_pixels_per_line, sse);
118}
119
120#endif
121