#include <assert.h>
#include <float.h>
#include "src/dsp/lossless_common.h"
#include "src/enc/backward_references_enc.h"
#include "src/enc/histogram_enc.h"
#include "src/utils/color_cache_utils.h"
#include "src/utils/utils.h"
#define VALUES_IN_BYTE …
extern void VP8LClearBackwardRefs(VP8LBackwardRefs* const refs);
extern int VP8LDistanceToPlaneCode(int xsize, int dist);
extern void VP8LBackwardRefsCursorAdd(VP8LBackwardRefs* const refs,
const PixOrCopy v);
CostModel;
static void ConvertPopulationCountTableToBitEstimates(
int num_symbols, const uint32_t population_counts[], float output[]) { … }
static int CostModelBuild(CostModel* const m, int xsize, int cache_bits,
const VP8LBackwardRefs* const refs) { … }
static WEBP_INLINE float GetLiteralCost(const CostModel* const m, uint32_t v) { … }
static WEBP_INLINE float GetCacheCost(const CostModel* const m, uint32_t idx) { … }
static WEBP_INLINE float GetLengthCost(const CostModel* const m,
uint32_t length) { … }
static WEBP_INLINE float GetDistanceCost(const CostModel* const m,
uint32_t distance) { … }
static WEBP_INLINE void AddSingleLiteralWithCostModel(
const uint32_t* const argb, VP8LColorCache* const hashers,
const CostModel* const cost_model, int idx, int use_color_cache,
float prev_cost, float* const cost, uint16_t* const dist_array) { … }
#define COST_CACHE_INTERVAL_SIZE_MAX …
CostInterval;
struct CostInterval { … };
CostCacheInterval;
#define COST_MANAGER_MAX_FREE_LIST …
CostManager;
static void CostIntervalAddToFreeList(CostManager* const manager,
CostInterval* const interval) { … }
static int CostIntervalIsInFreeList(const CostManager* const manager,
const CostInterval* const interval) { … }
static void CostManagerInitFreeList(CostManager* const manager) { … }
static void DeleteIntervalList(CostManager* const manager,
const CostInterval* interval) { … }
static void CostManagerClear(CostManager* const manager) { … }
static int CostManagerInit(CostManager* const manager,
uint16_t* const dist_array, int pix_count,
const CostModel* const cost_model) { … }
static WEBP_INLINE void UpdateCost(CostManager* const manager, int i,
int position, float cost) { … }
static WEBP_INLINE void UpdateCostPerInterval(CostManager* const manager,
int start, int end, int position,
float cost) { … }
static WEBP_INLINE void ConnectIntervals(CostManager* const manager,
CostInterval* const prev,
CostInterval* const next) { … }
static WEBP_INLINE void PopInterval(CostManager* const manager,
CostInterval* const interval) { … }
static WEBP_INLINE void UpdateCostAtIndex(CostManager* const manager, int i,
int do_clean_intervals) { … }
static WEBP_INLINE void PositionOrphanInterval(CostManager* const manager,
CostInterval* const current,
CostInterval* previous) { … }
static WEBP_INLINE void InsertInterval(CostManager* const manager,
CostInterval* const interval_in,
float cost, int position, int start,
int end) { … }
static WEBP_INLINE void PushInterval(CostManager* const manager,
float distance_cost, int position,
int len) { … }
static int BackwardReferencesHashChainDistanceOnly(
int xsize, int ysize, const uint32_t* const argb, int cache_bits,
const VP8LHashChain* const hash_chain, const VP8LBackwardRefs* const refs,
uint16_t* const dist_array) { … }
static void TraceBackwards(uint16_t* const dist_array,
int dist_array_size,
uint16_t** const chosen_path,
int* const chosen_path_size) { … }
static int BackwardReferencesHashChainFollowChosenPath(
const uint32_t* const argb, int cache_bits,
const uint16_t* const chosen_path, int chosen_path_size,
const VP8LHashChain* const hash_chain, VP8LBackwardRefs* const refs) { … }
extern int VP8LBackwardReferencesTraceBackwards(
int xsize, int ysize, const uint32_t* const argb, int cache_bits,
const VP8LHashChain* const hash_chain,
const VP8LBackwardRefs* const refs_src, VP8LBackwardRefs* const refs_dst);
int VP8LBackwardReferencesTraceBackwards(int xsize, int ysize,
const uint32_t* const argb,
int cache_bits,
const VP8LHashChain* const hash_chain,
const VP8LBackwardRefs* const refs_src,
VP8LBackwardRefs* const refs_dst) { … }