AOMedia AV1 Codec
rdopt.h
1 /*
2  * Copyright (c) 2016, Alliance for Open Media. All rights reserved
3  *
4  * This source code is subject to the terms of the BSD 2 Clause License and
5  * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6  * was not distributed with this source code in the LICENSE file, you can
7  * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8  * Media Patent License 1.0 was not distributed with this source code in the
9  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10  */
11 
12 #ifndef AOM_AV1_ENCODER_RDOPT_H_
13 #define AOM_AV1_ENCODER_RDOPT_H_
14 
15 #include <stdbool.h>
16 
17 #include "av1/common/blockd.h"
18 #include "av1/common/txb_common.h"
19 
20 #include "av1/encoder/block.h"
21 #include "av1/encoder/context_tree.h"
22 #include "av1/encoder/encoder.h"
23 #include "av1/encoder/encodetxb.h"
24 #include "av1/encoder/rdopt_utils.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 #define COMP_TYPE_RD_THRESH_SCALE 11
31 #define COMP_TYPE_RD_THRESH_SHIFT 4
32 #define MAX_WINNER_MOTION_MODES 10
33 
34 struct TileInfo;
35 struct macroblock;
36 struct RD_STATS;
37 
62 void av1_rd_pick_intra_mode_sb(const struct AV1_COMP *cpi, struct macroblock *x,
63  struct RD_STATS *rd_cost, BLOCK_SIZE bsize,
64  PICK_MODE_CONTEXT *ctx, int64_t best_rd);
65 
93 void av1_rd_pick_inter_mode(struct AV1_COMP *cpi, struct TileDataEnc *tile_data,
94  struct macroblock *x, struct RD_STATS *rd_cost,
95  BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx,
96  int64_t best_rd_so_far);
97 
123 void av1_nonrd_pick_intra_mode(AV1_COMP *cpi, MACROBLOCK *x, RD_STATS *rd_cost,
124  BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx);
125 
155 void av1_nonrd_pick_inter_mode_sb(struct AV1_COMP *cpi,
156  struct TileDataEnc *tile_data,
157  struct macroblock *x,
158  struct RD_STATS *rd_cost, BLOCK_SIZE bsize,
159  PICK_MODE_CONTEXT *ctx);
160 
161 void av1_rd_pick_inter_mode_sb_seg_skip(
162  const struct AV1_COMP *cpi, struct TileDataEnc *tile_data,
163  struct macroblock *x, int mi_row, int mi_col, struct RD_STATS *rd_cost,
164  BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx, int64_t best_rd_so_far);
165 
166 // TODO(any): The defs below could potentially be moved to rdopt_utils.h instead
167 // because they are not the main rdopt functions.
169 // The best edge strength seen in the block, as well as the best x and y
170 // components of edge strength seen.
171 typedef struct {
172  uint16_t magnitude;
173  uint16_t x;
174  uint16_t y;
175 } EdgeInfo;
184 EdgeInfo av1_edge_exists(const uint8_t *src, int src_stride, int w, int h,
185  bool high_bd, int bd);
186 
190 void av1_gaussian_blur(const uint8_t *src, int src_stride, int w, int h,
191  uint8_t *dst, bool high_bd, int bd);
192 
194 /* Applies standard 3x3 Sobel matrix. */
195 typedef struct {
196  int16_t x;
197  int16_t y;
198 } sobel_xy;
201 sobel_xy av1_sobel(const uint8_t *input, int stride, int i, int j,
202  bool high_bd);
203 
204 void av1_inter_mode_data_init(struct TileDataEnc *tile_data);
205 void av1_inter_mode_data_fit(TileDataEnc *tile_data, int rdmult);
206 
207 static INLINE int coded_to_superres_mi(int mi_col, int denom) {
208  return (mi_col * denom + SCALE_NUMERATOR / 2) / SCALE_NUMERATOR;
209 }
210 
211 static INLINE int av1_encoder_get_relative_dist(int a, int b) {
212  assert(a >= 0 && b >= 0);
213  return (a - b);
214 }
215 
216 // This function will return number of mi's in a superblock.
217 static INLINE int av1_get_sb_mi_size(const AV1_COMMON *const cm) {
218  const int mi_alloc_size_1d = mi_size_wide[cm->mi_params.mi_alloc_bsize];
219  int sb_mi_rows =
220  (mi_size_wide[cm->seq_params.sb_size] + mi_alloc_size_1d - 1) /
221  mi_alloc_size_1d;
222  assert(mi_size_wide[cm->seq_params.sb_size] ==
223  mi_size_high[cm->seq_params.sb_size]);
224  int sb_mi_size = sb_mi_rows * sb_mi_rows;
225 
226  return sb_mi_size;
227 }
228 
229 // This function will copy usable ref_mv_stack[ref_frame][4] and
230 // weight[ref_frame][4] information from ref_mv_stack[ref_frame][8] and
231 // weight[ref_frame][8].
232 static INLINE void av1_copy_usable_ref_mv_stack_and_weight(
233  const MACROBLOCKD *xd, MB_MODE_INFO_EXT *const mbmi_ext,
234  MV_REFERENCE_FRAME ref_frame) {
235  memcpy(mbmi_ext->weight[ref_frame], xd->weight[ref_frame],
236  USABLE_REF_MV_STACK_SIZE * sizeof(xd->weight[0][0]));
237  memcpy(mbmi_ext->ref_mv_stack[ref_frame], xd->ref_mv_stack[ref_frame],
238  USABLE_REF_MV_STACK_SIZE * sizeof(xd->ref_mv_stack[0][0]));
239 }
240 
241 // This function prunes the mode if either of the reference frame falls in the
242 // pruning list
243 static INLINE int prune_ref(const MV_REFERENCE_FRAME *const ref_frame,
244  const unsigned int *const ref_display_order_hint,
245  const unsigned int frame_display_order_hint,
246  const int *ref_frame_list) {
247  for (int i = 0; i < 2; i++) {
248  if (ref_frame_list[i] == NONE_FRAME) continue;
249 
250  if (ref_frame[0] == ref_frame_list[i] ||
251  ref_frame[1] == ref_frame_list[i]) {
252  if (av1_encoder_get_relative_dist(
253  ref_display_order_hint[ref_frame_list[i] - LAST_FRAME],
254  frame_display_order_hint) < 0)
255  return 1;
256  }
257  }
258  return 0;
259 }
260 
261 static INLINE int prune_ref_by_selective_ref_frame(
262  const AV1_COMP *const cpi, const MACROBLOCK *const x,
263  const MV_REFERENCE_FRAME *const ref_frame,
264  const unsigned int *const ref_display_order_hint) {
265  const SPEED_FEATURES *const sf = &cpi->sf;
266  if (!sf->inter_sf.selective_ref_frame) return 0;
267 
268  const int comp_pred = ref_frame[1] > INTRA_FRAME;
269 
270  if (sf->inter_sf.selective_ref_frame >= 2 ||
271  (sf->inter_sf.selective_ref_frame == 1 && comp_pred)) {
272  int ref_frame_list[2] = { LAST3_FRAME, LAST2_FRAME };
273 
274  if (x != NULL) {
275  // Disable pruning if either tpl suggests that we keep the frame or
276  // the pred_mv gives us the best sad
277  if (x->tpl_keep_ref_frame[LAST3_FRAME] ||
278  x->pred_mv_sad[LAST3_FRAME] == x->best_pred_mv_sad) {
279  ref_frame_list[0] = NONE_FRAME;
280  }
281  if (x->tpl_keep_ref_frame[LAST2_FRAME] ||
282  x->pred_mv_sad[LAST2_FRAME] == x->best_pred_mv_sad) {
283  ref_frame_list[1] = NONE_FRAME;
284  }
285  }
286 
287  if (prune_ref(ref_frame, ref_display_order_hint,
288  ref_display_order_hint[GOLDEN_FRAME - LAST_FRAME],
289  ref_frame_list))
290  return 1;
291  }
292 
293  if (sf->inter_sf.selective_ref_frame >= 3) {
294  int ref_frame_list[2] = { ALTREF2_FRAME, BWDREF_FRAME };
295 
296  if (x != NULL) {
297  // Disable pruning if either tpl suggests that we keep the frame or
298  // the pred_mv gives us the best sad
299  if (x->tpl_keep_ref_frame[ALTREF2_FRAME] ||
300  x->pred_mv_sad[ALTREF2_FRAME] == x->best_pred_mv_sad) {
301  ref_frame_list[0] = NONE_FRAME;
302  }
303  if (x->tpl_keep_ref_frame[BWDREF_FRAME] ||
304  x->pred_mv_sad[BWDREF_FRAME] == x->best_pred_mv_sad) {
305  ref_frame_list[1] = NONE_FRAME;
306  }
307  }
308 
309  if (prune_ref(ref_frame, ref_display_order_hint,
310  ref_display_order_hint[LAST_FRAME - LAST_FRAME],
311  ref_frame_list))
312  return 1;
313  }
314 
315  return 0;
316 }
317 
318 // This function will copy the best reference mode information from
319 // MB_MODE_INFO_EXT to MB_MODE_INFO_EXT_FRAME.
320 static INLINE void av1_copy_mbmi_ext_to_mbmi_ext_frame(
321  MB_MODE_INFO_EXT_FRAME *mbmi_ext_best,
322  const MB_MODE_INFO_EXT *const mbmi_ext, uint8_t ref_frame_type) {
323  memcpy(mbmi_ext_best->ref_mv_stack, mbmi_ext->ref_mv_stack[ref_frame_type],
324  sizeof(mbmi_ext->ref_mv_stack[USABLE_REF_MV_STACK_SIZE]));
325  memcpy(mbmi_ext_best->weight, mbmi_ext->weight[ref_frame_type],
326  sizeof(mbmi_ext->weight[USABLE_REF_MV_STACK_SIZE]));
327  mbmi_ext_best->mode_context = mbmi_ext->mode_context[ref_frame_type];
328  mbmi_ext_best->ref_mv_count = mbmi_ext->ref_mv_count[ref_frame_type];
329  memcpy(mbmi_ext_best->global_mvs, mbmi_ext->global_mvs,
330  sizeof(mbmi_ext->global_mvs));
331 }
332 
333 #ifdef __cplusplus
334 } // extern "C"
335 #endif
336 
337 #endif // AOM_AV1_ENCODER_RDOPT_H_
macroblockd::mb_to_left_edge
int mb_to_left_edge
Definition: blockd.h:675
OBMCBuffer::left_pred
uint8_t * left_pred
Prediction from the up predictor.
Definition: block.h:355
SPEED_FEATURES::rt_sf
REAL_TIME_SPEED_FEATURES rt_sf
Definition: speed_features.h:1184
TplParams::tpl_bsize_1d
uint8_t tpl_bsize_1d
Definition: tpl_model.h:138
MB_MODE_INFO_EXT::mode_context
int16_t mode_context[MODE_CTX_REF_FRAMES]
Context used to encode the current mode.
Definition: block.h:207
block.h
encoder.h
Declares top-level encoder structures and functions.
MB_MODE_INFO_EXT_FRAME
Stores best extended mode information at frame level.
Definition: block.h:216
FeatureFlags::interp_filter
InterpFilter interp_filter
Definition: av1_common_int.h:383
macroblock::obmc_buffer
OBMCBuffer obmc_buffer
Modified source and masks used for fast OBMC search.
Definition: block.h:905
av1_rd_pick_intra_sbuv_mode
int64_t av1_rd_pick_intra_sbuv_mode(const AV1_COMP *const cpi, MACROBLOCK *x, int *rate, int *rate_tokenonly, int64_t *distortion, int *skippable, BLOCK_SIZE bsize, TX_SIZE max_tx_size)
Perform intra-mode search on chroma channels.
Definition: intra_mode_search.c:558
CommonQuantParams::y_dc_delta_q
int y_dc_delta_q
Definition: av1_common_int.h:592
MB_MODE_INFO::wm_params
WarpedMotionParams wm_params
The parameters used in warp motion mode.
Definition: blockd.h:251
IntraModeSearchState
Variables related to intra-mode search during inter frame coding.
Definition: intra_mode_search.h:31
FeatureFlags
Frame level features.
Definition: av1_common_int.h:334
MvCosts::mv_cost_stack
int ** mv_cost_stack
Points to the nmv_cost_hp in use.
Definition: block.h:777
macroblock::dv_costs
IntraBCMVCosts * dv_costs
Definition: block.h:968
MB_MODE_INFO::ref_mv_idx
uint8_t ref_mv_idx
Which ref_mv to use.
Definition: blockd.h:308
ModeCosts::zeromv_mode_cost
int zeromv_mode_cost[GLOBALMV_MODE_CONTEXTS][2]
zeromv_mode_cost
Definition: block.h:645
ModeCosts
Holds the entropy costs for various modes sent to the bitstream.
Definition: block.h:583
macroblock::plane
struct macroblock_plane plane[3]
Each of the encoding plane.
Definition: block.h:856
OBMCBuffer
Contains buffers used to speed up rdopt for obmc.
Definition: block.h:335
MB_MODE_INFO::tx_size
TX_SIZE tx_size
Transform size when fixed size txfm is used (e.g. intra modes).
Definition: blockd.h:284
WARP_SAMPLE_INFO
Holds the motion samples for warp motion model estimation.
Definition: block.h:815
MB_MODE_INFO::angle_delta
int8_t angle_delta[PLANE_TYPES]
Directional mode delta: the angle is base angle + (angle_delta * step).
Definition: blockd.h:266
palette.h
Declares functions used in palette search.
inter_modes_info::num
int num
Definition: encoder.h:1121
ModeCosts::comp_ref_cost
int comp_ref_cost[REF_CONTEXTS][FWD_REFS - 1][2]
Cost for signaling ref_frame[0] in bidir-comp mode.
Definition: block.h:670
macroblockd::height
uint8_t height
Definition: blockd.h:764
motion_mode_candidate::skip_motion_mode
int skip_motion_mode
Definition: rdopt.c:2079
ModeCosts::comp_inter_cost
int comp_inter_cost[COMP_INTER_CONTEXTS][2]
comp_inter_cost
Definition: block.h:659
AOM_PLANE_Y
#define AOM_PLANE_Y
Definition: aom_image.h:199
SPEED_FEATURES::part_sf
PARTITION_SPEED_FEATURES part_sf
Definition: speed_features.h:1139
MB_MODE_INFO_EXT_FRAME::weight
uint16_t weight[USABLE_REF_MV_STACK_SIZE]
The weights used to compute the ref mvs.
Definition: block.h:220
TxfmSearchInfo::blk_skip
uint8_t blk_skip[MAX_MIB_SIZE *MAX_MIB_SIZE]
Whether to skip transform and quantization on a txfm block level.
Definition: block.h:531
MB_MODE_INFO::interp_filters
int_interpfilters interp_filters
Filter used in subpel interpolation.
Definition: blockd.h:242
intra_mode_search_utils.h
Defines utility functions used in intra mode search.
macroblock::mbmi_ext
MB_MODE_INFO_EXT mbmi_ext
Derived coding information.
Definition: block.h:871
intra_mode_info_cost_uv
static int intra_mode_info_cost_uv(const AV1_COMP *cpi, const MACROBLOCK *x, const MB_MODE_INFO *mbmi, BLOCK_SIZE bsize, int mode_cost)
Return the rate cost for chroma prediction mode info of intra blocks.
Definition: intra_mode_search_utils.h:340
AlgoCfg::enable_tpl_model
bool enable_tpl_model
Definition: encoder.h:753
macroblockd::above_mbmi
MB_MODE_INFO * above_mbmi
Definition: blockd.h:643
macroblockd::width
uint8_t width
Definition: blockd.h:763
AV1_COMP::frame_probs
FrameProbInfo frame_probs
Definition: encoder.h:2496
TxfmSearchParams
Defines the parameters used to perform txfm search.
Definition: block.h:425
MB_MODE_INFO::filter_intra_mode_info
FILTER_INTRA_MODE_INFO filter_intra_mode_info
The type of filter intra mode used (if applicable).
Definition: blockd.h:268
AOM_PLANE_U
#define AOM_PLANE_U
Definition: aom_image.h:200
macroblockd::mi_col
int mi_col
Definition: blockd.h:574
AV1_COMP::speed
int speed
Definition: encoder.h:2309
macroblockd::mb_to_bottom_edge
int mb_to_bottom_edge
Definition: blockd.h:678
IntraModeSearchState::best_intra_mode
PREDICTION_MODE best_intra_mode
The best luma intra-mode found so far.
Definition: intra_mode_search.h:35
PruneInfoFromTpl::best_inter_cost
int64_t best_inter_cost
Definition: rdopt.c:2163
AV1_COMP::sf
SPEED_FEATURES sf
Definition: encoder.h:2314
motion_mode_candidate::rate2_nocoeff
int rate2_nocoeff
Definition: rdopt.c:2073
ModeCosts::interintra_cost
int interintra_cost[4][2]
interintra_cost
Definition: block.h:691
AV1_COMP::gf_frame_index
unsigned char gf_frame_index
Definition: encoder.h:2362
TxfmSearchInfo::skip_txfm
int skip_txfm
Whether to skip transform and quantization on a partition block level.
Definition: block.h:522
av1_rd_pick_inter_mode
void av1_rd_pick_inter_mode(struct AV1_COMP *cpi, struct TileDataEnc *tile_data, struct macroblock *x, struct RD_STATS *rd_cost, BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx, int64_t best_rd_so_far)
AV1 inter mode selection.
Definition: rdopt.c:5163
macroblock::sb_enc
SuperBlockEnc sb_enc
Information on a whole superblock level.
Definition: block.h:1018
AlgoCfg::arnr_max_frames
int arnr_max_frames
Definition: encoder.h:735
AV1Common::seg
struct segmentation seg
Definition: av1_common_int.h:904
FeatureFlags::cur_frame_force_integer_mv
bool cur_frame_force_integer_mv
Definition: av1_common_int.h:347
av1_rd_pick_intra_mode_sb
void av1_rd_pick_intra_mode_sb(const struct AV1_COMP *cpi, struct macroblock *x, struct RD_STATS *rd_cost, BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx, int64_t best_rd)
AV1 intra mode selection for intra frames.
Definition: rdopt.c:3107
av1_txfm_uvrd
int av1_txfm_uvrd(const AV1_COMP *const cpi, MACROBLOCK *x, RD_STATS *rd_stats, BLOCK_SIZE bsize, int64_t ref_best_rd)
Chroma block transform search.
macroblockd::bd
int bd
Definition: blockd.h:806
AV1EncoderConfig::kf_cfg
KeyFrameCfg kf_cfg
Definition: encoder.h:822
AV1_COMP::prune_ref_frame_mask
int prune_ref_frame_mask
Definition: encoder.h:2518
macroblockd::is_chroma_ref
bool is_chroma_ref
Definition: blockd.h:599
macroblock::winner_mode_stats
WinnerModeStats * winner_mode_stats
Tracks the winner modes in the current coding block.
Definition: block.h:1117
macroblockd::up_available
bool up_available
Definition: blockd.h:620
init_intra_mode_search_state
static void init_intra_mode_search_state(IntraModeSearchState *intra_search_state)
Initializes the IntraModeSearchState struct.
Definition: intra_mode_search.h:259
TplParams
Params related to temporal dependency model.
Definition: tpl_model.h:129
av1_nonrd_pick_intra_mode
void av1_nonrd_pick_intra_mode(AV1_COMP *cpi, MACROBLOCK *x, RD_STATS *rd_cost, BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx)
AV1 intra mode selection based on Non-RD optimized model.
Definition: nonrd_pickmode.c:1657
FeatureFlags::allow_screen_content_tools
bool allow_screen_content_tools
Definition: av1_common_int.h:351
AV1Common::cur_frame
RefCntBuffer * cur_frame
Definition: av1_common_int.h:809
av1_restore_uv_color_map
void av1_restore_uv_color_map(const struct AV1_COMP *cpi, struct macroblock *x)
Resets palette color map for chroma channels.
MB_MODE_INFO_EXT_FRAME::mode_context
int16_t mode_context
Context used to encode the current mode.
Definition: block.h:227
macroblock::rdmult
int rdmult
Rate-distortion multiplier.
Definition: block.h:951
ModeCosts::motion_mode_cost
int motion_mode_cost[BLOCK_SIZES_ALL][MOTION_MODES]
motion_mode_cost
Definition: block.h:713
macroblockd::left_mbmi
MB_MODE_INFO * left_mbmi
Definition: blockd.h:638
WARP_SAMPLE_INFO::num
int num
Number of samples.
Definition: block.h:817
AV1_COMP::gf_group
GF_GROUP gf_group
Definition: encoder.h:2357
AV1_COMP
Top level encoder structure.
Definition: encoder.h:2095
inter_modes_info::est_rd_arr
int64_t est_rd_arr[MAX_INTER_MODES]
Definition: encoder.h:1137
motion_mode_candidate::rd_cost
int64_t rd_cost
Definition: rdopt.c:2083
inter_modes_info::rd_idx_pair_arr
RdIdxPair rd_idx_pair_arr[MAX_INTER_MODES]
Definition: encoder.h:1141
MB_MODE_INFO::compound_idx
uint8_t compound_idx
Indicates whether dist_wtd_comp(0) is used or not (0).
Definition: blockd.h:316
AV1Common::height
int height
Definition: av1_common_int.h:749
MB_MODE_INFO_EXT::ref_mv_stack
CANDIDATE_MV ref_mv_stack[MODE_CTX_REF_FRAMES][USABLE_REF_MV_STACK_SIZE]
The reference mv list for the current block.
Definition: block.h:199
macroblock::qindex
int qindex
Quantization index for the current partition block.
Definition: block.h:934
macroblock::tpl_keep_ref_frame
uint8_t tpl_keep_ref_frame[REF_FRAMES]
Disables certain ref frame pruning based on tpl.
Definition: block.h:1046
MB_MODE_INFO::use_intrabc
uint8_t use_intrabc
Whether intrabc is used.
Definition: blockd.h:312
macroblockd::mb_to_right_edge
int mb_to_right_edge
Definition: blockd.h:676
MB_MODE_INFO::interintra_mode
INTERINTRA_MODE interintra_mode
The type of intra mode used by inter-intra.
Definition: blockd.h:253
ModeCosts::comp_bwdref_cost
int comp_bwdref_cost[REF_CONTEXTS][BWD_REFS - 1][2]
Cost for signaling ref_frame[1] in bidir-comp mode.
Definition: block.h:675
MB_MODE_INFO::palette_mode_info
PALETTE_MODE_INFO palette_mode_info
Stores the size and colors of palette mode.
Definition: blockd.h:274
RefFrameDistanceInfo::ref_relative_dist
int ref_relative_dist[INTER_REFS_PER_FRAME]
Definition: encoder.h:1792
OBMCBuffer::wsrc
int32_t * wsrc
A new source weighted with the above and left predictors.
Definition: block.h:340
ModeCosts::intrabc_cost
int intrabc_cost[2]
intrabc_cost
Definition: block.h:618
KeyFrameCfg::enable_intrabc
bool enable_intrabc
Definition: encoder.h:424
OBMCBuffer::above_pred
uint8_t * above_pred
Prediction from the up predictor.
Definition: block.h:350
MotionVectorSearchParams::search_site_cfg
search_site_config search_site_cfg[SS_CFG_TOTAL][NUM_DISTINCT_SEARCH_METHODS]
Definition: encoder.h:1756
SuperBlockEnc::tpl_inter_cost
int64_t tpl_inter_cost[(128/16) *(128/16)]
TPL's estimate of inter cost for each tpl block.
Definition: block.h:70
macroblock::mv_costs
MvCosts * mv_costs
Definition: block.h:963
FrameProbInfo::obmc_probs
int obmc_probs[FRAME_UPDATE_TYPES][BLOCK_SIZES_ALL]
Definition: encoder.h:966
AV1_COMP::all_one_sided_refs
int all_one_sided_refs
Definition: encoder.h:2325
MB_MODE_INFO::skip_mode
uint8_t skip_mode
Inter skip mode.
Definition: blockd.h:310
AV1_COMP::common
AV1_COMMON common
Definition: encoder.h:2138
macroblock::pred_mv_sad
int pred_mv_sad[REF_FRAMES]
Sum absolute distortion of the predicted mv for each ref frame.
Definition: block.h:1036
MB_MODE_INFO::ref_frame
MV_REFERENCE_FRAME ref_frame[2]
The reference frames for the MV.
Definition: blockd.h:240
MB_MODE_INFO::uv_mode
UV_PREDICTION_MODE uv_mode
The UV mode when intra is used.
Definition: blockd.h:228
MB_MODE_INFO::interinter_comp
INTERINTER_COMPOUND_DATA interinter_comp
Struct that stores the data used in interinter compound mode.
Definition: blockd.h:257
MotionVectorSearchParams::mv_step_param
int mv_step_param
Definition: encoder.h:1740
macroblock_plane
Each source plane of the current macroblock.
Definition: block.h:103
macroblockd::mb_to_top_edge
int mb_to_top_edge
Definition: blockd.h:677
AV1Common::superres_upscaled_width
int superres_upscaled_width
Definition: av1_common_int.h:772
AV1_COMP::tpl_data
TplParams tpl_data
Definition: encoder.h:2202
macroblockd::cur_buf
const YV12_BUFFER_CONFIG * cur_buf
Definition: blockd.h:693
ModeCosts::uni_comp_ref_cost
int uni_comp_ref_cost[UNI_COMP_REF_CONTEXTS][UNIDIR_COMP_REFS - 1][((2)+1)]
uni_comp_ref_cost
Definition: block.h:665
IntraBCMVCosts::dv_costs
int * dv_costs[2]
Definition: block.h:795
WARP_SAMPLE_INFO::pts_inref
int pts_inref[16]
Sample location in the reference frame.
Definition: block.h:821
AV1_COMP::mv_search_params
MotionVectorSearchParams mv_search_params
Definition: encoder.h:2319
av1_search_palette_mode
int av1_search_palette_mode(IntraModeSearchState *intra_search_state, const AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize, unsigned int ref_frame_cost, PICK_MODE_CONTEXT *ctx, RD_STATS *this_rd_cost, int64_t best_rd)
Evaluate luma palette mode for inter frames.
Definition: intra_mode_search.c:718
macroblock::comp_rd_stats_idx
int comp_rd_stats_idx
The idx for the latest compound mode in the cache comp_rd_stats.
Definition: block.h:1154
macroblock::use_mb_mode_cache
int use_mb_mode_cache
Whether to reuse the mode stored in mb_mode_cache.
Definition: block.h:1172
MB_MODE_INFO_EXT_FRAME::ref_mv_stack
CANDIDATE_MV ref_mv_stack[USABLE_REF_MV_STACK_SIZE]
The reference mv list for the current block.
Definition: block.h:218
AV1_COMP::fn_ptr
aom_variance_fn_ptr_t fn_ptr[BLOCK_SIZES_ALL]
Definition: encoder.h:2347
WinnerModeStats::mbmi
MB_MODE_INFO mbmi
The mbmi used to reconstruct the winner mode.
Definition: block.h:84
SPEED_FEATURES::winner_mode_sf
WINNER_MODE_SPEED_FEATURES winner_mode_sf
Definition: speed_features.h:1174
inter_modes_info
Struct used to hold inter mode data for fast tx search.
Definition: encoder.h:1116
CommonModeInfoParams::mi_rows
int mi_rows
Definition: av1_common_int.h:498
SuperBlockEnc::tpl_data_count
int tpl_data_count
Number of TPL blocks in this superblock.
Definition: block.h:68
RefFrameDistanceInfo::nearest_past_ref
int8_t nearest_past_ref
Definition: encoder.h:1796
macroblock_plane::src_diff
int16_t * src_diff
Stores source - pred so the txfm can be computed later.
Definition: block.h:105
macroblockd::global_motion
const WarpedMotionParams * global_motion
Definition: blockd.h:841
inter_modes_info::mode_rate_arr
int mode_rate_arr[MAX_INTER_MODES]
Definition: encoder.h:1129
CompoundTypeRdBuffers
Contains buffers used by av1_compound_type_rd()
Definition: block.h:372
macroblock::intrabc_hash_info
IntraBCHashInfo intrabc_hash_info
Data structure to speed up intrabc search.
Definition: block.h:1169
macroblock::warp_sample_info
WARP_SAMPLE_INFO warp_sample_info[REF_FRAMES]
Warp motion samples buffer.
Definition: block.h:1052
WinnerModeStats
Stores the best performing modes.
Definition: block.h:82
SPEED_FEATURES
Top level speed vs quality trade off data struture.
Definition: speed_features.h:1120
av1_rd_pick_intra_sby_mode
int64_t av1_rd_pick_intra_sby_mode(const AV1_COMP *const cpi, MACROBLOCK *x, int *rate, int *rate_tokenonly, int64_t *distortion, int *skippable, BLOCK_SIZE bsize, int64_t best_rd, PICK_MODE_CONTEXT *ctx)
Perform intra-mode search on luma channels for intra frames.
Definition: intra_mode_search.c:1153
ModeCosts::drl_mode_cost0
int drl_mode_cost0[DRL_MODE_CONTEXTS][2]
drl_mode_cost0
Definition: block.h:649
MB_MODE_INFO_EXT::weight
uint16_t weight[MODE_CTX_REF_FRAMES][USABLE_REF_MV_STACK_SIZE]
The weights used to compute the ref mvs.
Definition: block.h:201
macroblock::mv_limits
FullMvLimits mv_limits
Limit for the range of motion vectors.
Definition: block.h:1194
motion_mode_rd
static int64_t motion_mode_rd(const AV1_COMP *const cpi, TileDataEnc *tile_data, MACROBLOCK *const x, BLOCK_SIZE bsize, RD_STATS *rd_stats, RD_STATS *rd_stats_y, RD_STATS *rd_stats_uv, HandleInterModeArgs *const args, int64_t ref_best_rd, int64_t *ref_skip_rd, int *rate_mv, const BUFFER_SET *orig_dst, int64_t *best_est_rd, int do_tx_search, InterModesInfo *inter_modes_info, int eval_motion_mode, int64_t *yrd)
AV1 motion mode search.
Definition: rdopt.c:1258
SPEED_FEATURES::inter_sf
INTER_MODE_SPEED_FEATURES inter_sf
Definition: speed_features.h:1149
MB_MODE_INFO_EXT
Extended mode info derived from mbmi.
Definition: block.h:196
MB_MODE_INFO::bsize
BLOCK_SIZE bsize
The block size of the current coding block.
Definition: blockd.h:222
macroblock::picked_ref_frames_mask
int picked_ref_frames_mask[MAX_MIB_SIZE *MAX_MIB_SIZE]
Reference frames picked by the square subblocks in a superblock.
Definition: block.h:1060
MB_MODE_INFO::partition
PARTITION_TYPE partition
The partition type of the current coding block.
Definition: blockd.h:224
WinnerModeStats::rd_cost
RD_STATS rd_cost
Rdstats of the winner mode.
Definition: block.h:86
WinnerModeStats::rate_uv
int rate_uv
Chroma rate of the winner mode.
Definition: block.h:92
inter_modes_info::rd_cost_arr
RD_STATS rd_cost_arr[MAX_INTER_MODES]
Definition: encoder.h:1145
MB_MODE_INFO::motion_mode
MOTION_MODE motion_mode
The motion mode used by the inter prediction.
Definition: blockd.h:244
AV1_COMP::rd
RD_OPT rd
Definition: encoder.h:2268
AV1Common::show_frame
int show_frame
Definition: av1_common_int.h:862
macroblock::best_pred_mv_sad
int best_pred_mv_sad
The minimum of pred_mv_sad.
Definition: block.h:1038
MB_MODE_INFO_EXT::ref_mv_count
uint8_t ref_mv_count[MODE_CTX_REF_FRAMES]
Number of ref mvs in the drl.
Definition: block.h:203
WinnerModeStats::rate_y
int rate_y
Luma rate of the winner mode.
Definition: block.h:90
RefFrameDistanceInfo::nearest_future_ref
int8_t nearest_future_ref
Definition: encoder.h:1800
AV1Common::quant_params
CommonQuantParams quant_params
Definition: av1_common_int.h:899
yv12_buffer_config
YV12 frame buffer data structure.
Definition: yv12config.h:38
handle_inter_mode
static int64_t handle_inter_mode(AV1_COMP *const cpi, TileDataEnc *tile_data, MACROBLOCK *x, BLOCK_SIZE bsize, RD_STATS *rd_stats, RD_STATS *rd_stats_y, RD_STATS *rd_stats_uv, HandleInterModeArgs *args, int64_t ref_best_rd, uint8_t *const tmp_buf, const CompoundTypeRdBuffers *rd_buffers, int64_t *best_est_rd, const int do_tx_search, InterModesInfo *inter_modes_info, motion_mode_candidate *motion_mode_cand, int64_t *skip_rd, PruneInfoFromTpl *inter_cost_info_from_tpl, int64_t *yrd)
AV1 inter mode RD computation.
Definition: rdopt.c:2578
MB_MODE_INFO::mode
PREDICTION_MODE mode
The prediction mode used.
Definition: blockd.h:226
WARP_SAMPLE_INFO::pts
int pts[16]
Sample locations in current frame.
Definition: block.h:819
av1_pick_recursive_tx_size_type_yrd
void av1_pick_recursive_tx_size_type_yrd(const AV1_COMP *cpi, MACROBLOCK *x, RD_STATS *rd_stats, BLOCK_SIZE bsize, int64_t ref_best_rd)
Recursive transform size and type search.
AV1Common::global_motion
WarpedMotionParams global_motion[REF_FRAMES]
Definition: av1_common_int.h:947
MB_MODE_INFO::mv
int_mv mv[2]
The motion vectors used by the current inter mode.
Definition: blockd.h:238
search_intra_modes_in_interframe
static void search_intra_modes_in_interframe(InterModeSearchState *search_state, const AV1_COMP *cpi, MACROBLOCK *x, RD_STATS *rd_cost, BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx, InterModeSFArgs *sf_args, unsigned int intra_ref_frame_cost, int64_t yrd_threshold)
Search intra modes in interframes.
Definition: rdopt.c:5001
av1_txfm_search
int av1_txfm_search(const AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize, RD_STATS *rd_stats, RD_STATS *rd_stats_y, RD_STATS *rd_stats_uv, int mode_rate, int64_t ref_best_rd)
Recursive transform size and type search.
FeatureFlags::allow_warped_motion
bool allow_warped_motion
Definition: av1_common_int.h:353
macroblock_plane::src
struct buf_2d src
A buffer containing the source frame.
Definition: block.h:117
AV1_COMP::rc
RATE_CONTROL rc
Definition: encoder.h:2294
macroblock::tmp_pred_bufs
uint8_t * tmp_pred_bufs[2]
Temporary buffer to hold prediction.
Definition: block.h:922
ModeCosts::refmv_mode_cost
int refmv_mode_cost[REFMV_MODE_CONTEXTS][2]
refmv_mode_cost
Definition: block.h:647
ModeCosts::comp_ref_type_cost
int comp_ref_type_cost[COMP_REF_TYPE_CONTEXTS][((COMP_REFERENCE_TYPES)+1)]
comp_ref_type_cost
Definition: block.h:662
CommonQuantParams::base_qindex
int base_qindex
Definition: av1_common_int.h:586
macroblock::must_find_valid_partition
int must_find_valid_partition
Whether to disable some features to force a mode in current block.
Definition: block.h:1086
FeatureFlags::switchable_motion_mode
bool switchable_motion_mode
Definition: av1_common_int.h:381
AV1Common
Top level common structure used by both encoder and decoder.
Definition: av1_common_int.h:723
SuperBlockEnc
Superblock level encoder info.
Definition: block.h:54
inter_modes_info::sse_arr
int64_t sse_arr[MAX_INTER_MODES]
Definition: encoder.h:1133
WinnerModeStats::mode_index
THR_MODES mode_index
The current winner mode.
Definition: block.h:96
AV1_COMP::ref_frame_flags
int ref_frame_flags
Definition: encoder.h:2304
macroblock::thresh_freq_fact
int thresh_freq_fact[BLOCK_SIZES_ALL][MAX_MODES]
Factors used for rd-thresholding.
Definition: block.h:1107
SPEED_FEATURES::intra_sf
INTRA_MODE_SPEED_FEATURES intra_sf
Definition: speed_features.h:1159
macroblockd::lossless
int lossless[8]
Definition: blockd.h:815
PruneInfoFromTpl
Struct used to hold TPL data to narrow down parts of the inter mode search.
Definition: rdopt.c:2159
AV1EncoderConfig::algo_cfg
AlgoCfg algo_cfg
Definition: encoder.h:817
av1_search_intra_uv_modes_in_interframe
int av1_search_intra_uv_modes_in_interframe(IntraModeSearchState *intra_search_state, const AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize, RD_STATS *rd_stats, const RD_STATS *rd_stats_y, RD_STATS *rd_stats_uv, int64_t best_rd)
Search through all chroma intra-modes for inter frames.
Definition: intra_mode_search.c:1093
motion_mode_candidate::mbmi
MB_MODE_INFO mbmi
Definition: rdopt.c:2065
MB_MODE_INFO::num_proj_ref
uint8_t num_proj_ref
Number of samples used by warp causal.
Definition: blockd.h:246
MAX_WINNER_MODE_COUNT_INTER
#define MAX_WINNER_MODE_COUNT_INTER
Number of inter winner modes kept.
Definition: block.h:42
CommonModeInfoParams::mi_alloc_bsize
BLOCK_SIZE mi_alloc_bsize
Definition: av1_common_int.h:526
macroblock::txfm_search_info
TxfmSearchInfo txfm_search_info
Results of the txfm searches that have been done.
Definition: block.h:1213
MB_MODE_INFO_EXT_FRAME::global_mvs
int_mv global_mvs[REF_FRAMES]
Global mvs.
Definition: block.h:225
MvCosts::nmv_joint_cost
int nmv_joint_cost[4]
Costs for coding the zero components.
Definition: block.h:766
TxfmSearchParams::tx_mode_search_type
TX_MODE tx_mode_search_type
How to search for the optimal tx_size.
Definition: block.h:468
macroblock::pred_sse
unsigned int pred_sse[REF_FRAMES]
SSE of the current predictor.
Definition: block.h:1230
MB_MODE_INFO_EXT::global_mvs
int_mv global_mvs[REF_FRAMES]
Global mvs.
Definition: block.h:205
MB_MODE_INFO::skip_txfm
int8_t skip_txfm
Whether to skip transforming and sending.
Definition: blockd.h:282
motion_mode_candidate
Motion mode information for inter mode search speedup.
Definition: rdopt.c:2061
MB_MODE_INFO::comp_group_idx
uint8_t comp_group_idx
Indicates if masked compound is used(1) or not (0).
Definition: blockd.h:314
ModeCosts::newmv_mode_cost
int newmv_mode_cost[NEWMV_MODE_CONTEXTS][2]
newmv_mode_cost
Definition: block.h:643
macroblock::mb_mode_cache
const MB_MODE_INFO * mb_mode_cache
The mode to reuse during av1_rd_pick_intra_mode_sb and av1_rd_pick_inter_mode.
Definition: block.h:1175
TxfmSearchInfo
Stores various encoding/search decisions related to txfm search.
Definition: block.h:520
ModeCosts::single_ref_cost
int single_ref_cost[REF_CONTEXTS][SINGLE_REFS - 1][2]
single_ref_cost
Definition: block.h:657
macroblockd::mi_row
int mi_row
Definition: blockd.h:573
av1_interpolation_filter_search
int64_t av1_interpolation_filter_search(MACROBLOCK *const x, const AV1_COMP *const cpi, const TileDataEnc *tile_data, BLOCK_SIZE bsize, const BUFFER_SET *const tmp_dst, const BUFFER_SET *const orig_dst, int64_t *const rd, int *const switchable_rate, int *skip_build_pred, HandleInterModeArgs *args, int64_t ref_best_rd)
AV1 interpolation filter search.
Definition: interp_search.c:648
TplParams::tpl_stats_block_mis_log2
uint8_t tpl_stats_block_mis_log2
Definition: tpl_model.h:133
ModeCosts::inter_compound_mode_cost
int inter_compound_mode_cost[INTER_MODE_CONTEXTS][INTER_COMPOUND_MODES]
inter_compound_mode_cost
Definition: block.h:685
MB_MODE_INFO
Stores the prediction/txfm mode of the current coding block.
Definition: blockd.h:216
AV1Common::superres_scale_denominator
uint8_t superres_scale_denominator
Definition: av1_common_int.h:780
rd_pick_intrabc_mode_sb
static int64_t rd_pick_intrabc_mode_sb(const AV1_COMP *cpi, MACROBLOCK *x, PICK_MODE_CONTEXT *ctx, RD_STATS *rd_stats, BLOCK_SIZE bsize, int64_t best_rd)
Search for the best intrabc predictor.
Definition: rdopt.c:2916
IntraBCMVCosts
Holds mv costs for intrabc.
Definition: block.h:783
inter_modes_info::rd_cost_y_arr
RD_STATS rd_cost_y_arr[MAX_INTER_MODES]
Definition: encoder.h:1149
macroblockd
Variables related to current coding block.
Definition: blockd.h:568
macroblock::compound_idx
uint8_t compound_idx
How to blend the compound predictions.
Definition: block.h:1149
ModeCosts::skip_mode_cost
int skip_mode_cost[SKIP_MODE_CONTEXTS][2]
skip_mode_cost
Definition: block.h:641
ModeCosts::intra_inter_cost
int intra_inter_cost[INTRA_INTER_CONTEXTS][2]
intra_inter_cost
Definition: block.h:683
macroblock::e_mbd
MACROBLOCKD e_mbd
Decoder's view of current coding block.
Definition: block.h:864
IntraBCMVCosts::joint_mv
int joint_mv[4]
Definition: block.h:785
CommonModeInfoParams::mi_cols
int mi_cols
Definition: av1_common_int.h:503
av1_handle_intra_y_mode
int av1_handle_intra_y_mode(IntraModeSearchState *intra_search_state, const AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize, unsigned int ref_frame_cost, const PICK_MODE_CONTEXT *ctx, RD_STATS *rd_stats_y, int64_t best_rd, int *mode_cost_y, int64_t *rd_y)
Evaluate a given luma intra-mode for inter frames.
Definition: intra_mode_search.c:1005
macroblock::txfm_search_params
TxfmSearchParams txfm_search_params
Parameters that control how motion search is done.
Definition: block.h:1206
inter_modes_info::rd_cost_uv_arr
RD_STATS rd_cost_uv_arr[MAX_INTER_MODES]
Definition: encoder.h:1153
macroblock::winner_mode_count
int winner_mode_count
Tracks how many winner modes there are.
Definition: block.h:1119
macroblockd::ref_mv_stack
CANDIDATE_MV ref_mv_stack[MODE_CTX_REF_FRAMES][MAX_REF_MV_STACK_SIZE]
Definition: blockd.h:774
MB_MODE_INFO::segment_id
uint8_t segment_id
The segment id.
Definition: blockd.h:304
AV1Common::width
int width
Definition: av1_common_int.h:748
SuperBlockEnc::tpl_intra_cost
int64_t tpl_intra_cost[(128/16) *(128/16)]
TPL's estimate of tpl cost for each tpl block.
Definition: block.h:72
macroblockd::left_available
bool left_available
Definition: blockd.h:624
macroblockd::mi_stride
int mi_stride
Definition: blockd.h:580
AV1_COMP::oxcf
AV1EncoderConfig oxcf
Definition: encoder.h:2143
TplParams::tpl_frame
TplDepFrame * tpl_frame
Definition: tpl_model.h:163
AV1Common::seq_params
SequenceHeader seq_params
Definition: av1_common_int.h:953
AV1_COMP::ref_frame_dist_info
RefFrameDistanceInfo ref_frame_dist_info
Definition: encoder.h:2592
macroblock::mode_costs
ModeCosts mode_costs
The rate needed to signal a mode to the bitstream.
Definition: block.h:959
SPEED_FEATURES::mv_sf
MV_SPEED_FEATURES mv_sf
Definition: speed_features.h:1144
MB_MODE_INFO::inter_tx_size
TX_SIZE inter_tx_size[INTER_TX_SIZE_BUF_LEN]
Transform size when recursive txfm tree is on.
Definition: blockd.h:286
FeatureFlags::allow_high_precision_mv
bool allow_high_precision_mv
Definition: av1_common_int.h:343
macroblockd::plane
struct macroblockd_plane plane[3]
Definition: blockd.h:604
MB_MODE_INFO_EXT_FRAME::ref_mv_count
uint8_t ref_mv_count
Number of ref mvs in the drl.
Definition: block.h:222
macroblockd::tile
TileInfo tile
Definition: blockd.h:609
ModeCosts::motion_mode_cost1
int motion_mode_cost1[BLOCK_SIZES_ALL][2]
motion_mode_cost1
Definition: block.h:715
av1_pick_uniform_tx_size_type_yrd
void av1_pick_uniform_tx_size_type_yrd(const AV1_COMP *const cpi, MACROBLOCK *x, RD_STATS *rd_stats, BLOCK_SIZE bs, int64_t ref_best_rd)
Uniform transform size and type search.
intra_mode_search.h
Declares high level functions to search through intra modes.
inter_modes_info::mbmi_arr
MB_MODE_INFO mbmi_arr[MAX_INTER_MODES]
Definition: encoder.h:1125
AV1Common::features
FeatureFlags features
Definition: av1_common_int.h:882
AV1Common::current_frame
CurrentFrame current_frame
Definition: av1_common_int.h:727
SuperBlockEnc::tpl_stride
int tpl_stride
TPL's stride for the arrays in this struct.
Definition: block.h:76
OBMCBuffer::mask
int32_t * mask
A new mask constructed from the original horz/vert mask.
Definition: block.h:345
macroblock::comp_rd_buffer
CompoundTypeRdBuffers comp_rd_buffer
Buffer used for compound_type_rd().
Definition: block.h:909
ModeCosts::intra_uv_mode_cost
int intra_uv_mode_cost[CFL_ALLOWED_TYPES][INTRA_MODES][UV_INTRA_MODES]
Chroma mode cost.
Definition: block.h:601
macroblockd::weight
uint16_t weight[MODE_CTX_REF_FRAMES][MAX_REF_MV_STACK_SIZE]
Definition: blockd.h:779
AV1Common::mi_params
CommonModeInfoParams mi_params
Definition: av1_common_int.h:887
macroblock::source_variance
unsigned int source_variance
Variance of the source frame.
Definition: block.h:1228
RefFrameDistanceInfo
Refrence frame distance related variables.
Definition: encoder.h:1788
macroblock
Encoder's parameters related to the current coding block.
Definition: block.h:846
macroblockd::tx_type_map
uint8_t * tx_type_map
Definition: blockd.h:664
macroblockd::mi
MB_MODE_INFO ** mi
Definition: blockd.h:615
motion_mode_candidate::rate_mv
int rate_mv
Definition: rdopt.c:2069
ModeCosts::skip_txfm_cost
int skip_txfm_cost[SKIP_CONTEXTS][2]
skip_txfm_cost
Definition: block.h:725
process_compound_inter_mode
static int process_compound_inter_mode(AV1_COMP *const cpi, MACROBLOCK *x, HandleInterModeArgs *args, int64_t ref_best_rd, int_mv *cur_mv, BLOCK_SIZE bsize, int *compmode_interinter_cost, const CompoundTypeRdBuffers *rd_buffers, const BUFFER_SET *orig_dst, const BUFFER_SET *tmp_dst, int *rate_mv, RD_STATS *rd_stats, int64_t *skip_rd, int *skip_build_pred)
High level function to select parameters for compound mode.
Definition: rdopt.c:2424
PruneInfoFromTpl::ref_inter_cost
int64_t ref_inter_cost[INTER_REFS_PER_FRAME]
Definition: rdopt.c:2167
av1_nonrd_pick_inter_mode_sb
void av1_nonrd_pick_inter_mode_sb(struct AV1_COMP *cpi, struct TileDataEnc *tile_data, struct macroblock *x, struct RD_STATS *rd_cost, BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx)
AV1 inter mode selection based on Non-RD optimized model.
Definition: nonrd_pickmode.c:2066
macroblock::inter_modes_info
struct inter_modes_info * inter_modes_info
Stores the inter mode information needed to build an rd model.
Definition: block.h:1146