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;
61 crc =
av_crc(ctx, 0x0F, data, byte_length);
65 while (bit_length--) {
66 int8_t
mask = bits ^ crc;
67 crc = (crc << 1) ^ ((mask >> 7) & 0x1D);
84 if (frame->
mode ==
MONO || frame->
mode == DUAL_CHANNEL) {
85 int bitneed[2][8],
loudness, max_bitneed, bitcount, slicecount, bitslice;
88 for (ch = 0; ch < frame->
channels; ch++) {
93 if (bitneed[ch][sb] > max_bitneed)
94 max_bitneed = bitneed[ch][sb];
106 bitneed[ch][sb] = loudness / 2;
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;
172 for (ch = 0; ch < 2; ch++) {
175 if (bitneed[ch][sb] > max_bitneed)
176 max_bitneed = bitneed[ch][sb];
180 for (ch = 0; ch < 2; ch++) {
183 bitneed[ch][sb] = -5;
190 bitneed[ch][sb] = loudness / 2;
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) {
enum sbc_frame::@131 allocation
enum sbc_frame::@130 mode
static const uint16_t mask[17]
uint32_t scale_factor[2][8]
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)
Calculate the CRC of a block.
uint8_t ff_sbc_crc8(const AVCRC *ctx, const uint8_t *data, size_t len)
Libavcodec external API header.
SBC common definitions for the encoder and decoder.
static const int sbc_offset4[4][4]
void ff_sbc_calculate_bits(const struct sbc_frame *frame, int(*bits)[8])
static const int sbc_offset8[4][8]