Commit 98ee8018 authored by Jingning Han's avatar Jingning Han
Browse files

Integrate motion vector into the coding pipeline

This commit ports the motion vector stack from motion field
analyzer to the encoding and decoding pipeline.

Change-Id: I9f265f198b3f7b52dad8948490959041159fd6b2
parent 1d1ede94
......@@ -195,6 +195,11 @@ typedef struct macroblockd {
/* pointer to current frame */
const YV12_BUFFER_CONFIG *cur_buf;
#if CONFIG_REF_MV
uint8_t ref_mv_count[MAX_REF_FRAMES];
CANDIDATE_MV ref_mv_stack[MAX_REF_FRAMES][MAX_REF_MV_STACK_SIZE];
#endif
ENTROPY_CONTEXT *above_context[MAX_MB_PLANE];
ENTROPY_CONTEXT left_context[MAX_MB_PLANE][16];
......
......@@ -16,7 +16,7 @@ static void scan_row_mbmi(const AV1_COMMON *cm, const MACROBLOCKD *xd,
const MV_REFERENCE_FRAME ref_frame,
int row_offset,
CANDIDATE_MV *ref_mv_stack,
int *refmv_count) {
uint8_t *refmv_count) {
const TileInfo *const tile = &xd->tile;
int i;
for (i = 0; i < xd->n8_w && *refmv_count < MAX_REF_MV_STACK_SIZE;) {
......@@ -63,7 +63,7 @@ static void scan_col_mbmi(const AV1_COMMON *cm, const MACROBLOCKD *xd,
const MV_REFERENCE_FRAME ref_frame,
int col_offset,
CANDIDATE_MV *ref_mv_stack,
int *refmv_count) {
uint8_t *refmv_count) {
const TileInfo *const tile = &xd->tile;
int i;
......@@ -111,7 +111,7 @@ static void scan_blk_mbmi(const AV1_COMMON *cm, const MACROBLOCKD *xd,
const MV_REFERENCE_FRAME ref_frame,
int row_offset, int col_offset,
CANDIDATE_MV *ref_mv_stack,
int *refmv_count) {
uint8_t *refmv_count) {
const TileInfo *const tile = &xd->tile;
POSITION mi_pos;
......@@ -149,34 +149,35 @@ static void scan_blk_mbmi(const AV1_COMMON *cm, const MACROBLOCKD *xd,
static void setup_ref_mv_list(const AV1_COMMON *cm, const MACROBLOCKD *xd,
MV_REFERENCE_FRAME ref_frame,
uint8_t *refmv_count,
CANDIDATE_MV *ref_mv_stack,
int_mv *mv_ref_list,
int block, int mi_row, int mi_col,
uint8_t *mode_context) {
int idx, refmv_count = 0, nearest_refmv_count = 0;
int idx, nearest_refmv_count = 0;
CANDIDATE_MV ref_mv_stack[MAX_REF_MV_STACK_SIZE];
CANDIDATE_MV tmp_mv;
int len, nr_len;
(void) mode_context;
memset(ref_mv_stack, 0, sizeof(ref_mv_stack));
*refmv_count = 0;
// Scan the first above row mode info.
scan_row_mbmi(cm, xd, mi_row, mi_col, block, ref_frame,
-1, ref_mv_stack, &refmv_count);
-1, ref_mv_stack, refmv_count);
// Scan the first left column mode info.
scan_col_mbmi(cm, xd, mi_row, mi_col, block, ref_frame,
-1, ref_mv_stack, &refmv_count);
-1, ref_mv_stack, refmv_count);
nearest_refmv_count = refmv_count;
nearest_refmv_count = *refmv_count;
// Scan the second outer area.
for (idx = 2; idx <= 4; ++idx) {
scan_row_mbmi(cm, xd, mi_row, mi_col, block, ref_frame,
-idx, ref_mv_stack, &refmv_count);
-idx, ref_mv_stack, refmv_count);
scan_col_mbmi(cm, xd, mi_row, mi_col, block, ref_frame,
-idx, ref_mv_stack, &refmv_count);
-idx, ref_mv_stack, refmv_count);
}
// Rank the likelihood and assign nearest and near mvs.
......@@ -194,7 +195,7 @@ static void setup_ref_mv_list(const AV1_COMMON *cm, const MACROBLOCKD *xd,
len = nr_len;
}
len = refmv_count;
len = *refmv_count;
while (len > nearest_refmv_count) {
nr_len = nearest_refmv_count;
for (idx = nearest_refmv_count + 1; idx < len; ++idx) {
......@@ -208,7 +209,7 @@ static void setup_ref_mv_list(const AV1_COMMON *cm, const MACROBLOCKD *xd,
len = nr_len;
}
for (idx = 0; idx < AOMMIN(MAX_MV_REF_CANDIDATES, refmv_count); ++idx) {
for (idx = 0; idx < AOMMIN(MAX_MV_REF_CANDIDATES, *refmv_count); ++idx) {
mv_ref_list[idx].as_int = ref_mv_stack[idx].this_mv.as_int;
clamp_mv_ref(&mv_ref_list[idx].as_mv,
(xd->n8_w << 3), (xd->n8_h << 3), xd);
......@@ -368,15 +369,21 @@ Done:
}
void av1_find_mv_refs(const AV1_COMMON *cm, const MACROBLOCKD *xd,
MODE_INFO *mi, MV_REFERENCE_FRAME ref_frame,
int_mv *mv_ref_list, int mi_row, int mi_col,
find_mv_refs_sync sync, void *const data,
uint8_t *mode_context) {
MODE_INFO *mi, MV_REFERENCE_FRAME ref_frame,
#if CONFIG_REF_MV
uint8_t *ref_mv_count,
CANDIDATE_MV *ref_mv_stack,
#endif
int_mv *mv_ref_list, int mi_row, int mi_col,
find_mv_refs_sync sync, void *const data,
uint8_t *mode_context) {
find_mv_refs_idx(cm, xd, mi, ref_frame, mv_ref_list, -1, mi_row, mi_col, sync,
data, mode_context);
#if CONFIG_REF_MV
setup_ref_mv_list(cm, xd, ref_frame, mv_ref_list, -1,
setup_ref_mv_list(cm, xd, ref_frame,
ref_mv_count, ref_mv_stack,
mv_ref_list, -1,
mi_row, mi_col, mode_context);
#endif
}
......
......@@ -304,10 +304,14 @@ static INLINE int is_inside(const TileInfo *const tile, int mi_col, int mi_row,
typedef void (*find_mv_refs_sync)(void *const data, int mi_row);
void av1_find_mv_refs(const AV1_COMMON *cm, const MACROBLOCKD *xd,
MODE_INFO *mi, MV_REFERENCE_FRAME ref_frame,
int_mv *mv_ref_list, int mi_row, int mi_col,
find_mv_refs_sync sync, void *const data,
uint8_t *mode_context);
MODE_INFO *mi, MV_REFERENCE_FRAME ref_frame,
#if CONFIG_REF_MV
uint8_t *ref_mv_count,
CANDIDATE_MV *ref_mv_stack,
#endif
int_mv *mv_ref_list, int mi_row, int mi_col,
find_mv_refs_sync sync, void *const data,
uint8_t *mode_context);
// check a list of motion vectors by sad score using a number rows of pixels
// above and a number cols of pixels in the left to select the one with best
......
......@@ -529,8 +529,13 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi,
aom_internal_error(xd->error_info, AOM_CODEC_UNSUP_BITSTREAM,
"Reference frame has invalid dimensions");
av1_setup_pre_planes(xd, ref, ref_buf->buf, mi_row, mi_col, &ref_buf->sf);
av1_find_mv_refs(cm, xd, mi, frame, ref_mvs[frame], mi_row, mi_col,
fpm_sync, (void *)pbi, inter_mode_ctx);
av1_find_mv_refs(cm, xd, mi, frame,
#if CONFIG_REF_MV
&xd->ref_mv_count[frame],
xd->ref_mv_stack[frame],
#endif
ref_mvs[frame], mi_row, mi_col,
fpm_sync, (void *)pbi, inter_mode_ctx);
}
if (segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) {
......
......@@ -14,6 +14,9 @@
#include "av1/common/entropymv.h"
#include "av1/common/entropy.h"
#if CONFIG_REF_MV
#include "av1/common/mvref_common.h"
#endif
#ifdef __cplusplus
extern "C" {
......@@ -51,6 +54,10 @@ typedef unsigned int av1_coeff_cost[PLANE_TYPES][REF_TYPES][COEF_BANDS][2]
typedef struct {
int_mv ref_mvs[MAX_REF_FRAMES][MAX_MV_REF_CANDIDATES];
uint8_t mode_context[MAX_REF_FRAMES];
#if CONFIG_REF_MV
uint8_t ref_mv_count[MAX_REF_FRAMES];
CANDIDATE_MV ref_mv_stack[MAX_REF_FRAMES][MAX_REF_MV_STACK_SIZE];
#endif
} MB_MODE_INFO_EXT;
typedef struct macroblock MACROBLOCK;
......
......@@ -2094,8 +2094,13 @@ static void setup_buffer_inter(AV1_COMP *cpi, MACROBLOCK *x,
av1_setup_pred_block(xd, yv12_mb[ref_frame], yv12, mi_row, mi_col, sf, sf);
// Gets an initial list of candidate vectors from neighbours and orders them
av1_find_mv_refs(cm, xd, mi, ref_frame, candidates, mi_row, mi_col, NULL,
NULL, mbmi_ext->mode_context);
av1_find_mv_refs(cm, xd, mi, ref_frame,
#if CONFIG_REF_MV
&mbmi_ext->ref_mv_count[ref_frame],
mbmi_ext->ref_mv_stack[ref_frame],
#endif
candidates, mi_row, mi_col, NULL,
NULL, mbmi_ext->mode_context);
// Candidate refinement carried out at encoder and decoder
av1_find_best_ref_mvs(cm->allow_high_precision_mv, candidates,
......
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