Debian Codegraph @

external/opusfile/opus/celt/entcode.h

raw symbols SCIP
1 /* Copyright (c) 2001-2011 Timothy B. Terriberry
2 Copyright (c) 2008-2009 Xiph.Org Foundation */
3 /*
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions
6 are met:
7
8 - Redistributions of source code must retain the above copyright
9 notice, this list of conditions and the following disclaimer.
10
11 - Redistributions in binary form must reproduce the above copyright
12 notice, this list of conditions and the following disclaimer in the
13 documentation and/or other materials provided with the distribution.
14
15 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
19 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
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.
26 */
27
28 #include "opus_types.h"cxx . . $ `<file>/external/opusfile/opus/opus_types.h`/
29 #include "opus_defines.h"cxx . . $ `<file>/external/opusfile/opus/opus_defines.h`/
30
31 #if !defined(_entcode_Hcxx . . $ `external/opusfile/opus/celt/entcode.h:32:10`!)
32 # define _entcode_Hcxx . . $ `external/opusfile/opus/celt/entcode.h:32:10`! (1)
33 # include <limits.h>
34 # include <stddef.h>
35 # include "ecintrin.h"cxx . . $ `<file>/external/opusfile/opus/celt/ecintrin.h`/
36
37 extern const opus_uint32cxx . . $ opus_uint32# SMALL_DIV_TABLEcxx . . $ SMALL_DIV_TABLE.[129];
38
39 #ifdef OPUS_ARM_ASM
40 #define USE_SMALL_DIV_TABLE
41 #endif
42
43 /*OPT: ec_window must be at least 32 bits, but if you have fast arithmetic on a
44 larger type, you can speed up the decoder by using it here.*/
45 typedef opus_uint32cxx . . $ opus_uint32# ec_windowcxx . . $ ec_window#;
46 typedef struct ec_ctxcxx . . $ ec_ctx# ec_ctxcxx . . $ ec_ctx#;
47 typedef struct ec_ctxcxx . . $ ec_ctx# ec_enccxx . . $ ec_enc#;
48 typedef struct ec_ctxcxx . . $ ec_ctx# ec_deccxx . . $ ec_dec#;
49
50 # define EC_WINDOW_SIZEcxx . . $ `external/opusfile/opus/celt/entcode.h:50:10`! ((int)sizeof(ec_window)*CHAR_BITcxx . . $ `<external>/67164224788392828/limits.h:64:9`!)
51
52 /*The number of bits to use for the range-coded part of unsigned integers.*/
53 # define EC_UINT_BITScxx . . $ `external/opusfile/opus/celt/entcode.h:53:10`! (8)
54
55 /*The resolution of fractional-precision bit usage measurements, i.e.,
56 3 => 1/8th bits.*/
57 # define BITREScxx . . $ `external/opusfile/opus/celt/entcode.h:57:10`! 3
58
59 /*The entropy encoder/decoder context.
60 We use the same structure for both, so that common functions like ec_tell()
61 can be used on either one.*/
62 struct ec_ctxcxx . . $ ec_ctx#{
63 /*Buffered input/output.*/
64 unsigned char *bufcxx . . $ ec_ctx#buf.;
65 /*The size of the buffer.*/
66 opus_uint32cxx . . $ opus_uint32# storagecxx . . $ ec_ctx#storage.;
67 /*The offset at which the last byte containing raw bits was read/written.*/
68 opus_uint32cxx . . $ opus_uint32# end_offscxx . . $ ec_ctx#end_offs.;
69 /*Bits that will be read from/written at the end.*/
70 ec_windowcxx . . $ ec_window# end_windowcxx . . $ ec_ctx#end_window.;
71 /*Number of valid bits in end_window.*/
72 int nend_bitscxx . . $ ec_ctx#nend_bits.;
73 /*The total number of whole bits read/written.
74 This does not include partial bits currently in the range coder.*/
75 int nbits_totalcxx . . $ ec_ctx#nbits_total.;
76 /*The offset at which the next range coder byte will be read/written.*/
77 opus_uint32cxx . . $ opus_uint32# offscxx . . $ ec_ctx#offs.;
78 /*The number of values in the current range.*/
79 opus_uint32cxx . . $ opus_uint32# rngcxx . . $ ec_ctx#rng.;
80 /*In the decoder: the difference between the top of the current range and
81 the input value, minus one.
82 In the encoder: the low end of the current range.*/
83 opus_uint32cxx . . $ opus_uint32# valcxx . . $ ec_ctx#val.;
84 /*In the decoder: the saved normalization factor from ec_decode().
85 In the encoder: the number of oustanding carry propagating symbols.*/
86 opus_uint32cxx . . $ opus_uint32# extcxx . . $ ec_ctx#ext.;
87 /*A buffered input/output symbol, awaiting carry propagation.*/
88 int remcxx . . $ ec_ctx#rem.;
89 /*Nonzero if an error occurred.*/
90 int errorcxx . . $ ec_ctx#error.;
91 };
92
93 static OPUS_INLINEcxx . . $ `external/opusfile/opus/opus_defines.h:110:10`! opus_uint32cxx . . $ opus_uint32# ec_range_bytescxx . . $ ec_range_bytes(a5b02a39389d8341).(ec_ctxcxx . . $ ec_ctx# *_this){
94 return _this->offscxx . . $ ec_ctx#offs.;
95 }
96
97 static OPUS_INLINEcxx . . $ `external/opusfile/opus/opus_defines.h:110:10`! unsigned char *ec_get_buffercxx . . $ ec_get_buffer(acb8a44ef6944599).(ec_ctxcxx . . $ ec_ctx# *_this){
98 return _this->bufcxx . . $ ec_ctx#buf.;
99 }
100
101 static OPUS_INLINEcxx . . $ `external/opusfile/opus/opus_defines.h:110:10`! int ec_get_errorcxx . . $ ec_get_error(d262775a7bafb6a0).(ec_ctxcxx . . $ ec_ctx# *_this){
102 return _this->errorcxx . . $ ec_ctx#error.;
103 }
104
105 /*Returns the number of bits "used" by the encoded or decoded symbols so far.
106 This same number can be computed in either the encoder or the decoder, and is
107 suitable for making coding decisions.
108 Return: The number of bits.
109 This will always be slightly larger than the exact value (e.g., all
110 rounding error is in the positive direction).*/
111 static OPUS_INLINEcxx . . $ `external/opusfile/opus/opus_defines.h:110:10`! int ec_tellcxx . . $ ec_tell(d262775a7bafb6a0).(ec_ctxcxx . . $ ec_ctx# *_this){
112 return _this->nbits_totalcxx . . $ ec_ctx#nbits_total.-EC_ILOGcxx . . $ ec_ctx#rng.(_this->rng);
113 }
114
115 /*Returns the number of bits "used" by the encoded or decoded symbols so far.
116 This same number can be computed in either the encoder or the decoder, and is
117 suitable for making coding decisions.
118 Return: The number of bits scaled by 2**BITRES.
119 This will always be slightly larger than the exact value (e.g., all
120 rounding error is in the positive direction).*/
121 opus_uint32cxx . . $ opus_uint32# ec_tell_fraccxx . . $ ec_tell_frac(a5b02a39389d8341).(ec_ctxcxx . . $ ec_ctx# *_this);
122
123 /* Tested exhaustively for all n and for 1<=d<=256 */
124 static OPUS_INLINEcxx . . $ `external/opusfile/opus/opus_defines.h:110:10`! opus_uint32cxx . . $ opus_uint32# celt_udivcxx . . $ celt_udiv(83f10ac8959d5577).(opus_uint32cxx . . $ opus_uint32# n, opus_uint32cxx . . $ opus_uint32# d) {
125 celt_sig_assertcxx . . $ `external/opusfile/opus/celt/arch.h:92:9`!(d>0);
126 #ifdef USE_SMALL_DIV_TABLE
127 if (d>256)
128 return n/d;
129 else {
130 opus_uint32 t, q;
131 t = EC_ILOG(d&-d);
132 q = (opus_uint64)SMALL_DIV_TABLE[d>>t]*(n>>(t-1))>>32;
133 return q+(n-q*d >= d);
134 }
135 #else
136 return n/d;
137 #endif
138 }
139
140 static OPUS_INLINEcxx . . $ `external/opusfile/opus/opus_defines.h:110:10`! opus_int32cxx . . $ opus_int32# celt_sudivcxx . . $ celt_sudiv(9b79fb6aee4c0440).(opus_int32cxx . . $ opus_int32# n, opus_int32cxx . . $ opus_int32# d) {
141 celt_sig_assertcxx . . $ `external/opusfile/opus/celt/arch.h:92:9`!(d>0);
142 #ifdef USE_SMALL_DIV_TABLE
143 if (n<0)
144 return -(opus_int32)celt_udiv(-n, d);
145 else
146 return celt_udiv(n, d);
147 #else
148 return n/d;
149 #endif
150 }
151
152 #endif