< prev index next >

src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFFaxDecompressor.java

Print this page


   1 /*
   2  * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  54      * that the EOL ends on a byte boundary, 0 otherwise.
  55      */
  56     private int fillBits = 0;
  57 
  58     /**
  59      * Coding dimensionality: 1 for 2-dimensional, 0 for 1-dimensional.
  60      */
  61     private int oneD;
  62 
  63     private byte[] data;
  64     private int bitPointer, bytePointer;
  65 
  66     // Output image buffer
  67     private byte[] buffer;
  68     private int w, h, bitsPerScanline;
  69     private int lineBitNum;
  70 
  71     // Data structures needed to store changing elements for the previous
  72     // and the current scanline
  73     private int changingElemSize = 0;
  74     private int prevChangingElems[];
  75     private int currChangingElems[];
  76 
  77     // Element at which to start search in getNextChangingElement
  78     private int lastChangingElement = 0;
  79 
  80     private static int table1[] = {
  81         0x00, // 0 bits are left in first byte - SHOULD NOT HAPPEN
  82         0x01, // 1 bits are left in first byte
  83         0x03, // 2 bits are left in first byte
  84         0x07, // 3 bits are left in first byte
  85         0x0f, // 4 bits are left in first byte
  86         0x1f, // 5 bits are left in first byte
  87         0x3f, // 6 bits are left in first byte
  88         0x7f, // 7 bits are left in first byte
  89         0xff  // 8 bits are left in first byte
  90     };
  91 
  92     private static int table2[] = {
  93         0x00, // 0
  94         0x80, // 1
  95         0xc0, // 2
  96         0xe0, // 3
  97         0xf0, // 4
  98         0xf8, // 5
  99         0xfc, // 6
 100         0xfe, // 7
 101         0xff  // 8
 102     };
 103 
 104     // Table to be used for flipping bytes when fillOrder is
 105     // BaselineTIFFTagSet.FILL_ORDER_RIGHT_TO_LEFT (2).
 106     static byte flipTable[] = {
 107          0,  -128,    64,   -64,    32,   -96,    96,   -32,
 108         16,  -112,    80,   -48,    48,   -80,   112,   -16,
 109          8,  -120,    72,   -56,    40,   -88,   104,   -24,
 110         24,  -104,    88,   -40,    56,   -72,   120,    -8,
 111          4,  -124,    68,   -60,    36,   -92,   100,   -28,
 112         20,  -108,    84,   -44,    52,   -76,   116,   -12,
 113         12,  -116,    76,   -52,    44,   -84,   108,   -20,
 114         28,  -100,    92,   -36,    60,   -68,   124,    -4,
 115          2,  -126,    66,   -62,    34,   -94,    98,   -30,
 116         18,  -110,    82,   -46,    50,   -78,   114,   -14,
 117         10,  -118,    74,   -54,    42,   -86,   106,   -22,
 118         26,  -102,    90,   -38,    58,   -70,   122,    -6,
 119          6,  -122,    70,   -58,    38,   -90,   102,   -26,
 120         22,  -106,    86,   -42,    54,   -74,   118,   -10,
 121         14,  -114,    78,   -50,    46,   -82,   110,   -18,
 122         30,   -98,    94,   -34,    62,   -66,   126,    -2,
 123          1,  -127,    65,   -63,    33,   -95,    97,   -31,
 124         17,  -111,    81,   -47,    49,   -79,   113,   -15,
 125          9,  -119,    73,   -55,    41,   -87,   105,   -23,
 126         25,  -103,    89,   -39,    57,   -71,   121,    -7,
 127          5,  -123,    69,   -59,    37,   -91,   101,   -27,
 128         21,  -107,    85,   -43,    53,   -75,   117,   -11,
 129         13,  -115,    77,   -51,    45,   -83,   109,   -19,
 130         29,   -99,    93,   -35,    61,   -67,   125,    -3,
 131          3,  -125,    67,   -61,    35,   -93,    99,   -29,
 132         19,  -109,    83,   -45,    51,   -77,   115,   -13,
 133         11,  -117,    75,   -53,    43,   -85,   107,   -21,
 134         27,  -101,    91,   -37,    59,   -69,   123,    -5,
 135          7,  -121,    71,   -57,    39,   -89,   103,   -25,
 136         23,  -105,    87,   -41,    55,   -73,   119,    -9,
 137         15,  -113,    79,   -49,    47,   -81,   111,   -17,
 138         31,   -97,    95,   -33,    63,   -65,   127,    -1,
 139     };
 140 
 141     // The main 10 bit white runs lookup table
 142     private static short white[] = {
 143         // 0 - 7
 144         6430,   6400,   6400,   6400,   3225,   3225,   3225,   3225,
 145         // 8 - 15
 146         944,    944,    944,    944,    976,    976,    976,    976,
 147         // 16 - 23
 148         1456,   1456,   1456,   1456,   1488,   1488,   1488,   1488,
 149         // 24 - 31
 150         718,    718,    718,    718,    718,    718,    718,    718,
 151         // 32 - 39
 152         750,    750,    750,    750,    750,    750,    750,    750,
 153         // 40 - 47
 154         1520,   1520,   1520,   1520,   1552,   1552,   1552,   1552,
 155         // 48 - 55
 156         428,    428,    428,    428,    428,    428,    428,    428,
 157         // 56 - 63
 158         428,    428,    428,    428,    428,    428,    428,    428,
 159         // 64 - 71
 160         654,    654,    654,    654,    654,    654,    654,    654,
 161         // 72 - 79
 162         1072,   1072,   1072,   1072,   1104,   1104,   1104,   1104,


 382         200,    200,    200,    200,    200,    200,    200,    200,
 383         // 960 - 967
 384         232,    232,    232,    232,    232,    232,    232,    232,
 385         // 968 - 975
 386         232,    232,    232,    232,    232,    232,    232,    232,
 387         // 976 - 983
 388         232,    232,    232,    232,    232,    232,    232,    232,
 389         // 984 - 991
 390         232,    232,    232,    232,    232,    232,    232,    232,
 391         // 992 - 999
 392         232,    232,    232,    232,    232,    232,    232,    232,
 393         // 1000 - 1007
 394         232,    232,    232,    232,    232,    232,    232,    232,
 395         // 1008 - 1015
 396         232,    232,    232,    232,    232,    232,    232,    232,
 397         // 1016 - 1023
 398         232,    232,    232,    232,    232,    232,    232,    232,
 399     };
 400 
 401     // Additional make up codes for both White and Black runs
 402     private static short additionalMakeup[] = {
 403         28679,  28679,  31752,  (short)32777,
 404         (short)33801,  (short)34825,  (short)35849,  (short)36873,
 405         (short)29703,  (short)29703,  (short)30727,  (short)30727,
 406         (short)37897,  (short)38921,  (short)39945,  (short)40969
 407     };
 408 
 409     // Initial black run look up table, uses the first 4 bits of a code
 410     private static short initBlack[] = {
 411         // 0 - 7
 412         3226,  6412,    200,    168,    38,     38,    134,    134,
 413         // 8 - 15
 414         100,    100,    100,    100,    68,     68,     68,     68
 415     };
 416 
 417     //
 418     private static short twoBitBlack[] = {292, 260, 226, 226};   // 0 - 3
 419 
 420     // Main black run table, using the last 9 bits of possible 13 bit code
 421     private static short black[] = {
 422         // 0 - 7
 423         62,     62,     30,     30,     0,      0,      0,      0,
 424         // 8 - 15
 425         0,      0,      0,      0,      0,      0,      0,      0,
 426         // 16 - 23
 427         0,      0,      0,      0,      0,      0,      0,      0,
 428         // 24 - 31
 429         0,      0,      0,      0,      0,      0,      0,      0,
 430         // 32 - 39
 431         3225,   3225,   3225,   3225,   3225,   3225,   3225,   3225,
 432         // 40 - 47
 433         3225,   3225,   3225,   3225,   3225,   3225,   3225,   3225,
 434         // 48 - 55
 435         3225,   3225,   3225,   3225,   3225,   3225,   3225,   3225,
 436         // 56 - 63
 437         3225,   3225,   3225,   3225,   3225,   3225,   3225,   3225,
 438         // 64 - 71
 439         588,    588,    588,    588,    588,    588,    588,    588,
 440         // 72 - 79
 441         1680,   1680,  20499,  22547,  24595,  26643,   1776,   1776,


 532         // 440 - 447
 533         12,     12,     12,     12,     12,     12,     12,     12,
 534         // 448 - 455
 535         390,    390,    390,    390,    390,    390,    390,    390,
 536         // 456 - 463
 537         390,    390,    390,    390,    390,    390,    390,    390,
 538         // 464 - 471
 539         390,    390,    390,    390,    390,    390,    390,    390,
 540         // 472 - 479
 541         390,    390,    390,    390,    390,    390,    390,    390,
 542         // 480 - 487
 543         390,    390,    390,    390,    390,    390,    390,    390,
 544         // 488 - 495
 545         390,    390,    390,    390,    390,    390,    390,    390,
 546         // 496 - 503
 547         390,    390,    390,    390,    390,    390,    390,    390,
 548         // 504 - 511
 549         390,    390,    390,    390,    390,    390,    390,    390,
 550     };
 551 
 552     private static byte twoDCodes[] = {
 553         // 0 - 7
 554         80,     88,     23,     71,     30,     30,     62,     62,
 555         // 8 - 15
 556         4,      4,      4,      4,      4,      4,      4,      4,
 557         // 16 - 23
 558         11,     11,     11,     11,     11,     11,     11,     11,
 559         // 24 - 31
 560         11,     11,     11,     11,     11,     11,     11,     11,
 561         // 32 - 39
 562         35,     35,     35,     35,     35,     35,     35,     35,
 563         // 40 - 47
 564         35,     35,     35,     35,     35,     35,     35,     35,
 565         // 48 - 55
 566         51,     51,     51,     51,     51,     51,     51,     51,
 567         // 56 - 63
 568         51,     51,     51,     51,     51,     51,     51,     51,
 569         // 64 - 71
 570         41,     41,     41,     41,     41,     41,     41,     41,
 571         // 72 - 79
 572         41,     41,     41,     41,     41,     41,     41,     41,


 836                    runLength != 0 && runLength % 64 == 0 &&
 837                    nextNBits(10) != 0x37) {
 838                     warning("Missing zero black run length terminating code!");
 839                     updatePointer(10);
 840                 }
 841                 break;
 842             }
 843         }
 844 
 845         currChangingElems[changingElemSize++] = bitOffset;
 846     }
 847 
 848     public void decodeT4() throws IIOException {
 849         int height = h;
 850 
 851         int a0, a1, b1, b2;
 852         int[] b = new int[2];
 853         int entry, code, bits, color;
 854         boolean isWhite;
 855         int currIndex = 0;
 856         int temp[];
 857 
 858         if(data.length < 2) {
 859             throw new IIOException("Insufficient data to read initial EOL.");
 860         }
 861 
 862         // The data should start with an EOL code
 863         int next12 = nextNBits(12);
 864         if(next12 != 1) {
 865             warning("T.4 compressed data should begin with EOL.");
 866         }
 867         updatePointer(12);
 868 
 869         // Find the first one-dimensionally encoded line.
 870         int modeFlag = 0;
 871         int lines = -1; // indicates imaginary line before first actual line.
 872         while(modeFlag != 1) {
 873             try {
 874                 modeFlag = findNextLine();
 875                 lines++; // Normally 'lines' will be 0 on exiting loop.
 876             } catch(EOFException eofe) {


1012             } else { // modeFlag == 1
1013                 // 1D encoded scanline follows
1014                 decodeNextScanline(srcMinY+lines);
1015             }
1016 
1017             lineBitNum += bitsPerScanline;
1018             lines++;
1019         } // while(lines < height)
1020     }
1021 
1022     public synchronized void decodeT6() throws IIOException {
1023         int height = h;
1024 
1025         int bufferOffset = 0;
1026 
1027         int a0, a1, b1, b2;
1028         int entry, code, bits;
1029         byte color;
1030         boolean isWhite;
1031         int currIndex;
1032         int temp[];
1033 
1034         // Return values from getNextChangingElement
1035         int[] b = new int[2];
1036 
1037         // uncompressedMode - have written some code for this, but this
1038         // has not been tested due to lack of test images using this optional
1039         // extension. This code is when code == 11. aastha 03/03/1999
1040 
1041         // Local cached reference
1042         int[] cce = currChangingElems;
1043 
1044         // Assume invisible preceding row of all white pixels and insert
1045         // both black and white changing elements beyond the end of this
1046         // imaginary scanline.
1047         changingElemSize = 0;
1048         cce[changingElemSize++] = w;
1049         cce[changingElemSize++] = w;
1050 
1051         int bitOffset;
1052 


   1 /*
   2  * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  54      * that the EOL ends on a byte boundary, 0 otherwise.
  55      */
  56     private int fillBits = 0;
  57 
  58     /**
  59      * Coding dimensionality: 1 for 2-dimensional, 0 for 1-dimensional.
  60      */
  61     private int oneD;
  62 
  63     private byte[] data;
  64     private int bitPointer, bytePointer;
  65 
  66     // Output image buffer
  67     private byte[] buffer;
  68     private int w, h, bitsPerScanline;
  69     private int lineBitNum;
  70 
  71     // Data structures needed to store changing elements for the previous
  72     // and the current scanline
  73     private int changingElemSize = 0;
  74     private int[] prevChangingElems;
  75     private int[] currChangingElems;
  76 
  77     // Element at which to start search in getNextChangingElement
  78     private int lastChangingElement = 0;
  79 
  80     private static int[] table1 = {
  81         0x00, // 0 bits are left in first byte - SHOULD NOT HAPPEN
  82         0x01, // 1 bits are left in first byte
  83         0x03, // 2 bits are left in first byte
  84         0x07, // 3 bits are left in first byte
  85         0x0f, // 4 bits are left in first byte
  86         0x1f, // 5 bits are left in first byte
  87         0x3f, // 6 bits are left in first byte
  88         0x7f, // 7 bits are left in first byte
  89         0xff  // 8 bits are left in first byte
  90     };
  91 
  92     private static int[] table2 = {
  93         0x00, // 0
  94         0x80, // 1
  95         0xc0, // 2
  96         0xe0, // 3
  97         0xf0, // 4
  98         0xf8, // 5
  99         0xfc, // 6
 100         0xfe, // 7
 101         0xff  // 8
 102     };
 103 
 104     // Table to be used for flipping bytes when fillOrder is
 105     // BaselineTIFFTagSet.FILL_ORDER_RIGHT_TO_LEFT (2).
 106     static byte[] flipTable = {
 107          0,  -128,    64,   -64,    32,   -96,    96,   -32,
 108         16,  -112,    80,   -48,    48,   -80,   112,   -16,
 109          8,  -120,    72,   -56,    40,   -88,   104,   -24,
 110         24,  -104,    88,   -40,    56,   -72,   120,    -8,
 111          4,  -124,    68,   -60,    36,   -92,   100,   -28,
 112         20,  -108,    84,   -44,    52,   -76,   116,   -12,
 113         12,  -116,    76,   -52,    44,   -84,   108,   -20,
 114         28,  -100,    92,   -36,    60,   -68,   124,    -4,
 115          2,  -126,    66,   -62,    34,   -94,    98,   -30,
 116         18,  -110,    82,   -46,    50,   -78,   114,   -14,
 117         10,  -118,    74,   -54,    42,   -86,   106,   -22,
 118         26,  -102,    90,   -38,    58,   -70,   122,    -6,
 119          6,  -122,    70,   -58,    38,   -90,   102,   -26,
 120         22,  -106,    86,   -42,    54,   -74,   118,   -10,
 121         14,  -114,    78,   -50,    46,   -82,   110,   -18,
 122         30,   -98,    94,   -34,    62,   -66,   126,    -2,
 123          1,  -127,    65,   -63,    33,   -95,    97,   -31,
 124         17,  -111,    81,   -47,    49,   -79,   113,   -15,
 125          9,  -119,    73,   -55,    41,   -87,   105,   -23,
 126         25,  -103,    89,   -39,    57,   -71,   121,    -7,
 127          5,  -123,    69,   -59,    37,   -91,   101,   -27,
 128         21,  -107,    85,   -43,    53,   -75,   117,   -11,
 129         13,  -115,    77,   -51,    45,   -83,   109,   -19,
 130         29,   -99,    93,   -35,    61,   -67,   125,    -3,
 131          3,  -125,    67,   -61,    35,   -93,    99,   -29,
 132         19,  -109,    83,   -45,    51,   -77,   115,   -13,
 133         11,  -117,    75,   -53,    43,   -85,   107,   -21,
 134         27,  -101,    91,   -37,    59,   -69,   123,    -5,
 135          7,  -121,    71,   -57,    39,   -89,   103,   -25,
 136         23,  -105,    87,   -41,    55,   -73,   119,    -9,
 137         15,  -113,    79,   -49,    47,   -81,   111,   -17,
 138         31,   -97,    95,   -33,    63,   -65,   127,    -1,
 139     };
 140 
 141     // The main 10 bit white runs lookup table
 142     private static short[] white = {
 143         // 0 - 7
 144         6430,   6400,   6400,   6400,   3225,   3225,   3225,   3225,
 145         // 8 - 15
 146         944,    944,    944,    944,    976,    976,    976,    976,
 147         // 16 - 23
 148         1456,   1456,   1456,   1456,   1488,   1488,   1488,   1488,
 149         // 24 - 31
 150         718,    718,    718,    718,    718,    718,    718,    718,
 151         // 32 - 39
 152         750,    750,    750,    750,    750,    750,    750,    750,
 153         // 40 - 47
 154         1520,   1520,   1520,   1520,   1552,   1552,   1552,   1552,
 155         // 48 - 55
 156         428,    428,    428,    428,    428,    428,    428,    428,
 157         // 56 - 63
 158         428,    428,    428,    428,    428,    428,    428,    428,
 159         // 64 - 71
 160         654,    654,    654,    654,    654,    654,    654,    654,
 161         // 72 - 79
 162         1072,   1072,   1072,   1072,   1104,   1104,   1104,   1104,


 382         200,    200,    200,    200,    200,    200,    200,    200,
 383         // 960 - 967
 384         232,    232,    232,    232,    232,    232,    232,    232,
 385         // 968 - 975
 386         232,    232,    232,    232,    232,    232,    232,    232,
 387         // 976 - 983
 388         232,    232,    232,    232,    232,    232,    232,    232,
 389         // 984 - 991
 390         232,    232,    232,    232,    232,    232,    232,    232,
 391         // 992 - 999
 392         232,    232,    232,    232,    232,    232,    232,    232,
 393         // 1000 - 1007
 394         232,    232,    232,    232,    232,    232,    232,    232,
 395         // 1008 - 1015
 396         232,    232,    232,    232,    232,    232,    232,    232,
 397         // 1016 - 1023
 398         232,    232,    232,    232,    232,    232,    232,    232,
 399     };
 400 
 401     // Additional make up codes for both White and Black runs
 402     private static short[] additionalMakeup = {
 403         28679,  28679,  31752,  (short)32777,
 404         (short)33801,  (short)34825,  (short)35849,  (short)36873,
 405         (short)29703,  (short)29703,  (short)30727,  (short)30727,
 406         (short)37897,  (short)38921,  (short)39945,  (short)40969
 407     };
 408 
 409     // Initial black run look up table, uses the first 4 bits of a code
 410     private static short[] initBlack = {
 411         // 0 - 7
 412         3226,  6412,    200,    168,    38,     38,    134,    134,
 413         // 8 - 15
 414         100,    100,    100,    100,    68,     68,     68,     68
 415     };
 416 
 417     //
 418     private static short[] twoBitBlack = {292, 260, 226, 226};   // 0 - 3
 419 
 420     // Main black run table, using the last 9 bits of possible 13 bit code
 421     private static short[] black = {
 422         // 0 - 7
 423         62,     62,     30,     30,     0,      0,      0,      0,
 424         // 8 - 15
 425         0,      0,      0,      0,      0,      0,      0,      0,
 426         // 16 - 23
 427         0,      0,      0,      0,      0,      0,      0,      0,
 428         // 24 - 31
 429         0,      0,      0,      0,      0,      0,      0,      0,
 430         // 32 - 39
 431         3225,   3225,   3225,   3225,   3225,   3225,   3225,   3225,
 432         // 40 - 47
 433         3225,   3225,   3225,   3225,   3225,   3225,   3225,   3225,
 434         // 48 - 55
 435         3225,   3225,   3225,   3225,   3225,   3225,   3225,   3225,
 436         // 56 - 63
 437         3225,   3225,   3225,   3225,   3225,   3225,   3225,   3225,
 438         // 64 - 71
 439         588,    588,    588,    588,    588,    588,    588,    588,
 440         // 72 - 79
 441         1680,   1680,  20499,  22547,  24595,  26643,   1776,   1776,


 532         // 440 - 447
 533         12,     12,     12,     12,     12,     12,     12,     12,
 534         // 448 - 455
 535         390,    390,    390,    390,    390,    390,    390,    390,
 536         // 456 - 463
 537         390,    390,    390,    390,    390,    390,    390,    390,
 538         // 464 - 471
 539         390,    390,    390,    390,    390,    390,    390,    390,
 540         // 472 - 479
 541         390,    390,    390,    390,    390,    390,    390,    390,
 542         // 480 - 487
 543         390,    390,    390,    390,    390,    390,    390,    390,
 544         // 488 - 495
 545         390,    390,    390,    390,    390,    390,    390,    390,
 546         // 496 - 503
 547         390,    390,    390,    390,    390,    390,    390,    390,
 548         // 504 - 511
 549         390,    390,    390,    390,    390,    390,    390,    390,
 550     };
 551 
 552     private static byte[] twoDCodes = {
 553         // 0 - 7
 554         80,     88,     23,     71,     30,     30,     62,     62,
 555         // 8 - 15
 556         4,      4,      4,      4,      4,      4,      4,      4,
 557         // 16 - 23
 558         11,     11,     11,     11,     11,     11,     11,     11,
 559         // 24 - 31
 560         11,     11,     11,     11,     11,     11,     11,     11,
 561         // 32 - 39
 562         35,     35,     35,     35,     35,     35,     35,     35,
 563         // 40 - 47
 564         35,     35,     35,     35,     35,     35,     35,     35,
 565         // 48 - 55
 566         51,     51,     51,     51,     51,     51,     51,     51,
 567         // 56 - 63
 568         51,     51,     51,     51,     51,     51,     51,     51,
 569         // 64 - 71
 570         41,     41,     41,     41,     41,     41,     41,     41,
 571         // 72 - 79
 572         41,     41,     41,     41,     41,     41,     41,     41,


 836                    runLength != 0 && runLength % 64 == 0 &&
 837                    nextNBits(10) != 0x37) {
 838                     warning("Missing zero black run length terminating code!");
 839                     updatePointer(10);
 840                 }
 841                 break;
 842             }
 843         }
 844 
 845         currChangingElems[changingElemSize++] = bitOffset;
 846     }
 847 
 848     public void decodeT4() throws IIOException {
 849         int height = h;
 850 
 851         int a0, a1, b1, b2;
 852         int[] b = new int[2];
 853         int entry, code, bits, color;
 854         boolean isWhite;
 855         int currIndex = 0;
 856         int[] temp;
 857 
 858         if(data.length < 2) {
 859             throw new IIOException("Insufficient data to read initial EOL.");
 860         }
 861 
 862         // The data should start with an EOL code
 863         int next12 = nextNBits(12);
 864         if(next12 != 1) {
 865             warning("T.4 compressed data should begin with EOL.");
 866         }
 867         updatePointer(12);
 868 
 869         // Find the first one-dimensionally encoded line.
 870         int modeFlag = 0;
 871         int lines = -1; // indicates imaginary line before first actual line.
 872         while(modeFlag != 1) {
 873             try {
 874                 modeFlag = findNextLine();
 875                 lines++; // Normally 'lines' will be 0 on exiting loop.
 876             } catch(EOFException eofe) {


1012             } else { // modeFlag == 1
1013                 // 1D encoded scanline follows
1014                 decodeNextScanline(srcMinY+lines);
1015             }
1016 
1017             lineBitNum += bitsPerScanline;
1018             lines++;
1019         } // while(lines < height)
1020     }
1021 
1022     public synchronized void decodeT6() throws IIOException {
1023         int height = h;
1024 
1025         int bufferOffset = 0;
1026 
1027         int a0, a1, b1, b2;
1028         int entry, code, bits;
1029         byte color;
1030         boolean isWhite;
1031         int currIndex;
1032         int[] temp;
1033 
1034         // Return values from getNextChangingElement
1035         int[] b = new int[2];
1036 
1037         // uncompressedMode - have written some code for this, but this
1038         // has not been tested due to lack of test images using this optional
1039         // extension. This code is when code == 11. aastha 03/03/1999
1040 
1041         // Local cached reference
1042         int[] cce = currChangingElems;
1043 
1044         // Assume invisible preceding row of all white pixels and insert
1045         // both black and white changing elements beyond the end of this
1046         // imaginary scanline.
1047         changingElemSize = 0;
1048         cce[changingElemSize++] = w;
1049         cce[changingElemSize++] = w;
1050 
1051         int bitOffset;
1052 


< prev index next >