Commit 7ad40117 authored by Dmitry Kovalev's avatar Dmitry Kovalev
Browse files

Reusing {above, left}_seg_context vars in both encoder and decoder.

Change-Id: Id1fa36c92cb007b73a450cc8552e810cedad38b9
parent 8e9c9f11
...@@ -108,6 +108,9 @@ void vp9_free_frame_buffers(VP9_COMMON *cm) { ...@@ -108,6 +108,9 @@ void vp9_free_frame_buffers(VP9_COMMON *cm) {
vpx_free(cm->last_frame_seg_map); vpx_free(cm->last_frame_seg_map);
cm->last_frame_seg_map = NULL; cm->last_frame_seg_map = NULL;
vpx_free(cm->above_seg_context);
cm->above_seg_context = NULL;
} }
int vp9_resize_frame_buffers(VP9_COMMON *cm, int width, int height) { int vp9_resize_frame_buffers(VP9_COMMON *cm, int width, int height) {
...@@ -134,6 +137,13 @@ int vp9_resize_frame_buffers(VP9_COMMON *cm, int width, int height) { ...@@ -134,6 +137,13 @@ int vp9_resize_frame_buffers(VP9_COMMON *cm, int width, int height) {
if (!cm->last_frame_seg_map) if (!cm->last_frame_seg_map)
goto fail; goto fail;
vpx_free(cm->above_seg_context);
cm->above_seg_context =
(PARTITION_CONTEXT *)vpx_calloc(mi_cols_aligned_to_sb(cm->mi_cols),
sizeof(*cm->above_seg_context));
if (!cm->above_seg_context)
goto fail;
return 0; return 0;
fail: fail:
...@@ -182,6 +192,13 @@ int vp9_alloc_frame_buffers(VP9_COMMON *cm, int width, int height) { ...@@ -182,6 +192,13 @@ int vp9_alloc_frame_buffers(VP9_COMMON *cm, int width, int height) {
if (!cm->last_frame_seg_map) if (!cm->last_frame_seg_map)
goto fail; goto fail;
cm->above_seg_context =
(PARTITION_CONTEXT *)vpx_calloc(mi_cols_aligned_to_sb(cm->mi_cols),
sizeof(*cm->above_seg_context));
if (!cm->above_seg_context)
goto fail;
return 0; return 0;
fail: fail:
......
...@@ -202,6 +202,8 @@ typedef struct VP9Common { ...@@ -202,6 +202,8 @@ typedef struct VP9Common {
// Handles memory for the codec. // Handles memory for the codec.
InternalFrameBufferList int_frame_buffers; InternalFrameBufferList int_frame_buffers;
PARTITION_CONTEXT *above_seg_context;
} VP9_COMMON; } VP9_COMMON;
static INLINE YV12_BUFFER_CONFIG *get_frame_new_buffer(VP9_COMMON *cm) { static INLINE YV12_BUFFER_CONFIG *get_frame_new_buffer(VP9_COMMON *cm) {
......
...@@ -206,13 +206,6 @@ static void alloc_tile_storage(VP9D_COMP *pbi, int tile_rows, int tile_cols) { ...@@ -206,13 +206,6 @@ static void alloc_tile_storage(VP9D_COMP *pbi, int tile_rows, int tile_cols) {
i * sizeof(*pbi->above_context[0]) * i * sizeof(*pbi->above_context[0]) *
2 * aligned_mi_cols; 2 * aligned_mi_cols;
} }
// This is sized based on the entire frame. Each tile operates within its
// column bounds.
CHECK_MEM_ERROR(cm, pbi->above_seg_context,
vpx_realloc(pbi->above_seg_context,
sizeof(*pbi->above_seg_context) *
aligned_mi_cols));
} }
static void inverse_transform_block(MACROBLOCKD* xd, int plane, int block, static void inverse_transform_block(MACROBLOCKD* xd, int plane, int block,
...@@ -722,7 +715,7 @@ static void setup_tile_context(VP9D_COMP *const pbi, MACROBLOCKD *const xd, ...@@ -722,7 +715,7 @@ static void setup_tile_context(VP9D_COMP *const pbi, MACROBLOCKD *const xd,
xd->above_context[i] = pbi->above_context[i]; xd->above_context[i] = pbi->above_context[i];
// see note in alloc_tile_storage(). // see note in alloc_tile_storage().
xd->above_seg_context = pbi->above_seg_context; xd->above_seg_context = pbi->common.above_seg_context;
} }
static void decode_tile(VP9D_COMP *pbi, const TileInfo *const tile, static void decode_tile(VP9D_COMP *pbi, const TileInfo *const tile,
...@@ -850,8 +843,8 @@ static const uint8_t *decode_tiles(VP9D_COMP *pbi, const uint8_t *data) { ...@@ -850,8 +843,8 @@ static const uint8_t *decode_tiles(VP9D_COMP *pbi, const uint8_t *data) {
vpx_memset(pbi->above_context[0], 0, vpx_memset(pbi->above_context[0], 0,
sizeof(*pbi->above_context[0]) * MAX_MB_PLANE * 2 * aligned_cols); sizeof(*pbi->above_context[0]) * MAX_MB_PLANE * 2 * aligned_cols);
vpx_memset(pbi->above_seg_context, 0, vpx_memset(cm->above_seg_context, 0,
sizeof(*pbi->above_seg_context) * aligned_cols); sizeof(*cm->above_seg_context) * aligned_cols);
// Load tile data into tile_buffers // Load tile data into tile_buffers
for (tile_row = 0; tile_row < tile_rows; ++tile_row) { for (tile_row = 0; tile_row < tile_rows; ++tile_row) {
...@@ -977,8 +970,8 @@ static const uint8_t *decode_tiles_mt(VP9D_COMP *pbi, const uint8_t *data) { ...@@ -977,8 +970,8 @@ static const uint8_t *decode_tiles_mt(VP9D_COMP *pbi, const uint8_t *data) {
vpx_memset(pbi->above_context[0], 0, vpx_memset(pbi->above_context[0], 0,
sizeof(*pbi->above_context[0]) * MAX_MB_PLANE * sizeof(*pbi->above_context[0]) * MAX_MB_PLANE *
2 * aligned_mi_cols); 2 * aligned_mi_cols);
vpx_memset(pbi->above_seg_context, 0, vpx_memset(cm->above_seg_context, 0,
sizeof(*pbi->above_seg_context) * aligned_mi_cols); sizeof(*cm->above_seg_context) * aligned_mi_cols);
// Load tile data into tile_buffers // Load tile data into tile_buffers
for (n = 0; n < tile_cols; ++n) { for (n = 0; n < tile_cols; ++n) {
......
...@@ -190,7 +190,7 @@ void vp9_remove_decompressor(VP9D_COMP *pbi) { ...@@ -190,7 +190,7 @@ void vp9_remove_decompressor(VP9D_COMP *pbi) {
} }
vpx_free(pbi->above_context[0]); vpx_free(pbi->above_context[0]);
vpx_free(pbi->above_seg_context); vpx_free(pbi->common.above_seg_context);
vpx_free(pbi); vpx_free(pbi);
} }
......
...@@ -74,7 +74,6 @@ typedef struct VP9Decompressor { ...@@ -74,7 +74,6 @@ typedef struct VP9Decompressor {
VP9LfSync lf_row_sync; VP9LfSync lf_row_sync;
ENTROPY_CONTEXT *above_context[MAX_MB_PLANE]; ENTROPY_CONTEXT *above_context[MAX_MB_PLANE];
PARTITION_CONTEXT *above_seg_context;
} VP9D_COMP; } VP9D_COMP;
void vp9_initialize_dec(); void vp9_initialize_dec();
......
...@@ -392,11 +392,11 @@ static void write_modes_b(VP9_COMP *cpi, const TileInfo *const tile, ...@@ -392,11 +392,11 @@ static void write_modes_b(VP9_COMP *cpi, const TileInfo *const tile,
pack_mb_tokens(w, tok, tok_end); pack_mb_tokens(w, tok, tok_end);
} }
static void write_partition(VP9_COMP *cpi, int hbs, int mi_row, int mi_col, static void write_partition(VP9_COMMON *cm, MACROBLOCKD *xd,
int hbs, int mi_row, int mi_col,
PARTITION_TYPE p, BLOCK_SIZE bsize, vp9_writer *w) { PARTITION_TYPE p, BLOCK_SIZE bsize, vp9_writer *w) {
VP9_COMMON *const cm = &cpi->common; const int ctx = partition_plane_context(xd->above_seg_context,
const int ctx = partition_plane_context(cpi->above_seg_context, xd->left_seg_context,
cpi->left_seg_context,
mi_row, mi_col, bsize); mi_row, mi_col, bsize);
const vp9_prob *const probs = get_partition_probs(cm, ctx); const vp9_prob *const probs = get_partition_probs(cm, ctx);
const int has_rows = (mi_row + hbs) < cm->mi_rows; const int has_rows = (mi_row + hbs) < cm->mi_rows;
...@@ -415,10 +415,13 @@ static void write_partition(VP9_COMP *cpi, int hbs, int mi_row, int mi_col, ...@@ -415,10 +415,13 @@ static void write_partition(VP9_COMP *cpi, int hbs, int mi_row, int mi_col,
} }
} }
static void write_modes_sb(VP9_COMP *cpi, const TileInfo *const tile, static void write_modes_sb(VP9_COMP *cpi,
const TileInfo *const tile,
vp9_writer *w, TOKENEXTRA **tok, TOKENEXTRA *tok_end, vp9_writer *w, TOKENEXTRA **tok, TOKENEXTRA *tok_end,
int mi_row, int mi_col, BLOCK_SIZE bsize) { int mi_row, int mi_col, BLOCK_SIZE bsize) {
VP9_COMMON *const cm = &cpi->common; VP9_COMMON *const cm = &cpi->common;
MACROBLOCKD *const xd = &cpi->mb.e_mbd;
const int bsl = b_width_log2(bsize); const int bsl = b_width_log2(bsize);
const int bs = (1 << bsl) / 4; const int bs = (1 << bsl) / 4;
PARTITION_TYPE partition; PARTITION_TYPE partition;
...@@ -429,7 +432,7 @@ static void write_modes_sb(VP9_COMP *cpi, const TileInfo *const tile, ...@@ -429,7 +432,7 @@ static void write_modes_sb(VP9_COMP *cpi, const TileInfo *const tile,
return; return;
partition = partition_lookup[bsl][m->mbmi.sb_type]; partition = partition_lookup[bsl][m->mbmi.sb_type];
write_partition(cpi, bs, mi_row, mi_col, partition, bsize, w); write_partition(cm, xd, bs, mi_row, mi_col, partition, bsize, w);
subsize = get_subsize(bsize, partition); subsize = get_subsize(bsize, partition);
if (subsize < BLOCK_8X8) { if (subsize < BLOCK_8X8) {
write_modes_b(cpi, tile, w, tok, tok_end, mi_row, mi_col); write_modes_b(cpi, tile, w, tok, tok_end, mi_row, mi_col);
...@@ -465,20 +468,22 @@ static void write_modes_sb(VP9_COMP *cpi, const TileInfo *const tile, ...@@ -465,20 +468,22 @@ static void write_modes_sb(VP9_COMP *cpi, const TileInfo *const tile,
// update partition context // update partition context
if (bsize >= BLOCK_8X8 && if (bsize >= BLOCK_8X8 &&
(bsize == BLOCK_8X8 || partition != PARTITION_SPLIT)) (bsize == BLOCK_8X8 || partition != PARTITION_SPLIT))
update_partition_context(cpi->above_seg_context, cpi->left_seg_context, update_partition_context(xd->above_seg_context, xd->left_seg_context,
mi_row, mi_col, subsize, bsize); mi_row, mi_col, subsize, bsize);
} }
static void write_modes(VP9_COMP *cpi, const TileInfo *const tile, static void write_modes(VP9_COMP *cpi,
const TileInfo *const tile,
vp9_writer *w, TOKENEXTRA **tok, TOKENEXTRA *tok_end) { vp9_writer *w, TOKENEXTRA **tok, TOKENEXTRA *tok_end) {
int mi_row, mi_col; int mi_row, mi_col;
for (mi_row = tile->mi_row_start; mi_row < tile->mi_row_end; for (mi_row = tile->mi_row_start; mi_row < tile->mi_row_end;
mi_row += MI_BLOCK_SIZE) { mi_row += MI_BLOCK_SIZE) {
vp9_zero(cpi->left_seg_context); vp9_zero(cpi->mb.e_mbd.left_seg_context);
for (mi_col = tile->mi_col_start; mi_col < tile->mi_col_end; for (mi_col = tile->mi_col_start; mi_col < tile->mi_col_end;
mi_col += MI_BLOCK_SIZE) mi_col += MI_BLOCK_SIZE)
write_modes_sb(cpi, tile, w, tok, tok_end, mi_row, mi_col, BLOCK_64X64); write_modes_sb(cpi, tile, w, tok, tok_end, mi_row, mi_col,
BLOCK_64X64);
} }
} }
...@@ -930,7 +935,7 @@ static size_t encode_tiles(VP9_COMP *cpi, uint8_t *data_ptr) { ...@@ -930,7 +935,7 @@ static size_t encode_tiles(VP9_COMP *cpi, uint8_t *data_ptr) {
const int tile_cols = 1 << cm->log2_tile_cols; const int tile_cols = 1 << cm->log2_tile_cols;
const int tile_rows = 1 << cm->log2_tile_rows; const int tile_rows = 1 << cm->log2_tile_rows;
vpx_memset(cpi->above_seg_context, 0, sizeof(*cpi->above_seg_context) * vpx_memset(cm->above_seg_context, 0, sizeof(*cm->above_seg_context) *
mi_cols_aligned_to_sb(cm->mi_cols)); mi_cols_aligned_to_sb(cm->mi_cols));
tok[0][0] = cpi->tok; tok[0][0] = cpi->tok;
......
...@@ -1217,10 +1217,10 @@ static void restore_context(VP9_COMP *cpi, int mi_row, int mi_col, ...@@ -1217,10 +1217,10 @@ static void restore_context(VP9_COMP *cpi, int mi_row, int mi_col,
(sizeof(ENTROPY_CONTEXT) * num_4x4_blocks_high) >> (sizeof(ENTROPY_CONTEXT) * num_4x4_blocks_high) >>
xd->plane[p].subsampling_y); xd->plane[p].subsampling_y);
} }
vpx_memcpy(cpi->above_seg_context + mi_col, sa, vpx_memcpy(xd->above_seg_context + mi_col, sa,
sizeof(*cpi->above_seg_context) * mi_width); sizeof(*xd->above_seg_context) * mi_width);
vpx_memcpy(cpi->left_seg_context + (mi_row & MI_MASK), sl, vpx_memcpy(xd->left_seg_context + (mi_row & MI_MASK), sl,
sizeof(cpi->left_seg_context[0]) * mi_height); sizeof(xd->left_seg_context[0]) * mi_height);
} }
static void save_context(VP9_COMP *cpi, int mi_row, int mi_col, static void save_context(VP9_COMP *cpi, int mi_row, int mi_col,
ENTROPY_CONTEXT a[16 * MAX_MB_PLANE], ENTROPY_CONTEXT a[16 * MAX_MB_PLANE],
...@@ -1249,10 +1249,10 @@ static void save_context(VP9_COMP *cpi, int mi_row, int mi_col, ...@@ -1249,10 +1249,10 @@ static void save_context(VP9_COMP *cpi, int mi_row, int mi_col,
(sizeof(ENTROPY_CONTEXT) * num_4x4_blocks_high) >> (sizeof(ENTROPY_CONTEXT) * num_4x4_blocks_high) >>
xd->plane[p].subsampling_y); xd->plane[p].subsampling_y);
} }
vpx_memcpy(sa, cpi->above_seg_context + mi_col, vpx_memcpy(sa, xd->above_seg_context + mi_col,
sizeof(*cpi->above_seg_context) * mi_width); sizeof(*xd->above_seg_context) * mi_width);
vpx_memcpy(sl, cpi->left_seg_context + (mi_row & MI_MASK), vpx_memcpy(sl, xd->left_seg_context + (mi_row & MI_MASK),
sizeof(cpi->left_seg_context[0]) * mi_height); sizeof(xd->left_seg_context[0]) * mi_height);
} }
static void encode_b(VP9_COMP *cpi, const TileInfo *const tile, static void encode_b(VP9_COMP *cpi, const TileInfo *const tile,
...@@ -1284,6 +1284,8 @@ static void encode_sb(VP9_COMP *cpi, const TileInfo *const tile, ...@@ -1284,6 +1284,8 @@ static void encode_sb(VP9_COMP *cpi, const TileInfo *const tile,
int output_enabled, BLOCK_SIZE bsize) { int output_enabled, BLOCK_SIZE bsize) {
VP9_COMMON *const cm = &cpi->common; VP9_COMMON *const cm = &cpi->common;
MACROBLOCK *const x = &cpi->mb; MACROBLOCK *const x = &cpi->mb;
MACROBLOCKD *const xd = &x->e_mbd;
const int bsl = b_width_log2(bsize), hbs = (1 << bsl) / 4; const int bsl = b_width_log2(bsize), hbs = (1 << bsl) / 4;
int ctx; int ctx;
PARTITION_TYPE partition; PARTITION_TYPE partition;
...@@ -1293,7 +1295,7 @@ static void encode_sb(VP9_COMP *cpi, const TileInfo *const tile, ...@@ -1293,7 +1295,7 @@ static void encode_sb(VP9_COMP *cpi, const TileInfo *const tile,
return; return;
if (bsize >= BLOCK_8X8) { if (bsize >= BLOCK_8X8) {
ctx = partition_plane_context(cpi->above_seg_context, cpi->left_seg_context, ctx = partition_plane_context(xd->above_seg_context, xd->left_seg_context,
mi_row, mi_col, bsize); mi_row, mi_col, bsize);
subsize = *get_sb_partitioning(x, bsize); subsize = *get_sb_partitioning(x, bsize);
} else { } else {
...@@ -1349,7 +1351,7 @@ static void encode_sb(VP9_COMP *cpi, const TileInfo *const tile, ...@@ -1349,7 +1351,7 @@ static void encode_sb(VP9_COMP *cpi, const TileInfo *const tile,
} }
if (partition != PARTITION_SPLIT || bsize == BLOCK_8X8) if (partition != PARTITION_SPLIT || bsize == BLOCK_8X8)
update_partition_context(cpi->above_seg_context, cpi->left_seg_context, update_partition_context(xd->above_seg_context, xd->left_seg_context,
mi_row, mi_col, subsize, bsize); mi_row, mi_col, subsize, bsize);
} }
...@@ -1510,6 +1512,8 @@ static void encode_sb_rt(VP9_COMP *cpi, const TileInfo *const tile, ...@@ -1510,6 +1512,8 @@ static void encode_sb_rt(VP9_COMP *cpi, const TileInfo *const tile,
int output_enabled, BLOCK_SIZE bsize) { int output_enabled, BLOCK_SIZE bsize) {
VP9_COMMON *const cm = &cpi->common; VP9_COMMON *const cm = &cpi->common;
MACROBLOCK *const x = &cpi->mb; MACROBLOCK *const x = &cpi->mb;
MACROBLOCKD *const xd = &x->e_mbd;
const int bsl = b_width_log2(bsize), hbs = (1 << bsl) / 4; const int bsl = b_width_log2(bsize), hbs = (1 << bsl) / 4;
int ctx; int ctx;
PARTITION_TYPE partition; PARTITION_TYPE partition;
...@@ -1522,7 +1526,7 @@ static void encode_sb_rt(VP9_COMP *cpi, const TileInfo *const tile, ...@@ -1522,7 +1526,7 @@ static void encode_sb_rt(VP9_COMP *cpi, const TileInfo *const tile,
MACROBLOCKD *const xd = &cpi->mb.e_mbd; MACROBLOCKD *const xd = &cpi->mb.e_mbd;
const int idx_str = xd->mode_info_stride * mi_row + mi_col; const int idx_str = xd->mode_info_stride * mi_row + mi_col;
MODE_INFO ** mi_8x8 = cm->mi_grid_visible + idx_str; MODE_INFO ** mi_8x8 = cm->mi_grid_visible + idx_str;
ctx = partition_plane_context(cpi->above_seg_context, cpi->left_seg_context, ctx = partition_plane_context(xd->above_seg_context, xd->left_seg_context,
mi_row, mi_col, bsize); mi_row, mi_col, bsize);
subsize = mi_8x8[0]->mbmi.sb_type; subsize = mi_8x8[0]->mbmi.sb_type;
} else { } else {
...@@ -1582,7 +1586,7 @@ static void encode_sb_rt(VP9_COMP *cpi, const TileInfo *const tile, ...@@ -1582,7 +1586,7 @@ static void encode_sb_rt(VP9_COMP *cpi, const TileInfo *const tile,
} }
if (partition != PARTITION_SPLIT || bsize == BLOCK_8X8) if (partition != PARTITION_SPLIT || bsize == BLOCK_8X8)
update_partition_context(cpi->above_seg_context, cpi->left_seg_context, update_partition_context(xd->above_seg_context, xd->left_seg_context,
mi_row, mi_col, subsize, bsize); mi_row, mi_col, subsize, bsize);
} }
...@@ -1594,6 +1598,7 @@ static void rd_use_partition(VP9_COMP *cpi, ...@@ -1594,6 +1598,7 @@ static void rd_use_partition(VP9_COMP *cpi,
int do_recon) { int do_recon) {
VP9_COMMON *const cm = &cpi->common; VP9_COMMON *const cm = &cpi->common;
MACROBLOCK *const x = &cpi->mb; MACROBLOCK *const x = &cpi->mb;
MACROBLOCKD *const xd = &x->e_mbd;
const int mis = cm->mode_info_stride; const int mis = cm->mode_info_stride;
const int bsl = b_width_log2(bsize); const int bsl = b_width_log2(bsize);
const int num_4x4_blocks_wide = num_4x4_blocks_wide_lookup[bsize]; const int num_4x4_blocks_wide = num_4x4_blocks_wide_lookup[bsize];
...@@ -1667,8 +1672,8 @@ static void rd_use_partition(VP9_COMP *cpi, ...@@ -1667,8 +1672,8 @@ static void rd_use_partition(VP9_COMP *cpi,
rd_pick_sb_modes(cpi, tile, mi_row, mi_col, &none_rate, &none_dist, bsize, rd_pick_sb_modes(cpi, tile, mi_row, mi_col, &none_rate, &none_dist, bsize,
get_block_context(x, bsize), INT64_MAX); get_block_context(x, bsize), INT64_MAX);
pl = partition_plane_context(cpi->above_seg_context, pl = partition_plane_context(xd->above_seg_context,
cpi->left_seg_context, xd->left_seg_context,
mi_row, mi_col, bsize); mi_row, mi_col, bsize);
if (none_rate < INT_MAX) { if (none_rate < INT_MAX) {
...@@ -1769,7 +1774,7 @@ static void rd_use_partition(VP9_COMP *cpi, ...@@ -1769,7 +1774,7 @@ static void rd_use_partition(VP9_COMP *cpi,
assert(0); assert(0);
} }
pl = partition_plane_context(cpi->above_seg_context, cpi->left_seg_context, pl = partition_plane_context(xd->above_seg_context, xd->left_seg_context,
mi_row, mi_col, bsize); mi_row, mi_col, bsize);
if (last_part_rate < INT_MAX) { if (last_part_rate < INT_MAX) {
last_part_rate += x->partition_cost[pl][partition]; last_part_rate += x->partition_cost[pl][partition];
...@@ -1823,13 +1828,13 @@ static void rd_use_partition(VP9_COMP *cpi, ...@@ -1823,13 +1828,13 @@ static void rd_use_partition(VP9_COMP *cpi,
encode_sb(cpi, tile, tp, mi_row + y_idx, mi_col + x_idx, 0, encode_sb(cpi, tile, tp, mi_row + y_idx, mi_col + x_idx, 0,
split_subsize); split_subsize);
pl = partition_plane_context(cpi->above_seg_context, pl = partition_plane_context(xd->above_seg_context,
cpi->left_seg_context, xd->left_seg_context,
mi_row + y_idx, mi_col + x_idx, mi_row + y_idx, mi_col + x_idx,
split_subsize); split_subsize);
chosen_rate += x->partition_cost[pl][PARTITION_NONE]; chosen_rate += x->partition_cost[pl][PARTITION_NONE];
} }
pl = partition_plane_context(cpi->above_seg_context, cpi->left_seg_context, pl = partition_plane_context(xd->above_seg_context, xd->left_seg_context,
mi_row, mi_col, bsize); mi_row, mi_col, bsize);
if (chosen_rate < INT_MAX) { if (chosen_rate < INT_MAX) {
chosen_rate += x->partition_cost[pl][PARTITION_SPLIT]; chosen_rate += x->partition_cost[pl][PARTITION_SPLIT];
...@@ -2029,6 +2034,7 @@ static void rd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile, ...@@ -2029,6 +2034,7 @@ static void rd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile,
int64_t *dist, int do_recon, int64_t best_rd) { int64_t *dist, int do_recon, int64_t best_rd) {
VP9_COMMON *const cm = &cpi->common; VP9_COMMON *const cm = &cpi->common;
MACROBLOCK *const x = &cpi->mb; MACROBLOCK *const x = &cpi->mb;
MACROBLOCKD *const xd = &x->e_mbd;
const int ms = num_8x8_blocks_wide_lookup[bsize] / 2; const int ms = num_8x8_blocks_wide_lookup[bsize] / 2;
ENTROPY_CONTEXT l[16 * MAX_MB_PLANE], a[16 * MAX_MB_PLANE]; ENTROPY_CONTEXT l[16 * MAX_MB_PLANE], a[16 * MAX_MB_PLANE];
PARTITION_CONTEXT sl[8], sa[8]; PARTITION_CONTEXT sl[8], sa[8];
...@@ -2110,8 +2116,8 @@ static void rd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile, ...@@ -2110,8 +2116,8 @@ static void rd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile,
ctx, best_rd); ctx, best_rd);
if (this_rate != INT_MAX) { if (this_rate != INT_MAX) {
if (bsize >= BLOCK_8X8) { if (bsize >= BLOCK_8X8) {
pl = partition_plane_context(cpi->above_seg_context, pl = partition_plane_context(xd->above_seg_context,
cpi->left_seg_context, xd->left_seg_context,
mi_row, mi_col, bsize); mi_row, mi_col, bsize);
this_rate += x->partition_cost[pl][PARTITION_NONE]; this_rate += x->partition_cost[pl][PARTITION_NONE];
} }
...@@ -2182,8 +2188,8 @@ static void rd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile, ...@@ -2182,8 +2188,8 @@ static void rd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile,
} }
} }
if (sum_rd < best_rd && i == 4) { if (sum_rd < best_rd && i == 4) {
pl = partition_plane_context(cpi->above_seg_context, pl = partition_plane_context(xd->above_seg_context,
cpi->left_seg_context, xd->left_seg_context,
mi_row, mi_col, bsize); mi_row, mi_col, bsize);
sum_rate += x->partition_cost[pl][PARTITION_SPLIT]; sum_rate += x->partition_cost[pl][PARTITION_SPLIT];
sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist); sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist);
...@@ -2240,8 +2246,8 @@ static void rd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile, ...@@ -2240,8 +2246,8 @@ static void rd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile,
} }
} }
if (sum_rd < best_rd) { if (sum_rd < best_rd) {
pl = partition_plane_context(cpi->above_seg_context, pl = partition_plane_context(xd->above_seg_context,
cpi->left_seg_context, xd->left_seg_context,
mi_row, mi_col, bsize); mi_row, mi_col, bsize);
sum_rate += x->partition_cost[pl][PARTITION_HORZ]; sum_rate += x->partition_cost[pl][PARTITION_HORZ];
sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist); sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist);
...@@ -2293,8 +2299,8 @@ static void rd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile, ...@@ -2293,8 +2299,8 @@ static void rd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile,
} }
} }
if (sum_rd < best_rd) { if (sum_rd < best_rd) {
pl = partition_plane_context(cpi->above_seg_context, pl = partition_plane_context(xd->above_seg_context,
cpi->left_seg_context, xd->left_seg_context,
mi_row, mi_col, bsize); mi_row, mi_col, bsize);
sum_rate += x->partition_cost[pl][PARTITION_VERT]; sum_rate += x->partition_cost[pl][PARTITION_VERT];
sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist); sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist);
...@@ -2344,11 +2350,12 @@ static void rd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile, ...@@ -2344,11 +2350,12 @@ static void rd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile,
static void encode_rd_sb_row(VP9_COMP *cpi, const TileInfo *const tile, static void encode_rd_sb_row(VP9_COMP *cpi, const TileInfo *const tile,
int mi_row, TOKENEXTRA **tp) { int mi_row, TOKENEXTRA **tp) {
VP9_COMMON *const cm = &cpi->common; VP9_COMMON *const cm = &cpi->common;
MACROBLOCKD *const xd = &cpi->mb.e_mbd;
int mi_col; int mi_col;
// Initialize the left context for the new SB row // Initialize the left context for the new SB row
vpx_memset(&cpi->left_context, 0, sizeof(cpi->left_context)); vpx_memset(&cpi->left_context, 0, sizeof(cpi->left_context));
vpx_memset(cpi->left_seg_context, 0, sizeof(cpi->left_seg_context)); vpx_memset(xd->left_seg_context, 0, sizeof(xd->left_seg_context));
// Code each SB in the row // Code each SB in the row
for (mi_col = tile->mi_col_start; mi_col < tile->mi_col_end; for (mi_col = tile->mi_col_start; mi_col < tile->mi_col_end;
...@@ -2477,8 +2484,8 @@ static void init_encode_frame_mb_context(VP9_COMP *cpi) { ...@@ -2477,8 +2484,8 @@ static void init_encode_frame_mb_context(VP9_COMP *cpi) {
vpx_memset(cpi->above_context[0], 0, vpx_memset(cpi->above_context[0], 0,
sizeof(*cpi->above_context[0]) * sizeof(*cpi->above_context[0]) *
2 * aligned_mi_cols * MAX_MB_PLANE); 2 * aligned_mi_cols * MAX_MB_PLANE);
vpx_memset(cpi->above_seg_context, 0, vpx_memset(xd->above_seg_context, 0,
sizeof(*cpi->above_seg_context) * aligned_mi_cols); sizeof(*xd->above_seg_context) * aligned_mi_cols);
} }
static void switch_lossless_mode(VP9_COMP *cpi, int lossless) { static void switch_lossless_mode(VP9_COMP *cpi, int lossless) {
...@@ -2801,11 +2808,12 @@ static void nonrd_use_partition(VP9_COMP *cpi, ...@@ -2801,11 +2808,12 @@ static void nonrd_use_partition(VP9_COMP *cpi,
static void encode_nonrd_sb_row(VP9_COMP *cpi, const TileInfo *const tile, static void encode_nonrd_sb_row(VP9_COMP *cpi, const TileInfo *const tile,
int mi_row, TOKENEXTRA **tp) { int mi_row, TOKENEXTRA **tp) {
VP9_COMMON *cm = &cpi->common; VP9_COMMON *cm = &cpi->common;
MACROBLOCKD *xd = &cpi->mb.e_mbd;
int mi_col; int mi_col;
// Initialize the left context for the new SB row // Initialize the left context for the new SB row
vpx_memset(&cpi->left_context, 0, sizeof(cpi->left_context)); vpx_memset(&cpi->left_context, 0, sizeof(cpi->left_context));
vpx_memset(cpi->left_seg_context, 0, sizeof(cpi->left_seg_context)); vpx_memset(xd->left_seg_context, 0, sizeof(xd->left_seg_context));
// Code each SB in the row // Code each SB in the row
for (mi_col = tile->mi_col_start; mi_col < tile->mi_col_end; for (mi_col = tile->mi_col_start; mi_col < tile->mi_col_end;
......
...@@ -197,9 +197,6 @@ static void dealloc_compressor_data(VP9_COMP *cpi) { ...@@ -197,9 +197,6 @@ static void dealloc_compressor_data(VP9_COMP *cpi) {
vpx_free(cpi->above_context[0]); vpx_free(cpi->above_context[0]);
cpi->above_context[0] = NULL; cpi->above_context[0] = NULL;
vpx_free(cpi->above_seg_context);