MCPcopy Create free account
hub / github.com/abbeycode/UnrarKit / UnpackLargeBlock

Method UnpackLargeBlock

Libraries/unrar/unpack50mt.cpp:520–655  ·  view source on GitHub ↗

For large blocks we decode and process in same function in single threaded mode, so we do not need to store intermediate data in memory.

Source from the content-addressed store, hash-verified

518// For large blocks we decode and process in same function in single threaded
519// mode, so we do not need to store intermediate data in memory.
520bool Unpack::UnpackLargeBlock(UnpackThreadData &D)
521{
522 if (!D.TableRead)
523 {
524 D.TableRead=true;
525 if (!ReadTables(D.Inp,D.BlockHeader,D.BlockTables))
526 {
527 D.DamagedData=true;
528 return false;
529 }
530 }
531
532 if (D.Inp.InAddr>D.BlockHeader.HeaderSize+D.BlockHeader.BlockSize)
533 {
534 D.DamagedData=true;
535 return false;
536 }
537
538 int BlockBorder=D.BlockHeader.BlockStart+D.BlockHeader.BlockSize-1;
539
540 // Reserve enough space even for filter entry.
541 int DataBorder=D.DataSize-16;
542 int ReadBorder=Min(BlockBorder,DataBorder);
543
544 while (true)
545 {
546 UnpPtr&=MaxWinMask;
547 if (D.Inp.InAddr>=ReadBorder)
548 {
549 if (D.Inp.InAddr>BlockBorder || D.Inp.InAddr==BlockBorder &&
550 D.Inp.InBit>=D.BlockHeader.BlockBitSize)
551 break;
552
553 // If we do not have any more data in file to read, we must process
554 // what we have until last byte. Otherwise we can return and append
555 // more data to unprocessed few bytes.
556 if ((D.Inp.InAddr>=DataBorder) && !D.NoDataLeft || D.Inp.InAddr>=D.DataSize)
557 {
558 D.Incomplete=true;
559 break;
560 }
561 }
562 if (((WriteBorder-UnpPtr) & MaxWinMask)<MAX_INC_LZ_MATCH && WriteBorder!=UnpPtr)
563 {
564 UnpWriteBuf();
565 if (WrittenFileSize>DestUnpSize)
566 return false;
567 }
568
569 uint MainSlot=DecodeNumber(D.Inp,&D.BlockTables.LD);
570 if (MainSlot<256)
571 {
572 Window[UnpPtr++]=(byte)MainSlot;
573 continue;
574 }
575 if (MainSlot>=262)
576 {
577 uint Length=SlotToLength(D.Inp,MainSlot-262);

Callers

nothing calls this directly

Calls 2

getbits32Method · 0.80
addbitsMethod · 0.80

Tested by

no test coverage detected