Changeset 127 for CoolStreaming
- Timestamp:
- Jan 16, 2011, 3:08:56 PM (14 years ago)
- Location:
- CoolStreaming
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
CoolStreaming/Demo/DynNumber/DynNumberDemo.lpi
r126 r127 39 39 </Item2> 40 40 </RequiredPackages> 41 <Units Count="1 4">41 <Units Count="15"> 42 42 <Unit0> 43 43 <Filename Value="DynNumberDemo.lpr"/> 44 44 <IsPartOfProject Value="True"/> 45 45 <UnitName Value="DynNumberDemo"/> 46 <EditorIndex Value="1"/>47 46 <WindowIndex Value="0"/> 48 47 <TopLine Value="1"/> 49 48 <CursorPos X="41" Y="19"/> 50 <UsageCount Value="36"/> 51 <Loaded Value="True"/> 49 <UsageCount Value="39"/> 52 50 </Unit0> 53 51 <Unit1> … … 60 58 <EditorIndex Value="0"/> 61 59 <WindowIndex Value="0"/> 62 <TopLine Value=" 67"/>63 <CursorPos X="2 3" Y="89"/>64 <UsageCount Value="3 6"/>60 <TopLine Value="39"/> 61 <CursorPos X="24" Y="53"/> 62 <UsageCount Value="39"/> 65 63 <Loaded Value="True"/> 66 64 <LoadedDesigner Value="True"/> … … 69 67 <Filename Value="..\..\UDynNumber.pas"/> 70 68 <UnitName Value="UDynNumber"/> 71 <EditorIndex Value=" 2"/>69 <EditorIndex Value="1"/> 72 70 <WindowIndex Value="0"/> 73 71 <TopLine Value="11"/> 74 <CursorPos X=" 49" Y="26"/>75 <UsageCount Value=" 18"/>72 <CursorPos X="8" Y="14"/> 73 <UsageCount Value="20"/> 76 74 <Loaded Value="True"/> 77 75 </Unit2> … … 79 77 <Filename Value="..\..\UBitStream.pas"/> 80 78 <UnitName Value="UBitStream"/> 81 <EditorIndex Value=" 5"/>82 <WindowIndex Value="0"/> 83 <TopLine Value=" 17"/>84 <CursorPos X=" 49" Y="33"/>85 <UsageCount Value=" 18"/>79 <EditorIndex Value="4"/> 80 <WindowIndex Value="0"/> 81 <TopLine Value="37"/> 82 <CursorPos X="14" Y="53"/> 83 <UsageCount Value="20"/> 86 84 <Loaded Value="True"/> 87 85 </Unit3> … … 89 87 <Filename Value="..\..\UBufferedFileStream.pas"/> 90 88 <UnitName Value="UBufferedFileStream"/> 91 <EditorIndex Value=" 3"/>89 <EditorIndex Value="2"/> 92 90 <WindowIndex Value="0"/> 93 91 <TopLine Value="38"/> 94 92 <CursorPos X="30" Y="54"/> 95 <UsageCount Value=" 18"/>93 <UsageCount Value="20"/> 96 94 <Loaded Value="True"/> 97 95 </Unit4> 98 96 <Unit5> 99 97 <Filename Value="..\..\..\..\..\..\..\..\usr\share\fpcsrc\2.4.0\rtl\objpas\classes\classesh.inc"/> 100 <EditorIndex Value=" 4"/>98 <EditorIndex Value="3"/> 101 99 <WindowIndex Value="0"/> 102 100 <TopLine Value="773"/> 103 101 <CursorPos X="17" Y="789"/> 104 <UsageCount Value=" 18"/>102 <UsageCount Value="20"/> 105 103 <Loaded Value="True"/> 106 104 </Unit5> … … 163 161 <UsageCount Value="10"/> 164 162 </Unit13> 163 <Unit14> 164 <Filename Value="..\..\..\..\..\..\..\..\usr\share\fpcsrc\2.4.0\rtl\inc\mathh.inc"/> 165 <WindowIndex Value="0"/> 166 <TopLine Value="62"/> 167 <CursorPos X="14" Y="78"/> 168 <UsageCount Value="11"/> 169 </Unit14> 165 170 </Units> 166 <JumpHistory Count=" 29" HistoryIndex="28">171 <JumpHistory Count="30" HistoryIndex="29"> 167 172 <Position1> 168 173 <Filename Value="UMainForm.pas"/> 169 <Caret Line=" 101" Column="1" TopLine="87"/>174 <Caret Line="56" Column="1" TopLine="39"/> 170 175 </Position1> 171 176 <Position2> 172 <Filename Value=" UMainForm.pas"/>173 <Caret Line=" 102" Column="1" TopLine="87"/>177 <Filename Value="..\..\UDynNumber.pas"/> 178 <Caret Line="31" Column="1" TopLine="21"/> 174 179 </Position2> 175 180 <Position3> 176 <Filename Value=" UMainForm.pas"/>177 <Caret Line=" 103" Column="1" TopLine="87"/>181 <Filename Value="..\..\UDynNumber.pas"/> 182 <Caret Line="32" Column="1" TopLine="21"/> 178 183 </Position3> 179 184 <Position4> 180 <Filename Value=" UMainForm.pas"/>181 <Caret Line=" 104" Column="1" TopLine="87"/>185 <Filename Value="..\..\UDynNumber.pas"/> 186 <Caret Line="33" Column="1" TopLine="21"/> 182 187 </Position4> 183 188 <Position5> 184 <Filename Value=" UMainForm.pas"/>185 <Caret Line=" 105" Column="1" TopLine="87"/>189 <Filename Value="..\..\UDynNumber.pas"/> 190 <Caret Line="34" Column="1" TopLine="21"/> 186 191 </Position5> 187 192 <Position6> 188 <Filename Value=" UMainForm.pas"/>189 <Caret Line=" 106" Column="1" TopLine="87"/>193 <Filename Value="..\..\UDynNumber.pas"/> 194 <Caret Line="31" Column="1" TopLine="21"/> 190 195 </Position6> 191 196 <Position7> 192 <Filename Value=" UMainForm.pas"/>193 <Caret Line=" 79" Column="1" TopLine="63"/>197 <Filename Value="..\..\UDynNumber.pas"/> 198 <Caret Line="32" Column="1" TopLine="21"/> 194 199 </Position7> 195 200 <Position8> 196 <Filename Value=" UMainForm.pas"/>197 <Caret Line=" 94" Column="1" TopLine="77"/>201 <Filename Value="..\..\UDynNumber.pas"/> 202 <Caret Line="35" Column="1" TopLine="21"/> 198 203 </Position8> 199 204 <Position9> 200 <Filename Value=" UMainForm.pas"/>201 <Caret Line=" 96" Column="1" TopLine="77"/>205 <Filename Value="..\..\UDynNumber.pas"/> 206 <Caret Line="36" Column="1" TopLine="21"/> 202 207 </Position9> 203 208 <Position10> 204 <Filename Value=" UMainForm.pas"/>205 <Caret Line=" 97" Column="1" TopLine="77"/>209 <Filename Value="..\..\UDynNumber.pas"/> 210 <Caret Line="37" Column="1" TopLine="21"/> 206 211 </Position10> 207 212 <Position11> 208 <Filename Value=" UMainForm.pas"/>209 <Caret Line=" 99" Column="1" TopLine="87"/>213 <Filename Value="..\..\UDynNumber.pas"/> 214 <Caret Line="38" Column="1" TopLine="21"/> 210 215 </Position11> 211 216 <Position12> 212 <Filename Value=" UMainForm.pas"/>213 <Caret Line=" 81" Column="15" TopLine="63"/>217 <Filename Value="..\..\UDynNumber.pas"/> 218 <Caret Line="36" Column="1" TopLine="21"/> 214 219 </Position12> 215 220 <Position13> 216 <Filename Value=" UMainForm.pas"/>217 <Caret Line=" 80" Column="15" TopLine="62"/>221 <Filename Value="..\..\UDynNumber.pas"/> 222 <Caret Line="37" Column="1" TopLine="21"/> 218 223 </Position13> 219 224 <Position14> 220 <Filename Value=" UMainForm.pas"/>221 <Caret Line=" 81" Column="15" TopLine="63"/>225 <Filename Value="..\..\UBitStream.pas"/> 226 <Caret Line="164" Column="1" TopLine="149"/> 222 227 </Position14> 223 228 <Position15> 224 <Filename Value=" UMainForm.pas"/>225 <Caret Line=" 48" Column="15" TopLine="32"/>229 <Filename Value="..\..\UBitStream.pas"/> 230 <Caret Line="246" Column="1" TopLine="230"/> 226 231 </Position15> 227 232 <Position16> 228 <Filename Value=" UMainForm.pas"/>229 <Caret Line=" 122" Column="17" TopLine="102"/>233 <Filename Value="..\..\UBitStream.pas"/> 234 <Caret Line="249" Column="1" TopLine="230"/> 230 235 </Position16> 231 236 <Position17> 232 <Filename Value=" UMainForm.pas"/>233 <Caret Line=" 78" Column="33" TopLine="78"/>237 <Filename Value="..\..\UBitStream.pas"/> 238 <Caret Line="250" Column="1" TopLine="230"/> 234 239 </Position17> 235 240 <Position18> 236 <Filename Value=" UMainForm.pas"/>237 <Caret Line=" 93" Column="19" TopLine="77"/>241 <Filename Value="..\..\UBitStream.pas"/> 242 <Caret Line="251" Column="1" TopLine="230"/> 238 243 </Position18> 239 244 <Position19> 240 245 <Filename Value="..\..\UBitStream.pas"/> 241 <Caret Line=" 38" Column="51" TopLine="22"/>246 <Caret Line="252" Column="1" TopLine="230"/> 242 247 </Position19> 243 248 <Position20> 244 249 <Filename Value="..\..\UBitStream.pas"/> 245 <Caret Line=" 162" Column="33" TopLine="142"/>250 <Caret Line="253" Column="1" TopLine="230"/> 246 251 </Position20> 247 252 <Position21> 248 253 <Filename Value="..\..\UBitStream.pas"/> 249 <Caret Line=" 38" Column="41" TopLine="22"/>254 <Caret Line="254" Column="1" TopLine="230"/> 250 255 </Position21> 251 256 <Position22> 252 257 <Filename Value="..\..\UBitStream.pas"/> 253 <Caret Line=" 157" Column="48" TopLine="141"/>258 <Caret Line="255" Column="1" TopLine="230"/> 254 259 </Position22> 255 260 <Position23> 256 <Filename Value=" UMainForm.pas"/>257 <Caret Line=" 93" Column="19" TopLine="77"/>261 <Filename Value="..\..\UBitStream.pas"/> 262 <Caret Line="257" Column="1" TopLine="230"/> 258 263 </Position23> 259 264 <Position24> 260 <Filename Value=" UMainForm.pas"/>261 <Caret Line=" 105" Column="16" TopLine="75"/>265 <Filename Value="..\..\UBitStream.pas"/> 266 <Caret Line="258" Column="1" TopLine="231"/> 262 267 </Position24> 263 268 <Position25> 264 <Filename Value=" UMainForm.pas"/>265 <Caret Line=" 91" Column="24" TopLine="75"/>269 <Filename Value="..\..\UBitStream.pas"/> 270 <Caret Line="241" Column="1" TopLine="231"/> 266 271 </Position25> 267 272 <Position26> 268 <Filename Value=" UMainForm.pas"/>269 <Caret Line=" 99" Column="80" TopLine="84"/>273 <Filename Value="..\..\UBitStream.pas"/> 274 <Caret Line="242" Column="1" TopLine="231"/> 270 275 </Position26> 271 276 <Position27> 272 <Filename Value=" UMainForm.pas"/>273 <Caret Line=" 92" Column="14" TopLine="82"/>277 <Filename Value="..\..\UBitStream.pas"/> 278 <Caret Line="243" Column="1" TopLine="231"/> 274 279 </Position27> 275 280 <Position28> 276 <Filename Value=" UMainForm.pas"/>277 <Caret Line="1 05" Column="37" TopLine="89"/>281 <Filename Value="..\..\UBitStream.pas"/> 282 <Caret Line="193" Column="1" TopLine="177"/> 278 283 </Position28> 279 284 <Position29> 280 <Filename Value=" UMainForm.pas"/>281 <Caret Line="1 06" Column="61" TopLine="89"/>285 <Filename Value="..\..\UBitStream.pas"/> 286 <Caret Line="194" Column="1" TopLine="177"/> 282 287 </Position29> 288 <Position30> 289 <Filename Value="..\..\UBitStream.pas"/> 290 <Caret Line="53" Column="14" TopLine="37"/> 291 </Position30> 283 292 </JumpHistory> 284 293 </ProjectOptions> -
CoolStreaming/Demo/DynNumber/UMainForm.pas
r126 r127 51 51 ListView1.BeginUpdate; 52 52 ListView1.Clear; 53 for I := 0 to 1 6do begin53 for I := 0 to 10000 do begin 54 54 N.Stream.Size := 0; 55 55 N.Write(I); … … 60 60 NewItem := ListView1.Items.Add; 61 61 NewItem.Caption := IntToStr(I); 62 NewItem.SubItems.Add(''); 62 J := Floor(Log2(I)) + 1; 63 NewItem.SubItems.Add(FloatToStr(Round((1 - (J / N.Stream.Size)) * 100) / 100)); 63 64 NewItem.SubItems.Add(Line); 64 65 end; … … 72 73 var 73 74 I: Integer; 75 II: Integer; 74 76 Count: Integer; 75 77 Parts: array of Integer; … … 80 82 NewItem: TListItem; 81 83 N: TDynamicNumber; 84 const 85 Step = 1; 82 86 begin 83 87 Count := 1; … … 87 91 ListView1.BeginUpdate; 88 92 ListView1.Clear; 89 for I := 0 to 1000 do begin90 93 for II := 0 to 20000 do begin 94 I := II * Step; 91 95 // Write 92 96 N.Stream.Size := 0; … … 104 108 NewItem.Caption := IntToStr(I); 105 109 J := Floor(Log2(I)) + 1; 106 NewItem.SubItems.Add(FloatToStr( 1 - (J / N.Stream.Size)));110 NewItem.SubItems.Add(FloatToStr(Round((1 - (J / N.Stream.Size)) * 100) / 100)); 107 111 Line := ''; 108 112 N.Stream.Position := 0; … … 112 116 113 117 // Increment value 118 for J := 0 to Step - 1 do begin 114 119 PartIndex := Count - 1; 115 120 repeat 116 121 Parts[PartIndex] := Parts[PartIndex] + 1; 117 if PartIndex > 0 then MaxValue := 1 shl (Parts[PartIndex - 1] + 1 )122 if PartIndex > 0 then MaxValue := 1 shl (Parts[PartIndex - 1] + 1 + PartIndex) 118 123 else MaxValue := 2; 119 124 if Parts[PartIndex] >= MaxValue then begin … … 129 134 end else Break; 130 135 until False; 136 end; 131 137 end; 132 138 finally -
CoolStreaming/UDynNumber.pas
r126 r127 6 6 7 7 uses 8 Classes, SysUtils, UBitStream ;8 Classes, SysUtils, UBitStream, Math; 9 9 10 10 type … … 26 26 procedure TDynamicNumber.Write(Value: QWord); 27 27 var 28 C: Integer;29 Parts: array ofInteger;28 Bit: Byte; 29 Length: Integer; 30 30 begin 31 C := 0; 32 for C := 0 to Value do 33 Stream.WriteBit(True); 34 Stream.WriteBit(False); 31 Length := Floor(Log2(Value)) + 1; 32 if Length > 1 then begin 33 Stream.WriteNumber(1, 1); 34 Write(Length - 2); 35 end else Stream.WriteNumber(0, 1); 36 if Length > 1 then Length := Length - 1; 37 Stream.WriteNumber(Value, Length); 35 38 end; 36 39 37 40 function TDynamicNumber.Read: QWord; 41 var 42 Bit: Byte; 43 Length: Integer; 38 44 begin 39 45 Bit := Stream.ReadNumber(1); 46 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); 40 50 end; 41 51
Note:
See TracChangeset
for help on using the changeset viewer.