D27_PRED, // Directional 27 deg = round(arctan(1/2) * 180/pi)
D63_PRED, // Directional 63 deg = round(arctan(2/1) * 180/pi)
TM_PRED, // True-motion
- I4X4_PRED, // Each 4x4 subblock has its own mode
NEARESTMV,
NEARMV,
ZEROMV,
ADST_ADST = 3 // ADST in both directions
} TX_TYPE;
-#define VP9_YMODES (I4X4_PRED + 1)
+#define VP9_YMODES (TM_PRED + 1)
#define VP9_UV_MODES (TM_PRED + 1)
#define VP9_I32X32_MODES (TM_PRED + 1)
}
static TX_TYPE get_tx_type_4x4(const MACROBLOCKD *xd, int ib) {
- TX_TYPE tx_type = DCT_DCT;
- if (xd->lossless)
+ TX_TYPE tx_type;
+ MODE_INFO *mi = xd->mode_info_context;
+ MB_MODE_INFO *const mbmi = &mi->mbmi;
+ if (xd->lossless || mbmi->ref_frame != INTRA_FRAME)
return DCT_DCT;
- if (xd->mode_info_context->mbmi.mode == I4X4_PRED) {
- tx_type = txfm_map(
- xd->mode_info_context->bmi[ib].as_mode.first);
- } else if (xd->mode_info_context->mbmi.mode <= TM_PRED) {
- tx_type = txfm_map(xd->mode_info_context->mbmi.mode);
+ if (mbmi->sb_type < BLOCK_SIZE_SB8X8) {
+ tx_type = txfm_map(mi->bmi[ib].as_mode.first);
+ } else {
+ assert(mbmi->mode <= TM_PRED);
+ tx_type = txfm_map(mbmi->mode);
}
return tx_type;
}
#include "vp9/common/vp9_alloccommon.h"
#include "vpx_mem/vpx_mem.h"
-static const unsigned int kf_y_mode_cts[8][VP9_YMODES] = {
- /* DC V H D45 135 117 153 D27 D63 TM i4X4 */
- {12, 6, 5, 5, 5, 5, 5, 5, 5, 2, 200},
- {25, 13, 13, 7, 7, 7, 7, 7, 7, 6, 160},
- {31, 17, 18, 8, 8, 8, 8, 8, 8, 9, 139},
- {40, 22, 23, 8, 8, 8, 8, 8, 8, 12, 116},
- {53, 26, 28, 8, 8, 8, 8, 8, 8, 13, 94},
- {68, 33, 35, 8, 8, 8, 8, 8, 8, 17, 68},
- {78, 38, 38, 8, 8, 8, 8, 8, 8, 19, 52},
- {89, 42, 42, 8, 8, 8, 8, 8, 8, 21, 34},
+static const unsigned int y_mode_cts[VP9_BINTRAMODES] = {
+ /* DC V H D45 D135 D117 D153 D27 D63 TM */
+ 98, 19, 15, 14, 14, 14, 14, 12, 12, 13,
};
-static const unsigned int y_mode_cts [VP9_YMODES] = {
- /* DC V H D45 135 117 153 D27 D63 TM i4X4 */
- 98, 19, 15, 14, 14, 14, 14, 12, 12, 13, 0
-};
-
-static const unsigned int uv_mode_cts [VP9_YMODES] [VP9_UV_MODES] = {
+static const unsigned int uv_mode_cts[VP9_YMODES][VP9_UV_MODES] = {
/* DC V H D45 135 117 153 D27 D63 TM */
{ 200, 15, 15, 10, 10, 10, 10, 10, 10, 6}, /* DC */
{ 130, 75, 10, 10, 10, 10, 10, 10, 10, 6}, /* V */
{ 150, 15, 10, 10, 10, 10, 10, 75, 10, 6}, /* D27 */
{ 150, 15, 10, 10, 10, 10, 10, 10, 75, 6}, /* D63 */
{ 160, 30, 30, 10, 10, 10, 10, 10, 10, 16}, /* TM */
- { 150, 35, 41, 10, 10, 10, 10, 10, 10, 10}, /* i4X4 */
};
-static const unsigned int kf_uv_mode_cts [VP9_YMODES] [VP9_UV_MODES] = {
+static const unsigned int kf_uv_mode_cts[VP9_YMODES][VP9_UV_MODES] = {
// DC V H D45 135 117 153 D27 D63 TM
{ 160, 24, 24, 20, 20, 20, 20, 20, 20, 8}, /* DC */
{ 102, 64, 30, 20, 20, 20, 20, 20, 20, 10}, /* V */
{ 102, 33, 20, 20, 20, 20, 20, 64, 20, 14}, /* D27 */
{ 102, 33, 20, 20, 20, 20, 20, 20, 64, 14}, /* D63 */
{ 132, 36, 30, 20, 20, 20, 20, 20, 20, 18}, /* TM */
- { 122, 41, 35, 20, 20, 20, 20, 20, 20, 18}, /* I4X4 */
-};
-
-static const unsigned int bmode_cts[VP9_BINTRAMODES] = {
- /* DC V H D45 D135 D117 D153 D27 D63 TM */
- 43891, 10036, 3920, 3363, 2546, 5119, 2471, 1723, 3221, 17694
};
const vp9_prob vp9_partition_probs[NUM_PARTITION_CONTEXTS]
/* On L edge, get from MB to left of us */
--cur_mb;
- if (cur_mb->mbmi.mode <= TM_PRED) {
- return cur_mb->mbmi.mode;
- } else if (cur_mb->mbmi.mode == I4X4_PRED) {
+ if (cur_mb->mbmi.ref_frame != INTRA_FRAME) {
+ return DC_PRED;
+ } else if (cur_mb->mbmi.sb_type < BLOCK_SIZE_SB8X8) {
return ((cur_mb->bmi + 1 + b)->as_mode.first);
} else {
- return DC_PRED;
+ return cur_mb->mbmi.mode;
}
}
assert(b == 1 || b == 3);
/* On top edge, get from MB above us */
cur_mb -= mi_stride;
- if (cur_mb->mbmi.mode <= TM_PRED) {
- return cur_mb->mbmi.mode;
- } else if (cur_mb->mbmi.mode == I4X4_PRED) {
+ if (cur_mb->mbmi.ref_frame != INTRA_FRAME) {
+ return DC_PRED;
+ } else if (cur_mb->mbmi.sb_type < BLOCK_SIZE_SB8X8) {
return ((cur_mb->bmi + 2 + b)->as_mode.first);
} else {
- return DC_PRED;
+ return cur_mb->mbmi.mode;
}
}
lfi->mode_lf_lut[V_PRED] = 1;
lfi->mode_lf_lut[H_PRED] = 1;
lfi->mode_lf_lut[TM_PRED] = 1;
- lfi->mode_lf_lut[I4X4_PRED] = 0;
lfi->mode_lf_lut[ZEROMV] = 1;
lfi->mode_lf_lut[NEARESTMV] = 2;
lfi->mode_lf_lut[NEARMV] = 2;
int bw = 1 << b_width_log2(m->mbmi.sb_type);
int bh = 1 << b_height_log2(m->mbmi.sb_type);
- m->mbmi.mode = I4X4_PRED;
for (idy = 0; idy < 2; idy += bh) {
for (idx = 0; idx < 2; idx += bw) {
int ib = idy * 2 + idx;
m->bmi[ib + k].as_mode.first = m->bmi[ib].as_mode.first;
}
}
+ m->mbmi.mode = m->bmi[3].as_mode.first;
}
m->mbmi.uv_mode = read_intra_mode(r, cm->kf_uv_mode_prob[m->mbmi.mode]);
cm->fc.y_mode_counts[mbmi->mode]++;
} else {
int idx, idy;
- mbmi->mode = I4X4_PRED;
for (idy = 0; idy < 2; idy += bh) {
for (idx = 0; idx < 2; idx += bw) {
int ib = idy * 2 + idx, k;
mi->bmi[ib + k].as_mode.first = m;
}
}
+ mbmi->mode = mi->bmi[3].as_mode.first;
}
mbmi->uv_mode = read_intra_mode(r, cm->fc.uv_mode_prob[mbmi->mode]);
mode = plane == 0? xd->mode_info_context->mbmi.mode:
xd->mode_info_context->mbmi.uv_mode;
- if (bsize <= BLOCK_SIZE_SB8X8 && mode == I4X4_PRED && plane == 0)
+ if (xd->mode_info_context->mbmi.sb_type < BLOCK_SIZE_SB8X8 && plane == 0) {
+ assert(bsize == BLOCK_SIZE_SB8X8);
b_mode = xd->mode_info_context->bmi[raster_block].as_mode.first;
- else
+ } else {
b_mode = mode;
+ }
plane_b_size = b_width_log2(bsize) - xd->plane[plane].subsampling_x;
vp9_predict_intra_block(xd, tx_ib, plane_b_size, tx_size,
xd->left_available = (mb_col != 0);
xd->mode_info_context->mbmi.sb_type = BLOCK_SIZE_MB16X16;
+ xd->mode_info_context->mbmi.ref_frame = INTRA_FRAME;
// do intra 16x16 prediction
this_error = vp9_encode_intra(cpi, x, use_dc_pred);
this_error = motion_error;
vp9_set_mbmode_and_mvs(x, NEWMV, &mv);
xd->mode_info_context->mbmi.txfm_size = TX_4X4;
+ xd->mode_info_context->mbmi.ref_frame = LAST_FRAME;
vp9_build_inter_predictors_sby(xd, mb_row << 1,
mb_col << 1,
BLOCK_SIZE_MB16X16);
DECLARE_ALIGNED(16, extern const uint8_t,
vp9_pt_energy_class[MAX_ENTROPY_TOKENS]);
+#define I4X4_PRED 0x8000
+
const MODE_DEFINITION vp9_mode_order[MAX_MODES] = {
{ZEROMV, LAST_FRAME, NONE},
{DC_PRED, INTRA_FRAME, NONE},
{SPLITMV, GOLDEN_FRAME, NONE},
{SPLITMV, ALTREF_FRAME, NONE},
- {I4X4_PRED, INTRA_FRAME, NONE},
+ {I4X4_PRED, INTRA_FRAME, NONE},
/* compound prediction modes */
{ZEROMV, LAST_FRAME, GOLDEN_FRAME},
int64_t total_rd = 0;
ENTROPY_CONTEXT t_above[4], t_left[4];
int *bmode_costs;
+ MODE_INFO *const mic = xd->mode_info_context;
vpx_memcpy(t_above, xd->plane[0].above_context, sizeof(t_above));
vpx_memcpy(t_left, xd->plane[0].left_context, sizeof(t_left));
- xd->mode_info_context->mbmi.mode = I4X4_PRED;
bmode_costs = mb->mbmode_cost;
for (idy = 0; idy < 2; idy += bh) {
for (idx = 0; idx < 2; idx += bw) {
- MODE_INFO *const mic = xd->mode_info_context;
const int mis = xd->mode_info_stride;
MB_PREDICTION_MODE UNINITIALIZED_IS_SAFE(best_mode);
int UNINITIALIZED_IS_SAFE(r), UNINITIALIZED_IS_SAFE(ry);
*Rate = cost;
*rate_y = tot_rate_y;
*Distortion = distortion;
+ xd->mode_info_context->mbmi.mode = mic->bmi[3].as_mode.first;
return RDCOST(mb->rdmult, mb->rddiv, cost, distortion);
}
best_mode = this_mode;
}
- // Store the respective mode distortions for later use.
- if (mode_distortions[this_mode] == -1
- || distortion2 < mode_distortions[this_mode]) {
- mode_distortions[this_mode] = distortion2;
- }
- if (frame_distortions[mbmi->ref_frame] == -1
- || distortion2 < frame_distortions[mbmi->ref_frame]) {
- frame_distortions[mbmi->ref_frame] = distortion2;
+ if (this_mode != I4X4_PRED) {
+ // Store the respective mode distortions for later use.
+ if (mode_distortions[this_mode] == -1
+ || distortion2 < mode_distortions[this_mode]) {
+ mode_distortions[this_mode] = distortion2;
+ }
+ if (frame_distortions[mbmi->ref_frame] == -1
+ || distortion2 < frame_distortions[mbmi->ref_frame]) {
+ frame_distortions[mbmi->ref_frame] = distortion2;
+ }
}
// Did this mode help.. i.e. is it the new best mode
// Note index of best mode so far
best_mode_index = mode_index;
- if (this_mode <= I4X4_PRED) {
+ if (ref_frame == INTRA_FRAME) {
/* required for left and above block mv */
mbmi->mv[0].as_int = 0;
}
assert((cm->mcomp_filter_type == SWITCHABLE) ||
(cm->mcomp_filter_type == best_mbmode.interp_filter) ||
- (best_mbmode.mode <= I4X4_PRED));
+ (best_mbmode.ref_frame == INTRA_FRAME));
// Accumulate filter usage stats
// TODO(agrange): Use RD criteria to select interpolation filter mode.
// macroblock modes
vpx_memcpy(mbmi, &best_mbmode, sizeof(MB_MODE_INFO));
- if (best_mbmode.mode == I4X4_PRED) {
+ if (best_mbmode.ref_frame == INTRA_FRAME &&
+ best_mbmode.sb_type < BLOCK_SIZE_SB8X8) {
for (i = 0; i < 4; i++) {
xd->mode_info_context->bmi[i].as_mode = best_bmodes[i].as_mode;
}