pdf_g4_tables.h

Fri, 21 Feb 2003 12:28:37 +0000

author
eric
date
Fri, 21 Feb 2003 12:28:37 +0000
changeset 69
1bec9168554f
parent 68
cba49c5dbaa4
permissions
-rw-r--r--

GPL

     1 /*
     2  * t2p: Create a PDF file from the contents of one or more TIFF
     3  *      bilevel image files.  The images in the resulting PDF file
     4  *      will be compressed using ITU-T T.6 (G4) fax encoding.
     5  *
     6  * G4 encoding tables
     7  * $Id: pdf_g4_tables.h,v 1.2 2003/02/21 04:28:37 eric Exp $
     8  * Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com>
     9  *
    10  * This program is free software; you can redistribute it and/or modify
    11  * it under the terms of the GNU General Public License version 2 as
    12  * published by the Free Software Foundation.  Note that permission is
    13  * not granted to redistribute this program under the terms of any
    14  * other version of the General Public License.
    15  *
    16  * This program is distributed in the hope that it will be useful,
    17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
    20  *
    21  * You should have received a copy of the GNU General Public License
    22  * along with this program; if not, write to the Free Software
    23  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
    24  */
    27 typedef struct
    28 {
    29   uint32_t count;
    30   uint32_t bits;
    31 } g4_bits;
    33 static g4_bits g4_long_makeup_code [12] =
    34   {
    35     { 11, 0x008 },  /* 1792 */
    36     { 11, 0x00c },  /* 1856 */
    37     { 11, 0x00d },  /* 1920 */
    38     { 12, 0x012 },  /* 1984 */
    39     { 12, 0x013 },  /* 2048 */
    40     { 12, 0x014 },  /* 2112 */
    41     { 12, 0x015 },  /* 2176 */
    42     { 12, 0x016 },  /* 2240 */
    43     { 12, 0x017 },  /* 2304 */
    44     { 12, 0x01c },  /* 2368 */
    45     { 12, 0x01d },  /* 2432 */
    46     { 12, 0x01e }   /* 2496 */
    47   };
    49 static g4_bits g4_makeup_code [2] [27] =
    50   {
    51     {
    52       /* white */
    53       { 5, 0x1b },  /* 64 */
    54       { 5, 0x12 },  /* 128 */
    55       { 6, 0x17 },  /* 192 */
    56       { 7, 0x37 },  /* 256 */
    57       { 8, 0x36 },  /* 320 */
    58       { 8, 0x37 },  /* 384 */
    59       { 8, 0x64 },  /* 448 */
    60       { 8, 0x65 },  /* 512 */
    61       { 8, 0x68 },  /* 576 */
    62       { 8, 0x67 },  /* 640 */
    63       { 9, 0x0cc }, /* 704 */
    64       { 9, 0x0cd }, /* 768 */
    65       { 9, 0x0d2 }, /* 832 */
    66       { 9, 0x0d3 }, /* 896 */
    67       { 9, 0x0d4 }, /* 960 */
    68       { 9, 0x0d5 }, /* 1024 */
    69       { 9, 0x0d6 }, /* 1088 */
    70       { 9, 0x0d7 }, /* 1152 */
    71       { 9, 0x0d8 }, /* 1216 */
    72       { 9, 0x0d9 }, /* 1280 */
    73       { 9, 0x0da }, /* 1344 */
    74       { 9, 0x0db }, /* 1408 */
    75       { 9, 0x098 }, /* 1472 */
    76       { 9, 0x099 }, /* 1536 */
    77       { 9, 0x09a }, /* 1600 */
    78       { 6, 0x18 },  /* 1664 */
    79       { 9, 0x09b }  /* 1728 */
    80     },
    81     {
    82       /* black */
    83       { 10, 0x00f },  /* 64 */
    84       { 12, 0x0c8 },  /* 128 */
    85       { 12, 0x0c9 },  /* 192 */
    86       { 12, 0x05b },  /* 256 */
    87       { 12, 0x033 },  /* 320 */
    88       { 12, 0x034 },  /* 384 */
    89       { 12, 0x035 },  /* 448 */
    90       { 13, 0x006c }, /* 512 */
    91       { 13, 0x006d }, /* 576 */
    92       { 13, 0x004a }, /* 640 */
    93       { 13, 0x004b }, /* 704 */
    94       { 13, 0x004c }, /* 768 */
    95       { 13, 0x004d }, /* 832 */
    96       { 13, 0x0072 }, /* 896 */
    97       { 13, 0x0073 }, /* 960 */
    98       { 13, 0x0074 }, /* 1024 */
    99       { 13, 0x0075 }, /* 1088 */
   100       { 13, 0x0076 }, /* 1152 */
   101       { 13, 0x0077 }, /* 1216 */
   102       { 13, 0x0052 }, /* 1280 */
   103       { 13, 0x0053 }, /* 1344 */
   104       { 13, 0x0054 }, /* 1408 */
   105       { 13, 0x0055 }, /* 1472 */
   106       { 13, 0x005a }, /* 1536 */
   107       { 13, 0x005b }, /* 1600 */
   108       { 13, 0x0064 }, /* 1664 */
   109       { 13, 0x0065 }, /* 1728 */
   110     }
   111   };
   114 static g4_bits g4_h_code [2] [64] =
   115   {
   116     {
   117       /* white */
   118       { 8, 0x35 },  /* 0 */
   119       { 6, 0x07 },  /* 1 */
   120       { 4, 0x7 },   /* 2 */
   121       { 4, 0x8 },   /* 3 */
   122       { 4, 0xb },   /* 4 */
   123       { 4, 0xc },   /* 5 */
   124       { 4, 0xe },   /* 6 */
   125       { 4, 0xf },   /* 7 */
   126       { 5, 0x13 },  /* 8 */
   127       { 5, 0x14 },  /* 9 */
   128       { 5, 0x07 },  /* 10 */
   129       { 5, 0x08 },  /* 11 */
   130       { 6, 0x08 },  /* 12 */
   131       { 6, 0x03 },  /* 13 */
   132       { 6, 0x34 },  /* 14 */
   133       { 6, 0x35 },  /* 15 */
   134       { 6, 0x2a },  /* 16 */
   135       { 6, 0x2b },  /* 17 */
   136       { 7, 0x27 },  /* 18 */
   137       { 7, 0x0c },  /* 19 */
   138       { 7, 0x04 },  /* 20 */
   139       { 7, 0x17 },  /* 21 */
   140       { 7, 0x03 },  /* 22 */
   141       { 7, 0x04 },  /* 23 */
   142       { 7, 0x28 },  /* 24 */
   143       { 7, 0x2b },  /* 25 */
   144       { 7, 0x13 },  /* 26 */
   145       { 7, 0x24 },  /* 27 */
   146       { 7, 0x18 },  /* 28 */
   147       { 8, 0x02 },  /* 29 */
   148       { 8, 0x03 },  /* 30 */
   149       { 8, 0x1a },  /* 31 */
   150       { 8, 0x1b },  /* 32 */
   151       { 8, 0x12 },  /* 33 */
   152       { 8, 0x13 },  /* 34 */
   153       { 8, 0x14 },  /* 35 */
   154       { 8, 0x15 },  /* 36 */
   155       { 8, 0x16 },  /* 37 */
   156       { 8, 0x17 },  /* 38 */
   157       { 8, 0x28 },  /* 39 */
   158       { 8, 0x29 },  /* 40 */
   159       { 8, 0x2a },  /* 41 */
   160       { 8, 0x2b },  /* 42 */
   161       { 8, 0x2c },  /* 43 */
   162       { 8, 0x2d },  /* 44 */
   163       { 8, 0x04 },  /* 45 */
   164       { 8, 0x05 },  /* 46 */
   165       { 8, 0x0a },  /* 47 */
   166       { 8, 0x0b },  /* 48 */
   167       { 8, 0x52 },  /* 49 */
   168       { 8, 0x53 },  /* 50 */
   169       { 8, 0x54 },  /* 51 */
   170       { 8, 0x55 },  /* 52 */
   171       { 8, 0x24 },  /* 53 */
   172       { 8, 0x25 },  /* 54 */
   173       { 8, 0x58 },  /* 55 */
   174       { 8, 0x59 },  /* 56 */
   175       { 8, 0x5a },  /* 57 */
   176       { 8, 0x5b },  /* 58 */
   177       { 8, 0x4a },  /* 59 */
   178       { 8, 0x4b },  /* 60 */
   179       { 8, 0x32 },  /* 61 */
   180       { 8, 0x33 },  /* 62 */
   181       { 8, 0x34 }   /* 63 */
   182     },
   183     {
   184       /* black */
   185       { 10, 0x037 },  /* 0 */
   186       { 3, 0x2 },     /* 1 */
   187       { 2, 0x3 },     /* 2 */
   188       { 2, 0x2 },     /* 3 */
   189       { 3, 0x3 },     /* 4 */
   190       { 4, 0x3 },     /* 5 */
   191       { 4, 0x2 },     /* 6 */
   192       { 5, 0x03 },    /* 7 */
   193       { 6, 0x05 },    /* 8 */
   194       { 6, 0x04 },    /* 9 */
   195       { 7, 0x04 },    /* 10 */
   196       { 7, 0x05 },    /* 11 */
   197       { 7, 0x07 },    /* 12 */
   198       { 8, 0x04 },    /* 13 */
   199       { 8, 0x07 },    /* 14 */
   200       { 9, 0x018 },   /* 15 */
   201       { 10, 0x017 },  /* 16 */
   202       { 10, 0x018 },  /* 17 */
   203       { 10, 0x008 },  /* 18 */
   204       { 11, 0x067 },  /* 19 */
   205       { 11, 0x068 },  /* 20 */
   206       { 11, 0x06c },  /* 21 */
   207       { 11, 0x037 },  /* 22 */
   208       { 11, 0x028 },  /* 23 */
   209       { 11, 0x017 },  /* 24 */
   210       { 11, 0x018 },  /* 25 */
   211       { 12, 0x0ca },  /* 26 */
   212       { 12, 0x0cb },  /* 27 */
   213       { 12, 0x0cc },  /* 28 */
   214       { 12, 0x0cd },  /* 29 */
   215       { 12, 0x068 },  /* 30 */
   216       { 12, 0x069 },  /* 31 */
   217       { 12, 0x06a },  /* 32 */
   218       { 12, 0x06b },  /* 33 */
   219       { 12, 0x0d2 },  /* 34 */
   220       { 12, 0x0d3 },  /* 35 */
   221       { 12, 0x0d4 },  /* 36 */
   222       { 12, 0x0d5 },  /* 37 */
   223       { 12, 0x0d6 },  /* 38 */
   224       { 12, 0x0d7 },  /* 39 */
   225       { 12, 0x06c },  /* 40 */
   226       { 12, 0x06d },  /* 41 */
   227       { 12, 0x0da },  /* 42 */
   228       { 12, 0x0db },  /* 43 */
   229       { 12, 0x054 },  /* 44 */
   230       { 12, 0x055 },  /* 45 */
   231       { 12, 0x056 },  /* 46 */
   232       { 12, 0x057 },  /* 47 */
   233       { 12, 0x064 },  /* 48 */
   234       { 12, 0x065 },  /* 49 */
   235       { 12, 0x052 },  /* 50 */
   236       { 12, 0x053 },  /* 51 */
   237       { 12, 0x024 },  /* 52 */
   238       { 12, 0x037 },  /* 53 */
   239       { 12, 0x038 },  /* 54 */
   240       { 12, 0x027 },  /* 55 */
   241       { 12, 0x028 },  /* 56 */
   242       { 12, 0x058 },  /* 57 */
   243       { 12, 0x059 },  /* 58 */
   244       { 12, 0x02b },  /* 59 */
   245       { 12, 0x02c },  /* 60 */
   246       { 12, 0x05a },  /* 61 */
   247       { 12, 0x066 },  /* 62 */
   248       { 12, 0x067 }   /* 63 */
   249     }
   250   };
   253 static g4_bits g4_vert_code [7] =
   254   {
   255     { 7, 0x02 },
   256     { 6, 0x02 },
   257     { 3, 0x02 },
   258     { 1, 0x01 },
   259     { 3, 0x03 },
   260     { 6, 0x03 },
   261     { 7, 0x03 }
   262   };