Commit 109a2edf authored by Marco's avatar Marco Committed by Gerrit Code Review
Browse files

Merge "Refactor set_vbp_thresholds."

parents 30181c46 f76d42a9
...@@ -464,46 +464,53 @@ static int set_vt_partitioning(VP9_COMP *cpi, ...@@ -464,46 +464,53 @@ static int set_vt_partitioning(VP9_COMP *cpi,
return 0; return 0;
} }
void vp9_set_vbp_thresholds(VP9_COMP *cpi, int q) { // Set the variance split thresholds for following the block sizes:
// 0 - threshold_64x64, 1 - threshold_32x32, 2 - threshold_16x16,
// 3 - vbp_threshold_8x8. vbp_threshold_8x8 (to split to 4x4 partition) is
// currently only used on key frame.
static void set_vbp_thresholds(VP9_COMP *cpi, int64_t thresholds[], int q) {
VP9_COMMON *const cm = &cpi->common;
const int is_key_frame = (cm->frame_type == KEY_FRAME);
const int threshold_multiplier = is_key_frame ? 20 : 1;
const int64_t threshold_base = (int64_t)(threshold_multiplier *
cpi->y_dequant[q][1]);
if (is_key_frame) {
thresholds[0] = threshold_base;
thresholds[1] = threshold_base >> 2;
thresholds[2] = threshold_base >> 2;
thresholds[3] = threshold_base << 2;
} else {
thresholds[1] = threshold_base;
if (cm->width <= 352 && cm->height <= 288) {
thresholds[0] = threshold_base >> 2;
thresholds[2] = threshold_base << 3;
} else {
thresholds[0] = threshold_base;
thresholds[1] = (5 * threshold_base) >> 2;
thresholds[2] = threshold_base << cpi->oxcf.speed;
}
}
}
void vp9_set_variance_partition_thresholds(VP9_COMP *cpi, int q) {
VP9_COMMON *const cm = &cpi->common;
SPEED_FEATURES *const sf = &cpi->sf; SPEED_FEATURES *const sf = &cpi->sf;
const int is_key_frame = (cm->frame_type == KEY_FRAME);
if (sf->partition_search_type != VAR_BASED_PARTITION && if (sf->partition_search_type != VAR_BASED_PARTITION &&
sf->partition_search_type != REFERENCE_PARTITION) { sf->partition_search_type != REFERENCE_PARTITION) {
return; return;
} else { } else {
VP9_COMMON *const cm = &cpi->common; set_vbp_thresholds(cpi, cpi->vbp_thresholds, q);
const int is_key_frame = (cm->frame_type == KEY_FRAME); // The thresholds below are not changed locally.
const int threshold_multiplier = is_key_frame ? 20 : 1;
const int64_t threshold_base = (int64_t)(threshold_multiplier *
cpi->y_dequant[q][1]);
// TODO(marpan): Allow 4x4 partitions for inter-frames.
// use_4x4_partition = (variance4x4downsample[i2 + j] == 1);
// If 4x4 partition is not used, then 8x8 partition will be selected
// if variance of 16x16 block is very high, so use larger threshold
// for 16x16 (threshold_bsize_min) in that case.
// Array index: 0 - threshold_64x64; 1 - threshold_32x32;
// 2 - threshold_16x16; 3 - vbp_threshold_8x8;
if (is_key_frame) { if (is_key_frame) {
cpi->vbp_thresholds[0] = threshold_base;
cpi->vbp_thresholds[1] = threshold_base >> 2;
cpi->vbp_thresholds[2] = threshold_base >> 2;
cpi->vbp_thresholds[3] = threshold_base << 2;
cpi->vbp_threshold_sad = 0; cpi->vbp_threshold_sad = 0;
cpi->vbp_bsize_min = BLOCK_8X8; cpi->vbp_bsize_min = BLOCK_8X8;
} else { } else {
cpi->vbp_thresholds[1] = threshold_base; if (cm->width <= 352 && cm->height <= 288)
if (cm->width <= 352 && cm->height <= 288) {
cpi->vbp_thresholds[0] = threshold_base >> 2;
cpi->vbp_thresholds[2] = threshold_base << 3;
cpi->vbp_threshold_sad = 100; cpi->vbp_threshold_sad = 100;
} else { else
cpi->vbp_thresholds[0] = threshold_base;
cpi->vbp_thresholds[1] = (5 * threshold_base) >> 2;
cpi->vbp_thresholds[2] = threshold_base << cpi->oxcf.speed;
cpi->vbp_threshold_sad = (cpi->y_dequant[q][1] << 1) > 1000 ? cpi->vbp_threshold_sad = (cpi->y_dequant[q][1] << 1) > 1000 ?
(cpi->y_dequant[q][1] << 1) : 1000; (cpi->y_dequant[q][1] << 1) : 1000;
}
cpi->vbp_bsize_min = BLOCK_16X16; cpi->vbp_bsize_min = BLOCK_16X16;
} }
cpi->vbp_threshold_minmax = 15 + (q >> 3); cpi->vbp_threshold_minmax = 15 + (q >> 3);
...@@ -552,23 +559,6 @@ static int compute_minmax_8x8(const uint8_t *s, int sp, const uint8_t *d, ...@@ -552,23 +559,6 @@ static int compute_minmax_8x8(const uint8_t *s, int sp, const uint8_t *d,
return (minmax_max - minmax_min); return (minmax_max - minmax_min);
} }
static void modify_vbp_thresholds(VP9_COMP *cpi, int64_t thresholds[], int q) {
VP9_COMMON *const cm = &cpi->common;
const int64_t threshold_base = (int64_t)(cpi->y_dequant[q][1]);
// Array index: 0 - threshold_64x64; 1 - threshold_32x32;
// 2 - threshold_16x16; 3 - vbp_threshold_8x8;
thresholds[1] = threshold_base;
if (cm->width <= 352 && cm->height <= 288) {
thresholds[0] = threshold_base >> 2;
thresholds[2] = threshold_base << 3;
} else {
thresholds[0] = threshold_base;
thresholds[1] = (5 * threshold_base) >> 2;
thresholds[2] = threshold_base << cpi->oxcf.speed;
}
}
static void fill_variance_4x4avg(const uint8_t *s, int sp, const uint8_t *d, static void fill_variance_4x4avg(const uint8_t *s, int sp, const uint8_t *d,
int dp, int x8_idx, int y8_idx, v8x8 *vst, int dp, int x8_idx, int y8_idx, v8x8 *vst,
#if CONFIG_VP9_HIGHBITDEPTH #if CONFIG_VP9_HIGHBITDEPTH
...@@ -681,7 +671,7 @@ static int choose_partitioning(VP9_COMP *cpi, ...@@ -681,7 +671,7 @@ static int choose_partitioning(VP9_COMP *cpi,
if (cyclic_refresh_segment_id_boosted(segment_id)) { if (cyclic_refresh_segment_id_boosted(segment_id)) {
int q = vp9_get_qindex(&cm->seg, segment_id, cm->base_qindex); int q = vp9_get_qindex(&cm->seg, segment_id, cm->base_qindex);
modify_vbp_thresholds(cpi, thresholds, q); set_vbp_thresholds(cpi, thresholds, q);
} }
} }
......
...@@ -40,7 +40,7 @@ void vp9_init_tile_data(struct VP9_COMP *cpi); ...@@ -40,7 +40,7 @@ void vp9_init_tile_data(struct VP9_COMP *cpi);
void vp9_encode_tile(struct VP9_COMP *cpi, struct ThreadData *td, void vp9_encode_tile(struct VP9_COMP *cpi, struct ThreadData *td,
int tile_row, int tile_col); int tile_row, int tile_col);
void vp9_set_vbp_thresholds(struct VP9_COMP *cpi, int q); void vp9_set_variance_partition_thresholds(struct VP9_COMP *cpi, int q);
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } // extern "C"
......
...@@ -3031,7 +3031,7 @@ static void encode_without_recode_loop(VP9_COMP *cpi) { ...@@ -3031,7 +3031,7 @@ static void encode_without_recode_loop(VP9_COMP *cpi) {
set_size_dependent_vars(cpi, &q, &bottom_index, &top_index); set_size_dependent_vars(cpi, &q, &bottom_index, &top_index);
vp9_set_quantizer(cm, q); vp9_set_quantizer(cm, q);
vp9_set_vbp_thresholds(cpi, q); vp9_set_variance_partition_thresholds(cpi, q);
setup_frame(cpi); setup_frame(cpi);
......
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