2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
11 #ifndef VP9_ENCODER_VP9_BLOCK_H_
12 #define VP9_ENCODER_VP9_BLOCK_H_
14 #include "vpx_util/vpx_thread.h"
16 #include "vp9/common/vp9_entropymv.h"
17 #include "vp9/common/vp9_entropy.h"
29 struct macroblock_plane {
30 DECLARE_ALIGNED(16, int16_t, src_diff[64 * 64]);
44 int64_t quant_thred[2];
47 /* The [2] dimension is for whether we skip the EOB node (i.e. if previous
48 * coefficient in this block was zero) or not. */
49 typedef unsigned int vp9_coeff_cost[PLANE_TYPES][REF_TYPES][COEF_BANDS][2]
50 [COEFF_CONTEXTS][ENTROPY_TOKENS];
53 int_mv ref_mvs[MAX_REF_FRAMES][MAX_MV_REF_CANDIDATES];
54 uint8_t mode_context[MAX_REF_FRAMES];
64 typedef struct macroblock MACROBLOCK;
66 // cf. https://bugs.chromium.org/p/webm/issues/detail?id=1054
67 #if defined(_MSC_VER) && _MSC_VER < 1900
68 int64_t bsse[MAX_MB_PLANE << 2];
71 struct macroblock_plane plane[MAX_MB_PLANE];
74 MB_MODE_INFO_EXT *mbmi_ext;
75 MB_MODE_INFO_EXT *mbmi_ext_base;
84 // The equivalent error at the current rdmult of one whole bit (not one
87 // The equivalend SAD error of one (whole) bit at the current quantizer
90 // The equivalend SAD error of one (whole) bit at the current quantizer
91 // for sub-8x8 blocks.
98 // These are set to their default values at the beginning, and then adjusted
99 // further in the encoding process.
100 BLOCK_SIZE min_partition_size;
101 BLOCK_SIZE max_partition_size;
103 int mv_best_ref_index[MAX_REF_FRAMES];
104 unsigned int max_mv_context[MAX_REF_FRAMES];
105 unsigned int source_variance;
106 unsigned int pred_sse[MAX_REF_FRAMES];
107 int pred_mv_sad[MAX_REF_FRAMES];
109 int nmvjointcost[MV_JOINTS];
114 int nmvjointsadcost[MV_JOINTS];
116 int *nmvsadcost_hp[2];
119 // These define limits to motion vector components to prevent them
120 // from extending outside the UMV borders
123 // Notes transform blocks where no coefficents are coded.
124 // Set during mode selection. Read during block encoding.
125 uint8_t zcoeff_blk[TX_SIZES][256];
127 // Accumulate the tx block eobs in a partition block.
128 int32_t sum_y_eobs[TX_SIZES];
134 // note that token_costs is the cost when eob node is skipped
135 vp9_coeff_cost token_costs[TX_SIZES];
139 // indicate if it is in the rd search loop or encoding process
143 // In first pass, intra prediction is done based on source pixels
144 // at tile boundaries
147 // use fast quantization process
150 // skip forward transform and quantization
151 uint8_t skip_txfm[MAX_MB_PLANE << 2];
152 #define SKIP_TXFM_NONE 0
153 #define SKIP_TXFM_AC_DC 1
154 #define SKIP_TXFM_AC_ONLY 2
156 // cf. https://bugs.chromium.org/p/webm/issues/detail?id=1054
157 #if !defined(_MSC_VER) || _MSC_VER >= 1900
158 int64_t bsse[MAX_MB_PLANE << 2];
161 // Used to store sub partition's choices.
162 MV pred_mv[MAX_REF_FRAMES];
164 // Strong color activity detection. Used in RTC coding mode to enhance
165 // the visual quality at the boundary of moving color objects.
166 uint8_t color_sensitivity[2];
170 uint8_t skip_low_source_sad;
172 uint8_t lowvar_highsumdiff;
174 uint8_t last_sb_high_content;
182 int sb_pickmode_part;
184 int zero_temp_sad_source;
186 // For each superblock: saves the content value (e.g., low/high sad/sumdiff)
187 // based on source sad, prior to encoding the frame.
188 uint8_t content_state_sb;
190 // Used to save the status of whether a block has a low variance in
191 // choose_partitioning. 0 for 64x64, 1~2 for 64x32, 3~4 for 32x64, 5~8 for
192 // 32x32, 9~24 for 16x16.
193 uint8_t variance_low[25];
195 uint8_t arf_frame_usage;
196 uint8_t lastgolden_frame_usage;
198 void (*fwd_txfm4x4)(const int16_t *input, tran_low_t *output, int stride);
199 void (*inv_txfm_add)(const tran_low_t *input, uint8_t *dest, int stride,
201 #if CONFIG_VP9_HIGHBITDEPTH
202 void (*highbd_inv_txfm_add)(const tran_low_t *input, uint16_t *dest,
203 int stride, int eob, int bd);
211 #endif // VP9_ENCODER_VP9_BLOCK_H_