1*a58d3d2aSXin Li /* Copyright (c) 2001-2008 Timothy B. Terriberry 2*a58d3d2aSXin Li Copyright (c) 2008-2009 Xiph.Org Foundation */ 3*a58d3d2aSXin Li /* 4*a58d3d2aSXin Li Redistribution and use in source and binary forms, with or without 5*a58d3d2aSXin Li modification, are permitted provided that the following conditions 6*a58d3d2aSXin Li are met: 7*a58d3d2aSXin Li 8*a58d3d2aSXin Li - Redistributions of source code must retain the above copyright 9*a58d3d2aSXin Li notice, this list of conditions and the following disclaimer. 10*a58d3d2aSXin Li 11*a58d3d2aSXin Li - Redistributions in binary form must reproduce the above copyright 12*a58d3d2aSXin Li notice, this list of conditions and the following disclaimer in the 13*a58d3d2aSXin Li documentation and/or other materials provided with the distribution. 14*a58d3d2aSXin Li 15*a58d3d2aSXin Li THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16*a58d3d2aSXin Li ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17*a58d3d2aSXin Li LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18*a58d3d2aSXin Li A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 19*a58d3d2aSXin Li OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20*a58d3d2aSXin Li EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21*a58d3d2aSXin Li PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22*a58d3d2aSXin Li PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23*a58d3d2aSXin Li LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24*a58d3d2aSXin Li NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25*a58d3d2aSXin Li SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26*a58d3d2aSXin Li */ 27*a58d3d2aSXin Li 28*a58d3d2aSXin Li #if !defined(_mfrngcode_H) 29*a58d3d2aSXin Li # define _mfrngcode_H (1) 30*a58d3d2aSXin Li # include "entcode.h" 31*a58d3d2aSXin Li 32*a58d3d2aSXin Li /*Constants used by the entropy encoder/decoder.*/ 33*a58d3d2aSXin Li 34*a58d3d2aSXin Li /*The number of bits to output at a time.*/ 35*a58d3d2aSXin Li # define EC_SYM_BITS (8) 36*a58d3d2aSXin Li /*The total number of bits in each of the state registers.*/ 37*a58d3d2aSXin Li # define EC_CODE_BITS (32) 38*a58d3d2aSXin Li /*The maximum symbol value.*/ 39*a58d3d2aSXin Li # define EC_SYM_MAX ((1U<<EC_SYM_BITS)-1) 40*a58d3d2aSXin Li /*Bits to shift by to move a symbol into the high-order position.*/ 41*a58d3d2aSXin Li # define EC_CODE_SHIFT (EC_CODE_BITS-EC_SYM_BITS-1) 42*a58d3d2aSXin Li /*Carry bit of the high-order range symbol.*/ 43*a58d3d2aSXin Li # define EC_CODE_TOP (((opus_uint32)1U)<<(EC_CODE_BITS-1)) 44*a58d3d2aSXin Li /*Low-order bit of the high-order range symbol.*/ 45*a58d3d2aSXin Li # define EC_CODE_BOT (EC_CODE_TOP>>EC_SYM_BITS) 46*a58d3d2aSXin Li /*The number of bits available for the last, partial symbol in the code field.*/ 47*a58d3d2aSXin Li # define EC_CODE_EXTRA ((EC_CODE_BITS-2)%EC_SYM_BITS+1) 48*a58d3d2aSXin Li #endif 49