76 #define PARAM_BLOCKSIZE (1 << 7)
77 #define PARAM_MATRIX (1 << 6)
78 #define PARAM_OUTSHIFT (1 << 5)
79 #define PARAM_QUANTSTEP (1 << 4)
80 #define PARAM_FIR (1 << 3)
81 #define PARAM_IIR (1 << 2)
82 #define PARAM_HUFFOFFSET (1 << 1)
83 #define PARAM_PRESENCE (1 << 0)
188 if (!huff_vlc[0].
bits) {
204 unsigned int substr,
unsigned int ch)
213 sign_huff_offset -= 7 << lsb_bits;
216 sign_huff_offset -= 1 << sign_shift;
218 return sign_huff_offset;
225 unsigned int substr,
unsigned int pos)
228 unsigned int mat, channel;
234 for (channel = s->
min_channel; channel <= s->max_channel; channel++) {
238 int lsb_bits = cp->
huff_lsbs - quant_step_size;
242 result =
get_vlc2(gbp, huff_vlc[codebook-1].table,
249 result = (result << lsb_bits) +
get_bits(gbp, lsb_bits);
252 result <<= quant_step_size;
296 "Channel group 2 cannot have more bits per sample than group 1.\n");
302 "Channel groups with differing sample rates are not currently supported.\n");
312 "Sampling rate %d is greater than the supported maximum (%d).\n",
318 "Block size %d is greater than the supported maximum (%d).\n",
324 "Block size pow2 %d is greater than the supported maximum (%d).\n",
337 "Number of substreams %d is larger than the maximum supported "
387 const uint8_t *buf,
unsigned int substr)
401 if (sync_word != 0x31ea >> 1) {
403 "restart header sync incorrect (got 0x%04x)\n", sync_word);
422 "Max matrix channel cannot be greater than %d.\n",
429 "Max channel must be equal max matrix channel.\n");
437 "Number of channels %d is larger than the maximum supported "
444 "Substream min channel cannot be greater than max channel.\n");
448 if (m->
avctx->request_channels > 0
450 && substr < m->max_decoded_substream) {
452 "Extracting %d channel downmix from substream %d. "
453 "Further substreams will be skipped.\n",
468 if (tmp != lossless_check)
470 "Lossless check failed - expected %02x, calculated %02x.\n",
471 lossless_check, tmp);
488 "Assignment of matrix channel %d to invalid output channel %d.\n",
509 for (ch = s->
min_channel; ch <= s->max_channel; ch++) {
534 unsigned int substr,
unsigned int channel,
540 const char fchar = filter ?
'I' :
'F';
552 if (order > max_order) {
554 "%cIR filter order %d is greater than maximum %d.\n",
555 fchar, order, max_order);
562 int coeff_bits, coeff_shift;
568 if (coeff_bits < 1 || coeff_bits > 16) {
570 "%cIR filter coeff_bits must be between 1 and 16.\n",
574 if (coeff_bits + coeff_shift > 16) {
576 "Sum of coeff_bits and coeff_shift for %cIR filter must be 16 or less.\n",
581 for (i = 0; i < order; i++)
582 fcoeff[i] =
get_sbits(gbp, coeff_bits) << coeff_shift;
585 int state_bits, state_shift;
589 "FIR filter has state data specified.\n");
598 for (i = 0; i < order; i++)
611 unsigned int mat, ch;
625 "Number of primitive matrices cannot be greater than %d.\n",
626 max_primitive_matrices);
631 int frac_bits, max_chan;
638 "Invalid channel %d specified as output from matrix.\n",
642 if (frac_bits > 14) {
644 "Too many fractional bits specified.\n");
652 for (ch = 0; ch <= max_chan; ch++) {
655 coeff_val =
get_sbits(gbp, frac_bits + 2);
657 s->
matrix_coeff[mat][ch] = coeff_val << (14 - frac_bits);
698 "FIR and IIR filters must use the same precision.\n");
770 for (ch = s->
min_channel; ch <= s->max_channel; ch++)
778 #define MSB_MASK(bits) (-1u << bits)
784 unsigned int channel)
793 unsigned int filter_shift = fir->
shift;
814 unsigned int i, ch, expected_stream_pos = 0;
819 expected_stream_pos +=
get_bits(gbp, 16);
821 "we have not tested yet.\n");
836 for (ch = s->
min_channel; ch <= s->max_channel; ch++)
853 30, 51, 22, 54, 3, 7, -4, 38, 14, 55, 46, 81, 22, 58, -3, 2,
854 52, 31, -7, 51, 15, 44, 74, 30, 85, -17, 10, 33, 18, 80, 28, 62,
855 10, 32, 23, 69, 72, 26, 35, 17, 73, 60, 8, 56, 2, 6, -2, -5,
856 51, 4, 11, 50, 66, 76, 21, 44, 33, 47, 1, 26, 64, 48, 57, 40,
857 38, 16, -10, -28, 92, 22, -18, 29, -10, 5, -13, 49, 19, 24, 70, 34,
858 61, 48, 30, 14, -6, 25, 58, 33, 42, 60, 67, 17, 54, 17, 22, 30,
859 67, 44, -9, 50, -11, 43, 40, 32, 59, 82, 13, 49, -14, 55, 60, 36,
860 48, 49, 31, 47, 15, 12, 4, 65, 1, 23, 29, 39, 45, -2, 84, 69,
861 0, 72, 37, 57, 27, 41, -15, -16, 35, 31, 14, 61, 24, 0, 27, 24,
862 16, 41, 55, 34, 53, 9, 56, 12, 25, 29, 53, 5, 20, -20, -8, 20,
863 13, 28, -3, 78, 38, 16, 11, 62, 46, 29, 21, 24, 46, 65, 43, -23,
864 89, 18, 74, 21, 38, -12, 19, 12, -19, 8, 15, 33, 4, 57, 9, -8,
865 36, 35, 26, 28, 7, 83, 63, 79, 75, 11, 3, 87, 37, 47, 34, 40,
866 39, 19, 20, 42, 27, 34, 39, 77, 13, 42, 59, 64, 45, -1, 32, 37,
867 45, -5, 53, -6, 7, 36, 50, 23, 6, 32, 9, -21, 18, 71, 27, 52,
868 -25, 31, 35, 42, -1, 68, 63, 52, 26, 43, 66, 37, 41, 25, 40, 70,
889 uint16_t seed_shr7 = seed >> 7;
893 seed = (seed << 16) ^ seed_shr7 ^ (seed_shr7 << 5);
908 uint8_t seed_shr15 = seed >> 15;
910 seed = (seed << 8) ^ seed_shr15 ^ (seed_shr15 << 5);
923 unsigned int mat, src_ch, i;
924 unsigned int maxchan;
940 int index2 = 2 * index + 1;
949 for (src_ch = 0; src_ch <= maxchan; src_ch++)
950 accum += (int64_t) samples[src_ch] * coeffs[src_ch];
952 if (matrix_noise_shift) {
958 samples[dest_ch] = ((accum >> 14) & mask) + bypassed_lsb;
966 void *
data,
int *got_frame_ptr)
970 unsigned int i, out_ch = 0;
1001 if (is32) *data_32++ = sample << 8;
1002 else *data_16++ = sample >> 8;
1017 int *got_frame_ptr,
AVPacket *avpkt)
1020 int buf_size = avpkt->
size;
1023 unsigned int length, substr;
1024 unsigned int substream_start;
1025 unsigned int header_size = 4;
1026 unsigned int substr_header_size = 0;
1035 length = (
AV_RB16(buf) & 0xfff) * 2;
1037 if (length < 4 || length > buf_size)
1052 "Stream parameters not seen; skipping frame.\n");
1057 substream_start = 0;
1060 int extraword_present, checkdata_present, end, nonrestart_substr;
1069 substr_header_size += 2;
1071 if (extraword_present) {
1077 substr_header_size += 2;
1085 if (end + header_size + substr_header_size > length) {
1087 "Indicated length of substream %d data goes off end of "
1088 "packet.\n", substr);
1089 end = length - header_size - substr_header_size;
1092 if (end < substream_start) {
1094 "Indicated end offset of substream %d data "
1095 "is smaller than calculated start offset.\n",
1103 substream_parity_present[substr] = checkdata_present;
1104 substream_data_len[substr] = end - substream_start;
1105 substream_start = end;
1111 if ((((parity_bits >> 4) ^ parity_bits) & 0xF) != 0xF) {
1116 buf += header_size + substr_header_size;
1148 goto substream_length_mismatch;
1154 if (substream_data_len[substr] * 8 -
get_bits_count(&gb) >= 32) {
1170 if (substream_parity_present[substr]) {
1174 goto substream_length_mismatch;
1179 if ((
get_bits(&gb, 8) ^ parity) != 0xa9 )
1186 goto substream_length_mismatch;
1191 "No restart header present in substream %d.\n", substr);
1193 buf += substream_data_len[substr];
1203 substream_length_mismatch:
1223 #if CONFIG_TRUEHD_DECODER
1231 .capabilities = CODEC_CAP_DR1,