Merge pick_sb_modes and pick_sb64_modes.
Change-Id: Iad69e7a3b7e470acf6094f6a52e7da69066fd552
This commit is contained in:
parent
38d7945345
commit
605ff051f7
@ -822,62 +822,25 @@ static int pick_mb_modes(VP9_COMP *cpi,
|
||||
return splitmodes_used;
|
||||
}
|
||||
|
||||
static void pick_sb_modes(VP9_COMP *cpi,
|
||||
int mb_row,
|
||||
int mb_col,
|
||||
TOKENEXTRA **tp,
|
||||
int *totalrate,
|
||||
int *totaldist) {
|
||||
static void pick_sb_modes(VP9_COMP *cpi, int mb_row, int mb_col,
|
||||
TOKENEXTRA **tp, int *totalrate, int *totaldist,
|
||||
BLOCK_SIZE_TYPE bsize, PICK_MODE_CONTEXT *ctx) {
|
||||
VP9_COMMON *const cm = &cpi->common;
|
||||
MACROBLOCK *const x = &cpi->mb;
|
||||
MACROBLOCKD *const xd = &x->e_mbd;
|
||||
|
||||
set_offsets(cpi, mb_row, mb_col, BLOCK_SIZE_SB32X32);
|
||||
xd->mode_info_context->mbmi.sb_type = BLOCK_SIZE_SB32X32;
|
||||
set_offsets(cpi, mb_row, mb_col, bsize);
|
||||
xd->mode_info_context->mbmi.sb_type = bsize;
|
||||
if (cpi->oxcf.tuning == VP8_TUNE_SSIM)
|
||||
vp9_activity_masking(cpi, x);
|
||||
|
||||
/* Find best coding mode & reconstruct the MB so it is available
|
||||
* as a predictor for MBs that follow in the SB */
|
||||
if (cm->frame_type == KEY_FRAME) {
|
||||
vp9_rd_pick_intra_mode_sb(cpi, x, totalrate, totaldist,
|
||||
BLOCK_SIZE_SB32X32);
|
||||
|
||||
/* Save the coding context */
|
||||
vpx_memcpy(&x->sb32_context[xd->sb_index].mic, xd->mode_info_context,
|
||||
sizeof(MODE_INFO));
|
||||
vp9_rd_pick_intra_mode_sb(cpi, x, totalrate, totaldist, bsize, ctx);
|
||||
} else {
|
||||
vp9_rd_pick_inter_mode_sb(cpi, x, mb_row, mb_col, totalrate, totaldist,
|
||||
BLOCK_SIZE_SB32X32);
|
||||
}
|
||||
}
|
||||
|
||||
static void pick_sb64_modes(VP9_COMP *cpi,
|
||||
int mb_row,
|
||||
int mb_col,
|
||||
TOKENEXTRA **tp,
|
||||
int *totalrate,
|
||||
int *totaldist) {
|
||||
VP9_COMMON *const cm = &cpi->common;
|
||||
MACROBLOCK *const x = &cpi->mb;
|
||||
MACROBLOCKD *const xd = &x->e_mbd;
|
||||
|
||||
set_offsets(cpi, mb_row, mb_col, BLOCK_SIZE_SB64X64);
|
||||
xd->mode_info_context->mbmi.sb_type = BLOCK_SIZE_SB64X64;
|
||||
if (cpi->oxcf.tuning == VP8_TUNE_SSIM)
|
||||
vp9_activity_masking(cpi, x);
|
||||
|
||||
/* Find best coding mode & reconstruct the MB so it is available
|
||||
* as a predictor for MBs that follow in the SB */
|
||||
if (cm->frame_type == KEY_FRAME) {
|
||||
vp9_rd_pick_intra_mode_sb(cpi, x, totalrate, totaldist,
|
||||
BLOCK_SIZE_SB64X64);
|
||||
|
||||
/* Save the coding context */
|
||||
vpx_memcpy(&x->sb64_context.mic, xd->mode_info_context, sizeof(MODE_INFO));
|
||||
} else {
|
||||
vp9_rd_pick_inter_mode_sb(cpi, x, mb_row, mb_col, totalrate, totaldist,
|
||||
BLOCK_SIZE_SB64X64);
|
||||
bsize, ctx);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1101,7 +1064,8 @@ static void encode_sb_row(VP9_COMP *cpi,
|
||||
mb_row + y_idx + 1 >= cm->mb_rows)) {
|
||||
/* Pick a mode assuming that it applies to all 4 of the MBs in the SB */
|
||||
pick_sb_modes(cpi, mb_row + y_idx, mb_col + x_idx,
|
||||
tp, &sb_rate, &sb_dist);
|
||||
tp, &sb_rate, &sb_dist, BLOCK_SIZE_SB32X32,
|
||||
&x->sb32_context[xd->sb_index]);
|
||||
sb_rate += vp9_cost_bit(cm->prob_sb32_coded, 1);
|
||||
}
|
||||
|
||||
@ -1138,7 +1102,8 @@ static void encode_sb_row(VP9_COMP *cpi,
|
||||
|
||||
if (!sb64_skip && !(mb_col + 3 >= cm->mb_cols ||
|
||||
mb_row + 3 >= cm->mb_rows)) {
|
||||
pick_sb64_modes(cpi, mb_row, mb_col, tp, &sb64_rate, &sb64_dist);
|
||||
pick_sb_modes(cpi, mb_row, mb_col, tp, &sb64_rate, &sb64_dist,
|
||||
BLOCK_SIZE_SB64X64, &x->sb64_context);
|
||||
sb64_rate += vp9_cost_bit(cm->prob_sb64_coded, 1);
|
||||
}
|
||||
|
||||
|
@ -4261,7 +4261,8 @@ end:
|
||||
|
||||
void vp9_rd_pick_intra_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
|
||||
int *returnrate, int *returndist,
|
||||
BLOCK_SIZE_TYPE bsize) {
|
||||
BLOCK_SIZE_TYPE bsize,
|
||||
PICK_MODE_CONTEXT *ctx) {
|
||||
VP9_COMMON *cm = &cpi->common;
|
||||
MACROBLOCKD *xd = &x->e_mbd;
|
||||
int rate_y = 0, rate_uv;
|
||||
@ -4281,26 +4282,19 @@ void vp9_rd_pick_intra_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
|
||||
*returnrate = rate_y + rate_uv - rate_y_tokenonly - rate_uv_tokenonly +
|
||||
vp9_cost_bit(vp9_get_pred_prob(cm, xd, PRED_MBSKIP), 1);
|
||||
*returndist = dist_y + (dist_uv >> 2);
|
||||
if (bsize == BLOCK_SIZE_SB32X32) {
|
||||
memset(x->sb32_context[xd->sb_index].txfm_rd_diff, 0,
|
||||
sizeof(x->sb32_context[xd->sb_index].txfm_rd_diff));
|
||||
} else {
|
||||
memset(x->sb64_context.txfm_rd_diff, 0,
|
||||
sizeof(x->sb64_context.txfm_rd_diff));
|
||||
}
|
||||
memset(ctx->txfm_rd_diff, 0,
|
||||
sizeof(x->sb32_context[xd->sb_index].txfm_rd_diff));
|
||||
} else {
|
||||
*returnrate = rate_y + rate_uv;
|
||||
if (cpi->common.mb_no_coeff_skip)
|
||||
*returnrate += vp9_cost_bit(vp9_get_pred_prob(cm, xd, PRED_MBSKIP), 0);
|
||||
*returndist = dist_y + (dist_uv >> 2);
|
||||
for (i = 0; i < NB_TXFM_MODES; i++) {
|
||||
if (bsize == BLOCK_SIZE_SB32X32) {
|
||||
x->sb32_context[xd->sb_index].txfm_rd_diff[i] = err - txfm_cache[i];
|
||||
} else {
|
||||
x->sb64_context.txfm_rd_diff[i] = err - txfm_cache[i];
|
||||
}
|
||||
ctx->txfm_rd_diff[i] = err - txfm_cache[i];
|
||||
}
|
||||
}
|
||||
|
||||
vpx_memcpy(&ctx->mic, xd->mode_info_context, sizeof(MODE_INFO));
|
||||
}
|
||||
|
||||
void vp9_rd_pick_intra_mode(VP9_COMP *cpi, MACROBLOCK *x,
|
||||
@ -4435,7 +4429,8 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
|
||||
int mb_row, int mb_col,
|
||||
int *returnrate,
|
||||
int *returndistortion,
|
||||
BLOCK_SIZE_TYPE bsize) {
|
||||
BLOCK_SIZE_TYPE bsize,
|
||||
PICK_MODE_CONTEXT *ctx) {
|
||||
const int block_size = (bsize == BLOCK_SIZE_SB64X64) ?
|
||||
BLOCK_64X64 : BLOCK_32X32;
|
||||
VP9_COMMON *cm = &cpi->common;
|
||||
@ -4940,16 +4935,11 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
|
||||
end:
|
||||
set_scale_factors(xd, mbmi->ref_frame, mbmi->second_ref_frame,
|
||||
scale_factor);
|
||||
{
|
||||
PICK_MODE_CONTEXT *p = (block_size == BLOCK_32X32) ?
|
||||
&x->sb32_context[xd->sb_index] :
|
||||
&x->sb64_context;
|
||||
store_coding_context(x, p, best_mode_index, NULL,
|
||||
&mbmi->ref_mvs[mbmi->ref_frame][0],
|
||||
&mbmi->ref_mvs[mbmi->second_ref_frame < 0 ? 0 :
|
||||
mbmi->second_ref_frame][0],
|
||||
best_pred_diff, best_txfm_diff);
|
||||
}
|
||||
store_coding_context(x, ctx, best_mode_index, NULL,
|
||||
&mbmi->ref_mvs[mbmi->ref_frame][0],
|
||||
&mbmi->ref_mvs[mbmi->second_ref_frame < 0 ? 0 :
|
||||
mbmi->second_ref_frame][0],
|
||||
best_pred_diff, best_txfm_diff);
|
||||
|
||||
return best_rd;
|
||||
}
|
||||
|
@ -23,7 +23,8 @@ void vp9_rd_pick_intra_mode(VP9_COMP *cpi, MACROBLOCK *x,
|
||||
int *r, int *d);
|
||||
|
||||
void vp9_rd_pick_intra_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
|
||||
int *r, int *d, BLOCK_SIZE_TYPE bsize);
|
||||
int *r, int *d, BLOCK_SIZE_TYPE bsize,
|
||||
PICK_MODE_CONTEXT *ctx);
|
||||
|
||||
void vp9_pick_mode_inter_macroblock(VP9_COMP *cpi, MACROBLOCK *x,
|
||||
int mb_row, int mb_col,
|
||||
@ -31,7 +32,8 @@ void vp9_pick_mode_inter_macroblock(VP9_COMP *cpi, MACROBLOCK *x,
|
||||
|
||||
int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
|
||||
int mb_row, int mb_col,
|
||||
int *r, int *d, BLOCK_SIZE_TYPE bsize);
|
||||
int *r, int *d, BLOCK_SIZE_TYPE bsize,
|
||||
PICK_MODE_CONTEXT *ctx);
|
||||
|
||||
void vp9_init_me_luts();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user