CWG-D078 BLOCK_256 Partitions
Performance relative to v5 anchor:
| CONFIG | b2 | PSNR_YUV | Enc Time | Dec Time |
| :----: | :--: | :------: | :------: | :------: |
| AI | w/o | +0.04% | 102% | 109% |
| | only | +0.02% | 104% | 109% |
| | | | | |
| RA | w/o | -0.47% | 116% | 105% |
| | only | -0.16% | 132% | 104% |
| | | | | |
| LD | w/o | -0.41% | 118% | 107% |
| | only | -0.47% | 129% | 103% |
STATS_CHANGED
diff --git a/av1/encoder/aq_complexity.c b/av1/encoder/aq_complexity.c
index bbf9a1e..1fff321 100644
--- a/av1/encoder/aq_complexity.c
+++ b/av1/encoder/aq_complexity.c
@@ -151,7 +151,7 @@
// It is converted to bits << AV1_PROB_COST_SHIFT units.
const int64_t num = (int64_t)(cpi->rc.sb64_target_rate * xmis * ymis)
<< AV1_PROB_COST_SHIFT;
- const int denom = cm->seq_params.mib_size * cm->seq_params.mib_size;
+ const int denom = cm->mib_size * cm->mib_size;
const int target_rate = (int)(num / denom);
double logvar;
double low_var_thresh;
diff --git a/av1/encoder/aq_cyclicrefresh.c b/av1/encoder/aq_cyclicrefresh.c
index dec9b59..a7ce0c0 100644
--- a/av1/encoder/aq_cyclicrefresh.c
+++ b/av1/encoder/aq_cyclicrefresh.c
@@ -270,10 +270,8 @@
int i, block_count, bl_index, sb_rows, sb_cols, sbs_in_frame;
int xmis, ymis, x, y;
memset(seg_map, CR_SEGMENT_ID_BASE, mi_params->mi_rows * mi_params->mi_cols);
- sb_cols = (mi_params->mi_cols + cm->seq_params.mib_size - 1) /
- cm->seq_params.mib_size;
- sb_rows = (mi_params->mi_rows + cm->seq_params.mib_size - 1) /
- cm->seq_params.mib_size;
+ sb_cols = (mi_params->mi_cols + cm->mib_size - 1) / cm->mib_size;
+ sb_rows = (mi_params->mi_rows + cm->mib_size - 1) / cm->mib_size;
sbs_in_frame = sb_cols * sb_rows;
// Number of target blocks to get the q delta (segment 1).
block_count =
@@ -290,8 +288,8 @@
// Get the mi_row/mi_col corresponding to superblock index i.
int sb_row_index = (i / sb_cols);
int sb_col_index = i - sb_row_index * sb_cols;
- int mi_row = sb_row_index * cm->seq_params.mib_size;
- int mi_col = sb_col_index * cm->seq_params.mib_size;
+ int mi_row = sb_row_index * cm->mib_size;
+ int mi_col = sb_col_index * cm->mib_size;
// TODO(any): Ensure the population of
// cpi->common.features.allow_screen_content_tools and use the same instead
// of cpi->oxcf.tune_cfg.content == AOM_CONTENT_SCREEN
@@ -305,8 +303,8 @@
assert(mi_col >= 0 && mi_col < mi_params->mi_cols);
bl_index = mi_row * mi_params->mi_cols + mi_col;
// Loop through all MI blocks in superblock and update map.
- xmis = AOMMIN(mi_params->mi_cols - mi_col, cm->seq_params.mib_size);
- ymis = AOMMIN(mi_params->mi_rows - mi_row, cm->seq_params.mib_size);
+ xmis = AOMMIN(mi_params->mi_cols - mi_col, cm->mib_size);
+ ymis = AOMMIN(mi_params->mi_rows - mi_row, cm->mib_size);
for (y = 0; y < ymis; y++) {
for (x = 0; x < xmis; x++) {
const int bl_index2 = bl_index + y * mi_params->mi_cols + x;
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index 2752709..19d0548 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -22,6 +22,7 @@
#include "aom_ports/bitops.h"
#include "aom_ports/mem_ops.h"
#include "aom_ports/system_state.h"
+#include "av1/common/av1_common_int.h"
#include "av1/common/blockd.h"
#include "av1/common/enums.h"
#if CONFIG_BITSTREAM_DEBUG
@@ -1550,7 +1551,7 @@
#endif // CONFIG_FIX_CDEF_SYNTAX
// At the start of a superblock, mark that we haven't yet written CDEF
// strengths for any of the CDEF units contained in this superblock.
- const int sb_mask = (cm->seq_params.mib_size - 1);
+ const int sb_mask = (cm->mib_size - 1);
const int mi_row_in_sb = (xd->mi_row & sb_mask);
const int mi_col_in_sb = (xd->mi_col & sb_mask);
if (mi_row_in_sb == 0 && mi_col_in_sb == 0) {
@@ -1680,11 +1681,10 @@
const MB_MODE_INFO *const mbmi = xd->mi[0];
const BLOCK_SIZE bsize = mbmi->sb_type[xd->tree_type == CHROMA_PART];
const int super_block_upper_left =
- ((xd->mi_row & (cm->seq_params.mib_size - 1)) == 0) &&
- ((xd->mi_col & (cm->seq_params.mib_size - 1)) == 0);
+ ((xd->mi_row & (cm->mib_size - 1)) == 0) &&
+ ((xd->mi_col & (cm->mib_size - 1)) == 0);
- if ((bsize != cm->seq_params.sb_size || skip == 0) &&
- super_block_upper_left) {
+ if ((bsize != cm->sb_size || skip == 0) && super_block_upper_left) {
assert(mbmi->current_qindex > 0);
const int reduced_delta_qindex =
(mbmi->current_qindex - xd->current_base_qindex) /
@@ -2858,7 +2858,7 @@
const BLOCK_SIZE bsize = mbmi->sb_type[xd->tree_type == CHROMA_PART];
if (xd->tree_type == SHARED_PART)
assert(mbmi->sb_type[PLANE_TYPE_Y] == mbmi->sb_type[PLANE_TYPE_UV]);
- assert(bsize <= cm->seq_params.sb_size ||
+ assert(bsize <= cm->sb_size ||
(bsize >= BLOCK_SIZES && bsize < BLOCK_SIZES_ALL));
const int bh = mi_size_high[bsize];
@@ -2970,7 +2970,7 @@
}
#endif // CONFIG_PC_WIENER
- av1_mark_block_as_coded(xd, bsize, cm->seq_params.sb_size);
+ av1_mark_block_as_coded(xd, bsize, cm->sb_size);
}
static AOM_INLINE void write_partition(const AV1_COMMON *const cm,
@@ -2982,27 +2982,21 @@
const PARTITION_TREE *ptree_luma,
#endif // CONFIG_EXT_RECUR_PARTITIONS
aom_writer *w) {
- if (!is_partition_point(bsize)) return;
-
const int plane = xd->tree_type == CHROMA_PART;
+#if !CONFIG_EXT_RECUR_PARTITIONS
+ if (!is_partition_point(bsize)) return;
if (bsize == BLOCK_8X8 && plane > 0) return;
+#endif // !CONFIG_EXT_RECUR_PARTITIONS
#if CONFIG_EXT_RECUR_PARTITIONS
const int ssx = cm->seq_params.subsampling_x;
const int ssy = cm->seq_params.subsampling_y;
- if (is_luma_chroma_share_same_partition(xd->tree_type, ptree_luma, bsize)) {
- assert(ptree_luma);
- assert(p ==
- sdp_chroma_part_from_luma(bsize, ptree_luma->partition, ssx, ssy));
- return;
- }
-
- PARTITION_TYPE implied_partition;
- const bool is_part_implied = is_partition_implied_at_boundary(
- &cm->mi_params, xd->tree_type, ssx, ssy, mi_row, mi_col, bsize,
- &ptree->chroma_ref_info, &implied_partition);
- if (is_part_implied) {
- assert(p == implied_partition);
+ const PARTITION_TYPE derived_partition =
+ av1_get_normative_forced_partition_type(
+ &cm->mi_params, xd->tree_type, ssx, ssy, mi_row, mi_col, bsize,
+ ptree_luma, &ptree->chroma_ref_info);
+ if (derived_partition != PARTITION_INVALID) {
+ assert(p == derived_partition);
return;
}
#endif // CONFIG_EXT_RECUR_PARTITIONS
@@ -3016,6 +3010,19 @@
if (!do_split) {
return;
}
+#if CONFIG_BLOCK_256
+ const bool do_square_split = p == PARTITION_SPLIT;
+ if (is_square_split_eligible(bsize, cm->sb_size)) {
+ const int square_split_ctx =
+ square_split_context(xd, mi_row, mi_col, bsize);
+ aom_write_symbol(w, do_square_split,
+ ec_ctx->do_square_split_cdf[plane][square_split_ctx], 2);
+ }
+ if (do_square_split) {
+ assert(p == PARTITION_SPLIT);
+ return;
+ }
+#endif // CONFIG_BLOCK_256
RECT_PART_TYPE rect_type = get_rect_part_type(p);
if (rect_type_implied_by_bsize(bsize, xd->tree_type) == RECT_INVALID) {
aom_write_symbol(w, rect_type, ec_ctx->rect_type_cdf[plane][ctx],
@@ -3096,7 +3103,7 @@
const TokenExtra **tok, const TokenExtra *const tok_end,
PARTITION_TREE *ptree,
#if CONFIG_EXT_RECUR_PARTITIONS
- PARTITION_TREE *ptree_luma,
+ const PARTITION_TREE *ptree_luma,
#endif // CONFIG_EXT_RECUR_PARTITIONS
int mi_row, int mi_col, BLOCK_SIZE bsize) {
const AV1_COMMON *const cm = &cpi->common;
@@ -3151,6 +3158,9 @@
w);
const int track_ptree_luma =
is_luma_chroma_share_same_partition(xd->tree_type, ptree_luma, bsize);
+ if (!track_ptree_luma) {
+ ptree_luma = NULL;
+ }
assert(IMPLIES(track_ptree_luma, ptree_luma));
#else
write_partition(cm, xd, mi_row, mi_col, partition, bsize, w);
@@ -3162,11 +3172,11 @@
case PARTITION_HORZ:
#if CONFIG_EXT_RECUR_PARTITIONS
write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[0],
- track_ptree_luma ? ptree_luma->sub_tree[0] : NULL, mi_row,
- mi_col, subsize);
+ get_partition_subtree_const(ptree_luma, 0), mi_row, mi_col,
+ subsize);
if (mi_row + hbs_h < mi_params->mi_rows) {
write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[1],
- track_ptree_luma ? ptree_luma->sub_tree[1] : NULL,
+ get_partition_subtree_const(ptree_luma, 1),
mi_row + hbs_h, mi_col, subsize);
}
#else // CONFIG_EXT_RECUR_PARTITIONS
@@ -3178,12 +3188,12 @@
case PARTITION_VERT:
#if CONFIG_EXT_RECUR_PARTITIONS
write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[0],
- track_ptree_luma ? ptree_luma->sub_tree[0] : NULL, mi_row,
- mi_col, subsize);
+ get_partition_subtree_const(ptree_luma, 0), mi_row, mi_col,
+ subsize);
if (mi_col + hbs_w < mi_params->mi_cols) {
write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[1],
- track_ptree_luma ? ptree_luma->sub_tree[1] : NULL,
- mi_row, mi_col + hbs_w, subsize);
+ get_partition_subtree_const(ptree_luma, 1), mi_row,
+ mi_col + hbs_w, subsize);
}
#else // CONFIG_EXT_RECUR_PARTITIONS
write_modes_b(cpi, tile, w, tok, tok_end, mi_row, mi_col);
@@ -3199,19 +3209,19 @@
get_partition_subsize(bsize_big, PARTITION_HORZ);
assert(subsize == get_partition_subsize(bsize_med, PARTITION_HORZ));
write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[0],
- track_ptree_luma ? ptree_luma->sub_tree[0] : NULL, mi_row,
- mi_col, subsize);
+ get_partition_subtree_const(ptree_luma, 0), mi_row, mi_col,
+ subsize);
if (mi_row + ebs_h >= mi_params->mi_rows) break;
write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[1],
- track_ptree_luma ? ptree_luma->sub_tree[1] : NULL,
- mi_row + ebs_h, mi_col, bsize_med);
+ get_partition_subtree_const(ptree_luma, 1), mi_row + ebs_h,
+ mi_col, bsize_med);
if (mi_row + 3 * ebs_h >= mi_params->mi_rows) break;
write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[2],
- track_ptree_luma ? ptree_luma->sub_tree[2] : NULL,
+ get_partition_subtree_const(ptree_luma, 2),
mi_row + 3 * ebs_h, mi_col, bsize_big);
if (mi_row + 7 * ebs_h >= mi_params->mi_rows) break;
write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[3],
- track_ptree_luma ? ptree_luma->sub_tree[3] : NULL,
+ get_partition_subtree_const(ptree_luma, 3),
mi_row + 7 * ebs_h, mi_col, subsize);
break;
}
@@ -3221,19 +3231,19 @@
get_partition_subsize(bsize_big, PARTITION_HORZ);
assert(subsize == get_partition_subsize(bsize_med, PARTITION_HORZ));
write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[0],
- track_ptree_luma ? ptree_luma->sub_tree[0] : NULL, mi_row,
- mi_col, subsize);
+ get_partition_subtree_const(ptree_luma, 0), mi_row, mi_col,
+ subsize);
if (mi_row + ebs_h >= mi_params->mi_rows) break;
write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[1],
- track_ptree_luma ? ptree_luma->sub_tree[1] : NULL,
- mi_row + ebs_h, mi_col, bsize_big);
+ get_partition_subtree_const(ptree_luma, 1), mi_row + ebs_h,
+ mi_col, bsize_big);
if (mi_row + 5 * ebs_h >= mi_params->mi_rows) break;
write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[2],
- track_ptree_luma ? ptree_luma->sub_tree[2] : NULL,
+ get_partition_subtree_const(ptree_luma, 2),
mi_row + 5 * ebs_h, mi_col, bsize_med);
if (mi_row + 7 * ebs_h >= mi_params->mi_rows) break;
write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[3],
- track_ptree_luma ? ptree_luma->sub_tree[3] : NULL,
+ get_partition_subtree_const(ptree_luma, 3),
mi_row + 7 * ebs_h, mi_col, subsize);
break;
}
@@ -3243,19 +3253,19 @@
get_partition_subsize(bsize_big, PARTITION_VERT);
assert(subsize == get_partition_subsize(bsize_med, PARTITION_VERT));
write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[0],
- track_ptree_luma ? ptree_luma->sub_tree[0] : NULL, mi_row,
- mi_col, subsize);
+ get_partition_subtree_const(ptree_luma, 0), mi_row, mi_col,
+ subsize);
if (mi_col + ebs_w >= mi_params->mi_cols) break;
write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[1],
- track_ptree_luma ? ptree_luma->sub_tree[1] : NULL, mi_row,
+ get_partition_subtree_const(ptree_luma, 1), mi_row,
mi_col + ebs_w, bsize_med);
if (mi_col + 3 * ebs_w >= mi_params->mi_cols) break;
write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[2],
- track_ptree_luma ? ptree_luma->sub_tree[2] : NULL, mi_row,
+ get_partition_subtree_const(ptree_luma, 2), mi_row,
mi_col + 3 * ebs_w, bsize_big);
if (mi_col + 7 * ebs_w >= mi_params->mi_cols) break;
write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[3],
- track_ptree_luma ? ptree_luma->sub_tree[3] : NULL, mi_row,
+ get_partition_subtree_const(ptree_luma, 3), mi_row,
mi_col + 7 * ebs_w, subsize);
break;
}
@@ -3265,19 +3275,19 @@
get_partition_subsize(bsize_big, PARTITION_VERT);
assert(subsize == get_partition_subsize(bsize_med, PARTITION_VERT));
write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[0],
- track_ptree_luma ? ptree_luma->sub_tree[0] : NULL, mi_row,
- mi_col, subsize);
+ get_partition_subtree_const(ptree_luma, 0), mi_row, mi_col,
+ subsize);
if (mi_col + ebs_w >= mi_params->mi_cols) break;
write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[1],
- track_ptree_luma ? ptree_luma->sub_tree[1] : NULL, mi_row,
+ get_partition_subtree_const(ptree_luma, 1), mi_row,
mi_col + ebs_w, bsize_big);
if (mi_col + 5 * ebs_w >= mi_params->mi_cols) break;
write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[2],
- track_ptree_luma ? ptree_luma->sub_tree[2] : NULL, mi_row,
+ get_partition_subtree_const(ptree_luma, 2), mi_row,
mi_col + 5 * ebs_w, bsize_med);
if (mi_col + 7 * ebs_w >= mi_params->mi_cols) break;
write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[3],
- track_ptree_luma ? ptree_luma->sub_tree[3] : NULL, mi_row,
+ get_partition_subtree_const(ptree_luma, 3), mi_row,
mi_col + 7 * ebs_w, subsize);
break;
}
@@ -3301,10 +3311,26 @@
}
write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[i],
- track_ptree_luma ? ptree_luma->sub_tree[i] : NULL,
- this_mi_row, this_mi_col, this_bsize);
+ get_partition_subtree_const(ptree_luma, i), this_mi_row,
+ this_mi_col, this_bsize);
}
break;
+#if CONFIG_BLOCK_256
+ case PARTITION_SPLIT:
+ write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[0],
+ get_partition_subtree_const(ptree_luma, 0), mi_row, mi_col,
+ subsize);
+ write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[1],
+ get_partition_subtree_const(ptree_luma, 1), mi_row,
+ mi_col + hbs_w, subsize);
+ write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[2],
+ get_partition_subtree_const(ptree_luma, 2), mi_row + hbs_h,
+ mi_col, subsize);
+ write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[3],
+ get_partition_subtree_const(ptree_luma, 3), mi_row + hbs_h,
+ mi_col + hbs_w, subsize);
+ break;
+#endif // CONFIG_BLOCK_256
#else // CONFIG_EXT_RECUR_PARTITIONS
case PARTITION_SPLIT:
write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[0], mi_row,
@@ -3380,10 +3406,9 @@
}
}
- for (int mi_row = mi_row_start; mi_row < mi_row_end;
- mi_row += cm->seq_params.mib_size) {
+ for (int mi_row = mi_row_start; mi_row < mi_row_end; mi_row += cm->mib_size) {
const int sb_row_in_tile =
- (mi_row - tile->mi_row_start) >> cm->seq_params.mib_size_log2;
+ (mi_row - tile->mi_row_start) >> cm->mib_size_log2;
const TokenExtra *tok =
cpi->token_info.tplist[tile_row][tile_col][sb_row_in_tile].start;
const TokenExtra *tok_end =
@@ -3392,8 +3417,8 @@
av1_zero_left_context(xd);
for (int mi_col = mi_col_start; mi_col < mi_col_end;
- mi_col += cm->seq_params.mib_size) {
- av1_reset_is_mi_coded_map(xd, cm->seq_params.mib_size);
+ mi_col += cm->mib_size) {
+ av1_reset_is_mi_coded_map(xd, cm->mib_size);
xd->sbi = av1_get_sb_info(cm, mi_row, mi_col);
cpi->td.mb.cb_coef_buff = av1_get_cb_coeff_buffer(cpi, mi_row, mi_col);
const int total_loop_num =
@@ -3407,7 +3432,7 @@
#if CONFIG_EXT_RECUR_PARTITIONS
NULL,
#endif // CONFIG_EXT_RECUR_PARTITIONS
- mi_row, mi_col, cm->seq_params.sb_size);
+ mi_row, mi_col, cm->sb_size);
if (total_loop_num == 2) {
xd->tree_type = CHROMA_PART;
write_modes_sb(cpi, tile, w, &tok, tok_end,
@@ -3415,7 +3440,7 @@
#if CONFIG_EXT_RECUR_PARTITIONS
xd->sbi->ptree_root[0],
#endif // CONFIG_EXT_RECUR_PARTITIONS
- mi_row, mi_col, cm->seq_params.sb_size);
+ mi_row, mi_col, cm->sb_size);
xd->tree_type = SHARED_PART;
}
}
@@ -3584,20 +3609,38 @@
}
#else
if (!all_none) {
- assert(cm->seq_params.sb_size == BLOCK_64X64 ||
- cm->seq_params.sb_size == BLOCK_128X128);
- const int sb_size = cm->seq_params.sb_size == BLOCK_128X128 ? 128 : 64;
+#if CONFIG_BLOCK_256
+ assert(cm->sb_size == BLOCK_64X64 || cm->sb_size == BLOCK_128X128 ||
+ cm->sb_size == BLOCK_256X256);
+#else
+ assert(cm->sb_size == BLOCK_64X64 || cm->sb_size == BLOCK_128X128);
+#endif // CONFIG_BLOCK_256
+ const int sb_size =
+#if CONFIG_BLOCK_256
+ cm->sb_size == BLOCK_256X256 ? 256 :
+#endif // CONFIG_BLOCK_256
+ cm->sb_size == BLOCK_128X128 ? 128
+ : 64;
RestorationInfo *rsi = &cm->rst_info[0];
assert(rsi->restoration_unit_size >= sb_size);
assert(RESTORATION_UNITSIZE_MAX == 256);
+#if CONFIG_BLOCK_256
+ if (sb_size <= 128) {
+ aom_wb_write_bit(wb, rsi->restoration_unit_size > 128);
+ }
+ if (sb_size == 64) {
+ aom_wb_write_bit(wb, rsi->restoration_unit_size > 64);
+ }
+#else
if (sb_size == 64) {
aom_wb_write_bit(wb, rsi->restoration_unit_size > 64);
}
if (rsi->restoration_unit_size > 64) {
aom_wb_write_bit(wb, rsi->restoration_unit_size > 128);
}
+#endif // CONFIG_BLOCK_256
}
if (num_planes > 1) {
@@ -4301,12 +4344,10 @@
static AOM_INLINE void write_tile_info_max_tile(
const AV1_COMMON *const cm, struct aom_write_bit_buffer *wb) {
- int width_mi =
- ALIGN_POWER_OF_TWO(cm->mi_params.mi_cols, cm->seq_params.mib_size_log2);
- int height_mi =
- ALIGN_POWER_OF_TWO(cm->mi_params.mi_rows, cm->seq_params.mib_size_log2);
- int width_sb = width_mi >> cm->seq_params.mib_size_log2;
- int height_sb = height_mi >> cm->seq_params.mib_size_log2;
+ int width_mi = ALIGN_POWER_OF_TWO(cm->mi_params.mi_cols, cm->mib_size_log2);
+ int height_mi = ALIGN_POWER_OF_TWO(cm->mi_params.mi_rows, cm->mib_size_log2);
+ int width_sb = width_mi >> cm->mib_size_log2;
+ int height_sb = height_mi >> cm->mib_size_log2;
int size_sb, i;
const CommonTileParams *const tiles = &cm->tiles;
@@ -4766,9 +4807,21 @@
(void)wb;
assert(seq_params->mib_size == mi_size_wide[seq_params->sb_size]);
assert(seq_params->mib_size == 1 << seq_params->mib_size_log2);
+
+#if CONFIG_BLOCK_256
+ assert(seq_params->sb_size == BLOCK_256X256 ||
+ seq_params->sb_size == BLOCK_128X128 ||
+ seq_params->sb_size == BLOCK_64X64);
+ const bool is_256 = seq_params->sb_size == BLOCK_256X256;
+ aom_wb_write_bit(wb, is_256);
+ if (is_256) {
+ return;
+ }
+#else
assert(seq_params->sb_size == BLOCK_128X128 ||
seq_params->sb_size == BLOCK_64X64);
- aom_wb_write_bit(wb, seq_params->sb_size == BLOCK_128X128 ? 1 : 0);
+#endif // CONFIG_BLOCK_256
+ aom_wb_write_bit(wb, seq_params->sb_size == BLOCK_128X128);
}
static AOM_INLINE void write_sequence_header(
diff --git a/av1/encoder/block.h b/av1/encoder/block.h
index 1db8135..c04d0c3 100644
--- a/av1/encoder/block.h
+++ b/av1/encoder/block.h
@@ -534,8 +534,28 @@
} SimpleMotionData;
/*!\cond */
+#if CONFIG_BLOCK_256
+
+#define BLOCK_256_COUNT 1
+#define BLOCK_128_COUNT 3
+#define BLOCK_64_COUNT 7
+
+#if CONFIG_UNEVEN_4WAY
+#define BLOCK_32_COUNT 31
+#define BLOCK_16_COUNT 63
+#define BLOCK_8_COUNT 64
+#else
+#define BLOCK_32_COUNT 15
+#define BLOCK_16_COUNT 31
+#define BLOCK_8_COUNT 63
+#endif // CONFIG_UNEVEN_4WAY
+
+#define BLOCK_4_COUNT 64
+
+#else
#define BLOCK_128_COUNT 1
#define BLOCK_64_COUNT 3
+
#if CONFIG_UNEVEN_4WAY
#define BLOCK_32_COUNT 15
#define BLOCK_16_COUNT 31
@@ -545,7 +565,9 @@
#define BLOCK_16_COUNT 15
#define BLOCK_8_COUNT 31
#endif // CONFIG_UNEVEN_4WAY
+
#define BLOCK_4_COUNT 32
+#endif // CONFIG_BLOCK_256
#define MAKE_SM_DATA_BUF(width, height) \
SimpleMotionData \
@@ -557,6 +579,9 @@
typedef struct SimpleMotionDataBufs {
/*!\cond */
// Square blocks
+#if CONFIG_BLOCK_256
+ MAKE_SM_DATA_BUF(256, 256);
+#endif // CONFIG_BLOCK_256
MAKE_SM_DATA_BUF(128, 128);
MAKE_SM_DATA_BUF(64, 64);
MAKE_SM_DATA_BUF(32, 32);
@@ -565,6 +590,9 @@
MAKE_SM_DATA_BUF(4, 4);
// 1:2 blocks
+#if CONFIG_BLOCK_256
+ MAKE_SM_DATA_BUF(128, 256);
+#endif // CONFIG_BLOCK_256
MAKE_SM_DATA_BUF(64, 128);
MAKE_SM_DATA_BUF(32, 64);
MAKE_SM_DATA_BUF(16, 32);
@@ -572,6 +600,9 @@
MAKE_SM_DATA_BUF(4, 8);
// 2:1 blocks
+#if CONFIG_BLOCK_256
+ MAKE_SM_DATA_BUF(256, 128);
+#endif // CONFIG_BLOCK_256
MAKE_SM_DATA_BUF(128, 64);
MAKE_SM_DATA_BUF(64, 32);
MAKE_SM_DATA_BUF(32, 16);
@@ -785,12 +816,13 @@
* \name Partition Costs
****************************************************************************/
/**@{*/
- //! Cost for coding the partition.
- int partition_cost[PARTITION_STRUCTURE_NUM][PARTITION_CONTEXTS]
- [EXT_PARTITION_TYPES];
#if CONFIG_EXT_RECUR_PARTITIONS
/*! Cost for sending split token. */
int do_split_cost[PARTITION_STRUCTURE_NUM][PARTITION_CONTEXTS][2];
+#if CONFIG_BLOCK_256
+ /*! Cost for sending square split token. */
+ int do_square_split_cost[PARTITION_STRUCTURE_NUM][SQUARE_SPLIT_CONTEXTS][2];
+#endif // CONFIG_BLOCK_256
/*! Cost for sending rectangular type token. */
int rect_type_cost[PARTITION_STRUCTURE_NUM][PARTITION_CONTEXTS][2];
/*! Cost for sending do_ext_partition token. */
@@ -805,6 +837,13 @@
[PARTITION_CONTEXTS]
[NUM_UNEVEN_4WAY_PARTS];
#endif // CONFIG_UNEVEN_4WAY
+ //! Cost for coding the partition.
+ int partition_cost[PARTITION_STRUCTURE_NUM][PARTITION_CONTEXTS]
+ [ALL_PARTITION_TYPES];
+#else
+ //! Cost for coding the partition.
+ int partition_cost[PARTITION_STRUCTURE_NUM][PARTITION_CONTEXTS]
+ [EXT_PARTITION_TYPES];
#endif // CONFIG_EXT_RECUR_PARTITIONS
/**@}*/
@@ -1706,6 +1745,11 @@
1, // BLOCK_64X128
1, // BLOCK_128X64
1, // BLOCK_128X128
+#if CONFIG_BLOCK_256
+ 1, // BLOCK_128X256
+ 1, // BLOCK_256X128
+ 1, // BLOCK_256X256
+#endif // CONFIG_BLOCK_256
1, // BLOCK_4X16
1, // BLOCK_16X4
1, // BLOCK_8X32
@@ -1729,6 +1773,11 @@
0, // BLOCK_64X128
0, // BLOCK_128X64
0, // BLOCK_128X128
+#if CONFIG_BLOCK_256
+ 0, // BLOCK_128X256
+ 0, // BLOCK_256X128
+ 0, // BLOCK_256X256
+#endif // CONFIG_BLOCK_256
1, // BLOCK_4X16
1, // BLOCK_16X4
1, // BLOCK_8X32
diff --git a/av1/encoder/compound_type.c b/av1/encoder/compound_type.c
index a165d82..90a4edc 100644
--- a/av1/encoder/compound_type.c
+++ b/av1/encoder/compound_type.c
@@ -131,6 +131,7 @@
const BLOCK_SIZE bsize, const uint16_t *pred0,
int stride0, const uint16_t *pred1,
int stride1) {
+ /* clang-format off */
static const BLOCK_SIZE split_qtr[BLOCK_SIZES_ALL] = {
// 4X4
BLOCK_INVALID,
@@ -144,11 +145,16 @@
BLOCK_16X32, BLOCK_32X16, BLOCK_32X32,
// 64x128, 128x64, 128x128
BLOCK_32X64, BLOCK_64X32, BLOCK_64X64,
+#if CONFIG_BLOCK_256
+ // 128X256, 256X128, 256X256
+ BLOCK_64X128, BLOCK_128X64, BLOCK_128X128,
+#endif // CONFIG_BLOCK_256
// 4X16, 16X4, 8X32
BLOCK_INVALID, BLOCK_INVALID, BLOCK_4X16,
// 32X8, 16X64, 64X16
BLOCK_16X4, BLOCK_8X32, BLOCK_32X8
};
+ /* clang-format on */
const struct macroblock_plane *const p = &x->plane[0];
const uint16_t *src = p->src.buf;
int src_stride = p->src.stride;
diff --git a/av1/encoder/context_tree.c b/av1/encoder/context_tree.c
index e436eff..c63b274 100644
--- a/av1/encoder/context_tree.c
+++ b/av1/encoder/context_tree.c
@@ -11,20 +11,25 @@
*/
#include "av1/encoder/context_tree.h"
+#include "av1/common/av1_common_int.h"
#include "av1/encoder/encoder.h"
#include "av1/encoder/rd.h"
static const BLOCK_SIZE square[MAX_SB_SIZE_LOG2 - 1] = {
- BLOCK_4X4, BLOCK_8X8, BLOCK_16X16, BLOCK_32X32, BLOCK_64X64, BLOCK_128X128,
+ BLOCK_4X4, BLOCK_8X8, BLOCK_16X16,
+ BLOCK_32X32, BLOCK_64X64, BLOCK_128X128,
+#if CONFIG_BLOCK_256
+ BLOCK_256X256,
+#endif // CONFIG_BLOCK_256
};
void av1_copy_tree_context(PICK_MODE_CONTEXT *dst_ctx,
PICK_MODE_CONTEXT *src_ctx) {
dst_ctx->mic = src_ctx->mic;
#if CONFIG_C071_SUBBLK_WARPMV
- if (is_warp_mode(src_ctx->mic.motion_mode))
- memcpy(dst_ctx->submic, src_ctx->submic,
- MAX_MIB_SIZE * MAX_MIB_SIZE * sizeof(*src_ctx->submic));
+ if (is_warp_mode(src_ctx->mic.motion_mode)) {
+ av1_copy_array(dst_ctx->submic, src_ctx->submic, src_ctx->num_4x4_blk);
+ }
#endif // CONFIG_C071_SUBBLK_WARPMV
dst_ctx->mbmi_ext_best = src_ctx->mbmi_ext_best;
@@ -48,12 +53,15 @@
dst_ctx->rd_stats = src_ctx->rd_stats;
dst_ctx->rd_mode_is_ready = src_ctx->rd_mode_is_ready;
#if CONFIG_EXT_RECUR_PARTITIONS
- for (int i = 0; i < 2; ++i) {
- const int num_blk =
- (i == 0) ? src_ctx->num_4x4_blk : src_ctx->num_4x4_blk_chroma;
- const int color_map_size = num_blk * 16;
- memcpy(dst_ctx->color_index_map[i], src_ctx->color_index_map[i],
- sizeof(src_ctx->color_index_map[i][0]) * color_map_size);
+ const int num_pix = src_ctx->num_4x4_blk * 16;
+ if (num_pix <= MAX_PALETTE_SQUARE) {
+ for (int i = 0; i < 2; ++i) {
+ const int num_blk =
+ (i == 0) ? src_ctx->num_4x4_blk : src_ctx->num_4x4_blk_chroma;
+ const int color_map_size = num_blk * 16;
+ memcpy(dst_ctx->color_index_map[i], src_ctx->color_index_map[i],
+ sizeof(src_ctx->color_index_map[i][0]) * color_map_size);
+ }
}
#endif // CONFIG_EXT_RECUR_PARTITIONS
}
@@ -123,6 +131,11 @@
aom_calloc(num_blk, sizeof(*ctx->blk_skip)));
AOM_CHECK_MEM_ERROR(&error, ctx->tx_type_map,
aom_calloc(num_blk, sizeof(*ctx->tx_type_map)));
+#if CONFIG_C071_SUBBLK_WARPMV
+ if (!frame_is_intra_only(cm)) {
+ ctx->submic = malloc(num_blk * sizeof(*ctx->submic));
+ }
+#endif // CONFIG_C071_SUBBLK_WARPMV
#if CONFIG_CROSS_CHROMA_TX
AOM_CHECK_MEM_ERROR(&error, ctx->cctx_type_map,
aom_calloc(num_blk, sizeof(*ctx->cctx_type_map)));
@@ -160,6 +173,11 @@
void av1_free_pmc(PICK_MODE_CONTEXT *ctx, int num_planes) {
if (ctx == NULL) return;
+#if CONFIG_C071_SUBBLK_WARPMV
+ if (ctx->submic) {
+ free(ctx->submic);
+ }
+#endif // CONFIG_C071_SUBBLK_WARPMV
aom_free(ctx->blk_skip);
ctx->blk_skip = NULL;
aom_free(ctx->tx_type_map);
@@ -640,9 +658,18 @@
}
#endif // CONFIG_EXT_RECUR_PARTITIONS
-static AOM_INLINE int get_pc_tree_nodes(const int is_sb_size_128,
+static AOM_INLINE int get_pc_tree_nodes(const BLOCK_SIZE sb_size,
int stat_generation_stage) {
- const int tree_nodes_inc = is_sb_size_128 ? 1024 : 0;
+ const int is_sb_size_128 = sb_size == BLOCK_128X128;
+#if CONFIG_BLOCK_256
+ const int is_sb_size_256 = sb_size == BLOCK_256X256;
+#endif // CONFIG_BLOCK_256
+ const int tree_nodes_inc =
+#if CONFIG_BLOCK_256
+ is_sb_size_256 ? (1024 + 4 * 1024) :
+#endif // CONFIG_BLOCK_256
+ is_sb_size_128 ? 1024
+ : 0;
const int tree_nodes =
stat_generation_stage ? 1 : (tree_nodes_inc + 256 + 64 + 16 + 4 + 1);
return tree_nodes;
@@ -651,9 +678,11 @@
void av1_setup_sms_tree(AV1_COMP *const cpi, ThreadData *td) {
AV1_COMMON *const cm = &cpi->common;
const int stat_generation_stage = is_stat_generation_stage(cpi);
- const int is_sb_size_128 = cm->seq_params.sb_size == BLOCK_128X128;
- const int tree_nodes =
- get_pc_tree_nodes(is_sb_size_128, stat_generation_stage);
+ const int is_sb_size_128 = cm->sb_size == BLOCK_128X128;
+#if CONFIG_BLOCK_256
+ const int is_sb_size_256 = cm->sb_size == BLOCK_256X256;
+#endif // CONFIG_BLOCK_256
+ const int tree_nodes = get_pc_tree_nodes(cm->sb_size, stat_generation_stage);
int sms_tree_index = 0;
SIMPLE_MOTION_DATA_TREE *this_sms;
int square_index = 1;
@@ -665,7 +694,13 @@
this_sms = &td->sms_tree[0];
if (!stat_generation_stage) {
- const int leaf_factor = is_sb_size_128 ? 4 : 1;
+ const int leaf_factor =
+#if CONFIG_BLOCK_256
+ is_sb_size_256 ? 16 :
+#endif // CONFIG_BLOCK_256
+ is_sb_size_128 ? 4
+ : 1;
+
const int leaf_nodes = 256 * leaf_factor;
// Sets up all the leaf nodes in the tree.
diff --git a/av1/encoder/context_tree.h b/av1/encoder/context_tree.h
index 3aaafe5..d99cb98 100644
--- a/av1/encoder/context_tree.h
+++ b/av1/encoder/context_tree.h
@@ -36,7 +36,7 @@
typedef struct PICK_MODE_CONTEXT {
MB_MODE_INFO mic;
#if CONFIG_C071_SUBBLK_WARPMV
- SUBMB_INFO submic[MAX_MIB_SIZE * MAX_MIB_SIZE];
+ SUBMB_INFO *submic;
#endif // CONFIG_C071_SUBBLK_WARPMV
MB_MODE_INFO_EXT_FRAME mbmi_ext_best;
uint8_t *color_index_map[2];
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index d755568..ecd0ee6 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -234,7 +234,7 @@
const DeltaQInfo *const delta_q_info = &cm->delta_q_info;
assert(delta_q_info->delta_q_present_flag);
- const BLOCK_SIZE sb_size = cm->seq_params.sb_size;
+ const BLOCK_SIZE sb_size = cm->sb_size;
// Delta-q modulation based on variance
av1_setup_src_planes(x, cpi->source, mi_row, mi_col, num_planes, NULL);
@@ -299,7 +299,7 @@
(int8_t)clamp(delta_lf_from_base, -MAX_LOOP_FILTER, MAX_LOOP_FILTER);
const int frame_lf_count =
av1_num_planes(cm) > 1 ? FRAME_LF_COUNT : FRAME_LF_COUNT - 2;
- const int mib_size = cm->seq_params.mib_size;
+ const int mib_size = cm->mib_size;
// pre-set the delta lf for loop filter. Note that this value is set
// before mi is assigned for each block in current superblock
@@ -345,7 +345,7 @@
const int tpl_stride = tpl_frame->stride;
int64_t inter_cost[INTER_REFS_PER_FRAME] = { 0 };
const int step = 1 << block_mis_log2;
- const BLOCK_SIZE sb_size = cm->seq_params.sb_size;
+ const BLOCK_SIZE sb_size = cm->sb_size;
const int mi_row_end =
AOMMIN(mi_size_high[sb_size] + mi_row, mi_params->mi_rows);
@@ -420,7 +420,7 @@
static AOM_INLINE void adjust_rdmult_tpl_model(AV1_COMP *cpi, MACROBLOCK *x,
int mi_row, int mi_col) {
- const BLOCK_SIZE sb_size = cpi->common.seq_params.sb_size;
+ const BLOCK_SIZE sb_size = cpi->common.sb_size;
const int orig_rdmult = cpi->rd.RDMULT;
assert(IMPLIES(cpi->gf_group.size > 0,
@@ -498,7 +498,7 @@
if (gather_tpl_data) {
if (cm->delta_q_info.delta_q_present_flag) {
const int num_planes = av1_num_planes(cm);
- const BLOCK_SIZE sb_size = cm->seq_params.sb_size;
+ const BLOCK_SIZE sb_size = cm->sb_size;
setup_delta_q(cpi, td, x, tile_info, mi_row, mi_col, num_planes);
av1_tpl_rdmult_setup_sb(cpi, x, sb_size, mi_row, mi_col);
}
@@ -514,8 +514,7 @@
#if CONFIG_EXT_RECUR_PARTITIONS
SimpleMotionDataBufs *data_bufs = x->sms_bufs;
av1_init_sms_data_bufs(data_bufs);
- fill_sms_buf(data_bufs, sms_root, mi_row, mi_col, cm->seq_params.sb_size,
- cm->seq_params.sb_size);
+ fill_sms_buf(data_bufs, sms_root, mi_row, mi_col, cm->sb_size, cm->sb_size);
#endif // CONFIG_EXT_RECUR_PARTITIONS
if (x->e_mbd.tree_type == CHROMA_PART) {
@@ -551,7 +550,7 @@
MACROBLOCKD *const xd = &x->e_mbd;
SuperBlockEnc *sb_enc = &x->sb_enc;
SIMPLE_MOTION_DATA_TREE *const sms_root = td->sms_root;
- const BLOCK_SIZE sb_size = cm->seq_params.sb_size;
+ const BLOCK_SIZE sb_size = cm->sb_size;
const int ss_x = cm->seq_params.subsampling_x;
const int ss_y = cm->seq_params.subsampling_y;
RD_STATS dummy_rdc;
@@ -612,7 +611,7 @@
const int mi_row, const int mi_col) {
SIMPLE_MOTION_DATA_TREE *const sms_root = td->sms_root;
AV1_COMMON *const cm = &cpi->common;
- const BLOCK_SIZE sb_size = cm->seq_params.sb_size;
+ const BLOCK_SIZE sb_size = cm->sb_size;
// First pass
SB_FIRST_PASS_STATS sb_fp_stats;
@@ -676,6 +675,7 @@
#endif // CONFIG_UNEVEN_4WAY
case PARTITION_HORZ_3:
case PARTITION_VERT_3: num_subtrees = 4; break;
+ case PARTITION_SPLIT: num_subtrees = 4; break;
default:
assert(0 && "Invalid partition type in set_min_none_to_invalid!");
return;
@@ -703,7 +703,7 @@
MACROBLOCK *const x = &td->mb;
MACROBLOCKD *const xd = &x->e_mbd;
- const BLOCK_SIZE sb_size = cm->seq_params.sb_size;
+ const BLOCK_SIZE sb_size = cm->sb_size;
assert(!frame_is_intra_only(cm));
// First pass to estimate partition structures
@@ -750,7 +750,7 @@
const TileInfo *const tile_info = &tile_data->tile_info;
MB_MODE_INFO **mi = cm->mi_params.mi_grid_base +
get_mi_grid_idx(&cm->mi_params, mi_row, mi_col);
- const BLOCK_SIZE sb_size = cm->seq_params.sb_size;
+ const BLOCK_SIZE sb_size = cm->sb_size;
const int num_planes = av1_num_planes(cm);
int dummy_rate;
int64_t dummy_dist;
@@ -920,9 +920,9 @@
MACROBLOCK *const x = &td->mb;
MACROBLOCKD *const xd = &x->e_mbd;
const int sb_cols_in_tile = av1_get_sb_cols_in_tile(cm, tile_data->tile_info);
- const BLOCK_SIZE sb_size = cm->seq_params.sb_size;
- const int mib_size = cm->seq_params.mib_size;
- const int mib_size_log2 = cm->seq_params.mib_size_log2;
+ const BLOCK_SIZE sb_size = cm->sb_size;
+ const int mib_size = cm->mib_size;
+ const int mib_size_log2 = cm->mib_size_log2;
const int sb_row = (mi_row - tile_info->mi_row_start) >> mib_size_log2;
#if CONFIG_COLLECT_COMPONENT_TIMING
@@ -947,7 +947,7 @@
for (int mi_col = tile_info->mi_col_start, sb_col_in_tile = 0;
mi_col < tile_info->mi_col_end; mi_col += mib_size, sb_col_in_tile++) {
(*(enc_row_mt->sync_read_ptr))(row_mt_sync, sb_row, sb_col_in_tile);
- av1_reset_is_mi_coded_map(xd, cm->seq_params.mib_size);
+ av1_reset_is_mi_coded_map(xd, cm->mib_size);
av1_set_sb_info(cm, xd, mi_row, mi_col);
if (tile_data->allow_update_cdf && row_mt_enabled &&
@@ -1064,9 +1064,8 @@
if (pre_tok != NULL && tplist != NULL) {
token_info->tile_tok[tile_row][tile_col] = pre_tok + tile_tok;
pre_tok = token_info->tile_tok[tile_row][tile_col];
- tile_tok = allocated_tokens(*tile_info,
- cm->seq_params.mib_size_log2 + MI_SIZE_LOG2,
- num_planes);
+ tile_tok = allocated_tokens(
+ *tile_info, cm->mib_size_log2 + MI_SIZE_LOG2, num_planes);
token_info->tplist[tile_row][tile_col] = tplist + tplist_count;
tplist = token_info->tplist[tile_row][tile_col];
tplist_count = av1_get_sb_rows_in_tile(cm, tile_data->tile_info);
@@ -1093,14 +1092,14 @@
TokenExtra *tok = NULL;
TokenList *const tplist = cpi->token_info.tplist[tile_row][tile_col];
const int sb_row_in_tile =
- (mi_row - tile_info->mi_row_start) >> cm->seq_params.mib_size_log2;
+ (mi_row - tile_info->mi_row_start) >> cm->mib_size_log2;
const int tile_mb_cols =
(tile_info->mi_col_end - tile_info->mi_col_start + 2) >> 2;
const int num_mb_rows_in_sb =
- ((1 << (cm->seq_params.mib_size_log2 + MI_SIZE_LOG2)) + 8) >> 4;
+ ((1 << (cm->mib_size_log2 + MI_SIZE_LOG2)) + 8) >> 4;
get_start_tok(cpi, tile_row, tile_col, mi_row, &tok,
- cm->seq_params.mib_size_log2 + MI_SIZE_LOG2, num_planes);
+ cm->mib_size_log2 + MI_SIZE_LOG2, num_planes);
tplist[sb_row_in_tile].start = tok;
encode_sb_row(cpi, td, this_tile, mi_row, &tok);
@@ -1110,8 +1109,7 @@
assert((unsigned int)(tok - tplist[sb_row_in_tile].start) <=
get_token_alloc(num_mb_rows_in_sb, tile_mb_cols,
- cm->seq_params.mib_size_log2 + MI_SIZE_LOG2,
- num_planes));
+ cm->mib_size_log2 + MI_SIZE_LOG2, num_planes));
(void)tile_mb_cols;
(void)num_mb_rows_in_sb;
@@ -1142,7 +1140,7 @@
&td->mb.txfm_search_info.mb_rd_record.crc_calculator);
for (int mi_row = tile_info->mi_row_start; mi_row < tile_info->mi_row_end;
- mi_row += cm->seq_params.mib_size) {
+ mi_row += cm->mib_size) {
#if CONFIG_REF_MV_BANK
av1_zero(td->mb.e_mbd.ref_mv_bank);
#if !CONFIG_MVP_IMPROVEMENT
@@ -1582,8 +1580,7 @@
block_hash_values[0], is_block_same[0]);
// Hash data generated for screen contents is used for intraBC ME
const int min_alloc_size = block_size_wide[mi_params->mi_alloc_bsize];
- const int max_sb_size =
- (1 << (cm->seq_params.mib_size_log2 + MI_SIZE_LOG2));
+ const int max_sb_size = (1 << (cm->mib_size_log2 + MI_SIZE_LOG2));
int src_idx = 0;
for (int size = 4; size <= max_sb_size; size *= 2, src_idx = !src_idx) {
const int dst_idx = !src_idx;
diff --git a/av1/encoder/encodeframe_utils.c b/av1/encoder/encodeframe_utils.c
index 4405d12..d38dbac 100644
--- a/av1/encoder/encodeframe_utils.c
+++ b/av1/encoder/encodeframe_utils.c
@@ -67,13 +67,13 @@
static int get_superblock_tpl_column_end(const AV1_COMMON *const cm, int mi_col,
int num_mi_w) {
// Find the start column of this superblock.
- const int sb_mi_col_start = (mi_col >> cm->seq_params.mib_size_log2)
- << cm->seq_params.mib_size_log2;
+ const int sb_mi_col_start = (mi_col >> cm->mib_size_log2)
+ << cm->mib_size_log2;
// Same but in superres upscaled dimension.
const int sb_mi_col_start_sr =
coded_to_superres_mi(sb_mi_col_start, cm->superres_scale_denominator);
// Width of this superblock in mi units.
- const int sb_mi_width = mi_size_wide[cm->seq_params.sb_size];
+ const int sb_mi_width = mi_size_wide[cm->sb_size];
// Same but in superres upscaled dimension.
const int sb_mi_width_sr =
coded_to_superres_mi(sb_mi_width, cm->superres_scale_denominator);
@@ -134,7 +134,7 @@
rdmult = AOMMAX(rdmult, 0);
av1_set_error_per_bit(&x->mv_costs, rdmult);
aom_clear_system_state();
- if (bsize == cm->seq_params.sb_size) {
+ if (bsize == cm->sb_size) {
const int rdmult_sb = set_deltaq_rdmult(cpi, x);
assert(rdmult_sb == rdmult);
(void)rdmult_sb;
@@ -759,8 +759,7 @@
memcpy(xd->left_txfm_context, ctx->tl,
sizeof(*xd->left_txfm_context) * mi_height);
#endif // !CONFIG_TX_PARTITION_CTX
- av1_mark_block_as_not_coded(xd, mi_row, mi_col, bsize,
- cm->seq_params.sb_size);
+ av1_mark_block_as_not_coded(xd, mi_row, mi_col, bsize, cm->sb_size);
}
void av1_save_context(const MACROBLOCK *x, RD_SEARCH_MACROBLOCK_CONTEXT *ctx,
@@ -805,9 +804,9 @@
MB_MODE_INFO **mib) {
int bh = bh_in;
int r, c;
- for (r = 0; r < cm->seq_params.mib_size; r += bh) {
+ for (r = 0; r < cm->mib_size; r += bh) {
int bw = bw_in;
- for (c = 0; c < cm->seq_params.mib_size; c += bw) {
+ for (c = 0; c < cm->mib_size; c += bw) {
const int grid_index = get_mi_grid_idx(&cm->mi_params, r, c);
const int mi_index = get_alloc_mi_idx(&cm->mi_params, r, c);
mib[grid_index] = mi + mi_index;
@@ -840,12 +839,10 @@
assert((mi_rows_remaining > 0) && (mi_cols_remaining > 0));
// Apply the requested partition size to the SB if it is all "in image"
- if ((mi_cols_remaining >= cm->seq_params.mib_size) &&
- (mi_rows_remaining >= cm->seq_params.mib_size)) {
- for (int block_row = 0; block_row < cm->seq_params.mib_size;
- block_row += bh) {
- for (int block_col = 0; block_col < cm->seq_params.mib_size;
- block_col += bw) {
+ if ((mi_cols_remaining >= cm->mib_size) &&
+ (mi_rows_remaining >= cm->mib_size)) {
+ for (int block_row = 0; block_row < cm->mib_size; block_row += bh) {
+ for (int block_col = 0; block_col < cm->mib_size; block_col += bw) {
const int grid_index = get_mi_grid_idx(mi_params, block_row, block_col);
const int mi_index = get_alloc_mi_idx(mi_params, block_row, block_col);
mib[grid_index] = mi_upper_left + mi_index;
@@ -1479,6 +1476,15 @@
ctx_tr->do_split_cdf[plane_index][i], 2);
}
}
+#if CONFIG_BLOCK_256
+ for (int plane_index = 0; plane_index < PARTITION_STRUCTURE_NUM;
+ plane_index++) {
+ for (int i = 0; i < SQUARE_SPLIT_CONTEXTS; i++) {
+ AVERAGE_CDF(ctx_left->do_square_split_cdf[plane_index][i],
+ ctx_tr->do_square_split_cdf[plane_index][i], 2);
+ }
+ }
+#endif // CONFIG_BLOCK_256
for (int plane_index = 0; plane_index < PARTITION_STRUCTURE_NUM;
plane_index++) {
for (int i = 0; i < PARTITION_CONTEXTS; i++) {
@@ -1665,7 +1671,7 @@
const AV1_COMMON *cm = &cpi->common;
const int num_planes = av1_num_planes(cm);
- const BLOCK_SIZE sb_size = cm->seq_params.sb_size;
+ const BLOCK_SIZE sb_size = cm->sb_size;
#if !CONFIG_TX_PARTITION_CTX
xd->above_txfm_context =
@@ -1707,7 +1713,7 @@
const AV1_COMMON *cm = &cpi->common;
const int num_planes = av1_num_planes(cm);
- const BLOCK_SIZE sb_size = cm->seq_params.sb_size;
+ const BLOCK_SIZE sb_size = cm->sb_size;
av1_restore_context(cm, x, &sb_fp_stats->x_ctx, mi_row, mi_col, sb_size,
num_planes);
diff --git a/av1/encoder/encodeframe_utils.h b/av1/encoder/encodeframe_utils.h
index 5fc666f..abe641e 100644
--- a/av1/encoder/encodeframe_utils.h
+++ b/av1/encoder/encodeframe_utils.h
@@ -151,14 +151,13 @@
// RD cost summed across all blocks of partition type.
RD_STATS sum_rdc;
+#if !CONFIG_EXT_RECUR_PARTITIONS
// Array holding partition type cost.
int tmp_partition_cost[PARTITION_TYPES];
-#if CONFIG_EXT_RECUR_PARTITIONS
- int partition_cost_table[EXT_PARTITION_TYPES];
-#endif
+#endif // CONFIG_EXT_RECUR_PARTITIONS
// Pointer to partition cost buffer
- int *partition_cost;
+ const int *partition_cost;
// RD costs for different partition types.
int64_t none_rd;
@@ -304,6 +303,9 @@
case 32: return BLOCK_32X32;
case 64: return BLOCK_64X64;
case 128: return BLOCK_128X128;
+#if CONFIG_BLOCK_256
+ case 256: return BLOCK_256X256;
+#endif // CONFIG_BLOCK_256
default: assert(0); return 0;
}
}
@@ -321,10 +323,8 @@
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);
+ sb_enc->max_partition_size = AOMMIN(sb_enc->max_partition_size, cm->sb_size);
+ sb_enc->min_partition_size = AOMMIN(sb_enc->min_partition_size, cm->sb_size);
if (use_auto_max_partition(cpi, sb_size, mi_row, mi_col)) {
float features[FEATURE_SIZE_MAX_MIN_PART_PRED] = { 0.0f };
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index 28c4263..d9c66b4 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -16,6 +16,7 @@
#include <stdio.h>
#include <string.h>
+#include "av1/common/av1_common_int.h"
#include "config/aom_config.h"
#include "config/aom_dsp_rtcd.h"
@@ -245,59 +246,6 @@
return uncompressed_frame_size / (double)encoded_frame_size;
}
-static void set_tile_info(AV1_COMMON *const cm,
- const TileConfig *const tile_cfg) {
- const CommonModeInfoParams *const mi_params = &cm->mi_params;
- const SequenceHeader *const seq_params = &cm->seq_params;
- CommonTileParams *const tiles = &cm->tiles;
- int i, start_sb;
-
- av1_get_tile_limits(cm);
-
- // configure tile columns
- if (tile_cfg->tile_width_count == 0 || tile_cfg->tile_height_count == 0) {
- tiles->uniform_spacing = 1;
- tiles->log2_cols = AOMMAX(tile_cfg->tile_columns, tiles->min_log2_cols);
- tiles->log2_cols = AOMMIN(tiles->log2_cols, tiles->max_log2_cols);
- } else {
- int mi_cols =
- ALIGN_POWER_OF_TWO(mi_params->mi_cols, seq_params->mib_size_log2);
- int sb_cols = mi_cols >> seq_params->mib_size_log2;
- int size_sb, j = 0;
- tiles->uniform_spacing = 0;
- for (i = 0, start_sb = 0; start_sb < sb_cols && i < MAX_TILE_COLS; i++) {
- tiles->col_start_sb[i] = start_sb;
- size_sb = tile_cfg->tile_widths[j++];
- if (j >= tile_cfg->tile_width_count) j = 0;
- start_sb += AOMMIN(size_sb, tiles->max_width_sb);
- }
- tiles->cols = i;
- tiles->col_start_sb[i] = sb_cols;
- }
- av1_calculate_tile_cols(seq_params, mi_params->mi_rows, mi_params->mi_cols,
- tiles);
-
- // configure tile rows
- if (tiles->uniform_spacing) {
- tiles->log2_rows = AOMMAX(tile_cfg->tile_rows, tiles->min_log2_rows);
- tiles->log2_rows = AOMMIN(tiles->log2_rows, tiles->max_log2_rows);
- } else {
- int mi_rows =
- ALIGN_POWER_OF_TWO(mi_params->mi_rows, seq_params->mib_size_log2);
- int sb_rows = mi_rows >> seq_params->mib_size_log2;
- int size_sb, j = 0;
- for (i = 0, start_sb = 0; start_sb < sb_rows && i < MAX_TILE_ROWS; i++) {
- tiles->row_start_sb[i] = start_sb;
- size_sb = tile_cfg->tile_heights[j++];
- if (j >= tile_cfg->tile_height_count) j = 0;
- start_sb += AOMMIN(size_sb, tiles->max_height_sb);
- }
- tiles->rows = i;
- tiles->row_start_sb[i] = sb_rows;
- }
- av1_calculate_tile_rows(seq_params, mi_params->mi_rows, tiles);
-}
-
static void update_frame_size(AV1_COMP *cpi) {
AV1_COMMON *const cm = &cpi->common;
MACROBLOCKD *const xd = &cpi->td.mb.e_mbd;
@@ -314,10 +262,15 @@
if (!is_stat_generation_stage(cpi))
alloc_context_buffers_ext(cm, &cpi->mbmi_ext_info);
- if (!cpi->seq_params_locked)
- set_sb_size(&cm->seq_params, av1_select_sb_size(cpi));
+ const BLOCK_SIZE sb_size = av1_select_sb_size(cpi);
+ if (!cpi->seq_params_locked) {
+ set_sb_size(cm, sb_size);
+ } else {
+ av1_set_frame_sb_size(cm, sb_size);
+ }
+ cpi->td.sb_size = cm->sb_size;
- set_tile_info(cm, &cpi->oxcf.tile_cfg);
+ av1_set_tile_info(cm, &cpi->oxcf.tile_cfg);
}
static INLINE int does_level_match(int width, int height, double fps,
@@ -645,8 +598,10 @@
cm->width = oxcf->frm_dim_cfg.width;
cm->height = oxcf->frm_dim_cfg.height;
- set_sb_size(seq_params,
- av1_select_sb_size(cpi)); // set sb size before allocations
+ // set sb size before allocations
+ const BLOCK_SIZE sb_size = av1_select_sb_size(cpi);
+ set_sb_size(cm, sb_size);
+ cpi->td.sb_size = cm->sb_size;
alloc_compressor_data(cpi);
av1_update_film_grain_parameters(cpi, oxcf);
@@ -909,18 +864,21 @@
cm->width = frm_dim_cfg->width;
cm->height = frm_dim_cfg->height;
- int sb_size = seq_params->sb_size;
+ BLOCK_SIZE sb_size = cm->sb_size;
+ BLOCK_SIZE new_sb_size = av1_select_sb_size(cpi);
// Superblock size should not be updated after the first key frame.
if (!cpi->seq_params_locked) {
- set_sb_size(&cm->seq_params, av1_select_sb_size(cpi));
+ set_sb_size(cm, new_sb_size);
for (int i = 0; i < MAX_NUM_OPERATING_POINTS; ++i)
seq_params->tier[i] = (oxcf->tier_mask >> i) & 1;
+ } else {
+ av1_set_frame_sb_size(cm, new_sb_size);
}
+ cpi->td.sb_size = cm->sb_size;
- if (initial_dimensions->width || sb_size != seq_params->sb_size) {
+ if (initial_dimensions->width || sb_size != cm->sb_size) {
if (cm->width > initial_dimensions->width ||
- cm->height > initial_dimensions->height ||
- seq_params->sb_size != sb_size) {
+ cm->height > initial_dimensions->height || cm->sb_size != sb_size) {
av1_free_context_buffers(cm);
av1_free_shared_coeff_buffer(&cpi->td.shared_coeff_buf);
av1_free_sms_tree(&cpi->td);
@@ -938,7 +896,7 @@
rc->is_src_frame_alt_ref = 0;
- set_tile_info(cm, &cpi->oxcf.tile_cfg);
+ av1_set_tile_info(cm, &cpi->oxcf.tile_cfg);
cpi->ext_flags.refresh_frame.update_pending = 0;
cpi->ext_flags.refresh_frame_context_pending = 0;
@@ -2341,6 +2299,7 @@
if (cm->cdef_info.cdef_frame_enable)
#endif // CONFIG_FIX_CDEF_SYNTAX
av1_cdef_frame(&cm->cur_frame->buf, cm, xd);
+
#if CONFIG_COLLECT_COMPONENT_TIMING
end_timing(cpi, cdef_time);
#endif
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h
index f481bd9..0e62818 100644
--- a/av1/encoder/encoder.h
+++ b/av1/encoder/encoder.h
@@ -235,12 +235,12 @@
* Indicates the minimum partition size that should be allowed. Both width and
* height of a partition cannot be smaller than the min_partition_size.
*/
- BLOCK_SIZE min_partition_size;
+ unsigned int min_partition_size;
/*!
* Indicates the maximum partition size that should be allowed. Both width and
* height of a partition cannot be larger than the max_partition_size.
*/
- BLOCK_SIZE max_partition_size;
+ unsigned int max_partition_size;
} PartitionCfg;
/*!
@@ -1270,6 +1270,8 @@
[PALETTE_COLORS];
#if CONFIG_EXT_RECUR_PARTITIONS
unsigned int do_split[PARTITION_STRUCTURE_NUM][PARTITION_CONTEXTS][2];
+ unsigned int do_square_split[PARTITION_STRUCTURE_NUM][SQUARE_SPLIT_CONTEXTS]
+ [2];
unsigned int rect_type[PARTITION_STRUCTURE_NUM][PARTITION_CONTEXTS][2];
unsigned int do_ext_partition[PARTITION_STRUCTURE_NUM][NUM_RECT_PARTS]
[PARTITION_CONTEXTS][2];
@@ -1703,6 +1705,7 @@
SIMPLE_MOTION_DATA_TREE *sms_root;
#if CONFIG_EXT_RECUR_PARTITIONS
struct SimpleMotionDataBufs *sms_bufs;
+ BLOCK_SIZE sb_size;
#endif // CONFIG_EXT_RECUR_PARTITIONS
InterModesInfo *inter_modes_info;
uint32_t *hash_value_buffer[2][2];
diff --git a/av1/encoder/encoder_alloc.h b/av1/encoder/encoder_alloc.h
index d40a3a8..2b6e702 100644
--- a/av1/encoder/encoder_alloc.h
+++ b/av1/encoder/encoder_alloc.h
@@ -333,7 +333,7 @@
static AOM_INLINE void variance_partition_alloc(AV1_COMP *cpi) {
AV1_COMMON *const cm = &cpi->common;
- const int num_64x64_blocks = (cm->seq_params.sb_size == BLOCK_64X64) ? 1 : 4;
+ const int num_64x64_blocks = (cm->sb_size == BLOCK_64X64) ? 1 : 4;
if (cpi->td.vt64x64) {
if (num_64x64_blocks != cpi->td.num_64x64_blocks) {
aom_free(cpi->td.vt64x64);
diff --git a/av1/encoder/encoder_utils.c b/av1/encoder/encoder_utils.c
index e18009c..3822b43 100644
--- a/av1/encoder/encoder_utils.c
+++ b/av1/encoder/encoder_utils.c
@@ -168,19 +168,171 @@
{ 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }
};
-const int default_obmc_probs[FRAME_UPDATE_TYPES][BLOCK_SIZES_ALL] = {
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 106, 90, 90, 97, 67, 59, 70, 28,
- 30, 38, 16, 16, 16, 0, 0, 44, 50, 26, 25 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 98, 93, 97, 68, 82, 85, 33, 30,
- 33, 16, 16, 16, 16, 0, 0, 43, 37, 26, 16 },
- { 0, 0, 0, 91, 80, 76, 78, 55, 49, 24, 16,
- 16, 16, 16, 16, 16, 0, 0, 29, 45, 16, 38 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 103, 89, 89, 89, 62, 63, 76, 34,
- 35, 32, 19, 16, 16, 0, 0, 49, 55, 29, 19 }
+/* clang-format off */
+const int default_obmc_probs[FRAME_UPDATE_TYPES][BLOCK_SIZES_ALL] = { {
+ // BLOCK_4X4
+ 0,
+ // BLOCK_4X8 .. BLOCK_8X8
+ 0, 0, 0,
+ // BLOCK_8X16 .. BLOCK_16X16
+ 0, 0, 0,
+ // BLOCK_16X32 .. BLOCK_32X32
+ 0, 0, 0,
+ // BLOCK_32X64 .. BLOCK_64X64
+ 0, 0, 0,
+ // BLOCK_64X128 .. BLOCK_128X128
+ 0, 0, 0,
+#if CONFIG_BLOCK_256
+ // BLOCK_128X256 .. BLOCK_256X256
+ 0, 0, 0,
+#endif // CONFIG_BLOCK_256
+ // BLOCK_4X16, BLOCK_16X4
+ 0, 0,
+ // BLOCK_8X32, BLOCK_32X8
+ 0, 0,
+ // BLOCK_16X64, BLOCK_64X16
+ 0, 0
+ }, {
+ // BLOCK_4X4
+ 0,
+ // BLOCK_4X8 .. BLOCK_8X8
+ 0, 0, 106,
+ // BLOCK_8X16 .. BLOCK_16X16
+ 90, 90, 97,
+ // BLOCK_16X32 .. BLOCK_32X32
+ 67, 59, 70,
+ // BLOCK_32X64 .. BLOCK_64X64
+ 28, 30, 38,
+ // BLOCK_64X128 .. BLOCK_128X128
+ 16, 16, 16,
+#if CONFIG_BLOCK_256
+ // BLOCK_128X256 .. BLOCK_256X256
+ 16, 16, 16,
+#endif // CONFIG_BLOCK_256
+ // BLOCK_4X16, BLOCK_16X4
+ 0, 0,
+ // BLOCK_8X32, BLOCK_32X8
+ 44, 50,
+ // BLOCK_16X64, BLOCK_64X16
+ 26, 25
+ }, {
+ // BLOCK_4X4
+ 0,
+ // BLOCK_4X8 .. BLOCK_8X8
+ 0, 0, 0,
+ // BLOCK_8X16 .. BLOCK_16X16
+ 0, 0, 0,
+ // BLOCK_16X32 .. BLOCK_32X32
+ 0, 0, 0,
+ // BLOCK_32X64 .. BLOCK_64X64
+ 0, 0, 0,
+ // BLOCK_64X128 .. BLOCK_128X128
+ 0, 0, 0,
+#if CONFIG_BLOCK_256
+ // BLOCK_128X256 .. BLOCK_256X256
+ 0, 0, 0,
+#endif // CONFIG_BLOCK_256
+ // BLOCK_4X16, BLOCK_16X4
+ 0, 0,
+ // BLOCK_8X32, BLOCK_32X8
+ 0, 0,
+ // BLOCK_16X64, BLOCK_64X16
+ 0, 0
+ }, {
+ // BLOCK_4X4
+ 0,
+ // BLOCK_4X8 .. BLOCK_8X8
+ 0, 0, 98,
+ // BLOCK_8X16 .. BLOCK_16X16
+ 93, 97, 68,
+ // BLOCK_16X32 .. BLOCK_32X32
+ 82, 85, 33,
+ // BLOCK_32X64 .. BLOCK_64X64
+ 30, 33, 16,
+ // BLOCK_64X128 .. BLOCK_128X128
+ 16, 16, 16,
+#if CONFIG_BLOCK_256
+ // BLOCK_128X256 .. BLOCK_256X256
+ 16, 16, 16,
+#endif // CONFIG_BLOCK_256
+ // BLOCK_4X16, BLOCK_16X4
+ 0, 0,
+ // BLOCK_8X32, BLOCK_32X8
+ 43, 37,
+ // BLOCK_16X64, BLOCK_64X16
+ 26, 16
+ }, {
+ // BLOCK_4X4
+ 0,
+ // BLOCK_4X8 .. BLOCK_8X8
+ 0, 0, 91,
+ // BLOCK_8X16 .. BLOCK_16X16
+ 80, 76, 78,
+ // BLOCK_16X32 .. BLOCK_32X32
+ 55, 49, 24,
+ // BLOCK_32X64 .. BLOCK_64X64
+ 16, 16, 16,
+ // BLOCK_64X128 .. BLOCK_128X128
+ 16, 16, 16,
+ // BLOCK_128X256 .. BLOCK_256X256
+#if CONFIG_BLOCK_256
+ 16, 16, 16,
+#endif // CONFIG_BLOCK_256
+ // BLOCK_4X16, BLOCK_16X4
+ 0, 0,
+ // BLOCK_8X32, BLOCK_32X8
+ 29, 45,
+ // BLOCK_16X64, BLOCK_64X16
+ 16, 38
+ }, {
+ // BLOCK_4X4
+ 0,
+ // BLOCK_4X8 .. BLOCK_8X8
+ 0, 0, 0,
+ // BLOCK_8X16 .. BLOCK_16X16
+ 0, 0, 0,
+ // BLOCK_16X32 .. BLOCK_32X32
+ 0, 0, 0,
+ // BLOCK_32X64 .. BLOCK_64X64
+ 0, 0, 0,
+ // BLOCK_64X128 .. BLOCK_128X128
+ 0, 0, 0,
+#if CONFIG_BLOCK_256
+ // BLOCK_128X256 .. BLOCK_256X256
+ 0, 0, 0,
+#endif // CONFIG_BLOCK_256
+ // BLOCK_4X16, BLOCK_16X4
+ 0, 0,
+ // BLOCK_8X32, BLOCK_32X8
+ 0, 0,
+ // BLOCK_16X64, BLOCK_64X16
+ 0, 0
+ }, {
+ // BLOCK_4X4
+ 0,
+ // BLOCK_4X8 .. BLOCK_8X8
+ 0, 0, 103,
+ // BLOCK_8X16 .. BLOCK_16X16
+ 89, 89, 89,
+ // BLOCK_16X32 .. BLOCK_32X32
+ 62, 63, 76,
+ // BLOCK_32X64 .. BLOCK_64X64
+ 34, 35, 32,
+ // BLOCK_64X128 .. BLOCK_128X128
+ 19, 16, 16,
+#if CONFIG_BLOCK_256
+ // BLOCK_128X256 .. BLOCK_256X256
+ 19, 16, 16,
+#endif // CONFIG_BLOCK_256
+ // BLOCK_4X16, BLOCK_16X4
+ 0, 0,
+ // BLOCK_8X32, BLOCK_32X8
+ 49, 55,
+ // BLOCK_16X64, BLOCK_64X16
+ 29, 19
+ }
};
+/* clang-format on */
const int default_warped_probs[FRAME_UPDATE_TYPES] = { 64, 64, 64, 64,
64, 64, 64 };
@@ -601,8 +753,53 @@
oxcf->resize_cfg.resize_mode == RESIZE_NONE && oxcf->speed >= 1) {
return AOMMIN(cm->width, cm->height) > 480 ? BLOCK_128X128 : BLOCK_64X64;
}
-
+#if CONFIG_BLOCK_256
+ return AOMMIN(oxcf->frm_dim_cfg.width, oxcf->frm_dim_cfg.height) >= 720
+ ? BLOCK_256X256
+ : BLOCK_128X128;
+#else
return BLOCK_128X128;
+#endif // CONFIG_BLOCK_256
+}
+
+static AOM_INLINE void reallocate_sb_size_dependent_buffers(AV1_COMP *cpi) {
+ // Note: this is heavier than it needs to be. We can avoid reallocating some
+ // of the buffers.
+ AV1_COMMON *const cm = &cpi->common;
+ const int num_planes = av1_num_planes(cm);
+
+ av1_set_tile_info(cm, &cpi->oxcf.tile_cfg);
+ av1_free_context_buffers(cm);
+ av1_free_shared_coeff_buffer(&cpi->td.shared_coeff_buf);
+ av1_free_sms_tree(&cpi->td);
+#if CONFIG_EXT_RECUR_PARTITIONS
+ av1_free_sms_bufs(&cpi->td);
+#endif // CONFIG_EXT_RECUR_PARTITIONS
+ av1_free_pmc(cpi->td.firstpass_ctx, num_planes);
+ cpi->td.firstpass_ctx = NULL;
+ alloc_compressor_data(cpi);
+ if (av1_alloc_above_context_buffers(&cm->above_contexts, cm->tiles.rows,
+ cm->mi_params.mi_cols, num_planes)) {
+ aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
+ "Failed to allocate context buffers");
+ }
+
+ const int old_restoration_unit_size = cm->rst_info[0].restoration_unit_size;
+
+ const SequenceHeader *const seq_params = &cm->seq_params;
+ const int frame_width = cm->superres_upscaled_width;
+ const int frame_height = cm->superres_upscaled_height;
+
+ set_restoration_unit_size(frame_width, frame_height,
+ seq_params->subsampling_x,
+ seq_params->subsampling_y, cm->rst_info);
+
+ if (old_restoration_unit_size != cm->rst_info[0].restoration_unit_size) {
+ for (int i = 0; i < num_planes; ++i)
+ cm->rst_info[i].frame_restoration_type = RESTORE_NONE;
+
+ av1_alloc_restoration_buffers(cm);
+ }
}
void av1_setup_frame(AV1_COMP *cpi) {
@@ -618,10 +815,11 @@
av1_setup_past_independence(cm);
}
+ const BLOCK_SIZE old_sb_size = cm->sb_size;
if ((cm->current_frame.frame_type == KEY_FRAME && cm->show_frame) ||
frame_is_sframe(cm)) {
if (!cpi->seq_params_locked) {
- set_sb_size(&cm->seq_params, av1_select_sb_size(cpi));
+ set_sb_size(cm, av1_select_sb_size(cpi));
}
} else {
const RefCntBuffer *const primary_ref_buf = get_primary_ref_frame_buf(cm);
@@ -633,6 +831,31 @@
*cm->fc = primary_ref_buf->frame_context;
}
}
+ av1_set_frame_sb_size(cm, cm->seq_params.sb_size);
+ cpi->td.sb_size = cm->sb_size;
+ av1_set_tile_info(cm, &cpi->oxcf.tile_cfg);
+ if (cm->sb_size != old_sb_size) {
+ av1_free_context_buffers(cm);
+ av1_free_shared_coeff_buffer(&cpi->td.shared_coeff_buf);
+ av1_free_sms_tree(&cpi->td);
+#if CONFIG_EXT_RECUR_PARTITIONS
+ av1_free_sms_bufs(&cpi->td);
+#endif // CONFIG_EXT_RECUR_PARTITIONS
+ av1_free_pmc(cpi->td.firstpass_ctx, av1_num_planes(cm));
+ cpi->td.firstpass_ctx = NULL;
+ alloc_compressor_data(cpi);
+ if (av1_alloc_above_context_buffers(&cm->above_contexts, cm->tiles.rows,
+ cm->mi_params.mi_cols,
+ av1_num_planes(cm))) {
+ aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
+ "Failed to allocate context buffers");
+ }
+ }
+
+ if (cm->seq_params.sb_size != old_sb_size) {
+ // Reallocate sb_size-dependent buffers if the sb_size has changed.
+ reallocate_sb_size_dependent_buffers(cpi);
+ }
av1_zero(cm->cur_frame->interp_filter_selected);
cm->prev_frame = get_primary_ref_frame_buf(cm);
diff --git a/av1/encoder/encoder_utils.h b/av1/encoder/encoder_utils.h
index 612bde5..5399797 100644
--- a/av1/encoder/encoder_utils.h
+++ b/av1/encoder/encoder_utils.h
@@ -248,6 +248,19 @@
4; \
}
+#if CONFIG_BLOCK_256
+MAKE_BFP_SAD_WRAPPER(aom_highbd_sad256x256)
+MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad256x256_avg)
+MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad256x256x4d)
+
+MAKE_BFP_SAD_WRAPPER(aom_highbd_sad256x128)
+MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad256x128_avg)
+MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad256x128x4d)
+
+MAKE_BFP_SAD_WRAPPER(aom_highbd_sad128x256)
+MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad128x256_avg)
+MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad128x256x4d)
+#endif // CONFIG_BLOCK_256
MAKE_BFP_SAD_WRAPPER(aom_highbd_sad128x128)
MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad128x128_avg)
MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad128x128x4d)
@@ -316,6 +329,11 @@
MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad64x16_avg)
MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad64x16x4d)
+#if CONFIG_BLOCK_256
+MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad256x256_avg)
+MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad256x128_avg)
+MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad128x256_avg)
+#endif // CONFIG_BLOCK_256
MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad128x128_avg)
MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad128x64_avg)
MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad64x128_avg)
@@ -373,6 +391,11 @@
4; \
}
+#if CONFIG_BLOCK_256
+MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad256x256)
+MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad256x128)
+MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad128x256)
+#endif // CONFIG_BLOCK_256
MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad128x128)
MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad128x64)
MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad64x128)
@@ -440,6 +463,11 @@
for (i = 0; i < 4; i++) sad_array[i] >>= 4; \
}
+#if CONFIG_BLOCK_256
+MAKE_SDSF_SKIP_SAD_WRAPPER(aom_highbd_sad_skip_256x256)
+MAKE_SDSF_SKIP_SAD_WRAPPER(aom_highbd_sad_skip_256x128)
+MAKE_SDSF_SKIP_SAD_WRAPPER(aom_highbd_sad_skip_128x256)
+#endif // CONFIG_BLOCK_256
MAKE_SDSF_SKIP_SAD_WRAPPER(aom_highbd_sad_skip_128x128)
MAKE_SDSF_SKIP_SAD_WRAPPER(aom_highbd_sad_skip_128x64)
MAKE_SDSF_SKIP_SAD_WRAPPER(aom_highbd_sad_skip_64x128)
@@ -460,6 +488,11 @@
MAKE_SDSF_SKIP_SAD_WRAPPER(aom_highbd_sad_skip_4x8)
MAKE_SDSF_SKIP_SAD_WRAPPER(aom_highbd_sad_skip_8x32)
+#if CONFIG_BLOCK_256
+MAKE_SDSF_SKIP_SAD_4D_WRAPPER(aom_highbd_sad_skip_256x256x4d)
+MAKE_SDSF_SKIP_SAD_4D_WRAPPER(aom_highbd_sad_skip_256x128x4d)
+MAKE_SDSF_SKIP_SAD_4D_WRAPPER(aom_highbd_sad_skip_128x256x4d)
+#endif // CONFIG_BLOCK_256
MAKE_SDSF_SKIP_SAD_4D_WRAPPER(aom_highbd_sad_skip_128x128x4d)
MAKE_SDSF_SKIP_SAD_4D_WRAPPER(aom_highbd_sad_skip_128x64x4d)
MAKE_SDSF_SKIP_SAD_4D_WRAPPER(aom_highbd_sad_skip_64x128x4d)
@@ -514,6 +547,11 @@
return fnname(ref, ref_stride, wsrc, msk) >> 4; \
}
+#if CONFIG_BLOCK_256
+MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad256x256)
+MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad256x128)
+MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad128x256)
+#endif // CONFIG_BLOCK_256
MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad128x128)
MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad128x64)
MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad64x128)
@@ -563,7 +601,15 @@
HIGHBD_BFP_WRAPPER(128, 128, 8)
HIGHBD_BFP_WRAPPER(128, 64, 8)
HIGHBD_BFP_WRAPPER(64, 128, 8)
+#if CONFIG_BLOCK_256
+ HIGHBD_BFP_WRAPPER(128, 256, 8)
+ HIGHBD_BFP_WRAPPER(256, 128, 8)
+ HIGHBD_BFP_WRAPPER(256, 256, 8)
+ HIGHBD_MBFP_WRAPPER(256, 256, 8)
+ HIGHBD_MBFP_WRAPPER(256, 128, 8)
+ HIGHBD_MBFP_WRAPPER(128, 256, 8)
+#endif // CONFIG_BLOCK_128
HIGHBD_MBFP_WRAPPER(128, 128, 8)
HIGHBD_MBFP_WRAPPER(128, 64, 8)
HIGHBD_MBFP_WRAPPER(64, 128, 8)
@@ -587,6 +633,11 @@
HIGHBD_MBFP_WRAPPER(16, 4, 8)
HIGHBD_MBFP_WRAPPER(4, 16, 8)
+#if CONFIG_BLOCK_256
+ LOWBD_OBFP_WRAPPER(256, 256)
+ LOWBD_OBFP_WRAPPER(256, 128)
+ LOWBD_OBFP_WRAPPER(128, 256)
+#endif // CONFIG_BLOCK_128
LOWBD_OBFP_WRAPPER(128, 128)
LOWBD_OBFP_WRAPPER(128, 64)
LOWBD_OBFP_WRAPPER(64, 128)
@@ -610,6 +661,11 @@
LOWBD_OBFP_WRAPPER(16, 4)
LOWBD_OBFP_WRAPPER(4, 16)
+#if CONFIG_BLOCK_256
+ HIGHBD_SDSFP_WRAPPER(256, 256, 8)
+ HIGHBD_SDSFP_WRAPPER(256, 128, 8)
+ HIGHBD_SDSFP_WRAPPER(128, 256, 8)
+#endif // CONFIG_BLOCK_128
HIGHBD_SDSFP_WRAPPER(128, 128, 8);
HIGHBD_SDSFP_WRAPPER(128, 64, 8);
HIGHBD_SDSFP_WRAPPER(64, 128, 8);
@@ -654,7 +710,15 @@
HIGHBD_BFP_WRAPPER(128, 128, 10)
HIGHBD_BFP_WRAPPER(128, 64, 10)
HIGHBD_BFP_WRAPPER(64, 128, 10)
+#if CONFIG_BLOCK_256
+ HIGHBD_BFP_WRAPPER(128, 256, 10)
+ HIGHBD_BFP_WRAPPER(256, 128, 10)
+ HIGHBD_BFP_WRAPPER(256, 256, 10)
+ HIGHBD_MBFP_WRAPPER(256, 256, 10)
+ HIGHBD_MBFP_WRAPPER(256, 128, 10)
+ HIGHBD_MBFP_WRAPPER(128, 256, 10)
+#endif // CONFIG_BLOCK_128
HIGHBD_MBFP_WRAPPER(128, 128, 10)
HIGHBD_MBFP_WRAPPER(128, 64, 10)
HIGHBD_MBFP_WRAPPER(64, 128, 10)
@@ -678,6 +742,11 @@
HIGHBD_MBFP_WRAPPER(16, 4, 10)
HIGHBD_MBFP_WRAPPER(4, 16, 10)
+#if CONFIG_BLOCK_256
+ HIGHBD_OBFP_WRAPPER(256, 256, 10)
+ HIGHBD_OBFP_WRAPPER(256, 128, 10)
+ HIGHBD_OBFP_WRAPPER(128, 256, 10)
+#endif // CONFIG_BLOCK_128
HIGHBD_OBFP_WRAPPER(128, 128, 10)
HIGHBD_OBFP_WRAPPER(128, 64, 10)
HIGHBD_OBFP_WRAPPER(64, 128, 10)
@@ -701,6 +770,11 @@
HIGHBD_OBFP_WRAPPER(16, 4, 10)
HIGHBD_OBFP_WRAPPER(4, 16, 10)
+#if CONFIG_BLOCK_256
+ HIGHBD_SDSFP_WRAPPER(256, 256, 10)
+ HIGHBD_SDSFP_WRAPPER(256, 128, 10)
+ HIGHBD_SDSFP_WRAPPER(128, 256, 10)
+#endif // CONFIG_BLOCK_128
HIGHBD_SDSFP_WRAPPER(128, 128, 10);
HIGHBD_SDSFP_WRAPPER(128, 64, 10);
HIGHBD_SDSFP_WRAPPER(64, 128, 10);
@@ -745,7 +819,15 @@
HIGHBD_BFP_WRAPPER(128, 128, 12)
HIGHBD_BFP_WRAPPER(128, 64, 12)
HIGHBD_BFP_WRAPPER(64, 128, 12)
+#if CONFIG_BLOCK_256
+ HIGHBD_BFP_WRAPPER(128, 256, 12)
+ HIGHBD_BFP_WRAPPER(256, 128, 12)
+ HIGHBD_BFP_WRAPPER(256, 256, 12)
+ HIGHBD_MBFP_WRAPPER(128, 256, 12)
+ HIGHBD_MBFP_WRAPPER(256, 128, 12)
+ HIGHBD_MBFP_WRAPPER(256, 256, 12)
+#endif // CONFIG_BLOCK_128
HIGHBD_MBFP_WRAPPER(128, 128, 12)
HIGHBD_MBFP_WRAPPER(128, 64, 12)
HIGHBD_MBFP_WRAPPER(64, 128, 12)
@@ -769,6 +851,11 @@
HIGHBD_MBFP_WRAPPER(16, 4, 12)
HIGHBD_MBFP_WRAPPER(4, 16, 12)
+#if CONFIG_BLOCK_256
+ HIGHBD_OBFP_WRAPPER(256, 256, 12)
+ HIGHBD_OBFP_WRAPPER(256, 128, 12)
+ HIGHBD_OBFP_WRAPPER(128, 256, 12)
+#endif // CONFIG_BLOCK_128
HIGHBD_OBFP_WRAPPER(128, 128, 12)
HIGHBD_OBFP_WRAPPER(128, 64, 12)
HIGHBD_OBFP_WRAPPER(64, 128, 12)
@@ -792,6 +879,11 @@
HIGHBD_OBFP_WRAPPER(16, 4, 12)
HIGHBD_OBFP_WRAPPER(4, 16, 12)
+#if CONFIG_BLOCK_256
+ HIGHBD_SDSFP_WRAPPER(256, 256, 12)
+ HIGHBD_SDSFP_WRAPPER(256, 128, 12)
+ HIGHBD_SDSFP_WRAPPER(128, 256, 12)
+#endif // CONFIG_BLOCK_128
HIGHBD_SDSFP_WRAPPER(128, 128, 12);
HIGHBD_SDSFP_WRAPPER(128, 64, 12);
HIGHBD_SDSFP_WRAPPER(64, 128, 12);
@@ -996,6 +1088,54 @@
void av1_save_all_coding_context(AV1_COMP *cpi);
+static AOM_INLINE void av1_set_tile_info(AV1_COMMON *const cm,
+ const TileConfig *const tile_cfg) {
+ const CommonModeInfoParams *const mi_params = &cm->mi_params;
+ CommonTileParams *const tiles = &cm->tiles;
+ int i, start_sb;
+
+ av1_get_tile_limits(cm);
+
+ // configure tile columns
+ if (tile_cfg->tile_width_count == 0 || tile_cfg->tile_height_count == 0) {
+ tiles->uniform_spacing = 1;
+ tiles->log2_cols = AOMMAX(tile_cfg->tile_columns, tiles->min_log2_cols);
+ tiles->log2_cols = AOMMIN(tiles->log2_cols, tiles->max_log2_cols);
+ } else {
+ int mi_cols = ALIGN_POWER_OF_TWO(mi_params->mi_cols, cm->mib_size_log2);
+ int sb_cols = mi_cols >> cm->mib_size_log2;
+ int size_sb, j = 0;
+ tiles->uniform_spacing = 0;
+ for (i = 0, start_sb = 0; start_sb < sb_cols && i < MAX_TILE_COLS; i++) {
+ tiles->col_start_sb[i] = start_sb;
+ size_sb = tile_cfg->tile_widths[j++];
+ if (j >= tile_cfg->tile_width_count) j = 0;
+ start_sb += AOMMIN(size_sb, tiles->max_width_sb);
+ }
+ tiles->cols = i;
+ tiles->col_start_sb[i] = sb_cols;
+ }
+ av1_calculate_tile_cols(cm, mi_params->mi_rows, mi_params->mi_cols, tiles);
+
+ // configure tile rows
+ if (tiles->uniform_spacing) {
+ tiles->log2_rows = AOMMAX(tile_cfg->tile_rows, tiles->min_log2_rows);
+ tiles->log2_rows = AOMMIN(tiles->log2_rows, tiles->max_log2_rows);
+ } else {
+ int mi_rows = ALIGN_POWER_OF_TWO(mi_params->mi_rows, cm->mib_size_log2);
+ int sb_rows = mi_rows >> cm->mib_size_log2;
+ int size_sb, j = 0;
+ for (i = 0, start_sb = 0; start_sb < sb_rows && i < MAX_TILE_ROWS; i++) {
+ tiles->row_start_sb[i] = start_sb;
+ size_sb = tile_cfg->tile_heights[j++];
+ if (j >= tile_cfg->tile_height_count) j = 0;
+ start_sb += AOMMIN(size_sb, tiles->max_height_sb);
+ }
+ tiles->rows = i;
+ tiles->row_start_sb[i] = sb_rows;
+ }
+ av1_calculate_tile_rows(cm, mi_params->mi_rows, tiles);
+}
#ifdef __cplusplus
} // extern "C"
#endif
diff --git a/av1/encoder/encodetxb.c b/av1/encoder/encodetxb.c
index b841090..0a14dff 100644
--- a/av1/encoder/encodetxb.c
+++ b/av1/encoder/encodetxb.c
@@ -96,8 +96,11 @@
void av1_alloc_txb_buf(AV1_COMP *cpi) {
AV1_COMMON *cm = &cpi->common;
- int size = ((cm->mi_params.mi_rows >> cm->seq_params.mib_size_log2) + 1) *
- ((cm->mi_params.mi_cols >> cm->seq_params.mib_size_log2) + 1);
+ // We use the frame level sb size here instead of the seq level sb size. This
+ // is because fr_sb_size <= seq_sb_size, and we want to avoid repeated
+ // allocations. So we prefer to to allocate a larger memory in one go here.
+ int size = ((cm->mi_params.mi_rows >> cm->mib_size_log2) + 1) *
+ ((cm->mi_params.mi_cols >> cm->mib_size_log2) + 1);
av1_free_txb_buf(cpi);
// TODO(jingning): This should be further reduced.
@@ -4760,7 +4763,7 @@
CB_COEFF_BUFFER *av1_get_cb_coeff_buffer(const struct AV1_COMP *cpi, int mi_row,
int mi_col) {
const AV1_COMMON *const cm = &cpi->common;
- const int mib_size_log2 = cm->seq_params.mib_size_log2;
+ const int mib_size_log2 = cm->mib_size_log2;
const int stride = (cm->mi_params.mi_cols >> mib_size_log2) + 1;
const int offset =
(mi_row >> mib_size_log2) * stride + (mi_col >> mib_size_log2);
diff --git a/av1/encoder/ethread.c b/av1/encoder/ethread.c
index f606924..a1d0de8 100644
--- a/av1/encoder/ethread.c
+++ b/av1/encoder/ethread.c
@@ -50,7 +50,7 @@
static AOM_INLINE void update_delta_lf_for_row_mt(AV1_COMP *cpi) {
AV1_COMMON *cm = &cpi->common;
MACROBLOCKD *xd = &cpi->td.mb.e_mbd;
- const int mib_size = cm->seq_params.mib_size;
+ const int mib_size = cm->mib_size;
const int frame_lf_count =
av1_num_planes(cm) > 1 ? FRAME_LF_COUNT : FRAME_LF_COUNT - 2;
for (int row = 0; row < cm->tiles.rows; row++) {
@@ -67,8 +67,7 @@
MB_MODE_INFO **mi = cm->mi_params.mi_grid_base + idx_str;
MB_MODE_INFO *mbmi = mi[0];
if (mbmi->skip_txfm[xd->tree_type == CHROMA_PART] == 1 &&
- (mbmi->sb_type[xd->tree_type == CHROMA_PART] ==
- cm->seq_params.sb_size)) {
+ (mbmi->sb_type[xd->tree_type == CHROMA_PART] == cm->sb_size)) {
for (int lf_id = 0; lf_id < frame_lf_count; ++lf_id)
mbmi->delta_lf[lf_id] = xd->delta_lf[lf_id];
mbmi->delta_lf_from_base = xd->delta_lf_from_base;
@@ -351,7 +350,7 @@
// which will be the least processed tile.
*cur_tile_id = tile_id;
get_next_job(&tile_data[tile_id], current_mi_row,
- is_firstpass ? FP_MIB_SIZE : cm->seq_params.mib_size);
+ is_firstpass ? FP_MIB_SIZE : cm->mib_size);
}
}
@@ -428,7 +427,7 @@
pthread_mutex_lock(enc_row_mt_mutex_);
#endif
if (!get_next_job(&cpi->tile_data[cur_tile_id], ¤t_mi_row,
- cm->seq_params.mib_size)) {
+ cm->mib_size)) {
// No jobs are available for the current tile. Query for the status of
// other tiles and get the next job if available
switch_tile_and_get_next_job(cm, cpi->tile_data, &cur_tile_id,
@@ -553,6 +552,7 @@
thread_data->thread_id = i;
if (i > 0) {
+ thread_data->td->sb_size = cpi->td.sb_size;
// Set up sms_tree.
av1_setup_sms_tree(cpi, thread_data->td);
#if CONFIG_EXT_RECUR_PARTITIONS
@@ -788,6 +788,10 @@
if (thread_data->td->counts != &cpi->counts) {
memcpy(thread_data->td->counts, &cpi->counts, sizeof(cpi->counts));
}
+ if (thread_data->td->sb_size != cpi->common.sb_size) {
+ av1_free_sms_tree(thread_data->td);
+ av1_setup_sms_tree(cpi, thread_data->td);
+ }
if (i > 0) {
thread_data->td->mb.palette_buffer = thread_data->td->palette_buffer;
diff --git a/av1/encoder/hash.h b/av1/encoder/hash.h
index 143947a..a06a149 100644
--- a/av1/encoder/hash.h
+++ b/av1/encoder/hash.h
@@ -45,7 +45,7 @@
// init table for software version crc32c
void av1_crc32c_calculator_init(CRC32C *p_crc32c);
-#define AOM_BUFFER_SIZE_FOR_BLOCK_HASH (4096)
+#define AOM_BUFFER_SIZE_FOR_BLOCK_HASH (1 << (2 * (MAX_SB_SIZE_LOG2 - 1)))
#ifdef __cplusplus
} // extern "C"
diff --git a/av1/encoder/hash_motion.c b/av1/encoder/hash_motion.c
index 1d501c5..879c4fe 100644
--- a/av1/encoder/hash_motion.c
+++ b/av1/encoder/hash_motion.c
@@ -50,7 +50,7 @@
}
// the hash value (hash_value1 consists two parts, the first 3 bits relate to
-// the block size and the remaining 16 bits are the crc values. This fuction
+// the block size and the remaining 16 bits are the crc values. This function
// is used to get the first 3 bits.
static int hash_block_size_to_index(int block_size) {
switch (block_size) {
@@ -60,6 +60,9 @@
case 32: return 3;
case 64: return 4;
case 128: return 5;
+#if CONFIG_BLOCK_256
+ case 256: return 6;
+#endif // CONFIG_BLOCK_256
default: return -1;
}
}
diff --git a/av1/encoder/mcomp.c b/av1/encoder/mcomp.c
index dd5ab29..6ab4fcb 100644
--- a/av1/encoder/mcomp.c
+++ b/av1/encoder/mcomp.c
@@ -147,12 +147,18 @@
init_ms_buffers(&ms_params->ms_buffers, x);
SEARCH_METHODS search_method = mv_sf->search_method;
+ const int min_dim = AOMMIN(block_size_wide[bsize], block_size_high[bsize]);
if (mv_sf->use_bsize_dependent_search_method) {
- const int min_dim = AOMMIN(block_size_wide[bsize], block_size_high[bsize]);
if (min_dim >= 32) {
search_method = get_faster_search_method(search_method);
}
}
+#if CONFIG_BLOCK_256
+ const int max_dim = AOMMAX(block_size_wide[bsize], block_size_high[bsize]);
+ if (cpi->sf.mv_sf.fast_motion_estimation_on_block_256 && max_dim >= 256) {
+ search_method = get_faster_search_method(search_method);
+ }
+#endif // CONFIG_BLOCK_256
#if CONFIG_FLEX_MVRES
// MV search of flex MV precision is supported only for NSTEP or DIAMOND
// search
@@ -307,6 +313,13 @@
ms_params->var_params.subpel_search_type =
cpi->sf.mv_sf.use_accurate_subpel_search;
#endif
+#if CONFIG_BLOCK_256
+ if (cpi->sf.mv_sf.fast_motion_estimation_on_block_256 &&
+ AOMMAX(block_size_wide[bsize], block_size_high[bsize]) >= 256) {
+ ms_params->var_params.subpel_search_type =
+ AOMMIN(ms_params->var_params.subpel_search_type, USE_2_TAPS);
+ }
+#endif // CONFIG_BLOCK_256
ms_params->var_params.w = block_size_wide[bsize];
ms_params->var_params.h = block_size_high[bsize];
@@ -2738,8 +2751,13 @@
// Should we allow a follow on exhaustive search?
if (!run_mesh_search && search_method == NSTEP) {
int exhaustive_thr = ms_params->force_mesh_thresh;
- exhaustive_thr >>=
+ const int right_shift =
10 - (mi_size_wide_log2[bsize] + mi_size_high_log2[bsize]);
+ if (right_shift >= 0) {
+ exhaustive_thr >>= right_shift;
+ } else {
+ exhaustive_thr <<= (-right_shift);
+ }
// Threshold variance for an exhaustive full search.
if (var > exhaustive_thr) run_mesh_search = 1;
}
@@ -2855,7 +2873,7 @@
const FullMvLimits *mv_limits = &ms_params->mv_limits;
const MV *dv = ms_params->mv_cost_params.ref_mv;
if (!av1_is_dv_valid(*dv, &cpi->common, xd, mi_row, mi_col, bsize,
- cpi->common.seq_params.mib_size_log2))
+ cpi->common.mib_size_log2))
return INT_MAX;
FULLPEL_MV cur_mv = get_fullmv_from_mv(dv);
@@ -2890,7 +2908,7 @@
const TileInfo *const tile = &fullms_params->xd->tile;
const AV1_COMMON *cm = fullms_params->cm;
const int mi_row = fullms_params->mi_row;
- av1_find_ref_dv(cur_ref_bv, tile, cm->seq_params.mib_size, mi_row);
+ av1_find_ref_dv(cur_ref_bv, tile, cm->mib_size, mi_row);
}
// Ref DV should not have sub-pel.
assert((cur_ref_bv->as_mv.col & 7) == 0);
@@ -3041,7 +3059,7 @@
const MV dv = { GET_MV_SUBPEL(ref_block_hash.y - y_pos),
GET_MV_SUBPEL(ref_block_hash.x - x_pos) };
if (!av1_is_dv_valid(dv, &cpi->common, xd, mi_row, mi_col, bsize,
- cpi->common.seq_params.mib_size_log2))
+ cpi->common.mib_size_log2))
continue;
FULLPEL_MV hash_mv;
diff --git a/av1/encoder/motion_search_facade.c b/av1/encoder/motion_search_facade.c
index 891fa86..b6481a4 100644
--- a/av1/encoder/motion_search_facade.c
+++ b/av1/encoder/motion_search_facade.c
@@ -163,8 +163,8 @@
const int nh = mi_size_high[bsize] / tplh;
if (nw >= 1 && nh >= 1) {
- const int of_h = mi_row % mi_size_high[cm->seq_params.sb_size];
- const int of_w = mi_col % mi_size_wide[cm->seq_params.sb_size];
+ const int of_h = mi_row % mi_size_high[cm->sb_size];
+ const int of_w = mi_col % mi_size_wide[cm->sb_size];
const int start = of_h / tplh * sb_enc->tpl_stride + of_w / tplw;
int valid = 1;
diff --git a/av1/encoder/mv_prec.c b/av1/encoder/mv_prec.c
index 3746342..2b0f175 100644
--- a/av1/encoder/mv_prec.c
+++ b/av1/encoder/mv_prec.c
@@ -682,15 +682,16 @@
collect_mv_stats_b(mv_stats, cpi, mi_row, mi_col + hbs_w);
#endif // CONFIG_EXT_RECUR_PARTITIONS
break;
-#if !CONFIG_EXT_RECUR_PARTITIONS
case PARTITION_SPLIT:
- collect_mv_stats_sb(mv_stats, cpi, mi_row, mi_col, subsize);
- collect_mv_stats_sb(mv_stats, cpi, mi_row, mi_col + hbs_w, subsize);
- collect_mv_stats_sb(mv_stats, cpi, mi_row + hbs_h, mi_col, subsize);
+ collect_mv_stats_sb(mv_stats, cpi, mi_row, mi_col, subsize,
+ ptree->sub_tree[0]);
+ collect_mv_stats_sb(mv_stats, cpi, mi_row, mi_col + hbs_w, subsize,
+ ptree->sub_tree[1]);
+ collect_mv_stats_sb(mv_stats, cpi, mi_row + hbs_h, mi_col, subsize,
+ ptree->sub_tree[2]);
collect_mv_stats_sb(mv_stats, cpi, mi_row + hbs_h, mi_col + hbs_w,
- subsize);
+ subsize, ptree->sub_tree[3]);
break;
-#endif // !CONFIG_EXT_RECUR_PARTITIONS
#if CONFIG_EXT_RECUR_PARTITIONS
#if CONFIG_UNEVEN_4WAY
case PARTITION_HORZ_4A: {
@@ -815,8 +816,8 @@
const int mi_row_end = tile_info->mi_row_end;
const int mi_col_start = tile_info->mi_col_start;
const int mi_col_end = tile_info->mi_col_end;
- const int sb_size_mi = cm->seq_params.mib_size;
- BLOCK_SIZE sb_size = cm->seq_params.sb_size;
+ const int sb_size_mi = cm->mib_size;
+ BLOCK_SIZE sb_size = cm->sb_size;
for (int mi_row = mi_row_start; mi_row < mi_row_end; mi_row += sb_size_mi) {
for (int mi_col = mi_col_start; mi_col < mi_col_end; mi_col += sb_size_mi) {
#if CONFIG_EXT_RECUR_PARTITIONS
diff --git a/av1/encoder/partition_search.c b/av1/encoder/partition_search.c
index 8758d6b..75de5fa 100644
--- a/av1/encoder/partition_search.c
+++ b/av1/encoder/partition_search.c
@@ -613,7 +613,7 @@
}
}
- av1_mark_block_as_coded(xd, bsize, cm->seq_params.sb_size);
+ av1_mark_block_as_coded(xd, bsize, cm->sb_size);
}
void setup_block_rdmult(const AV1_COMP *const cpi, MACROBLOCK *const x,
@@ -1251,12 +1251,11 @@
#if CONFIG_ENTROPY_STATS
// delta quant applies to both intra and inter
- const int super_block_upper_left =
- ((xd->mi_row & (cm->seq_params.mib_size - 1)) == 0) &&
- ((xd->mi_col & (cm->seq_params.mib_size - 1)) == 0);
+ const int super_block_upper_left = ((xd->mi_row & (cm->mib_size - 1)) == 0) &&
+ ((xd->mi_col & (cm->mib_size - 1)) == 0);
const DeltaQInfo *const delta_q_info = &cm->delta_q_info;
if (delta_q_info->delta_q_present_flag &&
- (bsize != cm->seq_params.sb_size ||
+ (bsize != cm->sb_size ||
!mbmi->skip_txfm[xd->tree_type == CHROMA_PART]) &&
super_block_upper_left) {
const int dq = (mbmi->current_qindex - xd->current_base_qindex) /
@@ -2034,7 +2033,7 @@
for (int plane = plane_start; plane < plane_end; plane++) {
x->mbmi_ext_frame->cb_offset[plane] = x->cb_offset[plane];
assert(x->cb_offset[plane] <
- (1 << num_pels_log2_lookup[cpi->common.seq_params.sb_size]));
+ (1 << num_pels_log2_lookup[cpi->common.sb_size]));
}
#if CONFIG_PC_WIENER
av1_init_txk_skip_array(&cpi->common, mi_row, mi_col, bsize, 0,
@@ -2056,7 +2055,7 @@
block_size_wide[bsize_base] * block_size_high[bsize_base];
}
}
- if (bsize == cpi->common.seq_params.sb_size &&
+ if (bsize == cpi->common.sb_size &&
mbmi->skip_txfm[xd->tree_type == CHROMA_PART] == 1 &&
cm->delta_q_info.delta_lf_present_flag) {
const int frame_lf_count =
@@ -2073,12 +2072,11 @@
}
// delta quant applies to both intra and inter
- const int super_block_upper_left =
- ((mi_row & (cm->seq_params.mib_size - 1)) == 0) &&
- ((mi_col & (cm->seq_params.mib_size - 1)) == 0);
+ const int super_block_upper_left = ((mi_row & (cm->mib_size - 1)) == 0) &&
+ ((mi_col & (cm->mib_size - 1)) == 0);
const DeltaQInfo *const delta_q_info = &cm->delta_q_info;
if (delta_q_info->delta_q_present_flag &&
- (bsize != cm->seq_params.sb_size ||
+ (bsize != cm->sb_size ||
!mbmi->skip_txfm[xd->tree_type == CHROMA_PART]) &&
super_block_upper_left) {
xd->current_base_qindex = mbmi->current_qindex;
@@ -2243,36 +2241,25 @@
#endif // CONFIG_EXT_RECUR_PARTITIONS
PARTITION_TYPE partition, const int mi_row,
const int mi_col, BLOCK_SIZE bsize,
- const int ctx) {
- const int plane_index = xd->tree_type == CHROMA_PART;
+ const int ctx, BLOCK_SIZE sb_size) {
+#if !CONFIG_BLOCK_256
+ (void)sb_size;
+#endif // !CONFIG_BLOCK_256
+ const TREE_TYPE tree_type = xd->tree_type;
+ const int plane_index = tree_type == CHROMA_PART;
FRAME_CONTEXT *fc = xd->tile_ctx;
#if CONFIG_EXT_RECUR_PARTITIONS
- if (!is_partition_point(bsize)) {
- return;
- }
- if (xd->tree_type == CHROMA_PART && bsize == BLOCK_8X8) {
- return;
- }
+ const bool ss_x = xd->plane[1].subsampling_x;
+ const bool ss_y = xd->plane[1].subsampling_y;
- const int ss_x = xd->plane[1].subsampling_x;
- const int ss_y = xd->plane[1].subsampling_y;
- if (is_luma_chroma_share_same_partition(xd->tree_type, ptree_luma, bsize)) {
- PARTITION_TYPE derived_partition_mode =
- sdp_chroma_part_from_luma(bsize, ptree_luma->partition, ss_x, ss_y);
- assert(partition == derived_partition_mode &&
- "Chroma partition does not match the derived mode.");
- (void)derived_partition_mode;
- return;
- }
-
- PARTITION_TYPE implied_partition;
- const bool is_part_implied = is_partition_implied_at_boundary(
- mi_params, xd->tree_type, ss_x, ss_y, mi_row, mi_col, bsize,
- chroma_ref_info, &implied_partition);
- if (is_part_implied) {
- assert(partition == implied_partition &&
- "Partition doesn't match the implied partition at boundary.");
+ const PARTITION_TYPE derived_partition =
+ av1_get_normative_forced_partition_type(mi_params, tree_type, ss_x, ss_y,
+ mi_row, mi_col, bsize, ptree_luma,
+ chroma_ref_info);
+ if (derived_partition != PARTITION_INVALID) {
+ assert(partition == derived_partition &&
+ "Partition does not match normatively derived partition.");
return;
}
@@ -2286,16 +2273,34 @@
if (!do_split) {
return;
}
+
+#if CONFIG_BLOCK_256
+ const bool do_square_split = partition == PARTITION_SPLIT;
+ if (is_square_split_eligible(bsize, sb_size)) {
+ const int square_split_ctx =
+ square_split_context(xd, mi_row, mi_col, bsize);
+#if CONFIG_ENTROPY_STATS
+ counts->do_sqaure_split[plane_index][square_split_ctx][do_square_split]++;
+#endif // CONFIG_ENTROPY_STATS
+ update_cdf(fc->do_square_split_cdf[plane_index][square_split_ctx],
+ do_square_split, 2);
+ }
+ if (do_square_split) {
+ return;
+ }
+#endif // CONFIG_BLOCK_256
+
RECT_PART_TYPE rect_type = get_rect_part_type(partition);
- if (rect_type_implied_by_bsize(bsize, xd->tree_type) == RECT_INVALID) {
+ if (rect_type_implied_by_bsize(bsize, tree_type) == RECT_INVALID) {
#if CONFIG_ENTROPY_STATS
counts->rect_type[plane_index][ctx][rect_type]++;
#endif // CONFIG_ENTROPY_STATS
update_cdf(fc->rect_type_cdf[plane_index][ctx], rect_type, 2);
}
+
const bool ext_partition_allowed =
!disable_ext_part &&
- is_ext_partition_allowed(bsize, rect_type, xd->tree_type);
+ is_ext_partition_allowed(bsize, rect_type, tree_type);
if (ext_partition_allowed) {
const bool do_ext_partition = (partition >= PARTITION_HORZ_3);
#if CONFIG_ENTROPY_STATS
@@ -2306,7 +2311,7 @@
#if CONFIG_UNEVEN_4WAY
if (do_ext_partition) {
const bool uneven_4way_partition_allowed =
- is_uneven_4way_partition_allowed(bsize, rect_type, xd->tree_type);
+ is_uneven_4way_partition_allowed(bsize, rect_type, tree_type);
if (uneven_4way_partition_allowed) {
const bool do_uneven_4way_partition = (partition >= PARTITION_HORZ_4A);
#if CONFIG_ENTROPY_STATS
@@ -2341,8 +2346,7 @@
if (has_rows && has_cols) {
int luma_split_flag = 0;
int parent_block_width = block_size_wide[bsize];
- if (xd->tree_type == CHROMA_PART &&
- parent_block_width >= SHARED_PART_SIZE) {
+ if (tree_type == CHROMA_PART && parent_block_width >= SHARED_PART_SIZE) {
luma_split_flag = get_luma_split_flag(bsize, mi_params, mi_row, mi_col);
}
if (luma_split_flag <= 3) {
@@ -2397,7 +2401,7 @@
TileDataEnc *tile_data, TokenExtra **tp, int mi_row,
int mi_col, RUN_TYPE dry_run, BLOCK_SIZE bsize,
const PC_TREE *pc_tree, PARTITION_TREE *ptree,
- PARTITION_TREE *ptree_luma, int *rate) {
+ const PARTITION_TREE *ptree_luma, int *rate) {
#else
/*!\brief Reconstructs a partition (may contain multiple coding blocks)
*
@@ -2468,9 +2472,6 @@
#endif // !CONFIG_EXT_RECUR_PARTITIONS
if (subsize == BLOCK_INVALID) return;
-#if CONFIG_EXT_RECUR_PARTITIONS
- assert(partition != PARTITION_SPLIT);
-#endif // CONFIG_EXT_RECUR_PARTITIONS
if (!dry_run && ctx >= 0)
update_partition_stats(xd,
@@ -2482,7 +2483,7 @@
disable_ext_part, ptree_luma,
&pc_tree->chroma_ref_info,
#endif // CONFIG_EXT_RECUR_PARTITIONS
- partition, mi_row, mi_col, bsize, ctx);
+ partition, mi_row, mi_col, bsize, ctx, cm->sb_size);
PARTITION_TREE *sub_tree[4] = { NULL, NULL, NULL, NULL };
#if CONFIG_EXT_RECUR_PARTITIONS
@@ -2543,8 +2544,15 @@
const int track_ptree_luma =
is_luma_chroma_share_same_partition(xd->tree_type, ptree_luma, bsize);
- if (track_ptree_luma && partition != PARTITION_NONE) {
- assert(ptree_luma);
+ if (track_ptree_luma) {
+ assert(partition ==
+ sdp_chroma_part_from_luma(bsize, ptree_luma->partition,
+ cm->seq_params.subsampling_x,
+ cm->seq_params.subsampling_x));
+ if (partition != PARTITION_NONE) {
+ assert(ptree_luma);
+ assert(ptree_luma->sub_tree);
+ }
}
#endif // CONFIG_EXT_RECUR_PARTITIONS
switch (partition) {
@@ -2705,6 +2713,20 @@
}
break;
}
+ case PARTITION_SPLIT:
+ encode_sb(cpi, td, tile_data, tp, mi_row, mi_col, dry_run, subsize,
+ pc_tree->split[0], sub_tree[0],
+ track_ptree_luma ? ptree_luma->sub_tree[0] : NULL, rate);
+ encode_sb(cpi, td, tile_data, tp, mi_row, mi_col + hbs_w, dry_run,
+ subsize, pc_tree->split[1], sub_tree[1],
+ track_ptree_luma ? ptree_luma->sub_tree[1] : NULL, rate);
+ encode_sb(cpi, td, tile_data, tp, mi_row + hbs_h, mi_col, dry_run,
+ subsize, pc_tree->split[2], sub_tree[2],
+ track_ptree_luma ? ptree_luma->sub_tree[2] : NULL, rate);
+ encode_sb(cpi, td, tile_data, tp, mi_row + hbs_h, mi_col + hbs_w, dry_run,
+ subsize, pc_tree->split[3], sub_tree[3],
+ track_ptree_luma ? ptree_luma->sub_tree[3] : NULL, rate);
+ break;
#else // CONFIG_EXT_RECUR_PARTITIONS
case PARTITION_SPLIT:
encode_sb(cpi, td, tile_data, tp, mi_row, mi_col, dry_run, subsize,
@@ -2829,18 +2851,36 @@
first_partition = PARTITION_VERT;
}
assert(first_partition != PARTITION_INVALID);
- const PARTITION_TYPE second_partition =
- (first_partition == PARTITION_HORZ) ? PARTITION_VERT : PARTITION_HORZ;
+ const BLOCK_SIZE subsize = subsize_lookup[PARTITION_SPLIT][bsize];
const int hbs_w = mi_size_wide[bsize] >> 1;
const int hbs_h = mi_size_high[bsize] >> 1;
- const BLOCK_SIZE subsize = subsize_lookup[PARTITION_SPLIT][bsize];
-
ptree->partition = first_partition;
+
+ if (first_partition == PARTITION_SPLIT) {
+ ptree->partition = first_partition;
+ ptree->sub_tree[0] = av1_alloc_ptree_node(ptree, 0);
+ ptree->sub_tree[1] = av1_alloc_ptree_node(ptree, 1);
+ ptree->sub_tree[2] = av1_alloc_ptree_node(ptree, 2);
+ ptree->sub_tree[3] = av1_alloc_ptree_node(ptree, 3);
+ build_one_split_tree(cm, tree_type, mi_row, mi_col, subsize, final_bsize,
+ ptree->sub_tree[0]);
+ build_one_split_tree(cm, tree_type, mi_row, mi_col + hbs_w, subsize,
+ final_bsize, ptree->sub_tree[1]);
+ build_one_split_tree(cm, tree_type, mi_row + hbs_h, mi_col, subsize,
+ final_bsize, ptree->sub_tree[2]);
+ build_one_split_tree(cm, tree_type, mi_row + hbs_h, mi_col + hbs_w, subsize,
+ final_bsize, ptree->sub_tree[3]);
+ return;
+ }
+
ptree->sub_tree[0] = av1_alloc_ptree_node(ptree, 0);
ptree->sub_tree[1] = av1_alloc_ptree_node(ptree, 1);
+ const PARTITION_TYPE second_partition =
+ (first_partition == PARTITION_HORZ) ? PARTITION_VERT : PARTITION_HORZ;
+
#ifndef NDEBUG
// Boundary sanity checks for 2nd partitions.
{
@@ -2905,7 +2945,7 @@
int mi_row, int mi_col,
BLOCK_SIZE bsize,
PARTITION_TREE *ptree) {
- const BLOCK_SIZE sb_size = cm->seq_params.sb_size;
+ const BLOCK_SIZE sb_size = cm->sb_size;
build_one_split_tree(cm, tree_type, mi_row, mi_col, sb_size, bsize, ptree);
}
@@ -2918,13 +2958,14 @@
if (ptree) {
#ifndef NDEBUG
#if CONFIG_EXT_RECUR_PARTITIONS
- const bool ssx = cm->cur_frame->buf.subsampling_x;
- const bool ssy = cm->cur_frame->buf.subsampling_y;
- PARTITION_TYPE implied_partition;
- const bool is_part_implied = is_partition_implied_at_boundary(
- &cm->mi_params, tree_type, ssx, ssy, mi_row, mi_col, bsize,
- &ptree->chroma_ref_info, &implied_partition);
- assert(IMPLIES(is_part_implied, ptree->partition == implied_partition));
+ const bool ss_x = cm->cur_frame->buf.subsampling_x;
+ const bool ss_y = cm->cur_frame->buf.subsampling_y;
+ const PARTITION_TYPE derived_partition =
+ av1_get_normative_forced_partition_type(
+ &cm->mi_params, tree_type, ss_x, ss_y, mi_row, mi_col, bsize,
+ /* ptree_luma= */ NULL, &ptree->chroma_ref_info);
+ assert(IMPLIES(derived_partition != PARTITION_INVALID,
+ ptree->partition == derived_partition));
#endif // CONFIG_EXT_RECUR_PARTITIONS
#endif // NDEBUG
return ptree->partition;
@@ -3159,6 +3200,37 @@
}
break;
#if CONFIG_EXT_RECUR_PARTITIONS
+ case PARTITION_SPLIT:
+ last_part_rdc.rate = 0;
+ last_part_rdc.dist = 0;
+ last_part_rdc.rdcost = 0;
+ for (int i = 0; i < SUB_PARTITIONS_SPLIT; i++) {
+ int x_idx = (i & 1) * hbs;
+ int y_idx = (i >> 1) * hbs;
+ int jj = i >> 1, ii = i & 0x01;
+ RD_STATS tmp_rdc;
+ if ((mi_row + y_idx >= mi_params->mi_rows) ||
+ (mi_col + x_idx >= mi_params->mi_cols))
+ continue;
+ pc_tree->split[i] = av1_alloc_pc_tree_node(
+ xd->tree_type, mi_row + y_idx, mi_col + x_idx, subsize, pc_tree,
+ PARTITION_SPLIT, i, i == 3, ss_x, ss_y);
+
+ av1_init_rd_stats(&tmp_rdc);
+ av1_rd_use_partition(
+ cpi, td, tile_data,
+ mib + jj * hbs * mi_params->mi_stride + ii * hbs, tp,
+ mi_row + y_idx, mi_col + x_idx, subsize, &tmp_rdc.rate,
+ &tmp_rdc.dist, i != (SUB_PARTITIONS_SPLIT - 1),
+ ptree ? ptree->sub_tree[1] : NULL, pc_tree->split[i]);
+ if (tmp_rdc.rate == INT_MAX || tmp_rdc.dist == INT64_MAX) {
+ av1_invalid_rd_stats(&last_part_rdc);
+ break;
+ }
+ last_part_rdc.rate += tmp_rdc.rate;
+ last_part_rdc.dist += tmp_rdc.dist;
+ }
+ break;
#if CONFIG_UNEVEN_4WAY
case PARTITION_HORZ_4A:
case PARTITION_HORZ_4B:
@@ -3222,11 +3294,11 @@
// We must have chosen a partitioning and encoding or we'll fail later on.
// No other opportunities for success.
- if (bsize == cm->seq_params.sb_size)
+ if (bsize == cm->sb_size)
assert(last_part_rdc.rate < INT_MAX && last_part_rdc.dist < INT64_MAX);
if (do_recon) {
- if (bsize == cm->seq_params.sb_size) {
+ if (bsize == cm->sb_size) {
// NOTE: To get estimate for rate due to the tokens, use:
// int rate_coeffs = 0;
// encode_sb(cpi, td, tile_data, tp, mi_row, mi_col, DRY_RUN_COSTCOEFFS,
@@ -3397,29 +3469,25 @@
BLOCK_SIZE bsize, const PARTITION_TREE *ptree_luma,
const PARTITION_TREE *template_tree,
const CHROMA_REF_INFO *chroma_ref_info) {
- const MACROBLOCKD *const xd = &x->e_mbd;
- const int ss_x = cm->seq_params.subsampling_x;
- const int ss_y = cm->seq_params.subsampling_y;
-
// Partition types forced by bitstream syntax.
- if (is_luma_chroma_share_same_partition(xd->tree_type, ptree_luma, bsize)) {
- return sdp_chroma_part_from_luma(bsize, ptree_luma->partition, ss_x, ss_y);
+ const MACROBLOCKD *xd = &x->e_mbd;
+ const bool ss_x = cm->seq_params.subsampling_x;
+ const bool ss_y = cm->seq_params.subsampling_y;
+ const PARTITION_TYPE derived_partition =
+ av1_get_normative_forced_partition_type(&cm->mi_params, xd->tree_type,
+ ss_x, ss_y, mi_row, mi_col, bsize,
+ ptree_luma, chroma_ref_info);
+ if (derived_partition != PARTITION_INVALID) {
+ return derived_partition;
}
- PARTITION_TYPE implied_partition;
- const bool is_part_implied = is_partition_implied_at_boundary(
- &cm->mi_params, xd->tree_type, ss_x, ss_y, mi_row, mi_col, bsize,
- chroma_ref_info, &implied_partition);
- if (is_part_implied) return implied_partition;
-
// Partition types forced by speed_features.
if (template_tree) {
return template_tree->partition;
}
if (should_reuse_mode(x, REUSE_PARTITION_MODE_FLAG)) {
- return av1_get_prev_partition(x, mi_row, mi_col, bsize,
- cm->seq_params.sb_size);
+ return av1_get_prev_partition(x, mi_row, mi_col, bsize, cm->sb_size);
}
return PARTITION_INVALID;
}
@@ -3531,6 +3599,8 @@
// than the bound best_rdc has been found.
part_search_state->found_best_partition = false;
}
+
+static const int kZeroPartitionCosts[ALL_PARTITION_TYPES];
#endif // CONFIG_EXT_RECUR_PARTITIONS
// Initialize state variables of partition search used in
// av1_rd_pick_partition().
@@ -3545,6 +3615,7 @@
const AV1_COMMON *const cm = &cpi->common;
PartitionBlkParams *blk_params = &part_search_state->part_blk_params;
const CommonModeInfoParams *const mi_params = &cpi->common.mi_params;
+ const TREE_TYPE tree_type = xd->tree_type;
assert(bsize < BLOCK_SIZES_ALL);
@@ -3577,6 +3648,10 @@
#endif // !CONFIG_EXT_RECUR_PARTITIONS
blk_params->bsize = bsize;
+ // Chroma subsampling.
+ part_search_state->ss_x = x->e_mbd.plane[1].subsampling_x;
+ part_search_state->ss_y = x->e_mbd.plane[1].subsampling_y;
+
// Check if the partition corresponds to edge block.
blk_params->has_rows = (blk_params->mi_row_edge < mi_params->mi_rows);
blk_params->has_cols = (blk_params->mi_col_edge < mi_params->mi_cols);
@@ -3607,8 +3682,16 @@
// Partition cost buffer update
ModeCosts *mode_costs = &x->mode_costs;
part_search_state->partition_cost =
- mode_costs->partition_cost[xd->tree_type == CHROMA_PART]
+ mode_costs->partition_cost[tree_type == CHROMA_PART]
[part_search_state->pl_ctx_idx];
+#if CONFIG_EXT_RECUR_PARTITIONS
+ if (av1_get_normative_forced_partition_type(
+ mi_params, tree_type, part_search_state->ss_x,
+ part_search_state->ss_y, mi_row, mi_col, bsize, ptree_luma,
+ &pc_tree->chroma_ref_info) != PARTITION_INVALID) {
+ part_search_state->partition_cost = kZeroPartitionCosts;
+ }
+#endif // CONFIG_EXT_RECUR_PARTITIONS
// Initialize HORZ and VERT win flags as true for all split partitions.
for (int i = 0; i < SUB_PARTITIONS_SPLIT; i++) {
@@ -3629,10 +3712,6 @@
// Initialize HORZ and VERT partitions to be not ready.
av1_zero(part_search_state->is_rect_ctx_is_ready);
- // Chroma subsampling.
- part_search_state->ss_x = x->e_mbd.plane[1].subsampling_x;
- part_search_state->ss_y = x->e_mbd.plane[1].subsampling_y;
-
// Initialize partition search flags to defaults.
part_search_state->terminate_partition_search = 0;
@@ -3652,7 +3731,7 @@
template_tree, &pc_tree->chroma_ref_info);
init_allowed_partitions(part_search_state, &cpi->oxcf.part_cfg,
- &pc_tree->chroma_ref_info, xd->tree_type);
+ &pc_tree->chroma_ref_info, tree_type);
if (max_recursion_depth == 0) {
part_search_state->prune_rect_part[HORZ] =
@@ -3669,10 +3748,10 @@
#else
part_search_state->do_square_split =
blk_params->bsize_at_least_8x8 &&
- (xd->tree_type != CHROMA_PART || bsize > BLOCK_8X8);
+ (tree_type != CHROMA_PART || bsize > BLOCK_8X8);
part_search_state->do_rectangular_split =
cpi->oxcf.part_cfg.enable_rect_partitions &&
- (xd->tree_type != CHROMA_PART || bsize > BLOCK_8X8);
+ (tree_type != CHROMA_PART || bsize > BLOCK_8X8);
const BLOCK_SIZE horz_subsize = get_partition_subsize(bsize, PARTITION_HORZ);
const BLOCK_SIZE vert_subsize = get_partition_subsize(bsize, PARTITION_VERT);
@@ -3685,7 +3764,7 @@
get_plane_block_size(vert_subsize, part_search_state->ss_x,
part_search_state->ss_y) != BLOCK_INVALID;
const bool no_sub_16_chroma_part =
- xd->tree_type != CHROMA_PART ||
+ tree_type != CHROMA_PART ||
(block_size_wide[bsize] > 8 && block_size_high[bsize] > 8);
// Initialize allowed partition types for the partition block.
@@ -3707,27 +3786,11 @@
#endif // CONFIG_EXT_RECUR_PARTITIONS
}
+#if !CONFIG_EXT_RECUR_PARTITIONS
// Override partition cost buffer for the edge blocks.
static void set_partition_cost_for_edge_blk(
AV1_COMMON const *cm, MACROBLOCKD *const xd,
-#if CONFIG_EXT_RECUR_PARTITIONS
- const CHROMA_REF_INFO *chroma_ref_info,
-#endif // CONFIG_EXT_RECUR_PARTITIONS
PartitionSearchState *part_search_state) {
-#if CONFIG_EXT_RECUR_PARTITIONS
- const PartitionBlkParams *blk_params = &part_search_state->part_blk_params;
- const bool is_part_implied = is_partition_implied_at_boundary(
- &cm->mi_params, xd->tree_type, part_search_state->ss_x,
- part_search_state->ss_y, blk_params->mi_row, blk_params->mi_col,
- blk_params->bsize, chroma_ref_info, NULL);
- if (is_part_implied) {
- for (int i = 0; i < PARTITION_TYPES; ++i) {
- part_search_state->tmp_partition_cost[i] = 0;
- }
- part_search_state->partition_cost = part_search_state->tmp_partition_cost;
- }
- (void)xd;
-#else // CONFIG_EXT_RECUR_PARTITIONS
PartitionBlkParams blk_params = part_search_state->part_blk_params;
assert(blk_params.bsize_at_least_8x8 && part_search_state->pl_ctx_idx >= 0);
const int plane = xd->tree_type == CHROMA_PART;
@@ -3756,10 +3819,8 @@
}
// Override the partition cost buffer.
part_search_state->partition_cost = part_search_state->tmp_partition_cost;
-#endif // CONFIG_EXT_RECUR_PARTITIONS
}
-#if !CONFIG_EXT_RECUR_PARTITIONS
// Reset the partition search state flags when
// must_find_valid_partition is equal to 1.
static AOM_INLINE void reset_part_limitations(
@@ -4092,9 +4153,12 @@
blk_params.subsize, pc_tree, partition_type, 1, 1, ss_x, ss_y);
bool both_blocks_skippable = true;
- const bool track_ptree_luma =
- is_luma_chroma_share_same_partition(xd->tree_type, ptree_luma, bsize);
+ const int track_ptree_luma =
+ is_luma_chroma_share_same_partition(x->e_mbd.tree_type, ptree_luma,
+ bsize) &&
+ partition_type ==
+ sdp_chroma_part_from_luma(bsize, ptree_luma->partition, ss_x, ss_y);
rd_pick_rect_partition(
cpi, td, tile_data, tp, x, pc_tree, part_search_state, best_rdc, i,
mi_pos_rect, blk_params.subsize, is_not_edge_block, multi_pass_mode,
@@ -4189,10 +4253,15 @@
#if CONFIG_EXT_RECUR_PARTITIONS
if (sum_rdc->rdcost < INT64_MAX && both_blocks_skippable &&
!frame_is_intra_only(cm)) {
- const int64_t dist_breakout_thr =
- (int64_t)(cpi->sf.part_sf.partition_search_breakout_dist_thr / 4) >>
- ((2 * (MAX_SB_SIZE_LOG2 - 2)) -
+ const int right_shift =
+ ((2 * (BLOCK_128_MI_SIZE_LOG2)) -
(mi_size_wide_log2[bsize] + mi_size_high_log2[bsize]));
+ const int64_t dist_breakout_thr =
+ (right_shift >= 0)
+ ? ((cpi->sf.part_sf.partition_search_breakout_dist_thr / 4) >>
+ right_shift)
+ : ((cpi->sf.part_sf.partition_search_breakout_dist_thr / 4)
+ << (-right_shift));
const int rate_breakout_thr =
(int64_t)25 * cpi->sf.part_sf.partition_search_breakout_rate_thr *
num_pels_log2_lookup[bsize];
@@ -4731,10 +4800,15 @@
}
// Adjust dist breakout threshold according to the partition size.
- const int64_t dist_breakout_thr =
- cpi->sf.part_sf.partition_search_breakout_dist_thr >>
- ((2 * (MAX_SB_SIZE_LOG2 - 2)) -
+ const int right_shift =
+ ((2 * (BLOCK_128_MI_SIZE_LOG2)) -
(mi_size_wide_log2[bsize] + mi_size_high_log2[bsize]));
+ const int64_t dist_breakout_thr =
+ (right_shift >= 0)
+ ? (cpi->sf.part_sf.partition_search_breakout_dist_thr >>
+ right_shift)
+ : (cpi->sf.part_sf.partition_search_breakout_dist_thr
+ << (-right_shift));
const int rate_breakout_thr =
cpi->sf.part_sf.partition_search_breakout_rate_thr *
num_pels_log2_lookup[bsize];
@@ -4887,8 +4961,8 @@
}
#endif
#if CONFIG_EXT_RECUR_PARTITIONS
- SimpleMotionData *sms_data = av1_get_sms_data_entry(
- x->sms_bufs, mi_row, mi_col, bsize, cm->seq_params.sb_size);
+ SimpleMotionData *sms_data =
+ av1_get_sms_data_entry(x->sms_bufs, mi_row, mi_col, bsize, cm->sb_size);
av1_set_best_mode_cache(x, sms_data->mode_cache);
#endif // CONFIG_EXT_RECUR_PARTITIONS
@@ -4925,8 +4999,8 @@
// Record picked ref frame to prune ref frames for other partition types.
if (cpi->sf.inter_sf.prune_ref_frame_for_rect_partitions) {
const int ref_type = av1_ref_frame_type(pc_tree->none->mic.ref_frame);
- av1_update_picked_ref_frames_mask(
- x, ref_type, bsize, cm->seq_params.mib_size, mi_row, mi_col);
+ av1_update_picked_ref_frames_mask(x, ref_type, bsize, cm->mib_size,
+ mi_row, mi_col);
}
// Calculate the total cost and update the best partition.
@@ -4962,7 +5036,6 @@
#endif // CONFIG_MVP_IMPROVEMENT || WARP_CU_BANK
}
-#if !CONFIG_EXT_RECUR_PARTITIONS
// PARTITION_SPLIT search.
static void split_partition_search(
AV1_COMP *const cpi, ThreadData *td, TileDataEnc *tile_data,
@@ -4973,7 +5046,12 @@
#if CONFIG_MVP_IMPROVEMENT || WARP_CU_BANK
,
LevelBanksRDO *level_banks
-#endif // CONFIG_MVP_IMPROVEMENT || WARP_CU_BANK
+#endif // CONFIG_C043_MVP_IMPROVEMENTS
+#if CONFIG_EXT_RECUR_PARTITIONS
+ ,
+ const PARTITION_TREE *ptree_luma, const PARTITION_TREE *template_tree,
+ int max_recursion_depth
+#endif // CONFIG_EXT_RECUR_PARTITIONS
) {
const AV1_COMMON *const cm = &cpi->common;
PartitionBlkParams blk_params = part_search_state->part_blk_params;
@@ -4986,9 +5064,38 @@
const BLOCK_SIZE subsize = get_partition_subsize(bsize, PARTITION_SPLIT);
// Check if partition split is allowed.
+#if CONFIG_EXT_RECUR_PARTITIONS
+ (void)sms_tree;
+ if (part_search_state->terminate_partition_search ||
+ !is_square_split_eligible(bsize, cm->sb_size)) {
+ return;
+ }
+ if (part_search_state->forced_partition != PARTITION_INVALID &&
+ part_search_state->forced_partition != PARTITION_SPLIT) {
+ return;
+ }
+ if (max_recursion_depth < 0) {
+ return;
+ }
+
+ const int num_planes = av1_num_planes(cm);
+ PC_TREE **sub_tree = pc_tree->split;
+ assert(sub_tree);
+ for (int idx = 0; idx < SUB_PARTITIONS_SPLIT; idx++) {
+ if (sub_tree[idx]) {
+ av1_free_pc_tree_recursive(sub_tree[idx], num_planes, 0, 0);
+ sub_tree[idx] = NULL;
+ }
+ }
+
+ const MACROBLOCKD *const xd = &x->e_mbd;
+ const int track_ptree_luma =
+ is_luma_chroma_share_same_partition(xd->tree_type, ptree_luma, bsize);
+#else
if (part_search_state->terminate_partition_search ||
!part_search_state->do_square_split)
return;
+#endif // CONFIG_EXT_RECUR_PARTITIONS
// Initialization of this partition RD stats.
av1_init_rd_stats(&sum_rdc);
@@ -5019,7 +5126,9 @@
PARTITION_SPLIT, idx, idx == 3, part_search_state->ss_x,
part_search_state->ss_y);
}
+#if !CONFIG_EXT_RECUR_PARTITIONS
int64_t *p_split_rd = &part_search_state->split_rd[idx];
+#endif // !CONFIG_EXT_RECUR_PARTITIONS
RD_STATS best_remain_rdcost;
av1_rd_stats_subtraction(x->rdmult, best_rdc, &sum_rdc,
&best_remain_rdcost);
@@ -5033,6 +5142,16 @@
// Split partition evaluation of corresponding idx.
// If the RD cost exceeds the best cost then do not
// evaluate other split sub-partitions.
+#if CONFIG_EXT_RECUR_PARTITIONS
+ if (!av1_rd_pick_partition(
+ cpi, td, tile_data, tp, mi_row + y_idx, mi_col + x_idx, subsize,
+ &part_search_state->this_rdc, best_remain_rdcost, sub_tree[idx],
+ track_ptree_luma ? ptree_luma->sub_tree[idx] : NULL,
+ get_partition_subtree_const(template_tree, idx),
+ max_recursion_depth, NULL, NULL, multi_pass_mode, NULL)) {
+ break;
+ }
+#else
if (!av1_rd_pick_partition(
cpi, td, tile_data, tp, mi_row + y_idx, mi_col + x_idx, subsize,
&part_search_state->this_rdc, best_remain_rdcost,
@@ -5041,6 +5160,7 @@
av1_invalid_rd_stats(&sum_rdc);
break;
}
+#endif // CONFIG_EXT_RECUR_PARTITIONS
if (frame_is_intra_only(cm) && bsize <= BLOCK_64X64) {
part_search_state->intra_part_info->quad_tree_idx = curr_quad_tree_idx;
}
@@ -5084,6 +5204,7 @@
pc_tree->partitioning = PARTITION_SPLIT;
}
} else if (cpi->sf.part_sf.less_rectangular_check_level > 0) {
+#if !CONFIG_EXT_RECUR_PARTITIONS
// Skip rectangular partition test when partition type none gives better
// rd than partition type split.
if (cpi->sf.part_sf.less_rectangular_check_level == 2 || idx <= 2) {
@@ -5093,13 +5214,13 @@
part_search_state->do_rectangular_split &=
!(partition_none_valid && partition_none_better);
}
+#endif // !CONFIG_EXT_RECUR_PARTITIONS
}
av1_restore_context(cm, x, x_ctx, mi_row, mi_col, bsize, av1_num_planes(cm));
#if CONFIG_MVP_IMPROVEMENT || WARP_CU_BANK
restore_level_banks(&x->e_mbd, level_banks);
#endif // CONFIG_MVP_IMPROVEMENT || WARP_CU_BANK
}
-#endif // !CONFIG_EXT_RECUR_PARTITIONS
#if CONFIG_EXT_RECUR_PARTITIONS
/*!\brief Stores some data used by rd_try_subblock_new to do rdopt. */
@@ -6431,6 +6552,81 @@
#endif // CONFIG_EXT_RECUR_PARTITIONS
+static AOM_INLINE int get_partition_depth(const PC_TREE *pc_tree,
+ int curr_depth) {
+ const PARTITION_TYPE partition = pc_tree->partitioning;
+ int max_depth = curr_depth;
+ switch (partition) {
+ case PARTITION_NONE: break;
+ case PARTITION_SPLIT:
+ for (int idx = 0; idx < 4; idx++) {
+ max_depth = AOMMAX(max_depth, get_partition_depth(pc_tree->split[idx],
+ curr_depth + 2));
+ }
+ break;
+ case PARTITION_HORZ:
+ for (int idx = 0; idx < 2; idx++) {
+ max_depth = AOMMAX(
+ max_depth,
+ get_partition_depth(pc_tree->horizontal[idx], curr_depth + 1));
+ }
+ break;
+ case PARTITION_VERT:
+ for (int idx = 0; idx < 2; idx++) {
+ max_depth =
+ AOMMAX(max_depth,
+ get_partition_depth(pc_tree->vertical[idx], curr_depth + 1));
+ }
+ break;
+ case PARTITION_HORZ_3:
+ for (int idx = 0; idx < 4; idx++) {
+ max_depth = AOMMAX(
+ max_depth,
+ get_partition_depth(pc_tree->horizontal3[idx], curr_depth + 1));
+ }
+ break;
+ case PARTITION_VERT_3:
+ for (int idx = 0; idx < 4; idx++) {
+ max_depth = AOMMAX(
+ max_depth,
+ get_partition_depth(pc_tree->vertical3[idx], curr_depth + 1));
+ }
+ break;
+#if CONFIG_UNEVEN_4WAY
+ case PARTITION_HORZ_4A:
+ for (int idx = 0; idx < 4; idx++) {
+ max_depth = AOMMAX(
+ max_depth,
+ get_partition_depth(pc_tree->horizontal4a[idx], curr_depth + 1));
+ }
+ break;
+ case PARTITION_HORZ_4B:
+ for (int idx = 0; idx < 4; idx++) {
+ max_depth = AOMMAX(
+ max_depth,
+ get_partition_depth(pc_tree->horizontal4b[idx], curr_depth + 1));
+ }
+ break;
+ case PARTITION_VERT_4A:
+ for (int idx = 0; idx < 4; idx++) {
+ max_depth = AOMMAX(
+ max_depth,
+ get_partition_depth(pc_tree->vertical4a[idx], curr_depth + 1));
+ }
+ break;
+ case PARTITION_VERT_4B:
+ for (int idx = 0; idx < 4; idx++) {
+ max_depth = AOMMAX(
+ max_depth,
+ get_partition_depth(pc_tree->vertical4b[idx], curr_depth + 1));
+ }
+ break;
+#endif // CONFIG_UNEVEN_4WAY
+ default: assert(0); break;
+ }
+ return max_depth;
+}
+
#if CONFIG_EXT_RECUR_PARTITIONS
static AOM_INLINE bool try_none_after_rect(
const MACROBLOCKD *xd, const CommonModeInfoParams *mi_params,
@@ -6509,19 +6705,29 @@
const PARTITION_TYPE cur_best_partition = pc_tree->partitioning;
PC_TREE *const *tree = NULL;
- if (cur_best_partition == PARTITION_HORZ) {
+ int num_sub_parts = 0;
+ if (cur_best_partition == PARTITION_SPLIT) {
+ tree = pc_tree->split;
+ num_sub_parts = SUB_PARTITIONS_SPLIT;
+ } else if (cur_best_partition == PARTITION_HORZ) {
tree = pc_tree->horizontal;
+ num_sub_parts = NUM_RECT_PARTS;
} else if (cur_best_partition == PARTITION_VERT) {
tree = pc_tree->vertical;
+ num_sub_parts = NUM_RECT_PARTS;
} else {
assert(0 &&
"Unexpected best partition type in prune_none_with_rect_results.");
}
// Give up on PARTITION_NONE if either of the subtrees decided to split
// further.
- part_search_state->prune_partition_none |=
- tree[0]->partitioning != PARTITION_NONE ||
- tree[1]->partitioning != PARTITION_NONE;
+ for (int idx = 0; idx < num_sub_parts; idx++) {
+ if (!tree[idx]) {
+ break;
+ }
+ part_search_state->prune_partition_none |=
+ tree[idx]->partitioning != PARTITION_NONE;
+ }
}
/*!\brief AV1 block partition search (full search).
@@ -6665,8 +6871,8 @@
#if WARP_CU_BANK
x->e_mbd.warp_param_bank = counterpart_block->warp_param_bank;
#endif // WARP_CU_BANK
- assert(bsize != cm->seq_params.sb_size);
- if (bsize == cm->seq_params.sb_size) exit(0);
+ assert(bsize != cm->sb_size);
+ if (bsize == cm->sb_size) exit(0);
if (!pc_tree->is_last_subblock) {
encode_sb(cpi, td, tile_data, tp, mi_row, mi_col, DRY_RUN_NORMAL, bsize,
@@ -6683,7 +6889,7 @@
}
}
#endif // CONFIG_EXT_RECUR_PARTITIONS
- if (bsize == cm->seq_params.sb_size) x->must_find_valid_partition = 0;
+ if (bsize == cm->sb_size) x->must_find_valid_partition = 0;
// Override skipping rectangular partition operations for edge blocks.
if (none_rd) *none_rd = 0;
@@ -6700,14 +6906,12 @@
#endif
#endif
+#if !CONFIG_EXT_RECUR_PARTITIONS
// Override partition costs at the edges of the frame in the same
// way as in read_partition (see decodeframe.c).
if (!(blk_params.has_rows && blk_params.has_cols))
- set_partition_cost_for_edge_blk(cm, xd,
-#if CONFIG_EXT_RECUR_PARTITIONS
- &pc_tree->chroma_ref_info,
-#endif // CONFIG_EXT_RECUR_PARTITIONS
- &part_search_state);
+ set_partition_cost_for_edge_blk(cm, xd, &part_search_state);
+#endif // !CONFIG_EXT_RECUR_PARTITIONS
// Disable rectangular partitions for inner blocks when the current block is
// forced to only use square partitions.
@@ -6735,12 +6939,18 @@
av1_set_offsets(cpi, tile_info, x, mi_row, mi_col, bsize,
&pc_tree->chroma_ref_info);
+ bool search_none_after_split = false;
bool search_none_after_rect = false;
#if CONFIG_EXT_RECUR_PARTITIONS
- if (cpi->sf.part_sf.adaptive_partition_search_order &&
- part_search_state.forced_partition == PARTITION_INVALID) {
- search_none_after_rect =
- try_none_after_rect(xd, &cm->mi_params, bsize, mi_row, mi_col);
+ if (part_search_state.forced_partition == PARTITION_INVALID) {
+ if (cpi->sf.part_sf.adaptive_partition_search_order) {
+ search_none_after_rect =
+ try_none_after_rect(xd, &cm->mi_params, bsize, mi_row, mi_col);
+ }
+#if CONFIG_BLOCK_256
+ // For 256X256, always search the subblocks first.
+ search_none_after_split |= bsize == BLOCK_256X256;
+#endif // CONFIG_BLOCK_256
}
#endif // CONFIG_EXT_RECUR_PARTITIONS
@@ -6774,8 +6984,8 @@
#endif // CONFIG_MVP_IMPROVEMENT
#if CONFIG_EXT_RECUR_PARTITIONS
{
- SimpleMotionData *sms_data = av1_get_sms_data_entry(
- x->sms_bufs, mi_row, mi_col, bsize, cm->seq_params.sb_size);
+ SimpleMotionData *sms_data =
+ av1_get_sms_data_entry(x->sms_bufs, mi_row, mi_col, bsize, cm->sb_size);
sms_tree = sms_data->old_sms;
}
#endif // CONFIG_EXT_RECUR_PARTITIONS
@@ -6853,7 +7063,7 @@
// PARTITION_NONE search stage.
int64_t part_none_rd = INT64_MAX;
- if (!search_none_after_rect) {
+ if (!search_none_after_rect && !search_none_after_split) {
none_partition_search(cpi, td, tile_data, x, pc_tree, sms_tree, &x_ctx,
&part_search_state, &best_rdc, &pb_source_variance,
none_rd, &part_none_rd
@@ -6879,7 +7089,6 @@
}
#endif // CONFIG_EXT_RECUR_PARTITIONS
-#if !CONFIG_EXT_RECUR_PARTITIONS
// PARTITION_SPLIT search stage.
int64_t part_split_rd = INT64_MAX;
split_partition_search(cpi, td, tile_data, tp, x, pc_tree, sms_tree, &x_ctx,
@@ -6889,13 +7098,18 @@
,
&level_banks
#endif // CONFIG_MVP_IMPROVEMENT || WARP_CU_BANK
+#if CONFIG_EXT_RECUR_PARTITIONS
+ ,
+ ptree_luma, template_tree, max_recursion_depth - 1
+#endif // CONFIG_EXT_RECUR_PARTITIONS
);
+#if !CONFIG_EXT_RECUR_PARTITIONS
// Terminate partition search for child partition,
// when NONE and SPLIT partition rd_costs are INT64_MAX.
if (cpi->sf.part_sf.early_term_after_none_split &&
part_none_rd == INT64_MAX && part_split_rd == INT64_MAX &&
- !x->must_find_valid_partition && (bsize != cm->seq_params.sb_size)) {
+ !x->must_find_valid_partition && (bsize != cm->sb_size)) {
part_search_state.terminate_partition_search = 1;
}
@@ -6903,6 +7117,45 @@
prune_partitions_after_split(cpi, x, sms_tree, &part_search_state, &best_rdc,
part_none_rd, part_split_rd);
#endif // !CONFIG_EXT_RECUR_PARTITIONS
+#if CONFIG_BLOCK_256
+ if (search_none_after_split) {
+ // Based on split result, decide if we want to further delay the search to
+ // after rect
+ assert(pc_tree->partitioning == PARTITION_SPLIT);
+ for (int idx = 0; idx < 4; idx++) {
+ const int depth = get_partition_depth(pc_tree->split[idx], 0);
+ search_none_after_split &= depth == 0;
+ }
+ }
+ if (cpi->sf.part_sf.prune_rect_with_split_depth && !frame_is_intra_only(cm) &&
+ part_search_state.forced_partition == PARTITION_INVALID &&
+ pc_tree->split[0] && pc_tree->split[1] && pc_tree->split[2] &&
+ pc_tree->split[3]) {
+ int min_depth = INT_MAX, max_depth = 0;
+ for (int idx = 0; idx < 4; idx++) {
+ const int depth = get_partition_depth(pc_tree->split[idx], 0);
+ min_depth = AOMMIN(min_depth, depth);
+ max_depth = AOMMAX(max_depth, depth);
+ }
+ if (min_depth > 4) {
+ part_search_state.prune_rect_part[HORZ] =
+ part_search_state.prune_rect_part[VERT] = true;
+ }
+ (void)max_depth;
+ }
+
+ if (part_search_state.forced_partition == PARTITION_INVALID &&
+ search_none_after_split) {
+ none_partition_search(cpi, td, tile_data, x, pc_tree, sms_tree, &x_ctx,
+ &part_search_state, &best_rdc, &pb_source_variance,
+ none_rd, &part_none_rd
+#if CONFIG_MVP_IMPROVEMENT || WARP_CU_BANK
+ ,
+ &level_banks
+#endif // CONFIG_MVP_IMPROVEMENT || WARP_CU_BANK
+ );
+ }
+#endif // CONFIG_BLOCK_256
// Rectangular partitions search stage.
rectangular_partition_search(
@@ -6925,7 +7178,7 @@
assert(IMPLIES(!cpi->oxcf.part_cfg.enable_rect_partitions,
!part_search_state.do_rectangular_split));
#if CONFIG_EXT_RECUR_PARTITIONS
- if (search_none_after_rect) {
+ if (search_none_after_rect && !search_none_after_split) {
prune_none_with_rect_results(&part_search_state, pc_tree);
none_partition_search(cpi, td, tile_data, x, pc_tree, sms_tree, &x_ctx,
&part_search_state, &best_rdc, &pb_source_variance,
@@ -7086,8 +7339,7 @@
multi_pass_mode, ext_recur_depth);
#endif // CONFIG_UNEVEN_4WAY
- if (bsize == cm->seq_params.sb_size &&
- !part_search_state.found_best_partition) {
+ if (bsize == cm->sb_size && !part_search_state.found_best_partition) {
if (x->must_find_valid_partition) {
aom_internal_error(
&cpi->common.error, AOM_CODEC_ERROR,
@@ -7135,8 +7387,8 @@
av1_invalid_rd_stats(&pc_tree->rd_cost);
} else {
#if CONFIG_EXT_RECUR_PARTITIONS
- av1_cache_best_partition(x->sms_bufs, mi_row, mi_col, bsize,
- cm->seq_params.sb_size, pc_tree->partitioning);
+ av1_cache_best_partition(x->sms_bufs, mi_row, mi_col, bsize, cm->sb_size,
+ pc_tree->partitioning);
#endif // CONFIG_EXT_RECUR_PARTITIONS
}
@@ -7196,10 +7448,7 @@
// If a valid partition is found and reconstruction is required for future
// sub-blocks in the same group.
if (part_search_state.found_best_partition && pc_tree->index != 3) {
-#if CONFIG_EXT_RECUR_PARTITIONS
- assert(pc_tree->partitioning != PARTITION_SPLIT);
-#endif // CONFIG_EXT_RECUR_PARTITIONS
- if (bsize == cm->seq_params.sb_size) {
+ if (bsize == cm->sb_size) {
// Encode the superblock.
const int emit_output = multi_pass_mode != SB_DRY_PASS;
const RUN_TYPE run_type = emit_output ? OUTPUT_ENABLED : DRY_RUN_NORMAL;
@@ -7241,7 +7490,7 @@
av1_free_pc_tree_recursive(pc_tree, num_planes, 1, 1);
}
- if (bsize == cm->seq_params.sb_size) {
+ if (bsize == cm->sb_size) {
assert(best_rdc.rate < INT_MAX);
assert(best_rdc.dist < INT64_MAX);
} else {
diff --git a/av1/encoder/partition_strategy.c b/av1/encoder/partition_strategy.c
index ac792a7..18fa5c1 100644
--- a/av1/encoder/partition_strategy.c
+++ b/av1/encoder/partition_strategy.c
@@ -63,8 +63,7 @@
int *partition_vert_allowed,
int *do_rectangular_split,
int *do_square_split) {
- assert(cm->seq_params.sb_size >= BLOCK_64X64 &&
- "Invalid sb_size for intra_cnn!");
+ assert(cm->sb_size >= BLOCK_64X64 && "Invalid sb_size for intra_cnn!");
const int bsize_idx = convert_bsize_to_idx(bsize);
if (bsize == BLOCK_128X128) {
@@ -618,6 +617,10 @@
ml_mean = av1_simple_motion_search_term_none_mean_16;
ml_std = av1_simple_motion_search_term_none_std_16;
ml_model = av1_simple_motion_search_term_none_model_16;
+#if CONFIG_BLOCK_256
+ } else if (bsize == BLOCK_256X256) {
+ return;
+#endif // CONFIG_BLOCK_256
} else {
assert(0 && "Unexpected block size in simple_motion_term_none");
}
@@ -641,7 +644,7 @@
float *features) {
AV1_COMMON *const cm = &cpi->common;
MACROBLOCKD *xd = &x->e_mbd;
- const BLOCK_SIZE sb_size = cm->seq_params.sb_size;
+ const BLOCK_SIZE sb_size = cm->sb_size;
assert(sb_size == BLOCK_128X128);
@@ -770,7 +773,7 @@
}
} else if (cpi->sf.part_sf.auto_max_partition_based_on_simple_motion ==
ADAPT_PRED) {
- const BLOCK_SIZE sb_size = cpi->common.seq_params.sb_size;
+ const BLOCK_SIZE sb_size = cpi->common.sb_size;
const MACROBLOCKD *const xd = &x->e_mbd;
// TODO(debargha): x->source_variance is unavailable at this point,
// so compute. The redundant recomputation later can be removed.
@@ -1264,6 +1267,9 @@
nn_config = &av1_partition_breakout_nnconfig_128;
thresh = cpi->sf.part_sf.ml_partition_search_breakout_thresh[4];
break;
+#if CONFIG_BLOCK_256
+ case BLOCK_256X256: return 0; break;
+#endif // CONFIG_BLOCK_256
default: assert(0 && "Unexpected bsize.");
}
if (!nn_config || thresh < 0) return 0;
@@ -1317,7 +1323,7 @@
const int try_intra_cnn_split =
!cpi->is_screen_content_type && frame_is_intra_only(cm) &&
cpi->sf.part_sf.intra_cnn_split && xd->tree_type != CHROMA_PART &&
- cm->seq_params.sb_size >= BLOCK_64X64 && bsize <= BLOCK_64X64 &&
+ cm->sb_size >= BLOCK_64X64 && bsize <= BLOCK_64X64 &&
bsize >= BLOCK_8X8 &&
mi_row + mi_size_high[bsize] <= mi_params->mi_rows &&
mi_col + mi_size_wide[bsize] <= mi_params->mi_cols;
@@ -1348,14 +1354,14 @@
do_square_split);
#if CONFIG_EXT_RECUR_PARTITIONS
if (!*partition_none_allowed) {
- av1_cache_best_partition(x->sms_bufs, mi_row, mi_col, bsize,
- cm->seq_params.sb_size, PARTITION_HORZ);
+ av1_cache_best_partition(x->sms_bufs, mi_row, mi_col, bsize, cm->sb_size,
+ PARTITION_HORZ);
const int mi_step = block_size_high[bsize] / 2;
BLOCK_SIZE subsize = get_partition_subsize(bsize, PARTITION_HORZ);
av1_cache_best_partition(x->sms_bufs, mi_row, mi_col, subsize,
- cm->seq_params.sb_size, PARTITION_VERT);
+ cm->sb_size, PARTITION_VERT);
av1_cache_best_partition(x->sms_bufs, mi_row + mi_step, mi_col, subsize,
- cm->seq_params.sb_size, PARTITION_VERT);
+ cm->sb_size, PARTITION_VERT);
}
(void)pc_tree;
#endif // CONFIG_EXT_RECUR_PARTITIONS
@@ -1613,6 +1619,9 @@
// Gets the number of sms data in a single dimension
static INLINE int get_sms_count_from_length(int mi_length) {
switch (mi_length) {
+#if CONFIG_BLOCK_256
+ case 64: return BLOCK_256_COUNT;
+#endif // CONFIG_BLOCK_256
case 32: return BLOCK_128_COUNT;
case 16: return BLOCK_64_COUNT;
case 8: return BLOCK_32_COUNT;
@@ -1666,6 +1675,9 @@
BLOCK_SIZE bsize) {
switch (bsize) {
// Square blocks
+#if CONFIG_BLOCK_256
+ MAKE_SMS_ARR_SWITCH_CASE(256, 256);
+#endif // CONFIG_BLOCK_256
MAKE_SMS_ARR_SWITCH_CASE(128, 128);
MAKE_SMS_ARR_SWITCH_CASE(64, 64);
MAKE_SMS_ARR_SWITCH_CASE(32, 32);
@@ -1674,6 +1686,9 @@
MAKE_SMS_ARR_SWITCH_CASE(4, 4);
// 1:2 blocks
+#if CONFIG_BLOCK_256
+ MAKE_SMS_ARR_SWITCH_CASE(128, 256);
+#endif // CONFIG_BLOCK_256
MAKE_SMS_ARR_SWITCH_CASE(64, 128);
MAKE_SMS_ARR_SWITCH_CASE(32, 64);
MAKE_SMS_ARR_SWITCH_CASE(16, 32);
@@ -1681,6 +1696,9 @@
MAKE_SMS_ARR_SWITCH_CASE(4, 8);
// 2:1 blocks
+#if CONFIG_BLOCK_256
+ MAKE_SMS_ARR_SWITCH_CASE(256, 128);
+#endif // CONFIG_BLOCK_256
MAKE_SMS_ARR_SWITCH_CASE(128, 64);
MAKE_SMS_ARR_SWITCH_CASE(64, 32);
MAKE_SMS_ARR_SWITCH_CASE(32, 16);
@@ -1820,10 +1838,9 @@
SimpleMotionDataBufs *sms_bufs, int mi_row, int mi_col, BLOCK_SIZE bsize,
BLOCK_SIZE sb_size, PARTITION_TYPE partition, MV start_mv) {
assert(bsize < BLOCK_SIZES_ALL);
-
const int eighth_step_h = block_size_high[bsize] / 8;
const int eighth_step_w = block_size_wide[bsize] / 8;
- static const int subblock_count[EXT_PARTITION_TYPES] = {
+ static const int subblock_count[ALL_PARTITION_TYPES] = {
1, // PARTITION_NONE
2, // PARTITION_HORZ
2, // PARTITION_VERT
@@ -1835,9 +1852,10 @@
4, // PARTITION_VERT_4A
4, // PARTITION_VERT_4B
#endif // CONFIG_UNEVEN_4WAY
+ 4, // PARTITION_SPLIT
};
// PARTITION x NUM_SUBBLOCKS x (ROW and COL)
- static const int step_multiplier[EXT_PARTITION_TYPES][4][2] = {
+ static const int step_multiplier[ALL_PARTITION_TYPES][4][2] = {
{ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } }, // PARTITION_NONE
{ { 0, 0 }, { 4, 0 }, { 0, 0 }, { 0, 0 } }, // PARTITION_HORZ
{ { 0, 0 }, { 0, 4 }, { 0, 0 }, { 0, 0 } }, // PARTITION_VERT
@@ -1849,6 +1867,7 @@
{ { 0, 0 }, { 0, 1 }, { 0, 3 }, { 0, 7 } }, // PARTITION_VERT_4A
{ { 0, 0 }, { 0, 1 }, { 0, 5 }, { 0, 7 } }, // PARTITION_VERT_4B
#endif // CONFIG_UNEVEN_4WAY
+ { { 0, 0 }, { 0, 4 }, { 4, 0 }, { 4, 4 } }, // PARTITION_SPLIT
};
// Sizes of subblocks.
@@ -1897,7 +1916,7 @@
const TileInfo *const tile, MACROBLOCK *x,
int mi_row, int mi_col, BLOCK_SIZE bsize) {
const AV1_COMMON *const cm = &cpi->common;
- const BLOCK_SIZE sb_size = cm->seq_params.sb_size;
+ const BLOCK_SIZE sb_size = cm->sb_size;
SimpleMotionDataBufs *sms_bufs = x->sms_bufs;
SimpleMotionData *cur_block =
av1_get_sms_data_entry(sms_bufs, mi_row, mi_col, bsize, sb_size);
diff --git a/av1/encoder/pickcdef.c b/av1/encoder/pickcdef.c
index 9d06025..8399c27 100644
--- a/av1/encoder/pickcdef.c
+++ b/av1/encoder/pickcdef.c
@@ -360,7 +360,11 @@
return;
}
+#if CONFIG_BLOCK_256
+ cdef_list dlist[MI_SIZE_256X256 * MI_SIZE_256X256];
+#else
cdef_list dlist[MI_SIZE_128X128 * MI_SIZE_128X128];
+#endif // CONFIG_BLOCK_256
int dir[CDEF_NBLOCKS][CDEF_NBLOCKS] = { { 0 } };
int var[CDEF_NBLOCKS][CDEF_NBLOCKS] = { { 0 } };
const CommonModeInfoParams *const mi_params = &cm->mi_params;
@@ -422,17 +426,56 @@
const MB_MODE_INFO *const mbmi =
mi_params->mi_grid_base[MI_SIZE_64X64 * fbr * mi_params->mi_stride +
MI_SIZE_64X64 * fbc];
+ BLOCK_SIZE bs = mbmi->sb_type[PLANE_TYPE_Y];
+#if CONFIG_BLOCK_256
+ if (bs > BLOCK_64X64 && bs <= BLOCK_256X256) {
+ const int bw = block_size_wide[bs];
+ const int bh = block_size_high[bs];
+ if ((bw == 256 && (fbc & 3)) || (bh == 256 && (fbr & 3))) {
+ continue;
+ };
+ if ((bw == 128 && (fbc & 1)) || (bh == 128 && (fbr & 1))) {
+ continue;
+ };
+ }
+#else
if (((fbc & 1) && (mbmi->sb_type[PLANE_TYPE_Y] == BLOCK_128X128 ||
mbmi->sb_type[PLANE_TYPE_Y] == BLOCK_128X64)) ||
((fbr & 1) && (mbmi->sb_type[PLANE_TYPE_Y] == BLOCK_128X128 ||
mbmi->sb_type[PLANE_TYPE_Y] == BLOCK_64X128)))
continue;
+#endif // CONFIG_BLOCK_256
int nhb = AOMMIN(MI_SIZE_64X64, mi_params->mi_cols - MI_SIZE_64X64 * fbc);
int nvb = AOMMIN(MI_SIZE_64X64, mi_params->mi_rows - MI_SIZE_64X64 * fbr);
int hb_step = 1;
int vb_step = 1;
- BLOCK_SIZE bs;
+#if CONFIG_BLOCK_256
+ if (bs > BLOCK_64X64 && bs <= BLOCK_256X256) {
+ if (block_size_wide[bs] == 256) {
+ nhb =
+ AOMMIN(MI_SIZE_256X256, mi_params->mi_cols - MI_SIZE_64X64 * fbc);
+ hb_step = 4;
+ }
+ if (block_size_high[bs] == 256) {
+ nvb =
+ AOMMIN(MI_SIZE_256X256, mi_params->mi_rows - MI_SIZE_64X64 * fbr);
+ vb_step = 4;
+ }
+ if (block_size_wide[bs] == 128) {
+ nhb =
+ AOMMIN(MI_SIZE_128X128, mi_params->mi_cols - MI_SIZE_64X64 * fbc);
+ hb_step = 2;
+ }
+ if (block_size_high[bs] == 128) {
+ nvb =
+ AOMMIN(MI_SIZE_128X128, mi_params->mi_rows - MI_SIZE_64X64 * fbr);
+ vb_step = 2;
+ }
+ } else {
+ bs = BLOCK_64X64;
+ }
+#else
if (mbmi->sb_type[PLANE_TYPE_Y] == BLOCK_128X128 ||
mbmi->sb_type[PLANE_TYPE_Y] == BLOCK_128X64 ||
mbmi->sb_type[PLANE_TYPE_Y] == BLOCK_64X128) {
@@ -450,6 +493,7 @@
} else {
bs = BLOCK_64X64;
}
+#endif // CONFIG_BLOCK_256
const int cdef_count = av1_cdef_compute_sb_list(
mi_params, fbr * MI_SIZE_64X64, fbc * MI_SIZE_64X64, dlist, bs);
@@ -552,17 +596,19 @@
}
}
mi_params->mi_grid_base[sb_index[i]]->cdef_strength = best_gi;
- int bsize_y = mi_params->mi_grid_base[sb_index[i]]->sb_type[PLANE_TYPE_Y];
+ BLOCK_SIZE bsize_y =
+ mi_params->mi_grid_base[sb_index[i]]->sb_type[PLANE_TYPE_Y];
const int bh = mi_size_high[bsize_y];
const int bw = mi_size_wide[bsize_y];
int mi_row = sb_index[i] / mi_params->mi_stride;
int mi_col = sb_index[i] % mi_params->mi_stride;
- if (mi_params->mi_grid_base[sb_index[i]]->sb_type[PLANE_TYPE_Y] ==
- BLOCK_64X128 ||
- mi_params->mi_grid_base[sb_index[i]]->sb_type[PLANE_TYPE_Y] ==
- BLOCK_128X128 ||
- mi_params->mi_grid_base[sb_index[i]]->sb_type[PLANE_TYPE_Y] ==
- BLOCK_128X64) {
+ if (
+#if CONFIG_BLOCK_256
+ bsize_y == BLOCK_256X256 || bsize_y == BLOCK_256X128 ||
+ bsize_y == BLOCK_128X256 ||
+#endif // CONFIG_BLOCK_256
+ bsize_y == BLOCK_128X128 || bsize_y == BLOCK_128X64 ||
+ bsize_y == BLOCK_64X128) {
const int x_inside_boundary = AOMMIN(bw, mi_params->mi_cols - mi_col);
const int y_inside_boundary = AOMMIN(bh, mi_params->mi_rows - mi_row);
int idx = mi_params->mi_stride;
diff --git a/av1/encoder/pickrst.c b/av1/encoder/pickrst.c
index eef3d93..5c49b56 100644
--- a/av1/encoder/pickrst.c
+++ b/av1/encoder/pickrst.c
@@ -4358,13 +4358,13 @@
reset_rsc(rsc);
rsc_on_tile(rsc, *processed);
for (int mi_row = tile_info.mi_row_start; mi_row < tile_info.mi_row_end;
- mi_row += rsc->cm->seq_params.mib_size) {
+ mi_row += rsc->cm->mib_size) {
for (int mi_col = tile_info.mi_col_start; mi_col < tile_info.mi_col_end;
- mi_col += rsc->cm->seq_params.mib_size) {
+ mi_col += rsc->cm->mib_size) {
int rrow0, rrow1, rcol0, rcol1;
- if (av1_loop_restoration_corners_in_sb(
- rsc->cm, rsc->plane, mi_row, mi_col, rsc->cm->seq_params.sb_size,
- &rcol0, &rcol1, &rrow0, &rrow1)) {
+ if (av1_loop_restoration_corners_in_sb(rsc->cm, rsc->plane, mi_row,
+ mi_col, rsc->cm->sb_size, &rcol0,
+ &rcol1, &rrow0, &rrow1)) {
// RU domain rectangle for the coded SB
AV1PixelRect ru_sb_rect = av1_get_rutile_rect(
rsc->cm, is_uv, rrow0, rrow1, rcol0, rcol1, ru_size, ru_size);
diff --git a/av1/encoder/rd.c b/av1/encoder/rd.c
index 3c6d75a..1671707 100644
--- a/av1/encoder/rd.c
+++ b/av1/encoder/rd.c
@@ -14,6 +14,8 @@
#include <math.h>
#include <stdio.h>
+#include "av1/common/blockd.h"
+#include "av1/common/enums.h"
#include "config/av1_rtcd.h"
#include "aom_dsp/aom_dsp_common.h"
@@ -55,7 +57,11 @@
// This table is used to correct for block size.
// The factors here are << 2 (2 = x0.5, 32 = x8 etc).
static const uint8_t rd_thresh_block_size_factor[BLOCK_SIZES_ALL] = {
- 2, 3, 3, 4, 6, 6, 8, 12, 12, 16, 24, 24, 32, 48, 48, 64, 4, 4, 8, 8, 16, 16
+ 2, 3, 3, 4, 6, 6, 8, 12, 12, 16, 24, 24, 32, 48, 48, 64,
+#if CONFIG_BLOCK_256
+ 96, 96, 128,
+#endif // CONFIG_BLOCK_256
+ 4, 4, 8, 8, 16, 16
};
static const int use_intra_ext_tx_for_txsize[EXT_TX_SETS_INTRA]
@@ -108,6 +114,15 @@
fc->do_split_cdf[plane_index][i], NULL);
}
}
+#if CONFIG_BLOCK_256
+ for (int plane_index = (xd->tree_type == CHROMA_PART);
+ plane_index < PARTITION_STRUCTURE_NUM; plane_index++) {
+ for (i = 0; i < SQUARE_SPLIT_CONTEXTS; ++i) {
+ av1_cost_tokens_from_cdf(mode_costs->do_square_split_cost[plane_index][i],
+ fc->do_square_split_cdf[plane_index][i], NULL);
+ }
+ }
+#endif // CONFIG_BLOCK_256
for (int plane_index = (xd->tree_type == CHROMA_PART);
plane_index < PARTITION_STRUCTURE_NUM; plane_index++) {
for (i = 0; i < PARTITION_CONTEXTS; ++i) {
@@ -142,7 +157,7 @@
plane_index < PARTITION_STRUCTURE_NUM; plane_index++) {
const TREE_TYPE tree_type = plane_index ? CHROMA_PART : LUMA_PART;
for (BLOCK_SIZE bsize = 0; bsize < BLOCK_SIZES; bsize++) {
- for (PARTITION_TYPE part = 0; part < EXT_PARTITION_TYPES; part++) {
+ for (PARTITION_TYPE part = 0; part < ALL_PARTITION_TYPES; part++) {
for (int context = 0; context < PARTITION_PLOFFSET; context++) {
const int ctx = PARTITION_PLOFFSET * bsize + context;
const bool do_split = part != PARTITION_NONE;
@@ -151,6 +166,17 @@
if (!do_split) {
continue;
}
+#if CONFIG_BLOCK_256
+ const bool do_square_split = part == PARTITION_SPLIT;
+ if (is_square_split_eligible(bsize, cm->sb_size)) {
+ mode_costs->partition_cost[plane_index][ctx][part] +=
+ mode_costs->do_square_split_cost[plane_index][context]
+ [do_square_split];
+ }
+ if (do_square_split) {
+ continue;
+ }
+#endif // CONFIG_BLOCK_256
RECT_PART_TYPE rect_type = get_rect_part_type(part);
if (rect_type_implied_by_bsize(bsize, tree_type) == RECT_INVALID) {
mode_costs->partition_cost[plane_index][ctx][part] +=
@@ -1471,7 +1497,33 @@
*/
static const uint8_t bsize_curvfit_model_cat_lookup[BLOCK_SIZES_ALL] = {
- 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 1, 1, 2, 2, 3, 3
+ 0,
+ 0,
+ 0,
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3,
+ 3,
+ 3,
+ 3,
+ 3,
+#if CONFIG_BLOCK_256
+ 3,
+ 3,
+ 3,
+#endif // CONFIG_BLOCK_256
+ 1,
+ 1,
+ 2,
+ 2,
+ 3,
+ 3
};
static int sse_norm_curvfit_model_cat_lookup(double sse_norm) {
@@ -1496,9 +1548,36 @@
}
static const uint8_t bsize_surffit_model_cat_lookup[BLOCK_SIZES_ALL] = {
- 0, 0, 0, 0, 1, 1, 2, 3, 3, 4, 5, 5, 6, 7, 7, 8, 0, 0, 2, 2, 4, 4
+ 0,
+ 0,
+ 0,
+ 0,
+ 1,
+ 1,
+ 2,
+ 3,
+ 3,
+ 4,
+ 5,
+ 5,
+ 6,
+ 7,
+ 7,
+ 8,
+#if CONFIG_BLOCK_256
+ 8,
+ 8,
+ 8,
+#endif // CONFIG_BLOCK_256
+ 0,
+ 0,
+ 2,
+ 2,
+ 4,
+ 4
};
+// TODO(any): Add models for BLOCK_256
static const double surffit_rate_params[9][4] = {
{
638.390212,
@@ -1883,7 +1962,7 @@
assert(use_adaptive_rd_thresh > 0);
const int max_rd_thresh_factor = use_adaptive_rd_thresh * RD_THRESH_MAX_FACT;
- const int bsize_is_1_to_4 = bsize > cm->seq_params.sb_size;
+ const int bsize_is_1_to_4 = bsize > cm->sb_size;
BLOCK_SIZE min_size, max_size;
if (bsize_is_1_to_4) {
// This part handles block sizes with 1:4 and 4:1 aspect ratios
@@ -1892,7 +1971,7 @@
max_size = bsize;
} else {
min_size = AOMMAX(bsize - 2, BLOCK_4X4);
- max_size = AOMMIN(bsize + 2, (int)cm->seq_params.sb_size);
+ max_size = AOMMIN(bsize + 2, (int)cm->sb_size);
}
for (PREDICTION_MODE mode = 0; mode < MB_MODE_COUNT; ++mode) {
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index 50121c3..e5c1dd0 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -736,7 +736,7 @@
const int mi_col = xd->mi_col;
const int x_inside_boundary = AOMMIN(bw, cm->mi_params.mi_cols - mi_col);
const int y_inside_boundary = AOMMIN(bh, cm->mi_params.mi_rows - mi_row);
- const int dst_stride = MAX_MIB_SIZE;
+ const int dst_stride = bw;
const int src_stride = cm->mi_params.mi_stride;
for (int y = 0; y < y_inside_boundary; y++) {
for (int x = 0; x < x_inside_boundary; x++) {
@@ -753,7 +753,7 @@
const int mi_col = xd->mi_col;
const int x_inside_boundary = AOMMIN(bw, cm->mi_params.mi_cols - mi_col);
const int y_inside_boundary = AOMMIN(bh, cm->mi_params.mi_rows - mi_row);
- const int src_stride = MAX_MIB_SIZE;
+ const int src_stride = bw;
const int dst_stride = cm->mi_params.mi_stride;
for (int y = 0; y < y_inside_boundary; y++) {
for (int x = 0; x < x_inside_boundary; x++) {
@@ -6113,8 +6113,7 @@
#endif
))
return 0;
- if (!av1_is_dv_valid(dv, cm, xd, mi_row, mi_col, bsize,
- cm->seq_params.mib_size_log2))
+ if (!av1_is_dv_valid(dv, cm, xd, mi_row, mi_col, bsize, cm->mib_size_log2))
return 0;
return 1;
}
@@ -6160,7 +6159,7 @@
cur_ref_bv.as_int = 0;
}
if (cur_ref_bv.as_int == 0) {
- av1_find_ref_dv(&cur_ref_bv, tile, cm->seq_params.mib_size, mi_row);
+ av1_find_ref_dv(&cur_ref_bv, tile, cm->mib_size, mi_row);
}
// Ref DV should not have sub-pel.
assert((cur_ref_bv.as_mv.col & 7) == 0);
@@ -6218,7 +6217,7 @@
cur_ref_bv.as_int = 0;
}
if (cur_ref_bv.as_int == 0) {
- av1_find_ref_dv(&cur_ref_bv, tile, cm->seq_params.mib_size, mi_row);
+ av1_find_ref_dv(&cur_ref_bv, tile, cm->mib_size, mi_row);
}
// Ref DV should not have sub-pel.
assert((cur_ref_bv.as_mv.col & 7) == 0);
@@ -6275,8 +6274,8 @@
const int mi_col = xd->mi_col;
const int w = block_size_wide[bsize];
const int h = block_size_high[bsize];
- const int sb_row = mi_row >> cm->seq_params.mib_size_log2;
- const int sb_col = mi_col >> cm->seq_params.mib_size_log2;
+ const int sb_row = mi_row >> cm->mib_size_log2;
+ const int sb_col = mi_col >> cm->mib_size_log2;
MB_MODE_INFO_EXT *const mbmi_ext = x->mbmi_ext;
MV_REFERENCE_FRAME ref_frame = INTRA_FRAME;
@@ -6319,7 +6318,7 @@
}
#endif // CONFIG_IBC_BV_IMPROVEMENT
if (dv_ref.as_int == 0) {
- av1_find_ref_dv(&dv_ref, tile, cm->seq_params.mib_size, mi_row);
+ av1_find_ref_dv(&dv_ref, tile, cm->mib_size, mi_row);
}
// Ref DV should not have sub-pel.
assert((dv_ref.as_mv.col & 7) == 0);
@@ -6380,7 +6379,7 @@
#if CONFIG_IBC_SR_EXT
fullms_params.xd = xd;
fullms_params.cm = cm;
- fullms_params.mib_size_log2 = cm->seq_params.mib_size_log2;
+ fullms_params.mib_size_log2 = cm->mib_size_log2;
fullms_params.mi_col = mi_col;
fullms_params.mi_row = mi_row;
#endif // CONFIG_IBC_SR_EXT
@@ -6417,7 +6416,7 @@
fullms_params.mv_limits.row_max = -h;
#else
fullms_params.mv_limits.row_max =
- (sb_row * cm->seq_params.mib_size - mi_row) * MI_SIZE - h;
+ (sb_row * cm->mib_size - mi_row) * MI_SIZE - h;
#endif // CONFIG_IBC_SR_EXT
break;
case IBC_MOTION_LEFT:
@@ -6427,14 +6426,14 @@
fullms_params.mv_limits.col_max = -w;
#else
fullms_params.mv_limits.col_max =
- (sb_col * cm->seq_params.mib_size - mi_col) * MI_SIZE - w;
+ (sb_col * cm->mib_size - mi_col) * MI_SIZE - w;
#endif // CONFIG_IBC_SR_EXT
// TODO(aconverse@google.com): Minimize the overlap between above and
// left areas.
fullms_params.mv_limits.row_min =
(tile->mi_row_start - mi_row) * MI_SIZE;
int bottom_coded_mi_edge =
- AOMMIN((sb_row + 1) * cm->seq_params.mib_size, tile->mi_row_end);
+ AOMMIN((sb_row + 1) * cm->mib_size, tile->mi_row_end);
fullms_params.mv_limits.row_max =
(bottom_coded_mi_edge - mi_row) * MI_SIZE - h;
break;
@@ -6443,13 +6442,12 @@
#if CONFIG_IBC_SR_EXT
} else {
int left_coded_mi_edge =
- AOMMAX((sb_col - 1) * cm->seq_params.mib_size, tile->mi_col_start);
+ AOMMAX((sb_col - 1) * cm->mib_size, tile->mi_col_start);
int right_coded_mi_edge =
- AOMMIN((sb_col + 1) * cm->seq_params.mib_size, tile->mi_col_end);
- int up_coded_mi_edge =
- AOMMAX((sb_row)*cm->seq_params.mib_size, tile->mi_row_start);
+ AOMMIN((sb_col + 1) * cm->mib_size, tile->mi_col_end);
+ int up_coded_mi_edge = AOMMAX((sb_row)*cm->mib_size, tile->mi_row_start);
int bottom_coded_mi_edge =
- AOMMIN((sb_row + 1) * cm->seq_params.mib_size, tile->mi_row_end);
+ AOMMIN((sb_row + 1) * cm->mib_size, tile->mi_row_end);
switch (dir) {
case IBC_MOTION_ABOVE:
@@ -6611,8 +6609,7 @@
#endif
))
continue;
- if (!av1_is_dv_valid(dv, cm, xd, mi_row, mi_col, bsize,
- cm->seq_params.mib_size_log2))
+ if (!av1_is_dv_valid(dv, cm, xd, mi_row, mi_col, bsize, cm->mib_size_log2))
continue;
#endif // CONFIG_IBC_BV_IMPROVEMENT
@@ -9460,10 +9457,9 @@
continue;
}
for (int sub_idx = 0; sub_idx < 2; sub_idx++) {
- const PARTITION_TYPE prev_part =
- av1_get_prev_partition(x, mi_pos_rect[rect_type][sub_idx][0],
- mi_pos_rect[rect_type][sub_idx][1],
- subsize, cm->seq_params.sb_size);
+ const PARTITION_TYPE prev_part = av1_get_prev_partition(
+ x, mi_pos_rect[rect_type][sub_idx][0],
+ mi_pos_rect[rect_type][sub_idx][1], subsize, cm->sb_size);
if (prev_part != PARTITION_INVALID) {
prune_ref_frames = true;
break;
@@ -9474,7 +9470,7 @@
if (prune_ref_frames) {
picked_ref_frames_mask =
- fetch_picked_ref_frames_mask(x, bsize, cm->seq_params.mib_size);
+ fetch_picked_ref_frames_mask(x, bsize, cm->mib_size);
}
}
#else // CONFIG_EXT_RECUR_PARTITIONS
@@ -9487,7 +9483,7 @@
mbmi->partition != PARTITION_HORZ) ||
cpi->sf.inter_sf.prune_ref_frame_for_rect_partitions >= 2) {
picked_ref_frames_mask =
- fetch_picked_ref_frames_mask(x, bsize, cm->seq_params.mib_size);
+ fetch_picked_ref_frames_mask(x, bsize, cm->mib_size);
}
}
#endif // CONFIG_EXT_RECUR_PARTITIONS
@@ -9593,7 +9589,7 @@
(AOMMIN(cm->width, cm->height) > 480 && cpi->speed <= 1) ? 0 : 1;
if (do_pruning && sf->intra_sf.skip_intra_in_interframe) {
// Only consider full SB.
- const BLOCK_SIZE sb_size = cm->seq_params.sb_size;
+ const BLOCK_SIZE sb_size = cm->sb_size;
const int tpl_bsize_1d = cpi->tpl_data.tpl_bsize_1d;
const int len = (block_size_wide[sb_size] / tpl_bsize_1d) *
(block_size_high[sb_size] / tpl_bsize_1d);
diff --git a/av1/encoder/rdopt.h b/av1/encoder/rdopt.h
index 3647c7d..de2167f 100644
--- a/av1/encoder/rdopt.h
+++ b/av1/encoder/rdopt.h
@@ -164,10 +164,8 @@
static INLINE int av1_get_sb_mi_size(const AV1_COMMON *const cm) {
const int mi_alloc_size_1d = mi_size_wide[cm->mi_params.mi_alloc_bsize];
int sb_mi_rows =
- (mi_size_wide[cm->seq_params.sb_size] + mi_alloc_size_1d - 1) /
- mi_alloc_size_1d;
- assert(mi_size_wide[cm->seq_params.sb_size] ==
- mi_size_high[cm->seq_params.sb_size]);
+ (mi_size_wide[cm->sb_size] + mi_alloc_size_1d - 1) / mi_alloc_size_1d;
+ assert(mi_size_wide[cm->sb_size] == mi_size_high[cm->sb_size]);
int sb_mi_size = sb_mi_rows * sb_mi_rows;
return sb_mi_size;
diff --git a/av1/encoder/segmentation.c b/av1/encoder/segmentation.c
index 766184d..7da61f4 100644
--- a/av1/encoder/segmentation.c
+++ b/av1/encoder/segmentation.c
@@ -291,19 +291,18 @@
tile_info.mi_row_start * cm->mi_params.mi_stride +
tile_info.mi_col_start;
for (mi_row = tile_info.mi_row_start; mi_row < tile_info.mi_row_end;
- mi_row += cm->seq_params.mib_size,
- mi_ptr += cm->seq_params.mib_size * cm->mi_params.mi_stride) {
+ mi_row += cm->mib_size,
+ mi_ptr += cm->mib_size * cm->mi_params.mi_stride) {
MB_MODE_INFO **mi = mi_ptr;
for (mi_col = tile_info.mi_col_start; mi_col < tile_info.mi_col_end;
- mi_col += cm->seq_params.mib_size,
- mi += cm->seq_params.mib_size) {
+ mi_col += cm->mib_size, mi += cm->mib_size) {
const SB_INFO *sbi = av1_get_sb_info(cm, mi_row, mi_col);
const PARTITION_TREE *ptree = sbi->ptree_root[AOM_PLANE_Y];
count_segs_sb(cm, xd, &tile_info, mi, no_pred_segcounts,
temporal_predictor_count, t_unpred_seg_counts, mi_row,
mi_col,
#if !CONFIG_EXT_RECUR_PARTITIONS
- cm->seq_params.sb_size,
+ cm->sb_size,
#endif // !CONFIG_EXT_RECUR_PARTITIONS
ptree);
}
diff --git a/av1/encoder/speed_features.c b/av1/encoder/speed_features.c
index 68fa3ee..0c8304f 100644
--- a/av1/encoder/speed_features.c
+++ b/av1/encoder/speed_features.c
@@ -309,6 +309,9 @@
sf->inter_sf.prune_ref_mv_idx_search = 1;
}
}
+#if CONFIG_BLOCK_256
+ sf->part_sf.use_square_partition_only_threshold = BLOCK_MAX;
+#endif // CONFIG_BLOCK_256
}
static void set_good_speed_features_framesize_independent(
@@ -393,6 +396,9 @@
} else {
sf->mv_sf.exhaustive_searches_thresh = (1 << 25);
}
+#if CONFIG_BLOCK_256
+ sf->mv_sf.fast_motion_estimation_on_block_256 = 1;
+#endif // CONFIG_BLOCK_256
sf->rd_sf.perform_coeff_opt = 1;
sf->hl_sf.superres_auto_search_type = SUPERRES_AUTO_DUAL;
@@ -754,6 +760,10 @@
part_sf->prune_rect_with_ml = 0;
part_sf->end_part_search_after_consec_failures = 0;
part_sf->ext_recur_depth = INT_MAX;
+#if CONFIG_BLOCK_256
+ part_sf->prune_rect_with_split_depth = 0;
+ part_sf->search_256_after_128 = 0;
+#endif // CONFIG_BLOCK_256
part_sf->prune_part_h_with_partition_boundary = 0;
#endif // CONFIG_EXT_RECUR_PARTITIONS
}
@@ -780,6 +790,9 @@
mv_sf->use_downsampled_sad = 0;
mv_sf->warp_search_method = WARP_SEARCH_SQUARE;
mv_sf->warp_search_iters = 8;
+#if CONFIG_BLOCK_256
+ mv_sf->fast_motion_estimation_on_block_256 = 0;
+#endif // CONFIG_BLOCK_256
}
#if CONFIG_FLEX_MVRES
@@ -990,6 +1003,12 @@
} else {
sf->part_sf.partition_search_breakout_dist_thr = (1 << 22);
}
+#if CONFIG_BLOCK_256
+ const int is_720p_or_larger = AOMMIN(cm->width, cm->height) >= 720;
+ if (is_720p_or_larger) {
+ sf->part_sf.prune_rect_with_split_depth = 1;
+ }
+#endif // CONFIG_BLOCK_256
sf->part_sf.partition_search_breakout_rate_thr = 100;
AOM_FALLTHROUGH_INTENDED;
case 4: AOM_FALLTHROUGH_INTENDED;
@@ -1069,6 +1088,9 @@
sf->inter_sf.reuse_erp_mode_flag =
(REUSE_PARTITION_MODE_FLAG | REUSE_INTERFRAME_FLAG);
sf->part_sf.prune_rect_with_none_rd = 1;
+#if CONFIG_BLOCK_256
+ sf->part_sf.search_256_after_128 = 1;
+#endif // CONFIG_BLOCK_256
AOM_FALLTHROUGH_INTENDED;
case 0: break;
default: assert(0 && "Invalid ERP pruning level.");
diff --git a/av1/encoder/speed_features.h b/av1/encoder/speed_features.h
index 90d048d..4607d30 100644
--- a/av1/encoder/speed_features.h
+++ b/av1/encoder/speed_features.h
@@ -515,6 +515,11 @@
// The recursion depth allowed for ext partitions
int ext_recur_depth;
+#if CONFIG_BLOCK_256
+ // Prune rect partitions if PARTITION_SPLIT goes deep.
+ int prune_rect_with_split_depth;
+#endif // CONFIG_BLOCK_256
+
// Search horizontal and vertical split before PARTITION_NONE if the neighbor
// blocks are much smaller than the current block size.
int adaptive_partition_search_order;
@@ -529,6 +534,10 @@
// H-parts.
int prune_part_4_with_partition_boundary;
#endif // CONFIG_UNEVEN_4WAY
+#if CONFIG_BLOCK_256
+ // Delay the search for block 256 to after block 128
+ int search_256_after_128;
+#endif // CONFIG_BLOCK_256
#endif // CONFIG_EXT_RECUR_PARTITIONS
} PARTITION_SPEED_FEATURES;
@@ -605,6 +614,11 @@
// Maximum number of iterations in WARPED_CAUSAL refinement search
int warp_search_iters;
+#if CONFIG_BLOCK_256
+ // Use faster motion search settings for partition blocks with at least one
+ // dimension that's >= 256
+ int fast_motion_estimation_on_block_256;
+#endif // CONFIG_BLOCK_256
} MV_SPEED_FEATURES;
typedef struct INTER_MODE_SPEED_FEATURES {
diff --git a/av1/encoder/tokenize.h b/av1/encoder/tokenize.h
index 5968d87..b886ea6 100644
--- a/av1/encoder/tokenize.h
+++ b/av1/encoder/tokenize.h
@@ -104,9 +104,12 @@
// Allocate memory for token related info.
static AOM_INLINE void alloc_token_info(AV1_COMMON *cm, TokenInfo *token_info) {
+ // We use the frame level sb size here instead of the seq level sb size. This
+ // is because fr_sb_size <= seq_sb_size, and we want to avoid repeated
+ // allocations. So we prefer to to allocate a larger memory in one go here.
int mi_rows_aligned_to_sb =
- ALIGN_POWER_OF_TWO(cm->mi_params.mi_rows, cm->seq_params.mib_size_log2);
- int sb_rows = mi_rows_aligned_to_sb >> cm->seq_params.mib_size_log2;
+ ALIGN_POWER_OF_TWO(cm->mi_params.mi_rows, cm->mib_size_log2);
+ int sb_rows = mi_rows_aligned_to_sb >> cm->mib_size_log2;
const int num_planes = av1_num_planes(cm);
unsigned int tokens =
get_token_alloc(cm->mi_params.mb_rows, cm->mi_params.mb_cols,
diff --git a/av1/encoder/tx_search.c b/av1/encoder/tx_search.c
index 53f4f4d..a98428c 100644
--- a/av1/encoder/tx_search.c
+++ b/av1/encoder/tx_search.c
@@ -56,16 +56,25 @@
// origin_threshold * 128 / 100
static const uint32_t skip_pred_threshold[3][BLOCK_SIZES_ALL] = {
{
- 64, 64, 64, 70, 60, 60, 68, 68, 68, 68, 68,
- 68, 68, 68, 68, 68, 64, 64, 70, 70, 68, 68,
+ 64, 64, 64, 70, 60, 60, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
+#if CONFIG_BLOCK_256
+ 68, 68, 68,
+#endif // CONFIG_BLOCK_256
+ 64, 64, 70, 70, 68, 68,
},
{
- 88, 88, 88, 86, 87, 87, 68, 68, 68, 68, 68,
- 68, 68, 68, 68, 68, 88, 88, 86, 86, 68, 68,
+ 88, 88, 88, 86, 87, 87, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
+#if CONFIG_BLOCK_256
+ 68, 68, 68,
+#endif // CONFIG_BLOCK_256
+ 88, 88, 86, 86, 68, 68,
},
{
- 90, 93, 93, 90, 93, 93, 74, 74, 74, 74, 74,
- 74, 74, 74, 74, 74, 90, 90, 90, 90, 74, 74,
+ 90, 93, 93, 90, 93, 93, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
+#if CONFIG_BLOCK_256
+ 74, 74, 74,
+#endif // CONFIG_BLOCK_256
+ 90, 90, 90, 90, 74, 74,
},
};
@@ -76,8 +85,11 @@
static const TX_SIZE max_predict_sf_tx_size[BLOCK_SIZES_ALL] = {
TX_4X4, TX_4X8, TX_8X4, TX_8X8, TX_8X16, TX_16X8,
TX_16X16, TX_16X16, TX_16X16, TX_16X16, TX_16X16, TX_16X16,
- TX_16X16, TX_16X16, TX_16X16, TX_16X16, TX_4X16, TX_16X4,
- TX_8X8, TX_8X8, TX_16X16, TX_16X16,
+ TX_16X16, TX_16X16, TX_16X16, TX_16X16,
+#if CONFIG_BLOCK_256
+ TX_16X16, TX_16X16, TX_16X16,
+#endif // CONFIG_BLOCK_256
+ TX_4X16, TX_16X4, TX_8X8, TX_8X8, TX_16X16, TX_16X16,
};
// look-up table for sqrt of number of pixels in a transform block
@@ -191,6 +203,7 @@
{ 0, { 5, 6, -1, -1 } },
};
+// TODO(any): Support rd_record_tree for BLOCK_256X256
static const RD_RECORD_IDX_NODE *rd_record_tree[BLOCK_SIZES_ALL] = {
NULL, // BLOCK_4X4
NULL, // BLOCK_4X8
@@ -208,12 +221,17 @@
rd_record_tree_64x128, // BLOCK_64X128
rd_record_tree_128x64, // BLOCK_128X64
rd_record_tree_128x128, // BLOCK_128X128
- NULL, // BLOCK_4X16
- NULL, // BLOCK_16X4
- rd_record_tree_1_4, // BLOCK_8X32
- rd_record_tree_4_1, // BLOCK_32X8
- rd_record_tree_1_4, // BLOCK_16X64
- rd_record_tree_4_1, // BLOCK_64X16
+#if CONFIG_BLOCK_256
+ NULL, // BLOCK_128X256
+ NULL, // BLOCK_256X128
+ NULL, // BLOCK_256X256
+#endif // CONFIG_BLOCK_256
+ NULL, // BLOCK_4X16
+ NULL, // BLOCK_16X4
+ rd_record_tree_1_4, // BLOCK_8X32
+ rd_record_tree_4_1, // BLOCK_32X8
+ rd_record_tree_1_4, // BLOCK_16X64
+ rd_record_tree_4_1, // BLOCK_64X16
};
static const int rd_record_tree_size[BLOCK_SIZES_ALL] = {
@@ -233,12 +251,17 @@
sizeof(rd_record_tree_64x128) / sizeof(RD_RECORD_IDX_NODE), // BLOCK_64X128
sizeof(rd_record_tree_128x64) / sizeof(RD_RECORD_IDX_NODE), // BLOCK_128X64
sizeof(rd_record_tree_128x128) / sizeof(RD_RECORD_IDX_NODE), // BLOCK_128X128
- 0, // BLOCK_4X16
- 0, // BLOCK_16X4
- sizeof(rd_record_tree_1_4) / sizeof(RD_RECORD_IDX_NODE), // BLOCK_8X32
- sizeof(rd_record_tree_4_1) / sizeof(RD_RECORD_IDX_NODE), // BLOCK_32X8
- sizeof(rd_record_tree_1_4) / sizeof(RD_RECORD_IDX_NODE), // BLOCK_16X64
- sizeof(rd_record_tree_4_1) / sizeof(RD_RECORD_IDX_NODE), // BLOCK_64X16
+#if CONFIG_BLOCK_256
+ 0, // BLOCK_128X256
+ 0, // BLOCK_256X128
+ 0, // BLOCK_256X256
+#endif // CONFIG_BLOCK_256
+ 0, // BLOCK_4X16
+ 0, // BLOCK_16X4
+ sizeof(rd_record_tree_1_4) / sizeof(RD_RECORD_IDX_NODE), // BLOCK_8X32
+ sizeof(rd_record_tree_4_1) / sizeof(RD_RECORD_IDX_NODE), // BLOCK_32X8
+ sizeof(rd_record_tree_1_4) / sizeof(RD_RECORD_IDX_NODE), // BLOCK_16X64
+ sizeof(rd_record_tree_4_1) / sizeof(RD_RECORD_IDX_NODE), // BLOCK_64X16
};
static INLINE void init_rd_record_tree(TXB_RD_INFO_NODE *tree,
@@ -2210,6 +2233,7 @@
if (plane) {
const CctxType cctx_type = av1_get_cctx_type(xd, blk_row, blk_col);
assert(cctx_type == CCTX_NONE);
+ (void)cctx_type;
}
#endif // CONFIG_DEBUG && CONFIG_CROSS_CHROMA_TX
@@ -3028,12 +3052,18 @@
// The buffer used to swap dqcoeff in macroblockd_plane so we can keep dqcoeff
// of the best tx_type. best_dqcoeff are initialized as those dqcoeffs
// obtained earlier with CCTX_NONE
+ const int max_sb_square_y = 1 << num_pels_log2_lookup[cm->sb_size];
+ const int max_sb_square_uv =
+ max_sb_square_y >>
+ (cm->seq_params.subsampling_x + cm->seq_params.subsampling_y);
tran_low_t *this_dqcoeff_c1 =
- aom_memalign(32, MAX_SB_SQUARE * sizeof(tran_low_t));
+ aom_memalign(32, max_sb_square_uv * sizeof(tran_low_t));
tran_low_t *this_dqcoeff_c2 =
- aom_memalign(32, MAX_SB_SQUARE * sizeof(tran_low_t));
- memcpy(this_dqcoeff_c1, p_c1->dqcoeff, sizeof(tran_low_t) * MAX_SB_SQUARE);
- memcpy(this_dqcoeff_c2, p_c2->dqcoeff, sizeof(tran_low_t) * MAX_SB_SQUARE);
+ aom_memalign(32, max_sb_square_uv * sizeof(tran_low_t));
+ memcpy(this_dqcoeff_c1 + BLOCK_OFFSET(block),
+ p_c1->dqcoeff + BLOCK_OFFSET(block), sizeof(tran_low_t) * max_eob);
+ memcpy(this_dqcoeff_c2 + BLOCK_OFFSET(block),
+ p_c2->dqcoeff + BLOCK_OFFSET(block), sizeof(tran_low_t) * max_eob);
tran_low_t *orig_dqcoeff_c1 = p_c1->dqcoeff;
tran_low_t *orig_dqcoeff_c2 = p_c2->dqcoeff;
tran_low_t *best_dqcoeff_c1 = this_dqcoeff_c1;