• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 /*
12  * arith_routins.h
13  *
14  * Functions for arithmetic coding.
15  *
16  */
17 
18 #ifndef MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_ARITH_ROUTINS_H_
19 #define MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_ARITH_ROUTINS_H_
20 
21 #include "modules/audio_coding/codecs/isac/fix/source/structs.h"
22 
23 /****************************************************************************
24  * WebRtcIsacfix_EncLogisticMulti2(...)
25  *
26  * Arithmetic coding of spectrum.
27  *
28  * Input:
29  *      - streamData        : in-/output struct containing bitstream
30  *      - dataQ7            : data vector in Q7
31  *      - envQ8             : side info vector defining the width of the pdf
32  *                            in Q8
33  *      - lenData           : data vector length
34  *
35  * Return value             :  0 if ok,
36  *                             <0 otherwise.
37  */
38 int WebRtcIsacfix_EncLogisticMulti2(Bitstr_enc* streamData,
39                                     int16_t* dataQ7,
40                                     const uint16_t* env,
41                                     const int16_t lenData);
42 
43 /****************************************************************************
44  * WebRtcIsacfix_EncTerminate(...)
45  *
46  * Final call to the arithmetic coder for an encoder call. This function
47  * terminates and return byte stream.
48  *
49  * Input:
50  *      - streamData        : in-/output struct containing bitstream
51  *
52  * Return value             : number of bytes in the stream
53  */
54 int16_t WebRtcIsacfix_EncTerminate(Bitstr_enc* streamData);
55 
56 /****************************************************************************
57  * WebRtcIsacfix_DecLogisticMulti2(...)
58  *
59  * Arithmetic decoding of spectrum.
60  *
61  * Input:
62  *      - streamData        : in-/output struct containing bitstream
63  *      - envQ8             : side info vector defining the width of the pdf
64  *                            in Q8
65  *      - lenData           : data vector length
66  *
67  * Input/Output:
68  *      - dataQ7            : input: dither vector, output: data vector, in Q7
69  *
70  * Return value             : number of bytes in the stream so far
71  *                            <0 if error detected
72  */
73 int WebRtcIsacfix_DecLogisticMulti2(int16_t* data,
74                                     Bitstr_dec* streamData,
75                                     const int32_t* env,
76                                     const int16_t lenData);
77 
78 /****************************************************************************
79  * WebRtcIsacfix_EncHistMulti(...)
80  *
81  * Encode the histogram interval
82  *
83  * Input:
84  *      - streamData        : in-/output struct containing bitstream
85  *      - data              : data vector
86  *      - cdf               : array of cdf arrays
87  *      - lenData           : data vector length
88  *
89  * Return value             : 0 if ok
90  *                            <0 if error detected
91  */
92 int WebRtcIsacfix_EncHistMulti(Bitstr_enc* streamData,
93                                const int16_t* data,
94                                const uint16_t* const* cdf,
95                                const int16_t lenData);
96 
97 /****************************************************************************
98  * WebRtcIsacfix_DecHistBisectMulti(...)
99  *
100  * Function to decode more symbols from the arithmetic bytestream, using
101  * method of bisection.
102  * C df tables should be of size 2^k-1 (which corresponds to an
103  * alphabet size of 2^k-2)
104  *
105  * Input:
106  *      - streamData        : in-/output struct containing bitstream
107  *      - cdf               : array of cdf arrays
108  *      - cdfSize           : array of cdf table sizes+1 (power of two: 2^k)
109  *      - lenData           : data vector length
110  *
111  * Output:
112  *      - data              : data vector
113  *
114  * Return value             : number of bytes in the stream
115  *                            <0 if error detected
116  */
117 int16_t WebRtcIsacfix_DecHistBisectMulti(int16_t* data,
118                                          Bitstr_dec* streamData,
119                                          const uint16_t* const* cdf,
120                                          const uint16_t* cdfSize,
121                                          const int16_t lenData);
122 
123 /****************************************************************************
124  * WebRtcIsacfix_DecHistOneStepMulti(...)
125  *
126  * Function to decode more symbols from the arithmetic bytestream, taking
127  * single step up or down at a time.
128  * cdf tables can be of arbitrary size, but large tables may take a lot of
129  * iterations.
130  *
131  * Input:
132  *      - streamData        : in-/output struct containing bitstream
133  *      - cdf               : array of cdf arrays
134  *      - initIndex         : vector of initial cdf table search entries
135  *      - lenData           : data vector length
136  *
137  * Output:
138  *      - data              : data vector
139  *
140  * Return value             : number of bytes in original stream
141  *                            <0 if error detected
142  */
143 int16_t WebRtcIsacfix_DecHistOneStepMulti(int16_t* data,
144                                           Bitstr_dec* streamData,
145                                           const uint16_t* const* cdf,
146                                           const uint16_t* initIndex,
147                                           const int16_t lenData);
148 
149 #endif /* MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_ARITH_ROUTINS_H_ */
150