aboutsummaryrefslogtreecommitdiff
path: root/third_party/libaom/source/libaom/av1/encoder/encodeframe_utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/libaom/source/libaom/av1/encoder/encodeframe_utils.h')
-rw-r--r--third_party/libaom/source/libaom/av1/encoder/encodeframe_utils.h147
1 files changed, 104 insertions, 43 deletions
diff --git a/third_party/libaom/source/libaom/av1/encoder/encodeframe_utils.h b/third_party/libaom/source/libaom/av1/encoder/encodeframe_utils.h
index 7bdfad5cba..3096181885 100644
--- a/third_party/libaom/source/libaom/av1/encoder/encodeframe_utils.h
+++ b/third_party/libaom/source/libaom/av1/encoder/encodeframe_utils.h
@@ -13,17 +13,68 @@
#define AOM_AV1_ENCODER_ENCODEFRAME_UTILS_H_
#include "aom_ports/aom_timer.h"
+#include "aom_ports/system_state.h"
#include "av1/common/reconinter.h"
#include "av1/encoder/encoder.h"
-#include "av1/encoder/partition_strategy.h"
#include "av1/encoder/rdopt.h"
#ifdef __cplusplus
extern "C" {
#endif
+#define WRITE_FEATURE_TO_FILE 0
+
+#define FEATURE_SIZE_SMS_SPLIT_FAST 6
+#define FEATURE_SIZE_SMS_SPLIT 17
+#define FEATURE_SIZE_SMS_PRUNE_PART 25
+#define FEATURE_SIZE_SMS_TERM_NONE 28
+#define FEATURE_SIZE_FP_SMS_TERM_NONE 20
+#define FEATURE_SIZE_MAX_MIN_PART_PRED 13
+#define MAX_NUM_CLASSES_MAX_MIN_PART_PRED 4
+
+#define FEATURE_SMS_NONE_FLAG 1
+#define FEATURE_SMS_SPLIT_FLAG (1 << 1)
+#define FEATURE_SMS_RECT_FLAG (1 << 2)
+
+#define FEATURE_SMS_PRUNE_PART_FLAG \
+ (FEATURE_SMS_NONE_FLAG | FEATURE_SMS_SPLIT_FLAG | FEATURE_SMS_RECT_FLAG)
+#define FEATURE_SMS_SPLIT_MODEL_FLAG \
+ (FEATURE_SMS_NONE_FLAG | FEATURE_SMS_SPLIT_FLAG)
+
+// Number of sub-partitions in rectangular partition types.
+#define SUB_PARTITIONS_RECT 2
+
+// Number of sub-partitions in split partition type.
+#define SUB_PARTITIONS_SPLIT 4
+
+// Number of sub-partitions in AB partition types.
+#define SUB_PARTITIONS_AB 3
+
+// Number of sub-partitions in 4-way partition types.
+#define SUB_PARTITIONS_PART4 4
+
+// 4part parition types.
+enum { HORZ4 = 0, VERT4, NUM_PART4_TYPES } UENUM1BYTE(PART4_TYPES);
+
+// AB parition types.
+enum {
+ HORZ_A = 0,
+ HORZ_B,
+ VERT_A,
+ VERT_B,
+ NUM_AB_PARTS
+} UENUM1BYTE(AB_PART_TYPE);
+
+// Rectangular parition types.
+enum { HORZ = 0, VERT, NUM_RECT_PARTS } UENUM1BYTE(RECT_PART_TYPE);
+
+// Structure to keep win flags for HORZ and VERT partition evaluations.
+typedef struct {
+ int rect_part_win[NUM_RECT_PARTS];
+} RD_RECT_PART_WIN_INFO;
+
enum { PICK_MODE_RD = 0, PICK_MODE_NONRD };
enum {
@@ -218,47 +269,6 @@ static AOM_INLINE const FIRSTPASS_STATS *read_one_frame_stats(const TWO_PASS *p,
return &p->stats_buf_ctx->stats_in_start[frm];
}
-static BLOCK_SIZE dim_to_size(int dim) {
- switch (dim) {
- case 4: return BLOCK_4X4;
- case 8: return BLOCK_8X8;
- case 16: return BLOCK_16X16;
- case 32: return BLOCK_32X32;
- case 64: return BLOCK_64X64;
- case 128: return BLOCK_128X128;
- default: assert(0); return 0;
- }
-}
-
-static AOM_INLINE void set_max_min_partition_size(SuperBlockEnc *sb_enc,
- AV1_COMP *cpi, MACROBLOCK *x,
- const SPEED_FEATURES *sf,
- BLOCK_SIZE sb_size,
- int mi_row, int mi_col) {
- const AV1_COMMON *cm = &cpi->common;
-
- sb_enc->max_partition_size =
- AOMMIN(sf->part_sf.default_max_partition_size,
- dim_to_size(cpi->oxcf.part_cfg.max_partition_size));
- sb_enc->min_partition_size =
- AOMMAX(sf->part_sf.default_min_partition_size,
- dim_to_size(cpi->oxcf.part_cfg.min_partition_size));
- sb_enc->max_partition_size =
- AOMMIN(sb_enc->max_partition_size, cm->seq_params.sb_size);
- sb_enc->min_partition_size =
- AOMMIN(sb_enc->min_partition_size, cm->seq_params.sb_size);
-
- if (use_auto_max_partition(cpi, sb_size, mi_row, mi_col)) {
- float features[FEATURE_SIZE_MAX_MIN_PART_PRED] = { 0.0f };
-
- av1_get_max_min_partition_features(cpi, x, mi_row, mi_col, features);
- sb_enc->max_partition_size =
- AOMMAX(AOMMIN(av1_predict_max_partition(cpi, x, features),
- sb_enc->max_partition_size),
- sb_enc->min_partition_size);
- }
-}
-
int av1_get_rdmult_delta(AV1_COMP *cpi, BLOCK_SIZE bsize, int mi_row,
int mi_col, int orig_rdmult);
@@ -335,6 +345,57 @@ void av1_set_cost_upd_freq(AV1_COMP *cpi, ThreadData *td,
const TileInfo *const tile_info, const int mi_row,
const int mi_col);
+static AOM_INLINE void av1_dealloc_mb_data(struct AV1Common *cm,
+ struct macroblock *mb) {
+ if (mb->txfm_search_info.txb_rd_records) {
+ aom_free(mb->txfm_search_info.txb_rd_records);
+ mb->txfm_search_info.txb_rd_records = NULL;
+ }
+ const int num_planes = av1_num_planes(cm);
+ for (int plane = 0; plane < num_planes; plane++) {
+ if (mb->plane[plane].src_diff) {
+ aom_free(mb->plane[plane].src_diff);
+ mb->plane[plane].src_diff = NULL;
+ }
+ }
+ if (mb->e_mbd.seg_mask) {
+ aom_free(mb->e_mbd.seg_mask);
+ mb->e_mbd.seg_mask = NULL;
+ }
+ if (mb->winner_mode_stats) {
+ aom_free(mb->winner_mode_stats);
+ mb->winner_mode_stats = NULL;
+ }
+}
+
+static AOM_INLINE void av1_alloc_mb_data(struct AV1Common *cm,
+ struct macroblock *mb,
+ int use_nonrd_pick_mode) {
+ if (!use_nonrd_pick_mode) {
+ mb->txfm_search_info.txb_rd_records =
+ (TxbRdRecords *)aom_malloc(sizeof(TxbRdRecords));
+ }
+ const int num_planes = av1_num_planes(cm);
+ for (int plane = 0; plane < num_planes; plane++) {
+ const int subsampling_xy =
+ plane ? cm->seq_params->subsampling_x + cm->seq_params->subsampling_y
+ : 0;
+ const int sb_size = MAX_SB_SQUARE >> subsampling_xy;
+ CHECK_MEM_ERROR(cm, mb->plane[plane].src_diff,
+ (int16_t *)aom_memalign(
+ 32, sizeof(*mb->plane[plane].src_diff) * sb_size));
+ }
+ CHECK_MEM_ERROR(cm, mb->e_mbd.seg_mask,
+ (uint8_t *)aom_memalign(
+ 16, 2 * MAX_SB_SQUARE * sizeof(mb->e_mbd.seg_mask[0])));
+ const int winner_mode_count = frame_is_intra_only(cm)
+ ? MAX_WINNER_MODE_COUNT_INTRA
+ : MAX_WINNER_MODE_COUNT_INTER;
+ CHECK_MEM_ERROR(cm, mb->winner_mode_stats,
+ (WinnerModeStats *)aom_malloc(
+ winner_mode_count * sizeof(mb->winner_mode_stats[0])));
+}
+
// This function will compute the number of reference frames to be disabled
// based on selective_ref_frame speed feature.
static AOM_INLINE unsigned int get_num_refs_to_disable(
@@ -359,7 +420,7 @@ static AOM_INLINE unsigned int get_num_refs_to_disable(
#if !CONFIG_REALTIME_ONLY
else if (is_stat_consumption_stage_twopass(cpi)) {
const FIRSTPASS_STATS *const this_frame_stats =
- read_one_frame_stats(&cpi->twopass, cur_frame_display_index);
+ read_one_frame_stats(&cpi->ppi->twopass, cur_frame_display_index);
aom_clear_system_state();
const double coded_error_per_mb =
this_frame_stats->coded_error / cpi->frame_info.num_mbs;