Merge "Rework coeff probability model update for rtc coding"
This commit is contained in:
commit
228ec17ff2
@ -535,6 +535,8 @@ static void update_coef_probs_common(vp9_writer* const bc, VP9_COMP *cpi,
|
|||||||
const vp9_prob upd = DIFF_UPDATE_PROB;
|
const vp9_prob upd = DIFF_UPDATE_PROB;
|
||||||
const int entropy_nodes_update = UNCONSTRAINED_NODES;
|
const int entropy_nodes_update = UNCONSTRAINED_NODES;
|
||||||
int i, j, k, l, t;
|
int i, j, k, l, t;
|
||||||
|
int stepsize = cpi->sf.coeff_prob_appx_step;
|
||||||
|
|
||||||
switch (cpi->sf.use_fast_coef_updates) {
|
switch (cpi->sf.use_fast_coef_updates) {
|
||||||
case TWO_LOOP: {
|
case TWO_LOOP: {
|
||||||
/* dry run to see if there is any update at all needed */
|
/* dry run to see if there is any update at all needed */
|
||||||
@ -552,7 +554,7 @@ static void update_coef_probs_common(vp9_writer* const bc, VP9_COMP *cpi,
|
|||||||
if (t == PIVOT_NODE)
|
if (t == PIVOT_NODE)
|
||||||
s = vp9_prob_diff_update_savings_search_model(
|
s = vp9_prob_diff_update_savings_search_model(
|
||||||
frame_branch_ct[i][j][k][l][0],
|
frame_branch_ct[i][j][k][l][0],
|
||||||
old_coef_probs[i][j][k][l], &newp, upd);
|
old_coef_probs[i][j][k][l], &newp, upd, stepsize);
|
||||||
else
|
else
|
||||||
s = vp9_prob_diff_update_savings_search(
|
s = vp9_prob_diff_update_savings_search(
|
||||||
frame_branch_ct[i][j][k][l][t], oldp, &newp, upd);
|
frame_branch_ct[i][j][k][l][t], oldp, &newp, upd);
|
||||||
@ -590,7 +592,7 @@ static void update_coef_probs_common(vp9_writer* const bc, VP9_COMP *cpi,
|
|||||||
if (t == PIVOT_NODE)
|
if (t == PIVOT_NODE)
|
||||||
s = vp9_prob_diff_update_savings_search_model(
|
s = vp9_prob_diff_update_savings_search_model(
|
||||||
frame_branch_ct[i][j][k][l][0],
|
frame_branch_ct[i][j][k][l][0],
|
||||||
old_coef_probs[i][j][k][l], &newp, upd);
|
old_coef_probs[i][j][k][l], &newp, upd, stepsize);
|
||||||
else
|
else
|
||||||
s = vp9_prob_diff_update_savings_search(
|
s = vp9_prob_diff_update_savings_search(
|
||||||
frame_branch_ct[i][j][k][l][t],
|
frame_branch_ct[i][j][k][l][t],
|
||||||
@ -613,14 +615,14 @@ static void update_coef_probs_common(vp9_writer* const bc, VP9_COMP *cpi,
|
|||||||
|
|
||||||
case ONE_LOOP:
|
case ONE_LOOP:
|
||||||
case ONE_LOOP_REDUCED: {
|
case ONE_LOOP_REDUCED: {
|
||||||
const int prev_coef_contexts_to_update =
|
|
||||||
cpi->sf.use_fast_coef_updates == ONE_LOOP_REDUCED ?
|
|
||||||
COEFF_CONTEXTS >> 1 : COEFF_CONTEXTS;
|
|
||||||
const int coef_band_to_update =
|
|
||||||
cpi->sf.use_fast_coef_updates == ONE_LOOP_REDUCED ?
|
|
||||||
COEF_BANDS >> 1 : COEF_BANDS;
|
|
||||||
int updates = 0;
|
int updates = 0;
|
||||||
int noupdates_before_first = 0;
|
int noupdates_before_first = 0;
|
||||||
|
|
||||||
|
if (tx_size >= TX_16X16 && cpi->sf.tx_size_search_method == USE_TX_8X8) {
|
||||||
|
vp9_write_bit(bc, 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < PLANE_TYPES; ++i) {
|
for (i = 0; i < PLANE_TYPES; ++i) {
|
||||||
for (j = 0; j < REF_TYPES; ++j) {
|
for (j = 0; j < REF_TYPES; ++j) {
|
||||||
for (k = 0; k < COEF_BANDS; ++k) {
|
for (k = 0; k < COEF_BANDS; ++k) {
|
||||||
@ -631,21 +633,19 @@ static void update_coef_probs_common(vp9_writer* const bc, VP9_COMP *cpi,
|
|||||||
vp9_prob *oldp = old_coef_probs[i][j][k][l] + t;
|
vp9_prob *oldp = old_coef_probs[i][j][k][l] + t;
|
||||||
int s;
|
int s;
|
||||||
int u = 0;
|
int u = 0;
|
||||||
if (l >= prev_coef_contexts_to_update ||
|
|
||||||
k >= coef_band_to_update) {
|
if (t == PIVOT_NODE) {
|
||||||
u = 0;
|
|
||||||
} else {
|
|
||||||
if (t == PIVOT_NODE)
|
|
||||||
s = vp9_prob_diff_update_savings_search_model(
|
s = vp9_prob_diff_update_savings_search_model(
|
||||||
frame_branch_ct[i][j][k][l][0],
|
frame_branch_ct[i][j][k][l][0],
|
||||||
old_coef_probs[i][j][k][l], &newp, upd);
|
old_coef_probs[i][j][k][l], &newp, upd, stepsize);
|
||||||
else
|
} else {
|
||||||
s = vp9_prob_diff_update_savings_search(
|
s = vp9_prob_diff_update_savings_search(
|
||||||
frame_branch_ct[i][j][k][l][t],
|
frame_branch_ct[i][j][k][l][t],
|
||||||
*oldp, &newp, upd);
|
*oldp, &newp, upd);
|
||||||
|
}
|
||||||
|
|
||||||
if (s > 0 && newp != *oldp)
|
if (s > 0 && newp != *oldp)
|
||||||
u = 1;
|
u = 1;
|
||||||
}
|
|
||||||
updates += u;
|
updates += u;
|
||||||
if (u == 0 && updates == 0) {
|
if (u == 0 && updates == 0) {
|
||||||
noupdates_before_first++;
|
noupdates_before_first++;
|
||||||
|
@ -249,7 +249,6 @@ static void set_rt_speed_feature(VP9_COMP *cpi, SPEED_FEATURES *sf,
|
|||||||
sf->use_uv_intra_rd_estimate = 1;
|
sf->use_uv_intra_rd_estimate = 1;
|
||||||
sf->skip_encode_sb = 1;
|
sf->skip_encode_sb = 1;
|
||||||
sf->mv.subpel_iters_per_step = 1;
|
sf->mv.subpel_iters_per_step = 1;
|
||||||
sf->use_fast_coef_updates = ONE_LOOP_REDUCED;
|
|
||||||
sf->adaptive_rd_thresh = 4;
|
sf->adaptive_rd_thresh = 4;
|
||||||
sf->mode_skip_start = 6;
|
sf->mode_skip_start = 6;
|
||||||
sf->allow_skip_recode = 0;
|
sf->allow_skip_recode = 0;
|
||||||
@ -304,6 +303,9 @@ static void set_rt_speed_feature(VP9_COMP *cpi, SPEED_FEATURES *sf,
|
|||||||
// This feature is only enabled when partition search is disabled.
|
// This feature is only enabled when partition search is disabled.
|
||||||
sf->reuse_inter_pred_sby = 1;
|
sf->reuse_inter_pred_sby = 1;
|
||||||
sf->partition_search_breakout_rate_thr = 200;
|
sf->partition_search_breakout_rate_thr = 200;
|
||||||
|
sf->coeff_prob_appx_step = 4;
|
||||||
|
sf->use_fast_coef_updates = is_keyframe ? TWO_LOOP : ONE_LOOP_REDUCED;
|
||||||
|
|
||||||
if (!is_keyframe) {
|
if (!is_keyframe) {
|
||||||
int i;
|
int i;
|
||||||
if (content == VP9E_CONTENT_SCREEN) {
|
if (content == VP9E_CONTENT_SCREEN) {
|
||||||
@ -394,6 +396,7 @@ void vp9_set_speed_features_framesize_independent(VP9_COMP *cpi) {
|
|||||||
sf->mv.subpel_force_stop = 0;
|
sf->mv.subpel_force_stop = 0;
|
||||||
sf->optimize_coefficients = !is_lossless_requested(&cpi->oxcf);
|
sf->optimize_coefficients = !is_lossless_requested(&cpi->oxcf);
|
||||||
sf->mv.reduce_first_step_size = 0;
|
sf->mv.reduce_first_step_size = 0;
|
||||||
|
sf->coeff_prob_appx_step = 1;
|
||||||
sf->mv.auto_mv_step_size = 0;
|
sf->mv.auto_mv_step_size = 0;
|
||||||
sf->mv.fullpel_search_step_param = 6;
|
sf->mv.fullpel_search_step_param = 6;
|
||||||
sf->comp_inter_joint_search_thresh = BLOCK_4X4;
|
sf->comp_inter_joint_search_thresh = BLOCK_4X4;
|
||||||
|
@ -236,6 +236,9 @@ typedef struct SPEED_FEATURES {
|
|||||||
// level within a frame.
|
// level within a frame.
|
||||||
int allow_skip_recode;
|
int allow_skip_recode;
|
||||||
|
|
||||||
|
// Coefficient probability model approximation step size
|
||||||
|
int coeff_prob_appx_step;
|
||||||
|
|
||||||
// The threshold is to determine how slow the motino is, it is used when
|
// The threshold is to determine how slow the motino is, it is used when
|
||||||
// use_lastframe_partitioning is set to LAST_FRAME_PARTITION_LOW_MOTION
|
// use_lastframe_partitioning is set to LAST_FRAME_PARTITION_LOW_MOTION
|
||||||
MOTION_THRESHOLD lf_motion_threshold;
|
MOTION_THRESHOLD lf_motion_threshold;
|
||||||
|
@ -140,7 +140,8 @@ int vp9_prob_diff_update_savings_search(const unsigned int *ct,
|
|||||||
int vp9_prob_diff_update_savings_search_model(const unsigned int *ct,
|
int vp9_prob_diff_update_savings_search_model(const unsigned int *ct,
|
||||||
const vp9_prob *oldp,
|
const vp9_prob *oldp,
|
||||||
vp9_prob *bestp,
|
vp9_prob *bestp,
|
||||||
vp9_prob upd) {
|
vp9_prob upd,
|
||||||
|
int stepsize) {
|
||||||
int i, old_b, new_b, update_b, savings, bestsavings, step;
|
int i, old_b, new_b, update_b, savings, bestsavings, step;
|
||||||
int newp;
|
int newp;
|
||||||
vp9_prob bestnewp, newplist[ENTROPY_NODES], oldplist[ENTROPY_NODES];
|
vp9_prob bestnewp, newplist[ENTROPY_NODES], oldplist[ENTROPY_NODES];
|
||||||
@ -153,9 +154,9 @@ int vp9_prob_diff_update_savings_search_model(const unsigned int *ct,
|
|||||||
bestsavings = 0;
|
bestsavings = 0;
|
||||||
bestnewp = oldp[PIVOT_NODE];
|
bestnewp = oldp[PIVOT_NODE];
|
||||||
|
|
||||||
step = (*bestp > oldp[PIVOT_NODE] ? -1 : 1);
|
if (*bestp > oldp[PIVOT_NODE]) {
|
||||||
|
step = -stepsize;
|
||||||
for (newp = *bestp; newp != oldp[PIVOT_NODE]; newp += step) {
|
for (newp = *bestp; newp > oldp[PIVOT_NODE]; newp += step) {
|
||||||
if (newp < 1 || newp > 255)
|
if (newp < 1 || newp > 255)
|
||||||
continue;
|
continue;
|
||||||
newplist[PIVOT_NODE] = newp;
|
newplist[PIVOT_NODE] = newp;
|
||||||
@ -171,6 +172,26 @@ int vp9_prob_diff_update_savings_search_model(const unsigned int *ct,
|
|||||||
bestnewp = newp;
|
bestnewp = newp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
step = stepsize;
|
||||||
|
for (newp = *bestp; newp < oldp[PIVOT_NODE]; newp += step) {
|
||||||
|
if (newp < 1 || newp > 255)
|
||||||
|
continue;
|
||||||
|
newplist[PIVOT_NODE] = newp;
|
||||||
|
vp9_model_to_full_probs(newplist, newplist);
|
||||||
|
for (i = UNCONSTRAINED_NODES, new_b = 0; i < ENTROPY_NODES; ++i)
|
||||||
|
new_b += cost_branch256(ct + 2 * i, newplist[i]);
|
||||||
|
new_b += cost_branch256(ct + 2 * PIVOT_NODE, newplist[PIVOT_NODE]);
|
||||||
|
update_b = prob_diff_update_cost(newp, oldp[PIVOT_NODE]) +
|
||||||
|
vp9_cost_upd256;
|
||||||
|
savings = old_b - new_b - update_b;
|
||||||
|
if (savings > bestsavings) {
|
||||||
|
bestsavings = savings;
|
||||||
|
bestnewp = newp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
*bestp = bestnewp;
|
*bestp = bestnewp;
|
||||||
return bestsavings;
|
return bestsavings;
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,8 @@ int vp9_prob_diff_update_savings_search(const unsigned int *ct,
|
|||||||
int vp9_prob_diff_update_savings_search_model(const unsigned int *ct,
|
int vp9_prob_diff_update_savings_search_model(const unsigned int *ct,
|
||||||
const vp9_prob *oldp,
|
const vp9_prob *oldp,
|
||||||
vp9_prob *bestp,
|
vp9_prob *bestp,
|
||||||
vp9_prob upd);
|
vp9_prob upd,
|
||||||
|
int stepsize);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user