| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
#ifndef WEBP_ENC_HISTOGRAM_ENC_H_ |
| 15 |
#define WEBP_ENC_HISTOGRAM_ENC_H_ |
| 16 |
|
| 17 |
#include <string.h> |
| 18 |
|
| 19 |
#include "src/enc/backward_references_enc.h" |
| 20 |
#include "src/webp/format_constants.h" |
| 21 |
#include "src/webp/types.h" |
| 22 |
|
| 23 |
#ifdef __cplusplus |
| 24 |
extern "C" { |
| 25 |
#endif |
| 26 |
|
| 27 |
|
| 28 |
#define VP8L_NON_TRIVIAL_SYM (0xffffffff) |
| 29 |
|
| 30 |
|
| 31 |
typedef struct { |
| 32 |
|
| 33 |
|
| 34 |
uint32_t* literal_; |
| 35 |
uint32_t red_[NUM_LITERAL_CODES]; |
| 36 |
uint32_t blue_[NUM_LITERAL_CODES]; |
| 37 |
uint32_t alpha_[NUM_LITERAL_CODES]; |
| 38 |
|
| 39 |
uint32_t distance_[NUM_DISTANCE_CODES]; |
| 40 |
int palette_code_bits_; |
| 41 |
uint32_t trivial_symbol_; |
| 42 |
|
| 43 |
float bit_cost_; |
| 44 |
float literal_cost_; |
| 45 |
float red_cost_; |
| 46 |
float blue_cost_; |
| 47 |
uint8_t is_used_[5]; |
| 48 |
} VP8LHistogram; |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
typedef struct { |
| 53 |
int size; |
| 54 |
int max_size; |
| 55 |
VP8LHistogram** histograms; |
| 56 |
} VP8LHistogramSet; |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
void VP8LHistogramCreate(VP8LHistogram* const p, |
| 64 |
const VP8LBackwardRefs* const refs, |
| 65 |
int palette_code_bits); |
| 66 |
|
| 67 |
|
| 68 |
int VP8LGetHistogramSize(int cache_bits); |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
void VP8LHistogramInit(VP8LHistogram* const p, int palette_code_bits, |
| 73 |
int init_arrays); |
| 74 |
|
| 75 |
|
| 76 |
void VP8LHistogramStoreRefs(const VP8LBackwardRefs* const refs, |
| 77 |
VP8LHistogram* const histo); |
| 78 |
|
| 79 |
|
| 80 |
void VP8LFreeHistogram(VP8LHistogram* const histo); |
| 81 |
|
| 82 |
|
| 83 |
void VP8LFreeHistogramSet(VP8LHistogramSet* const histo); |
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
VP8LHistogramSet* VP8LAllocateHistogramSet(int size, int cache_bits); |
| 88 |
|
| 89 |
|
| 90 |
void VP8LHistogramSetClear(VP8LHistogramSet* const set); |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
VP8LHistogram* VP8LAllocateHistogram(int cache_bits); |
| 96 |
|
| 97 |
|
| 98 |
void VP8LHistogramAddSinglePixOrCopy(VP8LHistogram* const histo, |
| 99 |
const PixOrCopy* const v, |
| 100 |
int (*const distance_modifier)(int, int), |
| 101 |
int distance_modifier_arg0); |
| 102 |
|
| 103 |
static WEBP_INLINE int VP8LHistogramNumCodes(int palette_code_bits) { |
| 104 |
return NUM_LITERAL_CODES + NUM_LENGTH_CODES + |
| 105 |
((palette_code_bits > 0) ? (1 << palette_code_bits) : 0); |
| 106 |
} |
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
int VP8LGetHistoImageSymbols(int xsize, int ysize, |
| 111 |
const VP8LBackwardRefs* const refs, int quality, |
| 112 |
int low_effort, int histogram_bits, int cache_bits, |
| 113 |
VP8LHistogramSet* const image_histo, |
| 114 |
VP8LHistogram* const tmp_histo, |
| 115 |
uint16_t* const histogram_symbols, |
| 116 |
const WebPPicture* const pic, int percent_range, |
| 117 |
int* const percent); |
| 118 |
|
| 119 |
|
| 120 |
float VP8LBitsEntropy(const uint32_t* const array, int n); |
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
float VP8LHistogramEstimateBits(VP8LHistogram* const p); |
| 125 |
|
| 126 |
#ifdef __cplusplus |
| 127 |
} |
| 128 |
#endif |
| 129 |
|
| 130 |
#endif |