Removed the reset of mode_info from previous frame

Prior to this commit, both encoder and decoder reset mode/mv info from
previous frame in error resilient mode to ensure bitstreams are able to
decode when there is loss of frame in decoder side. However, this is
not necessary. This commit changed to remove the reset, so encoder can
continue to use mode/mv/partition information from previously encoded
frame without affecting decodeablilty under loss of frame.

Change-Id: I0279f862900dc647fb471ae3389770bb1b9f454f
This commit is contained in:
Yaowu Xu 2014-02-12 11:04:58 -08:00
parent 279dbb9a30
commit 896d79a57e
6 changed files with 24 additions and 10 deletions

View File

@ -465,8 +465,10 @@ void vp9_setup_past_independence(VP9_COMMON *cm) {
cm->frame_contexts[cm->frame_context_idx] = cm->fc;
}
vpx_memset(cm->prev_mip, 0,
cm->mode_info_stride * (cm->mi_rows + 1) * sizeof(MODE_INFO));
if (frame_is_intra_only(cm))
vpx_memset(cm->prev_mip, 0,
cm->mode_info_stride * (cm->mi_rows + 1) * sizeof(MODE_INFO));
vpx_memset(cm->mip, 0,
cm->mode_info_stride * (cm->mi_rows + 1) * sizeof(MODE_INFO));

View File

@ -196,7 +196,8 @@ void vp9_find_mv_refs_idx(const VP9_COMMON *cm, const MACROBLOCKD *xd,
const int *ref_sign_bias = cm->ref_frame_sign_bias;
int i, refmv_count = 0;
const POSITION *const mv_ref_search = mv_ref_blocks[mi->mbmi.sb_type];
const MB_MODE_INFO *const prev_mbmi = prev_mi ? &prev_mi->mbmi : NULL;
const MB_MODE_INFO *const prev_mbmi = cm->coding_use_prev_mi && prev_mi ?
&prev_mi->mbmi : NULL;
int different_ref_found = 0;
int context_counter = 0;

View File

@ -224,6 +224,11 @@ typedef struct VP9Common {
int error_resilient_mode;
int frame_parallel_decoding_mode;
// Flag indicates if prev_mi can be used in coding:
// 0: encoder assumes decoder does not have prev_mi
// 1: encoder assumes decoder has and uses prev_mi
unsigned int coding_use_prev_mi;
int log2_tile_cols, log2_tile_rows;
// Private data associated with the frame buffer callbacks.
@ -302,7 +307,6 @@ static INLINE void set_mi_row_col(MACROBLOCKD *xd, const TileInfo *const tile,
static void set_prev_mi(VP9_COMMON *cm) {
const int use_prev_in_find_mv_refs = cm->width == cm->last_width &&
cm->height == cm->last_height &&
!cm->error_resilient_mode &&
!cm->intra_only &&
cm->last_show_frame;
// Special case: set prev_mi to NULL when the previous mode info

View File

@ -350,9 +350,9 @@ static void set_offsets(VP9_COMMON *const cm, MACROBLOCKD *const xd,
xd->mi_8x8 = cm->mi_grid_visible + offset;
xd->prev_mi_8x8 = cm->prev_mi_grid_visible + offset;
// Special case: if prev_mi is NULL, the previous mode info context
// cannot be used.
xd->last_mi = cm->prev_mi ? xd->prev_mi_8x8[0] : NULL;
xd->last_mi = cm->coding_use_prev_mi && cm->prev_mi ?
xd->prev_mi_8x8[0] : NULL;
xd->mi_8x8[0] = xd->mi_stream + offset - tile_offset;
xd->mi_8x8[0]->mbmi.sb_type = bsize;
@ -1203,9 +1203,11 @@ static size_t read_uncompressed_header(VP9D_COMP *pbi,
}
if (!cm->error_resilient_mode) {
cm->coding_use_prev_mi = 1;
cm->refresh_frame_context = vp9_rb_read_bit(rb);
cm->frame_parallel_decoding_mode = vp9_rb_read_bit(rb);
} else {
cm->coding_use_prev_mi = 0;
cm->refresh_frame_context = 0;
cm->frame_parallel_decoding_mode = 1;
}
@ -1373,7 +1375,10 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
alloc_tile_storage(pbi, tile_rows, tile_cols);
xd->mode_info_stride = cm->mode_info_stride;
set_prev_mi(cm);
if (cm->coding_use_prev_mi)
set_prev_mi(cm);
else
cm->prev_mi = NULL;
setup_plane_dequants(cm, xd, cm->base_qindex);
vp9_setup_block_planes(xd, cm->subsampling_x, cm->subsampling_y);

View File

@ -555,8 +555,6 @@ static void set_offsets(VP9_COMP *cpi, const TileInfo *const tile,
xd->mi_8x8 = cm->mi_grid_visible + idx_str;
xd->prev_mi_8x8 = cm->prev_mi_grid_visible + idx_str;
// Special case: if prev_mi is NULL, the previous mode info context
// cannot be used.
xd->last_mi = cm->prev_mi ? xd->prev_mi_8x8[0] : NULL;
xd->mi_8x8[0] = cm->mi + idx_str;

View File

@ -3153,7 +3153,11 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
cm->error_resilient_mode = (cpi->oxcf.error_resilient_mode != 0);
cm->frame_parallel_decoding_mode =
(cpi->oxcf.frame_parallel_decoding_mode != 0);
// By default, encoder assumes decoder can use prev_mi.
cm->coding_use_prev_mi = 1;
if (cm->error_resilient_mode) {
cm->coding_use_prev_mi = 0;
cm->frame_parallel_decoding_mode = 1;
cm->reset_frame_context = 0;
cm->refresh_frame_context = 0;