annotate src/opus-1.3/celt/entdec.h @ 169:223a55898ab9 tip default

Add null config files
author Chris Cannam <cannam@all-day-breakfast.com>
date Mon, 02 Mar 2020 14:03:47 +0000
parents 4664ac0c1032
children
rev   line source
cannam@154 1 /* Copyright (c) 2001-2011 Timothy B. Terriberry
cannam@154 2 Copyright (c) 2008-2009 Xiph.Org Foundation */
cannam@154 3 /*
cannam@154 4 Redistribution and use in source and binary forms, with or without
cannam@154 5 modification, are permitted provided that the following conditions
cannam@154 6 are met:
cannam@154 7
cannam@154 8 - Redistributions of source code must retain the above copyright
cannam@154 9 notice, this list of conditions and the following disclaimer.
cannam@154 10
cannam@154 11 - Redistributions in binary form must reproduce the above copyright
cannam@154 12 notice, this list of conditions and the following disclaimer in the
cannam@154 13 documentation and/or other materials provided with the distribution.
cannam@154 14
cannam@154 15 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
cannam@154 16 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
cannam@154 17 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
cannam@154 18 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
cannam@154 19 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
cannam@154 20 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
cannam@154 21 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
cannam@154 22 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
cannam@154 23 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
cannam@154 24 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
cannam@154 25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
cannam@154 26 */
cannam@154 27
cannam@154 28 #if !defined(_entdec_H)
cannam@154 29 # define _entdec_H (1)
cannam@154 30 # include <limits.h>
cannam@154 31 # include "entcode.h"
cannam@154 32
cannam@154 33 /*Initializes the decoder.
cannam@154 34 _buf: The input buffer to use.
cannam@154 35 Return: 0 on success, or a negative value on error.*/
cannam@154 36 void ec_dec_init(ec_dec *_this,unsigned char *_buf,opus_uint32 _storage);
cannam@154 37
cannam@154 38 /*Calculates the cumulative frequency for the next symbol.
cannam@154 39 This can then be fed into the probability model to determine what that
cannam@154 40 symbol is, and the additional frequency information required to advance to
cannam@154 41 the next symbol.
cannam@154 42 This function cannot be called more than once without a corresponding call to
cannam@154 43 ec_dec_update(), or decoding will not proceed correctly.
cannam@154 44 _ft: The total frequency of the symbols in the alphabet the next symbol was
cannam@154 45 encoded with.
cannam@154 46 Return: A cumulative frequency representing the encoded symbol.
cannam@154 47 If the cumulative frequency of all the symbols before the one that
cannam@154 48 was encoded was fl, and the cumulative frequency of all the symbols
cannam@154 49 up to and including the one encoded is fh, then the returned value
cannam@154 50 will fall in the range [fl,fh).*/
cannam@154 51 unsigned ec_decode(ec_dec *_this,unsigned _ft);
cannam@154 52
cannam@154 53 /*Equivalent to ec_decode() with _ft==1<<_bits.*/
cannam@154 54 unsigned ec_decode_bin(ec_dec *_this,unsigned _bits);
cannam@154 55
cannam@154 56 /*Advance the decoder past the next symbol using the frequency information the
cannam@154 57 symbol was encoded with.
cannam@154 58 Exactly one call to ec_decode() must have been made so that all necessary
cannam@154 59 intermediate calculations are performed.
cannam@154 60 _fl: The cumulative frequency of all symbols that come before the symbol
cannam@154 61 decoded.
cannam@154 62 _fh: The cumulative frequency of all symbols up to and including the symbol
cannam@154 63 decoded.
cannam@154 64 Together with _fl, this defines the range [_fl,_fh) in which the value
cannam@154 65 returned above must fall.
cannam@154 66 _ft: The total frequency of the symbols in the alphabet the symbol decoded
cannam@154 67 was encoded in.
cannam@154 68 This must be the same as passed to the preceding call to ec_decode().*/
cannam@154 69 void ec_dec_update(ec_dec *_this,unsigned _fl,unsigned _fh,unsigned _ft);
cannam@154 70
cannam@154 71 /* Decode a bit that has a 1/(1<<_logp) probability of being a one */
cannam@154 72 int ec_dec_bit_logp(ec_dec *_this,unsigned _logp);
cannam@154 73
cannam@154 74 /*Decodes a symbol given an "inverse" CDF table.
cannam@154 75 No call to ec_dec_update() is necessary after this call.
cannam@154 76 _icdf: The "inverse" CDF, such that symbol s falls in the range
cannam@154 77 [s>0?ft-_icdf[s-1]:0,ft-_icdf[s]), where ft=1<<_ftb.
cannam@154 78 The values must be monotonically non-increasing, and the last value
cannam@154 79 must be 0.
cannam@154 80 _ftb: The number of bits of precision in the cumulative distribution.
cannam@154 81 Return: The decoded symbol s.*/
cannam@154 82 int ec_dec_icdf(ec_dec *_this,const unsigned char *_icdf,unsigned _ftb);
cannam@154 83
cannam@154 84 /*Extracts a raw unsigned integer with a non-power-of-2 range from the stream.
cannam@154 85 The bits must have been encoded with ec_enc_uint().
cannam@154 86 No call to ec_dec_update() is necessary after this call.
cannam@154 87 _ft: The number of integers that can be decoded (one more than the max).
cannam@154 88 This must be at least 2, and no more than 2**32-1.
cannam@154 89 Return: The decoded bits.*/
cannam@154 90 opus_uint32 ec_dec_uint(ec_dec *_this,opus_uint32 _ft);
cannam@154 91
cannam@154 92 /*Extracts a sequence of raw bits from the stream.
cannam@154 93 The bits must have been encoded with ec_enc_bits().
cannam@154 94 No call to ec_dec_update() is necessary after this call.
cannam@154 95 _ftb: The number of bits to extract.
cannam@154 96 This must be between 0 and 25, inclusive.
cannam@154 97 Return: The decoded bits.*/
cannam@154 98 opus_uint32 ec_dec_bits(ec_dec *_this,unsigned _ftb);
cannam@154 99
cannam@154 100 #endif