2012-01-06 23:49:06 +01:00
|
|
|
// Copyright 2011 Google Inc. All Rights Reserved.
|
2011-02-19 08:33:46 +01:00
|
|
|
//
|
|
|
|
// This code is licensed under the same terms as WebM:
|
|
|
|
// Software License Agreement: http://www.webmproject.org/license/software/
|
|
|
|
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Cost tables for level and modes.
|
|
|
|
//
|
|
|
|
// Author: Skal (pascal.massimino@gmail.com)
|
|
|
|
|
|
|
|
#ifndef WEBP_ENC_COST_H_
|
|
|
|
#define WEBP_ENC_COST_H_
|
|
|
|
|
2011-12-01 11:00:03 +01:00
|
|
|
#include "./vp8enci.h"
|
2011-02-19 08:33:46 +01:00
|
|
|
|
|
|
|
#if defined(__cplusplus) || defined(c_plusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2013-03-24 16:47:41 +01:00
|
|
|
// approximate cost per level:
|
|
|
|
extern const uint16_t VP8LevelFixedCosts[MAX_LEVEL + 1];
|
2011-02-19 08:33:46 +01:00
|
|
|
extern const uint16_t VP8EntropyCost[256]; // 8bit fixed-point log(p)
|
|
|
|
|
|
|
|
// Cost of coding one event with probability 'proba'.
|
2011-11-05 03:44:57 +01:00
|
|
|
static WEBP_INLINE int VP8BitCost(int bit, uint8_t proba) {
|
2011-02-19 08:33:46 +01:00
|
|
|
return !bit ? VP8EntropyCost[proba] : VP8EntropyCost[255 - proba];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Level cost calculations
|
2011-07-13 00:52:43 +02:00
|
|
|
extern const uint16_t VP8LevelCodes[MAX_VARIABLE_LEVEL][2];
|
2011-02-19 08:33:46 +01:00
|
|
|
void VP8CalculateLevelCosts(VP8Proba* const proba);
|
2011-11-05 03:44:57 +01:00
|
|
|
static WEBP_INLINE int VP8LevelCost(const uint16_t* const table, int level) {
|
2011-02-19 08:33:46 +01:00
|
|
|
return VP8LevelFixedCosts[level]
|
2012-01-24 02:50:58 +01:00
|
|
|
+ table[(level > MAX_VARIABLE_LEVEL) ? MAX_VARIABLE_LEVEL : level];
|
2011-02-19 08:33:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Mode costs
|
|
|
|
extern const uint16_t VP8FixedCostsUV[4];
|
|
|
|
extern const uint16_t VP8FixedCostsI16[4];
|
|
|
|
extern const uint16_t VP8FixedCostsI4[NUM_BMODES][NUM_BMODES][NUM_BMODES];
|
|
|
|
|
2011-08-25 23:22:32 +02:00
|
|
|
//------------------------------------------------------------------------------
|
2011-02-19 08:33:46 +01:00
|
|
|
|
|
|
|
#if defined(__cplusplus) || defined(c_plusplus)
|
|
|
|
} // extern "C"
|
|
|
|
#endif
|
|
|
|
|
2011-09-07 07:31:28 +02:00
|
|
|
#endif /* WEBP_ENC_COST_H_ */
|