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