#ifdef HAVE_CONFIG_H
#include "src/webp/config.h"
#endif
#include <float.h>
#include <math.h>
#include "src/dsp/lossless.h"
#include "src/dsp/lossless_common.h"
#include "src/enc/backward_references_enc.h"
#include "src/enc/histogram_enc.h"
#include "src/enc/vp8i_enc.h"
#include "src/utils/utils.h"
#define MAX_BIT_COST …
#define NUM_PARTITIONS …
#define BIN_SIZE …
#define MAX_HISTO_GREEDY …
static void HistogramClear(VP8LHistogram* const p) { … }
static void HistogramSwap(VP8LHistogram** const A, VP8LHistogram** const B) { … }
static void HistogramCopy(const VP8LHistogram* const src,
VP8LHistogram* const dst) { … }
int VP8LGetHistogramSize(int cache_bits) { … }
void VP8LFreeHistogram(VP8LHistogram* const histo) { … }
void VP8LFreeHistogramSet(VP8LHistogramSet* const histo) { … }
void VP8LHistogramStoreRefs(const VP8LBackwardRefs* const refs,
VP8LHistogram* const histo) { … }
void VP8LHistogramCreate(VP8LHistogram* const p,
const VP8LBackwardRefs* const refs,
int palette_code_bits) { … }
void VP8LHistogramInit(VP8LHistogram* const p, int palette_code_bits,
int init_arrays) { … }
VP8LHistogram* VP8LAllocateHistogram(int cache_bits) { … }
static void HistogramSetResetPointers(VP8LHistogramSet* const set,
int cache_bits) { … }
static size_t HistogramSetTotalSize(int size, int cache_bits) { … }
VP8LHistogramSet* VP8LAllocateHistogramSet(int size, int cache_bits) { … }
void VP8LHistogramSetClear(VP8LHistogramSet* const set) { … }
static void HistogramSetRemoveHistogram(VP8LHistogramSet* const set, int i,
int* const num_used) { … }
void VP8LHistogramAddSinglePixOrCopy(VP8LHistogram* const histo,
const PixOrCopy* const v,
int (*const distance_modifier)(int, int),
int distance_modifier_arg0) { … }
static WEBP_INLINE float BitsEntropyRefine(const VP8LBitEntropy* entropy) { … }
float VP8LBitsEntropy(const uint32_t* const array, int n) { … }
static float InitialHuffmanCost(void) { … }
static float FinalHuffmanCost(const VP8LStreaks* const stats) { … }
static float PopulationCost(const uint32_t* const population, int length,
uint32_t* const trivial_sym,
uint8_t* const is_used) { … }
static WEBP_INLINE float GetCombinedEntropy(const uint32_t* const X,
const uint32_t* const Y, int length,
int is_X_used, int is_Y_used,
int trivial_at_end) { … }
float VP8LHistogramEstimateBits(VP8LHistogram* const p) { … }
static int GetCombinedHistogramEntropy(const VP8LHistogram* const a,
const VP8LHistogram* const b,
float cost_threshold, float* cost) { … }
static WEBP_INLINE void HistogramAdd(const VP8LHistogram* const a,
const VP8LHistogram* const b,
VP8LHistogram* const out) { … }
static float HistogramAddEval(const VP8LHistogram* const a,
const VP8LHistogram* const b,
VP8LHistogram* const out, float cost_threshold) { … }
static float HistogramAddThresh(const VP8LHistogram* const a,
const VP8LHistogram* const b,
float cost_threshold) { … }
DominantCostRange;
static void DominantCostRangeInit(DominantCostRange* const c) { … }
static void UpdateDominantCostRange(
const VP8LHistogram* const h, DominantCostRange* const c) { … }
static void UpdateHistogramCost(VP8LHistogram* const h) { … }
static int GetBinIdForEntropy(float min, float max, float val) { … }
static int GetHistoBinIndex(const VP8LHistogram* const h,
const DominantCostRange* const c, int low_effort) { … }
static void HistogramBuild(
int xsize, int histo_bits, const VP8LBackwardRefs* const backward_refs,
VP8LHistogramSet* const image_histo) { … }
static const uint16_t kInvalidHistogramSymbol = …;
static void HistogramCopyAndAnalyze(VP8LHistogramSet* const orig_histo,
VP8LHistogramSet* const image_histo,
int* const num_used,
uint16_t* const histogram_symbols) { … }
static void HistogramAnalyzeEntropyBin(VP8LHistogramSet* const image_histo,
uint16_t* const bin_map,
int low_effort) { … }
static void HistogramCombineEntropyBin(
VP8LHistogramSet* const image_histo, int* num_used,
const uint16_t* const clusters, uint16_t* const cluster_mappings,
VP8LHistogram* cur_combo, const uint16_t* const bin_map, int num_bins,
float combine_cost_factor, int low_effort) { … }
static uint32_t MyRand(uint32_t* const seed) { … }
HistogramPair;
HistoQueue;
static int HistoQueueInit(HistoQueue* const histo_queue, const int max_size) { … }
static void HistoQueueClear(HistoQueue* const histo_queue) { … }
static void HistoQueuePopPair(HistoQueue* const histo_queue,
HistogramPair* const pair) { … }
static void HistoQueueUpdateHead(HistoQueue* const histo_queue,
HistogramPair* const pair) { … }
static void HistoQueueUpdatePair(const VP8LHistogram* const h1,
const VP8LHistogram* const h2, float threshold,
HistogramPair* const pair) { … }
static float HistoQueuePush(HistoQueue* const histo_queue,
VP8LHistogram** const histograms, int idx1,
int idx2, float threshold) { … }
static int HistogramCombineGreedy(VP8LHistogramSet* const image_histo,
int* const num_used) { … }
static int PairComparison(const void* idx1, const void* idx2) { … }
static int HistogramCombineStochastic(VP8LHistogramSet* const image_histo,
int* const num_used, int min_cluster_size,
int* const do_greedy) { … }
static void HistogramRemap(const VP8LHistogramSet* const in,
VP8LHistogramSet* const out,
uint16_t* const symbols) { … }
static float GetCombineCostFactor(int histo_size, int quality) { … }
static void OptimizeHistogramSymbols(const VP8LHistogramSet* const set,
uint16_t* const cluster_mappings,
int num_clusters,
uint16_t* const cluster_mappings_tmp,
uint16_t* const symbols) { … }
static void RemoveEmptyHistograms(VP8LHistogramSet* const image_histo) { … }
int VP8LGetHistoImageSymbols(int xsize, int ysize,
const VP8LBackwardRefs* const refs, int quality,
int low_effort, int histogram_bits, int cache_bits,
VP8LHistogramSet* const image_histo,
VP8LHistogram* const tmp_histo,
uint16_t* const histogram_symbols,
const WebPPicture* const pic, int percent_range,
int* const percent) { … }