52 { {-52, 4}, {-29, 5}, {-31, 4}, { 19, 4}, {-16, 4},
53 { 12, 3}, { -7, 3}, { 9, 3}, { -5, 3}, { 6, 3},
54 { -4, 3}, { 3, 3}, { -3, 2}, { 3, 2}, { -2, 2},
55 { 3, 2}, { -1, 2}, { 2, 2}, { -1, 2}, { 2, 2} },
56 { {-58, 3}, {-42, 4}, {-46, 4}, { 37, 5}, {-36, 4},
57 { 29, 4}, {-29, 4}, { 25, 4}, {-23, 4}, { 20, 4},
58 {-17, 4}, { 16, 4}, {-12, 4}, { 12, 3}, {-10, 4},
59 { 7, 3}, { -4, 4}, { 3, 3}, { -1, 3}, { 1, 3} },
60 { {-59, 3}, {-45, 5}, {-50, 4}, { 38, 4}, {-39, 4},
61 { 32, 4}, {-30, 4}, { 25, 3}, {-23, 3}, { 20, 3},
62 {-20, 3}, { 16, 3}, {-13, 3}, { 10, 3}, { -7, 3},
63 { 3, 3}, { 0, 3}, { -1, 3}, { 2, 3}, { -1, 2} }
73 -1048544 / 32, -1048288 / 32, -1047776 / 32, -1047008 / 32,
74 -1045984 / 32, -1044704 / 32, -1043168 / 32, -1041376 / 32,
75 -1039328 / 32, -1037024 / 32, -1034464 / 32, -1031648 / 32,
76 -1028576 / 32, -1025248 / 32, -1021664 / 32, -1017824 / 32,
77 -1013728 / 32, -1009376 / 32, -1004768 / 32, -999904 / 32,
78 -994784 / 32, -989408 / 32, -983776 / 32, -977888 / 32,
79 -971744 / 32, -965344 / 32, -958688 / 32, -951776 / 32,
80 -944608 / 32, -937184 / 32, -929504 / 32, -921568 / 32,
81 -913376 / 32, -904928 / 32, -896224 / 32, -887264 / 32,
82 -878048 / 32, -868576 / 32, -858848 / 32, -848864 / 32,
83 -838624 / 32, -828128 / 32, -817376 / 32, -806368 / 32,
84 -795104 / 32, -783584 / 32, -771808 / 32, -759776 / 32,
85 -747488 / 32, -734944 / 32, -722144 / 32, -709088 / 32,
86 -695776 / 32, -682208 / 32, -668384 / 32, -654304 / 32,
87 -639968 / 32, -625376 / 32, -610528 / 32, -595424 / 32,
88 -580064 / 32, -564448 / 32, -548576 / 32, -532448 / 32,
89 -516064 / 32, -499424 / 32, -482528 / 32, -465376 / 32,
90 -447968 / 32, -430304 / 32, -412384 / 32, -394208 / 32,
91 -375776 / 32, -357088 / 32, -338144 / 32, -318944 / 32,
92 -299488 / 32, -279776 / 32, -259808 / 32, -239584 / 32,
93 -219104 / 32, -198368 / 32, -177376 / 32, -156128 / 32,
94 -134624 / 32, -112864 / 32, -90848 / 32, -68576 / 32,
95 -46048 / 32, -23264 / 32, -224 / 32, 23072 / 32,
96 46624 / 32, 70432 / 32, 94496 / 32, 118816 / 32,
97 143392 / 32, 168224 / 32, 193312 / 32, 218656 / 32,
98 244256 / 32, 270112 / 32, 296224 / 32, 322592 / 32,
99 349216 / 32, 376096 / 32, 403232 / 32, 430624 / 32,
100 458272 / 32, 486176 / 32, 514336 / 32, 542752 / 32,
101 571424 / 32, 600352 / 32, 629536 / 32, 658976 / 32,
102 688672 / 32, 718624 / 32, 748832 / 32, 779296 / 32,
103 810016 / 32, 840992 / 32, 872224 / 32, 903712 / 32,
104 935456 / 32, 967456 / 32, 999712 / 32, 1032224 / 32
123 204, 192, 179, 166, 153, 140, 128, 115,
124 102, 89, 76, 64, 51, 38, 25, 12,
125 0, -12, -25, -38, -51, -64, -76, -89,
126 -102, -115, -128, -140, -153, -166, -179, -192
133 { 74, 44, 25, 13, 7, 3},
134 { 68, 42, 24, 13, 7, 3},
135 { 58, 39, 23, 13, 7, 3},
136 {126, 70, 37, 19, 10, 5},
137 {132, 70, 37, 20, 10, 5},
138 {124, 70, 38, 20, 10, 5},
139 {120, 69, 37, 20, 11, 5},
140 {116, 67, 37, 20, 11, 5},
141 {108, 66, 36, 20, 10, 5},
142 {102, 62, 36, 20, 10, 5},
143 { 88, 58, 34, 19, 10, 5},
144 {162, 89, 49, 25, 13, 7},
145 {156, 87, 49, 26, 14, 7},
146 {150, 86, 47, 26, 14, 7},
147 {142, 84, 47, 26, 14, 7},
148 {131, 79, 46, 26, 14, 7}
296 int i, config_offset;
300 uint32_t als_id, header_size, trailer_size;
309 if (config_offset < 0)
349 if (als_id !=
MKBETAG(
'A',
'L',
'S',
'\0'))
362 int chan_pos_bits = av_ceil_log2(avctx->
channels);
363 int bits_needed = avctx->
channels * chan_pos_bits + 7;
372 for (i = 0; i < avctx->
channels; i++) {
376 for (i = 0; i < avctx->
channels; i++) {
399 if (header_size == 0xFFFFFFFF)
401 if (trailer_size == 0xFFFFFFFF)
404 ht_size = ((int64_t)(header_size) + (int64_t)(trailer_size)) << 3;
411 if (ht_size > INT32_MAX)
424 ctx->
crc = 0xFFFFFFFF;
447 #define MISSING_ERR(cond, str, errval) \
450 avpriv_report_missing_feature(ctx->avctx, \
466 unsigned int div,
unsigned int **div_blocks,
467 unsigned int *num_blocks)
469 if (n < 31 && ((bs_info << n) & 0x40000000)) {
510 for (i = 0, j = k - 1; i < j; i++, j--) {
511 int tmp1 = ((
MUL64(par[k], cof[j]) + (1 << 19)) >> 20);
512 cof[j] += ((
MUL64(par[k], cof[i]) + (1 << 19)) >> 20);
516 cof[i] += ((
MUL64(par[k], cof[j]) + (1 << 19)) >> 20);
531 unsigned int *ptr_div_blocks = div_blocks;
537 *bs_info <<= (32 - bs_info_len);
565 if (remaining <= div_blocks[b]) {
566 div_blocks[
b] = remaining;
571 remaining -= div_blocks[
b];
631 unsigned int sub_blocks, log2_sub_blocks, sb_length;
632 unsigned int start = 0;
633 unsigned int opt_order;
657 sub_blocks = 1 << log2_sub_blocks;
663 "Block length is not evenly divisible by the number of subblocks.\n");
671 for (k = 1; k < sub_blocks; k++)
674 for (k = 0; k < sub_blocks; k++) {
680 for (k = 1; k < sub_blocks; k++)
683 for (k = 1; k < sub_blocks; k++)
697 int opt_order_length = av_ceil_log2(av_clip((bd->
block_length >> 3) - 1,
729 for (k = 2; k < opt_order; k++)
736 k_max =
FFMIN(opt_order, 20);
737 for (k = 0; k < k_max; k++) {
741 if (quant_cof[k] < -64 || quant_cof[k] > 63) {
743 "quant_cof %"PRId32
" is out of range.\n",
750 k_max =
FFMIN(opt_order, 127);
751 for (; k < k_max; k++)
755 for (; k < opt_order; k++)
764 for (k = 2; k < opt_order; k++)
765 quant_cof[k] = (quant_cof[k] << 14) + (add_base << 13);
805 start =
FFMIN(opt_order, 3);
812 unsigned int b = av_clip((av_ceil_log2(bd->
block_length) - 3) >> 1, 0, 5);
823 for (sb = 0; sb < sub_blocks; sb++) {
824 unsigned int sb_len = sb_length - (sb ? 0 :
start);
826 k [sb] = s[sb] > b ? s[sb] - b : 0;
827 delta[sb] = 5 - s[sb] + k[sb];
832 current_res += sb_len;
841 for (sb = 0; sb < sub_blocks; sb++, start = 0) {
842 unsigned int cur_tail_code =
tail_code[sx[sb]][delta[sb]];
843 unsigned int cur_k = k[sb];
844 unsigned int cur_s = s[sb];
846 for (; start < sb_length; start++) {
849 if (res == cur_tail_code) {
850 unsigned int max_msb = (2 + (sx[sb] > 2) + (sx[sb] > 10))
856 res += (max_msb ) << cur_k;
858 res -= (max_msb - 1) << cur_k;
861 if (res > cur_tail_code)
875 *current_res++ = res;
881 for (sb = 0; sb < sub_blocks; sb++, start = 0)
882 for (; start < sb_length; start++)
896 unsigned int smp = 0;
911 for (ltp_smp =
FFMAX(*bd->
ltp_lag - 2, 0); ltp_smp < block_length; ltp_smp++) {
912 int center = ltp_smp - *bd->
ltp_lag;
913 int begin =
FFMAX(0, center - 2);
914 int end = center + 3;
915 int tab = 5 - (end - begin);
920 for (base = begin; base <
end; base++, tab++)
923 raw_samples[ltp_smp] += y >> 7;
929 for (smp = 0; smp < opt_order; smp++) {
932 for (sb = 0; sb < smp; sb++)
933 y +=
MUL64(lpc_cof[sb], raw_samples[-(sb + 1)]);
935 *raw_samples++ -= y >> 20;
939 for (k = 0; k < opt_order; k++)
959 for (sb = -1; sb >= -sconf->
max_order; sb--)
960 raw_samples[sb] = right[sb] - left[sb];
965 for (sb = -1; sb >= -sconf->
max_order; sb--)
970 lpc_cof = lpc_cof + opt_order;
972 for (sb = 0; sb < opt_order; sb++)
973 lpc_cof_reversed[sb] = lpc_cof[-(sb + 1)];
977 lpc_cof = lpc_cof_reversed + opt_order;
979 for (; raw_samples < raw_samples_end; raw_samples++) {
982 for (sb = -opt_order; sb < 0; sb++)
983 y +=
MUL64(lpc_cof[sb], raw_samples[sb]);
985 *raw_samples -= y >> 20;
993 sizeof(*raw_samples) * sconf->
max_order);
1065 const unsigned int *div_blocks,
int32_t *
buf)
1067 unsigned int count = 0;
1070 count += div_blocks[b++];
1073 memset(buf, 0,
sizeof(*buf) * count);
1080 unsigned int c,
const unsigned int *div_blocks,
1081 unsigned int *js_blocks)
1120 unsigned int c,
const unsigned int *div_blocks,
1121 unsigned int *js_blocks)
1173 if (bd[0].js_blocks) {
1174 if (bd[1].js_blocks)
1177 for (s = 0; s < div_blocks[
b]; s++)
1178 bd[0].raw_samples[s] = bd[1].raw_samples[s] - bd[0].raw_samples[s];
1179 }
else if (bd[1].js_blocks) {
1180 for (s = 0; s < div_blocks[
b]; s++)
1181 bd[1].raw_samples[s] = bd[1].raw_samples[s] + bd[0].raw_samples[s];
1184 offset += div_blocks[
b];
1247 if (entries == channels) {
1264 unsigned int dep = 0;
1273 while (dep < channels && !ch[dep].stop_flag) {
1275 ch[dep].master_channel);
1280 if (dep == channels) {
1296 for (dep = 0; !ch[dep].
stop_flag; dep++) {
1298 ptrdiff_t begin = 1;
1303 if (ch[dep].master_channel == c)
1306 if (ch[dep].time_diff_flag) {
1309 if (ch[dep].time_diff_sign) {
1325 FFMAX(end + 1, end + 1 + t) > ctx->
raw_buffer + channels * channel_size - master) {
1327 "sample pointer range [%p, %p] not contained in raw_buffer [%p, %p].\n",
1328 master +
FFMIN(begin - 1, begin - 1 + t), master +
FFMAX(end + 1, end + 1 + t),
1333 for (smp = begin; smp <
end; smp++) {
1335 MUL64(ch[dep].weighting[0], master[smp - 1 ]) +
1336 MUL64(ch[dep].weighting[1], master[smp ]) +
1337 MUL64(ch[dep].weighting[2], master[smp + 1 ]) +
1338 MUL64(ch[dep].weighting[3], master[smp - 1 + t]) +
1339 MUL64(ch[dep].weighting[4], master[smp + t]) +
1340 MUL64(ch[dep].weighting[5], master[smp + 1 + t]);
1347 end + 1 > ctx->
raw_buffer + channels * channel_size - master) {
1349 "sample pointer range [%p, %p] not contained in raw_buffer [%p, %p].\n",
1350 master + begin - 1, master + end + 1,
1355 for (smp = begin; smp <
end; smp++) {
1357 MUL64(ch[dep].weighting[0], master[smp - 1]) +
1358 MUL64(ch[dep].weighting[1], master[smp ]) +
1359 MUL64(ch[dep].weighting[2], master[smp + 1]);
1373 uint64_t mantissa_temp;
1375 int cutoff_bit_count;
1376 unsigned char last_2_bits;
1377 unsigned int mantissa;
1379 uint32_t return_val = 0;
1385 mantissa_temp = (uint64_t)a.
mant * (uint64_t)b.
mant;
1386 mask_64 = (uint64_t)0x1 << 47;
1389 while (!(mantissa_temp & mask_64) && mask_64) {
1395 cutoff_bit_count = bit_count - 24;
1396 if (cutoff_bit_count > 0) {
1397 last_2_bits = (
unsigned char)(((
unsigned int)mantissa_temp >> (cutoff_bit_count - 1)) & 0x3 );
1398 if ((last_2_bits == 0x3) || ((last_2_bits == 0x1) && ((
unsigned int)mantissa_temp & ((0x1UL << (cutoff_bit_count - 1)) - 1)))) {
1400 mantissa_temp += (uint64_t)0x1 << cutoff_bit_count;
1404 mantissa = (
unsigned int)(mantissa_temp >> cutoff_bit_count);
1407 if (mantissa & 0x01000000ul) {
1413 return_val = 0x80000000
U;
1416 return_val |= (a.
exp + b.
exp + bit_count - 47) << 23;
1417 return_val |= mantissa;
1432 int *nbits = ctx->
nbits;
1433 unsigned char *larray = ctx->
larray;
1436 unsigned int partA_flag;
1437 unsigned int highest_byte;
1438 unsigned int shift_amp;
1456 memset(last_acf_mantissa, 0, avctx->
channels *
sizeof(*last_acf_mantissa));
1457 memset(last_shift_value, 0, avctx->
channels *
sizeof(*last_shift_value) );
1466 last_acf_mantissa[
c] = tmp_32;
1468 tmp_32 = last_acf_mantissa[
c];
1481 last_shift_value[
c] = shift_value[
c];
1483 shift_value[
c] = last_shift_value[
c];
1488 for (i = 0; i < frame_length; ++i) {
1495 for (i = 0; i < frame_length; ++i) {
1502 if(tmp_32 != nchars) {
1507 for (i = 0; i < frame_length; ++i) {
1515 for (i = 0; i < frame_length; ++i) {
1523 nbits[i] =
FFMIN(nbits[i], highest_byte*8);
1528 for (i = 0; i < frame_length; ++i) {
1530 raw_mantissa[
c][i] =
get_bitsz(gb, nbits[i]);
1535 for (i = 0; i < frame_length; ++i) {
1537 nchars += (int) nbits[i] / 8;
1545 if(tmp_32 != nchars) {
1551 for (i = 0; i < frame_length; ++i) {
1554 nbits_aligned = 8 * ((
unsigned int)(nbits[i] / 8) + 1);
1556 nbits_aligned = nbits[i];
1559 for (k = 0; k < nbits_aligned/8; ++k) {
1560 acc = (acc << 8) + larray[j++];
1562 acc >>= (nbits_aligned - nbits[i]);
1563 raw_mantissa[
c][i] =
acc;
1569 for (i = 0; i < frame_length; ++i) {
1580 mantissa = (pcm_sf.
mant | 0x800000) + raw_mantissa[c][i];
1582 while(mantissa >= 0x1000000) {
1587 if (mantissa) e += (shift_value[
c] - 127);
1588 mantissa &= 0x007fffffUL;
1590 tmp_32 = (sign << 31) | ((e +
EXP_BIAS) << 23) | (mantissa);
1609 unsigned int div_blocks[32];
1611 unsigned int js_blocks[2];
1612 uint32_t bs_info = 0;
1627 for (c = 0; c < avctx->
channels; c++) {
1643 if (independent_bs) {
1645 div_blocks, js_blocks);
1650 ret =
decode_blocks(ctx, ra_frame, c, div_blocks, js_blocks);
1668 for (c = 0; c < avctx->
channels; c++)
1674 memset(reverted_channels, 0,
sizeof(*reverted_channels) * avctx->
channels);
1685 "Invalid block length %u in channel data!\n",
1690 for (c = 0; c < avctx->
channels; c++) {
1709 for (c = 0; c < avctx->
channels; c++) {
1711 reverted_channels, offset, c);
1715 for (c = 0; c < avctx->
channels; c++) {
1731 memset(reverted_channels, 0, avctx->
channels *
sizeof(*reverted_channels));
1732 offset += div_blocks[
b];
1737 for (c = 0; c < avctx->
channels; c++)
1765 int buffer_size = avpkt->
size;
1766 int invalid_frame, ret;
1779 if (sconf->
samples != 0xFFFFFFFF)
1788 "Reading frame data failed. Skipping RA unit.\n");
1798 #define INTERLEAVE_OUTPUT(bps) \
1800 int##bps##_t *dest = (int##bps##_t*)frame->data[0]; \
1801 shift = bps - ctx->avctx->bits_per_raw_sample; \
1802 if (!ctx->cs_switch) { \
1803 for (sample = 0; sample < ctx->cur_frame_length; sample++) \
1804 for (c = 0; c < avctx->channels; c++) \
1805 *dest++ = ctx->raw_samples[c][sample] << shift; \
1807 for (sample = 0; sample < ctx->cur_frame_length; sample++) \
1808 for (c = 0; c < avctx->channels; c++) \
1809 *dest++ = ctx->raw_samples[sconf->chan_pos[c]][sample] << shift; \
1821 int swap = HAVE_BIGENDIAN != sconf->
msb_first;
1835 if (!HAVE_BIGENDIAN)
1845 int16_t *
src = (int16_t*) frame->
data[0];
1853 (uint32_t *) frame->
data[0],
1858 crc_source = frame->
data[0];
1878 bytes_read = invalid_frame ? buffer_size :
1925 for (i = 0; i < avctx->
channels; i++) {
1942 unsigned int channel_size;
1943 int num_buffers, ret;
2012 for (c = 0; c < num_buffers; c++) {
2036 for (c = 0; c < num_buffers; c++)
2054 for (c = 0; c < num_buffers; c++)
2103 for (c = 1; c < avctx->
channels; c++)
void(* bswap_buf)(uint32_t *dst, const uint32_t *src, int w)
static int als_weighting(GetBitContext *gb, int k, int off)
static int decode_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
Decode the block data for a non-constant block.
int msb_first
1 = original CRC calculated on big-endian system, 0 = little-endian
const char const char void * val
unsigned char * larray
buffer to store the output of masked lz decompression
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static int shift(int a, int b)
This structure describes decoded (raw) audio or video data.
int * use_ltp
contains use_ltp flags for all channels
ptrdiff_t const GLvoid * data
av_cold void ff_bgmc_end(uint8_t **cf_lut, int **cf_lut_status)
Release the lookup table arrays.
MLZ * mlz
masked lz decompression structure
int32_t ** raw_samples
decoded raw samples for each channel
uint8_t * crc_buffer
buffer of byte order corrected samples used for CRC check
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_LOG_WARNING
Something somehow does not look correct.
static const int16_t mcc_weightings[]
Inter-channel weighting factors for multi-channel correlation.
static void skip_bits_long(GetBitContext *s, int n)
static av_cold int init(AVCodecContext *avctx)
int block_switching
number of block switching levels
int rlslms
use "Recursive Least Square-Least Mean Square" predictor: 1 = on, 0 = off
static int check_specific_config(ALSDecContext *ctx)
Check the ALSSpecificConfig for unsupported features.
int adapt_order
adaptive order: 1 = on, 0 = off
static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame)
Read the frame data.
int32_t * lpc_cof_reversed_buffer
temporary buffer to set up a reversed versio of lpc_cof_buffer
Block Gilbert-Moore decoder header.
int * nbits
contains the number of bits to read for masked lz decompression for all samples
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
unsigned int js_switch
if true, joint-stereo decoding is enforced
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
static int read_decode_block(ALSDecContext *ctx, ALSBlockData *bd)
Read and decode block data successively.
#define INTERLEAVE_OUTPUT(bps)
static int32_t decode_rice(GetBitContext *gb, unsigned int k)
Read and decode a Rice codeword.
static int get_sbits_long(GetBitContext *s, int n)
Read 0-32 bits as a signed integer.
int * ltp_lag
contains ltp lag values for all channels
int * const_block
contains const_block flags for all channels
static const uint8_t ltp_gain_values[4][4]
Gain values of p(0) for long-term prediction.
static av_cold int decode_init(AVCodecContext *avctx)
Initialize the ALS decoder.
int32_t * lpc_cof
coefficients of the direct form prediction
enum AVSampleFormat sample_fmt
audio sample format
static void decode_const_block_data(ALSDecContext *ctx, ALSBlockData *bd)
Decode the block data for a constant block.
static av_cold int end(AVCodecContext *avctx)
int ** ltp_gain
gain values for ltp 5-tap filter for a channel
static SoftFloat_IEEE754 av_bits2sf_ieee754(uint32_t n)
Make a softfloat out of the bitstream.
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
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
int chan_sort
channel rearrangement: 1 = on, 0 = off
int joint_stereo
joint stereo: 1 = on, 0 = off
Public header for CRC hash function implementation.
static SoftFloat_IEEE754 av_int2sf_ieee754(int64_t n, int e)
Convert integer to softfloat.
static int get_bits_count(const GetBitContext *s)
bitstream reader API header.
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.
void ff_bgmc_decode_init(GetBitContext *gb, unsigned int *h, unsigned int *l, unsigned int *v)
Initialize decoding and reads the first value.
unsigned int block_length
number of samples within the block
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...
int ra_distance
distance between RA frames (in frames, 0...255)
int32_t * quant_cof_buffer
contains all quantized parcor coefficients
ALSChannelData * chan_data_buffer
contains channel data for all channels
int bgmc
"Block Gilbert-Moore Code": 1 = on, 0 = off (Rice coding only)
unsigned int cs_switch
if true, channel rearrangement is done
static int get_bits_left(GetBitContext *gb)
int * use_ltp
if true, long-term prediction is used
enum RA_Flag ra_flag
indicates where the size of ra units is stored
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int ltp_lag_length
number of bits used for ltp lag value
#define PTRDIFF_SPECIFIER
static av_cold void dprint_specific_config(ALSDecContext *ctx)
unsigned int * opt_order
prediction order of this block
int * chan_pos
original channel positions
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static const int16_t parcor_scaled_values[]
Scaled PARCOR values used for the first two PARCOR coefficients.
static const SoftFloat FLOAT_1
1.0
static SoftFloat_IEEE754 multiply(SoftFloat_IEEE754 a, SoftFloat_IEEE754 b)
multiply two softfloats and handle the rounding off
int32_t ** lpc_cof
coefficients of the direct form prediction filter for a channel
static int read_diff_float_data(ALSDecContext *ctx, unsigned int ra_frame)
Read and decode the floating point sample data.
int chan_config_info
mapping of channels to loudspeaker locations. Unused until setting channel configuration is implement...
unsigned int num_blocks
number of blocks used in the current frame
const char * name
Name of the codec implementation.
int32_t * prev_raw_samples
contains unshifted raw samples from the previous block
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.
void ff_bgmc_decode_end(GetBitContext *gb)
Finish decoding.
static const uint8_t offset[127][2]
int * bgmc_lut_status
pointer at lookup table status flags used for BGMC
static void * av_mallocz_array(size_t nmemb, size_t size)
int * store_prev_samples
if true, carryover samples have to be stored
unsigned int * shift_lsbs
contains shift_lsbs flags for all channels
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
static int read_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
Read the block data for a non-constant block.
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.
GLsizei GLboolean const GLfloat * value
int chan_config
indicates that a chan_config_info field is present
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)
Calculate the CRC of a block.
int * last_shift_value
contains last shift value for all channels
static int av_cmp_sf_ieee754(SoftFloat_IEEE754 a, SoftFloat_IEEE754 b)
Compare a with b strictly.
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 av_cold int decode_end(AVCodecContext *avctx)
Uninitialize the ALS decoder.
int * const_block
if true, this is a constant value block
#define AV_EF_EXPLODE
abort decoding on minor error detection
int floating
1 = IEEE 32-bit floating-point, 0 = integer
SoftFloat_IEEE754 * acf
contains common multiplier for all channels
uint32_t crc
CRC value calculated from decoded data.
int coef_table
table index of Rice code parameters
static int read_const_block_data(ALSDecContext *ctx, ALSBlockData *bd)
Read the block data for a constant block.
#define FF_ARRAY_ELEMS(a)
int sb_part
sub-block partition
int32_t * raw_other
decoded raw samples of the other channel of a channel pair
uint8_t * bgmc_lut
pointer at lookup tables used for BGMC
av_cold void ff_mlz_init_dict(void *context, MLZ *mlz)
Initialize the dictionary.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
int * ltp_gain
gain values for ltp 5-tap filter
int js_blocks
true if this block contains a difference signal
unsigned int ra_block
if true, this is a random access block
Libavcodec external API header.
static void parcor_to_lpc(unsigned int k, const int32_t *par, int32_t *cof)
Convert PARCOR coefficient k to direct filter coefficient.
int * shift_value
value by which the binary point is to be shifted for all channels
int sample_rate
samples per second
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
main external API structure.
ALSChannelData ** chan_data
channel data for multi-channel correlation
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
Decode an ALS frame.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
#define MISSING_ERR(cond, str, errval)
#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 unsigned int get_bits1(GetBitContext *s)
static void skip_bits1(GetBitContext *s)
unsigned int s_max
maximum Rice parameter allowed in entropy coding
static void skip_bits(GetBitContext *s, int n)
#define AV_CODEC_CAP_SUBFRAMES
Codec can output multiple frames per AVPacket Normally demuxers return one frame at a time...
int * ltp_lag
lag value for long-term prediction
int32_t * lpc_cof_buffer
contains all coefficients of the direct form prediction filter
#define AV_EF_CRCCHECK
Verify checksums embedded in the bitstream (could be of either encoded or decoded data...
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 av_cold int read_specific_config(ALSDecContext *ctx)
Read an ALSSpecificConfig from a buffer into the output struct.
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
int long_term_prediction
long term prediction (LTP): 1 = on, 0 = off
int32_t * raw_samples
decoded raw samples / residuals for this block
int * reverted_channels
stores a flag for each reverted channel
int * last_acf_mantissa
contains the last acf mantissa data of common multiplier for all channels
unsigned int * opt_order
contains opt_order flags for all channels
int32_t * raw_buffer
contains all decoded raw samples including carryover samples
int max_order
maximum prediction order (0..1023)
uint32_t samples
number of samples, 0xFFFFFFFF if unknown
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
int mc_coding
extended inter-channel coding (multi channel coding): 1 = on, 0 = off
static const uint8_t tail_code[16][6]
Tail codes used in arithmetic coding using block Gilbert-Moore codes.
common internal api header.
int32_t * prev_raw_samples
contains unshifted raw samples from the previous block
static int get_unary(GetBitContext *gb, int stop, int len)
Get unary code of limited length.
av_cold void ff_mlz_flush_dict(MLZ *mlz)
Flush the dictionary.
static av_cold void flush(AVCodecContext *avctx)
Flush (reset) the frame ID after seeking.
int * ltp_gain_buffer
contains all gain values for ltp 5-tap filter
int32_t * quant_cof
quantized parcor coefficients
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(constuint8_t *) pi-0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(constint16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(constint32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(constint64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64,*(constint64_t *) pi *(1.0f/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64,*(constint64_t *) pi *(1.0/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(constfloat *) pi *(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(constdouble *) pi *(INT64_C(1)<< 63)))#defineFMT_PAIR_FUNC(out, in) staticconv_func_type *constfmt_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),};staticvoidcpy1(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, len);}staticvoidcpy2(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 2 *len);}staticvoidcpy4(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 4 *len);}staticvoidcpy8(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 8 *len);}AudioConvert *swri_audio_convert_alloc(enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, constint *ch_map, intflags){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) returnNULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) returnNULL;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)){case1:ctx->simd_f=cpy1;break;case2:ctx->simd_f=cpy2;break;case4:ctx->simd_f=cpy4;break;case8:ctx->simd_f=cpy8;break;}}if(HAVE_YASM &&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);returnctx;}voidswri_audio_convert_free(AudioConvert **ctx){av_freep(ctx);}intswri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, intlen){intch;intoff=0;constintos=(out->planar?1:out->ch_count)*out->bps;unsignedmisaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask){intplanes=in->planar?in->ch_count:1;unsignedm=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){intplanes=out->planar?out->ch_count:1;unsignedm=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){intplanes=out->planar?out->ch_count:1;for(ch=0;ch< planes;ch++){ctx->simd_f(out-> ch ch
int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf, int bit_size, int sync_extension)
Parse MPEG-4 systems extradata to retrieve audio configuration.
#define MKBETAG(a, b, c, d)
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...
av_cold void ff_bswapdsp_init(BswapDSPContext *c)
int32_t ** quant_cof
quantized parcor coefficients for a channel
int channels
number of audio channels
int crc_enabled
enable Cyclic Redundancy Checksum
int ** raw_mantissa
decoded mantissa bits of the difference signal
uint32_t crc_org
CRC value of the original input data.
static int decode_block(ALSDecContext *ctx, ALSBlockData *bd)
Decode the block data.
static int read_block(ALSDecContext *ctx, ALSBlockData *bd)
Read the block data.
int frame_length
frame length for each frame (last frame may differ)
static const uint8_t * align_get_bits(GetBitContext *s)
static const struct twinvq_data tab
unsigned int * shift_lsbs
shift of values for this block
static int decode(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *pkt)
av_cold int ff_bgmc_init(AVCodecContext *avctx, uint8_t **cf_lut, int **cf_lut_status)
Initialize the lookup table arrays.
#define av_malloc_array(a, b)
static int read_channel_data(ALSDecContext *ctx, ALSChannelData *cd, int c)
Read the channel data.
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.
int * store_prev_samples
contains store_prev_samples flags for all channels
static SoftFloat_IEEE754 av_div_sf_ieee754(SoftFloat_IEEE754 a, SoftFloat_IEEE754 b)
Divide a by b.
unsigned int frame_id
the frame ID / number of the current frame
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.
This structure stores compressed data.
int nb_samples
number of audio samples (per channel) described by this frame
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
unsigned int cur_frame_length
length of the current frame to decode
static av_always_inline int get_bitsz(GetBitContext *s, int n)
Read 0-25 bits.
int resolution
000 = 8-bit; 001 = 16-bit; 010 = 24-bit; 011 = 32-bit