1 /*
2 *
3 * This file is part of FFmpeg.
4 *
5 * FFmpeg is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * FFmpeg is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #include <string.h>
21
25
28
30
31 #define randomize_buffers(buf, size) \
32 do { \
33 int j; \
34 for (j = 0; j < size; j+=4) \
35 AV_WN32(buf + j, rnd()); \
36 } while (0)
37
38 // This reference function is the same approximate algorithm employed by the
39 // SIMD functions
41 const int16_t **
src, uint8_t *dest,
int dstW,
43 {
45 d = ((filterSize - 1) * 8 +
dither[0]) >> 4;
46 for (
i = 0;
i < dstW;
i++) {
48 int j;
49 union {
51 int16_t v[2];
52 } t;
53 for (j = 0; j < filterSize; j++){
56 }
58 }
59 }
60
62 {
64 int fsi, osi, isi,
i, j;
66 #define LARGEST_FILTER 16
67 #define FILTER_SIZES 4
68 static const int filter_sizes[
FILTER_SIZES] = {1, 4, 8, 16};
69 #define LARGEST_INPUT_SIZE 512
70 #define INPUT_SIZES 6
71 static const int input_sizes[
INPUT_SIZES] = {8, 24, 128, 144, 256, 512};
72
74 int filterSize,
const int16_t **
src, uint8_t *dest,
76
83 union VFilterData{
86 } *vFilterData;
87 uint8_t d_val =
rnd();
94
97 dstW = input_sizes[isi];
98 for(osi = 0; osi < 64; osi += 16){
101 vFilterData =
av_malloc((filter_sizes[fsi] + 2) *
sizeof(
union VFilterData));
102 memset(vFilterData, 0, (filter_sizes[fsi] + 2) * sizeof(union VFilterData));
103 for(
i = 0;
i < filter_sizes[fsi]; ++
i){
105 vFilterData[
i].src =
src[
i];
106 for(j = 0; j < 4; ++j)
107 vFilterData[
i].
coeff[j + 4] = filter_coeff[
i];
108 }
109 if (
check_func(
ctx->yuv2planeX,
"yuv2yuvX_%d_%d_%d", filter_sizes[fsi], osi, dstW)){
112
113 // The reference function is not the scalar function selected when mmx
114 // is deactivated as the SIMD functions do not give the same result as
115 // the scalar ones due to rounding. The SIMD functions are activated by
116 // the flag SWS_ACCURATE_RND
118 // There's no point in calling new for the reference function
119 if(
ctx->use_mmx_vfilter){
120 call_new((
const int16_t*)vFilterData, filter_sizes[fsi],
src, dst1, dstW - osi,
dither, osi);
124 bench_new((
const int16_t*)vFilterData, filter_sizes[fsi],
src, dst1, dstW - osi,
dither, osi);
125 }
126 }
129 }
130 }
131 }
133 #undef FILTER_SIZES
134 }
135
136 #undef SRC_PIXELS
137 #define SRC_PIXELS 512
138
140 {
141 #define MAX_FILTER_WIDTH 40
142 #define FILTER_SIZES 6
143 static const int filter_sizes[
FILTER_SIZES] = { 4, 8, 12, 16, 32, 40 };
144
145 #define HSCALE_PAIRS 2
147 { 8, 14 },
148 { 8, 18 },
149 };
150
151 #define LARGEST_INPUT_SIZE 512
152 #define INPUT_SIZES 6
153 static const int input_sizes[
INPUT_SIZES] = {8, 24, 128, 144, 256, 512};
154
155 int i, j, fsi, hpi,
width, dstWi;
157
158 // padded
162
163 // padded
168
169 // The dst parameter here is either int16_t or int32_t but we use void* to
170 // just cover both cases.
172 const uint8_t *
src,
const int16_t *
filter,
173 const int32_t *filterPos,
int filterSize);
174
176
180
182
186 width = filter_sizes[fsi];
187
188 ctx->srcBpc = hscale_pairs[hpi][0];
189 ctx->dstBpc = hscale_pairs[hpi][1];
191
195
196 // These filter cofficients are chosen to try break two corner
197 // cases, namely:
198 //
199 // - Negative filter coefficients. The filters output signed
200 // values, and it should be possible to end up with negative
201 // output values.
202 //
203 // - Positive clipping. The hscale filter function has clipping
204 // at (1<<15) - 1
205 //
206 // The coefficients sum to the 1.0 point for the hscale
207 // functions (1 << 14).
208
209 for (j = 0; j <
width; j++) {
211 }
213 }
214
216 // These values should be unused in SIMD implementations but
217 // may still be read, random coefficients here should help show
218 // issues where they are used in error.
219
221 }
222 ctx->dstW =
ctx->chrDstW = input_sizes[dstWi];
227
229 memset(dst0, 0,
SRC_PIXELS *
sizeof(dst0[0]));
230 memset(dst1, 0,
SRC_PIXELS *
sizeof(dst1[0]));
231
234 if (memcmp(dst0, dst1,
ctx->dstW *
sizeof(dst0[0])))
237 }
238 }
239 }
240 }
242 }
243
245 {
250 }