Changeset 128 for CoolStreaming/UDynNumber.pas
- Timestamp:
- Jan 16, 2011, 4:31:02 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
CoolStreaming/UDynNumber.pas
r127 r128 14 14 TDynamicNumber = class 15 15 Stream: TBitStream; 16 procedure Write (Value: QWord);17 function Read : QWord;16 procedure WriteNumber(Value: QWord); 17 function ReadNumber: QWord; 18 18 constructor Create; 19 19 destructor Destroy; override; 20 private 21 function ReadNumber2: QWord; 20 22 end; 21 23 … … 24 26 { TDynamicNumber } 25 27 26 procedure TDynamicNumber.Write (Value: QWord);28 procedure TDynamicNumber.WriteNumber(Value: QWord); 27 29 var 28 Bit: Byte;29 30 Length: Integer; 30 31 begin … … 32 33 if Length > 1 then begin 33 34 Stream.WriteNumber(1, 1); 34 Write (Length - 2);35 WriteNumber(Length - 2); 35 36 end else Stream.WriteNumber(0, 1); 36 37 if Length > 1 then Length := Length - 1; … … 38 39 end; 39 40 40 function TDynamicNumber.Read : QWord;41 function TDynamicNumber.ReadNumber: QWord; 41 42 var 42 43 Bit: Byte; 43 44 Length: Integer; 44 45 begin 46 Length := 0; 45 47 Bit := Stream.ReadNumber(1); 46 48 if Bit = 0 then Length := 1 47 else Length := Read + 2; 48 Result := Stream.ReadNumber(Length); 49 if Length > 0 then Result := Result or (1 shl Length); 49 else Length := ReadNumber2 + 2; 50 if Length > 1 then Result := Stream.ReadNumber(Length - 1) 51 else Result := Stream.ReadNumber(Length); 52 if Length > 1 then Result := Result or (QWord(1) shl (Length - 1)); 53 end; 54 55 function TDynamicNumber.ReadNumber2: QWord; 56 var 57 Bit: Byte; 58 Length: Integer; 59 begin 60 Length := 0; 61 Bit := Stream.ReadNumber(1); 62 if Bit = 0 then Length := 1 63 else Length := ReadNumber + 2; 64 if Length > 1 then Result := Stream.ReadNumber(Length - 1) 65 else Result := Stream.ReadNumber(Length); 66 if Length > 1 then Result := Result or (QWord(1) shl (Length - 1)); 50 67 end; 51 68
Note:
See TracChangeset
for help on using the changeset viewer.