Lines Matching refs:context

33 void CXInitUncompContextRL( CXUncompContextRL *context, void* dest )  in CXInitUncompContextRL()  argument
35 context->destp = (u8*)dest; in CXInitUncompContextRL()
36 context->destCount = 0; in CXInitUncompContextRL()
37 context->flags = 0; in CXInitUncompContextRL()
38 context->length = 0; in CXInitUncompContextRL()
39 context->headerSize = 8; in CXInitUncompContextRL()
40 context->forceDestCount = 0; in CXInitUncompContextRL()
54 void CXInitUncompContextLZ( CXUncompContextLZ *context, void* dest ) in CXInitUncompContextLZ() argument
56 context->destp = (u8*)dest; in CXInitUncompContextLZ()
57 context->destCount = 0; in CXInitUncompContextLZ()
58 context->flags = 0; in CXInitUncompContextLZ()
59 context->flagIndex = 0; in CXInitUncompContextLZ()
60 context->length = 0; in CXInitUncompContextLZ()
61 context->lengthFlg = 3; in CXInitUncompContextLZ()
62 context->headerSize = 8; in CXInitUncompContextLZ()
63 context->exFormat = 0; in CXInitUncompContextLZ()
64 context->forceDestCount = 0; in CXInitUncompContextLZ()
78 void CXInitUncompContextHuffman( CXUncompContextHuffman *context, void* dest ) in CXInitUncompContextHuffman() argument
80 context->destp = (u8*)dest; in CXInitUncompContextHuffman()
81 context->destCount = 0; in CXInitUncompContextHuffman()
82 context->bitSize = 0; in CXInitUncompContextHuffman()
83 context->treeSize = -1; in CXInitUncompContextHuffman()
84 context->treep = &context->tree[ 0 ]; in CXInitUncompContextHuffman()
85 context->destTmp = 0; in CXInitUncompContextHuffman()
86 context->destTmpCnt = 0; in CXInitUncompContextHuffman()
87 context->srcTmp = 0; in CXInitUncompContextHuffman()
88 context->srcTmpCnt = 0; in CXInitUncompContextHuffman()
89 context->headerSize = 8; in CXInitUncompContextHuffman()
90 context->forceDestCount = 0; in CXInitUncompContextHuffman()
155 s32 CXReadUncompRL( CXUncompContextRL *context, const void* data, u32 len ) in CXReadUncompRL() argument
161 if ( context->headerSize > 0 ) in CXReadUncompRL()
164 if ( context->headerSize == 8 ) in CXReadUncompRL()
175 …read_len = CXiReadHeader( &context->headerSize, &context->destCount, srcp, len, context->forceDest… in CXReadUncompRL()
180 return (context->headerSize == 0)? context->destCount : -1; in CXReadUncompRL()
184 while ( context->destCount > 0 ) in CXReadUncompRL()
187 if ( ! (context->flags & 0x80) ) in CXReadUncompRL()
190 while ( context->length > 0 ) in CXReadUncompRL()
192 *context->destp++ = *srcp++; in CXReadUncompRL()
193 context->length--; in CXReadUncompRL()
194 context->destCount--; in CXReadUncompRL()
199 return context->destCount; in CXReadUncompRL()
203 else if ( context->length > 0 ) in CXReadUncompRL()
208 while ( context->length > 0 ) in CXReadUncompRL()
210 *context->destp++ = srcTmp; in CXReadUncompRL()
211 context->length--; in CXReadUncompRL()
212 context->destCount--; in CXReadUncompRL()
216 return context->destCount; in CXReadUncompRL()
221 context->flags = *srcp++; in CXReadUncompRL()
223 context->length = (u16)(context->flags & 0x7F); in CXReadUncompRL()
224 if ( context->flags & 0x80 ) in CXReadUncompRL()
226 context->length += 3; in CXReadUncompRL()
230 context->length += 1; in CXReadUncompRL()
233 if ( context->length > context->destCount ) in CXReadUncompRL()
236 if ( context->forceDestCount == 0 ) in CXReadUncompRL()
240 context->length = (u16)context->destCount; in CXReadUncompRL()
244 return context->destCount; in CXReadUncompRL()
249 if ( (context->forceDestCount == 0) && (len > 32) ) in CXReadUncompRL()
271 s32 CXReadUncompLZ( CXUncompContextLZ *context, const void* data, u32 len ) in CXReadUncompLZ() argument
277 if ( context->headerSize > 0 ) in CXReadUncompLZ()
281 if ( context->headerSize == 8 ) in CXReadUncompLZ()
288 context->exFormat = (u8)( *srcp & 0x0F ); in CXReadUncompLZ()
289 if ( (context->exFormat != 0x0) && (context->exFormat != 0x1) ) in CXReadUncompLZ()
294 …read_len = CXiReadHeader( &context->headerSize, &context->destCount, srcp, len, context->forceDest… in CXReadUncompLZ()
299 return (context->headerSize == 0)? context->destCount : -1; in CXReadUncompLZ()
303 while ( context->destCount > 0 ) in CXReadUncompLZ()
305 while ( context->flagIndex > 0 ) in CXReadUncompLZ()
309 return context->destCount; in CXReadUncompLZ()
312 if ( ! (context->flags & 0x80) ) in CXReadUncompLZ()
315 *context->destp++ = *srcp++; in CXReadUncompLZ()
316 context->destCount--; in CXReadUncompLZ()
322 while ( context->lengthFlg > 0 ) in CXReadUncompLZ()
324 --context->lengthFlg; in CXReadUncompLZ()
325 if ( ! context->exFormat ) in CXReadUncompLZ()
327 context->length = *srcp++; in CXReadUncompLZ()
328 context->length += (3 << 4); in CXReadUncompLZ()
329 context->lengthFlg = 0; in CXReadUncompLZ()
333 switch ( context->lengthFlg ) in CXReadUncompLZ()
337 context->length = *srcp++; in CXReadUncompLZ()
338 if ( (context->length >> 4) == 1 ) in CXReadUncompLZ()
341 context->length = (context->length & 0x0F) << 16; in CXReadUncompLZ()
342 context->length += ( (0xFF + 0xF + 3) << 4 ); in CXReadUncompLZ()
344 else if ( (context->length >> 4) == 0 ) in CXReadUncompLZ()
347 context->length = (context->length & 0x0F) << 8; in CXReadUncompLZ()
348 context->length += ( (0xF + 2) << 4 ); in CXReadUncompLZ()
349 context->lengthFlg = 1; in CXReadUncompLZ()
353 context->length += (1 << 4); in CXReadUncompLZ()
354 context->lengthFlg = 0; in CXReadUncompLZ()
360 context->length += (*srcp++ << 8); in CXReadUncompLZ()
365 context->length += *srcp++; in CXReadUncompLZ()
372 return context->destCount; in CXReadUncompLZ()
376 offset = (context->length & 0xF) << 8; in CXReadUncompLZ()
377 context->length = context->length >> 4; in CXReadUncompLZ()
380 context->lengthFlg = 3; in CXReadUncompLZ()
383 if ( context->length > context->destCount ) in CXReadUncompLZ()
385 if ( context->forceDestCount == 0 ) in CXReadUncompLZ()
389 context->length = context->destCount; in CXReadUncompLZ()
392 while ( context->length > 0 ) in CXReadUncompLZ()
394 *context->destp = context->destp[ -offset ]; in CXReadUncompLZ()
395 context->destp++; in CXReadUncompLZ()
396 context->destCount--; in CXReadUncompLZ()
397 context->length--; in CXReadUncompLZ()
401 if ( context->destCount == 0 ) in CXReadUncompLZ()
405 context->flags <<= 1; in CXReadUncompLZ()
406 context->flagIndex--; in CXReadUncompLZ()
411 return context->destCount; in CXReadUncompLZ()
414 context->flags = *srcp++; in CXReadUncompLZ()
415 context->flagIndex = 8; in CXReadUncompLZ()
421 if ( (context->forceDestCount == 0) && (len > 32) ) in CXReadUncompLZ()
451 s32 CXReadUncompHuffman( CXUncompContextHuffman *context, const void* data, u32 len ) in CXReadUncompHuffman() argument
459 if ( context->headerSize > 0 ) in CXReadUncompHuffman()
463 if ( context->headerSize == 8 ) in CXReadUncompHuffman()
465 context->bitSize = (u8)(*srcp & 0xF); in CXReadUncompHuffman()
471 if ( (context->bitSize != 4) && (context->bitSize != 8) ) in CXReadUncompHuffman()
476 …read_len = CXiReadHeader( &context->headerSize, &context->destCount, srcp, len, context->forceDest… in CXReadUncompHuffman()
481 return (context->headerSize == 0)? context->destCount : -1; in CXReadUncompHuffman()
487 if ( context->treeSize < 0 ) in CXReadUncompHuffman()
489 context->treeSize = (s16)( ( *srcp + 1 ) * 2 - 1 ); in CXReadUncompHuffman()
490 *context->treep++ = *srcp++; in CXReadUncompHuffman()
495 while ( context->treeSize > 0 ) in CXReadUncompHuffman()
499 return context->destCount; in CXReadUncompHuffman()
501 *context->treep++ = *srcp++; in CXReadUncompHuffman()
502 context->treeSize--; in CXReadUncompHuffman()
504 if ( context->treeSize == 0 ) in CXReadUncompHuffman()
506 context->treep = &context->tree[ 1 ]; in CXReadUncompHuffman()
507 if ( ! CXiVerifyHuffmanTable_( &context->tree[ 0 ], context->bitSize ) ) in CXReadUncompHuffman()
515 while ( context->destCount > 0 ) in CXReadUncompHuffman()
518 while ( context->srcTmpCnt < 32 ) in CXReadUncompHuffman()
522 return context->destCount; in CXReadUncompHuffman()
524 context->srcTmp |= (*srcp++) << context->srcTmpCnt; in CXReadUncompHuffman()
526 context->srcTmpCnt += 8; in CXReadUncompHuffman()
530 while ( context->srcTmpCnt > 0 ) in CXReadUncompHuffman()
532 select = context->srcTmp >> 31; in CXReadUncompHuffman()
533 endFlag = (*context->treep << select) & TREE_END_MASK; in CXReadUncompHuffman()
534 context->treep = GetNextNode( context->treep, select ); in CXReadUncompHuffman()
535 context->srcTmp <<= 1; in CXReadUncompHuffman()
536 context->srcTmpCnt--; in CXReadUncompHuffman()
545 context->destTmp >>= context->bitSize; in CXReadUncompHuffman()
546 context->destTmp |= *context->treep << ( 32 - context->bitSize ); in CXReadUncompHuffman()
547 context->treep = &context->tree[ 1 ]; in CXReadUncompHuffman()
548 context->destTmpCnt += context->bitSize; in CXReadUncompHuffman()
550 if ( context->destCount <= (context->destTmpCnt / 8) ) in CXReadUncompHuffman()
552 context->destTmp >>= (32 - context->destTmpCnt); in CXReadUncompHuffman()
553 context->destTmpCnt = 32; in CXReadUncompHuffman()
557 if ( context->destTmpCnt == 32 ) in CXReadUncompHuffman()
559 *(u32*)context->destp = CXiConvertEndian_( context->destTmp ); in CXReadUncompHuffman()
560 context->destp += 4; in CXReadUncompHuffman()
561 context->destCount -= 4; in CXReadUncompHuffman()
562 context->destTmpCnt = 0; in CXReadUncompHuffman()
563 if ( context->destCount <= 0 ) in CXReadUncompHuffman()
573 if ( (context->forceDestCount == 0) && (len > 32) ) in CXReadUncompHuffman()
593 BitReader_Read( BitReader* context, u8 bits ) in BitReader_Read() argument
597 while ( context->stream_len < bits ) in BitReader_Read()
599 if ( context->cnt == 0 ) in BitReader_Read()
603 context->stream <<= 8; in BitReader_Read()
604 context->stream += *context->srcp; in BitReader_Read()
605 context->srcp++; in BitReader_Read()
606 context->cnt--; in BitReader_Read()
607 context->stream_len += 8; in BitReader_Read()
610 value = (s32)( (context->stream >> (context->stream_len - bits)) & ((1 << bits) - 1) ); in BitReader_Read()
611 context->stream_len -= bits; in BitReader_Read()
616 BitReader_ReadEx( BitReader* context, u8 bits ) in BitReader_ReadEx() argument
621 while ( context->stream_len < bits ) in BitReader_ReadEx()
623 if ( context->cnt == 0 ) in BitReader_ReadEx()
627 if ( context->stream_len > 24 ) in BitReader_ReadEx()
629 stock = (u8)( context->stream >> 24 ); in BitReader_ReadEx()
631 context->stream <<= 8; in BitReader_ReadEx()
632 context->stream += *context->srcp; in BitReader_ReadEx()
633 context->srcp++; in BitReader_ReadEx()
634 context->cnt--; in BitReader_ReadEx()
635 context->stream_len += 8; in BitReader_ReadEx()
637 value = context->stream; in BitReader_ReadEx()
639 value = (s64)( (value >> (context->stream_len - bits)) & ((1 << bits) - 1) ); in BitReader_ReadEx()
640 context->stream_len -= bits; in BitReader_ReadEx()
659 CXInitUncompContextLH( CXUncompContextLH * context, void* dest ) in CXInitUncompContextLH() argument
661 context->destp = dest; in CXInitUncompContextLH()
662 context->destCount = -1; in CXInitUncompContextLH()
663 context->nodep = context->huffTable9 + 1; in CXInitUncompContextLH()
664 context->tableSize9 = -1; in CXInitUncompContextLH()
665 context->tableSize12 = -1; in CXInitUncompContextLH()
666 context->headerSize = 8; in CXInitUncompContextLH()
667 context->length = 0; in CXInitUncompContextLH()
668 context->stream = 0; in CXInitUncompContextLH()
669 context->stream_len = 0; in CXInitUncompContextLH()
670 context->offset_bits = -1; in CXInitUncompContextLH()
671 context->forceDestCount = 0; in CXInitUncompContextLH()
689 CXReadUncompLH( CXUncompContextLH *context, const void* data, u32 len ) in CXReadUncompLH() argument
710 stream.stream = context->stream; in CXReadUncompLH()
711 stream.stream_len = context->stream_len; in CXReadUncompLH()
714 while ( context->headerSize > 0 ) in CXReadUncompLH()
721 context->headerSize -= 4; in CXReadUncompLH()
722 if ( context->headerSize == 4 ) in CXReadUncompLH()
729 context->destCount = (s32)( headerVal >> 8 ); in CXReadUncompLH()
731 if ( context->destCount == 0 ) in CXReadUncompLH()
733 context->headerSize = 4; in CXReadUncompLH()
734 context->destCount = -1; in CXReadUncompLH()
738 context->headerSize = 0; in CXReadUncompLH()
743 context->destCount = (s32)CXiConvertEndian_( (u32)val32 ); in CXReadUncompLH()
745 if ( context->headerSize == 0 ) in CXReadUncompLH()
747 … if ( ( context->forceDestCount > 0 ) && ( context->forceDestCount < context->destCount ) ) in CXReadUncompLH()
749 context->destCount = context->forceDestCount; in CXReadUncompLH()
756 if ( context->tableSize9 < 0 ) in CXReadUncompLH()
762context->tableSize9 = (CXiConvertEndian16_( (u16)val ) + 1) * 4 * 8; // shown with the bit count in CXReadUncompLH()
763 context->tableIdx = 1; in CXReadUncompLH()
764 context->tableSize9 -= 16; in CXReadUncompLH()
766 while ( context->tableSize9 >= LENGTH_BITS ) in CXReadUncompLH()
772 context->huffTable9[ context->tableIdx++ ] = (u16)val; in CXReadUncompLH()
773 context->tableSize9 -= LENGTH_BITS; in CXReadUncompLH()
775 while ( context->tableSize9 > 0 ) in CXReadUncompLH()
777 if ( ( val = BitReader_Read( &stream, (u8)context->tableSize9 ) ) < 0 ) in CXReadUncompLH()
781 context->tableSize9 = 0; in CXReadUncompLH()
784 if ( ! CXiLHVerifyTable( context->huffTable9, LENGTH_BITS ) ) in CXReadUncompLH()
790 if ( context->tableSize12 < 0 ) in CXReadUncompLH()
797 context->tableSize12 = (CXiConvertEndian16_( (u16)val ) + 1) * 4 * 8; in CXReadUncompLH()
799 context->tableSize12 = ((u16)val + 1) * 4 * 8; in CXReadUncompLH()
801 context->tableIdx = 1; in CXReadUncompLH()
802 context->tableSize12 -= (OFFSET_BITS > 8)? 16 : 8; in CXReadUncompLH()
805 while ( context->tableSize12 >= OFFSET_BITS ) in CXReadUncompLH()
811 context->huffTable12[ context->tableIdx++ ] = (u16)val; in CXReadUncompLH()
812 context->tableSize12 -= OFFSET_BITS; in CXReadUncompLH()
814 while ( context->tableSize12 > 0 ) in CXReadUncompLH()
816 if ( ( val = BitReader_Read( &stream, (u8)context->tableSize12 ) ) < 0 ) in CXReadUncompLH()
820 context->tableSize12 = 0; in CXReadUncompLH()
823 if ( ! CXiLHVerifyTable( context->huffTable12, OFFSET_BITS ) ) in CXReadUncompLH()
829 nodep = context->nodep; in CXReadUncompLH()
830 length = context->length; in CXReadUncompLH()
833 while ( context->destCount > 0 ) in CXReadUncompLH()
844 context->nodep = nodep; in CXReadUncompLH()
845 context->length = length; in CXReadUncompLH()
855 nodep = context->huffTable12 + 1; in CXReadUncompLH()
869 *context->destp++ = (u8)length; in CXReadUncompLH()
870 context->destCount--; in CXReadUncompLH()
871 nodep = context->huffTable9 + 1; in CXReadUncompLH()
881 if ( context->offset_bits < 0 ) in CXReadUncompLH()
891 context->nodep = nodep; in CXReadUncompLH()
892 context->length = length; in CXReadUncompLH()
902 context->offset_bits = (s8)( *(nodep + offset) ); in CXReadUncompLH()
919 if ( context->offset_bits <= 1 ) in CXReadUncompLH()
921 val = context->offset_bits; in CXReadUncompLH()
923 else if ( ( val = BitReader_Read( &stream, (u8)(context->offset_bits - 1) ) ) < 0 ) in CXReadUncompLH()
925 context->nodep = nodep; in CXReadUncompLH()
926 context->length = length; in CXReadUncompLH()
929 if ( context->offset_bits >= 2 ) in CXReadUncompLH()
931 val |= (1 << (context->offset_bits - 1)); in CXReadUncompLH()
934 context->offset_bits = -1; in CXReadUncompLH()
938 if ( context->destCount < lzLength ) in CXReadUncompLH()
941 if ( context->forceDestCount == 0 ) in CXReadUncompLH()
945 lzLength = (u16)context->destCount; in CXReadUncompLH()
948 context->destCount -= lzLength; in CXReadUncompLH()
951 *context->destp = *(context->destp - lzOffset); in CXReadUncompLH()
952 ++context->destp; in CXReadUncompLH()
955 nodep = context->huffTable9 + 1; in CXReadUncompLH()
960 context->stream = stream.stream; in CXReadUncompLH()
961 context->stream_len = stream.stream_len; in CXReadUncompLH()
965 if ( (context->destCount == 0) && in CXReadUncompLH()
966 (context->forceDestCount == 0) && in CXReadUncompLH()
972 return context->destCount; in CXReadUncompLH()
1018 CXUncompContextLRC *context, in LRCIntro_() argument
1023 info9->freq = context->freq9; in LRCIntro_()
1024 info9->low_cnt = context->low_cnt9; in LRCIntro_()
1025 info9->total = context->total9; in LRCIntro_()
1028 info12->freq = context->freq12; in LRCIntro_()
1029 info12->low_cnt = context->low_cnt12; in LRCIntro_()
1030 info12->total = context->total12; in LRCIntro_()
1033 state->low = context->low; in LRCIntro_()
1034 state->range = context->range; in LRCIntro_()
1035 state->code = context->code; in LRCIntro_()
1036 state->carry = context->carry; in LRCIntro_()
1037 state->carry_cnt = context->carry_cnt; in LRCIntro_()
1055 CXUncompContextLRC *context, in LRCFin_() argument
1060 context->total9 = info9->total; in LRCFin_()
1061 context->total12 = info12->total; in LRCFin_()
1063 context->low = state->low; in LRCFin_()
1064 context->range = state->range; in LRCFin_()
1065 context->code = state->code; in LRCFin_()
1066 context->carry = state->carry; in LRCFin_()
1067 context->carry_cnt = state->carry_cnt; in LRCFin_()
1274 CXInitUncompContextLRC( CXUncompContextLRC * context, void* dest ) in CXInitUncompContextLRC() argument
1283 LRCIntro_( context, &info9, &info12, &rcState ); in CXInitUncompContextLRC()
1285 context->destp = dest; in CXInitUncompContextLRC()
1286 context->destCount = 0; in CXInitUncompContextLRC()
1287 context->headerSize = 8; in CXInitUncompContextLRC()
1288 context->length = 0; in CXInitUncompContextLRC()
1289 context->forceDestCount = 0; in CXInitUncompContextLRC()
1291 context->codeLen = 4; in CXInitUncompContextLRC()
1299 LRCFin_( context, &info9, &info12, &rcState ); in CXInitUncompContextLRC()
1319 CXReadUncompLRC( CXUncompContextLRC *context, const void* data, u32 len ) in CXReadUncompLRC() argument
1327 LRCIntro_( context, &info9, &info12, &rcState ); in CXReadUncompLRC()
1330 if ( context->headerSize > 0 ) in CXReadUncompLRC()
1333 if ( context->headerSize == 8 ) in CXReadUncompLRC()
1345 …read_len = CXiReadHeader( &context->headerSize, &context->destCount, srcp, len, context->forceDest… in CXReadUncompLRC()
1350 return (context->headerSize == 0)? context->destCount : -1; in CXReadUncompLRC()
1355 while ( context->codeLen > 0 ) in CXReadUncompLRC()
1365 --context->codeLen; in CXReadUncompLRC()
1368 while ( context->destCount > 0 ) in CXReadUncompLRC()
1371 if ( context->length == 0 ) in CXReadUncompLRC()
1379 *context->destp++ = (u8)val; in CXReadUncompLRC()
1380 context->destCount--; in CXReadUncompLRC()
1385 context->length = (u16)( (val & 0xFF) + 3 ); in CXReadUncompLRC()
1391 context->codeLen = (u8)( -cnt ); in CXReadUncompLRC()
1399 if ( context->length > 0 ) in CXReadUncompLRC()
1405 if ( context->length > context->destCount ) in CXReadUncompLRC()
1407 if ( context->forceDestCount == 0 ) in CXReadUncompLRC()
1411 context->length = (u16)( context->destCount ); in CXReadUncompLRC()
1414 while ( context->length > 0 ) in CXReadUncompLRC()
1416 *context->destp = context->destp[ -val ]; in CXReadUncompLRC()
1417 context->destp++; in CXReadUncompLRC()
1418 context->destCount--; in CXReadUncompLRC()
1419 context->length--; in CXReadUncompLRC()
1424 context->codeLen = (u8)( -cnt ); in CXReadUncompLRC()
1433 LRCFin_( context, &info9, &info12, &rcState ); in CXReadUncompLRC()
1436 if ( (context->destCount == 0) && in CXReadUncompLRC()
1437 (context->forceDestCount == 0) && in CXReadUncompLRC()
1443 return context->destCount; in CXReadUncompLRC()