/* Copyright (c) 2001-2011 Timothy B. Terriberry Copyright (c) 2008-2009 Xiph.Org Foundation */ /* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #if defined(HAVE_CONFIG_H) # include "config.h" #endif #include "os_support.h" #include "arch.h" #include "entenc.h" #include "mfrngcod.h" /*A range encoder. See entdec.c and the references for implementation details \cite{Mar79,MNW98}. @INPROCEEDINGS{Mar79, author="Martin, G.N.N.", title="Range encoding: an algorithm for removing redundancy from a digitised message", booktitle="Video \& Data Recording Conference", year=1979, address="Southampton", month=Jul } @ARTICLE{MNW98, author="Alistair Moffat and Radford Neal and Ian H. Witten", title="Arithmetic Coding Revisited", journal="{ACM} Transactions on Information Systems", year=1998, volume=16, number=3, pages="256--294", month=Jul, URL="http://www.stanford.edu/class/ee398/handouts/papers/Moffat98ArithmCoding.pdf" }*/ static int ec_write_byte(ec_enc *_this,unsigned _value){ … } static int ec_write_byte_at_end(ec_enc *_this,unsigned _value){ … } /*Outputs a symbol, with a carry bit. If there is a potential to propagate a carry over several symbols, they are buffered until it can be determined whether or not an actual carry will occur. If the counter for the buffered symbols overflows, then the stream becomes undecodable. This gives a theoretical limit of a few billion symbols in a single packet on 32-bit systems. The alternative is to truncate the range in order to force a carry, but requires similar carry tracking in the decoder, needlessly slowing it down.*/ static void ec_enc_carry_out(ec_enc *_this,int _c){ … } static OPUS_INLINE void ec_enc_normalize(ec_enc *_this){ … } void ec_enc_init(ec_enc *_this,unsigned char *_buf,opus_uint32 _size){ … } void ec_encode(ec_enc *_this,unsigned _fl,unsigned _fh,unsigned _ft){ … } void ec_encode_bin(ec_enc *_this,unsigned _fl,unsigned _fh,unsigned _bits){ … } /*The probability of having a "one" is 1/(1<<_logp).*/ void ec_enc_bit_logp(ec_enc *_this,int _val,unsigned _logp){ … } void ec_enc_icdf(ec_enc *_this,int _s,const unsigned char *_icdf,unsigned _ftb){ … } void ec_enc_uint(ec_enc *_this,opus_uint32 _fl,opus_uint32 _ft){ … } void ec_enc_bits(ec_enc *_this,opus_uint32 _fl,unsigned _bits){ … } void ec_enc_patch_initial_bits(ec_enc *_this,unsigned _val,unsigned _nbits){ … } void ec_enc_shrink(ec_enc *_this,opus_uint32 _size){ … } void ec_enc_done(ec_enc *_this){ … }