summaryrefslogtreecommitdiff
path: root/vp9/encoder/vp9_encoder.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_encoder.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_encoder.c')
-rw-r--r--vp9/encoder/vp9_encoder.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c
index 1758e3fdb..6359754e9 100644
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -134,7 +134,7 @@ static void setup_frame(VP9_COMP *cpi) {
cpi->refresh_alt_ref_frame = 1;
vp9_zero(cpi->interp_filter_selected);
} else {
- cm->fc = cm->frame_contexts[cm->frame_context_idx];
+ *cm->fc = cm->frame_contexts[cm->frame_context_idx];
vp9_zero(cpi->interp_filter_selected[0]);
}
}
@@ -160,6 +160,11 @@ static void dealloc_compressor_data(VP9_COMP *cpi) {
VP9_COMMON *const cm = &cpi->common;
int i;
+ vpx_free(cm->fc);
+ cm->fc = NULL;
+ vpx_free(cm->frame_contexts);
+ cm->frame_contexts = NULL;
+
// Delete sementation map
vpx_free(cpi->segmentation_map);
cpi->segmentation_map = NULL;
@@ -257,7 +262,7 @@ static void save_coding_context(VP9_COMP *cpi) {
vp9_copy(cc->last_ref_lf_deltas, cm->lf.last_ref_deltas);
vp9_copy(cc->last_mode_lf_deltas, cm->lf.last_mode_deltas);
- cc->fc = cm->fc;
+ cc->fc = *cm->fc;
}
static void restore_coding_context(VP9_COMP *cpi) {
@@ -286,7 +291,7 @@ static void restore_coding_context(VP9_COMP *cpi) {
vp9_copy(cm->lf.last_ref_deltas, cc->last_ref_lf_deltas);
vp9_copy(cm->lf.last_mode_deltas, cc->last_mode_lf_deltas);
- cm->fc = cc->fc;
+ *cm->fc = cc->fc;
}
static void configure_static_seg_features(VP9_COMP *cpi) {
@@ -1374,6 +1379,12 @@ VP9_COMP *vp9_create_compressor(VP9EncoderConfig *oxcf) {
cm->error.setjmp = 1;
+ CHECK_MEM_ERROR(cm, cm->fc,
+ (FRAME_CONTEXT *)vpx_calloc(1, sizeof(*cm->fc)));
+ CHECK_MEM_ERROR(cm, cm->frame_contexts,
+ (FRAME_CONTEXT *)vpx_calloc(FRAME_CONTEXTS,
+ sizeof(*cm->frame_contexts)));
+
cpi->use_svc = 0;
init_config(cpi, oxcf);
@@ -3647,7 +3658,7 @@ int vp9_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags,
}
if (cm->refresh_frame_context)
- cm->frame_contexts[cm->frame_context_idx] = cm->fc;
+ cm->frame_contexts[cm->frame_context_idx] = *cm->fc;
// Frame was dropped, release scaled references.
if (*size == 0) {