#include <math.h>
#include <stdlib.h>
#include "iLBC_define.h"
#include "constants.h"
#include "helpfun.h"
#include "string.h"
Go to the source code of this file.
|
void | dopack (unsigned char **bitstream, int index, int bitno, int *pos) |
|
void | packcombine (int *index, int rest, int bitno_rest) |
|
void | packsplit (int *index, int *firstpart, int *rest, int bitno_firstpart, int bitno_total) |
|
void | unpack (unsigned char **bitstream, int *index, int bitno, int *pos) |
|
◆ dopack()
void dopack |
( |
unsigned char ** |
bitstream, |
|
|
int |
index, |
|
|
int |
bitno, |
|
|
int * |
pos |
|
) |
| |
Definition at line 68 of file packing.c.
79 {
80 int posLeft;
81
82
83
84 if ((*pos)==0) {
85
86
87
88
89
90 **bitstream=0;
91 }
92
93 while (bitno>0) {
94
95
96
97 if (*pos==8) {
98 *pos=0;
99 (*bitstream)++;
100 **bitstream=0;
101 }
102
103 posLeft=8-(*pos);
104
105
106
107 if (bitno <= posLeft) {
108 **bitstream |= (unsigned char)(index<<(posLeft-bitno));
109 *pos+=bitno;
110 bitno=0;
111 } else {
112 **bitstream |= (unsigned char)(index>>(bitno-posLeft));
113
114 *pos=8;
115 index-=((index>>(bitno-posLeft))<<(bitno-posLeft));
116
117 bitno-=posLeft;
118 }
119 }
120 }
Referenced by iLBC_encode().
◆ packcombine()
void packcombine |
( |
int * |
index, |
|
|
int |
rest, |
|
|
int |
bitno_rest |
|
) |
| |
Definition at line 53 of file packing.c.
59 {
60 *index = *index<<bitno_rest;
61 *index += rest;
62 }
Referenced by iLBC_decode().
◆ packsplit()
void packsplit |
( |
int * |
index, |
|
|
int * |
firstpart, |
|
|
int * |
rest, |
|
|
int |
bitno_firstpart, |
|
|
int |
bitno_total |
|
) |
| |
Definition at line 26 of file packing.c.
41 {
42 int bitno_rest = bitno_total-bitno_firstpart;
43
44 *firstpart = *index>>(bitno_rest);
45 *rest = *index-(*firstpart<<(bitno_rest));
46 }
Referenced by iLBC_encode().
◆ unpack()
void unpack |
( |
unsigned char ** |
bitstream, |
|
|
int * |
index, |
|
|
int |
bitno, |
|
|
int * |
pos |
|
) |
| |
Definition at line 126 of file packing.c.
143 {
144 int BitsLeft;
145
146 *index=0;
147
148 while (bitno>0) {
149
150
151
152
153 if (*pos==8) {
154 *pos=0;
155 (*bitstream)++;
156 }
157
158 BitsLeft=8-(*pos);
159
160
161
162 if (BitsLeft>=bitno) {
163 *index+=((((**bitstream)<<(*pos)) & 0xFF)>>(8-bitno));
164
165 *pos+=bitno;
166 bitno=0;
167 } else {
168
169 if ((8-bitno)>0) {
170 *index+=((((**bitstream)<<(*pos)) & 0xFF)>>
171 (8-bitno));
172 *pos=8;
173 } else {
174 *index+=(((int)(((**bitstream)<<(*pos)) & 0xFF))<<
175 (bitno-8));
176 *pos=8;
177 }
178 bitno-=BitsLeft;
179 }
180 }
181 }
Referenced by iLBC_decode().