Commit 0187f4b4 authored by Marco's avatar Marco

Adjustments to cyclic refresh (aq-mode=3).

Target higher delta-qp for big blocks with zero motion,
and for segment#1: avoid 64x64 partition size and force 8x8 tx size.

Metrics on RTC set mostly positive: SSIM up by ~4%, PSRN by ~1.5%.
Doesn't seem to be any change in speed.

Change-Id: I1f68fa3c4f62dab3b90cc58041f05ebb048ae5ac
parent a28a8cb7
This diff is collapsed.
......@@ -18,6 +18,18 @@
extern "C" {
#endif
// The segment ids used in cyclic refresh: from base (no boost) to increasing
// boost (higher delta-qp).
#define CR_SEGMENT_ID_BASE 0
#define CR_SEGMENT_ID_BOOST1 1
#define CR_SEGMENT_ID_BOOST2 2
// Maximum rate target ratio for setting segment delta-qp.
#define CR_MAX_RATE_TARGET_RATIO 4.0
// Boost factor for rate target ratio, for segment CR_SEGMENT_ID_BOOST2.
#define CR_BOOST2_FAC 1.7
struct VP9_COMP;
struct CYCLIC_REFRESH;
......
......@@ -403,7 +403,8 @@ static int set_vt_partitioning(VP9_COMP *cpi,
int mi_row,
int mi_col,
int64_t threshold,
BLOCK_SIZE bsize_min) {
BLOCK_SIZE bsize_min,
int segment_id) {
VP9_COMMON * const cm = &cpi->common;
variance_node vt;
const int block_width = num_8x8_blocks_wide_lookup[bsize];
......@@ -412,6 +413,10 @@ static int set_vt_partitioning(VP9_COMP *cpi,
assert(block_height == block_width);
tree_to_node(data, bsize, &vt);
// No 64x64 blocks on segments other than base (un-boosted) segment.
if (segment_id != CR_SEGMENT_ID_BASE && bsize == BLOCK_64X64)
return 0;
// For bsize=bsize_min (16x16/8x8 for 8x8/4x4 downsampling), select if
// variance is below threshold, otherwise split will be selected.
// No check for vert/horiz split as too few samples for variance.
......@@ -645,6 +650,13 @@ static void choose_partitioning(VP9_COMP *cpi,
const int low_res = (cm->width <= 352 && cm->height <= 288);
int variance4x4downsample[16];
int segment_id = CR_SEGMENT_ID_BASE;
if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ && cm->seg.enabled) {
const uint8_t *const map = cm->seg.update_map ? cpi->segmentation_map :
cm->last_frame_seg_map;
segment_id = vp9_get_segment_id(cm, map, BLOCK_64X64, mi_row, mi_col);
}
set_offsets(cpi, tile, x, mi_row, mi_col, BLOCK_64X64);
if (xd->mb_to_right_edge < 0)
......@@ -817,7 +829,8 @@ static void choose_partitioning(VP9_COMP *cpi,
// we get to one that's got a variance lower than our threshold.
if ( mi_col + 8 > cm->mi_cols || mi_row + 8 > cm->mi_rows ||
!set_vt_partitioning(cpi, xd, &vt, BLOCK_64X64, mi_row, mi_col,
cpi->vbp_threshold_bsize_max, BLOCK_16X16)) {
cpi->vbp_threshold_bsize_max, BLOCK_16X16,
segment_id)) {
for (i = 0; i < 4; ++i) {
const int x32_idx = ((i & 1) << 2);
const int y32_idx = ((i >> 1) << 2);
......@@ -825,7 +838,7 @@ static void choose_partitioning(VP9_COMP *cpi,
if (!set_vt_partitioning(cpi, xd, &vt.split[i], BLOCK_32X32,
(mi_row + y32_idx), (mi_col + x32_idx),
cpi->vbp_threshold,
BLOCK_16X16)) {
BLOCK_16X16, segment_id)) {
for (j = 0; j < 4; ++j) {
const int x16_idx = ((j & 1) << 1);
const int y16_idx = ((j >> 1) << 1);
......@@ -839,7 +852,7 @@ static void choose_partitioning(VP9_COMP *cpi,
mi_row + y32_idx + y16_idx,
mi_col + x32_idx + x16_idx,
cpi->vbp_threshold_16x16,
cpi->vbp_bsize_min)) {
cpi->vbp_bsize_min, segment_id)) {
for (k = 0; k < 4; ++k) {
const int x8_idx = (k & 1);
const int y8_idx = (k >> 1);
......@@ -849,7 +862,7 @@ static void choose_partitioning(VP9_COMP *cpi,
mi_row + y32_idx + y16_idx + y8_idx,
mi_col + x32_idx + x16_idx + x8_idx,
cpi->vbp_threshold_bsize_min,
BLOCK_8X8)) {
BLOCK_8X8, segment_id)) {
set_block_size(cpi, xd,
(mi_row + y32_idx + y16_idx + y8_idx),
(mi_col + x32_idx + x16_idx + x8_idx),
......
......@@ -242,9 +242,13 @@ static void model_rd_for_sb_y(VP9_COMP *cpi, BLOCK_SIZE bsize,
else
xd->mi[0].src_mi->mbmi.tx_size = TX_8X8;
if (cpi->sf.partition_search_type == VAR_BASED_PARTITION &&
xd->mi[0].src_mi->mbmi.tx_size > TX_16X16)
xd->mi[0].src_mi->mbmi.tx_size = TX_16X16;
if (cpi->sf.partition_search_type == VAR_BASED_PARTITION) {
if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ &&
xd->mi[0].src_mi->mbmi.segment_id != CR_SEGMENT_ID_BASE)
xd->mi[0].src_mi->mbmi.tx_size = TX_8X8;
else if (xd->mi[0].src_mi->mbmi.tx_size > TX_16X16)
xd->mi[0].src_mi->mbmi.tx_size = TX_16X16;
}
} else {
xd->mi[0].src_mi->mbmi.tx_size =
MIN(max_txsize_lookup[bsize],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment