summaryrefslogtreecommitdiff
path: root/vp9/encoder
diff options
context:
space:
mode:
authorJingning Han <jingning@google.com>2015-01-03 12:00:46 -0800
committerJingning Han <jingning@google.com>2015-01-07 08:49:04 -0800
commit27582e573b0f6fcee45dd860d67fe6ffa6ba86ba (patch)
treeaddeb4f3ae60589686e955f0774d64ad8c775a72 /vp9/encoder
parent5b860e1251c62f0561274ffdec53ec879250b268 (diff)
downloadlibvpx-27582e573b0f6fcee45dd860d67fe6ffa6ba86ba.tar
libvpx-27582e573b0f6fcee45dd860d67fe6ffa6ba86ba.tar.gz
libvpx-27582e573b0f6fcee45dd860d67fe6ffa6ba86ba.tar.bz2
libvpx-27582e573b0f6fcee45dd860d67fe6ffa6ba86ba.zip
Skip duplicate denoiser frame buffer allocation
Allocate the frame buffer allocation for denoiser once during the encoder initialization. This avoids allocating frame buffer multiple times and overwriting the buffer pointer without proper releasing. Change-Id: I9b3baa6283449d86fd164534d344c036bb035700
Diffstat (limited to 'vp9/encoder')
-rw-r--r--vp9/encoder/vp9_denoiser.c2
-rw-r--r--vp9/encoder/vp9_denoiser.h1
-rw-r--r--vp9/encoder/vp9_encoder.c32
3 files changed, 24 insertions, 11 deletions
diff --git a/vp9/encoder/vp9_denoiser.c b/vp9/encoder/vp9_denoiser.c
index 56ec6b335..e0ebb7750 100644
--- a/vp9/encoder/vp9_denoiser.c
+++ b/vp9/encoder/vp9_denoiser.c
@@ -458,12 +458,14 @@ int vp9_denoiser_alloc(VP9_DENOISER *denoiser, int width, int height,
make_grayscale(&denoiser->running_avg_y[i]);
#endif
denoiser->increase_denoising = 0;
+ denoiser->frame_buffer_initialized = 1;
return 0;
}
void vp9_denoiser_free(VP9_DENOISER *denoiser) {
int i;
+ denoiser->frame_buffer_initialized = 0;
if (denoiser == NULL) {
return;
}
diff --git a/vp9/encoder/vp9_denoiser.h b/vp9/encoder/vp9_denoiser.h
index 421dfcd0c..8eb5da1b8 100644
--- a/vp9/encoder/vp9_denoiser.h
+++ b/vp9/encoder/vp9_denoiser.h
@@ -29,6 +29,7 @@ typedef struct vp9_denoiser {
YV12_BUFFER_CONFIG running_avg_y[MAX_REF_FRAMES];
YV12_BUFFER_CONFIG mc_running_avg_y;
int increase_denoising;
+ int frame_buffer_initialized;
} VP9_DENOISER;
void vp9_denoiser_update_frame_info(VP9_DENOISER *denoiser,
diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c
index b7bfddff1..628660b5f 100644
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -1347,17 +1347,6 @@ void vp9_change_config(struct VP9_COMP *cpi, const VP9EncoderConfig *oxcf) {
#if CONFIG_VP9_HIGHBITDEPTH
highbd_set_var_fns(cpi);
#endif
-
-#if CONFIG_VP9_TEMPORAL_DENOISING
- if (cpi->oxcf.noise_sensitivity > 0) {
- vp9_denoiser_alloc(&(cpi->denoiser), cm->width, cm->height,
- cm->subsampling_x, cm->subsampling_y,
-#if CONFIG_VP9_HIGHBITDEPTH
- cm->use_highbitdepth,
-#endif
- VP9_ENC_BORDER_IN_PIXELS);
- }
-#endif
}
#ifndef M_LOG2_E
@@ -3408,6 +3397,20 @@ static void check_initial_width(VP9_COMP *cpi,
}
}
+#if CONFIG_VP9_TEMPORAL_DENOISING
+static void setup_denoiser_buffer(VP9_COMP *cpi) {
+ VP9_COMMON *const cm = &cpi->common;
+ if (cpi->oxcf.noise_sensitivity > 0 &&
+ !cpi->denoiser.frame_buffer_initialized) {
+ vp9_denoiser_alloc(&(cpi->denoiser), cm->width, cm->height,
+ cm->subsampling_x, cm->subsampling_y,
+#if CONFIG_VP9_HIGHBITDEPTH
+ cm->use_highbitdepth,
+#endif
+ VP9_ENC_BORDER_IN_PIXELS);
+ }
+}
+#endif
int vp9_receive_raw_frame(VP9_COMP *cpi, unsigned int frame_flags,
YV12_BUFFER_CONFIG *sd, int64_t time_stamp,
@@ -3424,6 +3427,9 @@ int vp9_receive_raw_frame(VP9_COMP *cpi, unsigned int frame_flags,
check_initial_width(cpi, subsampling_x, subsampling_y);
#endif // CONFIG_VP9_HIGHBITDEPTH
+#if CONFIG_VP9_TEMPORAL_DENOISING
+ setup_denoiser_buffer(cpi);
+#endif
vpx_usec_timer_start(&timer);
if (vp9_lookahead_push(cpi->lookahead, sd, time_stamp, end_time, frame_flags))
@@ -3998,6 +4004,10 @@ int vp9_set_size_literal(VP9_COMP *cpi, unsigned int width,
check_initial_width(cpi, 1, 1);
#endif // CONFIG_VP9_HIGHBITDEPTH
+#if CONFIG_VP9_TEMPORAL_DENOISING
+ setup_denoiser_buffer(cpi);
+#endif
+
if (width) {
cm->width = width;
if (cm->width > cpi->initial_width) {