FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
hevcdsp_init_neon.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 Seppo Tomperi <seppo.tomperi@vtt.fi>
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include "libavutil/attributes.h"
22 #include "libavutil/arm/cpu.h"
23 #include "libavcodec/hevcdsp.h"
24 
25 void ff_hevc_v_loop_filter_luma_neon(uint8_t *_pix, ptrdiff_t _stride, int _beta, int *_tc, uint8_t *_no_p, uint8_t *_no_q);
26 void ff_hevc_h_loop_filter_luma_neon(uint8_t *_pix, ptrdiff_t _stride, int _beta, int *_tc, uint8_t *_no_p, uint8_t *_no_q);
27 void ff_hevc_v_loop_filter_chroma_neon(uint8_t *_pix, ptrdiff_t _stride, int *_tc, uint8_t *_no_p, uint8_t *_no_q);
28 void ff_hevc_h_loop_filter_chroma_neon(uint8_t *_pix, ptrdiff_t _stride, int *_tc, uint8_t *_no_p, uint8_t *_no_q);
29 void ff_hevc_transform_4x4_neon_8(int16_t *coeffs, int col_limit);
30 void ff_hevc_transform_8x8_neon_8(int16_t *coeffs, int col_limit);
31 void ff_hevc_idct_4x4_dc_neon_8(int16_t *coeffs);
32 void ff_hevc_idct_8x8_dc_neon_8(int16_t *coeffs);
33 void ff_hevc_idct_16x16_dc_neon_8(int16_t *coeffs);
34 void ff_hevc_idct_32x32_dc_neon_8(int16_t *coeffs);
35 void ff_hevc_transform_luma_4x4_neon_8(int16_t *coeffs);
36 void ff_hevc_transform_add_4x4_neon_8(uint8_t *_dst, int16_t *coeffs,
37  ptrdiff_t stride);
38 void ff_hevc_transform_add_8x8_neon_8(uint8_t *_dst, int16_t *coeffs,
39  ptrdiff_t stride);
40 void ff_hevc_transform_add_16x16_neon_8(uint8_t *_dst, int16_t *coeffs,
41  ptrdiff_t stride);
42 void ff_hevc_transform_add_32x32_neon_8(uint8_t *_dst, int16_t *coeffs,
43  ptrdiff_t stride);
44 
45 #define PUT_PIXELS(name) \
46  void name(int16_t *dst, uint8_t *src, \
47  ptrdiff_t srcstride, int height, \
48  intptr_t mx, intptr_t my, int width)
49 PUT_PIXELS(ff_hevc_put_pixels_w2_neon_8);
50 PUT_PIXELS(ff_hevc_put_pixels_w4_neon_8);
51 PUT_PIXELS(ff_hevc_put_pixels_w6_neon_8);
52 PUT_PIXELS(ff_hevc_put_pixels_w8_neon_8);
53 PUT_PIXELS(ff_hevc_put_pixels_w12_neon_8);
54 PUT_PIXELS(ff_hevc_put_pixels_w16_neon_8);
55 PUT_PIXELS(ff_hevc_put_pixels_w24_neon_8);
56 PUT_PIXELS(ff_hevc_put_pixels_w32_neon_8);
57 PUT_PIXELS(ff_hevc_put_pixels_w48_neon_8);
58 PUT_PIXELS(ff_hevc_put_pixels_w64_neon_8);
59 #undef PUT_PIXELS
60 
61 static void (*put_hevc_qpel_neon[4][4])(int16_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride,
62  int height, int width);
63 static void (*put_hevc_qpel_uw_neon[4][4])(uint8_t *dst, ptrdiff_t dststride, uint8_t *_src, ptrdiff_t _srcstride,
64  int width, int height, int16_t* src2, ptrdiff_t src2stride);
65 void ff_hevc_put_qpel_neon_wrapper(int16_t *dst, uint8_t *src, ptrdiff_t srcstride,
66  int height, intptr_t mx, intptr_t my, int width);
67 void ff_hevc_put_qpel_uni_neon_wrapper(uint8_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride,
68  int height, intptr_t mx, intptr_t my, int width);
69 void ff_hevc_put_qpel_bi_neon_wrapper(uint8_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride,
70  int16_t *src2,
71  int height, intptr_t mx, intptr_t my, int width);
72 #define QPEL_FUNC(name) \
73  void name(int16_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride, \
74  int height, int width)
75 
76 QPEL_FUNC(ff_hevc_put_qpel_v1_neon_8);
77 QPEL_FUNC(ff_hevc_put_qpel_v2_neon_8);
78 QPEL_FUNC(ff_hevc_put_qpel_v3_neon_8);
79 QPEL_FUNC(ff_hevc_put_qpel_h1_neon_8);
80 QPEL_FUNC(ff_hevc_put_qpel_h2_neon_8);
81 QPEL_FUNC(ff_hevc_put_qpel_h3_neon_8);
82 QPEL_FUNC(ff_hevc_put_qpel_h1v1_neon_8);
83 QPEL_FUNC(ff_hevc_put_qpel_h1v2_neon_8);
84 QPEL_FUNC(ff_hevc_put_qpel_h1v3_neon_8);
85 QPEL_FUNC(ff_hevc_put_qpel_h2v1_neon_8);
86 QPEL_FUNC(ff_hevc_put_qpel_h2v2_neon_8);
87 QPEL_FUNC(ff_hevc_put_qpel_h2v3_neon_8);
88 QPEL_FUNC(ff_hevc_put_qpel_h3v1_neon_8);
89 QPEL_FUNC(ff_hevc_put_qpel_h3v2_neon_8);
90 QPEL_FUNC(ff_hevc_put_qpel_h3v3_neon_8);
91 #undef QPEL_FUNC
92 
93 #define QPEL_FUNC_UW_PIX(name) \
94  void name(uint8_t *dst, ptrdiff_t dststride, uint8_t *_src, ptrdiff_t _srcstride, \
95  int height, intptr_t mx, intptr_t my, int width);
96 QPEL_FUNC_UW_PIX(ff_hevc_put_qpel_uw_pixels_w4_neon_8);
97 QPEL_FUNC_UW_PIX(ff_hevc_put_qpel_uw_pixels_w8_neon_8);
98 QPEL_FUNC_UW_PIX(ff_hevc_put_qpel_uw_pixels_w16_neon_8);
99 QPEL_FUNC_UW_PIX(ff_hevc_put_qpel_uw_pixels_w24_neon_8);
100 QPEL_FUNC_UW_PIX(ff_hevc_put_qpel_uw_pixels_w32_neon_8);
101 QPEL_FUNC_UW_PIX(ff_hevc_put_qpel_uw_pixels_w48_neon_8);
102 QPEL_FUNC_UW_PIX(ff_hevc_put_qpel_uw_pixels_w64_neon_8);
103 #undef QPEL_FUNC_UW_PIX
104 
105 #define QPEL_FUNC_UW(name) \
106  void name(uint8_t *dst, ptrdiff_t dststride, uint8_t *_src, ptrdiff_t _srcstride, \
107  int width, int height, int16_t* src2, ptrdiff_t src2stride);
108 QPEL_FUNC_UW(ff_hevc_put_qpel_uw_pixels_neon_8);
109 QPEL_FUNC_UW(ff_hevc_put_qpel_uw_v1_neon_8);
110 QPEL_FUNC_UW(ff_hevc_put_qpel_uw_v2_neon_8);
111 QPEL_FUNC_UW(ff_hevc_put_qpel_uw_v3_neon_8);
112 QPEL_FUNC_UW(ff_hevc_put_qpel_uw_h1_neon_8);
113 QPEL_FUNC_UW(ff_hevc_put_qpel_uw_h2_neon_8);
114 QPEL_FUNC_UW(ff_hevc_put_qpel_uw_h3_neon_8);
115 QPEL_FUNC_UW(ff_hevc_put_qpel_uw_h1v1_neon_8);
116 QPEL_FUNC_UW(ff_hevc_put_qpel_uw_h1v2_neon_8);
117 QPEL_FUNC_UW(ff_hevc_put_qpel_uw_h1v3_neon_8);
118 QPEL_FUNC_UW(ff_hevc_put_qpel_uw_h2v1_neon_8);
119 QPEL_FUNC_UW(ff_hevc_put_qpel_uw_h2v2_neon_8);
120 QPEL_FUNC_UW(ff_hevc_put_qpel_uw_h2v3_neon_8);
121 QPEL_FUNC_UW(ff_hevc_put_qpel_uw_h3v1_neon_8);
122 QPEL_FUNC_UW(ff_hevc_put_qpel_uw_h3v2_neon_8);
123 QPEL_FUNC_UW(ff_hevc_put_qpel_uw_h3v3_neon_8);
124 #undef QPEL_FUNC_UW
125 
126 void ff_hevc_put_qpel_neon_wrapper(int16_t *dst, uint8_t *src, ptrdiff_t srcstride,
127  int height, intptr_t mx, intptr_t my, int width) {
128 
129  put_hevc_qpel_neon[my][mx](dst, MAX_PB_SIZE, src, srcstride, height, width);
130 }
131 
132 void ff_hevc_put_qpel_uni_neon_wrapper(uint8_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride,
133  int height, intptr_t mx, intptr_t my, int width) {
134 
135  put_hevc_qpel_uw_neon[my][mx](dst, dststride, src, srcstride, width, height, NULL, 0);
136 }
137 
138 void ff_hevc_put_qpel_bi_neon_wrapper(uint8_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride,
139  int16_t *src2,
140  int height, intptr_t mx, intptr_t my, int width) {
141  put_hevc_qpel_uw_neon[my][mx](dst, dststride, src, srcstride, width, height, src2, MAX_PB_SIZE);
142 }
143 
144 static av_cold void hevcdsp_init_neon(HEVCDSPContext *c, const int bit_depth)
145 {
146 #if HAVE_NEON
147  if (bit_depth == 8) {
148  int x;
164  put_hevc_qpel_neon[1][0] = ff_hevc_put_qpel_v1_neon_8;
165  put_hevc_qpel_neon[2][0] = ff_hevc_put_qpel_v2_neon_8;
166  put_hevc_qpel_neon[3][0] = ff_hevc_put_qpel_v3_neon_8;
167  put_hevc_qpel_neon[0][1] = ff_hevc_put_qpel_h1_neon_8;
168  put_hevc_qpel_neon[0][2] = ff_hevc_put_qpel_h2_neon_8;
169  put_hevc_qpel_neon[0][3] = ff_hevc_put_qpel_h3_neon_8;
170  put_hevc_qpel_neon[1][1] = ff_hevc_put_qpel_h1v1_neon_8;
171  put_hevc_qpel_neon[1][2] = ff_hevc_put_qpel_h2v1_neon_8;
172  put_hevc_qpel_neon[1][3] = ff_hevc_put_qpel_h3v1_neon_8;
173  put_hevc_qpel_neon[2][1] = ff_hevc_put_qpel_h1v2_neon_8;
174  put_hevc_qpel_neon[2][2] = ff_hevc_put_qpel_h2v2_neon_8;
175  put_hevc_qpel_neon[2][3] = ff_hevc_put_qpel_h3v2_neon_8;
176  put_hevc_qpel_neon[3][1] = ff_hevc_put_qpel_h1v3_neon_8;
177  put_hevc_qpel_neon[3][2] = ff_hevc_put_qpel_h2v3_neon_8;
178  put_hevc_qpel_neon[3][3] = ff_hevc_put_qpel_h3v3_neon_8;
179  put_hevc_qpel_uw_neon[1][0] = ff_hevc_put_qpel_uw_v1_neon_8;
180  put_hevc_qpel_uw_neon[2][0] = ff_hevc_put_qpel_uw_v2_neon_8;
181  put_hevc_qpel_uw_neon[3][0] = ff_hevc_put_qpel_uw_v3_neon_8;
182  put_hevc_qpel_uw_neon[0][1] = ff_hevc_put_qpel_uw_h1_neon_8;
183  put_hevc_qpel_uw_neon[0][2] = ff_hevc_put_qpel_uw_h2_neon_8;
184  put_hevc_qpel_uw_neon[0][3] = ff_hevc_put_qpel_uw_h3_neon_8;
185  put_hevc_qpel_uw_neon[1][1] = ff_hevc_put_qpel_uw_h1v1_neon_8;
186  put_hevc_qpel_uw_neon[1][2] = ff_hevc_put_qpel_uw_h2v1_neon_8;
187  put_hevc_qpel_uw_neon[1][3] = ff_hevc_put_qpel_uw_h3v1_neon_8;
188  put_hevc_qpel_uw_neon[2][1] = ff_hevc_put_qpel_uw_h1v2_neon_8;
189  put_hevc_qpel_uw_neon[2][2] = ff_hevc_put_qpel_uw_h2v2_neon_8;
190  put_hevc_qpel_uw_neon[2][3] = ff_hevc_put_qpel_uw_h3v2_neon_8;
191  put_hevc_qpel_uw_neon[3][1] = ff_hevc_put_qpel_uw_h1v3_neon_8;
192  put_hevc_qpel_uw_neon[3][2] = ff_hevc_put_qpel_uw_h2v3_neon_8;
193  put_hevc_qpel_uw_neon[3][3] = ff_hevc_put_qpel_uw_h3v3_neon_8;
194  for (x = 0; x < 10; x++) {
204  }
205  c->put_hevc_qpel[0][0][0] = ff_hevc_put_pixels_w2_neon_8;
206  c->put_hevc_qpel[1][0][0] = ff_hevc_put_pixels_w4_neon_8;
207  c->put_hevc_qpel[2][0][0] = ff_hevc_put_pixels_w6_neon_8;
208  c->put_hevc_qpel[3][0][0] = ff_hevc_put_pixels_w8_neon_8;
209  c->put_hevc_qpel[4][0][0] = ff_hevc_put_pixels_w12_neon_8;
210  c->put_hevc_qpel[5][0][0] = ff_hevc_put_pixels_w16_neon_8;
211  c->put_hevc_qpel[6][0][0] = ff_hevc_put_pixels_w24_neon_8;
212  c->put_hevc_qpel[7][0][0] = ff_hevc_put_pixels_w32_neon_8;
213  c->put_hevc_qpel[8][0][0] = ff_hevc_put_pixels_w48_neon_8;
214  c->put_hevc_qpel[9][0][0] = ff_hevc_put_pixels_w64_neon_8;
215 
216  c->put_hevc_qpel_uni[1][0][0] = ff_hevc_put_qpel_uw_pixels_w4_neon_8;
217  c->put_hevc_qpel_uni[3][0][0] = ff_hevc_put_qpel_uw_pixels_w8_neon_8;
218  c->put_hevc_qpel_uni[5][0][0] = ff_hevc_put_qpel_uw_pixels_w16_neon_8;
219  c->put_hevc_qpel_uni[6][0][0] = ff_hevc_put_qpel_uw_pixels_w24_neon_8;
220  c->put_hevc_qpel_uni[7][0][0] = ff_hevc_put_qpel_uw_pixels_w32_neon_8;
221  c->put_hevc_qpel_uni[8][0][0] = ff_hevc_put_qpel_uw_pixels_w48_neon_8;
222  c->put_hevc_qpel_uni[9][0][0] = ff_hevc_put_qpel_uw_pixels_w64_neon_8;
223  }
224 #endif // HAVE_NEON
225 }
226 
227 void ff_hevcdsp_init_arm(HEVCDSPContext *c, const int bit_depth)
228 {
229  int cpu_flags = av_get_cpu_flags();
230 
231  if (have_neon(cpu_flags))
232  hevcdsp_init_neon(c, bit_depth);
233 }