| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
#ifndef WEBP_ENC_COST_ENC_H_ |
| 15 |
#define WEBP_ENC_COST_ENC_H_ |
| 16 |
|
| 17 |
#include <assert.h> |
| 18 |
#include <stdlib.h> |
| 19 |
#include "src/enc/vp8i_enc.h" |
| 20 |
|
| 21 |
#ifdef __cplusplus |
| 22 |
extern "C" { |
| 23 |
#endif |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
typedef struct VP8Residual VP8Residual; |
| 28 |
struct VP8Residual { |
| 29 |
int first; |
| 30 |
int last; |
| 31 |
const int16_t* coeffs; |
| 32 |
|
| 33 |
int coeff_type; |
| 34 |
ProbaArray* prob; |
| 35 |
StatsArray* stats; |
| 36 |
CostArrayPtr costs; |
| 37 |
}; |
| 38 |
|
| 39 |
void VP8InitResidual(int first, int coeff_type, |
| 40 |
VP8Encoder* const enc, VP8Residual* const res); |
| 41 |
|
| 42 |
int VP8RecordCoeffs(int ctx, const VP8Residual* const res); |
| 43 |
|
| 44 |
|
| 45 |
static WEBP_INLINE int VP8RecordStats(int bit, proba_t* const stats) { |
| 46 |
proba_t p = *stats; |
| 47 |
|
| 48 |
|
| 49 |
if (p >= 0xfffe0000u) { |
| 50 |
p = ((p + 1u) >> 1) & 0x7fff7fffu; |
| 51 |
} |
| 52 |
|
| 53 |
p += 0x00010000u + bit; |
| 54 |
*stats = p; |
| 55 |
return bit; |
| 56 |
} |
| 57 |
|
| 58 |
|
| 59 |
static WEBP_INLINE int VP8BitCost(int bit, uint8_t proba) { |
| 60 |
return !bit ? VP8EntropyCost[proba] : VP8EntropyCost[255 - proba]; |
| 61 |
} |
| 62 |
|
| 63 |
|
| 64 |
extern const uint16_t VP8LevelCodes[MAX_VARIABLE_LEVEL][2]; |
| 65 |
void VP8CalculateLevelCosts(VP8EncProba* const proba); |
| 66 |
static WEBP_INLINE int VP8LevelCost(const uint16_t* const table, int level) { |
| 67 |
return VP8LevelFixedCosts[level] |
| 68 |
+ table[(level > MAX_VARIABLE_LEVEL) ? MAX_VARIABLE_LEVEL : level]; |
| 69 |
} |
| 70 |
|
| 71 |
|
| 72 |
extern const uint16_t VP8FixedCostsUV[4]; |
| 73 |
extern const uint16_t VP8FixedCostsI16[4]; |
| 74 |
extern const uint16_t VP8FixedCostsI4[NUM_BMODES][NUM_BMODES][NUM_BMODES]; |
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
#ifdef __cplusplus |
| 79 |
} |
| 80 |
#endif |
| 81 |
|
| 82 |
#endif |