variance.c 55.8 KB
Newer Older
Johann's avatar
Johann committed
1
/*
Yaowu Xu's avatar
Yaowu Xu committed
2
 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Johann's avatar
Johann committed
3
 *
Yaowu Xu's avatar
Yaowu Xu committed
4
5
6
7
8
9
 * This source code is subject to the terms of the BSD 2 Clause License and
 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
 * was not distributed with this source code in the LICENSE file, you can
 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
 * Media Patent License 1.0 was not distributed with this source code in the
 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
Johann's avatar
Johann committed
10
 */
11
#include <stdlib.h>
12
13
#include <string.h>
#include <assert.h>
Johann's avatar
Johann committed
14

Yaowu Xu's avatar
Yaowu Xu committed
15
16
#include "./aom_config.h"
#include "./aom_dsp_rtcd.h"
Johann's avatar
Johann committed
17

18
#include "aom_ports/mem.h"
Yaowu Xu's avatar
Yaowu Xu committed
19
#include "aom/aom_integer.h"
Johann's avatar
Johann committed
20

21
#include "aom_dsp/variance.h"
Yaowu Xu's avatar
Yaowu Xu committed
22
#include "aom_dsp/aom_filter.h"
23
#include "aom_dsp/blend.h"
Johann's avatar
Johann committed
24

25
26
27
#include "./av1_rtcd.h"
#include "av1/common/filter.h"

Yaowu Xu's avatar
Yaowu Xu committed
28
uint32_t aom_get4x4sse_cs_c(const uint8_t *a, int a_stride, const uint8_t *b,
clang-format's avatar
clang-format committed
29
                            int b_stride) {
Johann's avatar
Johann committed
30
31
32
  int distortion = 0;
  int r, c;

Johann's avatar
Johann committed
33
34
  for (r = 0; r < 4; ++r) {
    for (c = 0; c < 4; ++c) {
Johann's avatar
Johann committed
35
36
37
38
39
40
41
42
43
44
45
      int diff = a[c] - b[c];
      distortion += diff * diff;
    }

    a += a_stride;
    b += b_stride;
  }

  return distortion;
}

Yaowu Xu's avatar
Yaowu Xu committed
46
uint32_t aom_get_mb_ss_c(const int16_t *a) {
Johann's avatar
Johann committed
47
48
49
50
51
52
53
54
55
  unsigned int i, sum = 0;

  for (i = 0; i < 256; ++i) {
    sum += a[i] * a[i];
  }

  return sum;
}

Yaowu Xu's avatar
Yaowu Xu committed
56
uint32_t aom_variance_halfpixvar16x16_h_c(const uint8_t *a, int a_stride,
Johann's avatar
Johann committed
57
58
                                          const uint8_t *b, int b_stride,
                                          uint32_t *sse) {
Yaowu Xu's avatar
Yaowu Xu committed
59
  return aom_sub_pixel_variance16x16_c(a, a_stride, 4, 0, b, b_stride, sse);
Johann's avatar
Johann committed
60
61
}

Yaowu Xu's avatar
Yaowu Xu committed
62
uint32_t aom_variance_halfpixvar16x16_v_c(const uint8_t *a, int a_stride,
Johann's avatar
Johann committed
63
64
                                          const uint8_t *b, int b_stride,
                                          uint32_t *sse) {
Yaowu Xu's avatar
Yaowu Xu committed
65
  return aom_sub_pixel_variance16x16_c(a, a_stride, 0, 4, b, b_stride, sse);
Johann's avatar
Johann committed
66
67
}

Yaowu Xu's avatar
Yaowu Xu committed
68
uint32_t aom_variance_halfpixvar16x16_hv_c(const uint8_t *a, int a_stride,
Johann's avatar
Johann committed
69
70
                                           const uint8_t *b, int b_stride,
                                           uint32_t *sse) {
Yaowu Xu's avatar
Yaowu Xu committed
71
  return aom_sub_pixel_variance16x16_c(a, a_stride, 4, 4, b, b_stride, sse);
Johann's avatar
Johann committed
72
73
}

clang-format's avatar
clang-format committed
74
75
static void variance(const uint8_t *a, int a_stride, const uint8_t *b,
                     int b_stride, int w, int h, uint32_t *sse, int *sum) {
Johann's avatar
Johann committed
76
77
78
79
80
  int i, j;

  *sum = 0;
  *sse = 0;

Johann's avatar
Johann committed
81
82
  for (i = 0; i < h; ++i) {
    for (j = 0; j < w; ++j) {
Johann's avatar
Johann committed
83
84
85
86
87
88
89
90
91
92
      const int diff = a[j] - b[j];
      *sum += diff;
      *sse += diff * diff;
    }

    a += a_stride;
    b += b_stride;
  }
}

93
94
95
96
97
98
99
100
uint32_t aom_sse_odd_size(const uint8_t *a, int a_stride, const uint8_t *b,
                          int b_stride, int w, int h) {
  uint32_t sse;
  int sum;
  variance(a, a_stride, b, b_stride, w, h, &sse, &sum);
  return sse;
}

Johann's avatar
Johann committed
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// Applies a 1-D 2-tap bilinear filter to the source block in either horizontal
// or vertical direction to produce the filtered output block. Used to implement
// the first-pass of 2-D separable filter.
//
// Produces int16_t output to retain precision for the next pass. Two filter
// taps should sum to FILTER_WEIGHT. pixel_step defines whether the filter is
// applied horizontally (pixel_step = 1) or vertically (pixel_step = stride).
// It defines the offset required to move from one input to the next.
static void var_filter_block2d_bil_first_pass(const uint8_t *a, uint16_t *b,
                                              unsigned int src_pixels_per_line,
                                              int pixel_step,
                                              unsigned int output_height,
                                              unsigned int output_width,
                                              const uint8_t *filter) {
  unsigned int i, j;

  for (i = 0; i < output_height; ++i) {
    for (j = 0; j < output_width; ++j) {
clang-format's avatar
clang-format committed
119
120
      b[j] = ROUND_POWER_OF_TWO(
          (int)a[0] * filter[0] + (int)a[pixel_step] * filter[1], FILTER_BITS);
Johann's avatar
Johann committed
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144

      ++a;
    }

    a += src_pixels_per_line - output_width;
    b += output_width;
  }
}

// Applies a 1-D 2-tap bilinear filter to the source block in either horizontal
// or vertical direction to produce the filtered output block. Used to implement
// the second-pass of 2-D separable filter.
//
// Requires 16-bit input as produced by filter_block2d_bil_first_pass. Two
// filter taps should sum to FILTER_WEIGHT. pixel_step defines whether the
// filter is applied horizontally (pixel_step = 1) or vertically
// (pixel_step = stride). It defines the offset required to move from one input
// to the next. Output is 8-bit.
static void var_filter_block2d_bil_second_pass(const uint16_t *a, uint8_t *b,
                                               unsigned int src_pixels_per_line,
                                               unsigned int pixel_step,
                                               unsigned int output_height,
                                               unsigned int output_width,
                                               const uint8_t *filter) {
clang-format's avatar
clang-format committed
145
  unsigned int i, j;
Johann's avatar
Johann committed
146
147
148

  for (i = 0; i < output_height; ++i) {
    for (j = 0; j < output_width; ++j) {
clang-format's avatar
clang-format committed
149
150
      b[j] = ROUND_POWER_OF_TWO(
          (int)a[0] * filter[0] + (int)a[pixel_step] * filter[1], FILTER_BITS);
Johann's avatar
Johann committed
151
152
153
154
155
156
157
158
      ++a;
    }

    a += src_pixels_per_line - output_width;
    b += output_width;
  }
}

clang-format's avatar
clang-format committed
159
#define VAR(W, H)                                                    \
Yaowu Xu's avatar
Yaowu Xu committed
160
  uint32_t aom_variance##W##x##H##_c(const uint8_t *a, int a_stride, \
clang-format's avatar
clang-format committed
161
162
163
164
                                     const uint8_t *b, int b_stride, \
                                     uint32_t *sse) {                \
    int sum;                                                         \
    variance(a, a_stride, b, b_stride, W, H, sse, &sum);             \
165
    return *sse - (uint32_t)(((int64_t)sum * sum) / (W * H));        \
clang-format's avatar
clang-format committed
166
  }
Johann's avatar
Johann committed
167

clang-format's avatar
clang-format committed
168
#define SUBPIX_VAR(W, H)                                                \
Yaowu Xu's avatar
Yaowu Xu committed
169
  uint32_t aom_sub_pixel_variance##W##x##H##_c(                         \
clang-format's avatar
clang-format committed
170
171
172
173
174
175
176
177
178
179
      const uint8_t *a, int a_stride, int xoffset, int yoffset,         \
      const uint8_t *b, int b_stride, uint32_t *sse) {                  \
    uint16_t fdata3[(H + 1) * W];                                       \
    uint8_t temp2[H * W];                                               \
                                                                        \
    var_filter_block2d_bil_first_pass(a, fdata3, a_stride, 1, H + 1, W, \
                                      bilinear_filters_2t[xoffset]);    \
    var_filter_block2d_bil_second_pass(fdata3, temp2, W, W, H, W,       \
                                       bilinear_filters_2t[yoffset]);   \
                                                                        \
Yaowu Xu's avatar
Yaowu Xu committed
180
    return aom_variance##W##x##H##_c(temp2, W, b, b_stride, sse);       \
clang-format's avatar
clang-format committed
181
  }
Johann's avatar
Johann committed
182

clang-format's avatar
clang-format committed
183
#define SUBPIX_AVG_VAR(W, H)                                            \
Yaowu Xu's avatar
Yaowu Xu committed
184
  uint32_t aom_sub_pixel_avg_variance##W##x##H##_c(                     \
clang-format's avatar
clang-format committed
185
186
187
188
189
190
191
192
193
194
195
196
      const uint8_t *a, int a_stride, int xoffset, int yoffset,         \
      const uint8_t *b, int b_stride, uint32_t *sse,                    \
      const uint8_t *second_pred) {                                     \
    uint16_t fdata3[(H + 1) * W];                                       \
    uint8_t temp2[H * W];                                               \
    DECLARE_ALIGNED(16, uint8_t, temp3[H * W]);                         \
                                                                        \
    var_filter_block2d_bil_first_pass(a, fdata3, a_stride, 1, H + 1, W, \
                                      bilinear_filters_2t[xoffset]);    \
    var_filter_block2d_bil_second_pass(fdata3, temp2, W, W, H, W,       \
                                       bilinear_filters_2t[yoffset]);   \
                                                                        \
Yaowu Xu's avatar
Yaowu Xu committed
197
    aom_comp_avg_pred(temp3, second_pred, W, H, temp2, W);              \
clang-format's avatar
clang-format committed
198
                                                                        \
Yaowu Xu's avatar
Yaowu Xu committed
199
    return aom_variance##W##x##H##_c(temp3, W, b, b_stride, sse);       \
clang-format's avatar
clang-format committed
200
  }
Johann's avatar
Johann committed
201

Johann's avatar
Johann committed
202
203
204
205
/* Identical to the variance call except it takes an additional parameter, sum,
 * and returns that value using pass-by-reference instead of returning
 * sse - sum^2 / w*h
 */
clang-format's avatar
clang-format committed
206
#define GET_VAR(W, H)                                                         \
Yaowu Xu's avatar
Yaowu Xu committed
207
  void aom_get##W##x##H##var_c(const uint8_t *a, int a_stride,                \
clang-format's avatar
clang-format committed
208
209
210
211
                               const uint8_t *b, int b_stride, uint32_t *sse, \
                               int *sum) {                                    \
    variance(a, a_stride, b, b_stride, W, H, sse, sum);                       \
  }
Johann's avatar
Johann committed
212
213
214
215
216

/* Identical to the variance call except it does not calculate the
 * sse - sum^2 / w*h and returns sse in addtion to modifying the passed in
 * variable.
 */
clang-format's avatar
clang-format committed
217
#define MSE(W, H)                                               \
Yaowu Xu's avatar
Yaowu Xu committed
218
  uint32_t aom_mse##W##x##H##_c(const uint8_t *a, int a_stride, \
clang-format's avatar
clang-format committed
219
220
221
222
223
224
                                const uint8_t *b, int b_stride, \
                                uint32_t *sse) {                \
    int sum;                                                    \
    variance(a, a_stride, b, b_stride, W, H, sse, &sum);        \
    return *sse;                                                \
  }
Johann's avatar
Johann committed
225

Johann's avatar
Johann committed
226
227
/* All three forms of the variance are available in the same sizes. */
#define VARIANCES(W, H) \
clang-format's avatar
clang-format committed
228
229
230
  VAR(W, H)             \
  SUBPIX_VAR(W, H)      \
  SUBPIX_AVG_VAR(W, H)
Johann's avatar
Johann committed
231

Yaowu Xu's avatar
Yaowu Xu committed
232
#if CONFIG_AV1 && CONFIG_EXT_PARTITION
233
234
235
VARIANCES(128, 128)
VARIANCES(128, 64)
VARIANCES(64, 128)
Yaowu Xu's avatar
Yaowu Xu committed
236
#endif  // CONFIG_AV1 && CONFIG_EXT_PARTITION
Johann's avatar
Johann committed
237
238
239
240
241
242
243
244
245
246
247
248
249
VARIANCES(64, 64)
VARIANCES(64, 32)
VARIANCES(32, 64)
VARIANCES(32, 32)
VARIANCES(32, 16)
VARIANCES(16, 32)
VARIANCES(16, 16)
VARIANCES(16, 8)
VARIANCES(8, 16)
VARIANCES(8, 8)
VARIANCES(8, 4)
VARIANCES(4, 8)
VARIANCES(4, 4)
250
251
VARIANCES(4, 2)
VARIANCES(2, 4)
Jingning Han's avatar
Jingning Han committed
252
VARIANCES(2, 2)
Johann's avatar
Johann committed
253
254
255
256
257
258
259
260
261

GET_VAR(16, 16)
GET_VAR(8, 8)

MSE(16, 16)
MSE(16, 8)
MSE(8, 16)
MSE(8, 8)

Yaowu Xu's avatar
Yaowu Xu committed
262
void aom_comp_avg_pred_c(uint8_t *comp_pred, const uint8_t *pred, int width,
clang-format's avatar
clang-format committed
263
                         int height, const uint8_t *ref, int ref_stride) {
Johann's avatar
Johann committed
264
265
  int i, j;

Johann's avatar
Johann committed
266
267
  for (i = 0; i < height; ++i) {
    for (j = 0; j < width; ++j) {
Johann's avatar
Johann committed
268
269
270
271
272
273
274
275
276
      const int tmp = pred[j] + ref[j];
      comp_pred[j] = ROUND_POWER_OF_TWO(tmp, 1);
    }
    comp_pred += width;
    pred += width;
    ref += ref_stride;
  }
}

277
// Get pred block from up-sampled reference.
Yaowu Xu's avatar
Yaowu Xu committed
278
void aom_upsampled_pred_c(uint8_t *comp_pred, int width, int height,
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
                          int subpel_x_q3, int subpel_y_q3, const uint8_t *ref,
                          int ref_stride) {
  if (!subpel_x_q3 && !subpel_y_q3) {
    int i;
    for (i = 0; i < height; i++) {
      memcpy(comp_pred, ref, width * sizeof(*comp_pred));
      comp_pred += width;
      ref += ref_stride;
    }
  } else {
    InterpFilterParams filter;
    filter = av1_get_interp_filter_params(EIGHTTAP_REGULAR);
    if (!subpel_y_q3) {
      const int16_t *kernel;
      kernel = av1_get_interp_filter_subpel_kernel(filter, subpel_x_q3 << 1);
      /*Directly call C version to allow this to work for small (2x2) sizes.*/
      aom_convolve8_horiz_c(ref, ref_stride, comp_pred, width, kernel, 16, NULL,
                            -1, width, height);
    } else if (!subpel_x_q3) {
      const int16_t *kernel;
      kernel = av1_get_interp_filter_subpel_kernel(filter, subpel_y_q3 << 1);
      /*Directly call C version to allow this to work for small (2x2) sizes.*/
      aom_convolve8_vert_c(ref, ref_stride, comp_pred, width, NULL, -1, kernel,
                           16, width, height);
    } else {
      DECLARE_ALIGNED(16, uint8_t,
                      temp[((MAX_SB_SIZE * 2 + 16) + 16) * MAX_SB_SIZE]);
      const int16_t *kernel_x;
      const int16_t *kernel_y;
      int intermediate_height;
      kernel_x = av1_get_interp_filter_subpel_kernel(filter, subpel_x_q3 << 1);
      kernel_y = av1_get_interp_filter_subpel_kernel(filter, subpel_y_q3 << 1);
      intermediate_height =
          (((height - 1) * 8 + subpel_y_q3) >> 3) + filter.taps;
      assert(intermediate_height <= (MAX_SB_SIZE * 2 + 16) + 16);
      /*Directly call C versions to allow this to work for small (2x2) sizes.*/
      aom_convolve8_horiz_c(ref - ref_stride * ((filter.taps >> 1) - 1),
                            ref_stride, temp, MAX_SB_SIZE, kernel_x, 16, NULL,
                            -1, width, intermediate_height);
      aom_convolve8_vert_c(temp + MAX_SB_SIZE * ((filter.taps >> 1) - 1),
                           MAX_SB_SIZE, comp_pred, width, NULL, -1, kernel_y,
                           16, width, height);
321
    }
clang-format's avatar
clang-format committed
322
  }
323
324
}

Yaowu Xu's avatar
Yaowu Xu committed
325
void aom_comp_avg_upsampled_pred_c(uint8_t *comp_pred, const uint8_t *pred,
326
327
                                   int width, int height, int subpel_x_q3,
                                   int subpel_y_q3, const uint8_t *ref,
clang-format's avatar
clang-format committed
328
329
330
                                   int ref_stride) {
  int i, j;

331
332
  aom_upsampled_pred(comp_pred, width, height, subpel_x_q3, subpel_y_q3, ref,
                     ref_stride);
clang-format's avatar
clang-format committed
333
334
  for (i = 0; i < height; i++) {
    for (j = 0; j < width; j++) {
335
      comp_pred[j] = ROUND_POWER_OF_TWO(comp_pred[j] + pred[j], 1);
336
    }
clang-format's avatar
clang-format committed
337
338
339
    comp_pred += width;
    pred += width;
  }
340
341
}

342
#if CONFIG_HIGHBITDEPTH
clang-format's avatar
clang-format committed
343
344
345
static void highbd_variance64(const uint8_t *a8, int a_stride,
                              const uint8_t *b8, int b_stride, int w, int h,
                              uint64_t *sse, int64_t *sum) {
Johann's avatar
Johann committed
346
347
348
349
350
351
352
  int i, j;

  uint16_t *a = CONVERT_TO_SHORTPTR(a8);
  uint16_t *b = CONVERT_TO_SHORTPTR(b8);
  *sum = 0;
  *sse = 0;

Johann's avatar
Johann committed
353
354
  for (i = 0; i < h; ++i) {
    for (j = 0; j < w; ++j) {
Johann's avatar
Johann committed
355
356
357
358
359
360
361
362
363
      const int diff = a[j] - b[j];
      *sum += diff;
      *sse += diff * diff;
    }
    a += a_stride;
    b += b_stride;
  }
}

364
365
366
367
368
369
370
371
uint64_t aom_highbd_sse_odd_size(const uint8_t *a, int a_stride,
                                 const uint8_t *b, int b_stride, int w, int h) {
  uint64_t sse;
  int64_t sum;
  highbd_variance64(a, a_stride, b, b_stride, w, h, &sse, &sum);
  return sse;
}

clang-format's avatar
clang-format committed
372
373
374
static void highbd_8_variance(const uint8_t *a8, int a_stride,
                              const uint8_t *b8, int b_stride, int w, int h,
                              uint32_t *sse, int *sum) {
Johann's avatar
Johann committed
375
  uint64_t sse_long = 0;
376
  int64_t sum_long = 0;
Johann's avatar
Johann committed
377
  highbd_variance64(a8, a_stride, b8, b_stride, w, h, &sse_long, &sum_long);
Johann's avatar
Johann committed
378
  *sse = (uint32_t)sse_long;
Johann's avatar
Johann committed
379
380
381
  *sum = (int)sum_long;
}

clang-format's avatar
clang-format committed
382
383
384
static void highbd_10_variance(const uint8_t *a8, int a_stride,
                               const uint8_t *b8, int b_stride, int w, int h,
                               uint32_t *sse, int *sum) {
Johann's avatar
Johann committed
385
  uint64_t sse_long = 0;
386
  int64_t sum_long = 0;
Johann's avatar
Johann committed
387
  highbd_variance64(a8, a_stride, b8, b_stride, w, h, &sse_long, &sum_long);
Johann's avatar
Johann committed
388
  *sse = (uint32_t)ROUND_POWER_OF_TWO(sse_long, 4);
Johann's avatar
Johann committed
389
390
391
  *sum = (int)ROUND_POWER_OF_TWO(sum_long, 2);
}

clang-format's avatar
clang-format committed
392
393
394
static void highbd_12_variance(const uint8_t *a8, int a_stride,
                               const uint8_t *b8, int b_stride, int w, int h,
                               uint32_t *sse, int *sum) {
Johann's avatar
Johann committed
395
  uint64_t sse_long = 0;
396
  int64_t sum_long = 0;
Johann's avatar
Johann committed
397
  highbd_variance64(a8, a_stride, b8, b_stride, w, h, &sse_long, &sum_long);
Johann's avatar
Johann committed
398
  *sse = (uint32_t)ROUND_POWER_OF_TWO(sse_long, 8);
Johann's avatar
Johann committed
399
400
401
  *sum = (int)ROUND_POWER_OF_TWO(sum_long, 4);
}

clang-format's avatar
clang-format committed
402
#define HIGHBD_VAR(W, H)                                                       \
Yaowu Xu's avatar
Yaowu Xu committed
403
  uint32_t aom_highbd_8_variance##W##x##H##_c(const uint8_t *a, int a_stride,  \
clang-format's avatar
clang-format committed
404
405
406
407
                                              const uint8_t *b, int b_stride,  \
                                              uint32_t *sse) {                 \
    int sum;                                                                   \
    highbd_8_variance(a, a_stride, b, b_stride, W, H, sse, &sum);              \
408
    return *sse - (uint32_t)(((int64_t)sum * sum) / (W * H));                  \
clang-format's avatar
clang-format committed
409
410
  }                                                                            \
                                                                               \
Yaowu Xu's avatar
Yaowu Xu committed
411
  uint32_t aom_highbd_10_variance##W##x##H##_c(const uint8_t *a, int a_stride, \
clang-format's avatar
clang-format committed
412
413
414
415
416
417
418
419
420
                                               const uint8_t *b, int b_stride, \
                                               uint32_t *sse) {                \
    int sum;                                                                   \
    int64_t var;                                                               \
    highbd_10_variance(a, a_stride, b, b_stride, W, H, sse, &sum);             \
    var = (int64_t)(*sse) - (((int64_t)sum * sum) / (W * H));                  \
    return (var >= 0) ? (uint32_t)var : 0;                                     \
  }                                                                            \
                                                                               \
Yaowu Xu's avatar
Yaowu Xu committed
421
  uint32_t aom_highbd_12_variance##W##x##H##_c(const uint8_t *a, int a_stride, \
clang-format's avatar
clang-format committed
422
423
424
425
426
427
428
429
                                               const uint8_t *b, int b_stride, \
                                               uint32_t *sse) {                \
    int sum;                                                                   \
    int64_t var;                                                               \
    highbd_12_variance(a, a_stride, b, b_stride, W, H, sse, &sum);             \
    var = (int64_t)(*sse) - (((int64_t)sum * sum) / (W * H));                  \
    return (var >= 0) ? (uint32_t)var : 0;                                     \
  }
Johann's avatar
Johann committed
430

clang-format's avatar
clang-format committed
431
#define HIGHBD_GET_VAR(S)                                                    \
Yaowu Xu's avatar
Yaowu Xu committed
432
  void aom_highbd_8_get##S##x##S##var_c(const uint8_t *src, int src_stride,  \
clang-format's avatar
clang-format committed
433
434
435
436
437
                                        const uint8_t *ref, int ref_stride,  \
                                        uint32_t *sse, int *sum) {           \
    highbd_8_variance(src, src_stride, ref, ref_stride, S, S, sse, sum);     \
  }                                                                          \
                                                                             \
Yaowu Xu's avatar
Yaowu Xu committed
438
  void aom_highbd_10_get##S##x##S##var_c(const uint8_t *src, int src_stride, \
clang-format's avatar
clang-format committed
439
440
441
442
443
                                         const uint8_t *ref, int ref_stride, \
                                         uint32_t *sse, int *sum) {          \
    highbd_10_variance(src, src_stride, ref, ref_stride, S, S, sse, sum);    \
  }                                                                          \
                                                                             \
Yaowu Xu's avatar
Yaowu Xu committed
444
  void aom_highbd_12_get##S##x##S##var_c(const uint8_t *src, int src_stride, \
clang-format's avatar
clang-format committed
445
446
447
448
                                         const uint8_t *ref, int ref_stride, \
                                         uint32_t *sse, int *sum) {          \
    highbd_12_variance(src, src_stride, ref, ref_stride, S, S, sse, sum);    \
  }
Johann's avatar
Johann committed
449

clang-format's avatar
clang-format committed
450
#define HIGHBD_MSE(W, H)                                                      \
Yaowu Xu's avatar
Yaowu Xu committed
451
  uint32_t aom_highbd_8_mse##W##x##H##_c(const uint8_t *src, int src_stride,  \
clang-format's avatar
clang-format committed
452
453
454
455
456
457
458
                                         const uint8_t *ref, int ref_stride,  \
                                         uint32_t *sse) {                     \
    int sum;                                                                  \
    highbd_8_variance(src, src_stride, ref, ref_stride, W, H, sse, &sum);     \
    return *sse;                                                              \
  }                                                                           \
                                                                              \
Yaowu Xu's avatar
Yaowu Xu committed
459
  uint32_t aom_highbd_10_mse##W##x##H##_c(const uint8_t *src, int src_stride, \
clang-format's avatar
clang-format committed
460
461
462
463
464
465
466
                                          const uint8_t *ref, int ref_stride, \
                                          uint32_t *sse) {                    \
    int sum;                                                                  \
    highbd_10_variance(src, src_stride, ref, ref_stride, W, H, sse, &sum);    \
    return *sse;                                                              \
  }                                                                           \
                                                                              \
Yaowu Xu's avatar
Yaowu Xu committed
467
  uint32_t aom_highbd_12_mse##W##x##H##_c(const uint8_t *src, int src_stride, \
clang-format's avatar
clang-format committed
468
469
470
471
472
473
                                          const uint8_t *ref, int ref_stride, \
                                          uint32_t *sse) {                    \
    int sum;                                                                  \
    highbd_12_variance(src, src_stride, ref, ref_stride, W, H, sse, &sum);    \
    return *sse;                                                              \
  }
Johann's avatar
Johann committed
474

Yaowu Xu's avatar
Yaowu Xu committed
475
void aom_highbd_var_filter_block2d_bil_first_pass(
clang-format's avatar
clang-format committed
476
477
478
    const uint8_t *src_ptr8, uint16_t *output_ptr,
    unsigned int src_pixels_per_line, int pixel_step,
    unsigned int output_height, unsigned int output_width,
Johann's avatar
Johann committed
479
480
481
482
483
    const uint8_t *filter) {
  unsigned int i, j;
  uint16_t *src_ptr = CONVERT_TO_SHORTPTR(src_ptr8);
  for (i = 0; i < output_height; ++i) {
    for (j = 0; j < output_width; ++j) {
clang-format's avatar
clang-format committed
484
485
486
      output_ptr[j] = ROUND_POWER_OF_TWO(
          (int)src_ptr[0] * filter[0] + (int)src_ptr[pixel_step] * filter[1],
          FILTER_BITS);
Johann's avatar
Johann committed
487
488
489
490
491
492
493
494
495
496

      ++src_ptr;
    }

    // Next row...
    src_ptr += src_pixels_per_line - output_width;
    output_ptr += output_width;
  }
}

Yaowu Xu's avatar
Yaowu Xu committed
497
void aom_highbd_var_filter_block2d_bil_second_pass(
clang-format's avatar
clang-format committed
498
499
500
    const uint16_t *src_ptr, uint16_t *output_ptr,
    unsigned int src_pixels_per_line, unsigned int pixel_step,
    unsigned int output_height, unsigned int output_width,
Johann's avatar
Johann committed
501
    const uint8_t *filter) {
clang-format's avatar
clang-format committed
502
  unsigned int i, j;
Johann's avatar
Johann committed
503
504
505

  for (i = 0; i < output_height; ++i) {
    for (j = 0; j < output_width; ++j) {
clang-format's avatar
clang-format committed
506
507
508
      output_ptr[j] = ROUND_POWER_OF_TWO(
          (int)src_ptr[0] * filter[0] + (int)src_ptr[pixel_step] * filter[1],
          FILTER_BITS);
Johann's avatar
Johann committed
509
510
511
512
513
514
515
516
      ++src_ptr;
    }

    src_ptr += src_pixels_per_line - output_width;
    output_ptr += output_width;
  }
}

clang-format's avatar
clang-format committed
517
#define HIGHBD_SUBPIX_VAR(W, H)                                              \
Yaowu Xu's avatar
Yaowu Xu committed
518
  uint32_t aom_highbd_8_sub_pixel_variance##W##x##H##_c(                     \
clang-format's avatar
clang-format committed
519
520
521
522
523
      const uint8_t *src, int src_stride, int xoffset, int yoffset,          \
      const uint8_t *dst, int dst_stride, uint32_t *sse) {                   \
    uint16_t fdata3[(H + 1) * W];                                            \
    uint16_t temp2[H * W];                                                   \
                                                                             \
Yaowu Xu's avatar
Yaowu Xu committed
524
    aom_highbd_var_filter_block2d_bil_first_pass(                            \
clang-format's avatar
clang-format committed
525
        src, fdata3, src_stride, 1, H + 1, W, bilinear_filters_2t[xoffset]); \
Yaowu Xu's avatar
Yaowu Xu committed
526
    aom_highbd_var_filter_block2d_bil_second_pass(                           \
clang-format's avatar
clang-format committed
527
528
        fdata3, temp2, W, W, H, W, bilinear_filters_2t[yoffset]);            \
                                                                             \
Yaowu Xu's avatar
Yaowu Xu committed
529
    return aom_highbd_8_variance##W##x##H##_c(CONVERT_TO_BYTEPTR(temp2), W,  \
clang-format's avatar
clang-format committed
530
531
532
                                              dst, dst_stride, sse);         \
  }                                                                          \
                                                                             \
Yaowu Xu's avatar
Yaowu Xu committed
533
  uint32_t aom_highbd_10_sub_pixel_variance##W##x##H##_c(                    \
clang-format's avatar
clang-format committed
534
535
536
537
538
      const uint8_t *src, int src_stride, int xoffset, int yoffset,          \
      const uint8_t *dst, int dst_stride, uint32_t *sse) {                   \
    uint16_t fdata3[(H + 1) * W];                                            \
    uint16_t temp2[H * W];                                                   \
                                                                             \
Yaowu Xu's avatar
Yaowu Xu committed
539
    aom_highbd_var_filter_block2d_bil_first_pass(                            \
clang-format's avatar
clang-format committed
540
        src, fdata3, src_stride, 1, H + 1, W, bilinear_filters_2t[xoffset]); \
Yaowu Xu's avatar
Yaowu Xu committed
541
    aom_highbd_var_filter_block2d_bil_second_pass(                           \
clang-format's avatar
clang-format committed
542
543
        fdata3, temp2, W, W, H, W, bilinear_filters_2t[yoffset]);            \
                                                                             \
Yaowu Xu's avatar
Yaowu Xu committed
544
    return aom_highbd_10_variance##W##x##H##_c(CONVERT_TO_BYTEPTR(temp2), W, \
clang-format's avatar
clang-format committed
545
546
547
                                               dst, dst_stride, sse);        \
  }                                                                          \
                                                                             \
Yaowu Xu's avatar
Yaowu Xu committed
548
  uint32_t aom_highbd_12_sub_pixel_variance##W##x##H##_c(                    \
clang-format's avatar
clang-format committed
549
550
551
552
553
      const uint8_t *src, int src_stride, int xoffset, int yoffset,          \
      const uint8_t *dst, int dst_stride, uint32_t *sse) {                   \
    uint16_t fdata3[(H + 1) * W];                                            \
    uint16_t temp2[H * W];                                                   \
                                                                             \
Yaowu Xu's avatar
Yaowu Xu committed
554
    aom_highbd_var_filter_block2d_bil_first_pass(                            \
clang-format's avatar
clang-format committed
555
        src, fdata3, src_stride, 1, H + 1, W, bilinear_filters_2t[xoffset]); \
Yaowu Xu's avatar
Yaowu Xu committed
556
    aom_highbd_var_filter_block2d_bil_second_pass(                           \
clang-format's avatar
clang-format committed
557
558
        fdata3, temp2, W, W, H, W, bilinear_filters_2t[yoffset]);            \
                                                                             \
Yaowu Xu's avatar
Yaowu Xu committed
559
    return aom_highbd_12_variance##W##x##H##_c(CONVERT_TO_BYTEPTR(temp2), W, \
clang-format's avatar
clang-format committed
560
561
                                               dst, dst_stride, sse);        \
  }
Johann's avatar
Johann committed
562

clang-format's avatar
clang-format committed
563
#define HIGHBD_SUBPIX_AVG_VAR(W, H)                                          \
Yaowu Xu's avatar
Yaowu Xu committed
564
  uint32_t aom_highbd_8_sub_pixel_avg_variance##W##x##H##_c(                 \
clang-format's avatar
clang-format committed
565
566
567
568
569
570
571
      const uint8_t *src, int src_stride, int xoffset, int yoffset,          \
      const uint8_t *dst, int dst_stride, uint32_t *sse,                     \
      const uint8_t *second_pred) {                                          \
    uint16_t fdata3[(H + 1) * W];                                            \
    uint16_t temp2[H * W];                                                   \
    DECLARE_ALIGNED(16, uint16_t, temp3[H * W]);                             \
                                                                             \
Yaowu Xu's avatar
Yaowu Xu committed
572
    aom_highbd_var_filter_block2d_bil_first_pass(                            \
clang-format's avatar
clang-format committed
573
        src, fdata3, src_stride, 1, H + 1, W, bilinear_filters_2t[xoffset]); \
Yaowu Xu's avatar
Yaowu Xu committed
574
    aom_highbd_var_filter_block2d_bil_second_pass(                           \
clang-format's avatar
clang-format committed
575
576
        fdata3, temp2, W, W, H, W, bilinear_filters_2t[yoffset]);            \
                                                                             \
Yaowu Xu's avatar
Yaowu Xu committed
577
    aom_highbd_comp_avg_pred_c(temp3, second_pred, W, H,                     \
clang-format's avatar
clang-format committed
578
579
                               CONVERT_TO_BYTEPTR(temp2), W);                \
                                                                             \
Yaowu Xu's avatar
Yaowu Xu committed
580
    return aom_highbd_8_variance##W##x##H##_c(CONVERT_TO_BYTEPTR(temp3), W,  \
clang-format's avatar
clang-format committed
581
582
583
                                              dst, dst_stride, sse);         \
  }                                                                          \
                                                                             \
Yaowu Xu's avatar
Yaowu Xu committed
584
  uint32_t aom_highbd_10_sub_pixel_avg_variance##W##x##H##_c(                \
clang-format's avatar
clang-format committed
585
586
587
588
589
590
591
      const uint8_t *src, int src_stride, int xoffset, int yoffset,          \
      const uint8_t *dst, int dst_stride, uint32_t *sse,                     \
      const uint8_t *second_pred) {                                          \
    uint16_t fdata3[(H + 1) * W];                                            \
    uint16_t temp2[H * W];                                                   \
    DECLARE_ALIGNED(16, uint16_t, temp3[H * W]);                             \
                                                                             \
Yaowu Xu's avatar
Yaowu Xu committed
592
    aom_highbd_var_filter_block2d_bil_first_pass(                            \
clang-format's avatar
clang-format committed
593
        src, fdata3, src_stride, 1, H + 1, W, bilinear_filters_2t[xoffset]); \
Yaowu Xu's avatar
Yaowu Xu committed
594
    aom_highbd_var_filter_block2d_bil_second_pass(                           \
clang-format's avatar
clang-format committed
595
596
        fdata3, temp2, W, W, H, W, bilinear_filters_2t[yoffset]);            \
                                                                             \
Yaowu Xu's avatar
Yaowu Xu committed
597
    aom_highbd_comp_avg_pred_c(temp3, second_pred, W, H,                     \
clang-format's avatar
clang-format committed
598
599
                               CONVERT_TO_BYTEPTR(temp2), W);                \
                                                                             \
Yaowu Xu's avatar
Yaowu Xu committed
600
    return aom_highbd_10_variance##W##x##H##_c(CONVERT_TO_BYTEPTR(temp3), W, \
clang-format's avatar
clang-format committed
601
602
603
                                               dst, dst_stride, sse);        \
  }                                                                          \
                                                                             \
Yaowu Xu's avatar
Yaowu Xu committed
604
  uint32_t aom_highbd_12_sub_pixel_avg_variance##W##x##H##_c(                \
clang-format's avatar
clang-format committed
605
606
607
608
609
610
611
      const uint8_t *src, int src_stride, int xoffset, int yoffset,          \
      const uint8_t *dst, int dst_stride, uint32_t *sse,                     \
      const uint8_t *second_pred) {                                          \
    uint16_t fdata3[(H + 1) * W];                                            \
    uint16_t temp2[H * W];                                                   \
    DECLARE_ALIGNED(16, uint16_t, temp3[H * W]);                             \
                                                                             \
Yaowu Xu's avatar
Yaowu Xu committed
612
    aom_highbd_var_filter_block2d_bil_first_pass(                            \
clang-format's avatar
clang-format committed
613
        src, fdata3, src_stride, 1, H + 1, W, bilinear_filters_2t[xoffset]); \
Yaowu Xu's avatar
Yaowu Xu committed
614
    aom_highbd_var_filter_block2d_bil_second_pass(                           \
clang-format's avatar
clang-format committed
615
616
        fdata3, temp2, W, W, H, W, bilinear_filters_2t[yoffset]);            \
                                                                             \
Yaowu Xu's avatar
Yaowu Xu committed
617
    aom_highbd_comp_avg_pred_c(temp3, second_pred, W, H,                     \
clang-format's avatar
clang-format committed
618
619
                               CONVERT_TO_BYTEPTR(temp2), W);                \
                                                                             \
Yaowu Xu's avatar
Yaowu Xu committed
620
    return aom_highbd_12_variance##W##x##H##_c(CONVERT_TO_BYTEPTR(temp3), W, \
clang-format's avatar
clang-format committed
621
622
                                               dst, dst_stride, sse);        \
  }
Johann's avatar
Johann committed
623
624
625

/* All three forms of the variance are available in the same sizes. */
#define HIGHBD_VARIANCES(W, H) \
clang-format's avatar
clang-format committed
626
627
628
  HIGHBD_VAR(W, H)             \
  HIGHBD_SUBPIX_VAR(W, H)      \
  HIGHBD_SUBPIX_AVG_VAR(W, H)
Johann's avatar
Johann committed
629

Yaowu Xu's avatar
Yaowu Xu committed
630
#if CONFIG_AV1 && CONFIG_EXT_PARTITION
631
632
633
HIGHBD_VARIANCES(128, 128)
HIGHBD_VARIANCES(128, 64)
HIGHBD_VARIANCES(64, 128)
Yaowu Xu's avatar
Yaowu Xu committed
634
#endif  // CONFIG_AV1 && CONFIG_EXT_PARTITION
Johann's avatar
Johann committed
635
636
637
638
639
640
641
642
643
644
645
646
647
HIGHBD_VARIANCES(64, 64)
HIGHBD_VARIANCES(64, 32)
HIGHBD_VARIANCES(32, 64)
HIGHBD_VARIANCES(32, 32)
HIGHBD_VARIANCES(32, 16)
HIGHBD_VARIANCES(16, 32)
HIGHBD_VARIANCES(16, 16)
HIGHBD_VARIANCES(16, 8)
HIGHBD_VARIANCES(8, 16)
HIGHBD_VARIANCES(8, 8)
HIGHBD_VARIANCES(8, 4)
HIGHBD_VARIANCES(4, 8)
HIGHBD_VARIANCES(4, 4)
648
649
650
HIGHBD_VARIANCES(4, 2)
HIGHBD_VARIANCES(2, 4)
HIGHBD_VARIANCES(2, 2)
Johann's avatar
Johann committed
651

Johann's avatar
Johann committed
652
653
654
655
656
657
658
659
HIGHBD_GET_VAR(8)
HIGHBD_GET_VAR(16)

HIGHBD_MSE(16, 16)
HIGHBD_MSE(16, 8)
HIGHBD_MSE(8, 16)
HIGHBD_MSE(8, 8)

Yaowu Xu's avatar
Yaowu Xu committed
660
void aom_highbd_comp_avg_pred_c(uint16_t *comp_pred, const uint8_t *pred8,
661
662
                                int width, int height, const uint8_t *ref8,
                                int ref_stride) {
Johann's avatar
Johann committed
663
664
665
  int i, j;
  uint16_t *pred = CONVERT_TO_SHORTPTR(pred8);
  uint16_t *ref = CONVERT_TO_SHORTPTR(ref8);
Johann's avatar
Johann committed
666
667
  for (i = 0; i < height; ++i) {
    for (j = 0; j < width; ++j) {
Johann's avatar
Johann committed
668
669
670
671
672
673
674
675
      const int tmp = pred[j] + ref[j];
      comp_pred[j] = ROUND_POWER_OF_TWO(tmp, 1);
    }
    comp_pred += width;
    pred += width;
    ref += ref_stride;
  }
}
676

Yaowu Xu's avatar
Yaowu Xu committed
677
void aom_highbd_upsampled_pred_c(uint16_t *comp_pred, int width, int height,
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
                                 int subpel_x_q3, int subpel_y_q3,
                                 const uint8_t *ref8, int ref_stride, int bd) {
  if (!subpel_x_q3 && !subpel_y_q3) {
    const uint16_t *ref;
    int i;
    ref = CONVERT_TO_SHORTPTR(ref8);
    for (i = 0; i < height; i++) {
      memcpy(comp_pred, ref, width * sizeof(*comp_pred));
      comp_pred += width;
      ref += ref_stride;
    }
  } else {
    InterpFilterParams filter;
    filter = av1_get_interp_filter_params(EIGHTTAP_REGULAR);
    if (!subpel_y_q3) {
      const int16_t *kernel;
      kernel = av1_get_interp_filter_subpel_kernel(filter, subpel_x_q3 << 1);
      /*Directly call C version to allow this to work for small (2x2) sizes.*/
      aom_highbd_convolve8_horiz_c(ref8, ref_stride,
                                   CONVERT_TO_BYTEPTR(comp_pred), width, kernel,
                                   16, NULL, -1, width, height, bd);
    } else if (!subpel_x_q3) {
      const int16_t *kernel;
      kernel = av1_get_interp_filter_subpel_kernel(filter, subpel_y_q3 << 1);
      /*Directly call C version to allow this to work for small (2x2) sizes.*/
      aom_highbd_convolve8_vert_c(ref8, ref_stride,
                                  CONVERT_TO_BYTEPTR(comp_pred), width, NULL,
                                  -1, kernel, 16, width, height, bd);
    } else {
      DECLARE_ALIGNED(16, uint8_t,
                      temp[((MAX_SB_SIZE * 2 + 16) + 16) * MAX_SB_SIZE]);
      const uint16_t *ref;
      const int16_t *kernel_x;
      const int16_t *kernel_y;
      int intermediate_height;
      ref = CONVERT_TO_SHORTPTR(ref8);
      kernel_x = av1_get_interp_filter_subpel_kernel(filter, subpel_x_q3 << 1);
      kernel_y = av1_get_interp_filter_subpel_kernel(filter, subpel_y_q3 << 1);
      intermediate_height =
          (((height - 1) * 8 + subpel_y_q3) >> 3) + filter.taps;
      assert(intermediate_height <= (MAX_SB_SIZE * 2 + 16) + 16);
      /*Directly call C versions to allow this to work for small (2x2) sizes.*/
      aom_highbd_convolve8_horiz_c(
          CONVERT_TO_BYTEPTR(ref - ref_stride * ((filter.taps >> 1) - 1)),
          ref_stride, CONVERT_TO_BYTEPTR(temp), MAX_SB_SIZE, kernel_x, 16, NULL,
          -1, width, intermediate_height, bd);
      aom_highbd_convolve8_vert_c(
          CONVERT_TO_BYTEPTR(temp + MAX_SB_SIZE * ((filter.taps >> 1) - 1)),
          MAX_SB_SIZE, CONVERT_TO_BYTEPTR(comp_pred), width, NULL, -1, kernel_y,
          16, width, height, bd);
728
729
730
731
    }
  }
}

Yaowu Xu's avatar
Yaowu Xu committed
732
void aom_highbd_comp_avg_upsampled_pred_c(uint16_t *comp_pred,
clang-format's avatar
clang-format committed
733
                                          const uint8_t *pred8, int width,
734
735
736
                                          int height, int subpel_x_q3,
                                          int subpel_y_q3, const uint8_t *ref8,
                                          int ref_stride, int bd) {
737
738
  int i, j;

739
740
741
  const uint16_t *pred = CONVERT_TO_SHORTPTR(pred8);
  aom_highbd_upsampled_pred(comp_pred, width, height, subpel_x_q3, subpel_y_q3,
                            ref8, ref_stride, bd);
742
743
  for (i = 0; i < height; ++i) {
    for (j = 0; j < width; ++j) {
744
      comp_pred[j] = ROUND_POWER_OF_TWO(pred[j] + comp_pred[j], 1);
745
746
747
748
749
    }
    comp_pred += width;
    pred += width;
  }
}
750
#endif  // CONFIG_HIGHBITDEPTH
751

Yaowu Xu's avatar
Yaowu Xu committed
752
#if CONFIG_AV1 && CONFIG_EXT_INTER
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
void aom_comp_mask_pred_c(uint8_t *comp_pred, const uint8_t *pred, int width,
                          int height, const uint8_t *ref, int ref_stride,
                          const uint8_t *mask, int mask_stride,
                          int invert_mask) {
  int i, j;

  for (i = 0; i < height; ++i) {
    for (j = 0; j < width; ++j) {
      if (!invert_mask)
        comp_pred[j] = AOM_BLEND_A64(mask[j], ref[j], pred[j]);
      else
        comp_pred[j] = AOM_BLEND_A64(mask[j], pred[j], ref[j]);
    }
    comp_pred += width;
    pred += width;
    ref += ref_stride;
    mask += mask_stride;
  }
}

void aom_comp_mask_upsampled_pred_c(uint8_t *comp_pred, const uint8_t *pred,
774
775
                                    int width, int height, int subpel_x_q3,
                                    int subpel_y_q3, const uint8_t *ref,
776
777
778
779
                                    int ref_stride, const uint8_t *mask,
                                    int mask_stride, int invert_mask) {
  int i, j;

780
781
  aom_upsampled_pred(comp_pred, width, height, subpel_x_q3, subpel_y_q3, ref,
                     ref_stride);
782
783
784
  for (i = 0; i < height; i++) {
    for (j = 0; j < width; j++) {
      if (!invert_mask)
785
        comp_pred[j] = AOM_BLEND_A64(mask[j], comp_pred[j], pred[j]);
786
      else
787
        comp_pred[j] = AOM_BLEND_A64(mask[j], pred[j], comp_pred[j]);
788
789
790
791
792
793
794
    }
    comp_pred += width;
    pred += width;
    mask += mask_stride;
  }
}

David Barker's avatar
David Barker committed
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
#define MASK_SUBPIX_VAR(W, H)                                                 \
  unsigned int aom_masked_sub_pixel_variance##W##x##H##_c(                    \
      const uint8_t *src, int src_stride, int xoffset, int yoffset,           \
      const uint8_t *ref, int ref_stride, const uint8_t *second_pred,         \
      const uint8_t *msk, int msk_stride, int invert_mask,                    \
      unsigned int *sse) {                                                    \
    uint16_t fdata3[(H + 1) * W];                                             \
    uint8_t temp2[H * W];                                                     \
    DECLARE_ALIGNED(16, uint8_t, temp3[H * W]);                               \
                                                                              \
    var_filter_block2d_bil_first_pass(src, fdata3, src_stride, 1, H + 1, W,   \
                                      bilinear_filters_2t[xoffset]);          \
    var_filter_block2d_bil_second_pass(fdata3, temp2, W, W, H, W,             \
                                       bilinear_filters_2t[yoffset]);         \
                                                                              \
    aom_comp_mask_pred_c(temp3, second_pred, W, H, temp2, W, msk, msk_stride, \
                         invert_mask);                                        \
    return aom_variance##W##x##H##_c(temp3, W, ref, ref_stride, sse);         \
813
  }
814

815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
MASK_SUBPIX_VAR(4, 4)
MASK_SUBPIX_VAR(4, 8)
MASK_SUBPIX_VAR(8, 4)
MASK_SUBPIX_VAR(8, 8)
MASK_SUBPIX_VAR(8, 16)
MASK_SUBPIX_VAR(16, 8)
MASK_SUBPIX_VAR(16, 16)
MASK_SUBPIX_VAR(16, 32)
MASK_SUBPIX_VAR(32, 16)
MASK_SUBPIX_VAR(32, 32)
MASK_SUBPIX_VAR(32, 64)
MASK_SUBPIX_VAR(64, 32)
MASK_SUBPIX_VAR(64, 64)
#if CONFIG_EXT_PARTITION
MASK_SUBPIX_VAR(64, 128)
MASK_SUBPIX_VAR(128, 64)
MASK_SUBPIX_VAR(128, 128)
#endif  // CONFIG_EXT_PARTITION

834
#if CONFIG_HIGHBITDEPTH
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
void aom_highbd_comp_mask_pred_c(uint16_t *comp_pred, const uint8_t *pred8,
                                 int width, int height, const uint8_t *ref8,
                                 int ref_stride, const uint8_t *mask,
                                 int mask_stride, int invert_mask) {
  int i, j;
  uint16_t *pred = CONVERT_TO_SHORTPTR(pred8);
  uint16_t *ref = CONVERT_TO_SHORTPTR(ref8);
  for (i = 0; i < height; ++i) {
    for (j = 0; j < width; ++j) {
      if (!invert_mask)
        comp_pred[j] = AOM_BLEND_A64(mask[j], ref[j], pred[j]);
      else
        comp_pred[j] = AOM_BLEND_A64(mask[j], pred[j], ref[j]);
    }
    comp_pred += width;
    pred += width;
    ref += ref_stride;
    mask += mask_stride;
  }
}

856
857
858
859
void aom_highbd_comp_mask_upsampled_pred_c(
    uint16_t *comp_pred, const uint8_t *pred8, int width, int height,
    int subpel_x_q3, int subpel_y_q3, const uint8_t *ref8, int ref_stride,
    const uint8_t *mask, int mask_stride, int invert_mask, int bd) {
860
861
862
  int i, j;

  uint16_t *pred = CONVERT_TO_SHORTPTR(pred8);
863
864
  aom_highbd_upsampled_pred(comp_pred, width, height, subpel_x_q3, subpel_y_q3,
                            ref8, ref_stride, bd);
865
866
867
  for (i = 0; i < height; ++i) {
    for (j = 0; j < width; ++j) {
      if (!invert_mask)
868
        comp_pred[j] = AOM_BLEND_A64(mask[j], comp_pred[j], pred[j]);
869
      else
870
        comp_pred[j] = AOM_BLEND_A64(mask[j], pred[j], comp_pred[j]);
871
872
873
874
875
876
877
878
    }
    comp_pred += width;
    pred += width;
    mask += mask_stride;
  }
}

#define HIGHBD_MASK_SUBPIX_VAR(W, H)                                           \
David Barker's avatar
David Barker committed
879
  unsigned int aom_highbd_8_masked_sub_pixel_variance##W##x##H##_c(            \
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
      const uint8_t *src, int src_stride, int xoffset, int yoffset,            \
      const uint8_t *ref, int ref_stride, const uint8_t *second_pred,          \
      const uint8_t *msk, int msk_stride, int invert_mask,                     \
      unsigned int *sse) {                                                     \
    uint16_t fdata3[(H + 1) * W];                                              \
    uint16_t temp2[H * W];                                                     \
    DECLARE_ALIGNED(16, uint16_t, temp3[H * W]);                               \
                                                                               \
    aom_highbd_var_filter_block2d_bil_first_pass(                              \
        src, fdata3, src_stride, 1, H + 1, W, bilinear_filters_2t[xoffset]);   \
    aom_highbd_var_filter_block2d_bil_second_pass(                             \
        fdata3, temp2, W, W, H, W, bilinear_filters_2t[yoffset]);              \
                                                                               \
    aom_highbd_comp_mask_pred_c(temp3, second_pred, W, H,                      \
                                CONVERT_TO_BYTEPTR(temp2), W, msk, msk_stride, \
                                invert_mask);                                  \
                                                                               \
    return aom_highbd_8_variance##W##x##H##_c(CONVERT_TO_BYTEPTR(temp3), W,    \
                                              ref, ref_stride, sse);           \
  }                                                                            \
                                                                               \
David Barker's avatar
David Barker committed
901
  unsigned int aom_highbd_10_masked_sub_pixel_variance##W##x##H##_c(           \
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
      const uint8_t *src, int src_stride, int xoffset, int yoffset,            \
      const uint8_t *ref, int ref_stride, const uint8_t *second_pred,          \
      const uint8_t *msk, int msk_stride, int invert_mask,                     \
      unsigned int *sse) {                                                     \
    uint16_t fdata3[(H + 1) * W];                                              \
    uint16_t temp2[H * W];                                                     \
    DECLARE_ALIGNED(16, uint16_t, temp3[H * W]);                               \
                                                                               \
    aom_highbd_var_filter_block2d_bil_first_pass(                              \
        src, fdata3, src_stride, 1, H + 1, W, bilinear_filters_2t[xoffset]);   \
    aom_highbd_var_filter_block2d_bil_second_pass(                             \
        fdata3, temp2, W, W, H, W, bilinear_filters_2t[yoffset]);              \
                                                                               \
    aom_highbd_comp_mask_pred_c(temp3, second_pred, W, H,                      \
                                CONVERT_TO_BYTEPTR(temp2), W, msk, msk_stride, \
                                invert_mask);                                  \
                                                                               \
    return aom_highbd_10_variance##W##x##H##_c(CONVERT_TO_BYTEPTR(temp3), W,   \
                                               ref, ref_stride, sse);          \
  }                                                                            \
                                                                               \
David Barker's avatar
David Barker committed
923
  unsigned int aom_highbd_12_masked_sub_pixel_variance##W##x##H##_c(           \
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
      const uint8_t *src, int src_stride, int xoffset, int yoffset,            \
      const uint8_t *ref, int ref_stride, const uint8_t *second_pred,          \
      const uint8_t *msk, int msk_stride, int invert_mask,                     \
      unsigned int *sse) {                                                     \
    uint16_t fdata3[(H + 1) * W];                                              \
    uint16_t temp2[H * W];                                                     \
    DECLARE_ALIGNED(16, uint16_t, temp3[H * W]);                               \
                                                                               \
    aom_highbd_var_filter_block2d_bil_first_pass(                              \
        src, fdata3, src_stride, 1, H + 1, W, bilinear_filters_2t[xoffset]);   \
    aom_highbd_var_filter_block2d_bil_second_pass(                             \
        fdata3, temp2, W, W, H, W, bilinear_filters_2t[yoffset]);              \
                                                                               \
    aom_highbd_comp_mask_pred_c(temp3, second_pred, W, H,                      \
                                CONVERT_TO_BYTEPTR(temp2), W, msk, msk_stride, \
                                invert_mask);                                  \
                                                                               \
    return aom_highbd_12_variance##W##x##H##_c(CONVERT_TO_BYTEPTR(temp3), W,   \
                                               ref, ref_stride, sse);          \
clang-format's avatar
clang-format committed
943
  }
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962

HIGHBD_MASK_SUBPIX_VAR(4, 4)
HIGHBD_MASK_SUBPIX_VAR(4, 8)
HIGHBD_MASK_SUBPIX_VAR(8, 4)
HIGHBD_MASK_SUBPIX_VAR(8, 8)
HIGHBD_MASK_SUBPIX_VAR(8, 16)
HIGHBD_MASK_SUBPIX_VAR(16, 8)
HIGHBD_MASK_SUBPIX_VAR(16, 16)
HIGHBD_MASK_SUBPIX_VAR(16, 32)
HIGHBD_MASK_SUBPIX_VAR(32, 16)
HIGHBD_MASK_SUBPIX_VAR(32, 32)
HIGHBD_MASK_SUBPIX_VAR(32, 64)
HIGHBD_MASK_SUBPIX_VAR(64, 32)
HIGHBD_MASK_SUBPIX_VAR(64, 64)
#if CONFIG_EXT_PARTITION
HIGHBD_MASK_SUBPIX_VAR(64, 128)
HIGHBD_MASK_SUBPIX_VAR(128, 64)
HIGHBD_MASK_SUBPIX_VAR(128, 128)
#endif  // CONFIG_EXT_PARTITION
963
#endif  // CONFIG_HIGHBITDEPTH
Yaowu Xu's avatar
Yaowu Xu committed
964
#endif  // CONFIG_AV1 && CONFIG_EXT_INTER
965

Yue Chen's avatar
Yue Chen committed
966
#if CONFIG_AV1 && CONFIG_MOTION_VAR
clang-format's avatar
clang-format committed
967
static INLINE void obmc_variance(const uint8_t *pre, int pre_stride,
968
969
                                 const int32_t *wsrc, const int32_t *mask,
                                 int w, int h, unsigned int *sse, int *sum) {
970
971
972
973
974
975
976
  int i, j;

  *sse = 0;
  *sum = 0;

  for (i = 0; i < h; i++) {
    for (j = 0; j < w; j++) {
977
      int diff = ROUND_POWER_OF_TWO_SIGNED(wsrc[j] - pre[j] * mask[j], 12);
978
979
980
981
      *sum += diff;
      *sse += diff * diff;
    }

982
983
984
    pre += pre_stride;
    wsrc += w;
    mask += w;
985
986
987
  }
}

988
989
990
991
992
993
994
#define OBMC_VAR(W, H)                                            \
  unsigned int aom_obmc_variance##W##x##H##_c(                    \
      const uint8_t *pre, int pre_stride, const int32_t *wsrc,    \
      const int32_t *mask, unsigned int *sse) {                   \
    int sum;                                                      \
    obmc_variance(pre, pre_stride, wsrc, mask, W, H, sse, &sum);  \
    return *sse - (unsigned int)(((int64_t)sum * sum) / (W * H)); \
clang-format's avatar
clang-format committed
995
  }
996

clang-format's avatar
clang-format committed
997
#define OBMC_SUBPIX_VAR(W, H)                                               \
Yaowu Xu's avatar
Yaowu Xu committed
998
  unsigned int aom_obmc_sub_pixel_variance##W##x##H##_c(                    \
clang-format's avatar
clang-format committed
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
      const uint8_t *pre, int pre_stride, int xoffset, int yoffset,         \
      const int32_t *wsrc, const int32_t *mask, unsigned int *sse) {        \
    uint16_t fdata3[(H + 1) * W];                                           \
    uint8_t temp2[H * W];                                                   \
                                                                            \
    var_filter_block2d_bil_first_pass(pre, fdata3, pre_stride, 1, H + 1, W, \
                                      bilinear_filters_2t[xoffset]);        \
    var_filter_block2d_bil_second_pass(fdata3, temp2, W, W, H, W,           \
                                       bilinear_filters_2t[yoffset]);       \
                                                                            \
Yaowu Xu's avatar
Yaowu Xu committed
1009
    return aom_obmc_variance##W##x##H##_c(temp2, W, wsrc, mask, sse);       \
clang-format's avatar
clang-format committed
1010
  }
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061

OBMC_VAR(4, 4)
OBMC_SUBPIX_VAR(4, 4)

OBMC_VAR(4, 8)
OBMC_SUBPIX_VAR(4, 8)

OBMC_VAR(8, 4)
OBMC_SUBPIX_VAR(8, 4)

OBMC_VAR(8, 8)
OBMC_SUBPIX_VAR(8, 8)

OBMC_VAR(8, 16)
OBMC_SUBPIX_VAR(8, 16)

OBMC_VAR(16, 8)
OBMC_SUBPIX_VAR(16, 8)

OBMC_VAR(16, 16)
OBMC_SUBPIX_VAR(16, 16)

OBMC_VAR(16, 32)
OBMC_SUBPIX_VAR(16, 32)

OBMC_VAR(32, 16)
OBMC_SUBPIX_VAR(32, 16)

OBMC_VAR(32, 32)
OBMC_SUBPIX_VAR(32, 32)

OBMC_VAR(32, 64)
OBMC_SUBPIX_VAR(32, 64)

OBMC_VAR(64, 32)
OBMC_SUBPIX_VAR(64, 32)

OBMC_VAR(64, 64)
OBMC_SUBPIX_VAR(64, 64)

#if CONFIG_EXT_PARTITION
OBMC_VAR(64, 128)
OBMC_SUBPIX_VAR(64, 128)

OBMC_VAR(128, 64)
OBMC_SUBPIX_VAR(128, 64)

OBMC_VAR(128, 128)
OBMC_SUBPIX_VAR(128, 128)
#endif  // CONFIG_EXT_PARTITION

1062
#if CONFIG_HIGHBITDEPTH
1063
1064
static INLINE void highbd_obmc_variance64(const uint8_t *pre8, int pre_stride,
                                          const int32_t *wsrc,
clang-format's avatar
clang-format committed
1065
                                          const int32_t *mask, int w, int h,
1066
                                          uint64_t *sse, int64_t *sum) {
1067
  int i, j;
1068
  uint16_t *pre = CONVERT_TO_SHORTPTR(pre8);
1069
1070
1071
1072
1073
1074

  *sse = 0;
  *sum = 0;

  for (i = 0; i < h; i++) {
    for (j = 0; j < w; j++) {
1075
      int diff = ROUND_POWER_OF_TWO_SIGNED(wsrc[j] - pre[j] * mask[j], 12);
1076
1077
1078
1079
      *sum += diff;
      *sse += diff * diff;
    }

1080
1081
1082
    pre += pre_stride;
    wsrc += w;
    mask += w;
1083
1084
1085
  }
}

1086
1087
static INLINE void highbd_obmc_variance(const uint8_t *pre8, int pre_stride,
                                        const int32_t *wsrc,
clang-format's avatar
clang-format committed
1088
                                        const int32_t *mask, int w, int h,
1089
                                        unsigned int *sse, int *sum) {
1090
1091
  int64_t sum64;
  uint64_t sse64;
1092
  highbd_obmc_variance64(pre8, pre_stride, wsrc, mask, w, h, &sse64, &sum64);
1093
1094
1095
1096
  *sum = (int)sum64;
  *sse = (unsigned int)sse64;
}

clang-format's avatar
clang-format committed
1097
static INLINE void highbd_10_obmc_variance(const uint8_t *pre8, int pre_stride,
1098
                                           const int32_t *wsrc,
clang-format's avatar
clang-format committed
1099
                                           const int32_t *mask, int w, int h,
1100
                                           unsigned int *sse, int *sum) {
1101
1102
  int64_t sum64;
  uint64_t sse64;
1103
  highbd_obmc_variance64(pre8, pre_stride, wsrc, mask, w, h, &sse64, &sum64);
1104
1105
1106
1107
  *sum = (int)ROUND_POWER_OF_TWO(sum64, 2);
  *sse = (unsigned int)ROUND_POWER_OF_TWO(sse64, 4);
}

clang-format's avatar
clang-format committed
1108
static INLINE void highbd_12_obmc_variance(const uint8_t *pre8, int pre_stride,
1109
                                           const int32_t *wsrc,
clang-format's avatar
clang-format committed
1110
                                           const int32_t *mask, int w, int h,
1111
                                           unsigned int *sse, int *sum) {
1112
1113
  int64_t sum64;
  uint64_t sse64;
1114
  highbd_obmc_variance64(pre8, pre_stride, wsrc, mask, w, h, &sse64, &sum64);
1115
1116
1117
1118
  *sum = (int)ROUND_POWER_OF_TWO(sum64, 4);
  *sse = (unsigned int)ROUND_POWER_OF_TWO(sse64, 8);
}

clang-format's avatar
clang-format committed
1119
#define HIGHBD_OBMC_VAR(W, H)                                              \
Yaowu Xu's avatar
Yaowu Xu committed
1120
  unsigned int aom_highbd_obmc_variance##W##x##H##_c(                      \
clang-format's avatar
clang-format committed
1121
1122
1123
1124
      const uint8_t *pre, int pre_stride, const int32_t *wsrc,             \
      const int32_t *mask, unsigned int *sse) {                            \
    int sum;                                                               \
    highbd_obmc_variance(pre, pre_stride, wsrc, mask, W, H, sse, &sum);    \
1125
    return *sse - (unsigned int)(((int64_t)sum * sum) / (W * H));          \
clang-format's avatar
clang-format committed
1126
1127
  }                                                                        \
                                                                           \
Yaowu Xu's avatar
Yaowu Xu committed
1128
  unsigned int aom_highbd_10_obmc_variance##W##x##H##_c(                   \
clang-format's avatar
clang-format committed
1129
1130
1131
      const uint8_t *pre, int pre_stride, const int32_t *wsrc,             \
      const int32_t *mask, unsigned int *sse) {                            \
    int sum;                                                               \
1132
    int64_t var;                                                           \
clang-format's avatar
clang-format committed
1133
    highbd_10_obmc_variance(pre, pre_stride, wsrc, mask, W, H, sse, &sum); \
1134
1135
    var = (int64_t)(*sse) - (((int64_t)sum * sum) / (W * H));              \
    return (var >= 0) ? (uint32_t)var : 0;                                 \
clang-format's avatar
clang-format committed
1136
1137
  }                                                                        \
                                                                           \
Yaowu Xu's avatar
Yaowu Xu committed
1138
  unsigned int aom_highbd_12_obmc_variance##W##x##H##_c(                   \
clang-format's avatar
clang-format committed
1139
1140
1141
      const uint8_t *pre, int pre_stride, const int32_t *wsrc,             \
      const int32_t *mask, unsigned int *sse) {                            \
    int sum;                                                               \
1142
    int64_t var;                                                           \
clang-format's avatar
clang-format committed
1143
    highbd_12_obmc_variance(pre, pre_stride, wsrc, mask, W, H, sse, &sum); \
1144
1145
    var = (int64_t)(*sse) - (((int64_t)sum * sum) / (W * H));              \
    return (var >= 0) ? (uint32_t)var : 0;                                 \
clang-format's avatar
clang-format committed
1146
  }
1147

clang-format's avatar
clang-format committed
1148
#define HIGHBD_OBMC_SUBPIX_VAR(W, H)                                           \
Yaowu Xu's avatar
Yaowu Xu committed
1149
  unsigned int aom_highbd_obmc_sub_pixel_variance##W##x##H##_c(                \
clang-format's avatar
clang-format committed
1150
1151
1152
1153
1154
      const uint8_t *pre, int pre_stride, int xoffset, int yoffset,            \
      const int32_t *wsrc, const int32_t *mask, unsigned int *sse) {           \
    uint16_t fdata3[(H + 1) * W];                                              \
    uint16_t temp2[H * W];                                                     \
                                                                               \
Yaowu Xu's avatar
Yaowu Xu committed
1155
    aom_highbd_var_filter_block2d_bil_first_pass(                              \
clang-format's avatar
clang-format committed
1156
        pre, fdata3, pre_stride, 1, H + 1, W, bilinear_filters_2t[xoffset]);   \
Yaowu Xu's avatar
Yaowu Xu committed
1157
    aom_highbd_var_filter_block2d_bil_second_pass(                             \
clang-format's avatar
clang-format committed
1158
1159
        fdata3, temp2, W, W, H, W, bilinear_filters_2t[yoffset]);              \
                                                                               \
Yaowu Xu's avatar
Yaowu Xu committed
1160
    return aom_highbd_obmc_variance##W##x##H##_c(CONVERT_TO_BYTEPTR(temp2), W, \
clang-format's avatar
clang-format committed
1161
1162
1163
                                                 wsrc, mask, sse);             \
  }                                                                            \
                                                                               \
Yaowu Xu's avatar
Yaowu Xu committed
1164
  unsigned int aom_highbd_10_obmc_sub_pixel_variance##W##x##H##_c(             \
clang-format's avatar
clang-format committed
1165
1166
1167
1168
1169
      const uint8_t *pre, int pre_stride, int xoffset, int yoffset,            \
      const int32_t *wsrc, const int32_t *mask, unsigned int *sse) {           \
    uint16_t fdata3[(H + 1) * W];                                              \
    uint16_t temp2[H * W];                                                     \
                                                                               \
Yaowu Xu's avatar
Yaowu Xu committed
1170
    aom_highbd_var_filter_block2d_bil_first_pass(                              \
clang-format's avatar
clang-format committed
1171
        pre, fdata3, pre_stride, 1, H + 1, W, bilinear_filters_2t[xoffset]);   \
Yaowu Xu's avatar
Yaowu Xu committed
1172
    aom_highbd_var_filter_block2d_bil_second_pass(                             \
clang-format's avatar
clang-format committed
1173
1174
        fdata3, temp2, W, W, H, W, bilinear_filters_2t[yoffset]);              \
                                                                               \
Yaowu Xu's avatar
Yaowu Xu committed
1175
    return aom_highbd_10_obmc_variance##W##x##H##_c(CONVERT_TO_BYTEPTR(temp2), \
clang-format's avatar
clang-format committed
1176
1177
1178
                                                    W, wsrc, mask, sse);       \
  }                                                                            \
                                                                               \
Yaowu Xu's avatar
Yaowu Xu committed
1179
  unsigned int aom_highbd_12_obmc_sub_pixel_variance##W##x##H##_c(             \
clang-format's avatar
clang-format committed
1180
1181
1182
1183
1184
      const uint8_t *pre, int pre_stride, int xoffset, int yoffset,            \
      const int32_t *wsrc, const int32_t *mask, unsigned int *sse) {           \
    uint16_t fdata3[(H + 1) * W];                                              \
    uint16_t temp2[H * W];                                                     \
                                                                               \
Yaowu Xu's avatar
Yaowu Xu committed
1185
    aom_highbd_var_filter_block2d_bil_first_pass(                              \
clang-format's avatar
clang-format committed
1186
        pre, fdata3, pre_stride, 1, H + 1, W, bilinear_filters_2t[xoffset]);   \
Yaowu Xu's avatar
Yaowu Xu committed
1187
    aom_highbd_var_filter_block2d_bil_second_pass(                             \
clang-format's avatar
clang-format committed
1188
1189
        fdata3, temp2, W, W, H, W, bilinear_filters_2t[yoffset]);              \
                                                                               \
Yaowu Xu's avatar
Yaowu Xu committed
1190
    return aom_highbd_12_obmc_variance##W##x##H##_c(CONVERT_TO_BYTEPTR(temp2), \
clang-format's avatar
clang-format committed
1191
1192
                                                    W, wsrc, mask, sse);       \
  }
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242

HIGHBD_OBMC_VAR(4, 4)
HIGHBD_OBMC_SUBPIX_VAR(4, 4)

HIGHBD_OBMC_VAR(4, 8)
HIGHBD_OBMC_SUBPIX_VAR(4, 8)

HIGHBD_OBMC_VAR(8, 4)
HIGHBD_OBMC_SUBPIX_VAR(8, 4)

HIGHBD_OBMC_VAR(8, 8)
HIGHBD_OBMC_SUBPIX_VAR(8, 8)

HIGHBD_OBMC_VAR(8, 16)
HIGHBD_OBMC_SUBPIX_VAR(8, 16)

HIGHBD_OBMC_VAR(16, 8)
HIGHBD_OBMC_SUBPIX_VAR(16, 8)

HIGHBD_OBMC_VAR(16, 16)
HIGHBD_OBMC_SUBPIX_VAR(16, 16)

HIGHBD_OBMC_VAR(16, 32)
HIGHBD_OBMC_SUBPIX_VAR(16, 32)

HIGHBD_OBMC_VAR(32, 16)
HIGHBD_OBMC_SUBPIX_VAR(32, 16)

HIGHBD_OBMC_VAR(32, 32)
HIGHBD_OBMC_SUBPIX_VAR(32, 32)

HIGHBD_OBMC_VAR(32, 64)
HIGHBD_OBMC_SUBPIX_VAR(32, 64)

HIGHBD_OBMC_VAR(64, 32)
HIGHBD_OBMC_SUBPIX_VAR(64, 32)

HIGHBD_OBMC_VAR(64, 64)
HIGHBD_OBMC_SUBPIX_VAR(64, 64)

#if CONFIG_EXT_PARTITION
HIGHBD_OBMC_VAR(64, 128)
HIGHBD_OBMC_SUBPIX_VAR(64, 128)

HIGHBD_OBMC_VAR(128, 64)
HIGHBD_OBMC_SUBPIX_VAR(128, 64)

HIGHBD_OBMC_VAR(128, 128)
HIGHBD_OBMC_SUBPIX_VAR(128, 128)
#endif  // CONFIG_EXT_PARTITION
1243
#endif  // CONFIG_HIGHBITDEPTH
Yue Chen's avatar
Yue Chen committed
1244
#endif  // CONFIG_AV1 && CONFIG_MOTION_VAR