Moving vp9_tree_probs_from_distribution() to encoder.
Writing custom coeff branch count calculation (which is much clearer) in adapt_coef_probs() function. Removing vp9_treecoder.c file. Change-Id: I8880fb7a39996c8bcf6cd0acf9898a8c712ba91f
This commit is contained in:
Родитель
d72c847fe8
Коммит
4ac6a2552b
|
@ -756,25 +756,28 @@ static void adapt_coef_probs(VP9_COMMON *cm, TX_SIZE tx_size,
|
|||
unsigned int count_sat,
|
||||
unsigned int update_factor) {
|
||||
const FRAME_CONTEXT *pre_fc = &cm->frame_contexts[cm->frame_context_idx];
|
||||
|
||||
vp9_coeff_probs_model *dst_coef_probs = cm->fc.coef_probs[tx_size];
|
||||
const vp9_coeff_probs_model *pre_coef_probs = pre_fc->coef_probs[tx_size];
|
||||
vp9_coeff_count_model *coef_counts = cm->counts.coef[tx_size];
|
||||
unsigned int (*eob_branch_count)[REF_TYPES][COEF_BANDS][COEFF_CONTEXTS] =
|
||||
vp9_coeff_probs_model *const probs = cm->fc.coef_probs[tx_size];
|
||||
const vp9_coeff_probs_model *const pre_probs = pre_fc->coef_probs[tx_size];
|
||||
vp9_coeff_count_model *counts = cm->counts.coef[tx_size];
|
||||
unsigned int (*eob_counts)[REF_TYPES][COEF_BANDS][COEFF_CONTEXTS] =
|
||||
cm->counts.eob_branch[tx_size];
|
||||
int i, j, k, l, m;
|
||||
unsigned int branch_ct[UNCONSTRAINED_NODES][2];
|
||||
|
||||
for (i = 0; i < BLOCK_TYPES; ++i)
|
||||
for (j = 0; j < REF_TYPES; ++j)
|
||||
for (k = 0; k < COEF_BANDS; ++k)
|
||||
for (l = 0; l < BAND_COEFF_CONTEXTS(k); ++l) {
|
||||
vp9_tree_probs_from_distribution(vp9_coefmodel_tree, branch_ct,
|
||||
coef_counts[i][j][k][l]);
|
||||
branch_ct[0][1] = eob_branch_count[i][j][k][l] - branch_ct[0][0];
|
||||
const int n0 = counts[i][j][k][l][ZERO_TOKEN];
|
||||
const int n1 = counts[i][j][k][l][ONE_TOKEN];
|
||||
const int n2 = counts[i][j][k][l][TWO_TOKEN];
|
||||
const int neob = counts[i][j][k][l][EOB_MODEL_TOKEN];
|
||||
const unsigned int branch_ct[UNCONSTRAINED_NODES][2] = {
|
||||
{ neob, eob_counts[i][j][k][l] - neob },
|
||||
{ n0, n1 + n2 },
|
||||
{ n1, n2 }
|
||||
};
|
||||
for (m = 0; m < UNCONSTRAINED_NODES; ++m)
|
||||
dst_coef_probs[i][j][k][l][m] = merge_probs(
|
||||
pre_coef_probs[i][j][k][l][m],
|
||||
probs[i][j][k][l][m] = merge_probs(pre_probs[i][j][k][l][m],
|
||||
branch_ct[m],
|
||||
count_sat, update_factor);
|
||||
}
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "./vpx_config.h"
|
||||
#include "vp9/common/vp9_treecoder.h"
|
||||
|
||||
static unsigned int convert_distribution(unsigned int i, vp9_tree tree,
|
||||
unsigned int branch_ct[][2],
|
||||
const unsigned int num_events[]) {
|
||||
unsigned int left, right;
|
||||
|
||||
if (tree[i] <= 0)
|
||||
left = num_events[-tree[i]];
|
||||
else
|
||||
left = convert_distribution(tree[i], tree, branch_ct, num_events);
|
||||
|
||||
if (tree[i + 1] <= 0)
|
||||
right = num_events[-tree[i + 1]];
|
||||
else
|
||||
right = convert_distribution(tree[i + 1], tree, branch_ct, num_events);
|
||||
|
||||
branch_ct[i >> 1][0] = left;
|
||||
branch_ct[i >> 1][1] = right;
|
||||
return left + right;
|
||||
}
|
||||
|
||||
void vp9_tree_probs_from_distribution(vp9_tree tree,
|
||||
unsigned int branch_ct[/* n-1 */][2],
|
||||
const unsigned int num_events[/* n */]) {
|
||||
convert_distribution(0, tree, branch_ct, num_events);
|
||||
}
|
||||
|
||||
|
|
@ -39,11 +39,6 @@ typedef const vp9_tree_index vp9_tree[];
|
|||
taken for each node on the tree; this facilitiates decisions as to
|
||||
probability updates. */
|
||||
|
||||
void vp9_tree_probs_from_distribution(vp9_tree tree,
|
||||
unsigned int branch_ct[ /* n - 1 */ ][2],
|
||||
const unsigned int num_events[ /* n */ ]);
|
||||
|
||||
|
||||
static INLINE vp9_prob clip_prob(int p) {
|
||||
return (p > 255) ? 255u : (p < 1) ? 1u : p;
|
||||
}
|
||||
|
|
|
@ -57,3 +57,29 @@ void vp9_tokens_from_tree(struct vp9_token *tokens,
|
|||
const vp9_tree_index *tree) {
|
||||
tree2tok(tokens, tree, 0, 0, 0);
|
||||
}
|
||||
|
||||
static unsigned int convert_distribution(unsigned int i, vp9_tree tree,
|
||||
unsigned int branch_ct[][2],
|
||||
const unsigned int num_events[]) {
|
||||
unsigned int left, right;
|
||||
|
||||
if (tree[i] <= 0)
|
||||
left = num_events[-tree[i]];
|
||||
else
|
||||
left = convert_distribution(tree[i], tree, branch_ct, num_events);
|
||||
|
||||
if (tree[i + 1] <= 0)
|
||||
right = num_events[-tree[i + 1]];
|
||||
else
|
||||
right = convert_distribution(tree[i + 1], tree, branch_ct, num_events);
|
||||
|
||||
branch_ct[i >> 1][0] = left;
|
||||
branch_ct[i >> 1][1] = right;
|
||||
return left + right;
|
||||
}
|
||||
|
||||
void vp9_tree_probs_from_distribution(vp9_tree tree,
|
||||
unsigned int branch_ct[/* n-1 */][2],
|
||||
const unsigned int num_events[/* n */]) {
|
||||
convert_distribution(0, tree, branch_ct, num_events);
|
||||
}
|
||||
|
|
|
@ -75,4 +75,8 @@ static INLINE int treed_cost(vp9_tree tree, const vp9_prob *probs,
|
|||
void vp9_cost_tokens(int *costs, const vp9_prob *probs, vp9_tree tree);
|
||||
void vp9_cost_tokens_skip(int *costs, const vp9_prob *probs, vp9_tree tree);
|
||||
|
||||
void vp9_tree_probs_from_distribution(vp9_tree tree,
|
||||
unsigned int branch_ct[ /* n - 1 */ ][2],
|
||||
const unsigned int num_events[ /* n */ ]);
|
||||
|
||||
#endif // VP9_ENCODER_VP9_TREEWRITER_H_
|
||||
|
|
|
@ -61,7 +61,6 @@ VP9_COMMON_SRCS-yes += common/vp9_quant_common.c
|
|||
VP9_COMMON_SRCS-yes += common/vp9_reconinter.c
|
||||
VP9_COMMON_SRCS-yes += common/vp9_reconintra.c
|
||||
VP9_COMMON_SRCS-$(CONFIG_POSTPROC_VISUALIZER) += common/vp9_textblit.c
|
||||
VP9_COMMON_SRCS-yes += common/vp9_treecoder.c
|
||||
VP9_COMMON_SRCS-yes += common/vp9_common_data.c
|
||||
VP9_COMMON_SRCS-yes += common/vp9_common_data.h
|
||||
VP9_COMMON_SRCS-yes += common/vp9_scan.c
|
||||
|
|
Загрузка…
Ссылка в новой задаче