46 { {-52, 4}, {-29, 5}, {-31, 4}, { 19, 4}, {-16, 4},
47 { 12, 3}, { -7, 3}, { 9, 3}, { -5, 3}, { 6, 3},
48 { -4, 3}, { 3, 3}, { -3, 2}, { 3, 2}, { -2, 2},
49 { 3, 2}, { -1, 2}, { 2, 2}, { -1, 2}, { 2, 2} },
50 { {-58, 3}, {-42, 4}, {-46, 4}, { 37, 5}, {-36, 4},
51 { 29, 4}, {-29, 4}, { 25, 4}, {-23, 4}, { 20, 4},
52 {-17, 4}, { 16, 4}, {-12, 4}, { 12, 3}, {-10, 4},
53 { 7, 3}, { -4, 4}, { 3, 3}, { -1, 3}, { 1, 3} },
54 { {-59, 3}, {-45, 5}, {-50, 4}, { 38, 4}, {-39, 4},
55 { 32, 4}, {-30, 4}, { 25, 3}, {-23, 3}, { 20, 3},
56 {-20, 3}, { 16, 3}, {-13, 3}, { 10, 3}, { -7, 3},
57 { 3, 3}, { 0, 3}, { -1, 3}, { 2, 3}, { -1, 2} }
67 -1048544 / 32, -1048288 / 32, -1047776 / 32, -1047008 / 32,
68 -1045984 / 32, -1044704 / 32, -1043168 / 32, -1041376 / 32,
69 -1039328 / 32, -1037024 / 32, -1034464 / 32, -1031648 / 32,
70 -1028576 / 32, -1025248 / 32, -1021664 / 32, -1017824 / 32,
71 -1013728 / 32, -1009376 / 32, -1004768 / 32, -999904 / 32,
72 -994784 / 32, -989408 / 32, -983776 / 32, -977888 / 32,
73 -971744 / 32, -965344 / 32, -958688 / 32, -951776 / 32,
74 -944608 / 32, -937184 / 32, -929504 / 32, -921568 / 32,
75 -913376 / 32, -904928 / 32, -896224 / 32, -887264 / 32,
76 -878048 / 32, -868576 / 32, -858848 / 32, -848864 / 32,
77 -838624 / 32, -828128 / 32, -817376 / 32, -806368 / 32,
78 -795104 / 32, -783584 / 32, -771808 / 32, -759776 / 32,
79 -747488 / 32, -734944 / 32, -722144 / 32, -709088 / 32,
80 -695776 / 32, -682208 / 32, -668384 / 32, -654304 / 32,
81 -639968 / 32, -625376 / 32, -610528 / 32, -595424 / 32,
82 -580064 / 32, -564448 / 32, -548576 / 32, -532448 / 32,
83 -516064 / 32, -499424 / 32, -482528 / 32, -465376 / 32,
84 -447968 / 32, -430304 / 32, -412384 / 32, -394208 / 32,
85 -375776 / 32, -357088 / 32, -338144 / 32, -318944 / 32,
86 -299488 / 32, -279776 / 32, -259808 / 32, -239584 / 32,
87 -219104 / 32, -198368 / 32, -177376 / 32, -156128 / 32,
88 -134624 / 32, -112864 / 32, -90848 / 32, -68576 / 32,
89 -46048 / 32, -23264 / 32, -224 / 32, 23072 / 32,
90 46624 / 32, 70432 / 32, 94496 / 32, 118816 / 32,
91 143392 / 32, 168224 / 32, 193312 / 32, 218656 / 32,
92 244256 / 32, 270112 / 32, 296224 / 32, 322592 / 32,
93 349216 / 32, 376096 / 32, 403232 / 32, 430624 / 32,
94 458272 / 32, 486176 / 32, 514336 / 32, 542752 / 32,
95 571424 / 32, 600352 / 32, 629536 / 32, 658976 / 32,
96 688672 / 32, 718624 / 32, 748832 / 32, 779296 / 32,
97 810016 / 32, 840992 / 32, 872224 / 32, 903712 / 32,
98 935456 / 32, 967456 / 32, 999712 / 32, 1032224 / 32
117 204, 192, 179, 166, 153, 140, 128, 115,
118 102, 89, 76, 64, 51, 38, 25, 12,
119 0, -12, -25, -38, -51, -64, -76, -89,
120 -102, -115, -128, -140, -153, -166, -179, -192
127 { 74, 44, 25, 13, 7, 3},
128 { 68, 42, 24, 13, 7, 3},
129 { 58, 39, 23, 13, 7, 3},
130 {126, 70, 37, 19, 10, 5},
131 {132, 70, 37, 20, 10, 5},
132 {124, 70, 38, 20, 10, 5},
133 {120, 69, 37, 20, 11, 5},
134 {116, 67, 37, 20, 11, 5},
135 {108, 66, 36, 20, 10, 5},
136 {102, 62, 36, 20, 10, 5},
137 { 88, 58, 34, 19, 10, 5},
138 {162, 89, 49, 25, 13, 7},
139 {156, 87, 49, 26, 14, 7},
140 {150, 86, 47, 26, 14, 7},
141 {142, 84, 47, 26, 14, 7},
142 {131, 79, 46, 26, 14, 7}
282 int i, config_offset;
286 uint32_t als_id, header_size, trailer_size;
295 if (config_offset < 0)
335 if (als_id !=
MKBETAG(
'A',
'L',
'S',
'\0'))
348 int chan_pos_bits = av_ceil_log2(avctx->
channels);
349 int bits_needed = avctx->
channels * chan_pos_bits + 7;
358 for (i = 0; i < avctx->
channels; i++) {
381 if (header_size == 0xFFFFFFFF)
383 if (trailer_size == 0xFFFFFFFF)
386 ht_size = ((int64_t)(header_size) + (int64_t)(trailer_size)) << 3;
393 if (ht_size > INT32_MAX)
406 ctx->
crc = 0xFFFFFFFF;
429 #define MISSING_ERR(cond, str, errval) \
432 avpriv_report_missing_feature(ctx->avctx, \
449 unsigned int div,
unsigned int **div_blocks,
450 unsigned int *num_blocks)
452 if (n < 31 && ((bs_info << n) & 0x40000000)) {
493 for (i = 0, j = k - 1; i < j; i++, j--) {
494 int tmp1 = ((
MUL64(par[k], cof[j]) + (1 << 19)) >> 20);
495 cof[j] += ((
MUL64(par[k], cof[i]) + (1 << 19)) >> 20);
499 cof[i] += ((
MUL64(par[k], cof[j]) + (1 << 19)) >> 20);
514 unsigned int *ptr_div_blocks = div_blocks;
520 *bs_info <<= (32 - bs_info_len);
548 if (remaining <= div_blocks[b]) {
549 div_blocks[
b] = remaining;
554 remaining -= div_blocks[
b];
614 unsigned int sub_blocks, log2_sub_blocks, sb_length;
615 unsigned int start = 0;
616 unsigned int opt_order;
640 sub_blocks = 1 << log2_sub_blocks;
646 "Block length is not evenly divisible by the number of subblocks.\n");
654 for (k = 1; k < sub_blocks; k++)
657 for (k = 0; k < sub_blocks; k++) {
663 for (k = 1; k < sub_blocks; k++)
666 for (k = 1; k < sub_blocks; k++)
680 int opt_order_length = av_ceil_log2(av_clip((bd->
block_length >> 3) - 1,
708 for (k = 2; k < opt_order; k++)
715 k_max =
FFMIN(opt_order, 20);
716 for (k = 0; k < k_max; k++) {
720 if (quant_cof[k] < -64 || quant_cof[k] > 63) {
727 k_max =
FFMIN(opt_order, 127);
728 for (; k < k_max; k++)
732 for (; k < opt_order; k++)
741 for (k = 2; k < opt_order; k++)
742 quant_cof[k] = (quant_cof[k] << 14) + (add_base << 13);
777 start =
FFMIN(opt_order, 3);
784 unsigned int b = av_clip((av_ceil_log2(bd->
block_length) - 3) >> 1, 0, 5);
795 for (sb = 0; sb < sub_blocks; sb++) {
796 unsigned int sb_len = sb_length - (sb ? 0 :
start);
798 k [sb] = s[sb] > b ? s[sb] - b : 0;
799 delta[sb] = 5 - s[sb] + k[sb];
804 current_res += sb_len;
813 for (sb = 0; sb < sub_blocks; sb++, start = 0) {
814 unsigned int cur_tail_code =
tail_code[sx[sb]][delta[sb]];
815 unsigned int cur_k = k[sb];
816 unsigned int cur_s = s[sb];
818 for (; start < sb_length; start++) {
821 if (res == cur_tail_code) {
822 unsigned int max_msb = (2 + (sx[sb] > 2) + (sx[sb] > 10))
828 res += (max_msb ) << cur_k;
830 res -= (max_msb - 1) << cur_k;
833 if (res > cur_tail_code)
847 *current_res++ =
res;
853 for (sb = 0; sb < sub_blocks; sb++, start = 0)
854 for (; start < sb_length; start++)
871 unsigned int smp = 0;
886 for (ltp_smp =
FFMAX(*bd->
ltp_lag - 2, 0); ltp_smp < block_length; ltp_smp++) {
887 int center = ltp_smp - *bd->
ltp_lag;
888 int begin =
FFMAX(0, center - 2);
889 int end = center + 3;
890 int tab = 5 - (end - begin);
895 for (base = begin; base <
end; base++, tab++)
898 raw_samples[ltp_smp] += y >> 7;
904 for (smp = 0; smp < opt_order; smp++) {
907 for (sb = 0; sb < smp; sb++)
908 y +=
MUL64(lpc_cof[sb], raw_samples[-(sb + 1)]);
910 *raw_samples++ -= y >> 20;
914 for (k = 0; k < opt_order; k++)
934 for (sb = -1; sb >= -sconf->
max_order; sb--)
935 raw_samples[sb] = right[sb] - left[sb];
940 for (sb = -1; sb >= -sconf->
max_order; sb--)
945 lpc_cof = lpc_cof + opt_order;
947 for (sb = 0; sb < opt_order; sb++)
948 lpc_cof_reversed[sb] = lpc_cof[-(sb + 1)];
952 lpc_cof = lpc_cof_reversed + opt_order;
954 for (; raw_samples < raw_samples_end; raw_samples++) {
957 for (sb = -opt_order; sb < 0; sb++)
958 y +=
MUL64(lpc_cof[sb], raw_samples[sb]);
960 *raw_samples -= y >> 20;
968 sizeof(*raw_samples) * sconf->
max_order);
1038 const unsigned int *div_blocks,
int32_t *
buf)
1040 unsigned int count = 0;
1043 count += div_blocks[b++];
1046 memset(buf, 0,
sizeof(*buf) * count);
1053 unsigned int c,
const unsigned int *div_blocks,
1054 unsigned int *js_blocks)
1092 unsigned int c,
const unsigned int *div_blocks,
1093 unsigned int *js_blocks)
1147 if (bd[0].js_blocks) {
1148 if (bd[1].js_blocks)
1151 for (s = 0; s < div_blocks[
b]; s++)
1152 bd[0].raw_samples[s] = bd[1].raw_samples[s] - bd[0].raw_samples[s];
1153 }
else if (bd[1].js_blocks) {
1154 for (s = 0; s < div_blocks[
b]; s++)
1155 bd[1].raw_samples[s] = bd[1].raw_samples[s] + bd[0].raw_samples[s];
1158 offset += div_blocks[
b];
1210 if (entries == channels) {
1227 unsigned int dep = 0;
1235 while (dep < channels && !ch[dep].stop_flag) {
1237 ch[dep].master_channel);
1242 if (dep == channels) {
1259 while (!ch[dep].stop_flag) {
1261 unsigned int begin = 1;
1266 if (ch[dep].time_diff_flag) {
1269 if (ch[dep].time_diff_sign) {
1276 for (smp = begin; smp <
end; smp++) {
1278 MUL64(ch[dep].weighting[0], master[smp - 1 ]) +
1279 MUL64(ch[dep].weighting[1], master[smp ]) +
1280 MUL64(ch[dep].weighting[2], master[smp + 1 ]) +
1281 MUL64(ch[dep].weighting[3], master[smp - 1 + t]) +
1282 MUL64(ch[dep].weighting[4], master[smp + t]) +
1283 MUL64(ch[dep].weighting[5], master[smp + 1 + t]);
1288 for (smp = begin; smp <
end; smp++) {
1290 MUL64(ch[dep].weighting[0], master[smp - 1]) +
1291 MUL64(ch[dep].weighting[1], master[smp ]) +
1292 MUL64(ch[dep].weighting[2], master[smp + 1]);
1312 unsigned int div_blocks[32];
1314 unsigned int js_blocks[2];
1316 uint32_t bs_info = 0;
1330 for (c = 0; c < avctx->
channels; c++) {
1346 if (independent_bs) {
1369 for (c = 0; c < avctx->
channels; c++)
1375 memset(reverted_channels, 0,
sizeof(*reverted_channels) * avctx->
channels);
1385 for (c = 0; c < avctx->
channels; c++) {
1404 for (c = 0; c < avctx->
channels; c++)
1406 reverted_channels, offset, c))
1409 for (c = 0; c < avctx->
channels; c++) {
1425 memset(reverted_channels, 0, avctx->
channels *
sizeof(*reverted_channels));
1426 offset += div_blocks[
b];
1431 for (c = 0; c < avctx->
channels; c++)
1452 int buffer_size = avpkt->
size;
1453 int invalid_frame,
ret;
1465 if (sconf->
samples != 0xFFFFFFFF)
1474 "Reading frame data failed. Skipping RA unit.\n");
1484 #define INTERLEAVE_OUTPUT(bps) \
1486 int##bps##_t *dest = (int##bps##_t*)frame->data[0]; \
1487 shift = bps - ctx->avctx->bits_per_raw_sample; \
1488 if (!ctx->cs_switch) { \
1489 for (sample = 0; sample < ctx->cur_frame_length; sample++) \
1490 for (c = 0; c < avctx->channels; c++) \
1491 *dest++ = ctx->raw_samples[c][sample] << shift; \
1493 for (sample = 0; sample < ctx->cur_frame_length; sample++) \
1494 for (c = 0; c < avctx->channels; c++) \
1495 *dest++ = ctx->raw_samples[sconf->chan_pos[c]][sample] << shift; \
1507 int swap = HAVE_BIGENDIAN != sconf->
msb_first;
1521 if (!HAVE_BIGENDIAN)
1531 int16_t *
src = (int16_t*) frame->
data[0];
1539 (uint32_t *)frame->
data[0],
1544 crc_source = frame->
data[0];
1562 bytes_read = invalid_frame ? buffer_size :
1609 unsigned int channel_size;
1672 for (c = 0; c < num_buffers; c++) {
1697 for (c = 0; c < num_buffers; c++)
1703 num_buffers * num_buffers);
1715 for (c = 0; c < num_buffers; c++)
1738 for (c = 1; c < avctx->
channels; c++)