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

#include <math.h>
#include <stdio.h>
#include <limits.h>

#include "./vpx_config.h"

17
#include "vp10/common/alloccommon.h"
Steinar Midtskogen's avatar
Steinar Midtskogen committed
18 19 20
#if CONFIG_CLPF
#include "vp10/common/clpf.h"
#endif
21 22 23 24 25
#include "vp10/common/filter.h"
#include "vp10/common/idct.h"
#include "vp10/common/reconinter.h"
#include "vp10/common/reconintra.h"
#include "vp10/common/tile_common.h"
Jingning Han's avatar
Jingning Han committed
26

27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
#include "vp10/encoder/aq_complexity.h"
#include "vp10/encoder/aq_cyclicrefresh.h"
#include "vp10/encoder/aq_variance.h"
#include "vp10/encoder/bitstream.h"
#include "vp10/encoder/context_tree.h"
#include "vp10/encoder/encodeframe.h"
#include "vp10/encoder/encodemv.h"
#include "vp10/encoder/encoder.h"
#include "vp10/encoder/ethread.h"
#include "vp10/encoder/firstpass.h"
#include "vp10/encoder/mbgraph.h"
#include "vp10/encoder/picklpf.h"
#include "vp10/encoder/ratectrl.h"
#include "vp10/encoder/rd.h"
#include "vp10/encoder/resize.h"
#include "vp10/encoder/segmentation.h"
#include "vp10/encoder/skin_detection.h"
#include "vp10/encoder/speed_features.h"
#include "vp10/encoder/temporal_filter.h"
Jingning Han's avatar
Jingning Han committed
46

47 48 49 50 51 52 53
#include "./vp10_rtcd.h"
#include "./vpx_dsp_rtcd.h"
#include "./vpx_scale_rtcd.h"
#include "vpx/internal/vpx_psnr.h"
#if CONFIG_INTERNAL_STATS
#include "vpx_dsp/ssim.h"
#endif
54
#include "vpx_dsp/vpx_dsp_common.h"
55 56
#include "vpx_dsp/vpx_filter.h"
#include "vpx_ports/mem.h"
57
#include "vpx_ports/system_state.h"
58 59 60
#include "vpx_ports/vpx_timer.h"
#include "vpx_scale/vpx_scale.h"

Jingning Han's avatar
Jingning Han committed
61 62 63
#define AM_SEGMENT_ID_INACTIVE 7
#define AM_SEGMENT_ID_ACTIVE 0

clang-format's avatar
clang-format committed
64 65 66 67 68 69 70 71
#define SHARP_FILTER_QTHRESH 0 /* Q threshold for 8-tap sharp filter */

#define ALTREF_HIGH_PRECISION_MV 1     // Whether to use high precision mv
                                       //  for altref computation.
#define HIGH_PRECISION_MV_QTHRESH 200  // Q threshold for high precision
                                       // mv. Choose a very high value for
                                       // now so that HIGH_PRECISION is always
                                       // chosen.
Jingning Han's avatar
Jingning Han committed
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
// #define OUTPUT_YUV_REC

#ifdef OUTPUT_YUV_DENOISED
FILE *yuv_denoised_file = NULL;
#endif
#ifdef OUTPUT_YUV_SKINMAP
FILE *yuv_skinmap_file = NULL;
#endif
#ifdef OUTPUT_YUV_REC
FILE *yuv_rec_file;
#endif

#if 0
FILE *framepsnr;
FILE *kf_list;
FILE *keyfile;
#endif

static INLINE void Scale2Ratio(VPX_SCALING mode, int *hr, int *hs) {
  switch (mode) {
    case NORMAL:
      *hr = 1;
      *hs = 1;
      break;
    case FOURFIVE:
      *hr = 4;
      *hs = 5;
      break;
    case THREEFIVE:
      *hr = 3;
      *hs = 5;
clang-format's avatar
clang-format committed
103
      break;
Jingning Han's avatar
Jingning Han committed
104 105 106
    case ONETWO:
      *hr = 1;
      *hs = 2;
clang-format's avatar
clang-format committed
107
      break;
Jingning Han's avatar
Jingning Han committed
108 109 110
    default:
      *hr = 1;
      *hs = 1;
clang-format's avatar
clang-format committed
111
      assert(0);
Jingning Han's avatar
Jingning Han committed
112 113 114 115 116 117
      break;
  }
}

// Mark all inactive blocks as active. Other segmentation features may be set
// so memset cannot be used, instead only inactive blocks should be reset.
Yaowu Xu's avatar
Yaowu Xu committed
118
static void suppress_active_map(VP10_COMP *cpi) {
Jingning Han's avatar
Jingning Han committed
119 120 121 122 123 124 125 126
  unsigned char *const seg_map = cpi->segmentation_map;
  int i;
  if (cpi->active_map.enabled || cpi->active_map.update)
    for (i = 0; i < cpi->common.mi_rows * cpi->common.mi_cols; ++i)
      if (seg_map[i] == AM_SEGMENT_ID_INACTIVE)
        seg_map[i] = AM_SEGMENT_ID_ACTIVE;
}

Yaowu Xu's avatar
Yaowu Xu committed
127
static void apply_active_map(VP10_COMP *cpi) {
Jingning Han's avatar
Jingning Han committed
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
  struct segmentation *const seg = &cpi->common.seg;
  unsigned char *const seg_map = cpi->segmentation_map;
  const unsigned char *const active_map = cpi->active_map.map;
  int i;

  assert(AM_SEGMENT_ID_ACTIVE == CR_SEGMENT_ID_BASE);

  if (frame_is_intra_only(&cpi->common)) {
    cpi->active_map.enabled = 0;
    cpi->active_map.update = 1;
  }

  if (cpi->active_map.update) {
    if (cpi->active_map.enabled) {
      for (i = 0; i < cpi->common.mi_rows * cpi->common.mi_cols; ++i)
        if (seg_map[i] == AM_SEGMENT_ID_ACTIVE) seg_map[i] = active_map[i];
      vp10_enable_segmentation(seg);
      vp10_enable_segfeature(seg, AM_SEGMENT_ID_INACTIVE, SEG_LVL_SKIP);
      vp10_enable_segfeature(seg, AM_SEGMENT_ID_INACTIVE, SEG_LVL_ALT_LF);
      // Setting the data to -MAX_LOOP_FILTER will result in the computed loop
      // filter level being zero regardless of the value of seg->abs_delta.
clang-format's avatar
clang-format committed
149 150
      vp10_set_segdata(seg, AM_SEGMENT_ID_INACTIVE, SEG_LVL_ALT_LF,
                       -MAX_LOOP_FILTER);
Jingning Han's avatar
Jingning Han committed
151 152 153 154 155 156 157 158 159 160 161 162
    } else {
      vp10_disable_segfeature(seg, AM_SEGMENT_ID_INACTIVE, SEG_LVL_SKIP);
      vp10_disable_segfeature(seg, AM_SEGMENT_ID_INACTIVE, SEG_LVL_ALT_LF);
      if (seg->enabled) {
        seg->update_data = 1;
        seg->update_map = 1;
      }
    }
    cpi->active_map.update = 0;
  }
}

clang-format's avatar
clang-format committed
163 164
int vp10_set_active_map(VP10_COMP *cpi, unsigned char *new_map_16x16, int rows,
                        int cols) {
Jingning Han's avatar
Jingning Han committed
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
  if (rows == cpi->common.mb_rows && cols == cpi->common.mb_cols) {
    unsigned char *const active_map_8x8 = cpi->active_map.map;
    const int mi_rows = cpi->common.mi_rows;
    const int mi_cols = cpi->common.mi_cols;
    cpi->active_map.update = 1;
    if (new_map_16x16) {
      int r, c;
      for (r = 0; r < mi_rows; ++r) {
        for (c = 0; c < mi_cols; ++c) {
          active_map_8x8[r * mi_cols + c] =
              new_map_16x16[(r >> 1) * cols + (c >> 1)]
                  ? AM_SEGMENT_ID_ACTIVE
                  : AM_SEGMENT_ID_INACTIVE;
        }
      }
      cpi->active_map.enabled = 1;
    } else {
      cpi->active_map.enabled = 0;
    }
    return 0;
  } else {
    return -1;
  }
}

clang-format's avatar
clang-format committed
190 191
int vp10_get_active_map(VP10_COMP *cpi, unsigned char *new_map_16x16, int rows,
                        int cols) {
Jingning Han's avatar
Jingning Han committed
192 193
  if (rows == cpi->common.mb_rows && cols == cpi->common.mb_cols &&
      new_map_16x16) {
clang-format's avatar
clang-format committed
194
    unsigned char *const seg_map_8x8 = cpi->segmentation_map;
Jingning Han's avatar
Jingning Han committed
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214
    const int mi_rows = cpi->common.mi_rows;
    const int mi_cols = cpi->common.mi_cols;
    memset(new_map_16x16, !cpi->active_map.enabled, rows * cols);
    if (cpi->active_map.enabled) {
      int r, c;
      for (r = 0; r < mi_rows; ++r) {
        for (c = 0; c < mi_cols; ++c) {
          // Cyclic refresh segments are considered active despite not having
          // AM_SEGMENT_ID_ACTIVE
          new_map_16x16[(r >> 1) * cols + (c >> 1)] |=
              seg_map_8x8[r * mi_cols + c] != AM_SEGMENT_ID_INACTIVE;
        }
      }
    }
    return 0;
  } else {
    return -1;
  }
}

Yaowu Xu's avatar
Yaowu Xu committed
215
void vp10_set_high_precision_mv(VP10_COMP *cpi, int allow_high_precision_mv) {
Jingning Han's avatar
Jingning Han committed
216 217 218 219 220 221 222 223 224 225 226
  MACROBLOCK *const mb = &cpi->td.mb;
  cpi->common.allow_high_precision_mv = allow_high_precision_mv;
  if (cpi->common.allow_high_precision_mv) {
    mb->mvcost = mb->nmvcost_hp;
    mb->mvsadcost = mb->nmvsadcost_hp;
  } else {
    mb->mvcost = mb->nmvcost;
    mb->mvsadcost = mb->nmvsadcost;
  }
}

Yaowu Xu's avatar
Yaowu Xu committed
227
static void setup_frame(VP10_COMP *cpi) {
Yaowu Xu's avatar
Yaowu Xu committed
228
  VP10_COMMON *const cm = &cpi->common;
Jingning Han's avatar
Jingning Han committed
229 230 231 232 233 234 235 236
  // Set up entropy context depending on frame type. The decoder mandates
  // the use of the default context, index 0, for keyframes and inter
  // frames where the error_resilient_mode or intra_only flag is set. For
  // other inter-frames the encoder currently uses only two contexts;
  // context 1 for ALTREF frames and context 0 for the others.
  if (frame_is_intra_only(cm) || cm->error_resilient_mode) {
    vp10_setup_past_independence(cm);
  } else {
Yunqing Wang's avatar
Yunqing Wang committed
237
    cm->frame_context_idx = cpi->refresh_alt_ref_frame;
Jingning Han's avatar
Jingning Han committed
238 239 240
  }

  if (cm->frame_type == KEY_FRAME) {
Yunqing Wang's avatar
Yunqing Wang committed
241
    cpi->refresh_golden_frame = 1;
Jingning Han's avatar
Jingning Han committed
242 243 244 245 246 247 248 249
    cpi->refresh_alt_ref_frame = 1;
    vp10_zero(cpi->interp_filter_selected);
  } else {
    *cm->fc = cm->frame_contexts[cm->frame_context_idx];
    vp10_zero(cpi->interp_filter_selected[0]);
  }
}

Yaowu Xu's avatar
Yaowu Xu committed
250
static void vp10_enc_setup_mi(VP10_COMMON *cm) {
Jingning Han's avatar
Jingning Han committed
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267
  int i;
  cm->mi = cm->mip + cm->mi_stride + 1;
  memset(cm->mip, 0, cm->mi_stride * (cm->mi_rows + 1) * sizeof(*cm->mip));
  cm->prev_mi = cm->prev_mip + cm->mi_stride + 1;
  // Clear top border row
  memset(cm->prev_mip, 0, sizeof(*cm->prev_mip) * cm->mi_stride);
  // Clear left border column
  for (i = 1; i < cm->mi_rows + 1; ++i)
    memset(&cm->prev_mip[i * cm->mi_stride], 0, sizeof(*cm->prev_mip));

  cm->mi_grid_visible = cm->mi_grid_base + cm->mi_stride + 1;
  cm->prev_mi_grid_visible = cm->prev_mi_grid_base + cm->mi_stride + 1;

  memset(cm->mi_grid_base, 0,
         cm->mi_stride * (cm->mi_rows + 1) * sizeof(*cm->mi_grid_base));
}

Yaowu Xu's avatar
Yaowu Xu committed
268
static int vp10_enc_alloc_mi(VP10_COMMON *cm, int mi_size) {
Jingning Han's avatar
Jingning Han committed
269
  cm->mip = vpx_calloc(mi_size, sizeof(*cm->mip));
clang-format's avatar
clang-format committed
270
  if (!cm->mip) return 1;
Jingning Han's avatar
Jingning Han committed
271
  cm->prev_mip = vpx_calloc(mi_size, sizeof(*cm->prev_mip));
clang-format's avatar
clang-format committed
272
  if (!cm->prev_mip) return 1;
Jingning Han's avatar
Jingning Han committed
273 274
  cm->mi_alloc_size = mi_size;

clang-format's avatar
clang-format committed
275 276 277 278 279
  cm->mi_grid_base = (MODE_INFO **)vpx_calloc(mi_size, sizeof(MODE_INFO *));
  if (!cm->mi_grid_base) return 1;
  cm->prev_mi_grid_base =
      (MODE_INFO **)vpx_calloc(mi_size, sizeof(MODE_INFO *));
  if (!cm->prev_mi_grid_base) return 1;
Jingning Han's avatar
Jingning Han committed
280 281 282 283

  return 0;
}

Yaowu Xu's avatar
Yaowu Xu committed
284
static void vp10_enc_free_mi(VP10_COMMON *cm) {
Jingning Han's avatar
Jingning Han committed
285 286 287 288 289 290 291 292 293 294
  vpx_free(cm->mip);
  cm->mip = NULL;
  vpx_free(cm->prev_mip);
  cm->prev_mip = NULL;
  vpx_free(cm->mi_grid_base);
  cm->mi_grid_base = NULL;
  vpx_free(cm->prev_mi_grid_base);
  cm->prev_mi_grid_base = NULL;
}

Yaowu Xu's avatar
Yaowu Xu committed
295
static void vp10_swap_mi_and_prev_mi(VP10_COMMON *cm) {
Jingning Han's avatar
Jingning Han committed
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 321 322 323
  // Current mip will be the prev_mip for the next frame.
  MODE_INFO **temp_base = cm->prev_mi_grid_base;
  MODE_INFO *temp = cm->prev_mip;
  cm->prev_mip = cm->mip;
  cm->mip = temp;

  // Update the upper left visible macroblock ptrs.
  cm->mi = cm->mip + cm->mi_stride + 1;
  cm->prev_mi = cm->prev_mip + cm->mi_stride + 1;

  cm->prev_mi_grid_base = cm->mi_grid_base;
  cm->mi_grid_base = temp_base;
  cm->mi_grid_visible = cm->mi_grid_base + cm->mi_stride + 1;
  cm->prev_mi_grid_visible = cm->prev_mi_grid_base + cm->mi_stride + 1;
}

void vp10_initialize_enc(void) {
  static volatile int init_done = 0;

  if (!init_done) {
    vp10_rtcd();
    vpx_dsp_rtcd();
    vpx_scale_rtcd();
    vp10_init_intra_predictors();
    vp10_init_me_luts();
    vp10_rc_init_minq_luts();
    vp10_entropy_mv_init();
    vp10_temporal_filter_init();
324
    vp10_encode_token_init();
Jingning Han's avatar
Jingning Han committed
325 326 327 328
    init_done = 1;
  }
}

Yaowu Xu's avatar
Yaowu Xu committed
329
static void dealloc_compressor_data(VP10_COMP *cpi) {
Yaowu Xu's avatar
Yaowu Xu committed
330
  VP10_COMMON *const cm = &cpi->common;
Jingning Han's avatar
Jingning Han committed
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372

  vpx_free(cpi->mbmi_ext_base);
  cpi->mbmi_ext_base = NULL;

  vpx_free(cpi->tile_data);
  cpi->tile_data = NULL;

  // Delete sementation map
  vpx_free(cpi->segmentation_map);
  cpi->segmentation_map = NULL;
  vpx_free(cpi->coding_context.last_frame_seg_map_copy);
  cpi->coding_context.last_frame_seg_map_copy = NULL;

  vpx_free(cpi->nmvcosts[0]);
  vpx_free(cpi->nmvcosts[1]);
  cpi->nmvcosts[0] = NULL;
  cpi->nmvcosts[1] = NULL;

  vpx_free(cpi->nmvcosts_hp[0]);
  vpx_free(cpi->nmvcosts_hp[1]);
  cpi->nmvcosts_hp[0] = NULL;
  cpi->nmvcosts_hp[1] = NULL;

  vpx_free(cpi->nmvsadcosts[0]);
  vpx_free(cpi->nmvsadcosts[1]);
  cpi->nmvsadcosts[0] = NULL;
  cpi->nmvsadcosts[1] = NULL;

  vpx_free(cpi->nmvsadcosts_hp[0]);
  vpx_free(cpi->nmvsadcosts_hp[1]);
  cpi->nmvsadcosts_hp[0] = NULL;
  cpi->nmvsadcosts_hp[1] = NULL;

  vp10_cyclic_refresh_free(cpi->cyclic_refresh);
  cpi->cyclic_refresh = NULL;

  vpx_free(cpi->active_map.map);
  cpi->active_map.map = NULL;

  vp10_free_ref_frame_buffers(cm->buffer_pool);
  vp10_free_context_buffers(cm);

373 374 375 376
  vpx_free_frame_buffer(&cpi->last_frame_uf);
  vpx_free_frame_buffer(&cpi->scaled_source);
  vpx_free_frame_buffer(&cpi->scaled_last_source);
  vpx_free_frame_buffer(&cpi->alt_ref_buffer);
Jingning Han's avatar
Jingning Han committed
377 378 379 380 381 382 383 384 385 386 387 388 389
  vp10_lookahead_destroy(cpi->lookahead);

  vpx_free(cpi->tile_tok[0][0]);
  cpi->tile_tok[0][0] = 0;

  vp10_free_pc_tree(&cpi->td);

  if (cpi->source_diff_var != NULL) {
    vpx_free(cpi->source_diff_var);
    cpi->source_diff_var = NULL;
  }
}

Yaowu Xu's avatar
Yaowu Xu committed
390
static void save_coding_context(VP10_COMP *cpi) {
Jingning Han's avatar
Jingning Han committed
391
  CODING_CONTEXT *const cc = &cpi->coding_context;
Yaowu Xu's avatar
Yaowu Xu committed
392
  VP10_COMMON *cm = &cpi->common;
Jingning Han's avatar
Jingning Han committed
393 394 395 396 397

  // Stores a snapshot of key state variables which can subsequently be
  // restored with a call to vp10_restore_coding_context. These functions are
  // intended for use in a re-code loop in vp10_compress_frame where the
  // quantizer value is adjusted between loop iterations.
clang-format's avatar
clang-format committed
398
  vp10_copy(cc->nmvjointcost, cpi->td.mb.nmvjointcost);
Jingning Han's avatar
Jingning Han committed
399 400 401 402 403 404 405 406 407 408

  memcpy(cc->nmvcosts[0], cpi->nmvcosts[0],
         MV_VALS * sizeof(*cpi->nmvcosts[0]));
  memcpy(cc->nmvcosts[1], cpi->nmvcosts[1],
         MV_VALS * sizeof(*cpi->nmvcosts[1]));
  memcpy(cc->nmvcosts_hp[0], cpi->nmvcosts_hp[0],
         MV_VALS * sizeof(*cpi->nmvcosts_hp[0]));
  memcpy(cc->nmvcosts_hp[1], cpi->nmvcosts_hp[1],
         MV_VALS * sizeof(*cpi->nmvcosts_hp[1]));

409 410 411
#if !CONFIG_MISC_FIXES
  vp10_copy(cc->segment_pred_probs, cm->segp.pred_probs);
#endif
Jingning Han's avatar
Jingning Han committed
412

clang-format's avatar
clang-format committed
413 414
  memcpy(cpi->coding_context.last_frame_seg_map_copy, cm->last_frame_seg_map,
         (cm->mi_rows * cm->mi_cols));
Jingning Han's avatar
Jingning Han committed
415 416 417 418 419 420 421

  vp10_copy(cc->last_ref_lf_deltas, cm->lf.last_ref_deltas);
  vp10_copy(cc->last_mode_lf_deltas, cm->lf.last_mode_deltas);

  cc->fc = *cm->fc;
}

Yaowu Xu's avatar
Yaowu Xu committed
422
static void restore_coding_context(VP10_COMP *cpi) {
Jingning Han's avatar
Jingning Han committed
423
  CODING_CONTEXT *const cc = &cpi->coding_context;
Yaowu Xu's avatar
Yaowu Xu committed
424
  VP10_COMMON *cm = &cpi->common;
Jingning Han's avatar
Jingning Han committed
425 426 427 428 429 430 431 432 433 434 435 436

  // Restore key state variables to the snapshot state stored in the
  // previous call to vp10_save_coding_context.
  vp10_copy(cpi->td.mb.nmvjointcost, cc->nmvjointcost);

  memcpy(cpi->nmvcosts[0], cc->nmvcosts[0], MV_VALS * sizeof(*cc->nmvcosts[0]));
  memcpy(cpi->nmvcosts[1], cc->nmvcosts[1], MV_VALS * sizeof(*cc->nmvcosts[1]));
  memcpy(cpi->nmvcosts_hp[0], cc->nmvcosts_hp[0],
         MV_VALS * sizeof(*cc->nmvcosts_hp[0]));
  memcpy(cpi->nmvcosts_hp[1], cc->nmvcosts_hp[1],
         MV_VALS * sizeof(*cc->nmvcosts_hp[1]));

437 438 439
#if !CONFIG_MISC_FIXES
  vp10_copy(cm->segp.pred_probs, cc->segment_pred_probs);
#endif
Jingning Han's avatar
Jingning Han committed
440

clang-format's avatar
clang-format committed
441
  memcpy(cm->last_frame_seg_map, cpi->coding_context.last_frame_seg_map_copy,
Jingning Han's avatar
Jingning Han committed
442 443 444 445 446 447 448 449
         (cm->mi_rows * cm->mi_cols));

  vp10_copy(cm->lf.last_ref_deltas, cc->last_ref_lf_deltas);
  vp10_copy(cm->lf.last_mode_deltas, cc->last_mode_lf_deltas);

  *cm->fc = cc->fc;
}

Yaowu Xu's avatar
Yaowu Xu committed
450
static void configure_static_seg_features(VP10_COMP *cpi) {
Yaowu Xu's avatar
Yaowu Xu committed
451
  VP10_COMMON *const cm = &cpi->common;
Jingning Han's avatar
Jingning Han committed
452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492
  const RATE_CONTROL *const rc = &cpi->rc;
  struct segmentation *const seg = &cm->seg;

  int high_q = (int)(rc->avg_q > 48.0);
  int qi_delta;

  // Disable and clear down for KF
  if (cm->frame_type == KEY_FRAME) {
    // Clear down the global segmentation map
    memset(cpi->segmentation_map, 0, cm->mi_rows * cm->mi_cols);
    seg->update_map = 0;
    seg->update_data = 0;
    cpi->static_mb_pct = 0;

    // Disable segmentation
    vp10_disable_segmentation(seg);

    // Clear down the segment features.
    vp10_clearall_segfeatures(seg);
  } else if (cpi->refresh_alt_ref_frame) {
    // If this is an alt ref frame
    // Clear down the global segmentation map
    memset(cpi->segmentation_map, 0, cm->mi_rows * cm->mi_cols);
    seg->update_map = 0;
    seg->update_data = 0;
    cpi->static_mb_pct = 0;

    // Disable segmentation and individual segment features by default
    vp10_disable_segmentation(seg);
    vp10_clearall_segfeatures(seg);

    // Scan frames from current to arf frame.
    // This function re-enables segmentation if appropriate.
    vp10_update_mbgraph_stats(cpi);

    // If segmentation was enabled set those features needed for the
    // arf itself.
    if (seg->enabled) {
      seg->update_map = 1;
      seg->update_data = 1;

clang-format's avatar
clang-format committed
493 494
      qi_delta =
          vp10_compute_qdelta(rc, rc->avg_q, rc->avg_q * 0.875, cm->bit_depth);
Jingning Han's avatar
Jingning Han committed
495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515
      vp10_set_segdata(seg, 1, SEG_LVL_ALT_Q, qi_delta - 2);
      vp10_set_segdata(seg, 1, SEG_LVL_ALT_LF, -2);

      vp10_enable_segfeature(seg, 1, SEG_LVL_ALT_Q);
      vp10_enable_segfeature(seg, 1, SEG_LVL_ALT_LF);

      // Where relevant assume segment data is delta data
      seg->abs_delta = SEGMENT_DELTADATA;
    }
  } else if (seg->enabled) {
    // All other frames if segmentation has been enabled

    // First normal frame in a valid gf or alt ref group
    if (rc->frames_since_golden == 0) {
      // Set up segment features for normal frames in an arf group
      if (rc->source_alt_ref_active) {
        seg->update_map = 0;
        seg->update_data = 1;
        seg->abs_delta = SEGMENT_DELTADATA;

        qi_delta = vp10_compute_qdelta(rc, rc->avg_q, rc->avg_q * 1.125,
clang-format's avatar
clang-format committed
516
                                       cm->bit_depth);
Jingning Han's avatar
Jingning Han committed
517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573
        vp10_set_segdata(seg, 1, SEG_LVL_ALT_Q, qi_delta + 2);
        vp10_enable_segfeature(seg, 1, SEG_LVL_ALT_Q);

        vp10_set_segdata(seg, 1, SEG_LVL_ALT_LF, -2);
        vp10_enable_segfeature(seg, 1, SEG_LVL_ALT_LF);

        // Segment coding disabled for compred testing
        if (high_q || (cpi->static_mb_pct == 100)) {
          vp10_set_segdata(seg, 1, SEG_LVL_REF_FRAME, ALTREF_FRAME);
          vp10_enable_segfeature(seg, 1, SEG_LVL_REF_FRAME);
          vp10_enable_segfeature(seg, 1, SEG_LVL_SKIP);
        }
      } else {
        // Disable segmentation and clear down features if alt ref
        // is not active for this group

        vp10_disable_segmentation(seg);

        memset(cpi->segmentation_map, 0, cm->mi_rows * cm->mi_cols);

        seg->update_map = 0;
        seg->update_data = 0;

        vp10_clearall_segfeatures(seg);
      }
    } else if (rc->is_src_frame_alt_ref) {
      // Special case where we are coding over the top of a previous
      // alt ref frame.
      // Segment coding disabled for compred testing

      // Enable ref frame features for segment 0 as well
      vp10_enable_segfeature(seg, 0, SEG_LVL_REF_FRAME);
      vp10_enable_segfeature(seg, 1, SEG_LVL_REF_FRAME);

      // All mbs should use ALTREF_FRAME
      vp10_clear_segdata(seg, 0, SEG_LVL_REF_FRAME);
      vp10_set_segdata(seg, 0, SEG_LVL_REF_FRAME, ALTREF_FRAME);
      vp10_clear_segdata(seg, 1, SEG_LVL_REF_FRAME);
      vp10_set_segdata(seg, 1, SEG_LVL_REF_FRAME, ALTREF_FRAME);

      // Skip all MBs if high Q (0,0 mv and skip coeffs)
      if (high_q) {
        vp10_enable_segfeature(seg, 0, SEG_LVL_SKIP);
        vp10_enable_segfeature(seg, 1, SEG_LVL_SKIP);
      }
      // Enable data update
      seg->update_data = 1;
    } else {
      // All other frames.

      // No updates.. leave things as they are.
      seg->update_map = 0;
      seg->update_data = 0;
    }
  }
}

Yaowu Xu's avatar
Yaowu Xu committed
574
static void update_reference_segmentation_map(VP10_COMP *cpi) {
Yaowu Xu's avatar
Yaowu Xu committed
575
  VP10_COMMON *const cm = &cpi->common;
Jingning Han's avatar
Jingning Han committed
576 577 578 579 580 581 582 583 584 585 586 587 588 589
  MODE_INFO **mi_8x8_ptr = cm->mi_grid_visible;
  uint8_t *cache_ptr = cm->last_frame_seg_map;
  int row, col;

  for (row = 0; row < cm->mi_rows; row++) {
    MODE_INFO **mi_8x8 = mi_8x8_ptr;
    uint8_t *cache = cache_ptr;
    for (col = 0; col < cm->mi_cols; col++, mi_8x8++, cache++)
      cache[0] = mi_8x8[0]->mbmi.segment_id;
    mi_8x8_ptr += cm->mi_stride;
    cache_ptr += cm->mi_cols;
  }
}

Yaowu Xu's avatar
Yaowu Xu committed
590
static void alloc_raw_frame_buffers(VP10_COMP *cpi) {
Yaowu Xu's avatar
Yaowu Xu committed
591
  VP10_COMMON *cm = &cpi->common;
hui su's avatar
hui su committed
592
  const VP10EncoderConfig *oxcf = &cpi->oxcf;
Jingning Han's avatar
Jingning Han committed
593 594 595

  if (!cpi->lookahead)
    cpi->lookahead = vp10_lookahead_init(oxcf->width, oxcf->height,
clang-format's avatar
clang-format committed
596
                                         cm->subsampling_x, cm->subsampling_y,
597
#if CONFIG_VPX_HIGHBITDEPTH
clang-format's avatar
clang-format committed
598
                                         cm->use_highbitdepth,
Jingning Han's avatar
Jingning Han committed
599
#endif
clang-format's avatar
clang-format committed
600
                                         oxcf->lag_in_frames);
Jingning Han's avatar
Jingning Han committed
601 602 603 604 605
  if (!cpi->lookahead)
    vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR,
                       "Failed to allocate lag buffers");

  // TODO(agrange) Check if ARF is enabled and skip allocation if not.
clang-format's avatar
clang-format committed
606
  if (vpx_realloc_frame_buffer(&cpi->alt_ref_buffer, oxcf->width, oxcf->height,
Jingning Han's avatar
Jingning Han committed
607
                               cm->subsampling_x, cm->subsampling_y,
608
#if CONFIG_VPX_HIGHBITDEPTH
Jingning Han's avatar
Jingning Han committed
609 610
                               cm->use_highbitdepth,
#endif
Yaowu Xu's avatar
Yaowu Xu committed
611
                               VPX_ENC_BORDER_IN_PIXELS, cm->byte_alignment,
Jingning Han's avatar
Jingning Han committed
612 613 614 615 616
                               NULL, NULL, NULL))
    vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR,
                       "Failed to allocate altref buffer");
}

Yaowu Xu's avatar
Yaowu Xu committed
617
static void alloc_util_frame_buffers(VP10_COMP *cpi) {
Yaowu Xu's avatar
Yaowu Xu committed
618
  VP10_COMMON *const cm = &cpi->common;
clang-format's avatar
clang-format committed
619
  if (vpx_realloc_frame_buffer(&cpi->last_frame_uf, cm->width, cm->height,
Jingning Han's avatar
Jingning Han committed
620
                               cm->subsampling_x, cm->subsampling_y,
621
#if CONFIG_VPX_HIGHBITDEPTH
Jingning Han's avatar
Jingning Han committed
622 623
                               cm->use_highbitdepth,
#endif
Yaowu Xu's avatar
Yaowu Xu committed
624
                               VPX_ENC_BORDER_IN_PIXELS, cm->byte_alignment,
Jingning Han's avatar
Jingning Han committed
625 626 627 628
                               NULL, NULL, NULL))
    vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR,
                       "Failed to allocate last frame buffer");

clang-format's avatar
clang-format committed
629
  if (vpx_realloc_frame_buffer(&cpi->scaled_source, cm->width, cm->height,
Jingning Han's avatar
Jingning Han committed
630
                               cm->subsampling_x, cm->subsampling_y,
631
#if CONFIG_VPX_HIGHBITDEPTH
Jingning Han's avatar
Jingning Han committed
632 633
                               cm->use_highbitdepth,
#endif
Yaowu Xu's avatar
Yaowu Xu committed
634
                               VPX_ENC_BORDER_IN_PIXELS, cm->byte_alignment,
Jingning Han's avatar
Jingning Han committed
635 636 637 638
                               NULL, NULL, NULL))
    vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR,
                       "Failed to allocate scaled source buffer");

clang-format's avatar
clang-format committed
639
  if (vpx_realloc_frame_buffer(&cpi->scaled_last_source, cm->width, cm->height,
Jingning Han's avatar
Jingning Han committed
640
                               cm->subsampling_x, cm->subsampling_y,
641
#if CONFIG_VPX_HIGHBITDEPTH
Jingning Han's avatar
Jingning Han committed
642 643
                               cm->use_highbitdepth,
#endif
Yaowu Xu's avatar
Yaowu Xu committed
644
                               VPX_ENC_BORDER_IN_PIXELS, cm->byte_alignment,
Jingning Han's avatar
Jingning Han committed
645 646 647 648 649
                               NULL, NULL, NULL))
    vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR,
                       "Failed to allocate scaled last source buffer");
}

Yaowu Xu's avatar
Yaowu Xu committed
650
static int alloc_context_buffers_ext(VP10_COMP *cpi) {
Yaowu Xu's avatar
Yaowu Xu committed
651
  VP10_COMMON *cm = &cpi->common;
Jingning Han's avatar
Jingning Han committed
652 653 654
  int mi_size = cm->mi_cols * cm->mi_rows;

  cpi->mbmi_ext_base = vpx_calloc(mi_size, sizeof(*cpi->mbmi_ext_base));
clang-format's avatar
clang-format committed
655
  if (!cpi->mbmi_ext_base) return 1;
Jingning Han's avatar
Jingning Han committed
656 657 658 659

  return 0;
}

Yaowu Xu's avatar
Yaowu Xu committed
660
void vp10_alloc_compressor_data(VP10_COMP *cpi) {
Yaowu Xu's avatar
Yaowu Xu committed
661
  VP10_COMMON *cm = &cpi->common;
Jingning Han's avatar
Jingning Han committed
662 663 664 665 666 667 668 669 670 671

  vp10_alloc_context_buffers(cm, cm->width, cm->height);

  alloc_context_buffers_ext(cpi);

  vpx_free(cpi->tile_tok[0][0]);

  {
    unsigned int tokens = get_token_alloc(cm->mb_rows, cm->mb_cols);
    CHECK_MEM_ERROR(cm, cpi->tile_tok[0][0],
clang-format's avatar
clang-format committed
672
                    vpx_calloc(tokens, sizeof(*cpi->tile_tok[0][0])));
Jingning Han's avatar
Jingning Han committed
673 674 675 676 677
  }

  vp10_setup_pc_tree(&cpi->common, &cpi->td);
}

Yaowu Xu's avatar
Yaowu Xu committed
678
void vp10_new_framerate(VP10_COMP *cpi, double framerate) {
Jingning Han's avatar
Jingning Han committed
679 680 681 682
  cpi->framerate = framerate < 0.1 ? 30 : framerate;
  vp10_rc_update_framerate(cpi);
}

Yaowu Xu's avatar
Yaowu Xu committed
683
static void set_tile_limits(VP10_COMP *cpi) {
Yaowu Xu's avatar
Yaowu Xu committed
684
  VP10_COMMON *const cm = &cpi->common;
Jingning Han's avatar
Jingning Han committed
685 686 687 688

  int min_log2_tile_cols, max_log2_tile_cols;
  vp10_get_tile_n_bits(cm->mi_cols, &min_log2_tile_cols, &max_log2_tile_cols);

clang-format's avatar
clang-format committed
689 690
  cm->log2_tile_cols =
      clamp(cpi->oxcf.tile_columns, min_log2_tile_cols, max_log2_tile_cols);
Yunqing Wang's avatar
Yunqing Wang committed
691
  cm->log2_tile_rows = cpi->oxcf.tile_rows;
Jingning Han's avatar
Jingning Han committed
692 693
}

Yaowu Xu's avatar
Yaowu Xu committed
694
static void update_frame_size(VP10_COMP *cpi) {
Yaowu Xu's avatar
Yaowu Xu committed
695
  VP10_COMMON *const cm = &cpi->common;
Jingning Han's avatar
Jingning Han committed
696 697 698 699 700 701 702 703 704 705 706
  MACROBLOCKD *const xd = &cpi->td.mb.e_mbd;

  vp10_set_mb_mi(cm, cm->width, cm->height);
  vp10_init_context_buffers(cm);
  vp10_init_macroblockd(cm, xd, NULL);
  memset(cpi->mbmi_ext_base, 0,
         cm->mi_rows * cm->mi_cols * sizeof(*cpi->mbmi_ext_base));

  set_tile_limits(cpi);
}

Yaowu Xu's avatar
Yaowu Xu committed
707
static void init_buffer_indices(VP10_COMP *cpi) {
Jingning Han's avatar
Jingning Han committed
708 709 710 711 712
  cpi->lst_fb_idx = 0;
  cpi->gld_fb_idx = 1;
  cpi->alt_fb_idx = 2;
}

hui su's avatar
hui su committed
713
static void init_config(struct VP10_COMP *cpi, VP10EncoderConfig *oxcf) {
Yaowu Xu's avatar
Yaowu Xu committed
714
  VP10_COMMON *const cm = &cpi->common;
Jingning Han's avatar
Jingning Han committed
715 716 717 718 719 720

  cpi->oxcf = *oxcf;
  cpi->framerate = oxcf->init_framerate;

  cm->profile = oxcf->profile;
  cm->bit_depth = oxcf->bit_depth;
721
#if CONFIG_VPX_HIGHBITDEPTH
Jingning Han's avatar
Jingning Han committed
722 723 724
  cm->use_highbitdepth = oxcf->use_highbitdepth;
#endif
  cm->color_space = oxcf->color_space;
725
  cm->color_range = oxcf->color_range;
Jingning Han's avatar
Jingning Han committed
726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743

  cm->width = oxcf->width;
  cm->height = oxcf->height;
  vp10_alloc_compressor_data(cpi);

  // Single thread case: use counts in common.
  cpi->td.counts = &cm->counts;

  // change includes all joint functionality
  vp10_change_config(cpi, oxcf);

  cpi->static_mb_pct = 0;
  cpi->ref_frame_flags = 0;

  init_buffer_indices(cpi);
}

static void set_rc_buffer_sizes(RATE_CONTROL *rc,
hui su's avatar
hui su committed
744
                                const VP10EncoderConfig *oxcf) {
Jingning Han's avatar
Jingning Han committed
745 746 747 748 749 750
  const int64_t bandwidth = oxcf->target_bandwidth;
  const int64_t starting = oxcf->starting_buffer_level_ms;
  const int64_t optimal = oxcf->optimal_buffer_level_ms;
  const int64_t maximum = oxcf->maximum_buffer_size_ms;

  rc->starting_buffer_level = starting * bandwidth / 1000;
clang-format's avatar
clang-format committed
751 752 753 754
  rc->optimal_buffer_level =
      (optimal == 0) ? bandwidth / 8 : optimal * bandwidth / 1000;
  rc->maximum_buffer_size =
      (maximum == 0) ? bandwidth / 8 : maximum * bandwidth / 1000;
Jingning Han's avatar
Jingning Han committed
755 756
}

757
#if CONFIG_VPX_HIGHBITDEPTH
Jingning Han's avatar
Jingning Han committed
758
#define HIGHBD_BFP(BT, SDF, SDAF, VF, SVF, SVAF, SDX3F, SDX8F, SDX4DF) \
clang-format's avatar
clang-format committed
759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866
  cpi->fn_ptr[BT].sdf = SDF;                                           \
  cpi->fn_ptr[BT].sdaf = SDAF;                                         \
  cpi->fn_ptr[BT].vf = VF;                                             \
  cpi->fn_ptr[BT].svf = SVF;                                           \
  cpi->fn_ptr[BT].svaf = SVAF;                                         \
  cpi->fn_ptr[BT].sdx3f = SDX3F;                                       \
  cpi->fn_ptr[BT].sdx8f = SDX8F;                                       \
  cpi->fn_ptr[BT].sdx4df = SDX4DF;

#define MAKE_BFP_SAD_WRAPPER(fnname)                                           \
  static unsigned int fnname##_bits8(const uint8_t *src_ptr,                   \
                                     int source_stride,                        \
                                     const uint8_t *ref_ptr, int ref_stride) { \
    return fnname(src_ptr, source_stride, ref_ptr, ref_stride);                \
  }                                                                            \
  static unsigned int fnname##_bits10(                                         \
      const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr,       \
      int ref_stride) {                                                        \
    return fnname(src_ptr, source_stride, ref_ptr, ref_stride) >> 2;           \
  }                                                                            \
  static unsigned int fnname##_bits12(                                         \
      const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr,       \
      int ref_stride) {                                                        \
    return fnname(src_ptr, source_stride, ref_ptr, ref_stride) >> 4;           \
  }

#define MAKE_BFP_SADAVG_WRAPPER(fnname)                                        \
  static unsigned int fnname##_bits8(                                          \
      const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr,       \
      int ref_stride, const uint8_t *second_pred) {                            \
    return fnname(src_ptr, source_stride, ref_ptr, ref_stride, second_pred);   \
  }                                                                            \
  static unsigned int fnname##_bits10(                                         \
      const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr,       \
      int ref_stride, const uint8_t *second_pred) {                            \
    return fnname(src_ptr, source_stride, ref_ptr, ref_stride, second_pred) >> \
           2;                                                                  \
  }                                                                            \
  static unsigned int fnname##_bits12(                                         \
      const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr,       \
      int ref_stride, const uint8_t *second_pred) {                            \
    return fnname(src_ptr, source_stride, ref_ptr, ref_stride, second_pred) >> \
           4;                                                                  \
  }

#define MAKE_BFP_SAD3_WRAPPER(fnname)                                    \
  static void fnname##_bits8(const uint8_t *src_ptr, int source_stride,  \
                             const uint8_t *ref_ptr, int ref_stride,     \
                             unsigned int *sad_array) {                  \
    fnname(src_ptr, source_stride, ref_ptr, ref_stride, sad_array);      \
  }                                                                      \
  static void fnname##_bits10(const uint8_t *src_ptr, int source_stride, \
                              const uint8_t *ref_ptr, int ref_stride,    \
                              unsigned int *sad_array) {                 \
    int i;                                                               \
    fnname(src_ptr, source_stride, ref_ptr, ref_stride, sad_array);      \
    for (i = 0; i < 3; i++) sad_array[i] >>= 2;                          \
  }                                                                      \
  static void fnname##_bits12(const uint8_t *src_ptr, int source_stride, \
                              const uint8_t *ref_ptr, int ref_stride,    \
                              unsigned int *sad_array) {                 \
    int i;                                                               \
    fnname(src_ptr, source_stride, ref_ptr, ref_stride, sad_array);      \
    for (i = 0; i < 3; i++) sad_array[i] >>= 4;                          \
  }

#define MAKE_BFP_SAD8_WRAPPER(fnname)                                    \
  static void fnname##_bits8(const uint8_t *src_ptr, int source_stride,  \
                             const uint8_t *ref_ptr, int ref_stride,     \
                             unsigned int *sad_array) {                  \
    fnname(src_ptr, source_stride, ref_ptr, ref_stride, sad_array);      \
  }                                                                      \
  static void fnname##_bits10(const uint8_t *src_ptr, int source_stride, \
                              const uint8_t *ref_ptr, int ref_stride,    \
                              unsigned int *sad_array) {                 \
    int i;                                                               \
    fnname(src_ptr, source_stride, ref_ptr, ref_stride, sad_array);      \
    for (i = 0; i < 8; i++) sad_array[i] >>= 2;                          \
  }                                                                      \
  static void fnname##_bits12(const uint8_t *src_ptr, int source_stride, \
                              const uint8_t *ref_ptr, int ref_stride,    \
                              unsigned int *sad_array) {                 \
    int i;                                                               \
    fnname(src_ptr, source_stride, ref_ptr, ref_stride, sad_array);      \
    for (i = 0; i < 8; i++) sad_array[i] >>= 4;                          \
  }
#define MAKE_BFP_SAD4D_WRAPPER(fnname)                                        \
  static void fnname##_bits8(const uint8_t *src_ptr, int source_stride,       \
                             const uint8_t *const ref_ptr[], int ref_stride,  \
                             unsigned int *sad_array) {                       \
    fnname(src_ptr, source_stride, ref_ptr, ref_stride, sad_array);           \
  }                                                                           \
  static void fnname##_bits10(const uint8_t *src_ptr, int source_stride,      \
                              const uint8_t *const ref_ptr[], int ref_stride, \
                              unsigned int *sad_array) {                      \
    int i;                                                                    \
    fnname(src_ptr, source_stride, ref_ptr, ref_stride, sad_array);           \
    for (i = 0; i < 4; i++) sad_array[i] >>= 2;                               \
  }                                                                           \
  static void fnname##_bits12(const uint8_t *src_ptr, int source_stride,      \
                              const uint8_t *const ref_ptr[], int ref_stride, \
                              unsigned int *sad_array) {                      \
    int i;                                                                    \
    fnname(src_ptr, source_stride, ref_ptr, ref_stride, sad_array);           \
    for (i = 0; i < 4; i++) sad_array[i] >>= 4;                               \
  }

/* clang-format off */
Jingning Han's avatar
Jingning Han committed
867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921
MAKE_BFP_SAD_WRAPPER(vpx_highbd_sad32x16)
MAKE_BFP_SADAVG_WRAPPER(vpx_highbd_sad32x16_avg)
MAKE_BFP_SAD4D_WRAPPER(vpx_highbd_sad32x16x4d)
MAKE_BFP_SAD_WRAPPER(vpx_highbd_sad16x32)
MAKE_BFP_SADAVG_WRAPPER(vpx_highbd_sad16x32_avg)
MAKE_BFP_SAD4D_WRAPPER(vpx_highbd_sad16x32x4d)
MAKE_BFP_SAD_WRAPPER(vpx_highbd_sad64x32)
MAKE_BFP_SADAVG_WRAPPER(vpx_highbd_sad64x32_avg)
MAKE_BFP_SAD4D_WRAPPER(vpx_highbd_sad64x32x4d)
MAKE_BFP_SAD_WRAPPER(vpx_highbd_sad32x64)
MAKE_BFP_SADAVG_WRAPPER(vpx_highbd_sad32x64_avg)
MAKE_BFP_SAD4D_WRAPPER(vpx_highbd_sad32x64x4d)
MAKE_BFP_SAD_WRAPPER(vpx_highbd_sad32x32)
MAKE_BFP_SADAVG_WRAPPER(vpx_highbd_sad32x32_avg)
MAKE_BFP_SAD3_WRAPPER(vpx_highbd_sad32x32x3)
MAKE_BFP_SAD8_WRAPPER(vpx_highbd_sad32x32x8)
MAKE_BFP_SAD4D_WRAPPER(vpx_highbd_sad32x32x4d)
MAKE_BFP_SAD_WRAPPER(vpx_highbd_sad64x64)
MAKE_BFP_SADAVG_WRAPPER(vpx_highbd_sad64x64_avg)
MAKE_BFP_SAD3_WRAPPER(vpx_highbd_sad64x64x3)
MAKE_BFP_SAD8_WRAPPER(vpx_highbd_sad64x64x8)
MAKE_BFP_SAD4D_WRAPPER(vpx_highbd_sad64x64x4d)
MAKE_BFP_SAD_WRAPPER(vpx_highbd_sad16x16)
MAKE_BFP_SADAVG_WRAPPER(vpx_highbd_sad16x16_avg)
MAKE_BFP_SAD3_WRAPPER(vpx_highbd_sad16x16x3)
MAKE_BFP_SAD8_WRAPPER(vpx_highbd_sad16x16x8)
MAKE_BFP_SAD4D_WRAPPER(vpx_highbd_sad16x16x4d)
MAKE_BFP_SAD_WRAPPER(vpx_highbd_sad16x8)
MAKE_BFP_SADAVG_WRAPPER(vpx_highbd_sad16x8_avg)
MAKE_BFP_SAD3_WRAPPER(vpx_highbd_sad16x8x3)
MAKE_BFP_SAD8_WRAPPER(vpx_highbd_sad16x8x8)
MAKE_BFP_SAD4D_WRAPPER(vpx_highbd_sad16x8x4d)
MAKE_BFP_SAD_WRAPPER(vpx_highbd_sad8x16)
MAKE_BFP_SADAVG_WRAPPER(vpx_highbd_sad8x16_avg)
MAKE_BFP_SAD3_WRAPPER(vpx_highbd_sad8x16x3)
MAKE_BFP_SAD8_WRAPPER(vpx_highbd_sad8x16x8)
MAKE_BFP_SAD4D_WRAPPER(vpx_highbd_sad8x16x4d)
MAKE_BFP_SAD_WRAPPER(vpx_highbd_sad8x8)
MAKE_BFP_SADAVG_WRAPPER(vpx_highbd_sad8x8_avg)
MAKE_BFP_SAD3_WRAPPER(vpx_highbd_sad8x8x3)
MAKE_BFP_SAD8_WRAPPER(vpx_highbd_sad8x8x8)
MAKE_BFP_SAD4D_WRAPPER(vpx_highbd_sad8x8x4d)
MAKE_BFP_SAD_WRAPPER(vpx_highbd_sad8x4)
MAKE_BFP_SADAVG_WRAPPER(vpx_highbd_sad8x4_avg)
MAKE_BFP_SAD8_WRAPPER(vpx_highbd_sad8x4x8)
MAKE_BFP_SAD4D_WRAPPER(vpx_highbd_sad8x4x4d)
MAKE_BFP_SAD_WRAPPER(vpx_highbd_sad4x8)
MAKE_BFP_SADAVG_WRAPPER(vpx_highbd_sad4x8_avg)
MAKE_BFP_SAD8_WRAPPER(vpx_highbd_sad4x8x8)
MAKE_BFP_SAD4D_WRAPPER(vpx_highbd_sad4x8x4d)
MAKE_BFP_SAD_WRAPPER(vpx_highbd_sad4x4)
MAKE_BFP_SADAVG_WRAPPER(vpx_highbd_sad4x4_avg)
MAKE_BFP_SAD3_WRAPPER(vpx_highbd_sad4x4x3)
MAKE_BFP_SAD8_WRAPPER(vpx_highbd_sad4x4x8)
MAKE_BFP_SAD4D_WRAPPER(vpx_highbd_sad4x4x4d)
clang-format's avatar
clang-format committed
922
/* clang-format on */
Jingning Han's avatar
Jingning Han committed
923

clang-format's avatar
clang-format committed
924
static void highbd_set_var_fns(VP10_COMP *const cpi) {
Yaowu Xu's avatar
Yaowu Xu committed
925
  VP10_COMMON *const cm = &cpi->common;
Jingning Han's avatar
Jingning Han committed
926 927 928
  if (cm->use_highbitdepth) {
    switch (cm->bit_depth) {
      case VPX_BITS_8:
clang-format's avatar
clang-format committed
929 930
        HIGHBD_BFP(BLOCK_32X16, vpx_highbd_sad32x16_bits8,
                   vpx_highbd_sad32x16_avg_bits8, vpx_highbd_8_variance32x16,
Jingning Han's avatar
Jingning Han committed
931
                   vpx_highbd_8_sub_pixel_variance32x16,
clang-format's avatar
clang-format committed
932
                   vpx_highbd_8_sub_pixel_avg_variance32x16, NULL, NULL,
Jingning Han's avatar
Jingning Han committed
933 934
                   vpx_highbd_sad32x16x4d_bits8)

clang-format's avatar
clang-format committed
935 936
        HIGHBD_BFP(BLOCK_16X32, vpx_highbd_sad16x32_bits8,
                   vpx_highbd_sad16x32_avg_bits8, vpx_highbd_8_variance16x32,
Jingning Han's avatar
Jingning Han committed
937
                   vpx_highbd_8_sub_pixel_variance16x32,
clang-format's avatar
clang-format committed
938
                   vpx_highbd_8_sub_pixel_avg_variance16x32, NULL, NULL,
Jingning Han's avatar
Jingning Han committed
939 940
                   vpx_highbd_sad16x32x4d_bits8)

clang-format's avatar
clang-format committed
941 942
        HIGHBD_BFP(BLOCK_64X32, vpx_highbd_sad64x32_bits8,
                   vpx_highbd_sad64x32_avg_bits8, vpx_highbd_8_variance64x32,
Jingning Han's avatar
Jingning Han committed
943
                   vpx_highbd_8_sub_pixel_variance64x32,
clang-format's avatar
clang-format committed
944
                   vpx_highbd_8_sub_pixel_avg_variance64x32, NULL, NULL,
Jingning Han's avatar
Jingning Han committed
945 946
                   vpx_highbd_sad64x32x4d_bits8)

clang-format's avatar
clang-format committed
947 948
        HIGHBD_BFP(BLOCK_32X64, vpx_highbd_sad32x64_bits8,
                   vpx_highbd_sad32x64_avg_bits8, vpx_highbd_8_variance32x64,
Jingning Han's avatar
Jingning Han committed
949
                   vpx_highbd_8_sub_pixel_variance32x64,
clang-format's avatar
clang-format committed
950
                   vpx_highbd_8_sub_pixel_avg_variance32x64, NULL, NULL,
Jingning Han's avatar
Jingning Han committed
951 952
                   vpx_highbd_sad32x64x4d_bits8)

clang-format's avatar
clang-format committed
953 954
        HIGHBD_BFP(BLOCK_32X32, vpx_highbd_sad32x32_bits8,
                   vpx_highbd_sad32x32_avg_bits8, vpx_highbd_8_variance32x32,
Jingning Han's avatar
Jingning Han committed
955 956
                   vpx_highbd_8_sub_pixel_variance32x32,
                   vpx_highbd_8_sub_pixel_avg_variance32x32,
clang-format's avatar
clang-format committed
957
                   vpx_highbd_sad32x32x3_bits8, vpx_highbd_sad32x32x8_bits8,
Jingning Han's avatar
Jingning Han committed
958 959
                   vpx_highbd_sad32x32x4d_bits8)

clang-format's avatar
clang-format committed
960 961
        HIGHBD_BFP(BLOCK_64X64, vpx_highbd_sad64x64_bits8,
                   vpx_highbd_sad64x64_avg_bits8, vpx_highbd_8_variance64x64,
Jingning Han's avatar
Jingning Han committed
962 963
                   vpx_highbd_8_sub_pixel_variance64x64,
                   vpx_highbd_8_sub_pixel_avg_variance64x64,
clang-format's avatar
clang-format committed
964
                   vpx_highbd_sad64x64x3_bits8, vpx_highbd_sad64x64x8_bits8,
Jingning Han's avatar
Jingning Han committed
965 966
                   vpx_highbd_sad64x64x4d_bits8)

clang-format's avatar
clang-format committed
967 968
        HIGHBD_BFP(BLOCK_16X16, vpx_highbd_sad16x16_bits8,
                   vpx_highbd_sad16x16_avg_bits8, vpx_highbd_8_variance16x16,
Jingning Han's avatar
Jingning Han committed
969 970
                   vpx_highbd_8_sub_pixel_variance16x16,
                   vpx_highbd_8_sub_pixel_avg_variance16x16,
clang-format's avatar
clang-format committed
971
                   vpx_highbd_sad16x16x3_bits8, vpx_highbd_sad16x16x8_bits8,
Jingning Han's avatar
Jingning Han committed
972 973
                   vpx_highbd_sad16x16x4d_bits8)

clang-format's avatar
clang-format committed
974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993
        HIGHBD_BFP(
            BLOCK_16X8, vpx_highbd_sad16x8_bits8, vpx_highbd_sad16x8_avg_bits8,
            vpx_highbd_8_variance16x8, vpx_highbd_8_sub_pixel_variance16x8,
            vpx_highbd_8_sub_pixel_avg_variance16x8, vpx_highbd_sad16x8x3_bits8,
            vpx_highbd_sad16x8x8_bits8, vpx_highbd_sad16x8x4d_bits8)

        HIGHBD_BFP(
            BLOCK_8X16, vpx_highbd_sad8x16_bits8, vpx_highbd_sad8x16_avg_bits8,
            vpx_highbd_8_variance8x16, vpx_highbd_8_sub_pixel_variance8x16,
            vpx_highbd_8_sub_pixel_avg_variance8x16, vpx_highbd_sad8x16x3_bits8,
            vpx_highbd_sad8x16x8_bits8, vpx_highbd_sad8x16x4d_bits8)

        HIGHBD_BFP(
            BLOCK_8X8, vpx_highbd_sad8x8_bits8, vpx_highbd_sad8x8_avg_bits8,
            vpx_highbd_8_variance8x8, vpx_highbd_8_sub_pixel_variance8x8,
            vpx_highbd_8_sub_pixel_avg_variance8x8, vpx_highbd_sad8x8x3_bits8,
            vpx_highbd_sad8x8x8_bits8, vpx_highbd_sad8x8x4d_bits8)

        HIGHBD_BFP(BLOCK_8X4, vpx_highbd_sad8x4_bits8,
                   vpx_highbd_sad8x4_avg_bits8, vpx_highbd_8_variance8x4,
Jingning Han's avatar
Jingning Han committed
994
                   vpx_highbd_8_sub_pixel_variance8x4,
clang-format's avatar
clang-format committed
995 996 997 998 999
                   vpx_highbd_8_sub_pixel_avg_variance8x4, NULL,
                   vpx_highbd_sad8x4x8_bits8, vpx_highbd_sad8x4x4d_bits8)

        HIGHBD_BFP(BLOCK_4X8, vpx_highbd_sad4x8_bits8,
                   vpx_highbd_sad4x8_avg_bits8, vpx_highbd_8_variance4x8,
Jingning Han's avatar
Jingning Han committed
1000
                   vpx_highbd_8_sub_pixel_variance4x8,
clang-format's avatar
clang-format committed
1001 1002 1003 1004 1005 1006 1007 1008
                   vpx_highbd_8_sub_pixel_avg_variance4x8, NULL,
                   vpx_highbd_sad4x8x8_bits8, vpx_highbd_sad4x8x4d_bits8)

        HIGHBD_BFP(
            BLOCK_4X4, vpx_highbd_sad4x4_bits8, vpx_highbd_sad4x4_avg_bits8,
            vpx_highbd_8_variance4x4, vpx_highbd_8_sub_pixel_variance4x4,
            vpx_highbd_8_sub_pixel_avg_variance4x4, vpx_highbd_sad4x4x3_bits8,
            vpx_highbd_sad4x4x8_bits8, vpx_highbd_sad4x4x4d_bits8)
Jingning Han's avatar
Jingning Han committed
1009 1010 1011
        break;

      case VPX_BITS_10:
clang-format's avatar
clang-format committed
1012 1013
        HIGHBD_BFP(BLOCK_32X16, vpx_highbd_sad32x16_bits10,
                   vpx_highbd_sad32x16_avg_bits10, vpx_highbd_10_variance32x16,
Jingning Han's avatar
Jingning Han committed
1014
                   vpx_highbd_10_sub_pixel_variance32x16,
clang-format's avatar
clang-format committed
1015
                   vpx_highbd_10_sub_pixel_avg_variance32x16, NULL, NULL,
Jingning Han's avatar
Jingning Han committed
1016 1017
                   vpx_highbd_sad32x16x4d_bits10)

clang-format's avatar
clang-format committed
1018 1019
        HIGHBD_BFP(BLOCK_16X32, vpx_highbd_sad16x32_bits10,
                   vpx_highbd_sad16x32_avg_bits10, vpx_highbd_10_variance16x32,
Jingning Han's avatar
Jingning Han committed
1020
                   vpx_highbd_10_sub_pixel_variance16x32,
clang-format's avatar
clang-format committed
1021
                   vpx_highbd_10_sub_pixel_avg_variance16x32, NULL, NULL,
Jingning Han's avatar
Jingning Han committed
1022 1023
                   vpx_highbd_sad16x32x4d_bits10)

clang-format's avatar
clang-format committed
1024 1025
        HIGHBD_BFP(BLOCK_64X32, vpx_highbd_sad64x32_bits10,
                   vpx_highbd_sad64x32_avg_bits10, vpx_highbd_10_variance64x32,
Jingning Han's avatar
Jingning Han committed
1026
                   vpx_highbd_10_sub_pixel_variance64x32,
clang-format's avatar
clang-format committed
1027
                   vpx_highbd_10_sub_pixel_avg_variance64x32, NULL, NULL,
Jingning Han's avatar
Jingning Han committed
1028 1029
                   vpx_highbd_sad64x32x4d_bits10)

clang-format's avatar
clang-format committed
1030 1031
        HIGHBD_BFP(BLOCK_32X64, vpx_highbd_sad32x64_bits10,
                   vpx_highbd_sad32x64_avg_bits10, vpx_highbd_10_variance32x64,
Jingning Han's avatar
Jingning Han committed
1032
                   vpx_highbd_10_sub_pixel_variance32x64,
clang-format's avatar
clang-format committed
1033
                   vpx_highbd_10_sub_pixel_avg_variance32x64, NULL, NULL,
Jingning Han's avatar
Jingning Han committed
1034 1035
                   vpx_highbd_sad32x64x4d_bits10)

clang-format's avatar
clang-format committed
1036 1037
        HIGHBD_BFP(BLOCK_32X32, vpx_highbd_sad32x32_bits10,
                   vpx_highbd_sad32x32_avg_bits10, vpx_highbd_10_variance32x32,
Jingning Han's avatar
Jingning Han committed
1038 1039
                   vpx_highbd_10_sub_pixel_variance32x32,
                   vpx_highbd_10_sub_pixel_avg_variance32x32,
clang-format's avatar
clang-format committed
1040
                   vpx_highbd_sad32x32x3_bits10, vpx_highbd_sad32x32x8_bits10,
Jingning Han's avatar
Jingning Han committed
1041 1042
                   vpx_highbd_sad32x32x4d_bits10)

clang-format's avatar
clang-format committed
1043 1044
        HIGHBD_BFP(BLOCK_64X64, vpx_highbd_sad64x64_bits10,
                   vpx_highbd_sad64x64_avg_bits10, vpx_highbd_10_variance64x64,
Jingning Han's avatar
Jingning Han committed
1045 1046
                   vpx_highbd_10_sub_pixel_variance64x64,
                   vpx_highbd_10_sub_pixel_avg_variance64x64,
clang-format's avatar
clang-format committed
1047
                   vpx_highbd_sad64x64x3_bits10, vpx_highbd_sad64x64x8_bits10,
Jingning Han's avatar
Jingning Han committed
1048 1049
                   vpx_highbd_sad64x64x4d_bits10)

clang-format's avatar
clang-format committed
1050 1051
        HIGHBD_BFP(BLOCK_16X16, vpx_highbd_sad16x16_bits10,
                   vpx_highbd_sad16x16_avg_bits10, vpx_highbd_10_variance16x16,
Jingning Han's avatar
Jingning Han committed
1052 1053
                   vpx_highbd_10_sub_pixel_variance16x16,
                   vpx_highbd_10_sub_pixel_avg_variance16x16,
clang-format's avatar
clang-format committed
1054
                   vpx_highbd_sad16x16x3_bits10, vpx_highbd_sad16x16x8_bits10,
Jingning Han's avatar
Jingning Han committed
1055 1056
                   vpx_highbd_sad16x16x4d_bits10)

clang-format's avatar
clang-format committed
1057 1058
        HIGHBD_BFP(BLOCK_16X8, vpx_highbd_sad16x8_bits10,
                   vpx_highbd_sad16x8_avg_bits10, vpx_highbd_10_variance16x8,
Jingning Han's avatar
Jingning Han committed
1059 1060
                   vpx_highbd_10_sub_pixel_variance16x8,
                   vpx_highbd_10_sub_pixel_avg_variance16x8,
clang-format's avatar
clang-format committed
1061
                   vpx_highbd_sad16x8x3_bits10, vpx_highbd_sad16x8x8_bits10,
Jingning Han's avatar
Jingning Han committed
1062 1063
                   vpx_highbd_sad16x8x4d_bits10)

clang-format's avatar
clang-format committed
1064 1065
        HIGHBD_BFP(BLOCK_8X16, vpx_highbd_sad8x16_bits10,
                   vpx_highbd_sad8x16_avg_bits10, vpx_highbd_10_variance8x16,
Jingning Han's avatar
Jingning Han committed
1066 1067
                   vpx_highbd_10_sub_pixel_variance8x16,
                   vpx_highbd_10_sub_pixel_avg_variance8x16,
clang-format's avatar
clang-format committed
1068
                   vpx_highbd_sad8x16x3_bits10, vpx_highbd_sad8x16x8_bits10,
Jingning Han's avatar
Jingning Han committed
1069 1070
                   vpx_highbd_sad8x16x4d_bits10)

clang-format's avatar
clang-format committed
1071 1072 1073 1074 1075 1076 1077 1078
        HIGHBD_BFP(
            BLOCK_8X8, vpx_highbd_sad8x8_bits10, vpx_highbd_sad8x8_avg_bits10,
            vpx_highbd_10_variance8x8, vpx_highbd_10_sub_pixel_variance8x8,
            vpx_highbd_10_sub_pixel_avg_variance8x8, vpx_highbd_sad8x8x3_bits10,
            vpx_highbd_sad8x8x8_bits10, vpx_highbd_sad8x8x4d_bits10)

        HIGHBD_BFP(BLOCK_8X4, vpx_highbd_sad8x4_bits10,
                   vpx_highbd_sad8x4_avg_bits10, vpx_highbd_10_variance8x4,
Jingning Han's avatar
Jingning Han committed
1079
                   vpx_highbd_10_sub_pixel_variance8x4,
clang-format's avatar
clang-format committed
1080 1081 1082 1083 1084
                   vpx_highbd_10_sub_pixel_avg_variance8x4, NULL,
                   vpx_highbd_sad8x4x8_bits10, vpx_highbd_sad8x4x4d_bits10)

        HIGHBD_BFP(BLOCK_4X8, vpx_highbd_sad4x8_bits10,
                   vpx_highbd_sad4x8_avg_bits10, vpx_highbd_10_variance4x8,
Jingning Han's avatar
Jingning Han committed
1085
                   vpx_highbd_10_sub_pixel_variance4x8,
clang-format's avatar
clang-format committed
1086 1087 1088 1089 1090 1091 1092 1093
                   vpx_highbd_10_sub_pixel_avg_variance4x8, NULL,
                   vpx_highbd_sad4x8x8_bits10, vpx_highbd_sad4x8x4d_bits10)

        HIGHBD_BFP(
            BLOCK_4X4, vpx_highbd_sad4x4_bits10, vpx_highbd_sad4x4_avg_bits10,
            vpx_highbd_10_variance4x4, vpx_highbd_10_sub_pixel_variance4x4,
            vpx_highbd_10_sub_pixel_avg_variance4x4, vpx_highbd_sad4x4x3_bits10,
            vpx_highbd_sad4x4x8_bits10, vpx_highbd_sad4x4x4d_bits10)
Jingning Han's avatar
Jingning Han committed
1094 1095 1096
        break;

      case VPX_BITS_12:
clang-format's avatar
clang-format committed
1097 1098
        HIGHBD_BFP(BLOCK_32X16, vpx_highbd_sad32x16_bits12,
                   vpx_highbd_sad32x16_avg_bits12, vpx_highbd_12_variance32x16,
Jingning Han's avatar
Jingning Han committed
1099
                   vpx_highbd_12_sub_pixel_variance32x16,
clang-format's avatar
clang-format committed
1100
                   vpx_highbd_12_sub_pixel_avg_variance32x16, NULL, NULL,
Jingning Han's avatar
Jingning Han committed
1101 1102
                   vpx_highbd_sad32x16x4d_bits12)

clang-format's avatar
clang-format committed
1103 1104
        HIGHBD_BFP(BLOCK_16X32, vpx_highbd_sad16x32_bits12,
                   vpx_highbd_sad16x32_avg_bits12, vpx_highbd_12_variance16x32,
Jingning Han's avatar
Jingning Han committed
1105
                   vpx_highbd_12_sub_pixel_variance16x32,
clang-format's avatar
clang-format committed
1106
                   vpx_highbd_12_sub_pixel_avg_variance16x32, NULL, NULL,
Jingning Han's avatar
Jingning Han committed
1107 1108
                   vpx_highbd_sad16x32x4d_bits12)

clang-format's avatar
clang-format committed
1109 1110
        HIGHBD_BFP(BLOCK_64X32, vpx_highbd_sad64x32_bits12,
                   vpx_highbd_sad64x32_avg_bits12, vpx_highbd_12_variance64x32,
Jingning Han's avatar
Jingning Han committed
1111
                   vpx_highbd_12_sub_pixel_variance64x32,
clang-format's avatar
clang-format committed
1112
                   vpx_highbd_12_sub_pixel_avg_variance64x32, NULL, NULL,
Jingning Han's avatar
Jingning Han committed
1113 1114
                   vpx_highbd_sad64x32x4d_bits12)

clang-format's avatar
clang-format committed
1115 1116
        HIGHBD_BFP(BLOCK_32X64, vpx_highbd_sad32x64_bits12,
                   vpx_highbd_sad32x64_avg_bits12, vpx_highbd_12_variance32x64,
Jingning Han's avatar
Jingning Han committed
1117
                   vpx_highbd_12_sub_pixel_variance32x64,
clang-format's avatar
clang-format committed
1118
                   vpx_highbd_12_sub_pixel_avg_variance32x64, NULL, NULL,
Jingning Han's avatar
Jingning Han committed
1119 1120
                   vpx_highbd_sad32x64x4d_bits12)

clang-format's avatar
clang-format committed
1121 1122
        HIGHBD_BFP(BLOCK_32X32, vpx_highbd_sad32x32_bits12,
                   vpx_highbd_sad32x32_avg_bits12, vpx_highbd_12_variance32x32,
Jingning Han's avatar
Jingning Han committed
1123 1124
                   vpx_highbd_12_sub_pixel_variance32x32,
                   vpx_highbd_12_sub_pixel_avg_variance32x32,
clang-format's avatar
clang-format committed
1125
                   vpx_highbd_sad32x32x3_bits12, vpx_highbd_sad32x32x8_bits12,
Jingning Han's avatar
Jingning Han committed
1126 1127
                   vpx_highbd_sad32x32x4d_bits12)

clang-format's avatar
clang-format committed
1128 1129
        HIGHBD_BFP(BLOCK_64X64, vpx_highbd_sad64x64_bits12,
                   vpx_highbd_sad64x64_avg_bits12, vpx_highbd_12_variance64x64,
Jingning Han's avatar
Jingning Han committed
1130 1131
                   vpx_highbd_12_sub_pixel_variance64x64,
                   vpx_highbd_12_sub_pixel_avg_variance64x64,
clang-format's avatar
clang-format committed
1132
                   vpx_highbd_sad64x64x3_bits12, vpx_highbd_sad64x64x8_bits12,
Jingning Han's avatar
Jingning Han committed
1133 1134
                   vpx_highbd_sad64x64x4d_bits12)

clang-format's avatar
clang-format committed
1135 1136
        HIGHBD_BFP(BLOCK_16X16, vpx_highbd_sad16x16_bits12,
                   vpx_highbd_sad16x16_avg_bits12, vpx_highbd_12_variance16x16,
Jingning Han's avatar
Jingning Han committed
1137 1138
                   vpx_highbd_12_sub_pixel_variance16x16,
                   vpx_highbd_12_sub_pixel_avg_variance16x16,
clang-format's avatar
clang-format committed
1139
                   vpx_highbd_sad16x16x3_bits12, vpx_highbd_sad16x16x8_bits12,
Jingning Han's avatar
Jingning Han committed
1140 1141
                   vpx_highbd_sad16x16x4d_bits12)

clang-format's avatar
clang-format committed
1142 1143
        HIGHBD_BFP(BLOCK_16X8, vpx_highbd_sad16x8_bits12,
                   vpx_highbd_sad16x8_avg_bits12, vpx_highbd_12_variance16x8,
Jingning Han's avatar
Jingning Han committed
1144 1145
                   vpx_highbd_12_sub_pixel_variance16x8,
                   vpx_highbd_12_sub_pixel_avg_variance16x8,
clang-format's avatar
clang-format committed
1146
                   vpx_highbd_sad16x8x3_bits12, vpx_highbd_sad16x8x8_bits12,
Jingning Han's avatar
Jingning Han committed
1147 1148
                   vpx_highbd_sad16x8x4d_bits12)

clang-format's avatar
clang-format committed
1149 1150
        HIGHBD_BFP(BLOCK_8X16, vpx_highbd_sad8x16_bits12,
                   vpx_highbd_sad8x16_avg_bits12, vpx_highbd_12_variance8x16,
Jingning Han's avatar
Jingning Han committed
1151 1152
                   vpx_highbd_12_sub_pixel_variance8x16,
                   vpx_highbd_12_sub_pixel_avg_variance8x16,
clang-format's avatar
clang-format committed
1153
                   vpx_highbd_sad8x16x3_bits12, vpx_highbd_sad8x16x8_bits12,
Jingning Han's avatar
Jingning Han committed
1154 1155
                   vpx_highbd_sad8x16x4d_bits12)

clang-format's avatar
clang-format committed
1156 1157 1158 1159 1160 1161 1162 1163
        HIGHBD_BFP(
            BLOCK_8X8, vpx_highbd_sad8x8_bits12, vpx_highbd_sad8x8_avg_bits12,
            vpx_highbd_12_variance8x8, vpx_highbd_12_sub_pixel_variance8x8,
            vpx_highbd_12_sub_pixel_avg_variance8x8, vpx_highbd_sad8x8x3_bits12,
            vpx_highbd_sad8x8x8_bits12, vpx_highbd_sad8x8x4d_bits12)

        HIGHBD_BFP(BLOCK_8X4, vpx_highbd_sad8x4_bits12,
                   vpx_highbd_sad8x4_avg_bits12, vpx_highbd_12_variance8x4,
Jingning Han's avatar
Jingning Han committed
1164
                   vpx_highbd_12_sub_pixel_variance8x4,
clang-format's avatar
clang-format committed
1165 1166 1167 1168 1169
                   vpx_highbd_12_sub_pixel_avg_variance8x4, NULL,
                   vpx_highbd_sad8x4x8_bits12, vpx_highbd_sad8x4x4d_bits12)

        HIGHBD_BFP(BLOCK_4X8, vpx_highbd_sad4x8_bits12,
                   vpx_highbd_sad4x8_avg_bits12, vpx_highbd_12_variance4x8,
Jingning Han's avatar
Jingning Han committed
1170
                   vpx_highbd_12_sub_pixel_variance4x8,
clang-format's avatar
clang-format committed
1171 1172 1173 1174 1175 1176 1177 1178
                   vpx_highbd_12_sub_pixel_avg_variance4x8, NULL,
                   vpx_highbd_sad4x8x8_bits12, vpx_highbd_sad4x8x4d_bits12)

        HIGHBD_BFP(
            BLOCK_4X4, vpx_highbd_sad4x4_bits12, vpx_highbd_sad4x4_avg_bits12,
            vpx_highbd_12_variance4x4, vpx_highbd_12_sub_pixel_variance4x4,
            vpx_highbd_12_sub_pixel_avg_variance4x4, vpx_highbd_sad4x4x3_bits12,
            vpx_highbd_sad4x4x8_bits12, vpx_highbd_sad4x4x4d_bits12)
Jingning Han's avatar
Jingning Han committed
1179 1180 1181
        break;

      default:
clang-format's avatar
clang-format committed
1182 1183 1184
        assert(0 &&
               "cm->bit_depth should be VPX_BITS_8, "
               "VPX_BITS_10 or VPX_BITS_12");