Remove the redundant index computation in the first pass

Remove the redundant index computation when store the first
pass block-wise statistics. Currently, a single byte is
allocated for a 16x16 blocks, and all the frame statistics
saved during the first pass will be kept in memory for use
in the second pass. For a 1920x1080 300-frame clip, it will
take about 2.3 MB memory. This feature is off in current
setting.

Change-Id: I135a95b348ec093d54c6a07e1e8237626909e3bd
This commit is contained in:
Pengchong Jin 2014-07-28 16:04:36 -07:00
parent c580428928
commit 6491065775

View File

@ -553,6 +553,9 @@ void vp9_first_pass(VP9_COMP *cpi) {
const int use_dc_pred = (mb_col || mb_row) && (!mb_col || !mb_row);
double error_weight = 1.0;
const BLOCK_SIZE bsize = get_bsize(cm, mb_row, mb_col);
#if CONFIG_FP_MB_STATS
const int mb_index = mb_row * cm->mb_cols + mb_col;
#endif
vp9_clear_system_state();
@ -600,7 +603,7 @@ void vp9_first_pass(VP9_COMP *cpi) {
#if CONFIG_FP_MB_STATS
if (cpi->use_fp_mb_stats) {
// initialization
cpi->twopass.frame_mb_stats_buf[mb_row * cm->mb_cols + mb_col] = 0;
cpi->twopass.frame_mb_stats_buf[mb_index] = 0;
}
#endif
@ -704,26 +707,20 @@ void vp9_first_pass(VP9_COMP *cpi) {
#if CONFIG_FP_MB_STATS
if (cpi->use_fp_mb_stats) {
// intra predication statistics
cpi->twopass.frame_mb_stats_buf[mb_row * cm->mb_cols + mb_col] = 0;
cpi->twopass.frame_mb_stats_buf[mb_row * cm->mb_cols + mb_col] |=
FPMB_DCINTRA_MASK;
cpi->twopass.frame_mb_stats_buf[mb_row * cm->mb_cols + mb_col] &=
(~FPMB_NONZERO_MOTION_MASK);
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_row * cm->mb_cols + mb_col] |=
FPMB_ERROR_LEVEL4_MASK;
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_row * cm->mb_cols + mb_col] |=
FPMB_ERROR_LEVEL3_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_row * cm->mb_cols + mb_col] |=
FPMB_ERROR_LEVEL2_MASK;
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_row * cm->mb_cols + mb_col] |=
FPMB_ERROR_LEVEL1_MASK;
cpi->twopass.frame_mb_stats_buf[mb_index] |= FPMB_ERROR_LEVEL1_MASK;
} else {
cpi->twopass.frame_mb_stats_buf[mb_row * cm->mb_cols + mb_col] |=
FPMB_ERROR_LEVEL0_MASK;
cpi->twopass.frame_mb_stats_buf[mb_index] |= FPMB_ERROR_LEVEL0_MASK;
}
}
#endif
@ -759,25 +756,24 @@ void vp9_first_pass(VP9_COMP *cpi) {
#if CONFIG_FP_MB_STATS
if (cpi->use_fp_mb_stats) {
// inter predication statistics
cpi->twopass.frame_mb_stats_buf[mb_row * cm->mb_cols + mb_col] = 0;
cpi->twopass.frame_mb_stats_buf[mb_row * cm->mb_cols + mb_col] &=
(~FPMB_DCINTRA_MASK);
cpi->twopass.frame_mb_stats_buf[mb_row * cm->mb_cols + mb_col] &=
(~FPMB_NONZERO_MOTION_MASK);
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_row * cm->mb_cols + mb_col] |=
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_row * cm->mb_cols + mb_col] |=
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_row * cm->mb_cols + mb_col] |=
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_row * cm->mb_cols + mb_col] |=
cpi->twopass.frame_mb_stats_buf[mb_index] |=
FPMB_ERROR_LEVEL1_MASK;
} else {
cpi->twopass.frame_mb_stats_buf[mb_row * cm->mb_cols + mb_col] |=
cpi->twopass.frame_mb_stats_buf[mb_index] |=
FPMB_ERROR_LEVEL0_MASK;
}
}
@ -788,7 +784,7 @@ void vp9_first_pass(VP9_COMP *cpi) {
#if CONFIG_FP_MB_STATS
if (cpi->use_fp_mb_stats) {
cpi->twopass.frame_mb_stats_buf[mb_row * cm->mb_cols + mb_col] |=
cpi->twopass.frame_mb_stats_buf[mb_index] |=
FPMB_NONZERO_MOTION_MASK;
}
#endif