49 { {-52, 4}, {-29, 5}, {-31, 4}, { 19, 4}, {-16, 4},
50 { 12, 3}, { -7, 3}, { 9, 3}, { -5, 3}, { 6, 3},
51 { -4, 3}, { 3, 3}, { -3, 2}, { 3, 2}, { -2, 2},
52 { 3, 2}, { -1, 2}, { 2, 2}, { -1, 2}, { 2, 2} },
53 { {-58, 3}, {-42, 4}, {-46, 4}, { 37, 5}, {-36, 4},
54 { 29, 4}, {-29, 4}, { 25, 4}, {-23, 4}, { 20, 4},
55 {-17, 4}, { 16, 4}, {-12, 4}, { 12, 3}, {-10, 4},
56 { 7, 3}, { -4, 4}, { 3, 3}, { -1, 3}, { 1, 3} },
57 { {-59, 3}, {-45, 5}, {-50, 4}, { 38, 4}, {-39, 4},
58 { 32, 4}, {-30, 4}, { 25, 3}, {-23, 3}, { 20, 3},
59 {-20, 3}, { 16, 3}, {-13, 3}, { 10, 3}, { -7, 3},
60 { 3, 3}, { 0, 3}, { -1, 3}, { 2, 3}, { -1, 2} }
70 -1048544 / 32, -1048288 / 32, -1047776 / 32, -1047008 / 32,
71 -1045984 / 32, -1044704 / 32, -1043168 / 32, -1041376 / 32,
72 -1039328 / 32, -1037024 / 32, -1034464 / 32, -1031648 / 32,
73 -1028576 / 32, -1025248 / 32, -1021664 / 32, -1017824 / 32,
74 -1013728 / 32, -1009376 / 32, -1004768 / 32, -999904 / 32,
75 -994784 / 32, -989408 / 32, -983776 / 32, -977888 / 32,
76 -971744 / 32, -965344 / 32, -958688 / 32, -951776 / 32,
77 -944608 / 32, -937184 / 32, -929504 / 32, -921568 / 32,
78 -913376 / 32, -904928 / 32, -896224 / 32, -887264 / 32,
79 -878048 / 32, -868576 / 32, -858848 / 32, -848864 / 32,
80 -838624 / 32, -828128 / 32, -817376 / 32, -806368 / 32,
81 -795104 / 32, -783584 / 32, -771808 / 32, -759776 / 32,
82 -747488 / 32, -734944 / 32, -722144 / 32, -709088 / 32,
83 -695776 / 32, -682208 / 32, -668384 / 32, -654304 / 32,
84 -639968 / 32, -625376 / 32, -610528 / 32, -595424 / 32,
85 -580064 / 32, -564448 / 32, -548576 / 32, -532448 / 32,
86 -516064 / 32, -499424 / 32, -482528 / 32, -465376 / 32,
87 -447968 / 32, -430304 / 32, -412384 / 32, -394208 / 32,
88 -375776 / 32, -357088 / 32, -338144 / 32, -318944 / 32,
89 -299488 / 32, -279776 / 32, -259808 / 32, -239584 / 32,
90 -219104 / 32, -198368 / 32, -177376 / 32, -156128 / 32,
91 -134624 / 32, -112864 / 32, -90848 / 32, -68576 / 32,
92 -46048 / 32, -23264 / 32, -224 / 32, 23072 / 32,
93 46624 / 32, 70432 / 32, 94496 / 32, 118816 / 32,
94 143392 / 32, 168224 / 32, 193312 / 32, 218656 / 32,
95 244256 / 32, 270112 / 32, 296224 / 32, 322592 / 32,
96 349216 / 32, 376096 / 32, 403232 / 32, 430624 / 32,
97 458272 / 32, 486176 / 32, 514336 / 32, 542752 / 32,
98 571424 / 32, 600352 / 32, 629536 / 32, 658976 / 32,
99 688672 / 32, 718624 / 32, 748832 / 32, 779296 / 32,
100 810016 / 32, 840992 / 32, 872224 / 32, 903712 / 32,
101 935456 / 32, 967456 / 32, 999712 / 32, 1032224 / 32
120 204, 192, 179, 166, 153, 140, 128, 115,
121 102, 89, 76, 64, 51, 38, 25, 12,
122 0, -12, -25, -38, -51, -64, -76, -89,
123 -102, -115, -128, -140, -153, -166, -179, -192
130 { 74, 44, 25, 13, 7, 3},
131 { 68, 42, 24, 13, 7, 3},
132 { 58, 39, 23, 13, 7, 3},
133 {126, 70, 37, 19, 10, 5},
134 {132, 70, 37, 20, 10, 5},
135 {124, 70, 38, 20, 10, 5},
136 {120, 69, 37, 20, 11, 5},
137 {116, 67, 37, 20, 11, 5},
138 {108, 66, 36, 20, 10, 5},
139 {102, 62, 36, 20, 10, 5},
140 { 88, 58, 34, 19, 10, 5},
141 {162, 89, 49, 25, 13, 7},
142 {156, 87, 49, 26, 14, 7},
143 {150, 86, 47, 26, 14, 7},
144 {142, 84, 47, 26, 14, 7},
145 {131, 79, 46, 26, 14, 7}
285 int i, config_offset;
289 uint32_t als_id, header_size, trailer_size;
296 if (config_offset < 0)
336 if (als_id !=
MKBETAG(
'A',
'L',
'S',
'\0'))
349 int chan_pos_bits = av_ceil_log2(avctx->
channels);
350 int bits_needed = avctx->
channels * chan_pos_bits + 7;
357 for (i = 0; i < avctx->
channels; i++)
374 if (header_size == 0xFFFFFFFF)
376 if (trailer_size == 0xFFFFFFFF)
379 ht_size = ((int64_t)(header_size) + (int64_t)(trailer_size)) << 3;
399 ctx->
crc = 0xFFFFFFFF;
422 #define MISSING_ERR(cond, str, errval) \
425 av_log_missing_feature(ctx->avctx, str, 0); \
442 unsigned int div,
unsigned int **div_blocks,
443 unsigned int *num_blocks)
445 if (n < 31 && ((bs_info << n) & 0x40000000)) {
486 for (i = 0, j = k - 1; i < j; i++, j--) {
487 int tmp1 = ((
MUL64(par[k], cof[j]) + (1 << 19)) >> 20);
488 cof[j] += ((
MUL64(par[k], cof[i]) + (1 << 19)) >> 20);
492 cof[i] += ((
MUL64(par[k], cof[j]) + (1 << 19)) >> 20);
507 unsigned int *ptr_div_blocks = div_blocks;
513 *bs_info <<= (32 - bs_info_len);
541 if (remaining <= div_blocks[b]) {
542 div_blocks[
b] = remaining;
547 remaining -= div_blocks[
b];
602 unsigned int sub_blocks, log2_sub_blocks, sb_length;
603 unsigned int start = 0;
604 unsigned int opt_order;
607 int32_t *current_res;
628 sub_blocks = 1 << log2_sub_blocks;
634 "Block length is not evenly divisible by the number of subblocks.\n");
642 for (k = 1; k < sub_blocks; k++)
645 for (k = 0; k < sub_blocks; k++) {
651 for (k = 1; k < sub_blocks; k++)
663 int opt_order_length = av_ceil_log2(av_clip((bd->
block_length >> 3) - 1,
686 for (k = 2; k < opt_order; k++)
693 k_max =
FFMIN(opt_order, 20);
694 for (k = 0; k < k_max; k++) {
697 quant_cof[k] =
decode_rice(gb, rice_param) + offset;
701 k_max =
FFMIN(opt_order, 127);
702 for (; k < k_max; k++)
706 for (; k < opt_order; k++)
715 for (k = 2; k < opt_order; k++)
716 quant_cof[k] = (quant_cof[k] << 14) + (add_base << 13);
751 start =
FFMIN(opt_order, 3);
758 unsigned int b = av_clip((av_ceil_log2(bd->
block_length) - 3) >> 1, 0, 5);
759 unsigned int i = start;
770 for (sb = 0; sb < sub_blocks; sb++, i = 0) {
771 k [sb] = s[sb] > b ? s[sb] - b : 0;
772 delta[sb] = 5 - s[sb] + k[sb];
777 current_res += sb_length;
787 for (sb = 0; sb < sub_blocks; sb++, i = 0) {
788 unsigned int cur_tail_code =
tail_code[sx[sb]][delta[sb]];
789 unsigned int cur_k = k[sb];
790 unsigned int cur_s = s[sb];
792 for (; i < sb_length; i++) {
793 int32_t res = *current_res;
795 if (res == cur_tail_code) {
796 unsigned int max_msb = (2 + (sx[sb] > 2) + (sx[sb] > 10))
802 res += (max_msb ) << cur_k;
804 res -= (max_msb - 1) << cur_k;
807 if (res > cur_tail_code)
821 *current_res++ = res;
827 for (sb = 0; sb < sub_blocks; sb++, start = 0)
828 for (; start < sb_length; start++)
845 unsigned int smp = 0;
851 int32_t *lpc_cof = bd->
lpc_cof;
860 for (ltp_smp =
FFMAX(*bd->
ltp_lag - 2, 0); ltp_smp < block_length; ltp_smp++) {
861 int center = ltp_smp - *bd->
ltp_lag;
862 int begin =
FFMAX(0, center - 2);
863 int end = center + 3;
864 int tab = 5 - (end - begin);
869 for (base = begin; base < end; base++, tab++)
872 raw_samples[ltp_smp] += y >> 7;
878 for (smp = 0; smp < opt_order; smp++) {
881 for (sb = 0; sb < smp; sb++)
882 y +=
MUL64(lpc_cof[sb], raw_samples[-(sb + 1)]);
884 *raw_samples++ -= y >> 20;
888 for (k = 0; k < opt_order; k++)
898 int32_t *left, *right;
908 for (sb = -1; sb >= -sconf->
max_order; sb--)
909 raw_samples[sb] = right[sb] - left[sb];
914 for (sb = -1; sb >= -sconf->
max_order; sb--)
919 lpc_cof = lpc_cof + opt_order;
921 for (sb = 0; sb < opt_order; sb++)
922 lpc_cof_reversed[sb] = lpc_cof[-(sb + 1)];
926 lpc_cof = lpc_cof_reversed + opt_order;
928 for (; raw_samples < raw_samples_end; raw_samples++) {
931 for (sb = -opt_order; sb < 0; sb++)
932 y +=
MUL64(lpc_cof[sb], raw_samples[sb]);
934 *raw_samples -= y >> 20;
942 sizeof(*raw_samples) * sconf->
max_order);
1010 const unsigned int *div_blocks, int32_t *buf)
1012 unsigned int count = 0;
1014 for (; b < b_max; b++)
1015 count += div_blocks[b];
1018 memset(buf, 0,
sizeof(*buf) * count);
1025 unsigned int c,
const unsigned int *div_blocks,
1026 unsigned int *js_blocks)
1066 unsigned int c,
const unsigned int *div_blocks,
1067 unsigned int *js_blocks)
1070 unsigned int offset = 0;
1123 if (bd[0].js_blocks) {
1124 if (bd[1].js_blocks)
1127 for (s = 0; s < div_blocks[
b]; s++)
1128 bd[0].raw_samples[s] = bd[1].raw_samples[s] - bd[0].raw_samples[s];
1129 }
else if (bd[1].js_blocks) {
1130 for (s = 0; s < div_blocks[
b]; s++)
1131 bd[1].raw_samples[s] = bd[1].raw_samples[s] + bd[0].raw_samples[s];
1134 offset += div_blocks[
b];
1186 if (entries == channels) {
1200 unsigned int offset,
int c)
1203 unsigned int dep = 0;
1211 while (dep < channels && !ch[dep].stop_flag) {
1213 ch[dep].master_channel);
1218 if (dep == channels) {
1235 while (!ch[dep].stop_flag) {
1237 unsigned int begin = 1;
1242 if (ch[dep].time_diff_flag) {
1245 if (ch[dep].time_diff_sign) {
1252 for (smp = begin; smp < end; smp++) {
1254 MUL64(ch[dep].weighting[0], master[smp - 1 ]) +
1255 MUL64(ch[dep].weighting[1], master[smp ]) +
1256 MUL64(ch[dep].weighting[2], master[smp + 1 ]) +
1257 MUL64(ch[dep].weighting[3], master[smp - 1 + t]) +
1258 MUL64(ch[dep].weighting[4], master[smp + t]) +
1259 MUL64(ch[dep].weighting[5], master[smp + 1 + t]);
1264 for (smp = begin; smp < end; smp++) {
1266 MUL64(ch[dep].weighting[0], master[smp - 1]) +
1267 MUL64(ch[dep].weighting[1], master[smp ]) +
1268 MUL64(ch[dep].weighting[2], master[smp + 1]);
1288 unsigned int div_blocks[32];
1290 unsigned int js_blocks[2];
1292 uint32_t bs_info = 0;
1306 for (c = 0; c < avctx->
channels; c++) {
1322 if (independent_bs) {
1343 unsigned int offset = 0;
1345 for (c = 0; c < avctx->
channels; c++)
1352 memset(reverted_channels, 0,
sizeof(*reverted_channels) * avctx->
channels);
1362 for (c = 0; c < avctx->
channels; c++) {
1380 for (c = 0; c < avctx->
channels; c++)
1382 reverted_channels, offset, c))
1385 for (c = 0; c < avctx->
channels; c++) {
1399 memset(reverted_channels, 0, avctx->
channels *
sizeof(*reverted_channels));
1400 offset += div_blocks[
b];
1405 for (c = 0; c < avctx->
channels; c++)
1425 int buffer_size = avpkt->
size;
1426 int invalid_frame, ret;
1427 unsigned int c, sample, ra_frame, bytes_read, shift;
1438 if (sconf->
samples != 0xFFFFFFFF)
1447 "Reading frame data failed. Skipping RA unit.\n");
1459 #define INTERLEAVE_OUTPUT(bps) \
1461 int##bps##_t *dest = (int##bps##_t*)ctx->frame.data[0]; \
1462 shift = bps - ctx->avctx->bits_per_raw_sample; \
1463 for (sample = 0; sample < ctx->cur_frame_length; sample++) \
1464 for (c = 0; c < avctx->channels; c++) \
1465 *dest++ = ctx->raw_samples[c][sample] << shift; \
1476 int swap = HAVE_BIGENDIAN != sconf->
msb_first;
1479 int32_t *src = (int32_t *)ctx->
frame.
data[0];
1490 if (!HAVE_BIGENDIAN)
1496 uint8_t *crc_source;
1500 int16_t *src = (int16_t*) ctx->
frame.
data[0];
1533 bytes_read = invalid_frame ? buffer_size :
1580 unsigned int channel_size;
1643 for (c = 0; c < num_buffers; c++) {
1668 for (c = 0; c < num_buffers; c++)
1674 num_buffers * num_buffers);
1686 for (c = 0; c < num_buffers; c++)
1710 for (c = 1; c < avctx->
channels; c++)