summaryrefslogtreecommitdiff
path: root/vp9/common
diff options
context:
space:
mode:
authorMinghai Shang <minghai@google.com>2015-05-20 11:05:22 -0700
committerMinghai Shang <minghai@google.com>2015-05-20 11:05:22 -0700
commit48bfee879705f28cc5f1fa7f3beaf0c363d29ea9 (patch)
treec8c15557db12ddf0c16955978bff0383530bd098 /vp9/common
parent37d03809bfb523910b2a07a726a0dad82980047b (diff)
downloadlibvpx-48bfee879705f28cc5f1fa7f3beaf0c363d29ea9.tar
libvpx-48bfee879705f28cc5f1fa7f3beaf0c363d29ea9.tar.gz
libvpx-48bfee879705f28cc5f1fa7f3beaf0c363d29ea9.tar.bz2
libvpx-48bfee879705f28cc5f1fa7f3beaf0c363d29ea9.zip
[decoder] Optimize context buffer re-allocation
1. Check existing buffer sizes when re-allocate context buffers. 2. Don't need to set mi buffers to 0 during setup_mi. Change-Id: I6b48b0e077a4d804312b605ad0dc34aec5795a6d
Diffstat (limited to 'vp9/common')
-rw-r--r--vp9/common/vp9_alloccommon.c42
-rw-r--r--vp9/common/vp9_onyxc_int.h2
2 files changed, 29 insertions, 15 deletions
diff --git a/vp9/common/vp9_alloccommon.c b/vp9/common/vp9_alloccommon.c
index 600cb13d8..8eda491de 100644
--- a/vp9/common/vp9_alloccommon.c
+++ b/vp9/common/vp9_alloccommon.c
@@ -57,6 +57,7 @@ static int alloc_seg_map(VP9_COMMON *cm, int seg_map_size) {
if (cm->seg_map_array[i] == NULL)
return 1;
}
+ cm->seg_map_alloc_size = seg_map_size;
// Init the index.
cm->seg_map_idx = 0;
@@ -118,25 +119,36 @@ void vp9_free_context_buffers(VP9_COMMON *cm) {
}
int vp9_alloc_context_buffers(VP9_COMMON *cm, int width, int height) {
- vp9_free_context_buffers(cm);
+ int new_mi_size;
vp9_set_mb_mi(cm, width, height);
- if (cm->alloc_mi(cm, cm->mi_stride * calc_mi_size(cm->mi_rows)))
- goto fail;
-
- // Create the segmentation map structure and set to 0.
- free_seg_map(cm);
- if (alloc_seg_map(cm, cm->mi_rows * cm->mi_cols))
- goto fail;
+ new_mi_size = cm->mi_stride * calc_mi_size(cm->mi_rows);
+ if (cm->mi_alloc_size < new_mi_size) {
+ cm->free_mi(cm);
+ if (cm->alloc_mi(cm, new_mi_size))
+ goto fail;
+ }
- cm->above_context = (ENTROPY_CONTEXT *)vpx_calloc(
- 2 * mi_cols_aligned_to_sb(cm->mi_cols) * MAX_MB_PLANE,
- sizeof(*cm->above_context));
- if (!cm->above_context) goto fail;
+ if (cm->seg_map_alloc_size < cm->mi_rows * cm->mi_cols) {
+ // Create the segmentation map structure and set to 0.
+ free_seg_map(cm);
+ if (alloc_seg_map(cm, cm->mi_rows * cm->mi_cols))
+ goto fail;
+ }
- cm->above_seg_context = (PARTITION_CONTEXT *)vpx_calloc(
- mi_cols_aligned_to_sb(cm->mi_cols), sizeof(*cm->above_seg_context));
- if (!cm->above_seg_context) goto fail;
+ if (cm->above_context_alloc_cols < cm->mi_cols) {
+ vpx_free(cm->above_context);
+ cm->above_context = (ENTROPY_CONTEXT *)vpx_calloc(
+ 2 * mi_cols_aligned_to_sb(cm->mi_cols) * MAX_MB_PLANE,
+ sizeof(*cm->above_context));
+ if (!cm->above_context) goto fail;
+
+ vpx_free(cm->above_seg_context);
+ cm->above_seg_context = (PARTITION_CONTEXT *)vpx_calloc(
+ mi_cols_aligned_to_sb(cm->mi_cols), sizeof(*cm->above_seg_context));
+ if (!cm->above_seg_context) goto fail;
+ cm->above_context_alloc_cols = cm->mi_cols;
+ }
return 0;
diff --git a/vp9/common/vp9_onyxc_int.h b/vp9/common/vp9_onyxc_int.h
index 5179c6906..f710f8106 100644
--- a/vp9/common/vp9_onyxc_int.h
+++ b/vp9/common/vp9_onyxc_int.h
@@ -220,6 +220,7 @@ typedef struct VP9Common {
uint8_t *seg_map_array[NUM_PING_PONG_BUFFERS];
uint8_t *last_frame_seg_map;
uint8_t *current_frame_seg_map;
+ int seg_map_alloc_size;
INTERP_FILTER interp_filter;
@@ -276,6 +277,7 @@ typedef struct VP9Common {
PARTITION_CONTEXT *above_seg_context;
ENTROPY_CONTEXT *above_context;
+ int above_context_alloc_cols;
} VP9_COMMON;
// TODO(hkuang): Don't need to lock the whole pool after implementing atomic