]> granicus.if.org Git - libvpx/blob - vpx_dsp/postproc.c
vpx_dsp/*.[hc]: add missing vpx_dsp_rtcd.h include
[libvpx] / vpx_dsp / postproc.c
1 /*
2  *  Copyright (c) 2015 The WebM project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10
11 #include <stdlib.h>
12
13 #include "./vpx_config.h"
14 #include "./vpx_dsp_rtcd.h"
15
16 #include "vpx/vpx_integer.h"
17 #include "vpx_ports/mem.h"
18
19 void vpx_plane_add_noise_c(uint8_t *start, char *noise,
20                            char blackclamp[16],
21                            char whiteclamp[16],
22                            char bothclamp[16],
23                            unsigned int width, unsigned int height, int pitch) {
24   unsigned int i, j;
25
26   // TODO(jbb): why does simd code use both but c doesn't,  normalize and
27   // fix..
28   (void) bothclamp;
29   for (i = 0; i < height; i++) {
30     uint8_t *pos = start + i * pitch;
31     char  *ref = (char *)(noise + (rand() & 0xff));  // NOLINT
32
33     for (j = 0; j < width; j++) {
34       if (pos[j] < blackclamp[0])
35         pos[j] = blackclamp[0];
36
37       if (pos[j] > 255 - whiteclamp[0])
38         pos[j] = 255 - whiteclamp[0];
39
40       pos[j] += ref[j];
41     }
42   }
43 }