blob: dde39cb5c406d39a68260f95326213fcb26ee683 [file] [log] [blame]
Vikas Aroraa2415722012-08-09 16:18:58 -07001// Copyright 2011 Google Inc. All Rights Reserved.
2//
Vikas Arora0406ce12013-08-09 15:57:12 -07003// 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
5// tree. An additional intellectual property rights grant can be found
6// in the file PATENTS. All contributing project authors may
7// be found in the AUTHORS file in the root of the source tree.
Vikas Aroraa2415722012-08-09 16:18:58 -07008// -----------------------------------------------------------------------------
9//
10// Spatial prediction using various filters
11//
12// Author: Urvang (urvang@google.com)
13
14#ifndef WEBP_UTILS_FILTERS_H_
15#define WEBP_UTILS_FILTERS_H_
16
James Zern9e80ee92015-03-17 18:54:21 -070017#include "../webp/types.h"
Vikas Aroraa2415722012-08-09 16:18:58 -070018
Vikas Arora8b720222014-01-02 16:48:02 -080019#ifdef __cplusplus
Vikas Aroraa2415722012-08-09 16:18:58 -070020extern "C" {
21#endif
22
23// Filters.
24typedef enum {
25 WEBP_FILTER_NONE = 0,
26 WEBP_FILTER_HORIZONTAL,
27 WEBP_FILTER_VERTICAL,
28 WEBP_FILTER_GRADIENT,
29 WEBP_FILTER_LAST = WEBP_FILTER_GRADIENT + 1, // end marker
30 WEBP_FILTER_BEST,
31 WEBP_FILTER_FAST
32} WEBP_FILTER_TYPE;
33
34typedef void (*WebPFilterFunc)(const uint8_t* in, int width, int height,
Vikas Arora0406ce12013-08-09 15:57:12 -070035 int stride, uint8_t* out);
36typedef void (*WebPUnfilterFunc)(int width, int height, int stride,
Vikas Arora8b720222014-01-02 16:48:02 -080037 int row, int num_rows, uint8_t* data);
Vikas Aroraa2415722012-08-09 16:18:58 -070038
39// Filter the given data using the given predictor.
40// 'in' corresponds to a 2-dimensional pixel array of size (stride * height)
41// in raster order.
Vikas Aroraa2415722012-08-09 16:18:58 -070042// 'stride' is number of bytes per scan line (with possible padding).
43// 'out' should be pre-allocated.
44extern const WebPFilterFunc WebPFilters[WEBP_FILTER_LAST];
45
Vikas Arora0406ce12013-08-09 15:57:12 -070046// In-place reconstruct the original data from the given filtered data.
Vikas Arora8b720222014-01-02 16:48:02 -080047// The reconstruction will be done for 'num_rows' rows starting from 'row'
48// (assuming rows upto 'row - 1' are already reconstructed).
Vikas Arora0406ce12013-08-09 15:57:12 -070049extern const WebPUnfilterFunc WebPUnfilters[WEBP_FILTER_LAST];
Vikas Aroraa2415722012-08-09 16:18:58 -070050
51// Fast estimate of a potentially good filter.
Vikas Arora8b720222014-01-02 16:48:02 -080052WEBP_FILTER_TYPE EstimateBestFilter(const uint8_t* data,
53 int width, int height, int stride);
Vikas Aroraa2415722012-08-09 16:18:58 -070054
Vikas Arora8b720222014-01-02 16:48:02 -080055#ifdef __cplusplus
Vikas Aroraa2415722012-08-09 16:18:58 -070056} // extern "C"
57#endif
58
59#endif /* WEBP_UTILS_FILTERS_H_ */