#include <string.h>
#include <math.h>
#include "src/enc/cost_enc.h"
#include "src/enc/vp8i_enc.h"
#include "src/dsp/dsp.h"
#include "src/webp/format_constants.h"
#define SEGMENT_VISU …
#define DEBUG_SEARCH …
#define HEADER_SIZE_ESTIMATE …
#define DQ_LIMIT …
#define PARTITION0_SIZE_LIMIT …
static float Clamp(float v, float min, float max) { … }
PassStats;
static int InitPassStats(const VP8Encoder* const enc, PassStats* const s) { … }
static float ComputeNextQ(PassStats* const s) { … }
const uint8_t VP8Cat3[] = …;
const uint8_t VP8Cat4[] = …;
const uint8_t VP8Cat5[] = …;
const uint8_t VP8Cat6[] = …;
static void ResetStats(VP8Encoder* const enc) { … }
#define SKIP_PROBA_THRESHOLD …
static int CalcSkipProba(uint64_t nb, uint64_t total) { … }
static int FinalizeSkipProba(VP8Encoder* const enc) { … }
static int CalcTokenProba(int nb, int total) { … }
static int BranchCost(int nb, int total, int proba) { … }
static void ResetTokenStats(VP8Encoder* const enc) { … }
static int FinalizeTokenProbas(VP8EncProba* const proba) { … }
static int GetProba(int a, int b) { … }
static void ResetSegments(VP8Encoder* const enc) { … }
static void SetSegmentProbas(VP8Encoder* const enc) { … }
static int PutCoeffs(VP8BitWriter* const bw, int ctx, const VP8Residual* res) { … }
static void CodeResiduals(VP8BitWriter* const bw, VP8EncIterator* const it,
const VP8ModeScore* const rd) { … }
static void RecordResiduals(VP8EncIterator* const it,
const VP8ModeScore* const rd) { … }
#if !defined(DISABLE_TOKEN_BUFFER)
static int RecordTokens(VP8EncIterator* const it, const VP8ModeScore* const rd,
VP8TBuffer* const tokens) { … }
#endif
#if !defined(WEBP_DISABLE_STATS)
#if SEGMENT_VISU
static void SetBlock(uint8_t* p, int value, int size) {
int y;
for (y = 0; y < size; ++y) {
memset(p, value, size);
p += BPS;
}
}
#endif
static void ResetSSE(VP8Encoder* const enc) { … }
static void StoreSSE(const VP8EncIterator* const it) { … }
static void StoreSideInfo(const VP8EncIterator* const it) { … }
static void ResetSideInfo(const VP8EncIterator* const it) { … }
#else
static void ResetSSE(VP8Encoder* const enc) {
(void)enc;
}
static void StoreSideInfo(const VP8EncIterator* const it) {
VP8Encoder* const enc = it->enc_;
WebPPicture* const pic = enc->pic_;
if (pic->extra_info != NULL) {
if (it->x_ == 0 && it->y_ == 0) {
memset(pic->extra_info, 0,
enc->mb_w_ * enc->mb_h_ * sizeof(*pic->extra_info));
}
}
}
static void ResetSideInfo(const VP8EncIterator* const it) {
(void)it;
}
#endif
static double GetPSNR(uint64_t mse, uint64_t size) { … }
static void SetLoopParams(VP8Encoder* const enc, float q) { … }
static uint64_t OneStatPass(VP8Encoder* const enc, VP8RDLevel rd_opt,
int nb_mbs, int percent_delta,
PassStats* const s) { … }
static int StatLoop(VP8Encoder* const enc) { … }
static const uint8_t kAverageBytesPerMB[8] = …;
static int PreLoopInitialize(VP8Encoder* const enc) { … }
static int PostLoopFinalize(VP8EncIterator* const it, int ok) { … }
static void ResetAfterSkip(VP8EncIterator* const it) { … }
int VP8EncLoop(VP8Encoder* const enc) { … }
#if !defined(DISABLE_TOKEN_BUFFER)
#define MIN_COUNT …
int VP8EncTokenLoop(VP8Encoder* const enc) { … }
#else
int VP8EncTokenLoop(VP8Encoder* const enc) {
(void)enc;
return 0;
}
#endif