Commit 19407b52 authored by Angie Chiang's avatar Angie Chiang
Browse files

Add subtract_block()

This function help us merge subtract block code in
av1_subtract_plane and av1_encode_block_intra.

Change-Id: Ie793d88a218f1082c6fe28900a521f461e34d564
parent 0ec34d2c
......@@ -41,38 +41,49 @@
// Check if one needs to use c version subtraction.
static int check_subtract_block_size(int w, int h) { return w < 4 || h < 4; }
void av1_subtract_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane) {
struct macroblock_plane *const p = &x->plane[plane];
const struct macroblockd_plane *const pd = &x->e_mbd.plane[plane];
const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd);
const int bw = block_size_wide[plane_bsize];
const int bh = block_size_high[plane_bsize];
static void subtract_block(const MACROBLOCKD *xd, int rows, int cols,
int16_t *diff, ptrdiff_t diff_stride,
const uint8_t *src8, ptrdiff_t src_stride,
const uint8_t *pred8, ptrdiff_t pred_stride) {
#if !CONFIG_AOM_HIGHBITDEPTH
(void)xd;
#endif
if (check_subtract_block_size(bw, bh)) {
if (check_subtract_block_size(rows, cols)) {
#if CONFIG_AOM_HIGHBITDEPTH
if (x->e_mbd.cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
aom_highbd_subtract_block_c(bh, bw, p->src_diff, bw, p->src.buf,
p->src.stride, pd->dst.buf, pd->dst.stride,
x->e_mbd.bd);
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
aom_highbd_subtract_block_c(rows, cols, diff, diff_stride, src8,
src_stride, pred8, pred_stride, xd->bd);
return;
}
#endif // CONFIG_AOM_HIGHBITDEPTH
aom_subtract_block_c(bh, bw, p->src_diff, bw, p->src.buf, p->src.stride,
pd->dst.buf, pd->dst.stride);
aom_subtract_block_c(rows, cols, diff, diff_stride, src8, src_stride, pred8,
pred_stride);
return;
}
#if CONFIG_AOM_HIGHBITDEPTH
if (x->e_mbd.cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
aom_highbd_subtract_block(bh, bw, p->src_diff, bw, p->src.buf,
p->src.stride, pd->dst.buf, pd->dst.stride,
x->e_mbd.bd);
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
aom_highbd_subtract_block(rows, cols, diff, diff_stride, src8, src_stride,
pred8, pred_stride, xd->bd);
return;
}
#endif // CONFIG_AOM_HIGHBITDEPTH
aom_subtract_block(bh, bw, p->src_diff, bw, p->src.buf, p->src.stride,
pd->dst.buf, pd->dst.stride);
aom_subtract_block(rows, cols, diff, diff_stride, src8, src_stride, pred8,
pred_stride);
}
void av1_subtract_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane) {
struct macroblock_plane *const p = &x->plane[plane];
const struct macroblockd_plane *const pd = &x->e_mbd.plane[plane];
const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd);
const int bw = block_size_wide[plane_bsize];
const int bh = block_size_high[plane_bsize];
const MACROBLOCKD *xd = &x->e_mbd;
subtract_block(xd, bh, bw, p->src_diff, bw, p->src.buf, p->src.stride,
pd->dst.buf, pd->dst.stride);
}
typedef struct av1_token_state {
......@@ -1096,34 +1107,8 @@ void av1_encode_block_intra(int plane, int block, int blk_row, int blk_col,
mode, dst, dst_stride, dst, dst_stride, blk_col,
blk_row, plane);
if (check_subtract_block_size(tx1d_width, tx1d_height)) {
#if CONFIG_AOM_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
aom_highbd_subtract_block_c(tx1d_height, tx1d_width, src_diff,
diff_stride, src, src_stride, dst, dst_stride,
xd->bd);
} else {
aom_subtract_block_c(tx1d_height, tx1d_width, src_diff, diff_stride, src,
src_stride, dst, dst_stride);
}
#else
aom_subtract_block_c(tx1d_height, tx1d_width, src_diff, diff_stride, src,
src_stride, dst, dst_stride);
#endif // CONFIG_AOM_HIGHBITDEPTH
} else {
#if CONFIG_AOM_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
aom_highbd_subtract_block(tx1d_height, tx1d_width, src_diff, diff_stride,
src, src_stride, dst, dst_stride, xd->bd);
} else {
aom_subtract_block(tx1d_height, tx1d_width, src_diff, diff_stride, src,
src_stride, dst, dst_stride);
}
#else
aom_subtract_block(tx1d_height, tx1d_width, src_diff, diff_stride, src,
src_stride, dst, dst_stride);
#endif // CONFIG_AOM_HIGHBITDEPTH
}
subtract_block(xd, tx1d_height, tx1d_width, src_diff, diff_stride, src,
src_stride, dst, dst_stride);
#if !CONFIG_PVQ
const ENTROPY_CONTEXT *a = &args->ta[blk_col];
......
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