45 { -2, 0, 0, 0, 0, 0, 0, 1 },
46 { -3, 0, 0, 0, 0, 0, 1, 2 },
47 { -4, 0, 0, 0, 0, 0, 1, 2 },
48 { -4, 0, 0, 0, 0, 0, 1, 2 }
56 size_t byte_length =
len >> 3;
57 int bit_length =
len & 7;
64 while (bit_length--) {
66 crc = (crc << 1) ^ ((
mask >> 7) & 0x1D);
81 uint8_t sf =
frame->frequency;
84 int bitneed[2][8], loudness, max_bitneed, bitcount, slicecount, bitslice;
89 if (
frame->allocation == SNR) {
91 bitneed[ch][sb] =
frame->scale_factor[ch][sb];
92 if (bitneed[ch][sb] > max_bitneed)
93 max_bitneed = bitneed[ch][sb];
97 if (
frame->scale_factor[ch][sb] == 0)
105 bitneed[ch][sb] = loudness / 2;
107 bitneed[ch][sb] = loudness;
109 if (bitneed[ch][sb] > max_bitneed)
110 max_bitneed = bitneed[ch][sb];
116 bitslice = max_bitneed + 1;
119 bitcount += slicecount;
122 if ((bitneed[ch][sb] > bitslice + 1) && (bitneed[ch][sb] < bitslice + 16))
124 else if (bitneed[ch][sb] == bitslice + 1)
127 }
while (bitcount + slicecount < frame->bitpool);
129 if (bitcount + slicecount ==
frame->bitpool) {
130 bitcount += slicecount;
135 if (bitneed[ch][sb] < bitslice + 2)
138 bits[ch][sb] = bitneed[ch][sb] - bitslice;
139 if (
bits[ch][sb] > 16)
144 for (sb = 0; bitcount <
frame->bitpool &&
146 if ((
bits[ch][sb] >= 2) && (
bits[ch][sb] < 16)) {
149 }
else if ((bitneed[ch][sb] == bitslice + 1) && (
frame->bitpool > bitcount + 1)) {
155 for (sb = 0; bitcount <
frame->bitpool &&
157 if (
bits[ch][sb] < 16) {
166 int bitneed[2][8], loudness, max_bitneed, bitcount, slicecount, bitslice;
170 if (
frame->allocation == SNR) {
171 for (ch = 0; ch < 2; ch++) {
173 bitneed[ch][sb] =
frame->scale_factor[ch][sb];
174 if (bitneed[ch][sb] > max_bitneed)
175 max_bitneed = bitneed[ch][sb];
179 for (ch = 0; ch < 2; ch++) {
181 if (
frame->scale_factor[ch][sb] == 0)
182 bitneed[ch][sb] = -5;
189 bitneed[ch][sb] = loudness / 2;
191 bitneed[ch][sb] = loudness;
193 if (bitneed[ch][sb] > max_bitneed)
194 max_bitneed = bitneed[ch][sb];
201 bitslice = max_bitneed + 1;
204 bitcount += slicecount;
206 for (ch = 0; ch < 2; ch++) {
208 if ((bitneed[ch][sb] > bitslice + 1) && (bitneed[ch][sb] < bitslice + 16))
210 else if (bitneed[ch][sb] == bitslice + 1)
214 }
while (bitcount + slicecount < frame->bitpool);
216 if (bitcount + slicecount ==
frame->bitpool) {
217 bitcount += slicecount;
221 for (ch = 0; ch < 2; ch++) {
223 if (bitneed[ch][sb] < bitslice + 2) {
226 bits[ch][sb] = bitneed[ch][sb] - bitslice;
227 if (
bits[ch][sb] > 16)
235 while (bitcount < frame->bitpool) {
236 if ((
bits[ch][sb] >= 2) && (
bits[ch][sb] < 16)) {
239 }
else if ((bitneed[ch][sb] == bitslice + 1) && (
frame->bitpool > bitcount + 1)) {
254 while (bitcount < frame->bitpool) {
255 if (
bits[ch][sb] < 16) {