summaryrefslogtreecommitdiff
path: root/vp9/encoder/vp9_bitstream.c
diff options
context:
space:
mode:
authorYunqing Wang <yunqingwang@google.com>2014-10-22 14:37:38 -0700
committerYunqing Wang <yunqingwang@google.com>2014-10-22 15:03:12 -0700
commit7c7e4d4eb8ddc1f7884dcab380a5850fef8b2add (patch)
treed70087f4fef896739d4ec6093a8a5bee1c55ecb9 /vp9/encoder/vp9_bitstream.c
parent7c4992c4667f4f3392b911e3a8b17a776a216c5f (diff)
downloadlibvpx-7c7e4d4eb8ddc1f7884dcab380a5850fef8b2add.tar
libvpx-7c7e4d4eb8ddc1f7884dcab380a5850fef8b2add.tar.gz
libvpx-7c7e4d4eb8ddc1f7884dcab380a5850fef8b2add.tar.bz2
libvpx-7c7e4d4eb8ddc1f7884dcab380a5850fef8b2add.zip
vp9_ethread: allocate frame contexts outside VP9_COMMON struct
This patch allocated frame contexts outside VP9_COMMON. This allows multiple threads to share the same copy of frame contexts, and reduces the overhead. It also guarantees the correct update of these contexts during bitstream packing. This patch doesn't change encoding result. Change-Id: Ic181a2460b891d1d587278a6d02d8057b9dbd353
Diffstat (limited to 'vp9/encoder/vp9_bitstream.c')
-rw-r--r--vp9/encoder/vp9_bitstream.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/vp9/encoder/vp9_bitstream.c b/vp9/encoder/vp9_bitstream.c
index 421e04969..4166d3106 100644
--- a/vp9/encoder/vp9_bitstream.c
+++ b/vp9/encoder/vp9_bitstream.c
@@ -84,7 +84,7 @@ static void write_selected_tx_size(const VP9_COMMON *cm,
vp9_writer *w) {
const TX_SIZE max_tx_size = max_txsize_lookup[bsize];
const vp9_prob *const tx_probs = get_tx_probs2(max_tx_size, xd,
- &cm->fc.tx_probs);
+ &cm->fc->tx_probs);
vp9_write(w, tx_size != TX_4X4, tx_probs[0]);
if (tx_size != TX_4X4 && max_tx_size >= TX_16X16) {
vp9_write(w, tx_size != TX_8X8, tx_probs[1]);
@@ -108,14 +108,14 @@ static void update_skip_probs(VP9_COMMON *cm, vp9_writer *w) {
int k;
for (k = 0; k < SKIP_CONTEXTS; ++k)
- vp9_cond_prob_diff_update(w, &cm->fc.skip_probs[k], cm->counts.skip[k]);
+ vp9_cond_prob_diff_update(w, &cm->fc->skip_probs[k], cm->counts.skip[k]);
}
static void update_switchable_interp_probs(VP9_COMMON *cm, vp9_writer *w) {
int j;
for (j = 0; j < SWITCHABLE_FILTER_CONTEXTS; ++j)
prob_diff_update(vp9_switchable_interp_tree,
- cm->fc.switchable_interp_prob[j],
+ cm->fc->switchable_interp_prob[j],
cm->counts.switchable_interp[j], SWITCHABLE_FILTERS, w);
}
@@ -237,7 +237,7 @@ static void write_ref_frames(const VP9_COMMON *cm, const MACROBLOCKD *xd,
static void pack_inter_mode_mvs(VP9_COMP *cpi, const MODE_INFO *mi,
vp9_writer *w) {
VP9_COMMON *const cm = &cpi->common;
- const nmv_context *nmvc = &cm->fc.nmvc;
+ const nmv_context *nmvc = &cm->fc->nmvc;
const MACROBLOCK *const x = &cpi->mb;
const MACROBLOCKD *const xd = &x->e_mbd;
const struct segmentation *const seg = &cm->seg;
@@ -275,7 +275,7 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, const MODE_INFO *mi,
if (!is_inter) {
if (bsize >= BLOCK_8X8) {
- write_intra_mode(w, mode, cm->fc.y_mode_prob[size_group_lookup[bsize]]);
+ write_intra_mode(w, mode, cm->fc->y_mode_prob[size_group_lookup[bsize]]);
} else {
int idx, idy;
const int num_4x4_w = num_4x4_blocks_wide_lookup[bsize];
@@ -283,14 +283,14 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, const MODE_INFO *mi,
for (idy = 0; idy < 2; idy += num_4x4_h) {
for (idx = 0; idx < 2; idx += num_4x4_w) {
const PREDICTION_MODE b_mode = mi->bmi[idy * 2 + idx].as_mode;
- write_intra_mode(w, b_mode, cm->fc.y_mode_prob[0]);
+ write_intra_mode(w, b_mode, cm->fc->y_mode_prob[0]);
}
}
}
- write_intra_mode(w, mbmi->uv_mode, cm->fc.uv_mode_prob[mode]);
+ write_intra_mode(w, mbmi->uv_mode, cm->fc->uv_mode_prob[mode]);
} else {
const int mode_ctx = mbmi->mode_context[mbmi->ref_frame[0]];
- const vp9_prob *const inter_probs = cm->fc.inter_mode_probs[mode_ctx];
+ const vp9_prob *const inter_probs = cm->fc->inter_mode_probs[mode_ctx];
write_ref_frames(cm, xd, w);
// If segment skip is not enabled code the mode.
@@ -304,7 +304,7 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, const MODE_INFO *mi,
if (cm->interp_filter == SWITCHABLE) {
const int ctx = vp9_get_pred_context_switchable_interp(xd);
vp9_write_token(w, vp9_switchable_interp_tree,
- cm->fc.switchable_interp_prob[ctx],
+ cm->fc->switchable_interp_prob[ctx],
&switchable_interp_encodings[mbmi->interp_filter]);
++cpi->interp_filter_selected[0][mbmi->interp_filter];
} else {
@@ -528,7 +528,7 @@ static void update_coef_probs_common(vp9_writer* const bc, VP9_COMP *cpi,
TX_SIZE tx_size,
vp9_coeff_stats *frame_branch_ct,
vp9_coeff_probs_model *new_coef_probs) {
- vp9_coeff_probs_model *old_coef_probs = cpi->common.fc.coef_probs[tx_size];
+ vp9_coeff_probs_model *old_coef_probs = cpi->common.fc->coef_probs[tx_size];
const vp9_prob upd = DIFF_UPDATE_PROB;
const int entropy_nodes_update = UNCONSTRAINED_NODES;
int i, j, k, l, t;
@@ -830,20 +830,20 @@ static void encode_txfm_probs(VP9_COMMON *cm, vp9_writer *w) {
for (i = 0; i < TX_SIZE_CONTEXTS; i++) {
tx_counts_to_branch_counts_8x8(cm->counts.tx.p8x8[i], ct_8x8p);
for (j = 0; j < TX_SIZES - 3; j++)
- vp9_cond_prob_diff_update(w, &cm->fc.tx_probs.p8x8[i][j], ct_8x8p[j]);
+ vp9_cond_prob_diff_update(w, &cm->fc->tx_probs.p8x8[i][j], ct_8x8p[j]);
}
for (i = 0; i < TX_SIZE_CONTEXTS; i++) {
tx_counts_to_branch_counts_16x16(cm->counts.tx.p16x16[i], ct_16x16p);
for (j = 0; j < TX_SIZES - 2; j++)
- vp9_cond_prob_diff_update(w, &cm->fc.tx_probs.p16x16[i][j],
+ vp9_cond_prob_diff_update(w, &cm->fc->tx_probs.p16x16[i][j],
ct_16x16p[j]);
}
for (i = 0; i < TX_SIZE_CONTEXTS; i++) {
tx_counts_to_branch_counts_32x32(cm->counts.tx.p32x32[i], ct_32x32p);
for (j = 0; j < TX_SIZES - 1; j++)
- vp9_cond_prob_diff_update(w, &cm->fc.tx_probs.p32x32[i][j],
+ vp9_cond_prob_diff_update(w, &cm->fc->tx_probs.p32x32[i][j],
ct_32x32p[j]);
}
}
@@ -1161,7 +1161,7 @@ static void write_uncompressed_header(VP9_COMP *cpi,
static size_t write_compressed_header(VP9_COMP *cpi, uint8_t *data) {
VP9_COMMON *const cm = &cpi->common;
MACROBLOCKD *const xd = &cpi->mb.e_mbd;
- FRAME_CONTEXT *const fc = &cm->fc;
+ FRAME_CONTEXT *const fc = cm->fc;
vp9_writer header_bc;
vp9_start_encode(&header_bc, data);
@@ -1178,7 +1178,7 @@ static size_t write_compressed_header(VP9_COMP *cpi, uint8_t *data) {
int i;
for (i = 0; i < INTER_MODE_CONTEXTS; ++i)
- prob_diff_update(vp9_inter_mode_tree, cm->fc.inter_mode_probs[i],
+ prob_diff_update(vp9_inter_mode_tree, cm->fc->inter_mode_probs[i],
cm->counts.inter_mode[i], INTER_MODES, &header_bc);
vp9_zero(cm->counts.inter_mode);
@@ -1219,7 +1219,7 @@ static size_t write_compressed_header(VP9_COMP *cpi, uint8_t *data) {
cm->counts.comp_ref[i]);
for (i = 0; i < BLOCK_SIZE_GROUPS; ++i)
- prob_diff_update(vp9_intra_mode_tree, cm->fc.y_mode_prob[i],
+ prob_diff_update(vp9_intra_mode_tree, cm->fc->y_mode_prob[i],
cm->counts.y_mode[i], INTRA_MODES, &header_bc);
for (i = 0; i < PARTITION_CONTEXTS; ++i)