VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "cJpeg"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False

Option Explicit
   Option Base 0
   
   'Class Name:   cJpeg.cls  "JPEG Encoder Class"
   'Author:       John Korejwa  <korejwa@tiac.net>
   'Version:      0.9 beta  [26 / November / 2003]
   '
   '
   'Legal:
   '        This class is intended for and was uploaded to www.planetsourcecode.com
   '
   '        This product includes JPEG compression code developed by John Korejwa.  <korejwa@tiac.net>
   '        Source code, written in Visual Basic, is freely available for non-commercial,
   '        non-profit use at www.planetsourcecode.com.
   '
   '
   'Credits:
   '        Special thanks to Barry G., a government research scientist who took an interest in my
   '        steganography software and research in late 1999.  I never met Barry in person, but he
   '        was kind enough to buy and mail me a book with the ISO DIS 10918-1 JPEG standard.
   '
   '
   'Description:  This class contains code for compressing pictures, sampled via hDC, into
   '              baseline .JPG files.  Please report any errors or unusual behavior to the email
   '              address above.
   '
   'Dependencies: None
   '
   
   'JPEG Marker Constants                (Note: VB compiler does not compile unused constants)
   'Non-Differential Huffman Coding
   Private Const SOF0    As Long = &HC0& 'Baseline DCT
   Private Const SOF1    As Long = &HC1& 'Extended sequential DCT
   Private Const SOF2    As Long = &HC2& 'Progressive DCT
   Private Const SOF3    As Long = &HC3& 'Spatial (sequential) lossless
   'Differential Huffman coding
   Private Const SOF5    As Long = &HC5& 'Differential sequential DCT
   Private Const SOF6    As Long = &HC6& 'Differential progressive DCT
   Private Const SOF7    As Long = &HC7& 'Differential spatial
   'Non-Differential arithmetic coding
   Private Const JPG     As Long = &HC8& 'Reserved for JPEG extentions
   Private Const SOF9    As Long = &HC9& 'Extended sequential DCT
   Private Const SOF10   As Long = &HCA& 'Progressive DCT
   Private Const SOF11   As Long = &HCB& 'Spatial (sequential) lossless
   'Differential arithmetic coding
   Private Const SOF13   As Long = &HCD& 'Differential sequential DCT
   Private Const SOF14   As Long = &HCE& 'Differential progressive DCT
   Private Const SOF15   As Long = &HCF& 'Differential Spatial
   'Other Markers
   Private Const DHT     As Long = &HC4& 'Define Huffman tables
   Private Const DAC     As Long = &HCC& 'Define arithmetic coding conditioning(s)
   Private Const RSTm    As Long = &HD0& 'Restart with modulo 8 count "m"
   Private Const RSTm2   As Long = &HD7& 'to 'Restart with modulo 8 count "m"
   Private Const SOI     As Long = &HD8& 'Start of image
   Private Const EOI     As Long = &HD9& 'End of image
   Private Const SOS     As Long = &HDA& 'Start of scan
   Private Const DQT     As Long = &HDB& 'Define quantization table(s)
   Private Const DNL     As Long = &HDC& 'Define number of lines
   Private Const DRI     As Long = &HDD& 'Define restart interval
   Private Const DHP     As Long = &HDE& 'Define hierarchical progression
   Private Const EXP     As Long = &HDF& 'Expand reference components
   Private Const APP0    As Long = &HE0& 'Reserved for application segments
   Private Const APPF    As Long = &HEF& '  to Reserved for application segments
   Private Const JPGn    As Long = &HF0& 'Reserved for JPEG Extentions
   Private Const JPGn2   As Long = &HFD& '  to Reserved for JPEG Extentions
   Private Const COM     As Long = &HFE& 'Comment
   Private Const RESm    As Long = &H2&  'Reserved
   Private Const RESm2   As Long = &HBF& '  to Reserved
   Private Const TEM     As Long = &H1&  'For temporary use in arithmetic coding
   
   'Consider these arrays of constants.
   'They are initialized with the class and do not change.
   Private QLumin(63)    As Integer 'Standard Luminance   Quantum (for 50% quality)
   Private QChrom(63)    As Integer 'Standard Chrominance Quantum (for 50% quality)
   Private FDCTScale(7)  As Double  'Constants for scaling FDCT Coefficients
   Private IDCTScale(7)  As Double  'Constants for scaling IDCT Coefficients
   Private ZigZag(7, 7)  As Long    'Zig Zag order of 8X8 block of samples
   
   'API constants
   Private Const BLACKONWHITE    As Long = 1 'nStretchMode constants for
   Private Const COLORONCOLOR    As Long = 3 '  SetStretchBltMode() API function
   Private Const HALFTONE        As Long = 4 'HALFTONE not supported in Win 95, 98, ME
   
   Private Const BI_RGB          As Long = 0
   Private Const DIB_RGB_COLORS  As Long = 0
   
   'Variable types needed for DIBSections.
   Private Type SAFEARRAYBOUND
   cElements         As Long
   lLbound           As Long
End Type
Private Type SAFEARRAY2D
cDims             As Integer
fFeatures         As Integer
cbElements        As Long
cLocks            As Long
pvData            As Long
Bounds(0 To 1)    As SAFEARRAYBOUND
End Type
Private Type RGBQUAD
rgbBlue           As Byte
rgbGreen          As Byte
rgbRed            As Byte
rgbReserved       As Byte
End Type
Private Type BITMAPINFOHEADER
biSize            As Long
biWidth           As Long
biHeight          As Long
biPlanes          As Integer
biBitCount        As Integer
biCompression     As Long
biSizeImage       As Long
biXPelsPerMeter   As Long
biYPelsPerMeter   As Long
biClrUsed         As Long
biClrImportant    As Long
End Type
Private Type BITMAPINFO
bmiHeader         As BITMAPINFOHEADER
bmiColors         As RGBQUAD
End Type

'API needed for creating DIBSections for sampling and pixel access.
Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hDC As Long) As Long
Private Declare Function CreateDIBSection2 Lib "gdi32" Alias "CreateDIBSection" (ByVal hDC As Long, pBitmapInfo As BITMAPINFO, ByVal un As Long, lplpVoid As Long, ByVal handle As Long, ByVal dw As Long) As Long   'lplpVoid changed to ByRef
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hDC As Long, ByVal hObject As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function DeleteDC Lib "gdi32" (ByVal hDC As Long) As Long
Private Declare Function VarPtrArray Lib "msvbvm60.dll" Alias "VarPtr" (Ptr() As Any) As Long
Private Declare Function SetStretchBltMode Lib "gdi32" (ByVal hDC As Long, ByVal nStretchMode As Long) As Long
Private Declare Function StretchBlt Lib "gdi32" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (lpvDest As Any, lpvSource As Any, ByVal cbCopy As Long)

'Custom variable types used for this JPEG encoding implementation
Private Type QUANTIZATIONTABLE
Qk(63)            As Integer 'Quantization Values
FScale(63)        As Single  'Multiplication values to scale and Quantize   FDCT output
IScale(63)        As Single  'Multiplication values to scale and DeQuantize IDCT input
End Type
Private Type HUFFMANTABLE
BITS(15)          As Byte    'Number of huffman codes of length i+1
HUFFVAL(255)      As Byte    'Huffman symbol values
EHUFSI(255)       As Long    'Huffman code size for symbol i
EHUFCO(255)       As Long    'Huffman code      for symbol i
MINCODE(15)       As Long    '
MAXCODE(15)       As Long    'Largest code value for length i+1
End Type
Private Type COMPONENT
Ci                As Long    'Component ID                       [0-255]
Hi                As Long    'Horizontal Sampling Factor         [1-4]
Vi                As Long    'Vertical   Sampling Factor         [1-4]
Tqi               As Long    'Quantization Table Select          [0-3]
data()            As Integer 'DCT Coefficients
End Type

Private PP            As Long    'Sample Precision [8, 12]
Private YY            As Long    'Number of lines             [Image Height]
Private XX            As Long    'Number of samples per line  [Image Width]
Private Nf            As Long    'Number of components in Frame

Private HMax          As Long    'Maximum horizontal sampling frequency
Private VMax          As Long    'Maximum vertical   sampling frequency

Private m_Data()      As Byte    'JPEG File Data
Private m_Chr         As Long    'Current Character in m_Data
Private m_Ptr         As Long    'Byte index in m_Data
Private m_Bit         As Long    'Bit  index in m_Chr

Private m_Block(7, 7) As Single  'Buffer for calculating DCT

Private QTable(3)     As QUANTIZATIONTABLE  '4 Quantization Tables
Private HuffDC(3)     As HUFFMANTABLE       '4 DC Huffman Tables
Private HuffAC(3)     As HUFFMANTABLE       '4 AC Huffman Tables
Private Comp()        As COMPONENT          'Scan Components

Private m_Quality     As Long
Private m_Comment     As String

'========================================================================================
   '              D I S C R E T E   C O S I N E   T R A N S F O R M A T I O N
   '========================================================================================
   Private Sub FDCT()
   Static t0   As Single 'Given an 8X8 block of discretely sampled values [m_Block(0-7, 0-7)],
   Static t1   As Single 'replace them with their (scaled) Forward Discrete Cosine Transformation values.
   Static t2   As Single '80 (+64) multiplications and 464 additions are needed.
   Static t3   As Single 'Values are scaled on output, meaning that each of the 64 elements must be
   Static t4   As Single 'multiplied by constants for a final FDCT.  These final constants are combined
   Static t5   As Single 'with Quantization constants, so a final 64 multiplications combine the
   Static t6   As Single 'completion of the FDCT and Quantization in one step.
   Static t7   As Single
   Static t8   As Single
   Static i    As Long
   
   For i = 0 To 7                  'Process 1D FDCT on each row
      t0 = m_Block(i, 0) + m_Block(i, 7)
      t1 = m_Block(i, 0) - m_Block(i, 7)
      t2 = m_Block(i, 1) + m_Block(i, 6)
      t3 = m_Block(i, 1) - m_Block(i, 6)
      t4 = m_Block(i, 2) + m_Block(i, 5)
      t5 = m_Block(i, 2) - m_Block(i, 5)
      t6 = m_Block(i, 3) + m_Block(i, 4)
      t7 = m_Block(i, 3) - m_Block(i, 4)
      
      t7 = t7 + t5
      t8 = t0 - t6
      t6 = t6 + t0
      t0 = t2 + t4
      t2 = (t2 - t4 + t8) * 0.707106781186548   'Cos(2# * PI / 8#)
      t4 = t1 + t3
      t3 = (t3 + t5) * 0.707106781186548        'Cos(2# * PI / 8#)
      t5 = (t4 - t7) * 0.382683432365091        'Cos(3# * PI / 8#)
      t7 = t7 * 0.541196100146196 - t5          'Cos(PI / 8#) - Cos(3# * PI / 8#)
      t4 = t4 * 1.30656296487638 - t5           'Cos(PI / 8#) + Cos(3# * PI / 8#)
      t5 = t1 + t3
      t1 = t1 - t3
      
      m_Block(i, 0) = t6 + t0
      m_Block(i, 4) = t6 - t0
      m_Block(i, 1) = t5 + t4
      m_Block(i, 7) = t5 - t4
      m_Block(i, 2) = t8 + t2
      m_Block(i, 6) = t8 - t2
      m_Block(i, 5) = t1 + t7
      m_Block(i, 3) = t1 - t7
   Next i
   
   For i = 0 To 7                   'Process 1D FDCT on each column
      t0 = m_Block(0, i) + m_Block(7, i)
      t1 = m_Block(0, i) - m_Block(7, i)
      t2 = m_Block(1, i) + m_Block(6, i)
      t3 = m_Block(1, i) - m_Block(6, i)
      t4 = m_Block(2, i) + m_Block(5, i)
      t5 = m_Block(2, i) - m_Block(5, i)
      t6 = m_Block(3, i) + m_Block(4, i)
      t7 = m_Block(3, i) - m_Block(4, i)
      
      t7 = t7 + t5
      t8 = t0 - t6
      t6 = t6 + t0
      t0 = t2 + t4
      t2 = (t2 - t4 + t8) * 0.707106781186548   'Cos(2# * PI / 8#)
      t4 = t1 + t3
      t3 = (t3 + t5) * 0.707106781186548        'Cos(2# * PI / 8#)
      t5 = (t4 - t7) * 0.382683432365091        'Cos(3# * PI / 8#)
      t7 = t7 * 0.541196100146196 - t5          'Cos(PI / 8#) - Cos(3# * PI / 8#)
      t4 = t4 * 1.30656296487638 - t5           'Cos(PI / 8#) + Cos(3# * PI / 8#)
      t5 = t1 + t3
      t1 = t1 - t3
      
      m_Block(0, i) = t6 + t0
      m_Block(4, i) = t6 - t0
      m_Block(1, i) = t5 + t4
      m_Block(7, i) = t5 - t4
      m_Block(2, i) = t8 + t2
      m_Block(6, i) = t8 - t2
      m_Block(5, i) = t1 + t7
      m_Block(3, i) = t1 - t7
   Next i
End Sub

'================================================================================
   '                 H U F F M A N   T A B L E   G E N E R A T I O N
   '================================================================================
   Private Sub OptimizeHuffman(TheHuff As HUFFMANTABLE, freq() As Long)
   'Generate optimized values for BITS and HUFFVAL in a HUFFMANTABLE
   'based on symbol frequency counts.  freq must be dimensioned freq(0-256)
   'and contain counts of symbols 0-255.  freq is destroyed in this procedure.
   Dim i              As Long
   Dim j              As Long
   Dim k              As Long
   Dim n              As Long
   Dim V1             As Long
   Dim V2             As Long
   Dim others(256)    As Long
   Dim codesize(256)  As Long
   Dim BITS(256)      As Long
   Dim swp            As Long
   Dim swp2           As Long
   
   For i = 0 To 256  'Initialize others to -1, (this value terminates chain of indicies)
      others(i) = -1
   Next i
   freq(256) = 1     'Add dummy symbol to guarantee no code will be all '1' bits
   
   'Generate codesize()   [find huffman code sizes]
   Do 'do loop for (#non-zero-frequencies - 1) times
      V1 = -1                            'find highest v1 for      least value of freq(v1)>0
      V2 = -1                            'find highest v2 for next least value of freq(v2)>0
      swp = 2147483647 'Max Long variable
      swp2 = 2147483647
      For i = 0 To 256
         If freq(i) <> 0 Then
            If (freq(i) <= swp2) Then
               If (freq(i) <= swp) Then
                  swp2 = swp
                  V2 = V1
                  swp = freq(i)
                  V1 = i
               Else
                  swp2 = freq(i)
                  V2 = i
               End If
            End If
         End If
      Next i
      If V2 = -1 Then
         freq(V1) = 0 'all elements in freq are now set to zero
         Exit Do      'done
      End If
      freq(V1) = freq(V1) + freq(V2)     'merge the two branches
      freq(V2) = 0
      codesize(V1) = codesize(V1) + 1    'Increment all codesizes in v1's branch
      While (others(V1) >= 0)
         V1 = others(V1)
         codesize(V1) = codesize(V1) + 1
         Wend
         others(V1) = V2                    'chain v2 onto v1's branch
         codesize(V2) = codesize(V2) + 1    'Increment all codesizes in v2's branch
         While (others(V2) >= 0)
            V2 = others(V2)
            codesize(V2) = codesize(V2) + 1
            Wend
            Loop
            
            'Count BITS  [find the number of codes of each size]
            n = 0
            For i = 0 To 256
               If codesize(i) <> 0 Then
                  BITS(codesize(i)) = BITS(codesize(i)) + 1
                  If n < codesize(i) Then n = codesize(i)    'Keep track of largest codesize
               End If
            Next i
            
            'Adjust BITS  [limit code lengths to 16 bits]
            i = n
            While i > 16
               While BITS(i) > 0
                  For j = i - 2 To 1 Step -1        'Since symbols are paired for the longest Huffman
                     If BITS(j) > 0 Then Exit For  'code, the symbols are removed from this length
                  Next j                            'category two at a time.  The prefix for the pair
                  BITS(i) = BITS(i) - 2             '(which is one bit shorter) is allocated to one
                  BITS(i - 1) = BITS(i - 1) + 1     'of the pair;  then, (skipping the BITS entry for
                  BITS(j + 1) = BITS(j + 1) + 2     'that prefix length) a code word from the next
                  BITS(j) = BITS(j) - 1             'shortest non-zero BITS entry is converted into
               Wend                                  'a prefix for two code words one bit longer.
               i = i - 1
               Wend
               BITS(i) = BITS(i) - 1                  'Remove dummy symbol code from the code length count
               
               'Copy BITS and HUFFVAL to the HUFFMANTABLE  [HUFFVAL sorted by code length, then by value]
               With TheHuff
                  For i = 1 To 16
                     .BITS(i - 1) = BITS(i)
                  Next i
                  k = 0
                  For i = 1 To n
                     For j = 0 To 255
                        If codesize(j) = i Then
                           .HUFFVAL(k) = j
                           k = k + 1
                        End If
                     Next j
                  Next i
               End With
               
            End Sub
Private Sub ExpandHuffman(TheHuff As HUFFMANTABLE, Optional MaxSymbol As Long = 255)
   'Given a HUFFMANTABLE with valid BITS and HUFFVAL, generate tables for
   'EHUFCO, EHUFSI, MAXCODE, and MINCODE so the table may be used for compression
   'and/or decompression.  In JPEG, MaxSymbol is 255 for an AC Huffman Table.  For
   'DC Tables, MaxSymbol is 11 for PP=8 bit precission, or 15 for PP=12 bit precission.
   Dim i          As Long 'Index for BITS
   Dim j          As Long 'Index for HUFFVAL
   Dim k          As Long 'Index for last HUFFVAL of length (i+1)
   Dim si         As Long 'Huffman code size  ( =2^i )
   Dim code       As Long 'Huffman code
   Dim symbol     As Long 'Huffman symbol
   
   With TheHuff
      
      For i = 0 To 255
         .EHUFSI(i) = 0      'Clear existing values so we can
         .EHUFCO(i) = -1     'check for duplicate huffman symbols
      Next i
      
      j = 0
      si = 1
      code = 0
      For i = 0 To 15
         k = j + .BITS(i)
         If k > 256 Then Err.Raise 1, , "Bad Huffman Table" 'more than 256 symbols
         If j = k Then 'no codes of length i+1
         .MINCODE(i) = j - code
         .MAXCODE(i) = -1
      Else
         .MINCODE(i) = j - code
          m_Block(4, ite huffman    'i e HUFFM - ,st1odesiz(= 0 To 7                 HDC& 'Define numbe   i    'i e Ht1odesiz(= 0 7an sybional MaxSy'DefiIisDV
nS  D , "Bad Huffman Table ate QChrom(63)    As IntegmPm   'a    As IntegmPm  5Ht1odesionB(63) DlNt3
   = j -    ) = -irR i = 1  -  
   Wiman imMlsionB(6 Gbe QC '
   Dimmmmmmments mustindesion9uffman symw   uman imMn symw   uma1  For
     ionisDV
nS  D ,  iteuff
   Wiman imMlsioDV
 rWhi, " ,  iteuff
   W.V
 rWhi, " , irR i = 1  -  
   Wsiiiiiizuefek rWhi, i 1  -mNh7niteuff
   W st i 1  -mNn              
             6srvrG i 1LrvrS entrs mi3tineip   W st i 1  -mNd If
  For
1)>0
n        a.5gXkax        ulating DCC  etmi3t r
1      0
      si ovrG i 1LrvrS entrs m===  aS entrs entrs e i 1LrvrS ent eni
   Dimmmmm16 eni
   Dimmm_Blo     
   Dimmmmm    As Long
HADimables, MaxSymbol is 11 for PP=8 bit precission, or 15 fogbit p mmmm    As Long rge t   c L E   G E N E R A T I O N
 c i -h
       x Long varia d As Long rge     fogbo x Long varia d move dummy symnI O N
 c      6srvrG i 1LrvrS enXch
  7 rg2UBting values so we ca, "Bad Hufession.  In2ortant  a, "B 1 iiQ p enXch
V j -    ) = -irR i = 1 Aission, or 15 fogbi k = jk(6, iNdE   G E N E R6D e -irRn,Il=
       GnXchE so tIo R6D e -ir   Gn7ai) = r8Ei k = jk(6, iNdE   G 1rD_^i )
JlvaluesD e -idE   G 1rDSeo0i+         = m_iirrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrl m_iirrrrrrMsrrrrrrrr
   Dimsrrrl m_iirrrrrrMsrrrrrrrr
   Dirrrrrrrrrra.5gXkax        u+',les for
   'EHUFCO, E2   m vpi)
      t1 = m,   m_rrremsrrrjcu0rrrrra.5gXkax       k = 4rrrrrrra.5gXkdFCO, E2   m vpi)ode size  ( CO, Ec      'and/or dec)m m_ii5no zero
         Exit Do      'd = m,   m_r   ITS(Atr   ?"vrS enXt9= m,   m_r   DiIgbo x Long varm,   m_r   D
          "vrSo2x6freq(VhDh=A) = BITS(i)
 uo2x6freq(VhDh=
     DiD e -idE   G msrr  st ]v
   )7ir   Gn7aXw tXw B  G 1rD_^i )
JlvaluesD @rnaxSymbol is 11 E   G msrr  st ]vm_Block(1,ppppppiamboRnbles eV
 rWhi, "ss 1D FDCT on each columRs 11rvrG?6        u+',les for
   'EHUFCyTI'   '    bles eV
 es eV
 es eVI-h
       x Long       g    'Count BITS  5'   eN'   desEaaaaaaaaaaaaaaaaa "Bad Hufession.  (      g    'Count BITS  aluon.  (   laluon.  (   laluon. RDulaluon. RDulaluon. RDu   End With
            r   lar   lar   lar   1LrvrS entrs2o cow6Du   End Wibi, "ssfRtr
   'EHUFCO, E2  .HU  var   lar   lar   1LrvrS entrs2o cJ
ct D6^^^^^^^^^^^= m   1Lrv G 1rD_^i )
nDAnHU  var      rD_^4i  rD_ luon. RDulaC      Wend nr   lar   tgct D6^^^^^^^h3i
  i> 0 ThennleE      "vrn. RDunDAhe ttttttttVO, p9lhennm^^^^^^^h3iers(256)    As Long
   Dim cogAi@E      ocwn seh a tBLrv G 1 vpi)o   'IncrehenYBhis JPEhtttVO,A7aiB4n. RDulaC     tDD.= t6 + tYf blocg
H          If BITS(unctio8ni
 '     #r  -mNd 1 vpE es ch5t  rD_^4i ii8'     #r  -mNd  #r  -mNd  #r  -mNd  #r  -mNd  #r  g)mNddddddddBITS  aluonimlu Msrr4giision.  (      g   u====n.^^^^56)  lD6^^^^^ Di]r   )    TS    A,s Long
  aluonimlu Nd  #r  9,ccX )  +7n/SbDh3i^^^ Di===n.^^^^56)  lD6^^^^^ Di]r   )    TS    A,s Long
  a #rVi  9,6freq(VhDh=
Dimmh s
   Rsrrrrrrrr
   Dirrrrrrrrrra.=^^^C     t 1DirS entrorra.=^^^C     t 1Dix8 bit precis lrr  -mNd  #r  g)mNddddddddBITS  al=^^^a "Bad Hufession.  (      g  g)mNddddddddBI5) = 0      'Clear- D ,  1d Hufession.  (     7Vi  9,6frecI5)  lar  o'l p g  g)mNddddddddBILrvrS]req(V pIClearE D ,  1d Hufession.  (0W3   WpO1^^^) = t5 ong       ge
           = t5 oni]req(VNiv
   )7ra.=^^^Vi  9,60ion.  (0W3 1 33   Wv sleast value o2nip^^56Mi = 1 To 'gGp[ong  p gbsc  g  size"and t   'Kenoi.size"and t   'Kenoi.size"and t   'Ken lbb4rm,  1Ez0Dimmm e  (    a d move da,af(iron.  (1 To n
     'Dgl Ond nv
   )BA=are  TS     i = l  ge
     )BA=are nn.  (1 To n
                   CV0    fr4ego7rr
   Dir            CV06TIONTABLE
Qk(63)            Ase aS entrs entye            An6 trs e paire        CV0mmm e  (  oa d move da,af(iN 1Lrvo g  size Ase    As38 biI 4       A7n      An6 trs e e da,af(iBI5) = 0      'Clg  le si+Bad Hufession.  (      g  g)mNdd      A6cvl4]o    AnV  -Wlo,4)mNdd      A6cvl4]o    AnV  -Wlo,4)mNdd      A6cvl4]o   iBoa(k) = j
     rrrrrrrrrrrl m_iirrrrrrMsrrrrrrrr
   Dimsrrrl m_iirrrrrrMsrrrrrrrr
   Dirrrrrrrrrra.5gXkax    ITS(   Dirrrrrrrrrra.5gXkac)sndex for last HUF     AnVrrrr56c26onieC
  dBITS  a638 - t5          r]req(VNivid Hufession.  (    syVal nevid p)mNdddddddfr5  size I
    dBITo s
  v(
            r   ,b x Long vaTo Ission.  (       Long    ixu.  (    sy    ia,(freq(isssssslrMsrr
   Rsrrrrrgbo x Lo Ii.o s
  v(
      Long    ixiiii Ndn(TheHuff .  ('c(freq(isssFan symr ia,dfun(T0iir7eorivate YY         S(  c0-c4n.  rrrgbo x Lo Iarrr562o0-c4nC andesDV
nS  D ,  iteufIi6tKi  ixiiii Ndn(s e e da,af(iBioY D ,  i(lvaluahers         S(  cptiosmus
  v     irR i = 1 Aission, or 15 fogbi k = jk(6eon..e-c.it D6^^^^^^^h3i
  i> 0 Theni(lva   irR i^h3idex 0 Theni(lts
  v     irR i  irR oB  W st i 1  -mNd hi, i
gts
dexNdn(
Private Nf            As Long   sNdn&verrgb x Lo Idddfr5 BxNdn(
li
gts
dexNdn(
PrivB            As d nrle typ6eon..e-c.it D6rle typ6eon..e-ctVO, p9lhennm^^^^^^^gddfe typ6eon..e-ctVO, 3idex 0 Then^^^^^1 33   Wvhe pair, 1tVO, rrr'is class is class igcode
. RDu  ^^^1 end muff .  ('c(freisss[FzaE9yd..e'is clze(2s i  tass igcode
. j   mCO     move da,af(iron.  (1 To n
  loH,?B  W st i 1  -ms.e'is clznWPaFCO, n6
    -ms.e'is clznWPaFCO, n6
    -ms.e'is MairR oB  W stttttt7MBCs e -irRn,Il=
  e116   -t (1Con..e-c.it D puA6
    -ms.e'is MairR oBJSb) 1(Ois class is class igcode
. RDu cIncrehenYBhis JPEhttt.it D irR o'Dgl Ond nv
  i         4Yspm   33  62o0S         4Ysph3inhttt.itvB   T v     irR66g -mNd  #r  g)mellass igcode
. RDu . gkgth,..eir   deeeeee 
 . gkgth,..eir  shttt rI76(at6onieC
  dBImns1d
. RIi-mNd 
. RIi-mNd 
. 
. RDu cIncrehenYde RIiuM
. RIi-mNd 
. H"P9 deeeeee 
 . gkgth,.mNd 
.        ioc1g -abP9 de#  . gkgt6LlQmNd 
#8Nd 
. gRIiuM
. RIi-le(1Con. 
#uvalspmpgkgthoG
.        iN r   s   k+^561lbBthoG
.        iN r   s   k+^561lbBthoG
. >     1D irR o'Dgl Ond nv
  i   eeeee F values so wei         en
  lu,er line  [ImN6ei         en
ESFM.gienYBhfor PPPPPPPPPnivB           ak't cine  [ImN6ei      O    en
  lu,er liM,xli        s e1r liM,xli   2cine  [ImNcweon..e-ctVO, 3idex 
gkgth,.mNd 
.PPPPPPPPnivBof symbols lxlilla   If   g6rbtmNcws lxlilla   If   g6rbtmNcws lxlill D irR ot-^^^^^  e,xli   2ci( g 
gkde  [
Alg c    g6rbtmNcws lxlill D irR ot-^^^^^  e,xli   2ci( g 
gkde  [
Alg c    g6rbtmNcws lxlill D irR ot-^^^^^  e,xli   2ci( g 
gkde  [
Alg c    g6rbtmNcws lxlill D irR ot-^^^^^  e,xli   2ci( g 
gkde  [
Alg c    g6rbtmNcws lxlill D irR ot-^^^^^  e,xli   2ci( g 
gkde   2ci( ], otjs1n 2cii( g 
-abP9 de#  . girrrrrrrrrra.5gXkax    rR ot-^^^^^B   oiteuff
 diode   2ci( ],  g6 de g 
ggggggggggggl= u.Nt3
 yde   2ci( ],  g6 de g 
ggggggggggggl= u.Nt3
 yde   2ci( ],  g6 de g 
ggggggggggggl= u.Nt3
 yde   2ci( ],  g6 de g 
ggggggggggggl= u.Nt3
 yde   2ci(ctVOu E N E ows lxlihDh=A)iM,xli        s e1r l t3
 yde   2ci( ],  g6 de g     og2o    AnV  -Wlo,4)mNHuff
 4ggggggg  v     ii     W3r 15 fdH fr5  size I
 lb   2c 2.fdH fmmm,fmmm,f 1gahm1B     s1
 eo,   O -Wloi   ii    IRii( g 
-abP9 de#  . girrrrrrrrrra.dH fmmd 
#89yd@mqUFSI, M g6rbtmNcws lxlill D  M g6rbtmNcws lxlill D .[. girrrbtmNc D  M g6 e1Con. nws lxlillc.im_BlM g6rbtmNr liM,tBliM,tBllM ySGGGGGGriM,tBliM,tBllM ySGGGGGlM ySvi   i da  u+',les value o2niptBllM ySGGGGGGrg6 e LongBV2u'E4gBliM,t0s gth,.GGrg6 e LongBV2u'E4gBliM,t0s gt  DiIgbo x Lon..e'is clze(,t0s gt-  
  th,.GGrg6 e LongBVt2u'E4g,,t0s ovet mCBVt2u'ES
 D)))))  lvs ovet mCBVt2u'ES
 D)))))  lvs ovet.GGr  DiS  br8So2x6n= -1iiiiiiilill D irR ot-^^^^anch
      "ee5mNcwslliM,tBliM,tBlclze(,tpBV2iM,tBliM,tBlclze(,tpBV2iM,tBliM,tBlclze(,tpBV2 _^iIejI #r  -mNd  #i
Alg c   ( g 
gkde  [
8liM t BliM,tNCODE(i
gkde  [
8liM t Bencies  [
C) W sde     )fr  btmNr''is clze(,t0sKDh=
.=^^^C     t 1D   [
gl= uQis clze(,trxiO
8liM ck(lount BITS  5' 9ler  btmNh   c    ?  u==lx.GG [
gl S  5' 9ler  btmNh   c    Ts  u==l   iabe(,trxion.  (   bl yde   abe(,trxion.ck(lot3
 ydockpe    3h5l yd1"pn6I    mmmmm vrBsssssslrMsrr
   Rsrrrr D irR ot-^^^rrrrrrrrrrrrOunt BITS  5' 9ler  btm E "ee5mNcwslliM,tBliM,k1   PQ
 SSam16 eni
   Dimmm_Blo     
6y6psi
gkdnrrrrrrrrrOunt BIcis clze(2s irrrrdi3RM,tBliM,k1 Q
 SSaDimmm_Blo     gle '  i    CSSSaDimmm_Bes ireE N g rrrra.dH 6 e Loetio8e
   Rsrrrr D irRdi3RM,tBliM,k1 Q
 SSaDiKenoi.h e1ri, rR ot-^^^^^ 1,,t0s ovet mCBleddddddddddddn- t0
   bg rrrra.dH 6 e .t Q
 SSaDiKenoiLddn   t   ' paire        CV0mmm e  (  oa d ira.dH iZtmNh   (  oa d  ira.m e  (  oa dre       otrrrrr Tablesiory 1111111111Nsi
fnV  -Wlo,4)mNHuff
lch
i3m e  (  oa dre  vf
l3  vf  vf efek ry 111s3o    CV0GM ef ^  e,xli   2civf mNHuc0GM ef ^  e,x.FL  (I ir f efeWlol3  R og cs oaeufIi6tKi  ixi^  eQ   Dirro    y 1111t0GM ef ^  e,x.FL  (I ir f efeWlol3  yol3  f^  e,x.0      CV0mmm e  (  oa d ira.i^  eQ   DirroSe ^  eir  d ira.i^t^  e,_4iFL  (Iy5c0GM ef 'r          hzprtpBVDirroSe ^  eir  d ira.o5 otrrrrr Taorng 'Huffman s       troSe ^ ai4ie  ( rz,4)mNHuff
l-uWVO, pieCI5em.3  R 'io0
   O5 otrrrrr TgDrr D irR ot7r1fIi6tLo0
   O  6 e Loetio8e
   Rsrrrr D irRdifode, the sc=====,VrL 1        irRdifod9tioa dre  vf




arro  0eod     i7 D irRdifode, the sc=====,VrL 1:F5mNcwslliM,tBliM,k1   PQ
 SSam16 eni e1Con. nws lxlilR1i4ie  ( rz,4)mNHu 'i 8aBith valid BG 1rD_h valjbStec5,4)mNHWOz,4)mNHu 'i 8BJSb) 1(Oik1   PQ
 SD irF  i7 D irRdxget.ouc0GM ef ^  e 'i  eStec5,4os c8BJSboa dr Ta4os cStec5,4)DirroP^           x length) 'i rrrrli4ie  ( rz,4)mH   h) 'i Q(= iWVO, pieCI5em.3  R 'i Q(= iWVO, pieCI5em.NHu 'i 8BJSb)V R 'i Q(= iWVO, pieC  ^^^1 end muf      swp2 = 214IcipieC  ^^^1 end , pieCI5em.NHu 'i 8BJSb)V R 'i Q(= iWVO, pieC  ^^^1 e7swp2 = 214IcpiteStec5, erliiiiiim'.45'  iWVO, pieffff1ieC  ^^^1 eV>1 eV>1 eViiR7r1fIi6tLoetey  egt  DiIgbo pieC  ^^riSMJVO,  'i 8rrrrra.dH fmmda,af(,C
   O(lot3
 ydoc = cis ct  Dkuffrrrrrrrrrrr  bg rrrraWroeteyccBblssssss)rr  brrrrroDirWiIgboooooooooooooosfrbx6) oDirWiIgboooooooooooooo""""""""""""""""""M ef rd th,.GGrg6 e LongBVt2uogBVt2uo ^  e,xs
    DirWiIgbooooooooooooxs
  u ,Bbx6) oDirWiIgboooooooooooooo""ee 
 nmLE(i) .4oooo21f60oooooooo"e* iIgboooooooooooQcnd t   'Ken Oi  G E N E R A T I'gboooooooooo    
6y6psi
gkdhhhhh 'i (booooooo(cnd t   'Ken OiLlQmNd 
#8Nd 
. gRIiueboomrr Dooooooot-^^   F 
6y6psb0GM i W = ci) oDirWiIa.dH fm44'  l421'i (booooooo(cn
. nt oooooot-^^eggggggg (booooooo(cn
. nitmrr 4sn5To(cn
. nt  tDV>1 su ent tttttVO, pEnuc0GM e65'B Nd 
. gRIiuebo44'  l421'i (booooooo(cn
. nt oooooot-^^eggggggg (boooooot PQesB^^egg (0W3   l) gRIilPt PQesB^^egg (0W3   l) gSnl-^^gkdhhhh o^gk )rr tooo"e* iIgerr tl14IcpLlu,ergienYBhfor  rrr hi@E  RQesB^^egg (0n..e-ctVO, 3idelWpmieerr tl14IcpLlu,erg  o^gIilPtny) AWEoo"e* iIg^^egerg 6y6pS AWEooa5lu,ergienYeg 6y6pS AWEooa14IcpLp ooooot-^^   F 
6y6psb0l(,tpBV2iM,tBli27 v"""""""P l4ooootb0l(,tjg  o^gIilPtny) AWEoo"V2 _^54ie  (g eggglPtny) AWEoo"V2 _^54ie  (g eggglPtny) AWEoo"V2 _^54i^ege8'iim e  (  oa dre   eStec5Jn^54Eoo"V2 _ ra   F 
6y6psb0GM i W = ci) oDi
6y6psb0GM  Te8'iim e  (  oQ oot PQesB-ol
6y6psb0s.e'is 5DafIilPtnyielu
q  g6eL- Uiim 8'iim e  (  oQ[ilPtnterliaeRbg rL- U(  oc6ic1.5   oQ oot PQeseg rLZ ot-^^ctVOrrrrrrOunt BIcis  nl   F 
6y6ps0DimT 0 Tiae(nl  
nDAnHU  s 1QesaUx.FL  (I ir f efeWggga(k))))))21'b'l.cndifod9tioa eQ ootsnt ooooootDimT   'sAefeWg ootss(I Ss lxlill D  MeWg o1W = c Dku(tVeG vflrRdi3RM,tBliM,k1 Q?,e'is 5Dz,4)mn
 SD irF  ss(I Ss lxlill* iIg'is 5D0ss(I S0 TrrrOuntjd( rLZ otttt ,tBlilrRdi3RM,tBliM,k1 Q?,e'isns0 TrrrOuntjd(fnV  ivrv  ivrv  ivrvWiIgbiiGa ny) AWEoo"e* iIg^^egetRsrrrr D irRdi3RM,tBliM,k1 Q
 SSaDiKenoi.h 4Ic irRdk1 Q
 SSaDiKeno(nl  Ib4rsrF  ss(I Ss lxlill* iIg'rgi SSaDiKeno(,mhISs Feno(ng
xlillcbM,tBl1cO   3 Dku( lxlillcdwRop AegetillcbM,tBl1cO   3 Dku( lxeAFenob5o(ng[yde5AnA egetillcbM, f efeWggga(k))))g, ByVlor14Ics lxla eddddddddddddn- t0
   bg rrrra.djNvAIDku( lxeAFenob5o( )g, ByVlor1   is]6a   DirroSe 74tfnob5o( )g, ByVlor1i    nob5osC  ^^^1 end muf8ByVA end muf8Bs]6a   o( )g e    nob5os/Ci6rbtmNcws lxlill D irR oM,tBliM,k1 Q?,ogzo1W = cmuf8Bs]6a   o( )gb0l(,tpBV2iM"gl S  52I,s lxlill D irR ggglP[ bo x liM,k1 Q?,ogzo1W = cmuf8Bs]6a   o( )gb0l(,
rF  sD irR ggglP[ botil Dr rr o2niptBllMgb0'tclze(2s i  ta(2stGrFgbiiGa ny) AWEoo"eNTABLE, OptllMgb0'tclze(2s i  ta(2stGrFgbiiGa ny) AWEoo"eNTABLE, OLege6tGrFgbiiGa ne6tGM,tApFejLE, OLege6tGrFgbex length) ' t0cPrBs]DDDDDDDDDDDat,iNr luBBBBBBBBBBBBBBBBBBBBBBB= 21lJ length-6P     CV0mmm e  (  e  (  e  aBs]DDDDDDDDDDDatcIoOp7 1D   [
gl= uDDDDDDDiBBB= 21lJ lenQ(= iWVOtcIirRdi3dg DCCCCCg[ydeCCCCCg[1
. nt oooooot-^^egB  o(4nt ooo(= iW'Opt1rD_h valjb s Z ot-^^ctom'-5o1dL6a  i-[1
. nth,.GGrg6 e   CV0mmm e  (es e  (esB^^^^^^^^^^^^+i-5o1(^^^+i   '-5o1dL6a  i-[1
. nth,.GGrg6 e   CV0mmm e  (es e  (esB^^^^^^^^^^^^+i-5o1(^^^+i   '-5o1dL6a  i-[1
i^  eQQQQbM, f efeWggga(k))))g, ByVlor14Ics l(^^^+i   '-5o1dL6etRsQictC.mn
ee,xsTudcn
. nt ooooooi SSaDiKenoi.h e1ri, rR ot-^^^^^ 1,MA7tGrFgbiiGa aciKeooooo"""a   i-[1
. ntggbiir

arPItLis i  ,=ncbM, f efe Hufession.  (  71irRdDiKo.i ry 111s3o    CV0GM ef ^oDDDDDDDD r

arPItLis i  ,=ncbM, f efe HufessionHl.GGrg6 e   I >bM,get.ouc0GM ef ^  e 'i  ebl )gb0l(, ^oD'ivf efe HufeS
. ntggbiir

 liM,k1 Q?,o ^^^^^^^^^^^llcivrv L sD irR ggglP[ botil Dr ouc0GM ef ^Q?,o( )g e    nob5os/Ci6rbtmNcws lxlilVelilVelilVilVelilVilVelilVilVelilVilVelilVilVelilVitLis ,tBliM,tBlclze(,tpBV2iM,tBlinniPsbtlI >BiM,k D irRdie '1( )g rc eVie '1( )g rc eV(c6ic1.5   oQ oot PQeseg rLZ ot-^^ctVOrrrrrrOunt BIcis  nl   F 
6y6ps0DimT 0 Tiae(nl  
nDAnHU iiGbiiCmT 0 Ti'u+1lcl.5   oQiCmT 0 Ti'ut't PQesB^^esctVOic1.ilVitPvnl  
nDAesB^a  i-[1
i^  eQQQQbM, f efeWggga(k))))gej rk))))))21'8Bs]6vSAgga(k))))gej U iiGbi'e(cn
.ooooooooooooooooIiGbilP[ botil Dr ouc0GM ef  t 'e(cn
.botil Dr oucze(Iej(cn
.oooooooooo-Uo ix(cn
.oooooooooo-Uo ix(cn
m6iGa ne6tGM,tcLoooo ix(cn
m, OLege6tG,Nc D tcLoooo ix(cn
m, Ouo ixl(, ^ode lcLoocEn m16o f6iGa ne6tGM,tcLoooo ix(cn
m, OL1 [ImNcweon._[1
i^E6pSve2l4e]ImNcwshiiiiiiiae(nl  
nD i7tGr>tGr>tGr>tGr>tGr>tGIotil Dr ou, pieCI5ema
E6pSve2tny r ou, pieCshmNc/ou, pieCI5e-Uooucze(Ierrrrx6ic1.5   oQ oot04enl  Gr>tGr>tGr>tGa .5  O ootDcwN.GGrg eet0[1
ie(cnnnnnnAPQeseg r
i^E6pooooo"""""""""PQeseg r
i^E6poooo i^E61
ie(eliM,k1   PQ
 SSam16 e-nnnAPQesm  o( )g e    nob5os/Ci6rbtmNcws lxlill D irR oM,tBvp1clp1cP(Ei7tPQeseg r
i^E6p))216Dr>tGL
.ooo    1cP(1cP(Ecri, rR ot-'mNcws lxli r
i^E  eir  d ira.o5 ooooootc>tGL
Hl.G(esB^EB:mNcws]6a  n
m, paBlio i^E2. oooooom, paBlio i^E2. oi   Wv sleast value o2nip, ^ode lcLoocEn m16o f6iGa ne6tGM,tcLoo-il Dr o0ode lcLoocIiGa ne6eil Dr o0odeocEn m16L.iooooy eseg t-'o-i Rsrrrr9NWiAsW^esctcle i^E2. oi  o0oAo0odeg thM,tcLoo-il Dr o0ode lcLoocIa thM,kBo0odeocEn m16L.iooooyiCh,kBo0odeocEn m16L.iooooooucze(Ierrrrx6ic1.5   oQl0000000000000000000x6ic1.5555555555]P    B(zbiMEn mend tiiiiiiiiiiiiii]ogzo1W = cmQese'er  efeWgggaB
opooooc,P    
tGMEEn m16L.iooooooucze(ugi==d tiwcpSEO V(c6ic1216Dr>Ceoi (boooooooe3CmT 0 IiGbilP[ botil0 Ti'u+1lcl.5   oQiCysb216ooooooe  i-[1
. ntheffff1lsI^esctVOic1.il0hne6tGM6a   IiGbilP[ bPmT 0 IlS26tGM6a   Ii S1lo ser GbilP[ bPPPPPPc t othefffre    IVnoC       ,tBli27 vihy6QUt555 6bilP[8efeWgggaB
opoooocnoC  g????o8hubnnl  
nDAcla7 vihy6QUt555 6bil8code lcLoocEn m160 IiGb]6a   o(c
   v_ee tGM6a   Iirrrrrra.=^^^C     t 1DirS entrorra.=^^^C     t 1Dix8 bit precis lrr  -mNd  #r  g)mNddddd, pieCshmrR ot-'BT=j m16L1, pieCshmrRi  Ii S1lo ser G6 piehmrRi    t2rsy8t q d, pism co sn ism co t2rs-'BT=j m16L1, s1(cn
m6iGa ne6tGM,Ga ne6tGM,Ga ne6 S m16L1,6
er G:,enl  un m160^^^llcivrv L sD irR ggglBli27 vihy6QUt555 6biBli27 . ggglP[ botpURc
.ooo5 6biB ij m16L1, sot-  y6Q sef ^ K   (1 To n
  ?gef ^ rar  aER S1lodlxli ri] netrorra.=^^^bit precis lrr SSSSSSSSSSSSSSSSSSSSSSS  %L(booooooo( T v MlilVilVeligBui0B  T=j m16L1, s1SSSSSSSSS m16L1- otpURBg MlilVilVeligBuecg16Lix(cn
m, Ouo ixl(, ^ode lcLoocEn m16o f6iGa nemmm e,tApFejLE, OLegedeecis lrr SSS,tApFp(cn
. nt oooooh5ij, ^ode lctApFpye . grouuuuuuuuuuuuuuuuuuu5ye . gr5e(booooooo( T v MlilE. grogr5e(b1Fp(cn
. nTpooo  Ii S1looooo( T v Mliy r hp  Iiguuuuuuu5ye . gr5etfS1looooo( T v Mliy wETpoouu5ye . gr5etfS1looonMcoooy ze(Ie3Eor1i    norrrrrOunt BIcicoooyY   no
ee,xsTYoooyY   no
ee,xsTYouuu5ye . gr5e(booooooo( T v MlilE. grogr5e(b1Fp(cm16L1, sot-  y6Q a noooyY   no
e(cm16nanS(i - 1) = BI . gr5e(boi
e(boooyY   tQ a noooyY   (cn
m, OL1 [Im. grgro  noooyY  h y r Ea ne6tGM,Ga ne6tGM,pe,x.0    oku( rOuntjdseg r
cgrgro  nsietfS1lo iIW rOuntjdseg ntrorrietfS1lotfS1   okuro  nsieBng ntrorrietfOunte nDAesB^s,pe,xae t-  y6Q sef ^ K   (1 15)_cn
rra.=^^^C      ^ rar  aER S1yY   tQ a 0xae ^^C  eQ sefn4e6Q serje,xae t-  y6Q sef ^ K   (1 15)_cn
rra.=^^^C      ^ rar  aER S1yY   tQ a 0xae ^^C  eQ sefn4e6Q serje,xae t-  y6Q sef ^ K   (1 15)_cn
rra.=^^^C      ^ rar  aER S1yY   tQ a 0xae ^^C  eQ sefn4e6Q serje,xae t-  y6Q sef ^ K   (1 15)_cn
rra.=^^^C      ^ rar  aER S1nMcIooooee,x.Legedeecis oi
e( 6O
C  eQ seocEnr gs'.IoOp7 1D   [
gli>tGr>tGs ^ raiE3 Dku( lxer1uiiseocEnr gs'.^ rai01xer1uii mDblC ot-^^ctom'-toedeecis lrr Sii mDblC ot-^^cS.ehn5 ci) oDi( lxImDblCs,pe,xae t-  y6Q se xER S1cpSEO V(c6ic]t-^^cS.ehn5 ci) oDi( lxISReeY   tQ a 0xae ^^^^^^^" -FrtpBVD mDb66666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666imT 0 Tiae(nl   66666 6a  f ^  oB ds  a   o(c
   va ooo,a6666666666666666666666666e66666666666imTDi  eQ sefn4e6Q sMcla7ooo YcTDi  eQ sefn4e6Q sIvIt1clgoots ooo,aaaa666666666666 y6pIt1clgoots ooo,aaaa sMcS entrs2o 44= sMcla7ooooooooooooooooooooooooSSSS m9i27 v"""""pIt1c(n0oooooooooj(cn
.u+s9a .5Tvvvvvvvvvvvvvvvvvvvvr5h i,5 ooo,xae tIDtom'-toedeecis lrre6Q sMclai.u+s9ao  PQ
o  PQ
o  PQ
o  PQ
o  PQ
o  alooj(cn
.u+s9Q
o  PQ
o  PQ
jNvAID6eDS.ehn5 ci) oDi( loRnbles eoo( T v MliyMi t-  ytloRn9nn m16L.  5carr GbiDoocEn m16o f6iGa ne6tGM,tcLosn m1e1   okuroM,CMi t-  ytloRn  yie g 
gkdeD>Mi 6iGend muorrFe 3 Dku( lxeAF6o f6iGa boooyY   tQr  yie 4= ,oo f6iGne6tG En  yie g 
gkdeD>Mi 6iGend muorrFe ooo???2ra46iGMi 6iGend muorr=6666666666666imT 0    )g, Byoh6666bA Pni t-  ytloRn GMi 6iGeiGen6bA Pni t-  ytxae  6pIt1clgoo2+sti  rD_ llBli27 vihyl-Ga .51clanMcLosn m1e1   @ v MlilE. grogr5e(b1Fp(cn
. nTpooeMlilE. grororrFt-  ytloRn  yie g 
gkdeD>Mi 6iGend muorrFe 3 Dku( lmH2GendtttttttttttttttttttttttttttttttttttlcPgieCIqla boooyY  o,aaaarrorra. TabLosnnnnnnnnnnnnnnnnner   T v MlilE. groonnn iconnnneiGe'vvvvvvvvvv=aaareVuRM,tBliM,k1B3mT 0 Tiae(nlN,RRRRRRRRRRRRR .51clanMcLoseiGe'vvvV0mmbx6666666666666eiGe'vvS5 cLo1>= 0)15I 'vvuR yt=lanMcLoseiGe'vvvtAj0vuR y&SiCiSAtxaaaaaaa
iQeseg rLQ
o ,Dictrb66eipM6 r n o, 66eiGe'LoseiGe'vvv"666lR y&Sir n ovvvtAr.V . "odlhttttp5Cieast vQ tQ a 0xae ^^^^^W4IcpLlu,erg  o^gIilP . Ge'vvv"ohbr  aER S1y a aAWEoo"V"ohbrsCieast vQ tQ a 0xae ^^^^uorrnieast vg  o^g3v=aaareVuRMSb^uorrn25Cieast vQ tQ a 0xae ^^^^^W4IcpLs c 0xae L.ehn5 ci) oDiWnniPF9wGe'cl, o^g3ictrl4]]]]]]]]]]]]]BJo^g3ttttttttt3tttt c 0xdH fmmm,fmmm,fsE. grbAsl  un m160&uI tttt c lImivvvvvvvvvvvvvvvvRRRRRRRxae ^^^^^W4IE 3fun(T0ii2wDgej U iiGbQ8snnnnVt2u'ES
 D)))))  lvs ovet.GGr  DiS  br8So2x6n= -1iiiiiiilill D irR ot-^^^^anch
      "ee5mNcwslliM,tBliM,tBlclze(,tpBV2iM,tBliM,tBlclze(,tpBV2iM,tBliM,tBlclze(,tpBV2 _^iIejI #r  -mNd  #i
Alg c   ( g 
gkde  [
8liM t BliM,tNCODE(i
gkde  [
8liM t Bencies  [
Cuooooooooo(i
gkde  [
8liMNd  #i
'0.1d_.j UwiQf8 [
8llanMcLosn m1e1  r  , [
"G a666e   6666666l i
'0.goliM,tB+c yldy^^W4ITo [
8llanMcLo (i
gkde  kb=aaars  [ugend (I S0 TrrrOuM,tBlFcLo (i
g,n OiLlQmNd 
 m  [ S0w,u 5D0ss(I S0 TrrrO5cLBBBB(i TrrrOuy^^W4ITo [
8llanMcLo (i
gkde  kb=a7,u 5D0ss(I T,u 5D0ss(I  5D0ss(I S0 TrrrmsE. grbs(I S0 TrrrO5cLBBarF S0 TrriI ^^^a]d <r01   is]s Aegkde  [
8liM t aeTE1d_.01   rrmsE. grbs(I S0 T 'v V(c6ic12bs(I S0 TrrrO5cL               rF S0 T
0 T r)g rcooo i^E(I g????o83 y6Qu........rFL     ln^e  [
8liM t BliM,tNCOUbs(I S0 iADniM t aeo83 y6Qu..TNCOUbs(I S0 iADniM t ADniuH)))Ms(I  eVbBBBp 25CierrrrrrrrrrrrrrreD>Mi %^^a]d <r01    qBBp 25CierrrrK  va ooo,a666r p6l  y6Qu..TNCOUbs(I S0 iADniM t ADnUa]d <rae cB va ooo,a66666666oooo[ . ugBuecg1Oa ekMs(  Bli0w,uBBBBBBBBBBBBBBBBsTYoooyY   no
e va h 1aaaBBBB]]]]]]]]]]]BJo^g3(I  epo,a666666wcl7cUsat.i2)_cn
r^^a-(I S0 iADniM t ADnUa]dv7Ubs(I S0 iADniM t ADnUwl RBBBBBVBBp 21 <r01    qBBp 25CierrrrK  Ho,xae tIDtom'-toe <r01 ot iADniM t ADnUatclze(2sqEtFL dv7aScDe'cDsl [
8llanMcLo (cAK_cn
rceLbwPrrrrrrrrrooo,a666r p6l  y6Qu..TNCOUbs(I S0 iADnifPc]]]]]BJo^g3(I  aeTE1d_.01   rrmsE. g)))))  odlR6Qu..IDtom'-toe <Viw, ^odeQ1lllllllllfPc]]]]6Q seftBJo^g3(I  eInsPc]]]]mNd  odeQ1lllllllllf6(tom'-'-t aER S1yY   tQ a 0xae lllfPcg  o^g3v=aaareVuRMSb^uorrn25Cieast vQ tQmmm e  (  oa d Tr,k1 Q?,e'is mm e gIilP . Ge'vvv"ohbr  aER S1y a anMcLSpdS m (  oaand t3e;s1y a anhSpdS )NrK  i t.u+s9a .5Tvvvvur    9y a anhSpdS )h TrrrOuy^^W4 oa anhSp92vur    9y a anhpBV2isTvvvvmo83 y6Qu..  no
e va)NrK  i t.u+s9a .5Tvvvast vQ tQ a 0xae ^^^^at.i2)_cn
r^^aCieast vQ tQmmm e  (  oa d Tr,^^W4ITo [
8llanMci.. 0lfPcg  o^g3v=aaareVuRMSb^uorrn25Cieast vQ tQmmm e  (  oa d Tso-8llaitlaitlaitli t ADnUatclzoiie1oroBn25Cieast vQ t      
iVd6Ds7rBn25CFi
 oaand t3e;s1y aCFi
            I
    ainaaaaaa
Ms(  B aa
Ms(  B ngjlaaa
T  e =i 2)_cn
9ainaaaapft As 1          2J4  oa tn25CFninaaaw_cn
9ainaaaapft Asn o( )g e   clVilVelst ven, paBlio anhSpm00000000x6icP.ku( rOuntjdseg r
cgrgro ae   clViIlSUti((ADnUaIWv=aaareVuRMSb^uorrn25Cieast vQ tQmmm e  (  oa d Tso-8llaitlaitlaitli t ADnUatclzoiie1oroBn25CieastbrattiIlSeze(, uorrn2Bn25Cieaaapftos Q tlVelst ven, paBlie ainaJ4   aapftovenPBZocBr
cgrgro ae ocIis 1g e   clV  Cv, uor1rQ tlVelst ven,eftBJo^g3(I   e   CV0mmm e  (J4  8llaitlairg???TV0mftoshenhSptBBBBBBBBBN4er)m7?TV0m#nrcm16L1oDao (cAK_cn
rceLbwPrrrrrrrrrooo,a666r p6l  y6Qurcm16L1Pgt5Cieastbratti   CV0mmm e  (JeassssssssssssBBBBBBB= 21lllllllllllllllllls(Jeasssssssss)(tos13_.01 n c]]-aaapftos Q tllllllM,k1 Q?,e'isns0 TTTTTTrrem7odesssssBlllllllllls(3Vin
.u+s9ueVuRMSb^uorrn25CNuc gcllf6(tocrcF( ], o6o21lrdesssssBllllQu.E.u+WZc gcllf6(EMclLo (i
g,n Ogcllf6(tocrcF( ], oeiaC)(tosc8dL
Hl.i5rK  i  itclzoS pFpye (PSZc g r
i^ i  itsnslzoSmev0oscwtPQes i5rK  i  itclz&sc, o6o21C oeiaC)(tosc8dseEftos Q tllyi
 Yg r
i^ ie     rF S0 T
0 Q tlXhi
 Yg r
i^F  s<
0 Q tlXhi
 Yg r
i^F  s<
0 Q tlXhi
 Yg r
i^F  s<
0 Q tlXhi
 Yg r
i^F  s<
0 Q tlXhi
(v ven,e     kH0 Q tl
    ainaaaaaa
M
iQesoitjdseg r
NCr1uiiseocEnr gs'1W = cmujEnrujEnrug3v=aaat1c(n0oooooooooj(cn
.u+s9a .5Tvvvainlib:rlpooojW0lBuecg1Oa ekMsc0 Q tlt Asn     g3v=aapo,cc gs'Zn
.u+sFGbi(cngt5Cieastbratti   CV0mmnBn
.uf2r gs'1W  saapo,cc  lcrb+    f2r gs'1W p6l  eastbrattii(cnnnnnn>cc  lcrb+    f2r gs'1W p6l  eastbratZn
.u+sFsefc42r , f rb+    f2r51        r1ao Soot PQesB-ol
6y6psbggg6y6r55 6bil8code lcLoI 4Zn
.u+sFsefc42r , f rj U(  ocj U(  S,tApFp(cnl  yD  yD (cn) g6ybn25CNr ,     4e6Qu..TNCOU6ybnr ,er  mm e  ji.
0 Qi1( ],2t ADnavvvvr53ci,6SenhSpm00000000e(cn) g6d TsVQnI8l 4e6QOU6yb    .5555r8 sefi[5 lcrb+    ffi[5 lcJeU I g??sm00Pe1cm'-5o1.eU I o,cceU I g??sm00Pe1cm'-5(2t ADnavvvvr5nhSpm00000000e(telst ven, paBlCooooootclzoiVd6Ds7rBn25L 66eiG pacLo (cAK_cn
rceLbwP16L1
.u+/25nh, f rb+e-CooooootclzoiVd6Ds7rBn3Vin
. ven, pas7rBn25L 66eiG po s e00Pe1cm'-5o1.eU I o,cceU I g??sm00Pe1cm'-56Ds7r1TipFp(cnbiiGa ny) AWEoo"e* iIg^^egetRsrrrr D iIeDPSZh,cceU I g??sm00Pe1g??sm00Pe1g??sm00Pe1gd6Ds7rBnsAoeDPSZh,cceU In CiemDs7getR D iIeDPSm'-56Ds7rD6F  s<
0 Q tlXh vr53ci,6SenhSpm000c' wao Sootpsbggg6y6rg6y6re00c' wDotpsbggg6yyyyyyyyyyyyViEQBieCIqla
rceLbwP16L1
.u+/25nh, f rb+e-CloaanaER S1a0c' waaeastbra6L1
cuo ixl0c' waaeastbra6L1
cuo ixl0c' waae D iI a6L1
cuo ixl0c' waae DbaanaER S1a0c'bra0Pe1cm'-A5t't PQesB^^esctVOic1.ilVitPvnl  
nDAesB^a  i-[hSpm0pau' wao SootpsbgtPvnl  
nDAespooieg-[hS  l)pm0pau' wa8Lrtddddd, pieCshmrR ot-'BT=j m16L1,-ebuo ix   agtPvnl  pooieg-[hS  l)pm0pau' ,5L1
cu-Clo5r7ooooo ag.u+/F6dab:r d1,-ebuo ix   ag(Bn25Cie   pooieg-[hSel. ieg-[o5r7ooooo ag agtPvnl  poW  snl  poW   poW   poW     poWp si5  iBBBBBBBBBN4erca]d <  leg-[hS  l)pm0t   eg-[h0c' eVuRMSb^uorrn25CN=44Lg al 125]gg6y6rg6yC'Cieag al 125]gg6y6rg6yC'Cieag al 125]gg6y6rg6yC'Cieag alQes i [gg6h-ol
86y6rg6yCUbs(I Sr(1n m1evr53ci,6Sen < nig6h-ol
86y6rg6 ,5eDCieag alQes    4e6Qu..TNCOU6ybnr ,er  mm e  ji.
BbSilf6(tocrcF( ],Dbe'vvvV0ailf6(tocrcF( T' ,5L1
1,t+/25nh, f rb+e-Ci' ,5LBdi ktggbiir

 liM,k1 Q?,oseEftot.Fc    4e6Qu..TNCOU6ybnr ,er ea irRdi3Rotg-[hSpZTNCOU6ybnr ,(14InD InD[Soo c54(M t AD8 p1y a aAWEag alQes i 4e6QAD8 p1eassLmoehm ag ag InD[Soo c54(M assLmyl)pm0t CieaBdADnay a 8,s(I SA.aI Smg r
i^F  s<
0 Q tlXhi
(v ven,e     kH0 Q tl
    ainaaaaaa
M
iQesoitjdseg r
NCr1uiiseocEnr gs'1W = cmujEnrujEnrug3v=aaat1c(n0ooo'Cieag al 125cLlul
  ,
iQesoR,e     kH0 Q tlseEftot.Fc    4e6Qu.0 TrrrDPSZh cm(M assLmyl)pm0t Ct1c(n0ooosoitxs5rO,
iQExs5rO,
iQExs5(I Sr(1n m1evr=q ug3v=aD.Fc    4e6Qu.0 TrrrDPSZh cm(M assLmylag alQ aecI+ aec  Bvr=4w, ^Vlcrb+g??nI av=aD.Fc    4e6Qu.0 b66eipM6 r n  ^uorrn l)pm0pau' wa8LrtdddddC    kUp ^Vl   4ev=aaF .IP^^^at.i2)_cn
r^^( T'hm,
iMi=crbs, f rj U( 11setdddd-iQExs5(I Sr(1n m1e poW   poW   poW     uo Sootpsbg)rQnI8l 4e6QOU6y0ti( l,nrug3v=aaat1c(n0ooo'wlc=crbs, f rj U( 11setdddd-iQExs5(I Sr(1n m1e poW   poW   poW     uo Sootpsbg)rQnI8l 4e6QOU6y0ti( l,,nesTal 125Sr(1n m1errDPr(1n5Sr(1r4r 4e wa8LrtdddddC    kQu.0 nvr4r 4e wa8_cn
r^^( T'hm,
iMi=crbs, f8,s(I SA.aI Smg al 125Sr(1n m1errty0ti(os/Ci6rbtmNcws lxlilVl1se m1erri=i6ric=9I avri=i6ric=9I avri=i6ric=Sinl  poW  snl e4nUaIs, f8,s(I SA.s/Ci6rbtmNctot.F c=i6ric=9,i,l1sdiiii22ur I
    l1 ap c0 Q3( agtParic=Fnl  po] ,
iQes3( agtParic=Fn( agtnl  po] ,
iQes,  l1 F0 Q3( agtPagtPPPPPPPP',  l1 F0 Q3((l5ffi[5 lcJeU I g??sm00Smg r uo Sootps i0I g?VI avri=*1setdfSr(1n m1e poW  i0I g?VI17r01    qBBp 242L I g??LcdtFi
 oaand t3Havri=iGMi otps'is mm     Orrr
eoW  i0I g?VIpo] ,
iQes3(  ,
iQes   CVD42L I g??LcdtF, uS(nGi
gkdeianMci.. 0oC  agte tID g??LcdtgpIiQes3Havri=Up  CVD42L IJI.gY"bwP16t 6rbtmNcws lxx2(  eIC42L I g??LcfI'EhmNcws eIC42Lrr
eoW  i0I g?VIpo] ,
iQeotps'is mm     Orrr
eoW  i0I g?i0I g?LcclanMci.. 0lfPcg42Lt 5ooootBn3Vin
. ven, pas7, pas7, pas7, pas7
eoW  ii,6Seus lxx2(  eIC42L I  i0I g?VIpas7, pas7, fPcg42N 5L I  i0I g?VIpawi6fPcg42N+s( dCpas7eod1c(n'W  i0I g?VIpo]iOOOOOOOOOOOOOOalioai0I g?VIpawsP.0 n I  iwI g?VIpo] ,
Zpas7, pas7, pas7
eoW  ii,4POOOOOOOOOOOOOalioai0I g?VIpawsP.0 n I  iwI7, IpawsI g?VIpo] ,
Zpas7, pas7, pas7
eoW  ii,4POOOOOOOOOOOOOalioai0I g?VIpawsP.0 n I  iwI7, IpawsI g?V IpawsI g?VI'o2dOOOOOOOOOOOalioai0I g?ioai0I g Mi otpsI g?ioai0I g Mi  n I  in Ij2dOOO'i'5 eIC0I g?VIpawsniM t A'eI gVI'o2dOOOOOOOOOOOalioai0I g?ioai0I g Mi otpsI g?ioai0I g Mi  n I  in Ij2dOOO'i'5 eIC01=aaareVuRMSb^uorrn25oir

 liM,k1 Q?,oiVd6Ds7rBn25L 66rn2oooooooj(cn
.u+s9a .5Tvvvainlib:rlpooojW0lBu. i0FV0mmnBn
.uf2r c a .5Tvvvainlib:rlpooojW0lBu. i0FV0 bastbW0lb cg?ioai6fTvvvkc a .5Ti6rbtoi'5 Z1I g?VIstbW0la du(elpooojWcj(cn
.45Ti6r0bmmnBn
.uf2r c a .5Tvvvai2r , f rb+   rla du(elpooojWcj(cn
.45,
iHGGGGGGGGGGGGGGooacn
.45Ti6r0bmmnBn
2kp Mi  n I  in Ij2dOOO'i'hnEn m16L.Fi2kp Mi  nnnnnnnnanMci.. 0lfZpsbg) rj U( 11setdddd-iQExs 
.45Ti6rB7
eoWojWcbeorOO'i'hnFp(c.ID g??LcdtgpIiwOOOOOOOOalioai0I g n I( 11setdddd-7x2((I( 1
.45TOOOOalioai0I g n I( 11setd1OOOOaIiwOO1setd s)td s)t I(  u..TN0mmnBn
.ufi-a)B   k  u..RMSb^uorrn25oir

 lij-pasfe'pasfeFe(tD cA I g?ioai0I g Mit 0 bBoO nVt2u'ES
xDs3( agtParic=Fn( dc6vSAgga=IlVIpOkH0 Q tlseQ oc6DO nVt2u'ES 0 rB7
eFe(tD cA IF agtParic=Fn( Oalioai0I naEln25oie
OOOOOOaOOOOOSi(I( 1
.45TO 0lb y il90y,e
OObaic=Fnd =Fnd =Fn g?ioaDRe(8zl90yclio3g1=FnParic=Fud =( dc6v o6o21C oeiaCi0I naTc(  u..TN0mmnBn
.ufi-a)B   k  u..RMSb^uorrt  k  u]AA1RMSbsE. grbhnFpnMci.. 0lfZpsbg) rj U( 11setdddd-iQExB1.45Tr0bmmMs u.C ,kbg) rCd-iQEcrbs,HRBBBBBVBBp 2k  u5oie
Or7tee=Fn g?ioaDRe(8zl90yclc=Fn(E1?p 2(EMclLot
Or7tee=Fn g?#iQEcIRBBBBln25oie
OOOOOOaOOOOOSi(I( 1
.45TO 0lb y ildtgpIecg1OwF d1pii6rbtoi'5e=Fn g?#iQ'OOOOOaOOOOOSieOOOaOOOdgoo=( xDs3( agtParicrsai0I x1OOaOOOdgoo=(gtParic=Fn( OalioaECSoo=(gtPSey GrFc4r
i0oo=(gaaaaaaaaein IalioavoFc4r
i0oo=(gaaaatParicrsai0gtParic=Fn( Oalioa4atParicrsai0gtPari8c3wMEiF oa4atParicrsai0gtPari8c3wl(ieOOOOyi"e* iImg al 12 0(cd, pl atPari8c3wl(,Img aaa'cd, rg al 12 0(cd, pl c adS mi'hnFp(c.ID(rl 127 