ARM: NEON optimised H.264 biweighted prediction
[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
44void ff_put_h264_qpel16_mc00_neon(uint8_t *, uint8_t *, int);
5813e05d
MR
45void ff_put_h264_qpel16_mc10_neon(uint8_t *, uint8_t *, int);
46void ff_put_h264_qpel16_mc20_neon(uint8_t *, uint8_t *, int);
47void ff_put_h264_qpel16_mc30_neon(uint8_t *, uint8_t *, int);
48void ff_put_h264_qpel16_mc01_neon(uint8_t *, uint8_t *, int);
49void ff_put_h264_qpel16_mc11_neon(uint8_t *, uint8_t *, int);
50void ff_put_h264_qpel16_mc21_neon(uint8_t *, uint8_t *, int);
51void ff_put_h264_qpel16_mc31_neon(uint8_t *, uint8_t *, int);
52void ff_put_h264_qpel16_mc02_neon(uint8_t *, uint8_t *, int);
53void ff_put_h264_qpel16_mc12_neon(uint8_t *, uint8_t *, int);
54void ff_put_h264_qpel16_mc22_neon(uint8_t *, uint8_t *, int);
55void ff_put_h264_qpel16_mc32_neon(uint8_t *, uint8_t *, int);
56void ff_put_h264_qpel16_mc03_neon(uint8_t *, uint8_t *, int);
57void ff_put_h264_qpel16_mc13_neon(uint8_t *, uint8_t *, int);
58void ff_put_h264_qpel16_mc23_neon(uint8_t *, uint8_t *, int);
59void ff_put_h264_qpel16_mc33_neon(uint8_t *, uint8_t *, int);
60
569f5a75 61void ff_put_h264_qpel8_mc00_neon(uint8_t *, uint8_t *, int);
5813e05d
MR
62void ff_put_h264_qpel8_mc10_neon(uint8_t *, uint8_t *, int);
63void ff_put_h264_qpel8_mc20_neon(uint8_t *, uint8_t *, int);
64void ff_put_h264_qpel8_mc30_neon(uint8_t *, uint8_t *, int);
65void ff_put_h264_qpel8_mc01_neon(uint8_t *, uint8_t *, int);
66void ff_put_h264_qpel8_mc11_neon(uint8_t *, uint8_t *, int);
67void ff_put_h264_qpel8_mc21_neon(uint8_t *, uint8_t *, int);
68void ff_put_h264_qpel8_mc31_neon(uint8_t *, uint8_t *, int);
69void ff_put_h264_qpel8_mc02_neon(uint8_t *, uint8_t *, int);
70void ff_put_h264_qpel8_mc12_neon(uint8_t *, uint8_t *, int);
71void ff_put_h264_qpel8_mc22_neon(uint8_t *, uint8_t *, int);
72void ff_put_h264_qpel8_mc32_neon(uint8_t *, uint8_t *, int);
73void ff_put_h264_qpel8_mc03_neon(uint8_t *, uint8_t *, int);
74void ff_put_h264_qpel8_mc13_neon(uint8_t *, uint8_t *, int);
75void ff_put_h264_qpel8_mc23_neon(uint8_t *, uint8_t *, int);
76void ff_put_h264_qpel8_mc33_neon(uint8_t *, uint8_t *, int);
569f5a75
MR
77
78void ff_avg_h264_qpel16_mc00_neon(uint8_t *, uint8_t *, int);
79
1cce897a
MR
80void ff_put_h264_chroma_mc8_neon(uint8_t *, uint8_t *, int, int, int, int);
81void ff_put_h264_chroma_mc4_neon(uint8_t *, uint8_t *, int, int, int, int);
82
83void ff_avg_h264_chroma_mc8_neon(uint8_t *, uint8_t *, int, int, int, int);
84void ff_avg_h264_chroma_mc4_neon(uint8_t *, uint8_t *, int, int, int, int);
85
ad74a0f8
MR
86void ff_h264_v_loop_filter_luma_neon(uint8_t *pix, int stride, int alpha,
87 int beta, int8_t *tc0);
88void ff_h264_h_loop_filter_luma_neon(uint8_t *pix, int stride, int alpha,
89 int beta, int8_t *tc0);
90void ff_h264_v_loop_filter_chroma_neon(uint8_t *pix, int stride, int alpha,
91 int beta, int8_t *tc0);
92void ff_h264_h_loop_filter_chroma_neon(uint8_t *pix, int stride, int alpha,
93 int beta, int8_t *tc0);
94
5a29589b
MR
95void ff_biweight_h264_pixels_16x16_neon(uint8_t *dst, uint8_t *src, int stride,
96 int log2_den, int weightd, int weights,
97 int offset);
98void ff_biweight_h264_pixels_16x8_neon(uint8_t *dst, uint8_t *src, int stride,
99 int log2_den, int weightd, int weights,
100 int offset);
101void ff_biweight_h264_pixels_8x16_neon(uint8_t *dst, uint8_t *src, int stride,
102 int log2_den, int weightd, int weights,
103 int offset);
104void ff_biweight_h264_pixels_8x8_neon(uint8_t *dst, uint8_t *src, int stride,
105 int log2_den, int weightd, int weights,
106 int offset);
107void ff_biweight_h264_pixels_8x4_neon(uint8_t *dst, uint8_t *src, int stride,
108 int log2_den, int weightd, int weights,
109 int offset);
110void ff_biweight_h264_pixels_4x8_neon(uint8_t *dst, uint8_t *src, int stride,
111 int log2_den, int weightd, int weights,
112 int offset);
113void ff_biweight_h264_pixels_4x4_neon(uint8_t *dst, uint8_t *src, int stride,
114 int log2_den, int weightd, int weights,
115 int offset);
116void ff_biweight_h264_pixels_4x2_neon(uint8_t *dst, uint8_t *src, int stride,
117 int log2_den, int weightd, int weights,
118 int offset);
119
c598cf25 120void ff_h264_idct_add_neon(uint8_t *dst, DCTELEM *block, int stride);
1bf98d19 121void ff_h264_idct_dc_add_neon(uint8_t *dst, DCTELEM *block, int stride);
760badc1
MR
122void ff_h264_idct_add16_neon(uint8_t *dst, const int *block_offset,
123 DCTELEM *block, int stride,
124 const uint8_t nnzc[6*8]);
125void ff_h264_idct_add16intra_neon(uint8_t *dst, const int *block_offset,
126 DCTELEM *block, int stride,
127 const uint8_t nnzc[6*8]);
128void ff_h264_idct_add8_neon(uint8_t **dest, const int *block_offset,
129 DCTELEM *block, int stride,
130 const uint8_t nnzc[6*8]);
c598cf25 131
f23740d9
MR
132void ff_float_to_int16_neon(int16_t *, const float *, long);
133void ff_float_to_int16_interleave_neon(int16_t *, const float **, long, int);
134
569f5a75
MR
135void ff_dsputil_init_neon(DSPContext *c, AVCodecContext *avctx)
136{
137 c->put_pixels_tab[0][0] = ff_put_pixels16_neon;
138 c->put_pixels_tab[0][1] = ff_put_pixels16_x2_neon;
139 c->put_pixels_tab[0][2] = ff_put_pixels16_y2_neon;
140 c->put_pixels_tab[0][3] = ff_put_pixels16_xy2_neon;
141 c->put_pixels_tab[1][0] = ff_put_pixels8_neon;
142 c->put_pixels_tab[1][1] = ff_put_pixels8_x2_neon;
143 c->put_pixels_tab[1][2] = ff_put_pixels8_y2_neon;
144 c->put_pixels_tab[1][3] = ff_put_pixels8_xy2_neon;
145
146 c->put_no_rnd_pixels_tab[0][0] = ff_put_pixels16_neon;
147 c->put_no_rnd_pixels_tab[0][1] = ff_put_pixels16_x2_no_rnd_neon;
148 c->put_no_rnd_pixels_tab[0][2] = ff_put_pixels16_y2_no_rnd_neon;
149 c->put_no_rnd_pixels_tab[0][3] = ff_put_pixels16_xy2_no_rnd_neon;
150 c->put_no_rnd_pixels_tab[1][0] = ff_put_pixels8_neon;
151 c->put_no_rnd_pixels_tab[1][1] = ff_put_pixels8_x2_no_rnd_neon;
152 c->put_no_rnd_pixels_tab[1][2] = ff_put_pixels8_y2_no_rnd_neon;
153 c->put_no_rnd_pixels_tab[1][3] = ff_put_pixels8_xy2_no_rnd_neon;
154
155 c->avg_pixels_tab[0][0] = ff_avg_pixels16_neon;
156
1cce897a
MR
157 c->put_h264_chroma_pixels_tab[0] = ff_put_h264_chroma_mc8_neon;
158 c->put_h264_chroma_pixels_tab[1] = ff_put_h264_chroma_mc4_neon;
159
160 c->avg_h264_chroma_pixels_tab[0] = ff_avg_h264_chroma_mc8_neon;
161 c->avg_h264_chroma_pixels_tab[1] = ff_avg_h264_chroma_mc4_neon;
162
5813e05d
MR
163 c->put_h264_qpel_pixels_tab[0][ 0] = ff_put_h264_qpel16_mc00_neon;
164 c->put_h264_qpel_pixels_tab[0][ 1] = ff_put_h264_qpel16_mc10_neon;
165 c->put_h264_qpel_pixels_tab[0][ 2] = ff_put_h264_qpel16_mc20_neon;
166 c->put_h264_qpel_pixels_tab[0][ 3] = ff_put_h264_qpel16_mc30_neon;
167 c->put_h264_qpel_pixels_tab[0][ 4] = ff_put_h264_qpel16_mc01_neon;
168 c->put_h264_qpel_pixels_tab[0][ 5] = ff_put_h264_qpel16_mc11_neon;
169 c->put_h264_qpel_pixels_tab[0][ 6] = ff_put_h264_qpel16_mc21_neon;
170 c->put_h264_qpel_pixels_tab[0][ 7] = ff_put_h264_qpel16_mc31_neon;
171 c->put_h264_qpel_pixels_tab[0][ 8] = ff_put_h264_qpel16_mc02_neon;
172 c->put_h264_qpel_pixels_tab[0][ 9] = ff_put_h264_qpel16_mc12_neon;
173 c->put_h264_qpel_pixels_tab[0][10] = ff_put_h264_qpel16_mc22_neon;
174 c->put_h264_qpel_pixels_tab[0][11] = ff_put_h264_qpel16_mc32_neon;
175 c->put_h264_qpel_pixels_tab[0][12] = ff_put_h264_qpel16_mc03_neon;
176 c->put_h264_qpel_pixels_tab[0][13] = ff_put_h264_qpel16_mc13_neon;
177 c->put_h264_qpel_pixels_tab[0][14] = ff_put_h264_qpel16_mc23_neon;
178 c->put_h264_qpel_pixels_tab[0][15] = ff_put_h264_qpel16_mc33_neon;
179
180 c->put_h264_qpel_pixels_tab[1][ 0] = ff_put_h264_qpel8_mc00_neon;
181 c->put_h264_qpel_pixels_tab[1][ 1] = ff_put_h264_qpel8_mc10_neon;
182 c->put_h264_qpel_pixels_tab[1][ 2] = ff_put_h264_qpel8_mc20_neon;
183 c->put_h264_qpel_pixels_tab[1][ 3] = ff_put_h264_qpel8_mc30_neon;
184 c->put_h264_qpel_pixels_tab[1][ 4] = ff_put_h264_qpel8_mc01_neon;
185 c->put_h264_qpel_pixels_tab[1][ 5] = ff_put_h264_qpel8_mc11_neon;
186 c->put_h264_qpel_pixels_tab[1][ 6] = ff_put_h264_qpel8_mc21_neon;
187 c->put_h264_qpel_pixels_tab[1][ 7] = ff_put_h264_qpel8_mc31_neon;
188 c->put_h264_qpel_pixels_tab[1][ 8] = ff_put_h264_qpel8_mc02_neon;
189 c->put_h264_qpel_pixels_tab[1][ 9] = ff_put_h264_qpel8_mc12_neon;
190 c->put_h264_qpel_pixels_tab[1][10] = ff_put_h264_qpel8_mc22_neon;
191 c->put_h264_qpel_pixels_tab[1][11] = ff_put_h264_qpel8_mc32_neon;
192 c->put_h264_qpel_pixels_tab[1][12] = ff_put_h264_qpel8_mc03_neon;
193 c->put_h264_qpel_pixels_tab[1][13] = ff_put_h264_qpel8_mc13_neon;
194 c->put_h264_qpel_pixels_tab[1][14] = ff_put_h264_qpel8_mc23_neon;
195 c->put_h264_qpel_pixels_tab[1][15] = ff_put_h264_qpel8_mc33_neon;
569f5a75
MR
196
197 c->avg_h264_qpel_pixels_tab[0][ 0] = ff_avg_h264_qpel16_mc00_neon;
ad74a0f8
MR
198
199 c->h264_v_loop_filter_luma = ff_h264_v_loop_filter_luma_neon;
200 c->h264_h_loop_filter_luma = ff_h264_h_loop_filter_luma_neon;
201 c->h264_v_loop_filter_chroma = ff_h264_v_loop_filter_chroma_neon;
202 c->h264_h_loop_filter_chroma = ff_h264_h_loop_filter_chroma_neon;
c598cf25 203
5a29589b
MR
204 c->biweight_h264_pixels_tab[0] = ff_biweight_h264_pixels_16x16_neon;
205 c->biweight_h264_pixels_tab[1] = ff_biweight_h264_pixels_16x8_neon;
206 c->biweight_h264_pixels_tab[2] = ff_biweight_h264_pixels_8x16_neon;
207 c->biweight_h264_pixels_tab[3] = ff_biweight_h264_pixels_8x8_neon;
208 c->biweight_h264_pixels_tab[4] = ff_biweight_h264_pixels_8x4_neon;
209 c->biweight_h264_pixels_tab[5] = ff_biweight_h264_pixels_4x8_neon;
210 c->biweight_h264_pixels_tab[6] = ff_biweight_h264_pixels_4x4_neon;
211 c->biweight_h264_pixels_tab[7] = ff_biweight_h264_pixels_4x2_neon;
212
c598cf25 213 c->h264_idct_add = ff_h264_idct_add_neon;
1bf98d19 214 c->h264_idct_dc_add = ff_h264_idct_dc_add_neon;
760badc1
MR
215 c->h264_idct_add16 = ff_h264_idct_add16_neon;
216 c->h264_idct_add16intra = ff_h264_idct_add16intra_neon;
217 c->h264_idct_add8 = ff_h264_idct_add8_neon;
f23740d9
MR
218
219 if (!(avctx->flags & CODEC_FLAG_BITEXACT)) {
220 c->float_to_int16 = ff_float_to_int16_neon;
221 c->float_to_int16_interleave = ff_float_to_int16_interleave_neon;
222 }
569f5a75 223}