postproc: noise style fixes.
Change-Id: Ifdcb36b8e77b65faeeb10644256e175acb32275d
This commit is contained in:
parent
2ca24b0075
commit
e736691a6d
@ -49,7 +49,7 @@ TEST_P(AddNoiseTest, CheckNoiseAdded) {
|
||||
const int height = 64;
|
||||
const int image_size = width * height;
|
||||
char noise[3072];
|
||||
const int clamp = vpx_setup_noise(sizeof(noise), 4.4, noise);
|
||||
const int clamp = vpx_setup_noise(4.4, sizeof(noise), noise);
|
||||
|
||||
for (int i = 0; i < 16; i++) {
|
||||
blackclamp[i] = clamp;
|
||||
@ -84,7 +84,7 @@ TEST_P(AddNoiseTest, CheckNoiseAdded) {
|
||||
|
||||
// Check to make sure don't roll over.
|
||||
for (int i = 0; i < image_size; ++i) {
|
||||
EXPECT_GT((int)s[i], clamp) << "i = " << i;
|
||||
EXPECT_GT(static_cast<int>(s[i]), clamp) << "i = " << i;
|
||||
}
|
||||
|
||||
// Initialize pixels in the image to 0 and check for roll under.
|
||||
@ -95,7 +95,7 @@ TEST_P(AddNoiseTest, CheckNoiseAdded) {
|
||||
|
||||
// Check to make sure don't roll under.
|
||||
for (int i = 0; i < image_size; ++i) {
|
||||
EXPECT_LT((int)s[i], 255 - clamp) << "i = " << i;
|
||||
EXPECT_LT(static_cast<int>(s[i]), 255 - clamp) << "i = " << i;
|
||||
}
|
||||
|
||||
vpx_free(s);
|
||||
@ -110,7 +110,7 @@ TEST_P(AddNoiseTest, CheckCvsAssembly) {
|
||||
const int image_size = width * height;
|
||||
char noise[3072];
|
||||
|
||||
const int clamp = vpx_setup_noise(sizeof(noise), 4.4, noise);
|
||||
const int clamp = vpx_setup_noise(4.4, sizeof(noise), noise);
|
||||
|
||||
for (int i = 0; i < 16; i++) {
|
||||
blackclamp[i] = clamp;
|
||||
@ -133,7 +133,7 @@ TEST_P(AddNoiseTest, CheckCvsAssembly) {
|
||||
width, height, width));
|
||||
|
||||
for (int i = 0; i < image_size; ++i) {
|
||||
EXPECT_EQ((int)s[i], (int)d[i]) << "i = " << i;
|
||||
EXPECT_EQ(static_cast<int>(s[i]), static_cast<int>(d[i])) << "i = " << i;
|
||||
}
|
||||
|
||||
vpx_free(d);
|
||||
|
@ -495,7 +495,7 @@ 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;
|
||||
clamp = vpx_setup_noise(sizeof(ppstate->noise), sigma,
|
||||
clamp = vpx_setup_noise(sigma, sizeof(ppstate->noise),
|
||||
ppstate->noise);
|
||||
for (i = 0; i < 16; i++)
|
||||
{
|
||||
|
@ -421,7 +421,7 @@ int vp9_post_proc_frame(struct VP9Common *cm,
|
||||
int clamp, i;
|
||||
vpx_clear_system_state();
|
||||
sigma = noise_level + .5 + .6 * q / 63.0;
|
||||
clamp = vpx_setup_noise(sizeof(ppstate->noise), sigma,
|
||||
clamp = vpx_setup_noise(sigma, sizeof(ppstate->noise),
|
||||
ppstate->noise);
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
|
@ -24,11 +24,11 @@ void vpx_plane_add_noise_c(uint8_t *start, char *noise,
|
||||
unsigned int width, unsigned int height, int pitch) {
|
||||
unsigned int i, j;
|
||||
|
||||
for (i = 0; i < height; i++) {
|
||||
for (i = 0; i < height; ++i) {
|
||||
uint8_t *pos = start + i * pitch;
|
||||
char *ref = (char *)(noise + (rand() & 0xff)); // NOLINT
|
||||
|
||||
for (j = 0; j < width; j++) {
|
||||
for (j = 0; j < width; ++j) {
|
||||
int v = pos[j];
|
||||
|
||||
v = clamp(v - blackclamp[0], 0, 255);
|
||||
@ -45,28 +45,27 @@ static double gaussian(double sigma, double mu, double x) {
|
||||
(exp(-(x - mu) * (x - mu) / (2 * sigma * sigma)));
|
||||
}
|
||||
|
||||
int vpx_setup_noise(int size, double sigma, char *noise) {
|
||||
int vpx_setup_noise(double sigma, int size, char *noise) {
|
||||
char char_dist[256];
|
||||
int next, i, j;
|
||||
|
||||
next = 0;
|
||||
int next = 0, i, j;
|
||||
|
||||
// set up a 256 entry lookup that matches gaussian distribution
|
||||
for (i = -32; i < 32; i++) {
|
||||
int a_i = (int) (0.5 + 256 * gaussian(sigma, 0, i));
|
||||
for (i = -32; i < 32; ++i) {
|
||||
const int a_i = (int) (0.5 + 256 * gaussian(sigma, 0, i));
|
||||
if (a_i) {
|
||||
for (j = 0; j < a_i; j++) {
|
||||
char_dist[next + j] = (char) (i);
|
||||
for (j = 0; j < a_i; ++j) {
|
||||
char_dist[next + j] = (char)i;
|
||||
}
|
||||
next = next + j;
|
||||
}
|
||||
}
|
||||
|
||||
// Rounding error - might mean we have less than 256.
|
||||
for (; next < 256; next++)
|
||||
for (; next < 256; ++next) {
|
||||
char_dist[next] = 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < size; i++) {
|
||||
for (i = 0; i < size; ++i) {
|
||||
noise[i] = char_dist[rand() & 0xff]; // NOLINT
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int vpx_setup_noise(int size, double sigma, char *noise);
|
||||
// Fills a noise buffer with gaussian noise strength determined by sigma.
|
||||
int vpx_setup_noise(double sigma, int size, char *noise);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user