Merge "libvpx: vpx_add_plane_noise make c match assembly"
This commit is contained in:
Коммит
7cced7b3ea
|
@ -144,8 +144,7 @@ TEST_P(AddNoiseTest, CheckNoiseAdded) {
|
|||
vpx_free(s);
|
||||
}
|
||||
|
||||
// TODO(jimbankoski): Make the c work like assembly so we can enable this.
|
||||
TEST_P(AddNoiseTest, DISABLED_CheckCvsAssembly) {
|
||||
TEST_P(AddNoiseTest, CheckCvsAssembly) {
|
||||
DECLARE_ALIGNED(16, char, blackclamp[16]);
|
||||
DECLARE_ALIGNED(16, char, whiteclamp[16]);
|
||||
DECLARE_ALIGNED(16, char, bothclamp[16]);
|
||||
|
@ -167,8 +166,10 @@ TEST_P(AddNoiseTest, DISABLED_CheckCvsAssembly) {
|
|||
memset(s, 99, image_size);
|
||||
memset(d, 99, image_size);
|
||||
|
||||
srand(0);
|
||||
ASM_REGISTER_STATE_CHECK(GetParam()(s, noise, blackclamp, whiteclamp,
|
||||
bothclamp, width, height, width));
|
||||
srand(0);
|
||||
ASM_REGISTER_STATE_CHECK(vpx_plane_add_noise_c(d, noise, blackclamp,
|
||||
whiteclamp, bothclamp,
|
||||
width, height, width));
|
||||
|
|
|
@ -23,21 +23,18 @@ void vpx_plane_add_noise_c(uint8_t *start, char *noise,
|
|||
unsigned int width, unsigned int height, int pitch) {
|
||||
unsigned int i, j;
|
||||
|
||||
// TODO(jbb): why does simd code use both but c doesn't, normalize and
|
||||
// fix..
|
||||
(void) bothclamp;
|
||||
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++) {
|
||||
if (pos[j] < blackclamp[0])
|
||||
pos[j] = blackclamp[0];
|
||||
int v = pos[j];
|
||||
|
||||
if (pos[j] > 255 - whiteclamp[0])
|
||||
pos[j] = 255 - whiteclamp[0];
|
||||
v = clamp(v - blackclamp[0], 0, 255);
|
||||
v = clamp(v + bothclamp[0], 0, 255);
|
||||
v = clamp(v - whiteclamp[0], 0, 255);
|
||||
|
||||
pos[j] += ref[j];
|
||||
pos[j] = v + ref[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче