Coverage Report

Created: 2026-10-28 08:13

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ffmpeg/libavcodec/vp3dsp.c
Line
Count
Source
1
/*
2
 * Copyright (C) 2004 The FFmpeg project
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
/**
22
 * @file
23
 * Standard C DSP-oriented functions cribbed from the original VP3
24
 * source code.
25
 */
26
27
#include <string.h>
28
29
#include "config.h"
30
#include "libavutil/attributes.h"
31
#include "libavutil/common.h"
32
#include "libavutil/internal.h"
33
#include "libavutil/intreadwrite.h"
34
#include "libavutil/avassert.h"
35
36
#include "rnd_avg.h"
37
#include "vp3dsp.h"
38
39
418M
#define IdctAdjustBeforeShift 8
40
#define xC1S7 64277
41
#define xC2S6 60547
42
#define xC3S5 54491
43
418M
#define xC4S4 46341
44
#define xC5S3 36410
45
#define xC6S2 25080
46
#define xC7S1 12785
47
48
4.06G
#define M(a, b) ((int)((SUINT)(a) * (b)) >> 16)
49
50
static av_always_inline void idct(uint8_t *dst, ptrdiff_t stride,
51
                                  int16_t *input, int type)
52
72.3M
{
53
72.3M
    int16_t *ip = input;
54
55
72.3M
    int A, B, C, D, Ad, Bd, Cd, Dd, E, F, G, H;
56
72.3M
    int Ed, Gd, Add, Bdd, Fd, Hd;
57
58
72.3M
    int i;
59
60
    /* Inverse DCT on the rows now */
61
651M
    for (i = 0; i < 8; i++) {
62
        /* Check for non-zero values */
63
578M
        if (ip[0 * 8] | ip[1 * 8] | ip[2 * 8] | ip[3 * 8] |
64
578M
            ip[4 * 8] | ip[5 * 8] | ip[6 * 8] | ip[7 * 8]) {
65
104M
            A = M(xC1S7, ip[1 * 8]) + M(xC7S1, ip[7 * 8]);
66
104M
            B = M(xC7S1, ip[1 * 8]) - M(xC1S7, ip[7 * 8]);
67
104M
            C = M(xC3S5, ip[3 * 8]) + M(xC5S3, ip[5 * 8]);
68
104M
            D = M(xC3S5, ip[5 * 8]) - M(xC5S3, ip[3 * 8]);
69
70
104M
            Ad = M(xC4S4, (A - C));
71
104M
            Bd = M(xC4S4, (B - D));
72
73
104M
            Cd = A + C;
74
104M
            Dd = B + D;
75
76
104M
            E = M(xC4S4, (ip[0 * 8] + ip[4 * 8]));
77
104M
            F = M(xC4S4, (ip[0 * 8] - ip[4 * 8]));
78
79
104M
            G = M(xC2S6, ip[2 * 8]) + M(xC6S2, ip[6 * 8]);
80
104M
            H = M(xC6S2, ip[2 * 8]) - M(xC2S6, ip[6 * 8]);
81
82
104M
            Ed = E - G;
83
104M
            Gd = E + G;
84
85
104M
            Add = F + Ad;
86
104M
            Bdd = Bd - H;
87
88
104M
            Fd = F - Ad;
89
104M
            Hd = Bd + H;
90
91
            /*  Final sequence of operations over-write original inputs. */
92
104M
            ip[0 * 8] = Gd + Cd;
93
104M
            ip[7 * 8] = Gd - Cd;
94
95
104M
            ip[1 * 8] = Add + Hd;
96
104M
            ip[2 * 8] = Add - Hd;
97
98
104M
            ip[3 * 8] = Ed + Dd;
99
104M
            ip[4 * 8] = Ed - Dd;
100
101
104M
            ip[5 * 8] = Fd + Bdd;
102
104M
            ip[6 * 8] = Fd - Bdd;
103
104M
        }
104
105
578M
        ip += 1;            /* next row */
106
578M
    }
107
108
72.3M
    ip = input;
109
110
651M
    for (i = 0; i < 8; i++) {
111
        /* Check for non-zero values (bitwise or faster than ||) */
112
578M
        if (ip[1] | ip[2] | ip[3] |
113
578M
            ip[4] | ip[5] | ip[6] | ip[7]) {
114
128M
            A = M(xC1S7, ip[1]) + M(xC7S1, ip[7]);
115
128M
            B = M(xC7S1, ip[1]) - M(xC1S7, ip[7]);
116
128M
            C = M(xC3S5, ip[3]) + M(xC5S3, ip[5]);
117
128M
            D = M(xC3S5, ip[5]) - M(xC5S3, ip[3]);
118
119
128M
            Ad = M(xC4S4, (A - C));
120
128M
            Bd = M(xC4S4, (B - D));
121
122
128M
            Cd = A + C;
123
128M
            Dd = B + D;
124
125
128M
            E = M(xC4S4, (ip[0] + ip[4])) + 8;
126
128M
            F = M(xC4S4, (ip[0] - ip[4])) + 8;
127
128
128M
            if (type == 1) { // HACK
129
38.1M
                E += 16 * 128;
130
38.1M
                F += 16 * 128;
131
38.1M
            }
132
133
128M
            G = M(xC2S6, ip[2]) + M(xC6S2, ip[6]);
134
128M
            H = M(xC6S2, ip[2]) - M(xC2S6, ip[6]);
135
136
128M
            Ed = E - G;
137
128M
            Gd = E + G;
138
139
128M
            Add = F + Ad;
140
128M
            Bdd = Bd - H;
141
142
128M
            Fd = F - Ad;
143
128M
            Hd = Bd + H;
144
145
            /* Final sequence of operations over-write original inputs. */
146
128M
            if (type == 1) {
147
38.1M
                dst[0 * stride] = av_clip_uint8((Gd + Cd) >> 4);
148
38.1M
                dst[7 * stride] = av_clip_uint8((Gd - Cd) >> 4);
149
150
38.1M
                dst[1 * stride] = av_clip_uint8((Add + Hd) >> 4);
151
38.1M
                dst[2 * stride] = av_clip_uint8((Add - Hd) >> 4);
152
153
38.1M
                dst[3 * stride] = av_clip_uint8((Ed + Dd) >> 4);
154
38.1M
                dst[4 * stride] = av_clip_uint8((Ed - Dd) >> 4);
155
156
38.1M
                dst[5 * stride] = av_clip_uint8((Fd + Bdd) >> 4);
157
38.1M
                dst[6 * stride] = av_clip_uint8((Fd - Bdd) >> 4);
158
90.5M
            } else {
159
90.5M
                dst[0 * stride] = av_clip_uint8(dst[0 * stride] + ((Gd + Cd) >> 4));
160
90.5M
                dst[7 * stride] = av_clip_uint8(dst[7 * stride] + ((Gd - Cd) >> 4));
161
162
90.5M
                dst[1 * stride] = av_clip_uint8(dst[1 * stride] + ((Add + Hd) >> 4));
163
90.5M
                dst[2 * stride] = av_clip_uint8(dst[2 * stride] + ((Add - Hd) >> 4));
164
165
90.5M
                dst[3 * stride] = av_clip_uint8(dst[3 * stride] + ((Ed + Dd) >> 4));
166
90.5M
                dst[4 * stride] = av_clip_uint8(dst[4 * stride] + ((Ed - Dd) >> 4));
167
168
90.5M
                dst[5 * stride] = av_clip_uint8(dst[5 * stride] + ((Fd + Bdd) >> 4));
169
90.5M
                dst[6 * stride] = av_clip_uint8(dst[6 * stride] + ((Fd - Bdd) >> 4));
170
90.5M
            }
171
450M
        } else {
172
450M
            if (type == 1) {
173
317M
                dst[0*stride] =
174
317M
                dst[1*stride] =
175
317M
                dst[2*stride] =
176
317M
                dst[3*stride] =
177
317M
                dst[4*stride] =
178
317M
                dst[5*stride] =
179
317M
                dst[6*stride] =
180
317M
                dst[7*stride] = av_clip_uint8(128 + ((xC4S4 * ip[0] + (IdctAdjustBeforeShift << 16)) >> 20));
181
317M
            } else {
182
133M
                if (ip[0]) {
183
101M
                    int v = (xC4S4 * ip[0] + (IdctAdjustBeforeShift << 16)) >> 20;
184
101M
                    dst[0 * stride] = av_clip_uint8(dst[0 * stride] + v);
185
101M
                    dst[1 * stride] = av_clip_uint8(dst[1 * stride] + v);
186
101M
                    dst[2 * stride] = av_clip_uint8(dst[2 * stride] + v);
187
101M
                    dst[3 * stride] = av_clip_uint8(dst[3 * stride] + v);
188
101M
                    dst[4 * stride] = av_clip_uint8(dst[4 * stride] + v);
189
101M
                    dst[5 * stride] = av_clip_uint8(dst[5 * stride] + v);
190
101M
                    dst[6 * stride] = av_clip_uint8(dst[6 * stride] + v);
191
101M
                    dst[7 * stride] = av_clip_uint8(dst[7 * stride] + v);
192
101M
                }
193
133M
            }
194
450M
        }
195
196
578M
        ip += 8;            /* next column */
197
578M
        dst++;
198
578M
    }
199
72.3M
}
200
201
static av_always_inline void idct10(uint8_t *dst, ptrdiff_t stride,
202
                                    int16_t *input, int type)
203
6.96M
{
204
6.96M
    int16_t *ip = input;
205
206
6.96M
    int A, B, C, D, Ad, Bd, Cd, Dd, E, F, G, H;
207
6.96M
    int Ed, Gd, Add, Bdd, Fd, Hd;
208
209
6.96M
    int i;
210
211
    /* Inverse DCT on the rows now */
212
34.8M
    for (i = 0; i < 4; i++) {
213
        /* Check for non-zero values */
214
27.8M
        if (ip[0 * 8] | ip[1 * 8] | ip[2 * 8] | ip[3 * 8]) {
215
4.99M
            A =  M(xC1S7, ip[1 * 8]);
216
4.99M
            B =  M(xC7S1, ip[1 * 8]);
217
4.99M
            C =  M(xC3S5, ip[3 * 8]);
218
4.99M
            D = -M(xC5S3, ip[3 * 8]);
219
220
4.99M
            Ad = M(xC4S4, (A - C));
221
4.99M
            Bd = M(xC4S4, (B - D));
222
223
4.99M
            Cd = A + C;
224
4.99M
            Dd = B + D;
225
226
4.99M
            E = M(xC4S4, ip[0 * 8]);
227
4.99M
            F = E;
228
229
4.99M
            G = M(xC2S6, ip[2 * 8]);
230
4.99M
            H = M(xC6S2, ip[2 * 8]);
231
232
4.99M
            Ed = E - G;
233
4.99M
            Gd = E + G;
234
235
4.99M
            Add = F + Ad;
236
4.99M
            Bdd = Bd - H;
237
238
4.99M
            Fd = F - Ad;
239
4.99M
            Hd = Bd + H;
240
241
            /* Final sequence of operations over-write original inputs */
242
4.99M
            ip[0 * 8] = Gd + Cd;
243
4.99M
            ip[7 * 8] = Gd - Cd;
244
245
4.99M
            ip[1 * 8] = Add + Hd;
246
4.99M
            ip[2 * 8] = Add - Hd;
247
248
4.99M
            ip[3 * 8] = Ed + Dd;
249
4.99M
            ip[4 * 8] = Ed - Dd;
250
251
4.99M
            ip[5 * 8] = Fd + Bdd;
252
4.99M
            ip[6 * 8] = Fd - Bdd;
253
254
4.99M
        }
255
256
27.8M
        ip += 1;
257
27.8M
    }
258
259
6.96M
    ip = input;
260
261
62.6M
    for (i = 0; i < 8; i++) {
262
        /* Check for non-zero values (bitwise or faster than ||) */
263
55.7M
        if (ip[0] | ip[1] | ip[2] | ip[3]) {
264
31.9M
            A =  M(xC1S7, ip[1]);
265
31.9M
            B =  M(xC7S1, ip[1]);
266
31.9M
            C =  M(xC3S5, ip[3]);
267
31.9M
            D = -M(xC5S3, ip[3]);
268
269
31.9M
            Ad = M(xC4S4, (A - C));
270
31.9M
            Bd = M(xC4S4, (B - D));
271
272
31.9M
            Cd = A + C;
273
31.9M
            Dd = B + D;
274
275
31.9M
            E = M(xC4S4, ip[0]);
276
31.9M
            if (type == 1)
277
28.2M
                E += 16 * 128;
278
31.9M
            F = E;
279
280
31.9M
            G = M(xC2S6, ip[2]);
281
31.9M
            H = M(xC6S2, ip[2]);
282
283
31.9M
            Ed = E - G;
284
31.9M
            Gd = E + G;
285
286
31.9M
            Add = F + Ad;
287
31.9M
            Bdd = Bd - H;
288
289
31.9M
            Fd = F - Ad;
290
31.9M
            Hd = Bd + H;
291
292
31.9M
            Gd += 8;
293
31.9M
            Add += 8;
294
31.9M
            Ed += 8;
295
31.9M
            Fd += 8;
296
297
            /* Final sequence of operations over-write original inputs. */
298
31.9M
            if (type == 1) {
299
28.2M
                dst[0 * stride] = av_clip_uint8((Gd + Cd) >> 4);
300
28.2M
                dst[7 * stride] = av_clip_uint8((Gd - Cd) >> 4);
301
302
28.2M
                dst[1 * stride] = av_clip_uint8((Add + Hd) >> 4);
303
28.2M
                dst[2 * stride] = av_clip_uint8((Add - Hd) >> 4);
304
305
28.2M
                dst[3 * stride] = av_clip_uint8((Ed + Dd) >> 4);
306
28.2M
                dst[4 * stride] = av_clip_uint8((Ed - Dd) >> 4);
307
308
28.2M
                dst[5 * stride] = av_clip_uint8((Fd + Bdd) >> 4);
309
28.2M
                dst[6 * stride] = av_clip_uint8((Fd - Bdd) >> 4);
310
28.2M
            } else {
311
3.64M
                dst[0 * stride] = av_clip_uint8(dst[0 * stride] + ((Gd + Cd) >> 4));
312
3.64M
                dst[7 * stride] = av_clip_uint8(dst[7 * stride] + ((Gd - Cd) >> 4));
313
314
3.64M
                dst[1 * stride] = av_clip_uint8(dst[1 * stride] + ((Add + Hd) >> 4));
315
3.64M
                dst[2 * stride] = av_clip_uint8(dst[2 * stride] + ((Add - Hd) >> 4));
316
317
3.64M
                dst[3 * stride] = av_clip_uint8(dst[3 * stride] + ((Ed + Dd) >> 4));
318
3.64M
                dst[4 * stride] = av_clip_uint8(dst[4 * stride] + ((Ed - Dd) >> 4));
319
320
3.64M
                dst[5 * stride] = av_clip_uint8(dst[5 * stride] + ((Fd + Bdd) >> 4));
321
3.64M
                dst[6 * stride] = av_clip_uint8(dst[6 * stride] + ((Fd - Bdd) >> 4));
322
3.64M
            }
323
31.9M
        } else {
324
23.7M
            if (type == 1) {
325
6.14M
                dst[0*stride] =
326
6.14M
                dst[1*stride] =
327
6.14M
                dst[2*stride] =
328
6.14M
                dst[3*stride] =
329
6.14M
                dst[4*stride] =
330
6.14M
                dst[5*stride] =
331
6.14M
                dst[6*stride] =
332
6.14M
                dst[7*stride] = 128;
333
6.14M
            }
334
23.7M
        }
335
336
55.7M
        ip += 8;
337
55.7M
        dst++;
338
55.7M
    }
339
6.96M
}
340
341
void ff_vp3dsp_idct10_put(uint8_t *dest, ptrdiff_t stride, int16_t *block)
342
4.30M
{
343
4.30M
    idct10(dest, stride, block, 1);
344
4.30M
    memset(block, 0, sizeof(*block) * 64);
345
4.30M
}
346
347
void ff_vp3dsp_idct10_add(uint8_t *dest, ptrdiff_t stride, int16_t *block)
348
2.66M
{
349
2.66M
    idct10(dest, stride, block, 2);
350
2.66M
    memset(block, 0, sizeof(*block) * 64);
351
2.66M
}
352
353
static void vp3_idct_put_c(uint8_t *dest /* align 8 */, ptrdiff_t stride,
354
                           int16_t *block /* align 16 */)
355
44.4M
{
356
44.4M
    idct(dest, stride, block, 1);
357
44.4M
    memset(block, 0, sizeof(*block) * 64);
358
44.4M
}
359
360
static void vp3_idct_add_c(uint8_t *dest /* align 8 */, ptrdiff_t stride,
361
                           int16_t *block /* align 16 */)
362
27.9M
{
363
27.9M
    idct(dest, stride, block, 2);
364
27.9M
    memset(block, 0, sizeof(*block) * 64);
365
27.9M
}
366
367
static void vp3_idct_dc_add_c(uint8_t *dest /* align 8 */, ptrdiff_t stride,
368
                              int16_t *block /* align 16 */)
369
23.6M
{
370
23.6M
    int i, dc = (block[0] + 15) >> 5;
371
372
213M
    for (i = 0; i < 8; i++) {
373
189M
        dest[0] = av_clip_uint8(dest[0] + dc);
374
189M
        dest[1] = av_clip_uint8(dest[1] + dc);
375
189M
        dest[2] = av_clip_uint8(dest[2] + dc);
376
189M
        dest[3] = av_clip_uint8(dest[3] + dc);
377
189M
        dest[4] = av_clip_uint8(dest[4] + dc);
378
189M
        dest[5] = av_clip_uint8(dest[5] + dc);
379
189M
        dest[6] = av_clip_uint8(dest[6] + dc);
380
189M
        dest[7] = av_clip_uint8(dest[7] + dc);
381
189M
        dest   += stride;
382
189M
    }
383
23.6M
    block[0] = 0;
384
23.6M
}
385
386
static av_always_inline void vp3_v_loop_filter_c(uint8_t *first_pixel, ptrdiff_t stride,
387
                                                 int *bounding_values, int count)
388
35.1M
{
389
35.1M
    unsigned char *end;
390
35.1M
    int filter_value;
391
35.1M
    const ptrdiff_t nstride = -stride;
392
393
332M
    for (end = first_pixel + count; first_pixel < end; first_pixel++) {
394
297M
        filter_value = (first_pixel[2 * nstride] - first_pixel[stride]) +
395
297M
                       (first_pixel[0] - first_pixel[nstride]) * 3;
396
297M
        filter_value = bounding_values[(filter_value + 4) >> 3];
397
398
297M
        first_pixel[nstride] = av_clip_uint8(first_pixel[nstride] + filter_value);
399
297M
        first_pixel[0]       = av_clip_uint8(first_pixel[0] - filter_value);
400
297M
    }
401
35.1M
}
402
403
static av_always_inline void vp3_h_loop_filter_c(uint8_t *first_pixel, ptrdiff_t stride,
404
                                                 int *bounding_values, int count)
405
37.8M
{
406
37.8M
    unsigned char *end;
407
37.8M
    int filter_value;
408
409
360M
    for (end = first_pixel + count * stride; first_pixel != end; first_pixel += stride) {
410
322M
        filter_value = (first_pixel[-2] - first_pixel[1]) +
411
322M
                       (first_pixel[ 0] - first_pixel[-1]) * 3;
412
322M
        filter_value = bounding_values[(filter_value + 4) >> 3];
413
414
322M
        first_pixel[-1] = av_clip_uint8(first_pixel[-1] + filter_value);
415
322M
        first_pixel[ 0] = av_clip_uint8(first_pixel[ 0] - filter_value);
416
322M
    }
417
37.8M
}
418
419
#define LOOP_FILTER(prefix, suffix, dim, count) \
420
void prefix##_##dim##_loop_filter_##count##suffix(uint8_t *first_pixel, ptrdiff_t stride, \
421
72.9M
                                int *bounding_values) \
422
72.9M
{ \
423
72.9M
    vp3_##dim##_loop_filter_c(first_pixel, stride, bounding_values, count); \
424
72.9M
}
ff_vp3dsp_v_loop_filter_12
Line
Count
Source
421
3.99M
                                int *bounding_values) \
422
3.99M
{ \
423
3.99M
    vp3_##dim##_loop_filter_c(first_pixel, stride, bounding_values, count); \
424
3.99M
}
ff_vp3dsp_h_loop_filter_12
Line
Count
Source
421
5.07M
                                int *bounding_values) \
422
5.07M
{ \
423
5.07M
    vp3_##dim##_loop_filter_c(first_pixel, stride, bounding_values, count); \
424
5.07M
}
vp3dsp.c:vp3_v_loop_filter_8_c
Line
Count
Source
421
31.1M
                                int *bounding_values) \
422
31.1M
{ \
423
31.1M
    vp3_##dim##_loop_filter_c(first_pixel, stride, bounding_values, count); \
424
31.1M
}
vp3dsp.c:vp3_h_loop_filter_8_c
Line
Count
Source
421
32.7M
                                int *bounding_values) \
422
32.7M
{ \
423
32.7M
    vp3_##dim##_loop_filter_c(first_pixel, stride, bounding_values, count); \
424
32.7M
}
425
426
static LOOP_FILTER(vp3,_c, v, 8)
427
static LOOP_FILTER(vp3,_c, h, 8)
428
LOOP_FILTER(ff_vp3dsp, , v, 12)
429
LOOP_FILTER(ff_vp3dsp, , h, 12)
430
431
static void put_no_rnd_pixels_l2(uint8_t *dst, const uint8_t *src1,
432
                                 const uint8_t *src2, ptrdiff_t stride, int h)
433
6.96M
{
434
6.96M
    int i;
435
436
62.7M
    for (i = 0; i < h; i++) {
437
55.7M
        uint32_t a, b;
438
439
55.7M
        a = AV_RN32(&src1[i * stride]);
440
55.7M
        b = AV_RN32(&src2[i * stride]);
441
55.7M
        AV_WN32A(&dst[i * stride], no_rnd_avg32(a, b));
442
55.7M
        a = AV_RN32(&src1[i * stride + 4]);
443
55.7M
        b = AV_RN32(&src2[i * stride + 4]);
444
55.7M
        AV_WN32A(&dst[i * stride + 4], no_rnd_avg32(a, b));
445
55.7M
    }
446
6.96M
}
447
448
av_cold void ff_vp3dsp_init(VP3DSPContext *c)
449
38.5k
{
450
38.5k
    c->put_no_rnd_pixels_l2 = put_no_rnd_pixels_l2;
451
452
38.5k
    c->idct_put      = vp3_idct_put_c;
453
38.5k
    c->idct_add      = vp3_idct_add_c;
454
38.5k
    c->idct_dc_add   = vp3_idct_dc_add_c;
455
38.5k
    c->v_loop_filter = c->v_loop_filter_unaligned = vp3_v_loop_filter_8_c;
456
38.5k
    c->h_loop_filter = c->h_loop_filter_unaligned = vp3_h_loop_filter_8_c;
457
458
#if ARCH_ARM
459
    ff_vp3dsp_init_arm(c);
460
#elif ARCH_PPC
461
    ff_vp3dsp_init_ppc(c);
462
#elif ARCH_X86 && HAVE_X86ASM
463
    ff_vp3dsp_init_x86(c);
464
#elif ARCH_MIPS
465
    ff_vp3dsp_init_mips(c);
466
#endif
467
38.5k
}
468
469
/*
470
 * This function initializes the loop filter boundary limits if the frame's
471
 * quality index is different from the previous frame's.
472
 *
473
 * where sizeof(bounding_values_array) is 256 * sizeof(int)
474
 *
475
 * The filter_limit_values may not be larger than 127.
476
 */
477
void ff_vp3dsp_set_bounding_values(int * bounding_values_array, int filter_limit)
478
151k
{
479
151k
    int *bounding_values = bounding_values_array + 127;
480
151k
    int x;
481
151k
    int value;
482
483
151k
    av_assert0(filter_limit < 128U);
484
485
    /* set up the bounding values */
486
151k
    memset(bounding_values_array, 0, 256 * sizeof(int));
487
1.54M
    for (x = 0; x < filter_limit; x++) {
488
1.39M
        bounding_values[-x] = -x;
489
1.39M
        bounding_values[x] = x;
490
1.39M
    }
491
1.51M
    for (x = value = filter_limit; x < 128 && value; x++, value--) {
492
1.36M
        bounding_values[ x] =  value;
493
1.36M
        bounding_values[-x] = -value;
494
1.36M
    }
495
151k
    if (value)
496
282
        bounding_values[128] = value;
497
#if ARCH_X86
498
    bounding_values[129] = bounding_values[130] =
499
    bounding_values[131] = bounding_values[132] = filter_limit * 0x00020002U;
500
#else
501
151k
    bounding_values[129] = bounding_values[130] = filter_limit * 0x02020202U;
502
151k
#endif
503
151k
}