summaryrefslogtreecommitdiff
path: root/vp8
diff options
context:
space:
mode:
authorJerome Jiang <jianj@google.com>2017-07-19 13:02:53 -0700
committerJerome Jiang <jianj@google.com>2017-07-26 14:44:36 -0700
commit56d95b77f558c57ca3b04f727d51b2c70cce1503 (patch)
tree1d4fa48c82d002e73f15d62b1bce81fe022c1a13 /vp8
parent59e461db1faabb7601548c2b4d78e43dd681c72a (diff)
downloadlibvpx-56d95b77f558c57ca3b04f727d51b2c70cce1503.tar
libvpx-56d95b77f558c57ca3b04f727d51b2c70cce1503.tar.gz
libvpx-56d95b77f558c57ca3b04f727d51b2c70cce1503.tar.bz2
libvpx-56d95b77f558c57ca3b04f727d51b2c70cce1503.zip
vp8: Remove isolated skin & non skin blocks.
Neutral on RTC metrics and speed on Pixel. Change-Id: I26b907483fe133e6e4c1009d147631f0d0e0f2fb
Diffstat (limited to 'vp8')
-rw-r--r--vp8/encoder/onyx_if.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/vp8/encoder/onyx_if.c b/vp8/encoder/onyx_if.c
index b018ca61e..2b7f6795b 100644
--- a/vp8/encoder/onyx_if.c
+++ b/vp8/encoder/onyx_if.c
@@ -628,16 +628,15 @@ static void compute_skin_map(VP8_COMP *cpi) {
const SKIN_DETECTION_BLOCK_SIZE bsize =
(cm->Width * cm->Height <= 352 * 288) ? SKIN_8X8 : SKIN_16X16;
- int offset = 0;
+
for (mb_row = 0; mb_row < cm->mb_rows; mb_row++) {
num_bl = 0;
for (mb_col = 0; mb_col < cm->mb_cols; mb_col++) {
const int bl_index = mb_row * cm->mb_cols + mb_col;
- cpi->skin_map[offset] =
+ cpi->skin_map[bl_index] =
vp8_compute_skin_block(src_y, src_u, src_v, src_ystride, src_uvstride,
bsize, cpi->consec_zero_last[bl_index], 0);
num_bl++;
- offset++;
src_y += 16;
src_u += 8;
src_v += 8;
@@ -646,6 +645,29 @@ static void compute_skin_map(VP8_COMP *cpi) {
src_u += (src_uvstride << 3) - (num_bl << 3);
src_v += (src_uvstride << 3) - (num_bl << 3);
}
+
+ // Remove isolated skin blocks (none of its neighbors are skin) and isolated
+ // non-skin blocks (all of its neighbors are skin). Skip the boundary.
+ for (mb_row = 1; mb_row < cm->mb_rows - 1; mb_row++) {
+ for (mb_col = 1; mb_col < cm->mb_cols - 1; mb_col++) {
+ const int bl_index = mb_row * cm->mb_cols + mb_col;
+ int num_neighbor = 0;
+ int mi, mj;
+ int non_skin_threshold = 8;
+
+ for (mi = -1; mi <= 1; mi += 1) {
+ for (mj = -1; mj <= 1; mj += 1) {
+ int bl_neighbor_index = (mb_row + mi) * cm->mb_cols + mb_col + mj;
+ if (cpi->skin_map[bl_neighbor_index]) num_neighbor++;
+ }
+ }
+
+ if (cpi->skin_map[bl_index] && num_neighbor < 2)
+ cpi->skin_map[bl_index] = 0;
+ if (!cpi->skin_map[bl_index] && num_neighbor == non_skin_threshold)
+ cpi->skin_map[bl_index] = 1;
+ }
+ }
}
static void set_default_lf_deltas(VP8_COMP *cpi) {