FFmpeg
Macros | Functions | Variables
mlp.c File Reference
#include <stdint.h>
#include "libavutil/channel_layout.h"
#include "libavutil/crc.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/thread.h"
#include "mlp.h"

Go to the source code of this file.

Macros

#define CRC_TABLE_SIZE   1024
 

Functions

static av_cold void mlp_init_crc (void)
 
av_cold void ff_mlp_init_crc (void)
 
uint16_t ff_mlp_checksum16 (const uint8_t *buf, unsigned int buf_size)
 
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...
 
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...
 

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]
 
static AVCRC crc_63 [CRC_TABLE_SIZE]
 
static AVCRC crc_1D [CRC_TABLE_SIZE]
 
static AVCRC crc_2D [CRC_TABLE_SIZE]
 

Macro Definition Documentation

◆ CRC_TABLE_SIZE

#define CRC_TABLE_SIZE   1024

Definition at line 70 of file mlp.c.

Function Documentation

◆ mlp_init_crc()

static av_cold void mlp_init_crc ( void  )
static

Definition at line 76 of file mlp.c.

Referenced by ff_mlp_init_crc().

◆ ff_mlp_init_crc()

av_cold void ff_mlp_init_crc ( void  )

Definition at line 83 of file mlp.c.

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

◆ ff_mlp_checksum16()

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

Definition at line 89 of file mlp.c.

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

◆ 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 98 of file mlp.c.

Referenced by read_access_unit(), and write_substr().

◆ 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 105 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 124 of file mlp.c.

Referenced by read_access_unit(), and write_substr().

Variable Documentation

◆ ff_mlp_huffman_tables

const uint8_t ff_mlp_huffman_tables[3][18][2]
Initial value:
= {
{
{0x01, 9}, {0x01, 8}, {0x01, 7}, {0x01, 6}, {0x01, 5}, {0x01, 4}, {0x01, 3},
{0x04, 3}, {0x05, 3}, {0x06, 3}, {0x07, 3},
{0x03, 3}, {0x05, 4}, {0x09, 5}, {0x11, 6}, {0x21, 7}, {0x41, 8}, {0x81, 9},
}, {
{0x01, 9}, {0x01, 8}, {0x01, 7}, {0x01, 6}, {0x01, 5}, {0x01, 4}, {0x01, 3},
{0x02, 2}, {0x03, 2},
{0x03, 3}, {0x05, 4}, {0x09, 5}, {0x11, 6}, {0x21, 7}, {0x41, 8}, {0x81, 9},
}, {
{0x01, 9}, {0x01, 8}, {0x01, 7}, {0x01, 6}, {0x01, 5}, {0x01, 4}, {0x01, 3},
{0x01, 1},
{0x03, 3}, {0x05, 4}, {0x09, 5}, {0x11, 6}, {0x21, 7}, {0x41, 8}, {0x81, 9},
}
}

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]
Initial value:
= {
{ 0x01, 0x01, 0x00, 0x1f }, { 0x03, 0x02, 0x00, 0x1b },
{ 0x07, 0x02, 0x01, 0x1f }, { 0x0F, 0x02, 0x02, 0x19 },
{ 0x07, 0x02, 0x01, 0x03 }, { 0x0F, 0x02, 0x02, 0x1f },
{ 0x1F, 0x02, 0x03, 0x01 }, { 0x07, 0x02, 0x01, 0x1a },
{ 0x0F, 0x02, 0x02, 0x1f }, { 0x1F, 0x02, 0x03, 0x18 },
{ 0x0F, 0x02, 0x02, 0x02 }, { 0x1F, 0x02, 0x03, 0x1f },
{ 0x3F, 0x02, 0x04, 0x00 }, { 0x0F, 0x03, 0x01, 0x1f },
{ 0x1F, 0x03, 0x02, 0x18 }, { 0x0F, 0x03, 0x01, 0x02 },
{ 0x1F, 0x03, 0x02, 0x1f }, { 0x3F, 0x03, 0x03, 0x00 },
{ 0x1F, 0x04, 0x01, 0x01 }, { 0x1F, 0x04, 0x01, 0x18 },
{ 0x3F, 0x04, 0x02, 0x00 },
}

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]

◆ crc_63

AVCRC crc_63[CRC_TABLE_SIZE]
static

Definition at line 72 of file mlp.c.

Referenced by ff_mlp_checksum8(), and mlp_init_crc().

◆ crc_1D

AVCRC crc_1D[CRC_TABLE_SIZE]
static

Definition at line 73 of file mlp.c.

Referenced by ff_mlp_restart_checksum(), and mlp_init_crc().

◆ crc_2D

AVCRC crc_2D[CRC_TABLE_SIZE]
static

Definition at line 74 of file mlp.c.

Referenced by ff_mlp_checksum16(), and mlp_init_crc().

AV_CHANNEL_LAYOUT_STEREO
#define AV_CHANNEL_LAYOUT_STEREO
Definition: channel_layout.h:387
AV_CHANNEL_LAYOUT_4POINT1
#define AV_CHANNEL_LAYOUT_4POINT1
Definition: channel_layout.h:393
AV_CHANNEL_LAYOUT_2POINT1
#define AV_CHANNEL_LAYOUT_2POINT1
Definition: channel_layout.h:388
AV_CHANNEL_LAYOUT_SURROUND
#define AV_CHANNEL_LAYOUT_SURROUND
Definition: channel_layout.h:390
AV_CHANNEL_LAYOUT_4POINT0
#define AV_CHANNEL_LAYOUT_4POINT0
Definition: channel_layout.h:392
AV_CHANNEL_LAYOUT_5POINT0_BACK
#define AV_CHANNEL_LAYOUT_5POINT0_BACK
Definition: channel_layout.h:398
AV_CHANNEL_LAYOUT_QUAD
#define AV_CHANNEL_LAYOUT_QUAD
Definition: channel_layout.h:395
AV_CHANNEL_LAYOUT_3POINT1
#define AV_CHANNEL_LAYOUT_3POINT1
Definition: channel_layout.h:391
AV_CHANNEL_LAYOUT_2_1
#define AV_CHANNEL_LAYOUT_2_1
Definition: channel_layout.h:389
AV_CHANNEL_LAYOUT_MONO
#define AV_CHANNEL_LAYOUT_MONO
Definition: channel_layout.h:386
AV_CHANNEL_LAYOUT_5POINT1_BACK
#define AV_CHANNEL_LAYOUT_5POINT1_BACK
Definition: channel_layout.h:399