Commit de383d08 authored by hui su's avatar hui su

Add ext-intra experiment

compression improvement:
lowres  0.54%
midres  1.00%

Average encoding time increase is about 5%.

Change-Id: I397afcb59d56e39efe4262b444205ed53f53b518
parent 2a764519
......@@ -35,6 +35,48 @@ extern "C" {
#define MAX_MB_PLANE 3
#if CONFIG_EXT_INTRA
#define MAX_ANGLE_DELTA 3
#define MAX_ANGLE_DELTA_UV 2
#define ANGLE_STEP_UV 4
static const uint8_t av1_angle_step_y[TX_SIZES][INTRA_MODES] = {
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
},
{
0, 4, 4, 4, 4, 4, 4, 4, 4, 0,
},
{
0, 3, 3, 3, 3, 3, 3, 3, 3, 0,
},
{
0, 3, 3, 3, 3, 3, 3, 3, 3, 0,
},
};
static const uint8_t av1_max_angle_delta_y[TX_SIZES][INTRA_MODES] = {
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
},
{
0, 2, 2, 2, 2, 2, 2, 2, 2, 0,
},
{
0, 3, 3, 3, 3, 3, 3, 3, 3, 0,
},
{
0, 3, 3, 3, 3, 3, 3, 3, 3, 0,
},
};
static const uint8_t mode_to_angle_map[INTRA_MODES] = {
0, 90, 180, 45, 135, 111, 157, 203, 67, 0,
};
static INLINE int is_directional_mode(PREDICTION_MODE mode) {
return (mode < TM_PRED && mode != DC_PRED);
}
#endif // CONFIG_EXT_INTRA
typedef enum {
KEY_FRAME = 0,
INTER_FRAME = 1,
......@@ -90,6 +132,10 @@ typedef struct {
// Only for INTRA blocks
PREDICTION_MODE uv_mode;
#if CONFIG_EXT_INTRA
// The actual prediction angle is the base angle + (angle_delta * step).
int8_t intra_angle_delta[2];
#endif // CONFIG_EXT_INTRA
// Only for INTER blocks
InterpFilter interp_filter;
......
......@@ -132,6 +132,11 @@ typedef uint8_t PREDICTION_MODE;
#define INTER_MODES (1 + NEWMV - NEARESTMV)
#if CONFIG_EXT_INTRA
// all intra modes except DC and TM
#define DIRECTIONAL_MODES (INTRA_MODES - 2)
#endif // CONFIG_EXT_INTRA
#if CONFIG_MOTION_VAR
typedef enum {
SIMPLE_TRANSLATION = 0, // regular block based motion compensation
......
This diff is collapsed.
......@@ -329,6 +329,35 @@ static int read_skip(AV1_COMMON *cm, const MACROBLOCKD *xd, int segment_id,
}
}
#if CONFIG_EXT_INTRA
static INLINE int read_uniform(aom_reader *r, int n) {
const int l = get_unsigned_bits(n);
const int m = (1 << l) - n;
const int v = aom_read_literal(r, l - 1);
assert(l != 0);
return (v < m) ? v : ((v << 1) - m + aom_read_literal(r, 1));
}
static void read_intra_angle_info(MB_MODE_INFO *const mbmi, aom_reader *r) {
mbmi->intra_angle_delta[0] = 0;
mbmi->intra_angle_delta[1] = 0;
if (mbmi->sb_type < BLOCK_8X8) return;
if (is_directional_mode(mbmi->mode)) {
const TX_SIZE max_tx_size = max_txsize_lookup[mbmi->sb_type];
const int max_angle_delta = av1_max_angle_delta_y[max_tx_size][mbmi->mode];
mbmi->intra_angle_delta[0] =
read_uniform(r, 2 * max_angle_delta + 1) - max_angle_delta;
}
if (is_directional_mode(mbmi->uv_mode)) {
mbmi->intra_angle_delta[1] =
read_uniform(r, 2 * MAX_ANGLE_DELTA_UV + 1) - MAX_ANGLE_DELTA_UV;
}
}
#endif // CONFIG_EXT_INTRA
static void read_intra_frame_mode_info(AV1_COMMON *const cm,
MACROBLOCKD *const xd, int mi_row,
int mi_col, aom_reader *r) {
......@@ -377,6 +406,9 @@ static void read_intra_frame_mode_info(AV1_COMMON *const cm,
}
mbmi->uv_mode = read_intra_mode_uv(cm, xd, r, mbmi->mode);
#if CONFIG_EXT_INTRA
read_intra_angle_info(mbmi, r);
#endif // CONFIG_EXT_INTRA
if (mbmi->tx_size < TX_32X32 && cm->base_qindex > 0 && !mbmi->skip &&
!segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) {
......@@ -542,6 +574,9 @@ static void read_intra_block_mode_info(AV1_COMMON *const cm,
}
mbmi->uv_mode = read_intra_mode_uv(cm, xd, r, mbmi->mode);
#if CONFIG_EXT_INTRA
read_intra_angle_info(mbmi, r);
#endif // CONFIG_EXT_INTRA
}
static INLINE int is_mv_valid(const MV *mv) {
......
......@@ -421,6 +421,38 @@ static void write_ref_frames(const AV1_COMMON *cm, const MACROBLOCKD *xd,
}
}
#if CONFIG_EXT_INTRA
static INLINE void write_uniform(aom_writer *w, int n, int v) {
const int l = get_unsigned_bits(n);
const int m = (1 << l) - n;
if (l == 0) return;
if (v < m) {
aom_write_literal(w, v, l - 1);
} else {
aom_write_literal(w, m + ((v - m) >> 1), l - 1);
aom_write_literal(w, (v - m) & 1, 1);
}
}
static void write_intra_angle_info(const MB_MODE_INFO *const mbmi,
aom_writer *w) {
if (mbmi->sb_type < BLOCK_8X8) return;
if (is_directional_mode(mbmi->mode)) {
const TX_SIZE max_tx_size = max_txsize_lookup[mbmi->sb_type];
const int max_angle_delta = av1_max_angle_delta_y[max_tx_size][mbmi->mode];
write_uniform(w, 2 * max_angle_delta + 1,
max_angle_delta + mbmi->intra_angle_delta[0]);
}
if (is_directional_mode(mbmi->uv_mode)) {
write_uniform(w, 2 * MAX_ANGLE_DELTA_UV + 1,
MAX_ANGLE_DELTA_UV + mbmi->intra_angle_delta[1]);
}
}
#endif // CONFIG_EXT_INTRA
static void pack_inter_mode_mvs(AV1_COMP *cpi, const MODE_INFO *mi,
aom_writer *w) {
AV1_COMMON *const cm = &cpi->common;
......@@ -481,6 +513,9 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const MODE_INFO *mi,
}
}
write_intra_mode(w, mbmi->uv_mode, cm->fc->uv_mode_prob[mode]);
#if CONFIG_EXT_INTRA
write_intra_angle_info(mbmi, w);
#endif // CONFIG_EXT_INTRA
} else {
int16_t mode_ctx = mbmi_ext->mode_context[mbmi->ref_frame[0]];
write_ref_frames(cm, xd, w);
......@@ -620,6 +655,9 @@ static void write_mb_modes_kf(const AV1_COMMON *cm, const MACROBLOCKD *xd,
}
write_intra_mode(w, mbmi->uv_mode, cm->fc->uv_mode_prob[mbmi->mode]);
#if CONFIG_EXT_INTRA
write_intra_angle_info(mbmi, w);
#endif // CONFIG_EXT_INTRA
if (mbmi->tx_size < TX_32X32 && cm->base_qindex > 0 && !mbmi->skip &&
!segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) {
......
This diff is collapsed.
......@@ -253,6 +253,7 @@ EXPERIMENT_LIST="
clpf
dering
ref_mv
ext_intra
ext_interp
motion_var
ext_refs
......
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