Changeset 126 for CoolStreaming/Demo


Ignore:
Timestamp:
Jan 15, 2011, 10:03:27 PM (14 years ago)
Author:
george
Message:
  • Added: Generating encoded numbers for DynNumber demo.
Location:
CoolStreaming/Demo/DynNumber
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • CoolStreaming/Demo/DynNumber

    • Property svn:ignore
      •  

        old new  
        11DynNumberDemo.exe
        22lib
         3heaptrclog.trc
         4DynNumberDemo
  • CoolStreaming/Demo/DynNumber/DynNumberDemo.lpi

    r125 r126  
    2828      <local>
    2929        <FormatVersion Value="1"/>
     30        <LaunchingApplication PathPlusParams="\usr\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
    3031      </local>
    3132    </RunParams>
     
    3839      </Item2>
    3940    </RequiredPackages>
    40     <Units Count="4">
     41    <Units Count="14">
    4142      <Unit0>
    4243        <Filename Value="DynNumberDemo.lpr"/>
    4344        <IsPartOfProject Value="True"/>
    4445        <UnitName Value="DynNumberDemo"/>
    45         <UsageCount Value="20"/>
     46        <EditorIndex Value="1"/>
     47        <WindowIndex Value="0"/>
     48        <TopLine Value="1"/>
     49        <CursorPos X="41" Y="19"/>
     50        <UsageCount Value="36"/>
     51        <Loaded Value="True"/>
    4652      </Unit0>
    4753      <Unit1>
     
    5157        <ResourceBaseClass Value="Form"/>
    5258        <UnitName Value="UMainForm"/>
     59        <IsVisibleTab Value="True"/>
    5360        <EditorIndex Value="0"/>
    5461        <WindowIndex Value="0"/>
    55         <TopLine Value="42"/>
    56         <CursorPos X="12" Y="51"/>
    57         <UsageCount Value="20"/>
     62        <TopLine Value="67"/>
     63        <CursorPos X="23" Y="89"/>
     64        <UsageCount Value="36"/>
    5865        <Loaded Value="True"/>
    5966        <LoadedDesigner Value="True"/>
     
    6269        <Filename Value="..\..\UDynNumber.pas"/>
    6370        <UnitName Value="UDynNumber"/>
    64         <IsVisibleTab Value="True"/>
    65         <EditorIndex Value="1"/>
    66         <WindowIndex Value="0"/>
    67         <TopLine Value="26"/>
    68         <CursorPos X="8" Y="32"/>
    69         <UsageCount Value="10"/>
     71        <EditorIndex Value="2"/>
     72        <WindowIndex Value="0"/>
     73        <TopLine Value="11"/>
     74        <CursorPos X="49" Y="26"/>
     75        <UsageCount Value="18"/>
    7076        <Loaded Value="True"/>
    7177      </Unit2>
     
    7379        <Filename Value="..\..\UBitStream.pas"/>
    7480        <UnitName Value="UBitStream"/>
    75         <EditorIndex Value="2"/>
    76         <WindowIndex Value="0"/>
    77         <TopLine Value="119"/>
    78         <CursorPos X="1" Y="131"/>
     81        <EditorIndex Value="5"/>
     82        <WindowIndex Value="0"/>
     83        <TopLine Value="17"/>
     84        <CursorPos X="49" Y="33"/>
     85        <UsageCount Value="18"/>
     86        <Loaded Value="True"/>
     87      </Unit3>
     88      <Unit4>
     89        <Filename Value="..\..\UBufferedFileStream.pas"/>
     90        <UnitName Value="UBufferedFileStream"/>
     91        <EditorIndex Value="3"/>
     92        <WindowIndex Value="0"/>
     93        <TopLine Value="38"/>
     94        <CursorPos X="30" Y="54"/>
     95        <UsageCount Value="18"/>
     96        <Loaded Value="True"/>
     97      </Unit4>
     98      <Unit5>
     99        <Filename Value="..\..\..\..\..\..\..\..\usr\share\fpcsrc\2.4.0\rtl\objpas\classes\classesh.inc"/>
     100        <EditorIndex Value="4"/>
     101        <WindowIndex Value="0"/>
     102        <TopLine Value="773"/>
     103        <CursorPos X="17" Y="789"/>
     104        <UsageCount Value="18"/>
     105        <Loaded Value="True"/>
     106      </Unit5>
     107      <Unit6>
     108        <Filename Value="..\..\..\..\..\..\..\..\usr\share\fpcsrc\2.4.0\rtl\objpas\classes\streams.inc"/>
     109        <WindowIndex Value="0"/>
     110        <TopLine Value="462"/>
     111        <CursorPos X="19" Y="467"/>
     112        <UsageCount Value="8"/>
     113      </Unit6>
     114      <Unit7>
     115        <Filename Value="..\..\..\..\..\..\..\..\usr\share\fpcsrc\2.4.0\rtl\objpas\sysutils\filutilh.inc"/>
     116        <WindowIndex Value="0"/>
     117        <TopLine Value="60"/>
     118        <CursorPos X="10" Y="75"/>
     119        <UsageCount Value="8"/>
     120      </Unit7>
     121      <Unit8>
     122        <Filename Value="..\..\..\..\..\..\..\..\usr\share\fpcsrc\2.4.0\rtl\unix\sysutils.pp"/>
     123        <UnitName Value="sysutils"/>
     124        <WindowIndex Value="0"/>
     125        <TopLine Value="435"/>
     126        <CursorPos X="49" Y="435"/>
     127        <UsageCount Value="8"/>
     128      </Unit8>
     129      <Unit9>
     130        <Filename Value="..\..\..\..\..\..\..\..\usr\share\fpcsrc\2.4.0\rtl\unix\bunxovlh.inc"/>
     131        <WindowIndex Value="0"/>
     132        <TopLine Value="16"/>
     133        <CursorPos X="60" Y="32"/>
     134        <UsageCount Value="8"/>
     135      </Unit9>
     136      <Unit10>
     137        <Filename Value="..\..\..\..\..\..\..\..\usr\share\fpcsrc\2.4.0\rtl\unix\aliasptp.inc"/>
     138        <WindowIndex Value="0"/>
     139        <TopLine Value="16"/>
     140        <CursorPos X="27" Y="32"/>
     141        <UsageCount Value="8"/>
     142      </Unit10>
     143      <Unit11>
     144        <Filename Value="..\..\..\..\..\..\..\..\usr\share\fpcsrc\2.4.0\rtl\linux\ptypes.inc"/>
     145        <WindowIndex Value="0"/>
     146        <TopLine Value="41"/>
     147        <CursorPos X="22" Y="57"/>
     148        <UsageCount Value="8"/>
     149      </Unit11>
     150      <Unit12>
     151        <Filename Value="..\..\..\..\..\..\..\..\usr\share\fpcsrc\2.4.0\rtl\unix\ctypes.inc"/>
     152        <WindowIndex Value="0"/>
     153        <TopLine Value="21"/>
     154        <CursorPos X="3" Y="37"/>
     155        <UsageCount Value="8"/>
     156      </Unit12>
     157      <Unit13>
     158        <Filename Value="..\..\..\..\..\..\..\..\usr\share\fpcsrc\2.4.0\rtl\objpas\math.pp"/>
     159        <UnitName Value="math"/>
     160        <WindowIndex Value="0"/>
     161        <TopLine Value="308"/>
     162        <CursorPos X="10" Y="324"/>
    79163        <UsageCount Value="10"/>
    80         <Loaded Value="True"/>
    81       </Unit3>
     164      </Unit13>
    82165    </Units>
    83     <JumpHistory Count="19" HistoryIndex="18">
     166    <JumpHistory Count="29" HistoryIndex="28">
    84167      <Position1>
    85168        <Filename Value="UMainForm.pas"/>
    86         <Caret Line="9" Column="32" TopLine="1"/>
     169        <Caret Line="101" Column="1" TopLine="87"/>
    87170      </Position1>
    88171      <Position2>
    89172        <Filename Value="UMainForm.pas"/>
    90         <Caret Line="24" Column="5" TopLine="17"/>
     173        <Caret Line="102" Column="1" TopLine="87"/>
    91174      </Position2>
    92175      <Position3>
    93176        <Filename Value="UMainForm.pas"/>
    94         <Caret Line="44" Column="16" TopLine="24"/>
     177        <Caret Line="103" Column="1" TopLine="87"/>
    95178      </Position3>
    96179      <Position4>
    97         <Filename Value="..\..\UDynNumber.pas"/>
    98         <Caret Line="16" Column="25" TopLine="1"/>
     180        <Filename Value="UMainForm.pas"/>
     181        <Caret Line="104" Column="1" TopLine="87"/>
    99182      </Position4>
    100183      <Position5>
    101         <Filename Value="..\..\UDynNumber.pas"/>
    102         <Caret Line="17" Column="25" TopLine="5"/>
     184        <Filename Value="UMainForm.pas"/>
     185        <Caret Line="105" Column="1" TopLine="87"/>
    103186      </Position5>
    104187      <Position6>
    105         <Filename Value="..\..\UDynNumber.pas"/>
    106         <Caret Line="29" Column="3" TopLine="7"/>
     188        <Filename Value="UMainForm.pas"/>
     189        <Caret Line="106" Column="1" TopLine="87"/>
    107190      </Position6>
    108191      <Position7>
    109192        <Filename Value="UMainForm.pas"/>
    110         <Caret Line="46" Column="15" TopLine="36"/>
     193        <Caret Line="79" Column="1" TopLine="63"/>
    111194      </Position7>
    112195      <Position8>
    113196        <Filename Value="UMainForm.pas"/>
    114         <Caret Line="52" Column="21" TopLine="36"/>
     197        <Caret Line="94" Column="1" TopLine="77"/>
    115198      </Position8>
    116199      <Position9>
    117200        <Filename Value="UMainForm.pas"/>
    118         <Caret Line="50" Column="7" TopLine="36"/>
     201        <Caret Line="96" Column="1" TopLine="77"/>
    119202      </Position9>
    120203      <Position10>
    121204        <Filename Value="UMainForm.pas"/>
    122         <Caret Line="43" Column="16" TopLine="31"/>
     205        <Caret Line="97" Column="1" TopLine="77"/>
    123206      </Position10>
    124207      <Position11>
    125         <Filename Value="..\..\UDynNumber.pas"/>
    126         <Caret Line="19" Column="34" TopLine="2"/>
     208        <Filename Value="UMainForm.pas"/>
     209        <Caret Line="99" Column="1" TopLine="87"/>
    127210      </Position11>
    128211      <Position12>
    129         <Filename Value="..\..\UDynNumber.pas"/>
    130         <Caret Line="46" Column="10" TopLine="26"/>
     212        <Filename Value="UMainForm.pas"/>
     213        <Caret Line="81" Column="15" TopLine="63"/>
    131214      </Position12>
    132215      <Position13>
    133216        <Filename Value="UMainForm.pas"/>
    134         <Caret Line="54" Column="26" TopLine="37"/>
     217        <Caret Line="80" Column="15" TopLine="62"/>
    135218      </Position13>
    136219      <Position14>
    137220        <Filename Value="UMainForm.pas"/>
    138         <Caret Line="55" Column="1" TopLine="42"/>
     221        <Caret Line="81" Column="15" TopLine="63"/>
    139222      </Position14>
    140223      <Position15>
    141224        <Filename Value="UMainForm.pas"/>
    142         <Caret Line="57" Column="1" TopLine="42"/>
     225        <Caret Line="48" Column="15" TopLine="32"/>
    143226      </Position15>
    144227      <Position16>
    145228        <Filename Value="UMainForm.pas"/>
    146         <Caret Line="54" Column="1" TopLine="42"/>
     229        <Caret Line="122" Column="17" TopLine="102"/>
    147230      </Position16>
    148231      <Position17>
    149         <Filename Value="..\..\UBitStream.pas"/>
    150         <Caret Line="154" Column="1" TopLine="142"/>
     232        <Filename Value="UMainForm.pas"/>
     233        <Caret Line="78" Column="33" TopLine="78"/>
    151234      </Position17>
    152235      <Position18>
    153         <Filename Value="..\..\UDynNumber.pas"/>
    154         <Caret Line="41" Column="29" TopLine="27"/>
     236        <Filename Value="UMainForm.pas"/>
     237        <Caret Line="93" Column="19" TopLine="77"/>
    155238      </Position18>
    156239      <Position19>
    157         <Filename Value="UMainForm.pas"/>
    158         <Caret Line="51" Column="12" TopLine="42"/>
     240        <Filename Value="..\..\UBitStream.pas"/>
     241        <Caret Line="38" Column="51" TopLine="22"/>
    159242      </Position19>
     243      <Position20>
     244        <Filename Value="..\..\UBitStream.pas"/>
     245        <Caret Line="162" Column="33" TopLine="142"/>
     246      </Position20>
     247      <Position21>
     248        <Filename Value="..\..\UBitStream.pas"/>
     249        <Caret Line="38" Column="41" TopLine="22"/>
     250      </Position21>
     251      <Position22>
     252        <Filename Value="..\..\UBitStream.pas"/>
     253        <Caret Line="157" Column="48" TopLine="141"/>
     254      </Position22>
     255      <Position23>
     256        <Filename Value="UMainForm.pas"/>
     257        <Caret Line="93" Column="19" TopLine="77"/>
     258      </Position23>
     259      <Position24>
     260        <Filename Value="UMainForm.pas"/>
     261        <Caret Line="105" Column="16" TopLine="75"/>
     262      </Position24>
     263      <Position25>
     264        <Filename Value="UMainForm.pas"/>
     265        <Caret Line="91" Column="24" TopLine="75"/>
     266      </Position25>
     267      <Position26>
     268        <Filename Value="UMainForm.pas"/>
     269        <Caret Line="99" Column="80" TopLine="84"/>
     270      </Position26>
     271      <Position27>
     272        <Filename Value="UMainForm.pas"/>
     273        <Caret Line="92" Column="14" TopLine="82"/>
     274      </Position27>
     275      <Position28>
     276        <Filename Value="UMainForm.pas"/>
     277        <Caret Line="105" Column="37" TopLine="89"/>
     278      </Position28>
     279      <Position29>
     280        <Filename Value="UMainForm.pas"/>
     281        <Caret Line="106" Column="61" TopLine="89"/>
     282      </Position29>
    160283    </JumpHistory>
    161284  </ProjectOptions>
     
    170293      <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
    171294    </SearchPaths>
     295    <CodeGeneration>
     296      <Checks>
     297        <IOChecks Value="True"/>
     298        <RangeChecks Value="True"/>
     299        <OverflowChecks Value="True"/>
     300        <StackChecks Value="True"/>
     301      </Checks>
     302    </CodeGeneration>
    172303    <Linking>
     304      <Debugging>
     305        <UseHeaptrc Value="True"/>
     306      </Debugging>
    173307      <Options>
    174308        <Win32>
     
    178312    </Linking>
    179313    <Other>
     314      <CompilerMessages>
     315        <UseMsgFile Value="True"/>
     316      </CompilerMessages>
    180317      <CompilerPath Value="$(CompPath)"/>
    181318    </Other>
  • CoolStreaming/Demo/DynNumber/DynNumberDemo.lpr

    r125 r126  
    77  cthreads,
    88  {$ENDIF}{$ENDIF}
    9   Interfaces, // this includes the LCL widgetset
     9  Interfaces, SysUtils, // this includes the LCL widgetset
    1010  Forms, UMainForm, CoolStreaming
    1111  { you can add units after this };
     
    1313{$R *.res}
    1414
     15const
     16  HeapTraceLog = 'heaptrclog.trc';
    1517begin
     18  // Heap trace
     19  DeleteFile(ExtractFilePath(ParamStr(0)) + HeapTraceLog);
     20  SetHeapTraceOutput(ExtractFilePath(ParamStr(0)) + HeapTraceLog);
     21
    1622  Application.Initialize;
    1723  Application.CreateForm(TMainForm, MainForm);
  • CoolStreaming/Demo/DynNumber/UMainForm.lfm

    r125 r126  
    1010  OnDestroy = FormDestroy
    1111  LCLVersion = '0.9.31'
    12   object Memo1: TMemo
    13     Left = 8
    14     Height = 448
    15     Top = 40
    16     Width = 536
    17     Anchors = [akTop, akLeft, akRight, akBottom]
    18     Font.Name = 'Consolas'
    19     ParentFont = False
    20     TabOrder = 0
    21   end
    2212  object Edit1: TEdit
    2313    Left = 8
    24     Height = 21
     14    Height = 25
    2515    Top = 8
    2616    Width = 320
    27     TabOrder = 1
     17    TabOrder = 0
    2818    Text = '1'
    2919  end
     
    3525    Caption = 'Encode'
    3626    OnClick = Button1Click
     27    TabOrder = 1
     28  end
     29  object Button2: TButton
     30    Left = 416
     31    Height = 25
     32    Top = 7
     33    Width = 75
     34    Caption = 'Generate'
     35    OnClick = Button2Click
    3736    TabOrder = 2
    3837  end
     38  object ListView1: TListView
     39    Left = 8
     40    Height = 448
     41    Top = 40
     42    Width = 536
     43    Anchors = [akTop, akLeft, akRight, akBottom]
     44    Columns = <   
     45      item
     46        Caption = 'Number'
     47        Width = 70
     48      end   
     49      item
     50        Caption = 'Overhead'
     51        Width = 70
     52      end   
     53      item
     54        Caption = 'Value'
     55        Width = 375
     56      end>
     57    TabOrder = 3
     58    ViewStyle = vsReport
     59  end
    3960end
  • CoolStreaming/Demo/DynNumber/UMainForm.pas

    r125 r126  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
    9   UDynNumber;
     9  ComCtrls, UDynNumber, Math;
    1010
    1111type
     
    1515  TMainForm = class(TForm)
    1616    Button1: TButton;
     17    Button2: TButton;
    1718    Edit1: TEdit;
    18     Memo1: TMemo;
     19    ListView1: TListView;
    1920    procedure Button1Click(Sender: TObject);
     21    procedure Button2Click(Sender: TObject);
    2022    procedure FormCreate(Sender: TObject);
    2123    procedure FormDestroy(Sender: TObject);
     
    4345  N: TDynamicNumber;
    4446  Line: string;
     47  NewItem: TListItem;
    4548begin
    46   Memo1.Clear;
    4749  try
    4850    N := TDynamicNumber.Create;
     51    ListView1.BeginUpdate;
     52    ListView1.Clear;
    4953    for I := 0 to 16 do begin
    5054      N.Stream.Size := 0;
     
    5458      for J := 0 to N.Stream.Size - 1 do
    5559        Line := Line + IntToStr(Integer(N.Stream.ReadBit));
    56       Memo1.Lines.Add(Line);
     60      NewItem := ListView1.Items.Add;
     61      NewItem.Caption := IntToStr(I);
     62      NewItem.SubItems.Add('');
     63      NewItem.SubItems.Add(Line);
    5764    end;
    5865  finally
     66    ListView1.EndUpdate;
     67    N.Free;
     68  end;
     69end;
     70
     71procedure TMainForm.Button2Click(Sender: TObject);
     72var
     73  I: Integer;
     74  Count: Integer;
     75  Parts: array of Integer;
     76  PartIndex: Integer;
     77  MaxValue: Integer;
     78  J: Integer;
     79  Line: string;
     80  NewItem: TListItem;
     81  N: TDynamicNumber;
     82begin
     83  Count := 1;
     84  SetLength(Parts, Count);
     85  try
     86    N := TDynamicNumber.Create;
     87    ListView1.BeginUpdate;
     88    ListView1.Clear;
     89    for I := 0 to 1000 do begin
     90
     91    // Write
     92    N.Stream.Size := 0;
     93    for J := 0 to Count - 2 do
     94      N.Stream.WriteNumber(1, 1);
     95    N.Stream.WriteNumber(0, 1);
     96    for PartIndex := 0 to Count - 1 do begin
     97      if PartIndex > 0 then MaxValue := Parts[PartIndex - 1] + 1
     98        else MaxValue := 1;
     99      for J := MaxValue - 1 downto 0 do
     100        if ((Parts[PartIndex] shr J) and 1) = 1 then N.Stream.WriteNumber(1, 1)
     101          else N.Stream.WriteNumber(0, 1);
     102    end;
     103    NewItem := ListView1.Items.Add;
     104    NewItem.Caption := IntToStr(I);
     105    J := Floor(Log2(I)) + 1;
     106    NewItem.SubItems.Add(FloatToStr(1 - (J / N.Stream.Size)));
     107    Line := '';
     108    N.Stream.Position := 0;
     109    for J := 0 to N.Stream.Size - 1 do
     110      Line := Line + IntToStr(Integer(N.Stream.ReadBit));
     111    NewItem.SubItems.Add(Line);
     112
     113    // Increment value
     114    PartIndex := Count - 1;
     115    repeat
     116      Parts[PartIndex] := Parts[PartIndex] + 1;
     117      if PartIndex > 0 then MaxValue := 1 shl (Parts[PartIndex - 1] + 1)
     118        else MaxValue := 2;
     119      if Parts[PartIndex] >= MaxValue then begin
     120        Parts[PartIndex] := 0;
     121        PartIndex := PartIndex - 1;
     122        if PartIndex < 0 then begin
     123          Count := Count + 1;
     124          SetLength(Parts, Count);
     125          for PartIndex := 0 to Count - 1 do
     126            Parts[PartIndex] := 0;
     127          Break;
     128        end;
     129      end else Break;
     130    until False;
     131    end;
     132  finally
     133    ListView1.EndUpdate;
    59134    N.Free;
    60135  end;
Note: See TracChangeset for help on using the changeset viewer.