};
struct LZWState {
- int eob_reached;
uint8_t *pbuf, *ebuf;
int bbits;
unsigned int bbuf;
while (s->bbits < s->cursize) {
if (!s->bs) {
s->bs = *s->pbuf++;
- if(!s->bs) {
- s->eob_reached = 1;
- break;
- }
}
s->bbuf |= (*s->pbuf++) << s->bbits;
s->bbits += 8;
s->bbuf >>= s->cursize;
} else { // TIFF
while (s->bbits < s->cursize) {
- if (s->pbuf >= s->ebuf) {
- s->eob_reached = 1;
- }
s->bbuf = (s->bbuf << 8) | (*s->pbuf++);
s->bbits += 8;
}
void ff_lzw_decode_tail(LZWState *p)
{
struct LZWState *s = (struct LZWState *)p;
- while(!s->eob_reached)
- lzw_get_code(s);
+
+ if(s->mode == FF_LZW_GIF) {
+ while(s->pbuf < s->ebuf && s->bs>0){
+ s->pbuf += s->bs;
+ s->bs = *s->pbuf++;
+ }
+ }else
+ s->pbuf= s->ebuf;
}
void ff_lzw_decode_open(LZWState **p)
if(csize < 1 || csize > LZW_MAXBITS)
return -1;
/* read buffer */
- s->eob_reached = 0;
s->pbuf = buf;
s->ebuf = s->pbuf + buf_size;
s->bbuf = 0;