Merge "addnoise : clear out static size for generated noise"

This commit is contained in:
James Bankoski 2016-07-16 01:48:07 +00:00 committed by Gerrit Code Review
commit ce6678fdc9
6 changed files with 34 additions and 12 deletions

View File

@ -32,6 +32,9 @@ void vp8_de_alloc_frame_buffers(VP8_COMMON *oci)
vpx_free(oci->pp_limits_buffer);
oci->pp_limits_buffer = NULL;
vpx_free(oci->postproc_state.generated_noise);
oci->postproc_state.generated_noise = NULL;
#endif
vpx_free(oci->above_context);

View File

@ -411,6 +411,16 @@ int vp8_post_proc_frame(VP8_COMMON *oci, YV12_BUFFER_CONFIG *dest, vp8_ppflags_t
oci->postproc_state.last_frame_valid = 1;
return 0;
}
if (flags & VP8D_ADDNOISE)
{
if (!oci->postproc_state.generated_noise)
{
oci->postproc_state.generated_noise = vpx_calloc(
oci->Width + 256, sizeof(*oci->postproc_state.generated_noise));
if (!oci->postproc_state.generated_noise)
return 1;
}
}
/* Allocate post_proc_buffer_int if needed */
if ((flags & VP8D_MFQE) && !oci->post_proc_buffer_int_used)
@ -494,16 +504,15 @@ int vp8_post_proc_frame(VP8_COMMON *oci, YV12_BUFFER_CONFIG *dest, vp8_ppflags_t
struct postproc_state *ppstate = &oci->postproc_state;
vp8_clear_system_state();
sigma = noise_level + .5 + .6 * q / 63.0;
oci->postproc_state.clamp = vpx_setup_noise(sigma,
ppstate->noise,
sizeof(ppstate->noise));
ppstate->clamp = vpx_setup_noise(sigma, ppstate->generated_noise,
oci->Width + 256);
ppstate->last_q = q;
ppstate->last_noise = noise_level;
}
vpx_plane_add_noise
(oci->post_proc_buffer.y_buffer,
oci->postproc_state.noise,
oci->postproc_state.generated_noise,
oci->postproc_state.clamp,
oci->postproc_state.clamp,
oci->post_proc_buffer.y_width, oci->post_proc_buffer.y_height,

View File

@ -17,10 +17,10 @@ struct postproc_state
{
int last_q;
int last_noise;
int8_t noise[3072];
int last_base_qindex;
int last_frame_valid;
int clamp;
int8_t *generated_noise;
};
#include "onyxc_int.h"
#include "ppflags.h"

View File

@ -104,7 +104,9 @@ void vp9_free_postproc_buffers(VP9_COMMON *cm) {
vpx_free_frame_buffer(&cm->post_proc_buffer);
vpx_free_frame_buffer(&cm->post_proc_buffer_int);
vpx_free(cm->postproc_state.limits);
cm->postproc_state.limits = 0;
cm->postproc_state.limits = NULL;
vpx_free(cm->postproc_state.generated_noise);
cm->postproc_state.generated_noise = NULL;
#else
(void)cm;
#endif

View File

@ -379,6 +379,14 @@ int vp9_post_proc_frame(struct VP9Common *cm,
}
}
if (flags & VP9D_ADDNOISE) {
if (!cm->postproc_state.generated_noise) {
cm->postproc_state.generated_noise = vpx_calloc(
cm->width + 256, sizeof(*cm->postproc_state.generated_noise));
if (!cm->postproc_state.generated_noise)
return 1;
}
}
if ((flags & VP9D_MFQE) && cm->current_video_frame >= 2 &&
ppstate->last_frame_valid && cm->bit_depth == 8 &&
@ -420,14 +428,14 @@ int vp9_post_proc_frame(struct VP9Common *cm,
double sigma;
vpx_clear_system_state();
sigma = noise_level + .5 + .6 * q / 63.0;
ppstate->clamp = vpx_setup_noise(sigma, ppstate->noise,
sizeof(ppstate->noise));
ppstate->clamp = vpx_setup_noise(sigma, ppstate->generated_noise,
cm->width + 256);
ppstate->last_q = q;
ppstate->last_noise = noise_level;
}
vpx_plane_add_noise(ppbuf->y_buffer, ppstate->noise, ppstate->clamp,
ppstate->clamp, ppbuf->y_width, ppbuf->y_height,
ppbuf->y_stride);
vpx_plane_add_noise(ppbuf->y_buffer, ppstate->generated_noise,
ppstate->clamp, ppstate->clamp, ppbuf->y_width,
ppbuf->y_height, ppbuf->y_stride);
}
*dest = *ppbuf;

View File

@ -25,13 +25,13 @@ extern "C" {
struct postproc_state {
int last_q;
int last_noise;
int8_t noise[3072];
int last_base_qindex;
int last_frame_valid;
MODE_INFO *prev_mip;
MODE_INFO *prev_mi;
int clamp;
uint8_t *limits;
int8_t *generated_noise;
};
struct VP9Common;