| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
#ifndef WEBP_UTILS_RESCALER_UTILS_H_ |
| 15 |
#define WEBP_UTILS_RESCALER_UTILS_H_ |
| 16 |
|
| 17 |
#ifdef __cplusplus |
| 18 |
extern "C" { |
| 19 |
#endif |
| 20 |
|
| 21 |
#include "src/webp/types.h" |
| 22 |
|
| 23 |
#define WEBP_RESCALER_RFIX 32 // fixed-point precision for multiplies |
| 24 |
#define WEBP_RESCALER_ONE (1ull << WEBP_RESCALER_RFIX) |
| 25 |
#define WEBP_RESCALER_FRAC(x, y) \ |
| 26 |
((uint32_t)(((uint64_t)(x) << WEBP_RESCALER_RFIX) / (y))) |
| 27 |
|
| 28 |
|
| 29 |
typedef uint32_t rescaler_t; |
| 30 |
typedef struct WebPRescaler WebPRescaler; |
| 31 |
struct WebPRescaler { |
| 32 |
int x_expand; |
| 33 |
int y_expand; |
| 34 |
int num_channels; |
| 35 |
uint32_t fx_scale; |
| 36 |
uint32_t fy_scale; |
| 37 |
uint32_t fxy_scale; |
| 38 |
int y_accum; |
| 39 |
int y_add, y_sub; |
| 40 |
int x_add, x_sub; |
| 41 |
int src_width, src_height; |
| 42 |
int dst_width, dst_height; |
| 43 |
int src_y, dst_y; |
| 44 |
uint8_t* dst; |
| 45 |
int dst_stride; |
| 46 |
rescaler_t* irow, *frow; |
| 47 |
}; |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
int WebPRescalerInit(WebPRescaler* const rescaler, |
| 52 |
int src_width, int src_height, |
| 53 |
uint8_t* const dst, |
| 54 |
int dst_width, int dst_height, int dst_stride, |
| 55 |
int num_channels, |
| 56 |
rescaler_t* const work); |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
int WebPRescalerGetScaledDimensions(int src_width, int src_height, |
| 63 |
int* const scaled_width, |
| 64 |
int* const scaled_height); |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
int WebPRescaleNeededLines(const WebPRescaler* const rescaler, |
| 69 |
int max_num_lines); |
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
int WebPRescalerImport(WebPRescaler* const rescaler, int num_rows, |
| 74 |
const uint8_t* src, int src_stride); |
| 75 |
|
| 76 |
|
| 77 |
int WebPRescalerExport(WebPRescaler* const rescaler); |
| 78 |
|
| 79 |
|
| 80 |
static WEBP_INLINE |
| 81 |
int WebPRescalerInputDone(const WebPRescaler* const rescaler) { |
| 82 |
return (rescaler->src_y >= rescaler->src_height); |
| 83 |
} |
| 84 |
|
| 85 |
static WEBP_INLINE |
| 86 |
int WebPRescalerOutputDone(const WebPRescaler* const rescaler) { |
| 87 |
return (rescaler->dst_y >= rescaler->dst_height); |
| 88 |
} |
| 89 |
|
| 90 |
|
| 91 |
static WEBP_INLINE |
| 92 |
int WebPRescalerHasPendingOutput(const WebPRescaler* const rescaler) { |
| 93 |
return !WebPRescalerOutputDone(rescaler) && (rescaler->y_accum <= 0); |
| 94 |
} |
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
#ifdef __cplusplus |
| 99 |
} |
| 100 |
#endif |
| 101 |
|
| 102 |
#endif |