ref: 233e0ccc73eba5f52ddde366f7adae4cff55c3fd
parent: a3b062c56f237e1680e4fdae838842955fc7fdf6
author: Pengchong Jin <[email protected]>
date: Thu Jul 31 05:01:06 EDT 2014
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
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -2087,10 +2087,10 @@
for (r = mb_row; r < mb_row_end; r++) {
for (c = mb_col; c < mb_col_end; c++) {
const int mb_index = r * cm->mb_cols + c;
- if ((cpi->twopass.this_frame_mb_stats[mb_index] &
- FPMB_NONZERO_MOTION_MASK) ||
+ if (!(cpi->twopass.this_frame_mb_stats[mb_index] &
+ FPMB_MOTION_ZERO_MASK) ||
!(cpi->twopass.this_frame_mb_stats[mb_index] &
- FPMB_ERROR_LEVEL0_MASK)) {
+ FPMB_ERROR_SMALL_MASK)) {
skip = 0;
break;
}
--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -709,18 +709,11 @@
// intra predication statistics
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_NONZERO_MOTION_MASK;
- 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] |= 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;
+ cpi->twopass.frame_mb_stats_buf[mb_index] |= FPMB_MOTION_ZERO_MASK;
+ if (this_error > FPMB_ERROR_LARGE_TH) {
+ cpi->twopass.frame_mb_stats_buf[mb_index] |= FPMB_ERROR_LARGE_MASK;
+ } else if (this_error < FPMB_ERROR_SMALL_TH) {
+ cpi->twopass.frame_mb_stats_buf[mb_index] |= FPMB_ERROR_SMALL_MASK;
}
}
#endif
@@ -758,23 +751,13 @@
// inter predication statistics
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_NONZERO_MOTION_MASK;
- if (this_error > FPMB_ERROR_LEVEL4_TH) {
+ cpi->twopass.frame_mb_stats_buf[mb_index] |= FPMB_MOTION_ZERO_MASK;
+ if (this_error > FPMB_ERROR_LARGE_TH) {
cpi->twopass.frame_mb_stats_buf[mb_index] |=
- FPMB_ERROR_LEVEL4_MASK;
- } else if (this_error > FPMB_ERROR_LEVEL3_TH) {
+ FPMB_ERROR_LARGE_MASK;
+ } else if (this_error < FPMB_ERROR_SMALL_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] |=
- 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;
+ FPMB_ERROR_SMALL_MASK;
}
}
#endif
@@ -784,8 +767,28 @@
#if CONFIG_FP_MB_STATS
if (cpi->use_fp_mb_stats) {
- cpi->twopass.frame_mb_stats_buf[mb_index] |=
- FPMB_NONZERO_MOTION_MASK;
+ cpi->twopass.frame_mb_stats_buf[mb_index] &=
+ ~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
--- a/vp9/encoder/vp9_firstpass.h
+++ b/vp9/encoder/vp9_firstpass.h
@@ -21,17 +21,17 @@
#if CONFIG_FP_MB_STATS
#define FPMB_DCINTRA_MASK 0x01
-#define FPMB_NONZERO_MOTION_MASK 0x02
-#define FPMB_ERROR_LEVEL0_MASK 0x04
-#define FPMB_ERROR_LEVEL1_MASK 0x10
-#define FPMB_ERROR_LEVEL2_MASK 0x20
-#define FPMB_ERROR_LEVEL3_MASK 0x40
-#define FPMB_ERROR_LEVEL4_MASK 0x80
-#define FPMB_ERROR_LEVEL1_TH 2000
-#define FPMB_ERROR_LEVEL2_TH 8000
-#define FPMB_ERROR_LEVEL3_TH 24000
-#define FPMB_ERROR_LEVEL4_TH 48000
+#define FPMB_MOTION_ZERO_MASK 0x02
+#define FPMB_MOTION_LEFT_MASK 0x04
+#define FPMB_MOTION_RIGHT_MASK 0x08
+#define FPMB_MOTION_UP_MASK 0x10
+#define FPMB_MOTION_DOWN_MASK 0x20
+
+#define FPMB_ERROR_SMALL_MASK 0x40
+#define FPMB_ERROR_LARGE_MASK 0x80
+#define FPMB_ERROR_SMALL_TH 2000
+#define FPMB_ERROR_LARGE_TH 48000
typedef struct {
uint8_t *mb_stats_start;