| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
#ifndef WEBP_DSP_LOSSLESS_H_ |
| 16 |
#define WEBP_DSP_LOSSLESS_H_ |
| 17 |
|
| 18 |
#include "src/webp/types.h" |
| 19 |
#include "src/webp/decode.h" |
| 20 |
|
| 21 |
#include "src/enc/histogram_enc.h" |
| 22 |
#include "src/utils/utils.h" |
| 23 |
|
| 24 |
#ifdef __cplusplus |
| 25 |
extern "C" { |
| 26 |
#endif |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
typedef uint32_t (*VP8LPredictorFunc)(const uint32_t* const left, |
| 32 |
const uint32_t* const top); |
| 33 |
extern VP8LPredictorFunc VP8LPredictors[16]; |
| 34 |
|
| 35 |
uint32_t VP8LPredictor0_C(const uint32_t* const left, |
| 36 |
const uint32_t* const top); |
| 37 |
uint32_t VP8LPredictor1_C(const uint32_t* const left, |
| 38 |
const uint32_t* const top); |
| 39 |
uint32_t VP8LPredictor2_C(const uint32_t* const left, |
| 40 |
const uint32_t* const top); |
| 41 |
uint32_t VP8LPredictor3_C(const uint32_t* const left, |
| 42 |
const uint32_t* const top); |
| 43 |
uint32_t VP8LPredictor4_C(const uint32_t* const left, |
| 44 |
const uint32_t* const top); |
| 45 |
uint32_t VP8LPredictor5_C(const uint32_t* const left, |
| 46 |
const uint32_t* const top); |
| 47 |
uint32_t VP8LPredictor6_C(const uint32_t* const left, |
| 48 |
const uint32_t* const top); |
| 49 |
uint32_t VP8LPredictor7_C(const uint32_t* const left, |
| 50 |
const uint32_t* const top); |
| 51 |
uint32_t VP8LPredictor8_C(const uint32_t* const left, |
| 52 |
const uint32_t* const top); |
| 53 |
uint32_t VP8LPredictor9_C(const uint32_t* const left, |
| 54 |
const uint32_t* const top); |
| 55 |
uint32_t VP8LPredictor10_C(const uint32_t* const left, |
| 56 |
const uint32_t* const top); |
| 57 |
uint32_t VP8LPredictor11_C(const uint32_t* const left, |
| 58 |
const uint32_t* const top); |
| 59 |
uint32_t VP8LPredictor12_C(const uint32_t* const left, |
| 60 |
const uint32_t* const top); |
| 61 |
uint32_t VP8LPredictor13_C(const uint32_t* const left, |
| 62 |
const uint32_t* const top); |
| 63 |
|
| 64 |
|
| 65 |
typedef void (*VP8LPredictorAddSubFunc)(const uint32_t* in, |
| 66 |
const uint32_t* upper, int num_pixels, |
| 67 |
uint32_t* out); |
| 68 |
extern VP8LPredictorAddSubFunc VP8LPredictorsAdd[16]; |
| 69 |
extern VP8LPredictorAddSubFunc VP8LPredictorsAdd_C[16]; |
| 70 |
|
| 71 |
typedef void (*VP8LProcessDecBlueAndRedFunc)(const uint32_t* src, |
| 72 |
int num_pixels, uint32_t* dst); |
| 73 |
extern VP8LProcessDecBlueAndRedFunc VP8LAddGreenToBlueAndRed; |
| 74 |
|
| 75 |
typedef struct { |
| 76 |
|
| 77 |
|
| 78 |
uint8_t green_to_red_; |
| 79 |
uint8_t green_to_blue_; |
| 80 |
uint8_t red_to_blue_; |
| 81 |
} VP8LMultipliers; |
| 82 |
typedef void (*VP8LTransformColorInverseFunc)(const VP8LMultipliers* const m, |
| 83 |
const uint32_t* src, |
| 84 |
int num_pixels, uint32_t* dst); |
| 85 |
extern VP8LTransformColorInverseFunc VP8LTransformColorInverse; |
| 86 |
|
| 87 |
struct VP8LTransform; |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
void VP8LInverseTransform(const struct VP8LTransform* const transform, |
| 94 |
int row_start, int row_end, |
| 95 |
const uint32_t* const in, uint32_t* const out); |
| 96 |
|
| 97 |
|
| 98 |
typedef void (*VP8LConvertFunc)(const uint32_t* src, int num_pixels, |
| 99 |
uint8_t* dst); |
| 100 |
extern VP8LConvertFunc VP8LConvertBGRAToRGB; |
| 101 |
extern VP8LConvertFunc VP8LConvertBGRAToRGBA; |
| 102 |
extern VP8LConvertFunc VP8LConvertBGRAToRGBA4444; |
| 103 |
extern VP8LConvertFunc VP8LConvertBGRAToRGB565; |
| 104 |
extern VP8LConvertFunc VP8LConvertBGRAToBGR; |
| 105 |
|
| 106 |
|
| 107 |
void VP8LConvertFromBGRA(const uint32_t* const in_data, int num_pixels, |
| 108 |
WEBP_CSP_MODE out_colorspace, uint8_t* const rgba); |
| 109 |
|
| 110 |
typedef void (*VP8LMapARGBFunc)(const uint32_t* src, |
| 111 |
const uint32_t* const color_map, |
| 112 |
uint32_t* dst, int y_start, |
| 113 |
int y_end, int width); |
| 114 |
typedef void (*VP8LMapAlphaFunc)(const uint8_t* src, |
| 115 |
const uint32_t* const color_map, |
| 116 |
uint8_t* dst, int y_start, |
| 117 |
int y_end, int width); |
| 118 |
|
| 119 |
extern VP8LMapARGBFunc VP8LMapColor32b; |
| 120 |
extern VP8LMapAlphaFunc VP8LMapColor8b; |
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
void VP8LColorIndexInverseTransformAlpha( |
| 126 |
const struct VP8LTransform* const transform, int y_start, int y_end, |
| 127 |
const uint8_t* src, uint8_t* dst); |
| 128 |
|
| 129 |
|
| 130 |
void VP8LTransformColorInverse_C(const VP8LMultipliers* const m, |
| 131 |
const uint32_t* src, int num_pixels, |
| 132 |
uint32_t* dst); |
| 133 |
|
| 134 |
void VP8LConvertBGRAToRGB_C(const uint32_t* src, int num_pixels, uint8_t* dst); |
| 135 |
void VP8LConvertBGRAToRGBA_C(const uint32_t* src, int num_pixels, uint8_t* dst); |
| 136 |
void VP8LConvertBGRAToRGBA4444_C(const uint32_t* src, |
| 137 |
int num_pixels, uint8_t* dst); |
| 138 |
void VP8LConvertBGRAToRGB565_C(const uint32_t* src, |
| 139 |
int num_pixels, uint8_t* dst); |
| 140 |
void VP8LConvertBGRAToBGR_C(const uint32_t* src, int num_pixels, uint8_t* dst); |
| 141 |
void VP8LAddGreenToBlueAndRed_C(const uint32_t* src, int num_pixels, |
| 142 |
uint32_t* dst); |
| 143 |
|
| 144 |
|
| 145 |
void VP8LDspInit(void); |
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
typedef void (*VP8LProcessEncBlueAndRedFunc)(uint32_t* dst, int num_pixels); |
| 151 |
extern VP8LProcessEncBlueAndRedFunc VP8LSubtractGreenFromBlueAndRed; |
| 152 |
typedef void (*VP8LTransformColorFunc)(const VP8LMultipliers* const m, |
| 153 |
uint32_t* dst, int num_pixels); |
| 154 |
extern VP8LTransformColorFunc VP8LTransformColor; |
| 155 |
typedef void (*VP8LCollectColorBlueTransformsFunc)( |
| 156 |
const uint32_t* argb, int stride, |
| 157 |
int tile_width, int tile_height, |
| 158 |
int green_to_blue, int red_to_blue, int histo[]); |
| 159 |
extern VP8LCollectColorBlueTransformsFunc VP8LCollectColorBlueTransforms; |
| 160 |
|
| 161 |
typedef void (*VP8LCollectColorRedTransformsFunc)( |
| 162 |
const uint32_t* argb, int stride, |
| 163 |
int tile_width, int tile_height, |
| 164 |
int green_to_red, int histo[]); |
| 165 |
extern VP8LCollectColorRedTransformsFunc VP8LCollectColorRedTransforms; |
| 166 |
|
| 167 |
|
| 168 |
void VP8LTransformColor_C(const VP8LMultipliers* const m, |
| 169 |
uint32_t* data, int num_pixels); |
| 170 |
void VP8LSubtractGreenFromBlueAndRed_C(uint32_t* argb_data, int num_pixels); |
| 171 |
void VP8LCollectColorRedTransforms_C(const uint32_t* argb, int stride, |
| 172 |
int tile_width, int tile_height, |
| 173 |
int green_to_red, int histo[]); |
| 174 |
void VP8LCollectColorBlueTransforms_C(const uint32_t* argb, int stride, |
| 175 |
int tile_width, int tile_height, |
| 176 |
int green_to_blue, int red_to_blue, |
| 177 |
int histo[]); |
| 178 |
|
| 179 |
extern VP8LPredictorAddSubFunc VP8LPredictorsSub[16]; |
| 180 |
extern VP8LPredictorAddSubFunc VP8LPredictorsSub_C[16]; |
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
typedef uint32_t (*VP8LCostFunc)(const uint32_t* population, int length); |
| 186 |
typedef uint32_t (*VP8LCostCombinedFunc)(const uint32_t* X, const uint32_t* Y, |
| 187 |
int length); |
| 188 |
typedef float (*VP8LCombinedShannonEntropyFunc)(const int X[256], |
| 189 |
const int Y[256]); |
| 190 |
|
| 191 |
extern VP8LCostFunc VP8LExtraCost; |
| 192 |
extern VP8LCostCombinedFunc VP8LExtraCostCombined; |
| 193 |
extern VP8LCombinedShannonEntropyFunc VP8LCombinedShannonEntropy; |
| 194 |
|
| 195 |
typedef struct { |
| 196 |
int counts[2]; |
| 197 |
int streaks[2][2]; |
| 198 |
} VP8LStreaks; |
| 199 |
|
| 200 |
typedef struct { |
| 201 |
float entropy; |
| 202 |
uint32_t sum; |
| 203 |
int nonzeros; |
| 204 |
uint32_t max_val; |
| 205 |
uint32_t nonzero_code; |
| 206 |
} VP8LBitEntropy; |
| 207 |
|
| 208 |
void VP8LBitEntropyInit(VP8LBitEntropy* const entropy); |
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
typedef void (*VP8LGetCombinedEntropyUnrefinedFunc)( |
| 214 |
const uint32_t X[], const uint32_t Y[], int length, |
| 215 |
VP8LBitEntropy* const bit_entropy, VP8LStreaks* const stats); |
| 216 |
extern VP8LGetCombinedEntropyUnrefinedFunc VP8LGetCombinedEntropyUnrefined; |
| 217 |
|
| 218 |
|
| 219 |
typedef void (*VP8LGetEntropyUnrefinedFunc)(const uint32_t X[], int length, |
| 220 |
VP8LBitEntropy* const bit_entropy, |
| 221 |
VP8LStreaks* const stats); |
| 222 |
extern VP8LGetEntropyUnrefinedFunc VP8LGetEntropyUnrefined; |
| 223 |
|
| 224 |
void VP8LBitsEntropyUnrefined(const uint32_t* const array, int n, |
| 225 |
VP8LBitEntropy* const entropy); |
| 226 |
|
| 227 |
typedef void (*VP8LAddVectorFunc)(const uint32_t* a, const uint32_t* b, |
| 228 |
uint32_t* out, int size); |
| 229 |
extern VP8LAddVectorFunc VP8LAddVector; |
| 230 |
typedef void (*VP8LAddVectorEqFunc)(const uint32_t* a, uint32_t* out, int size); |
| 231 |
extern VP8LAddVectorEqFunc VP8LAddVectorEq; |
| 232 |
void VP8LHistogramAdd(const VP8LHistogram* const a, |
| 233 |
const VP8LHistogram* const b, |
| 234 |
VP8LHistogram* const out); |
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
typedef int (*VP8LVectorMismatchFunc)(const uint32_t* const array1, |
| 240 |
const uint32_t* const array2, int length); |
| 241 |
|
| 242 |
extern VP8LVectorMismatchFunc VP8LVectorMismatch; |
| 243 |
|
| 244 |
typedef void (*VP8LBundleColorMapFunc)(const uint8_t* const row, int width, |
| 245 |
int xbits, uint32_t* dst); |
| 246 |
extern VP8LBundleColorMapFunc VP8LBundleColorMap; |
| 247 |
void VP8LBundleColorMap_C(const uint8_t* const row, int width, int xbits, |
| 248 |
uint32_t* dst); |
| 249 |
|
| 250 |
|
| 251 |
void VP8LEncDspInit(void); |
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
#ifdef __cplusplus |
| 256 |
} |
| 257 |
#endif |
| 258 |
|
| 259 |
#endif |