fax/faxclientandserver/faxio/FAXHUFF.H
changeset 0 3553901f7fa8
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @publishedPartner
       
    19  @released
       
    20 */
       
    21 
       
    22 #if !defined(__FAXHUFF_H__)
       
    23 #define __FAXHUFF_H__
       
    24 
       
    25 #define KFaxBlack 0		// Mask for CFbsBitmap bytes
       
    26 #define KFaxWhite 0xFF	// Reversing gives a negative image
       
    27 
       
    28 typedef TUint32 TCodeDef;
       
    29 
       
    30 #define HUFF(len,bits) (TUint(len)<<16)|(bits)
       
    31 #define HUFFLEN(def) (TUint(def)>>16)
       
    32 #define HUFFBITS(def) (TUint(def)<<16)
       
    33 
       
    34 const TCodeDef KCodes[] =
       
    35 	{
       
    36 	// interleaved black/white runs
       
    37 	HUFF(10,0x0dc0),  // 0 black = 10 bit code is 0000110111
       
    38 	HUFF(8,0x3500),// 0 white = 8 bit code is 00110101
       
    39 	HUFF(3,0x4000),// 1 black = 3 bit code is 010
       
    40 	HUFF(6,0x1c00),// 1 white = 6 bit code is 000111
       
    41 	HUFF(2,0xc000),// 2 black = 2 bit code is 11
       
    42 	HUFF(4,0x7000),// 2 white = 4 bit code is 0111
       
    43 	HUFF(2,0x8000),// 3 black = 2 bit code is 10
       
    44 	HUFF(4,0x8000),// 3 white = 4 bit code is 1000
       
    45 	HUFF(3,0x6000),// 4 black = 3 bit code is 011
       
    46 	HUFF(4,0xb000),// 4 white = 4 bit code is 1011
       
    47 	HUFF(4,0x3000),// 5 black = 4 bit code is 0011
       
    48 	HUFF(4,0xc000),// 5 white = 4 bit code is 1100
       
    49 	HUFF(4,0x2000),// 6 black = 4 bit code is 0010
       
    50 	HUFF(4,0xe000),// 6 white = 4 bit code is 1110
       
    51 	HUFF(5,0x1800),// 7 black = 5 bit code is 00011
       
    52 	HUFF(4,0xf000),// 7 white = 4 bit code is 1111
       
    53 	HUFF(6,0x1400),// 8 black = 6 bit code is 000101
       
    54 	HUFF(5,0x9800),// 8 white = 5 bit code is 10011
       
    55 	HUFF(6,0x1000),// 9 black = 6 bit code is 000100
       
    56 	HUFF(5,0xa000),// 9 white = 5 bit code is 10100
       
    57 	HUFF(7,0x0800),// 10 black = 7 bit code is 0000100
       
    58 	HUFF(5,0x3800),// 10 white = 5 bit code is 00111
       
    59 	HUFF(7,0x0a00),// 11 black = 7 bit code is 0000101
       
    60 	HUFF(5,0x4000),// 11 white = 5 bit code is 01000
       
    61 	HUFF(7,0x0e00),// 12 black = 7 bit code is 0000111
       
    62 	HUFF(6,0x2000),// 12 white = 6 bit code is 001000
       
    63 	HUFF(8,0x0400),// 13 black = 8 bit code is 00000100
       
    64 	HUFF(6,0x0c00),// 13 white = 6 bit code is 000011
       
    65 	HUFF(8,0x0700),// 14 black = 8 bit code is 00000111
       
    66 	HUFF(6,0xd000),// 14 white = 6 bit code is 110100
       
    67 	HUFF(9,0x0c00),// 15 black = 9 bit code is 000011000
       
    68 	HUFF(6,0xd400),// 15 white = 6 bit code is 110101
       
    69 	HUFF(10,0x05c0),  // 16 black = 10 bit code is 0000010111
       
    70 	HUFF(6,0xa800),// 16 white = 6 bit code is 101010
       
    71 	HUFF(10,0x0600),  // 17 black = 10 bit code is 0000011000
       
    72 	HUFF(6,0xac00),// 17 white = 6 bit code is 101011
       
    73 	HUFF(10,0x0200),  // 18 black = 10 bit code is 0000001000
       
    74 	HUFF(7,0x4e00),// 18 white = 7 bit code is 0100111
       
    75 	HUFF(11,0x0ce0),  // 19 black = 11 bit code is 00001100111
       
    76 	HUFF(7,0x1800),// 19 white = 7 bit code is 0001100
       
    77 	HUFF(11,0x0d00),  // 20 black = 11 bit code is 00001101000
       
    78 	HUFF(7,0x1000),// 20 white = 7 bit code is 0001000
       
    79 	HUFF(11,0x0d80),  // 21 black = 11 bit code is 00001101100
       
    80 	HUFF(7,0x2e00),// 21 white = 7 bit code is 0010111
       
    81 	HUFF(11,0x06e0),  // 22 black = 11 bit code is 00000110111
       
    82 	HUFF(7,0x0600),// 22 white = 7 bit code is 0000011
       
    83 	HUFF(11,0x0500),  // 23 black = 11 bit code is 00000101000
       
    84 	HUFF(7,0x0800),// 23 white = 7 bit code is 0000100
       
    85 	HUFF(11,0x02e0),  // 24 black = 11 bit code is 00000010111
       
    86 	HUFF(7,0x5000),// 24 white = 7 bit code is 0101000
       
    87 	HUFF(11,0x0300),  // 25 black = 11 bit code is 00000011000
       
    88 	HUFF(7,0x5600),// 25 white = 7 bit code is 0101011
       
    89 	HUFF(12,0x0ca0),  // 26 black = 12 bit code is 000011001010
       
    90 	HUFF(7,0x2600),// 26 white = 7 bit code is 0010011
       
    91 	HUFF(12,0x0cb0),  // 27 black = 12 bit code is 000011001011
       
    92 	HUFF(7,0x4800),// 27 white = 7 bit code is 0100100
       
    93 	HUFF(12,0x0cc0),  // 28 black = 12 bit code is 000011001100
       
    94 	HUFF(7,0x3000),// 28 white = 7 bit code is 0011000
       
    95 	HUFF(12,0x0cd0),  // 29 black = 12 bit code is 000011001101
       
    96 	HUFF(8,0x0200),// 29 white = 8 bit code is 00000010
       
    97 	HUFF(12,0x0680),  // 30 black = 12 bit code is 000001101000
       
    98 	HUFF(8,0x0300),// 30 white = 8 bit code is 00000011
       
    99 	HUFF(12,0x0690),  // 31 black = 12 bit code is 000001101001
       
   100 	HUFF(8,0x1a00),// 31 white = 8 bit code is 00011010
       
   101 	HUFF(12,0x06a0),  // 32 black = 12 bit code is 000001101010
       
   102 	HUFF(8,0x1b00),// 32 white = 8 bit code is 00011011
       
   103 	HUFF(12,0x06b0),  // 33 black = 12 bit code is 000001101011
       
   104 	HUFF(8,0x1200),// 33 white = 8 bit code is 00010010
       
   105 	HUFF(12,0x0d20),  // 34 black = 12 bit code is 000011010010
       
   106 	HUFF(8,0x1300),// 34 white = 8 bit code is 00010011
       
   107 	HUFF(12,0x0d30),  // 35 black = 12 bit code is 000011010011
       
   108 	HUFF(8,0x1400),// 35 white = 8 bit code is 00010100
       
   109 	HUFF(12,0x0d40),  // 36 black = 12 bit code is 000011010100
       
   110 	HUFF(8,0x1500),// 36 white = 8 bit code is 00010101
       
   111 	HUFF(12,0x0d50),  // 37 black = 12 bit code is 000011010101
       
   112 	HUFF(8,0x1600),// 37 white = 8 bit code is 00010110
       
   113 	HUFF(12,0x0d60),  // 38 black = 12 bit code is 000011010110
       
   114 	HUFF(8,0x1700),// 38 white = 8 bit code is 00010111
       
   115 	HUFF(12,0x0d70),  // 39 black = 12 bit code is 000011010111
       
   116 	HUFF(8,0x2800),// 39 white = 8 bit code is 00101000
       
   117 	HUFF(12,0x06c0),  // 40 black = 12 bit code is 000001101100
       
   118 	HUFF(8,0x2900),// 40 white = 8 bit code is 00101001
       
   119 	HUFF(12,0x06d0),  // 41 black = 12 bit code is 000001101101
       
   120 	HUFF(8,0x2a00),// 41 white = 8 bit code is 00101010
       
   121 	HUFF(12,0x0da0),  // 42 black = 12 bit code is 000011011010
       
   122 	HUFF(8,0x2b00),// 42 white = 8 bit code is 00101011
       
   123 	HUFF(12,0x0db0),  // 43 black = 12 bit code is 000011011011
       
   124 	HUFF(8,0x2c00),// 43 white = 8 bit code is 00101100
       
   125 	HUFF(12,0x0540),  // 44 black = 12 bit code is 000001010100
       
   126 	HUFF(8,0x2d00),// 44 white = 8 bit code is 00101101
       
   127 	HUFF(12,0x0550),  // 45 black = 12 bit code is 000001010101
       
   128 	HUFF(8,0x0400),// 45 white = 8 bit code is 00000100
       
   129 	HUFF(12,0x0560),  // 46 black = 12 bit code is 000001010110
       
   130 	HUFF(8,0x0500),// 46 white = 8 bit code is 00000101
       
   131 	HUFF(12,0x0570),  // 47 black = 12 bit code is 000001010111
       
   132 	HUFF(8,0x0a00),// 47 white = 8 bit code is 00001010
       
   133 	HUFF(12,0x0640),  // 48 black = 12 bit code is 000001100100
       
   134 	HUFF(8,0x0b00),// 48 white = 8 bit code is 00001011
       
   135 	HUFF(12,0x0650),  // 49 black = 12 bit code is 000001100101
       
   136 	HUFF(8,0x5200),// 49 white = 8 bit code is 01010010
       
   137 	HUFF(12,0x0520),  // 50 black = 12 bit code is 000001010010
       
   138 	HUFF(8,0x5300),// 50 white = 8 bit code is 01010011
       
   139 	HUFF(12,0x0530),  // 51 black = 12 bit code is 000001010011
       
   140 	HUFF(8,0x5400),// 51 white = 8 bit code is 01010100
       
   141 	HUFF(12,0x0240),  // 52 black = 12 bit code is 000000100100
       
   142 	HUFF(8,0x5500),// 52 white = 8 bit code is 01010101
       
   143 	HUFF(12,0x0370),  // 53 black = 12 bit code is 000000110111
       
   144 	HUFF(8,0x2400),// 53 white = 8 bit code is 00100100
       
   145 	HUFF(12,0x0380),  // 54 black = 12 bit code is 000000111000
       
   146 	HUFF(8,0x2500),// 54 white = 8 bit code is 00100101
       
   147 	HUFF(12,0x0270),  // 55 black = 12 bit code is 000000100111
       
   148 	HUFF(8,0x5800),// 55 white = 8 bit code is 01011000
       
   149 	HUFF(12,0x0280),  // 56 black = 12 bit code is 000000101000
       
   150 	HUFF(8,0x5900),// 56 white = 8 bit code is 01011001
       
   151 	HUFF(12,0x0580),  // 57 black = 12 bit code is 000001011000
       
   152 	HUFF(8,0x5a00),// 57 white = 8 bit code is 01011010
       
   153 	HUFF(12,0x0590),  // 58 black = 12 bit code is 000001011001
       
   154 	HUFF(8,0x5b00),// 58 white = 8 bit code is 01011011
       
   155 	HUFF(12,0x02b0),  // 59 black = 12 bit code is 000000101011
       
   156 	HUFF(8,0x4a00),// 59 white = 8 bit code is 01001010
       
   157 	HUFF(12,0x02c0),  // 60 black = 12 bit code is 000000101100
       
   158 	HUFF(8,0x4b00),// 60 white = 8 bit code is 01001011
       
   159 	HUFF(12,0x05a0),  // 61 black = 12 bit code is 000001011010
       
   160 	HUFF(8,0x3200),// 61 white = 8 bit code is 00110010
       
   161 	HUFF(12,0x0660),  // 62 black = 12 bit code is 000001100110
       
   162 	HUFF(8,0x3300),// 62 white = 8 bit code is 00110011
       
   163 	HUFF(12,0x0670),  // 63 black = 12 bit code is 000001100111
       
   164 	HUFF(8,0x3400),// 63 white = 8 bit code is 00110100
       
   165 	// code 0x80 and 0x81 not used for makeup.. use for tag codes instead!
       
   166 	HUFF(9,0x0180),	// two-dimensional EOL plus singleton 1 tag bit = 000000011
       
   167 	HUFF(9,0x0100), // two-dimensional EOL plus singleton 0 tag bit = 000000010
       
   168 	// interleaved black/white makeup
       
   169 	HUFF(10,0x03c0),  // 64 black = 10 bit code is 0000001111
       
   170 	HUFF(5,0xd800),// 64 white = 5 bit code is 11011
       
   171 	HUFF(12,0x0c80),  // 128 black = 12 bit code is 000011001000
       
   172 	HUFF(5,0x9000),// 128 white = 5 bit code is 10010
       
   173 	HUFF(12,0x0c90),  // 192 black = 12 bit code is 000011001001
       
   174 	HUFF(6,0x5c00),// 192 white = 6 bit code is 010111
       
   175 	HUFF(12,0x05b0),  // 256 black = 12 bit code is 000001011011
       
   176 	HUFF(7,0x6e00),// 256 white = 7 bit code is 0110111
       
   177 	HUFF(12,0x0330),  // 320 black = 12 bit code is 000000110011
       
   178 	HUFF(8,0x3600),// 320 white = 8 bit code is 00110110
       
   179 	HUFF(12,0x0340),  // 384 black = 12 bit code is 000000110100
       
   180 	HUFF(8,0x3700),// 384 white = 8 bit code is 00110111
       
   181 	HUFF(12,0x0350),  // 448 black = 12 bit code is 000000110101
       
   182 	HUFF(8,0x6400),// 448 white = 8 bit code is 01100100
       
   183 	HUFF(13,0x0360),  // 512 black = 13 bit code is 0000001101100
       
   184 	HUFF(8,0x6500),// 512 white = 8 bit code is 01100101
       
   185 	HUFF(13,0x0368),  // 576 black = 13 bit code is 0000001101101
       
   186 	HUFF(8,0x6800),// 576 white = 8 bit code is 01101000
       
   187 	HUFF(13,0x0250),  // 640 black = 13 bit code is 0000001001010
       
   188 	HUFF(8,0x6700),// 640 white = 8 bit code is 01100111
       
   189 	HUFF(13,0x0258),  // 704 black = 13 bit code is 0000001001011
       
   190 	HUFF(9,0x6600),// 704 white = 9 bit code is 011001100
       
   191 	HUFF(13,0x0260),  // 768 black = 13 bit code is 0000001001100
       
   192 	HUFF(9,0x6680),// 768 white = 9 bit code is 011001101
       
   193 	HUFF(13,0x0268),  // 832 black = 13 bit code is 0000001001101
       
   194 	HUFF(9,0x6900),// 832 white = 9 bit code is 011010010
       
   195 	HUFF(13,0x0390),  // 896 black = 13 bit code is 0000001110010
       
   196 	HUFF(9,0x6980),// 896 white = 9 bit code is 011010011
       
   197 	HUFF(13,0x0398),  // 960 black = 13 bit code is 0000001110011
       
   198 	HUFF(9,0x6a00),// 960 white = 9 bit code is 011010100
       
   199 	HUFF(13,0x03a0),  // 1024 black = 13 bit code is 0000001110100
       
   200 	HUFF(9,0x6a80),// 1024 white = 9 bit code is 011010101
       
   201 	HUFF(13,0x03a8),  // 1088 black = 13 bit code is 0000001110101
       
   202 	HUFF(9,0x6b00),// 1088 white = 9 bit code is 011010110
       
   203 	HUFF(13,0x03b0),  // 1152 black = 13 bit code is 0000001110110
       
   204 	HUFF(9,0x6b80),// 1152 white = 9 bit code is 011010111
       
   205 	HUFF(13,0x03b8),  // 1216 black = 13 bit code is 0000001110111
       
   206 	HUFF(9,0x6c00),// 1216 white = 9 bit code is 011011000
       
   207 	HUFF(13,0x0290),  // 1280 black = 13 bit code is 0000001010010
       
   208 	HUFF(9,0x6c80),// 1280 white = 9 bit code is 011011001
       
   209 	HUFF(13,0x0298),  // 1344 black = 13 bit code is 0000001010011
       
   210 	HUFF(9,0x6d00),// 1344 white = 9 bit code is 011011010
       
   211 	HUFF(13,0x02a0),  // 1408 black = 13 bit code is 0000001010100
       
   212 	HUFF(9,0x6d80),// 1408 white = 9 bit code is 011011011
       
   213 	HUFF(13,0x02a8),  // 1472 black = 13 bit code is 0000001010101
       
   214 	HUFF(9,0x4c00),// 1472 white = 9 bit code is 010011000
       
   215 	HUFF(13,0x02d0),  // 1536 black = 13 bit code is 0000001011010
       
   216 	HUFF(9,0x4c80),// 1536 white = 9 bit code is 010011001
       
   217 	HUFF(13,0x02d8),  // 1600 black = 13 bit code is 0000001011011
       
   218 	HUFF(9,0x4d00),// 1600 white = 9 bit code is 010011010
       
   219 	HUFF(13,0x0320),  // 1664 black = 13 bit code is 0000001100100
       
   220 	HUFF(6,0x6000),// 1664 white = 6 bit code is 011000
       
   221 	HUFF(13,0x0328),  // 1728 black = 13 bit code is 0000001100101
       
   222 	HUFF(9,0x4d80), // 1728 white = 9 bit code is 010011011
       
   223 	// extra codes
       
   224 	HUFF(8,0x0100),	  // one-dimensional EOL = 00000001
       
   225 	HUFF(4,0x1000),   // pass mode = 4 bit code is 0001
       
   226 	HUFF(3,0x2000),   // horizontal mode = 3 bit code is 001 followed by run lengths (a1-a0) (a2-a1)
       
   227 	// vertical mode codes
       
   228 	HUFF(7,0x0600),   // +3 b1-a1 = 7 bit code is 0000011
       
   229 	HUFF(6,0x0c00),   // +2 b1-a1 = 6 bit code is 000011 
       
   230 	HUFF(3,0x6000),   // +1 b1-a1 = 3 bit code is 011 
       
   231 	HUFF(1,0x8000),   //  0 b1=a1 = 1 bit code is 1 
       
   232 	HUFF(3,0x4000),   // -1 b1-a1 = 3 bit code is 010
       
   233 	HUFF(6,0x0800),   // -2 b1-a1 = 6 bit code is 000010
       
   234 	HUFF(7,0x0400)    // -3 b1-a1 = 7 bit code is 0000010
       
   235 	};
       
   236 
       
   237 const TInt KRleBlack=0;
       
   238 const TInt KRleWhite=1;
       
   239 const TInt KRleMakeup=128;
       
   240 const TInt KRleTag1D=KRleMakeup;	// exploit the two holes in the table
       
   241 const TInt KRleTag2D=KRleMakeup+1;
       
   242 const TInt KRleExtra=KRleMakeup+2*(1+(1728>>6));
       
   243 const TInt KRleStd1D=KRleExtra;
       
   244 const TInt KRlePassMode=KRleExtra+1;
       
   245 const TInt KRleHorzMode=KRleExtra+2;
       
   246 const TInt KRleVertMode0=KRleExtra+6;
       
   247 
       
   248 
       
   249 const TInt KRleMakeupMask=~(KRleWhite|KRleMakeup);
       
   250 
       
   251 #endif // __FAXHUFF_H__