Commit fa589adc authored by Adrian Grange's avatar Adrian Grange
Browse files

Added save coding context & modified MV bounds

Added code to save the coding context in vp8_rd_pick_inter_mode
when the coding mode is forced to ARF(0,0).

Also, modified the MV bounds computation to comply with the
change in MV border from 32 to 64 pixels.

Change-Id: I96963a6f5f4d04ce84c807ae11e0635177c3ad6c
parent 636b2f38
......@@ -559,12 +559,12 @@ static void pick_mb_modes (VP8_COMP *cpi,
// Set up limit values for MV components to prevent them from
// extending beyond the UMV borders assuming 16x16 block size
x->mv_row_min = -((mb_row * 16) + (VP8BORDERINPIXELS - 16));
x->mv_col_min = -((mb_col * 16) + (VP8BORDERINPIXELS - 16));
x->mv_row_max = ((cm->mb_rows - 1 - mb_row) * 16)
+ (VP8BORDERINPIXELS - 16);
x->mv_col_max = ((cm->mb_cols - 1 - mb_col) * 16)
+ (VP8BORDERINPIXELS - 16);
x->mv_row_min = -((mb_row * 16) + VP8BORDERINPIXELS - INTERP_EXTEND);
x->mv_col_min = -((mb_col * 16) + VP8BORDERINPIXELS - INTERP_EXTEND);
x->mv_row_max = ((cm->mb_rows - mb_row) * 16 +
(VP8BORDERINPIXELS - 16 - INTERP_EXTEND));
x->mv_col_max = ((cm->mb_cols - mb_col) * 16 +
(VP8BORDERINPIXELS - 16 - INTERP_EXTEND));
xd->up_available = (mb_row != 0);
xd->left_available = (mb_col != 0);
......@@ -756,22 +756,22 @@ static void encode_sb ( VP8_COMP *cpi,
// Set up limit values for MV components to prevent them from
// extending beyond the UMV borders assuming 16x16 block size
x->mv_row_min = -((mb_row * 16) + (VP8BORDERINPIXELS - 16));
x->mv_col_min = -((mb_col * 16) + (VP8BORDERINPIXELS - 16));
x->mv_row_max = ((cm->mb_rows - 1 - mb_row) * 16)
+ (VP8BORDERINPIXELS - 16);
x->mv_col_max = ((cm->mb_cols - 1 - mb_col) * 16)
+ (VP8BORDERINPIXELS - 16);
x->mv_row_min = -((mb_row * 16) + VP8BORDERINPIXELS - INTERP_EXTEND);
x->mv_col_min = -((mb_col * 16) + VP8BORDERINPIXELS - INTERP_EXTEND);
x->mv_row_max = ((cm->mb_rows - mb_row) * 16 +
(VP8BORDERINPIXELS - 16 - INTERP_EXTEND));
x->mv_col_max = ((cm->mb_cols - mb_col) * 16 +
(VP8BORDERINPIXELS - 16 - INTERP_EXTEND));
#if CONFIG_SUPERBLOCKS
// Set up limit values for MV components to prevent them from
// extending beyond the UMV borders assuming 32x32 block size
x->mv_row_min_sb = -((mb_row * 16) + (VP8BORDERINPIXELS - 16));
x->mv_row_max_sb = ((cm->mb_rows - 1 - mb_row) * 16)
+ (VP8BORDERINPIXELS - 32);
x->mv_col_min_sb = -((mb_col * 16) + (VP8BORDERINPIXELS - 16));
x->mv_col_max_sb = ((cm->mb_cols - 1 - mb_col) * 16)
+ (VP8BORDERINPIXELS - 32);
x->mv_row_min_sb = -((mb_row * 16) + VP8BORDERINPIXELS - INTERP_EXTEND);
x->mv_col_min_sb = -((mb_col * 16) + VP8BORDERINPIXELS - INTERP_EXTEND);
x->mv_row_max_sb = ((cm->mb_rows - mb_row) * 16 +
(VP8BORDERINPIXELS - 32 - INTERP_EXTEND));
x->mv_col_max_sb = ((cm->mb_cols - mb_col) * 16 +
(VP8BORDERINPIXELS - 32 - INTERP_EXTEND));
#endif
xd->up_available = (mb_row != 0);
......
......@@ -2532,6 +2532,26 @@ void vp8_estimate_ref_frame_costs(VP8_COMP *cpi, unsigned int * ref_costs )
}
}
static void store_coding_context (MACROBLOCK *x, int mb_index,
int mode_index,
PARTITION_INFO *partition,
int_mv *ref_mv)
{
MACROBLOCKD *xd = &x->e_mbd;
// Take a snapshot of the coding context so it can be
// restored if we decide to encode this way
x->mb_context[mb_index].best_mode_index = mode_index;
vpx_memcpy(&x->mb_context[mb_index].mic, xd->mode_info_context,
sizeof(MODE_INFO));
vpx_memcpy(&x->mb_context[mb_index].partition_info, partition,
sizeof(PARTITION_INFO));
x->mb_context[mb_index].best_ref_mv.as_int = ref_mv->as_int;
//x->mb_context[mb_index].rddiv = x->rddiv;
//x->mb_context[mb_index].rdmult = x->rdmult;
}
void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int recon_uvoffset,
int *returnrate, int *returndistortion, int *returnintra,
int *best_single_rd_diff, int *best_comp_rd_diff,
......@@ -3536,6 +3556,8 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
*best_single_rd_diff = *best_comp_rd_diff = *best_hybrid_rd_diff = 0;
store_coding_context (x, mb_index, best_mode_index, &best_partition,
&frame_best_ref_mv[xd->mode_info_context->mbmi.ref_frame] );
return;
}
......@@ -3580,18 +3602,8 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
else
*best_hybrid_rd_diff = best_rd - best_hybrid_rd;
// Take a snapshot of the coding context so it can be
// restored if we decide to encode this way
x->mb_context[mb_index].best_mode_index = best_mode_index;
vpx_memcpy(&x->mb_context[mb_index].mic, x->e_mbd.mode_info_context,
sizeof(MODE_INFO));
vpx_memcpy(&x->mb_context[mb_index].partition_info, &best_partition,
sizeof(PARTITION_INFO));
vpx_memcpy(&x->mb_context[mb_index].best_ref_mv,
&frame_best_ref_mv[xd->mode_info_context->mbmi.ref_frame],
sizeof(int_mv));
//x->mb_context[mb_index].rddiv = x->rddiv;
//x->mb_context[mb_index].rdmult = x->rdmult;
store_coding_context (x, mb_index, best_mode_index, &best_partition,
&frame_best_ref_mv[xd->mode_info_context->mbmi.ref_frame] );
}
int vp8_rd_pick_intra_mode(VP8_COMP *cpi, MACROBLOCK *x)
......
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