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"
17
#include "./vp9_rtcd.h"
John Koleszar's avatar
John Koleszar committed
18

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

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

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

29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
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) {
49
  uint16_t fdata3[65 * 64];  // Temp data buffer used in filtering
50 51 52 53 54 55 56 57 58 59
  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);

60
  return vp9_variance64x32(temp2, 64, dst_ptr, dst_pixels_per_line, sse);
61 62
}

63 64 65 66 67 68 69 70
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) {
71
  uint16_t fdata3[65 * 64];  // Temp data buffer used in filtering
72 73 74 75 76 77 78 79 80 81 82
  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);
83
  return vp9_variance64x32(temp3, 64, dst_ptr, dst_pixels_per_line, sse);
84 85
}

86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
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) {
106
  uint16_t fdata3[65 * 64];  // Temp data buffer used in filtering
107 108 109 110 111 112 113 114
  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);
115
  var_filter_block2d_bil_second_pass(fdata3, temp2, 32, 32, 64, 32, vfilter);
116

117
  return vp9_variance32x64(temp2, 32, dst_ptr, dst_pixels_per_line, sse);
118 119
}

120 121 122 123 124 125 126 127
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) {
128
  uint16_t fdata3[65 * 64];  // Temp data buffer used in filtering
129 130 131 132 133 134 135 136 137 138 139
  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);
140
  return vp9_variance32x64(temp3, 32, dst_ptr, dst_pixels_per_line, sse);
141 142
}

143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
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) {
163
  uint16_t fdata3[33 * 32];  // Temp data buffer used in filtering
164 165 166 167 168 169 170 171 172 173
  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);

174
  return vp9_variance32x16(temp2, 32, dst_ptr, dst_pixels_per_line, sse);
175 176
}

177 178 179 180 181 182 183 184
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) {
185
  uint16_t fdata3[33 * 32];  // Temp data buffer used in filtering
186 187 188 189 190 191 192 193 194 195 196
  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);
197
  return vp9_variance32x16(temp3, 32, dst_ptr, dst_pixels_per_line, sse);
198 199
}

200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
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) {
220
  uint16_t fdata3[33 * 32];  // Temp data buffer used in filtering
221 222 223 224 225 226 227 228
  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);
229
  var_filter_block2d_bil_second_pass(fdata3, temp2, 16, 16, 32, 16, vfilter);
230

231
  return vp9_variance16x32(temp2, 16, dst_ptr, dst_pixels_per_line, sse);
232 233
}

234 235 236 237 238 239 240 241
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) {
242
  uint16_t fdata3[33 * 32];  // Temp data buffer used in filtering
243 244 245 246 247 248 249 250 251 252 253
  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);
254
  return vp9_variance16x32(temp3, 16, dst_ptr, dst_pixels_per_line, sse);
255 256
}

Ronald S. Bultje's avatar
Ronald S. Bultje committed
257 258 259 260 261 262 263 264 265 266 267 268 269
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));
}

270
unsigned int vp9_variance32x32_c(const uint8_t *src_ptr,
Ronald S. Bultje's avatar
Ronald S. Bultje committed
271
                                 int  source_stride,
272
                                 const uint8_t *ref_ptr,
Ronald S. Bultje's avatar
Ronald S. Bultje committed
273 274 275 276 277 278 279
                                 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;
280
  return (var - (((int64_t)avg * avg) >> 10));
Ronald S. Bultje's avatar
Ronald S. Bultje committed
281
}
John Koleszar's avatar
John Koleszar committed
282

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

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

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

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

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

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

Jim Bankoski's avatar
Jim Bankoski committed
322 323 324 325 326
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
327

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

  variance(src_ptr, source_stride, ref_ptr, recon_stride, 8, 8, &var, &avg);
  *sse = var;
338
  return (var - (((unsigned int)avg * avg) >> 6));
John Koleszar's avatar
John Koleszar committed
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 366
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));
}

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

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


381
unsigned int vp9_mse16x16_c(const uint8_t *src_ptr,
382
                            int  source_stride,
383
                            const uint8_t *ref_ptr,
384 385
                            int  recon_stride,
                            unsigned int *sse) {
John Koleszar's avatar
John Koleszar committed
386 387 388 389 390 391
  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
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 432
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
433

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

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

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

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

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

458 459 460 461 462 463 464 465 466 467 468
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
469
  uint16_t fdata3[5 * 4];  // Temp data buffer used in filtering
470 471 472 473 474 475 476 477 478 479 480

  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);
481
  return vp9_variance4x4(temp3, 4, dst_ptr, dst_pixels_per_line, sse);
482
}
John Koleszar's avatar
John Koleszar committed
483

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

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

498 499 500
  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
501

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

505 506 507 508 509 510 511 512
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) {
513
  uint16_t fdata3[9 * 8];  // Temp data buffer used in filtering
514 515 516 517 518 519 520 521 522 523 524
  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);
525
  return vp9_variance8x8(temp3, 8, dst_ptr, dst_pixels_per_line, sse);
526 527
}

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

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

542 543 544
  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
545

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

549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569
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);
570
  return vp9_variance16x16(temp3, 16, dst_ptr, dst_pixels_per_line, sse);
571 572
}

Ronald S. Bultje's avatar
Ronald S. Bultje committed
573 574 575 576 577 578 579
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) {
580
  uint16_t fdata3[65 * 64];  // Temp data buffer used in filtering
Ronald S. Bultje's avatar
Ronald S. Bultje committed
581
  uint8_t temp2[68 * 64];
582
  const int16_t *hfilter, *vfilter;
Ronald S. Bultje's avatar
Ronald S. Bultje committed
583

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

587 588 589
  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
590

591
  return vp9_variance64x64(temp2, 64, dst_ptr, dst_pixels_per_line, sse);
Ronald S. Bultje's avatar
Ronald S. Bultje committed
592 593
}

594 595 596 597 598 599 600 601
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) {
602
  uint16_t fdata3[65 * 64];  // Temp data buffer used in filtering
603 604 605 606 607 608 609 610 611 612 613
  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);
614
  return vp9_variance64x64(temp3, 64, dst_ptr, dst_pixels_per_line, sse);
615 616
}

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

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

631 632 633
  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
634

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

638 639 640 641 642 643 644 645
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) {
646
  uint16_t fdata3[33 * 32];  // Temp data buffer used in filtering
647 648 649 650 651 652 653 654 655 656 657
  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);
658
  return vp9_variance32x32(temp3, 32, dst_ptr, dst_pixels_per_line, sse);
659 660
}

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

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

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);
}
687

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

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

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);
}
714

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

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

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);
}
741

742
unsigned int vp9_sub_pixel_mse16x16_c(const uint8_t *src_ptr,
743 744 745
                                      int  src_pixels_per_line,
                                      int  xoffset,
                                      int  yoffset,
746
                                      const uint8_t *dst_ptr,
747 748 749 750 751
                                      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
752
  return *sse;
John Koleszar's avatar
John Koleszar committed
753 754
}

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

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
780

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

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

795 796 797
  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
798

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

802 803 804 805 806 807 808 809
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) {
810
  uint16_t fdata3[16 * 9];  // Temp data buffer used in filtering
811 812 813 814 815 816 817 818 819 820 821
  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);
822
  return vp9_variance16x8(temp3, 16, dst_ptr, dst_pixels_per_line, sse);
823 824
}

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

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

839 840 841
  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
842

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

846 847 848 849 850 851 852 853
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) {
854
  uint16_t fdata3[9 * 16];  // Temp data buffer used in filtering
855 856 857 858 859 860 861 862 863 864 865
  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);
866
  return vp9_variance8x16(temp3, 8, dst_ptr, dst_pixels_per_line, sse);
867
}
868 869 870 871 872 873 874 875

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) {
876
  uint16_t fdata3[8 * 5];  // Temp data buffer used in filtering
877 878 879 880 881 882 883 884 885 886
  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);

887
  return vp9_variance8x4(temp2, 8, dst_ptr, dst_pixels_per_line, sse);
888 889 890 891 892 893 894 895 896 897
}

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) {
898
  uint16_t fdata3[8 * 5];  // Temp data buffer used in filtering
899 900 901 902 903 904 905 906 907 908 909
  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);
910
  return vp9_variance8x4(temp3, 8, dst_ptr, dst_pixels_per_line, sse);
911 912 913 914 915 916 917 918 919
}

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) {
920
  uint16_t fdata3[5 * 8];  // Temp data buffer used in filtering
921 922
  // FIXME(jingning,rbultje): this temp2 buffer probably doesn't need to be
  // of this big? same issue appears in all other block size settings.
923 924 925 926 927 928 929
  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,
930
                                    1, 9, 4, hfilter);
931 932
  var_filter_block2d_bil_second_pass(fdata3, temp2, 4, 4, 8, 4, vfilter);

933
  return vp9_variance4x8(temp2, 4, dst_ptr, dst_pixels_per_line, sse);
934 935 936 937 938 939 940 941 942 943
}

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) {
944
  uint16_t fdata3[5 * 8];  // Temp data buffer used in filtering
945 946 947 948 949 950 951 952
  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,
953
                                    1, 9, 4, hfilter);
954 955
  var_filter_block2d_bil_second_pass(fdata3, temp2, 4, 4, 8, 4, vfilter);
  comp_avg_pred(temp3, second_pred, 4, 8, temp2, 4);
956
  return vp9_variance4x8(temp3, 4, dst_ptr, dst_pixels_per_line, sse);
957
}