Only compile in NEON optimizations for H.264 when the H.264 decoder is enabled.
[libav.git] / libavcodec / arm / dsputil_neon.c
CommitLineData
569f5a75
MR
1/*
2 * ARM NEON optimised DSP functions
3 * Copyright (c) 2008 Mans Rullgard <mans@mansr.com>
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#include <stdint.h>
23
24#include "libavcodec/avcodec.h"
25#include "libavcodec/dsputil.h"
26
27void ff_put_pixels16_neon(uint8_t *, const uint8_t *, int, int);
28void ff_put_pixels16_x2_neon(uint8_t *, const uint8_t *, int, int);
29void ff_put_pixels16_y2_neon(uint8_t *, const uint8_t *, int, int);
30void ff_put_pixels16_xy2_neon(uint8_t *, const uint8_t *, int, int);
31void ff_put_pixels8_neon(uint8_t *, const uint8_t *, int, int);
32void ff_put_pixels8_x2_neon(uint8_t *, const uint8_t *, int, int);
33void ff_put_pixels8_y2_neon(uint8_t *, const uint8_t *, int, int);
34void ff_put_pixels8_xy2_neon(uint8_t *, const uint8_t *, int, int);
35void ff_put_pixels16_x2_no_rnd_neon(uint8_t *, const uint8_t *, int, int);
36void ff_put_pixels16_y2_no_rnd_neon(uint8_t *, const uint8_t *, int, int);
37void ff_put_pixels16_xy2_no_rnd_neon(uint8_t *, const uint8_t *, int, int);
38void ff_put_pixels8_x2_no_rnd_neon(uint8_t *, const uint8_t *, int, int);
39void ff_put_pixels8_y2_no_rnd_neon(uint8_t *, const uint8_t *, int, int);
40void ff_put_pixels8_xy2_no_rnd_neon(uint8_t *, const uint8_t *, int, int);
41
42void ff_avg_pixels16_neon(uint8_t *, const uint8_t *, int, int);
43
08e12b22 44void ff_add_pixels_clamped_neon(const DCTELEM *, uint8_t *, int);
428bf2ac 45void ff_put_pixels_clamped_neon(const DCTELEM *, uint8_t *, int);
cc2e5554 46void ff_put_signed_pixels_clamped_neon(const DCTELEM *, uint8_t *, int);
08e12b22 47
569f5a75 48void ff_put_h264_qpel16_mc00_neon(uint8_t *, uint8_t *, int);
5813e05d
MR
49void ff_put_h264_qpel16_mc10_neon(uint8_t *, uint8_t *, int);
50void ff_put_h264_qpel16_mc20_neon(uint8_t *, uint8_t *, int);
51void ff_put_h264_qpel16_mc30_neon(uint8_t *, uint8_t *, int);
52void ff_put_h264_qpel16_mc01_neon(uint8_t *, uint8_t *, int);
53void ff_put_h264_qpel16_mc11_neon(uint8_t *, uint8_t *, int);
54void ff_put_h264_qpel16_mc21_neon(uint8_t *, uint8_t *, int);
55void ff_put_h264_qpel16_mc31_neon(uint8_t *, uint8_t *, int);
56void ff_put_h264_qpel16_mc02_neon(uint8_t *, uint8_t *, int);
57void ff_put_h264_qpel16_mc12_neon(uint8_t *, uint8_t *, int);
58void ff_put_h264_qpel16_mc22_neon(uint8_t *, uint8_t *, int);
59void ff_put_h264_qpel16_mc32_neon(uint8_t *, uint8_t *, int);
60void ff_put_h264_qpel16_mc03_neon(uint8_t *, uint8_t *, int);
61void ff_put_h264_qpel16_mc13_neon(uint8_t *, uint8_t *, int);
62void ff_put_h264_qpel16_mc23_neon(uint8_t *, uint8_t *, int);
63void ff_put_h264_qpel16_mc33_neon(uint8_t *, uint8_t *, int);
64
569f5a75 65void ff_put_h264_qpel8_mc00_neon(uint8_t *, uint8_t *, int);
5813e05d
MR
66void ff_put_h264_qpel8_mc10_neon(uint8_t *, uint8_t *, int);
67void ff_put_h264_qpel8_mc20_neon(uint8_t *, uint8_t *, int);
68void ff_put_h264_qpel8_mc30_neon(uint8_t *, uint8_t *, int);
69void ff_put_h264_qpel8_mc01_neon(uint8_t *, uint8_t *, int);
70void ff_put_h264_qpel8_mc11_neon(uint8_t *, uint8_t *, int);
71void ff_put_h264_qpel8_mc21_neon(uint8_t *, uint8_t *, int);
72void ff_put_h264_qpel8_mc31_neon(uint8_t *, uint8_t *, int);
73void ff_put_h264_qpel8_mc02_neon(uint8_t *, uint8_t *, int);
74void ff_put_h264_qpel8_mc12_neon(uint8_t *, uint8_t *, int);
75void ff_put_h264_qpel8_mc22_neon(uint8_t *, uint8_t *, int);
76void ff_put_h264_qpel8_mc32_neon(uint8_t *, uint8_t *, int);
77void ff_put_h264_qpel8_mc03_neon(uint8_t *, uint8_t *, int);
78void ff_put_h264_qpel8_mc13_neon(uint8_t *, uint8_t *, int);
79void ff_put_h264_qpel8_mc23_neon(uint8_t *, uint8_t *, int);
80void ff_put_h264_qpel8_mc33_neon(uint8_t *, uint8_t *, int);
569f5a75
MR
81
82void ff_avg_h264_qpel16_mc00_neon(uint8_t *, uint8_t *, int);
83
1cce897a
MR
84void ff_put_h264_chroma_mc8_neon(uint8_t *, uint8_t *, int, int, int, int);
85void ff_put_h264_chroma_mc4_neon(uint8_t *, uint8_t *, int, int, int, int);
86
87void ff_avg_h264_chroma_mc8_neon(uint8_t *, uint8_t *, int, int, int, int);
88void ff_avg_h264_chroma_mc4_neon(uint8_t *, uint8_t *, int, int, int, int);
89
ad74a0f8
MR
90void ff_h264_v_loop_filter_luma_neon(uint8_t *pix, int stride, int alpha,
91 int beta, int8_t *tc0);
92void ff_h264_h_loop_filter_luma_neon(uint8_t *pix, int stride, int alpha,
93 int beta, int8_t *tc0);
94void ff_h264_v_loop_filter_chroma_neon(uint8_t *pix, int stride, int alpha,
95 int beta, int8_t *tc0);
96void ff_h264_h_loop_filter_chroma_neon(uint8_t *pix, int stride, int alpha,
97 int beta, int8_t *tc0);
98
bd53b426
MR
99void ff_weight_h264_pixels_16x16_neon(uint8_t *ds, int stride, int log2_den,
100 int weight, int offset);
101void ff_weight_h264_pixels_16x8_neon(uint8_t *ds, int stride, int log2_den,
102 int weight, int offset);
103void ff_weight_h264_pixels_8x16_neon(uint8_t *ds, int stride, int log2_den,
104 int weight, int offset);
105void ff_weight_h264_pixels_8x8_neon(uint8_t *ds, int stride, int log2_den,
106 int weight, int offset);
107void ff_weight_h264_pixels_8x4_neon(uint8_t *ds, int stride, int log2_den,
108 int weight, int offset);
109void ff_weight_h264_pixels_4x8_neon(uint8_t *ds, int stride, int log2_den,
110 int weight, int offset);
111void ff_weight_h264_pixels_4x4_neon(uint8_t *ds, int stride, int log2_den,
112 int weight, int offset);
113void ff_weight_h264_pixels_4x2_neon(uint8_t *ds, int stride, int log2_den,
114 int weight, int offset);
115
5a29589b
MR
116void ff_biweight_h264_pixels_16x16_neon(uint8_t *dst, uint8_t *src, int stride,
117 int log2_den, int weightd, int weights,
118 int offset);
119void ff_biweight_h264_pixels_16x8_neon(uint8_t *dst, uint8_t *src, int stride,
120 int log2_den, int weightd, int weights,
121 int offset);
122void ff_biweight_h264_pixels_8x16_neon(uint8_t *dst, uint8_t *src, int stride,
123 int log2_den, int weightd, int weights,
124 int offset);
125void ff_biweight_h264_pixels_8x8_neon(uint8_t *dst, uint8_t *src, int stride,
126 int log2_den, int weightd, int weights,
127 int offset);
128void ff_biweight_h264_pixels_8x4_neon(uint8_t *dst, uint8_t *src, int stride,
129 int log2_den, int weightd, int weights,
130 int offset);
131void ff_biweight_h264_pixels_4x8_neon(uint8_t *dst, uint8_t *src, int stride,
132 int log2_den, int weightd, int weights,
133 int offset);
134void ff_biweight_h264_pixels_4x4_neon(uint8_t *dst, uint8_t *src, int stride,
135 int log2_den, int weightd, int weights,
136 int offset);
137void ff_biweight_h264_pixels_4x2_neon(uint8_t *dst, uint8_t *src, int stride,
138 int log2_den, int weightd, int weights,
139 int offset);
140
c598cf25 141void ff_h264_idct_add_neon(uint8_t *dst, DCTELEM *block, int stride);
1bf98d19 142void ff_h264_idct_dc_add_neon(uint8_t *dst, DCTELEM *block, int stride);
760badc1
MR
143void ff_h264_idct_add16_neon(uint8_t *dst, const int *block_offset,
144 DCTELEM *block, int stride,
145 const uint8_t nnzc[6*8]);
146void ff_h264_idct_add16intra_neon(uint8_t *dst, const int *block_offset,
147 DCTELEM *block, int stride,
148 const uint8_t nnzc[6*8]);
149void ff_h264_idct_add8_neon(uint8_t **dest, const int *block_offset,
150 DCTELEM *block, int stride,
151 const uint8_t nnzc[6*8]);
c598cf25 152
6db8697a
DC
153void ff_vp3_v_loop_filter_neon(uint8_t *, int, int *);
154void ff_vp3_h_loop_filter_neon(uint8_t *, int, int *);
155
dd927e2e 156void ff_vector_fmul_neon(float *dst, const float *src, int len);
e1f7cb7f
MR
157void ff_vector_fmul_window_neon(float *dst, const float *src0,
158 const float *src1, const float *win,
159 float add_bias, int len);
dd927e2e 160
f23740d9
MR
161void ff_float_to_int16_neon(int16_t *, const float *, long);
162void ff_float_to_int16_interleave_neon(int16_t *, const float **, long, int);
163
569f5a75
MR
164void ff_dsputil_init_neon(DSPContext *c, AVCodecContext *avctx)
165{
166 c->put_pixels_tab[0][0] = ff_put_pixels16_neon;
167 c->put_pixels_tab[0][1] = ff_put_pixels16_x2_neon;
168 c->put_pixels_tab[0][2] = ff_put_pixels16_y2_neon;
169 c->put_pixels_tab[0][3] = ff_put_pixels16_xy2_neon;
170 c->put_pixels_tab[1][0] = ff_put_pixels8_neon;
171 c->put_pixels_tab[1][1] = ff_put_pixels8_x2_neon;
172 c->put_pixels_tab[1][2] = ff_put_pixels8_y2_neon;
173 c->put_pixels_tab[1][3] = ff_put_pixels8_xy2_neon;
174
175 c->put_no_rnd_pixels_tab[0][0] = ff_put_pixels16_neon;
176 c->put_no_rnd_pixels_tab[0][1] = ff_put_pixels16_x2_no_rnd_neon;
177 c->put_no_rnd_pixels_tab[0][2] = ff_put_pixels16_y2_no_rnd_neon;
178 c->put_no_rnd_pixels_tab[0][3] = ff_put_pixels16_xy2_no_rnd_neon;
179 c->put_no_rnd_pixels_tab[1][0] = ff_put_pixels8_neon;
180 c->put_no_rnd_pixels_tab[1][1] = ff_put_pixels8_x2_no_rnd_neon;
181 c->put_no_rnd_pixels_tab[1][2] = ff_put_pixels8_y2_no_rnd_neon;
182 c->put_no_rnd_pixels_tab[1][3] = ff_put_pixels8_xy2_no_rnd_neon;
183
184 c->avg_pixels_tab[0][0] = ff_avg_pixels16_neon;
185
08e12b22 186 c->add_pixels_clamped = ff_add_pixels_clamped_neon;
428bf2ac 187 c->put_pixels_clamped = ff_put_pixels_clamped_neon;
cc2e5554 188 c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_neon;
08e12b22 189
31cf61b4 190 if (CONFIG_H264_DECODER) {
1cce897a
MR
191 c->put_h264_chroma_pixels_tab[0] = ff_put_h264_chroma_mc8_neon;
192 c->put_h264_chroma_pixels_tab[1] = ff_put_h264_chroma_mc4_neon;
193
194 c->avg_h264_chroma_pixels_tab[0] = ff_avg_h264_chroma_mc8_neon;
195 c->avg_h264_chroma_pixels_tab[1] = ff_avg_h264_chroma_mc4_neon;
196
5813e05d
MR
197 c->put_h264_qpel_pixels_tab[0][ 0] = ff_put_h264_qpel16_mc00_neon;
198 c->put_h264_qpel_pixels_tab[0][ 1] = ff_put_h264_qpel16_mc10_neon;
199 c->put_h264_qpel_pixels_tab[0][ 2] = ff_put_h264_qpel16_mc20_neon;
200 c->put_h264_qpel_pixels_tab[0][ 3] = ff_put_h264_qpel16_mc30_neon;
201 c->put_h264_qpel_pixels_tab[0][ 4] = ff_put_h264_qpel16_mc01_neon;
202 c->put_h264_qpel_pixels_tab[0][ 5] = ff_put_h264_qpel16_mc11_neon;
203 c->put_h264_qpel_pixels_tab[0][ 6] = ff_put_h264_qpel16_mc21_neon;
204 c->put_h264_qpel_pixels_tab[0][ 7] = ff_put_h264_qpel16_mc31_neon;
205 c->put_h264_qpel_pixels_tab[0][ 8] = ff_put_h264_qpel16_mc02_neon;
206 c->put_h264_qpel_pixels_tab[0][ 9] = ff_put_h264_qpel16_mc12_neon;
207 c->put_h264_qpel_pixels_tab[0][10] = ff_put_h264_qpel16_mc22_neon;
208 c->put_h264_qpel_pixels_tab[0][11] = ff_put_h264_qpel16_mc32_neon;
209 c->put_h264_qpel_pixels_tab[0][12] = ff_put_h264_qpel16_mc03_neon;
210 c->put_h264_qpel_pixels_tab[0][13] = ff_put_h264_qpel16_mc13_neon;
211 c->put_h264_qpel_pixels_tab[0][14] = ff_put_h264_qpel16_mc23_neon;
212 c->put_h264_qpel_pixels_tab[0][15] = ff_put_h264_qpel16_mc33_neon;
213
214 c->put_h264_qpel_pixels_tab[1][ 0] = ff_put_h264_qpel8_mc00_neon;
215 c->put_h264_qpel_pixels_tab[1][ 1] = ff_put_h264_qpel8_mc10_neon;
216 c->put_h264_qpel_pixels_tab[1][ 2] = ff_put_h264_qpel8_mc20_neon;
217 c->put_h264_qpel_pixels_tab[1][ 3] = ff_put_h264_qpel8_mc30_neon;
218 c->put_h264_qpel_pixels_tab[1][ 4] = ff_put_h264_qpel8_mc01_neon;
219 c->put_h264_qpel_pixels_tab[1][ 5] = ff_put_h264_qpel8_mc11_neon;
220 c->put_h264_qpel_pixels_tab[1][ 6] = ff_put_h264_qpel8_mc21_neon;
221 c->put_h264_qpel_pixels_tab[1][ 7] = ff_put_h264_qpel8_mc31_neon;
222 c->put_h264_qpel_pixels_tab[1][ 8] = ff_put_h264_qpel8_mc02_neon;
223 c->put_h264_qpel_pixels_tab[1][ 9] = ff_put_h264_qpel8_mc12_neon;
224 c->put_h264_qpel_pixels_tab[1][10] = ff_put_h264_qpel8_mc22_neon;
225 c->put_h264_qpel_pixels_tab[1][11] = ff_put_h264_qpel8_mc32_neon;
226 c->put_h264_qpel_pixels_tab[1][12] = ff_put_h264_qpel8_mc03_neon;
227 c->put_h264_qpel_pixels_tab[1][13] = ff_put_h264_qpel8_mc13_neon;
228 c->put_h264_qpel_pixels_tab[1][14] = ff_put_h264_qpel8_mc23_neon;
229 c->put_h264_qpel_pixels_tab[1][15] = ff_put_h264_qpel8_mc33_neon;
569f5a75
MR
230
231 c->avg_h264_qpel_pixels_tab[0][ 0] = ff_avg_h264_qpel16_mc00_neon;
ad74a0f8
MR
232
233 c->h264_v_loop_filter_luma = ff_h264_v_loop_filter_luma_neon;
234 c->h264_h_loop_filter_luma = ff_h264_h_loop_filter_luma_neon;
235 c->h264_v_loop_filter_chroma = ff_h264_v_loop_filter_chroma_neon;
236 c->h264_h_loop_filter_chroma = ff_h264_h_loop_filter_chroma_neon;
c598cf25 237
bd53b426
MR
238 c->weight_h264_pixels_tab[0] = ff_weight_h264_pixels_16x16_neon;
239 c->weight_h264_pixels_tab[1] = ff_weight_h264_pixels_16x8_neon;
240 c->weight_h264_pixels_tab[2] = ff_weight_h264_pixels_8x16_neon;
241 c->weight_h264_pixels_tab[3] = ff_weight_h264_pixels_8x8_neon;
242 c->weight_h264_pixels_tab[4] = ff_weight_h264_pixels_8x4_neon;
243 c->weight_h264_pixels_tab[5] = ff_weight_h264_pixels_4x8_neon;
244 c->weight_h264_pixels_tab[6] = ff_weight_h264_pixels_4x4_neon;
245 c->weight_h264_pixels_tab[7] = ff_weight_h264_pixels_4x2_neon;
246
5a29589b
MR
247 c->biweight_h264_pixels_tab[0] = ff_biweight_h264_pixels_16x16_neon;
248 c->biweight_h264_pixels_tab[1] = ff_biweight_h264_pixels_16x8_neon;
249 c->biweight_h264_pixels_tab[2] = ff_biweight_h264_pixels_8x16_neon;
250 c->biweight_h264_pixels_tab[3] = ff_biweight_h264_pixels_8x8_neon;
251 c->biweight_h264_pixels_tab[4] = ff_biweight_h264_pixels_8x4_neon;
252 c->biweight_h264_pixels_tab[5] = ff_biweight_h264_pixels_4x8_neon;
253 c->biweight_h264_pixels_tab[6] = ff_biweight_h264_pixels_4x4_neon;
254 c->biweight_h264_pixels_tab[7] = ff_biweight_h264_pixels_4x2_neon;
255
c598cf25 256 c->h264_idct_add = ff_h264_idct_add_neon;
1bf98d19 257 c->h264_idct_dc_add = ff_h264_idct_dc_add_neon;
760badc1
MR
258 c->h264_idct_add16 = ff_h264_idct_add16_neon;
259 c->h264_idct_add16intra = ff_h264_idct_add16intra_neon;
260 c->h264_idct_add8 = ff_h264_idct_add8_neon;
31cf61b4 261 }
f23740d9 262
99e5a9d1 263 if (CONFIG_VP3_DECODER) {
6db8697a
DC
264 c->vp3_v_loop_filter = ff_vp3_v_loop_filter_neon;
265 c->vp3_h_loop_filter = ff_vp3_h_loop_filter_neon;
266 }
267
dd927e2e 268 c->vector_fmul = ff_vector_fmul_neon;
e1f7cb7f 269 c->vector_fmul_window = ff_vector_fmul_window_neon;
dd927e2e 270
f23740d9
MR
271 if (!(avctx->flags & CODEC_FLAG_BITEXACT)) {
272 c->float_to_int16 = ff_float_to_int16_neon;
273 c->float_to_int16_interleave = ff_float_to_int16_interleave_neon;
274 }
569f5a75 275}