Commit b4e25d2c authored by hui su's avatar hui su Committed by Hui Su

Make ext-intra/intra-interp work with ec-multisymbol

Use cdf to signal intra filter type.
Skip forward update when ec-adapt is on.

Change-Id: Idd446e081b8e9ea33356e60423b372bfd85a80db
parent 5dad9a89
...@@ -5699,13 +5699,10 @@ void av1_average_tile_intra_cdfs(FRAME_CONTEXT *fc, FRAME_CONTEXT *ec_ctxs[], ...@@ -5699,13 +5699,10 @@ void av1_average_tile_intra_cdfs(FRAME_CONTEXT *fc, FRAME_CONTEXT *ec_ctxs[],
#if CONFIG_DELTA_Q #if CONFIG_DELTA_Q
AVERAGE_TILE_CDFS(delta_q_cdf) AVERAGE_TILE_CDFS(delta_q_cdf)
#endif #endif
#if CONFIG_EXT_INTRA #if CONFIG_EXT_INTRA && CONFIG_INTRA_INTERP
#if CONFIG_INTRA_INTERP AVERAGE_TILE_CDFS(intra_filter_cdf)
// FIXME: intra_filter probs #endif // CONFIG_EXT_INTRA && CONFIG_INTRA_INTERP
#endif // CONFIG_INTRA_INTERP
#endif // CONFIG_EXT_INTRA
#if CONFIG_FILTER_INTRA #if CONFIG_FILTER_INTRA
// FIXME: intra_filter probs
#endif // CONFIG_FILTER_INTRA #endif // CONFIG_FILTER_INTRA
} }
......
...@@ -1531,8 +1531,7 @@ static const aom_prob default_inter_ext_tx_prob[EXT_TX_SIZES][TX_TYPES - 1] = { ...@@ -1531,8 +1531,7 @@ static const aom_prob default_inter_ext_tx_prob[EXT_TX_SIZES][TX_TYPES - 1] = {
}; };
#endif // CONFIG_EXT_TX #endif // CONFIG_EXT_TX
#if CONFIG_EXT_INTRA #if CONFIG_EXT_INTRA && CONFIG_INTRA_INTERP
#if CONFIG_INTRA_INTERP
static const aom_prob static const aom_prob
default_intra_filter_probs[INTRA_FILTERS + 1][INTRA_FILTERS - 1] = { default_intra_filter_probs[INTRA_FILTERS + 1][INTRA_FILTERS - 1] = {
{ 98, 63, 60 }, { 98, 82, 80 }, { 94, 65, 103 }, { 98, 63, 60 }, { 98, 82, 80 }, { 94, 65, 103 },
...@@ -1542,8 +1541,11 @@ const aom_tree_index av1_intra_filter_tree[TREE_SIZE(INTRA_FILTERS)] = { ...@@ -1542,8 +1541,11 @@ const aom_tree_index av1_intra_filter_tree[TREE_SIZE(INTRA_FILTERS)] = {
-INTRA_FILTER_LINEAR, 2, -INTRA_FILTER_8TAP, 4, -INTRA_FILTER_8TAP_SHARP, -INTRA_FILTER_LINEAR, 2, -INTRA_FILTER_8TAP, 4, -INTRA_FILTER_8TAP_SHARP,
-INTRA_FILTER_8TAP_SMOOTH, -INTRA_FILTER_8TAP_SMOOTH,
}; };
#endif // CONFIG_INTRA_INTERP #if CONFIG_EC_MULTISYMBOL
#endif // CONFIG_EXT_INTRA int av1_intra_filter_ind[INTRA_FILTERS];
int av1_intra_filter_inv[INTRA_FILTERS];
#endif // CONFIG_EC_MULTISYMBOL
#endif // CONFIG_EXT_INTRA && CONFIG_INTRA_INTERP
#if CONFIG_FILTER_INTRA #if CONFIG_FILTER_INTRA
static const aom_prob default_filter_intra_probs[2] = { 230, 230 }; static const aom_prob default_filter_intra_probs[2] = { 230, 230 };
...@@ -1742,7 +1744,16 @@ static const aom_cdf_prob ...@@ -1742,7 +1744,16 @@ static const aom_cdf_prob
{ 22528, 25928, 29348, 32768, 0 }, { 22528, 25928, 29348, 32768, 0 },
{ 24576, 27296, 30032, 32768, 0 }, { 24576, 27296, 30032, 32768, 0 },
}; };
#endif #endif // !CONFIG_EXT_TX
#if CONFIG_EXT_INTRA && CONFIG_INTRA_INTERP
static const aom_cdf_prob
default_intra_filter_cdf[INTRA_FILTERS + 1][CDF_SIZE(INTRA_FILTERS)] = {
{ 12544, 17521, 21095, 32768, 0 }, { 12544, 19022, 23318, 32768, 0 },
{ 12032, 17297, 23522, 32768, 0 }, { 6272, 8860, 11101, 32768, 0 },
{ 9216, 12712, 16629, 32768, 0 },
};
#endif // CONFIG_EXT_INTRA && CONFIG_INTRA_INTERP
// CDF version of 'av1_kf_y_mode_prob'. // CDF version of 'av1_kf_y_mode_prob'.
const aom_cdf_prob const aom_cdf_prob
...@@ -2284,16 +2295,19 @@ static void init_mode_probs(FRAME_CONTEXT *fc) { ...@@ -2284,16 +2295,19 @@ static void init_mode_probs(FRAME_CONTEXT *fc) {
#if !CONFIG_EXT_TX #if !CONFIG_EXT_TX
av1_copy(fc->intra_ext_tx_cdf, default_intra_ext_tx_cdf); av1_copy(fc->intra_ext_tx_cdf, default_intra_ext_tx_cdf);
av1_copy(fc->inter_ext_tx_cdf, default_inter_ext_tx_cdf); av1_copy(fc->inter_ext_tx_cdf, default_inter_ext_tx_cdf);
#endif #endif // !CONFIG_EXT_TX
#if CONFIG_EXT_INTRA && CONFIG_INTRA_INTERP
av1_copy(fc->intra_filter_cdf, default_intra_filter_cdf);
#endif // CONFIG_EXT_INTRA && CONFIG_INTRA_INTERP
av1_copy(fc->seg.tree_cdf, default_seg_tree_cdf); av1_copy(fc->seg.tree_cdf, default_seg_tree_cdf);
av1_copy(fc->tx_size_cdf, default_tx_size_cdf); av1_copy(fc->tx_size_cdf, default_tx_size_cdf);
#endif #endif // CONFIG_EC_MULTISYMBOL
#if CONFIG_DELTA_Q #if CONFIG_DELTA_Q
av1_copy(fc->delta_q_prob, default_delta_q_probs); av1_copy(fc->delta_q_prob, default_delta_q_probs);
#if CONFIG_EC_MULTISYMBOL #if CONFIG_EC_MULTISYMBOL
av1_copy(fc->delta_q_cdf, default_delta_q_cdf); av1_copy(fc->delta_q_cdf, default_delta_q_cdf);
#endif #endif // CONFIG_EC_MULTISYMBOL
#endif #endif // CONFIG_DELTA_Q
} }
#if CONFIG_EC_MULTISYMBOL #if CONFIG_EC_MULTISYMBOL
...@@ -2374,9 +2388,15 @@ void av1_set_mode_cdfs(struct AV1Common *cm) { ...@@ -2374,9 +2388,15 @@ void av1_set_mode_cdfs(struct AV1Common *cm) {
fc->tx_size_cdf[i][j]); fc->tx_size_cdf[i][j]);
} }
} }
#if CONFIG_EXT_INTRA && CONFIG_INTRA_INTERP
for (i = 0; i < INTRA_FILTERS + 1; ++i) {
av1_tree_to_cdf(av1_intra_filter_tree, fc->intra_filter_probs[i],
fc->intra_filter_cdf[i]);
}
#endif // CONFIG_EXT_INTRA && CONFIG_INTRA_INTERP
} }
#endif // !CONFIG_EC_ADAPT #endif // !CONFIG_EC_ADAPT
#endif #endif // CONFIG_EC_MULTISYMBOL
#if CONFIG_DUAL_FILTER #if CONFIG_DUAL_FILTER
const aom_tree_index av1_switchable_interp_tree[TREE_SIZE(SWITCHABLE_FILTERS)] = const aom_tree_index av1_switchable_interp_tree[TREE_SIZE(SWITCHABLE_FILTERS)] =
......
...@@ -260,12 +260,15 @@ typedef struct frame_contexts { ...@@ -260,12 +260,15 @@ typedef struct frame_contexts {
[CDF_SIZE(MAX_TX_DEPTH + 1)]; [CDF_SIZE(MAX_TX_DEPTH + 1)];
#if CONFIG_DELTA_Q #if CONFIG_DELTA_Q
aom_cdf_prob delta_q_cdf[CDF_SIZE(DELTA_Q_PROBS + 1)]; aom_cdf_prob delta_q_cdf[CDF_SIZE(DELTA_Q_PROBS + 1)];
#endif #endif // CONFIG_DELTA_Q
#if !CONFIG_EXT_TX #if !CONFIG_EXT_TX
aom_cdf_prob intra_ext_tx_cdf[EXT_TX_SIZES][TX_TYPES][CDF_SIZE(TX_TYPES)]; aom_cdf_prob intra_ext_tx_cdf[EXT_TX_SIZES][TX_TYPES][CDF_SIZE(TX_TYPES)];
aom_cdf_prob inter_ext_tx_cdf[EXT_TX_SIZES][CDF_SIZE(TX_TYPES)]; aom_cdf_prob inter_ext_tx_cdf[EXT_TX_SIZES][CDF_SIZE(TX_TYPES)];
#endif #endif // !CONFIG_EXT_TX
#endif #if CONFIG_EXT_INTRA && CONFIG_INTRA_INTERP
aom_cdf_prob intra_filter_cdf[INTRA_FILTERS + 1][CDF_SIZE(INTRA_FILTERS)];
#endif // CONFIG_EXT_INTRA && CONFIG_INTRA_INTERP
#endif // CONFIG_EC_MULTISYMBOL
#if CONFIG_DELTA_Q #if CONFIG_DELTA_Q
aom_prob delta_q_prob[DELTA_Q_PROBS]; aom_prob delta_q_prob[DELTA_Q_PROBS];
#endif #endif
...@@ -450,11 +453,9 @@ extern const aom_tree_index ...@@ -450,11 +453,9 @@ extern const aom_tree_index
av1_palette_color_index_tree[PALETTE_SIZES][TREE_SIZE(PALETTE_COLORS)]; av1_palette_color_index_tree[PALETTE_SIZES][TREE_SIZE(PALETTE_COLORS)];
#endif // CONFIG_PALETTE #endif // CONFIG_PALETTE
extern const aom_tree_index av1_tx_size_tree[MAX_TX_DEPTH][TREE_SIZE(TX_SIZES)]; extern const aom_tree_index av1_tx_size_tree[MAX_TX_DEPTH][TREE_SIZE(TX_SIZES)];
#if CONFIG_EXT_INTRA #if CONFIG_EXT_INTRA && CONFIG_INTRA_INTERP
#if CONFIG_INTRA_INTERP
extern const aom_tree_index av1_intra_filter_tree[TREE_SIZE(INTRA_FILTERS)]; extern const aom_tree_index av1_intra_filter_tree[TREE_SIZE(INTRA_FILTERS)];
#endif // CONFIG_INTRA_INTERP #endif // CONFIG_EXT_INTRA && CONFIG_INTRA_INTERP
#endif // CONFIG_EXT_INTRA
#if CONFIG_EXT_TX #if CONFIG_EXT_TX
extern const aom_tree_index av1_ext_tx_inter_tree[EXT_TX_SETS_INTER] extern const aom_tree_index av1_ext_tx_inter_tree[EXT_TX_SETS_INTER]
[TREE_SIZE(TX_TYPES)]; [TREE_SIZE(TX_TYPES)];
......
...@@ -4471,7 +4471,7 @@ static int read_compressed_header(AV1Decoder *pbi, const uint8_t *data, ...@@ -4471,7 +4471,7 @@ static int read_compressed_header(AV1Decoder *pbi, const uint8_t *data,
FRAME_CONTEXT *const fc = cm->fc; FRAME_CONTEXT *const fc = cm->fc;
aom_reader r; aom_reader r;
int k, i; int k, i;
#if !CONFIG_EC_ADAPT || CONFIG_EXT_INTRA #if !CONFIG_EC_ADAPT
int j; int j;
#endif #endif
...@@ -4548,13 +4548,13 @@ static int read_compressed_header(AV1Decoder *pbi, const uint8_t *data, ...@@ -4548,13 +4548,13 @@ static int read_compressed_header(AV1Decoder *pbi, const uint8_t *data,
for (; j < PARTITION_CONTEXTS_PRIMARY + 2 * PARTITION_BLOCK_SIZES; ++j) for (; j < PARTITION_CONTEXTS_PRIMARY + 2 * PARTITION_BLOCK_SIZES; ++j)
av1_diff_update_prob(&r, &fc->partition_prob[j][PARTITION_HORZ], ACCT_STR); av1_diff_update_prob(&r, &fc->partition_prob[j][PARTITION_HORZ], ACCT_STR);
#endif // CONFIG_UNPOISON_PARTITION_CTX #endif // CONFIG_UNPOISON_PARTITION_CTX
#endif // !CONFIG_EC_ADAPT
#if CONFIG_EXT_INTRA && CONFIG_INTRA_INTERP #if CONFIG_EXT_INTRA && CONFIG_INTRA_INTERP
for (i = 0; i < INTRA_FILTERS + 1; ++i) for (i = 0; i < INTRA_FILTERS + 1; ++i)
for (j = 0; j < INTRA_FILTERS - 1; ++j) for (j = 0; j < INTRA_FILTERS - 1; ++j)
av1_diff_update_prob(&r, &fc->intra_filter_probs[i][j], ACCT_STR); av1_diff_update_prob(&r, &fc->intra_filter_probs[i][j], ACCT_STR);
#endif // CONFIG_EXT_INTRA && CONFIG_INTRA_INTERP #endif // CONFIG_EXT_INTRA && CONFIG_INTRA_INTERP
#endif // !CONFIG_EC_ADAPT
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);
......
...@@ -709,6 +709,11 @@ static void read_intra_angle_info(AV1_COMMON *const cm, MACROBLOCKD *const xd, ...@@ -709,6 +709,11 @@ static void read_intra_angle_info(AV1_COMMON *const cm, MACROBLOCKD *const xd,
MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
const BLOCK_SIZE bsize = mbmi->sb_type; const BLOCK_SIZE bsize = mbmi->sb_type;
#if CONFIG_INTRA_INTERP #if CONFIG_INTRA_INTERP
#if CONFIG_EC_ADAPT
FRAME_CONTEXT *const ec_ctx = xd->tile_ctx;
#else
FRAME_CONTEXT *const ec_ctx = cm->fc;
#endif // CONFIG_EC_ADAPT
const int ctx = av1_get_pred_context_intra_interp(xd); const int ctx = av1_get_pred_context_intra_interp(xd);
int p_angle; int p_angle;
#endif // CONFIG_INTRA_INTERP #endif // CONFIG_INTRA_INTERP
...@@ -725,8 +730,13 @@ static void read_intra_angle_info(AV1_COMMON *const cm, MACROBLOCKD *const xd, ...@@ -725,8 +730,13 @@ static void read_intra_angle_info(AV1_COMMON *const cm, MACROBLOCKD *const xd,
mbmi->angle_delta[0] * av1_get_angle_step(mbmi->sb_type, 0); mbmi->angle_delta[0] * av1_get_angle_step(mbmi->sb_type, 0);
if (av1_is_intra_filter_switchable(p_angle)) { if (av1_is_intra_filter_switchable(p_angle)) {
FRAME_COUNTS *counts = xd->counts; FRAME_COUNTS *counts = xd->counts;
#if CONFIG_EC_MULTISYMBOL
mbmi->intra_filter = aom_read_symbol(r, ec_ctx->intra_filter_cdf[ctx],
INTRA_FILTERS, ACCT_STR);
#else
mbmi->intra_filter = aom_read_tree( mbmi->intra_filter = aom_read_tree(
r, av1_intra_filter_tree, cm->fc->intra_filter_probs[ctx], ACCT_STR); r, av1_intra_filter_tree, ec_ctx->intra_filter_probs[ctx], ACCT_STR);
#endif // CONFIG_EC_MULTISYMBOL
if (counts) ++counts->intra_filter[ctx][mbmi->intra_filter]; if (counts) ++counts->intra_filter[ctx][mbmi->intra_filter];
} else { } else {
mbmi->intra_filter = INTRA_FILTER_LINEAR; mbmi->intra_filter = INTRA_FILTER_LINEAR;
......
...@@ -168,11 +168,9 @@ void av1_encode_token_init(void) { ...@@ -168,11 +168,9 @@ void av1_encode_token_init(void) {
} }
#endif // CONFIG_PALETTE #endif // CONFIG_PALETTE
#if CONFIG_EXT_INTRA #if CONFIG_EXT_INTRA && CONFIG_INTRA_INTERP
#if CONFIG_INTRA_INTERP
av1_tokens_from_tree(intra_filter_encodings, av1_intra_filter_tree); av1_tokens_from_tree(intra_filter_encodings, av1_intra_filter_tree);
#endif // CONFIG_INTRA_INTERP #endif // CONFIG_EXT_INTRA && CONFIG_INTRA_INTERP
#endif // CONFIG_EXT_INTRA
#if CONFIG_EXT_INTER #if CONFIG_EXT_INTER
av1_tokens_from_tree(interintra_mode_encodings, av1_interintra_mode_tree); av1_tokens_from_tree(interintra_mode_encodings, av1_interintra_mode_tree);
av1_tokens_from_tree(compound_type_encodings, av1_compound_type_tree); av1_tokens_from_tree(compound_type_encodings, av1_compound_type_tree);
...@@ -1263,8 +1261,8 @@ static void write_filter_intra_mode_info(const AV1_COMMON *const cm, ...@@ -1263,8 +1261,8 @@ static void write_filter_intra_mode_info(const AV1_COMMON *const cm,
#endif // CONFIG_FILTER_INTRA #endif // CONFIG_FILTER_INTRA
#if CONFIG_EXT_INTRA #if CONFIG_EXT_INTRA
static void write_intra_angle_info(const AV1_COMMON *cm, const MACROBLOCKD *xd, static void write_intra_angle_info(const MACROBLOCKD *xd,
aom_writer *w) { FRAME_CONTEXT *const ec_ctx, aom_writer *w) {
const MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; const MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
const BLOCK_SIZE bsize = mbmi->sb_type; const BLOCK_SIZE bsize = mbmi->sb_type;
#if CONFIG_INTRA_INTERP #if CONFIG_INTRA_INTERP
...@@ -1272,7 +1270,7 @@ static void write_intra_angle_info(const AV1_COMMON *cm, const MACROBLOCKD *xd, ...@@ -1272,7 +1270,7 @@ static void write_intra_angle_info(const AV1_COMMON *cm, const MACROBLOCKD *xd,
int p_angle; int p_angle;
#endif // CONFIG_INTRA_INTERP #endif // CONFIG_INTRA_INTERP
(void)cm; (void)ec_ctx;
if (bsize < BLOCK_8X8) return; if (bsize < BLOCK_8X8) return;
if (av1_is_directional_mode(mbmi->mode, bsize)) { if (av1_is_directional_mode(mbmi->mode, bsize)) {
...@@ -1283,9 +1281,15 @@ static void write_intra_angle_info(const AV1_COMMON *cm, const MACROBLOCKD *xd, ...@@ -1283,9 +1281,15 @@ static void write_intra_angle_info(const AV1_COMMON *cm, const MACROBLOCKD *xd,
p_angle = mode_to_angle_map[mbmi->mode] + p_angle = mode_to_angle_map[mbmi->mode] +
mbmi->angle_delta[0] * av1_get_angle_step(mbmi->sb_type, 0); mbmi->angle_delta[0] * av1_get_angle_step(mbmi->sb_type, 0);
if (av1_is_intra_filter_switchable(p_angle)) { if (av1_is_intra_filter_switchable(p_angle)) {
#if CONFIG_EC_MULTISYMBOL
aom_write_symbol(w, mbmi->intra_filter,
ec_ctx->intra_filter_cdf[intra_filter_ctx],
INTRA_FILTERS);
#else
av1_write_token(w, av1_intra_filter_tree, av1_write_token(w, av1_intra_filter_tree,
cm->fc->intra_filter_probs[intra_filter_ctx], ec_ctx->intra_filter_probs[intra_filter_ctx],
&intra_filter_encodings[mbmi->intra_filter]); &intra_filter_encodings[mbmi->intra_filter]);
#endif // CONFIG_EC_MULTISYMBOL
} }
#endif // CONFIG_INTRA_INTERP #endif // CONFIG_INTRA_INTERP
} }
...@@ -1653,7 +1657,7 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const MODE_INFO *mi, ...@@ -1653,7 +1657,7 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const MODE_INFO *mi,
#endif // CONFIG_CB4X4 #endif // CONFIG_CB4X4
#if CONFIG_EXT_INTRA #if CONFIG_EXT_INTRA
write_intra_angle_info(cm, xd, w); write_intra_angle_info(xd, ec_ctx, w);
#endif // CONFIG_EXT_INTRA #endif // CONFIG_EXT_INTRA
#if CONFIG_PALETTE #if CONFIG_PALETTE
if (bsize >= BLOCK_8X8 && cm->allow_screen_content_tools) if (bsize >= BLOCK_8X8 && cm->allow_screen_content_tools)
...@@ -1994,7 +1998,7 @@ static void write_mb_modes_kf(AV1_COMMON *cm, const MACROBLOCKD *xd, ...@@ -1994,7 +1998,7 @@ static void write_mb_modes_kf(AV1_COMMON *cm, const MACROBLOCKD *xd,
#endif // CONFIG_CB4X4 #endif // CONFIG_CB4X4
#if CONFIG_EXT_INTRA #if CONFIG_EXT_INTRA
write_intra_angle_info(cm, xd, w); write_intra_angle_info(xd, ec_ctx, w);
#endif // CONFIG_EXT_INTRA #endif // CONFIG_EXT_INTRA
#if CONFIG_PALETTE #if CONFIG_PALETTE
if (bsize >= BLOCK_8X8 && cm->allow_screen_content_tools) if (bsize >= BLOCK_8X8 && cm->allow_screen_content_tools)
...@@ -4623,13 +4627,12 @@ static uint32_t write_compressed_header(AV1_COMP *cpi, uint8_t *data) { ...@@ -4623,13 +4627,12 @@ static uint32_t write_compressed_header(AV1_COMP *cpi, uint8_t *data) {
ct, probwt); ct, probwt);
} }
#endif #endif
#endif // !CONFIG_EC_ADAPT
#if CONFIG_EXT_INTRA && CONFIG_INTRA_INTERP #if CONFIG_EXT_INTRA && CONFIG_INTRA_INTERP
for (i = 0; i < INTRA_FILTERS + 1; ++i) for (i = 0; i < INTRA_FILTERS + 1; ++i)
prob_diff_update(av1_intra_filter_tree, fc->intra_filter_probs[i], prob_diff_update(av1_intra_filter_tree, fc->intra_filter_probs[i],
counts->intra_filter[i], INTRA_FILTERS, probwt, header_bc); counts->intra_filter[i], INTRA_FILTERS, probwt, header_bc);
#endif // CONFIG_EXT_INTRA && CONFIG_INTRA_INTERP #endif // CONFIG_EXT_INTRA && CONFIG_INTRA_INTERP
#endif // !CONFIG_EC_ADAPT
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);
......
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