45 #define VLC_STATIC_SIZE 64
48 #define VLC_STATIC_SIZE 512
86 #define PARAM_BLOCKSIZE (1 << 7)
87 #define PARAM_MATRIX (1 << 6)
88 #define PARAM_OUTSHIFT (1 << 5)
89 #define PARAM_QUANTSTEP (1 << 4)
90 #define PARAM_FIR (1 << 3)
91 #define PARAM_IIR (1 << 2)
92 #define PARAM_HUFFOFFSET (1 << 1)
93 #define PARAM_PRESENCE (1 << 0)
200 if (!huff_vlc[0].
bits) {
216 unsigned int substr,
unsigned int ch)
225 sign_huff_offset -= 7 << lsb_bits;
228 sign_huff_offset -= 1 << sign_shift;
230 return sign_huff_offset;
237 unsigned int substr,
unsigned int pos)
240 unsigned int mat, channel;
246 for (channel = s->
min_channel; channel <= s->max_channel; channel++) {
250 int lsb_bits = cp->
huff_lsbs - quant_step_size;
261 result = (result << lsb_bits) +
get_bits(gbp, lsb_bits);
264 result <<= quant_step_size;
305 "Channel group 2 cannot have more bits per sample than group 1.\n");
311 "Channel groups with differing sample rates are not currently supported.\n");
321 "Sampling rate %d is greater than the supported maximum (%d).\n",
327 "Block size %d is greater than the supported maximum (%d).\n",
333 "Block size pow2 %d is greater than the supported maximum (%d).\n",
346 "%d substreams (more than the "
347 "maximum supported by the decoder)",
381 "unexpected stream_type %X in MLP",
391 "unexpected stream_type %X in !MLP",
470 int min_channel, max_channel, max_matrix_channel;
477 if (sync_word != 0x31ea >> 1) {
479 "restart header sync incorrect (got 0x%04x)\n", sync_word);
494 max_matrix_channel =
get_bits(gbp, 4);
496 if (max_matrix_channel > std_max_matrix_channel) {
498 "Max matrix channel cannot be greater than %d.\n",
499 std_max_matrix_channel);
503 if (max_channel != max_matrix_channel) {
505 "Max channel must be equal max matrix channel.\n");
513 "%d channels (more than the "
514 "maximum supported by the decoder)",
519 if (min_channel > max_channel) {
521 "Substream min channel cannot be greater than max channel.\n");
529 #if FF_API_REQUEST_CHANNELS
535 "Extracting %d-channel downmix from substream %d. "
536 "Further substreams will be skipped.\n",
545 "Extracting %d-channel downmix (0x%"PRIx64
") from substream %d. "
546 "Further substreams will be skipped.\n",
561 if (tmp != lossless_check)
563 "Lossless check failed - expected %02x, calculated %02x.\n",
564 lossless_check, tmp);
581 "Assignment of matrix channel %d to invalid output channel %d",
602 for (ch = s->
min_channel; ch <= s->max_channel; ch++) {
645 unsigned int substr,
unsigned int channel,
651 const char fchar = filter ?
'I' :
'F';
663 if (order > max_order) {
665 "%cIR filter order %d is greater than maximum %d.\n",
666 fchar, order, max_order);
673 int coeff_bits, coeff_shift;
679 if (coeff_bits < 1 || coeff_bits > 16) {
681 "%cIR filter coeff_bits must be between 1 and 16.\n",
685 if (coeff_bits + coeff_shift > 16) {
687 "Sum of coeff_bits and coeff_shift for %cIR filter must be 16 or less.\n",
692 for (i = 0; i < order; i++)
693 fcoeff[i] =
get_sbits(gbp, coeff_bits) << coeff_shift;
696 int state_bits, state_shift;
700 "FIR filter has state data specified.\n");
709 for (i = 0; i < order; i++)
710 fp->
state[i] = state_bits ?
get_sbits(gbp, state_bits) << state_shift : 0;
722 unsigned int mat, ch;
736 "Number of primitive matrices cannot be greater than %d.\n",
737 max_primitive_matrices);
742 int frac_bits, max_chan;
749 "Invalid channel %d specified as output from matrix.\n",
753 if (frac_bits > 14) {
755 "Too many fractional bits specified.\n");
763 for (ch = 0; ch <= max_chan; ch++) {
766 coeff_val =
get_sbits(gbp, frac_bits + 2);
768 s->
matrix_coeff[mat][ch] = coeff_val << (14 - frac_bits);
809 "FIR and IIR filters must use the same precision.\n");
888 for (ch = s->
min_channel; ch <= s->max_channel; ch++)
896 #define MSB_MASK(bits) (-1u << (bits))
902 unsigned int channel)
911 unsigned int filter_shift = fir->
shift;
932 unsigned int i, ch, expected_stream_pos = 0;
937 expected_stream_pos +=
get_bits(gbp, 16);
939 "Substreams with VLC block size check info");
954 for (ch = s->
min_channel; ch <= s->max_channel; ch++)
971 30, 51, 22, 54, 3, 7, -4, 38, 14, 55, 46, 81, 22, 58, -3, 2,
972 52, 31, -7, 51, 15, 44, 74, 30, 85, -17, 10, 33, 18, 80, 28, 62,
973 10, 32, 23, 69, 72, 26, 35, 17, 73, 60, 8, 56, 2, 6, -2, -5,
974 51, 4, 11, 50, 66, 76, 21, 44, 33, 47, 1, 26, 64, 48, 57, 40,
975 38, 16, -10, -28, 92, 22, -18, 29, -10, 5, -13, 49, 19, 24, 70, 34,
976 61, 48, 30, 14, -6, 25, 58, 33, 42, 60, 67, 17, 54, 17, 22, 30,
977 67, 44, -9, 50, -11, 43, 40, 32, 59, 82, 13, 49, -14, 55, 60, 36,
978 48, 49, 31, 47, 15, 12, 4, 65, 1, 23, 29, 39, 45, -2, 84, 69,
979 0, 72, 37, 57, 27, 41, -15, -16, 35, 31, 14, 61, 24, 0, 27, 24,
980 16, 41, 55, 34, 53, 9, 56, 12, 25, 29, 53, 5, 20, -20, -8, 20,
981 13, 28, -3, 78, 38, 16, 11, 62, 46, 29, 21, 24, 46, 65, 43, -23,
982 89, 18, 74, 21, 38, -12, 19, 12, -19, 8, 15, 33, 4, 57, 9, -8,
983 36, 35, 26, 28, 7, 83, 63, 79, 75, 11, 3, 87, 37, 47, 34, 40,
984 39, 19, 20, 42, 27, 34, 39, 77, 13, 42, 59, 64, 45, -1, 32, 37,
985 45, -5, 53, -6, 7, 36, 50, 23, 6, 32, 9, -21, 18, 71, 27, 52,
986 -25, 31, 35, 42, -1, 68, 63, 52, 26, 43, 66, 37, 41, 25, 40, 70,
1006 for (i = 0; i < s->
blockpos; i++) {
1007 uint16_t seed_shr7 = seed >> 7;
1011 seed = (seed << 16) ^ seed_shr7 ^ (seed_shr7 << 5);
1026 uint8_t seed_shr15 = seed >> 15;
1028 seed = (seed << 8) ^ seed_shr15 ^ (seed_shr15 << 5);
1042 unsigned int maxchan;
1115 int *got_frame_ptr,
AVPacket *avpkt)
1118 int buf_size = avpkt->
size;
1121 unsigned int length, substr;
1122 unsigned int substream_start;
1123 unsigned int header_size = 4;
1124 unsigned int substr_header_size = 0;
1133 length = (
AV_RB16(buf) & 0xfff) * 2;
1150 "Stream parameters not seen; skipping frame.\n");
1155 substream_start = 0;
1158 int extraword_present, checkdata_present,
end, nonrestart_substr;
1167 substr_header_size += 2;
1169 if (extraword_present) {
1175 substr_header_size += 2;
1183 if (end + header_size + substr_header_size > length) {
1185 "Indicated length of substream %d data goes off end of "
1186 "packet.\n", substr);
1187 end = length - header_size - substr_header_size;
1190 if (end < substream_start) {
1192 "Indicated end offset of substream %d data "
1193 "is smaller than calculated start offset.\n",
1201 substream_parity_present[substr] = checkdata_present;
1202 substream_data_len[substr] = end - substream_start;
1203 substream_start =
end;
1209 if ((((parity_bits >> 4) ^ parity_bits) & 0xF) != 0xF) {
1214 buf += header_size + substr_header_size;
1246 goto substream_length_mismatch;
1252 if (substream_data_len[substr] * 8 -
get_bits_count(&gb) >= 32) {
1268 if (substream_parity_present[substr]) {
1272 goto substream_length_mismatch;
1277 if ((
get_bits(&gb, 8) ^ parity) != 0xa9 )
1284 goto substream_length_mismatch;
1289 "No restart header present in substream %d.\n", substr);
1291 buf += substream_data_len[substr];
1301 substream_length_mismatch:
1310 #if CONFIG_MLP_DECODER
1322 #if CONFIG_TRUEHD_DECODER