Rework coeff probability model update for rtc coding

This commit reworks the ONE_LOOP_REDUCED coefficient probability
model update process. It allows model update for every coefficient
across the spectrum at a coarser resolution, instead of performing
precise update only for certain subset of probability models.

The overall runtime remains nearly same (<1% change) for speed -6.
The compression performance is improved by 7.5% in PSNR for speed
-5 and 4.57% for speed -6, respectively.

Change-Id: Ifb17136382ee7e39a9f34ff4a4f09a753125c8d1
This commit is contained in:
Jingning Han 2014-12-02 18:16:06 -08:00
Родитель bf758b6afa
Коммит 8fe50191c6
5 изменённых файлов: 68 добавлений и 40 удалений

Просмотреть файл

@ -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 int entropy_nodes_update = UNCONSTRAINED_NODES;
int i, j, k, l, t;
int stepsize = cpi->sf.coeff_prob_appx_step;
switch (cpi->sf.use_fast_coef_updates) {
case TWO_LOOP: {
/* 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)
s = vp9_prob_diff_update_savings_search_model(
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
s = vp9_prob_diff_update_savings_search(
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)
s = vp9_prob_diff_update_savings_search_model(
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
s = vp9_prob_diff_update_savings_search(
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_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 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 (j = 0; j < REF_TYPES; ++j) {
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;
int s;
int u = 0;
if (l >= prev_coef_contexts_to_update ||
k >= coef_band_to_update) {
u = 0;
if (t == PIVOT_NODE) {
s = vp9_prob_diff_update_savings_search_model(
frame_branch_ct[i][j][k][l][0],
old_coef_probs[i][j][k][l], &newp, upd, stepsize);
} else {
if (t == PIVOT_NODE)
s = vp9_prob_diff_update_savings_search_model(
frame_branch_ct[i][j][k][l][0],
old_coef_probs[i][j][k][l], &newp, upd);
else
s = vp9_prob_diff_update_savings_search(
frame_branch_ct[i][j][k][l][t],
*oldp, &newp, upd);
if (s > 0 && newp != *oldp)
u = 1;
s = vp9_prob_diff_update_savings_search(
frame_branch_ct[i][j][k][l][t],
*oldp, &newp, upd);
}
if (s > 0 && newp != *oldp)
u = 1;
updates += u;
if (u == 0 && updates == 0) {
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->skip_encode_sb = 1;
sf->mv.subpel_iters_per_step = 1;
sf->use_fast_coef_updates = ONE_LOOP_REDUCED;
sf->adaptive_rd_thresh = 4;
sf->mode_skip_start = 6;
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.
sf->reuse_inter_pred_sby = 1;
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) {
int i;
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->optimize_coefficients = !is_lossless_requested(&cpi->oxcf);
sf->mv.reduce_first_step_size = 0;
sf->coeff_prob_appx_step = 1;
sf->mv.auto_mv_step_size = 0;
sf->mv.fullpel_search_step_param = 6;
sf->comp_inter_joint_search_thresh = BLOCK_4X4;

Просмотреть файл

@ -236,6 +236,9 @@ typedef struct SPEED_FEATURES {
// level within a frame.
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
// use_lastframe_partitioning is set to LAST_FRAME_PARTITION_LOW_MOTION
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,
const vp9_prob *oldp,
vp9_prob *bestp,
vp9_prob upd) {
vp9_prob upd,
int stepsize) {
int i, old_b, new_b, update_b, savings, bestsavings, step;
int newp;
vp9_prob bestnewp, newplist[ENTROPY_NODES], oldplist[ENTROPY_NODES];
@ -153,24 +154,44 @@ int vp9_prob_diff_update_savings_search_model(const unsigned int *ct,
bestsavings = 0;
bestnewp = oldp[PIVOT_NODE];
step = (*bestp > oldp[PIVOT_NODE] ? -1 : 1);
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;
if (*bestp > oldp[PIVOT_NODE]) {
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;
}
}
} 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;
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,
const vp9_prob *oldp,
vp9_prob *bestp,
vp9_prob upd);
vp9_prob upd,
int stepsize);
#ifdef __cplusplus
} // extern "C"