Lines Matching refs:sp
188 #define NextCode(tif, sp, bp, code, get) get(sp, bp, code) argument
202 LZWCodecState* sp = DecoderState(tif); in LZWSetupDecode() local
205 if( sp == NULL ) in LZWSetupDecode()
226 sp = DecoderState(tif); in LZWSetupDecode()
229 assert(sp != NULL); in LZWSetupDecode()
231 if (sp->dec_codetab == NULL) { in LZWSetupDecode()
232 sp->dec_codetab = (code_t*)_TIFFmalloc(CSIZE*sizeof (code_t)); in LZWSetupDecode()
233 if (sp->dec_codetab == NULL) { in LZWSetupDecode()
243 sp->dec_codetab[code].value = code; in LZWSetupDecode()
244 sp->dec_codetab[code].firstchar = code; in LZWSetupDecode()
245 sp->dec_codetab[code].length = 1; in LZWSetupDecode()
246 sp->dec_codetab[code].next = NULL; in LZWSetupDecode()
251 _TIFFmemset(&sp->dec_codetab[CODE_CLEAR], 0, in LZWSetupDecode()
264 LZWCodecState *sp = DecoderState(tif); in LZWPreDecode() local
267 assert(sp != NULL); in LZWPreDecode()
268 if( sp->dec_codetab == NULL ) in LZWPreDecode()
271 if( sp->dec_codetab == NULL ) in LZWPreDecode()
280 if (!sp->dec_decode) { in LZWPreDecode()
299 sp->dec_decode = LZWDecodeCompat; in LZWPreDecode()
301 sp->lzw_maxcode = MAXCODE(BITS_MIN); in LZWPreDecode()
303 if (!sp->dec_decode) { in LZWPreDecode()
306 sp->dec_decode = LZWDecode; in LZWPreDecode()
311 sp->lzw_maxcode = MAXCODE(BITS_MIN)-1; in LZWPreDecode()
312 sp->dec_decode = LZWDecode; in LZWPreDecode()
314 sp->lzw_nbits = BITS_MIN; in LZWPreDecode()
315 sp->lzw_nextbits = 0; in LZWPreDecode()
316 sp->lzw_nextdata = 0; in LZWPreDecode()
318 sp->dec_restart = 0; in LZWPreDecode()
319 sp->dec_nbitsmask = MAXCODE(BITS_MIN); in LZWPreDecode()
321 sp->dec_bitsleft = ((uint64)tif->tif_rawcc) << 3; in LZWPreDecode()
323 sp->dec_free_entp = sp->dec_codetab + CODE_FIRST; in LZWPreDecode()
331 _TIFFmemset(sp->dec_free_entp, 0, (CSIZE-CODE_FIRST)*sizeof (code_t)); in LZWPreDecode()
332 sp->dec_oldcodep = &sp->dec_codetab[-1]; in LZWPreDecode()
333 sp->dec_maxcodep = &sp->dec_codetab[sp->dec_nbitsmask-1]; in LZWPreDecode()
340 #define GetNextCode(sp, bp, code) { \ argument
363 LZWCodecState *sp = DecoderState(tif); in LZWDecode() local
375 assert(sp != NULL); in LZWDecode()
376 assert(sp->dec_codetab != NULL); in LZWDecode()
386 if (sp->dec_restart) { in LZWDecode()
389 codep = sp->dec_codep; in LZWDecode()
390 residue = codep->length - sp->dec_restart; in LZWDecode()
398 sp->dec_restart += occ; in LZWDecode()
423 sp->dec_restart = 0; in LZWDecode()
427 nbits = sp->lzw_nbits; in LZWDecode()
428 nextdata = sp->lzw_nextdata; in LZWDecode()
429 nextbits = sp->lzw_nextbits; in LZWDecode()
430 nbitsmask = sp->dec_nbitsmask; in LZWDecode()
431 oldcodep = sp->dec_oldcodep; in LZWDecode()
432 free_entp = sp->dec_free_entp; in LZWDecode()
433 maxcodep = sp->dec_maxcodep; in LZWDecode()
436 NextCode(tif, sp, bp, code, GetNextCode); in LZWDecode()
441 free_entp = sp->dec_codetab + CODE_FIRST; in LZWDecode()
446 maxcodep = sp->dec_codetab + nbitsmask-1; in LZWDecode()
447 NextCode(tif, sp, bp, code, GetNextCode); in LZWDecode()
458 oldcodep = sp->dec_codetab + code; in LZWDecode()
461 codep = sp->dec_codetab + code; in LZWDecode()
466 if (free_entp < &sp->dec_codetab[0] || in LZWDecode()
467 free_entp >= &sp->dec_codetab[CSIZE]) { in LZWDecode()
475 if (free_entp->next < &sp->dec_codetab[0] || in LZWDecode()
476 free_entp->next >= &sp->dec_codetab[CSIZE]) { in LZWDecode()
490 maxcodep = sp->dec_codetab + nbitsmask-1; in LZWDecode()
512 sp->dec_codep = codep; in LZWDecode()
517 sp->dec_restart = (long)occ; in LZWDecode()
548 sp->lzw_nbits = (unsigned short) nbits; in LZWDecode()
549 sp->lzw_nextdata = nextdata; in LZWDecode()
550 sp->lzw_nextbits = nextbits; in LZWDecode()
551 sp->dec_nbitsmask = nbitsmask; in LZWDecode()
552 sp->dec_oldcodep = oldcodep; in LZWDecode()
553 sp->dec_free_entp = free_entp; in LZWDecode()
554 sp->dec_maxcodep = maxcodep; in LZWDecode()
575 #define GetNextCodeCompat(sp, bp, code) { \ argument
591 LZWCodecState *sp = DecoderState(tif); in LZWDecodeCompat() local
601 assert(sp != NULL); in LZWDecodeCompat()
612 if (sp->dec_restart) { in LZWDecodeCompat()
615 codep = sp->dec_codep; in LZWDecodeCompat()
616 residue = codep->length - sp->dec_restart; in LZWDecodeCompat()
624 sp->dec_restart += occ; in LZWDecodeCompat()
644 sp->dec_restart = 0; in LZWDecodeCompat()
648 nbits = sp->lzw_nbits; in LZWDecodeCompat()
649 nextdata = sp->lzw_nextdata; in LZWDecodeCompat()
650 nextbits = sp->lzw_nextbits; in LZWDecodeCompat()
651 nbitsmask = sp->dec_nbitsmask; in LZWDecodeCompat()
652 oldcodep = sp->dec_oldcodep; in LZWDecodeCompat()
653 free_entp = sp->dec_free_entp; in LZWDecodeCompat()
654 maxcodep = sp->dec_maxcodep; in LZWDecodeCompat()
657 NextCode(tif, sp, bp, code, GetNextCodeCompat); in LZWDecodeCompat()
662 free_entp = sp->dec_codetab + CODE_FIRST; in LZWDecodeCompat()
667 maxcodep = sp->dec_codetab + nbitsmask; in LZWDecodeCompat()
668 NextCode(tif, sp, bp, code, GetNextCodeCompat); in LZWDecodeCompat()
679 oldcodep = sp->dec_codetab + code; in LZWDecodeCompat()
682 codep = sp->dec_codetab + code; in LZWDecodeCompat()
687 if (free_entp < &sp->dec_codetab[0] || in LZWDecodeCompat()
688 free_entp >= &sp->dec_codetab[CSIZE]) { in LZWDecodeCompat()
695 if (free_entp->next < &sp->dec_codetab[0] || in LZWDecodeCompat()
696 free_entp->next >= &sp->dec_codetab[CSIZE]) { in LZWDecodeCompat()
709 maxcodep = sp->dec_codetab + nbitsmask; in LZWDecodeCompat()
731 sp->dec_codep = codep; in LZWDecodeCompat()
735 sp->dec_restart = occ; in LZWDecodeCompat()
754 sp->lzw_nbits = nbits; in LZWDecodeCompat()
755 sp->lzw_nextdata = nextdata; in LZWDecodeCompat()
756 sp->lzw_nextbits = nextbits; in LZWDecodeCompat()
757 sp->dec_nbitsmask = nbitsmask; in LZWDecodeCompat()
758 sp->dec_oldcodep = oldcodep; in LZWDecodeCompat()
759 sp->dec_free_entp = free_entp; in LZWDecodeCompat()
760 sp->dec_maxcodep = maxcodep; in LZWDecodeCompat()
786 LZWCodecState* sp = EncoderState(tif); in LZWSetupEncode() local
788 assert(sp != NULL); in LZWSetupEncode()
789 sp->enc_hashtab = (hash_t*) _TIFFmalloc(HSIZE*sizeof (hash_t)); in LZWSetupEncode()
790 if (sp->enc_hashtab == NULL) { in LZWSetupEncode()
804 LZWCodecState *sp = EncoderState(tif); in LZWPreEncode() local
807 assert(sp != NULL); in LZWPreEncode()
809 if( sp->enc_hashtab == NULL ) in LZWPreEncode()
814 sp->lzw_nbits = BITS_MIN; in LZWPreEncode()
815 sp->lzw_maxcode = MAXCODE(BITS_MIN); in LZWPreEncode()
816 sp->lzw_free_ent = CODE_FIRST; in LZWPreEncode()
817 sp->lzw_nextbits = 0; in LZWPreEncode()
818 sp->lzw_nextdata = 0; in LZWPreEncode()
819 sp->enc_checkpoint = CHECK_GAP; in LZWPreEncode()
820 sp->enc_ratio = 0; in LZWPreEncode()
821 sp->enc_incount = 0; in LZWPreEncode()
822 sp->enc_outcount = 0; in LZWPreEncode()
827 sp->enc_rawlimit = tif->tif_rawdata + tif->tif_rawdatasize-1 - 4; in LZWPreEncode()
828 cl_hash(sp); /* clear hash table */ in LZWPreEncode()
829 sp->enc_oldcode = (hcode_t) -1; /* generates CODE_CLEAR in LZWEncode */ in LZWPreEncode()
833 #define CALCRATIO(sp, rat) { \ argument
871 register LZWCodecState *sp = EncoderState(tif); in LZWEncode() local
885 if (sp == NULL) in LZWEncode()
888 assert(sp->enc_hashtab != NULL); in LZWEncode()
893 incount = sp->enc_incount; in LZWEncode()
894 outcount = sp->enc_outcount; in LZWEncode()
895 checkpoint = sp->enc_checkpoint; in LZWEncode()
896 nextdata = sp->lzw_nextdata; in LZWEncode()
897 nextbits = sp->lzw_nextbits; in LZWEncode()
898 free_ent = sp->lzw_free_ent; in LZWEncode()
899 maxcode = sp->lzw_maxcode; in LZWEncode()
900 nbits = sp->lzw_nbits; in LZWEncode()
902 limit = sp->enc_rawlimit; in LZWEncode()
903 ent = sp->enc_oldcode; in LZWEncode()
925 hp = &sp->enc_hashtab[h]; in LZWEncode()
944 hp = &sp->enc_hashtab[h]; in LZWEncode()
971 cl_hash(sp); in LZWEncode()
972 sp->enc_ratio = 0; in LZWEncode()
997 CALCRATIO(sp, rat); in LZWEncode()
998 if (rat <= sp->enc_ratio) { in LZWEncode()
999 cl_hash(sp); in LZWEncode()
1000 sp->enc_ratio = 0; in LZWEncode()
1008 sp->enc_ratio = rat; in LZWEncode()
1018 sp->enc_incount = incount; in LZWEncode()
1019 sp->enc_outcount = outcount; in LZWEncode()
1020 sp->enc_checkpoint = checkpoint; in LZWEncode()
1021 sp->enc_oldcode = ent; in LZWEncode()
1022 sp->lzw_nextdata = nextdata; in LZWEncode()
1023 sp->lzw_nextbits = nextbits; in LZWEncode()
1024 sp->lzw_free_ent = free_ent; in LZWEncode()
1025 sp->lzw_maxcode = maxcode; in LZWEncode()
1026 sp->lzw_nbits = nbits; in LZWEncode()
1038 register LZWCodecState *sp = EncoderState(tif); in LZWPostEncode() local
1040 long nextbits = sp->lzw_nextbits; in LZWPostEncode()
1041 unsigned long nextdata = sp->lzw_nextdata; in LZWPostEncode()
1042 long outcount = sp->enc_outcount; in LZWPostEncode()
1043 int nbits = sp->lzw_nbits; in LZWPostEncode()
1045 if (op > sp->enc_rawlimit) { in LZWPostEncode()
1050 if (sp->enc_oldcode != (hcode_t) -1) { in LZWPostEncode()
1051 PutNextCode(op, sp->enc_oldcode); in LZWPostEncode()
1052 sp->enc_oldcode = (hcode_t) -1; in LZWPostEncode()
1066 cl_hash(LZWCodecState* sp) in cl_hash() argument
1068 register hash_t *hp = &sp->enc_hashtab[HSIZE-1]; in cl_hash()