TX_SIZE contexts simplification.
Reduces TX_SIZE contexts to 2 for each kind. The code is cleaner and there is hardly any performance difference with more than two contexts. Results: almost neutral Change-Id: I17656bd6db76224ae2856adf882504560e7dbaa4
This commit is contained in:
Родитель
67cb1f093c
Коммит
17da2cab78
|
@ -149,24 +149,36 @@ static const vp9_prob default_single_ref_p[REF_CONTEXTS][2] = {
|
|||
{ 235, 248 },
|
||||
};
|
||||
|
||||
const vp9_prob vp9_default_tx_probs_32x32p[TX_SIZE_MAX_SB]
|
||||
#if TX_SIZE_CONTEXTS == 2
|
||||
const vp9_prob vp9_default_tx_probs_32x32p[TX_SIZE_CONTEXTS]
|
||||
[TX_SIZE_MAX_SB - 1] = {
|
||||
{ 16, 64, 96, },
|
||||
{ 32, 64, 96, },
|
||||
{ 32, 64, 96, },
|
||||
{ 32, 64, 96, },
|
||||
{ 16, 32, 64, },
|
||||
{ 16, 32, 64, },
|
||||
};
|
||||
const vp9_prob vp9_default_tx_probs_16x16p[TX_SIZE_MAX_SB - 1]
|
||||
const vp9_prob vp9_default_tx_probs_16x16p[TX_SIZE_CONTEXTS]
|
||||
[TX_SIZE_MAX_SB - 2] = {
|
||||
{ 32, 96, },
|
||||
{ 64, 96, },
|
||||
{ 64, 96, },
|
||||
{ 32, 64, },
|
||||
{ 32, 64, },
|
||||
};
|
||||
const vp9_prob vp9_default_tx_probs_8x8p[TX_SIZE_MAX_SB - 2]
|
||||
const vp9_prob vp9_default_tx_probs_8x8p[TX_SIZE_CONTEXTS]
|
||||
[TX_SIZE_MAX_SB - 3] = {
|
||||
{ 96, },
|
||||
{ 96, },
|
||||
{ 64, },
|
||||
{ 64, },
|
||||
};
|
||||
#else
|
||||
const vp9_prob vp9_default_tx_probs_32x32p[TX_SIZE_CONTEXTS]
|
||||
[TX_SIZE_MAX_SB - 1] = {
|
||||
{ 16, 32, 64, },
|
||||
};
|
||||
const vp9_prob vp9_default_tx_probs_16x16p[TX_SIZE_CONTEXTS]
|
||||
[TX_SIZE_MAX_SB - 2] = {
|
||||
{ 32, 64, },
|
||||
};
|
||||
const vp9_prob vp9_default_tx_probs_8x8p[TX_SIZE_CONTEXTS]
|
||||
[TX_SIZE_MAX_SB - 3] = {
|
||||
{ 64, },
|
||||
};
|
||||
#endif
|
||||
|
||||
void tx_counts_to_branch_counts_32x32(unsigned int *tx_count_32x32p,
|
||||
unsigned int (*ct_32x32p)[2]) {
|
||||
|
@ -438,7 +450,7 @@ void vp9_adapt_mode_probs(VP9_COMMON *cm) {
|
|||
unsigned int branch_ct_8x8p[TX_SIZE_MAX_SB - 3][2];
|
||||
unsigned int branch_ct_16x16p[TX_SIZE_MAX_SB - 2][2];
|
||||
unsigned int branch_ct_32x32p[TX_SIZE_MAX_SB - 1][2];
|
||||
for (i = 0; i < TX_SIZE_MAX_SB - 2; ++i) {
|
||||
for (i = 0; i < TX_SIZE_CONTEXTS; ++i) {
|
||||
tx_counts_to_branch_counts_8x8(cm->fc.tx_count_8x8p[i],
|
||||
branch_ct_8x8p);
|
||||
for (j = 0; j < TX_SIZE_MAX_SB - 3; ++j) {
|
||||
|
@ -452,7 +464,7 @@ void vp9_adapt_mode_probs(VP9_COMMON *cm) {
|
|||
cm->fc.pre_tx_probs_8x8p[i][j], prob, factor);
|
||||
}
|
||||
}
|
||||
for (i = 0; i < TX_SIZE_MAX_SB - 1; ++i) {
|
||||
for (i = 0; i < TX_SIZE_CONTEXTS; ++i) {
|
||||
tx_counts_to_branch_counts_16x16(cm->fc.tx_count_16x16p[i],
|
||||
branch_ct_16x16p);
|
||||
for (j = 0; j < TX_SIZE_MAX_SB - 2; ++j) {
|
||||
|
@ -466,7 +478,7 @@ void vp9_adapt_mode_probs(VP9_COMMON *cm) {
|
|||
cm->fc.pre_tx_probs_16x16p[i][j], prob, factor);
|
||||
}
|
||||
}
|
||||
for (i = 0; i < TX_SIZE_MAX_SB; ++i) {
|
||||
for (i = 0; i < TX_SIZE_CONTEXTS; ++i) {
|
||||
tx_counts_to_branch_counts_32x32(cm->fc.tx_count_32x32p[i],
|
||||
branch_ct_32x32p);
|
||||
for (j = 0; j < TX_SIZE_MAX_SB - 1; ++j) {
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "vp9/common/vp9_treecoder.h"
|
||||
|
||||
#define SUBMVREF_COUNT 5
|
||||
#define TX_SIZE_CONTEXTS 2
|
||||
|
||||
// #define MODE_STATS
|
||||
|
||||
|
@ -77,11 +78,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_32x32p[TX_SIZE_MAX_SB]
|
||||
extern const vp9_prob vp9_default_tx_probs_32x32p[TX_SIZE_CONTEXTS]
|
||||
[TX_SIZE_MAX_SB - 1];
|
||||
extern const vp9_prob vp9_default_tx_probs_16x16p[TX_SIZE_MAX_SB - 1]
|
||||
extern const vp9_prob vp9_default_tx_probs_16x16p[TX_SIZE_CONTEXTS]
|
||||
[TX_SIZE_MAX_SB - 2];
|
||||
extern const vp9_prob vp9_default_tx_probs_8x8p[TX_SIZE_MAX_SB - 2]
|
||||
extern const vp9_prob vp9_default_tx_probs_8x8p[TX_SIZE_CONTEXTS]
|
||||
[TX_SIZE_MAX_SB - 3];
|
||||
|
||||
extern void tx_counts_to_branch_counts_32x32(unsigned int *tx_count_32x32p,
|
||||
|
|
|
@ -90,15 +90,15 @@ typedef struct frame_contexts {
|
|||
unsigned int single_ref_count[REF_CONTEXTS][2][2];
|
||||
unsigned int comp_ref_count[REF_CONTEXTS][2];
|
||||
|
||||
vp9_prob tx_probs_32x32p[TX_SIZE_MAX_SB][TX_SIZE_MAX_SB - 1];
|
||||
vp9_prob tx_probs_16x16p[TX_SIZE_MAX_SB - 1][TX_SIZE_MAX_SB - 2];
|
||||
vp9_prob tx_probs_8x8p[TX_SIZE_MAX_SB - 2][TX_SIZE_MAX_SB - 3];
|
||||
vp9_prob pre_tx_probs_32x32p[TX_SIZE_MAX_SB][TX_SIZE_MAX_SB - 1];
|
||||
vp9_prob pre_tx_probs_16x16p[TX_SIZE_MAX_SB - 1][TX_SIZE_MAX_SB - 2];
|
||||
vp9_prob pre_tx_probs_8x8p[TX_SIZE_MAX_SB - 2][TX_SIZE_MAX_SB - 3];
|
||||
unsigned int tx_count_32x32p[TX_SIZE_MAX_SB][TX_SIZE_MAX_SB];
|
||||
unsigned int tx_count_16x16p[TX_SIZE_MAX_SB - 1][TX_SIZE_MAX_SB - 1];
|
||||
unsigned int tx_count_8x8p[TX_SIZE_MAX_SB - 2][TX_SIZE_MAX_SB - 2];
|
||||
vp9_prob tx_probs_32x32p[TX_SIZE_CONTEXTS][TX_SIZE_MAX_SB - 1];
|
||||
vp9_prob tx_probs_16x16p[TX_SIZE_CONTEXTS][TX_SIZE_MAX_SB - 2];
|
||||
vp9_prob tx_probs_8x8p[TX_SIZE_CONTEXTS][TX_SIZE_MAX_SB - 3];
|
||||
vp9_prob pre_tx_probs_32x32p[TX_SIZE_CONTEXTS][TX_SIZE_MAX_SB - 1];
|
||||
vp9_prob pre_tx_probs_16x16p[TX_SIZE_CONTEXTS][TX_SIZE_MAX_SB - 2];
|
||||
vp9_prob pre_tx_probs_8x8p[TX_SIZE_CONTEXTS][TX_SIZE_MAX_SB - 3];
|
||||
unsigned int tx_count_32x32p[TX_SIZE_CONTEXTS][TX_SIZE_MAX_SB];
|
||||
unsigned int tx_count_16x16p[TX_SIZE_CONTEXTS][TX_SIZE_MAX_SB - 1];
|
||||
unsigned int tx_count_8x8p[TX_SIZE_CONTEXTS][TX_SIZE_MAX_SB - 2];
|
||||
|
||||
vp9_prob mbskip_probs[MBSKIP_CONTEXTS];
|
||||
vp9_prob pre_mbskip_probs[MBSKIP_CONTEXTS];
|
||||
|
|
|
@ -349,7 +349,8 @@ unsigned char vp9_get_pred_context(const VP9_COMMON *const cm,
|
|||
}
|
||||
|
||||
case PRED_TX_SIZE: {
|
||||
int above_context = TX_16X16, left_context = TX_16X16;
|
||||
#if TX_SIZE_CONTEXTS == 2
|
||||
int above_context, left_context;
|
||||
int max_tx_size;
|
||||
if (mi->mbmi.sb_type < BLOCK_SIZE_SB8X8)
|
||||
max_tx_size = TX_4X4;
|
||||
|
@ -359,6 +360,7 @@ unsigned char vp9_get_pred_context(const VP9_COMMON *const cm,
|
|||
max_tx_size = TX_16X16;
|
||||
else
|
||||
max_tx_size = TX_32X32;
|
||||
above_context = left_context = max_tx_size;
|
||||
if (above_in_image) {
|
||||
above_context = (above_mi->mbmi.mb_skip_coeff ?
|
||||
max_tx_size : above_mi->mbmi.txfm_size);
|
||||
|
@ -373,9 +375,10 @@ unsigned char vp9_get_pred_context(const VP9_COMMON *const cm,
|
|||
if (!above_in_image) {
|
||||
above_context = left_context;
|
||||
}
|
||||
pred_context = (above_context + left_context + 1) >> 1;
|
||||
if (pred_context > max_tx_size)
|
||||
pred_context = max_tx_size;
|
||||
pred_context = (above_context + left_context > max_tx_size);
|
||||
#else
|
||||
pred_context = 0;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -59,21 +59,21 @@ static void setup_txfm_mode(VP9_COMMON *pc, int lossless, vp9_reader *r) {
|
|||
pc->txfm_mode += vp9_read_bit(r);
|
||||
if (pc->txfm_mode == TX_MODE_SELECT) {
|
||||
int i, j;
|
||||
for (i = 0; i < TX_SIZE_MAX_SB - 2; ++i) {
|
||||
for (i = 0; i < TX_SIZE_CONTEXTS; ++i) {
|
||||
for (j = 0; j < TX_SIZE_MAX_SB - 3; ++j) {
|
||||
if (vp9_read(r, VP9_DEF_UPDATE_PROB))
|
||||
pc->fc.tx_probs_8x8p[i][j] =
|
||||
vp9_read_prob_diff_update(r, pc->fc.tx_probs_8x8p[i][j]);
|
||||
}
|
||||
}
|
||||
for (i = 0; i < TX_SIZE_MAX_SB - 1; ++i) {
|
||||
for (i = 0; i < TX_SIZE_CONTEXTS; ++i) {
|
||||
for (j = 0; j < TX_SIZE_MAX_SB - 2; ++j) {
|
||||
if (vp9_read(r, VP9_DEF_UPDATE_PROB))
|
||||
pc->fc.tx_probs_16x16p[i][j] =
|
||||
vp9_read_prob_diff_update(r, pc->fc.tx_probs_16x16p[i][j]);
|
||||
}
|
||||
}
|
||||
for (i = 0; i < TX_SIZE_MAX_SB; ++i) {
|
||||
for (i = 0; i < TX_SIZE_CONTEXTS; ++i) {
|
||||
for (j = 0; j < TX_SIZE_MAX_SB - 1; ++j) {
|
||||
if (vp9_read(r, VP9_DEF_UPDATE_PROB))
|
||||
pc->fc.tx_probs_32x32p[i][j] =
|
||||
|
|
|
@ -52,9 +52,9 @@ extern unsigned int active_section;
|
|||
#define vp9_cost_upd256 ((int)(vp9_cost_one(upd) - vp9_cost_zero(upd)))
|
||||
|
||||
#ifdef MODE_STATS
|
||||
int64_t tx_count_32x32p_stats[TX_SIZE_MAX_SB][TX_SIZE_MAX_SB];
|
||||
int64_t tx_count_16x16p_stats[TX_SIZE_MAX_SB - 1][TX_SIZE_MAX_SB - 1];
|
||||
int64_t tx_count_8x8p_stats[TX_SIZE_MAX_SB - 2][TX_SIZE_MAX_SB - 2];
|
||||
int64_t tx_count_32x32p_stats[TX_SIZE_CONTEXTS][TX_SIZE_MAX_SB];
|
||||
int64_t tx_count_16x16p_stats[TX_SIZE_CONTEXTS][TX_SIZE_MAX_SB - 1];
|
||||
int64_t tx_count_8x8p_stats[TX_SIZE_CONTEXTS][TX_SIZE_MAX_SB - 2];
|
||||
|
||||
void init_tx_count_stats() {
|
||||
vp9_zero(tx_count_32x32p_stats);
|
||||
|
@ -64,17 +64,17 @@ void init_tx_count_stats() {
|
|||
|
||||
static void update_tx_count_stats(VP9_COMMON *cm) {
|
||||
int i, j;
|
||||
for (i = 0; i < TX_SIZE_MAX_SB; i++) {
|
||||
for (i = 0; i < TX_SIZE_CONTEXTS; i++) {
|
||||
for (j = 0; j < TX_SIZE_MAX_SB; j++) {
|
||||
tx_count_32x32p_stats[i][j] += cm->fc.tx_count_32x32p[i][j];
|
||||
}
|
||||
}
|
||||
for (i = 0; i < TX_SIZE_MAX_SB - 1; i++) {
|
||||
for (i = 0; i < TX_SIZE_CONTEXTS; i++) {
|
||||
for (j = 0; j < TX_SIZE_MAX_SB - 1; j++) {
|
||||
tx_count_16x16p_stats[i][j] += cm->fc.tx_count_16x16p[i][j];
|
||||
}
|
||||
}
|
||||
for (i = 0; i < TX_SIZE_MAX_SB - 2; i++) {
|
||||
for (i = 0; i < TX_SIZE_CONTEXTS; i++) {
|
||||
for (j = 0; j < TX_SIZE_MAX_SB - 2; j++) {
|
||||
tx_count_8x8p_stats[i][j] += cm->fc.tx_count_8x8p[i][j];
|
||||
}
|
||||
|
@ -89,27 +89,30 @@ void write_tx_count_stats() {
|
|||
fwrite(tx_count_8x8p_stats, sizeof(tx_count_8x8p_stats), 1, fp);
|
||||
fclose(fp);
|
||||
|
||||
printf("vp9_default_tx_count_32x32p[TX_SIZE_MAX_SB][TX_SIZE_MAX_SB] = {\n");
|
||||
for (i = 0; i < TX_SIZE_MAX_SB; i++) {
|
||||
printf("{ ");
|
||||
printf(
|
||||
"vp9_default_tx_count_32x32p[TX_SIZE_CONTEXTS][TX_SIZE_MAX_SB] = {\n");
|
||||
for (i = 0; i < TX_SIZE_CONTEXTS; i++) {
|
||||
printf(" { ");
|
||||
for (j = 0; j < TX_SIZE_MAX_SB; j++) {
|
||||
printf("%"PRId64", ", tx_count_32x32p_stats[i][j]);
|
||||
}
|
||||
printf("},\n");
|
||||
}
|
||||
printf("};\n");
|
||||
printf("vp9_default_tx_count_16x16p[TX_SIZE_MAX_SB-1][TX_SIZE_MAX_SB-1] = {\n");
|
||||
for (i = 0; i < TX_SIZE_MAX_SB - 1; i++) {
|
||||
printf("{ ");
|
||||
printf(
|
||||
"vp9_default_tx_count_16x16p[TX_SIZE_CONTEXTS][TX_SIZE_MAX_SB-1] = {\n");
|
||||
for (i = 0; i < TX_SIZE_CONTEXTS; i++) {
|
||||
printf(" { ");
|
||||
for (j = 0; j < TX_SIZE_MAX_SB - 1; j++) {
|
||||
printf("%"PRId64", ", tx_count_16x16p_stats[i][j]);
|
||||
}
|
||||
printf("},\n");
|
||||
}
|
||||
printf("};\n");
|
||||
printf("vp9_default_tx_count_8x8p[TX_SIZE_MAX_SB-2][TX_SIZE_MAX_SB-2] = {\n");
|
||||
for (i = 0; i < TX_SIZE_MAX_SB - 2; i++) {
|
||||
printf("{ ");
|
||||
printf(
|
||||
"vp9_default_tx_count_8x8p[TX_SIZE_CONTEXTS][TX_SIZE_MAX_SB-2] = {\n");
|
||||
for (i = 0; i < TX_SIZE_CONTEXTS; i++) {
|
||||
printf(" { ");
|
||||
for (j = 0; j < TX_SIZE_MAX_SB - 2; j++) {
|
||||
printf("%"PRId64", ", tx_count_8x8p_stats[i][j]);
|
||||
}
|
||||
|
@ -1301,7 +1304,7 @@ static void encode_txfm_probs(VP9_COMP *cpi, vp9_writer *w) {
|
|||
unsigned int ct_32x32p[TX_SIZE_MAX_SB - 1][2];
|
||||
|
||||
|
||||
for (i = 0; i < TX_SIZE_MAX_SB - 2; i++) {
|
||||
for (i = 0; i < TX_SIZE_CONTEXTS; i++) {
|
||||
tx_counts_to_branch_counts_8x8(cm->fc.tx_count_8x8p[i],
|
||||
ct_8x8p);
|
||||
for (j = 0; j < TX_SIZE_MAX_SB - 3; j++) {
|
||||
|
@ -1309,7 +1312,7 @@ static void encode_txfm_probs(VP9_COMP *cpi, vp9_writer *w) {
|
|||
VP9_DEF_UPDATE_PROB, ct_8x8p[j]);
|
||||
}
|
||||
}
|
||||
for (i = 0; i < TX_SIZE_MAX_SB - 1; i++) {
|
||||
for (i = 0; i < TX_SIZE_CONTEXTS; i++) {
|
||||
tx_counts_to_branch_counts_16x16(cm->fc.tx_count_16x16p[i],
|
||||
ct_16x16p);
|
||||
for (j = 0; j < TX_SIZE_MAX_SB - 2; j++) {
|
||||
|
@ -1317,7 +1320,7 @@ static void encode_txfm_probs(VP9_COMP *cpi, vp9_writer *w) {
|
|||
VP9_DEF_UPDATE_PROB, ct_16x16p[j]);
|
||||
}
|
||||
}
|
||||
for (i = 0; i < TX_SIZE_MAX_SB; i++) {
|
||||
for (i = 0; i < TX_SIZE_CONTEXTS; i++) {
|
||||
tx_counts_to_branch_counts_32x32(cm->fc.tx_count_32x32p[i],
|
||||
ct_32x32p);
|
||||
for (j = 0; j < TX_SIZE_MAX_SB - 1; j++) {
|
||||
|
|
|
@ -1869,28 +1869,28 @@ void vp9_encode_frame(VP9_COMP *cpi) {
|
|||
int count16x16_16x16p = 0, count16x16_lp = 0;
|
||||
int count32x32 = 0;
|
||||
|
||||
for (i = 0; i < TX_SIZE_MAX_SB; i++)
|
||||
for (i = 0; i < TX_SIZE_CONTEXTS; i++)
|
||||
count4x4 += cm->fc.tx_count_32x32p[i][TX_4X4];
|
||||
for (i = 0; i < TX_SIZE_MAX_SB - 1; i++)
|
||||
for (i = 0; i < TX_SIZE_CONTEXTS; i++)
|
||||
count4x4 += cm->fc.tx_count_16x16p[i][TX_4X4];
|
||||
for (i = 0; i < TX_SIZE_MAX_SB - 2; i++)
|
||||
for (i = 0; i < TX_SIZE_CONTEXTS; i++)
|
||||
count4x4 += cm->fc.tx_count_8x8p[i][TX_4X4];
|
||||
|
||||
for (i = 0; i < TX_SIZE_MAX_SB; i++)
|
||||
for (i = 0; i < TX_SIZE_CONTEXTS; i++)
|
||||
count8x8_lp += cm->fc.tx_count_32x32p[i][TX_8X8];
|
||||
for (i = 0; i < TX_SIZE_MAX_SB - 1; i++)
|
||||
for (i = 0; i < TX_SIZE_CONTEXTS; i++)
|
||||
count8x8_lp += cm->fc.tx_count_16x16p[i][TX_8X8];
|
||||
|
||||
for (i = 0; i < TX_SIZE_MAX_SB - 2; i++)
|
||||
for (i = 0; i < TX_SIZE_CONTEXTS; i++)
|
||||
count8x8_8x8p += cm->fc.tx_count_8x8p[i][TX_8X8];
|
||||
|
||||
for (i = 0; i < TX_SIZE_MAX_SB - 1; i++)
|
||||
for (i = 0; i < TX_SIZE_CONTEXTS; i++)
|
||||
count16x16_16x16p += cm->fc.tx_count_16x16p[i][TX_16X16];
|
||||
|
||||
for (i = 0; i < TX_SIZE_MAX_SB; i++)
|
||||
for (i = 0; i < TX_SIZE_CONTEXTS; i++)
|
||||
count16x16_lp += cm->fc.tx_count_32x32p[i][TX_16X16];
|
||||
|
||||
for (i = 0; i < TX_SIZE_MAX_SB; i++)
|
||||
for (i = 0; i < TX_SIZE_CONTEXTS; i++)
|
||||
count32x32 += cm->fc.tx_count_32x32p[i][TX_32X32];
|
||||
|
||||
if (count4x4 == 0 && count16x16_lp == 0 && count16x16_16x16p == 0 &&
|
||||
|
|
|
@ -89,9 +89,9 @@ typedef struct {
|
|||
int inter_mode_counts[INTER_MODE_CONTEXTS][VP9_INTER_MODES - 1][2];
|
||||
vp9_prob inter_mode_probs[INTER_MODE_CONTEXTS][VP9_INTER_MODES - 1];
|
||||
|
||||
vp9_prob tx_probs_8x8p[TX_SIZE_MAX_SB - 2][TX_SIZE_MAX_SB - 3];
|
||||
vp9_prob tx_probs_16x16p[TX_SIZE_MAX_SB - 1][TX_SIZE_MAX_SB - 2];
|
||||
vp9_prob tx_probs_32x32p[TX_SIZE_MAX_SB][TX_SIZE_MAX_SB - 1];
|
||||
vp9_prob tx_probs_8x8p[TX_SIZE_CONTEXTS][TX_SIZE_MAX_SB - 3];
|
||||
vp9_prob tx_probs_16x16p[TX_SIZE_CONTEXTS][TX_SIZE_MAX_SB - 2];
|
||||
vp9_prob tx_probs_32x32p[TX_SIZE_CONTEXTS][TX_SIZE_MAX_SB - 1];
|
||||
vp9_prob mbskip_probs[MBSKIP_CONTEXTS];
|
||||
} CODING_CONTEXT;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче