summaryrefslogtreecommitdiff
path: root/vp9/common
diff options
context:
space:
mode:
Diffstat (limited to 'vp9/common')
-rw-r--r--vp9/common/vp9_blockd.h9
-rw-r--r--vp9/common/vp9_entropymode.c64
-rw-r--r--vp9/common/vp9_entropymode.h7
-rw-r--r--vp9/common/vp9_onyxc_int.h8
4 files changed, 85 insertions, 3 deletions
diff --git a/vp9/common/vp9_blockd.h b/vp9/common/vp9_blockd.h
index b8822a614..fc9fe7cdf 100644
--- a/vp9/common/vp9_blockd.h
+++ b/vp9/common/vp9_blockd.h
@@ -122,6 +122,15 @@ typedef enum {
#define WHT_UPSCALE_FACTOR 2
+#define TX_SIZE_PROBS 6 // (TX_SIZE_MAX_SB * (TX_SIZE_MAX_SB - 1) / 2)
+
+#if TX_SIZE_PROBS == 6
+#define get_tx_probs_offset(b) ((b) < BLOCK_SIZE_MB16X16 ? 0 : \
+ (b) < BLOCK_SIZE_SB32X32 ? 1 : 3)
+#else
+#define get_tx_probs_offset(b) 0
+#endif
+
/* For keyframes, intra block modes are predicted by the (already decoded)
modes for the Y blocks to the left and above us; for interframes, there
is a single probability table. */
diff --git a/vp9/common/vp9_entropymode.c b/vp9/common/vp9_entropymode.c
index bed4edf97..699b84686 100644
--- a/vp9/common/vp9_entropymode.c
+++ b/vp9/common/vp9_entropymode.c
@@ -149,6 +149,54 @@ static const vp9_prob default_single_ref_p[REF_CONTEXTS][2] = {
{ 235, 248 },
};
+void tx_counts_to_branch_counts(unsigned int *tx_count_32x32p,
+ unsigned int *tx_count_16x16p,
+ unsigned int *tx_count_8x8p,
+ unsigned int (*ct)[2]) {
+#if TX_SIZE_PROBS == 6
+ ct[0][0] = tx_count_8x8p[TX_4X4];
+ ct[0][1] = tx_count_8x8p[TX_8X8];
+ ct[1][0] = tx_count_16x16p[TX_4X4];
+ ct[1][1] = tx_count_16x16p[TX_8X8] + tx_count_16x16p[TX_16X16];
+ ct[2][0] = tx_count_16x16p[TX_8X8];
+ ct[2][1] = tx_count_16x16p[TX_16X16];
+ ct[3][0] = tx_count_32x32p[TX_4X4];
+ ct[3][1] = tx_count_32x32p[TX_8X8] + tx_count_32x32p[TX_16X16] +
+ tx_count_32x32p[TX_32X32];
+ ct[4][0] = tx_count_32x32p[TX_8X8];
+ ct[4][1] = tx_count_32x32p[TX_16X16] + tx_count_32x32p[TX_32X32];
+ ct[5][0] = tx_count_32x32p[TX_16X16];
+ ct[5][1] = tx_count_32x32p[TX_32X32];
+#else
+ ct[0][0] = tx_count_32x32p[TX_4X4] +
+ tx_count_16x16p[TX_4X4] +
+ tx_count_8x8p[TX_4X4];
+ ct[0][1] = tx_count_32x32p[TX_8X8] +
+ tx_count_32x32p[TX_16X16] +
+ tx_count_32x32p[TX_32X32] +
+ tx_count_16x16p[TX_8X8] +
+ tx_count_16x16p[TX_16X16] +
+ tx_count_8x8p[TX_8X8];
+ ct[1][0] = tx_count_32x32p[TX_8X8] +
+ tx_count_16x16p[TX_8X8];
+ ct[1][1] = tx_count_32x32p[TX_16X16] +
+ tx_count_32x32p[TX_32X32] +
+ tx_count_16x16p[TX_16X16];
+ ct[2][0] = tx_count_32x32p[TX_16X16];
+ ct[2][1] = tx_count_32x32p[TX_32X32];
+#endif
+}
+
+#if TX_SIZE_PROBS == 6
+const vp9_prob vp9_default_tx_probs[TX_SIZE_PROBS] = {
+ 96, 96, 96, 96, 96, 96
+};
+#else
+const vp9_prob vp9_default_tx_probs[TX_SIZE_PROBS] = {
+ 96, 96, 96
+};
+#endif
+
void vp9_init_mbmode_probs(VP9_COMMON *x) {
vpx_memcpy(x->fc.uv_mode_prob, default_if_uv_probs,
sizeof(default_if_uv_probs));
@@ -171,6 +219,8 @@ void vp9_init_mbmode_probs(VP9_COMMON *x) {
sizeof(default_comp_ref_p));
vpx_memcpy(x->fc.single_ref_prob, default_single_ref_p,
sizeof(default_single_ref_p));
+ vpx_memcpy(x->fc.tx_probs, vp9_default_tx_probs,
+ sizeof(vp9_default_tx_probs));
}
#if VP9_SWITCHABLE_FILTERS == 3
@@ -374,6 +424,20 @@ void vp9_adapt_mode_probs(VP9_COMMON *cm) {
fc->switchable_interp_prob[i], 0);
}
}
+ if (cm->txfm_mode == TX_MODE_SELECT) {
+ unsigned int branch_ct[TX_SIZE_PROBS][2];
+ tx_counts_to_branch_counts(cm->fc.tx_count_32x32p,
+ cm->fc.tx_count_16x16p,
+ cm->fc.tx_count_8x8p, branch_ct);
+ for (i = 0; i < TX_SIZE_PROBS; ++i) {
+ int factor;
+ int count = branch_ct[i][0] + branch_ct[i][1];
+ vp9_prob prob = get_binary_prob(branch_ct[i][0], branch_ct[i][1]);
+ count = count > MODE_COUNT_SAT ? MODE_COUNT_SAT : count;
+ factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_COUNT_SAT);
+ cm->fc.tx_probs[i] = weighted_prob(cm->fc.pre_tx_probs[i], prob, factor);
+ }
+ }
}
static void set_default_lf_deltas(MACROBLOCKD *xd) {
diff --git a/vp9/common/vp9_entropymode.h b/vp9/common/vp9_entropymode.h
index 32a40adc7..ce13a4cb1 100644
--- a/vp9/common/vp9_entropymode.h
+++ b/vp9/common/vp9_entropymode.h
@@ -75,4 +75,11 @@ extern struct vp9_token vp9_switchable_interp_encodings[VP9_SWITCHABLE_FILTERS];
extern const vp9_prob vp9_switchable_interp_prob[VP9_SWITCHABLE_FILTERS + 1]
[VP9_SWITCHABLE_FILTERS - 1];
+extern const vp9_prob vp9_default_tx_probs[TX_SIZE_PROBS];
+
+extern void tx_counts_to_branch_counts(unsigned int *tx_count_32x32p,
+ unsigned int *tx_count_16x16p,
+ unsigned int *tx_count_8x8p,
+ unsigned int (*ct)[2]);
+
#endif // VP9_COMMON_VP9_ENTROPYMODE_H_
diff --git a/vp9/common/vp9_onyxc_int.h b/vp9/common/vp9_onyxc_int.h
index e73d88c26..dedda2069 100644
--- a/vp9/common/vp9_onyxc_int.h
+++ b/vp9/common/vp9_onyxc_int.h
@@ -89,6 +89,11 @@ typedef struct frame_contexts {
unsigned int comp_inter_count[COMP_INTER_CONTEXTS][2];
unsigned int single_ref_count[REF_CONTEXTS][2][2];
unsigned int comp_ref_count[REF_CONTEXTS][2];
+ vp9_prob tx_probs[TX_SIZE_PROBS];
+ vp9_prob pre_tx_probs[TX_SIZE_PROBS];
+ unsigned int tx_count_32x32p[TX_SIZE_MAX_SB];
+ unsigned int tx_count_16x16p[TX_SIZE_MAX_SB - 1];
+ unsigned int tx_count_8x8p[TX_SIZE_MAX_SB - 2];
} FRAME_CONTEXT;
typedef enum {
@@ -239,9 +244,6 @@ typedef struct VP9Common {
MV_REFERENCE_FRAME comp_var_ref[2];
COMPPREDMODE_TYPE comp_pred_mode;
- // FIXME contextualize
- vp9_prob prob_tx[TX_SIZE_MAX_SB - 1];
-
vp9_prob mbskip_pred_probs[MBSKIP_CONTEXTS];
FRAME_CONTEXT fc; /* this frame entropy */