Changing the order switchable filter enum constants.
This changeset allows to remove vp9_switchable_interp and vp9_switchable_interp_map arrays and make code much clear. Actually we still have to use these mapping but only inside read_interp_filter_type and write_interp_filter_type functions. Change-Id: I4026c6f8c4acefba6c81421b7bacbaa52cc45f50
This commit is contained in:
Родитель
d007446b3f
Коммит
3f611555d7
|
@ -56,11 +56,11 @@ typedef enum {
|
|||
} FRAME_TYPE;
|
||||
|
||||
typedef enum {
|
||||
EIGHTTAP_SMOOTH,
|
||||
EIGHTTAP,
|
||||
EIGHTTAP_SHARP,
|
||||
BILINEAR,
|
||||
SWITCHABLE /* should be the last one */
|
||||
EIGHTTAP = 0,
|
||||
EIGHTTAP_SMOOTH = 1,
|
||||
EIGHTTAP_SHARP = 2,
|
||||
BILINEAR = 3,
|
||||
SWITCHABLE = 4 /* should be the last one */
|
||||
} INTERPOLATIONFILTERTYPE;
|
||||
|
||||
typedef enum {
|
||||
|
|
|
@ -339,13 +339,10 @@ void vp9_init_mbmode_probs(VP9_COMMON *cm) {
|
|||
}
|
||||
|
||||
const vp9_tree_index vp9_switchable_interp_tree[VP9_SWITCHABLE_FILTERS*2-2] = {
|
||||
-0, 2,
|
||||
-1, -2
|
||||
-EIGHTTAP, 2,
|
||||
-EIGHTTAP_SMOOTH, -EIGHTTAP_SHARP
|
||||
};
|
||||
struct vp9_token vp9_switchable_interp_encodings[VP9_SWITCHABLE_FILTERS];
|
||||
const INTERPOLATIONFILTERTYPE vp9_switchable_interp[VP9_SWITCHABLE_FILTERS] = {
|
||||
EIGHTTAP, EIGHTTAP_SMOOTH, EIGHTTAP_SHARP};
|
||||
const int vp9_switchable_interp_map[SWITCHABLE + 1] = {1, 0, 2, -1, -1};
|
||||
|
||||
void vp9_entropy_mode_init() {
|
||||
vp9_tokens_from_tree(vp9_intra_mode_encodings, vp9_intra_mode_tree);
|
||||
|
|
|
@ -49,11 +49,6 @@ extern struct vp9_token vp9_inter_mode_encodings[VP9_INTER_MODES];
|
|||
extern const vp9_tree_index vp9_partition_tree[];
|
||||
extern struct vp9_token vp9_partition_encodings[PARTITION_TYPES];
|
||||
|
||||
extern const INTERPOLATIONFILTERTYPE vp9_switchable_interp
|
||||
[VP9_SWITCHABLE_FILTERS];
|
||||
|
||||
extern const int vp9_switchable_interp_map[SWITCHABLE + 1];
|
||||
|
||||
extern const vp9_tree_index vp9_switchable_interp_tree
|
||||
[2 * (VP9_SWITCHABLE_FILTERS - 1)];
|
||||
|
||||
|
|
|
@ -29,18 +29,16 @@ unsigned char vp9_get_pred_context_switchable_interp(const MACROBLOCKD *xd) {
|
|||
// The prediction flags in these dummy entries are initialised to 0.
|
||||
// left
|
||||
const int left_mv_pred = is_inter_mode(left_mbmi->mode);
|
||||
const int left_interp = left_in_image && left_mv_pred ?
|
||||
vp9_switchable_interp_map[left_mbmi->interp_filter] :
|
||||
VP9_SWITCHABLE_FILTERS;
|
||||
const int left_interp = left_in_image && left_mv_pred
|
||||
? left_mbmi->interp_filter
|
||||
: VP9_SWITCHABLE_FILTERS;
|
||||
|
||||
// above
|
||||
const int above_mv_pred = is_inter_mode(above_mbmi->mode);
|
||||
const int above_interp = above_in_image && above_mv_pred ?
|
||||
vp9_switchable_interp_map[above_mbmi->interp_filter] :
|
||||
VP9_SWITCHABLE_FILTERS;
|
||||
const int above_interp = above_in_image && above_mv_pred
|
||||
? above_mbmi->interp_filter
|
||||
: VP9_SWITCHABLE_FILTERS;
|
||||
|
||||
assert(left_interp != -1);
|
||||
assert(above_interp != -1);
|
||||
|
||||
if (left_interp == above_interp)
|
||||
return left_interp;
|
||||
|
|
|
@ -371,10 +371,10 @@ static INLINE INTERPOLATIONFILTERTYPE read_switchable_filter_type(
|
|||
VP9_COMMON *const cm = &pbi->common;
|
||||
MACROBLOCKD *const xd = &pbi->mb;
|
||||
const vp9_prob *probs = vp9_get_pred_probs_switchable_interp(cm, xd);
|
||||
const int index = treed_read(r, vp9_switchable_interp_tree, probs);
|
||||
const int type = treed_read(r, vp9_switchable_interp_tree, probs);
|
||||
const int ctx = vp9_get_pred_context_switchable_interp(xd);
|
||||
++cm->counts.switchable_interp[ctx][index];
|
||||
return vp9_switchable_interp[index];
|
||||
++cm->counts.switchable_interp[ctx][type];
|
||||
return type;
|
||||
}
|
||||
|
||||
static void read_intra_block_mode_info(VP9D_COMP *pbi, MODE_INFO *mi,
|
||||
|
|
|
@ -497,8 +497,11 @@ static void setup_quantization(VP9D_COMP *pbi, struct vp9_read_bit_buffer *rb) {
|
|||
|
||||
static INTERPOLATIONFILTERTYPE read_interp_filter_type(
|
||||
struct vp9_read_bit_buffer *rb) {
|
||||
const INTERPOLATIONFILTERTYPE literal_to_type[] = { EIGHTTAP_SMOOTH,
|
||||
EIGHTTAP,
|
||||
EIGHTTAP_SHARP };
|
||||
return vp9_rb_read_bit(rb) ? SWITCHABLE
|
||||
: vp9_rb_read_literal(rb, 2);
|
||||
: literal_to_type[vp9_rb_read_literal(rb, 2)];
|
||||
}
|
||||
|
||||
static void read_frame_size(struct vp9_read_bit_buffer *rb,
|
||||
|
@ -836,7 +839,7 @@ static size_t read_uncompressed_header(VP9D_COMP *pbi,
|
|||
pbi->refresh_frame_flags = vp9_rb_read_literal(rb, NUM_REF_FRAMES);
|
||||
setup_frame_size(pbi, rb);
|
||||
} else {
|
||||
pbi->refresh_frame_flags = vp9_rb_read_literal(rb, NUM_REF_FRAMES);
|
||||
pbi->refresh_frame_flags = vp9_rb_read_literal(rb, NUM_REF_FRAMES);
|
||||
|
||||
for (i = 0; i < ALLOWED_REFS_PER_FRAME; ++i) {
|
||||
const int ref = vp9_rb_read_literal(rb, NUM_REF_FRAMES_LOG2);
|
||||
|
|
|
@ -479,8 +479,7 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc) {
|
|||
if (cpi->common.mcomp_filter_type == SWITCHABLE) {
|
||||
write_token(bc, vp9_switchable_interp_tree,
|
||||
vp9_get_pred_probs_switchable_interp(&cpi->common, xd),
|
||||
vp9_switchable_interp_encodings +
|
||||
vp9_switchable_interp_map[mi->interp_filter]);
|
||||
&vp9_switchable_interp_encodings[mi->interp_filter]);
|
||||
} else {
|
||||
assert(mi->interp_filter == cpi->common.mcomp_filter_type);
|
||||
}
|
||||
|
@ -1072,9 +1071,11 @@ static void encode_txfm_probs(VP9_COMP *cpi, vp9_writer *w) {
|
|||
|
||||
static void write_interp_filter_type(INTERPOLATIONFILTERTYPE type,
|
||||
struct vp9_write_bit_buffer *wb) {
|
||||
const int type_to_literal[] = { 1, 0, 2 };
|
||||
|
||||
vp9_wb_write_bit(wb, type == SWITCHABLE);
|
||||
if (type != SWITCHABLE)
|
||||
vp9_wb_write_literal(wb, type, 2);
|
||||
vp9_wb_write_literal(wb, type_to_literal[type], 2);
|
||||
}
|
||||
|
||||
static void fix_mcomp_filter_type(VP9_COMP *cpi) {
|
||||
|
@ -1094,7 +1095,7 @@ static void fix_mcomp_filter_type(VP9_COMP *cpi) {
|
|||
// Only one filter is used. So set the filter at frame level
|
||||
for (i = 0; i < VP9_SWITCHABLE_FILTERS; ++i) {
|
||||
if (count[i]) {
|
||||
cm->mcomp_filter_type = vp9_switchable_interp[i];
|
||||
cm->mcomp_filter_type = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -439,8 +439,7 @@ static void update_state(VP9_COMP *cpi, PICK_MODE_CONTEXT *ctx,
|
|||
if (cpi->common.mcomp_filter_type == SWITCHABLE
|
||||
&& is_inter_mode(mbmi->mode)) {
|
||||
++cpi->common.counts.switchable_interp[
|
||||
vp9_get_pred_context_switchable_interp(xd)]
|
||||
[vp9_switchable_interp_map[mbmi->interp_filter]];
|
||||
vp9_get_pred_context_switchable_interp(xd)][mbmi->interp_filter];
|
||||
}
|
||||
|
||||
cpi->rd_comp_pred_diff[SINGLE_PREDICTION_ONLY] += ctx->single_pred_diff;
|
||||
|
@ -2385,15 +2384,15 @@ void vp9_encode_frame(VP9_COMP *cpi) {
|
|||
cpi->rd_filter_threshes[frame_type][2] &&
|
||||
cpi->rd_filter_threshes[frame_type][1] >
|
||||
cpi->rd_filter_threshes[frame_type][VP9_SWITCHABLE_FILTERS]) {
|
||||
filter_type = vp9_switchable_interp[1];
|
||||
filter_type = EIGHTTAP_SMOOTH;
|
||||
} else if (cpi->rd_filter_threshes[frame_type][2] >
|
||||
cpi->rd_filter_threshes[frame_type][0] &&
|
||||
cpi->rd_filter_threshes[frame_type][2] >
|
||||
cpi->rd_filter_threshes[frame_type][VP9_SWITCHABLE_FILTERS]) {
|
||||
filter_type = vp9_switchable_interp[2];
|
||||
filter_type = EIGHTTAP_SHARP;
|
||||
} else if (cpi->rd_filter_threshes[frame_type][0] >
|
||||
cpi->rd_filter_threshes[frame_type][VP9_SWITCHABLE_FILTERS]) {
|
||||
filter_type = vp9_switchable_interp[0];
|
||||
filter_type = EIGHTTAP;
|
||||
} else {
|
||||
filter_type = SWITCHABLE;
|
||||
}
|
||||
|
|
|
@ -2003,7 +2003,7 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x,
|
|||
}
|
||||
|
||||
if (mbmi->ref_frame[1] > 0 && this_mode == NEWMV &&
|
||||
mbmi->interp_filter == vp9_switchable_interp[0]) {
|
||||
mbmi->interp_filter == EIGHTTAP) {
|
||||
if (seg_mvs[i][mbmi->ref_frame[1]].as_int == INVALID_MV ||
|
||||
seg_mvs[i][mbmi->ref_frame[0]].as_int == INVALID_MV)
|
||||
continue;
|
||||
|
@ -2456,7 +2456,7 @@ static INLINE int get_switchable_rate(MACROBLOCK *x) {
|
|||
MB_MODE_INFO *const mbmi = &xd->mode_info_context->mbmi;
|
||||
|
||||
const int c = vp9_get_pred_context_switchable_interp(xd);
|
||||
const int m = vp9_switchable_interp_map[mbmi->interp_filter];
|
||||
const int m = mbmi->interp_filter;
|
||||
return SWITCHABLE_INTERP_RATE_FACTOR * x->switchable_interp_costs[c][m];
|
||||
}
|
||||
|
||||
|
@ -2882,9 +2882,8 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
|
|||
for (i = 0; i < VP9_SWITCHABLE_FILTERS; ++i) {
|
||||
int j;
|
||||
int64_t rs_rd;
|
||||
const INTERPOLATIONFILTERTYPE filter = vp9_switchable_interp[i];
|
||||
const int is_intpel_interp = intpel_mv;
|
||||
mbmi->interp_filter = filter;
|
||||
mbmi->interp_filter = i;
|
||||
vp9_setup_interp_filters(xd, mbmi->interp_filter, cm);
|
||||
rs = get_switchable_rate(x);
|
||||
rs_rd = RDCOST(x->rdmult, x->rddiv, rs, 0);
|
||||
|
@ -3593,8 +3592,7 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
|
|||
++switchable_filter_index) {
|
||||
int newbest, rs;
|
||||
int64_t rs_rd;
|
||||
mbmi->interp_filter =
|
||||
vp9_switchable_interp[switchable_filter_index];
|
||||
mbmi->interp_filter = switchable_filter_index;
|
||||
vp9_setup_interp_filters(xd, mbmi->interp_filter, &cpi->common);
|
||||
|
||||
tmp_rd = rd_pick_best_mbsegmentation(cpi, x,
|
||||
|
@ -3927,8 +3925,7 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
|
|||
if (!mode_excluded && !disable_skip && ref_frame != INTRA_FRAME &&
|
||||
cm->mcomp_filter_type != BILINEAR) {
|
||||
int64_t ref = cpi->rd_filter_cache[cm->mcomp_filter_type == SWITCHABLE ?
|
||||
VP9_SWITCHABLE_FILTERS :
|
||||
vp9_switchable_interp_map[cm->mcomp_filter_type]];
|
||||
VP9_SWITCHABLE_FILTERS : cm->mcomp_filter_type];
|
||||
for (i = 0; i <= VP9_SWITCHABLE_FILTERS; i++) {
|
||||
int64_t adj_rd;
|
||||
// In cases of poor prediction, filter_cache[] can contain really big
|
||||
|
|
Загрузка…
Ссылка в новой задаче