blob: f5d6527dab1b67a2567fd3f40530502d58a784dc [file] [log] [blame]
/*
* Copyright (c) 2016, Alliance for Open Media. All rights reserved
*
* 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.
*/
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include "config/aom_config.h"
#include "config/aom_dsp_rtcd.h"
#include "config/aom_scale_rtcd.h"
#include "config/av1_rtcd.h"
#include "aom_dsp/aom_dsp_common.h"
#include "aom_dsp/aom_filter.h"
#if CONFIG_DENOISE
#include "aom_dsp/grain_table.h"
#include "aom_dsp/noise_util.h"
#include "aom_dsp/noise_model.h"
#endif
#include "aom_dsp/psnr.h"
#if CONFIG_INTERNAL_STATS
#include "aom_dsp/ssim.h"
#endif
#include "aom_ports/aom_timer.h"
#include "aom_ports/mem.h"
#include "aom_ports/system_state.h"
#include "aom_scale/aom_scale.h"
#if CONFIG_BITSTREAM_DEBUG
#include "aom_util/debug_util.h"
#endif // CONFIG_BITSTREAM_DEBUG
#include "av1/common/alloccommon.h"
#include "av1/common/cdef.h"
#include "av1/common/filter.h"
#include "av1/common/idct.h"
#include "av1/common/reconinter.h"
#include "av1/common/reconintra.h"
#include "av1/common/resize.h"
#include "av1/common/tile_common.h"
#include "av1/encoder/av1_multi_thread.h"
#include "av1/encoder/aq_complexity.h"
#include "av1/encoder/aq_cyclicrefresh.h"
#include "av1/encoder/aq_variance.h"
#include "av1/encoder/bitstream.h"
#include "av1/encoder/context_tree.h"
#include "av1/encoder/encodeframe.h"
#include "av1/encoder/encodemv.h"
#include "av1/encoder/encode_strategy.h"
#include "av1/encoder/encoder.h"
#include "av1/encoder/encodetxb.h"
#include "av1/encoder/ethread.h"
#include "av1/encoder/firstpass.h"
#include "av1/encoder/grain_test_vectors.h"
#include "av1/encoder/hash_motion.h"
#include "av1/encoder/mbgraph.h"
#include "av1/encoder/pass2_strategy.h"
#include "av1/encoder/picklpf.h"
#include "av1/encoder/pickrst.h"
#include "av1/encoder/random.h"
#include "av1/encoder/ratectrl.h"
#include "av1/encoder/rd.h"
#include "av1/encoder/rdopt.h"
#include "av1/encoder/segmentation.h"
#include "av1/encoder/speed_features.h"
#include "av1/encoder/tpl_model.h"
#include "av1/encoder/reconinter_enc.h"
#include "av1/encoder/var_based_part.h"
#define DEFAULT_EXPLICIT_ORDER_HINT_BITS 7
#if CONFIG_ENTROPY_STATS
FRAME_COUNTS aggregate_fc;
#endif // CONFIG_ENTROPY_STATS
#define AM_SEGMENT_ID_INACTIVE 7
#define AM_SEGMENT_ID_ACTIVE 0
// Q threshold for high precision mv.
#define HIGH_PRECISION_MV_QTHRESH 128
// #define OUTPUT_YUV_REC
#ifdef OUTPUT_YUV_SKINMAP
FILE *yuv_skinmap_file = NULL;
#endif
#ifdef OUTPUT_YUV_REC
FILE *yuv_rec_file;
#define FILE_NAME_LEN 100
#endif
const int default_tx_type_probs[FRAME_UPDATE_TYPES][TX_SIZES_ALL][TX_TYPES] = {
{ { 221, 189, 214, 292, 0, 0, 0, 0, 0, 2, 38, 68, 0, 0, 0, 0 },
{ 262, 203, 216, 239, 0, 0, 0, 0, 0, 1, 37, 66, 0, 0, 0, 0 },
{ 315, 231, 239, 226, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 0 },
{ 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 222, 188, 214, 287, 0, 0, 0, 0, 0, 2, 50, 61, 0, 0, 0, 0 },
{ 256, 182, 205, 282, 0, 0, 0, 0, 0, 2, 21, 76, 0, 0, 0, 0 },
{ 281, 214, 217, 222, 0, 0, 0, 0, 0, 1, 48, 41, 0, 0, 0, 0 },
{ 263, 194, 225, 225, 0, 0, 0, 0, 0, 2, 15, 100, 0, 0, 0, 0 },
{ 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 170, 192, 242, 293, 0, 0, 0, 0, 0, 1, 68, 58, 0, 0, 0, 0 },
{ 199, 210, 213, 291, 0, 0, 0, 0, 0, 1, 14, 96, 0, 0, 0, 0 },
{ 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },
{ { 106, 69, 107, 278, 9, 15, 20, 45, 49, 23, 23, 88, 36, 74, 25, 57 },
{ 105, 72, 81, 98, 45, 49, 47, 50, 56, 72, 30, 81, 33, 95, 27, 83 },
{ 211, 105, 109, 120, 57, 62, 43, 49, 52, 58, 42, 116, 0, 0, 0, 0 },
{ 1008, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0 },
{ 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 131, 57, 98, 172, 19, 40, 37, 64, 69, 22, 41, 52, 51, 77, 35, 59 },
{ 176, 83, 93, 202, 22, 24, 28, 47, 50, 16, 12, 93, 26, 76, 17, 59 },
{ 136, 72, 89, 95, 46, 59, 47, 56, 61, 68, 35, 51, 32, 82, 26, 69 },
{ 122, 80, 87, 105, 49, 47, 46, 46, 57, 52, 13, 90, 19, 103, 15, 93 },
{ 1009, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 0, 0, 0 },
{ 1011, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 0 },
{ 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 202, 20, 84, 114, 14, 60, 41, 79, 99, 21, 41, 15, 50, 84, 34, 66 },
{ 196, 44, 23, 72, 30, 22, 28, 57, 67, 13, 4, 165, 15, 148, 9, 131 },
{ 882, 0, 0, 0, 0, 0, 0, 0, 0, 142, 0, 0, 0, 0, 0, 0 },
{ 840, 0, 0, 0, 0, 0, 0, 0, 0, 184, 0, 0, 0, 0, 0, 0 },
{ 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },
{ { 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
{ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
{ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
{ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
{ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
{ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
{ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
{ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
{ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
{ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
{ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
{ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
{ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
{ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
{ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
{ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
{ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
{ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
{ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 } },
{ { 213, 110, 141, 269, 12, 16, 15, 19, 21, 11, 38, 68, 22, 29, 16, 24 },
{ 216, 119, 128, 143, 38, 41, 26, 30, 31, 30, 42, 70, 23, 36, 19, 32 },
{ 367, 149, 154, 154, 38, 35, 17, 21, 21, 10, 22, 36, 0, 0, 0, 0 },
{ 1022, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0 },
{ 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 219, 96, 127, 191, 21, 40, 25, 32, 34, 18, 45, 45, 33, 39, 26, 33 },
{ 296, 99, 122, 198, 23, 21, 19, 24, 25, 13, 20, 64, 23, 32, 18, 27 },
{ 275, 128, 142, 143, 35, 48, 23, 30, 29, 18, 42, 36, 18, 23, 14, 20 },
{ 239, 132, 166, 175, 36, 27, 19, 21, 24, 14, 13, 85, 9, 31, 8, 25 },
{ 1022, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0 },
{ 1022, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0 },
{ 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 309, 25, 79, 59, 25, 80, 34, 53, 61, 25, 49, 23, 43, 64, 36, 59 },
{ 270, 57, 40, 54, 50, 42, 41, 53, 56, 28, 17, 81, 45, 86, 34, 70 },
{ 1005, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0 },
{ 992, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0 },
{ 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },
{ { 133, 63, 55, 83, 57, 87, 58, 72, 68, 16, 24, 35, 29, 105, 25, 114 },
{ 131, 75, 74, 60, 71, 77, 65, 66, 73, 33, 21, 79, 20, 83, 18, 78 },
{ 276, 95, 82, 58, 86, 93, 63, 60, 64, 17, 38, 92, 0, 0, 0, 0 },
{ 1006, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 0, 0, 0 },
{ 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 147, 49, 75, 78, 50, 97, 60, 67, 76, 17, 42, 35, 31, 93, 27, 80 },
{ 157, 49, 58, 75, 61, 52, 56, 67, 69, 12, 15, 79, 24, 119, 11, 120 },
{ 178, 69, 83, 77, 69, 85, 72, 77, 77, 20, 35, 40, 25, 48, 23, 46 },
{ 174, 55, 64, 57, 73, 68, 62, 61, 75, 15, 12, 90, 17, 99, 16, 86 },
{ 1008, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0 },
{ 1018, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0 },
{ 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 266, 31, 63, 64, 21, 52, 39, 54, 63, 30, 52, 31, 48, 89, 46, 75 },
{ 272, 26, 32, 44, 29, 31, 32, 53, 51, 13, 13, 88, 22, 153, 16, 149 },
{ 923, 0, 0, 0, 0, 0, 0, 0, 0, 101, 0, 0, 0, 0, 0, 0 },
{ 969, 0, 0, 0, 0, 0, 0, 0, 0, 55, 0, 0, 0, 0, 0, 0 },
{ 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },
{ { 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
{ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
{ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
{ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
{ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
{ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
{ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
{ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
{ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
{ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
{ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
{ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
{ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
{ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
{ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
{ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
{ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
{ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
{ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 } },
{ { 158, 92, 125, 298, 12, 15, 20, 29, 31, 12, 29, 67, 34, 44, 23, 35 },
{ 147, 94, 103, 123, 45, 48, 38, 41, 46, 48, 37, 78, 33, 63, 27, 53 },
{ 268, 126, 125, 136, 54, 53, 31, 38, 38, 33, 35, 87, 0, 0, 0, 0 },
{ 1018, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0 },
{ 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 159, 72, 103, 194, 20, 35, 37, 50, 56, 21, 39, 40, 51, 61, 38, 48 },
{ 259, 86, 95, 188, 32, 20, 25, 34, 37, 13, 12, 85, 25, 53, 17, 43 },
{ 189, 99, 113, 123, 45, 59, 37, 46, 48, 44, 39, 41, 31, 47, 26, 37 },
{ 175, 110, 113, 128, 58, 38, 33, 33, 43, 29, 13, 100, 14, 68, 12, 57 },
{ 1017, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0 },
{ 1019, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0 },
{ 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 208, 22, 84, 101, 21, 59, 44, 70, 90, 25, 59, 13, 64, 67, 49, 48 },
{ 277, 52, 32, 63, 43, 26, 33, 48, 54, 11, 6, 130, 18, 119, 11, 101 },
{ 963, 0, 0, 0, 0, 0, 0, 0, 0, 61, 0, 0, 0, 0, 0, 0 },
{ 979, 0, 0, 0, 0, 0, 0, 0, 0, 45, 0, 0, 0, 0, 0, 0 },
{ 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }
};
static INLINE void Scale2Ratio(AOM_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;
break;
case ONETWO:
*hr = 1;
*hs = 2;
break;
default:
*hr = 1;
*hs = 1;
assert(0);
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.
static void suppress_active_map(AV1_COMP *cpi) {
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;
}
static void apply_active_map(AV1_COMP *cpi) {
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];
av1_enable_segmentation(seg);
av1_enable_segfeature(seg, AM_SEGMENT_ID_INACTIVE, SEG_LVL_SKIP);
av1_enable_segfeature(seg, AM_SEGMENT_ID_INACTIVE, SEG_LVL_ALT_LF_Y_H);
av1_enable_segfeature(seg, AM_SEGMENT_ID_INACTIVE, SEG_LVL_ALT_LF_Y_V);
av1_enable_segfeature(seg, AM_SEGMENT_ID_INACTIVE, SEG_LVL_ALT_LF_U);
av1_enable_segfeature(seg, AM_SEGMENT_ID_INACTIVE, SEG_LVL_ALT_LF_V);
av1_set_segdata(seg, AM_SEGMENT_ID_INACTIVE, SEG_LVL_ALT_LF_Y_H,
-MAX_LOOP_FILTER);
av1_set_segdata(seg, AM_SEGMENT_ID_INACTIVE, SEG_LVL_ALT_LF_Y_V,
-MAX_LOOP_FILTER);
av1_set_segdata(seg, AM_SEGMENT_ID_INACTIVE, SEG_LVL_ALT_LF_U,
-MAX_LOOP_FILTER);
av1_set_segdata(seg, AM_SEGMENT_ID_INACTIVE, SEG_LVL_ALT_LF_V,
-MAX_LOOP_FILTER);
} else {
av1_disable_segfeature(seg, AM_SEGMENT_ID_INACTIVE, SEG_LVL_SKIP);
av1_disable_segfeature(seg, AM_SEGMENT_ID_INACTIVE, SEG_LVL_ALT_LF_Y_H);
av1_disable_segfeature(seg, AM_SEGMENT_ID_INACTIVE, SEG_LVL_ALT_LF_Y_V);
av1_disable_segfeature(seg, AM_SEGMENT_ID_INACTIVE, SEG_LVL_ALT_LF_U);
av1_disable_segfeature(seg, AM_SEGMENT_ID_INACTIVE, SEG_LVL_ALT_LF_V);
if (seg->enabled) {
seg->update_data = 1;
seg->update_map = 1;
}
}
cpi->active_map.update = 0;
}
}
int av1_set_active_map(AV1_COMP *cpi, unsigned char *new_map_16x16, int rows,
int cols) {
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;
const int row_scale = mi_size_high[BLOCK_16X16] == 2 ? 1 : 2;
const int col_scale = mi_size_wide[BLOCK_16X16] == 2 ? 1 : 2;
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 >> row_scale) * cols + (c >> col_scale)]
? AM_SEGMENT_ID_ACTIVE
: AM_SEGMENT_ID_INACTIVE;
}
}
cpi->active_map.enabled = 1;
} else {
cpi->active_map.enabled = 0;
}
return 0;
} else {
return -1;
}
}
int av1_get_active_map(AV1_COMP *cpi, unsigned char *new_map_16x16, int rows,
int cols) {
if (rows == cpi->common.mb_rows && cols == cpi->common.mb_cols &&
new_map_16x16) {
unsigned char *const seg_map_8x8 = cpi->segmentation_map;
const int mi_rows = cpi->common.mi_rows;
const int mi_cols = cpi->common.mi_cols;
const int row_scale = mi_size_high[BLOCK_16X16] == 2 ? 1 : 2;
const int col_scale = mi_size_wide[BLOCK_16X16] == 2 ? 1 : 2;
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 >> row_scale) * cols + (c >> col_scale)] |=
seg_map_8x8[r * mi_cols + c] != AM_SEGMENT_ID_INACTIVE;
}
}
}
return 0;
} else {
return -1;
}
}
// Compute the horizontal frequency components' energy in a frame
// by calculuating the 16x4 Horizontal DCT. This is to be used to
// decide the superresolution parameters.
static void analyze_hor_freq(const AV1_COMP *cpi, double *energy) {
uint64_t freq_energy[16] = { 0 };
const YV12_BUFFER_CONFIG *buf = cpi->source;
const int bd = cpi->td.mb.e_mbd.bd;
const int width = buf->y_crop_width;
const int height = buf->y_crop_height;
DECLARE_ALIGNED(16, int32_t, coeff[16 * 4]);
int n = 0;
memset(freq_energy, 0, sizeof(freq_energy));
if (buf->flags & YV12_FLAG_HIGHBITDEPTH) {
const int16_t *src16 = (const int16_t *)CONVERT_TO_SHORTPTR(buf->y_buffer);
for (int i = 0; i < height - 4; i += 4) {
for (int j = 0; j < width - 16; j += 16) {
av1_fwd_txfm2d_16x4(src16 + i * buf->y_stride + j, coeff, buf->y_stride,
H_DCT, bd);
for (int k = 1; k < 16; ++k) {
const uint64_t this_energy =
((int64_t)coeff[k] * coeff[k]) +
((int64_t)coeff[k + 16] * coeff[k + 16]) +
((int64_t)coeff[k + 32] * coeff[k + 32]) +
((int64_t)coeff[k + 48] * coeff[k + 48]);
freq_energy[k] += ROUND_POWER_OF_TWO(this_energy, 2 + 2 * (bd - 8));
}
n++;
}
}
} else {
assert(bd == 8);
DECLARE_ALIGNED(16, int16_t, src16[16 * 4]);
for (int i = 0; i < height - 4; i += 4) {
for (int j = 0; j < width - 16; j += 16) {
for (int ii = 0; ii < 4; ++ii)
for (int jj = 0; jj < 16; ++jj)
src16[ii * 16 + jj] =
buf->y_buffer[(i + ii) * buf->y_stride + (j + jj)];
av1_fwd_txfm2d_16x4(src16, coeff, 16, H_DCT, bd);
for (int k = 1; k < 16; ++k) {
const uint64_t this_energy =
((int64_t)coeff[k] * coeff[k]) +
((int64_t)coeff[k + 16] * coeff[k + 16]) +
((int64_t)coeff[k + 32] * coeff[k + 32]) +
((int64_t)coeff[k + 48] * coeff[k + 48]);
freq_energy[k] += ROUND_POWER_OF_TWO(this_energy, 2);
}
n++;
}
}
}
if (n) {
for (int k = 1; k < 16; ++k) energy[k] = (double)freq_energy[k] / n;
// Convert to cumulative energy
for (int k = 14; k > 0; --k) energy[k] += energy[k + 1];
} else {
for (int k = 1; k < 16; ++k) energy[k] = 1e+20;
}
}
static void set_high_precision_mv(AV1_COMP *cpi, int allow_high_precision_mv,
int cur_frame_force_integer_mv) {
MACROBLOCK *const x = &cpi->td.mb;
cpi->common.allow_high_precision_mv =
allow_high_precision_mv && cur_frame_force_integer_mv == 0;
const int copy_hp =
cpi->common.allow_high_precision_mv && cur_frame_force_integer_mv == 0;
x->nmvcost[0] = &x->nmv_costs[0][MV_MAX];
x->nmvcost[1] = &x->nmv_costs[1][MV_MAX];
x->nmvcost_hp[0] = &x->nmv_costs_hp[0][MV_MAX];
x->nmvcost_hp[1] = &x->nmv_costs_hp[1][MV_MAX];
int *(*src)[2] = copy_hp ? &x->nmvcost_hp : &x->nmvcost;
x->mv_cost_stack = *src;
}
static BLOCK_SIZE select_sb_size(const AV1_COMP *const cpi) {
const AV1_COMMON *const cm = &cpi->common;
if (cpi->oxcf.superblock_size == AOM_SUPERBLOCK_SIZE_64X64)
return BLOCK_64X64;
#if CONFIG_FILEOPTIONS
if (cm->options && cm->options->ext_partition)
#endif
if (cpi->oxcf.superblock_size == AOM_SUPERBLOCK_SIZE_128X128)
return BLOCK_128X128;
assert(cpi->oxcf.superblock_size == AOM_SUPERBLOCK_SIZE_DYNAMIC);
// TODO(any): Possibly could improve this with a heuristic.
#if CONFIG_FILEOPTIONS
if (cm->options && !cm->options->ext_partition) return BLOCK_64X64;
#endif
// When superres / resize is on, 'cm->width / height' can change between
// calls, so we don't apply this heuristic there.
// Things break if superblock size changes between the first pass and second
// pass encoding, which is why this heuristic is not configured as a
// speed-feature.
if (cpi->oxcf.superres_mode == SUPERRES_NONE &&
cpi->oxcf.resize_mode == RESIZE_NONE && cpi->oxcf.speed >= 1) {
return AOMMIN(cm->width, cm->height) > 480 ? BLOCK_128X128 : BLOCK_64X64;
}
return BLOCK_128X128;
}
static void setup_frame(AV1_COMP *cpi) {
AV1_COMMON *const cm = &cpi->common;
// 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 ||
cpi->ext_use_primary_ref_none) {
av1_setup_past_independence(cm);
}
if ((cm->current_frame.frame_type == KEY_FRAME && cm->show_frame) ||
frame_is_sframe(cm)) {
if (!cpi->seq_params_locked) {
set_sb_size(&cm->seq_params, select_sb_size(cpi));
}
} else {
const RefCntBuffer *const primary_ref_buf = get_primary_ref_frame_buf(cm);
if (primary_ref_buf == NULL) {
av1_setup_past_independence(cm);
cm->seg.update_map = 1;
cm->seg.update_data = 1;
} else {
*cm->fc = primary_ref_buf->frame_context;
}
}
av1_zero(cm->cur_frame->interp_filter_selected);
cm->prev_frame = get_primary_ref_frame_buf(cm);
cpi->vaq_refresh = 0;
}
static void enc_set_mb_mi(AV1_COMMON *cm, int width, int height) {
// Ensure that the decoded width and height are both multiples of
// 8 luma pixels (note: this may only be a multiple of 4 chroma pixels if
// subsampling is used).
// This simplifies the implementation of various experiments,
// eg. cdef, which operates on units of 8x8 luma pixels.
const int aligned_width = ALIGN_POWER_OF_TWO(width, 3);
const int aligned_height = ALIGN_POWER_OF_TWO(height, 3);
cm->mi_cols = aligned_width >> MI_SIZE_LOG2;
cm->mi_rows = aligned_height >> MI_SIZE_LOG2;
cm->mi_stride = calc_mi_size(cm->mi_cols);
cm->mb_cols = (cm->mi_cols + 2) >> 2;
cm->mb_rows = (cm->mi_rows + 2) >> 2;
cm->MBs = cm->mb_rows * cm->mb_cols;
const int is_4k_or_larger = AOMMIN(width, height) >= 2160;
cm->mi_alloc_bsize = is_4k_or_larger ? BLOCK_8X8 : BLOCK_4X4;
const int mi_alloc_size_1d = mi_size_wide[cm->mi_alloc_bsize];
cm->mi_alloc_rows = (cm->mi_rows + mi_alloc_size_1d - 1) / mi_alloc_size_1d;
cm->mi_alloc_cols = (cm->mi_cols + mi_alloc_size_1d - 1) / mi_alloc_size_1d;
cm->mi_alloc_stride =
(cm->mi_stride + mi_alloc_size_1d - 1) / mi_alloc_size_1d;
assert(mi_size_wide[cm->mi_alloc_bsize] == mi_size_high[cm->mi_alloc_bsize]);
#if CONFIG_LPF_MASK
av1_alloc_loop_filter_mask(cm);
#endif
}
static void enc_setup_mi(AV1_COMMON *cm) {
const int mi_grid_size = cm->mi_stride * calc_mi_size(cm->mi_rows);
memset(cm->mi, 0, cm->mi_alloc_size * sizeof(*cm->mi));
memset(cm->mi_grid_base, 0, mi_grid_size * sizeof(*cm->mi_grid_base));
}
static int enc_alloc_mi(AV1_COMMON *cm) {
const int mi_grid_size = cm->mi_stride * calc_mi_size(cm->mi_rows);
const int alloc_size_1d = mi_size_wide[cm->mi_alloc_bsize];
const int alloc_mi_size =
cm->mi_alloc_stride * (calc_mi_size(cm->mi_rows) / alloc_size_1d);
if (cm->mi_alloc_size < alloc_mi_size || cm->mi_grid_size < mi_grid_size) {
cm->free_mi(cm);
cm->mi = aom_calloc(alloc_mi_size, sizeof(*cm->mi));
if (!cm->mi) return 1;
cm->mi_alloc_size = alloc_mi_size;
cm->mi_grid_base =
(MB_MODE_INFO **)aom_calloc(mi_grid_size, sizeof(MB_MODE_INFO *));
if (!cm->mi_grid_base) return 1;
cm->mi_grid_size = mi_grid_size;
}
return 0;
}
static void enc_free_mi(AV1_COMMON *cm) {
aom_free(cm->mi);
cm->mi = NULL;
aom_free(cm->mi_grid_base);
cm->mi_grid_base = NULL;
cm->mi_alloc_size = 0;
}
void av1_initialize_enc(void) {
av1_rtcd();
aom_dsp_rtcd();
aom_scale_rtcd();
av1_init_intra_predictors();
av1_init_me_luts();
av1_rc_init_minq_luts();
av1_init_wedge_masks();
}
static void dealloc_context_buffers_ext(AV1_COMP *cpi) {
if (cpi->mbmi_ext_frame_base) {
aom_free(cpi->mbmi_ext_frame_base);
cpi->mbmi_ext_frame_base = NULL;
}
}
static void alloc_context_buffers_ext(AV1_COMP *cpi) {
AV1_COMMON *cm = &cpi->common;
const int new_ext_mi_size = cm->mi_alloc_rows * cm->mi_alloc_cols;
if (new_ext_mi_size > cpi->mi_ext_alloc_size) {
dealloc_context_buffers_ext(cpi);
CHECK_MEM_ERROR(
cm, cpi->mbmi_ext_frame_base,
aom_calloc(new_ext_mi_size, sizeof(*cpi->mbmi_ext_frame_base)));
cpi->mi_ext_alloc_size = new_ext_mi_size;
}
}
static void reset_film_grain_chroma_params(aom_film_grain_t *pars) {
pars->num_cr_points = 0;
pars->cr_mult = 0;
pars->cr_luma_mult = 0;
memset(pars->scaling_points_cr, 0, sizeof(pars->scaling_points_cr));
memset(pars->ar_coeffs_cr, 0, sizeof(pars->ar_coeffs_cr));
pars->num_cb_points = 0;
pars->cb_mult = 0;
pars->cb_luma_mult = 0;
pars->chroma_scaling_from_luma = 0;
memset(pars->scaling_points_cb, 0, sizeof(pars->scaling_points_cb));
memset(pars->ar_coeffs_cb, 0, sizeof(pars->ar_coeffs_cb));
}
static void update_film_grain_parameters(struct AV1_COMP *cpi,
const AV1EncoderConfig *oxcf) {
AV1_COMMON *const cm = &cpi->common;
cpi->oxcf = *oxcf;
if (cpi->film_grain_table) {
aom_film_grain_table_free(cpi->film_grain_table);
aom_free(cpi->film_grain_table);
cpi->film_grain_table = NULL;
}
if (oxcf->film_grain_test_vector) {
cm->seq_params.film_grain_params_present = 1;
if (cm->current_frame.frame_type == KEY_FRAME) {
memcpy(&cm->film_grain_params,
film_grain_test_vectors + oxcf->film_grain_test_vector - 1,
sizeof(cm->film_grain_params));
if (oxcf->monochrome)
reset_film_grain_chroma_params(&cm->film_grain_params);
cm->film_grain_params.bit_depth = cm->seq_params.bit_depth;
if (cm->seq_params.color_range == AOM_CR_FULL_RANGE) {
cm->film_grain_params.clip_to_restricted_range = 0;
}
}
} else if (oxcf->film_grain_table_filename) {
cm->seq_params.film_grain_params_present = 1;
cpi->film_grain_table = aom_malloc(sizeof(*cpi->film_grain_table));
memset(cpi->film_grain_table, 0, sizeof(aom_film_grain_table_t));
aom_film_grain_table_read(cpi->film_grain_table,
oxcf->film_grain_table_filename, &cm->error);
} else {
#if CONFIG_DENOISE
cm->seq_params.film_grain_params_present = (cpi->oxcf.noise_level > 0);
#else
cm->seq_params.film_grain_params_present = 0;
#endif
memset(&cm->film_grain_params, 0, sizeof(cm->film_grain_params));
}
}
static void dealloc_compressor_data(AV1_COMP *cpi) {
AV1_COMMON *const cm = &cpi->common;
const int num_planes = av1_num_planes(cm);
dealloc_context_buffers_ext(cpi);
aom_free(cpi->tile_data);
cpi->tile_data = NULL;
// Delete sementation map
aom_free(cpi->segmentation_map);
cpi->segmentation_map = NULL;
av1_cyclic_refresh_free(cpi->cyclic_refresh);
cpi->cyclic_refresh = NULL;
aom_free(cpi->active_map.map);
cpi->active_map.map = NULL;
aom_free(cpi->ssim_rdmult_scaling_factors);
cpi->ssim_rdmult_scaling_factors = NULL;
aom_free(cpi->tpl_rdmult_scaling_factors);
cpi->tpl_rdmult_scaling_factors = NULL;
aom_free(cpi->tpl_sb_rdmult_scaling_factors);
cpi->tpl_sb_rdmult_scaling_factors = NULL;
aom_free(cpi->td.mb.above_pred_buf);
cpi->td.mb.above_pred_buf = NULL;
aom_free(cpi->td.mb.left_pred_buf);
cpi->td.mb.left_pred_buf = NULL;
aom_free(cpi->td.mb.wsrc_buf);
cpi->td.mb.wsrc_buf = NULL;
aom_free(cpi->td.mb.inter_modes_info);
cpi->td.mb.inter_modes_info = NULL;
for (int i = 0; i < 2; i++)
for (int j = 0; j < 2; j++) {
aom_free(cpi->td.mb.hash_value_buffer[i][j]);
cpi->td.mb.hash_value_buffer[i][j] = NULL;
}
aom_free(cpi->td.mb.mask_buf);
cpi->td.mb.mask_buf = NULL;
aom_free(cm->tpl_mvs);
cm->tpl_mvs = NULL;
aom_free(cpi->td.mb.mbmi_ext);
cpi->td.mb.mbmi_ext = NULL;
av1_free_ref_frame_buffers(cm->buffer_pool);
av1_free_txb_buf(cpi);
av1_free_context_buffers(cm);
aom_free_frame_buffer(&cpi->last_frame_uf);
av1_free_restoration_buffers(cm);
aom_free_frame_buffer(&cpi->trial_frame_rst);
aom_free_frame_buffer(&cpi->scaled_source);
aom_free_frame_buffer(&cpi->scaled_last_source);
aom_free_frame_buffer(&cpi->alt_ref_buffer);
aom_free_frame_buffer(&cpi->source_kf_buffer);
av1_lookahead_destroy(cpi->lookahead);
aom_free(cpi->tile_tok[0][0]);
cpi->tile_tok[0][0] = 0;
aom_free(cpi->tplist[0][0]);
cpi->tplist[0][0] = NULL;
av1_free_pc_tree(&cpi->td, num_planes);
aom_free(cpi->td.mb.palette_buffer);
av1_release_compound_type_rd_buffers(&cpi->td.mb.comp_rd_buffer);
aom_free(cpi->td.mb.tmp_conv_dst);
for (int j = 0; j < 2; ++j) {
aom_free(cpi->td.mb.tmp_obmc_bufs[j]);
}
#if CONFIG_DENOISE
if (cpi->denoise_and_model) {
aom_denoise_and_model_free(cpi->denoise_and_model);
cpi->denoise_and_model = NULL;
}
#endif
if (cpi->film_grain_table) {
aom_film_grain_table_free(cpi->film_grain_table);
cpi->film_grain_table = NULL;
}
for (int i = 0; i < MAX_NUM_OPERATING_POINTS; ++i) {
aom_free(cpi->level_info[i]);
}
if (cpi->use_svc) av1_free_svc_cyclic_refresh(cpi);
}
static void configure_static_seg_features(AV1_COMP *cpi) {
AV1_COMMON *const cm = &cpi->common;
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->current_frame.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
av1_disable_segmentation(seg);
// Clear down the segment features.
av1_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
av1_disable_segmentation(seg);
av1_clearall_segfeatures(seg);
#if !CONFIG_REALTIME_ONLY
// Scan frames from current to arf frame.
// This function re-enables segmentation if appropriate.
av1_update_mbgraph_stats(cpi);
#endif
// If segmentation was enabled set those features needed for the
// arf itself.
if (seg->enabled) {
seg->update_map = 1;
seg->update_data = 1;
qi_delta = av1_compute_qdelta(rc, rc->avg_q, rc->avg_q * 0.875,
cm->seq_params.bit_depth);
av1_set_segdata(seg, 1, SEG_LVL_ALT_Q, qi_delta - 2);
av1_set_segdata(seg, 1, SEG_LVL_ALT_LF_Y_H, -2);
av1_set_segdata(seg, 1, SEG_LVL_ALT_LF_Y_V, -2);
av1_set_segdata(seg, 1, SEG_LVL_ALT_LF_U, -2);
av1_set_segdata(seg, 1, SEG_LVL_ALT_LF_V, -2);
av1_enable_segfeature(seg, 1, SEG_LVL_ALT_LF_Y_H);
av1_enable_segfeature(seg, 1, SEG_LVL_ALT_LF_Y_V);
av1_enable_segfeature(seg, 1, SEG_LVL_ALT_LF_U);
av1_enable_segfeature(seg, 1, SEG_LVL_ALT_LF_V);
av1_enable_segfeature(seg, 1, SEG_LVL_ALT_Q);
}
} 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;
qi_delta = av1_compute_qdelta(rc, rc->avg_q, rc->avg_q * 1.125,
cm->seq_params.bit_depth);
av1_set_segdata(seg, 1, SEG_LVL_ALT_Q, qi_delta + 2);
av1_enable_segfeature(seg, 1, SEG_LVL_ALT_Q);
av1_set_segdata(seg, 1, SEG_LVL_ALT_LF_Y_H, -2);
av1_set_segdata(seg, 1, SEG_LVL_ALT_LF_Y_V, -2);
av1_set_segdata(seg, 1, SEG_LVL_ALT_LF_U, -2);
av1_set_segdata(seg, 1, SEG_LVL_ALT_LF_V, -2);
av1_enable_segfeature(seg, 1, SEG_LVL_ALT_LF_Y_H);
av1_enable_segfeature(seg, 1, SEG_LVL_ALT_LF_Y_V);
av1_enable_segfeature(seg, 1, SEG_LVL_ALT_LF_U);
av1_enable_segfeature(seg, 1, SEG_LVL_ALT_LF_V);
// Segment coding disabled for compred testing
if (high_q || (cpi->static_mb_pct == 100)) {
av1_set_segdata(seg, 1, SEG_LVL_REF_FRAME, ALTREF_FRAME);
av1_enable_segfeature(seg, 1, SEG_LVL_REF_FRAME);
av1_enable_segfeature(seg, 1, SEG_LVL_SKIP);
}
} else {
// Disable segmentation and clear down features if alt ref
// is not active for this group
av1_disable_segmentation(seg);
memset(cpi->segmentation_map, 0, cm->mi_rows * cm->mi_cols);
seg->update_map = 0;
seg->update_data = 0;
av1_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
av1_enable_segfeature(seg, 0, SEG_LVL_REF_FRAME);
av1_enable_segfeature(seg, 1, SEG_LVL_REF_FRAME);
// All mbs should use ALTREF_FRAME
av1_clear_segdata(seg, 0, SEG_LVL_REF_FRAME);
av1_set_segdata(seg, 0, SEG_LVL_REF_FRAME, ALTREF_FRAME);
av1_clear_segdata(seg, 1, SEG_LVL_REF_FRAME);
av1_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) {
av1_enable_segfeature(seg, 0, SEG_LVL_SKIP);
av1_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;
}
}
}
static void update_reference_segmentation_map(AV1_COMP *cpi) {
AV1_COMMON *const cm = &cpi->common;
MB_MODE_INFO **mi_4x4_ptr = cm->mi_grid_base;
uint8_t *cache_ptr = cm->cur_frame->seg_map;
int row, col;
for (row = 0; row < cm->mi_rows; row++) {
MB_MODE_INFO **mi_4x4 = mi_4x4_ptr;
uint8_t *cache = cache_ptr;
for (col = 0; col < cm->mi_cols; col++, mi_4x4++, cache++)
cache[0] = mi_4x4[0]->segment_id;
mi_4x4_ptr += cm->mi_stride;
cache_ptr += cm->mi_cols;
}
}
static void alloc_raw_frame_buffers(AV1_COMP *cpi) {
AV1_COMMON *cm = &cpi->common;
const SequenceHeader *const seq_params = &cm->seq_params;
const AV1EncoderConfig *oxcf = &cpi->oxcf;
if (!cpi->lookahead) {
int is_scale = (oxcf->resize_mode || oxcf->superres_mode);
cpi->lookahead = av1_lookahead_init(
oxcf->width, oxcf->height, seq_params->subsampling_x,
seq_params->subsampling_y, seq_params->use_highbitdepth,
oxcf->lag_in_frames, oxcf->border_in_pixels, is_scale);
}
if (!cpi->lookahead)
aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
"Failed to allocate lag buffers");
// TODO(agrange) Check if ARF is enabled and skip allocation if not.
if (aom_realloc_frame_buffer(
&cpi->alt_ref_buffer, oxcf->width, oxcf->height,
seq_params->subsampling_x, seq_params->subsampling_y,
seq_params->use_highbitdepth, oxcf->border_in_pixels,
cm->byte_alignment, NULL, NULL, NULL))
aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
"Failed to allocate altref buffer");
// Allocate frame buffer to hold source frame whey key frame filtering
// is applied.
if (aom_realloc_frame_buffer(
&cpi->source_kf_buffer, oxcf->width, oxcf->height,
seq_params->subsampling_x, seq_params->subsampling_y,
seq_params->use_highbitdepth, oxcf->border_in_pixels,
cm->byte_alignment, NULL, NULL, NULL))
aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
"Failed to allocate altref buffer");
}
static void alloc_util_frame_buffers(AV1_COMP *cpi) {
AV1_COMMON *const cm = &cpi->common;
const SequenceHeader *const seq_params = &cm->seq_params;
if (aom_realloc_frame_buffer(
&cpi->last_frame_uf, cm->width, cm->height, seq_params->subsampling_x,
seq_params->subsampling_y, seq_params->use_highbitdepth,
cpi->oxcf.border_in_pixels, cm->byte_alignment, NULL, NULL, NULL))
aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
"Failed to allocate last frame buffer");
if (aom_realloc_frame_buffer(
&cpi->trial_frame_rst, cm->superres_upscaled_width,
cm->superres_upscaled_height, seq_params->subsampling_x,
seq_params->subsampling_y, seq_params->use_highbitdepth,
AOM_RESTORATION_FRAME_BORDER, cm->byte_alignment, NULL, NULL, NULL))
aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
"Failed to allocate trial restored frame buffer");
if (aom_realloc_frame_buffer(
&cpi->scaled_source, cm->width, cm->height, seq_params->subsampling_x,
seq_params->subsampling_y, seq_params->use_highbitdepth,
cpi->oxcf.border_in_pixels, cm->byte_alignment, NULL, NULL, NULL))
aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
"Failed to allocate scaled source buffer");
if (aom_realloc_frame_buffer(
&cpi->scaled_last_source, cm->width, cm->height,
seq_params->subsampling_x, seq_params->subsampling_y,
seq_params->use_highbitdepth, cpi->oxcf.border_in_pixels,
cm->byte_alignment, NULL, NULL, NULL))
aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
"Failed to allocate scaled last source buffer");
}
static void alloc_compressor_data(AV1_COMP *cpi) {
AV1_COMMON *cm = &cpi->common;
const int num_planes = av1_num_planes(cm);
if (av1_alloc_context_buffers(cm, cm->width, cm->height)) {
aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
"Failed to allocate context buffers");
}
int mi_rows_aligned_to_sb =
ALIGN_POWER_OF_TWO(cm->mi_rows, cm->seq_params.mib_size_log2);
int sb_rows = mi_rows_aligned_to_sb >> cm->seq_params.mib_size_log2;
av1_alloc_txb_buf(cpi);
alloc_context_buffers_ext(cpi);
aom_free(cpi->tile_tok[0][0]);
{
unsigned int tokens =
get_token_alloc(cm->mb_rows, cm->mb_cols, MAX_SB_SIZE_LOG2, num_planes);
CHECK_MEM_ERROR(cm, cpi->tile_tok[0][0],
aom_calloc(tokens, sizeof(*cpi->tile_tok[0][0])));
}
aom_free(cpi->tplist[0][0]);
CHECK_MEM_ERROR(cm, cpi->tplist[0][0],
aom_calloc(sb_rows * MAX_TILE_ROWS * MAX_TILE_COLS,
sizeof(*cpi->tplist[0][0])));
av1_setup_pc_tree(&cpi->common, &cpi->td);
}
void av1_new_framerate(AV1_COMP *cpi, double framerate) {
cpi->framerate = framerate < 0.1 ? 30 : framerate;
av1_rc_update_framerate(cpi, cpi->common.width, cpi->common.height);
}
double av1_get_compression_ratio(const AV1_COMMON *const cm,
size_t encoded_frame_size) {
const int upscaled_width = cm->superres_upscaled_width;
const int height = cm->height;
const int luma_pic_size = upscaled_width * height;
const SequenceHeader *const seq_params = &cm->seq_params;
const BITSTREAM_PROFILE profile = seq_params->profile;
const int pic_size_profile_factor =
profile == PROFILE_0 ? 15 : (profile == PROFILE_1 ? 30 : 36);
encoded_frame_size =
(encoded_frame_size > 129 ? encoded_frame_size - 128 : 1);
const size_t uncompressed_frame_size =
(luma_pic_size * pic_size_profile_factor) >> 3;
return uncompressed_frame_size / (double)encoded_frame_size;
}
static void set_tile_info(AV1_COMP *cpi) {
AV1_COMMON *const cm = &cpi->common;
int i, start_sb;
av1_get_tile_limits(cm);
// configure tile columns
if (cpi->oxcf.tile_width_count == 0 || cpi->oxcf.tile_height_count == 0) {
cm->uniform_tile_spacing_flag = 1;
cm->log2_tile_cols = AOMMAX(cpi->oxcf.tile_columns, cm->min_log2_tile_cols);
cm->log2_tile_cols = AOMMIN(cm->log2_tile_cols, cm->max_log2_tile_cols);
} else {
int mi_cols = ALIGN_POWER_OF_TWO(cm->mi_cols, cm->seq_params.mib_size_log2);
int sb_cols = mi_cols >> cm->seq_params.mib_size_log2;
int size_sb, j = 0;
cm->uniform_tile_spacing_flag = 0;
for (i = 0, start_sb = 0; start_sb < sb_cols && i < MAX_TILE_COLS; i++) {
cm->tile_col_start_sb[i] = start_sb;
size_sb = cpi->oxcf.tile_widths[j++];
if (j >= cpi->oxcf.tile_width_count) j = 0;
start_sb += AOMMIN(size_sb, cm->max_tile_width_sb);
}
cm->tile_cols = i;
cm->tile_col_start_sb[i] = sb_cols;
}
av1_calculate_tile_cols(cm);
// configure tile rows
if (cm->uniform_tile_spacing_flag) {
cm->log2_tile_rows = AOMMAX(cpi->oxcf.tile_rows, cm->min_log2_tile_rows);
cm->log2_tile_rows = AOMMIN(cm->log2_tile_rows, cm->max_log2_tile_rows);
} else {
int mi_rows = ALIGN_POWER_OF_TWO(cm->mi_rows, cm->seq_params.mib_size_log2);
int sb_rows = mi_rows >> cm->seq_params.mib_size_log2;
int size_sb, j = 0;
for (i = 0, start_sb = 0; start_sb < sb_rows && i < MAX_TILE_ROWS; i++) {
cm->tile_row_start_sb[i] = start_sb;
size_sb = cpi->oxcf.tile_heights[j++];
if (j >= cpi->oxcf.tile_height_count) j = 0;
start_sb += AOMMIN(size_sb, cm->max_tile_height_sb);
}
cm->tile_rows = i;
cm->tile_row_start_sb[i] = sb_rows;
}
av1_calculate_tile_rows(cm);
}
static void update_frame_size(AV1_COMP *cpi) {
AV1_COMMON *const cm = &cpi->common;
MACROBLOCKD *const xd = &cpi->td.mb.e_mbd;
// We need to reallocate the context buffers here in case we need more mis.
if (av1_alloc_context_buffers(cm, cm->width, cm->height)) {
aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
"Failed to allocate context buffers");
}
av1_init_context_buffers(cm);
av1_init_macroblockd(cm, xd, NULL);
const int ext_mi_size = cm->mi_alloc_rows * cm->mi_alloc_cols;
alloc_context_buffers_ext(cpi);
memset(cpi->mbmi_ext_frame_base, 0,
ext_mi_size * sizeof(*cpi->mbmi_ext_frame_base));
set_tile_info(cpi);
}
static void init_buffer_indices(AV1_COMP *cpi) {
int fb_idx;
for (fb_idx = 0; fb_idx < REF_FRAMES; ++fb_idx)
cpi->common.remapped_ref_idx[fb_idx] = fb_idx;
cpi->rate_index = 0;
cpi->rate_size = 0;
}
static INLINE int does_level_match(int width, int height, double fps,
int lvl_width, int lvl_height,
double lvl_fps, int lvl_dim_mult) {
const int64_t lvl_luma_pels = lvl_width * lvl_height;
const double lvl_display_sample_rate = lvl_luma_pels * lvl_fps;
const int64_t luma_pels = width * height;
const double display_sample_rate = luma_pels * fps;
return luma_pels <= lvl_luma_pels &&
display_sample_rate <= lvl_display_sample_rate &&
width <= lvl_width * lvl_dim_mult &&
height <= lvl_height * lvl_dim_mult;
}
static void set_bitstream_level_tier(SequenceHeader *seq, AV1_COMMON *cm,
const AV1EncoderConfig *oxcf) {
// TODO(any): This is a placeholder function that only addresses dimensions
// and max display sample rates.
// Need to add checks for max bit rate, max decoded luma sample rate, header
// rate, etc. that are not covered by this function.
AV1_LEVEL level = SEQ_LEVEL_MAX;
if (does_level_match(oxcf->width, oxcf->height, oxcf->init_framerate, 512,
288, 30.0, 4)) {
level = SEQ_LEVEL_2_0;
} else if (does_level_match(oxcf->width, oxcf->height, oxcf->init_framerate,
704, 396, 30.0, 4)) {
level = SEQ_LEVEL_2_1;
} else if (does_level_match(oxcf->width, oxcf->height, oxcf->init_framerate,
1088, 612, 30.0, 4)) {
level = SEQ_LEVEL_3_0;
} else if (does_level_match(oxcf->width, oxcf->height, oxcf->init_framerate,
1376, 774, 30.0, 4)) {
level = SEQ_LEVEL_3_1;
} else if (does_level_match(oxcf->width, oxcf->height, oxcf->init_framerate,
2048, 1152, 30.0, 3)) {
level = SEQ_LEVEL_4_0;
} else if (does_level_match(oxcf->width, oxcf->height, oxcf->init_framerate,
2048, 1152, 60.0, 3)) {
level = SEQ_LEVEL_4_1;
} else if (does_level_match(oxcf->width, oxcf->height, oxcf->init_framerate,
4096, 2176, 30.0, 2)) {
level = SEQ_LEVEL_5_0;
} else if (does_level_match(oxcf->width, oxcf->height, oxcf->init_framerate,
4096, 2176, 60.0, 2)) {
level = SEQ_LEVEL_5_1;
} else if (does_level_match(oxcf->width, oxcf->height, oxcf->init_framerate,
4096, 2176, 120.0, 2)) {
level = SEQ_LEVEL_5_2;
} else if (does_level_match(oxcf->width, oxcf->height, oxcf->init_framerate,
8192, 4352, 30.0, 2)) {
level = SEQ_LEVEL_6_0;
} else if (does_level_match(oxcf->width, oxcf->height, oxcf->init_framerate,
8192, 4352, 60.0, 2)) {
} else if (does_level_match(oxcf->width, oxcf->height, oxcf->init_framerate,
8192, 4352, 120.0, 2)) {
level = SEQ_LEVEL_6_2;
} else if (does_level_match(oxcf->width, oxcf->height, oxcf->init_framerate,
16384, 8704, 30.0, 2)) {
level = SEQ_LEVEL_7_0;
} else if (does_level_match(oxcf->width, oxcf->height, oxcf->init_framerate,
16384, 8704, 60.0, 2)) {
level = SEQ_LEVEL_7_1;
} else if (does_level_match(oxcf->width, oxcf->height, oxcf->init_framerate,
16384, 8704, 120.0, 2)) {
level = SEQ_LEVEL_7_2;
}
for (int i = 0; i < MAX_NUM_OPERATING_POINTS; ++i) {
seq->seq_level_idx[i] = level;
// Set the maximum parameters for bitrate and buffer size for this profile,
// level, and tier
cm->op_params[i].bitrate = av1_max_level_bitrate(
cm->seq_params.profile, seq->seq_level_idx[i], seq->tier[i]);
// Level with seq_level_idx = 31 returns a high "dummy" bitrate to pass the
// check
if (cm->op_params[i].bitrate == 0)
aom_internal_error(
&cm->error, AOM_CODEC_UNSUP_BITSTREAM,
"AV1 does not support this combination of profile, level, and tier.");
// Buffer size in bits/s is bitrate in bits/s * 1 s
cm->op_params[i].buffer_size = cm->op_params[i].bitrate;
}
}
static void init_seq_coding_tools(SequenceHeader *seq, AV1_COMMON *cm,
const AV1EncoderConfig *oxcf, int use_svc) {
seq->still_picture = (oxcf->force_video_mode == 0) && (oxcf->limit == 1);
seq->reduced_still_picture_hdr = seq->still_picture;
seq->reduced_still_picture_hdr &= !oxcf->full_still_picture_hdr;
seq->force_screen_content_tools = (oxcf->mode == REALTIME) ? 0 : 2;
seq->force_integer_mv = 2;
seq->order_hint_info.enable_order_hint = oxcf->enable_order_hint;
seq->frame_id_numbers_present_flag =
!(seq->still_picture && seq->reduced_still_picture_hdr) &&
!oxcf->large_scale_tile && oxcf->error_resilient_mode && !use_svc;
if (seq->still_picture && seq->reduced_still_picture_hdr) {
seq->order_hint_info.enable_order_hint = 0;
seq->force_screen_content_tools = 2;
seq->force_integer_mv = 2;
}
seq->order_hint_info.order_hint_bits_minus_1 =
seq->order_hint_info.enable_order_hint
? DEFAULT_EXPLICIT_ORDER_HINT_BITS - 1
: -1;
seq->max_frame_width =
oxcf->forced_max_frame_width ? oxcf->forced_max_frame_width : oxcf->width;
seq->max_frame_height = oxcf->forced_max_frame_height
? oxcf->forced_max_frame_height
: oxcf->height;
seq->num_bits_width =
(seq->max_frame_width > 1) ? get_msb(seq->max_frame_width - 1) + 1 : 1;
seq->num_bits_height =
(seq->max_frame_height > 1) ? get_msb(seq->max_frame_height - 1) + 1 : 1;
assert(seq->num_bits_width <= 16);
assert(seq->num_bits_height <= 16);
seq->frame_id_length = FRAME_ID_LENGTH;
seq->delta_frame_id_length = DELTA_FRAME_ID_LENGTH;
seq->enable_dual_filter = oxcf->enable_dual_filter;
seq->order_hint_info.enable_dist_wtd_comp = oxcf->enable_dist_wtd_comp;
seq->order_hint_info.enable_dist_wtd_comp &=
seq->order_hint_info.enable_order_hint;
seq->order_hint_info.enable_ref_frame_mvs = oxcf->enable_ref_frame_mvs;
seq->order_hint_info.enable_ref_frame_mvs &=
seq->order_hint_info.enable_order_hint;
seq->enable_superres = oxcf->enable_superres;
seq->enable_cdef = oxcf->enable_cdef;
seq->enable_restoration = oxcf->enable_restoration;
seq->enable_warped_motion = oxcf->enable_warped_motion;
seq->enable_interintra_compound = oxcf->enable_interintra_comp;
seq->enable_masked_compound = oxcf->enable_masked_comp;
seq->enable_intra_edge_filter = oxcf->enable_intra_edge_filter;
seq->enable_filter_intra = oxcf->enable_filter_intra;
set_bitstream_level_tier(seq, cm, oxcf);
if (seq->operating_points_cnt_minus_1 == 0) {
seq->operating_point_idc[0] = 0;
} else {
// Set operating_point_idc[] such that for the i-th operating point the
// first (operating_points_cnt-i) spatial layers and the first temporal
// layer are decoded Note that highest quality operating point should come
// first
for (int i = 0; i < seq->operating_points_cnt_minus_1 + 1; i++)
seq->operating_point_idc[i] =
(~(~0u << (seq->operating_points_cnt_minus_1 + 1 - i)) << 8) | 1;
}
}
static void init_config(struct AV1_COMP *cpi, AV1EncoderConfig *oxcf) {
AV1_COMMON *const cm = &cpi->common;
cpi->oxcf = *oxcf;
cpi->framerate = oxcf->init_framerate;
cm->seq_params.profile = oxcf->profile;
cm->seq_params.bit_depth = oxcf->bit_depth;
cm->seq_params.use_highbitdepth = oxcf->use_highbitdepth;
cm->seq_params.color_primaries = oxcf->color_primaries;
cm->seq_params.transfer_characteristics = oxcf->transfer_characteristics;
cm->seq_params.matrix_coefficients = oxcf->matrix_coefficients;
cm->seq_params.monochrome = oxcf->monochrome;
cm->seq_params.chroma_sample_position = oxcf->chroma_sample_position;
cm->seq_params.color_range = oxcf->color_range;
cm->timing_info_present = oxcf->timing_info_present;
cm->timing_info.num_units_in_display_tick =
oxcf->timing_info.num_units_in_display_tick;
cm->timing_info.time_scale = oxcf->timing_info.time_scale;
cm->timing_info.equal_picture_interval =
oxcf->timing_info.equal_picture_interval;
cm->timing_info.num_ticks_per_picture =
oxcf->timing_info.num_ticks_per_picture;
cm->seq_params.display_model_info_present_flag =
oxcf->display_model_info_present_flag;
cm->seq_params.decoder_model_info_present_flag =
oxcf->decoder_model_info_present_flag;
if (oxcf->decoder_model_info_present_flag) {
// set the decoder model parameters in schedule mode
cm->buffer_model.num_units_in_decoding_tick =
oxcf->buffer_model.num_units_in_decoding_tick;
cm->buffer_removal_time_present = 1;
av1_set_aom_dec_model_info(&cm->buffer_model);
av1_set_dec_model_op_parameters(&cm->op_params[0]);
} else if (cm->timing_info_present &&
cm->timing_info.equal_picture_interval &&
!cm->seq_params.decoder_model_info_present_flag) {
// set the decoder model parameters in resource availability mode
av1_set_resource_availability_parameters(&cm->op_params[0]);
} else {
cm->op_params[0].initial_display_delay =
10; // Default value (not signaled)
}
if (cm->seq_params.monochrome) {
cm->seq_params.subsampling_x = 1;
cm->seq_params.subsampling_y = 1;
} else if (cm->seq_params.color_primaries == AOM_CICP_CP_BT_709 &&
cm->seq_params.transfer_characteristics == AOM_CICP_TC_SRGB &&
cm->seq_params.matrix_coefficients == AOM_CICP_MC_IDENTITY) {
cm->seq_params.subsampling_x = 0;
cm->seq_params.subsampling_y = 0;
} else {
if (cm->seq_params.profile == 0) {
cm->seq_params.subsampling_x = 1;
cm->seq_params.subsampling_y = 1;
} else if (cm->seq_params.profile == 1) {
cm->seq_params.subsampling_x = 0;
cm->seq_params.subsampling_y = 0;
} else {
if (cm->seq_params.bit_depth == AOM_BITS_12) {
cm->seq_params.subsampling_x = oxcf->chroma_subsampling_x;
cm->seq_params.subsampling_y = oxcf->chroma_subsampling_y;
} else {
cm->seq_params.subsampling_x = 1;
cm->seq_params.subsampling_y = 0;
}
}
}
cm->width = oxcf->width;
cm->height = oxcf->height;
set_sb_size(&cm->seq_params,
select_sb_size(cpi)); // set sb size before allocations
alloc_compressor_data(cpi);
update_film_grain_parameters(cpi, oxcf);
// Single thread case: use counts in common.
cpi->td.counts = &cpi->counts;
cpi->use_svc = 0;
cpi->svc.external_ref_frame_config = 0;
cpi->svc.non_reference_frame = 0;
cm->number_spatial_layers = 1;
cm->number_temporal_layers = 1;
// change includes all joint functionality
av1_change_config(cpi, oxcf);
cpi->static_mb_pct = 0;
cpi->ref_frame_flags = 0;
// Reset resize pending flags
cpi->resize_pending_width = 0;
cpi->resize_pending_height = 0;
init_buffer_indices(cpi);
}
static void set_rc_buffer_sizes(RATE_CONTROL *rc,
const AV1EncoderConfig *oxcf) {
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;
rc->optimal_buffer_level =
(optimal == 0) ? bandwidth / 8 : optimal * bandwidth / 1000;
rc->maximum_buffer_size =
(maximum == 0) ? bandwidth / 8 : maximum * bandwidth / 1000;
}
#define HIGHBD_BFP(BT, SDF, SDAF, VF, SVF, SVAF, SDX4DF, JSDAF, JSVAF) \
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].sdx4df = SDX4DF; \
cpi->fn_ptr[BT].jsdaf = JSDAF; \
cpi->fn_ptr[BT].jsvaf = JSVAF;
#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_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; \
}
#define MAKE_BFP_JSADAVG_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, \
const DIST_WTD_COMP_PARAMS *jcp_param) { \
return fnname(src_ptr, source_stride, ref_ptr, ref_stride, second_pred, \
jcp_param); \
} \
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, \
const DIST_WTD_COMP_PARAMS *jcp_param) { \
return fnname(src_ptr, source_stride, ref_ptr, ref_stride, second_pred, \
jcp_param) >> \
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, \
const DIST_WTD_COMP_PARAMS *jcp_param) { \
return fnname(src_ptr, source_stride, ref_ptr, ref_stride, second_pred, \
jcp_param) >> \
4; \
}
#if CONFIG_AV1_HIGHBITDEPTH
MAKE_BFP_SAD_WRAPPER(aom_highbd_sad128x128)
MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad128x128_avg)
MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad128x128x4d)
MAKE_BFP_SAD_WRAPPER(aom_highbd_sad128x64)
MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad128x64_avg)
MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad128x64x4d)
MAKE_BFP_SAD_WRAPPER(aom_highbd_sad64x128)
MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad64x128_avg)
MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad64x128x4d)
MAKE_BFP_SAD_WRAPPER(aom_highbd_sad32x16)
MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad32x16_avg)
MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad32x16x4d)
MAKE_BFP_SAD_WRAPPER(aom_highbd_sad16x32)
MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad16x32_avg)
MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad16x32x4d)
MAKE_BFP_SAD_WRAPPER(aom_highbd_sad64x32)
MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad64x32_avg)
MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad64x32x4d)
MAKE_BFP_SAD_WRAPPER(aom_highbd_sad32x64)
MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad32x64_avg)
MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad32x64x4d)
MAKE_BFP_SAD_WRAPPER(aom_highbd_sad32x32)
MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad32x32_avg)
MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad32x32x4d)
MAKE_BFP_SAD_WRAPPER(aom_highbd_sad64x64)
MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad64x64_avg)
MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad64x64x4d)
MAKE_BFP_SAD_WRAPPER(aom_highbd_sad16x16)
MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad16x16_avg)
MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad16x16x4d)
MAKE_BFP_SAD_WRAPPER(aom_highbd_sad16x8)
MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad16x8_avg)
MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad16x8x4d)
MAKE_BFP_SAD_WRAPPER(aom_highbd_sad8x16)
MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad8x16_avg)
MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad8x16x4d)
MAKE_BFP_SAD_WRAPPER(aom_highbd_sad8x8)
MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad8x8_avg)
MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad8x8x4d)
MAKE_BFP_SAD_WRAPPER(aom_highbd_sad8x4)
MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad8x4_avg)
MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad8x4x4d)
MAKE_BFP_SAD_WRAPPER(aom_highbd_sad4x8)
MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad4x8_avg)
MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad4x8x4d)
MAKE_BFP_SAD_WRAPPER(aom_highbd_sad4x4)
MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad4x4_avg)
MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad4x4x4d)
MAKE_BFP_SAD_WRAPPER(aom_highbd_sad4x16)
MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad4x16_avg)
MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad4x16x4d)
MAKE_BFP_SAD_WRAPPER(aom_highbd_sad16x4)
MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad16x4_avg)
MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad16x4x4d)
MAKE_BFP_SAD_WRAPPER(aom_highbd_sad8x32)
MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad8x32_avg)
MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad8x32x4d)
MAKE_BFP_SAD_WRAPPER(aom_highbd_sad32x8)
MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad32x8_avg)
MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad32x8x4d)
MAKE_BFP_SAD_WRAPPER(aom_highbd_sad16x64)
MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad16x64_avg)
MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad16x64x4d)
MAKE_BFP_SAD_WRAPPER(aom_highbd_sad64x16)
MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad64x16_avg)
MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad64x16x4d)
MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad128x128_avg)
MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad128x64_avg)
MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad64x128_avg)
MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad32x16_avg)
MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad16x32_avg)
MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad64x32_avg)
MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad32x64_avg)
MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad32x32_avg)
MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad64x64_avg)
MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad16x16_avg)
MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad16x8_avg)
MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad8x16_avg)
MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad8x8_avg)
MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad8x4_avg)
MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad4x8_avg)
MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad4x4_avg)
MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad4x16_avg)
MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad16x4_avg)
MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad8x32_avg)
MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad32x8_avg)
MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad16x64_avg)
MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad64x16_avg)
#endif // CONFIG_AV1_HIGHBITDEPTH
#define HIGHBD_MBFP(BT, MCSDF, MCSVF) \
cpi->fn_ptr[BT].msdf = MCSDF; \
cpi->fn_ptr[BT].msvf = MCSVF;
#define MAKE_MBFP_COMPOUND_SAD_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_ptr, const uint8_t *m, \
int m_stride, int invert_mask) { \
return fnname(src_ptr, source_stride, ref_ptr, ref_stride, \
second_pred_ptr, m, m_stride, invert_mask); \
} \
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_ptr, const uint8_t *m, \
int m_stride, int invert_mask) { \
return fnname(src_ptr, source_stride, ref_ptr, ref_stride, \
second_pred_ptr, m, m_stride, invert_mask) >> \
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_ptr, const uint8_t *m, \
int m_stride, int invert_mask) { \
return fnname(src_ptr, source_stride, ref_ptr, ref_stride, \
second_pred_ptr, m, m_stride, invert_mask) >> \
4; \
}
#if CONFIG_AV1_HIGHBITDEPTH
MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad128x128)
MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad128x64)
MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad64x128)
MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad64x64)
MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad64x32)
MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad32x64)
MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad32x32)
MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad32x16)
MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad16x32)
MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad16x16)
MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad16x8)
MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad8x16)
MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad8x8)
MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad8x4)
MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad4x8)
MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad4x4)
MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad4x16)
MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad16x4)
MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad8x32)
MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad32x8)
MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad16x64)
MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad64x16)
#endif
#define HIGHBD_OBFP(BT, OSDF, OVF, OSVF) \
cpi->fn_ptr[BT].osdf = OSDF; \
cpi->fn_ptr[BT].ovf = OVF; \
cpi->fn_ptr[BT].osvf = OSVF;
#define MAKE_OBFP_SAD_WRAPPER(fnname) \
static unsigned int fnname##_bits8(const uint8_t *ref, int ref_stride, \
const int32_t *wsrc, \
const int32_t *msk) { \
return fnname(ref, ref_stride, wsrc, msk); \
} \
static unsigned int fnname##_bits10(const uint8_t *ref, int ref_stride, \
const int32_t *wsrc, \
const int32_t *msk) { \
return fnname(ref, ref_stride, wsrc, msk) >> 2; \
} \
static unsigned int fnname##_bits12(const uint8_t *ref, int ref_stride, \
const int32_t *wsrc, \
const int32_t *msk) { \
return fnname(ref, ref_stride, wsrc, msk) >> 4; \
}
#if CONFIG_AV1_HIGHBITDEPTH
MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad128x128)
MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad128x64)
MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad64x128)
MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad64x64)
MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad64x32)
MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad32x64)
MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad32x32)
MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad32x16)
MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad16x32)
MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad16x16)
MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad16x8)
MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad8x16)
MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad8x8)
MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad8x4)
MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad4x8)
MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad4x4)
MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad4x16)
MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad16x4)
MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad8x32)
MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad32x8)
MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad16x64)
MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad64x16)
static void highbd_set_var_fns(AV1_COMP *const cpi) {
AV1_COMMON *const cm = &cpi->common;
if (cm->seq_params.use_highbitdepth) {
switch (cm->seq_params.bit_depth) {
case AOM_BITS_8:
HIGHBD_BFP(BLOCK_64X16, aom_highbd_sad64x16_bits8,
aom_highbd_sad64x16_avg_bits8, aom_highbd_8_variance64x16,
aom_highbd_8_sub_pixel_variance64x16,
aom_highbd_8_sub_pixel_avg_variance64x16,
aom_highbd_sad64x16x4d_bits8,
aom_highbd_dist_wtd_sad64x16_avg_bits8,
aom_highbd_8_dist_wtd_sub_pixel_avg_variance64x16)
HIGHBD_BFP(BLOCK_16X64, aom_highbd_sad16x64_bits8,
aom_highbd_sad16x64_avg_bits8, aom_highbd_8_variance16x64,
aom_highbd_8_sub_pixel_variance16x64,
aom_highbd_8_sub_pixel_avg_variance16x64,
aom_highbd_sad16x64x4d_bits8,
aom_highbd_dist_wtd_sad16x64_avg_bits8,
aom_highbd_8_dist_wtd_sub_pixel_avg_variance16x64)
HIGHBD_BFP(
BLOCK_32X8, aom_highbd_sad32x8_bits8, aom_highbd_sad32x8_avg_bits8,
aom_highbd_8_variance32x8, aom_highbd_8_sub_pixel_variance32x8,
aom_highbd_8_sub_pixel_avg_variance32x8,
aom_highbd_sad32x8x4d_bits8, aom_highbd_dist_wtd_sad32x8_avg_bits8,
aom_highbd_8_dist_wtd_sub_pixel_avg_variance32x8)
HIGHBD_BFP(
BLOCK_8X32, aom_highbd_sad8x32_bits8, aom_highbd_sad8x32_avg_bits8,
aom_highbd_8_variance8x32, aom_highbd_8_sub_pixel_variance8x32,
aom_highbd_8_sub_pixel_avg_variance8x32,
aom_highbd_sad8x32x4d_bits8, aom_highbd_dist_wtd_sad8x32_avg_bits8,
aom_highbd_8_dist_wtd_sub_pixel_avg_variance8x32)
HIGHBD_BFP(
BLOCK_16X4, aom_highbd_sad16x4_bits8, aom_highbd_sad16x4_avg_bits8,
aom_highbd_8_variance16x4, aom_highbd_8_sub_pixel_variance16x4,
aom_highbd_8_sub_pixel_avg_variance16x4,
aom_highbd_sad16x4x4d_bits8, aom_highbd_dist_wtd_sad16x4_avg_bits8,
aom_highbd_8_dist_wtd_sub_pixel_avg_variance16x4)
HIGHBD_BFP(
BLOCK_4X16, aom_highbd_sad4x16_bits8, aom_highbd_sad4x16_avg_bits8,
aom_highbd_8_variance4x16, aom_highbd_8_sub_pixel_variance4x16,
aom_highbd_8_sub_pixel_avg_variance4x16,
aom_highbd_sad4x16x4d_bits8, aom_highbd_dist_wtd_sad4x16_avg_bits8,
aom_highbd_8_dist_wtd_sub_pixel_avg_variance4x16)
HIGHBD_BFP(BLOCK_32X16, aom_highbd_sad32x16_bits8,
aom_highbd_sad32x16_avg_bits8, aom_highbd_8_variance32x16,
aom_highbd_8_sub_pixel_variance32x16,
aom_highbd_8_sub_pixel_avg_variance32x16,
aom_highbd_sad32x16x4d_bits8,
aom_highbd_dist_wtd_sad32x16_avg_bits8,
aom_highbd_8_dist_wtd_sub_pixel_avg_variance32x16)
HIGHBD_BFP(BLOCK_16X32, aom_highbd_sad16x32_bits8,
aom_highbd_sad16x32_avg_bits8, aom_highbd_8_variance16x32,
aom_highbd_8_sub_pixel_variance16x32,
aom_highbd_8_sub_pixel_avg_variance16x32,
aom_highbd_sad16x32x4d_bits8,
aom_highbd_dist_wtd_sad16x32_avg_bits8,
aom_highbd_8_dist_wtd_sub_pixel_avg_variance16x32)
HIGHBD_BFP(BLOCK_64X32, aom_highbd_sad64x32_bits8,
aom_highbd_sad64x32_avg_bits8, aom_highbd_8_variance64x32,
aom_highbd_8_sub_pixel_variance64x32,
aom_highbd_8_sub_pixel_avg_variance64x32,
aom_highbd_sad64x32x4d_bits8,
aom_highbd_dist_wtd_sad64x32_avg_bits8,
aom_highbd_8_dist_wtd_sub_pixel_avg_variance64x32)
HIGHBD_BFP(BLOCK_32X64, aom_highbd_sad32x64_bits8,
aom_highbd_sad32x64_avg_bits8, aom_highbd_8_variance32x64,
aom_highbd_8_sub_pixel_variance32x64,
aom_highbd_8_sub_pixel_avg_variance32x64,
aom_highbd_sad32x64x4d_bits8,
aom_highbd_dist_wtd_sad32x64_avg_bits8,
aom_highbd_8_dist_wtd_sub_pixel_avg_variance32x64)
HIGHBD_BFP(BLOCK_32X32, aom_highbd_sad32x32_bits8,
aom_highbd_sad32x32_avg_bits8, aom_highbd_8_variance32x32,
aom_highbd_8_sub_pixel_variance32x32,
aom_highbd_8_sub_pixel_avg_variance32x32,
aom_highbd_sad32x32x4d_bits8,
aom_highbd_dist_wtd_sad32x32_avg_bits8,
aom_highbd_8_dist_wtd_sub_pixel_avg_variance32x32)
HIGHBD_BFP(BLOCK_64X64, aom_highbd_sad64x64_bits8,
aom_highbd_sad64x64_avg_bits8, aom_highbd_8_variance64x64,
aom_highbd_8_sub_pixel_variance64x64,
aom_highbd_8_sub_pixel_avg_variance64x64,
aom_highbd_sad64x64x4d_bits8,
aom_highbd_dist_wtd_sad64x64_avg_bits8,
aom_highbd_8_dist_wtd_sub_pixel_avg_variance64x64)
HIGHBD_BFP(BLOCK_16X16, aom_highbd_sad16x16_bits8,
aom_highbd_sad16x16_avg_bits8, aom_highbd_8_variance16x16,
aom_highbd_8_sub_pixel_variance16x16,
aom_highbd_8_sub_pixel_avg_variance16x16,
aom_highbd_sad16x16x4d_bits8,
aom_highbd_dist_wtd_sad16x16_avg_bits8,
aom_highbd_8_dist_wtd_sub_pixel_avg_variance16x16)
HIGHBD_BFP(
BLOCK_16X8, aom_highbd_sad16x8_bits8, aom_highbd_sad16x8_avg_bits8,
aom_highbd_8_variance16x8, aom_highbd_8_sub_pixel_variance16x8,
aom_highbd_8_sub_pixel_avg_variance16x8,
aom_highbd_sad16x8x4d_bits8, aom_highbd_dist_wtd_sad16x8_avg_bits8,
aom_highbd_8_dist_wtd_sub_pixel_avg_variance16x8)
HIGHBD_BFP(
BLOCK_8X16, aom_highbd_sad8x16_bits8, aom_highbd_sad8x16_avg_bits8,
aom_highbd_8_variance8x16, aom_highbd_8_sub_pixel_variance8x16,
aom_highbd_8_sub_pixel_avg_variance8x16,
aom_highbd_sad8x16x4d_bits8, aom_highbd_dist_wtd_sad8x16_avg_bits8,
aom_highbd_8_dist_wtd_sub_pixel_avg_variance8x16)
HIGHBD_BFP(
BLOCK_8X8, aom_highbd_sad8x8_bits8, aom_highbd_sad8x8_avg_bits8,
aom_highbd_8_variance8x8, aom_highbd_8_sub_pixel_variance8x8,
aom_highbd_8_sub_pixel_avg_variance8x8, aom_highbd_sad8x8x4d_bits8,
aom_highbd_dist_wtd_sad8x8_avg_bits8,
aom_highbd_8_dist_wtd_sub_pixel_avg_variance8x8)
HIGHBD_BFP(
BLOCK_8X4, aom_highbd_sad8x4_bits8, aom_highbd_sad8x4_avg_bits8,
aom_highbd_8_variance8x4, aom_highbd_8_sub_pixel_variance8x4,
aom_highbd_8_sub_pixel_avg_variance8x4, aom_highbd_sad8x4x4d_bits8,
aom_highbd_dist_wtd_sad8x4_avg_bits8,
aom_highbd_8_dist_wtd_sub_pixel_avg_variance8x4)
HIGHBD_BFP(
BLOCK_4X8, aom_highbd_sad4x8_bits8, aom_highbd_sad4x8_avg_bits8,
aom_highbd_8_variance4x8, aom_highbd_8_sub_pixel_variance4x8,
aom_highbd_8_sub_pixel_avg_variance4x8, aom_highbd_sad4x8x4d_bits8,
aom_highbd_dist_wtd_sad4x8_avg_bits8,
aom_highbd_8_dist_wtd_sub_pixel_avg_variance4x8)
HIGHBD_BFP(
BLOCK_4X4, aom_highbd_sad4x4_bits8, aom_highbd_sad4x4_avg_bits8,
aom_highbd_8_variance4x4, aom_highbd_8_sub_pixel_variance4x4,
aom_highbd_8_sub_pixel_avg_variance4x4, aom_highbd_sad4x4x4d_bits8,
aom_highbd_dist_wtd_sad4x4_avg_bits8,
aom_highbd_8_dist_wtd_sub_pixel_avg_variance4x4)
HIGHBD_BFP(BLOCK_128X128, aom_highbd_sad128x128_bits8,
aom_highbd_sad128x128_avg_bits8,
aom_highbd_8_variance128x128,
aom_highbd_8_sub_pixel_variance128x128,
aom_highbd_8_sub_pixel_avg_variance128x128,
aom_highbd_sad128x128x4d_bits8,
aom_highbd_dist_wtd_sad128x128_avg_bits8,
aom_highbd_8_dist_wtd_sub_pixel_avg_variance128x128)
HIGHBD_BFP(BLOCK_128X64, aom_highbd_sad128x64_bits8,
aom_highbd_sad128x64_avg_bits8, aom_highbd_8_variance128x64,
aom_highbd_8_sub_pixel_variance128x64,
aom_highbd_8_sub_pixel_avg_variance128x64,
aom_highbd_sad128x64x4d_bits8,
aom_highbd_dist_wtd_sad128x64_avg_bits8,
aom_highbd_8_dist_wtd_sub_pixel_avg_variance128x64)
HIGHBD_BFP(BLOCK_64X128, aom_highbd_sad64x128_bits8,
aom_highbd_sad64x128_avg_bits8, aom_highbd_8_variance64x128,
aom_highbd_8_sub_pixel_variance64x128,
aom_highbd_8_sub_pixel_avg_variance64x128,
aom_highbd_sad64x128x4d_bits8,
aom_highbd_dist_wtd_sad64x128_avg_bits8,
aom_highbd_8_dist_wtd_sub_pixel_avg_variance64x128)
HIGHBD_MBFP(BLOCK_128X128, aom_highbd_masked_sad128x128_bits8,
aom_highbd_8_masked_sub_pixel_variance128x128)
HIGHBD_MBFP(BLOCK_128X64, aom_highbd_masked_sad128x64_bits8,
aom_highbd_8_masked_sub_pixel_variance128x64)
HIGHBD_MBFP(BLOCK_64X128, aom_highbd_masked_sad64x128_bits8,
aom_highbd_8_masked_sub_pixel_variance64x128)
HIGHBD_MBFP(BLOCK_64X64, aom_highbd_masked_sad64x64_bits8,
aom_highbd_8_masked_sub_pixel_variance64x64)
HIGHBD_MBFP(BLOCK_64X32, aom_highbd_masked_sad64x32_bits8,
aom_highbd_8_masked_sub_pixel_variance64x32)
HIGHBD_MBFP(BLOCK_32X64, aom_highbd_masked_sad32x64_bits8,
aom_highbd_8_masked_sub_pixel_variance32x64)
HIGHBD_MBFP(BLOCK_32X32, aom_highbd_masked_sad32x32_bits8,
aom_highbd_8_masked_sub_pixel_variance32x32)
HIGHBD_MBFP(BLOCK_32X16, aom_highbd_masked_sad32x16_bits8,
aom_highbd_8_masked_sub_pixel_variance32x16)
HIGHBD_MBFP(BLOCK_16X32, aom_highbd_masked_sad16x32_bits8,
aom_highbd_8_masked_sub_pixel_variance16x32)
HIGHBD_MBFP(BLOCK_16X16, aom_highbd_masked_sad16x16_bits8,
aom_highbd_8_masked_sub_pixel_variance16x16)
HIGHBD_MBFP(BLOCK_8X16, aom_highbd_masked_sad8x16_bits8,
aom_highbd_8_masked_sub_pixel_variance8x16)
HIGHBD_MBFP(BLOCK_16X8, aom_highbd_masked_sad16x8_bits8,
aom_highbd_8_masked_sub_pixel_variance16x8)
HIGHBD_MBFP(BLOCK_8X8, aom_highbd_masked_sad8x8_bits8,
aom_highbd_8_masked_sub_pixel_variance8x8)
HIGHBD_MBFP(BLOCK_4X8, aom_highbd_masked_sad4x8_bits8,
aom_highbd_8_masked_sub_pixel_variance4x8)
HIGHBD_MBFP(BLOCK_8X4, aom_highbd_masked_sad8x4_bits8,
aom_highbd_8_masked_sub_pixel_variance8x4)
HIGHBD_MBFP(BLOCK_4X4, aom_highbd_masked_sad4x4_bits8,
aom_highbd_8_masked_sub_pixel_variance4x4)
HIGHBD_MBFP(BLOCK_64X16, aom_highbd_masked_sad64x16_bits8,
aom_highbd_8_masked_sub_pixel_variance64x16)
HIGHBD_MBFP(BLOCK_16X64, aom_highbd_masked_sad16x64_bits8,
aom_highbd_8_masked_sub_pixel_variance16x64)
HIGHBD_MBFP(BLOCK_32X8, aom_highbd_masked_sad32x8_bits8,
aom_highbd_8_masked_sub_pixel_variance32x8)
HIGHBD_MBFP(BLOCK_8X32, aom_highbd_masked_sad8x32_bits8,
aom_highbd_8_masked_sub_pixel_variance8x32)
HIGHBD_MBFP(BLOCK_16X4, aom_highbd_masked_sad16x4_bits8,
aom_highbd_8_masked_sub_pixel_variance16x4)
HIGHBD_MBFP(BLOCK_4X16, aom_highbd_masked_sad4x16_bits8,
aom_highbd_8_masked_sub_pixel_variance4x16)
HIGHBD_OBFP(BLOCK_128X128, aom_highbd_obmc_sad128x128_bits8,
aom_highbd_obmc_variance128x128,
aom_highbd_obmc_sub_pixel_variance128x128)
HIGHBD_OBFP(BLOCK_128X64, aom_highbd_obmc_sad128x64_bits8,
aom_highbd_obmc_variance128x64,
aom_highbd_obmc_sub_pixel_variance128x64)
HIGHBD_OBFP(BLOCK_64X128, aom_highbd_obmc_sad64x128_bits8,
aom_highbd_obmc_variance64x128,
aom_highbd_obmc_sub_pixel_variance64x128)
HIGHBD_OBFP(BLOCK_64X64, aom_highbd_obmc_sad64x64_bits8,
aom_highbd_obmc_variance64x64,
aom_highbd_obmc_sub_pixel_variance64x64)
HIGHBD_OBFP(BLOCK_64X32, aom_highbd_obmc_sad64x32_bits8,
aom_highbd_obmc_variance64x32,
aom_highbd_obmc_sub_pixel_variance64x32)
HIGHBD_OBFP(BLOCK_32X64, aom_highbd_obmc_sad32x64_bits8,
aom_highbd_obmc_variance32x64,
aom_highbd_obmc_sub_pixel_variance32x64)
HIGHBD_OBFP(BLOCK_32X32, aom_highbd_obmc_sad32x32_bits8,
aom_highbd_obmc_variance32x32,
aom_highbd_obmc_sub_pixel_variance32x32)
HIGHBD_OBFP(BLOCK_32X16, aom_highbd_obmc_sad32x16_bits8,
aom_highbd_obmc_variance32x16,
aom_highbd_obmc_sub_pixel_variance32x16)
HIGHBD_OBFP(BLOCK_16X32, aom_highbd_obmc_sad16x32_bits8,
aom_highbd_obmc_variance16x32,
aom_highbd_obmc_sub_pixel_variance16x32)
HIGHBD_OBFP(BLOCK_16X16, aom_highbd_obmc_sad16x16_bits8,
aom_highbd_obmc_variance16x16,
aom_highbd_obmc_sub_pixel_variance16x16)
HIGHBD_OBFP(BLOCK_8X16, aom_highbd_obmc_sad8x16_bits8,
aom_highbd_obmc_variance8x16,
aom_highbd_obmc_sub_pixel_variance8x16)
HIGHBD_OBFP(BLOCK_16X8, aom_highbd_obmc_sad16x8_bits8,
aom_highbd_obmc_variance16x8,
aom_highbd_obmc_sub_pixel_variance16x8)
HIGHBD_OBFP(BLOCK_8X8, aom_highbd_obmc_sad8x8_bits8,
aom_highbd_obmc_variance8x8,
aom_highbd_obmc_sub_pixel_variance8x8)
HIGHBD_OBFP(BLOCK_4X8, aom_highbd_obmc_sad4x8_bits8,
aom_highbd_obmc_variance4x8,
aom_highbd_obmc_sub_pixel_variance4x8)
HIGHBD_OBFP(BLOCK_8X4, aom_highbd_obmc_sad8x4_bits8,
aom_highbd_obmc_variance8x4,
aom_highbd_obmc_sub_pixel_variance8x4)
HIGHBD_OBFP(BLOCK_4X4, aom_highbd_obmc_sad4x4_bits8,
aom_highbd_obmc_variance4x4,
aom_highbd_obmc_sub_pixel_variance4x4)
HIGHBD_OBFP(BLOCK_64X16, aom_highbd_obmc_sad64x16_bits8,
aom_highbd_obmc_variance64x16,
aom_highbd_obmc_sub_pixel_variance64x16)
HIGHBD_OBFP(BLOCK_16X64, aom_highbd_obmc_sad16x64_bits8,
aom_highbd_obmc_variance16x64,
aom_highbd_obmc_sub_pixel_variance16x64)
HIGHBD_OBFP(BLOCK_32X8, aom_highbd_obmc_sad32x8_bits8,
aom_highbd_obmc_variance32x8,
aom_highbd_obmc_sub_pixel_variance32x8)
HIGHBD_OBFP(BLOCK_8X32, aom_highbd_obmc_sad8x32_bits8,
aom_highbd_obmc_variance8x32,
aom_highbd_obmc_sub_pixel_variance8x32)
HIGHBD_OBFP(BLOCK_16X4, aom_highbd_obmc_sad16x4_bits8,
aom_highbd_obmc_variance16x4,
aom_highbd_obmc_sub_pixel_variance16x4)
HIGHBD_OBFP(BLOCK_4X16, aom_highbd_obmc_sad4x16_bits8,
aom_highbd_obmc_variance4x16,
aom_highbd_obmc_sub_pixel_variance4x16)
break;
case AOM_BITS_10:
HIGHBD_BFP(BLOCK_64X16, aom_highbd_sad64x16_bits10,
aom_highbd_sad64x16_avg_bits10, aom_highbd_10_variance64x16,
aom_highbd_10_sub_pixel_variance64x16,
aom_highbd_10_sub_pixel_avg_variance64x16,
aom_highbd_sad64x16x4d_bits10,
aom_highbd_dist_wtd_sad64x16_avg_bits10,
aom_highbd_10_dist_wtd_sub_pixel_avg_variance64x16);
HIGHBD_BFP(BLOCK_16X64, aom_highbd_sad16x64_bits10,
aom_highbd_sad16x64_avg_bits10, aom_highbd_10_variance16x64,
aom_highbd_10_sub_pixel_variance16x64,
aom_highbd_10_sub_pixel_avg_variance16x64,
aom_highbd_sad16x64x4d_bits10,
aom_highbd_dist_wtd_sad16x64_avg_bits10,
aom_highbd_10_dist_wtd_sub_pixel_avg_variance16x64);
HIGHBD_BFP(BLOCK_32X8, aom_highbd_sad32x8_bits10,
aom_highbd_sad32x8_avg_bits10, aom_highbd_10_variance32x8,
aom_highbd_10_sub_pixel_variance32x8,
aom_highbd_10_sub_pixel_avg_variance32x8,
aom_highbd_sad32x8x4d_bits10,
aom_highbd_dist_wtd_sad32x8_avg_bits10,
aom_highbd_10_dist_wtd_sub_pixel_avg_variance32x8);
HIGHBD_BFP(BLOCK_8X32, aom_highbd_sad8x32_bits10,
aom_highbd_sad8x32_avg_bits10, aom_highbd_10_variance8x32,
aom_highbd_10_sub_pixel_variance8x32,
aom_highbd_10_sub_pixel_avg_variance8x32,
aom_highbd_sad8x32x4d_bits10,
aom_highbd_dist_wtd_sad8x32_avg_bits10,
aom_highbd_10_dist_wtd_sub_pixel_avg_variance8x32);
HIGHBD_BFP(BLOCK_16X4, aom_highbd_sad16x4_bits10,
aom_highbd_sad16x4_avg_bits10, aom_highbd_10_variance16x4,
aom_highbd_10_sub_pixel_variance16x4,
aom_highbd_10_sub_pixel_avg_variance16x4,
aom_highbd_sad16x4x4d_bits10,
aom_highbd_dist_wtd_sad16x4_avg_bits10,
aom_highbd_10_dist_wtd_sub_pixel_avg_variance16x4);
HIGHBD_BFP(BLOCK_4X16, aom_highbd_sad4x16_bits10,
aom_highbd_sad4x16_avg_bits10, aom_highbd_10_variance4x16,
aom_highbd_10_sub_pixel_variance4x16,
aom_highbd_10_sub_pixel_avg_variance4x16,
aom_highbd_sad4x16x4d_bits10,
aom_highbd_dist_wtd_sad4x16_avg_bits10,
aom_highbd_10_dist_wtd_sub_pixel_avg_variance4x16);
HIGHBD_BFP(BLOCK_32X16, aom_highbd_sad32x16_bits10,
aom_highbd_sad32x16_avg_bits10, aom_highbd_10_variance32x16,
aom_highbd_10_sub_pixel_variance32x16,
aom_highbd_10_sub_pixel_avg_variance32x16,
aom_highbd_sad32x16x4d_bits10,
aom_highbd_dist_wtd_sad32x16_avg_bits10,
aom_highbd_10_dist_wtd_sub_pixel_avg_variance32x16);
HIGHBD_BFP(BLOCK_16X32, aom_highbd_sad16x32_bits10,
aom_highbd_sad16x32_avg_bits10, aom_highbd_10_variance16x32,
aom_highbd_10_sub_pixel_variance16x32,
aom_highbd_10_sub_pixel_avg_variance16x32,
aom_highbd_sad16x32x4d_bits10,
aom_highbd_dist_wtd_sad16x32_avg_bits10,
aom_highbd_10_dist_wtd_sub_pixel_avg_variance16x32);
HIGHBD_BFP(BLOCK_64X32, aom_highbd_sad64x32_bits10,
aom_highbd_sad64x32_avg_bits10, aom_highbd_10_variance64x32,
aom_highbd_10_sub_pixel_variance64x32,
aom_highbd_10_sub_pixel_avg_variance64x32,
aom_highbd_sad64x32x4d_bits10,
aom_highbd_dist_wtd_sad64x32_avg_bits10,
aom_highbd_10_dist_wtd_sub_pixel_avg_variance64x32);
HIGHBD_BFP(BLOCK_32X64, aom_highbd_sad32x64_bits10,
aom_highbd_sad32x64_avg_bits10, aom_highbd_10_variance32x64,
aom_highbd_10_sub_pixel_variance32x64,
aom_highbd_10_sub_pixel_avg_variance32x64,
aom_highbd_sad32x64x4d_bits10,
aom_highbd_dist_wtd_sad32x64_avg_bits10,
aom_highbd_10_dist_wtd_sub_pixel_avg_variance32x64);
HIGHBD_BFP(BLOCK_32X32, aom_highbd_sad32x32_bits10,
aom_highbd_sad32x32_avg_bits10, aom_highbd_10_variance32x32,
aom_highbd_10_sub_pixel_variance32x32,
aom_highbd_10_sub_pixel_avg_variance32x32,
aom_highbd_sad32x32x4d_bits10,
aom_highbd_dist_wtd_sad32x32_avg_bits10,
aom_highbd_10_dist_wtd_sub_pixel_avg_variance32x32);
HIGHBD_BFP(BLOCK_64X64, aom_highbd_sad64x64_bits10,
aom_highbd_sad64x64_avg_bits10, aom_highbd_10_variance64x64,
aom_highbd_10_sub_pixel_variance64x64,
aom_highbd_10_sub_pixel_avg_variance64x64,
aom_highbd_sad64x64x4d_bits10,
aom_highbd_dist_wtd_sad64x64_avg_bits10,
aom_highbd_10_dist_wtd_sub_pixel_avg_variance64x64);
HIGHBD_BFP(BLOCK_16X16, aom_highbd_sad16x16_bits10,
aom_highbd_sad16x16_avg_bits10, aom_highbd_10_variance16x16,
aom_highbd_10_sub_pixel_variance16x16,
aom_highbd_10_sub_pixel_avg_variance16x16,
aom_highbd_sad16x16x4d_bits10,
aom_highbd_dist_wtd_sad16x16_avg_bits10,
aom_highbd_10_dist_wtd_sub_pixel_avg_variance16x16);
HIGHBD_BFP(BLOCK_16X8, aom_highbd_sad16x8_bits10,
aom_highbd_sad16x8_avg_bits10, aom_highbd_10_variance16x8,
aom_highbd_10_sub_pixel_variance16x8,
aom_highbd_10_sub_pixel_avg_variance16x8,
aom_highbd_sad16x8x4d_bits10,
aom_highbd_dist_wtd_sad16x8_avg_bits10,
aom_highbd_10_dist_wtd_sub_pixel_avg_variance16x8);
HIGHBD_BFP(BLOCK_8X16, aom_highbd_sad8x16_bits10,
aom_highbd_sad8x16_avg_bits10, aom_highbd_10_variance8x16,
aom_highbd_10_sub_pixel_variance8x16,
aom_highbd_10_sub_pixel_avg_variance8x16,
aom_highbd_sad8x16x4d_bits10,
aom_highbd_dist_wtd_sad8x16_avg_bits10,
aom_highbd_10_dist_wtd_sub_pixel_avg_variance8x16);
HIGHBD_BFP(
BLOCK_8X8, aom_highbd_sad8x8_bits10, aom_highbd_sad8x8_avg_bits10,
aom_highbd_10_variance8x8, aom_highbd_10_sub_pixel_variance8x8,
aom_highbd_10_sub_pixel_avg_variance8x8,
aom_highbd_sad8x8x4d_bits10, aom_highbd_dist_wtd_sad8x8_avg_bits10,
aom_highbd_10_dist_wtd_sub_pixel_avg_variance8x8);
HIGHBD_BFP(
BLOCK_8X4, aom_highbd_sad8x4_bits10, aom_highbd_sad8x4_avg_bits10,
aom_highbd_10_variance8x4, aom_highbd_10_sub_pixel_variance8x4,
aom_highbd_10_sub_pixel_avg_variance8x4,
aom_highbd_sad8x4x4d_bits10, aom_highbd_dist_wtd_sad8x4_avg_bits10,
aom_highbd_10_dist_wtd_sub_pixel_avg_variance8x4);
HIGHBD_BFP(
BLOCK_4X8, aom_highbd_sad4x8_bits10, aom_highbd_sad4x8_avg_bits10,
aom_highbd_10_variance4x8, aom_highbd_10_sub_pixel_variance4x8,
aom_highbd_10_sub_pixel_avg_variance4x8,
aom_highbd_sad4x8x4d_bits10, aom_highbd_dist_wtd_sad4x8_avg_bits10,
aom_highbd_10_dist_wtd_sub_pixel_avg_variance4x8);