48 { {-52, 4}, {-29, 5}, {-31, 4}, { 19, 4}, {-16, 4},
49 { 12, 3}, { -7, 3}, { 9, 3}, { -5, 3}, { 6, 3},
50 { -4, 3}, { 3, 3}, { -3, 2}, { 3, 2}, { -2, 2},
51 { 3, 2}, { -1, 2}, { 2, 2}, { -1, 2}, { 2, 2} },
52 { {-58, 3}, {-42, 4}, {-46, 4}, { 37, 5}, {-36, 4},
53 { 29, 4}, {-29, 4}, { 25, 4}, {-23, 4}, { 20, 4},
54 {-17, 4}, { 16, 4}, {-12, 4}, { 12, 3}, {-10, 4},
55 { 7, 3}, { -4, 4}, { 3, 3}, { -1, 3}, { 1, 3} },
56 { {-59, 3}, {-45, 5}, {-50, 4}, { 38, 4}, {-39, 4},
57 { 32, 4}, {-30, 4}, { 25, 3}, {-23, 3}, { 20, 3},
58 {-20, 3}, { 16, 3}, {-13, 3}, { 10, 3}, { -7, 3},
59 { 3, 3}, { 0, 3}, { -1, 3}, { 2, 3}, { -1, 2} }
69 -1048544 / 32, -1048288 / 32, -1047776 / 32, -1047008 / 32,
70 -1045984 / 32, -1044704 / 32, -1043168 / 32, -1041376 / 32,
71 -1039328 / 32, -1037024 / 32, -1034464 / 32, -1031648 / 32,
72 -1028576 / 32, -1025248 / 32, -1021664 / 32, -1017824 / 32,
73 -1013728 / 32, -1009376 / 32, -1004768 / 32, -999904 / 32,
74 -994784 / 32, -989408 / 32, -983776 / 32, -977888 / 32,
75 -971744 / 32, -965344 / 32, -958688 / 32, -951776 / 32,
76 -944608 / 32, -937184 / 32, -929504 / 32, -921568 / 32,
77 -913376 / 32, -904928 / 32, -896224 / 32, -887264 / 32,
78 -878048 / 32, -868576 / 32, -858848 / 32, -848864 / 32,
79 -838624 / 32, -828128 / 32, -817376 / 32, -806368 / 32,
80 -795104 / 32, -783584 / 32, -771808 / 32, -759776 / 32,
81 -747488 / 32, -734944 / 32, -722144 / 32, -709088 / 32,
82 -695776 / 32, -682208 / 32, -668384 / 32, -654304 / 32,
83 -639968 / 32, -625376 / 32, -610528 / 32, -595424 / 32,
84 -580064 / 32, -564448 / 32, -548576 / 32, -532448 / 32,
85 -516064 / 32, -499424 / 32, -482528 / 32, -465376 / 32,
86 -447968 / 32, -430304 / 32, -412384 / 32, -394208 / 32,
87 -375776 / 32, -357088 / 32, -338144 / 32, -318944 / 32,
88 -299488 / 32, -279776 / 32, -259808 / 32, -239584 / 32,
89 -219104 / 32, -198368 / 32, -177376 / 32, -156128 / 32,
90 -134624 / 32, -112864 / 32, -90848 / 32, -68576 / 32,
91 -46048 / 32, -23264 / 32, -224 / 32, 23072 / 32,
92 46624 / 32, 70432 / 32, 94496 / 32, 118816 / 32,
93 143392 / 32, 168224 / 32, 193312 / 32, 218656 / 32,
94 244256 / 32, 270112 / 32, 296224 / 32, 322592 / 32,
95 349216 / 32, 376096 / 32, 403232 / 32, 430624 / 32,
96 458272 / 32, 486176 / 32, 514336 / 32, 542752 / 32,
97 571424 / 32, 600352 / 32, 629536 / 32, 658976 / 32,
98 688672 / 32, 718624 / 32, 748832 / 32, 779296 / 32,
99 810016 / 32, 840992 / 32, 872224 / 32, 903712 / 32,
100 935456 / 32, 967456 / 32, 999712 / 32, 1032224 / 32
119 204, 192, 179, 166, 153, 140, 128, 115,
120 102, 89, 76, 64, 51, 38, 25, 12,
121 0, -12, -25, -38, -51, -64, -76, -89,
122 -102, -115, -128, -140, -153, -166, -179, -192
129 { 74, 44, 25, 13, 7, 3},
130 { 68, 42, 24, 13, 7, 3},
131 { 58, 39, 23, 13, 7, 3},
132 {126, 70, 37, 19, 10, 5},
133 {132, 70, 37, 20, 10, 5},
134 {124, 70, 38, 20, 10, 5},
135 {120, 69, 37, 20, 11, 5},
136 {116, 67, 37, 20, 11, 5},
137 {108, 66, 36, 20, 10, 5},
138 {102, 62, 36, 20, 10, 5},
139 { 88, 58, 34, 19, 10, 5},
140 {162, 89, 49, 25, 13, 7},
141 {156, 87, 49, 26, 14, 7},
142 {150, 86, 47, 26, 14, 7},
143 {142, 84, 47, 26, 14, 7},
144 {131, 79, 46, 26, 14, 7}
284 int i, config_offset;
288 uint32_t als_id, header_size, trailer_size;
297 if (config_offset < 0)
337 if (als_id !=
MKBETAG(
'A',
'L',
'S',
'\0'))
350 int chan_pos_bits = av_ceil_log2(avctx->
channels);
351 int bits_needed = avctx->
channels * chan_pos_bits + 7;
360 for (i = 0; i < avctx->
channels; i++) {
383 if (header_size == 0xFFFFFFFF)
385 if (trailer_size == 0xFFFFFFFF)
388 ht_size = ((int64_t)(header_size) + (int64_t)(trailer_size)) << 3;
395 if (ht_size > INT32_MAX)
408 ctx->
crc = 0xFFFFFFFF;
431 #define MISSING_ERR(cond, str, errval) \
434 avpriv_report_missing_feature(ctx->avctx, \
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,
714 for (k = 2; k < opt_order; k++)
721 k_max =
FFMIN(opt_order, 20);
722 for (k = 0; k < k_max; k++) {
726 if (quant_cof[k] < -64 || quant_cof[k] > 63) {
728 "quant_cof %"PRIu32
" is out of range.\n",
735 k_max =
FFMIN(opt_order, 127);
736 for (; k < k_max; k++)
740 for (; k < opt_order; k++)
749 for (k = 2; k < opt_order; k++)
750 quant_cof[k] = (quant_cof[k] << 14) + (add_base << 13);
785 start =
FFMIN(opt_order, 3);
792 unsigned int b = av_clip((av_ceil_log2(bd->
block_length) - 3) >> 1, 0, 5);
803 for (sb = 0; sb < sub_blocks; sb++) {
804 unsigned int sb_len = sb_length - (sb ? 0 :
start);
806 k [sb] = s[sb] > b ? s[sb] - b : 0;
807 delta[sb] = 5 - s[sb] + k[sb];
812 current_res += sb_len;
821 for (sb = 0; sb < sub_blocks; sb++, start = 0) {
822 unsigned int cur_tail_code =
tail_code[sx[sb]][delta[sb]];
823 unsigned int cur_k = k[sb];
824 unsigned int cur_s = s[sb];
826 for (; start < sb_length; start++) {
829 if (res == cur_tail_code) {
830 unsigned int max_msb = (2 + (sx[sb] > 2) + (sx[sb] > 10))
836 res += (max_msb ) << cur_k;
838 res -= (max_msb - 1) << cur_k;
841 if (res > cur_tail_code)
855 *current_res++ = res;
861 for (sb = 0; sb < sub_blocks; sb++, start = 0)
862 for (; start < sb_length; start++)
879 unsigned int smp = 0;
894 for (ltp_smp =
FFMAX(*bd->
ltp_lag - 2, 0); ltp_smp < block_length; ltp_smp++) {
895 int center = ltp_smp - *bd->
ltp_lag;
896 int begin =
FFMAX(0, center - 2);
897 int end = center + 3;
898 int tab = 5 - (end - begin);
903 for (base = begin; base <
end; base++, tab++)
906 raw_samples[ltp_smp] += y >> 7;
912 for (smp = 0; smp < opt_order; smp++) {
915 for (sb = 0; sb < smp; sb++)
916 y +=
MUL64(lpc_cof[sb], raw_samples[-(sb + 1)]);
918 *raw_samples++ -= y >> 20;
922 for (k = 0; k < opt_order; k++)
942 for (sb = -1; sb >= -sconf->
max_order; sb--)
943 raw_samples[sb] = right[sb] - left[sb];
948 for (sb = -1; sb >= -sconf->
max_order; sb--)
953 lpc_cof = lpc_cof + opt_order;
955 for (sb = 0; sb < opt_order; sb++)
956 lpc_cof_reversed[sb] = lpc_cof[-(sb + 1)];
960 lpc_cof = lpc_cof_reversed + opt_order;
962 for (; raw_samples < raw_samples_end; raw_samples++) {
965 for (sb = -opt_order; sb < 0; sb++)
966 y +=
MUL64(lpc_cof[sb], raw_samples[sb]);
968 *raw_samples -= y >> 20;
976 sizeof(*raw_samples) * sconf->
max_order);
1044 const unsigned int *div_blocks,
int32_t *
buf)
1046 unsigned int count = 0;
1049 count += div_blocks[b++];
1052 memset(buf, 0,
sizeof(*buf) * count);
1059 unsigned int c,
const unsigned int *div_blocks,
1060 unsigned int *js_blocks)
1099 unsigned int c,
const unsigned int *div_blocks,
1100 unsigned int *js_blocks)
1152 if (bd[0].js_blocks) {
1153 if (bd[1].js_blocks)
1156 for (s = 0; s < div_blocks[
b]; s++)
1157 bd[0].raw_samples[s] = bd[1].raw_samples[s] - bd[0].raw_samples[s];
1158 }
else if (bd[1].js_blocks) {
1159 for (s = 0; s < div_blocks[
b]; s++)
1160 bd[1].raw_samples[s] = bd[1].raw_samples[s] + bd[0].raw_samples[s];
1163 offset += div_blocks[
b];
1226 if (entries == channels) {
1243 unsigned int dep = 0;
1251 while (dep < channels && !ch[dep].stop_flag) {
1253 ch[dep].master_channel);
1258 if (dep == channels) {
1274 for (dep = 0; !ch[dep].
stop_flag; dep++) {
1276 unsigned int begin = 1;
1281 if (ch[dep].master_channel == c)
1284 if (ch[dep].time_diff_flag) {
1287 if (ch[dep].time_diff_sign) {
1294 for (smp = begin; smp <
end; smp++) {
1296 MUL64(ch[dep].weighting[0], master[smp - 1 ]) +
1297 MUL64(ch[dep].weighting[1], master[smp ]) +
1298 MUL64(ch[dep].weighting[2], master[smp + 1 ]) +
1299 MUL64(ch[dep].weighting[3], master[smp - 1 + t]) +
1300 MUL64(ch[dep].weighting[4], master[smp + t]) +
1301 MUL64(ch[dep].weighting[5], master[smp + 1 + t]);
1306 for (smp = begin; smp <
end; smp++) {
1308 MUL64(ch[dep].weighting[0], master[smp - 1]) +
1309 MUL64(ch[dep].weighting[1], master[smp ]) +
1310 MUL64(ch[dep].weighting[2], master[smp + 1]);
1328 unsigned int div_blocks[32];
1330 unsigned int js_blocks[2];
1331 uint32_t bs_info = 0;
1346 for (c = 0; c < avctx->
channels; c++) {
1362 if (independent_bs) {
1364 div_blocks, js_blocks);
1369 ret =
decode_blocks(ctx, ra_frame, c, div_blocks, js_blocks);
1387 for (c = 0; c < avctx->
channels; c++)
1393 memset(reverted_channels, 0,
sizeof(*reverted_channels) * avctx->
channels);
1404 "Invalid block length %u in channel data!\n",
1409 for (c = 0; c < avctx->
channels; c++) {
1428 for (c = 0; c < avctx->
channels; c++) {
1430 reverted_channels, offset, c);
1434 for (c = 0; c < avctx->
channels; c++) {
1450 memset(reverted_channels, 0, avctx->
channels *
sizeof(*reverted_channels));
1451 offset += div_blocks[
b];
1456 for (c = 0; c < avctx->
channels; c++)
1477 int buffer_size = avpkt->
size;
1478 int invalid_frame,
ret;
1490 if (sconf->
samples != 0xFFFFFFFF)
1499 "Reading frame data failed. Skipping RA unit.\n");
1509 #define INTERLEAVE_OUTPUT(bps) \
1511 int##bps##_t *dest = (int##bps##_t*)frame->data[0]; \
1512 shift = bps - ctx->avctx->bits_per_raw_sample; \
1513 if (!ctx->cs_switch) { \
1514 for (sample = 0; sample < ctx->cur_frame_length; sample++) \
1515 for (c = 0; c < avctx->channels; c++) \
1516 *dest++ = ctx->raw_samples[c][sample] << shift; \
1518 for (sample = 0; sample < ctx->cur_frame_length; sample++) \
1519 for (c = 0; c < avctx->channels; c++) \
1520 *dest++ = ctx->raw_samples[sconf->chan_pos[c]][sample] << shift; \
1532 int swap = HAVE_BIGENDIAN != sconf->
msb_first;
1546 if (!HAVE_BIGENDIAN)
1556 int16_t *
src = (int16_t*) frame->
data[0];
1564 (uint32_t *) frame->
data[0],
1569 crc_source = frame->
data[0];
1589 bytes_read = invalid_frame ? buffer_size :
1636 unsigned int channel_size;
1637 int num_buffers,
ret;
1700 for (c = 0; c < num_buffers; c++) {
1725 for (c = 0; c < num_buffers; c++)
1731 num_buffers * num_buffers);
1743 for (c = 0; c < num_buffers; c++)
1766 for (c = 1; c < avctx->
channels; c++)