ref: bf43b4c4b47eff60e52e9d036de8618b4a1fece1
parent: 8dc15230576f8900327f38c667dda1cab41e3894
parent: 9c2552a1c149cbc7ee407c514e0cf78e6f45bcec
author: Yunqing Wang <[email protected]>
date: Mon Mar 20 19:20:12 EDT 2017
Merge "Record the sum of tx block eobs in the partition block"
--- a/vp9/encoder/vp9_block.h
+++ b/vp9/encoder/vp9_block.h
@@ -128,6 +128,9 @@
// Set during mode selection. Read during block encoding.
uint8_t zcoeff_blk[TX_SIZES][256];
+ // Accumulate the tx block eobs in a partition block.
+ int32_t sum_y_eobs[TX_SIZES];
+
int skip;
int encode_breakout;
--- a/vp9/encoder/vp9_context_tree.h
+++ b/vp9/encoder/vp9_context_tree.h
@@ -73,7 +73,7 @@
INTERP_FILTER pred_interp_filter;
// Used for the machine learning-based early termination
- int sum_eobs;
+ int32_t sum_y_eobs;
} PICK_MODE_CONTEXT;
typedef struct PC_TREE {
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -2712,18 +2712,6 @@
}
#endif
-// Accumulate all tx blocks' eobs results got from the partition evaluation.
-static void accumulate_eobs(int plane, int block, int row, int col,
- BLOCK_SIZE plane_bsize, TX_SIZE tx_size,
- void *arg) {
- PICK_MODE_CONTEXT *ctx = (PICK_MODE_CONTEXT *)arg;
- (void)row;
- (void)col;
- (void)plane_bsize;
- (void)tx_size;
- ctx->sum_eobs += ctx->eobs_pbuf[plane][1][block];
-}
-
// TODO(jingning,jimbankoski,rbultje): properly skip partition types that are
// unlikely to be selected depending on previous rate-distortion optimization
// results, for encoding speed-up.
@@ -2900,6 +2888,8 @@
}
if (this_rdc.rdcost < best_rdc.rdcost) {
+ MODE_INFO *mi = xd->mi[0];
+
best_rdc = this_rdc;
if (bsize >= BLOCK_8X8) pc_tree->partitioning = PARTITION_NONE;
@@ -2918,7 +2908,9 @@
// Currently, the machine-learning based partition search early
// termination is only used while bsize is 16x16, 32x32 or 64x64,
// VPXMIN(cm->width, cm->height) >= 480, and speed = 0.
- if (ctx->mic.mode >= INTRA_MODES && bsize >= BLOCK_16X16) {
+ if (!x->e_mbd.lossless &&
+ !segfeature_active(&cm->seg, mi->segment_id, SEG_LVL_SKIP) &&
+ ctx->mic.mode >= INTRA_MODES && bsize >= BLOCK_16X16) {
const double *clf;
const double *mean;
const double *sd;
@@ -2937,10 +2929,6 @@
assert(b_width_log2_lookup[bsize] == b_height_log2_lookup[bsize]);
- ctx->sum_eobs = 0;
- vp9_foreach_transformed_block_in_plane(xd, bsize, 0,
- accumulate_eobs, ctx);
-
if (above_in_image) {
context_size = xd->above_mi->sb_type;
if (context_size < bsize)
@@ -2981,7 +2969,7 @@
clf[2] * (((double)mag_mv / 2 - mean[2]) * sd[2]) +
clf[3] * (((double)(left_par + above_par) / 2 - mean[3]) *
sd[3]) +
- clf[4] * (((double)ctx->sum_eobs - mean[4]) / sd[4]) +
+ clf[4] * (((double)ctx->sum_y_eobs - mean[4]) / sd[4]) +
clf[5] * (((double)cm->base_qindex - mean[5]) * sd[5]) +
clf[6] * (((double)last_par - mean[6]) * sd[6]) + clf[7];
if (score < 0) {
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -756,9 +756,11 @@
// TODO(jingning): temporarily enabled only for luma component
rd = VPXMIN(rd1, rd2);
- if (plane == 0)
+ if (plane == 0) {
x->zcoeff_blk[tx_size][block] =
!x->plane[plane].eobs[block] || (rd1 > rd2 && !xd->lossless);
+ x->sum_y_eobs[tx_size] += x->plane[plane].eobs[block];
+ }
args->this_rate += rate;
args->this_dist += dist;
@@ -3204,6 +3206,8 @@
ref_frame = vp9_mode_order[mode_index].ref_frame[0];
second_ref_frame = vp9_mode_order[mode_index].ref_frame[1];
+ vp9_zero(x->sum_y_eobs);
+
// Look at the reference frame of the best mode so far and set the
// skip mask to look at a subset of the remaining modes.
if (midx == mode_skip_start && best_mode_index >= 0) {
@@ -3483,6 +3487,7 @@
if (!x->select_tx_size) swap_block_ptr(x, ctx, 1, 0, 0, max_plane);
memcpy(ctx->zcoeff_blk, x->zcoeff_blk[mi->tx_size],
sizeof(ctx->zcoeff_blk[0]) * ctx->num_4x4_blk);
+ ctx->sum_y_eobs = x->sum_y_eobs[mi->tx_size];
// TODO(debargha): enhance this test with a better distortion prediction
// based on qp, activity mask and history
@@ -3713,6 +3718,8 @@
mi->mv[0].as_int = 0;
x->skip = 1;
+ ctx->sum_y_eobs = 0;
+
if (cm->interp_filter != BILINEAR) {
best_filter = EIGHTTAP;
if (cm->interp_filter == SWITCHABLE &&
@@ -3867,6 +3874,8 @@
ref_frame = vp9_ref_order[ref_index].ref_frame[0];
second_ref_frame = vp9_ref_order[ref_index].ref_frame[1];
+ vp9_zero(x->sum_y_eobs);
+
#if CONFIG_BETTER_HW_COMPATIBILITY
// forbid 8X4 and 4X8 partitions if any reference frame is scaled.
if (bsize == BLOCK_8X4 || bsize == BLOCK_4X8) {
@@ -4083,6 +4092,7 @@
for (i = 0; i < 4; i++) {
tmp_best_bmodes[i] = xd->mi[0]->bmi[i];
x->zcoeff_blk[TX_4X4][i] = !x->plane[0].eobs[i];
+ x->sum_y_eobs[TX_4X4] += x->plane[0].eobs[i];
}
pred_exists = 1;
if (switchable_filter_index == 0 && sf->use_rd_breakout &&
@@ -4247,6 +4257,7 @@
if (!x->select_tx_size) swap_block_ptr(x, ctx, 1, 0, 0, max_plane);
memcpy(ctx->zcoeff_blk, x->zcoeff_blk[TX_4X4],
sizeof(ctx->zcoeff_blk[0]) * ctx->num_4x4_blk);
+ ctx->sum_y_eobs = x->sum_y_eobs[TX_4X4];
for (i = 0; i < 4; i++) best_bmodes[i] = xd->mi[0]->bmi[i];
--- a/vp9/encoder/vp9_speed_features.c
+++ b/vp9/encoder/vp9_speed_features.c
@@ -73,10 +73,9 @@
// Currently, the machine-learning based partition search early termination
// is only used while VPXMIN(cm->width, cm->height) >= 480 and speed = 0.
- // TODO(yunqingwang): Re-enable when test failures are fixed.
- // if (VPXMIN(cm->width, cm->height) >= 480) {
- // sf->ml_partition_search_early_termination = 1;
- // }
+ if (VPXMIN(cm->width, cm->height) >= 480) {
+ sf->ml_partition_search_early_termination = 1;
+ }
if (speed >= 1) {
sf->ml_partition_search_early_termination = 0;