79 #define PARAM_BLOCKSIZE (1 << 7)
80 #define PARAM_MATRIX (1 << 6)
81 #define PARAM_OUTSHIFT (1 << 5)
82 #define PARAM_QUANTSTEP (1 << 4)
83 #define PARAM_FIR (1 << 3)
84 #define PARAM_IIR (1 << 2)
85 #define PARAM_HUFFOFFSET (1 << 1)
86 #define PARAM_PRESENCE (1 << 0)
190 if (!huff_vlc[0].
bits) {
206 unsigned int substr,
unsigned int ch)
215 sign_huff_offset -= 7 << lsb_bits;
218 sign_huff_offset -= 1 << sign_shift;
220 return sign_huff_offset;
227 unsigned int substr,
unsigned int pos)
230 unsigned int mat, channel;
236 for (channel = s->
min_channel; channel <= s->max_channel; channel++) {
240 int lsb_bits = cp->
huff_lsbs - quant_step_size;
244 result =
get_vlc2(gbp, huff_vlc[codebook-1].table,
251 result = (result << lsb_bits) +
get_bits(gbp, lsb_bits);
254 result <<= quant_step_size;
295 "Channel group 2 cannot have more bits per sample than group 1.\n");
301 "Channel groups with differing sample rates are not currently supported.\n");
311 "Sampling rate %d is greater than the supported maximum (%d).\n",
317 "Block size %d is greater than the supported maximum (%d).\n",
323 "Block size pow2 %d is greater than the supported maximum (%d).\n",
336 "%d substreams (more than the "
337 "maximum supported by the decoder)",
427 const uint8_t *buf,
unsigned int substr)
435 int min_channel, max_channel, max_matrix_channel;
442 if (sync_word != 0x31ea >> 1) {
444 "restart header sync incorrect (got 0x%04x)\n", sync_word);
459 max_matrix_channel =
get_bits(gbp, 4);
461 if (max_matrix_channel > std_max_matrix_channel) {
463 "Max matrix channel cannot be greater than %d.\n",
468 if (max_channel != max_matrix_channel) {
470 "Max channel must be equal max matrix channel.\n");
478 "%d channels (more than the "
479 "maximum supported by the decoder)",
484 if (min_channel > max_channel) {
486 "Substream min channel cannot be greater than max channel.\n");
494 #if FF_API_REQUEST_CHANNELS
500 "Extracting %d-channel downmix from substream %d. "
501 "Further substreams will be skipped.\n",
510 "Extracting %d-channel downmix (0x%"PRIx64
") from substream %d. "
511 "Further substreams will be skipped.\n",
526 if (tmp != lossless_check)
528 "Lossless check failed - expected %02x, calculated %02x.\n",
529 lossless_check, tmp);
546 "Assignment of matrix channel %d to invalid output channel %d",
567 for (ch = s->
min_channel; ch <= s->max_channel; ch++) {
592 unsigned int substr,
unsigned int channel,
598 const char fchar = filter ?
'I' :
'F';
610 if (order > max_order) {
612 "%cIR filter order %d is greater than maximum %d.\n",
613 fchar, order, max_order);
620 int coeff_bits, coeff_shift;
626 if (coeff_bits < 1 || coeff_bits > 16) {
628 "%cIR filter coeff_bits must be between 1 and 16.\n",
632 if (coeff_bits + coeff_shift > 16) {
634 "Sum of coeff_bits and coeff_shift for %cIR filter must be 16 or less.\n",
639 for (i = 0; i < order; i++)
640 fcoeff[i] =
get_sbits(gbp, coeff_bits) << coeff_shift;
643 int state_bits, state_shift;
647 "FIR filter has state data specified.\n");
656 for (i = 0; i < order; i++)
669 unsigned int mat, ch;
683 "Number of primitive matrices cannot be greater than %d.\n",
684 max_primitive_matrices);
689 int frac_bits, max_chan;
696 "Invalid channel %d specified as output from matrix.\n",
700 if (frac_bits > 14) {
702 "Too many fractional bits specified.\n");
710 for (ch = 0; ch <= max_chan; ch++) {
713 coeff_val =
get_sbits(gbp, frac_bits + 2);
715 s->
matrix_coeff[mat][ch] = coeff_val << (14 - frac_bits);
756 "FIR and IIR filters must use the same precision.\n");
828 for (ch = s->
min_channel; ch <= s->max_channel; ch++)
836 #define MSB_MASK(bits) (-1u << bits)
842 unsigned int channel)
851 unsigned int filter_shift = fir->
shift;
872 unsigned int i, ch, expected_stream_pos = 0;
877 expected_stream_pos +=
get_bits(gbp, 16);
879 "Substreams with VLC block size check info");
894 for (ch = s->
min_channel; ch <= s->max_channel; ch++)
911 30, 51, 22, 54, 3, 7, -4, 38, 14, 55, 46, 81, 22, 58, -3, 2,
912 52, 31, -7, 51, 15, 44, 74, 30, 85, -17, 10, 33, 18, 80, 28, 62,
913 10, 32, 23, 69, 72, 26, 35, 17, 73, 60, 8, 56, 2, 6, -2, -5,
914 51, 4, 11, 50, 66, 76, 21, 44, 33, 47, 1, 26, 64, 48, 57, 40,
915 38, 16, -10, -28, 92, 22, -18, 29, -10, 5, -13, 49, 19, 24, 70, 34,
916 61, 48, 30, 14, -6, 25, 58, 33, 42, 60, 67, 17, 54, 17, 22, 30,
917 67, 44, -9, 50, -11, 43, 40, 32, 59, 82, 13, 49, -14, 55, 60, 36,
918 48, 49, 31, 47, 15, 12, 4, 65, 1, 23, 29, 39, 45, -2, 84, 69,
919 0, 72, 37, 57, 27, 41, -15, -16, 35, 31, 14, 61, 24, 0, 27, 24,
920 16, 41, 55, 34, 53, 9, 56, 12, 25, 29, 53, 5, 20, -20, -8, 20,
921 13, 28, -3, 78, 38, 16, 11, 62, 46, 29, 21, 24, 46, 65, 43, -23,
922 89, 18, 74, 21, 38, -12, 19, 12, -19, 8, 15, 33, 4, 57, 9, -8,
923 36, 35, 26, 28, 7, 83, 63, 79, 75, 11, 3, 87, 37, 47, 34, 40,
924 39, 19, 20, 42, 27, 34, 39, 77, 13, 42, 59, 64, 45, -1, 32, 37,
925 45, -5, 53, -6, 7, 36, 50, 23, 6, 32, 9, -21, 18, 71, 27, 52,
926 -25, 31, 35, 42, -1, 68, 63, 52, 26, 43, 66, 37, 41, 25, 40, 70,
947 uint16_t seed_shr7 = seed >> 7;
951 seed = (seed << 16) ^ seed_shr7 ^ (seed_shr7 << 5);
966 uint8_t seed_shr15 = seed >> 15;
968 seed = (seed << 8) ^ seed_shr15 ^ (seed_shr15 << 5);
981 unsigned int mat, src_ch, i;
982 unsigned int maxchan;
998 int index2 = 2 * index + 1;
1002 for (i = 0; i < s->
blockpos; i++) {
1007 for (src_ch = 0; src_ch <= maxchan; src_ch++)
1008 accum += (int64_t) samples[src_ch] * coeffs[src_ch];
1010 if (matrix_noise_shift) {
1016 samples[dest_ch] = ((accum >> 14) & mask) + bypassed_lsb;
1024 AVFrame *frame,
int *got_frame_ptr)
1028 unsigned int i, out_ch = 0;
1051 data_16 = (int16_t *)frame->
data[0];
1053 for (i = 0; i < s->
blockpos; i++) {
1059 if (is32) *data_32++ = sample << 8;
1060 else *data_16++ = sample >> 8;
1078 int *got_frame_ptr,
AVPacket *avpkt)
1081 int buf_size = avpkt->
size;
1084 unsigned int length, substr;
1085 unsigned int substream_start;
1086 unsigned int header_size = 4;
1087 unsigned int substr_header_size = 0;
1096 length = (
AV_RB16(buf) & 0xfff) * 2;
1098 if (length < 4 || length > buf_size)
1113 "Stream parameters not seen; skipping frame.\n");
1118 substream_start = 0;
1121 int extraword_present, checkdata_present, end, nonrestart_substr;
1130 substr_header_size += 2;
1132 if (extraword_present) {
1138 substr_header_size += 2;
1146 if (end + header_size + substr_header_size > length) {
1148 "Indicated length of substream %d data goes off end of "
1149 "packet.\n", substr);
1150 end = length - header_size - substr_header_size;
1153 if (end < substream_start) {
1155 "Indicated end offset of substream %d data "
1156 "is smaller than calculated start offset.\n",
1164 substream_parity_present[substr] = checkdata_present;
1165 substream_data_len[substr] = end - substream_start;
1166 substream_start = end;
1172 if ((((parity_bits >> 4) ^ parity_bits) & 0xF) != 0xF) {
1177 buf += header_size + substr_header_size;
1209 goto substream_length_mismatch;
1215 if (substream_data_len[substr] * 8 -
get_bits_count(&gb) >= 32) {
1231 if (substream_parity_present[substr]) {
1235 goto substream_length_mismatch;
1240 if ((
get_bits(&gb, 8) ^ parity) != 0xa9 )
1247 goto substream_length_mismatch;
1252 "No restart header present in substream %d.\n", substr);
1254 buf += substream_data_len[substr];
1264 substream_length_mismatch:
1284 #if CONFIG_TRUEHD_DECODER