OLD | NEW |
1 // Copyright 2011 Google Inc. All Rights Reserved. | 1 // Copyright 2011 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 // Spatial prediction using various filters | 10 // Spatial prediction using various filters |
11 // | 11 // |
12 // Author: Urvang (urvang@google.com) | 12 // Author: Urvang (urvang@google.com) |
13 | 13 |
14 #ifndef WEBP_UTILS_FILTERS_H_ | 14 #ifndef WEBP_UTILS_FILTERS_H_ |
15 #define WEBP_UTILS_FILTERS_H_ | 15 #define WEBP_UTILS_FILTERS_H_ |
16 | 16 |
17 #include "../webp/types.h" | 17 #include "../webp/types.h" |
18 | 18 |
19 #if defined(__cplusplus) || defined(c_plusplus) | 19 #ifdef __cplusplus |
20 extern "C" { | 20 extern "C" { |
21 #endif | 21 #endif |
22 | 22 |
23 // Filters. | 23 // Filters. |
24 typedef enum { | 24 typedef enum { |
25 WEBP_FILTER_NONE = 0, | 25 WEBP_FILTER_NONE = 0, |
26 WEBP_FILTER_HORIZONTAL, | 26 WEBP_FILTER_HORIZONTAL, |
27 WEBP_FILTER_VERTICAL, | 27 WEBP_FILTER_VERTICAL, |
28 WEBP_FILTER_GRADIENT, | 28 WEBP_FILTER_GRADIENT, |
29 WEBP_FILTER_LAST = WEBP_FILTER_GRADIENT + 1, // end marker | 29 WEBP_FILTER_LAST = WEBP_FILTER_GRADIENT + 1, // end marker |
30 WEBP_FILTER_BEST, | 30 WEBP_FILTER_BEST, |
31 WEBP_FILTER_FAST | 31 WEBP_FILTER_FAST |
32 } WEBP_FILTER_TYPE; | 32 } WEBP_FILTER_TYPE; |
33 | 33 |
34 typedef void (*WebPFilterFunc)(const uint8_t* in, int width, int height, | 34 typedef void (*WebPFilterFunc)(const uint8_t* in, int width, int height, |
35 int stride, uint8_t* out); | 35 int stride, uint8_t* out); |
36 typedef void (*WebPUnfilterFunc)(int width, int height, int stride, | 36 typedef void (*WebPUnfilterFunc)(int width, int height, int stride, |
37 uint8_t* data); | 37 int row, int num_rows, uint8_t* data); |
38 | 38 |
39 // Filter the given data using the given predictor. | 39 // Filter the given data using the given predictor. |
40 // 'in' corresponds to a 2-dimensional pixel array of size (stride * height) | 40 // 'in' corresponds to a 2-dimensional pixel array of size (stride * height) |
41 // in raster order. | 41 // in raster order. |
42 // 'stride' is number of bytes per scan line (with possible padding). | 42 // 'stride' is number of bytes per scan line (with possible padding). |
43 // 'out' should be pre-allocated. | 43 // 'out' should be pre-allocated. |
44 extern const WebPFilterFunc WebPFilters[WEBP_FILTER_LAST]; | 44 extern const WebPFilterFunc WebPFilters[WEBP_FILTER_LAST]; |
45 | 45 |
46 // In-place reconstruct the original data from the given filtered data. | 46 // In-place reconstruct the original data from the given filtered data. |
| 47 // The reconstruction will be done for 'num_rows' rows starting from 'row' |
| 48 // (assuming rows upto 'row - 1' are already reconstructed). |
47 extern const WebPUnfilterFunc WebPUnfilters[WEBP_FILTER_LAST]; | 49 extern const WebPUnfilterFunc WebPUnfilters[WEBP_FILTER_LAST]; |
48 | 50 |
49 // Fast estimate of a potentially good filter. | 51 // Fast estimate of a potentially good filter. |
50 extern WEBP_FILTER_TYPE EstimateBestFilter(const uint8_t* data, | 52 WEBP_FILTER_TYPE EstimateBestFilter(const uint8_t* data, |
51 int width, int height, int stride); | 53 int width, int height, int stride); |
52 | 54 |
53 #if defined(__cplusplus) || defined(c_plusplus) | 55 #ifdef __cplusplus |
54 } // extern "C" | 56 } // extern "C" |
55 #endif | 57 #endif |
56 | 58 |
57 #endif /* WEBP_UTILS_FILTERS_H_ */ | 59 #endif /* WEBP_UTILS_FILTERS_H_ */ |
OLD | NEW |