summaryrefslogtreecommitdiff
path: root/vp9
diff options
context:
space:
mode:
authorhkuang <hkuang@google.com>2015-03-16 16:17:51 -0700
committerhkuang <hkuang@google.com>2015-03-19 12:21:00 -0700
commitb88dac8938106537460889e5eacaaafe59715048 (patch)
tree4b516847397c74fb6f4868316d43cce772d3062b /vp9
parentde3097aa2373a441b76364cc9a813b29462f86a1 (diff)
downloadlibvpx-b88dac8938106537460889e5eacaaafe59715048.tar
libvpx-b88dac8938106537460889e5eacaaafe59715048.tar.gz
libvpx-b88dac8938106537460889e5eacaaafe59715048.tar.bz2
libvpx-b88dac8938106537460889e5eacaaafe59715048.zip
Safely free all the frame buffers after all the workers finish the work.
Issue: 978 Change-Id: Ia7aa809095008f6819a44d7ecb0329def79b1117
Diffstat (limited to 'vp9')
-rw-r--r--vp9/common/vp9_alloccommon.c8
-rw-r--r--vp9/common/vp9_alloccommon.h4
-rw-r--r--vp9/common/vp9_onyxc_int.h2
-rw-r--r--vp9/encoder/vp9_encoder.c9
-rw-r--r--vp9/vp9_dx_iface.c7
5 files changed, 23 insertions, 7 deletions
diff --git a/vp9/common/vp9_alloccommon.c b/vp9/common/vp9_alloccommon.c
index e209788c3..20cf68618 100644
--- a/vp9/common/vp9_alloccommon.c
+++ b/vp9/common/vp9_alloccommon.c
@@ -83,8 +83,7 @@ static void free_seg_map(VP9_COMMON *cm) {
}
}
-void vp9_free_ref_frame_buffers(VP9_COMMON *cm) {
- BufferPool *const pool = cm->buffer_pool;
+void vp9_free_ref_frame_buffers(BufferPool *pool) {
int i;
for (i = 0; i < FRAME_BUFFERS; ++i) {
@@ -97,10 +96,14 @@ void vp9_free_ref_frame_buffers(VP9_COMMON *cm) {
pool->frame_bufs[i].mvs = NULL;
vp9_free_frame_buffer(&pool->frame_bufs[i].buf);
}
+}
+void vp9_free_postproc_buffers(VP9_COMMON *cm) {
#if CONFIG_VP9_POSTPROC
vp9_free_frame_buffer(&cm->post_proc_buffer);
vp9_free_frame_buffer(&cm->post_proc_buffer_int);
+#else
+ (void)cm;
#endif
}
@@ -142,7 +145,6 @@ int vp9_alloc_context_buffers(VP9_COMMON *cm, int width, int height) {
}
void vp9_remove_common(VP9_COMMON *cm) {
- vp9_free_ref_frame_buffers(cm);
vp9_free_context_buffers(cm);
vpx_free(cm->fc);
diff --git a/vp9/common/vp9_alloccommon.h b/vp9/common/vp9_alloccommon.h
index d82397fa3..c0e51a6ce 100644
--- a/vp9/common/vp9_alloccommon.h
+++ b/vp9/common/vp9_alloccommon.h
@@ -19,6 +19,7 @@ extern "C" {
#endif
struct VP9Common;
+struct BufferPool;
void vp9_remove_common(struct VP9Common *cm);
@@ -26,7 +27,8 @@ int vp9_alloc_context_buffers(struct VP9Common *cm, int width, int height);
void vp9_init_context_buffers(struct VP9Common *cm);
void vp9_free_context_buffers(struct VP9Common *cm);
-void vp9_free_ref_frame_buffers(struct VP9Common *cm);
+void vp9_free_ref_frame_buffers(struct BufferPool *pool);
+void vp9_free_postproc_buffers(struct VP9Common *cm);
int vp9_alloc_state_buffers(struct VP9Common *cm, int width, int height);
void vp9_free_state_buffers(struct VP9Common *cm);
diff --git a/vp9/common/vp9_onyxc_int.h b/vp9/common/vp9_onyxc_int.h
index 7ca24a56e..62e4ee7a5 100644
--- a/vp9/common/vp9_onyxc_int.h
+++ b/vp9/common/vp9_onyxc_int.h
@@ -88,7 +88,7 @@ typedef struct {
int col;
} RefCntBuffer;
-typedef struct {
+typedef struct BufferPool {
// Protect BufferPool from being accessed by several FrameWorkers at
// the same time during frame parallel decode.
// TODO(hkuang): Try to use atomic variable instead of locking the whole pool.
diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c
index 347570c96..f64b3ac82 100644
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -303,7 +303,10 @@ static void dealloc_compressor_data(VP9_COMP *cpi) {
vpx_free(cpi->active_map.map);
cpi->active_map.map = NULL;
- vp9_free_ref_frame_buffers(cm);
+ vp9_free_ref_frame_buffers(cm->buffer_pool);
+#if CONFIG_VP9_POSTPROC
+ vp9_free_postproc_buffers(cm);
+#endif
vp9_free_context_buffers(cm);
vp9_free_frame_buffer(&cpi->last_frame_uf);
@@ -1896,6 +1899,10 @@ void vp9_remove_compressor(VP9_COMP *cpi) {
#endif
vp9_remove_common(cm);
+ vp9_free_ref_frame_buffers(cm->buffer_pool);
+#if CONFIG_VP9_POSTPROC
+ vp9_free_postproc_buffers(cm);
+#endif
vpx_free(cpi);
#if CONFIG_VP9_TEMPORAL_DENOISING
diff --git a/vp9/vp9_dx_iface.c b/vp9/vp9_dx_iface.c
index 9e4c1a5c4..7350cb392 100644
--- a/vp9/vp9_dx_iface.c
+++ b/vp9/vp9_dx_iface.c
@@ -116,6 +116,9 @@ static vpx_codec_err_t decoder_destroy(vpx_codec_alg_priv_t *ctx) {
(FrameWorkerData *)worker->data1;
vp9_get_worker_interface()->end(worker);
vp9_remove_common(&frame_worker_data->pbi->common);
+#if CONFIG_VP9_POSTPROC
+ vp9_free_postproc_buffers(&frame_worker_data->pbi->common);
+#endif
vp9_decoder_remove(frame_worker_data->pbi);
vpx_free(frame_worker_data->scratch_buffer);
#if CONFIG_MULTITHREAD
@@ -129,8 +132,10 @@ static vpx_codec_err_t decoder_destroy(vpx_codec_alg_priv_t *ctx) {
#endif
}
- if (ctx->buffer_pool)
+ if (ctx->buffer_pool) {
+ vp9_free_ref_frame_buffers(ctx->buffer_pool);
vp9_free_internal_frame_buffers(&ctx->buffer_pool->int_frame_buffers);
+ }
vpx_free(ctx->frame_workers);
vpx_free(ctx->buffer_pool);