Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ DecodeDynamicBlockHeader()

bool System.IO.Compression.InflaterManaged.DecodeDynamicBlockHeader ( )
inlineprivate

Definition at line 382 of file InflaterManaged.cs.

383 {
384 switch (_state)
385 {
386 case InflaterState.ReadingNumLitCodes:
389 {
390 return false;
391 }
393 _state = InflaterState.ReadingNumDistCodes;
394 goto case InflaterState.ReadingNumDistCodes;
395 case InflaterState.ReadingNumDistCodes:
397 if (_distanceCodeCount < 0)
398 {
399 return false;
400 }
402 _state = InflaterState.ReadingNumCodeLengthCodes;
403 goto case InflaterState.ReadingNumCodeLengthCodes;
404 case InflaterState.ReadingNumCodeLengthCodes:
406 if (_codeLengthCodeCount < 0)
407 {
408 return false;
409 }
411 _loopCounter = 0;
412 _state = InflaterState.ReadingCodeLengthCodes;
413 goto case InflaterState.ReadingCodeLengthCodes;
414 case InflaterState.ReadingCodeLengthCodes:
415 {
417 {
418 int bits = _input.GetBits(3);
419 if (bits < 0)
420 {
421 return false;
422 }
424 _loopCounter++;
425 }
426 for (int l = _codeLengthCodeCount; l < s_codeOrder.Length; l++)
427 {
429 }
432 _loopCounter = 0;
433 _state = InflaterState.ReadingTreeCodesBefore;
434 goto case InflaterState.ReadingTreeCodesBefore;
435 }
436 case InflaterState.ReadingTreeCodesBefore:
437 case InflaterState.ReadingTreeCodesAfter:
438 {
440 {
441 if (_state == InflaterState.ReadingTreeCodesBefore && (_lengthCode = _codeLengthTree.GetNextSymbol(_input)) < 0)
442 {
443 return false;
444 }
445 if (_lengthCode <= 15)
446 {
448 }
449 else if (_lengthCode == 16)
450 {
452 {
453 _state = InflaterState.ReadingTreeCodesAfter;
454 return false;
455 }
456 if (_loopCounter == 0)
457 {
458 throw new InvalidDataException();
459 }
460 byte b = _codeList[_loopCounter - 1];
461 int num = _input.GetBits(2) + 3;
462 if (_loopCounter + num > _codeArraySize)
463 {
464 throw new InvalidDataException();
465 }
466 for (int i = 0; i < num; i++)
467 {
468 _codeList[_loopCounter++] = b;
469 }
470 }
471 else if (_lengthCode == 17)
472 {
474 {
475 _state = InflaterState.ReadingTreeCodesAfter;
476 return false;
477 }
478 int num = _input.GetBits(3) + 3;
479 if (_loopCounter + num > _codeArraySize)
480 {
481 throw new InvalidDataException();
482 }
483 for (int j = 0; j < num; j++)
484 {
485 _codeList[_loopCounter++] = 0;
486 }
487 }
488 else
489 {
491 {
492 _state = InflaterState.ReadingTreeCodesAfter;
493 return false;
494 }
495 int num = _input.GetBits(7) + 11;
496 if (_loopCounter + num > _codeArraySize)
497 {
498 throw new InvalidDataException();
499 }
500 for (int k = 0; k < num; k++)
501 {
502 _codeList[_loopCounter++] = 0;
503 }
504 }
505 _state = InflaterState.ReadingTreeCodesBefore;
506 }
507 byte[] array = new byte[288];
508 byte[] array2 = new byte[32];
511 if (array[256] == 0)
512 {
513 throw new InvalidDataException();
514 }
515 _literalLengthTree = new HuffmanTree(array);
516 _distanceTree = new HuffmanTree(array2);
517 _state = InflaterState.DecodeTop;
518 return true;
519 }
520 default:
521 throw new InvalidDataException(System.SR.UnknownState);
522 }
523 }
int GetNextSymbol(InputBuffer input)
static string UnknownState
Definition SR.cs:38
Definition SR.cs:7

References System.IO.Compression.InflaterManaged._codeArraySize, System.IO.Compression.InflaterManaged._codeLengthCodeCount, System.IO.Compression.InflaterManaged._codeLengthTree, System.IO.Compression.InflaterManaged._codeLengthTreeCodeLength, System.IO.Compression.InflaterManaged._codeList, System.IO.Compression.InflaterManaged._distanceCodeCount, System.IO.Compression.InflaterManaged._distanceTree, System.IO.Compression.InflaterManaged._input, System.IO.Compression.InflaterManaged._lengthCode, System.IO.Compression.InflaterManaged._literalLengthCodeCount, System.IO.Compression.InflaterManaged._literalLengthTree, System.IO.Compression.InflaterManaged._loopCounter, System.IO.Compression.InflaterManaged._state, System.array, System.Array.Copy(), System.IO.Compression.InputBuffer.EnsureBitsAvailable(), System.IO.Compression.InputBuffer.GetBits(), System.IO.Compression.HuffmanTree.GetNextSymbol(), System.IO.Compression.InflaterManaged.s_codeOrder, and System.SR.UnknownState.

Referenced by System.IO.Compression.InflaterManaged.Decode().