xref: /aosp_15_r20/external/libaom/av1/encoder/mv_prec.h (revision 77c1e3ccc04c968bd2bc212e87364f250e820521)
1*77c1e3ccSAndroid Build Coastguard Worker /*
2*77c1e3ccSAndroid Build Coastguard Worker  * Copyright (c) 2019, Alliance for Open Media. All rights reserved.
3*77c1e3ccSAndroid Build Coastguard Worker  *
4*77c1e3ccSAndroid Build Coastguard Worker  * This source code is subject to the terms of the BSD 2 Clause License and
5*77c1e3ccSAndroid Build Coastguard Worker  * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6*77c1e3ccSAndroid Build Coastguard Worker  * was not distributed with this source code in the LICENSE file, you can
7*77c1e3ccSAndroid Build Coastguard Worker  * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8*77c1e3ccSAndroid Build Coastguard Worker  * Media Patent License 1.0 was not distributed with this source code in the
9*77c1e3ccSAndroid Build Coastguard Worker  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10*77c1e3ccSAndroid Build Coastguard Worker  */
11*77c1e3ccSAndroid Build Coastguard Worker 
12*77c1e3ccSAndroid Build Coastguard Worker #ifndef AOM_AV1_ENCODER_MV_PREC_H_
13*77c1e3ccSAndroid Build Coastguard Worker #define AOM_AV1_ENCODER_MV_PREC_H_
14*77c1e3ccSAndroid Build Coastguard Worker 
15*77c1e3ccSAndroid Build Coastguard Worker #include "av1/encoder/encoder.h"
16*77c1e3ccSAndroid Build Coastguard Worker #include "av1/encoder/speed_features.h"
17*77c1e3ccSAndroid Build Coastguard Worker 
18*77c1e3ccSAndroid Build Coastguard Worker // Q threshold for high precision mv.
19*77c1e3ccSAndroid Build Coastguard Worker #define HIGH_PRECISION_MV_QTHRESH 128
20*77c1e3ccSAndroid Build Coastguard Worker #if !CONFIG_REALTIME_ONLY
21*77c1e3ccSAndroid Build Coastguard Worker void av1_collect_mv_stats(AV1_COMP *cpi, int current_q);
22*77c1e3ccSAndroid Build Coastguard Worker 
av1_frame_allows_smart_mv(const AV1_COMP * cpi)23*77c1e3ccSAndroid Build Coastguard Worker static inline int av1_frame_allows_smart_mv(const AV1_COMP *cpi) {
24*77c1e3ccSAndroid Build Coastguard Worker   const int gf_group_index = cpi->gf_frame_index;
25*77c1e3ccSAndroid Build Coastguard Worker   const int gf_update_type = cpi->ppi->gf_group.update_type[gf_group_index];
26*77c1e3ccSAndroid Build Coastguard Worker   return !frame_is_intra_only(&cpi->common) &&
27*77c1e3ccSAndroid Build Coastguard Worker          !(gf_update_type == INTNL_OVERLAY_UPDATE ||
28*77c1e3ccSAndroid Build Coastguard Worker            gf_update_type == OVERLAY_UPDATE);
29*77c1e3ccSAndroid Build Coastguard Worker }
30*77c1e3ccSAndroid Build Coastguard Worker #endif  // !CONFIG_REALTIME_ONLY
31*77c1e3ccSAndroid Build Coastguard Worker 
av1_set_high_precision_mv(AV1_COMP * cpi,int allow_high_precision_mv,int cur_frame_force_integer_mv)32*77c1e3ccSAndroid Build Coastguard Worker static inline void av1_set_high_precision_mv(AV1_COMP *cpi,
33*77c1e3ccSAndroid Build Coastguard Worker                                              int allow_high_precision_mv,
34*77c1e3ccSAndroid Build Coastguard Worker                                              int cur_frame_force_integer_mv) {
35*77c1e3ccSAndroid Build Coastguard Worker   MvCosts *const mv_costs = cpi->td.mb.mv_costs;
36*77c1e3ccSAndroid Build Coastguard Worker   // Avoid accessing 'mv_costs' when it is not allocated.
37*77c1e3ccSAndroid Build Coastguard Worker   if (mv_costs == NULL) return;
38*77c1e3ccSAndroid Build Coastguard Worker 
39*77c1e3ccSAndroid Build Coastguard Worker   const int copy_hp = cpi->common.features.allow_high_precision_mv =
40*77c1e3ccSAndroid Build Coastguard Worker       allow_high_precision_mv && !cur_frame_force_integer_mv;
41*77c1e3ccSAndroid Build Coastguard Worker 
42*77c1e3ccSAndroid Build Coastguard Worker   mv_costs->nmv_cost[0] = &mv_costs->nmv_cost_alloc[0][MV_MAX];
43*77c1e3ccSAndroid Build Coastguard Worker   mv_costs->nmv_cost[1] = &mv_costs->nmv_cost_alloc[1][MV_MAX];
44*77c1e3ccSAndroid Build Coastguard Worker   mv_costs->nmv_cost_hp[0] = &mv_costs->nmv_cost_hp_alloc[0][MV_MAX];
45*77c1e3ccSAndroid Build Coastguard Worker   mv_costs->nmv_cost_hp[1] = &mv_costs->nmv_cost_hp_alloc[1][MV_MAX];
46*77c1e3ccSAndroid Build Coastguard Worker   mv_costs->mv_cost_stack =
47*77c1e3ccSAndroid Build Coastguard Worker       copy_hp ? mv_costs->nmv_cost_hp : mv_costs->nmv_cost;
48*77c1e3ccSAndroid Build Coastguard Worker }
49*77c1e3ccSAndroid Build Coastguard Worker 
50*77c1e3ccSAndroid Build Coastguard Worker void av1_pick_and_set_high_precision_mv(AV1_COMP *cpi, int qindex);
51*77c1e3ccSAndroid Build Coastguard Worker 
52*77c1e3ccSAndroid Build Coastguard Worker #endif  // AOM_AV1_ENCODER_MV_PREC_H_
53