mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-16 13:59:51 +02:00
move token buffer to its own file (token.c)
Change-Id: Ib9791c52f48d98fad5ed3830f36894ef5ac362fa
This commit is contained in:
@ -321,40 +321,27 @@ void VP8SetSegment(const VP8EncIterator* const it, int segment);
|
||||
|
||||
// WIP: #define USE_TOKEN_BUFFER
|
||||
|
||||
#ifdef USE_TOKEN_BUFFER
|
||||
|
||||
#define MAX_NUM_TOKEN 2048
|
||||
|
||||
typedef struct VP8Tokens VP8Tokens;
|
||||
struct VP8Tokens {
|
||||
uint16_t tokens_[MAX_NUM_TOKEN]; // bit#15: bit, bits 0..14: slot
|
||||
int left_;
|
||||
VP8Tokens* next_;
|
||||
};
|
||||
typedef struct VP8Tokens VP8Tokens; // struct details in token.c
|
||||
|
||||
typedef struct {
|
||||
VP8Tokens* rows_;
|
||||
uint16_t* tokens_; // set to (*last_)->tokens_
|
||||
VP8Tokens** last_;
|
||||
int left_;
|
||||
int error_; // true in case of malloc error
|
||||
VP8Tokens* pages_; // first page
|
||||
VP8Tokens** last_page_; // last page
|
||||
uint16_t* tokens_; // set to (*last_page_)->tokens_
|
||||
int left_; // how many free tokens left before the page is full.
|
||||
int error_; // true in case of malloc error
|
||||
} VP8TBuffer;
|
||||
|
||||
void VP8TBufferInit(VP8TBuffer* const b); // initialize an empty buffer
|
||||
int VP8TBufferNewPage(VP8TBuffer* const b); // allocate a new page
|
||||
void VP8TBufferClear(VP8TBuffer* const b); // de-allocate memory
|
||||
|
||||
#ifdef USE_TOKEN_BUFFER
|
||||
|
||||
void VP8TBufferClear(VP8TBuffer* const b); // de-allocate pages memory
|
||||
|
||||
int VP8EmitTokens(const VP8TBuffer* const b, VP8BitWriter* const bw,
|
||||
const uint8_t* const probas);
|
||||
|
||||
static WEBP_INLINE int VP8AddToken(VP8TBuffer* const b,
|
||||
int bit, int proba_idx) {
|
||||
if (b->left_ > 0 || VP8TBufferNewPage(b)) {
|
||||
const int slot = --b->left_;
|
||||
b->tokens_[slot] = (bit << 15) | proba_idx;
|
||||
}
|
||||
return bit;
|
||||
}
|
||||
const uint8_t* const probas, int final_pass);
|
||||
int VP8RecordCoeffTokens(int ctx, int first, int last,
|
||||
const int16_t* const coeffs, VP8TBuffer* tokens);
|
||||
void VP8TokenToStats(const VP8TBuffer* const b, proba_t* const stats);
|
||||
|
||||
#endif // USE_TOKEN_BUFFER
|
||||
|
||||
@ -384,6 +371,10 @@ struct VP8Encoder {
|
||||
|
||||
int percent_; // for progress
|
||||
|
||||
#ifdef USE_TOKEN_BUFFER
|
||||
VP8TBuffer tokens_; // token buffer
|
||||
#endif
|
||||
|
||||
// transparency blob
|
||||
int has_alpha_;
|
||||
uint8_t* alpha_data_; // non-NULL if transparency is present
|
||||
@ -460,6 +451,11 @@ void VP8EncFreeBitWriters(VP8Encoder* const enc);
|
||||
|
||||
// in frame.c
|
||||
extern const uint8_t VP8EncBands[16 + 1];
|
||||
extern const uint8_t VP8Cat3[];
|
||||
extern const uint8_t VP8Cat4[];
|
||||
extern const uint8_t VP8Cat5[];
|
||||
extern const uint8_t VP8Cat6[];
|
||||
|
||||
// Form all the four Intra16x16 predictions in the yuv_p_ cache
|
||||
void VP8MakeLuma16Preds(const VP8EncIterator* const it);
|
||||
// Form all the four Chroma8x8 predictions in the yuv_p_ cache
|
||||
|
Reference in New Issue
Block a user