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 = (unsigned char)code; in LZWSetupDecode()
244 sp->dec_codetab[code].firstchar = (unsigned char)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 = 0; 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()
424 sp->dec_restart = 0; in LZWDecode()
429 sp->dec_bitsleft = (((uint64)tif->tif_rawcc) << 3); in LZWDecode()
431 nbits = sp->lzw_nbits; in LZWDecode()
432 nextdata = sp->lzw_nextdata; in LZWDecode()
433 nextbits = sp->lzw_nextbits; in LZWDecode()
434 nbitsmask = sp->dec_nbitsmask; in LZWDecode()
435 oldcodep = sp->dec_oldcodep; in LZWDecode()
436 free_entp = sp->dec_free_entp; in LZWDecode()
437 maxcodep = sp->dec_maxcodep; in LZWDecode()
440 NextCode(tif, sp, bp, code, GetNextCode); in LZWDecode()
445 free_entp = sp->dec_codetab + CODE_FIRST; in LZWDecode()
450 maxcodep = sp->dec_codetab + nbitsmask-1; in LZWDecode()
451 NextCode(tif, sp, bp, code, GetNextCode); in LZWDecode()
463 oldcodep = sp->dec_codetab + code; in LZWDecode()
466 codep = sp->dec_codetab + code; in LZWDecode()
471 if (free_entp < &sp->dec_codetab[0] || in LZWDecode()
472 free_entp >= &sp->dec_codetab[CSIZE]) { in LZWDecode()
480 if (free_entp->next < &sp->dec_codetab[0] || in LZWDecode()
481 free_entp->next >= &sp->dec_codetab[CSIZE]) { in LZWDecode()
495 maxcodep = sp->dec_codetab + nbitsmask-1; in LZWDecode()
517 sp->dec_codep = codep; in LZWDecode()
522 sp->dec_restart = (long)occ; in LZWDecode()
557 sp->lzw_nbits = (unsigned short) nbits; in LZWDecode()
558 sp->lzw_nextdata = nextdata; in LZWDecode()
559 sp->lzw_nextbits = nextbits; in LZWDecode()
560 sp->dec_nbitsmask = nbitsmask; in LZWDecode()
561 sp->dec_oldcodep = oldcodep; in LZWDecode()
562 sp->dec_free_entp = free_entp; in LZWDecode()
563 sp->dec_maxcodep = maxcodep; in LZWDecode()
584 #define GetNextCodeCompat(sp, bp, code) { \ argument
600 LZWCodecState *sp = DecoderState(tif); in LZWDecodeCompat() local
610 assert(sp != NULL); in LZWDecodeCompat()
621 if (sp->dec_restart) { in LZWDecodeCompat()
624 codep = sp->dec_codep; in LZWDecodeCompat()
625 residue = codep->length - sp->dec_restart; in LZWDecodeCompat()
633 sp->dec_restart += occ; in LZWDecodeCompat()
654 sp->dec_restart = 0; in LZWDecodeCompat()
658 nbits = sp->lzw_nbits; in LZWDecodeCompat()
659 nextdata = sp->lzw_nextdata; in LZWDecodeCompat()
660 nextbits = sp->lzw_nextbits; in LZWDecodeCompat()
661 nbitsmask = sp->dec_nbitsmask; in LZWDecodeCompat()
662 oldcodep = sp->dec_oldcodep; in LZWDecodeCompat()
663 free_entp = sp->dec_free_entp; in LZWDecodeCompat()
664 maxcodep = sp->dec_maxcodep; in LZWDecodeCompat()
667 NextCode(tif, sp, bp, code, GetNextCodeCompat); in LZWDecodeCompat()
672 free_entp = sp->dec_codetab + CODE_FIRST; in LZWDecodeCompat()
677 maxcodep = sp->dec_codetab + nbitsmask; in LZWDecodeCompat()
678 NextCode(tif, sp, bp, code, GetNextCodeCompat); in LZWDecodeCompat()
690 oldcodep = sp->dec_codetab + code; in LZWDecodeCompat()
693 codep = sp->dec_codetab + code; in LZWDecodeCompat()
698 if (free_entp < &sp->dec_codetab[0] || in LZWDecodeCompat()
699 free_entp >= &sp->dec_codetab[CSIZE]) { in LZWDecodeCompat()
706 if (free_entp->next < &sp->dec_codetab[0] || in LZWDecodeCompat()
707 free_entp->next >= &sp->dec_codetab[CSIZE]) { in LZWDecodeCompat()
720 maxcodep = sp->dec_codetab + nbitsmask; in LZWDecodeCompat()
742 sp->dec_codep = codep; in LZWDecodeCompat()
746 sp->dec_restart = occ; in LZWDecodeCompat()
768 sp->lzw_nbits = (unsigned short)nbits; in LZWDecodeCompat()
769 sp->lzw_nextdata = nextdata; in LZWDecodeCompat()
770 sp->lzw_nextbits = nextbits; in LZWDecodeCompat()
771 sp->dec_nbitsmask = nbitsmask; in LZWDecodeCompat()
772 sp->dec_oldcodep = oldcodep; in LZWDecodeCompat()
773 sp->dec_free_entp = free_entp; in LZWDecodeCompat()
774 sp->dec_maxcodep = maxcodep; in LZWDecodeCompat()
800 LZWCodecState* sp = EncoderState(tif); in LZWSetupEncode() local
802 assert(sp != NULL); in LZWSetupEncode()
803 sp->enc_hashtab = (hash_t*) _TIFFmalloc(HSIZE*sizeof (hash_t)); in LZWSetupEncode()
804 if (sp->enc_hashtab == NULL) { in LZWSetupEncode()
818 LZWCodecState *sp = EncoderState(tif); in LZWPreEncode() local
821 assert(sp != NULL); in LZWPreEncode()
823 if( sp->enc_hashtab == NULL ) in LZWPreEncode()
828 sp->lzw_nbits = BITS_MIN; in LZWPreEncode()
829 sp->lzw_maxcode = MAXCODE(BITS_MIN); in LZWPreEncode()
830 sp->lzw_free_ent = CODE_FIRST; in LZWPreEncode()
831 sp->lzw_nextbits = 0; in LZWPreEncode()
832 sp->lzw_nextdata = 0; in LZWPreEncode()
833 sp->enc_checkpoint = CHECK_GAP; in LZWPreEncode()
834 sp->enc_ratio = 0; in LZWPreEncode()
835 sp->enc_incount = 0; in LZWPreEncode()
836 sp->enc_outcount = 0; in LZWPreEncode()
841 sp->enc_rawlimit = tif->tif_rawdata + tif->tif_rawdatasize-1 - 4; in LZWPreEncode()
842 cl_hash(sp); /* clear hash table */ in LZWPreEncode()
843 sp->enc_oldcode = (hcode_t) -1; /* generates CODE_CLEAR in LZWEncode */ in LZWPreEncode()
847 #define CALCRATIO(sp, rat) { \ argument
885 register LZWCodecState *sp = EncoderState(tif); in LZWEncode() local
899 if (sp == NULL) in LZWEncode()
902 assert(sp->enc_hashtab != NULL); in LZWEncode()
907 incount = sp->enc_incount; in LZWEncode()
908 outcount = sp->enc_outcount; in LZWEncode()
909 checkpoint = sp->enc_checkpoint; in LZWEncode()
910 nextdata = sp->lzw_nextdata; in LZWEncode()
911 nextbits = sp->lzw_nextbits; in LZWEncode()
912 free_ent = sp->lzw_free_ent; in LZWEncode()
913 maxcode = sp->lzw_maxcode; in LZWEncode()
914 nbits = sp->lzw_nbits; in LZWEncode()
916 limit = sp->enc_rawlimit; in LZWEncode()
917 ent = (hcode_t)sp->enc_oldcode; in LZWEncode()
939 hp = &sp->enc_hashtab[h]; in LZWEncode()
958 hp = &sp->enc_hashtab[h]; in LZWEncode()
986 cl_hash(sp); in LZWEncode()
987 sp->enc_ratio = 0; in LZWEncode()
1012 CALCRATIO(sp, rat); in LZWEncode()
1013 if (rat <= sp->enc_ratio) { in LZWEncode()
1014 cl_hash(sp); in LZWEncode()
1015 sp->enc_ratio = 0; in LZWEncode()
1023 sp->enc_ratio = rat; in LZWEncode()
1033 sp->enc_incount = incount; in LZWEncode()
1034 sp->enc_outcount = outcount; in LZWEncode()
1035 sp->enc_checkpoint = checkpoint; in LZWEncode()
1036 sp->enc_oldcode = ent; in LZWEncode()
1037 sp->lzw_nextdata = nextdata; in LZWEncode()
1038 sp->lzw_nextbits = nextbits; in LZWEncode()
1039 sp->lzw_free_ent = (unsigned short)free_ent; in LZWEncode()
1040 sp->lzw_maxcode = (unsigned short)maxcode; in LZWEncode()
1041 sp->lzw_nbits = (unsigned short)nbits; in LZWEncode()
1053 register LZWCodecState *sp = EncoderState(tif); in LZWPostEncode() local
1055 long nextbits = sp->lzw_nextbits; in LZWPostEncode()
1056 unsigned long nextdata = sp->lzw_nextdata; in LZWPostEncode()
1057 long outcount = sp->enc_outcount; in LZWPostEncode()
1058 int nbits = sp->lzw_nbits; in LZWPostEncode()
1060 if (op > sp->enc_rawlimit) { in LZWPostEncode()
1066 if (sp->enc_oldcode != (hcode_t) -1) { in LZWPostEncode()
1067 int free_ent = sp->lzw_free_ent; in LZWPostEncode()
1069 PutNextCode(op, sp->enc_oldcode); in LZWPostEncode()
1070 sp->enc_oldcode = (hcode_t) -1; in LZWPostEncode()
1083 if (free_ent > sp->lzw_maxcode) { in LZWPostEncode()
1101 cl_hash(LZWCodecState* sp) in cl_hash() argument
1103 register hash_t *hp = &sp->enc_hashtab[HSIZE-1]; in cl_hash()