FFmpeg
Data Structures | Macros | Enumerations | Functions | Variables
mlp.h File Reference
#include <stdint.h>
#include "libavutil/channel_layout.h"

Go to the source code of this file.

Data Structures

struct  FilterParams
 filter data More...
 
struct  ChannelParams
 sample data coding information More...
 
struct  ChannelInformation
 

Macros

#define SYNC_MLP   0xbb
 
#define SYNC_TRUEHD   0xba
 
#define MAX_MATRIX_CHANNEL_MLP   5
 Last possible matrix channel for each codec. More...
 
#define MAX_MATRIX_CHANNEL_TRUEHD   7
 
#define MAX_CHANNELS   8
 Maximum number of channels in a valid stream. More...
 
#define MAX_MATRICES_MLP   6
 Maximum number of matrices used in decoding; most streams have one matrix per output channel, but some rematrix a channel (usually 0) more than once. More...
 
#define MAX_MATRICES_TRUEHD   8
 
#define MAX_MATRICES   8
 
#define MAX_SUBSTREAMS   4
 Maximum number of substreams that can be decoded. More...
 
#define MAX_RATEFACTOR   4
 which multiple of 48000 the maximum sample rate is More...
 
#define MAX_SAMPLERATE   (MAX_RATEFACTOR * 48000)
 maximum sample frequency seen in files More...
 
#define MAX_BLOCKSIZE   (40 * MAX_RATEFACTOR)
 maximum number of audio samples within one access unit More...
 
#define MAX_BLOCKSIZE_POW2   (64 * MAX_RATEFACTOR)
 next power of two greater than MAX_BLOCKSIZE More...
 
#define NUM_FILTERS   2
 number of allowed filters More...
 
#define MAX_FIR_ORDER   8
 The maximum number of taps in IIR and FIR filters. More...
 
#define MAX_IIR_ORDER   4
 
#define END_OF_STREAM   0xd234d234
 Code that signals end of a stream. More...
 
#define PARAM_BLOCKSIZE   (1 << 7)
 
#define PARAM_MATRIX   (1 << 6)
 
#define PARAM_OUTSHIFT   (1 << 5)
 
#define PARAM_QUANTSTEP   (1 << 4)
 
#define PARAM_FIR   (1 << 3)
 
#define PARAM_IIR   (1 << 2)
 
#define PARAM_HUFFOFFSET   (1 << 1)
 
#define PARAM_PRESENCE   (1 << 0)
 
#define FIR   0
 
#define IIR   1
 

Enumerations

enum  THDChannelModifier {
  THD_CH_MODIFIER_NOTINDICATED = 0x0, THD_CH_MODIFIER_STEREO = 0x0, THD_CH_MODIFIER_LTRT = 0x1, THD_CH_MODIFIER_LBINRBIN = 0x2,
  THD_CH_MODIFIER_MONO = 0x3, THD_CH_MODIFIER_NOTSURROUNDEX = 0x1, THD_CH_MODIFIER_SURROUNDEX = 0x2
}
 

Functions

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 implementation terms, the table lookup and XOR are reversed). More...
 
uint16_t ff_mlp_checksum16 (const uint8_t *buf, unsigned int buf_size)
 
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, starting two bits into the first byte of buf. More...
 
uint8_t ff_mlp_calculate_parity (const uint8_t *buf, unsigned int buf_size)
 XOR together all the bytes of a buffer. More...
 
void ff_mlp_init_crc (void)
 
static uint8_t xor_32_to_8 (uint32_t value)
 XOR four bytes into one. More...
 

Variables

const uint8_t ff_mlp_huffman_tables [3][18][2]
 Tables defining the Huffman codes. More...
 
const ChannelInformation ff_mlp_ch_info [21]
 Tables defining channel information. More...
 
const AVChannelLayout ff_mlp_ch_layouts [12]
 

Macro Definition Documentation

◆ SYNC_MLP

#define SYNC_MLP   0xbb

Definition at line 29 of file mlp.h.

◆ SYNC_TRUEHD

#define SYNC_TRUEHD   0xba

Definition at line 30 of file mlp.h.

◆ MAX_MATRIX_CHANNEL_MLP

#define MAX_MATRIX_CHANNEL_MLP   5

Last possible matrix channel for each codec.

Definition at line 33 of file mlp.h.

◆ MAX_MATRIX_CHANNEL_TRUEHD

#define MAX_MATRIX_CHANNEL_TRUEHD   7

Definition at line 34 of file mlp.h.

◆ MAX_CHANNELS

#define MAX_CHANNELS   8

Maximum number of channels in a valid stream.

MLP : 5.1 + 2 noise channels -> 8 channels TrueHD: 7.1 -> 8 channels

Definition at line 39 of file mlp.h.

◆ MAX_MATRICES_MLP

#define MAX_MATRICES_MLP   6

Maximum number of matrices used in decoding; most streams have one matrix per output channel, but some rematrix a channel (usually 0) more than once.

Definition at line 44 of file mlp.h.

◆ MAX_MATRICES_TRUEHD

#define MAX_MATRICES_TRUEHD   8

Definition at line 45 of file mlp.h.

◆ MAX_MATRICES

#define MAX_MATRICES   8

Definition at line 46 of file mlp.h.

◆ MAX_SUBSTREAMS

#define MAX_SUBSTREAMS   4

Maximum number of substreams that can be decoded.

MLP's limit is 2. TrueHD supports at least up to 3.

Definition at line 51 of file mlp.h.

◆ MAX_RATEFACTOR

#define MAX_RATEFACTOR   4

which multiple of 48000 the maximum sample rate is

Definition at line 54 of file mlp.h.

◆ MAX_SAMPLERATE

#define MAX_SAMPLERATE   (MAX_RATEFACTOR * 48000)

maximum sample frequency seen in files

Definition at line 56 of file mlp.h.

◆ MAX_BLOCKSIZE

#define MAX_BLOCKSIZE   (40 * MAX_RATEFACTOR)

maximum number of audio samples within one access unit

Definition at line 59 of file mlp.h.

◆ MAX_BLOCKSIZE_POW2

#define MAX_BLOCKSIZE_POW2   (64 * MAX_RATEFACTOR)

next power of two greater than MAX_BLOCKSIZE

Definition at line 61 of file mlp.h.

◆ NUM_FILTERS

#define NUM_FILTERS   2

number of allowed filters

Definition at line 64 of file mlp.h.

◆ MAX_FIR_ORDER

#define MAX_FIR_ORDER   8

The maximum number of taps in IIR and FIR filters.

Definition at line 67 of file mlp.h.

◆ MAX_IIR_ORDER

#define MAX_IIR_ORDER   4

Definition at line 68 of file mlp.h.

◆ END_OF_STREAM

#define END_OF_STREAM   0xd234d234

Code that signals end of a stream.

Definition at line 71 of file mlp.h.

◆ PARAM_BLOCKSIZE

#define PARAM_BLOCKSIZE   (1 << 7)

Definition at line 73 of file mlp.h.

◆ PARAM_MATRIX

#define PARAM_MATRIX   (1 << 6)

Definition at line 74 of file mlp.h.

◆ PARAM_OUTSHIFT

#define PARAM_OUTSHIFT   (1 << 5)

Definition at line 75 of file mlp.h.

◆ PARAM_QUANTSTEP

#define PARAM_QUANTSTEP   (1 << 4)

Definition at line 76 of file mlp.h.

◆ PARAM_FIR

#define PARAM_FIR   (1 << 3)

Definition at line 77 of file mlp.h.

◆ PARAM_IIR

#define PARAM_IIR   (1 << 2)

Definition at line 78 of file mlp.h.

◆ PARAM_HUFFOFFSET

#define PARAM_HUFFOFFSET   (1 << 1)

Definition at line 79 of file mlp.h.

◆ PARAM_PRESENCE

#define PARAM_PRESENCE   (1 << 0)

Definition at line 80 of file mlp.h.

◆ FIR

#define FIR   0

Definition at line 82 of file mlp.h.

◆ IIR

#define IIR   1

Definition at line 83 of file mlp.h.

Enumeration Type Documentation

◆ THDChannelModifier

Enumerator
THD_CH_MODIFIER_NOTINDICATED 
THD_CH_MODIFIER_STEREO 
THD_CH_MODIFIER_LTRT 
THD_CH_MODIFIER_LBINRBIN 
THD_CH_MODIFIER_MONO 
THD_CH_MODIFIER_NOTSURROUNDEX 
THD_CH_MODIFIER_SURROUNDEX 

Definition at line 182 of file mlp.h.

Function Documentation

◆ ff_mlp_checksum8()

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 implementation terms, the table lookup and XOR are reversed).

We can implement this behavior using a standard av_crc on all but the last element, then XOR that with the last element.

Definition at line 107 of file mlp.c.

Referenced by read_access_unit(), and write_substr().

◆ ff_mlp_checksum16()

uint16_t ff_mlp_checksum16 ( const uint8_t *  buf,
unsigned int  buf_size 
)

Definition at line 98 of file mlp.c.

Referenced by ff_mlp_read_major_sync(), truehd_core_filter(), and write_major_sync().

◆ ff_mlp_restart_checksum()

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, starting two bits into the first byte of buf.

Definition at line 114 of file mlp.c.

Referenced by read_restart_header(), and write_restart_header().

◆ ff_mlp_calculate_parity()

uint8_t ff_mlp_calculate_parity ( const uint8_t *  buf,
unsigned int  buf_size 
)

XOR together all the bytes of a buffer.

Does this belong in dspcontext?

Definition at line 133 of file mlp.c.

Referenced by read_access_unit(), and write_substr().

◆ ff_mlp_init_crc()

void ff_mlp_init_crc ( void  )

Definition at line 92 of file mlp.c.

Referenced by init_static(), mlp_encode_init_static(), and mlp_init().

◆ xor_32_to_8()

static uint8_t xor_32_to_8 ( uint32_t  value)
inlinestatic

XOR four bytes into one.

Definition at line 175 of file mlp.h.

Referenced by ff_mlp_calculate_parity(), read_restart_header(), and write_restart_header().

Variable Documentation

◆ ff_mlp_huffman_tables

const uint8_t ff_mlp_huffman_tables[3][18][2]

Tables defining the Huffman codes.

There are three entropy coding methods used in MLP (four if you count "none" as a method). These use the same sequences for codes starting with 00 or 01, but have different codes starting with 1.

Definition at line 30 of file mlp.c.

Referenced by codebook_bits_offset(), init_static(), and write_block_data().

◆ ff_mlp_ch_info

const ChannelInformation ff_mlp_ch_info[21]

Tables defining channel information.

Possible channel arrangements are:

(Group 1) C (Group 1) L, R (Group 1) Lf, Rf / (Group 2) S (Group 1) Lf, Rf / (Group 2) Ls, Rs (Group 1) Lf, Rf / (Group 2) LFE (Group 1) Lf, Rf / (Group 2) LFE, S (Group 1) Lf, Rf / (Group 2) LFE, Ls, Rs (Group 1) Lf, Rf / (Group 2) C (Group 1) Lf, Rf / (Group 2) C, S (Group 1) Lf, Rf / (Group 2) C, Ls, Rs (Group 1) Lf, Rf / (Group 2) C, LFE (Group 1) Lf, Rf / (Group 2) C, LFE, S (Group 1) Lf, Rf / (Group 2) C, LFE, Ls, Rs (Group 1) Lf, Rf C / (Group 2) S (Group 1) Lf, Rf C / (Group 2) Ls, Rs (Group 1) Lf, Rf C / (Group 2) LFE (Group 1) Lf, Rf C / (Group 2) LFE, S (Group 1) Lf, Rf C / (Group 2) LFE, Ls, Rs (Group 1) Lf, Rf Ls Rs / (Group 2) LFE (Group 1) Lf, Rf Ls Rs / (Group 2) C (Group 1) Lf, Rf, Ls, Rs / (Group 2) C, LFE

Definition at line 46 of file mlp.c.

Referenced by mlp_encode_init().

◆ ff_mlp_ch_layouts

const AVChannelLayout ff_mlp_ch_layouts[12]

Definition at line 69 of file mlp.c.