35 #define LZW_MAXBITS 12
36 #define LZW_SIZTABLE (1<<LZW_MAXBITS)
38 static const uint16_t
mask[17] =
40 0x0000, 0x0001, 0x0003, 0x0007,
41 0x000F, 0x001F, 0x003F, 0x007F,
42 0x00FF, 0x01FF, 0x03FF, 0x07FF,
43 0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF
78 while (
s->bbits <
s->cursize) {
80 s->bs = bytestream2_get_byte(&
s->gb);
82 s->bbuf |= bytestream2_get_byte(&
s->gb) <<
s->bbits;
87 s->bbuf >>=
s->cursize;
89 while (
s->bbits <
s->cursize) {
90 s->bbuf = (
s->bbuf << 8) | bytestream2_get_byte(&
s->gb);
93 c =
s->bbuf >> (
s->bbits -
s->cursize);
95 s->bbits -=
s->cursize;
96 return c &
s->curmask;
106 s->bs = bytestream2_get_byte(&
s->gb);
145 s->cursize =
s->codesize + 1;
146 s->curmask =
mask[
s->cursize];
147 s->top_slot = 1 <<
s->cursize;
148 s->clear_code = 1 <<
s->codesize;
149 s->end_code =
s->clear_code + 1;
150 s->slot =
s->newcodes =
s->clear_code + 2;
183 while (
sp >
s->stack) {
189 if (
c ==
s->end_code) {
191 }
else if (
c ==
s->clear_code) {
192 s->cursize =
s->codesize + 1;
193 s->curmask =
mask[
s->cursize];
194 s->slot =
s->newcodes;
195 s->top_slot = 1 <<
s->cursize;
199 if (
code ==
s->slot &&
fc>=0) {
202 }
else if(
code >=
s->slot)
204 while (
code >=
s->newcodes) {
209 if (
s->slot <
s->top_slot &&
oc>=0) {
210 s->suffix[
s->slot] =
code;
211 s->prefix[
s->slot++] =
oc;
215 if (
s->slot >=
s->top_slot -
s->extra_slot) {
218 s->curmask =
mask[++
s->cursize];
Libavcodec external API header.
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
static av_always_inline int bytestream2_tell(GetByteContext *g)
#define fc(width, name, range_min, range_max)
mode
Use these values in ebur128_init (or'ed).
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
av_cold void ff_lzw_decode_close(LZWState **p)
int ff_lzw_decode_init(LZWState *p, int csize, const uint8_t *buf, int buf_size, int mode)
Initialize LZW decoder.
static const uint16_t mask[17]
static int lzw_get_code(struct LZWState *s)
int ff_lzw_decode(LZWState *p, uint8_t *buf, int len)
Decode given number of bytes NOTE: the algorithm here is inspired from the LZW GIF decoder written by...
av_cold void ff_lzw_decode_open(LZWState **p)
int ff_lzw_decode_tail(LZWState *p)
Memory handling functions.
int newcodes
First available code.
uint16_t prefix[LZW_SIZTABLE]
int bs
current buffer size for GIF
uint8_t stack[LZW_SIZTABLE]
int top_slot
Highest code for current size.
int cursize
The current code size.
uint8_t suffix[LZW_SIZTABLE]