46 { -2, 0, 0, 0, 0, 0, 0, 1 },
47 { -3, 0, 0, 0, 0, 0, 1, 2 },
48 { -4, 0, 0, 0, 0, 0, 1, 2 },
49 { -4, 0, 0, 0, 0, 0, 1, 2 }
57 size_t byte_length =
len >> 3;
58 int bit_length =
len & 7;
65 while (bit_length--) {
67 crc = (crc << 1) ^ ((
mask >> 7) & 0x1D);
85 int bitneed[2][8],
loudness, max_bitneed, bitcount, slicecount, bitslice;
88 for (ch = 0; ch <
frame->channels; ch++) {
90 if (
frame->allocation == SNR) {
92 bitneed[ch][sb] =
frame->scale_factor[ch][sb];
93 if (bitneed[ch][sb] > max_bitneed)
94 max_bitneed = bitneed[ch][sb];
98 if (
frame->scale_factor[ch][sb] == 0)
110 if (bitneed[ch][sb] > max_bitneed)
111 max_bitneed = bitneed[ch][sb];
117 bitslice = max_bitneed + 1;
120 bitcount += slicecount;
123 if ((bitneed[ch][sb] > bitslice + 1) && (bitneed[ch][sb] < bitslice + 16))
125 else if (bitneed[ch][sb] == bitslice + 1)
128 }
while (bitcount + slicecount < frame->bitpool);
130 if (bitcount + slicecount ==
frame->bitpool) {
131 bitcount += slicecount;
136 if (bitneed[ch][sb] < bitslice + 2)
139 bits[ch][sb] = bitneed[ch][sb] - bitslice;
140 if (
bits[ch][sb] > 16)
145 for (sb = 0; bitcount <
frame->bitpool &&
147 if ((
bits[ch][sb] >= 2) && (
bits[ch][sb] < 16)) {
150 }
else if ((bitneed[ch][sb] == bitslice + 1) && (
frame->bitpool > bitcount + 1)) {
156 for (sb = 0; bitcount <
frame->bitpool &&
158 if (
bits[ch][sb] < 16) {
167 int bitneed[2][8],
loudness, max_bitneed, bitcount, slicecount, bitslice;
171 if (
frame->allocation == SNR) {
172 for (ch = 0; ch < 2; ch++) {
174 bitneed[ch][sb] =
frame->scale_factor[ch][sb];
175 if (bitneed[ch][sb] > max_bitneed)
176 max_bitneed = bitneed[ch][sb];
180 for (ch = 0; ch < 2; ch++) {
182 if (
frame->scale_factor[ch][sb] == 0)
183 bitneed[ch][sb] = -5;
194 if (bitneed[ch][sb] > max_bitneed)
195 max_bitneed = bitneed[ch][sb];
202 bitslice = max_bitneed + 1;
205 bitcount += slicecount;
207 for (ch = 0; ch < 2; ch++) {
209 if ((bitneed[ch][sb] > bitslice + 1) && (bitneed[ch][sb] < bitslice + 16))
211 else if (bitneed[ch][sb] == bitslice + 1)
215 }
while (bitcount + slicecount < frame->bitpool);
217 if (bitcount + slicecount ==
frame->bitpool) {
218 bitcount += slicecount;
222 for (ch = 0; ch < 2; ch++) {
224 if (bitneed[ch][sb] < bitslice + 2) {
227 bits[ch][sb] = bitneed[ch][sb] - bitslice;
228 if (
bits[ch][sb] > 16)
236 while (bitcount < frame->bitpool) {
237 if ((
bits[ch][sb] >= 2) && (
bits[ch][sb] < 16)) {
240 }
else if ((bitneed[ch][sb] == bitslice + 1) && (
frame->bitpool > bitcount + 1)) {
255 while (bitcount < frame->bitpool) {
256 if (
bits[ch][sb] < 16) {