Do a skip-block check for sub8x8 partitions also.
+0.2% SSIM and glbPSNR on derfraw300. Change-Id: I9cba0bca55e606a22f557c7732b064f738efe84d
This commit is contained in:
parent
df90d58f4f
commit
83c7e13a6b
@ -1659,7 +1659,7 @@ static int64_t encode_inter_mb_segment(VP9_COMP *cpi,
|
|||||||
int64_t best_yrd,
|
int64_t best_yrd,
|
||||||
int i,
|
int i,
|
||||||
int *labelyrate,
|
int *labelyrate,
|
||||||
int64_t *distortion,
|
int64_t *distortion, int64_t *sse,
|
||||||
ENTROPY_CONTEXT *ta,
|
ENTROPY_CONTEXT *ta,
|
||||||
ENTROPY_CONTEXT *tl) {
|
ENTROPY_CONTEXT *tl) {
|
||||||
int k;
|
int k;
|
||||||
@ -1684,7 +1684,7 @@ static int64_t encode_inter_mb_segment(VP9_COMP *cpi,
|
|||||||
uint8_t* const dst = raster_block_offset_uint8(xd, BLOCK_SIZE_SB8X8, 0, i,
|
uint8_t* const dst = raster_block_offset_uint8(xd, BLOCK_SIZE_SB8X8, 0, i,
|
||||||
xd->plane[0].dst.buf,
|
xd->plane[0].dst.buf,
|
||||||
xd->plane[0].dst.stride);
|
xd->plane[0].dst.stride);
|
||||||
int64_t thisdistortion = 0;
|
int64_t thisdistortion = 0, thissse = 0;
|
||||||
int thisrate = 0;
|
int thisrate = 0;
|
||||||
|
|
||||||
vp9_build_inter_predictor(pre,
|
vp9_build_inter_predictor(pre,
|
||||||
@ -1728,6 +1728,7 @@ static int64_t encode_inter_mb_segment(VP9_COMP *cpi,
|
|||||||
thisdistortion += vp9_block_error(coeff,
|
thisdistortion += vp9_block_error(coeff,
|
||||||
BLOCK_OFFSET(xd->plane[0].dqcoeff,
|
BLOCK_OFFSET(xd->plane[0].dqcoeff,
|
||||||
k, 16), 16, &ssz);
|
k, 16), 16, &ssz);
|
||||||
|
thissse += ssz;
|
||||||
thisrate += cost_coeffs(cm, x, 0, k, PLANE_TYPE_Y_WITH_DC,
|
thisrate += cost_coeffs(cm, x, 0, k, PLANE_TYPE_Y_WITH_DC,
|
||||||
ta + (k & 1),
|
ta + (k & 1),
|
||||||
tl + (k >> 1), TX_4X4, 16);
|
tl + (k >> 1), TX_4X4, 16);
|
||||||
@ -1735,6 +1736,7 @@ static int64_t encode_inter_mb_segment(VP9_COMP *cpi,
|
|||||||
}
|
}
|
||||||
*distortion += thisdistortion;
|
*distortion += thisdistortion;
|
||||||
*labelyrate += thisrate;
|
*labelyrate += thisrate;
|
||||||
|
*sse = thissse >> 2;
|
||||||
|
|
||||||
*distortion >>= 2;
|
*distortion >>= 2;
|
||||||
return RDCOST(x->rdmult, x->rddiv, *labelyrate, *distortion);
|
return RDCOST(x->rdmult, x->rddiv, *labelyrate, *distortion);
|
||||||
@ -1747,6 +1749,7 @@ typedef struct {
|
|||||||
int64_t segment_rd;
|
int64_t segment_rd;
|
||||||
int r;
|
int r;
|
||||||
int64_t d;
|
int64_t d;
|
||||||
|
int64_t sse;
|
||||||
int segment_yrate;
|
int segment_yrate;
|
||||||
MB_PREDICTION_MODE modes[4];
|
MB_PREDICTION_MODE modes[4];
|
||||||
int_mv mvs[4], second_mvs[4];
|
int_mv mvs[4], second_mvs[4];
|
||||||
@ -1795,7 +1798,7 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x,
|
|||||||
int_mv seg_mvs[4][MAX_REF_FRAMES],
|
int_mv seg_mvs[4][MAX_REF_FRAMES],
|
||||||
int mi_row, int mi_col) {
|
int mi_row, int mi_col) {
|
||||||
int i, j, br = 0, rate = 0, sbr = 0, idx, idy;
|
int i, j, br = 0, rate = 0, sbr = 0, idx, idy;
|
||||||
int64_t bd = 0, sbd = 0;
|
int64_t bd = 0, sbd = 0, subblock_sse = 0, block_sse = 0;
|
||||||
MB_PREDICTION_MODE this_mode;
|
MB_PREDICTION_MODE this_mode;
|
||||||
MB_MODE_INFO * mbmi = &x->e_mbd.mode_info_context->mbmi;
|
MB_MODE_INFO * mbmi = &x->e_mbd.mode_info_context->mbmi;
|
||||||
const int label_count = 4;
|
const int label_count = 4;
|
||||||
@ -1848,7 +1851,7 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x,
|
|||||||
// search for the best motion vector on this segment
|
// search for the best motion vector on this segment
|
||||||
for (this_mode = NEARESTMV; this_mode <= NEWMV; ++this_mode) {
|
for (this_mode = NEARESTMV; this_mode <= NEWMV; ++this_mode) {
|
||||||
int64_t this_rd;
|
int64_t this_rd;
|
||||||
int64_t distortion;
|
int64_t distortion, sse;
|
||||||
int labelyrate;
|
int labelyrate;
|
||||||
ENTROPY_CONTEXT t_above_s[4], t_left_s[4];
|
ENTROPY_CONTEXT t_above_s[4], t_left_s[4];
|
||||||
const struct buf_2d orig_src = x->plane[0].src;
|
const struct buf_2d orig_src = x->plane[0].src;
|
||||||
@ -1975,14 +1978,15 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x,
|
|||||||
|
|
||||||
this_rd = encode_inter_mb_segment(cpi, x,
|
this_rd = encode_inter_mb_segment(cpi, x,
|
||||||
bsi->segment_rd - this_segment_rd,
|
bsi->segment_rd - this_segment_rd,
|
||||||
i, &labelyrate,
|
i, &labelyrate, &distortion, &sse,
|
||||||
&distortion, t_above_s, t_left_s);
|
t_above_s, t_left_s);
|
||||||
this_rd += RDCOST(x->rdmult, x->rddiv, rate, 0);
|
this_rd += RDCOST(x->rdmult, x->rddiv, rate, 0);
|
||||||
rate += labelyrate;
|
rate += labelyrate;
|
||||||
|
|
||||||
if (this_rd < best_label_rd) {
|
if (this_rd < best_label_rd) {
|
||||||
sbr = rate;
|
sbr = rate;
|
||||||
sbd = distortion;
|
sbd = distortion;
|
||||||
|
subblock_sse = sse;
|
||||||
bestlabelyrate = labelyrate;
|
bestlabelyrate = labelyrate;
|
||||||
mode_selected = this_mode;
|
mode_selected = this_mode;
|
||||||
best_label_rd = this_rd;
|
best_label_rd = this_rd;
|
||||||
@ -2002,6 +2006,7 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x,
|
|||||||
|
|
||||||
br += sbr;
|
br += sbr;
|
||||||
bd += sbd;
|
bd += sbd;
|
||||||
|
block_sse += subblock_sse;
|
||||||
segmentyrate += bestlabelyrate;
|
segmentyrate += bestlabelyrate;
|
||||||
this_segment_rd += best_label_rd;
|
this_segment_rd += best_label_rd;
|
||||||
|
|
||||||
@ -2025,6 +2030,7 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x,
|
|||||||
bsi->d = bd;
|
bsi->d = bd;
|
||||||
bsi->segment_yrate = segmentyrate;
|
bsi->segment_yrate = segmentyrate;
|
||||||
bsi->segment_rd = this_segment_rd;
|
bsi->segment_rd = this_segment_rd;
|
||||||
|
bsi->sse = block_sse;
|
||||||
|
|
||||||
// store everything needed to come back to this!!
|
// store everything needed to come back to this!!
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
@ -2043,7 +2049,8 @@ static int64_t rd_pick_best_mbsegmentation(VP9_COMP *cpi, MACROBLOCK *x,
|
|||||||
int *returntotrate,
|
int *returntotrate,
|
||||||
int *returnyrate,
|
int *returnyrate,
|
||||||
int64_t *returndistortion,
|
int64_t *returndistortion,
|
||||||
int *skippable, int mvthresh,
|
int *skippable, int64_t *psse,
|
||||||
|
int mvthresh,
|
||||||
int_mv seg_mvs[4][MAX_REF_FRAMES],
|
int_mv seg_mvs[4][MAX_REF_FRAMES],
|
||||||
int mi_row, int mi_col) {
|
int mi_row, int mi_col) {
|
||||||
int i;
|
int i;
|
||||||
@ -2092,6 +2099,7 @@ static int64_t rd_pick_best_mbsegmentation(VP9_COMP *cpi, MACROBLOCK *x,
|
|||||||
*returndistortion = bsi.d;
|
*returndistortion = bsi.d;
|
||||||
*returnyrate = bsi.segment_yrate;
|
*returnyrate = bsi.segment_yrate;
|
||||||
*skippable = vp9_sby_is_skippable(&x->e_mbd, BLOCK_SIZE_SB8X8);
|
*skippable = vp9_sby_is_skippable(&x->e_mbd, BLOCK_SIZE_SB8X8);
|
||||||
|
*psse = bsi.sse;
|
||||||
mbmi->mode = bsi.modes[3];
|
mbmi->mode = bsi.modes[3];
|
||||||
|
|
||||||
return bsi.segment_rd;
|
return bsi.segment_rd;
|
||||||
@ -3413,7 +3421,7 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
|
|||||||
int64_t this_rd_thresh;
|
int64_t this_rd_thresh;
|
||||||
int64_t tmp_rd, tmp_best_rd = INT64_MAX, tmp_best_rdu = INT64_MAX;
|
int64_t tmp_rd, tmp_best_rd = INT64_MAX, tmp_best_rdu = INT64_MAX;
|
||||||
int tmp_best_rate = INT_MAX, tmp_best_ratey = INT_MAX;
|
int tmp_best_rate = INT_MAX, tmp_best_ratey = INT_MAX;
|
||||||
int64_t tmp_best_distortion = INT_MAX;
|
int64_t tmp_best_distortion = INT_MAX, tmp_best_sse, uv_sse;
|
||||||
int tmp_best_skippable = 0;
|
int tmp_best_skippable = 0;
|
||||||
int switchable_filter_index;
|
int switchable_filter_index;
|
||||||
int_mv *second_ref = is_comp_pred ?
|
int_mv *second_ref = is_comp_pred ?
|
||||||
@ -3456,7 +3464,7 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
|
|||||||
second_ref,
|
second_ref,
|
||||||
best_yrd,
|
best_yrd,
|
||||||
&rate, &rate_y, &distortion,
|
&rate, &rate_y, &distortion,
|
||||||
&skippable,
|
&skippable, &total_sse,
|
||||||
(int)this_rd_thresh, seg_mvs,
|
(int)this_rd_thresh, seg_mvs,
|
||||||
mi_row, mi_col);
|
mi_row, mi_col);
|
||||||
if (tmp_rd == INT64_MAX) {
|
if (tmp_rd == INT64_MAX) {
|
||||||
@ -3482,6 +3490,7 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
|
|||||||
tmp_best_rate = rate;
|
tmp_best_rate = rate;
|
||||||
tmp_best_ratey = rate_y;
|
tmp_best_ratey = rate_y;
|
||||||
tmp_best_distortion = distortion;
|
tmp_best_distortion = distortion;
|
||||||
|
tmp_best_sse = total_sse;
|
||||||
tmp_best_skippable = skippable;
|
tmp_best_skippable = skippable;
|
||||||
tmp_best_mbmode = *mbmi;
|
tmp_best_mbmode = *mbmi;
|
||||||
tmp_best_partition = *x->partition_info;
|
tmp_best_partition = *x->partition_info;
|
||||||
@ -3515,7 +3524,7 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
|
|||||||
second_ref,
|
second_ref,
|
||||||
best_yrd,
|
best_yrd,
|
||||||
&rate, &rate_y, &distortion,
|
&rate, &rate_y, &distortion,
|
||||||
&skippable,
|
&skippable, &total_sse,
|
||||||
(int)this_rd_thresh, seg_mvs,
|
(int)this_rd_thresh, seg_mvs,
|
||||||
mi_row, mi_col);
|
mi_row, mi_col);
|
||||||
if (tmp_rd == INT64_MAX)
|
if (tmp_rd == INT64_MAX)
|
||||||
@ -3526,6 +3535,7 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
|
|||||||
tmp_best_rdu -= RDCOST(x->rdmult, x->rddiv, rs, 0);
|
tmp_best_rdu -= RDCOST(x->rdmult, x->rddiv, rs, 0);
|
||||||
}
|
}
|
||||||
tmp_rd = tmp_best_rdu;
|
tmp_rd = tmp_best_rdu;
|
||||||
|
total_sse = tmp_best_sse;
|
||||||
rate = tmp_best_rate;
|
rate = tmp_best_rate;
|
||||||
rate_y = tmp_best_ratey;
|
rate_y = tmp_best_ratey;
|
||||||
distortion = tmp_best_distortion;
|
distortion = tmp_best_distortion;
|
||||||
@ -3558,11 +3568,12 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
|
|||||||
BLOCK_SIZE_SB8X8);
|
BLOCK_SIZE_SB8X8);
|
||||||
vp9_subtract_sbuv(x, BLOCK_SIZE_SB8X8);
|
vp9_subtract_sbuv(x, BLOCK_SIZE_SB8X8);
|
||||||
super_block_uvrd_for_txfm(cm, x, &rate_uv, &distortion_uv,
|
super_block_uvrd_for_txfm(cm, x, &rate_uv, &distortion_uv,
|
||||||
&uv_skippable, NULL,
|
&uv_skippable, &uv_sse,
|
||||||
BLOCK_SIZE_SB8X8, TX_4X4);
|
BLOCK_SIZE_SB8X8, TX_4X4);
|
||||||
rate2 += rate_uv;
|
rate2 += rate_uv;
|
||||||
distortion2 += distortion_uv;
|
distortion2 += distortion_uv;
|
||||||
skippable = skippable && uv_skippable;
|
skippable = skippable && uv_skippable;
|
||||||
|
total_sse += uv_sse;
|
||||||
|
|
||||||
txfm_cache[ONLY_4X4] = RDCOST(x->rdmult, x->rddiv, rate2, distortion2);
|
txfm_cache[ONLY_4X4] = RDCOST(x->rdmult, x->rddiv, rate2, distortion2);
|
||||||
for (i = 0; i < NB_TXFM_MODES; ++i)
|
for (i = 0; i < NB_TXFM_MODES; ++i)
|
||||||
@ -3624,7 +3635,7 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (mb_skip_allowed && ref_frame != INTRA_FRAME &&
|
} else if (mb_skip_allowed && ref_frame != INTRA_FRAME &&
|
||||||
this_mode != SPLITMV && !xd->lossless) {
|
!xd->lossless) {
|
||||||
if (RDCOST(x->rdmult, x->rddiv, rate_y + rate_uv, distortion2) <
|
if (RDCOST(x->rdmult, x->rddiv, rate_y + rate_uv, distortion2) <
|
||||||
RDCOST(x->rdmult, x->rddiv, 0, total_sse)) {
|
RDCOST(x->rdmult, x->rddiv, 0, total_sse)) {
|
||||||
// Add in the cost of the no skip flag.
|
// Add in the cost of the no skip flag.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user