Commit e5f47d43 authored by hui su's avatar hui su

ext-intra: refactor mode info. writing and reading

No performance changes.

Change-Id: I001068330ea217a993aee9b79d7ffead0d23100e
parent 88eaf5d6
......@@ -525,6 +525,37 @@ static void read_ext_intra_mode_info(VP10_COMMON *const cm,
++counts->ext_intra[1][mbmi->ext_intra_mode_info.use_ext_intra_mode[1]];
}
}
static void read_intra_angle_info(VP10_COMMON *const cm, MACROBLOCKD *const xd,
vp10_reader *r) {
MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
const BLOCK_SIZE bsize = mbmi->sb_type;
const int ctx = vp10_get_pred_context_intra_interp(xd);
int p_angle;
if (bsize < BLOCK_8X8)
return;
if (mbmi->mode != DC_PRED && mbmi->mode != TM_PRED) {
mbmi->angle_delta[0] =
read_uniform(r, 2 * MAX_ANGLE_DELTAS + 1) - MAX_ANGLE_DELTAS;
p_angle = mode_to_angle_map[mbmi->mode] + mbmi->angle_delta[0] * ANGLE_STEP;
if (vp10_is_intra_filter_switchable(p_angle)) {
FRAME_COUNTS *counts = xd->counts;
mbmi->intra_filter = vp10_read_tree(r, vp10_intra_filter_tree,
cm->fc->intra_filter_probs[ctx]);
if (counts)
++counts->intra_filter[ctx][mbmi->intra_filter];
} else {
mbmi->intra_filter = INTRA_FILTER_LINEAR;
}
}
if (mbmi->uv_mode != DC_PRED && mbmi->uv_mode != TM_PRED) {
mbmi->angle_delta[1] =
read_uniform(r, 2 * MAX_ANGLE_DELTAS + 1) - MAX_ANGLE_DELTAS;
}
}
#endif // CONFIG_EXT_INTRA
static void read_intra_frame_mode_info(VP10_COMMON *const cm,
......@@ -572,39 +603,22 @@ static void read_intra_frame_mode_info(VP10_COMMON *const cm,
default:
mbmi->mode = read_intra_mode(r,
get_y_mode_probs(cm, mi, above_mi, left_mi, 0));
#if CONFIG_EXT_INTRA
if (mbmi->mode != DC_PRED && mbmi->mode != TM_PRED) {
int p_angle;
const int ctx = vp10_get_pred_context_intra_interp(xd);
mbmi->angle_delta[0] =
read_uniform(r, 2 * MAX_ANGLE_DELTAS + 1) - MAX_ANGLE_DELTAS;
p_angle = mode_to_angle_map[mbmi->mode] +
mbmi->angle_delta[0] * ANGLE_STEP;
if (vp10_is_intra_filter_switchable(p_angle)) {
FRAME_COUNTS *counts = xd->counts;
mbmi->intra_filter = vp10_read_tree(r, vp10_intra_filter_tree,
cm->fc->intra_filter_probs[ctx]);
if (counts)
++counts->intra_filter[ctx][mbmi->intra_filter];
} else {
mbmi->intra_filter = INTRA_FILTER_LINEAR;
}
}
#endif // CONFIG_EXT_INTRA
}
mbmi->uv_mode = read_intra_mode_uv(cm, xd, r, mbmi->mode);
#if CONFIG_EXT_INTRA
if (mbmi->uv_mode != DC_PRED && mbmi->uv_mode != TM_PRED &&
bsize >= BLOCK_8X8)
mbmi->angle_delta[1] =
read_uniform(r, 2 * MAX_ANGLE_DELTAS + 1) - MAX_ANGLE_DELTAS;
#endif
read_intra_angle_info(cm, xd, r);
#endif // CONFIG_EXT_INTRA
mbmi->palette_mode_info.palette_size[0] = 0;
mbmi->palette_mode_info.palette_size[1] = 0;
if (bsize >= BLOCK_8X8 && cm->allow_screen_content_tools)
read_palette_mode_info(cm, xd, r);
#if CONFIG_EXT_INTRA
mbmi->ext_intra_mode_info.use_ext_intra_mode[0] = 0;
mbmi->ext_intra_mode_info.use_ext_intra_mode[1] = 0;
if (bsize >= BLOCK_8X8)
read_ext_intra_mode_info(cm, xd, r);
#endif // CONFIG_EXT_INTRA
if (!FIXED_TX_TYPE) {
#if CONFIG_EXT_TX
......@@ -641,13 +655,6 @@ static void read_intra_frame_mode_info(VP10_COMMON *const cm,
}
#endif // CONFIG_EXT_TX
}
#if CONFIG_EXT_INTRA
mbmi->ext_intra_mode_info.use_ext_intra_mode[0] = 0;
mbmi->ext_intra_mode_info.use_ext_intra_mode[1] = 0;
if (bsize >= BLOCK_8X8)
read_ext_intra_mode_info(cm, xd, r);
#endif // CONFIG_EXT_INTRA
}
static int read_mv_component(vp10_reader *r,
......@@ -951,34 +958,11 @@ static void read_intra_block_mode_info(VP10_COMMON *const cm,
break;
default:
mbmi->mode = read_intra_mode_y(cm, xd, r, size_group_lookup[bsize]);
#if CONFIG_EXT_INTRA
mbmi->angle_delta[0] = 0;
if (mbmi->mode != DC_PRED && mbmi->mode != TM_PRED) {
int p_angle;
mbmi->angle_delta[0] =
read_uniform(r, 2 * MAX_ANGLE_DELTAS + 1) - MAX_ANGLE_DELTAS;
p_angle =
mode_to_angle_map[mbmi->mode] + mbmi->angle_delta[0] * ANGLE_STEP;
if (vp10_is_intra_filter_switchable(p_angle)) {
FRAME_COUNTS *counts = xd->counts;
const int ctx = vp10_get_pred_context_intra_interp(xd);
mbmi->intra_filter = vp10_read_tree(r, vp10_intra_filter_tree,
cm->fc->intra_filter_probs[ctx]);
if (counts)
++counts->intra_filter[ctx][mbmi->intra_filter];
} else {
mbmi->intra_filter = INTRA_FILTER_LINEAR;
}
}
#endif // CONFIG_EXT_INTRA
}
mbmi->uv_mode = read_intra_mode_uv(cm, xd, r, mbmi->mode);
#if CONFIG_EXT_INTRA
if (mbmi->uv_mode != DC_PRED && mbmi->uv_mode != TM_PRED &&
bsize >= BLOCK_8X8)
mbmi->angle_delta[1] =
read_uniform(r, 2 * MAX_ANGLE_DELTAS + 1) - MAX_ANGLE_DELTAS;
read_intra_angle_info(cm, xd, r);
#endif // CONFIG_EXT_INTRA
mbmi->palette_mode_info.palette_size[0] = 0;
mbmi->palette_mode_info.palette_size[1] = 0;
......
......@@ -916,6 +916,7 @@ static void write_ext_intra_mode_info(const VP10_COMMON *const cm,
write_uniform(w, FILTER_INTRA_MODES, mode);
}
}
if (mbmi->uv_mode == DC_PRED &&
mbmi->palette_mode_info.palette_size[1] == 0) {
vp10_write(w, mbmi->ext_intra_mode_info.use_ext_intra_mode[1],
......@@ -926,6 +927,33 @@ static void write_ext_intra_mode_info(const VP10_COMMON *const cm,
}
}
}
static void write_intra_angle_info(const VP10_COMMON *cm, const MACROBLOCKD *xd,
vp10_writer *w) {
const MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
const BLOCK_SIZE bsize = mbmi->sb_type;
const int intra_filter_ctx = vp10_get_pred_context_intra_interp(xd);
int p_angle;
if (bsize < BLOCK_8X8)
return;
if (mbmi->mode != DC_PRED && mbmi->mode != TM_PRED) {
write_uniform(w, 2 * MAX_ANGLE_DELTAS + 1,
MAX_ANGLE_DELTAS + mbmi->angle_delta[0]);
p_angle = mode_to_angle_map[mbmi->mode] + mbmi->angle_delta[0] * ANGLE_STEP;
if (vp10_is_intra_filter_switchable(p_angle)) {
vp10_write_token(w, vp10_intra_filter_tree,
cm->fc->intra_filter_probs[intra_filter_ctx],
&intra_filter_encodings[mbmi->intra_filter]);
}
}
if (mbmi->uv_mode != DC_PRED && mbmi->uv_mode != TM_PRED) {
write_uniform(w, 2 * MAX_ANGLE_DELTAS + 1,
MAX_ANGLE_DELTAS + mbmi->angle_delta[1]);
}
}
#endif // CONFIG_EXT_INTRA
static void write_switchable_interp_filter(VP10_COMP *cpi,
......@@ -1106,20 +1134,6 @@ static void pack_inter_mode_mvs(VP10_COMP *cpi, const MODE_INFO *mi,
if (!is_inter) {
if (bsize >= BLOCK_8X8) {
write_intra_mode(w, mode, cm->fc->y_mode_prob[size_group_lookup[bsize]]);
#if CONFIG_EXT_INTRA
if (mode != DC_PRED && mode != TM_PRED) {
int p_angle;
write_uniform(w, 2 * MAX_ANGLE_DELTAS + 1,
MAX_ANGLE_DELTAS + mbmi->angle_delta[0]);
p_angle = mode_to_angle_map[mode] + mbmi->angle_delta[0] * ANGLE_STEP;
if (vp10_is_intra_filter_switchable(p_angle)) {
const int ctx = vp10_get_pred_context_intra_interp(xd);
vp10_write_token(w, vp10_intra_filter_tree,
cm->fc->intra_filter_probs[ctx],
&intra_filter_encodings[mbmi->intra_filter]);
}
}
#endif // CONFIG_EXT_INTRA
} else {
int idx, idy;
const int num_4x4_w = num_4x4_blocks_wide_lookup[bsize];
......@@ -1133,10 +1147,7 @@ static void pack_inter_mode_mvs(VP10_COMP *cpi, const MODE_INFO *mi,
}
write_intra_mode(w, mbmi->uv_mode, cm->fc->uv_mode_prob[mode]);
#if CONFIG_EXT_INTRA
if (mbmi->uv_mode != DC_PRED && mbmi->uv_mode != TM_PRED &&
bsize >= BLOCK_8X8)
write_uniform(w, 2 * MAX_ANGLE_DELTAS + 1,
MAX_ANGLE_DELTAS + mbmi->angle_delta[1]);
write_intra_angle_info(cm, xd, w);
#endif // CONFIG_EXT_INTRA
if (bsize >= BLOCK_8X8 && cm->allow_screen_content_tools)
write_palette_mode_info(cm, xd, mi, w);
......@@ -1467,21 +1478,6 @@ static void write_mb_modes_kf(const VP10_COMMON *cm, const MACROBLOCKD *xd,
if (bsize >= BLOCK_8X8) {
write_intra_mode(w, mbmi->mode,
get_y_mode_probs(cm, mi, above_mi, left_mi, 0));
#if CONFIG_EXT_INTRA
if (mbmi->mode != DC_PRED && mbmi->mode != TM_PRED) {
int p_angle;
const int intra_filter_ctx = vp10_get_pred_context_intra_interp(xd);
write_uniform(w, 2 * MAX_ANGLE_DELTAS + 1,
MAX_ANGLE_DELTAS + mbmi->angle_delta[0]);
p_angle =
mode_to_angle_map[mbmi->mode] + mbmi->angle_delta[0] * ANGLE_STEP;
if (vp10_is_intra_filter_switchable(p_angle)) {
vp10_write_token(w, vp10_intra_filter_tree,
cm->fc->intra_filter_probs[intra_filter_ctx],
&intra_filter_encodings[mbmi->intra_filter]);
}
}
#endif // CONFIG_EXT_INTRA
} else {
const int num_4x4_w = num_4x4_blocks_wide_lookup[bsize];
const int num_4x4_h = num_4x4_blocks_high_lookup[bsize];
......@@ -1498,13 +1494,14 @@ static void write_mb_modes_kf(const VP10_COMMON *cm, const MACROBLOCKD *xd,
write_intra_mode(w, mbmi->uv_mode, cm->fc->uv_mode_prob[mbmi->mode]);
#if CONFIG_EXT_INTRA
if (mbmi->uv_mode != DC_PRED && mbmi->uv_mode != TM_PRED &&
bsize >= BLOCK_8X8)
write_uniform(w, 2 * MAX_ANGLE_DELTAS + 1,
MAX_ANGLE_DELTAS + mbmi->angle_delta[1]);
write_intra_angle_info(cm, xd, w);
#endif // CONFIG_EXT_INTRA
if (bsize >= BLOCK_8X8 && cm->allow_screen_content_tools)
write_palette_mode_info(cm, xd, mi, w);
#if CONFIG_EXT_INTRA
if (bsize >= BLOCK_8X8)
write_ext_intra_mode_info(cm, mbmi, w);
#endif // CONFIG_EXT_INTRA
if (!FIXED_TX_TYPE) {
#if CONFIG_EXT_TX
......@@ -1531,11 +1528,6 @@ static void write_mb_modes_kf(const VP10_COMMON *cm, const MACROBLOCKD *xd,
}
#endif // CONFIG_EXT_TX
}
#if CONFIG_EXT_INTRA
if (bsize >= BLOCK_8X8)
write_ext_intra_mode_info(cm, mbmi, w);
#endif // CONFIG_EXT_INTRA
}
#if CONFIG_SUPERTX
......
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