AOMedia AV1 Codec
aom_external_partition.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021, 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 #ifndef AOM_AOM_AOM_EXTERNAL_PARTITION_H_
12 #define AOM_AOM_AOM_EXTERNAL_PARTITION_H_
13 
19 #include <stdint.h>
20 
37 #define AOM_EXT_PART_ABI_VERSION 8
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
45 typedef void *aom_ext_part_model_t;
46 
50 #define AOM_EXT_PART_SIZE_DIRECT_SPLIT 17
51 
56 #define AOM_EXT_PART_SIZE_PRUNE_PART 25
57 
61 #define AOM_EXT_PART_SIZE_PRUNE_NONE 4
62 
67 #define AOM_EXT_PART_SIZE_TERM_NONE 28
68 
71 #define AOM_EXT_PART_SIZE_TERM_SPLIT 31
72 
76 #define AOM_EXT_PART_SIZE_PRUNE_RECT 9
77 
81 #define AOM_EXT_PART_SIZE_PRUNE_AB 10
82 
86 #define AOM_EXT_PART_SIZE_PRUNE_4_WAY 18
87 
97  AOM_EXT_PART_WHOLE_TREE = 0,
98  AOM_EXT_PART_RECURSIVE = 1,
100 
105 typedef struct aom_ext_part_config {
108 
123 
133 
143 
151 
160 
164 typedef enum {
165  AOM_EXT_PART_FEATURE_BEFORE_NONE,
166  AOM_EXT_PART_FEATURE_BEFORE_NONE_PART2,
167  AOM_EXT_PART_FEATURE_AFTER_NONE,
168  AOM_EXT_PART_FEATURE_AFTER_NONE_PART2,
169  AOM_EXT_PART_FEATURE_AFTER_SPLIT,
170  AOM_EXT_PART_FEATURE_AFTER_SPLIT_PART2,
171  AOM_EXT_PART_FEATURE_AFTER_RECT,
172  AOM_EXT_PART_FEATURE_AFTER_AB
174 
183 typedef struct aom_sb_tpl_features {
184  int available;
186  int num_units;
187  int64_t intra_cost[64];
188  int64_t inter_cost[64];
189  int64_t mc_dep_cost[64];
191 
201  int num_units;
202  int block_sse[64];
203  int block_var[64];
205 
210 typedef struct aom_sb_features {
216 
225 typedef struct aom_partition_features {
226  // Features for the current supervised multi-stage ML model.
239 
240  // Features for a new ML model.
242  int mi_row;
243  int mi_col;
247 
256  int qindex;
257  int rdmult;
265 
276  unsigned int block_sse;
277  unsigned int block_var;
278  unsigned int sub_block_sse[4];
279  unsigned int sub_block_var[4];
280  unsigned int horz_block_sse[2];
281  unsigned int horz_block_var[2];
282  unsigned int vert_block_sse[2];
283  unsigned int vert_block_var[2];
284 
288  int64_t tpl_intra_cost;
289  int64_t tpl_inter_cost;
290  int64_t tpl_mc_dep_cost;
292 
302 typedef struct aom_partition_decision {
303  // Decisions for directly set partition types
305  int num_nodes;
306  int partition_decision[2048];
308 
309  // Decisions for partition type pruning
323 
331 typedef struct aom_partition_stats {
332  int rate;
333  int64_t dist;
334  int64_t rdcost;
336 
339 typedef enum aom_ext_part_status {
344 
355  void *priv, const aom_ext_part_config_t *part_config,
356  aom_ext_part_model_t *ext_part_model);
357 
367  aom_ext_part_model_t ext_part_model,
368  const aom_partition_features_t *part_features);
369 
380  aom_ext_part_model_t ext_part_model,
381  aom_partition_decision_t *ext_part_decision);
382 
392  aom_ext_part_model_t ext_part_model,
393  const aom_partition_stats_t *ext_part_stats);
394 
403  aom_ext_part_model_t ext_part_model);
404 
410 typedef struct aom_ext_part_funcs {
415 
420 
425 
430 
435 
440 
444  void *priv;
446 
448 #ifdef __cplusplus
449 } // extern "C"
450 #endif
451 
452 #endif // AOM_AOM_AOM_EXTERNAL_PARTITION_H_
aom_partition_features::after_part_none
aom_partition_features_none_t after_part_none
Definition: aom_external_partition.h:232
aom_partition_decision::partition_horz4_allowed
int partition_horz4_allowed
Allow HORZ4 partition.
Definition: aom_external_partition.h:320
aom_partition_decision::verta_partition_allowed
int verta_partition_allowed
Allow VERT_A partitioin.
Definition: aom_external_partition.h:318
aom_partition_features::tpl_inter_cost
int64_t tpl_inter_cost
Inter cost in tpl model.
Definition: aom_external_partition.h:289
aom_sb_tpl_features::num_units
int num_units
The number of units inside the current superblock.
Definition: aom_external_partition.h:186
aom_partition_stats::rdcost
int64_t rdcost
Rate-distortion cost of the block.
Definition: aom_external_partition.h:334
aom_sb_tpl_features::mc_dep_cost
int64_t mc_dep_cost[64]
The motion compensated dependency cost.
Definition: aom_external_partition.h:189
aom_ext_part_funcs_t
struct aom_ext_part_funcs aom_ext_part_funcs_t
Callback function set for external partition model.
aom_partition_decision::current_decision
int current_decision
Partition decision for the current block.
Definition: aom_external_partition.h:307
aom_partition_features_ab_t
struct aom_partition_features_ab aom_partition_features_ab_t
Features pass to the external model to make partition decisions. Specifically, features collected aft...
aom_partition_decision::partition_none_allowed
int partition_none_allowed
Allow partition none type.
Definition: aom_external_partition.h:311
aom_partition_decision
Partition decisions received from the external model.
Definition: aom_external_partition.h:302
aom_partition_features_rect_t
struct aom_partition_features_rect aom_partition_features_rect_t
Features pass to the external model to make partition decisions. Specifically, features collected aft...
aom_ext_part_funcs::priv
void * priv
Definition: aom_external_partition.h:444
aom_partition_decision_t
struct aom_partition_decision aom_partition_decision_t
Partition decisions received from the external model.
aom_sb_simple_motion_features::num_units
int num_units
The number of units inside the current superblock.
Definition: aom_external_partition.h:201
aom_sb_simple_motion_features::block_sse
int block_sse[64]
Sum of squared error of each unit.
Definition: aom_external_partition.h:202
aom_partition_features::block_sse
unsigned int block_sse
SSE of motion compensated residual.
Definition: aom_external_partition.h:276
aom_ext_part_model_t
void * aom_ext_part_model_t
Abstract external partition model handler.
Definition: aom_external_partition.h:45
aom_partition_decision::horza_partition_allowed
int horza_partition_allowed
Allow HORZ_A partitioin.
Definition: aom_external_partition.h:316
aom_sb_simple_motion_features::unit_length
int unit_length
The block length of the simple motion process.
Definition: aom_external_partition.h:200
aom_sb_features
Features of each super block.
Definition: aom_external_partition.h:210
aom_partition_features::vert_block_var
unsigned int vert_block_var[2]
Variance of vert sub blocks.
Definition: aom_external_partition.h:283
aom_partition_features::horz_block_sse
unsigned int horz_block_sse[2]
SSE of horz sub blocks.
Definition: aom_external_partition.h:280
aom_partition_features::left_block_width
int left_block_width
Width of the left block, -1 if not exist.
Definition: aom_external_partition.h:263
aom_partition_features_before_none
Features pass to the external model to make partition decisions. Specifically, features collected bef...
Definition: aom_external_partition.h:117
aom_partition_features::tpl_mc_dep_cost
int64_t tpl_mc_dep_cost
Motion compensated dependency cost in tpl model.
Definition: aom_external_partition.h:290
aom_partition_features_rect
Features pass to the external model to make partition decisions. Specifically, features collected aft...
Definition: aom_external_partition.h:147
aom_partition_features_rect::f
float f[10]
Definition: aom_external_partition.h:149
aom_partition_features_before_none_t
struct aom_partition_features_before_none aom_partition_features_before_none_t
Features pass to the external model to make partition decisions. Specifically, features collected bef...
aom_sb_features::motion_features
aom_sb_simple_motion_features_t motion_features
Definition: aom_external_partition.h:212
aom_partition_features::pyramid_level
int pyramid_level
The level of this frame in the hierarchical structure.
Definition: aom_external_partition.h:258
aom_partition_features::rdmult
int rdmult
Rate-distortion multiplier.
Definition: aom_external_partition.h:257
aom_partition_decision::horzb_partition_allowed
int horzb_partition_allowed
Allow HORZ_B partitioin.
Definition: aom_external_partition.h:317
aom_partition_features::mi_col
int mi_col
Mi_col position of the block.
Definition: aom_external_partition.h:243
aom_partition_features::mi_row
int mi_row
Mi_row position of the block.
Definition: aom_external_partition.h:242
AOM_EXT_PART_SIZE_DIRECT_SPLIT
#define AOM_EXT_PART_SIZE_DIRECT_SPLIT
Number of features to determine whether to skip partition none and do partition split directly....
Definition: aom_external_partition.h:50
aom_partition_stats::dist
int64_t dist
Distortion of the block.
Definition: aom_external_partition.h:333
aom_partition_features_none_t
struct aom_partition_features_none aom_partition_features_none_t
Features pass to the external model to make partition decisions. Specifically, features collected aft...
aom_partition_features_split
Features pass to the external model to make partition decisions. Specifically, features collected aft...
Definition: aom_external_partition.h:137
AOM_EXT_PART_SIZE_PRUNE_AB
#define AOM_EXT_PART_SIZE_PRUNE_AB
Number of features to prune AB partition using stats collected after rectangular partition....
Definition: aom_external_partition.h:81
aom_partition_features::block_size
int block_size
As "BLOCK_SIZE" in av1/common/enums.h.
Definition: aom_external_partition.h:246
aom_sb_tpl_features::tpl_unit_length
int tpl_unit_length
The block length of tpl process.
Definition: aom_external_partition.h:185
aom_ext_part_config
Config information sent to the external partition model.
Definition: aom_external_partition.h:105
aom_ext_part_decision_mode_t
enum aom_ext_part_decision_mode aom_ext_part_decision_mode_t
Decision mode of the external partition model. AOM_EXT_PART_WHOLE_TREE: the external partition model ...
aom_partition_features::sb_features
aom_sb_features_t sb_features
Features collected for the super block.
Definition: aom_external_partition.h:241
aom_sb_tpl_features::inter_cost
int64_t inter_cost[64]
The inter cost of each unit.
Definition: aom_external_partition.h:188
aom_ext_part_status_t
enum aom_ext_part_status aom_ext_part_status_t
Enum for return status.
aom_partition_decision::prune_rect_part
int prune_rect_part[2]
Prune rectangular partition.
Definition: aom_external_partition.h:315
aom_partition_decision::partition_vert4_allowed
int partition_vert4_allowed
Allow VERT4 partition.
Definition: aom_external_partition.h:321
aom_ext_part_send_partition_stats_fn_t
aom_ext_part_status_t(* aom_ext_part_send_partition_stats_fn_t)(aom_ext_part_model_t ext_part_model, const aom_partition_stats_t *ext_part_stats)
Callback of sending stats to the external partition model.
Definition: aom_external_partition.h:391
aom_partition_decision::vertb_partition_allowed
int vertb_partition_allowed
Allow VERT_B partitioin.
Definition: aom_external_partition.h:319
AOM_EXT_PART_OK
@ AOM_EXT_PART_OK
Status of success.
Definition: aom_external_partition.h:340
aom_partition_features::horz_block_var
unsigned int horz_block_var[2]
Variance of horz sub blocks.
Definition: aom_external_partition.h:281
aom_partition_features_ab
Features pass to the external model to make partition decisions. Specifically, features collected aft...
Definition: aom_external_partition.h:156
aom_partition_features::above_block_width
int above_block_width
Width of the above block, -1 if not exist.
Definition: aom_external_partition.h:260
aom_partition_features_none::f_terminate
float f_terminate[28]
Definition: aom_external_partition.h:131
aom_sb_simple_motion_features::block_var
int block_var[64]
Variance of each unit.
Definition: aom_external_partition.h:203
aom_ext_part_delete_model_fn_t
aom_ext_part_status_t(* aom_ext_part_delete_model_fn_t)(aom_ext_part_model_t ext_part_model)
Callback of deleting the external partition model.
Definition: aom_external_partition.h:402
aom_partition_features::tpl_intra_cost
int64_t tpl_intra_cost
Intra cost, ref to "TplDepStats" in tpl_model.h.
Definition: aom_external_partition.h:288
aom_partition_features::update_type
int update_type
Frame update type, defined in ratectrl.h.
Definition: aom_external_partition.h:255
aom_partition_stats::rate
int rate
Rate cost of the block.
Definition: aom_external_partition.h:332
aom_partition_features::block_var
unsigned int block_var
Variance of motion compensated residual.
Definition: aom_external_partition.h:277
aom_partition_features_split::f_prune_rect
float f_prune_rect[9]
Definition: aom_external_partition.h:141
aom_partition_decision::is_final_decision
int is_final_decision
The flag whether it's the final decision.
Definition: aom_external_partition.h:304
AOM_EXT_PART_FEATURE_ID
AOM_EXT_PART_FEATURE_ID
Feature id to tell the external model the current stage in partition pruning and what features to use...
Definition: aom_external_partition.h:164
aom_ext_part_create_model_fn_t
aom_ext_part_status_t(* aom_ext_part_create_model_fn_t)(void *priv, const aom_ext_part_config_t *part_config, aom_ext_part_model_t *ext_part_model)
Callback of creating an external partition model.
Definition: aom_external_partition.h:354
aom_partition_features::sub_block_var
unsigned int sub_block_var[4]
Variance of sub blocks.
Definition: aom_external_partition.h:279
aom_partition_decision::do_square_split
int do_square_split
Try square split partition.
Definition: aom_external_partition.h:314
aom_ext_part_funcs::send_features
aom_ext_part_send_features_fn_t send_features
Definition: aom_external_partition.h:419
aom_sb_tpl_features
Features collected from the tpl process.
Definition: aom_external_partition.h:183
AOM_EXT_PART_SIZE_PRUNE_NONE
#define AOM_EXT_PART_SIZE_PRUNE_NONE
Number of features to prune split and rectangular partition after PARTITION_NONE.
Definition: aom_external_partition.h:61
aom_ext_part_funcs::delete_model
aom_ext_part_delete_model_fn_t delete_model
Definition: aom_external_partition.h:434
aom_ext_part_config_t
struct aom_ext_part_config aom_ext_part_config_t
Config information sent to the external partition model.
aom_partition_features::left_block_height
int left_block_height
Height of the left block, -1 if not exist.
Definition: aom_external_partition.h:264
aom_partition_decision::num_nodes
int num_nodes
The number of leaf nodes.
Definition: aom_external_partition.h:305
aom_partition_features::id
AOM_EXT_PART_FEATURE_ID id
Definition: aom_external_partition.h:228
aom_partition_features::frame_width
int frame_width
Frame width.
Definition: aom_external_partition.h:244
aom_partition_features::after_part_ab
aom_partition_features_ab_t after_part_ab
Definition: aom_external_partition.h:238
AOM_EXT_PART_SIZE_PRUNE_PART
#define AOM_EXT_PART_SIZE_PRUNE_PART
Number of features to use simple motion search to prune out rectangular partition in some direction....
Definition: aom_external_partition.h:56
aom_partition_features::above_block_height
int above_block_height
Height of the above block, -1 if not exist.
Definition: aom_external_partition.h:261
aom_partition_features::valid_partition_types
int valid_partition_types
Definition: aom_external_partition.h:254
aom_partition_features
Features pass to the external model to make partition decisions.
Definition: aom_external_partition.h:225
aom_partition_features_ab::f
float f[18]
Definition: aom_external_partition.h:158
AOM_EXT_PART_SIZE_TERM_NONE
#define AOM_EXT_PART_SIZE_TERM_NONE
Number of features to terminates partition after partition none using simple_motion_search features a...
Definition: aom_external_partition.h:67
aom_partition_features::sub_block_sse
unsigned int sub_block_sse[4]
SSE of sub blocks.
Definition: aom_external_partition.h:278
aom_partition_features_split_t
struct aom_partition_features_split aom_partition_features_split_t
Features pass to the external model to make partition decisions. Specifically, features collected aft...
aom_partition_decision::do_rectangular_split
int do_rectangular_split
Try rectangular split partition.
Definition: aom_external_partition.h:313
AOM_EXT_PART_SIZE_TERM_SPLIT
#define AOM_EXT_PART_SIZE_TERM_SPLIT
Number of features to terminates partition after partition split.
Definition: aom_external_partition.h:71
AOM_EXT_PART_SIZE_PRUNE_4_WAY
#define AOM_EXT_PART_SIZE_PRUNE_4_WAY
Number of features to prune 4-way partition using stats collected after AB partition.
Definition: aom_external_partition.h:86
aom_partition_features::has_above_block
int has_above_block
Has above neighbor block.
Definition: aom_external_partition.h:259
aom_partition_features::after_part_rect
aom_partition_features_rect_t after_part_rect
Definition: aom_external_partition.h:236
aom_ext_part_config::superblock_size
int superblock_size
super block size (either 64x64 or 128x128)
Definition: aom_external_partition.h:106
aom_ext_part_funcs::get_partition_decision
aom_ext_part_get_decision_fn_t get_partition_decision
Definition: aom_external_partition.h:424
aom_ext_part_funcs::send_partition_stats
aom_ext_part_send_partition_stats_fn_t send_partition_stats
Definition: aom_external_partition.h:429
aom_partition_decision::terminate_partition_search
int terminate_partition_search
Terminate further partition search.
Definition: aom_external_partition.h:310
aom_partition_features::has_left_block
int has_left_block
Has left neighbor block.
Definition: aom_external_partition.h:262
aom_ext_part_get_decision_fn_t
aom_ext_part_status_t(* aom_ext_part_get_decision_fn_t)(aom_ext_part_model_t ext_part_model, aom_partition_decision_t *ext_part_decision)
Callback of receiving partition decisions from the external partition model.
Definition: aom_external_partition.h:379
aom_sb_features_t
struct aom_sb_features aom_sb_features_t
Features of each super block.
aom_partition_decision::partition_rect_allowed
int partition_rect_allowed[2]
Allow rectangular partitions.
Definition: aom_external_partition.h:312
aom_sb_features::tpl_features
aom_sb_tpl_features_t tpl_features
Definition: aom_external_partition.h:214
aom_partition_features::before_part_none
aom_partition_features_before_none_t before_part_none
Definition: aom_external_partition.h:230
aom_partition_features_none
Features pass to the external model to make partition decisions. Specifically, features collected aft...
Definition: aom_external_partition.h:127
aom_partition_features::vert_block_sse
unsigned int vert_block_sse[2]
SSE of vert sub blocks.
Definition: aom_external_partition.h:282
aom_partition_features::after_part_split
aom_partition_features_split_t after_part_split
Definition: aom_external_partition.h:234
aom_ext_part_funcs
Callback function set for external partition model.
Definition: aom_external_partition.h:410
aom_ext_part_decision_mode
aom_ext_part_decision_mode
Decision mode of the external partition model. AOM_EXT_PART_WHOLE_TREE: the external partition model ...
Definition: aom_external_partition.h:96
aom_sb_tpl_features::available
int available
If tpl stats are available.
Definition: aom_external_partition.h:184
aom_partition_features_none::f
float f[4]
Definition: aom_external_partition.h:129
aom_ext_part_send_features_fn_t
aom_ext_part_status_t(* aom_ext_part_send_features_fn_t)(aom_ext_part_model_t ext_part_model, const aom_partition_features_t *part_features)
Callback of sending features to the external partition model.
Definition: aom_external_partition.h:366
aom_partition_features_t
struct aom_partition_features aom_partition_features_t
Features pass to the external model to make partition decisions.
aom_ext_part_status
aom_ext_part_status
Enum for return status.
Definition: aom_external_partition.h:339
aom_ext_part_funcs::decision_mode
aom_ext_part_decision_mode_t decision_mode
Definition: aom_external_partition.h:439
aom_partition_features_split::f_terminate
float f_terminate[31]
Definition: aom_external_partition.h:139
aom_partition_decision::partition_decision
int partition_decision[2048]
Partition decisions.
Definition: aom_external_partition.h:306
aom_partition_stats
Encoding stats for the given partition decision.
Definition: aom_external_partition.h:331
aom_sb_tpl_features_t
struct aom_sb_tpl_features aom_sb_tpl_features_t
Features collected from the tpl process.
aom_partition_features_before_none::f_part2
float f_part2[25]
Definition: aom_external_partition.h:121
aom_sb_tpl_features::intra_cost
int64_t intra_cost[64]
The intra cost of each unit.
Definition: aom_external_partition.h:187
aom_partition_features_before_none::f
float f[17]
Definition: aom_external_partition.h:119
AOM_EXT_PART_TEST
@ AOM_EXT_PART_TEST
Status used for tests.
Definition: aom_external_partition.h:342
AOM_EXT_PART_SIZE_PRUNE_RECT
#define AOM_EXT_PART_SIZE_PRUNE_RECT
Number of features to prune rectangular partition using stats collected after partition split.
Definition: aom_external_partition.h:76
aom_partition_features::qindex
int qindex
Quantization index, range: [0, 255].
Definition: aom_external_partition.h:256
aom_partition_features::frame_height
int frame_height
Frame height.
Definition: aom_external_partition.h:245
aom_sb_simple_motion_features
Features collected from the simple motion process.
Definition: aom_external_partition.h:199
AOM_EXT_PART_ERROR
@ AOM_EXT_PART_ERROR
Status of failure.
Definition: aom_external_partition.h:341
aom_sb_simple_motion_features_t
struct aom_sb_simple_motion_features aom_sb_simple_motion_features_t
Features collected from the simple motion process.
aom_ext_part_funcs::create_model
aom_ext_part_create_model_fn_t create_model
Definition: aom_external_partition.h:414
aom_partition_stats_t
struct aom_partition_stats aom_partition_stats_t
Encoding stats for the given partition decision.