Commit 233e0ccc authored by Pengchong Jin's avatar Pengchong Jin

Store first pass motion vector directions

Re-organize the one-byte structure for 16x16 first pass
block. Add bits to indicate motion vector directions.

Change-Id: Id10754ba343dfc712c7fed5bcc85c67fa0bbcb89
parent a3b062c5
...@@ -2087,10 +2087,10 @@ static void rd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile, ...@@ -2087,10 +2087,10 @@ static void rd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile,
for (r = mb_row; r < mb_row_end; r++) { for (r = mb_row; r < mb_row_end; r++) {
for (c = mb_col; c < mb_col_end; c++) { for (c = mb_col; c < mb_col_end; c++) {
const int mb_index = r * cm->mb_cols + c; const int mb_index = r * cm->mb_cols + c;
if ((cpi->twopass.this_frame_mb_stats[mb_index] & if (!(cpi->twopass.this_frame_mb_stats[mb_index] &
FPMB_NONZERO_MOTION_MASK) || FPMB_MOTION_ZERO_MASK) ||
!(cpi->twopass.this_frame_mb_stats[mb_index] & !(cpi->twopass.this_frame_mb_stats[mb_index] &
FPMB_ERROR_LEVEL0_MASK)) { FPMB_ERROR_SMALL_MASK)) {
skip = 0; skip = 0;
break; break;
} }
......
...@@ -709,18 +709,11 @@ void vp9_first_pass(VP9_COMP *cpi) { ...@@ -709,18 +709,11 @@ void vp9_first_pass(VP9_COMP *cpi) {
// intra predication statistics // intra predication statistics
cpi->twopass.frame_mb_stats_buf[mb_index] = 0; cpi->twopass.frame_mb_stats_buf[mb_index] = 0;
cpi->twopass.frame_mb_stats_buf[mb_index] |= FPMB_DCINTRA_MASK; cpi->twopass.frame_mb_stats_buf[mb_index] |= FPMB_DCINTRA_MASK;
cpi->twopass.frame_mb_stats_buf[mb_index] &= cpi->twopass.frame_mb_stats_buf[mb_index] |= FPMB_MOTION_ZERO_MASK;
~FPMB_NONZERO_MOTION_MASK; if (this_error > FPMB_ERROR_LARGE_TH) {
if (this_error > FPMB_ERROR_LEVEL4_TH) { cpi->twopass.frame_mb_stats_buf[mb_index] |= FPMB_ERROR_LARGE_MASK;
cpi->twopass.frame_mb_stats_buf[mb_index] |= FPMB_ERROR_LEVEL4_MASK; } else if (this_error < FPMB_ERROR_SMALL_TH) {
} else if (this_error > FPMB_ERROR_LEVEL3_TH) { cpi->twopass.frame_mb_stats_buf[mb_index] |= FPMB_ERROR_SMALL_MASK;
cpi->twopass.frame_mb_stats_buf[mb_index] |= FPMB_ERROR_LEVEL3_MASK;
} else if (this_error > FPMB_ERROR_LEVEL2_TH) {
cpi->twopass.frame_mb_stats_buf[mb_index] |= FPMB_ERROR_LEVEL2_MASK;
} else if (this_error > FPMB_ERROR_LEVEL1_TH) {
cpi->twopass.frame_mb_stats_buf[mb_index] |= FPMB_ERROR_LEVEL1_MASK;
} else {
cpi->twopass.frame_mb_stats_buf[mb_index] |= FPMB_ERROR_LEVEL0_MASK;
} }
} }
#endif #endif
...@@ -758,23 +751,13 @@ void vp9_first_pass(VP9_COMP *cpi) { ...@@ -758,23 +751,13 @@ void vp9_first_pass(VP9_COMP *cpi) {
// inter predication statistics // inter predication statistics
cpi->twopass.frame_mb_stats_buf[mb_index] = 0; cpi->twopass.frame_mb_stats_buf[mb_index] = 0;
cpi->twopass.frame_mb_stats_buf[mb_index] &= ~FPMB_DCINTRA_MASK; cpi->twopass.frame_mb_stats_buf[mb_index] &= ~FPMB_DCINTRA_MASK;
cpi->twopass.frame_mb_stats_buf[mb_index] &= cpi->twopass.frame_mb_stats_buf[mb_index] |= FPMB_MOTION_ZERO_MASK;
~FPMB_NONZERO_MOTION_MASK; if (this_error > FPMB_ERROR_LARGE_TH) {
if (this_error > FPMB_ERROR_LEVEL4_TH) {
cpi->twopass.frame_mb_stats_buf[mb_index] |=
FPMB_ERROR_LEVEL4_MASK;
} else if (this_error > FPMB_ERROR_LEVEL3_TH) {
cpi->twopass.frame_mb_stats_buf[mb_index] |=
FPMB_ERROR_LEVEL3_MASK;
} else if (this_error > FPMB_ERROR_LEVEL2_TH) {
cpi->twopass.frame_mb_stats_buf[mb_index] |= cpi->twopass.frame_mb_stats_buf[mb_index] |=
FPMB_ERROR_LEVEL2_MASK; FPMB_ERROR_LARGE_MASK;
} else if (this_error > FPMB_ERROR_LEVEL1_TH) { } else if (this_error < FPMB_ERROR_SMALL_TH) {
cpi->twopass.frame_mb_stats_buf[mb_index] |= cpi->twopass.frame_mb_stats_buf[mb_index] |=
FPMB_ERROR_LEVEL1_MASK; FPMB_ERROR_SMALL_MASK;
} else {
cpi->twopass.frame_mb_stats_buf[mb_index] |=
FPMB_ERROR_LEVEL0_MASK;
} }
} }
#endif #endif
...@@ -784,8 +767,28 @@ void vp9_first_pass(VP9_COMP *cpi) { ...@@ -784,8 +767,28 @@ void vp9_first_pass(VP9_COMP *cpi) {
#if CONFIG_FP_MB_STATS #if CONFIG_FP_MB_STATS
if (cpi->use_fp_mb_stats) { if (cpi->use_fp_mb_stats) {
cpi->twopass.frame_mb_stats_buf[mb_index] |= cpi->twopass.frame_mb_stats_buf[mb_index] &=
FPMB_NONZERO_MOTION_MASK; ~FPMB_MOTION_ZERO_MASK;
// check estimated motion direction
if (mv.as_mv.col > 0 && mv.as_mv.col >= abs(mv.as_mv.row)) {
// right direction
cpi->twopass.frame_mb_stats_buf[mb_index] |=
FPMB_MOTION_RIGHT_MASK;
} else if (mv.as_mv.row < 0 &&
abs(mv.as_mv.row) >= abs(mv.as_mv.col)) {
// up direction
cpi->twopass.frame_mb_stats_buf[mb_index] |=
FPMB_MOTION_UP_MASK;
} else if (mv.as_mv.col < 0 &&
abs(mv.as_mv.col) >= abs(mv.as_mv.row)) {
// left direction
cpi->twopass.frame_mb_stats_buf[mb_index] |=
FPMB_MOTION_LEFT_MASK;
} else {
// down direction
cpi->twopass.frame_mb_stats_buf[mb_index] |=
FPMB_MOTION_DOWN_MASK;
}
} }
#endif #endif
......
...@@ -21,17 +21,17 @@ extern "C" { ...@@ -21,17 +21,17 @@ extern "C" {
#if CONFIG_FP_MB_STATS #if CONFIG_FP_MB_STATS
#define FPMB_DCINTRA_MASK 0x01 #define FPMB_DCINTRA_MASK 0x01
#define FPMB_NONZERO_MOTION_MASK 0x02
#define FPMB_ERROR_LEVEL0_MASK 0x04 #define FPMB_MOTION_ZERO_MASK 0x02
#define FPMB_ERROR_LEVEL1_MASK 0x10 #define FPMB_MOTION_LEFT_MASK 0x04
#define FPMB_ERROR_LEVEL2_MASK 0x20 #define FPMB_MOTION_RIGHT_MASK 0x08
#define FPMB_ERROR_LEVEL3_MASK 0x40 #define FPMB_MOTION_UP_MASK 0x10
#define FPMB_ERROR_LEVEL4_MASK 0x80 #define FPMB_MOTION_DOWN_MASK 0x20
#define FPMB_ERROR_LEVEL1_TH 2000 #define FPMB_ERROR_SMALL_MASK 0x40
#define FPMB_ERROR_LEVEL2_TH 8000 #define FPMB_ERROR_LARGE_MASK 0x80
#define FPMB_ERROR_LEVEL3_TH 24000 #define FPMB_ERROR_SMALL_TH 2000
#define FPMB_ERROR_LEVEL4_TH 48000 #define FPMB_ERROR_LARGE_TH 48000
typedef struct { typedef struct {
uint8_t *mb_stats_start; uint8_t *mb_stats_start;
......
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