1 /*
2 * Copyright (c) 2013 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 <assert.h>
12
13 #include "./vpx_dsp_rtcd.h"
14 #include "vpx_dsp/vpx_dsp_common.h"
15 #include "vpx_dsp/vpx_filter.h"
16 #include "vpx_ports/mem.h"
17
vpx_convolve8_neon(const uint8_t * src,ptrdiff_t src_stride,uint8_t * dst,ptrdiff_t dst_stride,const InterpKernel * filter,int x0_q4,int x_step_q4,int y0_q4,int y_step_q4,int w,int h)18 void vpx_convolve8_neon(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst,
19 ptrdiff_t dst_stride, const InterpKernel *filter,
20 int x0_q4, int x_step_q4, int y0_q4, int y_step_q4,
21 int w, int h) {
22 // Given our constraints: w <= 64, h <= 64, taps <= 8 we can reduce the
23 // maximum buffer size to 64 * (64 + 7) (+1 row to make it divisible by 4).
24 DECLARE_ALIGNED(32, uint8_t, im_block[64 * 72]);
25 const int im_stride = 64;
26
27 const int vert_filter_taps = vpx_get_filter_taps(filter[y0_q4]) <= 4 ? 4 : 8;
28 // Account for the vertical phase needing vert_filter_taps / 2 - 1 lines prior
29 // and vert_filter_taps / 2 lines post. (+1 to make total divisible by 4.)
30 const int im_height = h + vert_filter_taps;
31 const ptrdiff_t border_offset = vert_filter_taps / 2 - 1;
32
33 assert(y_step_q4 == 16);
34 assert(x_step_q4 == 16);
35
36 // Filter starting border_offset rows back. The Neon implementation will
37 // ignore the given height and filter a multiple of 4 lines. Since this goes
38 // into the temporary buffer which has lots of extra room and is subsequently
39 // discarded this is safe if somewhat less than ideal.
40 vpx_convolve8_horiz_neon(src - src_stride * border_offset, src_stride,
41 im_block, im_stride, filter, x0_q4, x_step_q4, y0_q4,
42 y_step_q4, w, im_height);
43
44 // Step into the temporary buffer border_offset rows to get actual frame data.
45 vpx_convolve8_vert_neon(im_block + im_stride * border_offset, im_stride, dst,
46 dst_stride, filter, x0_q4, x_step_q4, y0_q4,
47 y_step_q4, w, h);
48 }
49
vpx_convolve8_avg_neon(const uint8_t * src,ptrdiff_t src_stride,uint8_t * dst,ptrdiff_t dst_stride,const InterpKernel * filter,int x0_q4,int x_step_q4,int y0_q4,int y_step_q4,int w,int h)50 void vpx_convolve8_avg_neon(const uint8_t *src, ptrdiff_t src_stride,
51 uint8_t *dst, ptrdiff_t dst_stride,
52 const InterpKernel *filter, int x0_q4,
53 int x_step_q4, int y0_q4, int y_step_q4, int w,
54 int h) {
55 DECLARE_ALIGNED(32, uint8_t, im_block[64 * 72]);
56 const int im_stride = 64;
57 const int im_height = h + SUBPEL_TAPS;
58 const ptrdiff_t border_offset = SUBPEL_TAPS / 2 - 1;
59
60 assert(y_step_q4 == 16);
61 assert(x_step_q4 == 16);
62
63 // This implementation has the same issues as above. In addition, we only want
64 // to average the values after both passes.
65 vpx_convolve8_horiz_neon(src - src_stride * border_offset, src_stride,
66 im_block, im_stride, filter, x0_q4, x_step_q4, y0_q4,
67 y_step_q4, w, im_height);
68
69 vpx_convolve8_avg_vert_neon(im_block + im_stride * border_offset, im_stride,
70 dst, dst_stride, filter, x0_q4, x_step_q4, y0_q4,
71 y_step_q4, w, h);
72 }
73