39 #define FILTER_RAW 642
50 #define RALF_MAX_PKT_SIZE 8192
74 #define MAX_ELEMS 644 // no RALF table uses more than that
80 int counts[17], prefixes[18];
85 for (i = 0; i <= 16; i++)
87 for (i = 0; i < elems; i++) {
88 cur_len = (nb ? *data & 0xF : *data >> 4) + 1;
90 max_bits =
FFMAX(max_bits, cur_len);
96 for (i = 1; i <= 16; i++)
97 prefixes[i + 1] = (prefixes[i] + counts[i]) << 1;
99 for (i = 0; i < elems; i++)
100 codes[i] = prefixes[lens[i]]++;
103 lens, 1, 1, codes, 2, 2,
NULL, 0, 0, 0);
111 for (i = 0; i < 3; i++) {
115 for (j = 0; j < 10; j++)
116 for (k = 0; k < 11; k++)
118 for (j = 0; j < 15; j++)
120 for (j = 0; j < 125; j++)
163 for (i = 0; i < 3; i++) {
181 for (j = 0; j < 10; j++) {
182 for (k = 0; k < 11; k++) {
192 for (j = 0; j < 15; j++) {
200 for (j = 0; j < 125; j++) {
217 }
else if (val == range * 2) {
241 for (i = 0; i <
length; i++)
251 memset(dst, 0,
sizeof(*dst) * length);
256 int cmode = 0,
coeff = 0;
265 coeff -= 12 << add_bits;
269 cmode = coeff >> add_bits;
274 }
else if (cmode > 0) {
282 code_params =
get_vlc2(gb,
set->coding_mode.table,
set->coding_mode.bits, 2);
283 if (code_params >= 15) {
284 add_bits = av_clip((code_params / 5 - 3) / 2, 0, 10);
285 if (add_bits > 9 && (code_params % 5) != 2)
289 code_vlc =
set->long_codes + code_params - 15;
294 code_vlc =
set->short_codes + code_params;
297 for (i = 0; i <
length; i += 2) {
303 dst[i] =
extend_code(gb, code1, range, 0) << add_bits;
304 dst[i + 1] =
extend_code(gb, code2, range, 0) << add_bits;
307 dst[i + 1] |=
get_bits(gb, add_bits);
319 int max_clip = (1 <<
bits) - 1, min_clip = -max_clip - 1;
321 for (i = 1; i <
length; i++) {
325 for (j = 0; j < flen; j++)
326 acc += ctx->
filter[j] * audio[i - j - 1];
329 acc =
FFMAX(acc, min_clip);
332 acc =
FFMIN(acc, max_clip);
339 int16_t *dst0, int16_t *dst1)
349 if (len <= 7) len ^= 1;
354 "Decoder's stomach is crying, it ate too many samples\n");
363 mode[0] = (dmode == 4) ? 1 : 0;
364 mode[1] = (dmode >= 2) ? 2 : 0;
366 bits[1] = (mode[1] == 2) ? 17 : 16;
368 for (ch = 0; ch < avctx->
channels; ch++) {
369 if ((ret =
decode_channel(ctx, gb, ch, len, mode[ch], bits[ch])) < 0)
382 for (i = 0; i <
len; i++)
383 dst0[i] = ch0[i] + ctx->
bias[0];
386 for (i = 0; i <
len; i++) {
387 dst0[i] = ch0[i] + ctx->
bias[0];
388 dst1[i] = ch1[i] + ctx->
bias[1];
392 for (i = 0; i <
len; i++) {
393 ch0[i] += ctx->
bias[0];
395 dst1[i] = ch0[i] - (ch1[i] + ctx->
bias[1]);
399 for (i = 0; i <
len; i++) {
400 t = ch0[i] + ctx->
bias[0];
401 t2 = ch1[i] + ctx->
bias[1];
407 for (i = 0; i <
len; i++) {
408 t = ch1[i] + ctx->
bias[1];
409 t2 = ((ch0[i] + ctx->
bias[0]) << 1) | (t & 1);
410 dst0[i] = (t2 + t) / 2;
411 dst1[i] = (t2 - t) / 2;
430 int table_size, table_bytes, i;
442 if (memcmp(ctx->
pkt, avpkt->
data, 2 + table_bytes)) {
450 avpkt->
size - 2 - table_bytes);
460 src_size = avpkt->
size;
466 samples0 = (int16_t *)frame->
data[0];
467 samples1 = (int16_t *)frame->
data[1];
474 table_bytes = (table_size + 7) >> 3;
475 if (src_size < table_bytes + 3) {
491 block_pointer = src + table_bytes + 2;
492 bytes_left = src_size - table_bytes - 2;
495 if (bytes_left < ctx->block_size[i]) {
502 av_log(avctx,
AV_LOG_ERROR,
"Sir, I got carsick in your office. Not decoding the rest of packet.\n");