Turning model-based updates on with modelcoefprob
This patch changes the default with the modecoefprob expt to use mode-based forward updates with one-node pegged modeling. The maximum difference with fully trained tables is now less that 0.1%. Change-Id: I06b44322e10c6703f93f3c1d48d973b1136a0618
This commit is contained in:
Родитель
c18b2617a4
Коммит
66f413af4f
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -153,22 +153,18 @@ const int *vp9_get_coef_neighbors_handle(const int *scan, int *pad);
|
|||
#define UNCONSTRAINED_NODES 3 // Choose one of 2 or 3
|
||||
|
||||
// whether forward updates are model-based
|
||||
#define MODEL_BASED_UPDATE 0
|
||||
#define MODEL_BASED_UPDATE 1
|
||||
// if model-based how many nodes are unconstrained
|
||||
#define UNCONSTRAINED_UPDATE_NODES 3
|
||||
// whether backward updates are model-based
|
||||
#define MODEL_BASED_ADAPT 0
|
||||
#define UNCONSTRAINED_ADAPT_NODES 3
|
||||
|
||||
// whether to adjust the coef probs for key frames based on qindex
|
||||
#define ADJUST_KF_COEF_PROBS 0
|
||||
|
||||
typedef vp9_prob vp9_coeff_probs_model[REF_TYPES][COEF_BANDS]
|
||||
[PREV_COEF_CONTEXTS][2];
|
||||
extern const vp9_prob vp9_modelcoefprobs[COEFPROB_MODELS][ENTROPY_NODES - 1];
|
||||
void vp9_get_model_distribution(vp9_prob model, vp9_prob *tree_probs,
|
||||
int b, int r);
|
||||
void vp9_adjust_default_coef_probs(struct VP9Common *cm);
|
||||
#endif // CONFIG_MODELCOEFPROB
|
||||
|
||||
#if CONFIG_CODE_NONZEROCOUNT
|
||||
|
|
|
@ -1127,7 +1127,8 @@ static void read_nzc_probs(VP9_COMMON *cm,
|
|||
}
|
||||
#endif // CONFIG_CODE_NONZEROCOUNT
|
||||
|
||||
static void read_coef_probs_common(BOOL_DECODER* const bc,
|
||||
static void read_coef_probs_common(VP9D_COMP *pbi,
|
||||
BOOL_DECODER* const bc,
|
||||
vp9_coeff_probs *coef_probs,
|
||||
TX_SIZE tx_size) {
|
||||
#if CONFIG_MODELCOEFPROB && MODEL_BASED_UPDATE
|
||||
|
@ -1172,16 +1173,16 @@ static void read_coef_probs_common(BOOL_DECODER* const bc,
|
|||
static void read_coef_probs(VP9D_COMP *pbi, BOOL_DECODER* const bc) {
|
||||
VP9_COMMON *const pc = &pbi->common;
|
||||
|
||||
read_coef_probs_common(bc, pc->fc.coef_probs_4x4, TX_4X4);
|
||||
read_coef_probs_common(pbi, bc, pc->fc.coef_probs_4x4, TX_4X4);
|
||||
|
||||
if (pbi->common.txfm_mode != ONLY_4X4)
|
||||
read_coef_probs_common(bc, pc->fc.coef_probs_8x8, TX_8X8);
|
||||
read_coef_probs_common(pbi, bc, pc->fc.coef_probs_8x8, TX_8X8);
|
||||
|
||||
if (pbi->common.txfm_mode > ALLOW_8X8)
|
||||
read_coef_probs_common(bc, pc->fc.coef_probs_16x16, TX_16X16);
|
||||
read_coef_probs_common(pbi, bc, pc->fc.coef_probs_16x16, TX_16X16);
|
||||
|
||||
if (pbi->common.txfm_mode > ALLOW_16X16)
|
||||
read_coef_probs_common(bc, pc->fc.coef_probs_32x32, TX_32X32);
|
||||
read_coef_probs_common(pbi, bc, pc->fc.coef_probs_32x32, TX_32X32);
|
||||
}
|
||||
|
||||
static void update_frame_size(VP9D_COMP *pbi) {
|
||||
|
@ -1707,9 +1708,10 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
|
|||
if (vp9_read(&header_bc, 252))
|
||||
pc->fc.vp9_mode_contexts[i][j] = vp9_read_prob(&header_bc);
|
||||
}
|
||||
#if CONFIG_MODELCOEFPROB && ADJUST_KF_COEF_PROBS
|
||||
if (pc->frame_type == KEY_FRAME)
|
||||
vp9_adjust_default_coef_probs(pc);
|
||||
#if CONFIG_MODELCOEFPROB
|
||||
if (pc->frame_type == KEY_FRAME) {
|
||||
vp9_default_coef_probs(pc);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CONFIG_NEW_MVREF
|
||||
|
|
|
@ -404,7 +404,7 @@ static int prob_diff_update_savings_search_model(const unsigned int *ct,
|
|||
const vp9_prob *oldp,
|
||||
vp9_prob *bestp,
|
||||
const vp9_prob upd,
|
||||
int b, int r) {
|
||||
int b, int r, int q) {
|
||||
int i, old_b, new_b, update_b, savings, bestsavings, step;
|
||||
int newp;
|
||||
vp9_prob bestnewp, newplist[ENTROPY_NODES];
|
||||
|
@ -2068,8 +2068,8 @@ static void update_nzc_probs(VP9_COMP* cpi,
|
|||
#endif // CONFIG_CODE_NONZEROCOUNT
|
||||
|
||||
static void update_coef_probs_common(vp9_writer* const bc,
|
||||
#ifdef ENTROPY_STATS
|
||||
VP9_COMP *cpi,
|
||||
#ifdef ENTROPY_STATS
|
||||
vp9_coeff_stats *tree_update_hist,
|
||||
#endif
|
||||
vp9_coeff_probs *new_frame_coef_probs,
|
||||
|
@ -2112,7 +2112,8 @@ static void update_coef_probs_common(vp9_writer* const bc,
|
|||
if (t == UNCONSTRAINED_NODES - 1)
|
||||
s = prob_diff_update_savings_search_model(
|
||||
frame_branch_ct[i][j][k][l][0],
|
||||
old_frame_coef_probs[i][j][k][l], &newp, upd, i, j);
|
||||
old_frame_coef_probs[i][j][k][l], &newp, upd, i, j,
|
||||
cpi->common.base_qindex);
|
||||
else
|
||||
#endif
|
||||
s = prob_diff_update_savings_search(
|
||||
|
@ -2166,7 +2167,8 @@ static void update_coef_probs_common(vp9_writer* const bc,
|
|||
if (t == UNCONSTRAINED_NODES - 1)
|
||||
s = prob_diff_update_savings_search_model(
|
||||
frame_branch_ct[i][j][k][l][0],
|
||||
old_frame_coef_probs[i][j][k][l], &newp, upd, i, j);
|
||||
old_frame_coef_probs[i][j][k][l], &newp, upd, i, j,
|
||||
cpi->common.base_qindex);
|
||||
else
|
||||
#endif
|
||||
s = prob_diff_update_savings_search(
|
||||
|
@ -2209,8 +2211,8 @@ static void update_coef_probs(VP9_COMP* const cpi, vp9_writer* const bc) {
|
|||
build_coeff_contexts(cpi);
|
||||
|
||||
update_coef_probs_common(bc,
|
||||
#ifdef ENTROPY_STATS
|
||||
cpi,
|
||||
#ifdef ENTROPY_STATS
|
||||
tree_update_hist_4x4,
|
||||
#endif
|
||||
cpi->frame_coef_probs_4x4,
|
||||
|
@ -2221,8 +2223,8 @@ static void update_coef_probs(VP9_COMP* const cpi, vp9_writer* const bc) {
|
|||
/* do not do this if not even allowed */
|
||||
if (cpi->common.txfm_mode != ONLY_4X4) {
|
||||
update_coef_probs_common(bc,
|
||||
#ifdef ENTROPY_STATS
|
||||
cpi,
|
||||
#ifdef ENTROPY_STATS
|
||||
tree_update_hist_8x8,
|
||||
#endif
|
||||
cpi->frame_coef_probs_8x8,
|
||||
|
@ -2233,8 +2235,8 @@ static void update_coef_probs(VP9_COMP* const cpi, vp9_writer* const bc) {
|
|||
|
||||
if (cpi->common.txfm_mode > ALLOW_8X8) {
|
||||
update_coef_probs_common(bc,
|
||||
#ifdef ENTROPY_STATS
|
||||
cpi,
|
||||
#ifdef ENTROPY_STATS
|
||||
tree_update_hist_16x16,
|
||||
#endif
|
||||
cpi->frame_coef_probs_16x16,
|
||||
|
@ -2245,8 +2247,8 @@ static void update_coef_probs(VP9_COMP* const cpi, vp9_writer* const bc) {
|
|||
|
||||
if (cpi->common.txfm_mode > ALLOW_16X16) {
|
||||
update_coef_probs_common(bc,
|
||||
#ifdef ENTROPY_STATS
|
||||
cpi,
|
||||
#ifdef ENTROPY_STATS
|
||||
tree_update_hist_32x32,
|
||||
#endif
|
||||
cpi->frame_coef_probs_32x32,
|
||||
|
|
|
@ -2943,25 +2943,26 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
|
|||
// Set up entropy depending on frame type.
|
||||
if (cm->frame_type == KEY_FRAME) {
|
||||
/* Choose which entropy context to use. When using a forward reference
|
||||
* frame, it immediately follows the keyframe, and thus benefits from
|
||||
* using the same entropy context established by the keyframe. Otherwise,
|
||||
* use the default context 0.
|
||||
*/
|
||||
* frame, it immediately follows the keyframe, and thus benefits from
|
||||
* using the same entropy context established by the keyframe. Otherwise,
|
||||
* use the default context 0.
|
||||
*/
|
||||
cm->frame_context_idx = cpi->oxcf.play_alternate;
|
||||
vp9_setup_key_frame(cpi);
|
||||
} else {
|
||||
/* Choose which entropy context to use. Currently there are only two
|
||||
* contexts used, one for normal frames and one for alt ref frames.
|
||||
*/
|
||||
/* Choose which entropy context to use. Currently there are only two
|
||||
* contexts used, one for normal frames and one for alt ref frames.
|
||||
*/
|
||||
cpi->common.frame_context_idx = cpi->refresh_alt_ref_frame;
|
||||
vp9_setup_inter_frame(cpi);
|
||||
}
|
||||
}
|
||||
|
||||
// transform / motion compensation build reconstruction frame
|
||||
#if CONFIG_MODELCOEFPROB && ADJUST_KF_COEF_PROBS
|
||||
if (cm->frame_type == KEY_FRAME)
|
||||
vp9_adjust_default_coef_probs(cm);
|
||||
#if CONFIG_MODELCOEFPROB
|
||||
if (cm->frame_type == KEY_FRAME) {
|
||||
vp9_default_coef_probs(cm);
|
||||
}
|
||||
#endif
|
||||
|
||||
vp9_encode_frame(cpi);
|
||||
|
|
Загрузка…
Ссылка в новой задаче