vp9_variance_c.c 41.6 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 "vp9/encoder/vp9_variance.h"
13
14
#include "vp9/common/vp9_filter.h"
#include "vp9/common/vp9_subpelvar.h"
15
#include "vpx/vpx_integer.h"
16
#include "vpx_ports/mem.h"
John Koleszar's avatar
John Koleszar committed
17

18
unsigned int vp9_get_mb_ss_c(const int16_t *src_ptr) {
19
  unsigned int i, sum = 0;
John Koleszar's avatar
John Koleszar committed
20

21
  for (i = 0; i < 256; i++) {
John Koleszar's avatar
John Koleszar committed
22
    sum += (src_ptr[i] * src_ptr[i]);
23
  }
John Koleszar's avatar
John Koleszar committed
24

John Koleszar's avatar
John Koleszar committed
25
  return sum;
John Koleszar's avatar
John Koleszar committed
26
27
}

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
unsigned int vp9_variance64x32_c(const uint8_t *src_ptr,
                                 int  source_stride,
                                 const uint8_t *ref_ptr,
                                 int  recon_stride,
                                 unsigned int *sse) {
  unsigned int var;
  int avg;

  variance(src_ptr, source_stride, ref_ptr, recon_stride, 64, 32, &var, &avg);
  *sse = var;
  return (var - (((int64_t)avg * avg) >> 11));
}

unsigned int vp9_sub_pixel_variance64x32_c(const uint8_t *src_ptr,
                                           int  src_pixels_per_line,
                                           int  xoffset,
                                           int  yoffset,
                                           const uint8_t *dst_ptr,
                                           int dst_pixels_per_line,
                                           unsigned int *sse) {
  uint16_t fdata3[65 * 64];  // Temp data bufffer used in filtering
  uint8_t temp2[68 * 64];
  const int16_t *hfilter, *vfilter;

  hfilter = VP9_BILINEAR_FILTERS_2TAP(xoffset);
  vfilter = VP9_BILINEAR_FILTERS_2TAP(yoffset);

  var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line,
                                    1, 33, 64, hfilter);
  var_filter_block2d_bil_second_pass(fdata3, temp2, 64, 64, 32, 64, vfilter);

  return vp9_variance64x32_c(temp2, 64, dst_ptr, dst_pixels_per_line, sse);
}

62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
unsigned int vp9_sub_pixel_avg_variance64x32_c(const uint8_t *src_ptr,
                                               int  src_pixels_per_line,
                                               int  xoffset,
                                               int  yoffset,
                                               const uint8_t *dst_ptr,
                                               int dst_pixels_per_line,
                                               unsigned int *sse,
                                               const uint8_t *second_pred) {
  uint16_t fdata3[65 * 64];  // Temp data bufffer used in filtering
  uint8_t temp2[68 * 64];
  DECLARE_ALIGNED_ARRAY(16, uint8_t, temp3, 64 * 64);  // compound pred buffer
  const int16_t *hfilter, *vfilter;

  hfilter = VP9_BILINEAR_FILTERS_2TAP(xoffset);
  vfilter = VP9_BILINEAR_FILTERS_2TAP(yoffset);

  var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line,
                                    1, 33, 64, hfilter);
  var_filter_block2d_bil_second_pass(fdata3, temp2, 64, 64, 32, 64, vfilter);
  comp_avg_pred(temp3, second_pred, 64, 32, temp2, 64);
  return vp9_variance64x32_c(temp3, 64, dst_ptr, dst_pixels_per_line, sse);
}

85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
unsigned int vp9_variance32x64_c(const uint8_t *src_ptr,
                                 int  source_stride,
                                 const uint8_t *ref_ptr,
                                 int  recon_stride,
                                 unsigned int *sse) {
  unsigned int var;
  int avg;

  variance(src_ptr, source_stride, ref_ptr, recon_stride, 32, 64, &var, &avg);
  *sse = var;
  return (var - (((int64_t)avg * avg) >> 11));
}

unsigned int vp9_sub_pixel_variance32x64_c(const uint8_t *src_ptr,
                                           int  src_pixels_per_line,
                                           int  xoffset,
                                           int  yoffset,
                                           const uint8_t *dst_ptr,
                                           int dst_pixels_per_line,
                                           unsigned int *sse) {
  uint16_t fdata3[65 * 64];  // Temp data bufffer used in filtering
  uint8_t temp2[68 * 64];
  const int16_t *hfilter, *vfilter;

  hfilter = VP9_BILINEAR_FILTERS_2TAP(xoffset);
  vfilter = VP9_BILINEAR_FILTERS_2TAP(yoffset);

  var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line,
                                    1, 65, 32, hfilter);
114
  var_filter_block2d_bil_second_pass(fdata3, temp2, 32, 32, 64, 32, vfilter);
115

116
  return vp9_variance32x64_c(temp2, 32, dst_ptr, dst_pixels_per_line, sse);
117
118
}

119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
unsigned int vp9_sub_pixel_avg_variance32x64_c(const uint8_t *src_ptr,
                                               int  src_pixels_per_line,
                                               int  xoffset,
                                               int  yoffset,
                                               const uint8_t *dst_ptr,
                                               int dst_pixels_per_line,
                                               unsigned int *sse,
                                               const uint8_t *second_pred) {
  uint16_t fdata3[65 * 64];  // Temp data bufffer used in filtering
  uint8_t temp2[68 * 64];
  DECLARE_ALIGNED_ARRAY(16, uint8_t, temp3, 32 * 64);  // compound pred buffer
  const int16_t *hfilter, *vfilter;

  hfilter = VP9_BILINEAR_FILTERS_2TAP(xoffset);
  vfilter = VP9_BILINEAR_FILTERS_2TAP(yoffset);

  var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line,
                                    1, 65, 32, hfilter);
  var_filter_block2d_bil_second_pass(fdata3, temp2, 32, 32, 64, 32, vfilter);
  comp_avg_pred(temp3, second_pred, 32, 64, temp2, 32);
  return vp9_variance32x64_c(temp3, 32, dst_ptr, dst_pixels_per_line, sse);
}

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
167
168
169
170
171
172
173
174
175
unsigned int vp9_variance32x16_c(const uint8_t *src_ptr,
                                 int  source_stride,
                                 const uint8_t *ref_ptr,
                                 int  recon_stride,
                                 unsigned int *sse) {
  unsigned int var;
  int avg;

  variance(src_ptr, source_stride, ref_ptr, recon_stride, 32, 16, &var, &avg);
  *sse = var;
  return (var - (((int64_t)avg * avg) >> 9));
}

unsigned int vp9_sub_pixel_variance32x16_c(const uint8_t *src_ptr,
                                           int  src_pixels_per_line,
                                           int  xoffset,
                                           int  yoffset,
                                           const uint8_t *dst_ptr,
                                           int dst_pixels_per_line,
                                           unsigned int *sse) {
  uint16_t fdata3[33 * 32];  // Temp data bufffer used in filtering
  uint8_t temp2[36 * 32];
  const int16_t *hfilter, *vfilter;

  hfilter = VP9_BILINEAR_FILTERS_2TAP(xoffset);
  vfilter = VP9_BILINEAR_FILTERS_2TAP(yoffset);

  var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line,
                                    1, 17, 32, hfilter);
  var_filter_block2d_bil_second_pass(fdata3, temp2, 32, 32, 16, 32, vfilter);

  return vp9_variance32x16_c(temp2, 32, dst_ptr, dst_pixels_per_line, sse);
}

176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
unsigned int vp9_sub_pixel_avg_variance32x16_c(const uint8_t *src_ptr,
                                               int  src_pixels_per_line,
                                               int  xoffset,
                                               int  yoffset,
                                               const uint8_t *dst_ptr,
                                               int dst_pixels_per_line,
                                               unsigned int *sse,
                                               const uint8_t *second_pred) {
  uint16_t fdata3[33 * 32];  // Temp data bufffer used in filtering
  uint8_t temp2[36 * 32];
  DECLARE_ALIGNED_ARRAY(16, uint8_t, temp3, 32 * 16);  // compound pred buffer
  const int16_t *hfilter, *vfilter;

  hfilter = VP9_BILINEAR_FILTERS_2TAP(xoffset);
  vfilter = VP9_BILINEAR_FILTERS_2TAP(yoffset);

  var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line,
                                    1, 17, 32, hfilter);
  var_filter_block2d_bil_second_pass(fdata3, temp2, 32, 32, 16, 32, vfilter);
  comp_avg_pred(temp3, second_pred, 32, 16, temp2, 32);
  return vp9_variance32x16_c(temp3, 32, dst_ptr, dst_pixels_per_line, sse);
}

199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
unsigned int vp9_variance16x32_c(const uint8_t *src_ptr,
                                 int  source_stride,
                                 const uint8_t *ref_ptr,
                                 int  recon_stride,
                                 unsigned int *sse) {
  unsigned int var;
  int avg;

  variance(src_ptr, source_stride, ref_ptr, recon_stride, 16, 32, &var, &avg);
  *sse = var;
  return (var - (((int64_t)avg * avg) >> 9));
}

unsigned int vp9_sub_pixel_variance16x32_c(const uint8_t *src_ptr,
                                           int  src_pixels_per_line,
                                           int  xoffset,
                                           int  yoffset,
                                           const uint8_t *dst_ptr,
                                           int dst_pixels_per_line,
                                           unsigned int *sse) {
  uint16_t fdata3[33 * 32];  // Temp data bufffer used in filtering
  uint8_t temp2[36 * 32];
  const int16_t *hfilter, *vfilter;

  hfilter = VP9_BILINEAR_FILTERS_2TAP(xoffset);
  vfilter = VP9_BILINEAR_FILTERS_2TAP(yoffset);

  var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line,
                                    1, 33, 16, hfilter);
228
  var_filter_block2d_bil_second_pass(fdata3, temp2, 16, 16, 32, 16, vfilter);
229

230
  return vp9_variance16x32_c(temp2, 16, dst_ptr, dst_pixels_per_line, sse);
231
232
}

233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
unsigned int vp9_sub_pixel_avg_variance16x32_c(const uint8_t *src_ptr,
                                               int  src_pixels_per_line,
                                               int  xoffset,
                                               int  yoffset,
                                               const uint8_t *dst_ptr,
                                               int dst_pixels_per_line,
                                               unsigned int *sse,
                                               const uint8_t *second_pred) {
  uint16_t fdata3[33 * 32];  // Temp data bufffer used in filtering
  uint8_t temp2[36 * 32];
  DECLARE_ALIGNED_ARRAY(16, uint8_t, temp3, 16 * 32);  // compound pred buffer
  const int16_t *hfilter, *vfilter;

  hfilter = VP9_BILINEAR_FILTERS_2TAP(xoffset);
  vfilter = VP9_BILINEAR_FILTERS_2TAP(yoffset);

  var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line,
                                    1, 33, 16, hfilter);
  var_filter_block2d_bil_second_pass(fdata3, temp2, 16, 16, 32, 16, vfilter);
  comp_avg_pred(temp3, second_pred, 16, 32, temp2, 16);
  return vp9_variance16x32_c(temp3, 16, dst_ptr, dst_pixels_per_line, sse);
}

Ronald S. Bultje's avatar
Ronald S. Bultje committed
256
257
258
259
260
261
262
263
264
265
266
267
268
unsigned int vp9_variance64x64_c(const uint8_t *src_ptr,
                                 int  source_stride,
                                 const uint8_t *ref_ptr,
                                 int  recon_stride,
                                 unsigned int *sse) {
  unsigned int var;
  int avg;

  variance(src_ptr, source_stride, ref_ptr, recon_stride, 64, 64, &var, &avg);
  *sse = var;
  return (var - (((int64_t)avg * avg) >> 12));
}

269
unsigned int vp9_variance32x32_c(const uint8_t *src_ptr,
Ronald S. Bultje's avatar
Ronald S. Bultje committed
270
                                 int  source_stride,
271
                                 const uint8_t *ref_ptr,
Ronald S. Bultje's avatar
Ronald S. Bultje committed
272
273
274
275
276
277
278
                                 int  recon_stride,
                                 unsigned int *sse) {
  unsigned int var;
  int avg;

  variance(src_ptr, source_stride, ref_ptr, recon_stride, 32, 32, &var, &avg);
  *sse = var;
279
  return (var - (((int64_t)avg * avg) >> 10));
Ronald S. Bultje's avatar
Ronald S. Bultje committed
280
}
John Koleszar's avatar
John Koleszar committed
281

282
unsigned int vp9_variance16x16_c(const uint8_t *src_ptr,
283
                                 int  source_stride,
284
                                 const uint8_t *ref_ptr,
285
286
                                 int  recon_stride,
                                 unsigned int *sse) {
John Koleszar's avatar
John Koleszar committed
287
288
289
290
291
  unsigned int var;
  int avg;

  variance(src_ptr, source_stride, ref_ptr, recon_stride, 16, 16, &var, &avg);
  *sse = var;
292
  return (var - (((unsigned int)avg * avg) >> 8));
John Koleszar's avatar
John Koleszar committed
293
294
}

295
unsigned int vp9_variance8x16_c(const uint8_t *src_ptr,
296
                                int  source_stride,
297
                                const uint8_t *ref_ptr,
298
299
                                int  recon_stride,
                                unsigned int *sse) {
John Koleszar's avatar
John Koleszar committed
300
301
302
303
304
  unsigned int var;
  int avg;

  variance(src_ptr, source_stride, ref_ptr, recon_stride, 8, 16, &var, &avg);
  *sse = var;
305
  return (var - (((unsigned int)avg * avg) >> 7));
John Koleszar's avatar
John Koleszar committed
306
307
}

308
unsigned int vp9_variance16x8_c(const uint8_t *src_ptr,
309
                                int  source_stride,
310
                                const uint8_t *ref_ptr,
311
312
                                int  recon_stride,
                                unsigned int *sse) {
John Koleszar's avatar
John Koleszar committed
313
314
315
316
317
  unsigned int var;
  int avg;

  variance(src_ptr, source_stride, ref_ptr, recon_stride, 16, 8, &var, &avg);
  *sse = var;
318
  return (var - (((unsigned int)avg * avg) >> 7));
John Koleszar's avatar
John Koleszar committed
319
320
}

Jim Bankoski's avatar
Jim Bankoski committed
321
322
323
324
325
void vp9_get_sse_sum_8x8_c(const uint8_t *src_ptr, int source_stride,
                       const uint8_t *ref_ptr, int ref_stride,
                       unsigned int *sse, int *sum) {
  variance(src_ptr, source_stride, ref_ptr, ref_stride, 8, 8, sse, sum);
}
John Koleszar's avatar
John Koleszar committed
326

327
unsigned int vp9_variance8x8_c(const uint8_t *src_ptr,
328
                               int  source_stride,
329
                               const uint8_t *ref_ptr,
330
331
                               int  recon_stride,
                               unsigned int *sse) {
John Koleszar's avatar
John Koleszar committed
332
333
334
335
336
  unsigned int var;
  int avg;

  variance(src_ptr, source_stride, ref_ptr, recon_stride, 8, 8, &var, &avg);
  *sse = var;
337
  return (var - (((unsigned int)avg * avg) >> 6));
John Koleszar's avatar
John Koleszar committed
338
339
}

340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
unsigned int vp9_variance8x4_c(const uint8_t *src_ptr,
                               int  source_stride,
                               const uint8_t *ref_ptr,
                               int  recon_stride,
                               unsigned int *sse) {
  unsigned int var;
  int avg;

  variance(src_ptr, source_stride, ref_ptr, recon_stride, 8, 4, &var, &avg);
  *sse = var;
  return (var - (((unsigned int)avg * avg) >> 5));
}

unsigned int vp9_variance4x8_c(const uint8_t *src_ptr,
                               int  source_stride,
                               const uint8_t *ref_ptr,
                               int  recon_stride,
                               unsigned int *sse) {
  unsigned int var;
  int avg;

  variance(src_ptr, source_stride, ref_ptr, recon_stride, 4, 8, &var, &avg);
  *sse = var;
  return (var - (((unsigned int)avg * avg) >> 5));
}

366
unsigned int vp9_variance4x4_c(const uint8_t *src_ptr,
367
                               int  source_stride,
368
                               const uint8_t *ref_ptr,
369
370
                               int  recon_stride,
                               unsigned int *sse) {
John Koleszar's avatar
John Koleszar committed
371
372
373
374
375
  unsigned int var;
  int avg;

  variance(src_ptr, source_stride, ref_ptr, recon_stride, 4, 4, &var, &avg);
  *sse = var;
376
  return (var - (((unsigned int)avg * avg) >> 4));
John Koleszar's avatar
John Koleszar committed
377
378
379
}


380
unsigned int vp9_mse16x16_c(const uint8_t *src_ptr,
381
                            int  source_stride,
382
                            const uint8_t *ref_ptr,
383
384
                            int  recon_stride,
                            unsigned int *sse) {
John Koleszar's avatar
John Koleszar committed
385
386
387
388
389
390
  unsigned int var;
  int avg;

  variance(src_ptr, source_stride, ref_ptr, recon_stride, 16, 16, &var, &avg);
  *sse = var;
  return var;
John Koleszar's avatar
John Koleszar committed
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
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
unsigned int vp9_mse16x8_c(const uint8_t *src_ptr,
                           int  source_stride,
                           const uint8_t *ref_ptr,
                           int  recon_stride,
                           unsigned int *sse) {
  unsigned int var;
  int avg;

  variance(src_ptr, source_stride, ref_ptr, recon_stride, 16, 8, &var, &avg);
  *sse = var;
  return var;
}

unsigned int vp9_mse8x16_c(const uint8_t *src_ptr,
                           int  source_stride,
                           const uint8_t *ref_ptr,
                           int  recon_stride,
                           unsigned int *sse) {
  unsigned int var;
  int avg;

  variance(src_ptr, source_stride, ref_ptr, recon_stride, 8, 16, &var, &avg);
  *sse = var;
  return var;
}

unsigned int vp9_mse8x8_c(const uint8_t *src_ptr,
                          int  source_stride,
                          const uint8_t *ref_ptr,
                          int  recon_stride,
                          unsigned int *sse) {
  unsigned int var;
  int avg;

  variance(src_ptr, source_stride, ref_ptr, recon_stride, 8, 8, &var, &avg);
  *sse = var;
  return var;
}

John Koleszar's avatar
John Koleszar committed
432

433
unsigned int vp9_sub_pixel_variance4x4_c(const uint8_t *src_ptr,
434
435
436
                                         int  src_pixels_per_line,
                                         int  xoffset,
                                         int  yoffset,
437
                                         const uint8_t *dst_ptr,
438
439
                                         int dst_pixels_per_line,
                                         unsigned int *sse) {
440
  uint8_t temp2[20 * 16];
441
442
  const int16_t *hfilter, *vfilter;
  uint16_t fdata3[5 * 4];  // Temp data bufffer used in filtering
John Koleszar's avatar
John Koleszar committed
443

444
445
  hfilter = VP9_BILINEAR_FILTERS_2TAP(xoffset);
  vfilter = VP9_BILINEAR_FILTERS_2TAP(yoffset);
John Koleszar's avatar
John Koleszar committed
446
447

  // First filter 1d Horizontal
448
449
  var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line,
                                    1, 5, 4, hfilter);
John Koleszar's avatar
John Koleszar committed
450
451

  // Now filter Verticaly
452
  var_filter_block2d_bil_second_pass(fdata3, temp2, 4,  4,  4,  4, vfilter);
John Koleszar's avatar
John Koleszar committed
453

454
  return vp9_variance4x4_c(temp2, 4, dst_ptr, dst_pixels_per_line, sse);
John Koleszar's avatar
John Koleszar committed
455
456
}

457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
unsigned int vp9_sub_pixel_avg_variance4x4_c(const uint8_t *src_ptr,
                                             int  src_pixels_per_line,
                                             int  xoffset,
                                             int  yoffset,
                                             const uint8_t *dst_ptr,
                                             int dst_pixels_per_line,
                                             unsigned int *sse,
                                             const uint8_t *second_pred) {
  uint8_t temp2[20 * 16];
  const int16_t *hfilter, *vfilter;
  DECLARE_ALIGNED_ARRAY(16, uint8_t, temp3, 4 * 4);  // compound pred buffer
  uint16_t fdata3[5 * 4];  // Temp data bufffer used in filtering

  hfilter = VP9_BILINEAR_FILTERS_2TAP(xoffset);
  vfilter = VP9_BILINEAR_FILTERS_2TAP(yoffset);

  // First filter 1d Horizontal
  var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line,
                                    1, 5, 4, hfilter);

  // Now filter Verticaly
  var_filter_block2d_bil_second_pass(fdata3, temp2, 4,  4,  4,  4, vfilter);
  comp_avg_pred(temp3, second_pred, 4, 4, temp2, 4);
  return vp9_variance4x4_c(temp3, 4, dst_ptr, dst_pixels_per_line, sse);
}
John Koleszar's avatar
John Koleszar committed
482

483
unsigned int vp9_sub_pixel_variance8x8_c(const uint8_t *src_ptr,
484
485
486
                                         int  src_pixels_per_line,
                                         int  xoffset,
                                         int  yoffset,
487
                                         const uint8_t *dst_ptr,
488
489
                                         int dst_pixels_per_line,
                                         unsigned int *sse) {
490
  uint16_t fdata3[9 * 8];  // Temp data bufffer used in filtering
491
  uint8_t temp2[20 * 16];
492
  const int16_t *hfilter, *vfilter;
John Koleszar's avatar
John Koleszar committed
493

494
495
  hfilter = VP9_BILINEAR_FILTERS_2TAP(xoffset);
  vfilter = VP9_BILINEAR_FILTERS_2TAP(yoffset);
John Koleszar's avatar
John Koleszar committed
496

497
498
499
  var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line,
                                    1, 9, 8, hfilter);
  var_filter_block2d_bil_second_pass(fdata3, temp2, 8, 8, 8, 8, vfilter);
John Koleszar's avatar
John Koleszar committed
500

501
  return vp9_variance8x8_c(temp2, 8, dst_ptr, dst_pixels_per_line, sse);
John Koleszar's avatar
John Koleszar committed
502
503
}

504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
unsigned int vp9_sub_pixel_avg_variance8x8_c(const uint8_t *src_ptr,
                                             int  src_pixels_per_line,
                                             int  xoffset,
                                             int  yoffset,
                                             const uint8_t *dst_ptr,
                                             int dst_pixels_per_line,
                                             unsigned int *sse,
                                             const uint8_t *second_pred) {
  uint16_t fdata3[9 * 8];  // Temp data bufffer used in filtering
  uint8_t temp2[20 * 16];
  DECLARE_ALIGNED_ARRAY(16, uint8_t, temp3, 8 * 8);  // compound pred buffer
  const int16_t *hfilter, *vfilter;

  hfilter = VP9_BILINEAR_FILTERS_2TAP(xoffset);
  vfilter = VP9_BILINEAR_FILTERS_2TAP(yoffset);

  var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line,
                                    1, 9, 8, hfilter);
  var_filter_block2d_bil_second_pass(fdata3, temp2, 8, 8, 8, 8, vfilter);
  comp_avg_pred(temp3, second_pred, 8, 8, temp2, 8);
  return vp9_variance8x8_c(temp3, 8, dst_ptr, dst_pixels_per_line, sse);
}

527
unsigned int vp9_sub_pixel_variance16x16_c(const uint8_t *src_ptr,
528
529
530
                                           int  src_pixels_per_line,
                                           int  xoffset,
                                           int  yoffset,
531
                                           const uint8_t *dst_ptr,
532
533
                                           int dst_pixels_per_line,
                                           unsigned int *sse) {
534
  uint16_t fdata3[17 * 16];  // Temp data bufffer used in filtering
535
  uint8_t temp2[20 * 16];
536
  const int16_t *hfilter, *vfilter;
John Koleszar's avatar
John Koleszar committed
537

538
539
  hfilter = VP9_BILINEAR_FILTERS_2TAP(xoffset);
  vfilter = VP9_BILINEAR_FILTERS_2TAP(yoffset);
John Koleszar's avatar
John Koleszar committed
540

541
542
543
  var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line,
                                    1, 17, 16, hfilter);
  var_filter_block2d_bil_second_pass(fdata3, temp2, 16, 16, 16, 16, vfilter);
John Koleszar's avatar
John Koleszar committed
544

545
  return vp9_variance16x16_c(temp2, 16, dst_ptr, dst_pixels_per_line, sse);
John Koleszar's avatar
John Koleszar committed
546
547
}

548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
unsigned int vp9_sub_pixel_avg_variance16x16_c(const uint8_t *src_ptr,
                                               int  src_pixels_per_line,
                                               int  xoffset,
                                               int  yoffset,
                                               const uint8_t *dst_ptr,
                                               int dst_pixels_per_line,
                                               unsigned int *sse,
                                               const uint8_t *second_pred) {
  uint16_t fdata3[17 * 16];
  uint8_t temp2[20 * 16];
  DECLARE_ALIGNED_ARRAY(16, uint8_t, temp3, 16 * 16);  // compound pred buffer
  const int16_t *hfilter, *vfilter;

  hfilter = VP9_BILINEAR_FILTERS_2TAP(xoffset);
  vfilter = VP9_BILINEAR_FILTERS_2TAP(yoffset);

  var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line,
                                    1, 17, 16, hfilter);
  var_filter_block2d_bil_second_pass(fdata3, temp2, 16, 16, 16, 16, vfilter);

  comp_avg_pred(temp3, second_pred, 16, 16, temp2, 16);
  return vp9_variance16x16_c(temp3, 16, dst_ptr, dst_pixels_per_line, sse);
}

Ronald S. Bultje's avatar
Ronald S. Bultje committed
572
573
574
575
576
577
578
unsigned int vp9_sub_pixel_variance64x64_c(const uint8_t *src_ptr,
                                           int  src_pixels_per_line,
                                           int  xoffset,
                                           int  yoffset,
                                           const uint8_t *dst_ptr,
                                           int dst_pixels_per_line,
                                           unsigned int *sse) {
579
  uint16_t fdata3[65 * 64];  // Temp data bufffer used in filtering
Ronald S. Bultje's avatar
Ronald S. Bultje committed
580
  uint8_t temp2[68 * 64];
581
  const int16_t *hfilter, *vfilter;
Ronald S. Bultje's avatar
Ronald S. Bultje committed
582

583
584
  hfilter = VP9_BILINEAR_FILTERS_2TAP(xoffset);
  vfilter = VP9_BILINEAR_FILTERS_2TAP(yoffset);
Ronald S. Bultje's avatar
Ronald S. Bultje committed
585

586
587
588
  var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line,
                                    1, 65, 64, hfilter);
  var_filter_block2d_bil_second_pass(fdata3, temp2, 64, 64, 64, 64, vfilter);
Ronald S. Bultje's avatar
Ronald S. Bultje committed
589
590
591
592

  return vp9_variance64x64_c(temp2, 64, dst_ptr, dst_pixels_per_line, sse);
}

593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
unsigned int vp9_sub_pixel_avg_variance64x64_c(const uint8_t *src_ptr,
                                               int  src_pixels_per_line,
                                               int  xoffset,
                                               int  yoffset,
                                               const uint8_t *dst_ptr,
                                               int dst_pixels_per_line,
                                               unsigned int *sse,
                                               const uint8_t *second_pred) {
  uint16_t fdata3[65 * 64];  // Temp data bufffer used in filtering
  uint8_t temp2[68 * 64];
  DECLARE_ALIGNED_ARRAY(16, uint8_t, temp3, 64 * 64);  // compound pred buffer
  const int16_t *hfilter, *vfilter;

  hfilter = VP9_BILINEAR_FILTERS_2TAP(xoffset);
  vfilter = VP9_BILINEAR_FILTERS_2TAP(yoffset);

  var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line,
                                    1, 65, 64, hfilter);
  var_filter_block2d_bil_second_pass(fdata3, temp2, 64, 64, 64, 64, vfilter);
  comp_avg_pred(temp3, second_pred, 64, 64, temp2, 64);
  return vp9_variance64x64_c(temp3, 64, dst_ptr, dst_pixels_per_line, sse);
}

616
unsigned int vp9_sub_pixel_variance32x32_c(const uint8_t *src_ptr,
Ronald S. Bultje's avatar
Ronald S. Bultje committed
617
618
619
                                           int  src_pixels_per_line,
                                           int  xoffset,
                                           int  yoffset,
620
                                           const uint8_t *dst_ptr,
Ronald S. Bultje's avatar
Ronald S. Bultje committed
621
622
                                           int dst_pixels_per_line,
                                           unsigned int *sse) {
623
  uint16_t fdata3[33 * 32];  // Temp data bufffer used in filtering
624
  uint8_t temp2[36 * 32];
625
  const int16_t *hfilter, *vfilter;
Ronald S. Bultje's avatar
Ronald S. Bultje committed
626

627
628
  hfilter = VP9_BILINEAR_FILTERS_2TAP(xoffset);
  vfilter = VP9_BILINEAR_FILTERS_2TAP(yoffset);
Ronald S. Bultje's avatar
Ronald S. Bultje committed
629

630
631
632
  var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line,
                                    1, 33, 32, hfilter);
  var_filter_block2d_bil_second_pass(fdata3, temp2, 32, 32, 32, 32, vfilter);
Ronald S. Bultje's avatar
Ronald S. Bultje committed
633

634
  return vp9_variance32x32_c(temp2, 32, dst_ptr, dst_pixels_per_line, sse);
Ronald S. Bultje's avatar
Ronald S. Bultje committed
635
}
636

637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
unsigned int vp9_sub_pixel_avg_variance32x32_c(const uint8_t *src_ptr,
                                               int  src_pixels_per_line,
                                               int  xoffset,
                                               int  yoffset,
                                               const uint8_t *dst_ptr,
                                               int dst_pixels_per_line,
                                               unsigned int *sse,
                                               const uint8_t *second_pred) {
  uint16_t fdata3[33 * 32];  // Temp data bufffer used in filtering
  uint8_t temp2[36 * 32];
  DECLARE_ALIGNED_ARRAY(16, uint8_t, temp3, 32 * 32);  // compound pred buffer
  const int16_t *hfilter, *vfilter;

  hfilter = VP9_BILINEAR_FILTERS_2TAP(xoffset);
  vfilter = VP9_BILINEAR_FILTERS_2TAP(yoffset);

  var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line,
                                    1, 33, 32, hfilter);
  var_filter_block2d_bil_second_pass(fdata3, temp2, 32, 32, 32, 32, vfilter);
  comp_avg_pred(temp3, second_pred, 32, 32, temp2, 32);
  return vp9_variance32x32_c(temp3, 32, dst_ptr, dst_pixels_per_line, sse);
}

660
unsigned int vp9_variance_halfpixvar16x16_h_c(const uint8_t *src_ptr,
661
                                              int  source_stride,
662
                                              const uint8_t *ref_ptr,
663
664
                                              int  recon_stride,
                                              unsigned int *sse) {
665
  return vp9_sub_pixel_variance16x16_c(src_ptr, source_stride, 8, 0,
John Koleszar's avatar
John Koleszar committed
666
                                       ref_ptr, recon_stride, sse);
667
668
}

669
unsigned int vp9_variance_halfpixvar32x32_h_c(const uint8_t *src_ptr,
Ronald S. Bultje's avatar
Ronald S. Bultje committed
670
                                              int  source_stride,
671
                                              const uint8_t *ref_ptr,
Ronald S. Bultje's avatar
Ronald S. Bultje committed
672
673
                                              int  recon_stride,
                                              unsigned int *sse) {
674
  return vp9_sub_pixel_variance32x32_c(src_ptr, source_stride, 8, 0,
Ronald S. Bultje's avatar
Ronald S. Bultje committed
675
676
                                       ref_ptr, recon_stride, sse);
}
Ronald S. Bultje's avatar
Ronald S. Bultje committed
677
678
679
680
681
682
683
684
685

unsigned int vp9_variance_halfpixvar64x64_h_c(const uint8_t *src_ptr,
                                              int  source_stride,
                                              const uint8_t *ref_ptr,
                                              int  recon_stride,
                                              unsigned int *sse) {
  return vp9_sub_pixel_variance64x64_c(src_ptr, source_stride, 8, 0,
                                       ref_ptr, recon_stride, sse);
}
686

687
unsigned int vp9_variance_halfpixvar16x16_v_c(const uint8_t *src_ptr,
Ronald S. Bultje's avatar
Ronald S. Bultje committed
688
                                              int  source_stride,
689
                                              const uint8_t *ref_ptr,
Ronald S. Bultje's avatar
Ronald S. Bultje committed
690
691
                                              int  recon_stride,
                                              unsigned int *sse) {
692
  return vp9_sub_pixel_variance16x16_c(src_ptr, source_stride, 0, 8,
Ronald S. Bultje's avatar
Ronald S. Bultje committed
693
694
695
                                       ref_ptr, recon_stride, sse);
}

696
unsigned int vp9_variance_halfpixvar32x32_v_c(const uint8_t *src_ptr,
697
                                              int  source_stride,
698
                                              const uint8_t *ref_ptr,
699
700
                                              int  recon_stride,
                                              unsigned int *sse) {
701
  return vp9_sub_pixel_variance32x32_c(src_ptr, source_stride, 0, 8,
John Koleszar's avatar
John Koleszar committed
702
                                       ref_ptr, recon_stride, sse);
703
}
Ronald S. Bultje's avatar
Ronald S. Bultje committed
704
705
706
707
708
709
710
711
712

unsigned int vp9_variance_halfpixvar64x64_v_c(const uint8_t *src_ptr,
                                              int  source_stride,
                                              const uint8_t *ref_ptr,
                                              int  recon_stride,
                                              unsigned int *sse) {
  return vp9_sub_pixel_variance64x64_c(src_ptr, source_stride, 0, 8,
                                       ref_ptr, recon_stride, sse);
}
713

714
unsigned int vp9_variance_halfpixvar16x16_hv_c(const uint8_t *src_ptr,
715
                                               int  source_stride,
716
                                               const uint8_t *ref_ptr,
717
718
                                               int  recon_stride,
                                               unsigned int *sse) {
719
  return vp9_sub_pixel_variance16x16_c(src_ptr, source_stride, 8, 8,
John Koleszar's avatar
John Koleszar committed
720
                                       ref_ptr, recon_stride, sse);
721
722
}

723
unsigned int vp9_variance_halfpixvar32x32_hv_c(const uint8_t *src_ptr,
Ronald S. Bultje's avatar
Ronald S. Bultje committed
724
                                               int  source_stride,
725
                                               const uint8_t *ref_ptr,
Ronald S. Bultje's avatar
Ronald S. Bultje committed
726
727
                                               int  recon_stride,
                                               unsigned int *sse) {
728
  return vp9_sub_pixel_variance32x32_c(src_ptr, source_stride, 8, 8,
Ronald S. Bultje's avatar
Ronald S. Bultje committed
729
730
                                       ref_ptr, recon_stride, sse);
}
Ronald S. Bultje's avatar
Ronald S. Bultje committed
731
732
733
734
735
736
737
738
739

unsigned int vp9_variance_halfpixvar64x64_hv_c(const uint8_t *src_ptr,
                                               int  source_stride,
                                               const uint8_t *ref_ptr,
                                               int  recon_stride,
                                               unsigned int *sse) {
  return vp9_sub_pixel_variance64x64_c(src_ptr, source_stride, 8, 8,
                                       ref_ptr, recon_stride, sse);
}
740

741
unsigned int vp9_sub_pixel_mse16x16_c(const uint8_t *src_ptr,
742
743
744
                                      int  src_pixels_per_line,
                                      int  xoffset,
                                      int  yoffset,
745
                                      const uint8_t *dst_ptr,
746
747
748
749
750
                                      int dst_pixels_per_line,
                                      unsigned int *sse) {
  vp9_sub_pixel_variance16x16_c(src_ptr, src_pixels_per_line,
                                xoffset, yoffset, dst_ptr,
                                dst_pixels_per_line, sse);
John Koleszar's avatar
John Koleszar committed
751
  return *sse;
John Koleszar's avatar
John Koleszar committed
752
753
}

754
unsigned int vp9_sub_pixel_mse32x32_c(const uint8_t *src_ptr,
Ronald S. Bultje's avatar
Ronald S. Bultje committed
755
756
757
                                      int  src_pixels_per_line,
                                      int  xoffset,
                                      int  yoffset,
758
                                      const uint8_t *dst_ptr,
Ronald S. Bultje's avatar
Ronald S. Bultje committed
759
760
                                      int dst_pixels_per_line,
                                      unsigned int *sse) {
761
762
763
  vp9_sub_pixel_variance32x32_c(src_ptr, src_pixels_per_line,
                                xoffset, yoffset, dst_ptr,
                                dst_pixels_per_line, sse);
Ronald S. Bultje's avatar
Ronald S. Bultje committed
764
765
  return *sse;
}
Ronald S. Bultje's avatar
Ronald S. Bultje committed
766
767
768
769
770
771
772
773
774
775
776
777
778

unsigned int vp9_sub_pixel_mse64x64_c(const uint8_t *src_ptr,
                                      int  src_pixels_per_line,
                                      int  xoffset,
                                      int  yoffset,
                                      const uint8_t *dst_ptr,
                                      int dst_pixels_per_line,
                                      unsigned int *sse) {
  vp9_sub_pixel_variance64x64_c(src_ptr, src_pixels_per_line,
                                xoffset, yoffset, dst_ptr,
                                dst_pixels_per_line, sse);
  return *sse;
}
Ronald S. Bultje's avatar
Ronald S. Bultje committed
779

780
unsigned int vp9_sub_pixel_variance16x8_c(const uint8_t *src_ptr,
781
782
783
                                          int  src_pixels_per_line,
                                          int  xoffset,
                                          int  yoffset,
784
                                          const uint8_t *dst_ptr,
785
786
                                          int dst_pixels_per_line,
                                          unsigned int *sse) {
787
  uint16_t fdata3[16 * 9];  // Temp data bufffer used in filtering
788
  uint8_t temp2[20 * 16];
789
  const int16_t *hfilter, *vfilter;
John Koleszar's avatar
John Koleszar committed
790

791
792
  hfilter = VP9_BILINEAR_FILTERS_2TAP(xoffset);
  vfilter = VP9_BILINEAR_FILTERS_2TAP(yoffset);
John Koleszar's avatar
John Koleszar committed
793

794
795
796
  var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line,
                                    1, 9, 16, hfilter);
  var_filter_block2d_bil_second_pass(fdata3, temp2, 16, 16, 8, 16, vfilter);
John Koleszar's avatar
John Koleszar committed
797

798
  return vp9_variance16x8_c(temp2, 16, dst_ptr, dst_pixels_per_line, sse);
John Koleszar's avatar
John Koleszar committed
799
800
}

801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
unsigned int vp9_sub_pixel_avg_variance16x8_c(const uint8_t *src_ptr,
                                              int  src_pixels_per_line,
                                              int  xoffset,
                                              int  yoffset,
                                              const uint8_t *dst_ptr,
                                              int dst_pixels_per_line,
                                              unsigned int *sse,
                                              const uint8_t *second_pred) {
  uint16_t fdata3[16 * 9];  // Temp data bufffer used in filtering
  uint8_t temp2[20 * 16];
  DECLARE_ALIGNED_ARRAY(16, uint8_t, temp3, 16 * 8);  // compound pred buffer
  const int16_t *hfilter, *vfilter;

  hfilter = VP9_BILINEAR_FILTERS_2TAP(xoffset);
  vfilter = VP9_BILINEAR_FILTERS_2TAP(yoffset);

  var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line,
                                    1, 9, 16, hfilter);
  var_filter_block2d_bil_second_pass(fdata3, temp2, 16, 16, 8, 16, vfilter);
  comp_avg_pred(temp3, second_pred, 16, 8, temp2, 16);
  return vp9_variance16x8_c(temp3, 16, dst_ptr, dst_pixels_per_line, sse);
}

824
unsigned int vp9_sub_pixel_variance8x16_c(const uint8_t *src_ptr,
825
826
827
                                          int  src_pixels_per_line,
                                          int  xoffset,
                                          int  yoffset,
828
                                          const uint8_t *dst_ptr,
829
830
                                          int dst_pixels_per_line,
                                          unsigned int *sse) {
831
  uint16_t fdata3[9 * 16];  // Temp data bufffer used in filtering
832
  uint8_t temp2[20 * 16];
833
  const int16_t *hfilter, *vfilter;
John Koleszar's avatar
John Koleszar committed
834

835
836
  hfilter = VP9_BILINEAR_FILTERS_2TAP(xoffset);
  vfilter = VP9_BILINEAR_FILTERS_2TAP(yoffset);
John Koleszar's avatar
John Koleszar committed
837

838
839
840
  var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line,
                                    1, 17, 8, hfilter);
  var_filter_block2d_bil_second_pass(fdata3, temp2, 8, 8, 16, 8, vfilter);
John Koleszar's avatar
John Koleszar committed
841

842
  return vp9_variance8x16_c(temp2, 8, dst_ptr, dst_pixels_per_line, sse);
John Koleszar's avatar
John Koleszar committed
843
}
844

845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
unsigned int vp9_sub_pixel_avg_variance8x16_c(const uint8_t *src_ptr,
                                              int  src_pixels_per_line,
                                              int  xoffset,
                                              int  yoffset,
                                              const uint8_t *dst_ptr,
                                              int dst_pixels_per_line,
                                              unsigned int *sse,
                                              const uint8_t *second_pred) {
  uint16_t fdata3[9 * 16];  // Temp data bufffer used in filtering
  uint8_t temp2[20 * 16];
  DECLARE_ALIGNED_ARRAY(16, uint8_t, temp3, 8 * 16);  // compound pred buffer
  const int16_t *hfilter, *vfilter;

  hfilter = VP9_BILINEAR_FILTERS_2TAP(xoffset);
  vfilter = VP9_BILINEAR_FILTERS_2TAP(yoffset);

  var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line,
                                    1, 17, 8, hfilter);
  var_filter_block2d_bil_second_pass(fdata3, temp2, 8, 8, 16, 8, vfilter);
  comp_avg_pred(temp3, second_pred, 8, 16, temp2, 8);
  return vp9_variance8x16_c(temp3, 8, dst_ptr, dst_pixels_per_line, sse);
}
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919

unsigned int vp9_sub_pixel_variance8x4_c(const uint8_t *src_ptr,
                                         int  src_pixels_per_line,
                                         int  xoffset,
                                         int  yoffset,
                                         const uint8_t *dst_ptr,
                                         int dst_pixels_per_line,
                                         unsigned int *sse) {
  uint16_t fdata3[8 * 5];  // Temp data bufffer used in filtering
  uint8_t temp2[20 * 16];
  const int16_t *hfilter, *vfilter;

  hfilter = VP9_BILINEAR_FILTERS_2TAP(xoffset);
  vfilter = VP9_BILINEAR_FILTERS_2TAP(yoffset);

  var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line,
                                    1, 5, 8, hfilter);
  var_filter_block2d_bil_second_pass(fdata3, temp2, 8, 8, 4, 8, vfilter);

  return vp9_variance8x4_c(temp2, 8, dst_ptr, dst_pixels_per_line, sse);
}

unsigned int vp9_sub_pixel_avg_variance8x4_c(const uint8_t *src_ptr,
                                             int  src_pixels_per_line,
                                             int  xoffset,
                                             int  yoffset,
                                             const uint8_t *dst_ptr,
                                             int dst_pixels_per_line,
                                             unsigned int *sse,
                                             const uint8_t *second_pred) {
  uint16_t fdata3[8 * 5];  // Temp data bufffer used in filtering
  uint8_t temp2[20 * 16];
  DECLARE_ALIGNED_ARRAY(16, uint8_t, temp3, 8 * 4);  // compound pred buffer
  const int16_t *hfilter, *vfilter;

  hfilter = VP9_BILINEAR_FILTERS_2TAP(xoffset);
  vfilter = VP9_BILINEAR_FILTERS_2TAP(yoffset);

  var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line,
                                    1, 5, 8, hfilter);
  var_filter_block2d_bil_second_pass(fdata3, temp2, 8, 8, 4, 8, vfilter);
  comp_avg_pred(temp3, second_pred, 8, 4, temp2, 8);
  return vp9_variance8x4_c(temp3, 8, dst_ptr, dst_pixels_per_line, sse);
}

unsigned int vp9_sub_pixel_variance4x8_c(const uint8_t *src_ptr,
                                         int  src_pixels_per_line,
                                         int  xoffset,
                                         int  yoffset,
                                         const uint8_t *dst_ptr,
                                         int dst_pixels_per_line,
                                         unsigned int *sse) {
  uint16_t fdata3[5 * 8];  // Temp data bufffer used in filtering
920
921
  // FIXME(jingning,rbultje): this temp2 buffer probably doesn't need to be
  // of this big? same issue appears in all other block size settings.
922
923
924
925
926
927
928
  uint8_t temp2[20 * 16];
  const int16_t *hfilter, *vfilter;

  hfilter = VP9_BILINEAR_FILTERS_2TAP(xoffset);
  vfilter = VP9_BILINEAR_FILTERS_2TAP(yoffset);

  var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line,
929
                                    1, 9, 4, hfilter);
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
  var_filter_block2d_bil_second_pass(fdata3, temp2, 4, 4, 8, 4, vfilter);

  return vp9_variance4x8_c(temp2, 4, dst_ptr, dst_pixels_per_line, sse);
}

unsigned int vp9_sub_pixel_avg_variance4x8_c(const uint8_t *src_ptr,
                                             int  src_pixels_per_line,
                                             int  xoffset,
                                             int  yoffset,
                                             const uint8_t *dst_ptr,
                                             int dst_pixels_per_line,
                                             unsigned int *sse,
                                             const uint8_t *second_pred) {
  uint16_t fdata3[5 * 8];  // Temp data bufffer used in filtering
  uint8_t temp2[20 * 16];
  DECLARE_ALIGNED_ARRAY(16, uint8_t, temp3, 4 * 8);  // compound pred buffer
  const int16_t *hfilter, *vfilter;

  hfilter = VP9_BILINEAR_FILTERS_2TAP(xoffset);
  vfilter = VP9_BILINEAR_FILTERS_2TAP(yoffset);

  var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line,
952
                                    1, 9, 4, hfilter);
953
954
955
956
  var_filter_block2d_bil_second_pass(fdata3, temp2, 4, 4, 8, 4, vfilter);
  comp_avg_pred(temp3, second_pred, 4, 8, temp2, 4);
  return vp9_variance4x8_c(temp3, 4, dst_ptr, dst_pixels_per_line, sse);
}