Go to the documentation of this file.
51 { {-52, 4}, {-29, 5}, {-31, 4}, { 19, 4}, {-16, 4},
52 { 12, 3}, { -7, 3}, { 9, 3}, { -5, 3}, { 6, 3},
53 { -4, 3}, { 3, 3}, { -3, 2}, { 3, 2}, { -2, 2},
54 { 3, 2}, { -1, 2}, { 2, 2}, { -1, 2}, { 2, 2} },
55 { {-58, 3}, {-42, 4}, {-46, 4}, { 37, 5}, {-36, 4},
56 { 29, 4}, {-29, 4}, { 25, 4}, {-23, 4}, { 20, 4},
57 {-17, 4}, { 16, 4}, {-12, 4}, { 12, 3}, {-10, 4},
58 { 7, 3}, { -4, 4}, { 3, 3}, { -1, 3}, { 1, 3} },
59 { {-59, 3}, {-45, 5}, {-50, 4}, { 38, 4}, {-39, 4},
60 { 32, 4}, {-30, 4}, { 25, 3}, {-23, 3}, { 20, 3},
61 {-20, 3}, { 16, 3}, {-13, 3}, { 10, 3}, { -7, 3},
62 { 3, 3}, { 0, 3}, { -1, 3}, { 2, 3}, { -1, 2} }
72 -1048544 / 32, -1048288 / 32, -1047776 / 32, -1047008 / 32,
73 -1045984 / 32, -1044704 / 32, -1043168 / 32, -1041376 / 32,
74 -1039328 / 32, -1037024 / 32, -1034464 / 32, -1031648 / 32,
75 -1028576 / 32, -1025248 / 32, -1021664 / 32, -1017824 / 32,
76 -1013728 / 32, -1009376 / 32, -1004768 / 32, -999904 / 32,
77 -994784 / 32, -989408 / 32, -983776 / 32, -977888 / 32,
78 -971744 / 32, -965344 / 32, -958688 / 32, -951776 / 32,
79 -944608 / 32, -937184 / 32, -929504 / 32, -921568 / 32,
80 -913376 / 32, -904928 / 32, -896224 / 32, -887264 / 32,
81 -878048 / 32, -868576 / 32, -858848 / 32, -848864 / 32,
82 -838624 / 32, -828128 / 32, -817376 / 32, -806368 / 32,
83 -795104 / 32, -783584 / 32, -771808 / 32, -759776 / 32,
84 -747488 / 32, -734944 / 32, -722144 / 32, -709088 / 32,
85 -695776 / 32, -682208 / 32, -668384 / 32, -654304 / 32,
86 -639968 / 32, -625376 / 32, -610528 / 32, -595424 / 32,
87 -580064 / 32, -564448 / 32, -548576 / 32, -532448 / 32,
88 -516064 / 32, -499424 / 32, -482528 / 32, -465376 / 32,
89 -447968 / 32, -430304 / 32, -412384 / 32, -394208 / 32,
90 -375776 / 32, -357088 / 32, -338144 / 32, -318944 / 32,
91 -299488 / 32, -279776 / 32, -259808 / 32, -239584 / 32,
92 -219104 / 32, -198368 / 32, -177376 / 32, -156128 / 32,
93 -134624 / 32, -112864 / 32, -90848 / 32, -68576 / 32,
94 -46048 / 32, -23264 / 32, -224 / 32, 23072 / 32,
95 46624 / 32, 70432 / 32, 94496 / 32, 118816 / 32,
96 143392 / 32, 168224 / 32, 193312 / 32, 218656 / 32,
97 244256 / 32, 270112 / 32, 296224 / 32, 322592 / 32,
98 349216 / 32, 376096 / 32, 403232 / 32, 430624 / 32,
99 458272 / 32, 486176 / 32, 514336 / 32, 542752 / 32,
100 571424 / 32, 600352 / 32, 629536 / 32, 658976 / 32,
101 688672 / 32, 718624 / 32, 748832 / 32, 779296 / 32,
102 810016 / 32, 840992 / 32, 872224 / 32, 903712 / 32,
103 935456 / 32, 967456 / 32, 999712 / 32, 1032224 / 32
122 204, 192, 179, 166, 153, 140, 128, 115,
123 102, 89, 76, 64, 51, 38, 25, 12,
124 0, -12, -25, -38, -51, -64, -76, -89,
125 -102, -115, -128, -140, -153, -166, -179, -192
132 { 74, 44, 25, 13, 7, 3},
133 { 68, 42, 24, 13, 7, 3},
134 { 58, 39, 23, 13, 7, 3},
135 {126, 70, 37, 19, 10, 5},
136 {132, 70, 37, 20, 10, 5},
137 {124, 70, 38, 20, 10, 5},
138 {120, 69, 37, 20, 11, 5},
139 {116, 67, 37, 20, 11, 5},
140 {108, 66, 36, 20, 10, 5},
141 {102, 62, 36, 20, 10, 5},
142 { 88, 58, 34, 19, 10, 5},
143 {162, 89, 49, 25, 13, 7},
144 {156, 87, 49, 26, 14, 7},
145 {150, 86, 47, 26, 14, 7},
146 {142, 84, 47, 26, 14, 7},
147 {131, 79, 46, 26, 14, 7}
295 int i, config_offset;
299 uint32_t als_id, header_size, trailer_size;
308 if (config_offset < 0)
348 if (als_id !=
MKBETAG(
'A',
'L',
'S',
'\0'))
366 int chan_pos_bits = av_ceil_log2(avctx->
channels);
367 int bits_needed = avctx->
channels * chan_pos_bits + 7;
403 if (header_size == 0xFFFFFFFF)
405 if (trailer_size == 0xFFFFFFFF)
408 ht_size = ((int64_t)(header_size) + (int64_t)(trailer_size)) << 3;
415 if (ht_size > INT32_MAX)
428 ctx->crc = 0xFFFFFFFF;
451 #define MISSING_ERR(cond, str, errval) \
454 avpriv_report_missing_feature(ctx->avctx, \
470 unsigned int div,
unsigned int **div_blocks,
471 unsigned int *num_blocks)
473 if (
n < 31 && ((bs_info <<
n) & 0x40000000)) {
514 for (
i = 0, j = k - 1;
i < j;
i++, j--) {
515 unsigned tmp1 = ((
MUL64(par[k], cof[j]) + (1 << 19)) >> 20);
516 cof[j] += ((
MUL64(par[k], cof[
i]) + (1 << 19)) >> 20);
520 cof[
i] += ((
MUL64(par[k], cof[j]) + (1 << 19)) >> 20);
535 unsigned int *ptr_div_blocks = div_blocks;
541 *bs_info <<= (32 - bs_info_len);
562 for (
b = 0;
b <
ctx->num_blocks;
b++)
563 div_blocks[
b] =
ctx->sconf.frame_length >> div_blocks[
b];
565 if (
ctx->cur_frame_length !=
ctx->sconf.frame_length) {
566 unsigned int remaining =
ctx->cur_frame_length;
568 for (
b = 0;
b <
ctx->num_blocks;
b++) {
569 if (remaining <= div_blocks[
b]) {
570 div_blocks[
b] = remaining;
571 ctx->num_blocks =
b + 1;
575 remaining -= div_blocks[
b];
635 unsigned int sub_blocks, log2_sub_blocks, sb_length;
636 unsigned int start = 0;
637 unsigned int opt_order;
661 sub_blocks = 1 << log2_sub_blocks;
667 "Block length is not evenly divisible by the number of subblocks.\n");
675 for (k = 1; k < sub_blocks; k++)
678 for (k = 0; k < sub_blocks; k++) {
684 for (k = 1; k < sub_blocks; k++)
687 for (k = 1; k < sub_blocks; k++)
701 int opt_order_length = av_ceil_log2(av_clip((bd->
block_length >> 3) - 1,
728 for (k = 2; k < opt_order; k++)
735 k_max =
FFMIN(opt_order, 20);
736 for (k = 0; k < k_max; k++) {
740 if (quant_cof[k] < -64 || quant_cof[k] > 63) {
742 "quant_cof %"PRId32
" is out of range.\n",
749 k_max =
FFMIN(opt_order, 127);
750 for (; k < k_max; k++)
754 for (; k < opt_order; k++)
763 for (k = 2; k < opt_order; k++)
764 quant_cof[k] = (quant_cof[k] * (1
U << 14)) + (add_base << 13);
799 if (sb_length <=
start) {
817 unsigned int b = av_clip((av_ceil_log2(bd->
block_length) - 3) >> 1, 0, 5);
830 for (sb = 0; sb < sub_blocks; sb++) {
831 unsigned int sb_len = sb_length - (sb ? 0 :
start);
833 k [sb] =
s[sb] >
b ?
s[sb] -
b : 0;
834 delta[sb] = 5 -
s[sb] + k[sb];
840 delta[sb], sx[sb], &high, &low, &
value,
ctx->bgmc_lut,
ctx->bgmc_lut_status);
842 current_res += sb_len;
851 for (sb = 0; sb < sub_blocks; sb++,
start = 0) {
853 unsigned int cur_k = k[sb];
854 unsigned int cur_s =
s[sb];
859 if (res == cur_tail_code) {
860 unsigned int max_msb = (2 + (sx[sb] > 2) + (sx[sb] > 10))
866 res += (max_msb ) << cur_k;
868 res -= (max_msb - 1) << cur_k;
871 if (res > cur_tail_code)
885 *current_res++ = res;
891 for (sb = 0; sb < sub_blocks; sb++,
start = 0)
906 unsigned int smp = 0;
915 int32_t *lpc_cof_reversed =
ctx->lpc_cof_reversed_buffer;
921 for (ltp_smp =
FFMAX(*bd->
ltp_lag - 2, 0); ltp_smp < block_length; ltp_smp++) {
922 int center = ltp_smp - *bd->
ltp_lag;
923 int begin =
FFMAX(0, center - 2);
924 int end = center + 3;
925 int tab = 5 - (
end - begin);
933 raw_samples[ltp_smp] += y >> 7;
939 for (smp = 0; smp <
FFMIN(opt_order, block_length); smp++) {
942 for (sb = 0; sb < smp; sb++)
943 y += (uint64_t)
MUL64(lpc_cof[sb], raw_samples[-(sb + 1)]);
945 *raw_samples++ -= y >> 20;
949 for (k = 0; k < opt_order; k++)
959 uint32_t *
left, *right;
969 for (sb = -1; sb >= -sconf->
max_order; sb--)
970 raw_samples[sb] = right[sb] -
left[sb];
975 for (sb = -1; sb >= -sconf->
max_order; sb--)
980 lpc_cof = lpc_cof + opt_order;
982 for (sb = 0; sb < opt_order; sb++)
983 lpc_cof_reversed[sb] = lpc_cof[-(sb + 1)];
987 lpc_cof = lpc_cof_reversed + opt_order;
989 for (; raw_samples < raw_samples_end; raw_samples++) {
992 for (sb = -opt_order; sb < 0; sb++)
993 y += (uint64_t)
MUL64(lpc_cof[sb], raw_samples[sb]);
995 *raw_samples -= y >> 20;
1003 sizeof(*raw_samples) * sconf->
max_order);
1079 const unsigned int *div_blocks,
int32_t *
buf)
1081 unsigned int count = 0;
1084 count += div_blocks[
b++];
1094 unsigned int c,
const unsigned int *div_blocks,
1095 unsigned int *js_blocks)
1115 for (
b = 0;
b <
ctx->num_blocks;
b++) {
1134 unsigned int c,
const unsigned int *div_blocks,
1135 unsigned int *js_blocks)
1170 for (
b = 0;
b <
ctx->num_blocks;
b++) {
1187 if (bd[0].js_blocks) {
1188 if (bd[1].js_blocks)
1191 for (
s = 0;
s < div_blocks[
b];
s++)
1192 bd[0].raw_samples[
s] = bd[1].raw_samples[
s] - (
unsigned)bd[0].
raw_samples[
s];
1193 }
else if (bd[1].js_blocks) {
1194 for (
s = 0;
s < div_blocks[
b];
s++)
1195 bd[1].raw_samples[
s] = bd[1].raw_samples[
s] + (
unsigned)bd[0].
raw_samples[
s];
1278 unsigned int dep = 0;
1280 unsigned int channel_size =
ctx->sconf.frame_length +
ctx->sconf.max_order;
1287 while (dep <
channels && !
ch[dep].stop_flag) {
1289 ch[dep].master_channel);
1310 for (dep = 0; !
ch[dep].stop_flag; dep++) {
1312 ptrdiff_t begin = 1;
1317 if (
ch[dep].master_channel ==
c)
1320 if (
ch[dep].time_diff_flag) {
1321 int t =
ch[dep].time_diff_index;
1323 if (
ch[dep].time_diff_sign) {
1338 if (
FFMIN(begin - 1, begin - 1 + t) <
ctx->raw_buffer -
master ||
1341 "sample pointer range [%p, %p] not contained in raw_buffer [%p, %p].\n",
1347 for (smp = begin; smp <
end; smp++) {
1360 if (begin - 1 <
ctx->raw_buffer -
master ||
1363 "sample pointer range [%p, %p] not contained in raw_buffer [%p, %p].\n",
1369 for (smp = begin; smp <
end; smp++) {
1387 uint64_t mantissa_temp;
1389 int cutoff_bit_count;
1390 unsigned char last_2_bits;
1391 unsigned int mantissa;
1393 uint32_t return_val = 0;
1396 sign =
a.sign ^
b.sign;
1399 mantissa_temp = (uint64_t)
a.mant * (uint64_t)
b.mant;
1400 mask_64 = (uint64_t)0x1 << 47;
1406 while (!(mantissa_temp & mask_64) && mask_64) {
1412 cutoff_bit_count = bit_count - 24;
1413 if (cutoff_bit_count > 0) {
1414 last_2_bits = (
unsigned char)(((
unsigned int)mantissa_temp >> (cutoff_bit_count - 1)) & 0x3 );
1415 if ((last_2_bits == 0x3) || ((last_2_bits == 0x1) && ((
unsigned int)mantissa_temp & ((0x1UL << (cutoff_bit_count - 1)) - 1)))) {
1417 mantissa_temp += (uint64_t)0x1 << cutoff_bit_count;
1421 if (cutoff_bit_count >= 0) {
1422 mantissa = (
unsigned int)(mantissa_temp >> cutoff_bit_count);
1424 mantissa = (
unsigned int)(mantissa_temp <<-cutoff_bit_count);
1428 if (mantissa & 0x01000000ul) {
1434 return_val = 0x80000000
U;
1437 return_val |= ((unsigned)av_clip(
a.exp +
b.exp + bit_count - 47, -126, 127) << 23) & 0x7F800000;
1438 return_val |= mantissa;
1449 int *shift_value =
ctx->shift_value;
1450 int *last_shift_value =
ctx->last_shift_value;
1451 int *last_acf_mantissa =
ctx->last_acf_mantissa;
1452 int **raw_mantissa =
ctx->raw_mantissa;
1453 int *nbits =
ctx->nbits;
1454 unsigned char *larray =
ctx->larray;
1455 int frame_length =
ctx->cur_frame_length;
1457 unsigned int partA_flag;
1458 unsigned int highest_byte;
1459 unsigned int shift_amp;
1477 memset(last_acf_mantissa, 0, avctx->
channels *
sizeof(*last_acf_mantissa));
1478 memset(last_shift_value, 0, avctx->
channels *
sizeof(*last_shift_value) );
1490 last_acf_mantissa[
c] = tmp_32;
1492 tmp_32 = last_acf_mantissa[
c];
1505 last_shift_value[
c] = shift_value[
c];
1507 shift_value[
c] = last_shift_value[
c];
1512 for (
i = 0;
i < frame_length; ++
i) {
1513 if (
ctx->raw_samples[
c][
i] == 0) {
1519 for (
i = 0;
i < frame_length; ++
i) {
1520 if (
ctx->raw_samples[
c][
i] == 0) {
1526 if(tmp_32 != nchars) {
1531 for (
i = 0;
i < frame_length; ++
i) {
1539 for (
i = 0;
i < frame_length; ++
i) {
1540 if (
ctx->raw_samples[
c][
i] != 0) {
1547 nbits[
i] =
FFMIN(nbits[
i], highest_byte*8);
1552 for (
i = 0;
i < frame_length; ++
i) {
1553 if (
ctx->raw_samples[
c][
i] != 0) {
1559 for (
i = 0;
i < frame_length; ++
i) {
1560 if (
ctx->raw_samples[
c][
i]) {
1561 nchars += (
int) nbits[
i] / 8;
1569 if(tmp_32 != nchars) {
1575 for (
i = 0;
i < frame_length; ++
i) {
1576 if (
ctx->raw_samples[
c][
i]) {
1578 nbits_aligned = 8 * ((
unsigned int)(nbits[
i] / 8) + 1);
1580 nbits_aligned = nbits[
i];
1583 for (k = 0; k < nbits_aligned/8; ++k) {
1584 acc = (
acc << 8) + larray[j++];
1586 acc >>= (nbits_aligned - nbits[
i]);
1587 raw_mantissa[
c][
i] =
acc;
1593 for (
i = 0;
i < frame_length; ++
i) {
1597 if (
ctx->raw_samples[
c][
i] != 0) {
1604 mantissa = (pcm_sf.
mant | 0x800000) + raw_mantissa[
c][
i];
1606 while(mantissa >= 0x1000000) {
1611 if (mantissa) e += (shift_value[
c] - 127);
1612 mantissa &= 0x007fffffUL;
1614 tmp_32 = (sign << 31) | ((e +
EXP_BIAS) << 23) | (mantissa);
1615 ctx->raw_samples[
c][
i] = tmp_32;
1617 ctx->raw_samples[
c][
i] = raw_mantissa[
c][
i] & 0x007fffffUL;
1633 unsigned int div_blocks[32];
1635 unsigned int js_blocks[2];
1636 uint32_t bs_info = 0;
1667 if (independent_bs) {
1669 div_blocks, js_blocks);
1689 int *reverted_channels =
ctx->reverted_channels;
1693 if (
ctx->chan_data[
c] <
ctx->chan_data_buffer) {
1698 memset(reverted_channels, 0,
sizeof(*reverted_channels) * avctx->
channels);
1705 for (
b = 0;
b <
ctx->num_blocks;
b++) {
1709 "Invalid block length %u in channel data!\n",
1735 reverted_channels,
offset,
c);
1755 memset(reverted_channels, 0, avctx->
channels *
sizeof(*reverted_channels));
1789 int buffer_size = avpkt->
size;
1790 int invalid_frame,
ret;
1803 if (sconf->
samples != 0xFFFFFFFF)
1812 "Reading frame data failed. Skipping RA unit.\n");
1817 frame->nb_samples =
ctx->cur_frame_length;
1822 #define INTERLEAVE_OUTPUT(bps) \
1824 int##bps##_t *dest = (int##bps##_t*)frame->data[0]; \
1825 int channels = avctx->channels; \
1826 int32_t **raw_samples = ctx->raw_samples; \
1827 shift = bps - ctx->avctx->bits_per_raw_sample; \
1828 if (!ctx->cs_switch) { \
1829 for (sample = 0; sample < ctx->cur_frame_length; sample++) \
1830 for (c = 0; c < channels; c++) \
1831 *dest++ = raw_samples[c][sample] * (1U << shift); \
1833 for (sample = 0; sample < ctx->cur_frame_length; sample++) \
1834 for (c = 0; c < channels; c++) \
1835 *dest++ = raw_samples[sconf->chan_pos[c]][sample] * (1U << shift);\
1839 if (
ctx->avctx->bits_per_raw_sample <= 16) {
1847 int swap = HAVE_BIGENDIAN != sconf->
msb_first;
1849 if (
ctx->avctx->bits_per_raw_sample == 24) {
1861 if (!HAVE_BIGENDIAN)
1870 if (
ctx->avctx->bits_per_raw_sample <= 16) {
1871 int16_t *
src = (int16_t*)
frame->data[0];
1872 int16_t *dest = (int16_t*)
ctx->crc_buffer;
1878 ctx->bdsp.bswap_buf((uint32_t *)
ctx->crc_buffer,
1879 (uint32_t *)
frame->data[0],
1882 crc_source =
ctx->crc_buffer;
1884 crc_source =
frame->data[0];
1895 ctx->crc_org !=
ctx->crc) {
1904 bytes_read = invalid_frame ? buffer_size :
1950 if (
ctx->raw_mantissa) {
1968 unsigned int channel_size;
1969 int num_buffers,
ret;
2019 if (num_buffers * (uint64_t)num_buffers > INT_MAX)
2025 sizeof(*
ctx->quant_cof_buffer));
2027 sizeof(*
ctx->lpc_cof_buffer));
2029 sizeof(*
ctx->lpc_cof_buffer));
2031 if (!
ctx->quant_cof || !
ctx->lpc_cof ||
2032 !
ctx->quant_cof_buffer || !
ctx->lpc_cof_buffer ||
2033 !
ctx->lpc_cof_reversed_buffer) {
2040 for (
c = 0;
c < num_buffers;
c++) {
2055 if (!
ctx->const_block || !
ctx->shift_lsbs ||
2056 !
ctx->opt_order || !
ctx->store_prev_samples ||
2057 !
ctx->use_ltp || !
ctx->ltp_lag ||
2058 !
ctx->ltp_gain || !
ctx->ltp_gain_buffer) {
2064 for (
c = 0;
c < num_buffers;
c++)
2065 ctx->ltp_gain[
c] =
ctx->ltp_gain_buffer +
c * 5;
2070 sizeof(*
ctx->chan_data_buffer));
2072 sizeof(*
ctx->chan_data));
2074 sizeof(*
ctx->reverted_channels));
2076 if (!
ctx->chan_data_buffer || !
ctx->chan_data || !
ctx->reverted_channels) {
2082 for (
c = 0;
c < num_buffers;
c++)
2083 ctx->chan_data[
c] =
ctx->chan_data_buffer +
c * num_buffers;
2087 ctx->reverted_channels =
NULL;
2107 if (!
ctx->mlz || !
ctx->acf || !
ctx->shift_value || !
ctx->last_shift_value
2108 || !
ctx->last_acf_mantissa || !
ctx->raw_mantissa) {
2123 if (!
ctx->prev_raw_samples || !
ctx->raw_buffer|| !
ctx->raw_samples) {
2132 ctx->raw_samples[
c] =
ctx->raw_samples[
c - 1] + channel_size;
2140 sizeof(*
ctx->crc_buffer));
2141 if (!
ctx->crc_buffer) {
MLZ * mlz
masked lz decompression structure
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
#define AV_LOG_WARNING
Something somehow does not look correct.
unsigned int * opt_order
contains opt_order flags for all channels
unsigned int cur_frame_length
length of the current frame to decode
int32_t ** lpc_cof
coefficients of the direct form prediction filter for a channel
static av_cold int init(AVCodecContext *avctx)
static int get_bits_left(GetBitContext *gb)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
int * ltp_lag
contains ltp lag values for all channels
uint32_t crc_org
CRC value of the original input data.
int * reverted_channels
stores a flag for each reverted channel
int block_switching
number of block switching levels
int ff_bgmc_decode_init(GetBitContext *gb, unsigned int *h, unsigned int *l, unsigned int *v)
Initialize decoding and reads the first value.
int * shift_value
value by which the binary point is to be shifted for all channels
av_cold void ff_mlz_flush_dict(MLZ *mlz)
Flush the dictionary.
int sample_rate
samples per second
int msb_first
1 = original CRC calculated on big-endian system, 0 = little-endian
int32_t * raw_samples
decoded raw samples / residuals for this block
ALSChannelData * chan_data_buffer
contains channel data for all channels
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
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 SoftFloat_IEEE754 av_bits2sf_ieee754(uint32_t n)
Make a softfloat out of the bitstream.
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(const uint8_t *) pi - 0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(const int16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(const int16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(const int32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(const int32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(const int64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0f/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(const float *) pi *(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(const double *) pi *(INT64_C(1)<< 63))) #define FMT_PAIR_FUNC(out, in) static conv_func_type *const fmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB *AV_SAMPLE_FMT_NB]={ FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S64), };static void cpy1(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, len);} static void cpy2(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 2 *len);} static void cpy4(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 4 *len);} static void cpy8(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 8 *len);} AudioConvert *swri_audio_convert_alloc(enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, const int *ch_map, int flags) { AudioConvert *ctx;conv_func_type *f=fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt)+AV_SAMPLE_FMT_NB *av_get_packed_sample_fmt(in_fmt)];if(!f) return NULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) return NULL;if(channels==1){ in_fmt=av_get_planar_sample_fmt(in_fmt);out_fmt=av_get_planar_sample_fmt(out_fmt);} ctx->channels=channels;ctx->conv_f=f;ctx->ch_map=ch_map;if(in_fmt==AV_SAMPLE_FMT_U8||in_fmt==AV_SAMPLE_FMT_U8P) memset(ctx->silence, 0x80, sizeof(ctx->silence));if(out_fmt==in_fmt &&!ch_map) { switch(av_get_bytes_per_sample(in_fmt)){ case 1:ctx->simd_f=cpy1;break;case 2:ctx->simd_f=cpy2;break;case 4:ctx->simd_f=cpy4;break;case 8:ctx->simd_f=cpy8;break;} } if(HAVE_X86ASM &&1) swri_audio_convert_init_x86(ctx, out_fmt, in_fmt, channels);if(ARCH_ARM) swri_audio_convert_init_arm(ctx, out_fmt, in_fmt, channels);if(ARCH_AARCH64) swri_audio_convert_init_aarch64(ctx, out_fmt, in_fmt, channels);return ctx;} void swri_audio_convert_free(AudioConvert **ctx) { av_freep(ctx);} int swri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, int len) { int ch;int off=0;const int os=(out->planar ? 1 :out->ch_count) *out->bps;unsigned misaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask) { int planes=in->planar ? in->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) in->ch[ch];misaligned|=m &ctx->in_simd_align_mask;} if(ctx->out_simd_align_mask) { int planes=out->planar ? out->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) out->ch[ch];misaligned|=m &ctx->out_simd_align_mask;} if(ctx->simd_f &&!ctx->ch_map &&!misaligned){ off=len &~15;av_assert1(off >=0);av_assert1(off<=len);av_assert2(ctx->channels==SWR_CH_MAX||!in->ch[ctx->channels]);if(off >0){ if(out->planar==in->planar){ int planes=out->planar ? out->ch_count :1;for(ch=0;ch< planes;ch++){ ctx->simd_f(out-> ch ch
static av_cold int decode_init(AVCodecContext *avctx)
Initialize the ALS decoder.
unsigned int * opt_order
prediction order of this block
static int get_bits_count(const GetBitContext *s)
static av_cold int end(AVCodecContext *avctx)
unsigned int ra_block
if true, this is a random access block
static const int16_t mcc_weightings[]
Inter-channel weighting factors for multi-channel correlation.
uint8_t * bgmc_lut
pointer at lookup tables used for BGMC
This structure describes decoded (raw) audio or video data.
int frame_length
frame length for each frame (last frame may differ)
static int als_weighting(GetBitContext *gb, int k, int off)
static int read_decode_block(ALSDecContext *ctx, ALSBlockData *bd)
Read and decode block data successively.
int resolution
000 = 8-bit; 001 = 16-bit; 010 = 24-bit; 011 = 32-bit
static int read_diff_float_data(ALSDecContext *ctx, unsigned int ra_frame)
Read and decode the floating point sample data.
void * av_mallocz_array(size_t nmemb, size_t size)
ALSChannelData ** chan_data
channel data for multi-channel correlation
unsigned char * larray
buffer to store the output of masked lz decompression
int joint_stereo
joint stereo: 1 = on, 0 = off
static const SoftFloat FLOAT_1
1.0
unsigned int cs_switch
if true, channel rearrangement is done
unsigned int js_switch
if true, joint-stereo decoding is enforced
av_cold void ff_bgmc_end(uint8_t **cf_lut, int **cf_lut_status)
Release the lookup table arrays.
static SoftFloat_IEEE754 av_int2sf_ieee754(int64_t n, int e)
Convert integer to softfloat.
static void skip_bits(GetBitContext *s, int n)
int ra_distance
distance between RA frames (in frames, 0...255)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static int read_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
Read the block data for a non-constant block.
static const uint8_t ltp_gain_values[4][4]
Gain values of p(0) for long-term prediction.
int * store_prev_samples
if true, carryover samples have to be stored
int * const_block
contains const_block flags for all channels
static const struct twinvq_data tab
int32_t * raw_buffer
contains all decoded raw samples including carryover samples
int * ltp_gain
gain values for ltp 5-tap filter
int32_t * raw_other
decoded raw samples of the other channel of a channel pair
int adapt_order
adaptive order: 1 = on, 0 = off
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
unsigned int * shift_lsbs
shift of values for this block
#define MISSING_ERR(cond, str, errval)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
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.
int chan_sort
channel rearrangement: 1 = on, 0 = off
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
int ltp_lag_length
number of bits used for ltp lag value
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.
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.
static void decode_const_block_data(ALSDecContext *ctx, ALSBlockData *bd)
Decode the block data for a constant block.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static void parcor_to_lpc(unsigned int k, const int32_t *par, int32_t *cof)
Convert PARCOR coefficient k to direct filter coefficient.
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
static int av_cmp_sf_ieee754(SoftFloat_IEEE754 a, SoftFloat_IEEE754 b)
Compare a with b strictly.
int * last_shift_value
contains last shift value for all channels
int * ltp_lag
lag value for long-term prediction
static SoftFloat_IEEE754 multiply(SoftFloat_IEEE754 a, SoftFloat_IEEE754 b)
multiply two softfloats and handle the rounding off
int bgmc
"Block Gilbert-Moore Code": 1 = on, 0 = off (Rice coding only)
int * ltp_gain_buffer
contains all gain values for ltp 5-tap filter
uint32_t crc
CRC value calculated from decoded data.
static av_cold int decode_end(AVCodecContext *avctx)
Uninitialize the ALS decoder.
unsigned int block_length
number of samples within the block
av_cold void ff_bswapdsp_init(BswapDSPContext *c)
#define PTRDIFF_SPECIFIER
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
static const SoftFloat FLOAT_0
0.0
int chan_config
indicates that a chan_config_info field is present
static int check_specific_config(ALSDecContext *ctx)
Check the ALSSpecificConfig for unsupported features.
unsigned int num_blocks
number of blocks used in the current frame
static unsigned int get_bits1(GetBitContext *s)
int * chan_pos
original channel positions
int * bgmc_lut_status
pointer at lookup table status flags used for BGMC
#define AV_EF_EXPLODE
abort decoding on minor error detection
int long_term_prediction
long term prediction (LTP): 1 = on, 0 = off
enum RA_Flag ra_flag
indicates where the size of ra units is stored
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
static int get_unary(GetBitContext *gb, int stop, int len)
Get unary code of limited length.
static void error(const char *err)
#define AV_EF_CAREFUL
consider things that violate the spec, are fast to calculate and have not been seen in the wild as er...
static int read_block(ALSDecContext *ctx, ALSBlockData *bd)
Read the block data.
static const uint8_t tail_code[16][6]
Tail codes used in arithmetic coding using block Gilbert-Moore codes.
static const int16_t parcor_scaled_values[]
Scaled PARCOR values used for the first two PARCOR coefficients.
av_cold int ff_bgmc_init(AVCodecContext *avctx, uint8_t **cf_lut, int **cf_lut_status)
Initialize the lookup table arrays.
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
Decode an ALS frame.
unsigned int s_max
maximum Rice parameter allowed in entropy coding
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int ** ltp_gain
gain values for ltp 5-tap filter for a channel
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
int * nbits
contains the number of bits to read for masked lz decompression for all samples
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static int read_const_block_data(ALSDecContext *ctx, ALSBlockData *bd)
Read the block data for a constant block.
int chan_config_info
mapping of channels to loudspeaker locations. Unused until setting channel configuration is implement...
int32_t * lpc_cof_buffer
contains all coefficients of the direct form prediction filter
enum AVSampleFormat sample_fmt
audio sample format
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
#define MKBETAG(a, b, c, d)
const char const char void * val
unsigned int * shift_lsbs
contains shift_lsbs flags for all channels
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
int crc_enabled
enable Cyclic Redundancy Checksum
int * use_ltp
contains use_ltp flags for all channels
int floating
1 = IEEE 32-bit floating-point, 0 = integer
static void skip_bits1(GetBitContext *s)
int * store_prev_samples
contains store_prev_samples flags for all channels
int channels
number of audio channels
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.
int * use_ltp
if true, long-term prediction is used
#define i(width, name, range_min, range_max)
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
int rlslms
use "Recursive Least Square-Least Mean Square" predictor: 1 = on, 0 = off
#define av_malloc_array(a, b)
int * last_acf_mantissa
contains the last acf mantissa data of common multiplier for all channels
int32_t * quant_cof
quantized parcor coefficients
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
@ AV_SAMPLE_FMT_S16
signed 16 bits
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
const char * name
Name of the codec implementation.
int32_t ** quant_cof
quantized parcor coefficients for a channel
int ** raw_mantissa
decoded mantissa bits of the difference signal
int32_t * lpc_cof
coefficients of the direct form prediction
int32_t * prev_raw_samples
contains unshifted raw samples from the previous block
int sb_part
sub-block partition
static av_cold void dprint_specific_config(ALSDecContext *ctx)
uint8_t * crc_buffer
buffer of byte order corrected samples used for CRC check
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
#define AV_EF_CRCCHECK
Verify checksums embedded in the bitstream (could be of either encoded or decoded data,...
static const uint8_t * align_get_bits(GetBitContext *s)
static SoftFloat_IEEE754 av_div_sf_ieee754(SoftFloat_IEEE754 a, SoftFloat_IEEE754 b)
Divide a by b.
Tag MUST be and< 10hcoeff half pel interpolation filter coefficients, hcoeff[0] are the 2 middle coefficients[1] are the next outer ones and so on, resulting in a filter like:...eff[2], hcoeff[1], hcoeff[0], hcoeff[0], hcoeff[1], hcoeff[2] ... the sign of the coefficients is not explicitly stored but alternates after each coeff and coeff[0] is positive, so ...,+,-,+,-,+,+,-,+,-,+,... hcoeff[0] is not explicitly stored but found by subtracting the sum of all stored coefficients with signs from 32 hcoeff[0]=32 - hcoeff[1] - hcoeff[2] - ... a good choice for hcoeff and htaps is htaps=6 hcoeff={40,-10, 2} an alternative which requires more computations at both encoder and decoder side and may or may not be better is htaps=8 hcoeff={42,-14, 6,-2}ref_frames minimum of the number of available reference frames and max_ref_frames for example the first frame after a key frame always has ref_frames=1spatial_decomposition_type wavelet type 0 is a 9/7 symmetric compact integer wavelet 1 is a 5/3 symmetric compact integer wavelet others are reserved stored as delta from last, last is reset to 0 if always_reset||keyframeqlog quality(logarithmic quantizer scale) stored as delta from last, last is reset to 0 if always_reset||keyframemv_scale stored as delta from last, last is reset to 0 if always_reset||keyframe FIXME check that everything works fine if this changes between framesqbias dequantization bias stored as delta from last, last is reset to 0 if always_reset||keyframeblock_max_depth maximum depth of the block tree stored as delta from last, last is reset to 0 if always_reset||keyframequant_table quantization tableHighlevel bitstream structure:==============================--------------------------------------------|Header|--------------------------------------------|------------------------------------|||Block0||||split?||||yes no||||......... intra?||||:Block01 :yes no||||:Block02 :....... ..........||||:Block03 ::y DC ::ref index:||||:Block04 ::cb DC ::motion x :||||......... :cr DC ::motion y :||||....... ..........|||------------------------------------||------------------------------------|||Block1|||...|--------------------------------------------|------------ ------------ ------------|||Y subbands||Cb subbands||Cr subbands||||--- ---||--- ---||--- ---|||||LL0||HL0||||LL0||HL0||||LL0||HL0|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||LH0||HH0||||LH0||HH0||||LH0||HH0|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||HL1||LH1||||HL1||LH1||||HL1||LH1|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||HH1||HL2||||HH1||HL2||||HH1||HL2|||||...||...||...|||------------ ------------ ------------|--------------------------------------------Decoding process:=================------------|||Subbands|------------||||------------|Intra DC||||LL0 subband prediction ------------|\ Dequantization ------------------- \||Reference frames|\ IDWT|------- -------|Motion \|||Frame 0||Frame 1||Compensation . OBMC v -------|------- -------|--------------. \------> Frame n output Frame Frame<----------------------------------/|...|------------------- Range Coder:============Binary Range Coder:------------------- The implemented range coder is an adapted version based upon "Range encoding: an algorithm for removing redundancy from a digitised message." by G. N. N. Martin. The symbols encoded by the Snow range coder are bits(0|1). The associated probabilities are not fix but change depending on the symbol mix seen so far. bit seen|new state ---------+----------------------------------------------- 0|256 - state_transition_table[256 - old_state];1|state_transition_table[old_state];state_transition_table={ 0, 0, 0, 0, 0, 0, 0, 0, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 190, 191, 192, 194, 194, 195, 196, 197, 198, 199, 200, 201, 202, 202, 204, 205, 206, 207, 208, 209, 209, 210, 211, 212, 213, 215, 215, 216, 217, 218, 219, 220, 220, 222, 223, 224, 225, 226, 227, 227, 229, 229, 230, 231, 232, 234, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 248, 0, 0, 0, 0, 0, 0, 0};FIXME Range Coding of integers:------------------------- FIXME Neighboring Blocks:===================left and top are set to the respective blocks unless they are outside of the image in which case they are set to the Null block top-left is set to the top left block unless it is outside of the image in which case it is set to the left block if this block has no larger parent block or it is at the left side of its parent block and the top right block is not outside of the image then the top right block is used for top-right else the top-left block is used Null block y, cb, cr are 128 level, ref, mx and my are 0 Motion Vector Prediction:=========================1. the motion vectors of all the neighboring blocks are scaled to compensate for the difference of reference frames scaled_mv=(mv *(256 *(current_reference+1)/(mv.reference+1))+128)> the median of the scaled left
#define FF_ARRAY_ELEMS(a)
main external API structure.
int coef_table
table index of Rice code parameters
static int read_channel_data(ALSDecContext *ctx, ALSChannelData *cd, int c)
Read the channel data.
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)
Calculate the CRC of a block.
int32_t ** raw_samples
decoded raw samples for each channel
int32_t * lpc_cof_reversed_buffer
temporary buffer to set up a reversed versio of lpc_cof_buffer
static int32_t decode_rice(GetBitContext *gb, unsigned int k)
Read and decode a Rice codeword.
int32_t * quant_cof_buffer
contains all quantized parcor coefficients
static av_cold void flush(AVCodecContext *avctx)
Flush (reset) the frame ID after seeking.
static av_cold int read_specific_config(ALSDecContext *ctx)
Read an ALSSpecificConfig from a buffer into the output struct.
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.
int32_t * prev_raw_samples
contains unshifted raw samples from the previous block
static int shift(int a, int b)
uint32_t samples
number of samples, 0xFFFFFFFF if unknown
static av_always_inline int get_bitsz(GetBitContext *s, int n)
Read 0-25 bits.
#define AV_CODEC_CAP_SUBFRAMES
Codec can output multiple frames per AVPacket Normally demuxers return one frame at a time,...
int js_blocks
true if this block contains a difference signal
static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame)
Read the frame data.
#define avpriv_request_sample(...)
static int decode_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
Decode the block data for a non-constant block.
#define INTERLEAVE_OUTPUT(bps)
This structure stores compressed data.
unsigned int frame_id
the frame ID / number of the current frame
static int decode_block(ALSDecContext *ctx, ALSBlockData *bd)
Decode the block data.
void ff_bgmc_decode_end(GetBitContext *gb)
Finish decoding.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
av_cold void ff_mlz_init_dict(void *context, MLZ *mlz)
Initialize the dictionary.
int max_order
maximum prediction order (0..1023)
int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf, int bit_size, int sync_extension)
Parse MPEG-4 systems extradata from a raw buffer to retrieve audio configuration.
#define FF_SANE_NB_CHANNELS
static int get_sbits_long(GetBitContext *s, int n)
Read 0-32 bits as a signed integer.
@ AV_SAMPLE_FMT_S32
signed 32 bits
SoftFloat_IEEE754 * acf
contains common multiplier for all channels
int mc_coding
extended inter-channel coding (multi channel coding): 1 = on, 0 = off
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.
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 const int8_t parcor_rice_table[3][20][2]
Rice parameters and corresponding index offsets for decoding the indices of scaled PARCOR values.
int * const_block
if true, this is a constant value block