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 WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_ARITH_ROUTINS_H_ 19 #define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_ARITH_ROUTINS_H_ 20 21 #include "structs.h" 22 23 24 /**************************************************************************** 25 * WebRtcIsacfix_EncLogisticMulti2(...) 26 * 27 * Arithmetic coding of spectrum. 28 * 29 * Input: 30 * - streamData : in-/output struct containing bitstream 31 * - dataQ7 : data vector in Q7 32 * - envQ8 : side info vector defining the width of the pdf 33 * in Q8 34 * - lenData : data vector length 35 * 36 * Return value : 0 if ok, 37 * <0 otherwise. 38 */ 39 int WebRtcIsacfix_EncLogisticMulti2( 40 Bitstr_enc *streamData, 41 int16_t *dataQ7, 42 const uint16_t *env, 43 const int16_t lenData); 44 45 46 /**************************************************************************** 47 * WebRtcIsacfix_EncTerminate(...) 48 * 49 * Final call to the arithmetic coder for an encoder call. This function 50 * terminates and return byte stream. 51 * 52 * Input: 53 * - streamData : in-/output struct containing bitstream 54 * 55 * Return value : number of bytes in the stream 56 */ 57 int16_t WebRtcIsacfix_EncTerminate(Bitstr_enc *streamData); 58 59 60 /**************************************************************************** 61 * WebRtcIsacfix_DecLogisticMulti2(...) 62 * 63 * Arithmetic decoding of spectrum. 64 * 65 * Input: 66 * - streamData : in-/output struct containing bitstream 67 * - envQ8 : side info vector defining the width of the pdf 68 * in Q8 69 * - lenData : data vector length 70 * 71 * Input/Output: 72 * - dataQ7 : input: dither vector, output: data vector, in Q7 73 * 74 * Return value : number of bytes in the stream so far 75 * <0 if error detected 76 */ 77 int WebRtcIsacfix_DecLogisticMulti2( 78 int16_t *data, 79 Bitstr_dec *streamData, 80 const int32_t *env, 81 const int16_t lenData); 82 83 84 /**************************************************************************** 85 * WebRtcIsacfix_EncHistMulti(...) 86 * 87 * Encode the histogram interval 88 * 89 * Input: 90 * - streamData : in-/output struct containing bitstream 91 * - data : data vector 92 * - cdf : array of cdf arrays 93 * - lenData : data vector length 94 * 95 * Return value : 0 if ok 96 * <0 if error detected 97 */ 98 int WebRtcIsacfix_EncHistMulti( 99 Bitstr_enc *streamData, 100 const int16_t *data, 101 const uint16_t **cdf, 102 const int16_t lenData); 103 104 105 /**************************************************************************** 106 * WebRtcIsacfix_DecHistBisectMulti(...) 107 * 108 * Function to decode more symbols from the arithmetic bytestream, using 109 * method of bisection. 110 * C df tables should be of size 2^k-1 (which corresponds to an 111 * alphabet size of 2^k-2) 112 * 113 * Input: 114 * - streamData : in-/output struct containing bitstream 115 * - cdf : array of cdf arrays 116 * - cdfSize : array of cdf table sizes+1 (power of two: 2^k) 117 * - lenData : data vector length 118 * 119 * Output: 120 * - data : data vector 121 * 122 * Return value : number of bytes in the stream 123 * <0 if error detected 124 */ 125 int16_t WebRtcIsacfix_DecHistBisectMulti( 126 int16_t *data, 127 Bitstr_dec *streamData, 128 const uint16_t **cdf, 129 const uint16_t *cdfSize, 130 const int16_t lenData); 131 132 133 /**************************************************************************** 134 * WebRtcIsacfix_DecHistOneStepMulti(...) 135 * 136 * Function to decode more symbols from the arithmetic bytestream, taking 137 * single step up or down at a time. 138 * cdf tables can be of arbitrary size, but large tables may take a lot of 139 * iterations. 140 * 141 * Input: 142 * - streamData : in-/output struct containing bitstream 143 * - cdf : array of cdf arrays 144 * - initIndex : vector of initial cdf table search entries 145 * - lenData : data vector length 146 * 147 * Output: 148 * - data : data vector 149 * 150 * Return value : number of bytes in original stream 151 * <0 if error detected 152 */ 153 int16_t WebRtcIsacfix_DecHistOneStepMulti( 154 int16_t *data, 155 Bitstr_dec *streamData, 156 const uint16_t **cdf, 157 const uint16_t *initIndex, 158 const int16_t lenData); 159 160 #endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_ARITH_ROUTINS_H_ */ 161