Coverage Report

Created: 2026-09-14 08:00

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
453M
#define IdctAdjustBeforeShift 8
40
#define xC1S7 64277
41
#define xC2S6 60547
42
#define xC3S5 54491
43
453M
#define xC4S4 46341
44
#define xC5S3 36410
45
#define xC6S2 25080
46
#define xC7S1 12785
47
48
4.10G
#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
75.9M
{
53
75.9M
    int16_t *ip = input;
54
55
75.9M
    int A, B, C, D, Ad, Bd, Cd, Dd, E, F, G, H;
56
75.9M
    int Ed, Gd, Add, Bdd, Fd, Hd;
57
58
75.9M
    int i;
59
60
    /* Inverse DCT on the rows now */
61
683M
    for (i = 0; i < 8; i++) {
62
        /* Check for non-zero values */
63
607M
        if (ip[0 * 8] | ip[1 * 8] | ip[2 * 8] | ip[3 * 8] |
64
607M
            ip[4 * 8] | ip[5 * 8] | ip[6 * 8] | ip[7 * 8]) {
65
101M
            A = M(xC1S7, ip[1 * 8]) + M(xC7S1, ip[7 * 8]);
66
101M
            B = M(xC7S1, ip[1 * 8]) - M(xC1S7, ip[7 * 8]);
67
101M
            C = M(xC3S5, ip[3 * 8]) + M(xC5S3, ip[5 * 8]);
68
101M
            D = M(xC3S5, ip[5 * 8]) - M(xC5S3, ip[3 * 8]);
69
70
101M
            Ad = M(xC4S4, (A - C));
71
101M
            Bd = M(xC4S4, (B - D));
72
73
101M
            Cd = A + C;
74
101M
            Dd = B + D;
75
76
101M
            E = M(xC4S4, (ip[0 * 8] + ip[4 * 8]));
77
101M
            F = M(xC4S4, (ip[0 * 8] - ip[4 * 8]));
78
79
101M
            G = M(xC2S6, ip[2 * 8]) + M(xC6S2, ip[6 * 8]);
80
101M
            H = M(xC6S2, ip[2 * 8]) - M(xC2S6, ip[6 * 8]);
81
82
101M
            Ed = E - G;
83
101M
            Gd = E + G;
84
85
101M
            Add = F + Ad;
86
101M
            Bdd = Bd - H;
87
88
101M
            Fd = F - Ad;
89
101M
            Hd = Bd + H;
90
91
            /*  Final sequence of operations over-write original inputs. */
92
101M
            ip[0 * 8] = Gd + Cd;
93
101M
            ip[7 * 8] = Gd - Cd;
94
95
101M
            ip[1 * 8] = Add + Hd;
96
101M
            ip[2 * 8] = Add - Hd;
97
98
101M
            ip[3 * 8] = Ed + Dd;
99
101M
            ip[4 * 8] = Ed - Dd;
100
101
101M
            ip[5 * 8] = Fd + Bdd;
102
101M
            ip[6 * 8] = Fd - Bdd;
103
101M
        }
104
105
607M
        ip += 1;            /* next row */
106
607M
    }
107
108
75.9M
    ip = input;
109
110
683M
    for (i = 0; i < 8; i++) {
111
        /* Check for non-zero values (bitwise or faster than ||) */
112
607M
        if (ip[1] | ip[2] | ip[3] |
113
607M
            ip[4] | ip[5] | ip[6] | ip[7]) {
114
123M
            A = M(xC1S7, ip[1]) + M(xC7S1, ip[7]);
115
123M
            B = M(xC7S1, ip[1]) - M(xC1S7, ip[7]);
116
123M
            C = M(xC3S5, ip[3]) + M(xC5S3, ip[5]);
117
123M
            D = M(xC3S5, ip[5]) - M(xC5S3, ip[3]);
118
119
123M
            Ad = M(xC4S4, (A - C));
120
123M
            Bd = M(xC4S4, (B - D));
121
122
123M
            Cd = A + C;
123
123M
            Dd = B + D;
124
125
123M
            E = M(xC4S4, (ip[0] + ip[4])) + 8;
126
123M
            F = M(xC4S4, (ip[0] - ip[4])) + 8;
127
128
123M
            if (type == 1) { // HACK
129
33.0M
                E += 16 * 128;
130
33.0M
                F += 16 * 128;
131
33.0M
            }
132
133
123M
            G = M(xC2S6, ip[2]) + M(xC6S2, ip[6]);
134
123M
            H = M(xC6S2, ip[2]) - M(xC2S6, ip[6]);
135
136
123M
            Ed = E - G;
137
123M
            Gd = E + G;
138
139
123M
            Add = F + Ad;
140
123M
            Bdd = Bd - H;
141
142
123M
            Fd = F - Ad;
143
123M
            Hd = Bd + H;
144
145
            /* Final sequence of operations over-write original inputs. */
146
123M
            if (type == 1) {
147
33.0M
                dst[0 * stride] = av_clip_uint8((Gd + Cd) >> 4);
148
33.0M
                dst[7 * stride] = av_clip_uint8((Gd - Cd) >> 4);
149
150
33.0M
                dst[1 * stride] = av_clip_uint8((Add + Hd) >> 4);
151
33.0M
                dst[2 * stride] = av_clip_uint8((Add - Hd) >> 4);
152
153
33.0M
                dst[3 * stride] = av_clip_uint8((Ed + Dd) >> 4);
154
33.0M
                dst[4 * stride] = av_clip_uint8((Ed - Dd) >> 4);
155
156
33.0M
                dst[5 * stride] = av_clip_uint8((Fd + Bdd) >> 4);
157
33.0M
                dst[6 * stride] = av_clip_uint8((Fd - Bdd) >> 4);
158
90.0M
            } else {
159
90.0M
                dst[0 * stride] = av_clip_uint8(dst[0 * stride] + ((Gd + Cd) >> 4));
160
90.0M
                dst[7 * stride] = av_clip_uint8(dst[7 * stride] + ((Gd - Cd) >> 4));
161
162
90.0M
                dst[1 * stride] = av_clip_uint8(dst[1 * stride] + ((Add + Hd) >> 4));
163
90.0M
                dst[2 * stride] = av_clip_uint8(dst[2 * stride] + ((Add - Hd) >> 4));
164
165
90.0M
                dst[3 * stride] = av_clip_uint8(dst[3 * stride] + ((Ed + Dd) >> 4));
166
90.0M
                dst[4 * stride] = av_clip_uint8(dst[4 * stride] + ((Ed - Dd) >> 4));
167
168
90.0M
                dst[5 * stride] = av_clip_uint8(dst[5 * stride] + ((Fd + Bdd) >> 4));
169
90.0M
                dst[6 * stride] = av_clip_uint8(dst[6 * stride] + ((Fd - Bdd) >> 4));
170
90.0M
            }
171
484M
        } else {
172
484M
            if (type == 1) {
173
358M
                dst[0*stride] =
174
358M
                dst[1*stride] =
175
358M
                dst[2*stride] =
176
358M
                dst[3*stride] =
177
358M
                dst[4*stride] =
178
358M
                dst[5*stride] =
179
358M
                dst[6*stride] =
180
358M
                dst[7*stride] = av_clip_uint8(128 + ((xC4S4 * ip[0] + (IdctAdjustBeforeShift << 16)) >> 20));
181
358M
            } else {
182
125M
                if (ip[0]) {
183
94.4M
                    int v = (xC4S4 * ip[0] + (IdctAdjustBeforeShift << 16)) >> 20;
184
94.4M
                    dst[0 * stride] = av_clip_uint8(dst[0 * stride] + v);
185
94.4M
                    dst[1 * stride] = av_clip_uint8(dst[1 * stride] + v);
186
94.4M
                    dst[2 * stride] = av_clip_uint8(dst[2 * stride] + v);
187
94.4M
                    dst[3 * stride] = av_clip_uint8(dst[3 * stride] + v);
188
94.4M
                    dst[4 * stride] = av_clip_uint8(dst[4 * stride] + v);
189
94.4M
                    dst[5 * stride] = av_clip_uint8(dst[5 * stride] + v);
190
94.4M
                    dst[6 * stride] = av_clip_uint8(dst[6 * stride] + v);
191
94.4M
                    dst[7 * stride] = av_clip_uint8(dst[7 * stride] + v);
192
94.4M
                }
193
125M
            }
194
484M
        }
195
196
607M
        ip += 8;            /* next column */
197
607M
        dst++;
198
607M
    }
199
75.9M
}
200
201
static av_always_inline void idct10(uint8_t *dst, ptrdiff_t stride,
202
                                    int16_t *input, int type)
203
13.6M
{
204
13.6M
    int16_t *ip = input;
205
206
13.6M
    int A, B, C, D, Ad, Bd, Cd, Dd, E, F, G, H;
207
13.6M
    int Ed, Gd, Add, Bdd, Fd, Hd;
208
209
13.6M
    int i;
210
211
    /* Inverse DCT on the rows now */
212
68.2M
    for (i = 0; i < 4; i++) {
213
        /* Check for non-zero values */
214
54.6M
        if (ip[0 * 8] | ip[1 * 8] | ip[2 * 8] | ip[3 * 8]) {
215
7.24M
            A =  M(xC1S7, ip[1 * 8]);
216
7.24M
            B =  M(xC7S1, ip[1 * 8]);
217
7.24M
            C =  M(xC3S5, ip[3 * 8]);
218
7.24M
            D = -M(xC5S3, ip[3 * 8]);
219
220
7.24M
            Ad = M(xC4S4, (A - C));
221
7.24M
            Bd = M(xC4S4, (B - D));
222
223
7.24M
            Cd = A + C;
224
7.24M
            Dd = B + D;
225
226
7.24M
            E = M(xC4S4, ip[0 * 8]);
227
7.24M
            F = E;
228
229
7.24M
            G = M(xC2S6, ip[2 * 8]);
230
7.24M
            H = M(xC6S2, ip[2 * 8]);
231
232
7.24M
            Ed = E - G;
233
7.24M
            Gd = E + G;
234
235
7.24M
            Add = F + Ad;
236
7.24M
            Bdd = Bd - H;
237
238
7.24M
            Fd = F - Ad;
239
7.24M
            Hd = Bd + H;
240
241
            /* Final sequence of operations over-write original inputs */
242
7.24M
            ip[0 * 8] = Gd + Cd;
243
7.24M
            ip[7 * 8] = Gd - Cd;
244
245
7.24M
            ip[1 * 8] = Add + Hd;
246
7.24M
            ip[2 * 8] = Add - Hd;
247
248
7.24M
            ip[3 * 8] = Ed + Dd;
249
7.24M
            ip[4 * 8] = Ed - Dd;
250
251
7.24M
            ip[5 * 8] = Fd + Bdd;
252
7.24M
            ip[6 * 8] = Fd - Bdd;
253
254
7.24M
        }
255
256
54.6M
        ip += 1;
257
54.6M
    }
258
259
13.6M
    ip = input;
260
261
122M
    for (i = 0; i < 8; i++) {
262
        /* Check for non-zero values (bitwise or faster than ||) */
263
109M
        if (ip[0] | ip[1] | ip[2] | ip[3]) {
264
49.2M
            A =  M(xC1S7, ip[1]);
265
49.2M
            B =  M(xC7S1, ip[1]);
266
49.2M
            C =  M(xC3S5, ip[3]);
267
49.2M
            D = -M(xC5S3, ip[3]);
268
269
49.2M
            Ad = M(xC4S4, (A - C));
270
49.2M
            Bd = M(xC4S4, (B - D));
271
272
49.2M
            Cd = A + C;
273
49.2M
            Dd = B + D;
274
275
49.2M
            E = M(xC4S4, ip[0]);
276
49.2M
            if (type == 1)
277
43.9M
                E += 16 * 128;
278
49.2M
            F = E;
279
280
49.2M
            G = M(xC2S6, ip[2]);
281
49.2M
            H = M(xC6S2, ip[2]);
282
283
49.2M
            Ed = E - G;
284
49.2M
            Gd = E + G;
285
286
49.2M
            Add = F + Ad;
287
49.2M
            Bdd = Bd - H;
288
289
49.2M
            Fd = F - Ad;
290
49.2M
            Hd = Bd + H;
291
292
49.2M
            Gd += 8;
293
49.2M
            Add += 8;
294
49.2M
            Ed += 8;
295
49.2M
            Fd += 8;
296
297
            /* Final sequence of operations over-write original inputs. */
298
49.2M
            if (type == 1) {
299
43.9M
                dst[0 * stride] = av_clip_uint8((Gd + Cd) >> 4);
300
43.9M
                dst[7 * stride] = av_clip_uint8((Gd - Cd) >> 4);
301
302
43.9M
                dst[1 * stride] = av_clip_uint8((Add + Hd) >> 4);
303
43.9M
                dst[2 * stride] = av_clip_uint8((Add - Hd) >> 4);
304
305
43.9M
                dst[3 * stride] = av_clip_uint8((Ed + Dd) >> 4);
306
43.9M
                dst[4 * stride] = av_clip_uint8((Ed - Dd) >> 4);
307
308
43.9M
                dst[5 * stride] = av_clip_uint8((Fd + Bdd) >> 4);
309
43.9M
                dst[6 * stride] = av_clip_uint8((Fd - Bdd) >> 4);
310
43.9M
            } else {
311
5.25M
                dst[0 * stride] = av_clip_uint8(dst[0 * stride] + ((Gd + Cd) >> 4));
312
5.25M
                dst[7 * stride] = av_clip_uint8(dst[7 * stride] + ((Gd - Cd) >> 4));
313
314
5.25M
                dst[1 * stride] = av_clip_uint8(dst[1 * stride] + ((Add + Hd) >> 4));
315
5.25M
                dst[2 * stride] = av_clip_uint8(dst[2 * stride] + ((Add - Hd) >> 4));
316
317
5.25M
                dst[3 * stride] = av_clip_uint8(dst[3 * stride] + ((Ed + Dd) >> 4));
318
5.25M
                dst[4 * stride] = av_clip_uint8(dst[4 * stride] + ((Ed - Dd) >> 4));
319
320
5.25M
                dst[5 * stride] = av_clip_uint8(dst[5 * stride] + ((Fd + Bdd) >> 4));
321
5.25M
                dst[6 * stride] = av_clip_uint8(dst[6 * stride] + ((Fd - Bdd) >> 4));
322
5.25M
            }
323
60.0M
        } else {
324
60.0M
            if (type == 1) {
325
9.22M
                dst[0*stride] =
326
9.22M
                dst[1*stride] =
327
9.22M
                dst[2*stride] =
328
9.22M
                dst[3*stride] =
329
9.22M
                dst[4*stride] =
330
9.22M
                dst[5*stride] =
331
9.22M
                dst[6*stride] =
332
9.22M
                dst[7*stride] = 128;
333
9.22M
            }
334
60.0M
        }
335
336
109M
        ip += 8;
337
109M
        dst++;
338
109M
    }
339
13.6M
}
340
341
void ff_vp3dsp_idct10_put(uint8_t *dest, ptrdiff_t stride, int16_t *block)
342
6.64M
{
343
6.64M
    idct10(dest, stride, block, 1);
344
6.64M
    memset(block, 0, sizeof(*block) * 64);
345
6.64M
}
346
347
void ff_vp3dsp_idct10_add(uint8_t *dest, ptrdiff_t stride, int16_t *block)
348
7.01M
{
349
7.01M
    idct10(dest, stride, block, 2);
350
7.01M
    memset(block, 0, sizeof(*block) * 64);
351
7.01M
}
352
353
static void vp3_idct_put_c(uint8_t *dest /* align 8 */, ptrdiff_t stride,
354
                           int16_t *block /* align 16 */)
355
48.9M
{
356
48.9M
    idct(dest, stride, block, 1);
357
48.9M
    memset(block, 0, sizeof(*block) * 64);
358
48.9M
}
359
360
static void vp3_idct_add_c(uint8_t *dest /* align 8 */, ptrdiff_t stride,
361
                           int16_t *block /* align 16 */)
362
26.9M
{
363
26.9M
    idct(dest, stride, block, 2);
364
26.9M
    memset(block, 0, sizeof(*block) * 64);
365
26.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
26.1M
{
370
26.1M
    int i, dc = (block[0] + 15) >> 5;
371
372
234M
    for (i = 0; i < 8; i++) {
373
208M
        dest[0] = av_clip_uint8(dest[0] + dc);
374
208M
        dest[1] = av_clip_uint8(dest[1] + dc);
375
208M
        dest[2] = av_clip_uint8(dest[2] + dc);
376
208M
        dest[3] = av_clip_uint8(dest[3] + dc);
377
208M
        dest[4] = av_clip_uint8(dest[4] + dc);
378
208M
        dest[5] = av_clip_uint8(dest[5] + dc);
379
208M
        dest[6] = av_clip_uint8(dest[6] + dc);
380
208M
        dest[7] = av_clip_uint8(dest[7] + dc);
381
208M
        dest   += stride;
382
208M
    }
383
26.1M
    block[0] = 0;
384
26.1M
}
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
36.7M
{
389
36.7M
    unsigned char *end;
390
36.7M
    int filter_value;
391
36.7M
    const ptrdiff_t nstride = -stride;
392
393
342M
    for (end = first_pixel + count; first_pixel < end; first_pixel++) {
394
306M
        filter_value = (first_pixel[2 * nstride] - first_pixel[stride]) +
395
306M
                       (first_pixel[0] - first_pixel[nstride]) * 3;
396
306M
        filter_value = bounding_values[(filter_value + 4) >> 3];
397
398
306M
        first_pixel[nstride] = av_clip_uint8(first_pixel[nstride] + filter_value);
399
306M
        first_pixel[0]       = av_clip_uint8(first_pixel[0] - filter_value);
400
306M
    }
401
36.7M
}
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
39.8M
{
406
39.8M
    unsigned char *end;
407
39.8M
    int filter_value;
408
409
373M
    for (end = first_pixel + count * stride; first_pixel != end; first_pixel += stride) {
410
333M
        filter_value = (first_pixel[-2] - first_pixel[1]) +
411
333M
                       (first_pixel[ 0] - first_pixel[-1]) * 3;
412
333M
        filter_value = bounding_values[(filter_value + 4) >> 3];
413
414
333M
        first_pixel[-1] = av_clip_uint8(first_pixel[-1] + filter_value);
415
333M
        first_pixel[ 0] = av_clip_uint8(first_pixel[ 0] - filter_value);
416
333M
    }
417
39.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
76.6M
                                int *bounding_values) \
422
76.6M
{ \
423
76.6M
    vp3_##dim##_loop_filter_c(first_pixel, stride, bounding_values, count); \
424
76.6M
}
ff_vp3dsp_v_loop_filter_12
Line
Count
Source
421
3.05M
                                int *bounding_values) \
422
3.05M
{ \
423
3.05M
    vp3_##dim##_loop_filter_c(first_pixel, stride, bounding_values, count); \
424
3.05M
}
ff_vp3dsp_h_loop_filter_12
Line
Count
Source
421
3.70M
                                int *bounding_values) \
422
3.70M
{ \
423
3.70M
    vp3_##dim##_loop_filter_c(first_pixel, stride, bounding_values, count); \
424
3.70M
}
vp3dsp.c:vp3_v_loop_filter_8_c
Line
Count
Source
421
33.6M
                                int *bounding_values) \
422
33.6M
{ \
423
33.6M
    vp3_##dim##_loop_filter_c(first_pixel, stride, bounding_values, count); \
424
33.6M
}
vp3dsp.c:vp3_h_loop_filter_8_c
Line
Count
Source
421
36.1M
                                int *bounding_values) \
422
36.1M
{ \
423
36.1M
    vp3_##dim##_loop_filter_c(first_pixel, stride, bounding_values, count); \
424
36.1M
}
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.17M
{
434
6.17M
    int i;
435
436
55.5M
    for (i = 0; i < h; i++) {
437
49.3M
        uint32_t a, b;
438
439
49.3M
        a = AV_RN32(&src1[i * stride]);
440
49.3M
        b = AV_RN32(&src2[i * stride]);
441
49.3M
        AV_WN32A(&dst[i * stride], no_rnd_avg32(a, b));
442
49.3M
        a = AV_RN32(&src1[i * stride + 4]);
443
49.3M
        b = AV_RN32(&src2[i * stride + 4]);
444
49.3M
        AV_WN32A(&dst[i * stride + 4], no_rnd_avg32(a, b));
445
49.3M
    }
446
6.17M
}
447
448
av_cold void ff_vp3dsp_init(VP3DSPContext *c)
449
39.9k
{
450
39.9k
    c->put_no_rnd_pixels_l2 = put_no_rnd_pixels_l2;
451
452
39.9k
    c->idct_put      = vp3_idct_put_c;
453
39.9k
    c->idct_add      = vp3_idct_add_c;
454
39.9k
    c->idct_dc_add   = vp3_idct_dc_add_c;
455
39.9k
    c->v_loop_filter = c->v_loop_filter_unaligned = vp3_v_loop_filter_8_c;
456
39.9k
    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
39.9k
}
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
177k
{
479
177k
    int *bounding_values = bounding_values_array + 127;
480
177k
    int x;
481
177k
    int value;
482
483
177k
    av_assert0(filter_limit < 128U);
484
485
    /* set up the bounding values */
486
177k
    memset(bounding_values_array, 0, 256 * sizeof(int));
487
1.80M
    for (x = 0; x < filter_limit; x++) {
488
1.63M
        bounding_values[-x] = -x;
489
1.63M
        bounding_values[x] = x;
490
1.63M
    }
491
1.77M
    for (x = value = filter_limit; x < 128 && value; x++, value--) {
492
1.60M
        bounding_values[ x] =  value;
493
1.60M
        bounding_values[-x] = -value;
494
1.60M
    }
495
177k
    if (value)
496
304
        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
177k
    bounding_values[129] = bounding_values[130] = filter_limit * 0x02020202U;
502
177k
#endif
503
177k
}