Optimizing set_contexts() function.
Inlining set_contexts_on_border() into set_contexts(). The only difference is the additional check that "has_eob != 0" in addition to "xd->mb_to_right_edge < 0" and "xd->mb_to_right_edge < 0". If has_eob == 0 then memset does the right thing and works faster. Change-Id: I5206f767d729f758b14c667592b7034df4837d0e
This commit is contained in:
parent
614effc0f6
commit
22a001988b
@ -457,57 +457,46 @@ static void extend_for_intra(MACROBLOCKD *xd, BLOCK_SIZE plane_bsize,
|
||||
}
|
||||
}
|
||||
}
|
||||
static void set_contexts_on_border(const MACROBLOCKD *xd,
|
||||
struct macroblockd_plane *pd,
|
||||
BLOCK_SIZE plane_bsize,
|
||||
int tx_size_in_blocks, int has_eob,
|
||||
int aoff, int loff,
|
||||
ENTROPY_CONTEXT *A, ENTROPY_CONTEXT *L) {
|
||||
int mi_blocks_wide = num_4x4_blocks_wide_lookup[plane_bsize];
|
||||
int mi_blocks_high = num_4x4_blocks_high_lookup[plane_bsize];
|
||||
int above_contexts = tx_size_in_blocks;
|
||||
int left_contexts = tx_size_in_blocks;
|
||||
int pt;
|
||||
|
||||
// xd->mb_to_right_edge is in units of pixels * 8. This converts
|
||||
// it to 4x4 block sizes.
|
||||
if (xd->mb_to_right_edge < 0)
|
||||
mi_blocks_wide += (xd->mb_to_right_edge >> (5 + pd->subsampling_x));
|
||||
|
||||
if (xd->mb_to_bottom_edge < 0)
|
||||
mi_blocks_high += (xd->mb_to_bottom_edge >> (5 + pd->subsampling_y));
|
||||
|
||||
// this code attempts to avoid copying into contexts that are outside
|
||||
// our border. Any blocks that do are set to 0...
|
||||
if (above_contexts + aoff > mi_blocks_wide)
|
||||
above_contexts = mi_blocks_wide - aoff;
|
||||
|
||||
if (left_contexts + loff > mi_blocks_high)
|
||||
left_contexts = mi_blocks_high - loff;
|
||||
|
||||
for (pt = 0; pt < above_contexts; pt++)
|
||||
A[pt] = has_eob;
|
||||
for (pt = above_contexts; pt < tx_size_in_blocks; pt++)
|
||||
A[pt] = 0;
|
||||
for (pt = 0; pt < left_contexts; pt++)
|
||||
L[pt] = has_eob;
|
||||
for (pt = left_contexts; pt < tx_size_in_blocks; pt++)
|
||||
L[pt] = 0;
|
||||
}
|
||||
|
||||
static void set_contexts(const MACROBLOCKD *xd, struct macroblockd_plane *pd,
|
||||
BLOCK_SIZE plane_bsize, TX_SIZE tx_size,
|
||||
int has_eob, int aoff, int loff) {
|
||||
ENTROPY_CONTEXT *const A = pd->above_context + aoff;
|
||||
ENTROPY_CONTEXT *const L = pd->left_context + loff;
|
||||
ENTROPY_CONTEXT *const a = pd->above_context + aoff;
|
||||
ENTROPY_CONTEXT *const l = pd->left_context + loff;
|
||||
const int tx_size_in_blocks = 1 << tx_size;
|
||||
|
||||
if (xd->mb_to_right_edge < 0 || xd->mb_to_bottom_edge < 0) {
|
||||
set_contexts_on_border(xd, pd, plane_bsize, tx_size_in_blocks, has_eob,
|
||||
aoff, loff, A, L);
|
||||
// above
|
||||
if (has_eob && xd->mb_to_right_edge < 0) {
|
||||
int i;
|
||||
const int blocks_wide = num_4x4_blocks_wide_lookup[plane_bsize] +
|
||||
(xd->mb_to_right_edge >> (5 + pd->subsampling_x));
|
||||
int above_contexts = tx_size_in_blocks;
|
||||
if (above_contexts + aoff > blocks_wide)
|
||||
above_contexts = blocks_wide - aoff;
|
||||
|
||||
for (i = 0; i < above_contexts; ++i)
|
||||
a[i] = has_eob;
|
||||
for (i = above_contexts; i < tx_size_in_blocks; ++i)
|
||||
a[i] = 0;
|
||||
} else {
|
||||
vpx_memset(A, has_eob, sizeof(ENTROPY_CONTEXT) * tx_size_in_blocks);
|
||||
vpx_memset(L, has_eob, sizeof(ENTROPY_CONTEXT) * tx_size_in_blocks);
|
||||
vpx_memset(a, has_eob, sizeof(ENTROPY_CONTEXT) * tx_size_in_blocks);
|
||||
}
|
||||
|
||||
// left
|
||||
if (has_eob && xd->mb_to_bottom_edge < 0) {
|
||||
int i;
|
||||
const int blocks_high = num_4x4_blocks_high_lookup[plane_bsize] +
|
||||
(xd->mb_to_bottom_edge >> (5 + pd->subsampling_y));
|
||||
int left_contexts = tx_size_in_blocks;
|
||||
if (left_contexts + loff > blocks_high)
|
||||
left_contexts = blocks_high - loff;
|
||||
|
||||
for (i = 0; i < left_contexts; ++i)
|
||||
l[i] = has_eob;
|
||||
for (i = left_contexts; i < tx_size_in_blocks; ++i)
|
||||
l[i] = 0;
|
||||
} else {
|
||||
vpx_memset(l, has_eob, sizeof(ENTROPY_CONTEXT) * tx_size_in_blocks);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user