filter.c 33.2 KB
Newer Older
John Koleszar's avatar
John Koleszar committed
1
/*
2
 *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
John Koleszar's avatar
John Koleszar committed
3
 *
4
 *  Use of this source code is governed by a BSD-style license
5
6
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
7
 *  in the file PATENTS.  All contributing project authors may
8
 *  be found in the AUTHORS file in the root of the source tree.
John Koleszar's avatar
John Koleszar committed
9
10
11
12
 */


#include <stdlib.h>
Johann's avatar
Johann committed
13
14
#include "filter.h"
#include "vpx_ports/mem.h"
John Koleszar's avatar
John Koleszar committed
15

16
DECLARE_ALIGNED(16, const short, vp8_bilinear_filters[SUBPEL_SHIFTS][2]) =
John Koleszar's avatar
John Koleszar committed
17
{
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#if SUBPEL_SHIFTS==16
    { 128,   0 },
    { 120,   8 },
    { 112,  16 },
    { 104,  24 },
    {  96,  32 },
    {  88,  40 },
    {  80,  48 },
    {  72,  56 },
    {  64,  64 },
    {  56,  72 },
    {  48,  80 },
    {  40,  88 },
    {  32,  96 },
    {  24, 104 },
    {  16, 112 },
    {   8, 120 }
#else
John Koleszar's avatar
John Koleszar committed
36
37
38
39
40
41
42
43
    { 128,   0 },
    { 112,  16 },
    {  96,  32 },
    {  80,  48 },
    {  64,  64 },
    {  48,  80 },
    {  32,  96 },
    {  16, 112 }
44
#endif  /* SUBPEL_SHIFTS==16 */
John Koleszar's avatar
John Koleszar committed
45
46
};

47
#if CONFIG_ENHANCED_INTERP
48
#define FILTER_ALPHA 60
49
DECLARE_ALIGNED(16, const short, vp8_sub_pel_filters[SUBPEL_SHIFTS][2*INTERP_EXTEND]) =
50
51
{
    /* Generated using MATLAB:
52
     * alpha = 0.6;
53
54
55
56
57
     * b=intfilt(8,4,alpha);
     * bi=round(128*b);
     * ba=flipud(reshape([bi 0], 8, 8));
     * disp(num2str(ba, '%d,'))
     */
58
#if SUBPEL_SHIFTS==16
59
#if FILTER_ALPHA == 70
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
    /* alpha = 0.70 */
    { 0,   0,   0, 128,   0,   0,   0,  0},
    { 0,   2,  -6, 126,   8,  -3,   1,  0},
    {-1,   4, -11, 123,  18,  -7,   3, -1},
    {-1,   5, -15, 119,  27, -10,   4, -1},
    {-2,   6, -18, 113,  38, -13,   5, -1},
    {-2,   7, -20, 106,  49, -16,   6, -2},
    {-2,   8, -22,  98,  59, -18,   7, -2},
    {-2,   8, -22,  89,  69, -20,   8, -2},
    {-2,   8, -21,  79,  79, -21,   8, -2},
    {-2,   8, -20,  69,  89, -22,   8, -2},
    {-2,   7, -18,  59,  98, -22,   8, -2},
    {-2,   6, -16,  49, 106, -20,   7, -2},
    {-1,   5, -13,  38, 113, -18,   6, -2},
    {-1,   4, -10,  27, 119, -15,   5, -1},
    {-1,   3,  -7,  18, 123, -11,   4, -1},
    { 0,   1,  -3,   8, 126,  -6,   2,  0}
#elif FILTER_ALPHA == 65
    /* alpha = 0.65 */
    { 0,   0,   0, 128,   0,   0,   0,  0},
    { 0,   2,  -6, 126,   8,  -3,   1,  0},
    {-1,   3, -10, 123,  18,  -6,   2, -1},
    {-1,   5, -14, 118,  27, -10,   4, -1},
    {-1,   5, -17, 112,  38, -13,   5, -1},
    {-2,   6, -19, 106,  48, -15,   5, -1},
    {-2,   7, -21,  98,  59, -17,   6, -2},
    {-2,   7, -21,  89,  69, -19,   7, -2},
    {-2,   7, -20,  79,  79, -20,   7, -2},
    {-2,   7, -19,  69,  89, -21,   7, -2},
    {-2,   6, -17,  59,  98, -21,   7, -2},
    {-1,   5, -15,  48, 106, -19,   6, -2},
    {-1,   5, -13,  38, 112, -17,   5, -1},
    {-1,   4, -10,  27, 118, -14,   5, -1},
    {-1,   2,  -6,  18, 123, -10,   3, -1},
94
    { 0,   1,  -3,   8, 126,  -6,   2,  0}
95
96
#elif FILTER_ALPHA == 60
    /* alpha = 0.60 */
97
    { 0,   0,   0, 128,   0,   0,   0,  0},
98
99
100
101
102
103
104
105
106
107
108
109
110
111
    { 0,   2,  -6, 126,   8,  -3,   1,  0},
    {-1,   3, -10, 123,  18,  -6,   2, -1},
    {-1,   4, -14, 118,  28,  -9,   3, -1},
    {-1,   5, -17, 112,  38, -12,   4, -1},
    {-1,   6, -19, 105,  48, -15,   5, -1},
    {-1,   6, -20,  97,  58, -17,   6, -1},
    {-1,   6, -20,  88,  69, -19,   6, -1},
    {-1,   6, -20,  79,  79, -20,   6, -1},
    {-1,   6, -19,  69,  88, -20,   6, -1},
    {-1,   6, -17,  58,  97, -20,   6, -1},
    {-1,   5, -15,  48, 105, -19,   6, -1},
    {-1,   4, -12,  38, 112, -17,   5, -1},
    {-1,   3,  -9,  28, 118, -14,   4, -1},
    {-1,   2,  -6,  18, 123, -10,   3, -1},
112
    { 0,   1,  -3,   8, 126,  -6,   2,  0}
113
114
#elif FILTER_ALPHA == 55
    /* alpha = 0.55 */
115
116
    { 0,   0,   0, 128,   0,   0,   0,  0},
    { 0,   1,  -5, 126,   8,  -3,   1,  0},
117
118
119
120
121
122
123
124
125
126
127
128
    {-1,   2, -10, 123,  18,  -6,   2,  0},
    {-1,   4, -13, 118,  27,  -9,   3, -1},
    {-1,   5, -16, 112,  37, -12,   4, -1},
    {-1,   5, -18, 105,  48, -14,   4, -1},
    {-1,   5, -19,  97,  58, -16,   5, -1},
    {-1,   6, -19,  88,  68, -18,   5, -1},
    {-1,   6, -19,  78,  78, -19,   6, -1},
    {-1,   5, -18,  68,  88, -19,   6, -1},
    {-1,   5, -16,  58,  97, -19,   5, -1},
    {-1,   4, -14,  48, 105, -18,   5, -1},
    {-1,   4, -12,  37, 112, -16,   5, -1},
    {-1,   3,  -9,  27, 118, -13,   4, -1},
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
    { 0,   2,  -6,  18, 123, -10,   2, -1},
    { 0,   1,  -3,   8, 126,  -5,   1,  0}
#elif FILTER_ALPHA == 50
    /* alpha = 0.50 */
    { 0,   0,   0, 128,   0,   0,   0,  0},
    { 0,   1,  -5, 126,   8,  -3,   1,  0},
    { 0,   2, -10, 122,  18,  -6,   2,  0},
    {-1,   3, -13, 118,  27,  -9,   3,  0},
    {-1,   4, -16, 112,  37, -11,   3,  0},
    {-1,   5, -17, 104,  48, -14,   4, -1},
    {-1,   5, -18,  96,  58, -16,   5, -1},
    {-1,   5, -19,  88,  68, -17,   5, -1},
    {-1,   5, -18,  78,  78, -18,   5, -1},
    {-1,   5, -17,  68,  88, -19,   5, -1},
    {-1,   5, -16,  58,  96, -18,   5, -1},
    {-1,   4, -14,  48, 104, -17,   5, -1},
    { 0,   3, -11,  37, 112, -16,   4, -1},
    { 0,   3,  -9,  27, 118, -13,   3, -1},
    { 0,   2,  -6,  18, 122, -10,   2,  0},
    { 0,   1,  -3,   8, 126,  -5,   1,  0}
#elif FILTER_ALPHA == 0
    /* Lagrangian interpolation filter */
    { 0,   0,   0, 128,   0,   0,   0,   0},
    { 0,   1,  -5, 126,   8,  -3,   1,   0},
    {-1,   3, -10, 122,  18,  -6,   2,   0},
    {-1,   4, -13, 118,  27,  -9,   3,  -1},
    {-1,   4, -16, 112,  37, -11,   4,  -1},
    {-1,   5, -18, 105,  48, -14,   4,  -1},
    {-1,   5, -19,  97,  58, -16,   5,  -1},
    {-1,   6, -19,  88,  68, -18,   5,  -1},
    {-1,   6, -19,  78,  78, -19,   6,  -1},
    {-1,   5, -18,  68,  88, -19,   6,  -1},
    {-1,   5, -16,  58,  97, -19,   5,  -1},
    {-1,   4, -14,  48, 105, -18,   5,  -1},
    {-1,   4, -11,  37, 112, -16,   4,  -1},
    {-1,   3,  -9,  27, 118, -13,   4,  -1},
    { 0,   2,  -6,  18, 122, -10,   3,  -1},
    { 0,   1,  -3,   8, 126,  -5,   1,   0}
167
168
#endif  /* FILTER_ALPHA */
#else   /* SUBPEL_SHIFTS==16 */
169
#if FILTER_ALPHA == 70
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
    /* alpha = 0.70 */
    { 0,   0,   0, 128,   0,   0,   0,  0},
    {-1,   4, -11, 123,  18,  -7,   3, -1},
    {-2,   6, -18, 113,  38, -13,   5, -1},
    {-2,   8, -22,  98,  59, -18,   7, -2},
    {-2,   8, -21,  79,  79, -21,   8, -2},
    {-2,   7, -18,  59,  98, -22,   8, -2},
    {-1,   5, -13,  38, 113, -18,   6, -2},
    {-1,   3,  -7,  18, 123, -11,   4, -1}
#elif FILTER_ALPHA == 65
    /* alpha = 0.65 */
    { 0,   0,   0, 128,   0,   0,   0, 0},
    {-1,   3, -10, 123,  18,  -6,   2, -1},
    {-1,   5, -17, 112,  38, -13,   5, -1},
    {-2,   7, -21,  98,  59, -17,   6, -2},
    {-2,   7, -20,  79,  79, -20,   7, -2},
    {-2,   6, -17,  59,  98, -21,   7, -2},
    {-1,   5, -13,  38, 112, -17,   5, -1},
    {-1,   2,  -6,  18, 123, -10,   3, -1}
#elif FILTER_ALPHA == 60
    /* alpha = 0.60 */
    { 0,   0,   0, 128,   0,   0,   0, 0},
    {-1,   3, -10, 123,  18,  -6,   2, -1},
    {-1,   5, -17, 112,  38, -12,   4, -1},
    {-1,   6, -20,  97,  58, -17,   6, -1},
    {-1,   6, -20,  79,  79, -20,   6, -1},
    {-1,   6, -17,  58,  97, -20,   6, -1},
    {-1,   4, -12,  38, 112, -17,   5, -1},
    {-1,   2,  -6,  18, 123, -10,   3, -1}
199
200
201
202
203
204
205
206
207
208
#elif FILTER_ALPHA == 55
    /* alpha = 0.55 */
    { 0,   0,   0, 128,   0,   0,   0,  0},
    {-1,   2, -10, 123,  18,  -6,   2,  0},
    {-1,   5, -16, 112,  37, -12,   4, -1},
    {-1,   5, -19,  97,  58, -16,   5, -1},
    {-1,   6, -19,  78,  78, -19,   6, -1},
    {-1,   5, -16,  58,  97, -19,   5, -1},
    {-1,   4, -12,  37, 112, -16,   5, -1},
    { 0,   2,  -6,  18, 123, -10,   2, -1}
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#elif FILTER_ALPHA == 50
    /* alpha = 0.50 */
    { 0,   0,   0, 128,   0,   0,   0,  0},
    { 0,   2, -10, 122,  18,  -6,   2,  0},
    {-1,   4, -16, 112,  37, -11,   3,  0},
    {-1,   5, -18,  96,  58, -16,   5, -1},
    {-1,   5, -18,  78,  78, -18,   5, -1},
    {-1,   5, -16,  58,  96, -18,   5, -1},
    { 0,   3, -11,  37, 112, -16,   4, -1},
    { 0,   2,  -6,  18, 122, -10,   2,  0}
#elif FILTER_ALPHA == 0
    /* Lagrangian interpolation filter */
    { 0,   0,   0, 128,   0,   0,   0,   0},
    {-1,   3, -10, 122,  18,  -6,   2,   0},
    {-1,   4, -16, 112,  37, -11,   4,  -1},
    {-1,   5, -19,  97,  58, -16,   5,  -1},
    {-1,   6, -19,  78,  78, -19,   6,  -1},
    {-1,   5, -16,  58,  97, -19,   5,  -1},
    {-1,   4, -11,  37, 112, -16,   4,  -1},
    { 0,   2,  -6,  18, 122, -10,   3,  -1},
229
230
#endif  /* FILTER_ALPHA */
#endif  /* SUBPEL_SHIFTS==16 */
231
};
232
233
234

#else  // CONFIG_ENHANCED_INTERP

Johann's avatar
Johann committed
235
DECLARE_ALIGNED(16, const short, vp8_sub_pel_filters[8][6]) =
John Koleszar's avatar
John Koleszar committed
236
237
{

238
    { 0,  0,  128,    0,   0,  0 },         /* note that 1/8 pel positions are just as per alpha -0.5 bicubic */
John Koleszar's avatar
John Koleszar committed
239
    { 0, -6,  123,   12,  -1,  0 },
240
    { 2, -11, 108,   36,  -8,  1 },         /* New 1/4 pel 6 tap filter */
John Koleszar's avatar
John Koleszar committed
241
    { 0, -9,   93,   50,  -6,  0 },
242
    { 3, -16,  77,   77, -16,  3 },         /* New 1/2 pel 6 tap filter */
John Koleszar's avatar
John Koleszar committed
243
    { 0, -6,   50,   93,  -9,  0 },
244
    { 1, -8,   36,  108, -11,  2 },         /* New 1/4 pel 6 tap filter */
John Koleszar's avatar
John Koleszar committed
245
246
    { 0, -1,   12,  123,  -6,  0 },
};
247

248
#endif  // CONFIG_ENHANCED_INTERP
John Koleszar's avatar
John Koleszar committed
249

250
static void filter_block2d_first_pass
John Koleszar's avatar
John Koleszar committed
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
(
    unsigned char *src_ptr,
    int *output_ptr,
    unsigned int src_pixels_per_line,
    unsigned int pixel_step,
    unsigned int output_height,
    unsigned int output_width,
    const short *vp8_filter
)
{
    unsigned int i, j;
    int  Temp;

    for (i = 0; i < output_height; i++)
    {
        for (j = 0; j < output_width; j++)
        {
268
#if INTERP_EXTEND == 3
John Koleszar's avatar
John Koleszar committed
269
270
            Temp = ((int)src_ptr[-2 * (int)pixel_step] * vp8_filter[0]) +
                   ((int)src_ptr[-1 * (int)pixel_step] * vp8_filter[1]) +
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
                   ((int)src_ptr[0]                    * vp8_filter[2]) +
                   ((int)src_ptr[pixel_step]           * vp8_filter[3]) +
                   ((int)src_ptr[2*pixel_step]         * vp8_filter[4]) +
                   ((int)src_ptr[3*pixel_step]         * vp8_filter[5]) +
                   (VP8_FILTER_WEIGHT >> 1);      /* Rounding */
#elif INTERP_EXTEND == 4
            Temp = ((int)src_ptr[-3 * (int)pixel_step] * vp8_filter[0]) +
                   ((int)src_ptr[-2 * (int)pixel_step] * vp8_filter[1]) +
                   ((int)src_ptr[-1 * (int)pixel_step] * vp8_filter[2]) +
                   ((int)src_ptr[0]                    * vp8_filter[3]) +
                   ((int)src_ptr[pixel_step]           * vp8_filter[4]) +
                   ((int)src_ptr[2 * pixel_step]       * vp8_filter[5]) +
                   ((int)src_ptr[3 * pixel_step]       * vp8_filter[6]) +
                   ((int)src_ptr[4 * pixel_step]       * vp8_filter[7]) +
                   (VP8_FILTER_WEIGHT >> 1);      /* Rounding */
#elif INTERP_EXTEND == 5
            Temp = ((int)src_ptr[-4 * (int)pixel_step] * vp8_filter[0]) +
                   ((int)src_ptr[-3 * (int)pixel_step] * vp8_filter[1]) +
                   ((int)src_ptr[-2 * (int)pixel_step] * vp8_filter[2]) +
                   ((int)src_ptr[-1 * (int)pixel_step] * vp8_filter[3]) +
                   ((int)src_ptr[0]                    * vp8_filter[4]) +
                   ((int)src_ptr[pixel_step]           * vp8_filter[5]) +
                   ((int)src_ptr[2 * pixel_step]       * vp8_filter[6]) +
                   ((int)src_ptr[3 * pixel_step]       * vp8_filter[7]) +
                   ((int)src_ptr[4 * pixel_step]       * vp8_filter[8]) +
                   ((int)src_ptr[5 * pixel_step]       * vp8_filter[9]) +
297
                   (VP8_FILTER_WEIGHT >> 1);      /* Rounding */
298
#endif
John Koleszar's avatar
John Koleszar committed
299

300
            /* Normalize back to 0-255 */
John Koleszar's avatar
John Koleszar committed
301
302
303
304
305
306
307
308
309
310
311
            Temp = Temp >> VP8_FILTER_SHIFT;

            if (Temp < 0)
                Temp = 0;
            else if (Temp > 255)
                Temp = 255;

            output_ptr[j] = Temp;
            src_ptr++;
        }

312
        /* Next row... */
John Koleszar's avatar
John Koleszar committed
313
314
315
316
317
        src_ptr    += src_pixels_per_line - output_width;
        output_ptr += output_width;
    }
}

318
static void filter_block2d_second_pass
John Koleszar's avatar
John Koleszar committed
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
(
    int *src_ptr,
    unsigned char *output_ptr,
    int output_pitch,
    unsigned int src_pixels_per_line,
    unsigned int pixel_step,
    unsigned int output_height,
    unsigned int output_width,
    const short *vp8_filter
)
{
    unsigned int i, j;
    int  Temp;

    for (i = 0; i < output_height; i++)
    {
        for (j = 0; j < output_width; j++)
        {
337
            /* Apply filter */
338
#if INTERP_EXTEND == 3
John Koleszar's avatar
John Koleszar committed
339
340
            Temp = ((int)src_ptr[-2 * (int)pixel_step] * vp8_filter[0]) +
                   ((int)src_ptr[-1 * (int)pixel_step] * vp8_filter[1]) +
341
342
343
344
                   ((int)src_ptr[0]                    * vp8_filter[2]) +
                   ((int)src_ptr[pixel_step]           * vp8_filter[3]) +
                   ((int)src_ptr[2*pixel_step]         * vp8_filter[4]) +
                   ((int)src_ptr[3*pixel_step]         * vp8_filter[5]) +
345
                   (VP8_FILTER_WEIGHT >> 1);   /* Rounding */
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
#elif INTERP_EXTEND == 4
            Temp = ((int)src_ptr[-3 * (int)pixel_step] * vp8_filter[0]) +
                   ((int)src_ptr[-2 * (int)pixel_step] * vp8_filter[1]) +
                   ((int)src_ptr[-1 * (int)pixel_step] * vp8_filter[2]) +
                   ((int)src_ptr[0]                    * vp8_filter[3]) +
                   ((int)src_ptr[pixel_step]           * vp8_filter[4]) +
                   ((int)src_ptr[2 * pixel_step]       * vp8_filter[5]) +
                   ((int)src_ptr[3 * pixel_step]       * vp8_filter[6]) +
                   ((int)src_ptr[4 * pixel_step]       * vp8_filter[7]) +
                   (VP8_FILTER_WEIGHT >> 1);      /* Rounding */
#elif INTERP_EXTEND == 5
            Temp = ((int)src_ptr[-4 * (int)pixel_step] * vp8_filter[0]) +
                   ((int)src_ptr[-3 * (int)pixel_step] * vp8_filter[1]) +
                   ((int)src_ptr[-2 * (int)pixel_step] * vp8_filter[2]) +
                   ((int)src_ptr[-1 * (int)pixel_step] * vp8_filter[3]) +
                   ((int)src_ptr[0]                    * vp8_filter[4]) +
                   ((int)src_ptr[pixel_step]           * vp8_filter[5]) +
                   ((int)src_ptr[2 * pixel_step]       * vp8_filter[6]) +
                   ((int)src_ptr[3 * pixel_step]       * vp8_filter[7]) +
                   ((int)src_ptr[4 * pixel_step]       * vp8_filter[8]) +
                   ((int)src_ptr[5 * pixel_step]       * vp8_filter[9]) +
                   (VP8_FILTER_WEIGHT >> 1);      /* Rounding */
#endif
John Koleszar's avatar
John Koleszar committed
369

370
            /* Normalize back to 0-255 */
John Koleszar's avatar
John Koleszar committed
371
372
373
374
375
376
377
378
379
380
381
            Temp = Temp >> VP8_FILTER_SHIFT;

            if (Temp < 0)
                Temp = 0;
            else if (Temp > 255)
                Temp = 255;

            output_ptr[j] = (unsigned char)Temp;
            src_ptr++;
        }

382
        /* Start next row */
John Koleszar's avatar
John Koleszar committed
383
384
385
386
387
        src_ptr    += src_pixels_per_line - output_width;
        output_ptr += output_pitch;
    }
}

388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
/*
 * The only functional difference between filter_block2d_second_pass()
 * and this function is that filter_block2d_second_pass() does a sixtap
 * filter on the input and stores it in the output. This function
 * (filter_block2d_second_pass_avg()) does a sixtap filter on the input,
 * and then averages that with the content already present in the output
 * ((filter_result + dest + 1) >> 1) and stores that in the output.
 */
static void filter_block2d_second_pass_avg
(
    int *src_ptr,
    unsigned char *output_ptr,
    int output_pitch,
    unsigned int src_pixels_per_line,
    unsigned int pixel_step,
    unsigned int output_height,
    unsigned int output_width,
    const short *vp8_filter
)
{
    unsigned int i, j;
    int  Temp;

    for (i = 0; i < output_height; i++)
    {
        for (j = 0; j < output_width; j++)
        {
            /* Apply filter */
416
#if INTERP_EXTEND == 3
417
418
            Temp = ((int)src_ptr[-2 * (int)pixel_step] * vp8_filter[0]) +
                   ((int)src_ptr[-1 * (int)pixel_step] * vp8_filter[1]) +
419
420
421
422
                   ((int)src_ptr[0]                    * vp8_filter[2]) +
                   ((int)src_ptr[pixel_step]           * vp8_filter[3]) +
                   ((int)src_ptr[2*pixel_step]         * vp8_filter[4]) +
                   ((int)src_ptr[3*pixel_step]         * vp8_filter[5]) +
423
                   (VP8_FILTER_WEIGHT >> 1);   /* Rounding */
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
#elif INTERP_EXTEND == 4
            Temp = ((int)src_ptr[-3 * (int)pixel_step] * vp8_filter[0]) +
                   ((int)src_ptr[-2 * (int)pixel_step] * vp8_filter[1]) +
                   ((int)src_ptr[-1 * (int)pixel_step] * vp8_filter[2]) +
                   ((int)src_ptr[0]                    * vp8_filter[3]) +
                   ((int)src_ptr[pixel_step]           * vp8_filter[4]) +
                   ((int)src_ptr[2 * pixel_step]       * vp8_filter[5]) +
                   ((int)src_ptr[3 * pixel_step]       * vp8_filter[6]) +
                   ((int)src_ptr[4 * pixel_step]       * vp8_filter[7]) +
                   (VP8_FILTER_WEIGHT >> 1);      /* Rounding */
#elif INTERP_EXTEND == 5
            Temp = ((int)src_ptr[-4 * (int)pixel_step] * vp8_filter[0]) +
                   ((int)src_ptr[-3 * (int)pixel_step] * vp8_filter[1]) +
                   ((int)src_ptr[-2 * (int)pixel_step] * vp8_filter[2]) +
                   ((int)src_ptr[-1 * (int)pixel_step] * vp8_filter[3]) +
                   ((int)src_ptr[0]                    * vp8_filter[4]) +
                   ((int)src_ptr[pixel_step]           * vp8_filter[5]) +
                   ((int)src_ptr[2 * pixel_step]       * vp8_filter[6]) +
                   ((int)src_ptr[3 * pixel_step]       * vp8_filter[7]) +
                   ((int)src_ptr[4 * pixel_step]       * vp8_filter[8]) +
                   ((int)src_ptr[5 * pixel_step]       * vp8_filter[9]) +
                   (VP8_FILTER_WEIGHT >> 1);      /* Rounding */
#endif
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464

            /* Normalize back to 0-255 */
            Temp = Temp >> VP8_FILTER_SHIFT;

            if (Temp < 0)
                Temp = 0;
            else if (Temp > 255)
                Temp = 255;

            output_ptr[j] = (unsigned char) ((output_ptr[j] + Temp + 1) >> 1);
            src_ptr++;
        }

        /* Start next row */
        src_ptr    += src_pixels_per_line - output_width;
        output_ptr += output_pitch;
    }
}
John Koleszar's avatar
John Koleszar committed
465

466
static void filter_block2d
John Koleszar's avatar
John Koleszar committed
467
468
469
470
471
472
473
474
475
(
    unsigned char  *src_ptr,
    unsigned char  *output_ptr,
    unsigned int src_pixels_per_line,
    int output_pitch,
    const short  *HFilter,
    const short  *VFilter
)
{
476
    int FData[(3+INTERP_EXTEND*2)*4]; /* Temp data buffer used in filtering */
John Koleszar's avatar
John Koleszar committed
477

478
    /* First filter 1-D horizontally... */
479
480
    filter_block2d_first_pass(src_ptr - ((INTERP_EXTEND-1) * src_pixels_per_line), FData, src_pixels_per_line, 1,
                              3+INTERP_EXTEND*2, 4, HFilter);
John Koleszar's avatar
John Koleszar committed
481

482
    /* then filter verticaly... */
483
    filter_block2d_second_pass(FData + 4*(INTERP_EXTEND-1), output_ptr, output_pitch, 4, 4, 4, 4, VFilter);
John Koleszar's avatar
John Koleszar committed
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
}


void vp8_sixtap_predict_c
(
    unsigned char  *src_ptr,
    int   src_pixels_per_line,
    int  xoffset,
    int  yoffset,
    unsigned char *dst_ptr,
    int dst_pitch
)
{
    const short  *HFilter;
    const short  *VFilter;

Johann's avatar
Johann committed
500
501
    HFilter = vp8_sub_pel_filters[xoffset];   /* 6 tap */
    VFilter = vp8_sub_pel_filters[yoffset];   /* 6 tap */
John Koleszar's avatar
John Koleszar committed
502

503
    filter_block2d(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter);
John Koleszar's avatar
John Koleszar committed
504
505
506
507
508
509
510
511
512
513
514
515
516
}
void vp8_sixtap_predict8x8_c
(
    unsigned char  *src_ptr,
    int  src_pixels_per_line,
    int  xoffset,
    int  yoffset,
    unsigned char *dst_ptr,
    int  dst_pitch
)
{
    const short  *HFilter;
    const short  *VFilter;
517
518
    // int FData[(7+INTERP_EXTEND*2)*16];   /* Temp data buffer used in filtering */
    int FData[(7+INTERP_EXTEND*2)*8];   /* Temp data buffer used in filtering */
John Koleszar's avatar
John Koleszar committed
519

Johann's avatar
Johann committed
520
521
    HFilter = vp8_sub_pel_filters[xoffset];   /* 6 tap */
    VFilter = vp8_sub_pel_filters[yoffset];   /* 6 tap */
John Koleszar's avatar
John Koleszar committed
522

523
    /* First filter 1-D horizontally... */
524
525
    filter_block2d_first_pass(src_ptr - ((INTERP_EXTEND-1) * src_pixels_per_line), FData, src_pixels_per_line, 1,
                              7+INTERP_EXTEND*2, 8, HFilter);
John Koleszar's avatar
John Koleszar committed
526
527


528
    /* then filter verticaly... */
529
    filter_block2d_second_pass(FData + 8*(INTERP_EXTEND-1), dst_ptr, dst_pitch, 8, 8, 8, 8, VFilter);
John Koleszar's avatar
John Koleszar committed
530
531
532

}

533
534
535
536
537
538
539
540
541
542
543
544
void vp8_sixtap_predict_avg8x8_c
(
    unsigned char  *src_ptr,
    int  src_pixels_per_line,
    int  xoffset,
    int  yoffset,
    unsigned char *dst_ptr,
    int  dst_pitch
)
{
    const short  *HFilter;
    const short  *VFilter;
545
546
    // int FData[(7+INTERP_EXTEND*2)*16];   /* Temp data buffer used in filtering */
    int FData[(7+INTERP_EXTEND*2)*8];   /* Temp data buffer used in filtering */
547
548
549
550
551

    HFilter = vp8_sub_pel_filters[xoffset];   /* 6 tap */
    VFilter = vp8_sub_pel_filters[yoffset];   /* 6 tap */

    /* First filter 1-D horizontally... */
552
553
    filter_block2d_first_pass(src_ptr - ((INTERP_EXTEND-1) * src_pixels_per_line), FData, src_pixels_per_line, 1,
                              7+INTERP_EXTEND*2, 8, HFilter);
554
555

    /* then filter verticaly... */
556
    filter_block2d_second_pass_avg(FData + 8*(INTERP_EXTEND-1), dst_ptr, dst_pitch, 8, 8, 8, 8, VFilter);
557
558
}

John Koleszar's avatar
John Koleszar committed
559
560
561
562
563
564
565
566
567
568
569
570
void vp8_sixtap_predict8x4_c
(
    unsigned char  *src_ptr,
    int  src_pixels_per_line,
    int  xoffset,
    int  yoffset,
    unsigned char *dst_ptr,
    int  dst_pitch
)
{
    const short  *HFilter;
    const short  *VFilter;
571
572
    // int FData[(7+INTERP_EXTEND*2)*16];   /* Temp data buffer used in filtering */
    int FData[(3+INTERP_EXTEND*2)*8];   /* Temp data buffer used in filtering */
John Koleszar's avatar
John Koleszar committed
573

Johann's avatar
Johann committed
574
575
    HFilter = vp8_sub_pel_filters[xoffset];   /* 6 tap */
    VFilter = vp8_sub_pel_filters[yoffset];   /* 6 tap */
John Koleszar's avatar
John Koleszar committed
576

577
    /* First filter 1-D horizontally... */
578
579
    filter_block2d_first_pass(src_ptr - ((INTERP_EXTEND-1) * src_pixels_per_line), FData, src_pixels_per_line, 1,
                              3+INTERP_EXTEND*2, 8, HFilter);
John Koleszar's avatar
John Koleszar committed
580
581


582
    /* then filter verticaly... */
583
    filter_block2d_second_pass(FData + 8*(INTERP_EXTEND-1), dst_ptr, dst_pitch, 8, 8, 4, 8, VFilter);
John Koleszar's avatar
John Koleszar committed
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598

}

void vp8_sixtap_predict16x16_c
(
    unsigned char  *src_ptr,
    int  src_pixels_per_line,
    int  xoffset,
    int  yoffset,
    unsigned char *dst_ptr,
    int  dst_pitch
)
{
    const short  *HFilter;
    const short  *VFilter;
599
600
    // int FData[(15+INTERP_EXTEND*2)*24];   /* Temp data buffer used in filtering */
    int FData[(15+INTERP_EXTEND*2)*16];  /* Temp data buffer used in filtering */
John Koleszar's avatar
John Koleszar committed
601
602


Johann's avatar
Johann committed
603
604
    HFilter = vp8_sub_pel_filters[xoffset];   /* 6 tap */
    VFilter = vp8_sub_pel_filters[yoffset];   /* 6 tap */
John Koleszar's avatar
John Koleszar committed
605

606
    /* First filter 1-D horizontally... */
607
608
    filter_block2d_first_pass(src_ptr - ((INTERP_EXTEND-1) * src_pixels_per_line), FData, src_pixels_per_line, 1,
                              15+INTERP_EXTEND*2, 16, HFilter);
John Koleszar's avatar
John Koleszar committed
609

610
    /* then filter verticaly... */
611
    filter_block2d_second_pass(FData + 16*(INTERP_EXTEND-1), dst_ptr, dst_pitch, 16, 16, 16, 16, VFilter);
John Koleszar's avatar
John Koleszar committed
612
613
614

}

615
616
617
618
619
620
621
622
623
624
625
626
void vp8_sixtap_predict_avg16x16_c
(
    unsigned char  *src_ptr,
    int  src_pixels_per_line,
    int  xoffset,
    int  yoffset,
    unsigned char *dst_ptr,
    int  dst_pitch
)
{
    const short  *HFilter;
    const short  *VFilter;
627
628
    // int FData[(15+INTERP_EXTEND*2)*24];   /* Temp data buffer used in filtering */
    int FData[(15+INTERP_EXTEND*2)*16];  /* Temp data buffer used in filtering */
629
630
631
632
633

    HFilter = vp8_sub_pel_filters[xoffset];   /* 6 tap */
    VFilter = vp8_sub_pel_filters[yoffset];   /* 6 tap */

    /* First filter 1-D horizontally... */
634
635
    filter_block2d_first_pass(src_ptr - ((INTERP_EXTEND-1) * src_pixels_per_line), FData,
                              src_pixels_per_line, 1, 15+INTERP_EXTEND*2, 16, HFilter);
636
637

    /* then filter verticaly... */
638
    filter_block2d_second_pass_avg(FData + 16*(INTERP_EXTEND-1), dst_ptr, dst_pitch,
639
640
                                   16, 16, 16, 16, VFilter);
}
John Koleszar's avatar
John Koleszar committed
641
642
643
644
645

/****************************************************************************
 *
 *  ROUTINE       : filter_block2d_bil_first_pass
 *
Johann's avatar
Johann committed
646
647
648
649
650
 *  INPUTS        : UINT8  *src_ptr    : Pointer to source block.
 *                  UINT32  src_stride : Stride of source block.
 *                  UINT32  height     : Block height.
 *                  UINT32  width      : Block width.
 *                  INT32  *vp8_filter : Array of 2 bi-linear filter taps.
John Koleszar's avatar
John Koleszar committed
651
 *
Johann's avatar
Johann committed
652
 *  OUTPUTS       : INT32  *dst_ptr    : Pointer to filtered block.
John Koleszar's avatar
John Koleszar committed
653
654
655
 *
 *  RETURNS       : void
 *
Johann's avatar
Johann committed
656
657
658
 *  FUNCTION      : Applies a 1-D 2-tap bi-linear filter to the source block
 *                  in the horizontal direction to produce the filtered output
 *                  block. Used to implement first-pass of 2-D separable filter.
John Koleszar's avatar
John Koleszar committed
659
660
661
662
663
 *
 *  SPECIAL NOTES : Produces INT32 output to retain precision for next pass.
 *                  Two filter taps should sum to VP8_FILTER_WEIGHT.
 *
 ****************************************************************************/
664
static void filter_block2d_bil_first_pass
John Koleszar's avatar
John Koleszar committed
665
(
Johann's avatar
Johann committed
666
667
668
669
670
671
    unsigned char  *src_ptr,
    unsigned short *dst_ptr,
    unsigned int    src_stride,
    unsigned int    height,
    unsigned int    width,
    const short    *vp8_filter
John Koleszar's avatar
John Koleszar committed
672
673
674
675
)
{
    unsigned int i, j;

Johann's avatar
Johann committed
676
    for (i = 0; i < height; i++)
John Koleszar's avatar
John Koleszar committed
677
    {
Johann's avatar
Johann committed
678
        for (j = 0; j < width; j++)
John Koleszar's avatar
John Koleszar committed
679
        {
680
            /* Apply bilinear filter */
Johann's avatar
Johann committed
681
682
683
            dst_ptr[j] = (((int)src_ptr[0] * vp8_filter[0]) +
                          ((int)src_ptr[1] * vp8_filter[1]) +
                          (VP8_FILTER_WEIGHT / 2)) >> VP8_FILTER_SHIFT;
John Koleszar's avatar
John Koleszar committed
684
685
686
            src_ptr++;
        }

687
        /* Next row... */
Johann's avatar
Johann committed
688
689
        src_ptr += src_stride - width;
        dst_ptr += width;
John Koleszar's avatar
John Koleszar committed
690
691
692
693
694
695
696
    }
}

/****************************************************************************
 *
 *  ROUTINE       : filter_block2d_bil_second_pass
 *
Johann's avatar
Johann committed
697
698
699
700
701
 *  INPUTS        : INT32  *src_ptr    : Pointer to source block.
 *                  UINT32  dst_pitch  : Destination block pitch.
 *                  UINT32  height     : Block height.
 *                  UINT32  width      : Block width.
 *                  INT32  *vp8_filter : Array of 2 bi-linear filter taps.
John Koleszar's avatar
John Koleszar committed
702
 *
Johann's avatar
Johann committed
703
 *  OUTPUTS       : UINT16 *dst_ptr    : Pointer to filtered block.
John Koleszar's avatar
John Koleszar committed
704
705
706
 *
 *  RETURNS       : void
 *
Johann's avatar
Johann committed
707
708
709
 *  FUNCTION      : Applies a 1-D 2-tap bi-linear filter to the source block
 *                  in the vertical direction to produce the filtered output
 *                  block. Used to implement second-pass of 2-D separable filter.
John Koleszar's avatar
John Koleszar committed
710
711
712
713
714
 *
 *  SPECIAL NOTES : Requires 32-bit input as produced by filter_block2d_bil_first_pass.
 *                  Two filter taps should sum to VP8_FILTER_WEIGHT.
 *
 ****************************************************************************/
715
static void filter_block2d_bil_second_pass
John Koleszar's avatar
John Koleszar committed
716
717
(
    unsigned short *src_ptr,
Johann's avatar
Johann committed
718
719
720
721
722
    unsigned char  *dst_ptr,
    int             dst_pitch,
    unsigned int    height,
    unsigned int    width,
    const short    *vp8_filter
John Koleszar's avatar
John Koleszar committed
723
724
725
726
727
)
{
    unsigned int  i, j;
    int  Temp;

Johann's avatar
Johann committed
728
    for (i = 0; i < height; i++)
John Koleszar's avatar
John Koleszar committed
729
    {
Johann's avatar
Johann committed
730
        for (j = 0; j < width; j++)
John Koleszar's avatar
John Koleszar committed
731
        {
732
            /* Apply filter */
Johann's avatar
Johann committed
733
734
            Temp = ((int)src_ptr[0]     * vp8_filter[0]) +
                   ((int)src_ptr[width] * vp8_filter[1]) +
John Koleszar's avatar
John Koleszar committed
735
                   (VP8_FILTER_WEIGHT / 2);
Johann's avatar
Johann committed
736
            dst_ptr[j] = (unsigned int)(Temp >> VP8_FILTER_SHIFT);
John Koleszar's avatar
John Koleszar committed
737
738
739
            src_ptr++;
        }

740
        /* Next row... */
Johann's avatar
Johann committed
741
        dst_ptr += dst_pitch;
John Koleszar's avatar
John Koleszar committed
742
743
744
    }
}

745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
/*
 * As before for filter_block2d_second_pass_avg(), the functional difference
 * between filter_block2d_bil_second_pass() and filter_block2d_bil_second_pass_avg()
 * is that filter_block2d_bil_second_pass() does a bilinear filter on input
 * and stores the result in output; filter_block2d_bil_second_pass_avg(),
 * instead, does a bilinear filter on input, averages the resulting value
 * with the values already present in the output and stores the result of
 * that back into the output ((filter_result + dest + 1) >> 1).
 */
static void filter_block2d_bil_second_pass_avg
(
    unsigned short *src_ptr,
    unsigned char  *dst_ptr,
    int             dst_pitch,
    unsigned int    height,
    unsigned int    width,
    const short    *vp8_filter
)
{
    unsigned int  i, j;
    int  Temp;

    for (i = 0; i < height; i++)
    {
        for (j = 0; j < width; j++)
        {
            /* Apply filter */
            Temp = ((int)src_ptr[0]     * vp8_filter[0]) +
                   ((int)src_ptr[width] * vp8_filter[1]) +
                   (VP8_FILTER_WEIGHT / 2);
            dst_ptr[j] = (unsigned int)(((Temp >> VP8_FILTER_SHIFT) + dst_ptr[j] + 1) >> 1);
            src_ptr++;
        }

        /* Next row... */
        dst_ptr += dst_pitch;
    }
}
John Koleszar's avatar
John Koleszar committed
783
784
785
786
787
788

/****************************************************************************
 *
 *  ROUTINE       : filter_block2d_bil
 *
 *  INPUTS        : UINT8  *src_ptr          : Pointer to source block.
Johann's avatar
Johann committed
789
790
791
792
793
794
 *                  UINT32  src_pitch        : Stride of source block.
 *                  UINT32  dst_pitch        : Stride of destination block.
 *                  INT32  *HFilter          : Array of 2 horizontal filter taps.
 *                  INT32  *VFilter          : Array of 2 vertical filter taps.
 *                  INT32  Width             : Block width
 *                  INT32  Height            : Block height
John Koleszar's avatar
John Koleszar committed
795
 *
Johann's avatar
Johann committed
796
 *  OUTPUTS       : UINT16 *dst_ptr       : Pointer to filtered block.
John Koleszar's avatar
John Koleszar committed
797
798
799
800
801
802
803
804
805
806
 *
 *  RETURNS       : void
 *
 *  FUNCTION      : 2-D filters an input block by applying a 2-tap
 *                  bi-linear filter horizontally followed by a 2-tap
 *                  bi-linear filter vertically on the result.
 *
 *  SPECIAL NOTES : The largest block size can be handled here is 16x16
 *
 ****************************************************************************/
807
static void filter_block2d_bil
John Koleszar's avatar
John Koleszar committed
808
809
(
    unsigned char *src_ptr,
Johann's avatar
Johann committed
810
811
    unsigned char *dst_ptr,
    unsigned int   src_pitch,
John Koleszar's avatar
John Koleszar committed
812
    unsigned int   dst_pitch,
Johann's avatar
Johann committed
813
814
    const short   *HFilter,
    const short   *VFilter,
John Koleszar's avatar
John Koleszar committed
815
816
817
818
819
    int            Width,
    int            Height
)
{

Johann's avatar
Johann committed
820
    unsigned short FData[17*16];    /* Temp data buffer used in filtering */
John Koleszar's avatar
John Koleszar committed
821

822
    /* First filter 1-D horizontally... */
823
    filter_block2d_bil_first_pass(src_ptr, FData, src_pitch, Height + 1, Width, HFilter);
John Koleszar's avatar
John Koleszar committed
824

825
    /* then 1-D vertically... */
826
    filter_block2d_bil_second_pass(FData, dst_ptr, dst_pitch, Height, Width, VFilter);
John Koleszar's avatar
John Koleszar committed
827
828
}

829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
static void filter_block2d_bil_avg
(
    unsigned char *src_ptr,
    unsigned char *dst_ptr,
    unsigned int   src_pitch,
    unsigned int   dst_pitch,
    const short   *HFilter,
    const short   *VFilter,
    int            Width,
    int            Height
)
{
    unsigned short FData[17*16];    /* Temp data buffer used in filtering */

    /* First filter 1-D horizontally... */
    filter_block2d_bil_first_pass(src_ptr, FData, src_pitch, Height + 1, Width, HFilter);

    /* then 1-D vertically... */
    filter_block2d_bil_second_pass_avg(FData, dst_ptr, dst_pitch, Height, Width, VFilter);
}
John Koleszar's avatar
John Koleszar committed
849
850
851
852
853
854
855
856
857
858
859

void vp8_bilinear_predict4x4_c
(
    unsigned char  *src_ptr,
    int   src_pixels_per_line,
    int  xoffset,
    int  yoffset,
    unsigned char *dst_ptr,
    int dst_pitch
)
{
Johann's avatar
Johann committed
860
861
    const short *HFilter;
    const short *VFilter;
John Koleszar's avatar
John Koleszar committed
862

Johann's avatar
Johann committed
863
864
    HFilter = vp8_bilinear_filters[xoffset];
    VFilter = vp8_bilinear_filters[yoffset];
John Koleszar's avatar
John Koleszar committed
865
866
867
868
869
870
871
#if 0
    {
        int i;
        unsigned char temp1[16];
        unsigned char temp2[16];

        bilinear_predict4x4_mmx(src_ptr, src_pixels_per_line, xoffset, yoffset, temp1, 4);
872
        filter_block2d_bil(src_ptr, temp2, src_pixels_per_line, 4, HFilter, VFilter, 4, 4);
John Koleszar's avatar
John Koleszar committed
873
874
875
876
877
878

        for (i = 0; i < 16; i++)
        {
            if (temp1[i] != temp2[i])
            {
                bilinear_predict4x4_mmx(src_ptr, src_pixels_per_line, xoffset, yoffset, temp1, 4);
879
                filter_block2d_bil(src_ptr, temp2, src_pixels_per_line, 4, HFilter, VFilter, 4, 4);
John Koleszar's avatar
John Koleszar committed
880
881
882
883
            }
        }
    }
#endif
884
    filter_block2d_bil(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter, 4, 4);
John Koleszar's avatar
John Koleszar committed
885
886
887
888
889
890
891
892
893
894
895
896
897

}

void vp8_bilinear_predict8x8_c
(
    unsigned char  *src_ptr,
    int  src_pixels_per_line,
    int  xoffset,
    int  yoffset,
    unsigned char *dst_ptr,
    int  dst_pitch
)
{
Johann's avatar
Johann committed
898
899
    const short *HFilter;
    const short *VFilter;
John Koleszar's avatar
John Koleszar committed
900

Johann's avatar
Johann committed
901
902
    HFilter = vp8_bilinear_filters[xoffset];
    VFilter = vp8_bilinear_filters[yoffset];
John Koleszar's avatar
John Koleszar committed
903

904
    filter_block2d_bil(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter, 8, 8);
John Koleszar's avatar
John Koleszar committed
905
906
907

}

908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
void vp8_bilinear_predict_avg8x8_c
(
    unsigned char  *src_ptr,
    int  src_pixels_per_line,
    int  xoffset,
    int  yoffset,
    unsigned char *dst_ptr,
    int  dst_pitch
)
{
    const short *HFilter;
    const short *VFilter;

    HFilter = vp8_bilinear_filters[xoffset];
    VFilter = vp8_bilinear_filters[yoffset];

    filter_block2d_bil_avg(src_ptr, dst_ptr, src_pixels_per_line,
                           dst_pitch, HFilter, VFilter, 8, 8);
}

John Koleszar's avatar
John Koleszar committed
928
929
930
931
932
933
934
935
936
937
void vp8_bilinear_predict8x4_c
(
    unsigned char  *src_ptr,
    int  src_pixels_per_line,
    int  xoffset,
    int  yoffset,
    unsigned char *dst_ptr,
    int  dst_pitch
)
{
Johann's avatar
Johann committed
938
939
    const short *HFilter;
    const short *VFilter;
John Koleszar's avatar
John Koleszar committed
940

Johann's avatar
Johann committed
941
942
    HFilter = vp8_bilinear_filters[xoffset];
    VFilter = vp8_bilinear_filters[yoffset];
John Koleszar's avatar
John Koleszar committed
943

944
    filter_block2d_bil(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter, 8, 4);
John Koleszar's avatar
John Koleszar committed
945
946
947
948
949
950
951
952
953
954
955
956
957

}

void vp8_bilinear_predict16x16_c
(
    unsigned char  *src_ptr,
    int  src_pixels_per_line,
    int  xoffset,
    int  yoffset,
    unsigned char *dst_ptr,
    int  dst_pitch
)
{
Johann's avatar
Johann committed
958
959
    const short *HFilter;
    const short *VFilter;
John Koleszar's avatar
John Koleszar committed
960

Johann's avatar
Johann committed
961
962
    HFilter = vp8_bilinear_filters[xoffset];
    VFilter = vp8_bilinear_filters[yoffset];
John Koleszar's avatar
John Koleszar committed
963

964
    filter_block2d_bil(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter, 16, 16);
John Koleszar's avatar
John Koleszar committed
965
}
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985

void vp8_bilinear_predict_avg16x16_c
(
    unsigned char  *src_ptr,
    int  src_pixels_per_line,
    int  xoffset,
    int  yoffset,
    unsigned char *dst_ptr,
    int  dst_pitch
)
{
    const short *HFilter;
    const short *VFilter;

    HFilter = vp8_bilinear_filters[xoffset];
    VFilter = vp8_bilinear_filters[yoffset];

    filter_block2d_bil_avg(src_ptr, dst_ptr, src_pixels_per_line,
                           dst_pitch, HFilter, VFilter, 16, 16);
}