Commit 3ef926ed authored by Nathan E. Egge's avatar Nathan E. Egge Committed by Yaowu Xu

Update kf_y_mode_cdf tables once per frame.

Move computing the kf_y_mode_cdf tables per coded intra mode symbol to
 computing them only when the probabilities are updated.

Change-Id: I5999447050c2f7d5dbccde80bee05ecd1c5440ab
parent 5357dcaf
...@@ -147,6 +147,9 @@ const aom_prob av1_kf_y_mode_prob[INTRA_MODES][INTRA_MODES][INTRA_MODES - 1] = { ...@@ -147,6 +147,9 @@ const aom_prob av1_kf_y_mode_prob[INTRA_MODES][INTRA_MODES][INTRA_MODES - 1] = {
{ 43, 81, 53, 140, 169, 204, 68, 84, 72 } // left = tm { 43, 81, 53, 140, 169, 204, 68, 84, 72 } // left = tm
} }
}; };
#if CONFIG_DAALA_EC
aom_cdf_prob av1_kf_y_mode_cdf[INTRA_MODES][INTRA_MODES][INTRA_MODES];
#endif
static const aom_prob default_if_y_probs[BLOCK_SIZE_GROUPS][INTRA_MODES - 1] = { static const aom_prob default_if_y_probs[BLOCK_SIZE_GROUPS][INTRA_MODES - 1] = {
{ 65, 32, 18, 144, 162, 194, 41, 51, 98 }, // block_size < 8x8 { 65, 32, 18, 144, 162, 194, 41, 51, 98 }, // block_size < 8x8
...@@ -368,6 +371,8 @@ static const aom_prob default_motion_mode_prob[BLOCK_SIZES][MOTION_MODES - 1] = ...@@ -368,6 +371,8 @@ static const aom_prob default_motion_mode_prob[BLOCK_SIZES][MOTION_MODES - 1] =
static const aom_prob default_delta_q_probs[DELTA_Q_CONTEXTS] = { 220, 220, static const aom_prob default_delta_q_probs[DELTA_Q_CONTEXTS] = { 220, 220,
220 }; 220 };
#endif #endif
int av1_intra_mode_ind[INTRA_MODES];
int av1_intra_mode_inv[INTRA_MODES];
/* Array indices are identical to previously-existing INTRAMODECONTEXTNODES. */ /* Array indices are identical to previously-existing INTRAMODECONTEXTNODES. */
const aom_tree_index av1_intra_mode_tree[TREE_SIZE(INTRA_MODES)] = { const aom_tree_index av1_intra_mode_tree[TREE_SIZE(INTRA_MODES)] = {
...@@ -1414,6 +1419,8 @@ static void init_mode_probs(FRAME_CONTEXT *fc) { ...@@ -1414,6 +1419,8 @@ static void init_mode_probs(FRAME_CONTEXT *fc) {
fc->inter_ext_tx_cdf, EXT_TX_SIZES); fc->inter_ext_tx_cdf, EXT_TX_SIZES);
av1_tree_to_cdf_1D(av1_partition_tree, fc->partition_prob, fc->partition_cdf, av1_tree_to_cdf_1D(av1_partition_tree, fc->partition_prob, fc->partition_cdf,
PARTITION_CONTEXTS); PARTITION_CONTEXTS);
av1_tree_to_cdf_2D(av1_intra_mode_tree, av1_kf_y_mode_prob, av1_kf_y_mode_cdf,
INTRA_MODES, INTRA_MODES);
av1_tree_to_cdf(av1_segment_tree, fc->seg.tree_probs, fc->seg.tree_cdf); av1_tree_to_cdf(av1_segment_tree, fc->seg.tree_probs, fc->seg.tree_cdf);
#endif #endif
#if CONFIG_DELTA_Q #if CONFIG_DELTA_Q
......
...@@ -276,6 +276,9 @@ typedef struct FRAME_COUNTS { ...@@ -276,6 +276,9 @@ typedef struct FRAME_COUNTS {
extern const aom_prob av1_kf_y_mode_prob[INTRA_MODES][INTRA_MODES] extern const aom_prob av1_kf_y_mode_prob[INTRA_MODES][INTRA_MODES]
[INTRA_MODES - 1]; [INTRA_MODES - 1];
#if CONFIG_DAALA_EC
extern aom_cdf_prob av1_kf_y_mode_cdf[INTRA_MODES][INTRA_MODES][INTRA_MODES];
#endif
#if CONFIG_PALETTE #if CONFIG_PALETTE
extern const aom_prob av1_default_palette_y_mode_prob[PALETTE_BLOCK_SIZES] extern const aom_prob av1_default_palette_y_mode_prob[PALETTE_BLOCK_SIZES]
[PALETTE_Y_MODE_CONTEXTS]; [PALETTE_Y_MODE_CONTEXTS];
...@@ -294,6 +297,10 @@ extern const aom_prob av1_default_palette_uv_color_prob[PALETTE_MAX_SIZE - 1] ...@@ -294,6 +297,10 @@ extern const aom_prob av1_default_palette_uv_color_prob[PALETTE_MAX_SIZE - 1]
extern const aom_tree_index av1_intra_mode_tree[TREE_SIZE(INTRA_MODES)]; extern const aom_tree_index av1_intra_mode_tree[TREE_SIZE(INTRA_MODES)];
extern const aom_tree_index av1_inter_mode_tree[TREE_SIZE(INTER_MODES)]; extern const aom_tree_index av1_inter_mode_tree[TREE_SIZE(INTER_MODES)];
#if CONFIG_DAALA_EC
extern int av1_intra_mode_ind[INTRA_MODES];
extern int av1_intra_mode_inv[INTRA_MODES];
#endif
#if CONFIG_EXT_INTER #if CONFIG_EXT_INTER
extern const aom_tree_index extern const aom_tree_index
av1_interintra_mode_tree[TREE_SIZE(INTERINTRA_MODES)]; av1_interintra_mode_tree[TREE_SIZE(INTERINTRA_MODES)];
......
...@@ -378,6 +378,9 @@ typedef struct AV1Common { ...@@ -378,6 +378,9 @@ typedef struct AV1Common {
// - this is intentionally not placed in FRAME_CONTEXT since it's reset upon // - this is intentionally not placed in FRAME_CONTEXT since it's reset upon
// each keyframe and not used afterwards // each keyframe and not used afterwards
aom_prob kf_y_prob[INTRA_MODES][INTRA_MODES][INTRA_MODES - 1]; aom_prob kf_y_prob[INTRA_MODES][INTRA_MODES][INTRA_MODES - 1];
#if CONFIG_DAALA_EC
aom_cdf_prob kf_y_cdf[INTRA_MODES][INTRA_MODES][INTRA_MODES];
#endif
#if CONFIG_GLOBAL_MOTION #if CONFIG_GLOBAL_MOTION
Global_Motion_Params global_motion[TOTAL_REFS_PER_FRAME]; Global_Motion_Params global_motion[TOTAL_REFS_PER_FRAME];
#endif #endif
...@@ -582,6 +585,18 @@ static INLINE const aom_prob *get_y_mode_probs(const AV1_COMMON *cm, ...@@ -582,6 +585,18 @@ static INLINE const aom_prob *get_y_mode_probs(const AV1_COMMON *cm,
return cm->kf_y_prob[above][left]; return cm->kf_y_prob[above][left];
} }
#if CONFIG_DAALA_EC
static INLINE const aom_cdf_prob *get_y_mode_cdf(const AV1_COMMON *cm,
const MODE_INFO *mi,
const MODE_INFO *above_mi,
const MODE_INFO *left_mi,
int block) {
const PREDICTION_MODE above = av1_above_block_mode(mi, above_mi, block);
const PREDICTION_MODE left = av1_left_block_mode(mi, left_mi, block);
return cm->kf_y_cdf[above][left];
}
#endif
static INLINE void update_partition_context(MACROBLOCKD *xd, int mi_row, static INLINE void update_partition_context(MACROBLOCKD *xd, int mi_row,
int mi_col, BLOCK_SIZE subsize, int mi_col, BLOCK_SIZE subsize,
BLOCK_SIZE bsize) { BLOCK_SIZE bsize) {
......
...@@ -3754,10 +3754,18 @@ static int read_compressed_header(AV1Decoder *pbi, const uint8_t *data, ...@@ -3754,10 +3754,18 @@ static int read_compressed_header(AV1Decoder *pbi, const uint8_t *data,
if (frame_is_intra_only(cm)) { if (frame_is_intra_only(cm)) {
av1_copy(cm->kf_y_prob, av1_kf_y_mode_prob); av1_copy(cm->kf_y_prob, av1_kf_y_mode_prob);
#if CONFIG_DAALA_EC
av1_copy(cm->kf_y_cdf, av1_kf_y_mode_cdf);
#endif
for (k = 0; k < INTRA_MODES; k++) for (k = 0; k < INTRA_MODES; k++)
for (j = 0; j < INTRA_MODES; j++) for (j = 0; j < INTRA_MODES; j++) {
for (i = 0; i < INTRA_MODES - 1; ++i) for (i = 0; i < INTRA_MODES - 1; ++i)
av1_diff_update_prob(&r, &cm->kf_y_prob[k][j][i], ACCT_STR); av1_diff_update_prob(&r, &cm->kf_y_prob[k][j][i], ACCT_STR);
#if CONFIG_DAALA_EC
av1_tree_to_cdf(av1_intra_mode_tree, cm->kf_y_prob[k][j],
cm->kf_y_cdf[k][j]);
#endif
}
} else { } else {
#if !CONFIG_REF_MV #if !CONFIG_REF_MV
nmv_context *const nmvc = &fc->nmvc; nmv_context *const nmvc = &fc->nmvc;
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include "aom_dsp/aom_dsp_common.h" #include "aom_dsp/aom_dsp_common.h"
#define ACCT_STR __func__ #define ACCT_STR __func__
#if CONFIG_EXT_INTRA || CONFIG_FILTER_INTRA || CONFIG_PALETTE #if CONFIG_EXT_INTRA || CONFIG_FILTER_INTRA || CONFIG_PALETTE
static INLINE int read_uniform(aom_reader *r, int n) { static INLINE int read_uniform(aom_reader *r, int n) {
int l = get_unsigned_bits(n); int l = get_unsigned_bits(n);
...@@ -42,6 +41,13 @@ static INLINE int read_uniform(aom_reader *r, int n) { ...@@ -42,6 +41,13 @@ static INLINE int read_uniform(aom_reader *r, int n) {
} }
#endif // CONFIG_EXT_INTRA || CONFIG_FILTER_INTRA || CONFIG_PALETTE #endif // CONFIG_EXT_INTRA || CONFIG_FILTER_INTRA || CONFIG_PALETTE
#if CONFIG_DAALA_EC
static PREDICTION_MODE read_intra_mode_cdf(aom_reader *r,
const aom_cdf_prob *cdf) {
return (PREDICTION_MODE)
av1_intra_mode_inv[aom_read_symbol(r, cdf, INTRA_MODES, ACCT_STR)];
}
#endif
static PREDICTION_MODE read_intra_mode(aom_reader *r, const aom_prob *p) { static PREDICTION_MODE read_intra_mode(aom_reader *r, const aom_prob *p) {
return (PREDICTION_MODE)aom_read_tree(r, av1_intra_mode_tree, p, ACCT_STR); return (PREDICTION_MODE)aom_read_tree(r, av1_intra_mode_tree, p, ACCT_STR);
} }
...@@ -657,24 +663,49 @@ static void read_intra_frame_mode_info(AV1_COMMON *const cm, ...@@ -657,24 +663,49 @@ static void read_intra_frame_mode_info(AV1_COMMON *const cm,
case BLOCK_4X4: case BLOCK_4X4:
for (i = 0; i < 4; ++i) for (i = 0; i < 4; ++i)
mi->bmi[i].as_mode = mi->bmi[i].as_mode =
#if CONFIG_DAALA_EC
read_intra_mode_cdf(r,
get_y_mode_cdf(cm, mi, above_mi, left_mi, i));
#else
read_intra_mode(r, get_y_mode_probs(cm, mi, above_mi, left_mi, i)); read_intra_mode(r, get_y_mode_probs(cm, mi, above_mi, left_mi, i));
#endif
mbmi->mode = mi->bmi[3].as_mode; mbmi->mode = mi->bmi[3].as_mode;
break; break;
case BLOCK_4X8: case BLOCK_4X8:
mi->bmi[0].as_mode = mi->bmi[2].as_mode = mi->bmi[0].as_mode = mi->bmi[2].as_mode =
#if CONFIG_DAALA_EC
read_intra_mode_cdf(r, get_y_mode_cdf(cm, mi, above_mi, left_mi, 0));
#else
read_intra_mode(r, get_y_mode_probs(cm, mi, above_mi, left_mi, 0)); read_intra_mode(r, get_y_mode_probs(cm, mi, above_mi, left_mi, 0));
#endif
mi->bmi[1].as_mode = mi->bmi[3].as_mode = mbmi->mode = mi->bmi[1].as_mode = mi->bmi[3].as_mode = mbmi->mode =
#if CONFIG_DAALA_EC
read_intra_mode_cdf(r, get_y_mode_cdf(cm, mi, above_mi, left_mi, 1));
#else
read_intra_mode(r, get_y_mode_probs(cm, mi, above_mi, left_mi, 1)); read_intra_mode(r, get_y_mode_probs(cm, mi, above_mi, left_mi, 1));
#endif
break; break;
case BLOCK_8X4: case BLOCK_8X4:
mi->bmi[0].as_mode = mi->bmi[1].as_mode = mi->bmi[0].as_mode = mi->bmi[1].as_mode =
#if CONFIG_DAALA_EC
read_intra_mode_cdf(r, get_y_mode_cdf(cm, mi, above_mi, left_mi, 0));
#else
read_intra_mode(r, get_y_mode_probs(cm, mi, above_mi, left_mi, 0)); read_intra_mode(r, get_y_mode_probs(cm, mi, above_mi, left_mi, 0));
#endif
mi->bmi[2].as_mode = mi->bmi[3].as_mode = mbmi->mode = mi->bmi[2].as_mode = mi->bmi[3].as_mode = mbmi->mode =
#if CONFIG_DAALA_EC
read_intra_mode_cdf(r, get_y_mode_cdf(cm, mi, above_mi, left_mi, 2));
#else
read_intra_mode(r, get_y_mode_probs(cm, mi, above_mi, left_mi, 2)); read_intra_mode(r, get_y_mode_probs(cm, mi, above_mi, left_mi, 2));
#endif
break; break;
default: default:
mbmi->mode = mbmi->mode =
#if CONFIG_DAALA_EC
read_intra_mode_cdf(r, get_y_mode_cdf(cm, mi, above_mi, left_mi, 0));
#else
read_intra_mode(r, get_y_mode_probs(cm, mi, above_mi, left_mi, 0)); read_intra_mode(r, get_y_mode_probs(cm, mi, above_mi, left_mi, 0));
#endif
} }
mbmi->uv_mode = read_intra_mode_uv(cm, xd, r, mbmi->mode); mbmi->uv_mode = read_intra_mode_uv(cm, xd, r, mbmi->mode);
......
...@@ -52,6 +52,8 @@ static void initialize_dec(void) { ...@@ -52,6 +52,8 @@ static void initialize_dec(void) {
SWITCHABLE_FILTERS, av1_switchable_interp_tree); SWITCHABLE_FILTERS, av1_switchable_interp_tree);
av1_indices_from_tree(av1_ext_tx_ind, av1_ext_tx_inv, TX_TYPES, av1_indices_from_tree(av1_ext_tx_ind, av1_ext_tx_inv, TX_TYPES,
av1_ext_tx_tree); av1_ext_tx_tree);
av1_indices_from_tree(av1_intra_mode_ind, av1_intra_mode_inv, INTRA_MODES,
av1_intra_mode_tree);
#endif #endif
} }
} }
......
...@@ -192,6 +192,8 @@ void av1_encode_token_init(void) { ...@@ -192,6 +192,8 @@ void av1_encode_token_init(void) {
structure. */ structure. */
av1_indices_from_tree(av1_ext_tx_ind, av1_ext_tx_inv, TX_TYPES, av1_indices_from_tree(av1_ext_tx_ind, av1_ext_tx_inv, TX_TYPES,
av1_ext_tx_tree); av1_ext_tx_tree);
av1_indices_from_tree(av1_intra_mode_ind, av1_intra_mode_inv, INTRA_MODES,
av1_intra_mode_tree);
#endif #endif
} }
...@@ -1622,8 +1624,13 @@ static void write_mb_modes_kf(const AV1_COMMON *cm, const MACROBLOCKD *xd, ...@@ -1622,8 +1624,13 @@ static void write_mb_modes_kf(const AV1_COMMON *cm, const MACROBLOCKD *xd,
write_selected_tx_size(cm, xd, w); write_selected_tx_size(cm, xd, w);
if (bsize >= BLOCK_8X8) { if (bsize >= BLOCK_8X8) {
#if CONFIG_DAALA_EC
aom_write_symbol(w, av1_intra_mode_ind[mbmi->mode],
get_y_mode_cdf(cm, mi, above_mi, left_mi, 0), INTRA_MODES);
#else
write_intra_mode(w, mbmi->mode, write_intra_mode(w, mbmi->mode,
get_y_mode_probs(cm, mi, above_mi, left_mi, 0)); get_y_mode_probs(cm, mi, above_mi, left_mi, 0));
#endif
} else { } else {
const int num_4x4_w = num_4x4_blocks_wide_lookup[bsize]; const int num_4x4_w = num_4x4_blocks_wide_lookup[bsize];
const int num_4x4_h = num_4x4_blocks_high_lookup[bsize]; const int num_4x4_h = num_4x4_blocks_high_lookup[bsize];
...@@ -1632,8 +1639,14 @@ static void write_mb_modes_kf(const AV1_COMMON *cm, const MACROBLOCKD *xd, ...@@ -1632,8 +1639,14 @@ static void write_mb_modes_kf(const AV1_COMMON *cm, const MACROBLOCKD *xd,
for (idy = 0; idy < 2; idy += num_4x4_h) { for (idy = 0; idy < 2; idy += num_4x4_h) {
for (idx = 0; idx < 2; idx += num_4x4_w) { for (idx = 0; idx < 2; idx += num_4x4_w) {
const int block = idy * 2 + idx; const int block = idy * 2 + idx;
#if CONFIG_DAALA_EC
aom_write_symbol(w, av1_intra_mode_ind[mi->bmi[block].as_mode],
get_y_mode_cdf(cm, mi, above_mi, left_mi, block),
INTRA_MODES);
#else
write_intra_mode(w, mi->bmi[block].as_mode, write_intra_mode(w, mi->bmi[block].as_mode,
get_y_mode_probs(cm, mi, above_mi, left_mi, block)); get_y_mode_probs(cm, mi, above_mi, left_mi, block));
#endif
} }
} }
} }
...@@ -3621,10 +3634,18 @@ static uint32_t write_compressed_header(AV1_COMP *cpi, uint8_t *data) { ...@@ -3621,10 +3634,18 @@ static uint32_t write_compressed_header(AV1_COMP *cpi, uint8_t *data) {
if (frame_is_intra_only(cm)) { if (frame_is_intra_only(cm)) {
av1_copy(cm->kf_y_prob, av1_kf_y_mode_prob); av1_copy(cm->kf_y_prob, av1_kf_y_mode_prob);
#if CONFIG_DAALA_EC
av1_copy(cm->kf_y_cdf, av1_kf_y_mode_cdf);
#endif
for (i = 0; i < INTRA_MODES; ++i) for (i = 0; i < INTRA_MODES; ++i)
for (j = 0; j < INTRA_MODES; ++j) for (j = 0; j < INTRA_MODES; ++j) {
prob_diff_update(av1_intra_mode_tree, cm->kf_y_prob[i][j], prob_diff_update(av1_intra_mode_tree, cm->kf_y_prob[i][j],
counts->kf_y_mode[i][j], INTRA_MODES, header_bc); counts->kf_y_mode[i][j], INTRA_MODES, header_bc);
#if CONFIG_DAALA_EC
av1_tree_to_cdf(av1_intra_mode_tree, cm->kf_y_prob[i][j],
cm->kf_y_cdf[i][j]);
#endif
}
} else { } else {
#if CONFIG_REF_MV #if CONFIG_REF_MV
update_inter_mode_probs(cm, header_bc, counts); update_inter_mode_probs(cm, header_bc, counts);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment