Commit 19b9f72b authored by Yunqing Wang's avatar Yunqing Wang

Remove mi's offset

The frame mi has an 1 row and 1 column offset from the beginning of
the allocated memory.
cm->mi = cm->mip + cm->mi_stride + 1;
This offset can be removed. This doesn't change the bitstream.

Also, fixed 1 bug in first_pass code to update xd->mi for each block.

Change-Id: I2327aaadc62d2b00baa5a3c5135281d7fc864ed7
parent 6839682c
......@@ -1385,7 +1385,7 @@ void av1_setup_past_independence(AV1_COMMON *cm) {
// prev_mip will only be allocated in encoder.
if (frame_is_intra_only(cm) && cm->prev_mip && !cm->frame_parallel_decode)
memset(cm->prev_mip, 0,
cm->mi_stride * (cm->mi_rows + 1) * sizeof(*cm->prev_mip));
cm->mi_stride * cm->mi_rows * sizeof(*cm->prev_mip));
#if !CONFIG_NO_FRAME_CONTEXT_SIGNALING
cm->frame_context_idx = 0;
#endif // !CONFIG_NO_FRAME_CONTEXT_SIGNALING
......
......@@ -53,10 +53,10 @@ static void initialize_dec(void) {
}
static void av1_dec_setup_mi(AV1_COMMON *cm) {
cm->mi = cm->mip + cm->mi_stride + 1;
cm->mi_grid_visible = cm->mi_grid_base + cm->mi_stride + 1;
cm->mi = cm->mip;
cm->mi_grid_visible = cm->mi_grid_base;
memset(cm->mi_grid_base, 0,
cm->mi_stride * (cm->mi_rows + 1) * sizeof(*cm->mi_grid_base));
cm->mi_stride * cm->mi_rows * sizeof(*cm->mi_grid_base));
memset(cm->boundary_info, 0,
cm->boundary_info_alloc_size * sizeof(*cm->boundary_info));
......
......@@ -4519,8 +4519,7 @@ static void encode_frame_internal(AV1_COMP *cpi) {
// Special case: set prev_mi to NULL when the previous mode info
// context cannot be used.
cm->prev_mi =
cm->use_prev_frame_mvs ? cm->prev_mip + cm->mi_stride + 1 : NULL;
cm->prev_mi = cm->use_prev_frame_mvs ? cm->prev_mip : NULL;
x->txb_split_count = 0;
av1_zero(x->blk_skip_drl);
......
......@@ -389,19 +389,19 @@ static void setup_frame(AV1_COMP *cpi) {
static void enc_setup_mi(AV1_COMMON *cm) {
int i;
cm->mi = cm->mip + cm->mi_stride + 1;
memset(cm->mip, 0, cm->mi_stride * (cm->mi_rows + 1) * sizeof(*cm->mip));
cm->prev_mi = cm->prev_mip + cm->mi_stride + 1;
cm->mi = cm->mip;
memset(cm->mip, 0, cm->mi_stride * cm->mi_rows * sizeof(*cm->mip));
cm->prev_mi = cm->prev_mip;
// Clear top border row
memset(cm->prev_mip, 0, sizeof(*cm->prev_mip) * cm->mi_stride);
// Clear left border column
for (i = 1; i < cm->mi_rows + 1; ++i)
for (i = 0; i < cm->mi_rows; ++i)
memset(&cm->prev_mip[i * cm->mi_stride], 0, sizeof(*cm->prev_mip));
cm->mi_grid_visible = cm->mi_grid_base + cm->mi_stride + 1;
cm->prev_mi_grid_visible = cm->prev_mi_grid_base + cm->mi_stride + 1;
cm->mi_grid_visible = cm->mi_grid_base;
cm->prev_mi_grid_visible = cm->prev_mi_grid_base;
memset(cm->mi_grid_base, 0,
cm->mi_stride * (cm->mi_rows + 1) * sizeof(*cm->mi_grid_base));
cm->mi_stride * cm->mi_rows * sizeof(*cm->mi_grid_base));
memset(cm->boundary_info, 0,
cm->boundary_info_alloc_size * sizeof(*cm->boundary_info));
......@@ -443,13 +443,13 @@ static void swap_mi_and_prev_mi(AV1_COMMON *cm) {
cm->mip = temp;
// Update the upper left visible macroblock ptrs.
cm->mi = cm->mip + cm->mi_stride + 1;
cm->prev_mi = cm->prev_mip + cm->mi_stride + 1;
cm->mi = cm->mip;
cm->prev_mi = cm->prev_mip;
cm->prev_mi_grid_base = cm->mi_grid_base;
cm->mi_grid_base = temp_base;
cm->mi_grid_visible = cm->mi_grid_base + cm->mi_stride + 1;
cm->prev_mi_grid_visible = cm->prev_mi_grid_base + cm->mi_stride + 1;
cm->mi_grid_visible = cm->mi_grid_base;
cm->prev_mi_grid_visible = cm->prev_mi_grid_base;
}
void av1_initialize_enc(void) {
......
......@@ -617,6 +617,9 @@ void av1_first_pass(AV1_COMP *cpi, const struct lookahead_entry *source) {
aom_clear_system_state();
const int idx_str = xd->mi_stride * mb_row * mb_scale + mb_col * mb_scale;
xd->mi = cm->mi_grid_visible + idx_str;
xd->mi[0] = cm->mi + idx_str;
xd->plane[0].dst.buf = new_yv12->y_buffer + recon_yoffset;
xd->plane[1].dst.buf = new_yv12->u_buffer + recon_uvoffset;
xd->plane[2].dst.buf = new_yv12->v_buffer + recon_uvoffset;
......
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