OLD | NEW |
1 // Copyright 2013 Google Inc. All Rights Reserved. | 1 // Copyright 2013 Google Inc. All Rights Reserved. |
2 // | 2 // |
3 // Use of this source code is governed by a BSD-style license | 3 // Use of this source code is governed by a BSD-style license |
4 // that can be found in the COPYING file in the root of the source | 4 // that can be found in the COPYING file in the root of the source |
5 // tree. An additional intellectual property rights grant can be found | 5 // tree. An additional intellectual property rights grant can be found |
6 // in the file PATENTS. All contributing project authors may | 6 // in the file PATENTS. All contributing project authors may |
7 // be found in the AUTHORS file in the root of the source tree. | 7 // be found in the AUTHORS file in the root of the source tree. |
8 // ----------------------------------------------------------------------------- | 8 // ----------------------------------------------------------------------------- |
9 // | 9 // |
10 // Implement gradient smoothing: we replace a current alpha value by its | 10 // Implement gradient smoothing: we replace a current alpha value by its |
(...skipping 14 matching lines...) Expand all Loading... |
25 #define FIX 16 // fix-point precision for averaging | 25 #define FIX 16 // fix-point precision for averaging |
26 #define LFIX 2 // extra precision for look-up table | 26 #define LFIX 2 // extra precision for look-up table |
27 #define LUT_SIZE ((1 << (8 + LFIX)) - 1) // look-up table size | 27 #define LUT_SIZE ((1 << (8 + LFIX)) - 1) // look-up table size |
28 | 28 |
29 #if defined(USE_DITHERING) | 29 #if defined(USE_DITHERING) |
30 | 30 |
31 #define DFIX 4 // extra precision for ordered dithering | 31 #define DFIX 4 // extra precision for ordered dithering |
32 #define DSIZE 4 // dithering size (must be a power of two) | 32 #define DSIZE 4 // dithering size (must be a power of two) |
33 // cf. http://en.wikipedia.org/wiki/Ordered_dithering | 33 // cf. http://en.wikipedia.org/wiki/Ordered_dithering |
34 static const uint8_t kOrderedDither[DSIZE][DSIZE] = { | 34 static const uint8_t kOrderedDither[DSIZE][DSIZE] = { |
35 { 0, 8, 2, 10 }, // coefficients are in DFIX fixed-point precision | 35 { 0, 8, 2, 10 }, // coefficients are in DFIX fixed-point precision |
36 { 12, 4, 14, 6 }, | 36 { 12, 4, 14, 6 }, |
37 { 3, 11, 1, 9 }, | 37 { 3, 11, 1, 9 }, |
38 { 15, 7, 13, 5 } | 38 { 15, 7, 13, 5 } |
39 }; | 39 }; |
40 | 40 |
41 #else | 41 #else |
42 #define DFIX 0 | 42 #define DFIX 0 |
43 #endif | 43 #endif |
44 | 44 |
45 typedef struct { | 45 typedef struct { |
46 int width_, height_; // dimension | 46 int width_, height_; // dimension |
47 int row_; // current input row being processed | 47 int row_; // current input row being processed |
48 uint8_t* src_; // input pointer | 48 uint8_t* src_; // input pointer |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 if (p.row_ >= p.radius_) { | 270 if (p.row_ >= p.radius_) { |
271 HFilter(&p); | 271 HFilter(&p); |
272 ApplyFilter(&p); | 272 ApplyFilter(&p); |
273 } | 273 } |
274 } | 274 } |
275 } | 275 } |
276 CleanupParams(&p); | 276 CleanupParams(&p); |
277 } | 277 } |
278 return 1; | 278 return 1; |
279 } | 279 } |
OLD | NEW |