summaryrefslogtreecommitdiff
path: root/vp9/encoder
diff options
context:
space:
mode:
authorDmitry Kovalev <dkovalev@google.com>2013-12-03 17:59:32 -0800
committerDmitry Kovalev <dkovalev@google.com>2013-12-03 17:59:32 -0800
commitf00d157c125a5362b48037a2c65d2f0eee4f5f84 (patch)
treec3ed89ef93a5cc82057ab6371733875e18691874 /vp9/encoder
parent3c34619125ea8a5ea1657d06d7c4d970d0a30599 (diff)
downloadlibvpx-f00d157c125a5362b48037a2c65d2f0eee4f5f84.tar
libvpx-f00d157c125a5362b48037a2c65d2f0eee4f5f84.tar.gz
libvpx-f00d157c125a5362b48037a2c65d2f0eee4f5f84.tar.bz2
libvpx-f00d157c125a5362b48037a2c65d2f0eee4f5f84.zip
Moving eob array to the encoder.
In the decoder we don't need to save eobs, we can pass eob as an argument. That's why removing eob arrays from VP9Decompressor and TileWorkerData, and moving eob pointer from macroblockd_plane to macroblock_plane. Change-Id: I8eb919acc837acfb3abdd8319af63d1bbca8217a
Diffstat (limited to 'vp9/encoder')
-rw-r--r--vp9/encoder/vp9_block.h1
-rw-r--r--vp9/encoder/vp9_encodeframe.c6
-rw-r--r--vp9/encoder/vp9_encodemb.c30
-rw-r--r--vp9/encoder/vp9_firstpass.c2
-rw-r--r--vp9/encoder/vp9_quantize.c2
-rw-r--r--vp9/encoder/vp9_rdopt.c27
-rw-r--r--vp9/encoder/vp9_tokenize.c28
-rw-r--r--vp9/encoder/vp9_tokenize.h5
8 files changed, 52 insertions, 49 deletions
diff --git a/vp9/encoder/vp9_block.h b/vp9/encoder/vp9_block.h
index 71f7e7a52..4af40da75 100644
--- a/vp9/encoder/vp9_block.h
+++ b/vp9/encoder/vp9_block.h
@@ -71,6 +71,7 @@ struct macroblock_plane {
DECLARE_ALIGNED(16, int16_t, src_diff[64 * 64]);
int16_t *qcoeff;
int16_t *coeff;
+ uint16_t *eobs;
struct buf_2d src;
// Quantizer setings
diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c
index 89da78190..f53c3c962 100644
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -441,14 +441,14 @@ static void update_state(VP9_COMP *cpi, PICK_MODE_CONTEXT *ctx,
p[i].coeff = ctx->coeff_pbuf[i][1];
p[i].qcoeff = ctx->qcoeff_pbuf[i][1];
pd[i].dqcoeff = ctx->dqcoeff_pbuf[i][1];
- pd[i].eobs = ctx->eobs_pbuf[i][1];
+ p[i].eobs = ctx->eobs_pbuf[i][1];
}
for (i = max_plane; i < MAX_MB_PLANE; ++i) {
p[i].coeff = ctx->coeff_pbuf[i][2];
p[i].qcoeff = ctx->qcoeff_pbuf[i][2];
pd[i].dqcoeff = ctx->dqcoeff_pbuf[i][2];
- pd[i].eobs = ctx->eobs_pbuf[i][2];
+ p[i].eobs = ctx->eobs_pbuf[i][2];
}
// Restore the coding context of the MB to that that was in place
@@ -677,7 +677,7 @@ static void pick_sb_modes(VP9_COMP *cpi, const TileInfo *const tile,
p[i].coeff = ctx->coeff_pbuf[i][0];
p[i].qcoeff = ctx->qcoeff_pbuf[i][0];
pd[i].dqcoeff = ctx->dqcoeff_pbuf[i][0];
- pd[i].eobs = ctx->eobs_pbuf[i][0];
+ p[i].eobs = ctx->eobs_pbuf[i][0];
}
ctx->is_coded = 0;
x->skip_recode = 0;
diff --git a/vp9/encoder/vp9_encodemb.c b/vp9/encoder/vp9_encodemb.c
index 3691e7a7b..885c76795 100644
--- a/vp9/encoder/vp9_encodemb.c
+++ b/vp9/encoder/vp9_encodemb.c
@@ -144,7 +144,7 @@ static void optimize_b(MACROBLOCK *mb,
const int16_t *coeff_ptr = BLOCK_OFFSET(mb->plane[plane].coeff, block);
int16_t *qcoeff_ptr;
int16_t *dqcoeff_ptr;
- int eob = pd->eobs[block], final_eob, sz = 0;
+ int eob = p->eobs[block], final_eob, sz = 0;
const int i0 = 0;
int rc, x, next, i;
int64_t rdmult, rddiv, rd_cost0, rd_cost1;
@@ -334,7 +334,7 @@ static void optimize_b(MACROBLOCK *mb,
}
final_eob++;
- xd->plane[plane].eobs[block] = final_eob;
+ mb->plane[plane].eobs[block] = final_eob;
*a = *l = (final_eob > 0);
}
@@ -372,7 +372,7 @@ void vp9_xform_quant(int plane, int block, BLOCK_SIZE plane_bsize,
int16_t *qcoeff = BLOCK_OFFSET(p->qcoeff, block);
int16_t *dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
const scan_order *so;
- uint16_t *eob = &pd->eobs[block];
+ uint16_t *eob = &p->eobs[block];
const int diff_stride = 4 * num_4x4_blocks_wide_lookup[plane_bsize];
int i, j;
int16_t *src_diff;
@@ -423,6 +423,7 @@ static void encode_block(int plane, int block, BLOCK_SIZE plane_bsize,
MACROBLOCK *const x = args->x;
MACROBLOCKD *const xd = &x->e_mbd;
struct optimize_ctx *const ctx = args->ctx;
+ struct macroblock_plane *const p = &x->plane[plane];
struct macroblockd_plane *const pd = &xd->plane[plane];
int16_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
int i, j;
@@ -433,7 +434,7 @@ static void encode_block(int plane, int block, BLOCK_SIZE plane_bsize,
// TODO(jingning): per transformed block zero forcing only enabled for
// luma component. will integrate chroma components as well.
if (x->zcoeff_blk[tx_size][block] && plane == 0) {
- pd->eobs[block] = 0;
+ p->eobs[block] = 0;
ctx->ta[plane][i] = 0;
ctx->tl[plane][j] = 0;
return;
@@ -445,28 +446,28 @@ static void encode_block(int plane, int block, BLOCK_SIZE plane_bsize,
if (x->optimize && (!x->skip_recode || !x->skip_optimize)) {
vp9_optimize_b(plane, block, plane_bsize, tx_size, x, ctx);
} else {
- ctx->ta[plane][i] = pd->eobs[block] > 0;
- ctx->tl[plane][j] = pd->eobs[block] > 0;
+ ctx->ta[plane][i] = p->eobs[block] > 0;
+ ctx->tl[plane][j] = p->eobs[block] > 0;
}
- if (x->skip_encode || pd->eobs[block] == 0)
+ if (x->skip_encode || p->eobs[block] == 0)
return;
switch (tx_size) {
case TX_32X32:
- vp9_idct32x32_add(dqcoeff, dst, pd->dst.stride, pd->eobs[block]);
+ vp9_idct32x32_add(dqcoeff, dst, pd->dst.stride, p->eobs[block]);
break;
case TX_16X16:
- vp9_idct16x16_add(dqcoeff, dst, pd->dst.stride, pd->eobs[block]);
+ vp9_idct16x16_add(dqcoeff, dst, pd->dst.stride, p->eobs[block]);
break;
case TX_8X8:
- vp9_idct8x8_add(dqcoeff, dst, pd->dst.stride, pd->eobs[block]);
+ vp9_idct8x8_add(dqcoeff, dst, pd->dst.stride, p->eobs[block]);
break;
case TX_4X4:
// this is like vp9_short_idct4x4 but has a special case around eob<=1
// which is significant (not just an optimization) for the lossless
// case.
- xd->itxm_add(dqcoeff, dst, pd->dst.stride, pd->eobs[block]);
+ xd->itxm_add(dqcoeff, dst, pd->dst.stride, p->eobs[block]);
break;
default:
assert(!"Invalid transform size");
@@ -478,6 +479,7 @@ static void encode_block_pass1(int plane, int block, BLOCK_SIZE plane_bsize,
struct encode_b_args *const args = arg;
MACROBLOCK *const x = args->x;
MACROBLOCKD *const xd = &x->e_mbd;
+ struct macroblock_plane *const p = &x->plane[plane];
struct macroblockd_plane *const pd = &xd->plane[plane];
int16_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
int i, j;
@@ -487,10 +489,10 @@ static void encode_block_pass1(int plane, int block, BLOCK_SIZE plane_bsize,
vp9_xform_quant(plane, block, plane_bsize, tx_size, arg);
- if (pd->eobs[block] == 0)
+ if (p->eobs[block] == 0)
return;
- xd->itxm_add(dqcoeff, dst, pd->dst.stride, pd->eobs[block]);
+ xd->itxm_add(dqcoeff, dst, pd->dst.stride, p->eobs[block]);
}
void vp9_encode_sby(MACROBLOCK *x, BLOCK_SIZE bsize) {
@@ -540,7 +542,7 @@ void vp9_encode_block_intra(int plane, int block, BLOCK_SIZE plane_bsize,
const int diff_stride = 4 * (1 << bwl);
uint8_t *src, *dst;
int16_t *src_diff;
- uint16_t *eob = &pd->eobs[block];
+ uint16_t *eob = &p->eobs[block];
int i, j;
txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &i, &j);
dst = &pd->dst.buf[4 * (j * pd->dst.stride + i)];
diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c
index 50d803680..30e18a37f 100644
--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -545,7 +545,7 @@ void vp9_first_pass(VP9_COMP *cpi) {
p[i].coeff = ctx->coeff_pbuf[i][1];
p[i].qcoeff = ctx->qcoeff_pbuf[i][1];
pd[i].dqcoeff = ctx->dqcoeff_pbuf[i][1];
- pd[i].eobs = ctx->eobs_pbuf[i][1];
+ p[i].eobs = ctx->eobs_pbuf[i][1];
}
x->skip_recode = 0;
diff --git a/vp9/encoder/vp9_quantize.c b/vp9/encoder/vp9_quantize.c
index 2591a5783..8c4172421 100644
--- a/vp9/encoder/vp9_quantize.c
+++ b/vp9/encoder/vp9_quantize.c
@@ -148,7 +148,7 @@ void vp9_regular_quantize_b_4x4(MACROBLOCK *x, int plane, int block,
p->zbin, p->round, p->quant, p->quant_shift,
BLOCK_OFFSET(p->qcoeff, block),
BLOCK_OFFSET(pd->dqcoeff, block),
- pd->dequant, p->zbin_extra, &pd->eobs[block], scan, iscan);
+ pd->dequant, p->zbin_extra, &p->eobs[block], scan, iscan);
}
static void invert_quant(int16_t *quant, int16_t *shift, int d) {
diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c
index 65cf5c797..3402d6302 100644
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -525,7 +525,7 @@ static INLINE int cost_coeffs(MACROBLOCK *x,
struct macroblockd_plane *pd = &xd->plane[plane];
const PLANE_TYPE type = pd->plane_type;
const int16_t *band_count = &band_counts[tx_size][1];
- const int eob = pd->eobs[block];
+ const int eob = p->eobs[block];
const int16_t *const qcoeff_ptr = BLOCK_OFFSET(p->qcoeff, block);
const int ref = mbmi->ref_frame[0] != INTRA_FRAME;
unsigned int (*token_costs)[2][PREV_COEF_CONTEXTS][MAX_ENTROPY_TOKENS] =
@@ -643,7 +643,7 @@ static void block_rd_txfm(int plane, int block, BLOCK_SIZE plane_bsize,
// TODO(jingning): temporarily enabled only for luma component
rd = MIN(rd1, rd2);
if (plane == 0)
- x->zcoeff_blk[tx_size][block] = !xd->plane[plane].eobs[block] ||
+ x->zcoeff_blk[tx_size][block] = !x->plane[plane].eobs[block] ||
(rd1 > rd2 && !xd->lossless);
args->this_rate += args->rate;
@@ -739,7 +739,7 @@ static void txfm_rd_in_plane(MACROBLOCK *x,
*distortion = rd_stack->this_dist;
*rate = rd_stack->this_rate;
*sse = rd_stack->this_sse;
- *skippable = vp9_is_skippable_in_plane(xd, bsize, plane);
+ *skippable = vp9_is_skippable_in_plane(x, bsize, plane);
}
}
@@ -1329,7 +1329,7 @@ static int64_t rd_pick_intra_sbuv_mode(VP9_COMP *cpi, MACROBLOCK *x,
p[i].coeff = ctx->coeff_pbuf[i][2];
p[i].qcoeff = ctx->qcoeff_pbuf[i][2];
pd[i].dqcoeff = ctx->dqcoeff_pbuf[i][2];
- pd[i].eobs = ctx->eobs_pbuf[i][2];
+ p[i].eobs = ctx->eobs_pbuf[i][2];
ctx->coeff_pbuf[i][2] = ctx->coeff_pbuf[i][0];
ctx->qcoeff_pbuf[i][2] = ctx->qcoeff_pbuf[i][0];
@@ -1339,7 +1339,7 @@ static int64_t rd_pick_intra_sbuv_mode(VP9_COMP *cpi, MACROBLOCK *x,
ctx->coeff_pbuf[i][0] = p[i].coeff;
ctx->qcoeff_pbuf[i][0] = p[i].qcoeff;
ctx->dqcoeff_pbuf[i][0] = pd[i].dqcoeff;
- ctx->eobs_pbuf[i][0] = pd[i].eobs;
+ ctx->eobs_pbuf[i][0] = p[i].eobs;
}
}
}
@@ -1630,6 +1630,7 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x,
MB_PREDICTION_MODE this_mode;
MODE_INFO *mi = x->e_mbd.mi_8x8[0];
MB_MODE_INFO *const mbmi = &mi->mbmi;
+ struct macroblock_plane *const p = &x->plane[0];
struct macroblockd_plane *const pd = &x->e_mbd.plane[0];
const int label_count = 4;
int64_t this_segment_rd = 0;
@@ -1958,11 +1959,11 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x,
bsi->rdstat[i][mode_idx].brdcost += RDCOST(x->rdmult, x->rddiv,
bsi->rdstat[i][mode_idx].brate, 0);
bsi->rdstat[i][mode_idx].brate += bsi->rdstat[i][mode_idx].byrate;
- bsi->rdstat[i][mode_idx].eobs = pd->eobs[i];
+ bsi->rdstat[i][mode_idx].eobs = p->eobs[i];
if (num_4x4_blocks_wide > 1)
- bsi->rdstat[i + 1][mode_idx].eobs = pd->eobs[i + 1];
+ bsi->rdstat[i + 1][mode_idx].eobs = p->eobs[i + 1];
if (num_4x4_blocks_high > 1)
- bsi->rdstat[i + 2][mode_idx].eobs = pd->eobs[i + 2];
+ bsi->rdstat[i + 2][mode_idx].eobs = p->eobs[i + 2];
}
if (bsi->rdstat[i][mode_idx].brdcost < best_rd) {
@@ -2060,7 +2061,7 @@ static int64_t rd_pick_best_mbsegmentation(VP9_COMP *cpi, MACROBLOCK *x,
mi->bmi[i].as_mv[0].as_int = bsi->rdstat[i][mode_idx].mvs[0].as_int;
if (has_second_ref(mbmi))
mi->bmi[i].as_mv[1].as_int = bsi->rdstat[i][mode_idx].mvs[1].as_int;
- xd->plane[0].eobs[i] = bsi->rdstat[i][mode_idx].eobs;
+ x->plane[0].eobs[i] = bsi->rdstat[i][mode_idx].eobs;
mi->bmi[i].as_mode = bsi->modes[i];
}
@@ -2070,7 +2071,7 @@ static int64_t rd_pick_best_mbsegmentation(VP9_COMP *cpi, MACROBLOCK *x,
*returntotrate = bsi->r;
*returndistortion = bsi->d;
*returnyrate = bsi->segment_yrate;
- *skippable = vp9_is_skippable_in_plane(&x->e_mbd, BLOCK_8X8, 0);
+ *skippable = vp9_is_skippable_in_plane(x, BLOCK_8X8, 0);
*psse = bsi->sse;
mbmi->mode = bsi->modes[3];
@@ -3005,7 +3006,7 @@ static void swap_block_ptr(MACROBLOCK *x, PICK_MODE_CONTEXT *ctx,
p[i].coeff = ctx->coeff_pbuf[i][1];
p[i].qcoeff = ctx->qcoeff_pbuf[i][1];
pd[i].dqcoeff = ctx->dqcoeff_pbuf[i][1];
- pd[i].eobs = ctx->eobs_pbuf[i][1];
+ p[i].eobs = ctx->eobs_pbuf[i][1];
ctx->coeff_pbuf[i][1] = ctx->coeff_pbuf[i][0];
ctx->qcoeff_pbuf[i][1] = ctx->qcoeff_pbuf[i][0];
@@ -3015,7 +3016,7 @@ static void swap_block_ptr(MACROBLOCK *x, PICK_MODE_CONTEXT *ctx,
ctx->coeff_pbuf[i][0] = p[i].coeff;
ctx->qcoeff_pbuf[i][0] = p[i].qcoeff;
ctx->dqcoeff_pbuf[i][0] = pd[i].dqcoeff;
- ctx->eobs_pbuf[i][0] = pd[i].eobs;
+ ctx->eobs_pbuf[i][0] = p[i].eobs;
}
}
@@ -4133,7 +4134,7 @@ int64_t vp9_rd_pick_inter_mode_sub8x8(VP9_COMP *cpi, MACROBLOCK *x,
tmp_best_mbmode = *mbmi;
for (i = 0; i < 4; i++) {
tmp_best_bmodes[i] = xd->mi_8x8[0]->bmi[i];
- x->zcoeff_blk[TX_4X4][i] = !xd->plane[0].eobs[i];
+ x->zcoeff_blk[TX_4X4][i] = !x->plane[0].eobs[i];
}
pred_exists = 1;
if (switchable_filter_index == 0 &&
diff --git a/vp9/encoder/vp9_tokenize.c b/vp9/encoder/vp9_tokenize.c
index 389ec152a..5e3b4b1c6 100644
--- a/vp9/encoder/vp9_tokenize.c
+++ b/vp9/encoder/vp9_tokenize.c
@@ -168,10 +168,11 @@ static void set_entropy_context_b(int plane, int block, BLOCK_SIZE plane_bsize,
TX_SIZE tx_size, void *arg) {
struct tokenize_b_args* const args = arg;
MACROBLOCKD *const xd = args->xd;
+ struct macroblock_plane *p = &args->cpi->mb.plane[plane];
struct macroblockd_plane *pd = &xd->plane[plane];
int aoff, loff;
txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &aoff, &loff);
- set_contexts(xd, pd, plane_bsize, tx_size, pd->eobs[block] > 0, aoff, loff);
+ set_contexts(xd, pd, plane_bsize, tx_size, p->eobs[block] > 0, aoff, loff);
}
static void tokenize_b(int plane, int block, BLOCK_SIZE plane_bsize,
@@ -181,16 +182,15 @@ static void tokenize_b(int plane, int block, BLOCK_SIZE plane_bsize,
MACROBLOCKD *xd = args->xd;
TOKENEXTRA **tp = args->tp;
uint8_t *token_cache = args->token_cache;
+ struct macroblock_plane *p = &cpi->mb.plane[plane];
struct macroblockd_plane *pd = &xd->plane[plane];
MB_MODE_INFO *mbmi = &xd->mi_8x8[0]->mbmi;
int pt; /* near block/prev token context index */
int c = 0, rc = 0;
TOKENEXTRA *t = *tp; /* store tokens starting here */
- const int eob = pd->eobs[block];
+ const int eob = p->eobs[block];
const PLANE_TYPE type = pd->plane_type;
- struct macroblock_plane *p = &cpi->mb.plane[plane];
const int16_t *qcoeff_ptr = BLOCK_OFFSET(p->qcoeff, block);
-
const int segment_id = mbmi->segment_id;
const int16_t *scan, *nb;
const scan_order *so;
@@ -249,7 +249,7 @@ static void tokenize_b(int plane, int block, BLOCK_SIZE plane_bsize,
}
struct is_skippable_args {
- MACROBLOCKD *xd;
+ MACROBLOCK *x;
int *skippable;
};
@@ -257,21 +257,21 @@ static void is_skippable(int plane, int block,
BLOCK_SIZE plane_bsize, TX_SIZE tx_size,
void *argv) {
struct is_skippable_args *args = argv;
- args->skippable[0] &= (!args->xd->plane[plane].eobs[block]);
+ args->skippable[0] &= (!args->x->plane[plane].eobs[block]);
}
-int vp9_sb_is_skippable(MACROBLOCKD *xd, BLOCK_SIZE bsize) {
+static int sb_is_skippable(MACROBLOCK *x, BLOCK_SIZE bsize) {
int result = 1;
- struct is_skippable_args args = {xd, &result};
- foreach_transformed_block(xd, bsize, is_skippable, &args);
+ struct is_skippable_args args = {x, &result};
+ foreach_transformed_block(&x->e_mbd, bsize, is_skippable, &args);
return result;
}
-int vp9_is_skippable_in_plane(MACROBLOCKD *xd, BLOCK_SIZE bsize,
- int plane) {
+int vp9_is_skippable_in_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane) {
int result = 1;
- struct is_skippable_args args = {xd, &result};
- foreach_transformed_block_in_plane(xd, bsize, plane, is_skippable, &args);
+ struct is_skippable_args args = {x, &result};
+ foreach_transformed_block_in_plane(&x->e_mbd, bsize, plane, is_skippable,
+ &args);
return result;
}
@@ -286,7 +286,7 @@ void vp9_tokenize_sb(VP9_COMP *cpi, TOKENEXTRA **t, int dry_run,
SEG_LVL_SKIP);
struct tokenize_b_args arg = {cpi, xd, t, mbmi->tx_size, cpi->mb.token_cache};
- mbmi->skip_coeff = vp9_sb_is_skippable(xd, bsize);
+ mbmi->skip_coeff = sb_is_skippable(&cpi->mb, bsize);
if (mbmi->skip_coeff) {
if (!dry_run)
cm->counts.mbskip[mb_skip_context][1] += skip_inc;
diff --git a/vp9/encoder/vp9_tokenize.h b/vp9/encoder/vp9_tokenize.h
index 2e3bf5203..1b6e6e18b 100644
--- a/vp9/encoder/vp9_tokenize.h
+++ b/vp9/encoder/vp9_tokenize.h
@@ -32,9 +32,8 @@ extern const vp9_tree_index vp9_coef_tree[];
extern const vp9_tree_index vp9_coef_con_tree[];
extern struct vp9_token vp9_coef_encodings[];
-int vp9_sb_is_skippable(MACROBLOCKD *xd, BLOCK_SIZE bsize);
-int vp9_is_skippable_in_plane(MACROBLOCKD *xd, BLOCK_SIZE bsize,
- int plane);
+int vp9_is_skippable_in_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane);
+
struct VP9_COMP;
void vp9_tokenize_sb(struct VP9_COMP *cpi, TOKENEXTRA **t, int dry_run,