54 { {-52, 4}, {-29, 5}, {-31, 4}, { 19, 4}, {-16, 4},
55 { 12, 3}, { -7, 3}, { 9, 3}, { -5, 3}, { 6, 3},
56 { -4, 3}, { 3, 3}, { -3, 2}, { 3, 2}, { -2, 2},
57 { 3, 2}, { -1, 2}, { 2, 2}, { -1, 2}, { 2, 2} },
58 { {-58, 3}, {-42, 4}, {-46, 4}, { 37, 5}, {-36, 4},
59 { 29, 4}, {-29, 4}, { 25, 4}, {-23, 4}, { 20, 4},
60 {-17, 4}, { 16, 4}, {-12, 4}, { 12, 3}, {-10, 4},
61 { 7, 3}, { -4, 4}, { 3, 3}, { -1, 3}, { 1, 3} },
62 { {-59, 3}, {-45, 5}, {-50, 4}, { 38, 4}, {-39, 4},
63 { 32, 4}, {-30, 4}, { 25, 3}, {-23, 3}, { 20, 3},
64 {-20, 3}, { 16, 3}, {-13, 3}, { 10, 3}, { -7, 3},
65 { 3, 3}, { 0, 3}, { -1, 3}, { 2, 3}, { -1, 2} }
75 -1048544 / 32, -1048288 / 32, -1047776 / 32, -1047008 / 32,
76 -1045984 / 32, -1044704 / 32, -1043168 / 32, -1041376 / 32,
77 -1039328 / 32, -1037024 / 32, -1034464 / 32, -1031648 / 32,
78 -1028576 / 32, -1025248 / 32, -1021664 / 32, -1017824 / 32,
79 -1013728 / 32, -1009376 / 32, -1004768 / 32, -999904 / 32,
80 -994784 / 32, -989408 / 32, -983776 / 32, -977888 / 32,
81 -971744 / 32, -965344 / 32, -958688 / 32, -951776 / 32,
82 -944608 / 32, -937184 / 32, -929504 / 32, -921568 / 32,
83 -913376 / 32, -904928 / 32, -896224 / 32, -887264 / 32,
84 -878048 / 32, -868576 / 32, -858848 / 32, -848864 / 32,
85 -838624 / 32, -828128 / 32, -817376 / 32, -806368 / 32,
86 -795104 / 32, -783584 / 32, -771808 / 32, -759776 / 32,
87 -747488 / 32, -734944 / 32, -722144 / 32, -709088 / 32,
88 -695776 / 32, -682208 / 32, -668384 / 32, -654304 / 32,
89 -639968 / 32, -625376 / 32, -610528 / 32, -595424 / 32,
90 -580064 / 32, -564448 / 32, -548576 / 32, -532448 / 32,
91 -516064 / 32, -499424 / 32, -482528 / 32, -465376 / 32,
92 -447968 / 32, -430304 / 32, -412384 / 32, -394208 / 32,
93 -375776 / 32, -357088 / 32, -338144 / 32, -318944 / 32,
94 -299488 / 32, -279776 / 32, -259808 / 32, -239584 / 32,
95 -219104 / 32, -198368 / 32, -177376 / 32, -156128 / 32,
96 -134624 / 32, -112864 / 32, -90848 / 32, -68576 / 32,
97 -46048 / 32, -23264 / 32, -224 / 32, 23072 / 32,
98 46624 / 32, 70432 / 32, 94496 / 32, 118816 / 32,
99 143392 / 32, 168224 / 32, 193312 / 32, 218656 / 32,
100 244256 / 32, 270112 / 32, 296224 / 32, 322592 / 32,
101 349216 / 32, 376096 / 32, 403232 / 32, 430624 / 32,
102 458272 / 32, 486176 / 32, 514336 / 32, 542752 / 32,
103 571424 / 32, 600352 / 32, 629536 / 32, 658976 / 32,
104 688672 / 32, 718624 / 32, 748832 / 32, 779296 / 32,
105 810016 / 32, 840992 / 32, 872224 / 32, 903712 / 32,
106 935456 / 32, 967456 / 32, 999712 / 32, 1032224 / 32
125 204, 192, 179, 166, 153, 140, 128, 115,
126 102, 89, 76, 64, 51, 38, 25, 12,
127 0, -12, -25, -38, -51, -64, -76, -89,
128 -102, -115, -128, -140, -153, -166, -179, -192
135 { 74, 44, 25, 13, 7, 3},
136 { 68, 42, 24, 13, 7, 3},
137 { 58, 39, 23, 13, 7, 3},
138 {126, 70, 37, 19, 10, 5},
139 {132, 70, 37, 20, 10, 5},
140 {124, 70, 38, 20, 10, 5},
141 {120, 69, 37, 20, 11, 5},
142 {116, 67, 37, 20, 11, 5},
143 {108, 66, 36, 20, 10, 5},
144 {102, 62, 36, 20, 10, 5},
145 { 88, 58, 34, 19, 10, 5},
146 {162, 89, 49, 25, 13, 7},
147 {156, 87, 49, 26, 14, 7},
148 {150, 86, 47, 26, 14, 7},
149 {142, 84, 47, 26, 14, 7},
150 {131, 79, 46, 26, 14, 7}
301 int i, config_offset;
305 uint32_t als_id, header_size, trailer_size;
314 if (config_offset < 0)
365 if (als_id !=
MKBETAG(
'A',
'L',
'S',
'\0'))
423 if (header_size == 0xFFFFFFFF)
425 if (trailer_size == 0xFFFFFFFF)
428 ht_size = ((
int64_t)(header_size) + (
int64_t)(trailer_size)) << 3;
435 if (ht_size > INT32_MAX)
448 ctx->crc = 0xFFFFFFFF;
471 #define MISSING_ERR(cond, str, errval) \
474 avpriv_report_missing_feature(ctx->avctx, \
490 unsigned int div,
unsigned int **div_blocks,
491 unsigned int *num_blocks)
493 if (n < 31 && ((bs_info << n) & 0x40000000)) {
534 for (
i = 0, j = k - 1;
i < j;
i++, j--) {
535 unsigned tmp1 = ((
MUL64(par[k], cof[j]) + (1 << 19)) >> 20);
536 cof[j] += ((
MUL64(par[k], cof[
i]) + (1 << 19)) >> 20);
540 cof[
i] += ((
MUL64(par[k], cof[j]) + (1 << 19)) >> 20);
555 unsigned int *ptr_div_blocks = div_blocks;
561 *bs_info <<= (32 - bs_info_len);
582 for (
b = 0;
b <
ctx->num_blocks;
b++)
583 div_blocks[
b] =
ctx->sconf.frame_length >> div_blocks[
b];
585 if (
ctx->cur_frame_length !=
ctx->sconf.frame_length) {
586 unsigned int remaining =
ctx->cur_frame_length;
588 for (
b = 0;
b <
ctx->num_blocks;
b++) {
589 if (remaining <= div_blocks[
b]) {
590 div_blocks[
b] = remaining;
591 ctx->num_blocks =
b + 1;
595 remaining -= div_blocks[
b];
655 unsigned int sub_blocks, log2_sub_blocks, sb_length;
656 unsigned int start = 0;
657 unsigned int opt_order;
681 sub_blocks = 1 << log2_sub_blocks;
687 "Block length is not evenly divisible by the number of subblocks.\n");
695 for (k = 1; k < sub_blocks; k++)
698 for (k = 0; k < sub_blocks; k++) {
704 for (k = 1; k < sub_blocks; k++)
707 for (k = 1; k < sub_blocks; k++)
748 for (k = 2; k < opt_order; k++)
755 k_max =
FFMIN(opt_order, 20);
756 for (k = 0; k < k_max; k++) {
760 if (quant_cof[k] < -64 || quant_cof[k] > 63) {
762 "quant_cof %"PRId32
" is out of range.\n",
769 k_max =
FFMIN(opt_order, 127);
770 for (; k < k_max; k++)
774 for (; k < opt_order; k++)
783 for (k = 2; k < opt_order; k++)
784 quant_cof[k] = (quant_cof[k] * (1U << 14)) + (add_base << 13);
817 start =
FFMIN(opt_order, 3);
819 if (sb_length <= start) {
850 for (sb = 0; sb < sub_blocks; sb++) {
851 unsigned int sb_len = sb_length - (sb ? 0 : start);
853 k [sb] =
s[sb] >
b ?
s[sb] -
b : 0;
854 delta[sb] = 5 -
s[sb] + k[sb];
862 current_res += sb_len;
871 for (sb = 0; sb < sub_blocks; sb++, start = 0) {
873 unsigned int cur_k = k[sb];
874 unsigned int cur_s =
s[sb];
876 for (; start < sb_length; start++) {
879 if (res == cur_tail_code) {
880 unsigned int max_msb = (2 + (sx[sb] > 2) + (sx[sb] > 10))
886 res += (max_msb ) << cur_k;
888 res -= (max_msb - 1) << cur_k;
891 if (res > cur_tail_code)
905 *current_res++ = res;
911 for (sb = 0; sb < sub_blocks; sb++, start = 0)
912 for (; start < sb_length; start++)
926 unsigned int smp = 0;
935 int32_t *lpc_cof_reversed =
ctx->lpc_cof_reversed_buffer;
941 for (ltp_smp =
FFMAX(*bd->
ltp_lag - 2, 0); ltp_smp < block_length; ltp_smp++) {
942 int center = ltp_smp - *bd->
ltp_lag;
943 int begin =
FFMAX(0, center - 2);
944 int end = center + 3;
945 int tab = 5 - (end - begin);
953 raw_samples[ltp_smp] += y >> 7;
959 for (smp = 0; smp <
FFMIN(opt_order, block_length); smp++) {
962 for (sb = 0; sb < smp; sb++)
963 y += (uint64_t)
MUL64(lpc_cof[sb], raw_samples[-(sb + 1)]);
965 *raw_samples++ -= y >> 20;
969 for (k = 0; k < opt_order; k++)
979 uint32_t *
left, *right;
989 for (sb = -1; sb >= -sconf->
max_order; sb--)
990 raw_samples[sb] = right[sb] -
left[sb];
995 for (sb = -1; sb >= -sconf->
max_order; sb--)
1000 lpc_cof = lpc_cof + opt_order;
1002 for (sb = 0; sb < opt_order; sb++)
1003 lpc_cof_reversed[sb] = lpc_cof[-(sb + 1)];
1007 lpc_cof = lpc_cof_reversed + opt_order;
1009 for (; raw_samples < raw_samples_end; raw_samples++) {
1012 for (sb = -opt_order; sb < 0; sb++)
1013 y += (uint64_t)
MUL64(lpc_cof[sb], raw_samples[sb]);
1015 *raw_samples -= y >> 20;
1023 sizeof(*raw_samples) * sconf->
max_order);
1099 const unsigned int *div_blocks,
int32_t *buf)
1101 unsigned int count = 0;
1104 count += div_blocks[
b++];
1107 memset(buf, 0,
sizeof(*buf) * count);
1114 unsigned int c,
const unsigned int *div_blocks,
1115 unsigned int *js_blocks)
1135 for (
b = 0;
b <
ctx->num_blocks;
b++) {
1154 unsigned int c,
const unsigned int *div_blocks,
1155 unsigned int *js_blocks)
1190 for (
b = 0;
b <
ctx->num_blocks;
b++) {
1207 if (bd[0].js_blocks) {
1208 if (bd[1].js_blocks)
1211 for (
s = 0;
s < div_blocks[
b];
s++)
1212 bd[0].raw_samples[
s] = bd[1].raw_samples[
s] - (
unsigned)bd[0].
raw_samples[
s];
1213 }
else if (bd[1].js_blocks) {
1214 for (
s = 0;
s < div_blocks[
b];
s++)
1215 bd[1].raw_samples[
s] = bd[1].raw_samples[
s] + (
unsigned)bd[0].
raw_samples[
s];
1250 unsigned int channels =
ctx->avctx->ch_layout.nb_channels;
1261 if (
current->master_channel !=
c) {
1267 if (
current->time_diff_flag) {
1298 unsigned int dep = 0;
1299 unsigned int channels =
ctx->avctx->ch_layout.nb_channels;
1300 unsigned int channel_size =
ctx->sconf.frame_length +
ctx->sconf.max_order;
1307 while (dep <
channels && !ch[dep].stop_flag) {
1309 ch[dep].master_channel);
1330 for (dep = 0; !ch[dep].
stop_flag; dep++) {
1332 ptrdiff_t begin = 1;
1337 if (ch[dep].master_channel ==
c)
1340 if (ch[dep].time_diff_flag) {
1343 if (ch[dep].time_diff_sign) {
1358 if (
FFMIN(begin - 1, begin - 1 + t) <
ctx->raw_buffer -
master ||
1361 "sample pointer range [%p, %p] not contained in raw_buffer [%p, %p].\n",
1367 for (smp = begin; smp < end; smp++) {
1372 MUL64(ch[dep].weighting[3],
master[smp - 1 + t]) +
1380 if (begin - 1 <
ctx->raw_buffer -
master ||
1383 "sample pointer range [%p, %p] not contained in raw_buffer [%p, %p].\n",
1389 for (smp = begin; smp < end; smp++) {
1407 uint64_t mantissa_temp;
1409 int cutoff_bit_count;
1410 unsigned char last_2_bits;
1411 unsigned int mantissa;
1413 uint32_t return_val = 0;
1416 sign =
a.sign ^
b.sign;
1419 mantissa_temp = (uint64_t)
a.mant * (uint64_t)
b.mant;
1420 mask_64 = (uint64_t)0x1 << 47;
1426 while (!(mantissa_temp & mask_64) && mask_64) {
1432 cutoff_bit_count = bit_count - 24;
1433 if (cutoff_bit_count > 0) {
1434 last_2_bits = (
unsigned char)(((
unsigned int)mantissa_temp >> (cutoff_bit_count - 1)) & 0x3 );
1435 if ((last_2_bits == 0x3) || ((last_2_bits == 0x1) && ((
unsigned int)mantissa_temp & ((0x1UL << (cutoff_bit_count - 1)) - 1)))) {
1437 mantissa_temp += (uint64_t)0x1 << cutoff_bit_count;
1441 if (cutoff_bit_count >= 0) {
1442 mantissa = (
unsigned int)(mantissa_temp >> cutoff_bit_count);
1444 mantissa = (
unsigned int)(mantissa_temp <<-cutoff_bit_count);
1448 if (mantissa & 0x01000000ul) {
1454 return_val = 0x80000000U;
1457 return_val |= ((unsigned)
av_clip(
a.exp +
b.exp + bit_count - 47, -126, 127) << 23) & 0x7F800000;
1458 return_val |= mantissa;
1469 int *shift_value =
ctx->shift_value;
1470 int *last_shift_value =
ctx->last_shift_value;
1471 int *last_acf_mantissa =
ctx->last_acf_mantissa;
1472 int **raw_mantissa =
ctx->raw_mantissa;
1473 int *nbits =
ctx->nbits;
1474 unsigned char *larray =
ctx->larray;
1475 int frame_length =
ctx->cur_frame_length;
1477 unsigned int partA_flag;
1478 unsigned int highest_byte;
1479 unsigned int shift_amp;
1510 last_acf_mantissa[
c] = tmp_32;
1512 tmp_32 = last_acf_mantissa[
c];
1525 last_shift_value[
c] = shift_value[
c];
1527 shift_value[
c] = last_shift_value[
c];
1532 for (
i = 0;
i < frame_length; ++
i) {
1533 if (
ctx->raw_samples[
c][
i] == 0) {
1539 for (
i = 0;
i < frame_length; ++
i) {
1540 if (
ctx->raw_samples[
c][
i] == 0) {
1546 if(tmp_32 != nchars) {
1552 for (
i = 0;
i < frame_length; ++
i) {
1553 if (
ctx->raw_samples[
c][
i] == 0) {
1563 for (
i = 0;
i < frame_length; ++
i) {
1564 if (
ctx->raw_samples[
c][
i] != 0) {
1570 nbits[
i] = 23 - nbit;
1574 nbits[
i] =
FFMIN(nbits[
i], highest_byte*8);
1579 for (
i = 0;
i < frame_length; ++
i) {
1580 if (
ctx->raw_samples[
c][
i] != 0) {
1586 for (
i = 0;
i < frame_length; ++
i) {
1587 if (
ctx->raw_samples[
c][
i]) {
1588 nchars += (int) nbits[
i] / 8;
1596 if(tmp_32 != nchars) {
1602 for (
i = 0;
i < frame_length; ++
i) {
1603 if (
ctx->raw_samples[
c][
i]) {
1605 nbits_aligned = 8 * ((
unsigned int)(nbits[
i] / 8) + 1);
1607 nbits_aligned = nbits[
i];
1610 for (k = 0; k < nbits_aligned/8; ++k) {
1611 acc = (acc << 8) + larray[j++];
1613 acc >>= (nbits_aligned - nbits[
i]);
1614 raw_mantissa[
c][
i] = acc;
1620 for (
i = 0;
i < frame_length; ++
i) {
1624 if (
ctx->raw_samples[
c][
i] != 0) {
1631 mantissa = (pcm_sf.
mant | 0x800000) + raw_mantissa[
c][
i];
1633 while(mantissa >= 0x1000000) {
1638 if (mantissa) e += (shift_value[
c] - 127);
1639 mantissa &= 0x007fffffUL;
1641 tmp_32 = (sign << 31) | ((e +
EXP_BIAS) << 23) | (mantissa);
1642 ctx->raw_samples[
c][
i] = tmp_32;
1644 ctx->raw_samples[
c][
i] = raw_mantissa[
c][
i];
1660 unsigned int div_blocks[32];
1662 unsigned int js_blocks[2];
1664 uint32_t bs_info = 0;
1696 if (independent_bs) {
1698 div_blocks, js_blocks);
1714 ctx->highest_decoded_channel =
c;
1719 int *reverted_channels =
ctx->reverted_channels;
1723 if (
ctx->chan_data[
c] <
ctx->chan_data_buffer) {
1728 memset(reverted_channels, 0,
sizeof(*reverted_channels) *
channels);
1735 for (
b = 0;
b <
ctx->num_blocks;
b++) {
1739 "Invalid block length %u in channel data!\n",
1765 reverted_channels,
offset,
c);
1784 ctx->highest_decoded_channel =
FFMAX(
ctx->highest_decoded_channel,
c);
1787 memset(reverted_channels, 0,
channels *
sizeof(*reverted_channels));
1817 int *got_frame_ptr,
AVPacket *avpkt)
1822 int buffer_size = avpkt->
size;
1823 int invalid_frame, ret;
1837 if (sconf->
samples != 0xFFFFFFFF)
1843 ctx->highest_decoded_channel = -1;
1847 "Reading frame data failed. Skipping RA unit.\n");
1849 if (
ctx->highest_decoded_channel == -1) {
1851 "No channel data decoded.\n");
1858 frame->nb_samples =
ctx->cur_frame_length;
1863 #define INTERLEAVE_OUTPUT(bps) \
1865 int##bps##_t *dest = (int##bps##_t*)frame->data[0]; \
1866 int32_t *raw_samples = ctx->raw_samples[0]; \
1867 int raw_step = channels > 1 ? ctx->raw_samples[1] - raw_samples : 1; \
1868 shift = bps - ctx->avctx->bits_per_raw_sample; \
1869 if (!ctx->cs_switch) { \
1870 for (sample = 0; sample < ctx->cur_frame_length; sample++) \
1871 for (c = 0; c < channels; c++) \
1872 *dest++ = raw_samples[c*raw_step + sample] * (1U << shift); \
1874 for (sample = 0; sample < ctx->cur_frame_length; sample++) \
1875 for (c = 0; c < channels; c++) \
1876 *dest++ = raw_samples[sconf->chan_pos[c]*raw_step + sample] * (1U << shift);\
1880 if (
ctx->avctx->bits_per_raw_sample <= 16) {
1888 int swap = HAVE_BIGENDIAN != sconf->
msb_first;
1890 if (
ctx->avctx->bits_per_raw_sample == 24) {
1902 if (!HAVE_BIGENDIAN)
1908 uint8_t *crc_source;
1911 if (
ctx->avctx->bits_per_raw_sample <= 16) {
1912 int16_t *
src = (int16_t*)
frame->data[0];
1913 int16_t *dest = (int16_t*)
ctx->crc_buffer;
1919 ctx->bdsp.bswap_buf((uint32_t *)
ctx->crc_buffer,
1920 (uint32_t *)
frame->data[0],
1923 crc_source =
ctx->crc_buffer;
1925 crc_source =
frame->data[0];
1936 ctx->crc_org !=
ctx->crc) {
1945 bytes_read = invalid_frame ? buffer_size :
1991 if (
ctx->raw_mantissa) {
2009 unsigned int channel_size;
2010 int num_buffers, ret;
2061 if (num_buffers * (uint64_t)num_buffers > INT_MAX)
2067 sizeof(*
ctx->quant_cof_buffer));
2069 sizeof(*
ctx->lpc_cof_buffer));
2071 sizeof(*
ctx->lpc_cof_buffer));
2073 if (!
ctx->quant_cof || !
ctx->lpc_cof ||
2074 !
ctx->quant_cof_buffer || !
ctx->lpc_cof_buffer ||
2075 !
ctx->lpc_cof_reversed_buffer) {
2081 for (
c = 0;
c < num_buffers;
c++) {
2096 if (!
ctx->const_block || !
ctx->shift_lsbs ||
2097 !
ctx->opt_order || !
ctx->store_prev_samples ||
2098 !
ctx->use_ltp || !
ctx->ltp_lag ||
2099 !
ctx->ltp_gain || !
ctx->ltp_gain_buffer) {
2104 for (
c = 0;
c < num_buffers;
c++)
2105 ctx->ltp_gain[
c] =
ctx->ltp_gain_buffer +
c * 5;
2109 ctx->chan_data_buffer =
av_calloc(num_buffers * num_buffers,
2110 sizeof(*
ctx->chan_data_buffer));
2113 sizeof(*
ctx->reverted_channels));
2115 if (!
ctx->chan_data_buffer || !
ctx->chan_data || !
ctx->reverted_channels) {
2120 for (
c = 0;
c < num_buffers;
c++)
2121 ctx->chan_data[
c] =
ctx->chan_data_buffer +
c * num_buffers;
2125 ctx->reverted_channels =
NULL;
2139 if (!
ctx->larray || !
ctx->nbits || !
ctx->mlz || !
ctx->acf || !
ctx->shift_value
2140 || !
ctx->last_shift_value || !
ctx->last_acf_mantissa || !
ctx->raw_mantissa) {
2152 if (!
ctx->raw_mantissa[
c]) {
2165 if (!
ctx->prev_raw_samples || !
ctx->raw_buffer|| !
ctx->raw_samples) {
2173 ctx->raw_samples[
c] =
ctx->raw_samples[
c - 1] + channel_size;
2181 sizeof(*
ctx->crc_buffer));
2182 if (!
ctx->crc_buffer) {
2209 .class_name =
"als",
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static double val(void *priv, double ch)
const FFCodec ff_als_decoder
static int read_channel_data(ALSDecContext *ctx, ALSChannelData *cd, int c)
Read the channel data.
static int decode_blocks(ALSDecContext *ctx, unsigned int ra_frame, unsigned int c, const unsigned int *div_blocks, unsigned int *js_blocks)
Decode blocks dependently.
static av_cold int read_specific_config(ALSDecContext *ctx)
Read an ALSSpecificConfig from a buffer into the output struct.
static void zero_remaining(unsigned int b, unsigned int b_max, const unsigned int *div_blocks, int32_t *buf)
Compute the number of samples left to decode for the current frame and sets these samples to zero.
static SoftFloat_IEEE754 multiply(SoftFloat_IEEE754 a, SoftFloat_IEEE754 b)
multiply two softfloats and handle the rounding off
static int read_const_block_data(ALSDecContext *ctx, ALSBlockData *bd)
Read the block data for a constant block.
static const int8_t parcor_rice_table[3][20][2]
Rice parameters and corresponding index offsets for decoding the indices of scaled PARCOR values.
static const AVClass als_class
static int decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
Decode an ALS frame.
static int read_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
Read the block data for a non-constant block.
static int als_weighting(GetBitContext *gb, int k, int off)
static const uint8_t tail_code[16][6]
Tail codes used in arithmetic coding using block Gilbert-Moore codes.
static void parcor_to_lpc(unsigned int k, const int32_t *par, int32_t *cof)
Convert PARCOR coefficient k to direct filter coefficient.
static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame)
Read the frame data.
static av_cold int decode_init(AVCodecContext *avctx)
Initialize the ALS decoder.
static int decode_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
Decode the block data for a non-constant block.
static av_cold void dprint_specific_config(ALSDecContext *ctx)
static av_cold int decode_end(AVCodecContext *avctx)
Uninitialize the ALS decoder.
static const int16_t mcc_weightings[]
Inter-channel weighting factors for multi-channel correlation.
static void decode_const_block_data(ALSDecContext *ctx, ALSBlockData *bd)
Decode the block data for a constant block.
static int decode_blocks_ind(ALSDecContext *ctx, unsigned int ra_frame, unsigned int c, const unsigned int *div_blocks, unsigned int *js_blocks)
Decode blocks independently.
static int32_t decode_rice(GetBitContext *gb, unsigned int k)
Read and decode a Rice codeword.
static const uint8_t ltp_gain_values[4][4]
Gain values of p(0) for long-term prediction.
static int read_block(ALSDecContext *ctx, ALSBlockData *bd)
Read the block data.
static int revert_channel_correlation(ALSDecContext *ctx, ALSBlockData *bd, ALSChannelData **cd, int *reverted, unsigned int offset, int c)
Recursively reverts the inter-channel correlation for a block.
static const int16_t parcor_scaled_values[]
Scaled PARCOR values used for the first two PARCOR coefficients.
static int read_decode_block(ALSDecContext *ctx, ALSBlockData *bd)
Read and decode block data successively.
#define MISSING_ERR(cond, str, errval)
static int check_specific_config(ALSDecContext *ctx)
Check the ALSSpecificConfig for unsupported features.
static void get_block_sizes(ALSDecContext *ctx, unsigned int *div_blocks, uint32_t *bs_info)
Read block switching field if necessary and set actual block sizes.
#define INTERLEAVE_OUTPUT(bps)
static void parse_bs_info(const uint32_t bs_info, unsigned int n, unsigned int div, unsigned int **div_blocks, unsigned int *num_blocks)
Parse the bs_info field to extract the block partitioning used in block switching mode,...
static int read_diff_float_data(ALSDecContext *ctx, unsigned int ra_frame)
Read and decode the floating point sample data.
static int decode_block(ALSDecContext *ctx, ALSBlockData *bd)
Decode the block data.
static av_cold void close(AVCodecParserContext *s)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Libavcodec external API header.
av_cold int ff_bgmc_init(void *logctx, uint8_t **cf_lut, int **cf_lut_status)
Initialize the lookup table arrays.
int ff_bgmc_decode_init(GetBitContext *gb, unsigned int *h, unsigned int *l, unsigned int *v)
Initialize decoding and reads the first value.
void ff_bgmc_decode(GetBitContext *gb, unsigned int num, int32_t *dst, int delta, unsigned int sx, unsigned int *h, unsigned int *l, unsigned int *v, uint8_t *cf_lut, int *cf_lut_status)
Read and decode a block Gilbert-Moore coded symbol.
av_cold void ff_bgmc_end(uint8_t **cf_lut, int **cf_lut_status)
Release the lookup table arrays.
void ff_bgmc_decode_end(GetBitContext *gb)
Finish decoding.
Block Gilbert-Moore decoder header.
static int BS_FUNC left(const BSCTX *bc)
Return the number of the bits left in a buffer.
#define i(width, name, range_min, range_max)
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
#define FFABSU(a)
Unsigned Absolute value.
Public header for CRC hash function implementation.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
#define AV_EF_CRCCHECK
Verify checksums embedded in the bitstream (could be of either encoded or decoded data,...
#define AV_EF_EXPLODE
abort decoding on minor error detection
#define AV_EF_CAREFUL
consider things that violate the spec, are fast to calculate and have not been seen in the wild as er...
void(* flush)(AVBSFContext *ctx)
int(* init)(AVBSFContext *ctx)
static struct @111144215057303131116103221376075045141373005341 current
bitstream reader API header.
static int get_sbits_long(GetBitContext *s, int n)
Read 0-32 bits as a signed integer.
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static int get_bits_left(GetBitContext *gb)
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits(GetBitContext *s, int n)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static const uint8_t * align_get_bits(GetBitContext *s)
static int get_bits_count(const GetBitContext *s)
static void skip_bits1(GetBitContext *s)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static av_always_inline int get_bitsz(GetBitContext *s, int n)
Read 0-25 bits.
#define AV_OPT_FLAG_AUDIO_PARAM
#define AV_OPT_FLAG_DECODING_PARAM
A generic parameter which can be set by the user for demuxing or decoding.
@ AV_OPT_TYPE_INT
Underlying C type is int.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
@ AV_CHANNEL_ORDER_UNSPEC
Only the channel count is specified, without any further information about the channel order.
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)
Calculate the CRC of a block.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
@ AV_SAMPLE_FMT_S32
signed 32 bits
@ AV_SAMPLE_FMT_S16
signed 16 bits
#define LIBAVUTIL_VERSION_INT
static void scale(int *out, const int *in, const int w, const int h, const int shift)
static av_cold int decode_init(AVCodecContext *avctx)
static av_cold int decode_end(AVCodecContext *avctx)
static int decode_frame(AVCodecContext *avctx, AVFrame *picture, int *got_frame, AVPacket *avpkt)
static int shift(int a, int b)
av_cold void ff_bswapdsp_init(BswapDSPContext *c)
common internal api header.
#define FF_SANE_NB_CHANNELS
#define MKBETAG(a, b, c, d)
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
av_cold void ff_mlz_flush_dict(MLZ *mlz)
Flush the dictionary.
int ff_mlz_decompression(MLZ *mlz, GetBitContext *gb, int size, unsigned char *buff)
Run mlz decompression on the next size bits and the output will be stored in buff.
av_cold int ff_mlz_init_dict(void *context, MLZ *mlz)
Initialize the dictionary.
int avpriv_mpeg4audio_get_config2(MPEG4AudioConfig *c, const uint8_t *buf, int size, int sync_extension, void *logctx)
Parse MPEG-4 systems extradata from a raw buffer to retrieve audio configuration.
#define FF_ARRAY_ELEMS(a)
static const SoftFloat FLOAT_1
1.0
static const SoftFloat FLOAT_0
0.0
static SoftFloat_IEEE754 av_div_sf_ieee754(SoftFloat_IEEE754 a, SoftFloat_IEEE754 b)
Divide a by b.
static int av_cmp_sf_ieee754(SoftFloat_IEEE754 a, SoftFloat_IEEE754 b)
Compare a with b strictly.
static SoftFloat_IEEE754 av_bits2sf_ieee754(uint32_t n)
Make a softfloat out of the bitstream.
static SoftFloat_IEEE754 av_int2sf_ieee754(int64_t n, int e)
Convert integer to softfloat.
unsigned int * shift_lsbs
shift of values for this block
int32_t * prev_raw_samples
contains unshifted raw samples from the previous block
int32_t * raw_samples
decoded raw samples / residuals for this block
int * const_block
if true, this is a constant value block
int * use_ltp
if true, long-term prediction is used
unsigned int ra_block
if true, this is a random access block
int32_t * quant_cof
quantized parcor coefficients
unsigned int block_length
number of samples within the block
int * ltp_lag
lag value for long-term prediction
int js_blocks
true if this block contains a difference signal
unsigned int * opt_order
prediction order of this block
int * ltp_gain
gain values for ltp 5-tap filter
int32_t * lpc_cof
coefficients of the direct form prediction
int * store_prev_samples
if true, carryover samples have to be stored
int32_t * raw_other
decoded raw samples of the other channel of a channel pair
int * shift_value
value by which the binary point is to be shifted for all channels
int32_t * lpc_cof_buffer
contains all coefficients of the direct form prediction filter
int * ltp_gain_buffer
contains all gain values for ltp 5-tap filter
int32_t * quant_cof_buffer
contains all quantized parcor coefficients
uint32_t crc_org
CRC value of the original input data.
int32_t * raw_buffer
contains all decoded raw samples including carryover samples
unsigned int s_max
maximum Rice parameter allowed in entropy coding
unsigned int frame_id
the frame ID / number of the current frame
int32_t ** raw_samples
decoded raw samples for each channel
uint8_t * crc_buffer
buffer of byte order corrected samples used for CRC check
SoftFloat_IEEE754 * acf
contains common multiplier for all channels
int ** raw_mantissa
decoded mantissa bits of the difference signal
int highest_decoded_channel
unsigned int num_blocks
number of blocks used in the current frame
ALSChannelData ** chan_data
channel data for multi-channel correlation
int user_max_order
user specified maximum prediction order
unsigned int js_switch
if true, joint-stereo decoding is enforced
int32_t ** lpc_cof
coefficients of the direct form prediction filter for a channel
int * nbits
contains the number of bits to read for masked lz decompression for all samples
unsigned int * opt_order
contains opt_order flags for all channels
int * bgmc_lut_status
pointer at lookup table status flags used for BGMC
MLZ * mlz
masked lz decompression structure
int * last_acf_mantissa
contains the last acf mantissa data of common multiplier for all channels
int32_t ** quant_cof
quantized parcor coefficients for a channel
ALSChannelData * chan_data_buffer
contains channel data for all channels
unsigned int cur_frame_length
length of the current frame to decode
int32_t * prev_raw_samples
contains unshifted raw samples from the previous block
int ltp_lag_length
number of bits used for ltp lag value
int * use_ltp
contains use_ltp flags for all channels
int ** ltp_gain
gain values for ltp 5-tap filter for a channel
uint8_t * bgmc_lut
pointer at lookup tables used for BGMC
unsigned int cs_switch
if true, channel rearrangement is done
int32_t * lpc_cof_reversed_buffer
temporary buffer to set up a reversed version of lpc_cof_buffer
int * last_shift_value
contains last shift value for all channels
int * reverted_channels
stores a flag for each reverted channel
unsigned int * shift_lsbs
contains shift_lsbs flags for all channels
unsigned char * larray
buffer to store the output of masked lz decompression
uint32_t crc
CRC value calculated from decoded data.
int * ltp_lag
contains ltp lag values for all channels
int * store_prev_samples
contains store_prev_samples flags for all channels
int * const_block
contains const_block flags for all channels
int floating
1 = IEEE 32-bit floating-point, 0 = integer
int crc_enabled
enable Cyclic Redundancy Checksum
int chan_config
indicates that a chan_config_info field is present
int resolution
000 = 8-bit; 001 = 16-bit; 010 = 24-bit; 011 = 32-bit
int * chan_pos
original channel positions
int msb_first
1 = original CRC calculated on big-endian system, 0 = little-endian
int chan_sort
channel rearrangement: 1 = on, 0 = off
int block_switching
number of block switching levels
int rlslms
use "Recursive Least Square-Least Mean Square" predictor: 1 = on, 0 = off
int joint_stereo
joint stereo: 1 = on, 0 = off
int coef_table
table index of Rice code parameters
int frame_length
frame length for each frame (last frame may differ)
int adapt_order
adaptive order: 1 = on, 0 = off
int ra_distance
distance between RA frames (in frames, 0...255)
int max_order
maximum prediction order (0..1023)
enum RA_Flag ra_flag
indicates where the size of ra units is stored
int long_term_prediction
long term prediction (LTP): 1 = on, 0 = off
int chan_config_info
mapping of channels to loudspeaker locations. Unused until setting channel configuration is implement...
int mc_coding
extended inter-channel coding (multi channel coding): 1 = on, 0 = off
uint32_t samples
number of samples, 0xFFFFFFFF if unknown
int sb_part
sub-block partition
int bgmc
"Block Gilbert-Moore Code": 1 = on, 0 = off (Rice coding only)
enum AVChannelOrder order
Channel order used in this layout.
int nb_channels
Number of channels in this layout.
Describe the class of an AVClass context structure.
main external API structure.
AVChannelLayout ch_layout
Audio channel layout.
enum AVSampleFormat sample_fmt
audio sample format
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
int sample_rate
samples per second
uint8_t * extradata
Out-of-band global headers that may be used by some codecs.
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.
#define av_malloc_array(a, b)
#define avpriv_request_sample(...)
static void error(const char *err)
static AVFormatContext * ctx
static const struct twinvq_data tab
static int get_unary(GetBitContext *gb, int stop, int len)
Get unary code of limited length.