ref: e350e3fe68bef41d824aaef0f7fed4baa70c773b
parent: 28a1ee86b9df48925ea99657bb542a79dca44f17
parent: e4aac6bb61cba7ab387a959c82b292ead6eba758
author: Yunqing Wang <[email protected]>
date: Wed Oct 1 12:19:56 EDT 2014
Merge "Modify block transform skipping check"
--- a/vp9/encoder/vp9_quantize.c
+++ b/vp9/encoder/vp9_quantize.c
@@ -641,13 +641,14 @@
x->plane[0].quant_shift = quants->y_quant_shift[qindex];
x->plane[0].zbin = quants->y_zbin[qindex];
x->plane[0].round = quants->y_round[qindex];
- x->plane[0].quant_thred[0] = cm->y_dequant[qindex][0] *
- cm->y_dequant[qindex][0];
- x->plane[0].quant_thred[1] = cm->y_dequant[qindex][1] *
- cm->y_dequant[qindex][1];
x->plane[0].zbin_extra = (int16_t)((cm->y_dequant[qindex][1] * zbin) >> 7);
xd->plane[0].dequant = cm->y_dequant[qindex];
+ x->plane[0].quant_thred[0] = (x->plane[0].zbin[0] + x->plane[0].zbin_extra) *
+ (x->plane[0].zbin[0] + x->plane[0].zbin_extra);
+ x->plane[0].quant_thred[1] = (x->plane[0].zbin[1] + x->plane[0].zbin_extra) *
+ (x->plane[0].zbin[1] + x->plane[0].zbin_extra);
+
// UV
for (i = 1; i < 3; i++) {
x->plane[i].quant = quants->uv_quant[qindex];
@@ -656,12 +657,15 @@
x->plane[i].quant_shift = quants->uv_quant_shift[qindex];
x->plane[i].zbin = quants->uv_zbin[qindex];
x->plane[i].round = quants->uv_round[qindex];
- x->plane[i].quant_thred[0] = cm->y_dequant[qindex][0] *
- cm->y_dequant[qindex][0];
- x->plane[i].quant_thred[1] = cm->y_dequant[qindex][1] *
- cm->y_dequant[qindex][1];
x->plane[i].zbin_extra = (int16_t)((cm->uv_dequant[qindex][1] * zbin) >> 7);
xd->plane[i].dequant = cm->uv_dequant[qindex];
+
+ x->plane[i].quant_thred[0] =
+ (x->plane[i].zbin[0] + x->plane[i].zbin_extra) *
+ (x->plane[i].zbin[0] + x->plane[i].zbin_extra);
+ x->plane[i].quant_thred[1] =
+ (x->plane[i].zbin[1] + x->plane[i].zbin_extra) *
+ (x->plane[i].zbin[1] + x->plane[i].zbin_extra);
}
x->skip_block = vp9_segfeature_active(&cm->seg, segment_id, SEG_LVL_SKIP);
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -180,7 +180,7 @@
unsigned int sse;
unsigned int var = 0;
unsigned int sum_sse = 0;
- const int shift = 8;
+ const int shift = 6;
int rate;
int64_t dist;
@@ -212,12 +212,16 @@
sum_sse += sse;
if (!x->select_tx_size) {
- if (x->bsse[(i << 2) + block_idx] < p->quant_thred[0] >> shift)
- x->skip_txfm[(i << 2) + block_idx] = 1;
- else if (var < p->quant_thred[1] >> shift)
+ // Check if all ac coefficients can be quantized to zero.
+ if (var < p->quant_thred[1] >> shift) {
x->skip_txfm[(i << 2) + block_idx] = 2;
- else
+
+ // Check if dc coefficient can be quantized to zero.
+ if (sse - var < p->quant_thred[0] >> shift)
+ x->skip_txfm[(i << 2) + block_idx] = 1;
+ } else {
x->skip_txfm[(i << 2) + block_idx] = 0;
+ }
}
if (i == 0)
@@ -484,9 +488,15 @@
vp9_xform_quant_dc(x, plane, block, plane_bsize, tx_size);
args->sse = x->bsse[(plane << 2) + (block >> (tx_size << 1))] << 4;
args->dist = args->sse;
- if (!x->plane[plane].eobs[block])
- args->dist = args->sse - ((coeff[0] * coeff[0] -
- (coeff[0] - dqcoeff[0]) * (coeff[0] - dqcoeff[0])) >> 2);
+ if (x->plane[plane].eobs[block]) {
+ int64_t dc_correct = coeff[0] * coeff[0] -
+ (coeff[0] - dqcoeff[0]) * (coeff[0] - dqcoeff[0]);
+
+ if (tx_size != TX_32X32)
+ dc_correct >>= 2;
+
+ args->dist = args->sse - dc_correct;
+ }
} else {
// skip forward transform
x->plane[plane].eobs[block] = 0;