Commit f4b79c72 authored by Hui Su's avatar Hui Su

Flatten blk_skip[]

It's only needed for luma components. By reducing its size, we can save
some unnecessary memset and memcpy operations.

Change-Id: Ibc98aac026182429c27344a5304c42669d0b1600
parent faa02492
......@@ -101,7 +101,7 @@ typedef struct {
typedef struct {
TX_SIZE tx_size;
TX_SIZE inter_tx_size[INTER_TX_SIZE_BUF_LEN];
uint8_t blk_skip[MAX_MIB_SIZE * MAX_MIB_SIZE * 8];
uint8_t blk_skip[MAX_MIB_SIZE * MAX_MIB_SIZE];
TX_TYPE txk_type[TXK_TYPE_BUF_LEN];
RD_STATS rd_stats;
uint32_t hash_value;
......@@ -219,8 +219,8 @@ struct macroblock {
// from extending outside the UMV borders
MvLimits mv_limits;
uint8_t blk_skip[MAX_MB_PLANE][MAX_MIB_SIZE * MAX_MIB_SIZE];
uint8_t blk_skip_drl[MAX_MB_PLANE][MAX_MIB_SIZE * MAX_MIB_SIZE];
uint8_t blk_skip[MAX_MIB_SIZE * MAX_MIB_SIZE];
uint8_t blk_skip_drl[MAX_MIB_SIZE * MAX_MIB_SIZE];
int skip;
int skip_chroma_rd;
......
......@@ -23,8 +23,8 @@ static void alloc_mode_context(AV1_COMMON *cm, int num_pix,
const int num_blk = num_pix / 16;
ctx->num_4x4_blk = num_blk;
CHECK_MEM_ERROR(cm, ctx->blk_skip, aom_calloc(num_blk, sizeof(uint8_t)));
for (i = 0; i < num_planes; ++i) {
CHECK_MEM_ERROR(cm, ctx->blk_skip[i], aom_calloc(num_blk, sizeof(uint8_t)));
CHECK_MEM_ERROR(cm, ctx->coeff[i],
aom_memalign(32, num_pix * sizeof(*ctx->coeff[i])));
CHECK_MEM_ERROR(cm, ctx->qcoeff[i],
......@@ -49,9 +49,9 @@ static void alloc_mode_context(AV1_COMMON *cm, int num_pix,
static void free_mode_context(PICK_MODE_CONTEXT *ctx, const int num_planes) {
int i;
aom_free(ctx->blk_skip);
ctx->blk_skip = 0;
for (i = 0; i < num_planes; ++i) {
aom_free(ctx->blk_skip[i]);
ctx->blk_skip[i] = 0;
aom_free(ctx->coeff[i]);
ctx->coeff[i] = 0;
aom_free(ctx->qcoeff[i]);
......@@ -186,7 +186,7 @@ void av1_free_pc_tree(ThreadData *td, const int num_planes) {
}
void av1_copy_tree_context(PICK_MODE_CONTEXT *dst_ctx,
PICK_MODE_CONTEXT *src_ctx, int num_planes) {
PICK_MODE_CONTEXT *src_ctx) {
dst_ctx->mic = src_ctx->mic;
dst_ctx->mbmi_ext = src_ctx->mbmi_ext;
......@@ -195,10 +195,8 @@ void av1_copy_tree_context(PICK_MODE_CONTEXT *dst_ctx,
dst_ctx->skippable = src_ctx->skippable;
dst_ctx->best_mode_index = src_ctx->best_mode_index;
for (int i = 0; i < num_planes; ++i) {
memcpy(dst_ctx->blk_skip[i], src_ctx->blk_skip[i],
sizeof(uint8_t) * src_ctx->num_4x4_blk);
}
memcpy(dst_ctx->blk_skip, src_ctx->blk_skip,
sizeof(uint8_t) * src_ctx->num_4x4_blk);
dst_ctx->hybrid_pred_diff = src_ctx->hybrid_pred_diff;
dst_ctx->comp_pred_diff = src_ctx->comp_pred_diff;
......
......@@ -39,7 +39,7 @@ typedef struct {
MODE_INFO mic;
MB_MODE_INFO_EXT mbmi_ext;
uint8_t *color_index_map[2];
uint8_t *blk_skip[MAX_MB_PLANE];
uint8_t *blk_skip;
tran_low_t *coeff[MAX_MB_PLANE];
tran_low_t *qcoeff[MAX_MB_PLANE];
......@@ -92,7 +92,7 @@ typedef struct PC_TREE {
void av1_setup_pc_tree(struct AV1Common *cm, struct ThreadData *td);
void av1_free_pc_tree(struct ThreadData *td, const int num_planes);
void av1_copy_tree_context(PICK_MODE_CONTEXT *dst_ctx,
PICK_MODE_CONTEXT *src_ctx, int num_planes);
PICK_MODE_CONTEXT *src_ctx);
#ifdef __cplusplus
} // extern "C"
......
......@@ -346,7 +346,7 @@ static void reset_tx_size(MACROBLOCK *x, MB_MODE_INFO *mbmi,
memset(mbmi->inter_tx_size, mbmi->tx_size, sizeof(mbmi->inter_tx_size));
}
memset(mbmi->txk_type, DCT_DCT, sizeof(mbmi->txk_type[0]) * TXK_TYPE_BUF_LEN);
av1_zero(x->blk_skip[0]);
av1_zero(x->blk_skip);
x->skip = 0;
}
......@@ -424,10 +424,7 @@ static void update_state(const AV1_COMP *const cpi, TileDataEnc *tile_data,
set_ref_and_pred_mvs(x, mi->mbmi.pred_mv, rf_type);
}
for (i = 0; i < 1; ++i) {
memcpy(x->blk_skip[i], ctx->blk_skip[i],
sizeof(uint8_t) * ctx->num_4x4_blk);
}
memcpy(x->blk_skip, ctx->blk_skip, sizeof(x->blk_skip[0]) * ctx->num_4x4_blk);
x->skip = ctx->skip;
......@@ -2387,7 +2384,7 @@ static void rd_pick_sqr_partition(const AV1_COMP *const cpi, ThreadData *td,
// Nothing should rely on the default value of this array (which is just
// leftover from encoding the previous block. Setting it to magic number
// when debugging.
memset(x->blk_skip[0], 234, sizeof(x->blk_skip[0]));
memset(x->blk_skip, 234, sizeof(x->blk_skip));
#endif // NDEBUG
assert(mi_size_wide[bsize] == mi_size_high[bsize]);
......@@ -2671,7 +2668,7 @@ static void rd_pick_partition(const AV1_COMP *const cpi, ThreadData *td,
// Nothing should rely on the default value of this array (which is just
// leftover from encoding the previous block. Setting it to magic number
// when debugging.
memset(x->blk_skip[0], 234, sizeof(x->blk_skip[0]));
memset(x->blk_skip, 234, sizeof(x->blk_skip));
#endif // NDEBUG
assert(mi_size_wide[bsize] == mi_size_high[bsize]);
......@@ -3193,13 +3190,12 @@ BEGIN_PARTITION_SEARCH:
pc_tree->horizontala[1].rd_mode_is_ready = 0;
pc_tree->horizontala[2].rd_mode_is_ready = 0;
if (split_ctx_is_ready[0]) {
av1_copy_tree_context(&pc_tree->horizontala[0], &pc_tree->split[0]->none,
num_planes);
av1_copy_tree_context(&pc_tree->horizontala[0], &pc_tree->split[0]->none);
pc_tree->horizontala[0].mic.mbmi.partition = PARTITION_HORZ_A;
pc_tree->horizontala[0].rd_mode_is_ready = 1;
if (split_ctx_is_ready[1]) {
av1_copy_tree_context(&pc_tree->horizontala[1],
&pc_tree->split[1]->none, num_planes);
&pc_tree->split[1]->none);
pc_tree->horizontala[1].mic.mbmi.partition = PARTITION_HORZ_A;
pc_tree->horizontala[1].rd_mode_is_ready = 1;
}
......@@ -3218,8 +3214,7 @@ BEGIN_PARTITION_SEARCH:
pc_tree->horizontalb[1].rd_mode_is_ready = 0;
pc_tree->horizontalb[2].rd_mode_is_ready = 0;
if (horz_ctx_is_ready) {
av1_copy_tree_context(&pc_tree->horizontalb[0], &pc_tree->horizontal[0],
num_planes);
av1_copy_tree_context(&pc_tree->horizontalb[0], &pc_tree->horizontal[0]);
pc_tree->horizontalb[0].mic.mbmi.partition = PARTITION_HORZ_B;
pc_tree->horizontalb[0].rd_mode_is_ready = 1;
}
......@@ -3247,8 +3242,7 @@ BEGIN_PARTITION_SEARCH:
pc_tree->verticala[1].rd_mode_is_ready = 0;
pc_tree->verticala[2].rd_mode_is_ready = 0;
if (split_ctx_is_ready[0]) {
av1_copy_tree_context(&pc_tree->verticala[0], &pc_tree->split[0]->none,
num_planes);
av1_copy_tree_context(&pc_tree->verticala[0], &pc_tree->split[0]->none);
pc_tree->verticala[0].mic.mbmi.partition = PARTITION_VERT_A;
pc_tree->verticala[0].rd_mode_is_ready = 1;
}
......@@ -3266,8 +3260,7 @@ BEGIN_PARTITION_SEARCH:
pc_tree->verticalb[1].rd_mode_is_ready = 0;
pc_tree->verticalb[2].rd_mode_is_ready = 0;
if (vert_ctx_is_ready) {
av1_copy_tree_context(&pc_tree->verticalb[0], &pc_tree->vertical[0],
num_planes);
av1_copy_tree_context(&pc_tree->verticalb[0], &pc_tree->vertical[0]);
pc_tree->verticalb[0].mic.mbmi.partition = PARTITION_VERT_B;
pc_tree->verticalb[0].rd_mode_is_ready = 1;
}
......
......@@ -221,9 +221,10 @@ static void encode_block(int plane, int block, int blk_row, int blk_col,
l = &args->tl[blk_row];
// Assert not magic number (uninitialized).
assert(x->blk_skip[plane][blk_row * bw + blk_col] != 234);
assert(plane != 0 || x->blk_skip[blk_row * bw + blk_col] != 234);
if (x->blk_skip[plane][blk_row * bw + blk_col] == 0 && !mbmi->skip_mode) {
if ((plane != 0 || x->blk_skip[blk_row * bw + blk_col] == 0) &&
!mbmi->skip_mode) {
if (args->enable_optimize_b) {
av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize,
tx_size, AV1_XFORM_QUANT_FP);
......@@ -516,8 +517,8 @@ void av1_encode_block_intra(int plane, int block, int blk_row, int blk_col,
const int bw = block_size_wide[plane_bsize] >> tx_size_wide_log2[0];
// Assert not magic number (uninitialized).
assert(x->blk_skip[plane][blk_row * bw + blk_col] != 234);
if (x->blk_skip[plane][blk_row * bw + blk_col] && plane == 0) {
assert(plane != 0 || x->blk_skip[blk_row * bw + blk_col] != 234);
if (plane == 0 && x->blk_skip[blk_row * bw + blk_col]) {
*eob = 0;
p->txb_entropy_ctx[block] = 0;
} else {
......
This diff is collapsed.
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