Commit graph

23 commits

Author SHA1 Message Date
Timothy B. Terriberry
53454f4910 More simplifications to the decoder renormalization loop.
This removes an XOR, an ADD, and an AND, and replaces them with
 an AND NOT in ec_dec_normalize().
Also, simplify the loop structure of ec_dec_cdf() and eliminate a
 CMOV.
2010-12-18 09:06:06 -05:00
Timothy B. Terriberry
e86fb268b0 Replace ec_{enc|dec}_bit_prob() with ec_{enc|dec}_bit_logp().
All of our usage of ec_{enc|dec}_bit_prob had the probability of a
 "one" being a power of two.
This adds a new ec_{enc|dec}_bit_logp() function that takes this
 explicitly into account.
It introduces less rounding error than the bit_prob version, does not
 require 17-bit integers to be emulated by ec_{encode|decode}_bin(),
 and does not require any multiplies or divisions at all.
It is exactly equivalent to
 ec_encode_bin(enc,_val?0:(1<<_logp)-1,(1<<_logp)-(_val?1:0),1<<_logp)

The old ec_{enc|dec}_bit_prob functions are left in place for now,
 because I am not sure if SILK is still using them or not when
 combined in Opus.
2010-12-18 09:06:06 -05:00
Timothy B. Terriberry
8c23a3a0fd Subtract one from dif in the range decoder.
It turns out to be more convenient to store dif=low+rng-code-1
 instead of dif=low+rng-code.
This gets rid of a decrement in the normal decode path, replaces a
 decrement and an "and" in the normalization loop with a single
 add, and makes it clear that the new ec_dec_cdf() will not result
 in an infinite loop.
This does not change the bitstream.
2010-12-18 09:06:06 -05:00
Timothy B. Terriberry
a0b664df3d Add a generic CDF decoding routine.
This decodes a value encoded with ec_encode_bin() without using any
 divisions.
It is only meant for small alphabets.
If a symbol can take on a large number of possible values, a binary
 search would be better.

This patch also converts spread_decision to use it, since it is
 faster and introduces less rounding error to encode a single
 decision for the entire value than to encode it a bit at a time.
2010-12-17 14:21:43 -05:00
Jean-Marc Valin
aaedf1711c Simplifies convoluted raw bits calls. 2010-09-10 20:20:04 -04:00
Jean-Marc Valin
cef1d6ac0f Raw bit init for for architectures with chars larger than 8 bits 2010-09-02 10:16:56 -04:00
Jean-Marc Valin
531f2ae7e3 Remove useless use of "long", remove useless prototypes 2010-08-02 09:01:28 -04:00
Jean-Marc Valin
b1e017f58d Error checking on the decoder side 2010-07-18 21:20:35 -04:00
Timothy B. Terriberry
43e9406201 Change ec_{enc|dec}_bit_prob to take probabilities in units of 1/65536 instead of 1/256. This allows them to use a single 16x16->32 multiply instead of a 24x8->32 multiply. Also change the time-frequency resolution flag coding to ensure that "0" is always the most-probable symbol (i.e., that prob("1")<50%), as that's where all the rounding error accumulates. 2010-05-29 23:45:28 -04:00
Timothy B. Terriberry
299747ee24 Provide direct implementations ec_{enc|dec}_bit_prob() that do not require a division instead of using the normal entropy coder path. This should be exactly equivalent to the existing code. 2010-05-29 23:45:18 -04:00
Jean-Marc Valin
8b2ff0da5a Updated copyright notices 2009-10-17 21:40:10 -04:00
Jean-Marc Valin
949a29bf0c Raw bits encoding/decoding functions renamed to *_raw() and re-introducing
original ec_encode_bin()/ec_decode_bin() to optimize performance when ft is
a power of two.
2009-07-25 20:16:01 -04:00
Jean-Marc Valin
c08be4485b Implemented "raw bits"
Making it so all the information encoded directly with ec_enc_bits() gets
stored at the end of the stream, without going through the range coder. This
should be both faster and reduce the effects of bit errors.

Conflicts:

	tests/ectest.c
2009-07-23 07:33:24 -04:00
Timothy B. Terriberry
8d940a664e Change end-of-stream handling in the range coder.
Instead of trying to maximize the number of trailing zeros (minimize the number
 of bits encoded), we try to maximize the number of trailing bits that can
 contain arbitrary data.
Note that this requires ec_enc_tell() and ec_dec_tell() to reserve an extra
 bit, since depending on the exact final codeword, as little as half the final
 range might be available for storing arbitrary data.
This is the first step needed to start packing literal bits outside the range
 coder (for speed and robustness purposes).
2009-07-23 07:33:24 -04:00
Jean-Marc Valin
6fa4b56ba8 ietf doc: fixing up references, removed misleading comments in rangedec.c 2009-07-03 10:44:16 -04:00
Gregory Maxwell
f40bbf751d Include missing copyright information in various files, for signoff.
Signed-off-by: Timothy B. Terriberry <tterribe@xiph.org>
2009-02-03 23:08:31 -05:00
Timothy B.B Terriberry
d77f61ac22 Fixes some issues in the MF range coder on systems were ints are 16 bits. 2008-10-19 20:01:34 -04:00
Jean-Marc Valin
821945d97c Defining IMUL32 for 32x32=>32 int multiplications and using it in the range
coder
2008-04-10 13:24:48 +10:00
Jean-Marc Valin
fd8fda9937 Making a few functions static inline 2008-03-27 09:00:37 +11:00
Jean-Marc Valin
c2decd39a6 Made a second version of ec_{en|de}code optimised for encoding bits (no div
required) and using it in ec_{en|de}c_bits()
2008-03-22 22:58:45 +11:00
Jean-Marc Valin
71a84590e7 Removed unnecessary header inclusions 2008-03-14 11:09:50 +11:00
Jean-Marc Valin
02fa913c32 More C89 fixes, making sure to include config.h from all source files. 2008-02-20 12:09:29 +11:00
Jean-Marc Valin
6238bc0ece Moved the content of libentcode into libcelt to reduce dependencies,
especially now that we have a custom version of that code anyway. Moved
the test code to tests/
2008-01-28 22:28:54 +11:00
Renamed from libentcode/rangedec.c (Browse further)