Guido Vollbeding | 1e247ac | 1998-03-28 00:00:00 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * jaricom.c |
| 3 | * |
| 4 | * Copyright (C) 1997, Guido Vollbeding <guivol@esc.de>. |
| 5 | * This file is NOT part of the Independent JPEG Group's software |
| 6 | * for legal reasons. |
| 7 | * See the accompanying README file for conditions of distribution and use. |
| 8 | * |
| 9 | * This file contains probability estimation tables for common use in |
| 10 | * arithmetic entropy encoding and decoding routines. |
| 11 | * |
| 12 | * This data represents Table D.2 in the JPEG spec (ISO/IEC IS 10918-1 |
| 13 | * and CCITT Recommendation ITU-T T.81) and Table 24 in the JBIG spec |
| 14 | * (ISO/IEC IS 11544 and CCITT Recommendation ITU-T T.82). |
| 15 | */ |
| 16 | |
| 17 | #define JPEG_INTERNALS |
| 18 | #include "jinclude.h" |
| 19 | #include "jpeglib.h" |
| 20 | |
| 21 | /* The following #define specifies the packing of the four components |
| 22 | * into the compact INT32 representation. |
| 23 | * Note that this formula must match the actual arithmetic encoder |
| 24 | * and decoder implementation. The implementation has to be changed |
| 25 | * if this formula is changed. |
| 26 | * The current organisation is leaned on Markus Kuhn's JBIG |
| 27 | * implementation (jbig_tab.c). |
| 28 | */ |
| 29 | |
| 30 | #define V(a,b,c,d) (((INT32)a << 16) | ((INT32)c << 8) | ((INT32)d << 7) | b) |
| 31 | |
| 32 | const INT32 jaritab[113] = { |
| 33 | /* |
| 34 | * Index, Qe_Value, Next_Index_LPS, Next_Index_MPS, Switch_MPS |
| 35 | */ |
| 36 | /* 0 */ V( 0x5a1d, 1, 1, 1 ), |
| 37 | /* 1 */ V( 0x2586, 14, 2, 0 ), |
| 38 | /* 2 */ V( 0x1114, 16, 3, 0 ), |
| 39 | /* 3 */ V( 0x080b, 18, 4, 0 ), |
| 40 | /* 4 */ V( 0x03d8, 20, 5, 0 ), |
| 41 | /* 5 */ V( 0x01da, 23, 6, 0 ), |
| 42 | /* 6 */ V( 0x00e5, 25, 7, 0 ), |
| 43 | /* 7 */ V( 0x006f, 28, 8, 0 ), |
| 44 | /* 8 */ V( 0x0036, 30, 9, 0 ), |
| 45 | /* 9 */ V( 0x001a, 33, 10, 0 ), |
| 46 | /* 10 */ V( 0x000d, 35, 11, 0 ), |
| 47 | /* 11 */ V( 0x0006, 9, 12, 0 ), |
| 48 | /* 12 */ V( 0x0003, 10, 13, 0 ), |
| 49 | /* 13 */ V( 0x0001, 12, 13, 0 ), |
| 50 | /* 14 */ V( 0x5a7f, 15, 15, 1 ), |
| 51 | /* 15 */ V( 0x3f25, 36, 16, 0 ), |
| 52 | /* 16 */ V( 0x2cf2, 38, 17, 0 ), |
| 53 | /* 17 */ V( 0x207c, 39, 18, 0 ), |
| 54 | /* 18 */ V( 0x17b9, 40, 19, 0 ), |
| 55 | /* 19 */ V( 0x1182, 42, 20, 0 ), |
| 56 | /* 20 */ V( 0x0cef, 43, 21, 0 ), |
| 57 | /* 21 */ V( 0x09a1, 45, 22, 0 ), |
| 58 | /* 22 */ V( 0x072f, 46, 23, 0 ), |
| 59 | /* 23 */ V( 0x055c, 48, 24, 0 ), |
| 60 | /* 24 */ V( 0x0406, 49, 25, 0 ), |
| 61 | /* 25 */ V( 0x0303, 51, 26, 0 ), |
| 62 | /* 26 */ V( 0x0240, 52, 27, 0 ), |
| 63 | /* 27 */ V( 0x01b1, 54, 28, 0 ), |
| 64 | /* 28 */ V( 0x0144, 56, 29, 0 ), |
| 65 | /* 29 */ V( 0x00f5, 57, 30, 0 ), |
| 66 | /* 30 */ V( 0x00b7, 59, 31, 0 ), |
| 67 | /* 31 */ V( 0x008a, 60, 32, 0 ), |
| 68 | /* 32 */ V( 0x0068, 62, 33, 0 ), |
| 69 | /* 33 */ V( 0x004e, 63, 34, 0 ), |
| 70 | /* 34 */ V( 0x003b, 32, 35, 0 ), |
| 71 | /* 35 */ V( 0x002c, 33, 9, 0 ), |
| 72 | /* 36 */ V( 0x5ae1, 37, 37, 1 ), |
| 73 | /* 37 */ V( 0x484c, 64, 38, 0 ), |
| 74 | /* 38 */ V( 0x3a0d, 65, 39, 0 ), |
| 75 | /* 39 */ V( 0x2ef1, 67, 40, 0 ), |
| 76 | /* 40 */ V( 0x261f, 68, 41, 0 ), |
| 77 | /* 41 */ V( 0x1f33, 69, 42, 0 ), |
| 78 | /* 42 */ V( 0x19a8, 70, 43, 0 ), |
| 79 | /* 43 */ V( 0x1518, 72, 44, 0 ), |
| 80 | /* 44 */ V( 0x1177, 73, 45, 0 ), |
| 81 | /* 45 */ V( 0x0e74, 74, 46, 0 ), |
| 82 | /* 46 */ V( 0x0bfb, 75, 47, 0 ), |
| 83 | /* 47 */ V( 0x09f8, 77, 48, 0 ), |
| 84 | /* 48 */ V( 0x0861, 78, 49, 0 ), |
| 85 | /* 49 */ V( 0x0706, 79, 50, 0 ), |
| 86 | /* 50 */ V( 0x05cd, 48, 51, 0 ), |
| 87 | /* 51 */ V( 0x04de, 50, 52, 0 ), |
| 88 | /* 52 */ V( 0x040f, 50, 53, 0 ), |
| 89 | /* 53 */ V( 0x0363, 51, 54, 0 ), |
| 90 | /* 54 */ V( 0x02d4, 52, 55, 0 ), |
| 91 | /* 55 */ V( 0x025c, 53, 56, 0 ), |
| 92 | /* 56 */ V( 0x01f8, 54, 57, 0 ), |
| 93 | /* 57 */ V( 0x01a4, 55, 58, 0 ), |
| 94 | /* 58 */ V( 0x0160, 56, 59, 0 ), |
| 95 | /* 59 */ V( 0x0125, 57, 60, 0 ), |
| 96 | /* 60 */ V( 0x00f6, 58, 61, 0 ), |
| 97 | /* 61 */ V( 0x00cb, 59, 62, 0 ), |
| 98 | /* 62 */ V( 0x00ab, 61, 63, 0 ), |
| 99 | /* 63 */ V( 0x008f, 61, 32, 0 ), |
| 100 | /* 64 */ V( 0x5b12, 65, 65, 1 ), |
| 101 | /* 65 */ V( 0x4d04, 80, 66, 0 ), |
| 102 | /* 66 */ V( 0x412c, 81, 67, 0 ), |
| 103 | /* 67 */ V( 0x37d8, 82, 68, 0 ), |
| 104 | /* 68 */ V( 0x2fe8, 83, 69, 0 ), |
| 105 | /* 69 */ V( 0x293c, 84, 70, 0 ), |
| 106 | /* 70 */ V( 0x2379, 86, 71, 0 ), |
| 107 | /* 71 */ V( 0x1edf, 87, 72, 0 ), |
| 108 | /* 72 */ V( 0x1aa9, 87, 73, 0 ), |
| 109 | /* 73 */ V( 0x174e, 72, 74, 0 ), |
| 110 | /* 74 */ V( 0x1424, 72, 75, 0 ), |
| 111 | /* 75 */ V( 0x119c, 74, 76, 0 ), |
| 112 | /* 76 */ V( 0x0f6b, 74, 77, 0 ), |
| 113 | /* 77 */ V( 0x0d51, 75, 78, 0 ), |
| 114 | /* 78 */ V( 0x0bb6, 77, 79, 0 ), |
| 115 | /* 79 */ V( 0x0a40, 77, 48, 0 ), |
| 116 | /* 80 */ V( 0x5832, 80, 81, 1 ), |
| 117 | /* 81 */ V( 0x4d1c, 88, 82, 0 ), |
| 118 | /* 82 */ V( 0x438e, 89, 83, 0 ), |
| 119 | /* 83 */ V( 0x3bdd, 90, 84, 0 ), |
| 120 | /* 84 */ V( 0x34ee, 91, 85, 0 ), |
| 121 | /* 85 */ V( 0x2eae, 92, 86, 0 ), |
| 122 | /* 86 */ V( 0x299a, 93, 87, 0 ), |
| 123 | /* 87 */ V( 0x2516, 86, 71, 0 ), |
| 124 | /* 88 */ V( 0x5570, 88, 89, 1 ), |
| 125 | /* 89 */ V( 0x4ca9, 95, 90, 0 ), |
| 126 | /* 90 */ V( 0x44d9, 96, 91, 0 ), |
| 127 | /* 91 */ V( 0x3e22, 97, 92, 0 ), |
| 128 | /* 92 */ V( 0x3824, 99, 93, 0 ), |
| 129 | /* 93 */ V( 0x32b4, 99, 94, 0 ), |
| 130 | /* 94 */ V( 0x2e17, 93, 86, 0 ), |
| 131 | /* 95 */ V( 0x56a8, 95, 96, 1 ), |
| 132 | /* 96 */ V( 0x4f46, 101, 97, 0 ), |
| 133 | /* 97 */ V( 0x47e5, 102, 98, 0 ), |
| 134 | /* 98 */ V( 0x41cf, 103, 99, 0 ), |
| 135 | /* 99 */ V( 0x3c3d, 104, 100, 0 ), |
| 136 | /* 100 */ V( 0x375e, 99, 93, 0 ), |
| 137 | /* 101 */ V( 0x5231, 105, 102, 0 ), |
| 138 | /* 102 */ V( 0x4c0f, 106, 103, 0 ), |
| 139 | /* 103 */ V( 0x4639, 107, 104, 0 ), |
| 140 | /* 104 */ V( 0x415e, 103, 99, 0 ), |
| 141 | /* 105 */ V( 0x5627, 105, 106, 1 ), |
| 142 | /* 106 */ V( 0x50e7, 108, 107, 0 ), |
| 143 | /* 107 */ V( 0x4b85, 109, 103, 0 ), |
| 144 | /* 108 */ V( 0x5597, 110, 109, 0 ), |
| 145 | /* 109 */ V( 0x504f, 111, 107, 0 ), |
| 146 | /* 110 */ V( 0x5a10, 110, 111, 1 ), |
| 147 | /* 111 */ V( 0x5522, 112, 109, 0 ), |
| 148 | /* 112 */ V( 0x59eb, 112, 111, 1 ) |
| 149 | }; |