AOMedia AV1 Codec
nonrd_opt.h
1 /*
2  * Copyright (c) 2022, 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_NONRD_OPT_H_
13 #define AOM_AV1_ENCODER_NONRD_OPT_H_
14 
15 #include "av1/encoder/rdopt_utils.h"
16 
43 static INLINE void find_predictors(
44  AV1_COMP *cpi, MACROBLOCK *x, MV_REFERENCE_FRAME ref_frame,
45  int_mv frame_mv[MB_MODE_COUNT][REF_FRAMES], TileDataEnc *tile_data,
46  struct buf_2d yv12_mb[8][MAX_MB_PLANE], BLOCK_SIZE bsize,
47  int force_skip_low_temp_var, int skip_pred_mv) {
48  AV1_COMMON *const cm = &cpi->common;
49  MACROBLOCKD *const xd = &x->e_mbd;
50  MB_MODE_INFO *const mbmi = xd->mi[0];
51  MB_MODE_INFO_EXT *const mbmi_ext = &x->mbmi_ext;
52  const YV12_BUFFER_CONFIG *yv12 = get_ref_frame_yv12_buf(cm, ref_frame);
53  const int num_planes = av1_num_planes(cm);
54  (void)tile_data;
55 
56  x->pred_mv_sad[ref_frame] = INT_MAX;
57  x->pred_mv0_sad[ref_frame] = INT_MAX;
58  x->pred_mv1_sad[ref_frame] = INT_MAX;
59  frame_mv[NEWMV][ref_frame].as_int = INVALID_MV;
60  // TODO(kyslov) this needs various further optimizations. to be continued..
61  assert(yv12 != NULL);
62  if (yv12 != NULL) {
63  const struct scale_factors *const sf =
64  get_ref_scale_factors_const(cm, ref_frame);
65  av1_setup_pred_block(xd, yv12_mb[ref_frame], yv12, sf, sf, num_planes);
66  av1_find_mv_refs(cm, xd, mbmi, ref_frame, mbmi_ext->ref_mv_count,
67  xd->ref_mv_stack, xd->weight, NULL, mbmi_ext->global_mvs,
68  mbmi_ext->mode_context);
69  // TODO(Ravi): Populate mbmi_ext->ref_mv_stack[ref_frame][4] and
70  // mbmi_ext->weight[ref_frame][4] inside av1_find_mv_refs.
71  av1_copy_usable_ref_mv_stack_and_weight(xd, mbmi_ext, ref_frame);
72  av1_find_best_ref_mvs_from_stack(
73  cm->features.allow_high_precision_mv, mbmi_ext, ref_frame,
74  &frame_mv[NEARESTMV][ref_frame], &frame_mv[NEARMV][ref_frame], 0);
75  frame_mv[GLOBALMV][ref_frame] = mbmi_ext->global_mvs[ref_frame];
76  // Early exit for non-LAST frame if force_skip_low_temp_var is set.
77  if (!av1_is_scaled(sf) && bsize >= BLOCK_8X8 && !skip_pred_mv &&
78  !(force_skip_low_temp_var && ref_frame != LAST_FRAME)) {
79  av1_mv_pred(cpi, x, yv12_mb[ref_frame][0].buf, yv12->y_stride, ref_frame,
80  bsize);
81  }
82  }
83  av1_count_overlappable_neighbors(cm, xd);
84  mbmi->num_proj_ref = 1;
85 }
86 
87 #endif // AOM_AV1_ENCODER_NONRD_OPT_H_
static void find_predictors(AV1_COMP *cpi, MACROBLOCK *x, MV_REFERENCE_FRAME ref_frame, int_mv frame_mv[MB_MODE_COUNT][REF_FRAMES], TileDataEnc *tile_data, struct buf_2d yv12_mb[8][3], BLOCK_SIZE bsize, int force_skip_low_temp_var, int skip_pred_mv)
Finds predicted motion vectors for a block.
Definition: nonrd_opt.h:43
Top level common structure used by both encoder and decoder.
Definition: av1_common_int.h:750
FeatureFlags features
Definition: av1_common_int.h:905
Top level encoder structure.
Definition: encoder.h:2664
AV1_COMMON common
Definition: encoder.h:2707
bool allow_high_precision_mv
Definition: av1_common_int.h:367
Extended mode info derived from mbmi.
Definition: block.h:192
int_mv global_mvs[REF_FRAMES]
Global mvs.
Definition: block.h:201
int16_t mode_context[MODE_CTX_REF_FRAMES]
Context used to encode the current mode.
Definition: block.h:203
uint8_t ref_mv_count[MODE_CTX_REF_FRAMES]
Number of ref mvs in the drl.
Definition: block.h:199
Stores the prediction/txfm mode of the current coding block.
Definition: blockd.h:222
uint8_t num_proj_ref
Number of samples used by warp causal.
Definition: blockd.h:252
Encoder's parameters related to the current coding block.
Definition: block.h:813
MACROBLOCKD e_mbd
Decoder's view of current coding block.
Definition: block.h:831
int pred_mv1_sad[REF_FRAMES]
The sad of the 2nd mv ref (near).
Definition: block.h:1028
int pred_mv0_sad[REF_FRAMES]
The sad of the 1st mv ref (nearest).
Definition: block.h:1026
int pred_mv_sad[REF_FRAMES]
Sum absolute distortion of the predicted mv for each ref frame.
Definition: block.h:1018
MB_MODE_INFO_EXT mbmi_ext
Derived coding information.
Definition: block.h:838
Variables related to current coding block.
Definition: blockd.h:577
uint16_t weight[MODE_CTX_REF_FRAMES][MAX_REF_MV_STACK_SIZE]
Definition: blockd.h:788
CANDIDATE_MV ref_mv_stack[MODE_CTX_REF_FRAMES][MAX_REF_MV_STACK_SIZE]
Definition: blockd.h:783
MB_MODE_INFO ** mi
Definition: blockd.h:624
YV12 frame buffer data structure.
Definition: yv12config.h:39