Moving above_context to VP9_COMMON.
Change-Id: I713af99d1e17e05a20eab20df51d74ebfd1a68d2
This commit is contained in:
parent
c4e807ae2f
commit
ed39c40a2e
@ -108,6 +108,9 @@ void vp9_free_frame_buffers(VP9_COMMON *cm) {
|
||||
vpx_free(cm->last_frame_seg_map);
|
||||
cm->last_frame_seg_map = NULL;
|
||||
|
||||
vpx_free(cm->above_context);
|
||||
cm->above_context = NULL;
|
||||
|
||||
vpx_free(cm->above_seg_context);
|
||||
cm->above_seg_context = NULL;
|
||||
}
|
||||
@ -136,6 +139,14 @@ int vp9_resize_frame_buffers(VP9_COMMON *cm, int width, int height) {
|
||||
if (!cm->last_frame_seg_map)
|
||||
goto fail;
|
||||
|
||||
vpx_free(cm->above_context);
|
||||
cm->above_context =
|
||||
(ENTROPY_CONTEXT *)vpx_calloc(2 * mi_cols_aligned_to_sb(cm->mi_cols) *
|
||||
MAX_MB_PLANE,
|
||||
sizeof(*cm->above_context));
|
||||
if (!cm->above_context)
|
||||
goto fail;
|
||||
|
||||
vpx_free(cm->above_seg_context);
|
||||
cm->above_seg_context =
|
||||
(PARTITION_CONTEXT *)vpx_calloc(mi_cols_aligned_to_sb(cm->mi_cols),
|
||||
@ -151,12 +162,11 @@ int vp9_resize_frame_buffers(VP9_COMMON *cm, int width, int height) {
|
||||
}
|
||||
|
||||
int vp9_alloc_frame_buffers(VP9_COMMON *cm, int width, int height) {
|
||||
int i;
|
||||
|
||||
const int aligned_width = ALIGN_POWER_OF_TWO(width, MI_SIZE_LOG2);
|
||||
const int aligned_height = ALIGN_POWER_OF_TWO(height, MI_SIZE_LOG2);
|
||||
const int ss_x = cm->subsampling_x;
|
||||
const int ss_y = cm->subsampling_y;
|
||||
int i;
|
||||
|
||||
vp9_free_frame_buffers(cm);
|
||||
|
||||
@ -191,6 +201,12 @@ int vp9_alloc_frame_buffers(VP9_COMMON *cm, int width, int height) {
|
||||
if (!cm->last_frame_seg_map)
|
||||
goto fail;
|
||||
|
||||
cm->above_context =
|
||||
(ENTROPY_CONTEXT *)vpx_calloc(2 * mi_cols_aligned_to_sb(cm->mi_cols) *
|
||||
MAX_MB_PLANE,
|
||||
sizeof(*cm->above_context));
|
||||
if (!cm->above_context)
|
||||
goto fail;
|
||||
|
||||
cm->above_seg_context =
|
||||
(PARTITION_CONTEXT *)vpx_calloc(mi_cols_aligned_to_sb(cm->mi_cols),
|
||||
|
@ -204,6 +204,7 @@ typedef struct VP9Common {
|
||||
InternalFrameBufferList int_frame_buffers;
|
||||
|
||||
PARTITION_CONTEXT *above_seg_context;
|
||||
ENTROPY_CONTEXT *above_context;
|
||||
} VP9_COMMON;
|
||||
|
||||
static INLINE YV12_BUFFER_CONFIG *get_frame_new_buffer(VP9_COMMON *cm) {
|
||||
|
@ -187,27 +187,6 @@ static void setup_plane_dequants(VP9_COMMON *cm, MACROBLOCKD *xd, int q_index) {
|
||||
xd->plane[i].dequant = cm->uv_dequant[q_index];
|
||||
}
|
||||
|
||||
// Allocate storage for each tile column.
|
||||
// TODO(jzern): when max_threads <= 1 the same storage could be used for each
|
||||
// tile.
|
||||
static void alloc_tile_storage(VP9D_COMP *pbi, int tile_rows, int tile_cols) {
|
||||
VP9_COMMON *const cm = &pbi->common;
|
||||
const int aligned_mi_cols = mi_cols_aligned_to_sb(cm->mi_cols);
|
||||
int i;
|
||||
|
||||
// 2 contexts per 'mi unit', so that we have one context per 4x4 txfm
|
||||
// block where mi unit size is 8x8.
|
||||
CHECK_MEM_ERROR(cm, pbi->above_context[0],
|
||||
vpx_realloc(pbi->above_context[0],
|
||||
sizeof(*pbi->above_context[0]) * MAX_MB_PLANE *
|
||||
2 * aligned_mi_cols));
|
||||
for (i = 1; i < MAX_MB_PLANE; ++i) {
|
||||
pbi->above_context[i] = pbi->above_context[0] +
|
||||
i * sizeof(*pbi->above_context[0]) *
|
||||
2 * aligned_mi_cols;
|
||||
}
|
||||
}
|
||||
|
||||
static void inverse_transform_block(MACROBLOCKD* xd, int plane, int block,
|
||||
TX_SIZE tx_size, uint8_t *dst, int stride,
|
||||
int eob) {
|
||||
@ -706,13 +685,14 @@ static void setup_frame_size_with_refs(VP9D_COMP *pbi,
|
||||
|
||||
static void setup_tile_context(VP9D_COMP *const pbi, MACROBLOCKD *const xd,
|
||||
int tile_row, int tile_col) {
|
||||
VP9_COMMON *const cm = &pbi->common;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MAX_MB_PLANE; ++i)
|
||||
xd->above_context[i] = pbi->above_context[i];
|
||||
xd->above_context[i] = cm->above_context +
|
||||
i * sizeof(*cm->above_context) * 2 * mi_cols_aligned_to_sb(cm->mi_cols);
|
||||
|
||||
// see note in alloc_tile_storage().
|
||||
xd->above_seg_context = pbi->common.above_seg_context;
|
||||
xd->above_seg_context = cm->above_seg_context;
|
||||
}
|
||||
|
||||
static void decode_tile(VP9D_COMP *pbi, const TileInfo *const tile,
|
||||
@ -838,8 +818,8 @@ static const uint8_t *decode_tiles(VP9D_COMP *pbi,
|
||||
|
||||
// Note: this memset assumes above_context[0], [1] and [2]
|
||||
// are allocated as part of the same buffer.
|
||||
vpx_memset(pbi->above_context[0], 0,
|
||||
sizeof(*pbi->above_context[0]) * MAX_MB_PLANE * 2 * aligned_cols);
|
||||
vpx_memset(cm->above_context, 0,
|
||||
sizeof(*cm->above_context) * MAX_MB_PLANE * 2 * aligned_cols);
|
||||
|
||||
vpx_memset(cm->above_seg_context, 0,
|
||||
sizeof(*cm->above_seg_context) * aligned_cols);
|
||||
@ -966,9 +946,8 @@ static const uint8_t *decode_tiles_mt(VP9D_COMP *pbi,
|
||||
|
||||
// Note: this memset assumes above_context[0], [1] and [2]
|
||||
// are allocated as part of the same buffer.
|
||||
vpx_memset(pbi->above_context[0], 0,
|
||||
sizeof(*pbi->above_context[0]) * MAX_MB_PLANE *
|
||||
2 * aligned_mi_cols);
|
||||
vpx_memset(cm->above_context, 0,
|
||||
sizeof(*cm->above_context) * MAX_MB_PLANE * 2 * aligned_mi_cols);
|
||||
vpx_memset(cm->above_seg_context, 0,
|
||||
sizeof(*cm->above_seg_context) * aligned_mi_cols);
|
||||
|
||||
@ -1347,8 +1326,6 @@ int vp9_decode_frame(VP9D_COMP *pbi,
|
||||
}
|
||||
}
|
||||
|
||||
alloc_tile_storage(pbi, tile_rows, tile_cols);
|
||||
|
||||
xd->mode_info_stride = cm->mode_info_stride;
|
||||
if (cm->coding_use_prev_mi)
|
||||
set_prev_mi(cm);
|
||||
|
@ -189,7 +189,6 @@ void vp9_remove_decompressor(VP9D_COMP *pbi) {
|
||||
vp9_loop_filter_dealloc(lf_sync, sb_rows);
|
||||
}
|
||||
|
||||
vpx_free(pbi->above_context[0]);
|
||||
vpx_free(pbi->common.above_seg_context);
|
||||
vpx_free(pbi);
|
||||
}
|
||||
|
@ -61,8 +61,6 @@ typedef struct VP9Decompressor {
|
||||
int num_tile_workers;
|
||||
|
||||
VP9LfSync lf_row_sync;
|
||||
|
||||
ENTROPY_CONTEXT *above_context[MAX_MB_PLANE];
|
||||
} VP9D_COMP;
|
||||
|
||||
void vp9_initialize_dec();
|
||||
|
@ -207,7 +207,7 @@ static void set_offsets(VP9_COMP *cpi, const TileInfo *const tile,
|
||||
const int idx_map = mb_row * cm->mb_cols + mb_col;
|
||||
const struct segmentation *const seg = &cm->seg;
|
||||
|
||||
set_skip_context(xd, cpi->above_context, cpi->left_context, mi_row, mi_col);
|
||||
set_skip_context(xd, xd->above_context, xd->left_context, mi_row, mi_col);
|
||||
|
||||
// Activity map pointer
|
||||
x->mb_activity_ptr = &cpi->mb_activity_map[idx_map];
|
||||
@ -1207,12 +1207,12 @@ static void restore_context(VP9_COMP *cpi, int mi_row, int mi_col,
|
||||
int mi_height = num_8x8_blocks_high_lookup[bsize];
|
||||
for (p = 0; p < MAX_MB_PLANE; p++) {
|
||||
vpx_memcpy(
|
||||
cpi->above_context[p] + ((mi_col * 2) >> xd->plane[p].subsampling_x),
|
||||
xd->above_context[p] + ((mi_col * 2) >> xd->plane[p].subsampling_x),
|
||||
a + num_4x4_blocks_wide * p,
|
||||
(sizeof(ENTROPY_CONTEXT) * num_4x4_blocks_wide) >>
|
||||
xd->plane[p].subsampling_x);
|
||||
vpx_memcpy(
|
||||
cpi->left_context[p]
|
||||
xd->left_context[p]
|
||||
+ ((mi_row & MI_MASK) * 2 >> xd->plane[p].subsampling_y),
|
||||
l + num_4x4_blocks_high * p,
|
||||
(sizeof(ENTROPY_CONTEXT) * num_4x4_blocks_high) >>
|
||||
@ -1240,12 +1240,12 @@ static void save_context(VP9_COMP *cpi, int mi_row, int mi_col,
|
||||
for (p = 0; p < MAX_MB_PLANE; ++p) {
|
||||
vpx_memcpy(
|
||||
a + num_4x4_blocks_wide * p,
|
||||
cpi->above_context[p] + (mi_col * 2 >> xd->plane[p].subsampling_x),
|
||||
xd->above_context[p] + (mi_col * 2 >> xd->plane[p].subsampling_x),
|
||||
(sizeof(ENTROPY_CONTEXT) * num_4x4_blocks_wide) >>
|
||||
xd->plane[p].subsampling_x);
|
||||
vpx_memcpy(
|
||||
l + num_4x4_blocks_high * p,
|
||||
cpi->left_context[p]
|
||||
xd->left_context[p]
|
||||
+ ((mi_row & MI_MASK) * 2 >> xd->plane[p].subsampling_y),
|
||||
(sizeof(ENTROPY_CONTEXT) * num_4x4_blocks_high) >>
|
||||
xd->plane[p].subsampling_y);
|
||||
@ -2346,7 +2346,7 @@ static void encode_rd_sb_row(VP9_COMP *cpi, const TileInfo *const tile,
|
||||
int mi_col;
|
||||
|
||||
// Initialize the left context for the new SB row
|
||||
vpx_memset(&cpi->left_context, 0, sizeof(cpi->left_context));
|
||||
vpx_memset(&xd->left_context, 0, sizeof(xd->left_context));
|
||||
vpx_memset(xd->left_seg_context, 0, sizeof(xd->left_seg_context));
|
||||
|
||||
// Code each SB in the row
|
||||
@ -2473,8 +2473,8 @@ static void init_encode_frame_mb_context(VP9_COMP *cpi) {
|
||||
|
||||
// Note: this memset assumes above_context[0], [1] and [2]
|
||||
// are allocated as part of the same buffer.
|
||||
vpx_memset(cpi->above_context[0], 0,
|
||||
sizeof(*cpi->above_context[0]) *
|
||||
vpx_memset(xd->above_context[0], 0,
|
||||
sizeof(*xd->above_context[0]) *
|
||||
2 * aligned_mi_cols * MAX_MB_PLANE);
|
||||
vpx_memset(xd->above_seg_context, 0,
|
||||
sizeof(*xd->above_seg_context) * aligned_mi_cols);
|
||||
@ -3052,7 +3052,7 @@ static void encode_nonrd_sb_row(VP9_COMP *cpi, const TileInfo *const tile,
|
||||
int mi_col;
|
||||
|
||||
// Initialize the left context for the new SB row
|
||||
vpx_memset(&cpi->left_context, 0, sizeof(cpi->left_context));
|
||||
vpx_memset(&xd->left_context, 0, sizeof(xd->left_context));
|
||||
vpx_memset(xd->left_seg_context, 0, sizeof(xd->left_seg_context));
|
||||
|
||||
// Code each SB in the row
|
||||
|
@ -194,9 +194,6 @@ static void dealloc_compressor_data(VP9_COMP *cpi) {
|
||||
cpi->mb_activity_map = 0;
|
||||
vpx_free(cpi->mb_norm_activity_map);
|
||||
cpi->mb_norm_activity_map = 0;
|
||||
|
||||
vpx_free(cpi->above_context[0]);
|
||||
cpi->above_context[0] = NULL;
|
||||
}
|
||||
|
||||
// Computes a q delta (in "q index" terms) to get from a starting q value
|
||||
@ -1062,19 +1059,12 @@ void vp9_alloc_compressor_data(VP9_COMP *cpi) {
|
||||
CHECK_MEM_ERROR(cm, cpi->mb_norm_activity_map,
|
||||
vpx_calloc(sizeof(unsigned int),
|
||||
cm->mb_rows * cm->mb_cols));
|
||||
|
||||
// 2 contexts per 'mi unit', so that we have one context per 4x4 txfm
|
||||
// block where mi unit size is 8x8.
|
||||
vpx_free(cpi->above_context[0]);
|
||||
CHECK_MEM_ERROR(cm, cpi->above_context[0],
|
||||
vpx_calloc(2 * mi_cols_aligned_to_sb(cm->mi_cols) *
|
||||
MAX_MB_PLANE,
|
||||
sizeof(*cpi->above_context[0])));
|
||||
}
|
||||
|
||||
|
||||
static void update_frame_size(VP9_COMP *cpi) {
|
||||
VP9_COMMON *cm = &cpi->common;
|
||||
VP9_COMMON *const cm = &cpi->common;
|
||||
MACROBLOCKD *const xd = &cpi->mb.e_mbd;
|
||||
|
||||
vp9_update_frame_size(cm);
|
||||
|
||||
@ -1105,13 +1095,13 @@ static void update_frame_size(VP9_COMP *cpi) {
|
||||
|
||||
{
|
||||
int i;
|
||||
for (i = 1; i < MAX_MB_PLANE; ++i) {
|
||||
cpi->above_context[i] = cpi->above_context[0] +
|
||||
i * sizeof(*cpi->above_context[0]) * 2 *
|
||||
mi_cols_aligned_to_sb(cm->mi_cols);
|
||||
cpi->mb.e_mbd.above_seg_context = cpi->common.above_seg_context;
|
||||
}
|
||||
|
||||
for (i = 0; i < MAX_MB_PLANE; ++i)
|
||||
xd->above_context[i] = cm->above_context +
|
||||
i * sizeof(*cm->above_context) * 2 * mi_cols_aligned_to_sb(cm->mi_cols);
|
||||
}
|
||||
|
||||
xd->above_seg_context = cpi->common.above_seg_context;
|
||||
}
|
||||
|
||||
// Table that converts 0-63 Q range values passed in outside to the Qindex
|
||||
|
@ -814,10 +814,6 @@ typedef struct VP9_COMP {
|
||||
// Debug / test stats
|
||||
int64_t mode_test_hits[BLOCK_SIZES];
|
||||
#endif
|
||||
|
||||
// Y,U,V,(A)
|
||||
ENTROPY_CONTEXT *above_context[MAX_MB_PLANE];
|
||||
ENTROPY_CONTEXT left_context[MAX_MB_PLANE][16];
|
||||
} VP9_COMP;
|
||||
|
||||
void vp9_initialize_enc();
|
||||
|
Loading…
x
Reference in New Issue
Block a user