1 /*
2 * MLP decoder
3 * Copyright (c) 2007-2008 Ian Caulfield
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 /**
23 * @file
24 * MLP decoder
25 */
26
27 #include "config_components.h"
28
29 #include <stdint.h>
30
45 #include "config.h"
47
48 /** number of bits used for VLC lookup - longest Huffman code is 9 */
49 #if ARCH_ARM
50 #define VLC_BITS 5
51 #define VLC_STATIC_SIZE 64
52 #else
54 #define VLC_STATIC_SIZE 512
55 #endif
56
58 /// Set if a valid restart header has been read. Otherwise the substream cannot be decoded.
60 /// Set if end of stream is encountered
62
63 //@{
64 /** restart header data */
65 /// The type of noise to be used in the rematrix stage.
67
68 /// The index of the first channel coded in this substream.
70 /// The index of the last channel coded in this substream.
72 /// The coded channels mask in this substream.
74 /// The number of channels input into the rematrix stage.
76 /// For each channel output by the matrix, the output channel to map it to
78 /// The channel layout for this substream
80 /// The matrix encoding mode for this substream
83
84 /// Channel coding parameters for channels in the substream
86
87 /// The left shift applied to random noise in 0x31ea substreams.
89 /// The current seed value for the pseudorandom noise generator(s).
91
92 /// Set if the substream contains extra info to check the size of VLC blocks.
94
95 /// Bitmask of which parameter sets are conveyed in a decoding parameter block.
97 //@}
98
99 //@{
100 /** matrix data */
101
102 /// Number of matrices to be applied.
104
105 /// matrix output channel
107
108 /// Whether the LSBs of the matrix output are encoded in the bitstream.
110 /// Matrix coefficients, stored as 2.14 fixed point.
112 /// Left shift to apply to noise values in 0x31eb substreams.
114 //@}
115
116 /// Left shift to apply to Huffman-decoded residuals.
118
119 /// number of PCM samples in current audio block
121 /// Number of PCM samples decoded so far in this frame.
123
124 /// Left shift to apply to decoded PCM values to get final 24-bit output.
126
127 /// Running XOR of all output samples.
129
131
135
137
138 /// Current access unit being read has a major sync.
140
141 /// Size of the major sync unit, in bytes
143
144 /// Set if a valid major sync block has been read. Otherwise no decoding is possible.
146
147 /// Number of substreams contained within this stream.
149
150 /// Which substream of substreams carry 16-channel presentation
152
153 /// Which substream of substreams carry 2/6/8-channel presentation
155
156 /// Index of the last substream to decode - further substreams are skipped.
158
159 /// Stream needs channel reordering to comply with FFmpeg's channel order
161
162 /// number of PCM samples contained in each frame
164 /// next power of two above the number of samples in each frame
166
168
171
175
178 uint16_t blockpos,
181 uint8_t *ch_assign,
182 int8_t *output_shift,
183 uint8_t max_matrix_channel,
184 int is32);
186
201 };
202
204 {
208 }
209
212 {
214
217
222 }
223
225
226 /** Initialize static data, constant between all invocations of the codec. */
227
229 {
230 for (
int i = 0;
i < 3;
i++) {
237 }
238
240 }
241
243 unsigned int substr, unsigned int ch)
244 {
247 int lsb_bits = cp->
huff_lsbs -
s->quant_step_size[ch];
250
252 sign_huff_offset -= 7 << lsb_bits;
253
254 if (sign_shift >= 0)
255 sign_huff_offset -= 1 << sign_shift;
256
257 return sign_huff_offset;
258 }
259
260 /** Read a sample, consisting of either, both or neither of entropy-coded MSBs
261 * and plain LSBs. */
262
264 unsigned int substr,
unsigned int pos)
265 {
268
269 for (mat = 0; mat <
s->num_primitive_matrices; mat++)
270 if (
s->lsb_bypass[mat])
272
279
283
286
287 if (lsb_bits > 0)
289
292
294 }
295
296 return 0;
297 }
298
300 {
303 int substr;
304
309
321 }
322 else {
325 }
326 }
327
329
330 return 0;
331 }
332
333 /** Read a major sync info header - contains high level information about
334 * the stream - sample rate, channel arrangement etc. Most of this
335 * information is not actually necessary for decoding, only for playback.
336 */
337
339 {
342
345
346 if (
mh.group1_bits == 0) {
349 }
350 if (
mh.group2_bits >
mh.group1_bits) {
352 "Channel group 2 cannot have more bits per sample than group 1.\n");
354 }
355
356 if (
mh.group2_samplerate &&
mh.group2_samplerate !=
mh.group1_samplerate) {
358 "Channel groups with differing sample rates are not currently supported.\n");
360 }
361
362 if (
mh.group1_samplerate == 0) {
365 }
368 "Sampling rate %d is greater than the supported maximum (%d).\n",
371 }
374 "Block size %d is greater than the supported maximum (%d).\n",
377 }
380 "Block size pow2 %d is greater than the supported maximum (%d).\n",
383 }
384
385 if (
mh.num_substreams == 0)
390 }
393 "%d substreams (more than the "
394 "maximum supported by the decoder)",
397 }
398
400
403
407
408 /* If there is a 4th substream and the MSB of substream_info is set,
409 * there is a 16-channel spatial presentation (Atmos in TrueHD).
410 */
414 }
415
416 /* limit to decoding 3 substreams, as the 4th is used by Dolby Atmos for non-audio data */
418
421
423 if (
mh.group1_bits > 16)
425 else
431
435
436 /* Set the layout for each substream. When there's more than one, the first
437 * substream is Stereo. Subsequent substreams' layouts are indicated in the
438 * major sync. */
442 "unexpected stream_type %X in MLP",
445 }
446 if ((substr = (
mh.num_substreams > 1)))
449 } else {
452 "unexpected stream_type %X in !MLP",
455 }
457 if (
mh.channels_thd_stream1 == 2 &&
458 mh.channels_thd_stream2 == 2)
460 if ((substr = (
mh.num_substreams > 1)))
462 if (
mh.num_substreams == 1 &&
463 mh.channels_thd_stream1 == 1 &&
464 mh.channels_thd_stream2 == 1)
466 if (
mh.num_substreams > 2)
467 if (
mh.channel_layout_thd_stream2)
469 else
474 }
475
477
478 /* Parse the TrueHD decoder channel modifiers and set each substream's
479 * AVMatrixEncoding accordingly.
480 *
481 * The meaning of the modifiers depends on the channel layout:
482 *
483 * - THD_CH_MODIFIER_LTRT, THD_CH_MODIFIER_LBINRBIN only apply to 2-channel
484 *
485 * - THD_CH_MODIFIER_MONO applies to 1-channel or 2-channel (dual mono)
486 *
487 * - THD_CH_MODIFIER_SURROUNDEX, THD_CH_MODIFIER_NOTSURROUNDEX only apply to
488 * layouts with an Ls/Rs channel pair
489 */
493 if (
mh.num_substreams > 2 &&
498
499 if (
mh.num_substreams > 1 &&
504
505 if (
mh.num_substreams > 0)
506 switch (
mh.channel_modifier_thd_stream0) {
509 break;
512 break;
513 default:
514 break;
515 }
516 }
517
518 return 0;
519 }
520
521 /** Read a restart header from a block in a substream. This contains parameters
522 * required to decode the audio that do not change very often. Generally
523 * (always) present only in blocks following a major sync. */
524
526 const uint8_t *buf, unsigned int substr)
527 {
529 unsigned int ch;
531 uint8_t checksum;
532 uint8_t lossless_check;
534 int min_channel, max_channel, max_matrix_channel, noise_type;
538
540
541 if (sync_word != 0x31ea >> 1) {
543 "restart header sync incorrect (got 0x%04x)\n", sync_word);
545 }
546
548
552 }
553
554 skip_bits(gbp, 16);
/* Output timestamp */
555
558 max_matrix_channel =
get_bits(gbp, 4);
559
560 if (max_matrix_channel > std_max_matrix_channel) {
562 "Max matrix channel cannot be greater than %d.\n",
563 std_max_matrix_channel);
565 }
566
567 /* This should happen for TrueHD streams with >6 channels and MLP's noise
568 * type. It is not yet known if this is allowed. */
571 "%d channels (more than the "
572 "maximum supported by the decoder)",
573 max_channel + 2);
575 }
576
577 if (max_channel + 1 >
MAX_CHANNELS || max_channel + 1 < min_channel)
579
580 s->min_channel = min_channel;
581 s->max_channel = max_channel;
582 s->coded_channels = ((1LL << (max_channel - min_channel + 1)) - 1) << min_channel;
583 s->max_matrix_channel = max_matrix_channel;
584 s->noise_type = noise_type;
585
589 "Extracting %d-channel downmix (0x%"PRIx64") from substream %d. "
590 "Further substreams will be skipped.\n",
591 s->max_channel + 1,
s->mask, substr);
593 }
594
597
599
603 &&
s->lossless_check_data != 0xffffffff) {
605 if (
tmp != lossless_check)
607 "Lossless check failed - expected %02x, calculated %02x.\n",
608 lossless_check,
tmp);
609 }
610
612
613 memset(
s->ch_assign, 0,
sizeof(
s->ch_assign));
614
615 for (ch = 0; ch <=
s->max_matrix_channel; ch++) {
620
623 }
624 if (ch_assign < 0 || ch_assign >
s->max_matrix_channel) {
626 "Assignment of matrix channel %d to invalid output channel %d",
627 ch, ch_assign);
629 }
630 s->ch_assign[ch_assign] = ch;
631 }
632
634
637
638 /* Set default decoding parameters. */
639 s->param_presence_flags = 0xff;
640 s->num_primitive_matrices = 0;
642 s->lossless_check_data = 0;
643
644 memset(
s->output_shift , 0,
sizeof(
s->output_shift ));
645 memset(
s->quant_step_size, 0,
sizeof(
s->quant_step_size));
646
647 for (ch =
s->min_channel; ch <= s->max_channel; ch++) {
653
654 /* Default audio coding is 24-bit raw PCM. */
659 }
660
666 s->max_matrix_channel,
668
672 int i =
s->ch_assign[4];
673 s->ch_assign[4] =
s->ch_assign[3];
674 s->ch_assign[3] =
s->ch_assign[2];
677 FFSWAP(
int,
s->ch_assign[2],
s->ch_assign[4]);
678 FFSWAP(
int,
s->ch_assign[3],
s->ch_assign[5]);
679 }
680 }
681
682 }
683
684 return 0;
685 }
686
687 /** Read parameters for one of the prediction filters. */
688
690 unsigned int substr,
unsigned int channel,
692 {
696 const char fchar =
filter ?
'I' :
'F';
698
699 // Filter is 0 for FIR, 1 for IIR.
701
705 }
706
708 if (order > max_order) {
710 "%cIR filter order %d is greater than maximum %d.\n",
711 fchar, order, max_order);
713 }
715
716 if (order > 0) {
718 int coeff_bits, coeff_shift;
719
721
724 if (coeff_bits < 1 || coeff_bits > 16) {
726 "%cIR filter coeff_bits must be between 1 and 16.\n",
727 fchar);
729 }
730 if (coeff_bits + coeff_shift > 16) {
732 "Sum of coeff_bits and coeff_shift for %cIR filter must be 16 or less.\n",
733 fchar);
735 }
736
737 for (
i = 0;
i < order;
i++)
738 fcoeff[
i] =
get_sbits(gbp, coeff_bits) * (1 << coeff_shift);
739
741 int state_bits, state_shift;
742
745 "FIR filter has state data specified.\n");
747 }
748
751
752 /* TODO: Check validity of state data. */
753
754 for (
i = 0;
i < order;
i++)
755 fp->
state[
i] = state_bits ?
get_sbits(gbp, state_bits) * (1 << state_shift) : 0;
756 }
757 }
758
759 return 0;
760 }
761
762 /** Read parameters for primitive matrices. */
763
765 {
767 unsigned int mat, ch;
771
775 }
776
777 s->num_primitive_matrices =
get_bits(gbp, 4);
778
779 if (
s->num_primitive_matrices > max_primitive_matrices) {
781 "Number of primitive matrices cannot be greater than %d.\n",
782 max_primitive_matrices);
784 }
785
786 for (mat = 0; mat <
s->num_primitive_matrices; mat++) {
787 int frac_bits, max_chan;
788 s->matrix_out_ch[mat] =
get_bits(gbp, 4);
791
792 if (
s->matrix_out_ch[mat] >
s->max_matrix_channel) {
794 "Invalid channel %d specified as output from matrix.\n",
795 s->matrix_out_ch[mat]);
797 }
798 if (frac_bits > 14) {
800 "Too many fractional bits specified.\n");
802 }
803
804 max_chan =
s->max_matrix_channel;
806 max_chan+=2;
807
808 for (ch = 0; ch <= max_chan; ch++) {
809 int coeff_val = 0;
811 coeff_val =
get_sbits(gbp, frac_bits + 2);
812
813 s->matrix_coeff[mat][ch] = coeff_val * (1 << (14 - frac_bits));
814 }
815
817 s->matrix_noise_shift[mat] =
get_bits(gbp, 4);
818 else
819 s->matrix_noise_shift[mat] = 0;
820 }
821
822 return 0;
824 s->num_primitive_matrices = 0;
825 memset(
s->matrix_out_ch, 0,
sizeof(
s->matrix_out_ch));
826
828 }
829
830 /** Read channel parameters. */
831
834 {
840
845
850
854 }
855
859 "FIR and IIR filters must use the same precision.\n");
861 }
862 /* The FIR and IIR filters must have the same precision.
863 * To simplify the filtering code, only the precision of the
864 * FIR filter is considered. If only the IIR filter is employed,
865 * the FIR filter precision is set to that of the IIR filter, so
866 * that the filtering code can use it. */
869
873
876
881 }
882
883 return 0;
884 }
885
886 /** Read decoding parameters that change more often than those in the restart
887 * header. */
888
890 unsigned int substr)
891 {
893 unsigned int ch;
895 unsigned recompute_sho = 0;
896
899 s->param_presence_flags =
get_bits(gbp, 8);
900
908 }
909 }
910
915
918 for (ch = 0; ch <=
s->max_matrix_channel; ch++) {
920 if (
s->output_shift[ch] < 0) {
922 s->output_shift[ch] = 0;
923 }
924 }
928 s->max_matrix_channel,
930 }
931
934 for (ch = 0; ch <=
s->max_channel; ch++) {
935 s->quant_step_size[ch] =
get_bits(gbp, 4);
936
937 recompute_sho |= 1<<ch;
938 }
939
940 for (ch =
s->min_channel; ch <= s->max_channel; ch++)
942 recompute_sho |= 1<<ch;
945 }
946
947
949 for (ch = 0; ch <=
s->max_channel; ch++) {
950 if (recompute_sho & (1<<ch)) {
952
957 }
958 s->quant_step_size[ch] = 0;
959 }
960
962 }
963 }
965 }
966
967 #define MSB_MASK(bits) (-(1 << (bits)))
968
969 /** Generate PCM samples using the prediction filters and residual values
970 * read from the data stream, and update the filter state. */
971
974 {
982 unsigned int filter_shift = fir->
shift;
984
987
990 filter_shift,
mask,
s->blocksize,
992
995 }
996
997 /** Read a block of PCM residual data (or actual if no filtering active). */
998
1000 unsigned int substr)
1001 {
1003 unsigned int i, ch, expected_stream_pos = 0;
1005
1006 if (
s->data_check_present) {
1008 expected_stream_pos +=
get_bits(gbp, 16);
1010 "Substreams with VLC block size check info");
1011 }
1012
1016 }
1017
1020
1021 for (
i = 0;
i <
s->blocksize;
i++)
1024
1025 for (ch =
s->min_channel; ch <= s->max_channel; ch++)
1027
1028 s->blockpos +=
s->blocksize;
1029
1030 if (
s->data_check_present) {
1034 }
1035
1036 return 0;
1037 }
1038
1039 /** Data table used for TrueHD noise generation function. */
1040
1042 30, 51, 22, 54, 3, 7, -4, 38, 14, 55, 46, 81, 22, 58, -3, 2,
1043 52, 31, -7, 51, 15, 44, 74, 30, 85, -17, 10, 33, 18, 80, 28, 62,
1044 10, 32, 23, 69, 72, 26, 35, 17, 73, 60, 8, 56, 2, 6, -2, -5,
1045 51, 4, 11, 50, 66, 76, 21, 44, 33, 47, 1, 26, 64, 48, 57, 40,
1046 38, 16, -10, -28, 92, 22, -18, 29, -10, 5, -13, 49, 19, 24, 70, 34,
1047 61, 48, 30, 14, -6, 25, 58, 33, 42, 60, 67, 17, 54, 17, 22, 30,
1048 67, 44, -9, 50, -11, 43, 40, 32, 59, 82, 13, 49, -14, 55, 60, 36,
1049 48, 49, 31, 47, 15, 12, 4, 65, 1, 23, 29, 39, 45, -2, 84, 69,
1050 0, 72, 37, 57, 27, 41, -15, -16, 35, 31, 14, 61, 24, 0, 27, 24,
1051 16, 41, 55, 34, 53, 9, 56, 12, 25, 29, 53, 5, 20, -20, -8, 20,
1052 13, 28, -3, 78, 38, 16, 11, 62, 46, 29, 21, 24, 46, 65, 43, -23,
1053 89, 18, 74, 21, 38, -12, 19, 12, -19, 8, 15, 33, 4, 57, 9, -8,
1054 36, 35, 26, 28, 7, 83, 63, 79, 75, 11, 3, 87, 37, 47, 34, 40,
1055 39, 19, 20, 42, 27, 34, 39, 77, 13, 42, 59, 64, 45, -1, 32, 37,
1056 45, -5, 53, -6, 7, 36, 50, 23, 6, 32, 9, -21, 18, 71, 27, 52,
1057 -25, 31, 35, 42, -1, 68, 63, 52, 26, 43, 66, 37, 41, 25, 40, 70,
1058 };
1059
1060 /** Noise generation functions.
1061 * I'm not sure what these are for - they seem to be some kind of pseudorandom
1062 * sequence generators, used to generate noise data which is used when the
1063 * channels are rematrixed. I'm not sure if they provide a practical benefit
1064 * to compression, or just obfuscate the decoder. Are they for some kind of
1065 * dithering? */
1066
1067 /** Generate two channels of noise, used in the matrix when
1068 * restart sync word == 0x31ea. */
1069
1071 {
1074 uint32_t
seed =
s->noisegen_seed;
1075 unsigned int maxchan =
s->max_matrix_channel;
1076
1077 for (
i = 0;
i <
s->blockpos;
i++) {
1078 uint16_t seed_shr7 =
seed >> 7;
1080 m->
sample_buffer[
i][maxchan+2] = ((int8_t) seed_shr7) * (1 <<
s->noise_shift);
1081
1082 seed = (
seed << 16) ^ seed_shr7 ^ (seed_shr7 << 5);
1083 }
1084
1085 s->noisegen_seed =
seed;
1086 }
1087
1088 /** Generate a block of noise, used when restart sync word == 0x31eb. */
1089
1091 {
1094 uint32_t
seed =
s->noisegen_seed;
1095
1097 uint8_t seed_shr15 =
seed >> 15;
1099 seed = (
seed << 8) ^ seed_shr15 ^ (seed_shr15 << 5);
1100 }
1101
1102 s->noisegen_seed =
seed;
1103 }
1104
1105 /** Write the audio data into the output buffer. */
1106
1109 {
1112 unsigned int mat;
1113 unsigned int maxchan;
1116
1120 }
1121
1125 }
1126
1127 maxchan =
s->max_matrix_channel;
1128 if (!
s->noise_type) {
1130 maxchan += 2;
1131 } else {
1133 }
1134
1135 /* Apply the channel matrices in turn to reconstruct the original audio
1136 * samples. */
1137 for (mat = 0; mat <
s->num_primitive_matrices; mat++) {
1138 unsigned int dest_ch =
s->matrix_out_ch[mat];
1140 s->matrix_coeff[mat],
1143 s->num_primitive_matrices - mat,
1144 dest_ch,
1146 maxchan,
1147 s->matrix_noise_shift[mat],
1150 }
1151
1152 /* get output buffer */
1153 frame->nb_samples =
s->blockpos;
1156 s->lossless_check_data = m->
pack_output(
s->lossless_check_data,
1162 s->max_matrix_channel,
1163 is32);
1164
1165 /* Update matrix encoding side data */
1166 if (
s->matrix_encoding !=
s->prev_matrix_encoding) {
1169
1170 s->prev_matrix_encoding =
s->matrix_encoding;
1171 }
1172
1173 *got_frame_ptr = 1;
1174
1175 return 0;
1176 }
1177
1178 /** Read an access unit from the stream.
1179 * @return negative on error, 0 if not enough data is present in the input stream,
1180 * otherwise the number of bytes consumed. */
1181
1183 int *got_frame_ptr,
AVPacket *avpkt)
1184 {
1185 const uint8_t *buf = avpkt->
data;
1186 int buf_size = avpkt->
size;
1189 unsigned int length, substr;
1190 unsigned int substream_start;
1191 unsigned int header_size = 4;
1192 unsigned int substr_header_size = 0;
1195 uint8_t parity_bits;
1197
1198 if (buf_size < 4)
1200
1201 length = (
AV_RB16(buf) & 0xfff) * 2;
1202
1203 if (length < 4 || length > buf_size)
1205
1207
1215 }
1216
1219 "Stream parameters not seen; skipping frame.\n");
1220 *got_frame_ptr = 0;
1221 return length;
1222 }
1223
1224 substream_start = 0;
1225
1227 int extraword_present, checkdata_present, end, nonrestart_substr;
1228
1233
1235
1236 substr_header_size += 2;
1237
1238 if (extraword_present) {
1242 }
1244 substr_header_size += 2;
1245 }
1246
1247 if (length < header_size + substr_header_size) {
1250 }
1251
1255 }
1256
1257 if (end + header_size + substr_header_size > length) {
1259 "Indicated length of substream %d data goes off end of "
1260 "packet.\n", substr);
1261 end = length - header_size - substr_header_size;
1262 }
1263
1264 if (end < substream_start) {
1266 "Indicated end offset of substream %d data "
1267 "is smaller than calculated start offset.\n",
1268 substr);
1270 }
1271
1273 continue;
1274
1275 substream_parity_present[substr] = checkdata_present;
1276 substream_data_len[substr] = end - substream_start;
1277 substream_start = end;
1278 }
1279
1282
1283 if ((((parity_bits >> 4) ^ parity_bits) & 0xF) != 0xF) {
1286 }
1287
1288 buf += header_size + substr_header_size;
1289
1292
1294
1297
1299 do {
1302 /* A restart header should be present. */
1304 goto next_substr;
1305 s->restart_seen = 1;
1306 }
1307
1308 if (!
s->restart_seen)
1309 goto next_substr;
1311 goto next_substr;
1312 }
1313
1314 if (!
s->restart_seen)
1315 goto next_substr;
1316
1323 substr > 0 && substr < m->max_decoded_substream &&
1326 "Previous substream(%d) channels overlaps current substream(%d) channels, skipping.\n",
1327 substr - 1, substr);
1328 goto next_substr;
1329 }
1330
1334 "Current substream(%d) channels overlaps final substream(%d) channels, skipping.\n",
1336 goto next_substr;
1337 }
1338
1341
1343 goto substream_length_mismatch;
1344
1346
1348
1349 if (substream_data_len[substr] * 8 -
get_bits_count(&gb) >= 32) {
1350 int shorten_by;
1351
1354
1357 s->blockpos -=
FFMIN(shorten_by & 0x1FFF,
s->blockpos);
1360
1362 s->end_of_stream = 1;
1363 }
1364
1365 if (substream_parity_present[substr]) {
1366 uint8_t
parity, checksum;
1367
1369 goto substream_length_mismatch;
1370
1373
1378 }
1379
1381 goto substream_length_mismatch;
1382
1383 next_substr:
1384 if (!
s->restart_seen)
1386 "No restart header present in substream %d.\n", substr);
1387
1388 buf += substream_data_len[substr];
1389 }
1390
1393
1396
1397 if (
s->end_of_stream) {
1398 s->lossless_check_data = 0xffffffff;
1399 s->end_of_stream = 0;
1401 }
1402 }
1403
1404 return length;
1405
1406 substream_length_mismatch:
1409
1413 }
1414
1416 {
1418
1422
1423 s->lossless_check_data = 0xffffffff;
1424 s->prev_matrix_encoding = 0;
1425 }
1426 }
1427
1428 #define OFFSET(x) offsetof(MLPDecodeContext, x)
1429 #define FLAGS (AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM)
1431 {
"downmix",
"Request a specific channel layout from the decoder",
OFFSET(downmix_layout),
1434 };
1435
1441 };
1442
1448 };
1449
1450 #if CONFIG_MLP_DECODER
1462 };
1463 #endif
1464 #if CONFIG_TRUEHD_DECODER
1477 };
1478 #endif /* CONFIG_TRUEHD_DECODER */