Changeset 129 for CoolStreaming
- Timestamp:
- Jan 17, 2011, 6:55:36 AM (14 years ago)
- Location:
- CoolStreaming/Demo/BitStream
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
CoolStreaming/Demo/BitStream/BitStreamTest.lpi
r122 r129 42 42 </Item2> 43 43 </RequiredPackages> 44 <Units Count=" 5">44 <Units Count="6"> 45 45 <Unit0> 46 46 <Filename Value="BitStreamTest.lpr"/> 47 47 <IsPartOfProject Value="True"/> 48 48 <UnitName Value="BitStreamTest"/> 49 <EditorIndex Value=" 1"/>49 <EditorIndex Value="2"/> 50 50 <WindowIndex Value="0"/> 51 51 <TopLine Value="1"/> … … 64 64 <EditorIndex Value="0"/> 65 65 <WindowIndex Value="0"/> 66 <TopLine Value="1 "/>67 <CursorPos X=" 3" Y="18"/>66 <TopLine Value="132"/> 67 <CursorPos X="1" Y="150"/> 68 68 <UsageCount Value="20"/> 69 69 <Loaded Value="True"/> … … 83 83 <Filename Value="E:\Programy\Lazarus\lcl\controls.pp"/> 84 84 <UnitName Value="Controls"/> 85 <EditorIndex Value=" 2"/>85 <EditorIndex Value="3"/> 86 86 <WindowIndex Value="0"/> 87 87 <TopLine Value="1207"/> … … 98 98 <UsageCount Value="10"/> 99 99 </Unit4> 100 <Unit5> 101 <Filename Value="E:\Programy\Lazarus\fpc\2.4.3\source\rtl\objpas\sysutils\sysutilh.inc"/> 102 <EditorIndex Value="1"/> 103 <WindowIndex Value="0"/> 104 <TopLine Value="84"/> 105 <CursorPos X="79" Y="89"/> 106 <UsageCount Value="10"/> 107 <Loaded Value="True"/> 108 </Unit5> 100 109 </Units> 101 <JumpHistory Count="30" HistoryIndex="2 8">110 <JumpHistory Count="30" HistoryIndex="29"> 102 111 <Position1> 103 112 <Filename Value="UMainForm.pas"/> 104 <Caret Line="9 5" Column="1" TopLine="85"/>113 <Caret Line="99" Column="1" TopLine="85"/> 105 114 </Position1> 106 115 <Position2> 107 116 <Filename Value="UMainForm.pas"/> 108 <Caret Line=" 98" Column="1" TopLine="85"/>117 <Caret Line="101" Column="1" TopLine="85"/> 109 118 </Position2> 110 119 <Position3> 111 120 <Filename Value="UMainForm.pas"/> 112 <Caret Line="9 9" Column="1" TopLine="85"/>121 <Caret Line="94" Column="1" TopLine="85"/> 113 122 </Position3> 114 123 <Position4> 115 124 <Filename Value="UMainForm.pas"/> 116 <Caret Line="9 2" Column="13" TopLine="85"/>125 <Caret Line="95" Column="1" TopLine="85"/> 117 126 </Position4> 118 127 <Position5> 119 128 <Filename Value="UMainForm.pas"/> 120 <Caret Line="9 9" Column="1" TopLine="85"/>129 <Caret Line="98" Column="1" TopLine="85"/> 121 130 </Position5> 122 131 <Position6> 123 132 <Filename Value="UMainForm.pas"/> 124 <Caret Line=" 101" Column="1" TopLine="85"/>133 <Caret Line="99" Column="1" TopLine="85"/> 125 134 </Position6> 126 135 <Position7> 127 136 <Filename Value="UMainForm.pas"/> 128 <Caret Line=" 94" Column="1" TopLine="85"/>137 <Caret Line="101" Column="1" TopLine="85"/> 129 138 </Position7> 130 139 <Position8> 131 140 <Filename Value="UMainForm.pas"/> 132 <Caret Line="9 5" Column="1" TopLine="85"/>141 <Caret Line="94" Column="1" TopLine="85"/> 133 142 </Position8> 134 143 <Position9> 135 144 <Filename Value="UMainForm.pas"/> 136 <Caret Line="9 8" Column="1" TopLine="85"/>145 <Caret Line="95" Column="1" TopLine="85"/> 137 146 </Position9> 138 147 <Position10> … … 142 151 <Position11> 143 152 <Filename Value="UMainForm.pas"/> 144 <Caret Line="1 01" Column="1" TopLine="85"/>153 <Caret Line="119" Column="27" TopLine="109"/> 145 154 </Position11> 146 155 <Position12> 147 156 <Filename Value="UMainForm.pas"/> 148 <Caret Line="9 4" Column="1" TopLine="85"/>157 <Caret Line="99" Column="32" TopLine="78"/> 149 158 </Position12> 150 159 <Position13> 151 160 <Filename Value="UMainForm.pas"/> 152 <Caret Line="9 5" Column="1" TopLine="85"/>161 <Caret Line="98" Column="29" TopLine="78"/> 153 162 </Position13> 154 163 <Position14> 155 164 <Filename Value="UMainForm.pas"/> 156 <Caret Line=" 99" Column="1" TopLine="85"/>165 <Caret Line="102" Column="14" TopLine="78"/> 157 166 </Position14> 158 167 <Position15> 159 <Filename Value=" UMainForm.pas"/>160 <Caret Line="1 19" Column="27" TopLine="109"/>168 <Filename Value="BitStreamTest.lpr"/> 169 <Caret Line="19" Column="1" TopLine="1"/> 161 170 </Position15> 162 171 <Position16> 163 172 <Filename Value="UMainForm.pas"/> 164 <Caret Line=" 99" Column="32" TopLine="78"/>173 <Caret Line="101" Column="12" TopLine="85"/> 165 174 </Position16> 166 175 <Position17> 167 176 <Filename Value="UMainForm.pas"/> 168 <Caret Line=" 98" Column="29" TopLine="78"/>177 <Caret Line="111" Column="49" TopLine="111"/> 169 178 </Position17> 170 179 <Position18> 171 180 <Filename Value="UMainForm.pas"/> 172 <Caret Line=" 102" Column="14" TopLine="78"/>181 <Caret Line="24" Column="59" TopLine="23"/> 173 182 </Position18> 174 183 <Position19> 175 <Filename Value=" BitStreamTest.lpr"/>176 <Caret Line=" 19" Column="1" TopLine="1"/>184 <Filename Value="UMainForm.pas"/> 185 <Caret Line="58" Column="21" TopLine="45"/> 177 186 </Position19> 178 187 <Position20> 179 188 <Filename Value="UMainForm.pas"/> 180 <Caret Line=" 101" Column="12" TopLine="85"/>189 <Caret Line="72" Column="9" TopLine="59"/> 181 190 </Position20> 182 191 <Position21> 183 <Filename Value=" UMainForm.pas"/>184 <Caret Line="1 11" Column="49" TopLine="111"/>192 <Filename Value="BitStreamTest.lpr"/> 193 <Caret Line="19" Column="1" TopLine="1"/> 185 194 </Position21> 186 195 <Position22> 187 <Filename Value=" UMainForm.pas"/>188 <Caret Line=" 24" Column="59" TopLine="23"/>196 <Filename Value="BitStreamTest.lpr"/> 197 <Caret Line="18" Column="29" TopLine="1"/> 189 198 </Position22> 190 199 <Position23> 191 200 <Filename Value="UMainForm.pas"/> 192 <Caret Line=" 58" Column="21" TopLine="45"/>201 <Caret Line="89" Column="23" TopLine="80"/> 193 202 </Position23> 194 203 <Position24> 195 204 <Filename Value="UMainForm.pas"/> 196 <Caret Line=" 72" Column="9" TopLine="59"/>205 <Caret Line="15" Column="1" TopLine="3"/> 197 206 </Position24> 198 207 <Position25> 199 <Filename Value=" BitStreamTest.lpr"/>200 <Caret Line=" 19" Column="1" TopLine="1"/>208 <Filename Value="UMainForm.pas"/> 209 <Caret Line="56" Column="11" TopLine="44"/> 201 210 </Position25> 202 211 <Position26> 203 <Filename Value=" BitStreamTest.lpr"/>204 <Caret Line=" 18" Column="29" TopLine="1"/>212 <Filename Value="UMainForm.pas"/> 213 <Caret Line="76" Column="3" TopLine="69"/> 205 214 </Position26> 206 215 <Position27> 207 216 <Filename Value="UMainForm.pas"/> 208 <Caret Line=" 89" Column="23" TopLine="80"/>217 <Caret Line="15" Column="7" TopLine="3"/> 209 218 </Position27> 210 219 <Position28> 211 220 <Filename Value="UMainForm.pas"/> 212 <Caret Line="1 5" Column="1" TopLine="3"/>221 <Caret Line="11" Column="1" TopLine="1"/> 213 222 </Position28> 214 223 <Position29> 215 224 <Filename Value="UMainForm.pas"/> 216 <Caret Line=" 56" Column="11" TopLine="44"/>225 <Caret Line="124" Column="53" TopLine="112"/> 217 226 </Position29> 218 227 <Position30> 219 228 <Filename Value="UMainForm.pas"/> 220 <Caret Line=" 22" Column="15" TopLine="10"/>229 <Caret Line="143" Column="50" TopLine="131"/> 221 230 </Position30> 222 231 </JumpHistory> -
CoolStreaming/Demo/BitStream/UMainForm.pas
r122 r129 9 9 UBitStream; 10 10 11 const12 Symbols: array[0..1] of Char = ('.', '#');13 14 11 type 15 TByteArray = array of Byte; 16 12 TArrayOfByte = array of Byte; 17 13 18 14 { TMainForm } … … 23 19 private 24 20 procedure PrintBitStream(Stream: TBitStream; StringList: TStrings); 25 procedure PrintData(Data: T ByteArray; Count: Integer; StringList: TStrings);21 procedure PrintData(Data: TArrayOfByte; Count: Integer; StringList: TStrings); 26 22 procedure PrintStream(Stream: TStream; StringList: TStrings); 27 { private declarations }28 23 public 29 { public declarations }30 24 end; 31 25 … … 48 42 WindowState := wsMaximized; 49 43 50 with Memo1, Lines do begin 51 BitStream := TMemoryBitStream.Create; 52 BitStream2 := TMemoryBitStream.Create; 53 SetLength(Buffer, 4); 54 Buffer[0] := $12; 55 Buffer[1] := $34; 56 Buffer[2] := $56; 57 Buffer[3] := $78; 58 Add('Source data:'); 59 PrintData(Buffer, Length(Buffer) * 8, Lines); 44 with Memo1, Lines do try 45 BeginUpdate; 46 BitStream := TMemoryBitStream.Create; 47 BitStream2 := TMemoryBitStream.Create; 48 SetLength(Buffer, 4); 49 Buffer[0] := $12; 50 Buffer[1] := $34; 51 Buffer[2] := $56; 52 Buffer[3] := $78; 53 Add('Source data:'); 54 PrintData(Buffer, Length(Buffer) * 8, Lines); 60 55 61 BitStream.Write(Buffer[0], 28);62 Add('Write data to stream:');63 PrintBitStream(BitStream, Lines);64 // Write second bit array after first which lead to store data as shifted65 BitStream.Write(Buffer[0], 28);66 Add('Append shifted data to stream:');67 PrintBitStream(BitStream, Lines);56 BitStream.Write(Buffer[0], 28); 57 Add('Write data to stream:'); 58 PrintBitStream(BitStream, Lines); 59 // Write second bit array after first which lead to store data as shifted 60 BitStream.Write(Buffer[0], 28); 61 Add('Append shifted data to stream:'); 62 PrintBitStream(BitStream, Lines); 68 63 69 // Read test of sub bit array70 BitStream.Position := 1;71 BitStream.Read(Buffer[0], 32);72 Add('Read bit data part:');73 PrintData(Buffer, Length(Buffer) * 8, Lines);64 // Read test of sub bit array 65 BitStream.Position := 1; 66 BitStream.Read(Buffer[0], 32); 67 Add('Read bit data part:'); 68 PrintData(Buffer, Length(Buffer) * 8, Lines); 74 69 75 (* // Test stream copy 76 Add('Copy bit block to another stream:'); 77 for I := 0 to BitStream.Size do begin 78 BitStream.Position := I; 79 BitStream2.Size := 0; 80 BitStream2.CopyFrom(BitStream, BitStream.Size); 81 PrintBitStream(BitStream2, Lines); 82 end; 83 for I := 0 to BitStream.Size do begin 84 BitStream.Position := 0; 85 BitStream2.Size := 0; 86 BitStream2.Position := I; 87 BitStream2.CopyFrom(BitStream, BitStream.Size); 88 PrintBitStream(BitStream2, Lines); 89 end; *) 90 91 Add('Bit copy of substreams'); 92 SetLength(Buffer, 1000); 93 for Y := 1 to BitStream.Size do begin 94 Add('Size: ' + IntToStr(Y)); 95 for I := 0 to BitStream.Size - Y do begin 70 (* // Test stream copy 71 Add('Copy bit block to another stream:'); 72 for I := 0 to BitStream.Size do begin 96 73 BitStream.Position := I; 97 74 BitStream2.Size := 0; 98 //BitStream2.CopyFrom(BitStream, Y); 99 //PrintBitStream(BitStream2, Lines); 100 SetLength(Buffer, 1000); 101 C := BitStream.Read(Buffer[0], Y); 102 SetLength(Buffer, C div 8 + 1); 103 PrintData(Buffer, C, Lines); 75 BitStream2.CopyFrom(BitStream, BitStream.Size); 76 PrintBitStream(BitStream2, Lines); 104 77 end; 105 Add(''); 106 end; 78 for I := 0 to BitStream.Size do begin 79 BitStream.Position := 0; 80 BitStream2.Size := 0; 81 BitStream2.Position := I; 82 BitStream2.CopyFrom(BitStream, BitStream.Size); 83 PrintBitStream(BitStream2, Lines); 84 end; *) 107 85 108 BitStream.Destroy; 109 BitStream2.Destroy; 86 Add('Bit copy of substreams'); 87 SetLength(Buffer, 1000); 88 for Y := 1 to BitStream.Size do begin 89 Add('Size: ' + IntToStr(Y)); 90 for I := 0 to BitStream.Size - Y do begin 91 BitStream.Position := I; 92 BitStream2.Size := 0; 93 //BitStream2.CopyFrom(BitStream, Y); 94 //PrintBitStream(BitStream2, Lines); 95 SetLength(Buffer, 1000); 96 C := BitStream.Read(Buffer[0], Y); 97 SetLength(Buffer, C div 8 + 1); 98 PrintData(Buffer, C, Lines); 99 end; 100 Add(''); 101 end; 102 finally 103 BitStream.Free; 104 BitStream2.Free; 105 EndUpdate; 110 106 end; 111 107 end; 112 108 113 procedure TMainForm.PrintData(Data: T ByteArray; Count: Integer; StringList: TStrings);109 procedure TMainForm.PrintData(Data: TArrayOfByte; Count: Integer; StringList: TStrings); 114 110 var 115 111 I: Integer; … … 124 120 for B := 0 to 7 do begin 125 121 if ((I * 8) + B) >= Count then Break; 126 Line := Line + Symbols[(OneByte shr B) and 1];122 Line := Line + IntToStr((OneByte shr B) and 1); 127 123 end; 128 124 end; … … 143 139 Data := Stream.ReadByte; 144 140 for B := 0 to 7 do 145 Line := Line + Symbols[(Data shr B) and 1];141 Line := Line + IntToStr((Data shr B) and 1); 146 142 end; 147 143 StringList.Add(Line); … … 150 146 151 147 procedure TMainForm.PrintBitStream(Stream: TBitStream; StringList: TStrings); 152 var153 I: Integer;154 Line: string;155 148 begin 156 Stream.Position := 0; 157 for I := 0 to Stream.Size - 1 do 158 Line := Line + Symbols[Integer(Stream.ReadBit)]; 159 StringList.Add(Line); 160 //StringList.Add(''); 149 StringList.Add(Stream.AsString); 161 150 end; 162 151
Note:
See TracChangeset
for help on using the changeset viewer.