ref: d8dbd853e9496dae01e06333a1d8433f11a441cc
parent: 46c96ee9c730ab8f265a0c10a6c860ece7793ae6
parent: 15e3a1f176aa3a0d08862d1c08fcc0984da35b80
author: Jingning Han <[email protected]>
date: Fri Mar 22 01:01:57 EDT 2019
Merge "Use most common segment index for 64x64 level decision"
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -3651,22 +3651,35 @@
VPXMIN((mi_row + num_8x8_blocks_high_lookup[bsize]) >> 1, cm->mb_rows);
int mb_col_end =
VPXMIN((mi_col + num_8x8_blocks_wide_lookup[bsize]) >> 1, cm->mb_cols);
- int row, col;
+ int row, col, idx;
int64_t wiener_variance = 0;
int segment_id;
+ int8_t seg_hist[MAX_SEGMENTS] = { 0 };
+ int8_t max_count = 0, max_index = -1;
vpx_clear_system_state();
assert(cpi->norm_wiener_variance > 0);
- for (row = mb_row_start; row < mb_row_end; ++row)
- for (col = mb_col_start; col < mb_col_end; ++col)
- wiener_variance += cpi->mb_wiener_variance[row * cm->mb_cols + col];
+ for (row = mb_row_start; row < mb_row_end; ++row) {
+ for (col = mb_col_start; col < mb_col_end; ++col) {
+ wiener_variance = cpi->mb_wiener_variance[row * cm->mb_cols + col];
+ segment_id =
+ vp9_get_group_idx(log_wiener_var(wiener_variance),
+ cpi->kmeans_boundary_ls, cpi->kmeans_ctr_num);
+ ++seg_hist[segment_id];
+ }
+ }
- wiener_variance /= (mb_row_end - mb_row_start) * (mb_col_end - mb_col_start);
+ for (idx = 0; idx < cpi->kmeans_ctr_num; ++idx) {
+ if (seg_hist[idx] > max_count) {
+ max_count = seg_hist[idx];
+ max_index = idx;
+ }
+ }
- segment_id = vp9_get_group_idx(log_wiener_var(wiener_variance),
- cpi->kmeans_boundary_ls, cpi->kmeans_ctr_num);
+ assert(max_index >= 0);
+ segment_id = max_index;
return segment_id;
}