1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/libopus/celt/entdec.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,100 @@ 1.4 +/* Copyright (c) 2001-2011 Timothy B. Terriberry 1.5 + Copyright (c) 2008-2009 Xiph.Org Foundation */ 1.6 +/* 1.7 + Redistribution and use in source and binary forms, with or without 1.8 + modification, are permitted provided that the following conditions 1.9 + are met: 1.10 + 1.11 + - Redistributions of source code must retain the above copyright 1.12 + notice, this list of conditions and the following disclaimer. 1.13 + 1.14 + - Redistributions in binary form must reproduce the above copyright 1.15 + notice, this list of conditions and the following disclaimer in the 1.16 + documentation and/or other materials provided with the distribution. 1.17 + 1.18 + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1.19 + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1.20 + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1.21 + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 1.22 + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 1.23 + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 1.24 + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 1.25 + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 1.26 + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 1.27 + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 1.28 + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 1.29 +*/ 1.30 + 1.31 +#if !defined(_entdec_H) 1.32 +# define _entdec_H (1) 1.33 +# include <limits.h> 1.34 +# include "entcode.h" 1.35 + 1.36 +/*Initializes the decoder. 1.37 + _buf: The input buffer to use. 1.38 + Return: 0 on success, or a negative value on error.*/ 1.39 +void ec_dec_init(ec_dec *_this,unsigned char *_buf,opus_uint32 _storage); 1.40 + 1.41 +/*Calculates the cumulative frequency for the next symbol. 1.42 + This can then be fed into the probability model to determine what that 1.43 + symbol is, and the additional frequency information required to advance to 1.44 + the next symbol. 1.45 + This function cannot be called more than once without a corresponding call to 1.46 + ec_dec_update(), or decoding will not proceed correctly. 1.47 + _ft: The total frequency of the symbols in the alphabet the next symbol was 1.48 + encoded with. 1.49 + Return: A cumulative frequency representing the encoded symbol. 1.50 + If the cumulative frequency of all the symbols before the one that 1.51 + was encoded was fl, and the cumulative frequency of all the symbols 1.52 + up to and including the one encoded is fh, then the returned value 1.53 + will fall in the range [fl,fh).*/ 1.54 +unsigned ec_decode(ec_dec *_this,unsigned _ft); 1.55 + 1.56 +/*Equivalent to ec_decode() with _ft==1<<_bits.*/ 1.57 +unsigned ec_decode_bin(ec_dec *_this,unsigned _bits); 1.58 + 1.59 +/*Advance the decoder past the next symbol using the frequency information the 1.60 + symbol was encoded with. 1.61 + Exactly one call to ec_decode() must have been made so that all necessary 1.62 + intermediate calculations are performed. 1.63 + _fl: The cumulative frequency of all symbols that come before the symbol 1.64 + decoded. 1.65 + _fh: The cumulative frequency of all symbols up to and including the symbol 1.66 + decoded. 1.67 + Together with _fl, this defines the range [_fl,_fh) in which the value 1.68 + returned above must fall. 1.69 + _ft: The total frequency of the symbols in the alphabet the symbol decoded 1.70 + was encoded in. 1.71 + This must be the same as passed to the preceding call to ec_decode().*/ 1.72 +void ec_dec_update(ec_dec *_this,unsigned _fl,unsigned _fh,unsigned _ft); 1.73 + 1.74 +/* Decode a bit that has a 1/(1<<_logp) probability of being a one */ 1.75 +int ec_dec_bit_logp(ec_dec *_this,unsigned _logp); 1.76 + 1.77 +/*Decodes a symbol given an "inverse" CDF table. 1.78 + No call to ec_dec_update() is necessary after this call. 1.79 + _icdf: The "inverse" CDF, such that symbol s falls in the range 1.80 + [s>0?ft-_icdf[s-1]:0,ft-_icdf[s]), where ft=1<<_ftb. 1.81 + The values must be monotonically non-increasing, and the last value 1.82 + must be 0. 1.83 + _ftb: The number of bits of precision in the cumulative distribution. 1.84 + Return: The decoded symbol s.*/ 1.85 +int ec_dec_icdf(ec_dec *_this,const unsigned char *_icdf,unsigned _ftb); 1.86 + 1.87 +/*Extracts a raw unsigned integer with a non-power-of-2 range from the stream. 1.88 + The bits must have been encoded with ec_enc_uint(). 1.89 + No call to ec_dec_update() is necessary after this call. 1.90 + _ft: The number of integers that can be decoded (one more than the max). 1.91 + This must be at least one, and no more than 2**32-1. 1.92 + Return: The decoded bits.*/ 1.93 +opus_uint32 ec_dec_uint(ec_dec *_this,opus_uint32 _ft); 1.94 + 1.95 +/*Extracts a sequence of raw bits from the stream. 1.96 + The bits must have been encoded with ec_enc_bits(). 1.97 + No call to ec_dec_update() is necessary after this call. 1.98 + _ftb: The number of bits to extract. 1.99 + This must be between 0 and 25, inclusive. 1.100 + Return: The decoded bits.*/ 1.101 +opus_uint32 ec_dec_bits(ec_dec *_this,unsigned _ftb); 1.102 + 1.103 +#endif