xref: /aosp_15_r20/external/libaom/av1/encoder/partition_search.h (revision 77c1e3ccc04c968bd2bc212e87364f250e820521)
1*77c1e3ccSAndroid Build Coastguard Worker /*
2*77c1e3ccSAndroid Build Coastguard Worker  * Copyright (c) 2020, 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_PARTITION_SEARCH_H_
13*77c1e3ccSAndroid Build Coastguard Worker #define AOM_AV1_ENCODER_PARTITION_SEARCH_H_
14*77c1e3ccSAndroid Build Coastguard Worker 
15*77c1e3ccSAndroid Build Coastguard Worker #include "av1/encoder/block.h"
16*77c1e3ccSAndroid Build Coastguard Worker #include "av1/encoder/encoder.h"
17*77c1e3ccSAndroid Build Coastguard Worker #include "av1/encoder/encodeframe.h"
18*77c1e3ccSAndroid Build Coastguard Worker #include "av1/encoder/tokenize.h"
19*77c1e3ccSAndroid Build Coastguard Worker 
20*77c1e3ccSAndroid Build Coastguard Worker void av1_set_offsets_without_segment_id(const AV1_COMP *const cpi,
21*77c1e3ccSAndroid Build Coastguard Worker                                         const TileInfo *const tile,
22*77c1e3ccSAndroid Build Coastguard Worker                                         MACROBLOCK *const x, int mi_row,
23*77c1e3ccSAndroid Build Coastguard Worker                                         int mi_col, BLOCK_SIZE bsize);
24*77c1e3ccSAndroid Build Coastguard Worker void av1_set_offsets(const AV1_COMP *const cpi, const TileInfo *const tile,
25*77c1e3ccSAndroid Build Coastguard Worker                      MACROBLOCK *const x, int mi_row, int mi_col,
26*77c1e3ccSAndroid Build Coastguard Worker                      BLOCK_SIZE bsize);
27*77c1e3ccSAndroid Build Coastguard Worker void av1_rd_use_partition(AV1_COMP *cpi, ThreadData *td, TileDataEnc *tile_data,
28*77c1e3ccSAndroid Build Coastguard Worker                           MB_MODE_INFO **mib, TokenExtra **tp, int mi_row,
29*77c1e3ccSAndroid Build Coastguard Worker                           int mi_col, BLOCK_SIZE bsize, int *rate,
30*77c1e3ccSAndroid Build Coastguard Worker                           int64_t *dist, int do_recon, PC_TREE *pc_tree);
31*77c1e3ccSAndroid Build Coastguard Worker void av1_nonrd_use_partition(AV1_COMP *cpi, ThreadData *td,
32*77c1e3ccSAndroid Build Coastguard Worker                              TileDataEnc *tile_data, MB_MODE_INFO **mib,
33*77c1e3ccSAndroid Build Coastguard Worker                              TokenExtra **tp, int mi_row, int mi_col,
34*77c1e3ccSAndroid Build Coastguard Worker                              BLOCK_SIZE bsize, PC_TREE *pc_tree);
35*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_RT_ML_PARTITIONING
36*77c1e3ccSAndroid Build Coastguard Worker void av1_nonrd_pick_partition(AV1_COMP *cpi, ThreadData *td,
37*77c1e3ccSAndroid Build Coastguard Worker                               TileDataEnc *tile_data, TokenExtra **tp,
38*77c1e3ccSAndroid Build Coastguard Worker                               int mi_row, int mi_col, BLOCK_SIZE bsize,
39*77c1e3ccSAndroid Build Coastguard Worker                               RD_STATS *rd_cost, int do_recon, int64_t best_rd,
40*77c1e3ccSAndroid Build Coastguard Worker                               PC_TREE *pc_tree);
41*77c1e3ccSAndroid Build Coastguard Worker #endif
42*77c1e3ccSAndroid Build Coastguard Worker void av1_reset_part_sf(PARTITION_SPEED_FEATURES *part_sf);
43*77c1e3ccSAndroid Build Coastguard Worker void av1_reset_sf_for_ext_part(AV1_COMP *const cpi);
44*77c1e3ccSAndroid Build Coastguard Worker 
45*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_PARTITION_SEARCH_ORDER
46*77c1e3ccSAndroid Build Coastguard Worker bool av1_rd_partition_search(AV1_COMP *const cpi, ThreadData *td,
47*77c1e3ccSAndroid Build Coastguard Worker                              TileDataEnc *tile_data, TokenExtra **tp,
48*77c1e3ccSAndroid Build Coastguard Worker                              SIMPLE_MOTION_DATA_TREE *sms_root, int mi_row,
49*77c1e3ccSAndroid Build Coastguard Worker                              int mi_col, BLOCK_SIZE bsize,
50*77c1e3ccSAndroid Build Coastguard Worker                              RD_STATS *best_rd_cost);
51*77c1e3ccSAndroid Build Coastguard Worker #endif
52*77c1e3ccSAndroid Build Coastguard Worker 
53*77c1e3ccSAndroid Build Coastguard Worker bool av1_rd_pick_partition(AV1_COMP *const cpi, ThreadData *td,
54*77c1e3ccSAndroid Build Coastguard Worker                            TileDataEnc *tile_data, TokenExtra **tp, int mi_row,
55*77c1e3ccSAndroid Build Coastguard Worker                            int mi_col, BLOCK_SIZE bsize, RD_STATS *rd_cost,
56*77c1e3ccSAndroid Build Coastguard Worker                            RD_STATS best_rdc, PC_TREE *pc_tree,
57*77c1e3ccSAndroid Build Coastguard Worker                            SIMPLE_MOTION_DATA_TREE *sms_tree, int64_t *none_rd,
58*77c1e3ccSAndroid Build Coastguard Worker                            SB_MULTI_PASS_MODE multi_pass_mode,
59*77c1e3ccSAndroid Build Coastguard Worker                            RD_RECT_PART_WIN_INFO *rect_part_win_info);
60*77c1e3ccSAndroid Build Coastguard Worker 
set_cb_offsets(uint16_t * cb_offset,const uint16_t cb_offset_y,const uint16_t cb_offset_uv)61*77c1e3ccSAndroid Build Coastguard Worker static inline void set_cb_offsets(uint16_t *cb_offset,
62*77c1e3ccSAndroid Build Coastguard Worker                                   const uint16_t cb_offset_y,
63*77c1e3ccSAndroid Build Coastguard Worker                                   const uint16_t cb_offset_uv) {
64*77c1e3ccSAndroid Build Coastguard Worker   cb_offset[PLANE_TYPE_Y] = cb_offset_y;
65*77c1e3ccSAndroid Build Coastguard Worker   cb_offset[PLANE_TYPE_UV] = cb_offset_uv;
66*77c1e3ccSAndroid Build Coastguard Worker }
67*77c1e3ccSAndroid Build Coastguard Worker 
update_cb_offsets(MACROBLOCK * x,const BLOCK_SIZE bsize,const int subsampling_x,const int subsampling_y)68*77c1e3ccSAndroid Build Coastguard Worker static inline void update_cb_offsets(MACROBLOCK *x, const BLOCK_SIZE bsize,
69*77c1e3ccSAndroid Build Coastguard Worker                                      const int subsampling_x,
70*77c1e3ccSAndroid Build Coastguard Worker                                      const int subsampling_y) {
71*77c1e3ccSAndroid Build Coastguard Worker   x->cb_offset[PLANE_TYPE_Y] += block_size_wide[bsize] * block_size_high[bsize];
72*77c1e3ccSAndroid Build Coastguard Worker   if (x->e_mbd.is_chroma_ref) {
73*77c1e3ccSAndroid Build Coastguard Worker     const BLOCK_SIZE plane_bsize =
74*77c1e3ccSAndroid Build Coastguard Worker         get_plane_block_size(bsize, subsampling_x, subsampling_y);
75*77c1e3ccSAndroid Build Coastguard Worker     assert(plane_bsize != BLOCK_INVALID);
76*77c1e3ccSAndroid Build Coastguard Worker     x->cb_offset[PLANE_TYPE_UV] +=
77*77c1e3ccSAndroid Build Coastguard Worker         block_size_wide[plane_bsize] * block_size_high[plane_bsize];
78*77c1e3ccSAndroid Build Coastguard Worker   }
79*77c1e3ccSAndroid Build Coastguard Worker }
80*77c1e3ccSAndroid Build Coastguard Worker 
81*77c1e3ccSAndroid Build Coastguard Worker #endif  // AOM_AV1_ENCODER_PARTITION_SEARCH_H_
82