Bugfix for SDP when multiple tiles are applied
This commit fixes the bug when multiple-tile encoding are employed. tree_type is a super block level parameter, it can be luma_part or chroma_part or shared_part. When SDP is enabled, encoder will loop luma_part and chroma_part for each super block. But previously, this variable tree_type was mistakenly added to AV1_COMMON struct.
The compiling flag CONFIG_SDP is turned off by default in this CL.
Change-Id: Ia05424455fd7583a5eb059ead46dd55a4563452b
(cherry picked from commit 3af1f7b6353b81e2684e0496099c29938f4eab1f)
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index a05c320..a07b973 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -652,7 +652,7 @@
const AV1_COMMON *cm, const MACROBLOCKD *xd, const MB_MODE_INFO *const mbmi,
aom_writer *w) {
#if CONFIG_SDP
- if (av1_filter_intra_allowed(cm, mbmi) && cm->tree_type != CHROMA_PART) {
+ if (av1_filter_intra_allowed(cm, mbmi) && xd->tree_type != CHROMA_PART) {
#else
if (av1_filter_intra_allowed(cm, mbmi)) {
#endif
@@ -869,7 +869,12 @@
}
const int uv_dc_pred =
+#if CONFIG_SDP
+ num_planes > 1 && xd->tree_type != LUMA_PART &&
+ mbmi->uv_mode == UV_DC_PRED && xd->is_chroma_ref;
+#else
num_planes > 1 && mbmi->uv_mode == UV_DC_PRED && xd->is_chroma_ref;
+#endif
if (uv_dc_pred) {
const int n = pmi->palette_size[1];
const int palette_uv_mode_ctx = (pmi->palette_size[0] > 0);
@@ -1111,7 +1116,7 @@
// Y mode.
#if CONFIG_SDP
const int use_angle_delta = av1_use_angle_delta(bsize);
- if (cm->tree_type != CHROMA_PART) {
+ if (xd->tree_type != CHROMA_PART) {
#endif
if (is_keyframe) {
const MB_MODE_INFO *const above_mi = xd->above_mbmi;
@@ -1141,7 +1146,7 @@
// UV mode and UV angle delta.
#if CONFIG_SDP
if (!cm->seq_params.monochrome && xd->is_chroma_ref &&
- cm->tree_type != LUMA_PART) {
+ xd->tree_type != LUMA_PART) {
#else
if (!cm->seq_params.monochrome && xd->is_chroma_ref) {
#endif
@@ -1425,7 +1430,11 @@
write_delta_q_params(cpi, skip, w);
+#if CONFIG_SDP
+ if (av1_allow_intrabc(cm) && xd->tree_type != CHROMA_PART) {
+#else
if (av1_allow_intrabc(cm)) {
+#endif
write_intrabc_info(xd, mbmi_ext_frame, w);
if (is_intrabc_block(mbmi)) return;
}
@@ -1634,7 +1643,13 @@
const int num_planes = av1_num_planes(cm);
for (int row = 0; row < num_4x4_h; row += mu_blocks_high) {
for (int col = 0; col < num_4x4_w; col += mu_blocks_wide) {
+#if CONFIG_SDP
+ const int plane_start = (xd->tree_type == CHROMA_PART);
+ const int plane_end = (xd->tree_type == LUMA_PART) ? 1 : num_planes;
+ for (int plane = plane_start; plane < plane_end; ++plane) {
+#else
for (int plane = 0; plane < num_planes; ++plane) {
+#endif
if (plane && !xd->is_chroma_ref) break;
write_inter_txb_coeff(cm, x, mbmi, w, tok, tok_end, &token_stats, row,
col, &block[plane], plane);
@@ -1701,8 +1716,10 @@
write_mbmi_b(cpi, w);
#if CONFIG_SDP
- for (int plane = (cm->tree_type == CHROMA_PART);
- plane < AOMMIN(2, av1_num_planes(cm)); ++plane) {
+ const int plane_start = (xd->tree_type == CHROMA_PART);
+ const int plane_end =
+ (xd->tree_type == LUMA_PART ? 1 : AOMMIN(2, av1_num_planes(cm)));
+ for (int plane = plane_start; plane < plane_end; ++plane) {
#else
for (int plane = 0; plane < AOMMIN(2, av1_num_planes(cm)); ++plane) {
#endif
@@ -1743,7 +1760,7 @@
#endif
const int segment_id = mbmi->segment_id;
#if CONFIG_SDP
- if (cm->tree_type != CHROMA_PART) {
+ if (xd->tree_type != CHROMA_PART) {
#endif
if (cm->features.tx_mode == TX_MODE_SELECT && block_signals_txsize(bsize) &&
!(is_inter_tx && skip_txfm) && !xd->lossless[segment_id]) {
@@ -1860,16 +1877,21 @@
const int hbs = mi_size_wide[bsize] / 2;
const int quarter_step = mi_size_wide[bsize] / 4;
int i;
+#if CONFIG_SDP
+ const PARTITION_TYPE partition =
+ get_partition(cm, xd->tree_type == CHROMA_PART, mi_row, mi_col, bsize);
+#else
const PARTITION_TYPE partition = get_partition(cm, mi_row, mi_col, bsize);
+#endif
const BLOCK_SIZE subsize = get_partition_subsize(bsize, partition);
if (mi_row >= mi_params->mi_rows || mi_col >= mi_params->mi_cols) return;
const int num_planes = av1_num_planes(cm);
#if CONFIG_SDP
- xd->tree_type = cm->tree_type;
- for (int plane = (cm->tree_type == CHROMA_PART); plane < num_planes;
- ++plane) {
+ const int plane_start = (xd->tree_type == CHROMA_PART);
+ const int plane_end = (xd->tree_type == LUMA_PART) ? 1 : num_planes;
+ for (int plane = plane_start; plane < plane_end; ++plane) {
#else
for (int plane = 0; plane < num_planes; ++plane) {
#endif
@@ -1993,17 +2015,16 @@
#if CONFIG_SDP
int totalLoopNum =
(frame_is_intra_only(cm) && !cm->seq_params.monochrome) ? 2 : 1;
- cm->tree_type = (totalLoopNum == 1 ? SHARED_PART : LUMA_PART);
+ xd->tree_type = (totalLoopNum == 1 ? SHARED_PART : LUMA_PART);
#endif
write_modes_sb(cpi, tile, w, &tok, tok_end, mi_row, mi_col,
cm->seq_params.sb_size);
#if CONFIG_SDP
if (totalLoopNum == 2) {
- cm->tree_type = CHROMA_PART;
+ xd->tree_type = CHROMA_PART;
write_modes_sb(cpi, tile, w, &tok, tok_end, mi_row, mi_col,
cm->seq_params.sb_size);
- cm->tree_type = SHARED_PART;
- xd->tree_type = cm->tree_type;
+ xd->tree_type = SHARED_PART;
}
#endif
}
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index c537461..9818ae1 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -482,14 +482,22 @@
av1_set_offsets(cpi, tile_info, x, mi_row, mi_col, sb_size);
const BLOCK_SIZE bsize =
seg_skip ? sb_size : sf->part_sf.fixed_partition_size;
+#if CONFIG_SDP
+ av1_set_fixed_partitioning(cpi, tile_info, x, mi, mi_row, mi_col, bsize);
+#else
av1_set_fixed_partitioning(cpi, tile_info, mi, mi_row, mi_col, bsize);
+#endif
} else if (cpi->partition_search_skippable_frame) {
// set a fixed-size partition for which the size is determined by the source
// variance
av1_set_offsets(cpi, tile_info, x, mi_row, mi_col, sb_size);
const BLOCK_SIZE bsize =
get_rd_var_based_fixed_partition(cpi, x, mi_row, mi_col);
+#if CONFIG_SDP
+ av1_set_fixed_partitioning(cpi, tile_info, x, mi, mi_row, mi_col, bsize);
+#else
av1_set_fixed_partitioning(cpi, tile_info, mi, mi_row, mi_col, bsize);
+#endif
} else if (sf->part_sf.partition_search_type == VAR_BASED_PARTITION) {
// set a variance-based partition
av1_set_offsets_without_segment_id(cpi, tile_info, x, mi_row, mi_col,
@@ -510,15 +518,13 @@
(frame_is_intra_only(cm) && !cm->seq_params.monochrome) ? 2 : 1;
MACROBLOCKD *const xd = &x->e_mbd;
for (int loopIdx = 0; loopIdx < totalLoopNum; loopIdx++) {
- cm->tree_type =
+ xd->tree_type =
(totalLoopNum == 1 ? SHARED_PART
: (loopIdx == 0 ? LUMA_PART : CHROMA_PART));
- xd->tree_type = cm->tree_type;
- td->mb.cb_offset[cm->tree_type == CHROMA_PART] = 0;
+ td->mb.cb_offset[xd->tree_type == CHROMA_PART] = 0;
av1_nonrd_use_partition(cpi, td, tile_data, mi, tp, mi_row, mi_col, sb_size,
pc_root);
}
- cm->tree_type = SHARED_PART;
xd->tree_type = SHARED_PART;
#else
av1_nonrd_use_partition(cpi, td, tile_data, mi, tp, mi_row, mi_col, sb_size,
@@ -619,10 +625,9 @@
#if CONFIG_SDP
for (int loopIdx = 0; loopIdx < totalLoopNum; loopIdx++) {
- cm->tree_type =
+ xd->tree_type =
(totalLoopNum == 1 ? SHARED_PART
: (loopIdx == 0 ? LUMA_PART : CHROMA_PART));
- xd->tree_type = cm->tree_type;
int num_planes = av1_num_planes(cm);
#endif
init_encode_rd_sb(cpi, td, tile_data, sms_root, &dummy_rdc, mi_row, mi_col,
@@ -645,7 +650,11 @@
av1_set_offsets(cpi, tile_info, x, mi_row, mi_col, sb_size);
const BLOCK_SIZE bsize =
seg_skip ? sb_size : sf->part_sf.fixed_partition_size;
+#if CONFIG_SDP
+ av1_set_fixed_partitioning(cpi, tile_info, x, mi, mi_row, mi_col, bsize);
+#else
av1_set_fixed_partitioning(cpi, tile_info, mi, mi_row, mi_col, bsize);
+#endif
PC_TREE *const pc_root = av1_alloc_pc_tree_node(sb_size);
av1_rd_use_partition(cpi, td, tile_data, mi, tp, mi_row, mi_col, sb_size,
&dummy_rate, &dummy_dist, 1, pc_root);
@@ -656,7 +665,11 @@
av1_set_offsets(cpi, tile_info, x, mi_row, mi_col, sb_size);
const BLOCK_SIZE bsize =
get_rd_var_based_fixed_partition(cpi, x, mi_row, mi_col);
+#if CONFIG_SDP
+ av1_set_fixed_partitioning(cpi, tile_info, x, mi, mi_row, mi_col, bsize);
+#else
av1_set_fixed_partitioning(cpi, tile_info, mi, mi_row, mi_col, bsize);
+#endif
PC_TREE *const pc_root = av1_alloc_pc_tree_node(sb_size);
av1_rd_use_partition(cpi, td, tile_data, mi, tp, mi_row, mi_col, sb_size,
&dummy_rate, &dummy_dist, 1, pc_root);
@@ -722,7 +735,6 @@
}
#endif
#if CONFIG_SDP
- cm->tree_type = SHARED_PART;
xd->tree_type = SHARED_PART;
#endif
diff --git a/av1/encoder/encodeframe_utils.c b/av1/encoder/encodeframe_utils.c
index 5546ff6..d716db9 100644
--- a/av1/encoder/encodeframe_utils.c
+++ b/av1/encoder/encodeframe_utils.c
@@ -730,6 +730,9 @@
}
static void set_partial_sb_partition(const AV1_COMMON *const cm,
+#if CONFIG_SDP
+ MACROBLOCKD *const xd,
+#endif
MB_MODE_INFO *mi, int bh_in, int bw_in,
int mi_rows_remaining,
int mi_cols_remaining, BLOCK_SIZE bsize,
@@ -743,7 +746,7 @@
const int mi_index = get_alloc_mi_idx(&cm->mi_params, r, c);
mib[grid_index] = mi + mi_index;
#if CONFIG_SDP
- mib[grid_index]->sb_type[cm->tree_type == CHROMA_PART] =
+ mib[grid_index]->sb_type[xd->tree_type == CHROMA_PART] =
find_partition_size(bsize, mi_rows_remaining - r,
mi_cols_remaining - c, &bh, &bw);
#else
@@ -760,6 +763,9 @@
// may not be allowed in which case this code attempts to choose the largest
// allowable partition.
void av1_set_fixed_partitioning(AV1_COMP *cpi, const TileInfo *const tile,
+#if CONFIG_SDP
+ MACROBLOCK *const x,
+#endif
MB_MODE_INFO **mib, int mi_row, int mi_col,
BLOCK_SIZE bsize) {
AV1_COMMON *const cm = &cpi->common;
@@ -771,6 +777,10 @@
int bh = mi_size_high[bsize];
int bw = mi_size_wide[bsize];
+#if CONFIG_SDP
+ MACROBLOCKD *const xd = &x->e_mbd;
+#endif
+
assert(bsize >= mi_params->mi_alloc_bsize &&
"Attempted to use bsize < mi_params->mi_alloc_bsize");
assert((mi_rows_remaining > 0) && (mi_cols_remaining > 0));
@@ -786,7 +796,7 @@
const int mi_index = get_alloc_mi_idx(mi_params, block_row, block_col);
mib[grid_index] = mi_upper_left + mi_index;
#if CONFIG_SDP
- mib[grid_index]->sb_type[cm->tree_type == CHROMA_PART] = bsize;
+ mib[grid_index]->sb_type[xd->tree_type == CHROMA_PART] = bsize;
#else
mib[grid_index]->sb_type = bsize;
#endif
@@ -794,12 +804,20 @@
}
} else {
// Else this is a partial SB.
+#if CONFIG_SDP
+ set_partial_sb_partition(cm, xd, mi_upper_left, bh, bw, mi_rows_remaining,
+#else
set_partial_sb_partition(cm, mi_upper_left, bh, bw, mi_rows_remaining,
+#endif
mi_cols_remaining, bsize, mib);
}
}
-
+#if CONFIG_SDP
+int av1_is_leaf_split_partition(AV1_COMMON *cm, MACROBLOCKD *const xd,
+ int mi_row, int mi_col,
+#else
int av1_is_leaf_split_partition(AV1_COMMON *cm, int mi_row, int mi_col,
+#endif
BLOCK_SIZE bsize) {
const int bs = mi_size_wide[bsize];
const int hbs = bs / 2;
@@ -812,7 +830,12 @@
if ((mi_row + y_idx >= cm->mi_params.mi_rows) ||
(mi_col + x_idx >= cm->mi_params.mi_cols))
return 0;
+#if CONFIG_SDP
+ if (get_partition(cm, xd->tree_type == CHROMA_PART, mi_row + y_idx,
+ mi_col + x_idx, subsize) !=
+#else
if (get_partition(cm, mi_row + y_idx, mi_col + x_idx, subsize) !=
+#endif
PARTITION_NONE &&
subsize != BLOCK_8X8)
return 0;
@@ -1457,7 +1480,11 @@
if (mi_col != tile_info->mi_col_start) break;
AOM_FALLTHROUGH_INTENDED;
case COST_UPD_SB: // SB level
+#if CONFIG_SDP
+ av1_fill_mode_rates(cm, xd, &x->mode_costs, xd->tile_ctx);
+#else
av1_fill_mode_rates(cm, &x->mode_costs, xd->tile_ctx);
+#endif
break;
default: assert(0);
}
diff --git a/av1/encoder/encodeframe_utils.h b/av1/encoder/encodeframe_utils.h
index 20927f5..cee182d 100644
--- a/av1/encoder/encodeframe_utils.h
+++ b/av1/encoder/encodeframe_utils.h
@@ -301,10 +301,17 @@
const int num_planes);
void av1_set_fixed_partitioning(AV1_COMP *cpi, const TileInfo *const tile,
+#if CONFIG_SDP
+ MACROBLOCK *const x,
+#endif
MB_MODE_INFO **mib, int mi_row, int mi_col,
BLOCK_SIZE bsize);
-
+#if CONFIG_SDP
+int av1_is_leaf_split_partition(AV1_COMMON *cm, MACROBLOCKD *const xd,
+ int mi_row, int mi_col,
+#else
int av1_is_leaf_split_partition(AV1_COMMON *cm, int mi_row, int mi_col,
+#endif
BLOCK_SIZE bsize);
void av1_reset_simple_motion_tree_partition(SIMPLE_MOTION_DATA_TREE *sms_tree,
diff --git a/av1/encoder/encodetxb.c b/av1/encoder/encodetxb.c
index 5691870..f6addbb 100644
--- a/av1/encoder/encodetxb.c
+++ b/av1/encoder/encodetxb.c
@@ -496,8 +496,9 @@
for (row = 0; row < max_blocks_high; row += mu_blocks_high) {
for (col = 0; col < max_blocks_wide; col += mu_blocks_wide) {
#if CONFIG_SDP
- for (int plane = (cm->tree_type == CHROMA_PART); plane < num_planes;
- ++plane) {
+ const int plane_start = (xd->tree_type == CHROMA_PART);
+ const int plane_end = (xd->tree_type == LUMA_PART) ? 1 : num_planes;
+ for (int plane = plane_start; plane < plane_end; ++plane) {
#else
for (int plane = 0; plane < num_planes; ++plane) {
#endif
@@ -1576,8 +1577,9 @@
return;
}
#if CONFIG_SDP
- for (int plane = (xd->tree_type == CHROMA_PART); plane < num_planes;
- ++plane) {
+ const int plane_start = (xd->tree_type == CHROMA_PART);
+ const int plane_end = (xd->tree_type == LUMA_PART) ? 1 : num_planes;
+ for (int plane = plane_start; plane < plane_end; ++plane) {
#else
for (int plane = 0; plane < num_planes; ++plane) {
#endif
diff --git a/av1/encoder/intra_mode_search_utils.h b/av1/encoder/intra_mode_search_utils.h
index 65f2336..89335c3 100644
--- a/av1/encoder/intra_mode_search_utils.h
+++ b/av1/encoder/intra_mode_search_utils.h
@@ -319,7 +319,11 @@
#endif
}
}
+#if CONFIG_SDP
+ if (av1_allow_intrabc(&cpi->common) && mbmi->tree_type != CHROMA_PART)
+#else
if (av1_allow_intrabc(&cpi->common))
+#endif
total_rate += mode_costs->intrabc_cost[use_intrabc];
return total_rate;
}
diff --git a/av1/encoder/mv_prec.c b/av1/encoder/mv_prec.c
index d1984e9..4dfc6ba 100644
--- a/av1/encoder/mv_prec.c
+++ b/av1/encoder/mv_prec.c
@@ -275,8 +275,12 @@
if (mi_row >= cm->mi_params.mi_rows || mi_col >= cm->mi_params.mi_cols)
return;
-
+#if CONFIG_SDP
+ const PARTITION_TYPE partition =
+ get_partition(cm, SHARED_PART, mi_row, mi_col, bsize);
+#else
const PARTITION_TYPE partition = get_partition(cm, mi_row, mi_col, bsize);
+#endif
const BLOCK_SIZE subsize = get_partition_subsize(bsize, partition);
const int hbs = mi_size_wide[bsize] / 2;
diff --git a/av1/encoder/partition_search.c b/av1/encoder/partition_search.c
index 62ba72f..25ba7d5 100644
--- a/av1/encoder/partition_search.c
+++ b/av1/encoder/partition_search.c
@@ -247,7 +247,7 @@
const int mi_col = xd->mi_col;
if (!is_inter) {
#if CONFIG_SDP
- if (cm->tree_type != LUMA_PART) {
+ if (xd->tree_type != LUMA_PART) {
xd->cfl.store_y = store_cfl_required(cm, xd);
}
#else
@@ -259,8 +259,9 @@
mbmi->skip_txfm = 1;
#endif
#if CONFIG_SDP
- for (int plane = (xd->tree_type == CHROMA_PART); plane < num_planes;
- ++plane) {
+ const int plane_start = (xd->tree_type == CHROMA_PART);
+ const int plane_end = (xd->tree_type == LUMA_PART) ? 1 : num_planes;
+ for (int plane = plane_start; plane < plane_end; ++plane) {
#else
for (int plane = 0; plane < num_planes; ++plane) {
#endif
@@ -282,8 +283,7 @@
xd->cfl.store_y = 0;
if (av1_allow_palette(cm->features.allow_screen_content_tools, bsize)) {
#if CONFIG_SDP
- for (int plane = (cm->tree_type == CHROMA_PART);
- plane < AOMMIN(2, av1_num_planes(cm)); ++plane) {
+ for (int plane = plane_start; plane < AOMMIN(2, plane_end); ++plane) {
#else
for (int plane = 0; plane < AOMMIN(2, num_planes); ++plane) {
#endif
@@ -947,8 +947,11 @@
av1_sum_intra_stats(cm, td->counts, xd, mbmi, xd->above_mbmi, xd->left_mbmi,
frame_is_intra_only(cm));
}
-
+#if CONFIG_SDP
+ if (av1_allow_intrabc(cm) && mbmi->tree_type != CHROMA_PART) {
+#else
if (av1_allow_intrabc(cm)) {
+#endif
update_cdf(fc->intrabc_cdf, is_intrabc_block(mbmi), 2);
#if CONFIG_ENTROPY_STATS
++td->counts->intrabc[is_intrabc_block(mbmi)];
@@ -1538,10 +1541,9 @@
if (tile_data->allow_update_cdf) {
FRAME_CONTEXT *fc = xd->tile_ctx;
#if CONFIG_SDP
-#if CONFIG_SDP
int luma_split_flag = 0;
int parent_block_width = block_size_wide[bsize];
- if (cm->tree_type == CHROMA_PART &&
+ if (xd->tree_type == CHROMA_PART &&
parent_block_width >= SHARED_PART_SIZE) {
luma_split_flag =
get_luma_split_flag(bsize, mi_params, mi_row, mi_col);
@@ -1554,10 +1556,6 @@
assert(partition == PARTITION_SPLIT);
}
#else
- update_cdf(fc->partition_cdf[plane_index][ctx], partition,
- partition_cdf_length(bsize));
-#endif
-#else
update_cdf(fc->partition_cdf[ctx], partition,
partition_cdf_length(bsize));
#endif
@@ -1703,7 +1701,12 @@
? partition_plane_context(xd, mi_row, mi_col, bsize)
: 0;
const PARTITION_TYPE partition =
+#if CONFIG_SDP
+ (bsize >= BLOCK_8X8) ? get_partition(cm, xd->tree_type == CHROMA_PART,
+ mi_row, mi_col, bsize)
+#else
(bsize >= BLOCK_8X8) ? get_partition(cm, mi_row, mi_col, bsize)
+#endif
: PARTITION_NONE;
const BLOCK_SIZE subsize = get_partition_subsize(bsize, partition);
RD_SEARCH_MACROBLOCK_CONTEXT x_ctx;
@@ -2245,7 +2248,12 @@
const int bs = mi_size_wide[bsize];
const int hbs = bs / 2;
const PARTITION_TYPE partition =
+#if CONFIG_SDP
+ (bsize >= BLOCK_8X8) ? get_partition(cm, xd->tree_type == CHROMA_PART,
+ mi_row, mi_col, bsize)
+#else
(bsize >= BLOCK_8X8) ? get_partition(cm, mi_row, mi_col, bsize)
+#endif
: PARTITION_NONE;
BLOCK_SIZE subsize = get_partition_subsize(bsize, partition);
assert(subsize <= BLOCK_LARGEST);
@@ -2398,7 +2406,11 @@
pc_tree->split[i]->index = i;
}
if (cpi->sf.rt_sf.nonrd_check_partition_merge_mode &&
+#if CONFIG_SDP
+ av1_is_leaf_split_partition(cm, xd, mi_row, mi_col, bsize) &&
+#else
av1_is_leaf_split_partition(cm, mi_row, mi_col, bsize) &&
+#endif
!frame_is_intra_only(cm) && bsize <= BLOCK_32X32) {
RD_SEARCH_MACROBLOCK_CONTEXT x_ctx;
RD_STATS split_rdc, none_rdc;
@@ -2738,11 +2750,16 @@
// Override partition cost buffer for the edge blocks.
static void set_partition_cost_for_edge_blk(
+#if CONFIG_SDP
+ AV1_COMMON const *cm, MACROBLOCKD *const xd,
+ PartitionSearchState *part_search_state) {
+#else
AV1_COMMON const *cm, PartitionSearchState *part_search_state) {
+#endif
PartitionBlkParams blk_params = part_search_state->part_blk_params;
assert(blk_params.bsize_at_least_8x8 && part_search_state->pl_ctx_idx >= 0);
#if CONFIG_SDP
- const int plane = cm->tree_type == CHROMA_PART;
+ const int plane = xd->tree_type == CHROMA_PART;
const aom_cdf_prob *partition_cdf =
cm->fc->partition_cdf[plane][part_search_state->pl_ctx_idx];
#else
@@ -3803,7 +3820,11 @@
// 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))
+#if CONFIG_SDP
+ set_partition_cost_for_edge_blk(cm, xd, &part_search_state);
+#else
set_partition_cost_for_edge_blk(cm, &part_search_state);
+#endif
// Disable rectangular partitions for inner blocks when the current block is
// forced to only use square partitions.
@@ -3867,7 +3888,7 @@
int luma_split_flag = 0;
int parent_block_width = block_size_wide[bsize];
const CommonModeInfoParams *const mi_params = &cm->mi_params;
- if (cm->tree_type == CHROMA_PART && parent_block_width >= SHARED_PART_SIZE) {
+ if (xd->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 blocks uses smaller blocks, then chroma will also split
diff --git a/av1/encoder/rd.c b/av1/encoder/rd.c
index a55d248..d92dfa0 100644
--- a/av1/encoder/rd.c
+++ b/av1/encoder/rd.c
@@ -83,13 +83,17 @@
EXT_TX_SET_DCT_IDTX,
},
};
-
+#if CONFIG_SDP
+void av1_fill_mode_rates(AV1_COMMON *const cm, const MACROBLOCKD *xd,
+ ModeCosts *mode_costs,
+#else
void av1_fill_mode_rates(AV1_COMMON *const cm, ModeCosts *mode_costs,
+#endif
FRAME_CONTEXT *fc) {
int i, j;
#if CONFIG_SDP
const int num_planes = av1_num_planes(cm);
- for (int plane_index = (cm->tree_type == CHROMA_PART);
+ for (int plane_index = (xd->tree_type == CHROMA_PART);
plane_index < num_planes; plane_index++) {
for (i = 0; i < PARTITION_CONTEXTS; ++i)
av1_cost_tokens_from_cdf(mode_costs->partition_cost[plane_index][i],
diff --git a/av1/encoder/rd.h b/av1/encoder/rd.h
index 5e9bfcd..ecc101f 100644
--- a/av1/encoder/rd.h
+++ b/av1/encoder/rd.h
@@ -353,8 +353,12 @@
int av1_get_intra_cost_penalty(int qindex, int qdelta,
aom_bit_depth_t bit_depth);
-
+#if CONFIG_SDP
+void av1_fill_mode_rates(AV1_COMMON *const cm, const MACROBLOCKD *xd,
+ ModeCosts *mode_costs,
+#else
void av1_fill_mode_rates(AV1_COMMON *const cm, ModeCosts *mode_costs,
+#endif
FRAME_CONTEXT *fc);
void av1_fill_lr_rates(ModeCosts *mode_costs, FRAME_CONTEXT *fc);
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index b906838..35c8451 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -2954,11 +2954,18 @@
RD_STATS *rd_stats, BLOCK_SIZE bsize,
int64_t best_rd) {
const AV1_COMMON *const cm = &cpi->common;
+#if CONFIG_SDP
+ MACROBLOCKD *const xd = &x->e_mbd;
+ if (!av1_allow_intrabc(cm) || (xd->tree_type == CHROMA_PART) ||
+ !cpi->oxcf.kf_cfg.enable_intrabc)
+#else
if (!av1_allow_intrabc(cm) || !cpi->oxcf.kf_cfg.enable_intrabc)
+#endif
return INT64_MAX;
const int num_planes = av1_num_planes(cm);
-
+#if !CONFIG_SDP
MACROBLOCKD *const xd = &x->e_mbd;
+#endif
const TileInfo *tile = &xd->tile;
MB_MODE_INFO *mbmi = xd->mi[0];
TxfmSearchInfo *txfm_info = &x->txfm_search_info;
@@ -5347,7 +5354,7 @@
float probs[2] = { 0.0f };
#if CONFIG_SDP
nn_features[0] = (float)search_state.best_mbmode
- .skip_txfm[cm->tree_type != CHROMA_PART ? 0 : 1];
+ .skip_txfm[xd->tree_type != CHROMA_PART ? 0 : 1];
#else
nn_features[0] = (float)search_state.best_mbmode.skip_txfm;
#endif
@@ -5366,7 +5373,7 @@
if (probs[1] > 0.8) search_state.intra_search_state.skip_intra_modes = 1;
#if CONFIG_SDP
} else if ((search_state.best_mbmode
- .skip_txfm[cm->tree_type == CHROMA_PART]) &&
+ .skip_txfm[xd->tree_type == CHROMA_PART]) &&
(sf->intra_sf.skip_intra_in_interframe >= 2)) {
#else
} else if ((search_state.best_mbmode.skip_txfm) &&
diff --git a/av1/encoder/segmentation.c b/av1/encoder/segmentation.c
index daa62f5..a240b59 100644
--- a/av1/encoder/segmentation.c
+++ b/av1/encoder/segmentation.c
@@ -108,7 +108,12 @@
if (bsize == BLOCK_8X8)
partition = PARTITION_NONE;
else
+#if CONFIG_SDP
+ partition =
+ get_partition(cm, xd->tree_type == CHROMA_PART, mi_row, mi_col, bsize);
+#else
partition = get_partition(cm, mi_row, mi_col, bsize);
+#endif
switch (partition) {
case PARTITION_NONE: CSEGS(bs, bs, 0, 0); break;
case PARTITION_HORZ:
diff --git a/av1/encoder/tokenize.c b/av1/encoder/tokenize.c
index 1047ee1..d977c7b 100644
--- a/av1/encoder/tokenize.c
+++ b/av1/encoder/tokenize.c
@@ -214,8 +214,13 @@
av1_reset_entropy_context(xd, bsize, num_planes);
return;
}
-
+#if CONFIG_SDP
+ const int plane_start = (xd->tree_type == CHROMA_PART);
+ const int plane_end = (xd->tree_type == LUMA_PART) ? 1 : num_planes;
+ for (int plane = plane_start; plane < plane_end; ++plane) {
+#else
for (int plane = 0; plane < num_planes; ++plane) {
+#endif
if (plane && !xd->is_chroma_ref) break;
const struct macroblockd_plane *const pd = &xd->plane[plane];
const int ss_x = pd->subsampling_x;