FFmpeg
Data Structures | Macros | Enumerations | Functions | Variables
dca_lbr.c File Reference
#include "libavutil/channel_layout.h"
#include "dcadec.h"
#include "dcadata.h"
#include "dcahuff.h"
#include "dca_syncwords.h"
#include "bytestream.h"

Go to the source code of this file.

Data Structures

struct  LBRChunk
 

Macros

#define BITSTREAM_READER_LE
 
#define AMP_MAX   56
 

Enumerations

enum  LBRFlags {
  LBR_FLAG_24_BIT = 0x01, LBR_FLAG_LFE_PRESENT = 0x02, LBR_FLAG_BAND_LIMIT_2_3 = 0x04, LBR_FLAG_BAND_LIMIT_1_2 = 0x08,
  LBR_FLAG_BAND_LIMIT_1_3 = 0x0c, LBR_FLAG_BAND_LIMIT_1_4 = 0x10, LBR_FLAG_BAND_LIMIT_1_8 = 0x18, LBR_FLAG_BAND_LIMIT_NONE = 0x14,
  LBR_FLAG_BAND_LIMIT_MASK = 0x1c, LBR_FLAG_DMIX_STEREO = 0x20, LBR_FLAG_DMIX_MULTI_CH = 0x40
}
 
enum  LBRChunkTypes {
  LBR_CHUNK_NULL = 0x00, LBR_CHUNK_PAD = 0x01, LBR_CHUNK_FRAME = 0x04, LBR_CHUNK_FRAME_NO_CSUM = 0x06,
  LBR_CHUNK_LFE = 0x0a, LBR_CHUNK_ECS = 0x0b, LBR_CHUNK_RESERVED_1 = 0x0c, LBR_CHUNK_RESERVED_2 = 0x0d,
  LBR_CHUNK_SCF = 0x0e, LBR_CHUNK_TONAL = 0x10, LBR_CHUNK_TONAL_GRP_1 = 0x11, LBR_CHUNK_TONAL_GRP_2 = 0x12,
  LBR_CHUNK_TONAL_GRP_3 = 0x13, LBR_CHUNK_TONAL_GRP_4 = 0x14, LBR_CHUNK_TONAL_GRP_5 = 0x15, LBR_CHUNK_TONAL_SCF = 0x16,
  LBR_CHUNK_TONAL_SCF_GRP_1 = 0x17, LBR_CHUNK_TONAL_SCF_GRP_2 = 0x18, LBR_CHUNK_TONAL_SCF_GRP_3 = 0x19, LBR_CHUNK_TONAL_SCF_GRP_4 = 0x1a,
  LBR_CHUNK_TONAL_SCF_GRP_5 = 0x1b, LBR_CHUNK_RES_GRID_LR = 0x30, LBR_CHUNK_RES_GRID_LR_LAST = 0x3f, LBR_CHUNK_RES_GRID_HR = 0x40,
  LBR_CHUNK_RES_GRID_HR_LAST = 0x4f, LBR_CHUNK_RES_TS_1 = 0x50, LBR_CHUNK_RES_TS_1_LAST = 0x5f, LBR_CHUNK_RES_TS_2 = 0x60,
  LBR_CHUNK_RES_TS_2_LAST = 0x6f, LBR_CHUNK_EXTENSION = 0x7f
}
 

Functions

static av_cold void init_tables (void)
 
static int parse_lfe_24 (DCALbrDecoder *s)
 
static int parse_lfe_16 (DCALbrDecoder *s)
 
static int parse_lfe_chunk (DCALbrDecoder *s, LBRChunk *chunk)
 
static int parse_vlc (GetBitContext *s, VLC *vlc, int max_depth)
 
static int parse_tonal (DCALbrDecoder *s, int group)
 
static int parse_tonal_chunk (DCALbrDecoder *s, LBRChunk *chunk)
 
static int parse_tonal_group (DCALbrDecoder *s, LBRChunk *chunk)
 
static int ensure_bits (GetBitContext *s, int n)
 Check point to ensure that enough bits are left. More...
 
static int parse_scale_factors (DCALbrDecoder *s, uint8_t *scf)
 
static int parse_st_code (GetBitContext *s, int min_v)
 
static int parse_grid_1_chunk (DCALbrDecoder *s, LBRChunk *chunk, int ch1, int ch2)
 
static int parse_grid_1_sec_ch (DCALbrDecoder *s, int ch2)
 
static void parse_grid_3 (DCALbrDecoder *s, int ch1, int ch2, int sb, int flag)
 
static float lbr_rand (DCALbrDecoder *s, int sb)
 
static void parse_ch (DCALbrDecoder *s, int ch, int sb, int quant_level, int flag)
 Parse time samples for one subband, filling truncated samples with randomness. More...
 
static int parse_ts (DCALbrDecoder *s, int ch1, int ch2, int start_sb, int end_sb, int flag)
 
static void convert_lpc (float *coeff, const int *codes)
 Convert from reflection coefficients to direct form coefficients. More...
 
static int parse_lpc (DCALbrDecoder *s, int ch1, int ch2, int start_sb, int end_sb)
 
static int parse_high_res_grid (DCALbrDecoder *s, LBRChunk *chunk, int ch1, int ch2)
 
static int parse_grid_2 (DCALbrDecoder *s, int ch1, int ch2, int start_sb, int end_sb, int flag)
 
static int parse_ts1_chunk (DCALbrDecoder *s, LBRChunk *chunk, int ch1, int ch2)
 
static int parse_ts2_chunk (DCALbrDecoder *s, LBRChunk *chunk, int ch1, int ch2)
 
static int init_sample_rate (DCALbrDecoder *s)
 
static int alloc_sample_buffer (DCALbrDecoder *s)
 
static int parse_decoder_init (DCALbrDecoder *s, GetByteContext *gb)
 
int ff_dca_lbr_parse (DCALbrDecoder *s, uint8_t *data, DCAExssAsset *asset)
 
static void decode_grid (DCALbrDecoder *s, int ch1, int ch2)
 Reconstruct high-frequency resolution grid from first and third grids. More...
 
static void random_ts (DCALbrDecoder *s, int ch1, int ch2)
 Fill unallocated subbands with randomness. More...
 
static void predict (float *samples, const float *coeff, int nsamples)
 
static void synth_lpc (DCALbrDecoder *s, int ch1, int ch2, int sb)
 
static void filter_ts (DCALbrDecoder *s, int ch1, int ch2)
 
static void decode_part_stereo (DCALbrDecoder *s, int ch1, int ch2)
 Modulate by interpolated partial stereo coefficients. More...
 
static void synth_tones (DCALbrDecoder *s, int ch, float *values, int group, int group_sf, int synth_idx)
 Synthesise tones in the given group for the given tonal subframe. More...
 
static void base_func_synth (DCALbrDecoder *s, int ch, float *values, int sf)
 Synthesise all tones in all groups for the given residual subframe. More...
 
static void transform_channel (DCALbrDecoder *s, int ch, float *output)
 
int ff_dca_lbr_filter_frame (DCALbrDecoder *s, AVFrame *frame)
 
av_cold void ff_dca_lbr_flush (DCALbrDecoder *s)
 
av_cold int ff_dca_lbr_init (DCALbrDecoder *s)
 
av_cold void ff_dca_lbr_close (DCALbrDecoder *s)
 

Variables

static const int8_t channel_reorder_nolfe [7][5]
 
static const int8_t channel_reorder_lfe [7][5]
 
static const uint8_t lfe_index [7]
 
static const uint8_t channel_counts [7]
 
static const uint16_t channel_layouts [7]
 
static float cos_tab [256]
 
static float lpc_tab [16]
 

Macro Definition Documentation

◆ BITSTREAM_READER_LE

#define BITSTREAM_READER_LE

Definition at line 21 of file dca_lbr.c.

◆ AMP_MAX

#define AMP_MAX   56

Definition at line 31 of file dca_lbr.c.

Enumeration Type Documentation

◆ LBRFlags

enum LBRFlags
Enumerator
LBR_FLAG_24_BIT 
LBR_FLAG_LFE_PRESENT 
LBR_FLAG_BAND_LIMIT_2_3 
LBR_FLAG_BAND_LIMIT_1_2 
LBR_FLAG_BAND_LIMIT_1_3 
LBR_FLAG_BAND_LIMIT_1_4 
LBR_FLAG_BAND_LIMIT_1_8 
LBR_FLAG_BAND_LIMIT_NONE 
LBR_FLAG_BAND_LIMIT_MASK 
LBR_FLAG_DMIX_STEREO 
LBR_FLAG_DMIX_MULTI_CH 

Definition at line 33 of file dca_lbr.c.

◆ LBRChunkTypes

Enumerator
LBR_CHUNK_NULL 
LBR_CHUNK_PAD 
LBR_CHUNK_FRAME 
LBR_CHUNK_FRAME_NO_CSUM 
LBR_CHUNK_LFE 
LBR_CHUNK_ECS 
LBR_CHUNK_RESERVED_1 
LBR_CHUNK_RESERVED_2 
LBR_CHUNK_SCF 
LBR_CHUNK_TONAL 
LBR_CHUNK_TONAL_GRP_1 
LBR_CHUNK_TONAL_GRP_2 
LBR_CHUNK_TONAL_GRP_3 
LBR_CHUNK_TONAL_GRP_4 
LBR_CHUNK_TONAL_GRP_5 
LBR_CHUNK_TONAL_SCF 
LBR_CHUNK_TONAL_SCF_GRP_1 
LBR_CHUNK_TONAL_SCF_GRP_2 
LBR_CHUNK_TONAL_SCF_GRP_3 
LBR_CHUNK_TONAL_SCF_GRP_4 
LBR_CHUNK_TONAL_SCF_GRP_5 
LBR_CHUNK_RES_GRID_LR 
LBR_CHUNK_RES_GRID_LR_LAST 
LBR_CHUNK_RES_GRID_HR 
LBR_CHUNK_RES_GRID_HR_LAST 
LBR_CHUNK_RES_TS_1 
LBR_CHUNK_RES_TS_1_LAST 
LBR_CHUNK_RES_TS_2 
LBR_CHUNK_RES_TS_2_LAST 
LBR_CHUNK_EXTENSION 

Definition at line 47 of file dca_lbr.c.

Function Documentation

◆ init_tables()

static av_cold void init_tables ( void  )
static

Definition at line 126 of file dca_lbr.c.

Referenced by ff_dca_lbr_init().

◆ parse_lfe_24()

static int parse_lfe_24 ( DCALbrDecoder s)
static

Definition at line 143 of file dca_lbr.c.

Referenced by parse_lfe_chunk().

◆ parse_lfe_16()

static int parse_lfe_16 ( DCALbrDecoder s)
static

Definition at line 197 of file dca_lbr.c.

Referenced by parse_lfe_chunk().

◆ parse_lfe_chunk()

static int parse_lfe_chunk ( DCALbrDecoder s,
LBRChunk chunk 
)
static

Definition at line 247 of file dca_lbr.c.

Referenced by ff_dca_lbr_parse().

◆ parse_vlc()

static int parse_vlc ( GetBitContext s,
VLC vlc,
int  max_depth 
)
inlinestatic

◆ parse_tonal()

static int parse_tonal ( DCALbrDecoder s,
int  group 
)
static

Definition at line 280 of file dca_lbr.c.

Referenced by parse_tonal_chunk(), and parse_tonal_group().

◆ parse_tonal_chunk()

static int parse_tonal_chunk ( DCALbrDecoder s,
LBRChunk chunk 
)
static

Definition at line 362 of file dca_lbr.c.

Referenced by ff_dca_lbr_parse().

◆ parse_tonal_group()

static int parse_tonal_group ( DCALbrDecoder s,
LBRChunk chunk 
)
static

Definition at line 395 of file dca_lbr.c.

Referenced by ff_dca_lbr_parse().

◆ ensure_bits()

static int ensure_bits ( GetBitContext s,
int  n 
)
static

Check point to ensure that enough bits are left.

Aborts decoding by skipping to the end of chunk otherwise.

Definition at line 413 of file dca_lbr.c.

Referenced by parse_ch(), parse_grid_1_chunk(), parse_grid_1_sec_ch(), parse_grid_2(), parse_grid_3(), parse_lpc(), parse_scale_factors(), and parse_ts().

◆ parse_scale_factors()

static int parse_scale_factors ( DCALbrDecoder s,
uint8_t scf 
)
static

Definition at line 425 of file dca_lbr.c.

Referenced by parse_grid_1_chunk(), parse_grid_1_sec_ch(), and parse_high_res_grid().

◆ parse_st_code()

static int parse_st_code ( GetBitContext s,
int  min_v 
)
static

Definition at line 495 of file dca_lbr.c.

Referenced by parse_grid_1_chunk().

◆ parse_grid_1_chunk()

static int parse_grid_1_chunk ( DCALbrDecoder s,
LBRChunk chunk,
int  ch1,
int  ch2 
)
static

Definition at line 509 of file dca_lbr.c.

Referenced by ff_dca_lbr_parse().

◆ parse_grid_1_sec_ch()

static int parse_grid_1_sec_ch ( DCALbrDecoder s,
int  ch2 
)
static

Definition at line 577 of file dca_lbr.c.

Referenced by parse_ts2_chunk().

◆ parse_grid_3()

static void parse_grid_3 ( DCALbrDecoder s,
int  ch1,
int  ch2,
int  sb,
int  flag 
)
static

Definition at line 603 of file dca_lbr.c.

Referenced by parse_ts().

◆ lbr_rand()

static float lbr_rand ( DCALbrDecoder s,
int  sb 
)
static

Definition at line 625 of file dca_lbr.c.

Referenced by parse_ch(), and random_ts().

◆ parse_ch()

static void parse_ch ( DCALbrDecoder s,
int  ch,
int  sb,
int  quant_level,
int  flag 
)
static

Parse time samples for one subband, filling truncated samples with randomness.

Definition at line 634 of file dca_lbr.c.

Referenced by parse_ts().

◆ parse_ts()

static int parse_ts ( DCALbrDecoder s,
int  ch1,
int  ch2,
int  start_sb,
int  end_sb,
int  flag 
)
static

Definition at line 708 of file dca_lbr.c.

Referenced by parse_high_res_grid(), parse_ts1_chunk(), and parse_ts2_chunk().

◆ convert_lpc()

static void convert_lpc ( float *  coeff,
const int codes 
)
static

Convert from reflection coefficients to direct form coefficients.

Definition at line 771 of file dca_lbr.c.

Referenced by parse_lpc().

◆ parse_lpc()

static int parse_lpc ( DCALbrDecoder s,
int  ch1,
int  ch2,
int  start_sb,
int  end_sb 
)
static

Definition at line 787 of file dca_lbr.c.

Referenced by parse_high_res_grid(), and parse_ts1_chunk().

◆ parse_high_res_grid()

static int parse_high_res_grid ( DCALbrDecoder s,
LBRChunk chunk,
int  ch1,
int  ch2 
)
static

Definition at line 808 of file dca_lbr.c.

Referenced by ff_dca_lbr_parse().

◆ parse_grid_2()

static int parse_grid_2 ( DCALbrDecoder s,
int  ch1,
int  ch2,
int  start_sb,
int  end_sb,
int  flag 
)
static

Definition at line 870 of file dca_lbr.c.

Referenced by parse_ts1_chunk(), and parse_ts2_chunk().

◆ parse_ts1_chunk()

static int parse_ts1_chunk ( DCALbrDecoder s,
LBRChunk chunk,
int  ch1,
int  ch2 
)
static

Definition at line 912 of file dca_lbr.c.

Referenced by ff_dca_lbr_parse().

◆ parse_ts2_chunk()

static int parse_ts2_chunk ( DCALbrDecoder s,
LBRChunk chunk,
int  ch1,
int  ch2 
)
static

Definition at line 930 of file dca_lbr.c.

Referenced by ff_dca_lbr_parse().

◆ init_sample_rate()

static int init_sample_rate ( DCALbrDecoder s)
static

Definition at line 953 of file dca_lbr.c.

Referenced by parse_decoder_init().

◆ alloc_sample_buffer()

static int alloc_sample_buffer ( DCALbrDecoder s)
static

Definition at line 991 of file dca_lbr.c.

Referenced by parse_decoder_init().

◆ parse_decoder_init()

static int parse_decoder_init ( DCALbrDecoder s,
GetByteContext gb 
)
static

Definition at line 1015 of file dca_lbr.c.

Referenced by ff_dca_lbr_parse().

◆ ff_dca_lbr_parse()

int ff_dca_lbr_parse ( DCALbrDecoder s,
uint8_t data,
DCAExssAsset asset 
)

Definition at line 1167 of file dca_lbr.c.

Referenced by dcadec_decode_frame().

◆ decode_grid()

static void decode_grid ( DCALbrDecoder s,
int  ch1,
int  ch2 
)
static

Reconstruct high-frequency resolution grid from first and third grids.

Definition at line 1404 of file dca_lbr.c.

Referenced by ff_dca_lbr_filter_frame().

◆ random_ts()

static void random_ts ( DCALbrDecoder s,
int  ch1,
int  ch2 
)
static

Fill unallocated subbands with randomness.

Definition at line 1441 of file dca_lbr.c.

Referenced by ff_dca_lbr_filter_frame().

◆ predict()

static void predict ( float *  samples,
const float *  coeff,
int  nsamples 
)
static

Definition at line 1477 of file dca_lbr.c.

Referenced by synth_lpc().

◆ synth_lpc()

static void synth_lpc ( DCALbrDecoder s,
int  ch1,
int  ch2,
int  sb 
)
static

Definition at line 1489 of file dca_lbr.c.

Referenced by filter_ts().

◆ filter_ts()

static void filter_ts ( DCALbrDecoder s,
int  ch1,
int  ch2 
)
static

Definition at line 1511 of file dca_lbr.c.

Referenced by ff_dca_lbr_filter_frame().

◆ decode_part_stereo()

static void decode_part_stereo ( DCALbrDecoder s,
int  ch1,
int  ch2 
)
static

Modulate by interpolated partial stereo coefficients.

Definition at line 1596 of file dca_lbr.c.

Referenced by ff_dca_lbr_filter_frame().

◆ synth_tones()

static void synth_tones ( DCALbrDecoder s,
int  ch,
float *  values,
int  group,
int  group_sf,
int  synth_idx 
)
static

Synthesise tones in the given group for the given tonal subframe.

Definition at line 1622 of file dca_lbr.c.

Referenced by base_func_synth().

◆ base_func_synth()

static void base_func_synth ( DCALbrDecoder s,
int  ch,
float *  values,
int  sf 
)
static

Synthesise all tones in all groups for the given residual subframe.

Definition at line 1686 of file dca_lbr.c.

Referenced by transform_channel().

◆ transform_channel()

static void transform_channel ( DCALbrDecoder s,
int  ch,
float *  output 
)
static

Definition at line 1700 of file dca_lbr.c.

Referenced by ff_dca_lbr_filter_frame().

◆ ff_dca_lbr_filter_frame()

int ff_dca_lbr_filter_frame ( DCALbrDecoder s,
AVFrame frame 
)

Definition at line 1734 of file dca_lbr.c.

Referenced by dcadec_decode_frame().

◆ ff_dca_lbr_flush()

av_cold void ff_dca_lbr_flush ( DCALbrDecoder s)

Definition at line 1794 of file dca_lbr.c.

Referenced by dcadec_flush(), and parse_decoder_init().

◆ ff_dca_lbr_init()

av_cold int ff_dca_lbr_init ( DCALbrDecoder s)

Definition at line 1818 of file dca_lbr.c.

Referenced by dcadec_init().

◆ ff_dca_lbr_close()

av_cold void ff_dca_lbr_close ( DCALbrDecoder s)

Definition at line 1829 of file dca_lbr.c.

Referenced by dcadec_close().

Variable Documentation

◆ channel_reorder_nolfe

const int8_t channel_reorder_nolfe[7][5]
static
Initial value:
= {
{ 0, -1, -1, -1, -1 },
{ 0, 1, -1, -1, -1 },
{ 0, 1, 2, -1, -1 },
{ 0, 1, -1, -1, -1 },
{ 1, 2, 0, -1, -1 },
{ 0, 1, 2, 3, -1 },
{ 0, 1, 3, 4, 2 },
}

Definition at line 85 of file dca_lbr.c.

Referenced by encode_init(), and ff_dca_lbr_filter_frame().

◆ channel_reorder_lfe

const int8_t channel_reorder_lfe[7][5]
static
Initial value:
= {
{ 0, -1, -1, -1, -1 },
{ 0, 1, -1, -1, -1 },
{ 0, 1, 2, -1, -1 },
{ 1, 2, -1, -1, -1 },
{ 2, 3, 0, -1, -1 },
{ 0, 1, 3, 4, -1 },
{ 0, 1, 4, 5, 2 },
}

Definition at line 95 of file dca_lbr.c.

Referenced by encode_init(), and ff_dca_lbr_filter_frame().

◆ lfe_index

const uint8_t lfe_index[7]
static
Initial value:
= {
1, 2, 3, 0, 1, 2, 3
}

Definition at line 105 of file dca_lbr.c.

Referenced by ff_dca_lbr_filter_frame(), and lfe_downsample().

◆ channel_counts

const uint8_t channel_counts[7]
static
Initial value:
= {
1, 2, 3, 2, 3, 4, 5
}

Definition at line 109 of file dca_lbr.c.

Referenced by asink_query_formats(), ff_dca_lbr_filter_frame(), and get_stream_info().

◆ channel_layouts

const uint16_t channel_layouts[7]
static

◆ cos_tab

float cos_tab[256]
static

Definition at line 123 of file dca_lbr.c.

Referenced by eval_lpcenv_or_interp(), get_cos(), init_tables(), lpc2lsp(), lsp2lpc(), and synth_tones().

◆ lpc_tab

float lpc_tab[16]
static

Definition at line 124 of file dca_lbr.c.

Referenced by convert_lpc(), and init_tables().

AV_CH_LAYOUT_MONO
#define AV_CH_LAYOUT_MONO
Definition: channel_layout.h:85
AV_CH_LAYOUT_STEREO
#define AV_CH_LAYOUT_STEREO
Definition: channel_layout.h:86
AV_CH_FRONT_CENTER
#define AV_CH_FRONT_CENTER
Definition: channel_layout.h:51
AV_CH_LAYOUT_5POINT0
#define AV_CH_LAYOUT_5POINT0
Definition: channel_layout.h:95
AV_CH_SIDE_RIGHT
#define AV_CH_SIDE_RIGHT
Definition: channel_layout.h:59
AV_CH_LAYOUT_SURROUND
#define AV_CH_LAYOUT_SURROUND
Definition: channel_layout.h:89
AV_CH_LAYOUT_2_2
#define AV_CH_LAYOUT_2_2
Definition: channel_layout.h:93
AV_CH_SIDE_LEFT
#define AV_CH_SIDE_LEFT
Definition: channel_layout.h:58