| OLD | NEW |
| 1 /* Copyright (c) 2001-2011 Timothy B. Terriberry | 1 /* Copyright (c) 2001-2011 Timothy B. Terriberry |
| 2 Copyright (c) 2008-2009 Xiph.Org Foundation */ | 2 Copyright (c) 2008-2009 Xiph.Org Foundation */ |
| 3 /* | 3 /* |
| 4 Redistribution and use in source and binary forms, with or without | 4 Redistribution and use in source and binary forms, with or without |
| 5 modification, are permitted provided that the following conditions | 5 modification, are permitted provided that the following conditions |
| 6 are met: | 6 are met: |
| 7 | 7 |
| 8 - Redistributions of source code must retain the above copyright | 8 - Redistributions of source code must retain the above copyright |
| 9 notice, this list of conditions and the following disclaimer. | 9 notice, this list of conditions and the following disclaimer. |
| 10 | 10 |
| 11 - Redistributions in binary form must reproduce the above copyright | 11 - Redistributions in binary form must reproduce the above copyright |
| 12 notice, this list of conditions and the following disclaimer in the | 12 notice, this list of conditions and the following disclaimer in the |
| 13 documentation and/or other materials provided with the distribution. | 13 documentation and/or other materials provided with the distribution. |
| 14 | 14 |
| 15 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 15 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 16 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 16 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 17 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 17 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 18 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER | 18 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER |
| 19 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 19 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 20 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 20 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 21 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 21 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 22 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | 22 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| 23 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 23 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 24 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 */ | 26 */ |
| 27 | 27 |
| 28 #include "opus_types.h" | 28 #include "opus_types.h" |
| 29 #include "opus_defines.h" |
| 29 | 30 |
| 30 #if !defined(_entcode_H) | 31 #if !defined(_entcode_H) |
| 31 # define _entcode_H (1) | 32 # define _entcode_H (1) |
| 32 # include <limits.h> | 33 # include <limits.h> |
| 33 # include <stddef.h> | 34 # include <stddef.h> |
| 34 # include "ecintrin.h" | 35 # include "ecintrin.h" |
| 35 | 36 |
| 36 /*OPT: ec_window must be at least 32 bits, but if you have fast arithmetic on a | 37 /*OPT: ec_window must be at least 32 bits, but if you have fast arithmetic on a |
| 37 larger type, you can speed up the decoder by using it here.*/ | 38 larger type, you can speed up the decoder by using it here.*/ |
| 38 typedef opus_uint32 ec_window; | 39 typedef opus_uint32 ec_window; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 opus_uint32 val; | 77 opus_uint32 val; |
| 77 /*In the decoder: the saved normalization factor from ec_decode(). | 78 /*In the decoder: the saved normalization factor from ec_decode(). |
| 78 In the encoder: the number of oustanding carry propagating symbols.*/ | 79 In the encoder: the number of oustanding carry propagating symbols.*/ |
| 79 opus_uint32 ext; | 80 opus_uint32 ext; |
| 80 /*A buffered input/output symbol, awaiting carry propagation.*/ | 81 /*A buffered input/output symbol, awaiting carry propagation.*/ |
| 81 int rem; | 82 int rem; |
| 82 /*Nonzero if an error occurred.*/ | 83 /*Nonzero if an error occurred.*/ |
| 83 int error; | 84 int error; |
| 84 }; | 85 }; |
| 85 | 86 |
| 86 static inline opus_uint32 ec_range_bytes(ec_ctx *_this){ | 87 static OPUS_INLINE opus_uint32 ec_range_bytes(ec_ctx *_this){ |
| 87 return _this->offs; | 88 return _this->offs; |
| 88 } | 89 } |
| 89 | 90 |
| 90 static inline unsigned char *ec_get_buffer(ec_ctx *_this){ | 91 static OPUS_INLINE unsigned char *ec_get_buffer(ec_ctx *_this){ |
| 91 return _this->buf; | 92 return _this->buf; |
| 92 } | 93 } |
| 93 | 94 |
| 94 static inline int ec_get_error(ec_ctx *_this){ | 95 static OPUS_INLINE int ec_get_error(ec_ctx *_this){ |
| 95 return _this->error; | 96 return _this->error; |
| 96 } | 97 } |
| 97 | 98 |
| 98 /*Returns the number of bits "used" by the encoded or decoded symbols so far. | 99 /*Returns the number of bits "used" by the encoded or decoded symbols so far. |
| 99 This same number can be computed in either the encoder or the decoder, and is | 100 This same number can be computed in either the encoder or the decoder, and is |
| 100 suitable for making coding decisions. | 101 suitable for making coding decisions. |
| 101 Return: The number of bits. | 102 Return: The number of bits. |
| 102 This will always be slightly larger than the exact value (e.g., all | 103 This will always be slightly larger than the exact value (e.g., all |
| 103 rounding error is in the positive direction).*/ | 104 rounding error is in the positive direction).*/ |
| 104 static inline int ec_tell(ec_ctx *_this){ | 105 static OPUS_INLINE int ec_tell(ec_ctx *_this){ |
| 105 return _this->nbits_total-EC_ILOG(_this->rng); | 106 return _this->nbits_total-EC_ILOG(_this->rng); |
| 106 } | 107 } |
| 107 | 108 |
| 108 /*Returns the number of bits "used" by the encoded or decoded symbols so far. | 109 /*Returns the number of bits "used" by the encoded or decoded symbols so far. |
| 109 This same number can be computed in either the encoder or the decoder, and is | 110 This same number can be computed in either the encoder or the decoder, and is |
| 110 suitable for making coding decisions. | 111 suitable for making coding decisions. |
| 111 Return: The number of bits scaled by 2**BITRES. | 112 Return: The number of bits scaled by 2**BITRES. |
| 112 This will always be slightly larger than the exact value (e.g., all | 113 This will always be slightly larger than the exact value (e.g., all |
| 113 rounding error is in the positive direction).*/ | 114 rounding error is in the positive direction).*/ |
| 114 opus_uint32 ec_tell_frac(ec_ctx *_this); | 115 opus_uint32 ec_tell_frac(ec_ctx *_this); |
| 115 | 116 |
| 116 #endif | 117 #endif |
| OLD | NEW |