Asterisk - The Open Source Telephony Project  18.5.0
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Modules Pages
Functions
packing.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

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)
 

Function Documentation

◆ dopack()

void dopack ( unsigned char **  bitstream,
int  index,
int  bitno,
int *  pos 
)

Definition at line 68 of file packing.c.

Referenced by iLBC_encode().

79  {
80  int posLeft;
81 
82  /* Clear the bits before starting in a new byte */
83 
84  if ((*pos)==0) {
85 
86 
87 
88 
89 
90  **bitstream=0;
91  }
92 
93  while (bitno>0) {
94 
95  /* Jump to the next byte if end of this byte is reached*/
96 
97  if (*pos==8) {
98  *pos=0;
99  (*bitstream)++;
100  **bitstream=0;
101  }
102 
103  posLeft=8-(*pos);
104 
105  /* Insert index into the bitstream */
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  }

◆ packcombine()

void packcombine ( int *  index,
int  rest,
int  bitno_rest 
)

Definition at line 53 of file packing.c.

Referenced by iLBC_decode().

59  {
60  *index = *index<<bitno_rest;
61  *index += rest;
62  }

◆ packsplit()

void packsplit ( int *  index,
int *  firstpart,
int *  rest,
int  bitno_firstpart,
int  bitno_total 
)

Definition at line 26 of file packing.c.

Referenced by iLBC_encode().

41  {
42  int bitno_rest = bitno_total-bitno_firstpart;
43 
44  *firstpart = *index>>(bitno_rest);
45  *rest = *index-(*firstpart<<(bitno_rest));
46  }

◆ unpack()

void unpack ( unsigned char **  bitstream,
int *  index,
int  bitno,
int *  pos 
)

Definition at line 126 of file packing.c.

Referenced by iLBC_decode().

143  {
144  int BitsLeft;
145 
146  *index=0;
147 
148  while (bitno>0) {
149 
150  /* move forward in bitstream when the end of the
151  byte is reached */
152 
153  if (*pos==8) {
154  *pos=0;
155  (*bitstream)++;
156  }
157 
158  BitsLeft=8-(*pos);
159 
160  /* Extract bits to index */
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  }