Cleaning up vp9_append_sub8x8_mvs_for_idx().
Replacing if-else with switch statement, reordering function arguments. Change-Id: I4825d2ef311ba8999b6d4ceb0eef003587a13434
This commit is contained in:
Родитель
014b9c70f7
Коммит
098d13ba10
|
@ -36,46 +36,49 @@ void vp9_find_best_ref_mvs(MACROBLOCKD *xd, int allow_hp,
|
||||||
|
|
||||||
void vp9_append_sub8x8_mvs_for_idx(VP9_COMMON *cm, MACROBLOCKD *xd,
|
void vp9_append_sub8x8_mvs_for_idx(VP9_COMMON *cm, MACROBLOCKD *xd,
|
||||||
const TileInfo *const tile,
|
const TileInfo *const tile,
|
||||||
int_mv *dst_nearest, int_mv *dst_near,
|
int block, int ref, int mi_row, int mi_col,
|
||||||
int block_idx, int ref_idx,
|
int_mv *nearest, int_mv *near) {
|
||||||
int mi_row, int mi_col) {
|
|
||||||
int_mv mv_list[MAX_MV_REF_CANDIDATES];
|
int_mv mv_list[MAX_MV_REF_CANDIDATES];
|
||||||
MODE_INFO *const mi = xd->mi_8x8[0];
|
MODE_INFO *const mi = xd->mi_8x8[0];
|
||||||
b_mode_info *bmi = mi->bmi;
|
b_mode_info *bmi = mi->bmi;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
assert(ref_idx == 0 || ref_idx == 1);
|
|
||||||
assert(MAX_MV_REF_CANDIDATES == 2);
|
assert(MAX_MV_REF_CANDIDATES == 2);
|
||||||
|
|
||||||
vp9_find_mv_refs_idx(cm, xd, tile, mi, xd->last_mi,
|
vp9_find_mv_refs_idx(cm, xd, tile, mi, xd->last_mi, mi->mbmi.ref_frame[ref],
|
||||||
mi->mbmi.ref_frame[ref_idx],
|
mv_list, block, mi_row, mi_col);
|
||||||
mv_list, block_idx, mi_row, mi_col);
|
|
||||||
|
|
||||||
dst_near->as_int = 0;
|
near->as_int = 0;
|
||||||
if (block_idx == 0) {
|
switch (block) {
|
||||||
dst_nearest->as_int = mv_list[0].as_int;
|
case 0:
|
||||||
dst_near->as_int = mv_list[1].as_int;
|
nearest->as_int = mv_list[0].as_int;
|
||||||
} else if (block_idx == 1 || block_idx == 2) {
|
near->as_int = mv_list[1].as_int;
|
||||||
dst_nearest->as_int = bmi[0].as_mv[ref_idx].as_int;
|
break;
|
||||||
for (n = 0; n < MAX_MV_REF_CANDIDATES; ++n)
|
case 1:
|
||||||
if (dst_nearest->as_int != mv_list[n].as_int) {
|
case 2:
|
||||||
dst_near->as_int = mv_list[n].as_int;
|
nearest->as_int = bmi[0].as_mv[ref].as_int;
|
||||||
break;
|
for (n = 0; n < MAX_MV_REF_CANDIDATES; ++n)
|
||||||
}
|
if (nearest->as_int != mv_list[n].as_int) {
|
||||||
} else {
|
near->as_int = mv_list[n].as_int;
|
||||||
int_mv candidates[2 + MAX_MV_REF_CANDIDATES];
|
break;
|
||||||
candidates[0] = bmi[1].as_mv[ref_idx];
|
}
|
||||||
candidates[1] = bmi[0].as_mv[ref_idx];
|
break;
|
||||||
candidates[2] = mv_list[0];
|
case 3: {
|
||||||
candidates[3] = mv_list[1];
|
int_mv candidates[2 + MAX_MV_REF_CANDIDATES];
|
||||||
|
candidates[0] = bmi[1].as_mv[ref];
|
||||||
|
candidates[1] = bmi[0].as_mv[ref];
|
||||||
|
candidates[2] = mv_list[0];
|
||||||
|
candidates[3] = mv_list[1];
|
||||||
|
|
||||||
assert(block_idx == 3);
|
nearest->as_int = bmi[2].as_mv[ref].as_int;
|
||||||
dst_nearest->as_int = bmi[2].as_mv[ref_idx].as_int;
|
for (n = 0; n < 2 + MAX_MV_REF_CANDIDATES; ++n)
|
||||||
for (n = 0; n < 2 + MAX_MV_REF_CANDIDATES; ++n) {
|
if (nearest->as_int != candidates[n].as_int) {
|
||||||
if (dst_nearest->as_int != candidates[n].as_int) {
|
near->as_int = candidates[n].as_int;
|
||||||
dst_near->as_int = candidates[n].as_int;
|
break;
|
||||||
break;
|
}
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
assert("Invalid block index.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,9 +36,7 @@ static void clamp_mv2(MV *mv, const MACROBLOCKD *xd) {
|
||||||
|
|
||||||
void vp9_append_sub8x8_mvs_for_idx(VP9_COMMON *cm, MACROBLOCKD *xd,
|
void vp9_append_sub8x8_mvs_for_idx(VP9_COMMON *cm, MACROBLOCKD *xd,
|
||||||
const TileInfo *const tile,
|
const TileInfo *const tile,
|
||||||
int_mv *dst_nearest,
|
int block, int ref, int mi_row, int mi_col,
|
||||||
int_mv *dst_near,
|
int_mv *nearest, int_mv *near);
|
||||||
int block_idx, int ref_idx,
|
|
||||||
int mi_row, int mi_col);
|
|
||||||
|
|
||||||
#endif // VP9_COMMON_VP9_FINDNEARMV_H_
|
#endif // VP9_COMMON_VP9_FINDNEARMV_H_
|
||||||
|
|
|
@ -475,8 +475,8 @@ static void read_inter_block_mode_info(VP9_COMMON *const cm,
|
||||||
|
|
||||||
if (b_mode == NEARESTMV || b_mode == NEARMV)
|
if (b_mode == NEARESTMV || b_mode == NEARMV)
|
||||||
for (ref = 0; ref < 1 + is_compound; ++ref)
|
for (ref = 0; ref < 1 + is_compound; ++ref)
|
||||||
vp9_append_sub8x8_mvs_for_idx(cm, xd, tile, &nearest[ref],
|
vp9_append_sub8x8_mvs_for_idx(cm, xd, tile, j, ref, mi_row, mi_col,
|
||||||
&nearmv[ref], j, ref, mi_row, mi_col);
|
&nearest[ref], &nearmv[ref]);
|
||||||
|
|
||||||
if (!assign_mv(cm, b_mode, block, best, nearest, nearmv,
|
if (!assign_mv(cm, b_mode, block, best, nearest, nearmv,
|
||||||
is_compound, allow_hp, r)) {
|
is_compound, allow_hp, r)) {
|
||||||
|
|
|
@ -1669,15 +1669,15 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x,
|
||||||
|
|
||||||
frame_mv[ZEROMV][mbmi->ref_frame[0]].as_int = 0;
|
frame_mv[ZEROMV][mbmi->ref_frame[0]].as_int = 0;
|
||||||
vp9_append_sub8x8_mvs_for_idx(&cpi->common, &x->e_mbd, tile,
|
vp9_append_sub8x8_mvs_for_idx(&cpi->common, &x->e_mbd, tile,
|
||||||
|
i, 0, mi_row, mi_col,
|
||||||
&frame_mv[NEARESTMV][mbmi->ref_frame[0]],
|
&frame_mv[NEARESTMV][mbmi->ref_frame[0]],
|
||||||
&frame_mv[NEARMV][mbmi->ref_frame[0]],
|
&frame_mv[NEARMV][mbmi->ref_frame[0]]);
|
||||||
i, 0, mi_row, mi_col);
|
|
||||||
if (has_second_rf) {
|
if (has_second_rf) {
|
||||||
frame_mv[ZEROMV][mbmi->ref_frame[1]].as_int = 0;
|
frame_mv[ZEROMV][mbmi->ref_frame[1]].as_int = 0;
|
||||||
vp9_append_sub8x8_mvs_for_idx(&cpi->common, &x->e_mbd, tile,
|
vp9_append_sub8x8_mvs_for_idx(&cpi->common, &x->e_mbd, tile,
|
||||||
|
i, 1, mi_row, mi_col,
|
||||||
&frame_mv[NEARESTMV][mbmi->ref_frame[1]],
|
&frame_mv[NEARESTMV][mbmi->ref_frame[1]],
|
||||||
&frame_mv[NEARMV][mbmi->ref_frame[1]],
|
&frame_mv[NEARMV][mbmi->ref_frame[1]]);
|
||||||
i, 1, mi_row, mi_col);
|
|
||||||
}
|
}
|
||||||
// search for the best motion vector on this segment
|
// search for the best motion vector on this segment
|
||||||
for (this_mode = NEARESTMV; this_mode <= NEWMV; ++this_mode) {
|
for (this_mode = NEARESTMV; this_mode <= NEWMV; ++this_mode) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче