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()
220 if ( context->destCount == 0 ) in CXReadUncompRL()
226 context->flags = *srcp++; in CXReadUncompRL()
228 context->length = (u16)(context->flags & 0x7F); in CXReadUncompRL()
229 if ( context->flags & 0x80 ) in CXReadUncompRL()
231 context->length += 3; in CXReadUncompRL()
235 context->length += 1; in CXReadUncompRL()
238 if ( context->length > context->destCount ) in CXReadUncompRL()
241 if ( context->forceDestCount == 0 ) in CXReadUncompRL()
245 context->length = (u16)context->destCount; in CXReadUncompRL()
249 return context->destCount; in CXReadUncompRL()
254 if ( (context->forceDestCount == 0) && (len > 32) ) in CXReadUncompRL()
276 s32 CXReadUncompLZ( CXUncompContextLZ *context, const void* data, u32 len ) in CXReadUncompLZ() argument
282 if ( context->headerSize > 0 ) in CXReadUncompLZ()
286 if ( context->headerSize == 8 ) in CXReadUncompLZ()
293 context->exFormat = (u8)( *srcp & 0x0F ); in CXReadUncompLZ()
294 if ( (context->exFormat != 0x0) && (context->exFormat != 0x1) ) in CXReadUncompLZ()
299 …read_len = CXiReadHeader( &context->headerSize, &context->destCount, srcp, len, context->forceDest… in CXReadUncompLZ()
304 return (context->headerSize == 0)? context->destCount : -1; in CXReadUncompLZ()
308 while ( context->destCount > 0 ) in CXReadUncompLZ()
310 while ( context->flagIndex > 0 ) in CXReadUncompLZ()
314 return context->destCount; in CXReadUncompLZ()
317 if ( ! (context->flags & 0x80) ) in CXReadUncompLZ()
320 *context->destp++ = *srcp++; in CXReadUncompLZ()
321 context->destCount--; in CXReadUncompLZ()
327 while ( context->lengthFlg > 0 ) in CXReadUncompLZ()
329 --context->lengthFlg; in CXReadUncompLZ()
330 if ( ! context->exFormat ) in CXReadUncompLZ()
332 context->length = *srcp++; in CXReadUncompLZ()
333 context->length += (3 << 4); in CXReadUncompLZ()
334 context->lengthFlg = 0; in CXReadUncompLZ()
338 switch ( context->lengthFlg ) in CXReadUncompLZ()
342 context->length = *srcp++; in CXReadUncompLZ()
343 if ( (context->length >> 4) == 1 ) in CXReadUncompLZ()
346 context->length = (context->length & 0x0F) << 16; in CXReadUncompLZ()
347 context->length += ( (0xFF + 0xF + 3) << 4 ); in CXReadUncompLZ()
349 else if ( (context->length >> 4) == 0 ) in CXReadUncompLZ()
352 context->length = (context->length & 0x0F) << 8; in CXReadUncompLZ()
353 context->length += ( (0xF + 2) << 4 ); in CXReadUncompLZ()
354 context->lengthFlg = 1; in CXReadUncompLZ()
358 context->length += (1 << 4); in CXReadUncompLZ()
359 context->lengthFlg = 0; in CXReadUncompLZ()
365 context->length += (*srcp++ << 8); in CXReadUncompLZ()
370 context->length += *srcp++; in CXReadUncompLZ()
377 return context->destCount; in CXReadUncompLZ()
381 offset = (context->length & 0xF) << 8; in CXReadUncompLZ()
382 context->length = context->length >> 4; in CXReadUncompLZ()
385 context->lengthFlg = 3; in CXReadUncompLZ()
388 if ( context->length > context->destCount ) in CXReadUncompLZ()
390 if ( context->forceDestCount == 0 ) in CXReadUncompLZ()
394 context->length = context->destCount; in CXReadUncompLZ()
397 while ( context->length > 0 ) in CXReadUncompLZ()
399 *context->destp = context->destp[ -offset ]; in CXReadUncompLZ()
400 context->destp++; in CXReadUncompLZ()
401 context->destCount--; in CXReadUncompLZ()
402 context->length--; in CXReadUncompLZ()
406 if ( context->destCount == 0 ) in CXReadUncompLZ()
410 context->flags <<= 1; in CXReadUncompLZ()
411 context->flagIndex--; in CXReadUncompLZ()
416 return context->destCount; in CXReadUncompLZ()
419 context->flags = *srcp++; in CXReadUncompLZ()
420 context->flagIndex = 8; in CXReadUncompLZ()
426 if ( (context->forceDestCount == 0) && (len > 32) ) in CXReadUncompLZ()
456 s32 CXReadUncompHuffman( CXUncompContextHuffman *context, const void* data, u32 len ) in CXReadUncompHuffman() argument
464 if ( context->headerSize > 0 ) in CXReadUncompHuffman()
468 if ( context->headerSize == 8 ) in CXReadUncompHuffman()
470 context->bitSize = (u8)(*srcp & 0xF); in CXReadUncompHuffman()
476 if ( (context->bitSize != 4) && (context->bitSize != 8) ) in CXReadUncompHuffman()
481 …read_len = CXiReadHeader( &context->headerSize, &context->destCount, srcp, len, context->forceDest… in CXReadUncompHuffman()
486 return (context->headerSize == 0)? context->destCount : -1; in CXReadUncompHuffman()
492 if ( context->treeSize < 0 ) in CXReadUncompHuffman()
494 context->treeSize = (s16)( ( *srcp + 1 ) * 2 - 1 ); in CXReadUncompHuffman()
495 *context->treep++ = *srcp++; in CXReadUncompHuffman()
500 while ( context->treeSize > 0 ) in CXReadUncompHuffman()
504 return context->destCount; in CXReadUncompHuffman()
506 *context->treep++ = *srcp++; in CXReadUncompHuffman()
507 context->treeSize--; in CXReadUncompHuffman()
509 if ( context->treeSize == 0 ) in CXReadUncompHuffman()
511 context->treep = &context->tree[ 1 ]; in CXReadUncompHuffman()
512 if ( ! CXiVerifyHuffmanTable_( &context->tree[ 0 ], context->bitSize ) ) in CXReadUncompHuffman()
520 while ( context->destCount > 0 ) in CXReadUncompHuffman()
523 while ( context->srcTmpCnt < 32 ) in CXReadUncompHuffman()
527 return context->destCount; in CXReadUncompHuffman()
529 context->srcTmp |= (*srcp++) << context->srcTmpCnt; in CXReadUncompHuffman()
531 context->srcTmpCnt += 8; in CXReadUncompHuffman()
535 while ( context->srcTmpCnt > 0 ) in CXReadUncompHuffman()
537 select = context->srcTmp >> 31; in CXReadUncompHuffman()
538 endFlag = (*context->treep << select) & TREE_END_MASK; in CXReadUncompHuffman()
539 context->treep = GetNextNode( context->treep, select ); in CXReadUncompHuffman()
540 context->srcTmp <<= 1; in CXReadUncompHuffman()
541 context->srcTmpCnt--; in CXReadUncompHuffman()
550 context->destTmp >>= context->bitSize; in CXReadUncompHuffman()
551 context->destTmp |= *context->treep << ( 32 - context->bitSize ); in CXReadUncompHuffman()
552 context->treep = &context->tree[ 1 ]; in CXReadUncompHuffman()
553 context->destTmpCnt += context->bitSize; in CXReadUncompHuffman()
555 if ( context->destCount <= (context->destTmpCnt / 8) ) in CXReadUncompHuffman()
557 context->destTmp >>= (32 - context->destTmpCnt); in CXReadUncompHuffman()
558 context->destTmpCnt = 32; in CXReadUncompHuffman()
562 if ( context->destTmpCnt == 32 ) in CXReadUncompHuffman()
564 *(u32*)context->destp = CXiConvertEndian_( context->destTmp ); in CXReadUncompHuffman()
565 context->destp += 4; in CXReadUncompHuffman()
566 context->destCount -= 4; in CXReadUncompHuffman()
567 context->destTmpCnt = 0; in CXReadUncompHuffman()
568 if ( context->destCount <= 0 ) in CXReadUncompHuffman()
578 if ( (context->forceDestCount == 0) && (len > 32) ) in CXReadUncompHuffman()
598 BitReader_Read( BitReader* context, u8 bits ) in BitReader_Read() argument
602 while ( context->stream_len < bits ) in BitReader_Read()
604 if ( context->cnt == 0 ) in BitReader_Read()
608 context->stream <<= 8; in BitReader_Read()
609 context->stream += *context->srcp; in BitReader_Read()
610 context->srcp++; in BitReader_Read()
611 context->cnt--; in BitReader_Read()
612 context->stream_len += 8; in BitReader_Read()
615 value = (s32)( (context->stream >> (context->stream_len - bits)) & ((1 << bits) - 1) ); in BitReader_Read()
616 context->stream_len -= bits; in BitReader_Read()
621 BitReader_ReadEx( BitReader* context, u8 bits ) in BitReader_ReadEx() argument
626 while ( context->stream_len < bits ) in BitReader_ReadEx()
628 if ( context->cnt == 0 ) in BitReader_ReadEx()
632 if ( context->stream_len > 24 ) in BitReader_ReadEx()
634 stock = (u8)( context->stream >> 24 ); in BitReader_ReadEx()
636 context->stream <<= 8; in BitReader_ReadEx()
637 context->stream += *context->srcp; in BitReader_ReadEx()
638 context->srcp++; in BitReader_ReadEx()
639 context->cnt--; in BitReader_ReadEx()
640 context->stream_len += 8; in BitReader_ReadEx()
642 value = context->stream; in BitReader_ReadEx()
644 value = (s64)( (value >> (context->stream_len - bits)) & ((1 << bits) - 1) ); in BitReader_ReadEx()
645 context->stream_len -= bits; in BitReader_ReadEx()
664 CXInitUncompContextLH( CXUncompContextLH * context, void* dest ) in CXInitUncompContextLH() argument
666 context->destp = dest; in CXInitUncompContextLH()
667 context->destCount = -1; in CXInitUncompContextLH()
668 context->nodep = context->huffTable9 + 1; in CXInitUncompContextLH()
669 context->tableSize9 = -1; in CXInitUncompContextLH()
670 context->tableSize12 = -1; in CXInitUncompContextLH()
671 context->headerSize = 8; in CXInitUncompContextLH()
672 context->length = 0; in CXInitUncompContextLH()
673 context->stream = 0; in CXInitUncompContextLH()
674 context->stream_len = 0; in CXInitUncompContextLH()
675 context->offset_bits = -1; in CXInitUncompContextLH()
676 context->forceDestCount = 0; in CXInitUncompContextLH()
694 CXReadUncompLH( CXUncompContextLH *context, const void* data, u32 len ) in CXReadUncompLH() argument
715 stream.stream = context->stream; in CXReadUncompLH()
716 stream.stream_len = context->stream_len; in CXReadUncompLH()
719 while ( context->headerSize > 0 ) in CXReadUncompLH()
726 context->headerSize -= 4; in CXReadUncompLH()
727 if ( context->headerSize == 4 ) in CXReadUncompLH()
734 context->destCount = (s32)( headerVal >> 8 ); in CXReadUncompLH()
736 if ( context->destCount == 0 ) in CXReadUncompLH()
738 context->headerSize = 4; in CXReadUncompLH()
739 context->destCount = -1; in CXReadUncompLH()
743 context->headerSize = 0; in CXReadUncompLH()
748 context->destCount = (s32)CXiConvertEndian_( (u32)val32 ); in CXReadUncompLH()
751 if ( context->headerSize == 0 ) in CXReadUncompLH()
753 … if ( ( context->forceDestCount > 0 ) && ( context->forceDestCount < context->destCount ) ) in CXReadUncompLH()
755 context->destCount = context->forceDestCount; in CXReadUncompLH()
762 if ( context->tableSize9 < 0 ) in CXReadUncompLH()
768 … context->tableSize9 = (CXiConvertEndian16_( (u16)val ) + 1) * 4 * 8; // shown with the bit count in CXReadUncompLH()
769 context->tableIdx = 1; in CXReadUncompLH()
770 context->tableSize9 -= 16; in CXReadUncompLH()
773 while ( context->tableSize9 >= LENGTH_BITS ) in CXReadUncompLH()
779 context->huffTable9[ context->tableIdx++ ] = (u16)val; in CXReadUncompLH()
780 context->tableSize9 -= LENGTH_BITS; in CXReadUncompLH()
783 context->huffTable9[ 0 ] = (u16)context->tableIdx; in CXReadUncompLH()
785 if ( context->tableSize9 > 0 ) in CXReadUncompLH()
787 if ( ( val = BitReader_Read( &stream, (u8)context->tableSize9 ) ) < 0 ) in CXReadUncompLH()
791 context->tableSize9 = 0; in CXReadUncompLH()
794 if ( ! CXiLHVerifyTable( context->huffTable9, LENGTH_BITS ) ) in CXReadUncompLH()
801 if ( context->tableSize12 < 0 ) in CXReadUncompLH()
808 context->tableSize12 = (CXiConvertEndian16_( (u16)val ) + 1) * 4 * 8; in CXReadUncompLH()
810 context->tableSize12 = ((u16)val + 1) * 4 * 8; in CXReadUncompLH()
812 context->tableIdx = 1; in CXReadUncompLH()
813 context->tableSize12 -= (OFFSET_BITS > 8)? 16 : 8; in CXReadUncompLH()
816 while ( context->tableSize12 >= OFFSET_BITS ) in CXReadUncompLH()
822 context->huffTable12[ context->tableIdx++ ] = (u16)val; in CXReadUncompLH()
823 context->tableSize12 -= OFFSET_BITS; in CXReadUncompLH()
826 context->huffTable12[ 0 ] = (u16)context->tableIdx; in CXReadUncompLH()
828 if ( context->tableSize12 > 0 ) in CXReadUncompLH()
830 if ( ( val = BitReader_Read( &stream, (u8)context->tableSize12 ) ) < 0 ) in CXReadUncompLH()
834 context->tableSize12 = 0; in CXReadUncompLH()
837 if ( ! CXiLHVerifyTable( context->huffTable12, OFFSET_BITS ) ) in CXReadUncompLH()
844 nodep = context->nodep; in CXReadUncompLH()
845 length = context->length; in CXReadUncompLH()
848 while ( context->destCount > 0 ) in CXReadUncompLH()
859 context->nodep = nodep; in CXReadUncompLH()
860 context->length = length; in CXReadUncompLH()
870 nodep = context->huffTable12 + 1; in CXReadUncompLH()
884 *context->destp++ = (u8)length; in CXReadUncompLH()
885 context->destCount--; in CXReadUncompLH()
886 nodep = context->huffTable9 + 1; in CXReadUncompLH()
896 if ( context->offset_bits < 0 ) in CXReadUncompLH()
906 context->nodep = nodep; in CXReadUncompLH()
907 context->length = length; in CXReadUncompLH()
917 context->offset_bits = (s8)( *(nodep + offset) ); in CXReadUncompLH()
934 if ( context->offset_bits <= 1 ) in CXReadUncompLH()
936 val = context->offset_bits; in CXReadUncompLH()
938 else if ( ( val = BitReader_Read( &stream, (u8)(context->offset_bits - 1) ) ) < 0 ) in CXReadUncompLH()
940 context->nodep = nodep; in CXReadUncompLH()
941 context->length = length; in CXReadUncompLH()
944 if ( context->offset_bits >= 2 ) in CXReadUncompLH()
946 val |= (1 << (context->offset_bits - 1)); in CXReadUncompLH()
949 context->offset_bits = -1; in CXReadUncompLH()
953 if ( context->destCount < lzLength ) in CXReadUncompLH()
956 if ( context->forceDestCount == 0 ) in CXReadUncompLH()
960 lzLength = (u16)context->destCount; in CXReadUncompLH()
963 context->destCount -= lzLength; in CXReadUncompLH()
966 *context->destp = *(context->destp - lzOffset); in CXReadUncompLH()
967 ++context->destp; in CXReadUncompLH()
970 nodep = context->huffTable9 + 1; in CXReadUncompLH()
975 context->stream = stream.stream; in CXReadUncompLH()
976 context->stream_len = stream.stream_len; in CXReadUncompLH()
979 if ( (context->destCount == 0) && in CXReadUncompLH()
980 (context->forceDestCount == 0) && in CXReadUncompLH()
986 return context->destCount; in CXReadUncompLH()
1032 CXUncompContextLRC *context, in LRCIntro_() argument
1037 info9->freq = context->freq9; in LRCIntro_()
1038 info9->low_cnt = context->low_cnt9; in LRCIntro_()
1039 info9->total = context->total9; in LRCIntro_()
1042 info12->freq = context->freq12; in LRCIntro_()
1043 info12->low_cnt = context->low_cnt12; in LRCIntro_()
1044 info12->total = context->total12; in LRCIntro_()
1047 state->low = context->low; in LRCIntro_()
1048 state->range = context->range; in LRCIntro_()
1049 state->code = context->code; in LRCIntro_()
1050 state->carry = context->carry; in LRCIntro_()
1051 state->carry_cnt = context->carry_cnt; in LRCIntro_()
1069 CXUncompContextLRC *context, in LRCFin_() argument
1074 context->total9 = info9->total; in LRCFin_()
1075 context->total12 = info12->total; in LRCFin_()
1077 context->low = state->low; in LRCFin_()
1078 context->range = state->range; in LRCFin_()
1079 context->code = state->code; in LRCFin_()
1080 context->carry = state->carry; in LRCFin_()
1081 context->carry_cnt = state->carry_cnt; in LRCFin_()
1287 CXInitUncompContextLRC( CXUncompContextLRC * context, void* dest ) in CXInitUncompContextLRC() argument
1296 LRCIntro_( context, &info9, &info12, &rcState ); in CXInitUncompContextLRC()
1298 context->destp = dest; in CXInitUncompContextLRC()
1299 context->destCount = 0; in CXInitUncompContextLRC()
1300 context->headerSize = 8; in CXInitUncompContextLRC()
1301 context->length = 0; in CXInitUncompContextLRC()
1302 context->forceDestCount = 0; in CXInitUncompContextLRC()
1304 context->codeLen = 4; in CXInitUncompContextLRC()
1312 LRCFin_( context, &info9, &info12, &rcState ); in CXInitUncompContextLRC()
1332 CXReadUncompLRC( CXUncompContextLRC *context, const void* data, u32 len ) in CXReadUncompLRC() argument
1340 LRCIntro_( context, &info9, &info12, &rcState ); in CXReadUncompLRC()
1343 if ( context->headerSize > 0 ) in CXReadUncompLRC()
1346 if ( context->headerSize == 8 ) in CXReadUncompLRC()
1358 …read_len = CXiReadHeader( &context->headerSize, &context->destCount, srcp, len, context->forceDest… in CXReadUncompLRC()
1363 return (context->headerSize == 0)? context->destCount : -1; in CXReadUncompLRC()
1368 while ( context->codeLen > 0 ) in CXReadUncompLRC()
1378 --context->codeLen; in CXReadUncompLRC()
1381 while ( context->destCount > 0 ) in CXReadUncompLRC()
1384 if ( context->length == 0 ) in CXReadUncompLRC()
1392 *context->destp++ = (u8)val; in CXReadUncompLRC()
1393 context->destCount--; in CXReadUncompLRC()
1398 context->length = (u16)( (val & 0xFF) + 3 ); in CXReadUncompLRC()
1404 context->codeLen = (u8)( -cnt ); in CXReadUncompLRC()
1412 if ( context->length > 0 ) in CXReadUncompLRC()
1418 if ( context->length > context->destCount ) in CXReadUncompLRC()
1420 if ( context->forceDestCount == 0 ) in CXReadUncompLRC()
1424 context->length = (u16)( context->destCount ); in CXReadUncompLRC()
1427 while ( context->length > 0 ) in CXReadUncompLRC()
1429 *context->destp = context->destp[ -val ]; in CXReadUncompLRC()
1430 context->destp++; in CXReadUncompLRC()
1431 context->destCount--; in CXReadUncompLRC()
1432 context->length--; in CXReadUncompLRC()
1437 context->codeLen = (u8)( -cnt ); in CXReadUncompLRC()
1446 LRCFin_( context, &info9, &info12, &rcState ); in CXReadUncompLRC()
1449 if ( (context->destCount == 0) && in CXReadUncompLRC()
1450 (context->forceDestCount == 0) && in CXReadUncompLRC()
1456 return context->destCount; in CXReadUncompLRC()