Go to the documentation of this file.
47 #define VLC_STATIC_SIZE 64
50 #define VLC_STATIC_SIZE 512
88 #define PARAM_BLOCKSIZE (1 << 7)
89 #define PARAM_MATRIX (1 << 6)
90 #define PARAM_OUTSHIFT (1 << 5)
91 #define PARAM_QUANTSTEP (1 << 4)
92 #define PARAM_FIR (1 << 3)
93 #define PARAM_IIR (1 << 2)
94 #define PARAM_HUFFOFFSET (1 << 1)
95 #define PARAM_PRESENCE (1 << 0)
187 return channel_layout && ((channel_layout &
mask) == channel_layout);
210 for (
int i = 0;
i < 3;
i++) {
223 unsigned int substr,
unsigned int ch)
227 int lsb_bits = cp->
huff_lsbs -
s->quant_step_size[ch];
232 sign_huff_offset -= 7 << lsb_bits;
235 sign_huff_offset -= 1 << sign_shift;
237 return sign_huff_offset;
244 unsigned int substr,
unsigned int pos)
249 for (mat = 0; mat <
s->num_primitive_matrices; mat++)
250 if (
s->lsb_bypass[mat])
308 if (
mh.group1_bits == 0) {
312 if (
mh.group2_bits >
mh.group1_bits) {
314 "Channel group 2 cannot have more bits per sample than group 1.\n");
318 if (
mh.group2_samplerate &&
mh.group2_samplerate !=
mh.group1_samplerate) {
320 "Channel groups with differing sample rates are not currently supported.\n");
324 if (
mh.group1_samplerate == 0) {
330 "Sampling rate %d is greater than the supported maximum (%d).\n",
336 "Block size %d is greater than the supported maximum (%d).\n",
342 "Block size pow2 %d is greater than the supported maximum (%d).\n",
347 if (
mh.num_substreams == 0)
355 "%d substreams (more than the "
356 "maximum supported by the decoder)",
375 if (
mh.group1_bits > 16)
392 if (
mh.stream_type != 0xbb) {
394 "unexpected stream_type %X in MLP",
398 if ((substr = (
mh.num_substreams > 1)))
402 if (
mh.stream_type != 0xba) {
404 "unexpected stream_type %X in !MLP",
408 if ((substr = (
mh.num_substreams > 1)))
410 if (
mh.num_substreams > 2)
411 if (
mh.channel_layout_thd_stream2)
442 if (
mh.num_substreams > 2 &&
448 if (
mh.num_substreams > 1 &&
454 if (
mh.num_substreams > 0)
455 switch (
mh.channel_modifier_thd_stream0) {
475 const uint8_t *buf,
unsigned int substr)
483 int min_channel, max_channel, max_matrix_channel, noise_type;
490 if (sync_word != 0x31ea >> 1) {
492 "restart header sync incorrect (got 0x%04x)\n", sync_word);
507 max_matrix_channel =
get_bits(gbp, 4);
509 if (max_matrix_channel > std_max_matrix_channel) {
511 "Max matrix channel cannot be greater than %d.\n",
512 std_max_matrix_channel);
516 if (max_channel != max_matrix_channel) {
518 "Max channel must be equal max matrix channel.\n");
526 "%d channels (more than the "
527 "maximum supported by the decoder)",
532 if (min_channel > max_channel) {
534 "Substream min channel cannot be greater than max channel.\n");
538 s->min_channel = min_channel;
539 s->max_channel = max_channel;
540 s->max_matrix_channel = max_matrix_channel;
541 s->noise_type = noise_type;
546 "Extracting %d-channel downmix (0x%"PRIx64
") from substream %d. "
547 "Further substreams will be skipped.\n",
548 s->max_channel + 1,
s->mask, substr);
560 &&
s->lossless_check_data != 0xffffffff) {
562 if (
tmp != lossless_check)
564 "Lossless check failed - expected %02x, calculated %02x.\n",
565 lossless_check,
tmp);
570 memset(
s->ch_assign, 0,
sizeof(
s->ch_assign));
572 for (ch = 0; ch <=
s->max_matrix_channel; ch++) {
580 if (ch_assign < 0 || ch_assign >
s->max_matrix_channel) {
582 "Assignment of matrix channel %d to invalid output channel %d",
586 s->ch_assign[ch_assign] = ch;
595 s->param_presence_flags = 0xff;
596 s->num_primitive_matrices = 0;
598 s->lossless_check_data = 0;
600 memset(
s->output_shift , 0,
sizeof(
s->output_shift ));
601 memset(
s->quant_step_size, 0,
sizeof(
s->quant_step_size));
603 for (ch =
s->min_channel; ch <= s->max_channel; ch++) {
622 s->max_matrix_channel,
628 int i =
s->ch_assign[4];
629 s->ch_assign[4] =
s->ch_assign[3];
630 s->ch_assign[3] =
s->ch_assign[2];
633 FFSWAP(
int,
s->ch_assign[2],
s->ch_assign[4]);
634 FFSWAP(
int,
s->ch_assign[3],
s->ch_assign[5]);
646 unsigned int substr,
unsigned int channel,
652 const char fchar =
filter ?
'I' :
'F';
664 if (order > max_order) {
666 "%cIR filter order %d is greater than maximum %d.\n",
667 fchar, order, max_order);
674 int coeff_bits, coeff_shift;
680 if (coeff_bits < 1 || coeff_bits > 16) {
682 "%cIR filter coeff_bits must be between 1 and 16.\n",
686 if (coeff_bits + coeff_shift > 16) {
688 "Sum of coeff_bits and coeff_shift for %cIR filter must be 16 or less.\n",
693 for (
i = 0;
i < order;
i++)
694 fcoeff[
i] =
get_sbits(gbp, coeff_bits) * (1 << coeff_shift);
697 int state_bits, state_shift;
701 "FIR filter has state data specified.\n");
710 for (
i = 0;
i < order;
i++)
711 fp->state[
i] = state_bits ?
get_sbits(gbp, state_bits) * (1 << state_shift) : 0;
723 unsigned int mat, ch;
733 s->num_primitive_matrices =
get_bits(gbp, 4);
735 if (
s->num_primitive_matrices > max_primitive_matrices) {
737 "Number of primitive matrices cannot be greater than %d.\n",
738 max_primitive_matrices);
742 for (mat = 0; mat <
s->num_primitive_matrices; mat++) {
743 int frac_bits, max_chan;
744 s->matrix_out_ch[mat] =
get_bits(gbp, 4);
748 if (
s->matrix_out_ch[mat] >
s->max_matrix_channel) {
750 "Invalid channel %d specified as output from matrix.\n",
751 s->matrix_out_ch[mat]);
754 if (frac_bits > 14) {
756 "Too many fractional bits specified.\n");
760 max_chan =
s->max_matrix_channel;
764 for (ch = 0; ch <= max_chan; ch++) {
767 coeff_val =
get_sbits(gbp, frac_bits + 2);
769 s->matrix_coeff[mat][ch] = coeff_val * (1 << (14 - frac_bits));
773 s->matrix_noise_shift[mat] =
get_bits(gbp, 4);
775 s->matrix_noise_shift[mat] = 0;
780 s->num_primitive_matrices = 0;
781 memset(
s->matrix_out_ch, 0,
sizeof(
s->matrix_out_ch));
815 "FIR and IIR filters must use the same precision.\n");
851 unsigned recompute_sho = 0;
855 s->param_presence_flags =
get_bits(gbp, 8);
874 for (ch = 0; ch <=
s->max_matrix_channel; ch++) {
876 if (
s->output_shift[ch] < 0) {
878 s->output_shift[ch] = 0;
884 s->max_matrix_channel,
890 for (ch = 0; ch <=
s->max_channel; ch++) {
891 s->quant_step_size[ch] =
get_bits(gbp, 4);
893 recompute_sho |= 1<<ch;
896 for (ch =
s->min_channel; ch <= s->max_channel; ch++)
898 recompute_sho |= 1<<ch;
905 for (ch = 0; ch <=
s->max_channel; ch++) {
906 if (recompute_sho & (1<<ch)) {
914 s->quant_step_size[ch] = 0;
923 #define MSB_MASK(bits) (-1u << (bits))
938 unsigned int filter_shift = fir->
shift;
946 filter_shift,
mask,
s->blocksize,
959 unsigned int i, ch, expected_stream_pos = 0;
962 if (
s->data_check_present) {
964 expected_stream_pos +=
get_bits(gbp, 16);
966 "Substreams with VLC block size check info");
977 for (
i = 0;
i <
s->blocksize;
i++)
981 for (ch =
s->min_channel; ch <= s->max_channel; ch++)
984 s->blockpos +=
s->blocksize;
986 if (
s->data_check_present) {
998 30, 51, 22, 54, 3, 7, -4, 38, 14, 55, 46, 81, 22, 58, -3, 2,
999 52, 31, -7, 51, 15, 44, 74, 30, 85, -17, 10, 33, 18, 80, 28, 62,
1000 10, 32, 23, 69, 72, 26, 35, 17, 73, 60, 8, 56, 2, 6, -2, -5,
1001 51, 4, 11, 50, 66, 76, 21, 44, 33, 47, 1, 26, 64, 48, 57, 40,
1002 38, 16, -10, -28, 92, 22, -18, 29, -10, 5, -13, 49, 19, 24, 70, 34,
1003 61, 48, 30, 14, -6, 25, 58, 33, 42, 60, 67, 17, 54, 17, 22, 30,
1004 67, 44, -9, 50, -11, 43, 40, 32, 59, 82, 13, 49, -14, 55, 60, 36,
1005 48, 49, 31, 47, 15, 12, 4, 65, 1, 23, 29, 39, 45, -2, 84, 69,
1006 0, 72, 37, 57, 27, 41, -15, -16, 35, 31, 14, 61, 24, 0, 27, 24,
1007 16, 41, 55, 34, 53, 9, 56, 12, 25, 29, 53, 5, 20, -20, -8, 20,
1008 13, 28, -3, 78, 38, 16, 11, 62, 46, 29, 21, 24, 46, 65, 43, -23,
1009 89, 18, 74, 21, 38, -12, 19, 12, -19, 8, 15, 33, 4, 57, 9, -8,
1010 36, 35, 26, 28, 7, 83, 63, 79, 75, 11, 3, 87, 37, 47, 34, 40,
1011 39, 19, 20, 42, 27, 34, 39, 77, 13, 42, 59, 64, 45, -1, 32, 37,
1012 45, -5, 53, -6, 7, 36, 50, 23, 6, 32, 9, -21, 18, 71, 27, 52,
1013 -25, 31, 35, 42, -1, 68, 63, 52, 26, 43, 66, 37, 41, 25, 40, 70,
1030 uint32_t
seed =
s->noisegen_seed;
1031 unsigned int maxchan =
s->max_matrix_channel;
1033 for (
i = 0;
i <
s->blockpos;
i++) {
1034 uint16_t seed_shr7 =
seed >> 7;
1036 m->
sample_buffer[
i][maxchan+2] = ((int8_t) seed_shr7) * (1 <<
s->noise_shift);
1038 seed = (
seed << 16) ^ seed_shr7 ^ (seed_shr7 << 5);
1041 s->noisegen_seed =
seed;
1050 uint32_t
seed =
s->noisegen_seed;
1055 seed = (
seed << 8) ^ seed_shr15 ^ (seed_shr15 << 5);
1058 s->noisegen_seed =
seed;
1069 unsigned int maxchan;
1083 maxchan =
s->max_matrix_channel;
1084 if (!
s->noise_type) {
1093 for (mat = 0; mat <
s->num_primitive_matrices; mat++) {
1094 unsigned int dest_ch =
s->matrix_out_ch[mat];
1096 s->matrix_coeff[mat],
1099 s->num_primitive_matrices - mat,
1103 s->matrix_noise_shift[mat],
1109 frame->nb_samples =
s->blockpos;
1118 s->max_matrix_channel,
1135 int *got_frame_ptr,
AVPacket *avpkt)
1138 int buf_size = avpkt->
size;
1141 unsigned int length, substr;
1142 unsigned int substream_start;
1143 unsigned int header_size = 4;
1144 unsigned int substr_header_size = 0;
1153 length = (
AV_RB16(buf) & 0xfff) * 2;
1155 if (length < 4 || length > buf_size)
1170 "Stream parameters not seen; skipping frame.\n");
1175 substream_start = 0;
1178 int extraword_present, checkdata_present, end, nonrestart_substr;
1187 substr_header_size += 2;
1189 if (extraword_present) {
1195 substr_header_size += 2;
1198 if (length < header_size + substr_header_size) {
1208 if (end + header_size + substr_header_size > length) {
1210 "Indicated length of substream %d data goes off end of "
1211 "packet.\n", substr);
1212 end = length - header_size - substr_header_size;
1215 if (end < substream_start) {
1217 "Indicated end offset of substream %d data "
1218 "is smaller than calculated start offset.\n",
1226 substream_parity_present[substr] = checkdata_present;
1227 substream_data_len[substr] = end - substream_start;
1228 substream_start = end;
1234 if ((((parity_bits >> 4) ^ parity_bits) & 0xF) != 0xF) {
1239 buf += header_size + substr_header_size;
1255 s->restart_seen = 1;
1258 if (!
s->restart_seen)
1264 if (!
s->restart_seen)
1271 goto substream_length_mismatch;
1277 if (substream_data_len[substr] * 8 -
get_bits_count(&gb) >= 32) {
1285 s->blockpos -=
FFMIN(shorten_by & 0x1FFF,
s->blockpos);
1293 if (substream_parity_present[substr]) {
1297 goto substream_length_mismatch;
1309 goto substream_length_mismatch;
1312 if (!
s->restart_seen)
1314 "No restart header present in substream %d.\n", substr);
1316 buf += substream_data_len[substr];
1324 substream_length_mismatch:
1333 #if CONFIG_MLP_DECODER
1346 #if CONFIG_TRUEHD_DECODER
uint8_t params_valid
Set if a valid major sync block has been read. Otherwise no decoding is possible.
static void error(const char *err)
int frame_size
Number of samples per channel in an audio frame.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
static const int8_t noise_table[256]
Data table used for TrueHD noise generation function.
#define AV_CH_LAYOUT_5POINT0_BACK
static av_cold int init(AVCodecContext *avctx)
static unsigned int show_bits_long(GetBitContext *s, int n)
Show 0-32 bits.
uint8_t codebook
Which VLC codebook to use to read residuals.
static uint8_t xor_32_to_8(uint32_t value)
XOR four bytes into one.
int32_t matrix_coeff[MAX_MATRICES][MAX_CHANNELS]
Matrix coefficients, stored as 2.14 fixed point.
uint64_t channel_layout
Audio channel layout.
#define AV_CH_TOP_FRONT_CENTER
int sample_rate
samples per second
#define FFSWAP(type, a, b)
#define AV_CH_LOW_FREQUENCY_2
static const uint64_t thd_channel_order[]
#define AV_CH_LAYOUT_MONO
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
int8_t output_shift[MAX_CHANNELS]
Left shift to apply to decoded PCM values to get final 24-bit output.
@ THD_CH_MODIFIER_SURROUNDEX
static int get_bits_count(const GetBitContext *s)
static int read_decoding_params(MLPDecodeContext *m, GetBitContext *gbp, unsigned int substr)
Read decoding parameters that change more often than those in the restart header.
#define MAX_SAMPLERATE
maximum sample frequency seen in files
#define AV_CH_TOP_FRONT_RIGHT
static av_cold void init_static(void)
Initialize static data, constant between all invocations of the codec.
This structure describes decoded (raw) audio or video data.
uint8_t ff_mlp_calculate_parity(const uint8_t *buf, unsigned int buf_size)
XOR together all the bytes of a buffer.
#define init_vlc(vlc, nb_bits, nb_codes, bits, bits_wrap, bits_size, codes, codes_wrap, codes_size, flags)
static const uint16_t table[]
static void filter_channel(MLPDecodeContext *m, unsigned int substr, unsigned int channel)
Generate PCM samples using the prediction filters and residual values read from the data stream,...
AVCodec ff_truehd_decoder
uint8_t restart_seen
Set if a valid restart header has been read. Otherwise the substream cannot be decoded.
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
static int output_data(MLPDecodeContext *m, unsigned int substr, AVFrame *frame, int *got_frame_ptr)
Write the audio data into the output buffer.
uint64_t mask
The channel layout for this substream.
uint8_t min_channel
The index of the first channel coded in this substream.
#define AV_CH_TOP_FRONT_LEFT
int major_sync_header_size
Size of the major sync unit, in bytes.
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce then the filter should push the output frames on the output link immediately As an exception to the previous rule if the input frame is enough to produce several output frames then the filter needs output only at least one per link The additional frames can be left buffered in the filter
uint64_t request_channel_layout
Request decoder to use this channel layout if it can (0 for default)
av_cold void ff_mlpdsp_init(MLPDSPContext *c)
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
uint8_t max_channel
The index of the last channel coded in this substream.
uint8_t ch_assign[MAX_CHANNELS]
For each channel output by the matrix, the output channel to map it to.
#define AV_CH_SURROUND_DIRECT_RIGHT
int32_t(* mlp_pack_output)(int32_t lossless_check_data, uint16_t blockpos, int32_t(*sample_buffer)[MAX_CHANNELS], void *data, uint8_t *ch_assign, int8_t *output_shift, uint8_t max_matrix_channel, int is32)
static void skip_bits(GetBitContext *s, int n)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
FilterParams filter_params[NUM_FILTERS]
uint8_t ff_mlp_checksum8(const uint8_t *buf, unsigned int buf_size)
MLP uses checksums that seem to be based on the standard CRC algorithm, but are not (in implementatio...
uint8_t huff_lsbs
Size of residual suffix not encoded using VLC.
static int32_t calculate_sign_huff(MLPDecodeContext *m, unsigned int substr, unsigned int ch)
#define AV_CH_LAYOUT_STEREO
#define AV_CH_LAYOUT_QUAD
#define MAX_MATRICES_MLP
Maximum number of matrices used in decoding; most streams have one matrix per output channel,...
static int ff_thread_once(char *control, void(*routine)(void))
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
uint8_t needs_reordering
Stream needs channel reordering to comply with FFmpeg's channel order.
#define FF_ARRAY_ELEMS(a)
@ AV_MATRIX_ENCODING_DOLBY
ChannelParams channel_params[MAX_CHANNELS]
Channel coding parameters for channels in the substream.
#define AV_CH_LOW_FREQUENCY
static const uint16_t mask[17]
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
void(* mlp_filter_channel)(int32_t *state, const int32_t *coeff, int firorder, int iirorder, unsigned int filter_shift, int32_t mask, int blocksize, int32_t *sample_buffer)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
static int get_sbits(GetBitContext *s, int n)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int32_t(*(* mlp_select_pack_output)(uint8_t *ch_assign, int8_t *output_shift, uint8_t max_matrix_channel, int is32))(int32_t
@ AV_MATRIX_ENCODING_DOLBYHEADPHONE
and forward the result(frame or status change) to the corresponding input. If nothing is possible
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
static uint64_t thd_channel_layout_extract_channel(uint64_t channel_layout, int index)
int32_t lossless_check_data
Running XOR of all output samples.
int8_t bypassed_lsbs[MAX_BLOCKSIZE][MAX_CHANNELS]
uint8_t quant_step_size[MAX_CHANNELS]
Left shift to apply to Huffman-decoded residuals.
static unsigned int get_bits1(GetBitContext *s)
static const float quant_step_size[]
#define INIT_VLC_USE_NEW_STATIC
int filter_changed[MAX_CHANNELS][NUM_FILTERS]
#define AV_CH_FRONT_CENTER
#define AV_CH_FRONT_LEFT_OF_CENTER
int access_unit_size
number of PCM samples contained in each frame
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
uint8_t max_matrix_channel
The number of channels input into the rematrix stage.
@ THD_CH_MODIFIER_LBINRBIN
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
int32_t sample_buffer[MAX_BLOCKSIZE][MAX_CHANNELS]
uint8_t ff_mlp_restart_checksum(const uint8_t *buf, unsigned int bit_size)
Calculate an 8-bit checksum over a restart header – a non-multiple-of-8 number of bits,...
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define MAX_MATRIX_CHANNEL_MLP
Last possible matrix channel for each codec.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
uint16_t noise_type
restart header data
uint8_t num_substreams
Number of substreams contained within this stream.
SubStream substream[MAX_SUBSTREAMS]
@ AV_MATRIX_ENCODING_NONE
enum AVSampleFormat sample_fmt
audio sample format
#define MAX_SUBSTREAMS
Maximum number of substreams that can be decoded.
int is_major_sync_unit
Current access unit being read has a major sync.
#define MAX_MATRIX_CHANNEL_TRUEHD
static av_cold int mlp_decode_init(AVCodecContext *avctx)
#define MAX_MATRICES_TRUEHD
#define NUM_FILTERS
number of allowed filters
uint8_t order
number of taps in filter
int ff_mlp_read_major_sync(void *log, MLPHeaderInfo *mh, GetBitContext *gb)
Read a major sync info header - contains high level information about the stream - sample rate,...
#define AV_CH_LAYOUT_5POINT1_BACK
int16_t huff_offset
Offset to apply to residual values.
static void skip_bits1(GetBitContext *s)
#define AV_CH_FRONT_RIGHT_OF_CENTER
uint32_t noisegen_seed
The current seed value for the pseudorandom noise generator(s).
uint8_t max_decoded_substream
Index of the last substream to decode - further substreams are skipped.
uint8_t lsb_bypass[MAX_MATRICES]
Whether the LSBs of the matrix output are encoded in the bitstream.
uint8_t matrix_out_ch[MAX_MATRICES]
matrix output channel
#define MAX_FIR_ORDER
The maximum number of taps in IIR and FIR filters.
void(* mlp_rematrix_channel)(int32_t *samples, const int32_t *coeffs, const uint8_t *bypassed_lsbs, const int8_t *noise_buffer, int index, unsigned int dest_ch, uint16_t blockpos, unsigned int maxchan, int matrix_noise_shift, int access_unit_size_pow2, int32_t mask)
#define AV_LOG_INFO
Standard information.
static int mlp_channel_layout_subset(uint64_t channel_layout, uint64_t mask)
int channels
number of audio channels
#define DECLARE_ALIGNED(n, t, v)
static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp, const uint8_t *buf, unsigned int substr)
Read a restart header from a block in a substream.
uint16_t blockpos
Number of PCM samples decoded so far in this frame.
uint8_t noise_shift
The left shift applied to random noise in 0x31ea substreams.
uint16_t blocksize
number of PCM samples in current audio block
int av_get_channel_layout_channel_index(uint64_t channel_layout, uint64_t channel)
Get the index of a channel in channel_layout.
#define AV_CH_BACK_CENTER
@ AV_SAMPLE_FMT_S16
signed 16 bits
static int read_channel_params(MLPDecodeContext *m, unsigned int substr, GetBitContext *gbp, unsigned int ch)
Read channel parameters.
const char * name
Name of the codec implementation.
sample data coding information
static void fill_noise_buffer(MLPDecodeContext *m, unsigned int substr)
Generate a block of noise, used when restart sync word == 0x31eb.
av_cold void ff_mlp_init_crc(void)
int32_t sign_huff_offset
sign/rounding-corrected version of huff_offset
int access_unit_size_pow2
next power of two above the number of samples in each frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
uint8_t num_primitive_matrices
matrix data
static volatile int checksum
int32_t state[MAX_FIR_ORDER]
uint8_t data_check_present
Set if the substream contains extra info to check the size of VLC blocks.
static VLC_TYPE vlc_buf[16716][2]
uint8_t matrix_noise_shift[MAX_MATRICES]
Left shift to apply to noise values in 0x31eb substreams.
main external API structure.
#define VLC_BITS
number of bits used for VLC lookup - longest Huffman code is 9
static int read_access_unit(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
Read an access unit from the stream.
@ AV_MATRIX_ENCODING_DOLBYEX
#define AV_CH_SURROUND_DIRECT_LEFT
#define AV_CH_FRONT_RIGHT
int ff_side_data_update_matrix_encoding(AVFrame *frame, enum AVMatrixEncoding matrix_encoding)
Add or update AV_FRAME_DATA_MATRIXENCODING side data.
static int read_filter_params(MLPDecodeContext *m, GetBitContext *gbp, unsigned int substr, unsigned int channel, unsigned int filter)
Read parameters for one of the prediction filters.
static int read_huff_channels(MLPDecodeContext *m, GetBitContext *gbp, unsigned int substr, unsigned int pos)
Read a sample, consisting of either, both or neither of entropy-coded MSBs and plain LSBs.
#define avpriv_request_sample(...)
static int read_major_sync(MLPDecodeContext *m, GetBitContext *gb)
Read a major sync info header - contains high level information about the stream - sample rate,...
const uint8_t ff_mlp_huffman_tables[3][18][2]
Tables defining the Huffman codes.
uint8_t param_presence_flags
Bitmask of which parameter sets are conveyed in a decoding parameter block.
This structure stores compressed data.
static int read_matrix_params(MLPDecodeContext *m, unsigned int substr, GetBitContext *gbp)
Read parameters for primitive matrices.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
uint8_t shift
Right shift to apply to output of filter.
@ AV_SAMPLE_FMT_S32
signed 32 bits
VLC_TYPE(* table)[2]
code, bits
static void generate_2_noise_channels(MLPDecodeContext *m, unsigned int substr)
Noise generation functions.
enum AVMatrixEncoding matrix_encoding
The matrix encoding mode for this substream.
#define MAX_BLOCKSIZE_POW2
next power of two greater than MAX_BLOCKSIZE
int8_t noise_buffer[MAX_BLOCKSIZE_POW2]
static const unsigned codebook[256][2]
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_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_RB16
static int read_block_data(MLPDecodeContext *m, GetBitContext *gbp, unsigned int substr)
Read a block of PCM residual data (or actual if no filtering active).