Lines Matching refs:context

62 void InitUncompContextRL( UncompContextRL *context, void* dest )  in InitUncompContextRL()  argument
64 NN_NULL_TASSERT_(context); in InitUncompContextRL()
65 context->destp = (u8*)dest; in InitUncompContextRL()
66 context->destCount = 0; in InitUncompContextRL()
67 context->flags = 0; in InitUncompContextRL()
68 context->length = 0; in InitUncompContextRL()
69 context->headerSize = 8; in InitUncompContextRL()
70 context->forceDestCount = 0; in InitUncompContextRL()
84 void InitUncompContextLZ( UncompContextLZ *context, void* dest ) in InitUncompContextLZ() argument
86 NN_NULL_TASSERT_(context); in InitUncompContextLZ()
87 context->destp = (u8*)dest; in InitUncompContextLZ()
88 context->destCount = 0; in InitUncompContextLZ()
89 context->flags = 0; in InitUncompContextLZ()
90 context->flagIndex = 0; in InitUncompContextLZ()
91 context->length = 0; in InitUncompContextLZ()
92 context->lengthFlg = 3; in InitUncompContextLZ()
93 context->headerSize = 8; in InitUncompContextLZ()
94 context->exFormat = 0; in InitUncompContextLZ()
95 context->forceDestCount = 0; in InitUncompContextLZ()
109 void InitUncompContextHuffman( UncompContextHuffman *context, void* dest ) in InitUncompContextHuffman() argument
111 NN_NULL_TASSERT_(context); in InitUncompContextHuffman()
112 context->destp = (u8*)dest; in InitUncompContextHuffman()
113 context->destCount = 0; in InitUncompContextHuffman()
114 context->bitSize = 0; in InitUncompContextHuffman()
115 context->treeSize = -1; in InitUncompContextHuffman()
116 context->treep = &context->tree[ 0 ]; in InitUncompContextHuffman()
117 context->destTmp = 0; in InitUncompContextHuffman()
118 context->destTmpCnt = 0; in InitUncompContextHuffman()
119 context->srcTmp = 0; in InitUncompContextHuffman()
120 context->srcTmpCnt = 0; in InitUncompContextHuffman()
121 context->headerSize = 8; in InitUncompContextHuffman()
122 context->forceDestCount = 0; in InitUncompContextHuffman()
193 s32 ReadUncompRL( UncompContextRL *context, const void* data, u32 len ) in ReadUncompRL() argument
195 NN_NULL_TASSERT_(context); in ReadUncompRL()
202 if ( context->headerSize > 0 ) in ReadUncompRL()
205 if ( context->headerSize == 8 ) in ReadUncompRL()
216 …read_len = ReadHeader( &context->headerSize, &context->destCount, srcp, len, context->forceDestCou… in ReadUncompRL()
221 return (context->headerSize == 0)? context->destCount : -1; in ReadUncompRL()
225 while ( context->destCount > 0 ) in ReadUncompRL()
228 if ( ! (context->flags & 0x80) ) in ReadUncompRL()
231 while ( context->length > 0 ) in ReadUncompRL()
233 *context->destp++ = *srcp++; in ReadUncompRL()
234 context->length--; in ReadUncompRL()
235 context->destCount--; in ReadUncompRL()
240 return context->destCount; in ReadUncompRL()
244 else if ( context->length > 0 ) in ReadUncompRL()
249 while ( context->length > 0 ) in ReadUncompRL()
251 *context->destp++ = srcTmp; in ReadUncompRL()
252 context->length--; in ReadUncompRL()
253 context->destCount--; in ReadUncompRL()
257 return context->destCount; in ReadUncompRL()
262 context->flags = *srcp++; in ReadUncompRL()
264 context->length = (u16)(context->flags & 0x7F); in ReadUncompRL()
265 if ( context->flags & 0x80 ) in ReadUncompRL()
267 context->length += 3; in ReadUncompRL()
271 context->length += 1; in ReadUncompRL()
274 if ( context->length > context->destCount ) in ReadUncompRL()
277 if ( context->forceDestCount == 0 ) in ReadUncompRL()
281 context->length = (u16)context->destCount; in ReadUncompRL()
285 return context->destCount; in ReadUncompRL()
290 if ( (context->forceDestCount == 0) && (len > 32) ) in ReadUncompRL()
312 s32 ReadUncompLZ( UncompContextLZ *context, const void* data, u32 len ) in ReadUncompLZ() argument
314 NN_NULL_TASSERT_(context); in ReadUncompLZ()
321 if ( context->headerSize > 0 ) in ReadUncompLZ()
325 if ( context->headerSize == 8 ) in ReadUncompLZ()
332 context->exFormat = (u8)( *srcp & 0x0F ); in ReadUncompLZ()
333 if ( (context->exFormat != 0x0) && (context->exFormat != 0x1) ) in ReadUncompLZ()
338 …read_len = ReadHeader( &context->headerSize, &context->destCount, srcp, len, context->forceDestCou… in ReadUncompLZ()
343 return (context->headerSize == 0)? context->destCount : -1; in ReadUncompLZ()
347 while ( context->destCount > 0 ) in ReadUncompLZ()
349 while ( context->flagIndex > 0 ) in ReadUncompLZ()
353 return context->destCount; in ReadUncompLZ()
356 if ( ! (context->flags & 0x80) ) in ReadUncompLZ()
359 *context->destp++ = *srcp++; in ReadUncompLZ()
360 context->destCount--; in ReadUncompLZ()
366 while ( context->lengthFlg > 0 ) in ReadUncompLZ()
368 --context->lengthFlg; in ReadUncompLZ()
369 if ( ! context->exFormat ) in ReadUncompLZ()
371 context->length = *srcp++; in ReadUncompLZ()
372 context->length += (3 << 4); in ReadUncompLZ()
373 context->lengthFlg = 0; in ReadUncompLZ()
377 switch ( context->lengthFlg ) in ReadUncompLZ()
381 context->length = *srcp++; in ReadUncompLZ()
382 if ( (context->length >> 4) == 1 ) in ReadUncompLZ()
385 context->length = (context->length & 0x0F) << 16; in ReadUncompLZ()
386 context->length += ( (0xFF + 0xF + 3) << 4 ); in ReadUncompLZ()
388 else if ( (context->length >> 4) == 0 ) in ReadUncompLZ()
391 context->length = (context->length & 0x0F) << 8; in ReadUncompLZ()
392 context->length += ( (0xF + 2) << 4 ); in ReadUncompLZ()
393 context->lengthFlg = 1; in ReadUncompLZ()
397 context->length += (1 << 4); in ReadUncompLZ()
398 context->lengthFlg = 0; in ReadUncompLZ()
404 context->length += (*srcp++ << 8); in ReadUncompLZ()
409 context->length += *srcp++; in ReadUncompLZ()
416 return context->destCount; in ReadUncompLZ()
420 offset = (context->length & 0xF) << 8; in ReadUncompLZ()
421 context->length = context->length >> 4; in ReadUncompLZ()
424 context->lengthFlg = 3; in ReadUncompLZ()
427 if ( context->length > context->destCount ) in ReadUncompLZ()
429 if ( context->forceDestCount == 0 ) in ReadUncompLZ()
433 context->length = context->destCount; in ReadUncompLZ()
436 while ( context->length > 0 ) in ReadUncompLZ()
438 *context->destp = context->destp[ -offset ]; in ReadUncompLZ()
439 context->destp++; in ReadUncompLZ()
440 context->destCount--; in ReadUncompLZ()
441 context->length--; in ReadUncompLZ()
445 if ( context->destCount == 0 ) in ReadUncompLZ()
449 context->flags <<= 1; in ReadUncompLZ()
450 context->flagIndex--; in ReadUncompLZ()
455 return context->destCount; in ReadUncompLZ()
458 context->flags = *srcp++; in ReadUncompLZ()
459 context->flagIndex = 8; in ReadUncompLZ()
465 if ( (context->forceDestCount == 0) && (len > 32) ) in ReadUncompLZ()
496 s32 ReadUncompHuffman( UncompContextHuffman *context, const void* data, u32 len ) in ReadUncompHuffman() argument
498 NN_NULL_TASSERT_(context); in ReadUncompHuffman()
507 if ( context->headerSize > 0 ) in ReadUncompHuffman()
511 if ( context->headerSize == 8 ) in ReadUncompHuffman()
513 context->bitSize = (u8)(*srcp & 0xF); in ReadUncompHuffman()
519 if ( (context->bitSize != 4) && (context->bitSize != 8) ) in ReadUncompHuffman()
524 …read_len = ReadHeader( &context->headerSize, &context->destCount, srcp, len, context->forceDestCou… in ReadUncompHuffman()
529 return (context->headerSize == 0)? context->destCount : -1; in ReadUncompHuffman()
535 if ( context->treeSize < 0 ) in ReadUncompHuffman()
537 context->treeSize = (s16)( ( *srcp + 1 ) * 2 - 1 ); in ReadUncompHuffman()
538 *context->treep++ = *srcp++; in ReadUncompHuffman()
543 while ( context->treeSize > 0 ) in ReadUncompHuffman()
547 return context->destCount; in ReadUncompHuffman()
549 *context->treep++ = *srcp++; in ReadUncompHuffman()
550 context->treeSize--; in ReadUncompHuffman()
552 if ( context->treeSize == 0 ) in ReadUncompHuffman()
554 context->treep = &context->tree[ 1 ]; in ReadUncompHuffman()
555 if ( ! internal::VerifyHuffmanTable( &context->tree[ 0 ], context->bitSize ) ) in ReadUncompHuffman()
563 while ( context->destCount > 0 ) in ReadUncompHuffman()
566 while ( context->srcTmpCnt < 32 ) in ReadUncompHuffman()
570 return context->destCount; in ReadUncompHuffman()
572 context->srcTmp |= (*srcp++) << context->srcTmpCnt; in ReadUncompHuffman()
574 context->srcTmpCnt += 8; in ReadUncompHuffman()
578 while ( context->srcTmpCnt > 0 ) in ReadUncompHuffman()
580 select = context->srcTmp >> 31; in ReadUncompHuffman()
581 endFlag = (*context->treep << select) & TREE_END_MASK; in ReadUncompHuffman()
582 context->treep = GetNextNode( context->treep, select ); in ReadUncompHuffman()
583 context->srcTmp <<= 1; in ReadUncompHuffman()
584 context->srcTmpCnt--; in ReadUncompHuffman()
593 context->destTmp >>= context->bitSize; in ReadUncompHuffman()
594 context->destTmp |= *context->treep << ( 32 - context->bitSize ); in ReadUncompHuffman()
595 context->treep = &context->tree[ 1 ]; in ReadUncompHuffman()
596 context->destTmpCnt += context->bitSize; in ReadUncompHuffman()
598 if ( context->destCount <= (context->destTmpCnt / 8) ) in ReadUncompHuffman()
600 context->destTmp >>= (32 - context->destTmpCnt); in ReadUncompHuffman()
601 context->destTmpCnt = 32; in ReadUncompHuffman()
605 if ( context->destTmpCnt == 32 ) in ReadUncompHuffman()
607 *(u32*)context->destp = internal::ConvertEndian( context->destTmp ); in ReadUncompHuffman()
608 context->destp += 4; in ReadUncompHuffman()
609 context->destCount -= 4; in ReadUncompHuffman()
610 context->destTmpCnt = 0; in ReadUncompHuffman()
611 if ( context->destCount <= 0 ) in ReadUncompHuffman()
621 if ( (context->forceDestCount == 0) && (len > 32) ) in ReadUncompHuffman()
641 BitReader_Read( BitReader* context, u8 bits ) in BitReader_Read() argument
645 while ( context->stream_len < bits ) in BitReader_Read()
647 if ( context->cnt == 0 ) in BitReader_Read()
651 context->stream <<= 8; in BitReader_Read()
652 context->stream += *context->srcp; in BitReader_Read()
653 context->srcp++; in BitReader_Read()
654 context->cnt--; in BitReader_Read()
655 context->stream_len += 8; in BitReader_Read()
658 value = (s32)( (context->stream >> (context->stream_len - bits)) & ((1 << bits) - 1) ); in BitReader_Read()
659 context->stream_len -= bits; in BitReader_Read()
664 BitReader_ReadEx( BitReader* context, u8 bits ) in BitReader_ReadEx() argument
669 while ( context->stream_len < bits ) in BitReader_ReadEx()
671 if ( context->cnt == 0 ) in BitReader_ReadEx()
675 if ( context->stream_len > 24 ) in BitReader_ReadEx()
677 stock = (u8)( context->stream >> 24 ); in BitReader_ReadEx()
679 context->stream <<= 8; in BitReader_ReadEx()
680 context->stream += *context->srcp; in BitReader_ReadEx()
681 context->srcp++; in BitReader_ReadEx()
682 context->cnt--; in BitReader_ReadEx()
683 context->stream_len += 8; in BitReader_ReadEx()
685 value = context->stream; in BitReader_ReadEx()
687 value = (s64)( (value >> (context->stream_len - bits)) & ((1 << bits) - 1) ); in BitReader_ReadEx()
688 context->stream_len -= bits; in BitReader_ReadEx()
709 InitUncompContextLH( UncompContextLH * context, void* dest ) in InitUncompContextLH() argument
711 NN_NULL_TASSERT_(context); in InitUncompContextLH()
712 context->destp = static_cast<u8*>(dest); in InitUncompContextLH()
713 context->destCount = -1; in InitUncompContextLH()
714 context->nodep = context->huffTable9 + 1; in InitUncompContextLH()
715 context->tableSize9 = -1; in InitUncompContextLH()
716 context->tableSize12 = -1; in InitUncompContextLH()
717 context->headerSize = 8; in InitUncompContextLH()
718 context->length = 0; in InitUncompContextLH()
719 context->stream = 0; in InitUncompContextLH()
720 context->stream_len = 0; in InitUncompContextLH()
721 context->offset_bits = -1; in InitUncompContextLH()
722 context->forceDestCount = 0; in InitUncompContextLH()
738 ReadUncompLH( UncompContextLH *context, const void* data, u32 len ) in ReadUncompLH() argument
740 NN_NULL_TASSERT_(context); in ReadUncompLH()
762 stream.stream = context->stream; in ReadUncompLH()
763 stream.stream_len = context->stream_len; in ReadUncompLH()
766 while ( context->headerSize > 0 ) in ReadUncompLH()
773 context->headerSize -= 4; in ReadUncompLH()
774 if ( context->headerSize == 4 ) in ReadUncompLH()
781 context->destCount = (s32)( headerVal >> 8 ); in ReadUncompLH()
783 if ( context->destCount == 0 ) in ReadUncompLH()
785 context->headerSize = 4; in ReadUncompLH()
786 context->destCount = -1; in ReadUncompLH()
790 context->headerSize = 0; in ReadUncompLH()
795 context->destCount = (s32)internal::ForceConvertEndian( (u32)val32 ); in ReadUncompLH()
798 if ( context->headerSize == 0 ) in ReadUncompLH()
800 … if ( ( context->forceDestCount > 0 ) && ( context->forceDestCount < context->destCount ) ) in ReadUncompLH()
802 context->destCount = context->forceDestCount; in ReadUncompLH()
809 if ( context->tableSize9 < 0 ) in ReadUncompLH()
815context->tableSize9 = (internal::ForceConvertEndian16( (u16)val ) + 1) * 4 * 8; // shown with the … in ReadUncompLH()
816 context->tableIdx = 1; in ReadUncompLH()
817 context->tableSize9 -= 16; in ReadUncompLH()
822 while ( context->tableSize9 >= LENGTH_BITS ) in ReadUncompLH()
829 if ( context->tableIdx < MAX_IDX ) in ReadUncompLH()
831 context->huffTable9[ context->tableIdx++ ] = (u16)val; in ReadUncompLH()
833 context->tableSize9 -= LENGTH_BITS; in ReadUncompLH()
836 context->huffTable9[ 0 ] = (u16)context->tableIdx; in ReadUncompLH()
838 if ( context->tableSize9 > 0 ) in ReadUncompLH()
840 if ( ( val = BitReader_Read( &stream, (u8)context->tableSize9 ) ) < 0 ) in ReadUncompLH()
845 context->tableSize9 = 0; in ReadUncompLH()
848 if ( ! internal::LHVerifyTable( context->huffTable9, LENGTH_BITS ) ) in ReadUncompLH()
855 if ( context->tableSize12 < 0 ) in ReadUncompLH()
862 context->tableSize12 = (internal::ForceConvertEndian16( (u16)val ) + 1) * 4 * 8; in ReadUncompLH()
864 context->tableSize12 = ((u16)val + 1) * 4 * 8; in ReadUncompLH()
866 context->tableIdx = 1; in ReadUncompLH()
867 context->tableSize12 -= (OFFSET_BITS > 8)? 16 : 8; in ReadUncompLH()
872 while ( context->tableSize12 >= OFFSET_BITS ) in ReadUncompLH()
879 if ( context->tableIdx < MAX_IDX ) in ReadUncompLH()
881 context->huffTable12[ context->tableIdx++ ] = (u16)val; in ReadUncompLH()
883 context->tableSize12 -= OFFSET_BITS; in ReadUncompLH()
886 context->huffTable12[ 0 ] = (u16)context->tableIdx; in ReadUncompLH()
888 if ( context->tableSize12 > 0 ) in ReadUncompLH()
890 if ( ( val = BitReader_Read( &stream, (u8)context->tableSize12 ) ) < 0 ) in ReadUncompLH()
895 context->tableSize12 = 0; in ReadUncompLH()
898 if ( ! internal::LHVerifyTable( context->huffTable12, OFFSET_BITS ) ) in ReadUncompLH()
905 nodep = context->nodep; in ReadUncompLH()
906 length = context->length; in ReadUncompLH()
909 while ( context->destCount > 0 ) in ReadUncompLH()
920 context->nodep = nodep; in ReadUncompLH()
921 context->length = length; in ReadUncompLH()
931 nodep = context->huffTable12 + 1; in ReadUncompLH()
945 *context->destp++ = (u8)length; in ReadUncompLH()
946 context->destCount--; in ReadUncompLH()
947 nodep = context->huffTable9 + 1; in ReadUncompLH()
957 if ( context->offset_bits < 0 ) in ReadUncompLH()
967 context->nodep = nodep; in ReadUncompLH()
968 context->length = length; in ReadUncompLH()
978 context->offset_bits = (s8)( *(nodep + offset) ); in ReadUncompLH()
995 if ( context->offset_bits <= 1 ) in ReadUncompLH()
997 val = context->offset_bits; in ReadUncompLH()
999 else if ( ( val = BitReader_Read( &stream, (u8)(context->offset_bits - 1) ) ) < 0 ) in ReadUncompLH()
1001 context->nodep = nodep; in ReadUncompLH()
1002 context->length = length; in ReadUncompLH()
1005 if ( context->offset_bits >= 2 ) in ReadUncompLH()
1007 val |= (1 << (context->offset_bits - 1)); in ReadUncompLH()
1010 context->offset_bits = -1; in ReadUncompLH()
1014 if ( context->destCount < lzLength ) in ReadUncompLH()
1017 if ( context->forceDestCount == 0 ) in ReadUncompLH()
1021 lzLength = (u16)context->destCount; in ReadUncompLH()
1024 context->destCount -= lzLength; in ReadUncompLH()
1027 *context->destp = *(context->destp - lzOffset); in ReadUncompLH()
1028 ++context->destp; in ReadUncompLH()
1031 nodep = context->huffTable9 + 1; in ReadUncompLH()
1036 context->stream = stream.stream; in ReadUncompLH()
1037 context->stream_len = stream.stream_len; in ReadUncompLH()
1041 if ( (context->destCount == 0) && in ReadUncompLH()
1042 (context->forceDestCount == 0) && in ReadUncompLH()
1048 return context->destCount; in ReadUncompLH()
1094 UncompContextLRC *context, in LRCIntro_() argument
1099 info9->freq = context->freq9; in LRCIntro_()
1100 info9->low_cnt = context->low_cnt9; in LRCIntro_()
1101 info9->total = context->total9; in LRCIntro_()
1104 info12->freq = context->freq12; in LRCIntro_()
1105 info12->low_cnt = context->low_cnt12; in LRCIntro_()
1106 info12->total = context->total12; in LRCIntro_()
1109 state->low = context->low; in LRCIntro_()
1110 state->range = context->range; in LRCIntro_()
1111 state->code = context->code; in LRCIntro_()
1112 state->carry = context->carry; in LRCIntro_()
1113 state->carry_cnt = context->carry_cnt; in LRCIntro_()
1131 UncompContextLRC *context, in LRCFin_() argument
1136 context->total9 = info9->total; in LRCFin_()
1137 context->total12 = info12->total; in LRCFin_()
1139 context->low = state->low; in LRCFin_()
1140 context->range = state->range; in LRCFin_()
1141 context->code = state->code; in LRCFin_()
1142 context->carry = state->carry; in LRCFin_()
1143 context->carry_cnt = state->carry_cnt; in LRCFin_()
1350 InitUncompContextLRC( UncompContextLRC * context, void* dest ) in InitUncompContextLRC() argument
1352 NN_NULL_TASSERT_(context); in InitUncompContextLRC()
1361 LRCIntro_( context, &info9, &info12, &rcState ); in InitUncompContextLRC()
1363 context->destp = static_cast<u8*>(dest); in InitUncompContextLRC()
1364 context->destCount = 0; in InitUncompContextLRC()
1365 context->headerSize = 8; in InitUncompContextLRC()
1366 context->length = 0; in InitUncompContextLRC()
1367 context->forceDestCount = 0; in InitUncompContextLRC()
1369 context->codeLen = 4; in InitUncompContextLRC()
1377 LRCFin_( context, &info9, &info12, &rcState ); in InitUncompContextLRC()
1397 ReadUncompLRC( UncompContextLRC *context, const void* data, u32 len ) in ReadUncompLRC() argument
1399 NN_NULL_TASSERT_(context); in ReadUncompLRC()
1408 LRCIntro_( context, &info9, &info12, &rcState ); in ReadUncompLRC()
1411 if ( context->headerSize > 0 ) in ReadUncompLRC()
1414 if ( context->headerSize == 8 ) in ReadUncompLRC()
1426 …read_len = ReadHeader( &context->headerSize, &context->destCount, srcp, len, context->forceDestCou… in ReadUncompLRC()
1431 return (context->headerSize == 0)? context->destCount : -1; in ReadUncompLRC()
1436 while ( context->codeLen > 0 ) in ReadUncompLRC()
1446 --context->codeLen; in ReadUncompLRC()
1449 while ( context->destCount > 0 ) in ReadUncompLRC()
1452 if ( context->length == 0 ) in ReadUncompLRC()
1460 *context->destp++ = (u8)val; in ReadUncompLRC()
1461 context->destCount--; in ReadUncompLRC()
1466 context->length = (u16)( (val & 0xFF) + 3 ); in ReadUncompLRC()
1472 context->codeLen = (u8)( -cnt ); in ReadUncompLRC()
1480 if ( context->length > 0 ) in ReadUncompLRC()
1486 if ( context->length > context->destCount ) in ReadUncompLRC()
1488 if ( context->forceDestCount == 0 ) in ReadUncompLRC()
1492 context->length = (u16)( context->destCount ); in ReadUncompLRC()
1495 while ( context->length > 0 ) in ReadUncompLRC()
1497 *context->destp = context->destp[ -val ]; in ReadUncompLRC()
1498 context->destp++; in ReadUncompLRC()
1499 context->destCount--; in ReadUncompLRC()
1500 context->length--; in ReadUncompLRC()
1505 context->codeLen = (u8)( -cnt ); in ReadUncompLRC()
1514 LRCFin_( context, &info9, &info12, &rcState ); in ReadUncompLRC()
1517 if ( (context->destCount == 0) && in ReadUncompLRC()
1518 (context->forceDestCount == 0) && in ReadUncompLRC()
1524 return context->destCount; in ReadUncompLRC()