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 
33 #define AOM_EXT_PART_ABI_VERSION 3
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
41 typedef void *aom_ext_part_model_t;
42 
46 #define AOM_EXT_PART_SIZE_DIRECT_SPLIT 17
47 
52 #define AOM_EXT_PART_SIZE_PRUNE_PART 25
53 
57 #define AOM_EXT_PART_SIZE_PRUNE_NONE 4
58 
63 #define AOM_EXT_PART_SIZE_TERM_NONE 28
64 
67 #define AOM_EXT_PART_SIZE_TERM_SPLIT 31
68 
72 #define AOM_EXT_PART_SIZE_PRUNE_RECT 9
73 
77 #define AOM_EXT_PART_SIZE_PRUNE_AB 10
78 
82 #define AOM_EXT_PART_SIZE_PRUNE_4_WAY 18
83 
93  AOM_EXT_PART_WHOLE_TREE = 0,
94  AOM_EXT_PART_RECURSIVE = 1,
96 
101 typedef struct aom_ext_part_config {
104 
119 
129 
139 
147 
156 
160 typedef enum {
161  AOM_EXT_PART_FEATURE_BEFORE_NONE,
162  AOM_EXT_PART_FEATURE_BEFORE_NONE_PART2,
163  AOM_EXT_PART_FEATURE_AFTER_NONE,
164  AOM_EXT_PART_FEATURE_AFTER_NONE_PART2,
165  AOM_EXT_PART_FEATURE_AFTER_SPLIT,
166  AOM_EXT_PART_FEATURE_AFTER_SPLIT_PART2,
167  AOM_EXT_PART_FEATURE_AFTER_RECT,
168  AOM_EXT_PART_FEATURE_AFTER_AB
170 
179 typedef struct aom_sb_tpl_features {
180  int available;
182  int num_units;
183  int64_t intra_cost[64];
184  int64_t inter_cost[64];
185  int64_t mc_dep_cost[64];
187 
197  int num_units;
198  int block_sse[64];
199  int block_var[64];
201 
206 typedef struct aom_sb_features {
212 
221 typedef struct aom_partition_features {
222  // Features for the current supervised multi-stage ML model.
235 
236  // Features for a new ML model.
238  int mi_row;
239  int mi_col;
244 
254 typedef struct aom_partition_decision {
255  // Decisions for directly set partition types
257  int num_nodes;
258  int partition_decision[2048];
260 
261  // Decisions for partition type pruning
275 
283 typedef struct aom_partition_stats {
284  int rate;
285  int64_t dist;
286  int64_t rdcost;
288 
291 typedef enum aom_ext_part_status {
296 
307  void *priv, const aom_ext_part_config_t *part_config,
308  aom_ext_part_model_t *ext_part_model);
309 
319  aom_ext_part_model_t ext_part_model,
320  const aom_partition_features_t *part_features);
321 
332  aom_ext_part_model_t ext_part_model,
333  aom_partition_decision_t *ext_part_decision);
334 
344  aom_ext_part_model_t ext_part_model,
345  const aom_partition_stats_t *ext_part_stats);
346 
355  aom_ext_part_model_t ext_part_model);
356 
362 typedef struct aom_ext_part_funcs {
367 
372 
377 
382 
387 
392 
396  void *priv;
398 
400 #ifdef __cplusplus
401 } // extern "C"
402 #endif
403 
404 #endif // AOM_AOM_AOM_EXTERNAL_PARTITION_H_
struct aom_partition_features_split aom_partition_features_split_t
Features pass to the external model to make partition decisions. Specifically, features collected aft...
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_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:306
#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:82
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:160
#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:63
#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:52
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:343
struct aom_partition_features aom_partition_features_t
Features pass to the external model to make partition decisions.
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...
enum aom_ext_part_status aom_ext_part_status_t
Enum for return status.
aom_ext_part_status
Enum for return status.
Definition: aom_external_partition.h:291
#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:72
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:92
struct aom_sb_simple_motion_features aom_sb_simple_motion_features_t
Features collected from the simple motion process.
struct aom_ext_part_config aom_ext_part_config_t
Config information sent to the external partition model.
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:318
void * aom_ext_part_model_t
Abstract external partition model handler.
Definition: aom_external_partition.h:41
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:354
struct aom_partition_stats aom_partition_stats_t
Encoding stats for the given partition decision.
struct aom_ext_part_funcs aom_ext_part_funcs_t
Callback function set for external partition model.
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 ...
struct aom_sb_features aom_sb_features_t
Features of each super block.
struct aom_partition_features_rect aom_partition_features_rect_t
Features pass to the external model to make partition decisions. Specifically, features collected aft...
struct aom_sb_tpl_features aom_sb_tpl_features_t
Features collected from the tpl process.
#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:77
#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:46
struct aom_partition_decision aom_partition_decision_t
Partition decisions received from the external model.
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_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:331
#define AOM_EXT_PART_SIZE_PRUNE_NONE
Number of features to prune split and rectangular partition after PARTITION_NONE.
Definition: aom_external_partition.h:57
#define AOM_EXT_PART_SIZE_TERM_SPLIT
Number of features to terminates partition after partition split.
Definition: aom_external_partition.h:67
@ AOM_EXT_PART_TEST
Status used for tests.
Definition: aom_external_partition.h:294
@ AOM_EXT_PART_ERROR
Status of failure.
Definition: aom_external_partition.h:293
@ AOM_EXT_PART_OK
Status of success.
Definition: aom_external_partition.h:292
Config information sent to the external partition model.
Definition: aom_external_partition.h:101
int superblock_size
super block size (either 64x64 or 128x128)
Definition: aom_external_partition.h:102
Callback function set for external partition model.
Definition: aom_external_partition.h:362
aom_ext_part_delete_model_fn_t delete_model
Definition: aom_external_partition.h:386
aom_ext_part_get_decision_fn_t get_partition_decision
Definition: aom_external_partition.h:376
void * priv
Definition: aom_external_partition.h:396
aom_ext_part_decision_mode_t decision_mode
Definition: aom_external_partition.h:391
aom_ext_part_create_model_fn_t create_model
Definition: aom_external_partition.h:366
aom_ext_part_send_features_fn_t send_features
Definition: aom_external_partition.h:371
aom_ext_part_send_partition_stats_fn_t send_partition_stats
Definition: aom_external_partition.h:381
Partition decisions received from the external model.
Definition: aom_external_partition.h:254
int is_final_decision
The flag whether it's the final decision.
Definition: aom_external_partition.h:256
int do_square_split
Try square split partition.
Definition: aom_external_partition.h:266
int verta_partition_allowed
Allow VERT_A partitioin.
Definition: aom_external_partition.h:270
int terminate_partition_search
Terminate further partition search.
Definition: aom_external_partition.h:262
int partition_vert4_allowed
Allow VERT4 partition.
Definition: aom_external_partition.h:273
int vertb_partition_allowed
Allow VERT_B partitioin.
Definition: aom_external_partition.h:271
int horzb_partition_allowed
Allow HORZ_B partitioin.
Definition: aom_external_partition.h:269
int partition_rect_allowed[2]
Allow rectangular partitions.
Definition: aom_external_partition.h:264
int num_nodes
The number of leaf nodes.
Definition: aom_external_partition.h:257
int horza_partition_allowed
Allow HORZ_A partitioin.
Definition: aom_external_partition.h:268
int partition_none_allowed
Allow partition none type.
Definition: aom_external_partition.h:263
int do_rectangular_split
Try rectangular split partition.
Definition: aom_external_partition.h:265
int partition_horz4_allowed
Allow HORZ4 partition.
Definition: aom_external_partition.h:272
int partition_decision[2048]
Partition decisions.
Definition: aom_external_partition.h:258
int current_decision
Partition decision for the current block.
Definition: aom_external_partition.h:259
int prune_rect_part[2]
Prune rectangular partition.
Definition: aom_external_partition.h:267
Features pass to the external model to make partition decisions. Specifically, features collected aft...
Definition: aom_external_partition.h:152
float f[18]
Definition: aom_external_partition.h:154
Features pass to the external model to make partition decisions. Specifically, features collected bef...
Definition: aom_external_partition.h:113
float f[17]
Definition: aom_external_partition.h:115
float f_part2[25]
Definition: aom_external_partition.h:117
Features pass to the external model to make partition decisions. Specifically, features collected aft...
Definition: aom_external_partition.h:123
float f_terminate[28]
Definition: aom_external_partition.h:127
float f[4]
Definition: aom_external_partition.h:125
Features pass to the external model to make partition decisions. Specifically, features collected aft...
Definition: aom_external_partition.h:143
float f[10]
Definition: aom_external_partition.h:145
Features pass to the external model to make partition decisions. Specifically, features collected aft...
Definition: aom_external_partition.h:133
float f_terminate[31]
Definition: aom_external_partition.h:135
float f_prune_rect[9]
Definition: aom_external_partition.h:137
Features pass to the external model to make partition decisions.
Definition: aom_external_partition.h:221
aom_partition_features_rect_t after_part_rect
Definition: aom_external_partition.h:232
aom_partition_features_ab_t after_part_ab
Definition: aom_external_partition.h:234
AOM_EXT_PART_FEATURE_ID id
Definition: aom_external_partition.h:224
aom_partition_features_none_t after_part_none
Definition: aom_external_partition.h:228
int frame_width
Frame width.
Definition: aom_external_partition.h:240
int block_size
As "BLOCK_SIZE" in av1/common/enums.h.
Definition: aom_external_partition.h:242
int mi_row
Mi_row position of the block.
Definition: aom_external_partition.h:238
aom_partition_features_before_none_t before_part_none
Definition: aom_external_partition.h:226
int frame_height
Frame height.
Definition: aom_external_partition.h:241
aom_sb_features_t sb_features
Features collected for the super block.
Definition: aom_external_partition.h:237
aom_partition_features_split_t after_part_split
Definition: aom_external_partition.h:230
int mi_col
Mi_col position of the block.
Definition: aom_external_partition.h:239
Encoding stats for the given partition decision.
Definition: aom_external_partition.h:283
int64_t dist
Distortion of the block.
Definition: aom_external_partition.h:285
int64_t rdcost
Rate-distortion cost of the block.
Definition: aom_external_partition.h:286
int rate
Rate cost of the block.
Definition: aom_external_partition.h:284
Features of each super block.
Definition: aom_external_partition.h:206
aom_sb_tpl_features_t tpl_features
Definition: aom_external_partition.h:210
aom_sb_simple_motion_features_t motion_features
Definition: aom_external_partition.h:208
Features collected from the simple motion process.
Definition: aom_external_partition.h:195
int num_units
The number of units inside the current superblock.
Definition: aom_external_partition.h:197
int block_var[64]
Variance of each unit.
Definition: aom_external_partition.h:199
int unit_length
The block length of the simple motion process.
Definition: aom_external_partition.h:196
int block_sse[64]
Sum of squared error of each unit.
Definition: aom_external_partition.h:198
Features collected from the tpl process.
Definition: aom_external_partition.h:179
int available
If tpl stats are available.
Definition: aom_external_partition.h:180
int num_units
The number of units inside the current superblock.
Definition: aom_external_partition.h:182
int64_t mc_dep_cost[64]
The motion compensated dependency cost.
Definition: aom_external_partition.h:185
int64_t inter_cost[64]
The inter cost of each unit.
Definition: aom_external_partition.h:184
int64_t intra_cost[64]
The intra cost of each unit.
Definition: aom_external_partition.h:183
int tpl_unit_length
The block length of tpl process.
Definition: aom_external_partition.h:181