#include <assert.h>
#include <stdlib.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/enc/vp8li_enc.h"
#include "src/utils/bit_writer_utils.h"
#include "src/utils/huffman_encode_utils.h"
#include "src/utils/palette.h"
#include "src/utils/utils.h"
#include "src/webp/encode.h"
#include "src/webp/format_constants.h"
#define MAX_HUFF_IMAGE_SIZE …
EntropyIx;
HistoIx;
static void AddSingleSubGreen(uint32_t p,
uint32_t* const r, uint32_t* const b) { … }
static void AddSingle(uint32_t p,
uint32_t* const a, uint32_t* const r,
uint32_t* const g, uint32_t* const b) { … }
static WEBP_INLINE uint32_t HashPix(uint32_t pix) { … }
static int AnalyzeEntropy(const uint32_t* argb,
int width, int height, int argb_stride,
int use_palette,
int palette_size, int transform_bits,
EntropyIx* const min_entropy_ix,
int* const red_and_blue_always_zero) { … }
static int GetHistoBits(int method, int use_palette, int width, int height) { … }
static int GetTransformBits(int method, int histo_bits) { … }
#define CRUNCH_SUBCONFIGS_MAX …
CrunchSubConfig;
CrunchConfig;
#define CRUNCH_CONFIGS_MAX …
static int EncoderAnalyze(VP8LEncoder* const enc,
CrunchConfig crunch_configs[CRUNCH_CONFIGS_MAX],
int* const crunch_configs_size,
int* const red_and_blue_always_zero) { … }
static int EncoderInit(VP8LEncoder* const enc) { … }
static int GetHuffBitLengthsAndCodes(
const VP8LHistogramSet* const histogram_image,
HuffmanTreeCode* const huffman_codes) { … }
static void StoreHuffmanTreeOfHuffmanTreeToBitMask(
VP8LBitWriter* const bw, const uint8_t* code_length_bitdepth) { … }
static void ClearHuffmanTreeIfOnlyOneSymbol(
HuffmanTreeCode* const huffman_code) { … }
static void StoreHuffmanTreeToBitMask(
VP8LBitWriter* const bw,
const HuffmanTreeToken* const tokens, const int num_tokens,
const HuffmanTreeCode* const huffman_code) { … }
static void StoreFullHuffmanCode(VP8LBitWriter* const bw,
HuffmanTree* const huff_tree,
HuffmanTreeToken* const tokens,
const HuffmanTreeCode* const tree) { … }
static void StoreHuffmanCode(VP8LBitWriter* const bw,
HuffmanTree* const huff_tree,
HuffmanTreeToken* const tokens,
const HuffmanTreeCode* const huffman_code) { … }
static WEBP_INLINE void WriteHuffmanCode(VP8LBitWriter* const bw,
const HuffmanTreeCode* const code,
int code_index) { … }
static WEBP_INLINE void WriteHuffmanCodeWithExtraBits(
VP8LBitWriter* const bw,
const HuffmanTreeCode* const code,
int code_index,
int bits,
int n_bits) { … }
static int StoreImageToBitMask(
VP8LBitWriter* const bw, int width, int histo_bits,
const VP8LBackwardRefs* const refs,
const uint16_t* histogram_symbols,
const HuffmanTreeCode* const huffman_codes, const WebPPicture* const pic) { … }
static int EncodeImageNoHuffman(VP8LBitWriter* const bw,
const uint32_t* const argb,
VP8LHashChain* const hash_chain,
VP8LBackwardRefs* const refs_array, int width,
int height, int quality, int low_effort,
const WebPPicture* const pic, int percent_range,
int* const percent) { … }
static int EncodeImageInternal(
VP8LBitWriter* const bw, const uint32_t* const argb,
VP8LHashChain* const hash_chain, VP8LBackwardRefs refs_array[4], int width,
int height, int quality, int low_effort, const CrunchConfig* const config,
int* cache_bits, int histogram_bits, size_t init_byte_position,
int* const hdr_size, int* const data_size, const WebPPicture* const pic,
int percent_range, int* const percent) { … }
static void ApplySubtractGreen(VP8LEncoder* const enc, int width, int height,
VP8LBitWriter* const bw) { … }
static int ApplyPredictFilter(const VP8LEncoder* const enc, int width,
int height, int quality, int low_effort,
int used_subtract_green, VP8LBitWriter* const bw,
int percent_range, int* const percent) { … }
static int ApplyCrossColorFilter(const VP8LEncoder* const enc, int width,
int height, int quality, int low_effort,
VP8LBitWriter* const bw, int percent_range,
int* const percent) { … }
static int WriteRiffHeader(const WebPPicture* const pic, size_t riff_size,
size_t vp8l_size) { … }
static int WriteImageSize(const WebPPicture* const pic,
VP8LBitWriter* const bw) { … }
static int WriteRealAlphaAndVersion(VP8LBitWriter* const bw, int has_alpha) { … }
static int WriteImage(const WebPPicture* const pic, VP8LBitWriter* const bw,
size_t* const coded_size) { … }
static void ClearTransformBuffer(VP8LEncoder* const enc) { … }
static int AllocateTransformBuffer(VP8LEncoder* const enc, int width,
int height) { … }
static int MakeInputImageCopy(VP8LEncoder* const enc) { … }
#define APPLY_PALETTE_GREEDY_MAX …
static WEBP_INLINE uint32_t SearchColorGreedy(const uint32_t palette[],
int palette_size,
uint32_t color) { … }
static WEBP_INLINE uint32_t ApplyPaletteHash0(uint32_t color) { … }
#define PALETTE_INV_SIZE_BITS …
#define PALETTE_INV_SIZE …
static WEBP_INLINE uint32_t ApplyPaletteHash1(uint32_t color) { … }
static WEBP_INLINE uint32_t ApplyPaletteHash2(uint32_t color) { … }
#define APPLY_PALETTE_FOR …
static int ApplyPalette(const uint32_t* src, uint32_t src_stride, uint32_t* dst,
uint32_t dst_stride, const uint32_t* palette,
int palette_size, int width, int height, int xbits,
const WebPPicture* const pic) { … }
#undef APPLY_PALETTE_FOR
#undef PALETTE_INV_SIZE_BITS
#undef PALETTE_INV_SIZE
#undef APPLY_PALETTE_GREEDY_MAX
static int MapImageFromPalette(VP8LEncoder* const enc, int in_place) { … }
static WebPEncodingError EncodePalette(VP8LBitWriter* const bw, int low_effort,
VP8LEncoder* const enc,
int percent_range, int* const percent) { … }
static VP8LEncoder* VP8LEncoderNew(const WebPConfig* const config,
const WebPPicture* const picture) { … }
static void VP8LEncoderDelete(VP8LEncoder* enc) { … }
StreamEncodeContext;
static int EncodeStreamHook(void* input, void* data2) { … }
int VP8LEncodeStream(const WebPConfig* const config,
const WebPPicture* const picture,
VP8LBitWriter* const bw_main) { … }
#undef CRUNCH_CONFIGS_MAX
#undef CRUNCH_SUBCONFIGS_MAX
int VP8LEncodeImage(const WebPConfig* const config,
const WebPPicture* const picture) { … }