50 { {-52, 4}, {-29, 5}, {-31, 4}, { 19, 4}, {-16, 4},
51 { 12, 3}, { -7, 3}, { 9, 3}, { -5, 3}, { 6, 3},
52 { -4, 3}, { 3, 3}, { -3, 2}, { 3, 2}, { -2, 2},
53 { 3, 2}, { -1, 2}, { 2, 2}, { -1, 2}, { 2, 2} },
54 { {-58, 3}, {-42, 4}, {-46, 4}, { 37, 5}, {-36, 4},
55 { 29, 4}, {-29, 4}, { 25, 4}, {-23, 4}, { 20, 4},
56 {-17, 4}, { 16, 4}, {-12, 4}, { 12, 3}, {-10, 4},
57 { 7, 3}, { -4, 4}, { 3, 3}, { -1, 3}, { 1, 3} },
58 { {-59, 3}, {-45, 5}, {-50, 4}, { 38, 4}, {-39, 4},
59 { 32, 4}, {-30, 4}, { 25, 3}, {-23, 3}, { 20, 3},
60 {-20, 3}, { 16, 3}, {-13, 3}, { 10, 3}, { -7, 3},
61 { 3, 3}, { 0, 3}, { -1, 3}, { 2, 3}, { -1, 2} }
71 -1048544 / 32, -1048288 / 32, -1047776 / 32, -1047008 / 32,
72 -1045984 / 32, -1044704 / 32, -1043168 / 32, -1041376 / 32,
73 -1039328 / 32, -1037024 / 32, -1034464 / 32, -1031648 / 32,
74 -1028576 / 32, -1025248 / 32, -1021664 / 32, -1017824 / 32,
75 -1013728 / 32, -1009376 / 32, -1004768 / 32, -999904 / 32,
76 -994784 / 32, -989408 / 32, -983776 / 32, -977888 / 32,
77 -971744 / 32, -965344 / 32, -958688 / 32, -951776 / 32,
78 -944608 / 32, -937184 / 32, -929504 / 32, -921568 / 32,
79 -913376 / 32, -904928 / 32, -896224 / 32, -887264 / 32,
80 -878048 / 32, -868576 / 32, -858848 / 32, -848864 / 32,
81 -838624 / 32, -828128 / 32, -817376 / 32, -806368 / 32,
82 -795104 / 32, -783584 / 32, -771808 / 32, -759776 / 32,
83 -747488 / 32, -734944 / 32, -722144 / 32, -709088 / 32,
84 -695776 / 32, -682208 / 32, -668384 / 32, -654304 / 32,
85 -639968 / 32, -625376 / 32, -610528 / 32, -595424 / 32,
86 -580064 / 32, -564448 / 32, -548576 / 32, -532448 / 32,
87 -516064 / 32, -499424 / 32, -482528 / 32, -465376 / 32,
88 -447968 / 32, -430304 / 32, -412384 / 32, -394208 / 32,
89 -375776 / 32, -357088 / 32, -338144 / 32, -318944 / 32,
90 -299488 / 32, -279776 / 32, -259808 / 32, -239584 / 32,
91 -219104 / 32, -198368 / 32, -177376 / 32, -156128 / 32,
92 -134624 / 32, -112864 / 32, -90848 / 32, -68576 / 32,
93 -46048 / 32, -23264 / 32, -224 / 32, 23072 / 32,
94 46624 / 32, 70432 / 32, 94496 / 32, 118816 / 32,
95 143392 / 32, 168224 / 32, 193312 / 32, 218656 / 32,
96 244256 / 32, 270112 / 32, 296224 / 32, 322592 / 32,
97 349216 / 32, 376096 / 32, 403232 / 32, 430624 / 32,
98 458272 / 32, 486176 / 32, 514336 / 32, 542752 / 32,
99 571424 / 32, 600352 / 32, 629536 / 32, 658976 / 32,
100 688672 / 32, 718624 / 32, 748832 / 32, 779296 / 32,
101 810016 / 32, 840992 / 32, 872224 / 32, 903712 / 32,
102 935456 / 32, 967456 / 32, 999712 / 32, 1032224 / 32
121 204, 192, 179, 166, 153, 140, 128, 115,
122 102, 89, 76, 64, 51, 38, 25, 12,
123 0, -12, -25, -38, -51, -64, -76, -89,
124 -102, -115, -128, -140, -153, -166, -179, -192
131 { 74, 44, 25, 13, 7, 3},
132 { 68, 42, 24, 13, 7, 3},
133 { 58, 39, 23, 13, 7, 3},
134 {126, 70, 37, 19, 10, 5},
135 {132, 70, 37, 20, 10, 5},
136 {124, 70, 38, 20, 10, 5},
137 {120, 69, 37, 20, 11, 5},
138 {116, 67, 37, 20, 11, 5},
139 {108, 66, 36, 20, 10, 5},
140 {102, 62, 36, 20, 10, 5},
141 { 88, 58, 34, 19, 10, 5},
142 {162, 89, 49, 25, 13, 7},
143 {156, 87, 49, 26, 14, 7},
144 {150, 86, 47, 26, 14, 7},
145 {142, 84, 47, 26, 14, 7},
146 {131, 79, 46, 26, 14, 7}
287 int i, config_offset;
291 uint32_t als_id, header_size, trailer_size;
298 if (config_offset < 0)
338 if (als_id !=
MKBETAG(
'A',
'L',
'S',
'\0'))
351 int chan_pos_bits = av_ceil_log2(avctx->
channels);
352 int bits_needed = avctx->
channels * chan_pos_bits + 7;
361 for (i = 0; i < avctx->
channels; i++) {
384 if (header_size == 0xFFFFFFFF)
386 if (trailer_size == 0xFFFFFFFF)
389 ht_size = ((int64_t)(header_size) + (int64_t)(trailer_size)) << 3;
396 if (ht_size > INT32_MAX)
409 ctx->
crc = 0xFFFFFFFF;
432 #define MISSING_ERR(cond, str, errval) \
435 av_log_missing_feature(ctx->avctx, str, 0); \
451 unsigned int div,
unsigned int **div_blocks,
452 unsigned int *num_blocks)
454 if (n < 31 && ((bs_info << n) & 0x40000000)) {
495 for (i = 0, j = k - 1; i < j; i++, j--) {
496 int tmp1 = ((
MUL64(par[k], cof[j]) + (1 << 19)) >> 20);
497 cof[j] += ((
MUL64(par[k], cof[i]) + (1 << 19)) >> 20);
501 cof[i] += ((
MUL64(par[k], cof[j]) + (1 << 19)) >> 20);
516 unsigned int *ptr_div_blocks = div_blocks;
522 *bs_info <<= (32 - bs_info_len);
550 if (remaining <= div_blocks[b]) {
551 div_blocks[
b] = remaining;
556 remaining -= div_blocks[
b];
616 unsigned int sub_blocks, log2_sub_blocks, sb_length;
617 unsigned int start = 0;
618 unsigned int opt_order;
642 sub_blocks = 1 << log2_sub_blocks;
648 "Block length is not evenly divisible by the number of subblocks.\n");
656 for (k = 1; k < sub_blocks; k++)
659 for (k = 0; k < sub_blocks; k++) {
665 for (k = 1; k < sub_blocks; k++)
668 for (k = 1; k < sub_blocks; k++)
682 int opt_order_length = av_ceil_log2(av_clip((bd->
block_length >> 3) - 1,
710 for (k = 2; k < opt_order; k++)
717 k_max =
FFMIN(opt_order, 20);
718 for (k = 0; k < k_max; k++) {
722 if (quant_cof[k] < -64 || quant_cof[k] > 63) {
729 k_max =
FFMIN(opt_order, 127);
730 for (; k < k_max; k++)
734 for (; k < opt_order; k++)
743 for (k = 2; k < opt_order; k++)
744 quant_cof[k] = (quant_cof[k] << 14) + (add_base << 13);
779 start =
FFMIN(opt_order, 3);
786 unsigned int b = av_clip((av_ceil_log2(bd->
block_length) - 3) >> 1, 0, 5);
797 for (sb = 0; sb < sub_blocks; sb++) {
798 unsigned int sb_len = sb_length - (sb ? 0 : start);
800 k [sb] = s[sb] > b ? s[sb] - b : 0;
801 delta[sb] = 5 - s[sb] + k[sb];
806 current_res += sb_len;
815 for (sb = 0; sb < sub_blocks; sb++, start = 0) {
816 unsigned int cur_tail_code =
tail_code[sx[sb]][delta[sb]];
817 unsigned int cur_k = k[sb];
818 unsigned int cur_s = s[sb];
820 for (; start < sb_length; start++) {
823 if (res == cur_tail_code) {
824 unsigned int max_msb = (2 + (sx[sb] > 2) + (sx[sb] > 10))
830 res += (max_msb ) << cur_k;
832 res -= (max_msb - 1) << cur_k;
835 if (res > cur_tail_code)
849 *current_res++ = res;
855 for (sb = 0; sb < sub_blocks; sb++, start = 0)
856 for (; start < sb_length; start++)
873 unsigned int smp = 0;
888 for (ltp_smp =
FFMAX(*bd->
ltp_lag - 2, 0); ltp_smp < block_length; ltp_smp++) {
889 int center = ltp_smp - *bd->
ltp_lag;
890 int begin =
FFMAX(0, center - 2);
891 int end = center + 3;
892 int tab = 5 - (end - begin);
897 for (base = begin; base <
end; base++, tab++)
900 raw_samples[ltp_smp] += y >> 7;
906 for (smp = 0; smp < opt_order; smp++) {
909 for (sb = 0; sb < smp; sb++)
910 y +=
MUL64(lpc_cof[sb], raw_samples[-(sb + 1)]);
912 *raw_samples++ -= y >> 20;
916 for (k = 0; k < opt_order; k++)
936 for (sb = -1; sb >= -sconf->
max_order; sb--)
937 raw_samples[sb] = right[sb] - left[sb];
942 for (sb = -1; sb >= -sconf->
max_order; sb--)
947 lpc_cof = lpc_cof + opt_order;
949 for (sb = 0; sb < opt_order; sb++)
950 lpc_cof_reversed[sb] = lpc_cof[-(sb + 1)];
954 lpc_cof = lpc_cof_reversed + opt_order;
956 for (; raw_samples < raw_samples_end; raw_samples++) {
959 for (sb = -opt_order; sb < 0; sb++)
960 y +=
MUL64(lpc_cof[sb], raw_samples[sb]);
962 *raw_samples -= y >> 20;
970 sizeof(*raw_samples) * sconf->
max_order);
1040 const unsigned int *div_blocks,
int32_t *buf)
1042 unsigned int count = 0;
1045 count += div_blocks[b++];
1048 memset(buf, 0,
sizeof(*buf) * count);
1055 unsigned int c,
const unsigned int *div_blocks,
1056 unsigned int *js_blocks)
1094 unsigned int c,
const unsigned int *div_blocks,
1095 unsigned int *js_blocks)
1149 if (bd[0].js_blocks) {
1150 if (bd[1].js_blocks)
1153 for (s = 0; s < div_blocks[
b]; s++)
1154 bd[0].raw_samples[s] = bd[1].raw_samples[s] - bd[0].raw_samples[s];
1155 }
else if (bd[1].js_blocks) {
1156 for (s = 0; s < div_blocks[
b]; s++)
1157 bd[1].raw_samples[s] = bd[1].raw_samples[s] + bd[0].raw_samples[s];
1160 offset += div_blocks[
b];
1212 if (entries == channels) {
1229 unsigned int dep = 0;
1237 while (dep < channels && !ch[dep].stop_flag) {
1239 ch[dep].master_channel);
1244 if (dep == channels) {
1261 while (!ch[dep].stop_flag) {
1263 unsigned int begin = 1;
1268 if (ch[dep].time_diff_flag) {
1271 if (ch[dep].time_diff_sign) {
1278 for (smp = begin; smp <
end; smp++) {
1280 MUL64(ch[dep].weighting[0], master[smp - 1 ]) +
1281 MUL64(ch[dep].weighting[1], master[smp ]) +
1282 MUL64(ch[dep].weighting[2], master[smp + 1 ]) +
1283 MUL64(ch[dep].weighting[3], master[smp - 1 + t]) +
1284 MUL64(ch[dep].weighting[4], master[smp + t]) +
1285 MUL64(ch[dep].weighting[5], master[smp + 1 + t]);
1290 for (smp = begin; smp <
end; smp++) {
1292 MUL64(ch[dep].weighting[0], master[smp - 1]) +
1293 MUL64(ch[dep].weighting[1], master[smp ]) +
1294 MUL64(ch[dep].weighting[2], master[smp + 1]);
1314 unsigned int div_blocks[32];
1316 unsigned int js_blocks[2];
1318 uint32_t bs_info = 0;
1332 for (c = 0; c < avctx->
channels; c++) {
1348 if (independent_bs) {
1371 for (c = 0; c < avctx->
channels; c++)
1377 memset(reverted_channels, 0,
sizeof(*reverted_channels) * avctx->
channels);
1387 for (c = 0; c < avctx->
channels; c++) {
1406 for (c = 0; c < avctx->
channels; c++)
1408 reverted_channels, offset, c))
1411 for (c = 0; c < avctx->
channels; c++) {
1427 memset(reverted_channels, 0, avctx->
channels *
sizeof(*reverted_channels));
1428 offset += div_blocks[
b];
1433 for (c = 0; c < avctx->
channels; c++)
1453 int buffer_size = avpkt->
size;
1454 int invalid_frame, ret;
1466 if (sconf->
samples != 0xFFFFFFFF)
1475 "Reading frame data failed. Skipping RA unit.\n");
1487 #define INTERLEAVE_OUTPUT(bps) \
1489 int##bps##_t *dest = (int##bps##_t*)ctx->frame.data[0]; \
1490 shift = bps - ctx->avctx->bits_per_raw_sample; \
1491 if (!ctx->cs_switch) { \
1492 for (sample = 0; sample < ctx->cur_frame_length; sample++) \
1493 for (c = 0; c < avctx->channels; c++) \
1494 *dest++ = ctx->raw_samples[c][sample] << shift; \
1496 for (sample = 0; sample < ctx->cur_frame_length; sample++) \
1497 for (c = 0; c < avctx->channels; c++) \
1498 *dest++ = ctx->raw_samples[sconf->chan_pos[c]][sample] << shift; \
1510 int swap = HAVE_BIGENDIAN != sconf->
msb_first;
1524 if (!HAVE_BIGENDIAN)
1534 int16_t *src = (int16_t*) ctx->
frame.
data[0];
1567 bytes_read = invalid_frame ? buffer_size :
1614 unsigned int channel_size;
1677 for (c = 0; c < num_buffers; c++) {
1702 for (c = 0; c < num_buffers; c++)
1708 num_buffers * num_buffers);
1720 for (c = 0; c < num_buffers; c++)
1743 for (c = 1; c < avctx->
channels; c++)