Commit 4aa50c17 authored by hui su's avatar hui su

refactor ext-intra

Coding gain remains about the same, while overall speed is
substantially increased.

Change-Id: I2989bebcfd21092cd6a02653d4df4a3bf6780874
parent b49ac0b1
......@@ -89,7 +89,6 @@ typedef struct {
// 1: an ext intra mode is used; 0: otherwise.
uint8_t use_ext_intra_mode[PLANE_TYPES];
EXT_INTRA_MODE ext_intra_mode[PLANE_TYPES];
uint8_t ext_intra_angle[PLANE_TYPES];
} EXT_INTRA_MODE_INFO;
#endif // CONFIG_EXT_INTRA
......@@ -124,6 +123,7 @@ typedef struct {
#if CONFIG_EXT_INTRA
EXT_INTRA_MODE_INFO ext_intra_mode_info;
int8_t angle_delta[2];
#endif // CONFIG_EXT_INTRA
// TODO(slavarnway): Delete and use bmi[3].as_mv[] instead.
......@@ -328,14 +328,14 @@ static const int ext_tx_used_inter[EXT_TX_SETS_INTER][TX_TYPES] = {
#endif // CONFIG_EXT_TX
#if CONFIG_EXT_INTRA
// 0: use both directional and filter modes; 1: use directional modes only.
#define DR_ONLY 0
// 0: use slow exhaustive search; 1: use fast sub-optimal search.
#define ALLOW_FILTER_INTRA_MODES 1
#define ANGLE_STEP 3
#define MAX_ANGLE_DELTAS 3
#define ANGLE_FAST_SEARCH 1
// A parameter to adjust early termination in the fast search of angles.
#define RD_ADJUSTER 1.4
// Number of different angles that are supported
#define EXT_INTRA_ANGLES 128
static uint8_t mode_to_angle_map[INTRA_MODES] = {
0, 90, 180, 45, 135, 111, 157, 203, 67, 0,
};
static const TX_TYPE filter_intra_mode_to_tx_type_lookup[FILTER_INTRA_MODES] = {
DCT_DCT, // FILTER_DC
......@@ -349,13 +349,6 @@ static const TX_TYPE filter_intra_mode_to_tx_type_lookup[FILTER_INTRA_MODES] = {
ADST_DCT, // FILTER_D63
ADST_ADST, // FILTER_TM
};
// Maps the angle index to the actual prediction angle (in degrees).
// Angle index is in the range [0, EXT_INTRA_ANGLES); the actual prediction
// angle is in the range (0, 270).
static INLINE int prediction_angle_map(int angle_in) {
return (10 + 2 * angle_in);
}
#endif // CONFIG_EXT_INTRA
static INLINE TX_TYPE get_tx_type(PLANE_TYPE plane_type,
......@@ -363,33 +356,44 @@ static INLINE TX_TYPE get_tx_type(PLANE_TYPE plane_type,
int block_idx, TX_SIZE tx_size) {
const MODE_INFO *const mi = xd->mi[0];
const MB_MODE_INFO *const mbmi = &mi->mbmi;
#if CONFIG_EXT_INTRA
const int use_ext_intra_mode_info =
mbmi->ext_intra_mode_info.use_ext_intra_mode[plane_type];
const EXT_INTRA_MODE ext_intra_mode =
mbmi->ext_intra_mode_info.ext_intra_mode[plane_type];
if (!is_inter_block(mbmi)) {
const int use_ext_intra_mode_info =
mbmi->ext_intra_mode_info.use_ext_intra_mode[plane_type];
const EXT_INTRA_MODE ext_intra_mode =
mbmi->ext_intra_mode_info.ext_intra_mode[plane_type];
const PREDICTION_MODE mode = (plane_type == PLANE_TYPE_Y) ?
get_y_mode(mi, block_idx) : mbmi->uv_mode;
if (xd->lossless[mbmi->segment_id] || tx_size >= TX_32X32)
return DCT_DCT;
if (!is_inter_block(mbmi) && use_ext_intra_mode_info) {
if (!xd->lossless[mbmi->segment_id] && tx_size < TX_32X32
#if CONFIG_EXT_TX
&& !(mbmi->sb_type >= BLOCK_8X8 && plane_type == PLANE_TYPE_Y)
if (mbmi->sb_type >= BLOCK_8X8 && plane_type == PLANE_TYPE_Y)
return mbmi->tx_type;
#endif // CONFIG_EXT_TX
) {
if (ext_intra_mode > FILTER_TM_PRED) {
int angle = mbmi->ext_intra_mode_info.ext_intra_angle[plane_type];
angle = prediction_angle_map(angle);
assert(angle > 0 && angle < 270);
if (angle == 135)
return ADST_ADST;
else if (angle < 45 || angle > 225)
return DCT_DCT;
else if (angle < 135)
return ADST_DCT;
else
return DCT_ADST;
} else {
return filter_intra_mode_to_tx_type_lookup[ext_intra_mode];
}
if (use_ext_intra_mode_info)
return filter_intra_mode_to_tx_type_lookup[ext_intra_mode];
if (mode == DC_PRED) {
return DCT_DCT;
} else if (mode == TM_PRED) {
return ADST_ADST;
} else {
int angle = mode_to_angle_map[mode];
if (mbmi->sb_type >= BLOCK_8X8)
angle += mbmi->angle_delta[plane_type] * ANGLE_STEP;
assert(angle > 0 && angle < 270);
if (angle == 135)
return ADST_ADST;
else if (angle < 45 || angle > 225)
return DCT_DCT;
else if (angle < 135)
return ADST_DCT;
else
return DCT_ADST;
}
}
#endif // CONFIG_EXT_INTRA
......
......@@ -967,7 +967,7 @@ static const struct segmentation_probs default_seg_probs = {
#endif
#if CONFIG_EXT_INTRA
static const vpx_prob default_ext_intra_probs[2] = {200, 200};
static const vpx_prob default_ext_intra_probs[2] = {230, 230};
#endif // CONFIG_EXT_INTRA
static void init_mode_probs(FRAME_CONTEXT *fc) {
......
......@@ -32,11 +32,6 @@ extern "C" {
#define PALETTE_BLOCK_SIZES (BLOCK_64X64 - BLOCK_8X8 + 1)
#define PALETTE_Y_MODE_CONTEXTS 3
#if CONFIG_EXT_INTRA
// Probability that an ext_intra mode is a directional prediction mode
#define DR_EXT_INTRA_PROB 144
#endif // CONFIG_EXT_INTRA
struct VP10Common;
struct tx_probs {
......
......@@ -168,7 +168,6 @@ typedef enum {
FILTER_D207_PRED,
FILTER_D63_PRED,
FILTER_TM_PRED,
EXT_DR_PRED,
EXT_INTRA_MODES,
} EXT_INTRA_MODE;
......
......@@ -405,32 +405,11 @@ static void dr_prediction_z3(uint8_t *dst, ptrdiff_t stride, int bs,
}
}
static INLINE void v_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
const uint8_t *above, const uint8_t *left) {
int r;
(void) left;
for (r = 0; r < bs; r++) {
memcpy(dst, above, bs);
dst += stride;
}
}
static INLINE void h_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
const uint8_t *above, const uint8_t *left) {
int r;
(void) above;
for (r = 0; r < bs; r++) {
memset(dst, left[r], bs);
dst += stride;
}
}
static void dr_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
static void dr_predictor(uint8_t *dst, ptrdiff_t stride, TX_SIZE tx_size,
const uint8_t *above, const uint8_t *left, int angle) {
double t = 0;
int dx, dy;
int bs = 4 << tx_size;
if (angle != 90 && angle != 180)
t = tan(angle * PI / 180.0);
......@@ -448,9 +427,9 @@ static void dr_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
dy = -((int)(256 * t));
dr_prediction_z3(dst, stride, bs, above, left, dx, dy);
} else if (angle == 90) {
v_predictor(dst, stride, bs, above, left);
pred[V_PRED][tx_size](dst, stride, above, left);
} else if (angle == 180) {
h_predictor(dst, stride, bs, above, left);
pred[H_PRED][tx_size](dst, stride, above, left);
}
}
......@@ -915,11 +894,7 @@ static void build_intra_predictors_high(const MACROBLOCKD *xd,
int i;
uint16_t *dst = CONVERT_TO_SHORTPTR(dst8);
uint16_t *ref = CONVERT_TO_SHORTPTR(ref8);
#if CONFIG_MISC_FIXES
DECLARE_ALIGNED(16, uint16_t, left_col[32]);
#else
DECLARE_ALIGNED(16, uint16_t, left_col[64]);
#endif
DECLARE_ALIGNED(16, uint16_t, above_data[64 + 16]);
uint16_t *above_row = above_data + 16;
const uint16_t *const_above_row = above_row;
......@@ -946,37 +921,38 @@ static void build_intra_predictors_high(const MACROBLOCKD *xd,
&xd->mi[0]->mbmi.ext_intra_mode_info;
const EXT_INTRA_MODE ext_intra_mode =
ext_intra_mode_info->ext_intra_mode[plane != 0];
const int angle =
prediction_angle_map(ext_intra_mode_info->ext_intra_angle[plane != 0]);
int p_angle = 0;
if (ext_intra_mode_info->use_ext_intra_mode[plane != 0]) {
EXT_INTRA_MODE ext_intra_mode =
ext_intra_mode_info->ext_intra_mode[plane != 0];
if (ext_intra_mode <= FILTER_TM_PRED) {
need_left = ext_intra_extend_modes[ext_intra_mode] & NEED_LEFT;
need_above = ext_intra_extend_modes[ext_intra_mode] & NEED_ABOVE;
need_aboveright =
ext_intra_extend_modes[ext_intra_mode] & NEED_ABOVERIGHT;
} else {
assert(angle > 0 && angle < 270);
if (mode != DC_PRED && mode != TM_PRED &&
xd->mi[0]->mbmi.sb_type >= BLOCK_8X8) {
p_angle = mode_to_angle_map[mode] +
xd->mi[0]->mbmi.angle_delta[plane != 0] * ANGLE_STEP;
#if CONFIG_MISC_FIXES
if (angle <= 90)
need_above = 1, need_left = 0;
else if (angle < 180)
need_above = 1, need_left = 1;
else
need_above = 0, need_left = 1;
if (p_angle <= 90)
need_above = 1, need_left = 0;
else if (p_angle < 180)
need_above = 1, need_left = 1;
else
need_above = 0, need_left = 1;
#else
if (angle < 90)
need_above = 0, need_aboveright = 1, need_left = 0;
else if (angle == 90)
need_above = 1, need_aboveright = 0, need_left = 0;
else if (angle < 180)
need_above = 1, need_aboveright = 0, need_left = 1;
else
need_above = 0, need_aboveright = 0, need_left = 1;
if (p_angle < 90)
need_above = 0, need_aboveright = 1, need_left = 0;
else if (p_angle == 90)
need_above = 1, need_aboveright = 0, need_left = 0;
else if (p_angle < 180)
need_above = 1, need_aboveright = 0, need_left = 1;
else
need_above = 0, need_aboveright = 0, need_left = 1;
#endif // CONFIG_MISC_FIXES
}
}
if (ext_intra_mode_info->use_ext_intra_mode[plane != 0]) {
EXT_INTRA_MODE ext_intra_mode =
ext_intra_mode_info->ext_intra_mode[plane != 0];
need_left = ext_intra_extend_modes[ext_intra_mode] & NEED_LEFT;
need_above = ext_intra_extend_modes[ext_intra_mode] & NEED_ABOVE;
need_aboveright =
ext_intra_extend_modes[ext_intra_mode] & NEED_ABOVERIGHT;
}
#endif // CONFIG_EXT_INTRA
......@@ -993,10 +969,10 @@ static void build_intra_predictors_high(const MACROBLOCKD *xd,
#if CONFIG_EXT_INTRA
int need_bottom;
if (ext_intra_mode_info->use_ext_intra_mode[plane != 0]) {
if (ext_intra_mode <= FILTER_TM_PRED)
need_bottom = 0;
else
need_bottom = angle > 180;
} else if (mode != DC_PRED && mode != TM_PRED &&
xd->mi[0]->mbmi.sb_type >= BLOCK_8X8) {
need_bottom = p_angle > 180;
} else {
need_bottom = !!(extend_modes[mode] & NEED_BOTTOMLEFT);
}
......@@ -1024,10 +1000,10 @@ static void build_intra_predictors_high(const MACROBLOCKD *xd,
#if CONFIG_EXT_INTRA
int need_right;
if (ext_intra_mode_info->use_ext_intra_mode[plane != 0]) {
if (ext_intra_mode <= FILTER_TM_PRED)
need_right = 1;
else
need_right = angle < 90;
need_right = 1;
} else if (mode != DC_PRED && mode != TM_PRED &&
xd->mi[0]->mbmi.sb_type >= BLOCK_8X8) {
need_right = p_angle < 90;
} else {
need_right = !!(extend_modes[mode] & NEED_ABOVERIGHT);
}
......@@ -1052,7 +1028,9 @@ static void build_intra_predictors_high(const MACROBLOCKD *xd,
(void)need_aboveright;
#if CONFIG_EXT_INTRA
if (ext_intra_mode_info->use_ext_intra_mode[plane != 0] ||
(extend_modes[mode] & NEED_ABOVELEFT)) {
(extend_modes[mode] & NEED_ABOVELEFT) ||
(mode != DC_PRED && mode != TM_PRED &&
xd->mi[0]->mbmi.sb_type >= BLOCK_8X8)) {
above_row[-1] = n_top_px > 0 ?
(n_left_px > 0 ? above_ref[-1] : base + 1) : base - 1;
}
......@@ -1185,13 +1163,15 @@ static void build_intra_predictors_high(const MACROBLOCKD *xd,
#if CONFIG_EXT_INTRA
if (ext_intra_mode_info->use_ext_intra_mode[plane != 0]) {
if (ext_intra_mode <= FILTER_TM_PRED)
highbd_filter_intra_predictors[ext_intra_mode](dst, dst_stride, bs,
const_above_row, left_col,
bd);
else
highbd_dr_predictor(dst, dst_stride, bs, const_above_row, left_col,
angle, bd);
highbd_filter_intra_predictors[ext_intra_mode](dst, dst_stride, bs,
const_above_row, left_col, bd);
return;
}
if (mode != DC_PRED && mode != TM_PRED &&
xd->mi[0]->mbmi.sb_type >= BLOCK_8X8) {
highbd_dr_predictor(dst, dst_stride, bs, const_above_row, left_col,
p_angle, bd);
return;
}
#endif // CONFIG_EXT_INTRA
......@@ -1247,37 +1227,39 @@ static void build_intra_predictors(const MACROBLOCKD *xd, const uint8_t *ref,
&xd->mi[0]->mbmi.ext_intra_mode_info;
const EXT_INTRA_MODE ext_intra_mode =
ext_intra_mode_info->ext_intra_mode[plane != 0];
const int angle =
prediction_angle_map(ext_intra_mode_info->ext_intra_angle[plane != 0]);
int p_angle = 0;
if (mode != DC_PRED && mode != TM_PRED &&
xd->mi[0]->mbmi.sb_type >= BLOCK_8X8) {
p_angle = mode_to_angle_map[mode] +
xd->mi[0]->mbmi.angle_delta[plane != 0] * ANGLE_STEP;
if (ext_intra_mode_info->use_ext_intra_mode[plane != 0]) {
EXT_INTRA_MODE ext_intra_mode =
ext_intra_mode_info->ext_intra_mode[plane != 0];
if (ext_intra_mode <= FILTER_TM_PRED) {
need_left = ext_intra_extend_modes[ext_intra_mode] & NEED_LEFT;
need_above = ext_intra_extend_modes[ext_intra_mode] & NEED_ABOVE;
need_aboveright =
ext_intra_extend_modes[ext_intra_mode] & NEED_ABOVERIGHT;
} else {
assert(angle > 0 && angle < 270);
#if CONFIG_MISC_FIXES
if (angle <= 90)
need_above = 1, need_left = 0;
else if (angle < 180)
need_above = 1, need_left = 1;
else
need_above = 0, need_left = 1;
if (p_angle <= 90)
need_above = 1, need_left = 0;
else if (p_angle < 180)
need_above = 1, need_left = 1;
else
need_above = 0, need_left = 1;
#else
if (angle < 90)
need_above = 0, need_aboveright = 1, need_left = 0;
else if (angle == 90)
need_above = 1, need_aboveright = 0, need_left = 0;
else if (angle < 180)
need_above = 1, need_aboveright = 0, need_left = 1;
else
need_above = 0, need_aboveright = 0, need_left = 1;
if (p_angle < 90)
need_above = 0, need_aboveright = 1, need_left = 0;
else if (p_angle == 90)
need_above = 1, need_aboveright = 0, need_left = 0;
else if (p_angle < 180)
need_above = 1, need_aboveright = 0, need_left = 1;
else
need_above = 0, need_aboveright = 0, need_left = 1;
#endif // CONFIG_MISC_FIXES
}
}
if (ext_intra_mode_info->use_ext_intra_mode[plane != 0]) {
EXT_INTRA_MODE ext_intra_mode =
ext_intra_mode_info->ext_intra_mode[plane != 0];
need_left = ext_intra_extend_modes[ext_intra_mode] & NEED_LEFT;
need_above = ext_intra_extend_modes[ext_intra_mode] & NEED_ABOVE;
need_aboveright =
ext_intra_extend_modes[ext_intra_mode] & NEED_ABOVERIGHT;
}
#endif // CONFIG_EXT_INTRA
......@@ -1318,10 +1300,10 @@ static void build_intra_predictors(const MACROBLOCKD *xd, const uint8_t *ref,
#if CONFIG_EXT_INTRA
int need_bottom;
if (ext_intra_mode_info->use_ext_intra_mode[plane != 0]) {
if (ext_intra_mode <= FILTER_TM_PRED)
need_bottom = 0;
else
need_bottom = angle > 180;
need_bottom = 0;
} else if (mode != DC_PRED && mode != TM_PRED &&
xd->mi[0]->mbmi.sb_type >= BLOCK_8X8) {
need_bottom = p_angle > 180;
} else {
need_bottom = !!(extend_modes[mode] & NEED_BOTTOMLEFT);
}
......@@ -1373,10 +1355,10 @@ static void build_intra_predictors(const MACROBLOCKD *xd, const uint8_t *ref,
#if CONFIG_EXT_INTRA
int need_right;
if (ext_intra_mode_info->use_ext_intra_mode[plane != 0]) {
if (ext_intra_mode <= FILTER_TM_PRED)
need_right = 1;
else
need_right = angle < 90;
need_right = 1;
} else if (mode != DC_PRED && mode != TM_PRED &&
xd->mi[0]->mbmi.sb_type >= BLOCK_8X8) {
need_right = p_angle < 90;
} else {
need_right = !!(extend_modes[mode] & NEED_ABOVERIGHT);
}
......@@ -1428,7 +1410,9 @@ static void build_intra_predictors(const MACROBLOCKD *xd, const uint8_t *ref,
(void)need_aboveright;
#if CONFIG_EXT_INTRA
if (ext_intra_mode_info->use_ext_intra_mode[plane != 0] ||
(extend_modes[mode] & NEED_ABOVELEFT)) {
(extend_modes[mode] & NEED_ABOVELEFT) ||
(mode != DC_PRED && mode != TM_PRED &&
xd->mi[0]->mbmi.sb_type >= BLOCK_8X8)) {
above_row[-1] = n_top_px > 0 ? (n_left_px > 0 ? above_ref[-1] : 129) : 127;
}
#else
......@@ -1486,11 +1470,14 @@ static void build_intra_predictors(const MACROBLOCKD *xd, const uint8_t *ref,
#if CONFIG_EXT_INTRA
if (ext_intra_mode_info->use_ext_intra_mode[plane != 0]) {
if (ext_intra_mode <= FILTER_TM_PRED)
filter_intra_predictors[ext_intra_mode](dst, dst_stride, bs,
const_above_row, left_col);
else
dr_predictor(dst, dst_stride, bs, const_above_row, left_col, angle);
filter_intra_predictors[ext_intra_mode](dst, dst_stride, bs,
const_above_row, left_col);
return;
}
if (mode != DC_PRED && mode != TM_PRED &&
xd->mi[0]->mbmi.sb_type >= BLOCK_8X8) {
dr_predictor(dst, dst_stride, tx_size, const_above_row, left_col, p_angle);
return;
}
#endif // CONFIG_EXT_INTRA
......@@ -1510,10 +1497,10 @@ static void build_intra_predictors(const MACROBLOCKD *xd, const uint8_t *ref,
}
void vp10_predict_intra_block(const MACROBLOCKD *xd, int bwl_in, int bhl_in,
TX_SIZE tx_size, PREDICTION_MODE mode,
const uint8_t *ref, int ref_stride,
uint8_t *dst, int dst_stride,
int aoff, int loff, int plane) {
TX_SIZE tx_size, PREDICTION_MODE mode,
const uint8_t *ref, int ref_stride,
uint8_t *dst, int dst_stride,
int aoff, int loff, int plane) {
const int txw = (1 << tx_size);
const int have_top = loff || xd->up_available;
const int have_left = aoff || xd->left_available;
......
......@@ -346,18 +346,16 @@ static void read_ext_intra_mode_info(VP10_COMMON *const cm,
MODE_INFO *const mi = xd->mi[0];
MB_MODE_INFO *const mbmi = &mi->mbmi;
FRAME_COUNTS *counts = xd->counts;
#if !ALLOW_FILTER_INTRA_MODES
return;
#endif
if (mbmi->mode == DC_PRED) {
mbmi->ext_intra_mode_info.use_ext_intra_mode[0] =
vpx_read(r, cm->fc->ext_intra_probs[0]);
if (mbmi->ext_intra_mode_info.use_ext_intra_mode[0]) {
if (DR_ONLY ? 1 : vpx_read(r, DR_EXT_INTRA_PROB)) {
mbmi->ext_intra_mode_info.ext_intra_mode[0] = EXT_DR_PRED;
mbmi->ext_intra_mode_info.ext_intra_angle[0] =
read_uniform(r, EXT_INTRA_ANGLES);
} else {
mbmi->ext_intra_mode_info.ext_intra_mode[0] =
read_uniform(r, FILTER_INTRA_MODES);
}
mbmi->ext_intra_mode_info.ext_intra_mode[0] =
read_uniform(r, FILTER_INTRA_MODES);
}
if (counts)
++counts->ext_intra[0][mbmi->ext_intra_mode_info.use_ext_intra_mode[0]];
......@@ -366,14 +364,8 @@ static void read_ext_intra_mode_info(VP10_COMMON *const cm,
mbmi->ext_intra_mode_info.use_ext_intra_mode[1] =
vpx_read(r, cm->fc->ext_intra_probs[1]);
if (mbmi->ext_intra_mode_info.use_ext_intra_mode[1]) {
if (DR_ONLY ? 1 : vpx_read(r, DR_EXT_INTRA_PROB)) {
mbmi->ext_intra_mode_info.ext_intra_mode[1] = EXT_DR_PRED;
mbmi->ext_intra_mode_info.ext_intra_angle[1] =
read_uniform(r, EXT_INTRA_ANGLES);
} else {
mbmi->ext_intra_mode_info.ext_intra_mode[1] =
read_uniform(r, FILTER_INTRA_MODES);
}
mbmi->ext_intra_mode_info.ext_intra_mode[1] =
read_uniform(r, FILTER_INTRA_MODES);
}
if (counts)
++counts->ext_intra[1][mbmi->ext_intra_mode_info.use_ext_intra_mode[1]];
......@@ -426,9 +418,20 @@ 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)
mbmi->angle_delta[0] =
read_uniform(r, 2 * MAX_ANGLE_DELTAS + 1) - MAX_ANGLE_DELTAS;
#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
mbmi->palette_mode_info.palette_size[0] = 0;
mbmi->palette_mode_info.palette_size[1] = 0;
......@@ -591,8 +594,6 @@ static INLINE INTERP_FILTER read_switchable_interp_filter(
cm->fc->switchable_interp_prob[ctx]);
if (counts)
++counts->switchable_interp[ctx][type];
// printf("%d/%d -> %d, %d\n", cm->current_video_frame, cm->show_frame,
// xd->mi[0]->mbmi.sb_type, xd->mi[0]->mbmi.interp_filter);
return type;
}
......@@ -626,9 +627,22 @@ 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)
mbmi->angle_delta[0] =
read_uniform(r, 2 * MAX_ANGLE_DELTAS + 1) - MAX_ANGLE_DELTAS;
#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 // CONFIG_EXT_INTRA
mbmi->palette_mode_info.palette_size[0] = 0;
mbmi->palette_mode_info.palette_size[1] = 0;
#if CONFIG_EXT_INTRA
......
......@@ -520,19 +520,15 @@ static void write_ref_frames(const VP10_COMMON *cm, const MACROBLOCKD *xd,
static void write_ext_intra_mode_info(const VP10_COMMON *const cm,
const MB_MODE_INFO *const mbmi,
vpx_writer *w) {
#if !ALLOW_FILTER_INTRA_MODES
return;
#endif
if (mbmi->mode == DC_PRED) {
vpx_write(w, mbmi->ext_intra_mode_info.use_ext_intra_mode[0],
cm->fc->ext_intra_probs[0]);
if (mbmi->ext_intra_mode_info.use_ext_intra_mode[0]) {
EXT_INTRA_MODE mode = mbmi->ext_intra_mode_info.ext_intra_mode[0];
int dr_mode = mode > FILTER_TM_PRED;
if (!DR_ONLY)
vpx_write(w, dr_mode, DR_EXT_INTRA_PROB);
if (dr_mode)
write_uniform(w, EXT_INTRA_ANGLES,
mbmi->ext_intra_mode_info.ext_intra_angle[0]);
else
write_uniform(w, FILTER_INTRA_MODES, mode);
write_uniform(w, FILTER_INTRA_MODES, mode);
}
}
if (mbmi->uv_mode == DC_PRED) {
......@@ -540,14 +536,7 @@ static void write_ext_intra_mode_info(const VP10_COMMON *const cm,
cm->fc->ext_intra_probs[1]);
if (mbmi->ext_intra_mode_info.use_ext_intra_mode[1]) {
EXT_INTRA_MODE mode = mbmi->ext_intra_mode_info.ext_intra_mode[1];
int dr_mode = mode > FILTER_TM_PRED;
if (!DR_ONLY)
vpx_write(w, dr_mode, DR_EXT_INTRA_PROB);
if (dr_mode)
write_uniform(w, EXT_INTRA_ANGLES,
mbmi->ext_intra_mode_info.ext_intra_angle[1]);
else
write_uniform(w, FILTER_INTRA_MODES, mode);
write_uniform(w, FILTER_INTRA_MODES, mode);
}
}
}
......@@ -644,6 +633,12 @@ 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) {
write_uniform(w, 2 * MAX_ANGLE_DELTAS + 1,
MAX_ANGLE_DELTAS + mbmi->angle_delta[0]);
}
#endif // CONFIG_EXT_INTRA
} else {
int idx, idy;
const int num_4x4_w = num_4x4_blocks_wide_lookup[bsize];
......@@ -657,6 +652,11 @@ static void pack_inter_mode_mvs(VP10_COMP *cpi, const MODE_INFO *mi,
}
write_intra_mode(w, mbmi->uv_mode, cm->fc->uv_mode_pro