Commit 3d6b0cb8 authored by Jerome Jiang's avatar Jerome Jiang

vp9: Move skinmap computation into multithreading loop.

Change-Id: Iebc9dd293d8b1449c0674c0295349297e9b90646
parent 125a532b
...@@ -4129,6 +4129,10 @@ static void encode_nonrd_sb_row(VP9_COMP *cpi, ThreadData *td, ...@@ -4129,6 +4129,10 @@ static void encode_nonrd_sb_row(VP9_COMP *cpi, ThreadData *td,
(*(cpi->row_mt_sync_read_ptr))(&tile_data->row_mt_sync, sb_row, (*(cpi->row_mt_sync_read_ptr))(&tile_data->row_mt_sync, sb_row,
sb_col_in_tile); sb_col_in_tile);
if (cpi->use_skin_detection) {
vp9_compute_skin_sb(cpi, BLOCK_16X16, mi_row, mi_col);
}
x->source_variance = UINT_MAX; x->source_variance = UINT_MAX;
vp9_zero(x->pred_mv); vp9_zero(x->pred_mv);
vp9_rd_cost_init(&dummy_rdc); vp9_rd_cost_init(&dummy_rdc);
......
...@@ -3557,7 +3557,6 @@ static void encode_without_recode_loop(VP9_COMP *cpi, size_t *size, ...@@ -3557,7 +3557,6 @@ static void encode_without_recode_loop(VP9_COMP *cpi, size_t *size,
cpi->oxcf.content != VP9E_CONTENT_SCREEN && cpi->oxcf.content != VP9E_CONTENT_SCREEN &&
cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ) { cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ) {
cpi->use_skin_detection = 1; cpi->use_skin_detection = 1;
vp9_compute_skin_map(cpi, BLOCK_16X16);
} }
vp9_set_quantizer(cm, q); vp9_set_quantizer(cm, q);
......
...@@ -172,6 +172,7 @@ void vp9_update_noise_estimate(VP9_COMP *const cpi) { ...@@ -172,6 +172,7 @@ void vp9_update_noise_estimate(VP9_COMP *const cpi) {
int mi_row, mi_col; int mi_row, mi_col;
int num_low_motion = 0; int num_low_motion = 0;
int frame_low_motion = 1; int frame_low_motion = 1;
if (cpi->use_skin_detection) vp9_compute_skin_map(cpi, BLOCK_16X16);
for (mi_row = 0; mi_row < cm->mi_rows; mi_row++) { for (mi_row = 0; mi_row < cm->mi_rows; mi_row++) {
for (mi_col = 0; mi_col < cm->mi_cols; mi_col++) { for (mi_col = 0; mi_col < cm->mi_cols; mi_col++) {
int bl_index = mi_row * cm->mi_cols + mi_col; int bl_index = mi_row * cm->mi_cols + mi_col;
......
...@@ -37,8 +37,9 @@ int vp9_compute_skin_block(const uint8_t *y, const uint8_t *u, const uint8_t *v, ...@@ -37,8 +37,9 @@ int vp9_compute_skin_block(const uint8_t *y, const uint8_t *u, const uint8_t *v,
} }
} }
void vp9_compute_skin_map(VP9_COMP *const cpi, BLOCK_SIZE bsize) { void vp9_compute_skin_sb(VP9_COMP *const cpi, BLOCK_SIZE bsize, int mi_row,
int mi_row, mi_col, num_bl; int mi_col) {
int i, j, num_bl;
VP9_COMMON *const cm = &cpi->common; VP9_COMMON *const cm = &cpi->common;
const uint8_t *src_y = cpi->Source->y_buffer; const uint8_t *src_y = cpi->Source->y_buffer;
const uint8_t *src_u = cpi->Source->u_buffer; const uint8_t *src_u = cpi->Source->u_buffer;
...@@ -50,13 +51,17 @@ void vp9_compute_skin_map(VP9_COMP *const cpi, BLOCK_SIZE bsize) { ...@@ -50,13 +51,17 @@ void vp9_compute_skin_map(VP9_COMP *const cpi, BLOCK_SIZE bsize) {
const int shy = (y_bsize == 8) ? 3 : 4; const int shy = (y_bsize == 8) ? 3 : 4;
const int shuv = shy - 1; const int shuv = shy - 1;
const int fac = y_bsize / 8; const int fac = y_bsize / 8;
// Loop through blocks and set skin map based on center pixel of block. const int y_shift = src_ystride * (mi_row << 3) + (mi_col << 3);
// Ignore rightmost/bottom boundary blocks. const int uv_shift = src_uvstride * (mi_row << 2) + (mi_col << 2);
for (mi_row = 0; mi_row < cm->mi_rows - 1; mi_row += fac) { src_y += y_shift;
src_u += uv_shift;
src_v += uv_shift;
for (i = mi_row; i < VPXMIN(mi_row + 7, cm->mi_rows - 1); i += fac) {
num_bl = 0; num_bl = 0;
for (mi_col = 0; mi_col < cm->mi_cols - 1; mi_col += fac) { for (j = mi_col; j < VPXMIN(mi_col + 7, cm->mi_cols - 1); j += fac) {
int consec_zeromv = 0; int consec_zeromv = 0;
int bl_index = mi_row * cm->mi_cols + mi_col; int bl_index = i * cm->mi_cols + j;
int bl_index1 = bl_index + 1; int bl_index1 = bl_index + 1;
int bl_index2 = bl_index + cm->mi_cols; int bl_index2 = bl_index + cm->mi_cols;
int bl_index3 = bl_index2 + 1; int bl_index3 = bl_index2 + 1;
...@@ -67,7 +72,7 @@ void vp9_compute_skin_map(VP9_COMP *const cpi, BLOCK_SIZE bsize) { ...@@ -67,7 +72,7 @@ void vp9_compute_skin_map(VP9_COMP *const cpi, BLOCK_SIZE bsize) {
VPXMIN(cpi->consec_zero_mv[bl_index1], VPXMIN(cpi->consec_zero_mv[bl_index1],
VPXMIN(cpi->consec_zero_mv[bl_index2], VPXMIN(cpi->consec_zero_mv[bl_index2],
cpi->consec_zero_mv[bl_index3]))); cpi->consec_zero_mv[bl_index3])));
cpi->skin_map[mi_row * cm->mi_cols + mi_col] = cpi->skin_map[bl_index] =
vp9_compute_skin_block(src_y, src_u, src_v, src_ystride, src_uvstride, vp9_compute_skin_block(src_y, src_u, src_v, src_ystride, src_uvstride,
bsize, consec_zeromv, 0); bsize, consec_zeromv, 0);
num_bl++; num_bl++;
...@@ -81,6 +86,18 @@ void vp9_compute_skin_map(VP9_COMP *const cpi, BLOCK_SIZE bsize) { ...@@ -81,6 +86,18 @@ void vp9_compute_skin_map(VP9_COMP *const cpi, BLOCK_SIZE bsize) {
} }
} }
void vp9_compute_skin_map(VP9_COMP *const cpi, BLOCK_SIZE bsize) {
int mi_row, mi_col;
VP9_COMMON *const cm = &cpi->common;
// Loop through blocks and set skin map based on center pixel of block.
// Ignore rightmost/bottom boundary blocks.
for (mi_row = 0; mi_row < cm->mi_rows - 1; mi_row += MI_BLOCK_SIZE) {
for (mi_col = 0; mi_col < cm->mi_cols - 1; mi_col += MI_BLOCK_SIZE) {
vp9_compute_skin_sb(cpi, bsize, mi_row, mi_col);
}
}
}
#ifdef OUTPUT_YUV_SKINMAP #ifdef OUTPUT_YUV_SKINMAP
// For viewing skin map on input source. // For viewing skin map on input source.
void vp9_output_skin_map(VP9_COMP *const cpi, FILE *yuv_skinmap_file) { void vp9_output_skin_map(VP9_COMP *const cpi, FILE *yuv_skinmap_file) {
......
...@@ -25,6 +25,9 @@ int vp9_compute_skin_block(const uint8_t *y, const uint8_t *u, const uint8_t *v, ...@@ -25,6 +25,9 @@ int vp9_compute_skin_block(const uint8_t *y, const uint8_t *u, const uint8_t *v,
int stride, int strideuv, int bsize, int stride, int strideuv, int bsize,
int consec_zeromv, int curr_motion_magn); int consec_zeromv, int curr_motion_magn);
void vp9_compute_skin_sb(struct VP9_COMP *const cpi, BLOCK_SIZE bsize,
int mi_row, int mi_col);
void vp9_compute_skin_map(struct VP9_COMP *const cpi, BLOCK_SIZE bsize); void vp9_compute_skin_map(struct VP9_COMP *const cpi, BLOCK_SIZE bsize);
#ifdef OUTPUT_YUV_SKINMAP #ifdef OUTPUT_YUV_SKINMAP
......
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