Merge "simp-mv-pred integration with ref-mv" into nextgenv2
This commit is contained in:
@@ -350,7 +350,11 @@ static int add_col_ref_mv(const AV1_COMMON *cm,
|
|||||||
|
|
||||||
if (idx == *refmv_count && *refmv_count < MAX_REF_MV_STACK_SIZE) {
|
if (idx == *refmv_count && *refmv_count < MAX_REF_MV_STACK_SIZE) {
|
||||||
ref_mv_stack[idx].this_mv.as_int = this_refmv.as_int;
|
ref_mv_stack[idx].this_mv.as_int = this_refmv.as_int;
|
||||||
|
#if CONFIG_SIMP_MV_PRED
|
||||||
|
ref_mv_stack[idx].pred_mv[0] = prev_frame_mvs->mv[ref];
|
||||||
|
#else
|
||||||
ref_mv_stack[idx].pred_mv[0] = prev_frame_mvs->pred_mv[ref];
|
ref_mv_stack[idx].pred_mv[0] = prev_frame_mvs->pred_mv[ref];
|
||||||
|
#endif
|
||||||
ref_mv_stack[idx].weight = 2;
|
ref_mv_stack[idx].weight = 2;
|
||||||
++(*refmv_count);
|
++(*refmv_count);
|
||||||
}
|
}
|
||||||
@@ -420,12 +424,25 @@ static void setup_ref_mv_list(const AV1_COMMON *cm, const MACROBLOCKD *xd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Scan the second outer area.
|
// Scan the second outer area.
|
||||||
|
#if CONFIG_SIMP_MV_PRED
|
||||||
|
scan_blk_mbmi(cm, xd, mi_row, mi_col, block, rf, -1, -1, ref_mv_stack,
|
||||||
|
refmv_count);
|
||||||
|
for (idx = 2; idx <= 3; ++idx) {
|
||||||
|
scan_row_mbmi(cm, xd, mi_row, mi_col, block, rf, -idx, ref_mv_stack,
|
||||||
|
refmv_count);
|
||||||
|
scan_col_mbmi(cm, xd, mi_row, mi_col, block, rf, -idx, ref_mv_stack,
|
||||||
|
refmv_count);
|
||||||
|
}
|
||||||
|
scan_col_mbmi(cm, xd, mi_row, mi_col, block, rf, -4, ref_mv_stack,
|
||||||
|
refmv_count);
|
||||||
|
#else
|
||||||
for (idx = 2; idx <= 4; ++idx) {
|
for (idx = 2; idx <= 4; ++idx) {
|
||||||
scan_row_mbmi(cm, xd, mi_row, mi_col, block, rf, -idx, ref_mv_stack,
|
scan_row_mbmi(cm, xd, mi_row, mi_col, block, rf, -idx, ref_mv_stack,
|
||||||
refmv_count);
|
refmv_count);
|
||||||
scan_col_mbmi(cm, xd, mi_row, mi_col, block, rf, -idx, ref_mv_stack,
|
scan_col_mbmi(cm, xd, mi_row, mi_col, block, rf, -idx, ref_mv_stack,
|
||||||
refmv_count);
|
refmv_count);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
switch (nearest_refmv_count) {
|
switch (nearest_refmv_count) {
|
||||||
case 0:
|
case 0:
|
||||||
@@ -530,7 +547,9 @@ static void find_mv_refs_idx(const AV1_COMMON *cm, const MACROBLOCKD *xd,
|
|||||||
void *const data, int16_t *mode_context) {
|
void *const data, int16_t *mode_context) {
|
||||||
const int *ref_sign_bias = cm->ref_frame_sign_bias;
|
const int *ref_sign_bias = cm->ref_frame_sign_bias;
|
||||||
int i, refmv_count = 0;
|
int i, refmv_count = 0;
|
||||||
|
#if !CONFIG_SIMP_MV_PRED
|
||||||
const POSITION *const mv_ref_search = mv_ref_blocks[mi->mbmi.sb_type];
|
const POSITION *const mv_ref_search = mv_ref_blocks[mi->mbmi.sb_type];
|
||||||
|
#endif
|
||||||
int different_ref_found = 0;
|
int different_ref_found = 0;
|
||||||
int context_counter = 0;
|
int context_counter = 0;
|
||||||
const MV_REF *const prev_frame_mvs =
|
const MV_REF *const prev_frame_mvs =
|
||||||
@@ -540,6 +559,29 @@ static void find_mv_refs_idx(const AV1_COMMON *cm, const MACROBLOCKD *xd,
|
|||||||
const TileInfo *const tile = &xd->tile;
|
const TileInfo *const tile = &xd->tile;
|
||||||
const int bw = num_8x8_blocks_wide_lookup[mi->mbmi.sb_type] << 3;
|
const int bw = num_8x8_blocks_wide_lookup[mi->mbmi.sb_type] << 3;
|
||||||
const int bh = num_8x8_blocks_high_lookup[mi->mbmi.sb_type] << 3;
|
const int bh = num_8x8_blocks_high_lookup[mi->mbmi.sb_type] << 3;
|
||||||
|
#if CONFIG_SIMP_MV_PRED
|
||||||
|
POSITION mv_ref_search[MVREF_NEIGHBOURS];
|
||||||
|
const int num_8x8_blocks_wide = bw >> 3;
|
||||||
|
const int num_8x8_blocks_high = bh >> 3;
|
||||||
|
mv_ref_search[0].row = num_8x8_blocks_high - 1;
|
||||||
|
mv_ref_search[0].col = -1;
|
||||||
|
mv_ref_search[1].row = -1;
|
||||||
|
mv_ref_search[1].col = num_8x8_blocks_wide - 1;
|
||||||
|
mv_ref_search[2].row = -1;
|
||||||
|
mv_ref_search[2].col = (num_8x8_blocks_wide - 1) >> 1;
|
||||||
|
mv_ref_search[3].row = (num_8x8_blocks_high - 1) >> 1;
|
||||||
|
mv_ref_search[3].col = -1;
|
||||||
|
mv_ref_search[4].row = -1;
|
||||||
|
mv_ref_search[4].col = -1;
|
||||||
|
mv_ref_search[5].row = -1;
|
||||||
|
mv_ref_search[5].col = num_8x8_blocks_wide;
|
||||||
|
mv_ref_search[6].row = num_8x8_blocks_high;
|
||||||
|
mv_ref_search[6].col = -1;
|
||||||
|
mv_ref_search[7].row = -1;
|
||||||
|
mv_ref_search[7].col = -3;
|
||||||
|
mv_ref_search[8].row = num_8x8_blocks_high - 1;
|
||||||
|
mv_ref_search[8].col = -3;
|
||||||
|
#endif
|
||||||
|
|
||||||
// The nearest 2 blocks are treated differently
|
// The nearest 2 blocks are treated differently
|
||||||
// if the size < 8x8 we get the mv from the bmi substructure,
|
// if the size < 8x8 we get the mv from the bmi substructure,
|
||||||
@@ -571,6 +613,12 @@ static void find_mv_refs_idx(const AV1_COMMON *cm, const MACROBLOCKD *xd,
|
|||||||
if (is_inside(tile, mi_col, mi_row, mv_ref)) {
|
if (is_inside(tile, mi_col, mi_row, mv_ref)) {
|
||||||
const MB_MODE_INFO *const candidate =
|
const MB_MODE_INFO *const candidate =
|
||||||
&xd->mi[mv_ref->col + mv_ref->row * xd->mi_stride]->mbmi;
|
&xd->mi[mv_ref->col + mv_ref->row * xd->mi_stride]->mbmi;
|
||||||
|
#if CONFIG_SIMP_MV_PRED
|
||||||
|
if (candidate == NULL)
|
||||||
|
continue;
|
||||||
|
if ((mi_row % 8) + mv_ref->row >= 8 || (mi_col % 8) + mv_ref->col >= 8)
|
||||||
|
continue;
|
||||||
|
#endif
|
||||||
different_ref_found = 1;
|
different_ref_found = 1;
|
||||||
|
|
||||||
if (candidate->ref_frame[0] == ref_frame)
|
if (candidate->ref_frame[0] == ref_frame)
|
||||||
@@ -617,6 +665,12 @@ static void find_mv_refs_idx(const AV1_COMMON *cm, const MACROBLOCKD *xd,
|
|||||||
if (is_inside(tile, mi_col, mi_row, mv_ref)) {
|
if (is_inside(tile, mi_col, mi_row, mv_ref)) {
|
||||||
const MB_MODE_INFO *const candidate =
|
const MB_MODE_INFO *const candidate =
|
||||||
&xd->mi[mv_ref->col + mv_ref->row * xd->mi_stride]->mbmi;
|
&xd->mi[mv_ref->col + mv_ref->row * xd->mi_stride]->mbmi;
|
||||||
|
#if CONFIG_SIMP_MV_PRED
|
||||||
|
if (candidate == NULL)
|
||||||
|
continue;
|
||||||
|
if ((mi_row % 8) + mv_ref->row >= 8 || (mi_col % 8) + mv_ref->col >= 8)
|
||||||
|
continue;
|
||||||
|
#endif
|
||||||
|
|
||||||
// If the candidate is INTRA we don't want to consider its mv.
|
// If the candidate is INTRA we don't want to consider its mv.
|
||||||
IF_DIFF_REF_FRAME_ADD_MV(candidate, ref_frame, ref_sign_bias,
|
IF_DIFF_REF_FRAME_ADD_MV(candidate, ref_frame, ref_sign_bias,
|
||||||
|
@@ -18,7 +18,11 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_SIMP_MV_PRED
|
||||||
|
#define MVREF_NEIGHBOURS 9
|
||||||
|
#else
|
||||||
#define MVREF_NEIGHBOURS 8
|
#define MVREF_NEIGHBOURS 8
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct position {
|
typedef struct position {
|
||||||
int row;
|
int row;
|
||||||
@@ -96,6 +100,7 @@ static const int counter_to_context[19] = {
|
|||||||
BOTH_INTRA // 18
|
BOTH_INTRA // 18
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if !CONFIG_SIMP_MV_PRED
|
||||||
static const POSITION mv_ref_blocks[BLOCK_SIZES][MVREF_NEIGHBOURS] = {
|
static const POSITION mv_ref_blocks[BLOCK_SIZES][MVREF_NEIGHBOURS] = {
|
||||||
// 4X4
|
// 4X4
|
||||||
{ { -1, 0 },
|
{ { -1, 0 },
|
||||||
@@ -245,6 +250,7 @@ static const POSITION mv_ref_blocks[BLOCK_SIZES][MVREF_NEIGHBOURS] = {
|
|||||||
{ -2, 12 } },
|
{ -2, 12 } },
|
||||||
#endif // CONFIG_EXT_PARTITION
|
#endif // CONFIG_EXT_PARTITION
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
static const int idx_n_column_to_subblock[4][2] = {
|
static const int idx_n_column_to_subblock[4][2] = {
|
||||||
{ 1, 2 }, { 1, 3 }, { 3, 2 }, { 3, 3 }
|
{ 1, 2 }, { 1, 3 }, { 3, 2 }, { 3, 3 }
|
||||||
@@ -268,22 +274,30 @@ static INLINE void clamp_mv_ref(MV *mv, int bw, int bh, const MACROBLOCKD *xd) {
|
|||||||
// on whether the block_size < 8x8 and we have check_sub_blocks set.
|
// on whether the block_size < 8x8 and we have check_sub_blocks set.
|
||||||
static INLINE int_mv get_sub_block_mv(const MODE_INFO *candidate, int which_mv,
|
static INLINE int_mv get_sub_block_mv(const MODE_INFO *candidate, int which_mv,
|
||||||
int search_col, int block_idx) {
|
int search_col, int block_idx) {
|
||||||
|
#if CONFIG_SIMP_MV_PRED
|
||||||
|
return candidate->mbmi.mv[which_mv];
|
||||||
|
#else
|
||||||
return block_idx >= 0 && candidate->mbmi.sb_type < BLOCK_8X8
|
return block_idx >= 0 && candidate->mbmi.sb_type < BLOCK_8X8
|
||||||
? candidate
|
? candidate
|
||||||
->bmi[idx_n_column_to_subblock[block_idx][search_col == 0]]
|
->bmi[idx_n_column_to_subblock[block_idx][search_col == 0]]
|
||||||
.as_mv[which_mv]
|
.as_mv[which_mv]
|
||||||
: candidate->mbmi.mv[which_mv];
|
: candidate->mbmi.mv[which_mv];
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_REF_MV
|
#if CONFIG_REF_MV
|
||||||
static INLINE int_mv get_sub_block_pred_mv(const MODE_INFO *candidate,
|
static INLINE int_mv get_sub_block_pred_mv(const MODE_INFO *candidate,
|
||||||
int which_mv, int search_col,
|
int which_mv, int search_col,
|
||||||
int block_idx) {
|
int block_idx) {
|
||||||
|
#if CONFIG_SIMP_MV_PRED
|
||||||
|
return candidate->mbmi.mv[which_mv];
|
||||||
|
#else
|
||||||
return block_idx >= 0 && candidate->mbmi.sb_type < BLOCK_8X8
|
return block_idx >= 0 && candidate->mbmi.sb_type < BLOCK_8X8
|
||||||
? candidate
|
? candidate
|
||||||
->bmi[idx_n_column_to_subblock[block_idx][search_col == 0]]
|
->bmi[idx_n_column_to_subblock[block_idx][search_col == 0]]
|
||||||
.pred_mv[which_mv]
|
.pred_mv[which_mv]
|
||||||
: candidate->mbmi.pred_mv[which_mv];
|
: candidate->mbmi.pred_mv[which_mv];
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -4074,6 +4074,10 @@ void av1_decode_frame(AV1Decoder *pbi, const uint8_t *data,
|
|||||||
aom_internal_error(&cm->error, AOM_CODEC_CORRUPT_FRAME,
|
aom_internal_error(&cm->error, AOM_CODEC_CORRUPT_FRAME,
|
||||||
"Truncated packet or corrupt header length");
|
"Truncated packet or corrupt header length");
|
||||||
|
|
||||||
|
#if CONFIG_SIMP_MV_PRED
|
||||||
|
cm->setup_mi(cm);
|
||||||
|
#endif
|
||||||
|
|
||||||
cm->use_prev_frame_mvs =
|
cm->use_prev_frame_mvs =
|
||||||
!cm->error_resilient_mode && cm->width == cm->last_width &&
|
!cm->error_resilient_mode && cm->width == cm->last_width &&
|
||||||
cm->height == cm->last_height && !cm->last_intra_only &&
|
cm->height == cm->last_height && !cm->last_intra_only &&
|
||||||
|
@@ -4639,6 +4639,9 @@ static void encode_frame_internal(AV1_COMP *cpi) {
|
|||||||
|
|
||||||
x->min_partition_size = AOMMIN(x->min_partition_size, cm->sb_size);
|
x->min_partition_size = AOMMIN(x->min_partition_size, cm->sb_size);
|
||||||
x->max_partition_size = AOMMIN(x->max_partition_size, cm->sb_size);
|
x->max_partition_size = AOMMIN(x->max_partition_size, cm->sb_size);
|
||||||
|
#if CONFIG_SIMP_MV_PRED
|
||||||
|
cm->setup_mi(cm);
|
||||||
|
#endif
|
||||||
|
|
||||||
xd->mi = cm->mi_grid_visible;
|
xd->mi = cm->mi_grid_visible;
|
||||||
xd->mi[0] = cm->mi;
|
xd->mi[0] = cm->mi;
|
||||||
|
Reference in New Issue
Block a user