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,
712 for (k = 2; k < opt_order; k++)
719 k_max =
FFMIN(opt_order, 20);
720 for (k = 0; k < k_max; k++) {
724 if (quant_cof[k] < -64 || quant_cof[k] > 63) {
731 k_max =
FFMIN(opt_order, 127);
732 for (; k < k_max; k++)
736 for (; k < opt_order; k++)
745 for (k = 2; k < opt_order; k++)
746 quant_cof[k] = (quant_cof[k] << 14) + (add_base << 13);
781 start =
FFMIN(opt_order, 3);
788 unsigned int b = av_clip((av_ceil_log2(bd->
block_length) - 3) >> 1, 0, 5);
799 for (sb = 0; sb < sub_blocks; sb++) {
800 unsigned int sb_len = sb_length - (sb ? 0 :
start);
802 k [sb] = s[sb] > b ? s[sb] - b : 0;
803 delta[sb] = 5 - s[sb] + k[sb];
808 current_res += sb_len;
817 for (sb = 0; sb < sub_blocks; sb++, start = 0) {
818 unsigned int cur_tail_code =
tail_code[sx[sb]][delta[sb]];
819 unsigned int cur_k = k[sb];
820 unsigned int cur_s = s[sb];
822 for (; start < sb_length; start++) {
825 if (res == cur_tail_code) {
826 unsigned int max_msb = (2 + (sx[sb] > 2) + (sx[sb] > 10))
832 res += (max_msb ) << cur_k;
834 res -= (max_msb - 1) << cur_k;
837 if (res > cur_tail_code)
851 *current_res++ =
res;
857 for (sb = 0; sb < sub_blocks; sb++, start = 0)
858 for (; start < sb_length; start++)
875 unsigned int smp = 0;
890 for (ltp_smp =
FFMAX(*bd->
ltp_lag - 2, 0); ltp_smp < block_length; ltp_smp++) {
891 int center = ltp_smp - *bd->
ltp_lag;
892 int begin =
FFMAX(0, center - 2);
893 int end = center + 3;
894 int tab = 5 - (end - begin);
899 for (base = begin; base <
end; base++, tab++)
902 raw_samples[ltp_smp] += y >> 7;
908 for (smp = 0; smp < opt_order; smp++) {
911 for (sb = 0; sb < smp; sb++)
912 y +=
MUL64(lpc_cof[sb], raw_samples[-(sb + 1)]);
914 *raw_samples++ -= y >> 20;
918 for (k = 0; k < opt_order; k++)
938 for (sb = -1; sb >= -sconf->
max_order; sb--)
939 raw_samples[sb] = right[sb] - left[sb];
944 for (sb = -1; sb >= -sconf->
max_order; sb--)
949 lpc_cof = lpc_cof + opt_order;
951 for (sb = 0; sb < opt_order; sb++)
952 lpc_cof_reversed[sb] = lpc_cof[-(sb + 1)];
956 lpc_cof = lpc_cof_reversed + opt_order;
958 for (; raw_samples < raw_samples_end; raw_samples++) {
961 for (sb = -opt_order; sb < 0; sb++)
962 y +=
MUL64(lpc_cof[sb], raw_samples[sb]);
964 *raw_samples -= y >> 20;
972 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)
1095 unsigned int c,
const unsigned int *div_blocks,
1096 unsigned int *js_blocks)
1148 if (bd[0].js_blocks) {
1149 if (bd[1].js_blocks)
1152 for (s = 0; s < div_blocks[
b]; s++)
1153 bd[0].raw_samples[s] = bd[1].raw_samples[s] - bd[0].raw_samples[s];
1154 }
else if (bd[1].js_blocks) {
1155 for (s = 0; s < div_blocks[
b]; s++)
1156 bd[1].raw_samples[s] = bd[1].raw_samples[s] + bd[0].raw_samples[s];
1159 offset += div_blocks[
b];
1222 if (entries == channels) {
1239 unsigned int dep = 0;
1247 while (dep < channels && !ch[dep].stop_flag) {
1249 ch[dep].master_channel);
1254 if (dep == channels) {
1270 for (dep = 0; !ch[dep].
stop_flag; dep++) {
1272 unsigned int begin = 1;
1277 if (ch[dep].master_channel == c)
1280 if (ch[dep].time_diff_flag) {
1283 if (ch[dep].time_diff_sign) {
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 ]) +
1295 MUL64(ch[dep].weighting[3], master[smp - 1 + t]) +
1296 MUL64(ch[dep].weighting[4], master[smp + t]) +
1297 MUL64(ch[dep].weighting[5], master[smp + 1 + t]);
1302 for (smp = begin; smp <
end; smp++) {
1304 MUL64(ch[dep].weighting[0], master[smp - 1]) +
1305 MUL64(ch[dep].weighting[1], master[smp ]) +
1306 MUL64(ch[dep].weighting[2], master[smp + 1]);
1324 unsigned int div_blocks[32];
1326 unsigned int js_blocks[2];
1327 uint32_t bs_info = 0;
1342 for (c = 0; c < avctx->
channels; c++) {
1358 if (independent_bs) {
1360 div_blocks, js_blocks);
1365 ret =
decode_blocks(ctx, ra_frame, c, div_blocks, js_blocks);
1383 for (c = 0; c < avctx->
channels; c++)
1389 memset(reverted_channels, 0,
sizeof(*reverted_channels) * avctx->
channels);
1400 "Invalid block length %d in channel data!\n", bd.
block_length);
1404 for (c = 0; c < avctx->
channels; c++) {
1423 for (c = 0; c < avctx->
channels; c++) {
1425 reverted_channels, offset, c);
1429 for (c = 0; c < avctx->
channels; c++) {
1445 memset(reverted_channels, 0, avctx->
channels *
sizeof(*reverted_channels));
1446 offset += div_blocks[
b];
1451 for (c = 0; c < avctx->
channels; c++)
1472 int buffer_size = avpkt->
size;
1473 int invalid_frame,
ret;
1485 if (sconf->
samples != 0xFFFFFFFF)
1494 "Reading frame data failed. Skipping RA unit.\n");
1504 #define INTERLEAVE_OUTPUT(bps) \
1506 int##bps##_t *dest = (int##bps##_t*)frame->data[0]; \
1507 shift = bps - ctx->avctx->bits_per_raw_sample; \
1508 if (!ctx->cs_switch) { \
1509 for (sample = 0; sample < ctx->cur_frame_length; sample++) \
1510 for (c = 0; c < avctx->channels; c++) \
1511 *dest++ = ctx->raw_samples[c][sample] << shift; \
1513 for (sample = 0; sample < ctx->cur_frame_length; sample++) \
1514 for (c = 0; c < avctx->channels; c++) \
1515 *dest++ = ctx->raw_samples[sconf->chan_pos[c]][sample] << shift; \
1527 int swap = HAVE_BIGENDIAN != sconf->
msb_first;
1541 if (!HAVE_BIGENDIAN)
1551 int16_t *
src = (int16_t*) frame->
data[0];
1559 (uint32_t *)frame->
data[0],
1564 crc_source = frame->
data[0];
1584 bytes_read = invalid_frame ? buffer_size :
1631 unsigned int channel_size;
1632 int num_buffers,
ret;
1695 for (c = 0; c < num_buffers; c++) {
1720 for (c = 0; c < num_buffers; c++)
1726 num_buffers * num_buffers);
1738 for (c = 0; c < num_buffers; c++)
1761 for (c = 1; c < avctx->
channels; c++)