/* sff2jpeg - convert sff group 3 fax files to jpeg. Copyright (C) 2002,2003 Matthias Kramm This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* rfc 804 */ struct huffcode { char*code; int len; int run; }; static struct huffcode termwhite[] = { {"00110101", 8, 0}, {"000111", 6, 1}, {"0111", 4, 2}, {"1000", 4, 3}, {"1011", 4, 4}, {"1100", 4, 5}, {"1110", 4, 6}, {"1111", 4, 7}, {"10011", 5, 8}, {"10100", 5, 9}, {"00111", 5, 10}, {"01000", 5, 11}, {"001000", 6, 12}, {"000011", 6, 13}, {"110100", 6, 14}, {"110101", 6, 15}, {"101010", 6, 16}, {"101011", 6, 17}, {"0100111", 7, 18}, {"0001100", 7, 19}, {"0001000", 7, 20}, {"0010111", 7, 21}, {"0000011", 7, 22}, {"0000100", 7, 23}, {"0101000", 7, 24}, {"0101011", 7, 25}, {"0010011", 7, 26}, {"0100100", 7, 27}, {"0011000", 7, 28}, {"00000010", 8, 29}, {"00000011", 8, 30}, {"00011010", 8, 31}, {"00011011", 8, 32}, {"00010010", 8, 33}, {"00010011", 8, 34}, {"00010100", 8, 35}, {"00010101", 8, 36}, {"00010110", 8, 37}, {"00010111", 8, 38}, {"00101000", 8, 39}, {"00101001", 8, 40}, {"00101010", 8, 41}, {"00101011", 8, 42}, {"00101100", 8, 43}, {"00101101", 8, 44}, {"00000100", 8, 45}, {"00000101", 8, 46}, {"00001010", 8, 47}, {"00001011", 8, 48}, {"01010010", 8, 49}, {"01010011", 8, 50}, {"01010100", 8, 51}, {"01010101", 8, 52}, {"00100100", 8, 53}, {"00100101", 8, 54}, {"01011000", 8, 55}, {"01011001", 8, 56}, {"01011010", 8, 57}, {"01011011", 8, 58}, {"01001010", 8, 59}, {"01001011", 8, 60}, {"00110010", 8, 61}, {"00110011", 8, 62}, {"00110100", 8, 63}, {0,0,0} }; static struct huffcode makeupwhite[] = { {"11011", 5, 64}, {"10010", 5, 128}, {"010111", 6, 192}, {"0110111", 7, 256}, {"00110110", 8, 320}, {"00110111", 8, 384}, {"01100100", 8, 448}, {"01100101", 8, 512}, {"01101000", 8, 576}, {"01100111", 8, 640}, {"011001100", 9, 704}, {"011001101", 9, 768}, {"011010010", 9, 832}, {"011010011", 9, 896}, {"011010100", 9, 960}, {"011010101", 9, 1024}, {"011010110", 9, 1088}, {"011010111", 9, 1152}, {"011011000", 9, 1216}, {"011011001", 9, 1280}, {"011011010", 9, 1344}, {"011011011", 9, 1408}, {"010011000", 9, 1472}, {"010011001", 9, 1536}, {"010011010", 9, 1600}, {"011000", 6, 1664}, {"010011011", 9, 1728}, {0,0,0} }; static struct huffcode termblack[] = { {"0000110111", 10, 0}, {"010", 3, 1}, {"11", 2, 2}, {"10", 2, 3}, {"011", 3, 4}, {"0011", 4, 5}, {"0010", 4, 6}, {"00011", 5, 7}, {"000101", 6, 8}, {"000100", 6, 9}, {"0000100", 7, 10}, {"0000101", 7, 11}, {"0000111", 7, 12}, {"00000100", 8, 13}, {"00000111", 8, 14}, {"000011000", 9, 15}, {"0000010111", 10, 16}, {"0000011000", 10, 17}, {"0000001000", 10, 18}, {"00001100111", 11, 19}, {"00001101000", 11, 20}, {"00001101100", 11, 21}, {"00000110111", 11, 22}, {"00000101000", 11, 23}, {"00000010111", 11, 24}, {"00000011000", 11, 25}, {"000011001010", 12, 26}, {"000011001011", 12, 27}, {"000011001100", 12, 28}, {"000011001101", 12, 29}, {"000001101000", 12, 30}, {"000001101001", 12, 31}, {"000001101010", 12, 32}, {"000001101011", 12, 33}, {"000011010010", 12, 34}, {"000011010011", 12, 35}, {"000011010100", 12, 36}, {"000011010101", 12, 37}, {"000011010110", 12, 38}, {"000011010111", 12, 39}, {"000001101100", 12, 40}, {"000001101101", 12, 41}, {"000011011010", 12, 42}, {"000011011011", 12, 43}, {"000001010100", 12, 44}, {"000001010101", 12, 45}, {"000001010110", 12, 46}, {"000001010111", 12, 47}, {"000001100100", 12, 48}, {"000001100101", 12, 49}, {"000001010010", 12, 50}, {"000001010011", 12, 51}, {"000000100100", 12, 52}, {"000000110111", 12, 53}, {"000000111000", 12, 54}, {"000000100111", 12, 55}, {"000000101000", 12, 56}, {"000001011000", 12, 57}, {"000001011001", 12, 58}, {"000000101011", 12, 59}, {"000000101100", 12, 60}, {"000001011010", 12, 61}, {"000001100110", 12, 62}, {"000001100111", 12, 63}, {0,0,0} }; static struct huffcode makeupblack[] = { {"0000001111", 10, 64}, {"000011001000", 12, 128}, {"000011001001", 12, 192}, {"000001011011", 12, 256}, {"000000110011", 12, 320}, {"000000110100", 12, 384}, {"000000110101", 12, 448}, {"0000001101100", 13, 512}, {"0000001101101", 13, 576}, {"0000001001010", 13, 640}, {"0000001001011", 13, 704}, {"0000001001100", 13, 768}, {"0000001001101", 13, 832}, {"0000001110010", 13, 896}, {"0000001110011", 13, 960}, {"0000001110100", 13, 1024}, {"0000001110101", 13, 1088}, {"0000001110110", 13, 1152}, {"0000001110111", 13, 1216}, {"0000001010010", 13, 1280}, {"0000001010011", 13, 1344}, {"0000001010100", 13, 1408}, {"0000001010101", 13, 1472}, {"0000001011010", 13, 1536}, {"0000001011011", 13, 1600}, {"0000001100100", 13, 1664}, {"0000001100101", 13, 1728}, {0,0,0} }; static struct huffcode extmakeup[] = { {"00000001000", 11, 1792}, {"00000001100", 11, 1856}, {"00000001101", 11, 1920}, {"000000010010", 12, 1984}, {"000000010011", 12, 2048}, {"000000010100", 12, 2112}, {"000000010101", 12, 2176}, {"000000010110", 12, 2240}, {"000000010111", 12, 2304}, {"000000011100", 12, 2368}, {"000000011101", 12, 2432}, {"000000011110", 12, 2496}, {"000000011111", 12, 2560}, {0,0,0} }; static struct huffcode term[] = { {"000000000001", 12, -1}, {0,0,0} };