Fix cdf and cost update of sb partition 1) Add cdf update in RDO 2) Always enable cost update instead of only for key frames 3) Skip cdf update and stats collection at frame border BDRate: -0.068% Change-Id: I949ba0164a262eef4aef49bf2102eb417aa429ff
diff --git a/av1/common/enums.h b/av1/common/enums.h index 902bc7f..e48682a 100644 --- a/av1/common/enums.h +++ b/av1/common/enums.h
@@ -160,8 +160,7 @@ typedef char PARTITION_CONTEXT; #define PARTITION_PLOFFSET 4 // number of probability models per block size #define PARTITION_BLOCK_SIZES 5 -#define PARTITION_CONTEXTS_PRIMARY (PARTITION_BLOCK_SIZES * PARTITION_PLOFFSET) -#define PARTITION_CONTEXTS PARTITION_CONTEXTS_PRIMARY +#define PARTITION_CONTEXTS (PARTITION_BLOCK_SIZES * PARTITION_PLOFFSET) // block transform size #if defined(_MSC_VER)
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c index d4310ed..82331bf 100644 --- a/av1/encoder/encodeframe.c +++ b/av1/encoder/encodeframe.c
@@ -1467,7 +1467,20 @@ if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) return; - if (!dry_run && ctx >= 0) td->counts->partition[ctx][partition]++; + if (!dry_run && ctx >= 0) { + const int has_rows = (mi_row + hbs) < cm->mi_rows; + const int has_cols = (mi_col + hbs) < cm->mi_cols; + + if (has_rows && has_cols) { + td->counts->partition[ctx][partition]++; + + if (tile_data->allow_update_cdf) { + FRAME_CONTEXT *fc = xd->tile_ctx; + update_cdf(fc->partition_cdf[ctx], partition, + partition_cdf_length(bsize)); + } + } + } switch (partition) { case PARTITION_NONE:
diff --git a/av1/encoder/rd.c b/av1/encoder/rd.c index eea5995..50efbfa 100644 --- a/av1/encoder/rd.c +++ b/av1/encoder/rd.c
@@ -92,11 +92,8 @@ FRAME_CONTEXT *fc) { int i, j; - if (cm->frame_type == KEY_FRAME) { - for (i = 0; i < PARTITION_CONTEXTS_PRIMARY; ++i) - av1_cost_tokens_from_cdf(x->partition_cost[i], fc->partition_cdf[i], - NULL); - } + for (i = 0; i < PARTITION_CONTEXTS; ++i) + av1_cost_tokens_from_cdf(x->partition_cost[i], fc->partition_cdf[i], NULL); if (cm->skip_mode_flag) { for (i = 0; i < SKIP_CONTEXTS; ++i) {