FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions | Variables
dcadec.c File Reference
#include <math.h>
#include <stddef.h>
#include <stdio.h>
#include "libavutil/attributes.h"
#include "libavutil/channel_layout.h"
#include "libavutil/common.h"
#include "libavutil/float_dsp.h"
#include "libavutil/internal.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mathematics.h"
#include "libavutil/opt.h"
#include "libavutil/samplefmt.h"
#include "avcodec.h"
#include "dca.h"
#include "dca_syncwords.h"
#include "dcadata.h"
#include "dcadsp.h"
#include "dcahuff.h"
#include "fft.h"
#include "fmtconvert.h"
#include "get_bits.h"
#include "internal.h"
#include "mathops.h"
#include "synth_filter.h"

Go to the source code of this file.

Data Structures

struct  BitAlloc
 Bit allocation. More...
 

Macros

#define DCA_DOLBY   101 /* FIXME */
 
#define DCA_CHANNEL_BITS   6
 
#define DCA_CHANNEL_MASK   0x3F
 
#define DCA_LFE   0x80
 
#define HEADER_SIZE   14
 
#define DCA_NSYNCAUX   0x9A1105A0
 
#define MIX_REAR1(samples, s1, rs, coef)
 
#define MIX_REAR2(samples, s1, s2, rs, coef)
 
#define MIX_FRONT3(samples, coef)
 
#define DOWNMIX_TO_STEREO(op1, op2)
 

Enumerations

enum  DCAMode {
  DCA_MONO = 0, DCA_CHANNEL, DCA_STEREO, DCA_STEREO_SUMDIFF,
  DCA_STEREO_TOTAL, DCA_3F, DCA_2F1R, DCA_3F1R,
  DCA_2F2R, DCA_3F2R, DCA_4F2R
}
 
enum  DCAXxchSpeakerMask {
  DCA_XXCH_FRONT_CENTER = 0x0000001, DCA_XXCH_FRONT_LEFT = 0x0000002, DCA_XXCH_FRONT_RIGHT = 0x0000004, DCA_XXCH_SIDE_REAR_LEFT = 0x0000008,
  DCA_XXCH_SIDE_REAR_RIGHT = 0x0000010, DCA_XXCH_LFE1 = 0x0000020, DCA_XXCH_REAR_CENTER = 0x0000040, DCA_XXCH_SURROUND_REAR_LEFT = 0x0000080,
  DCA_XXCH_SURROUND_REAR_RIGHT = 0x0000100, DCA_XXCH_SIDE_SURROUND_LEFT = 0x0000200, DCA_XXCH_SIDE_SURROUND_RIGHT = 0x0000400, DCA_XXCH_FRONT_CENTER_LEFT = 0x0000800,
  DCA_XXCH_FRONT_CENTER_RIGHT = 0x0001000, DCA_XXCH_FRONT_HIGH_LEFT = 0x0002000, DCA_XXCH_FRONT_HIGH_CENTER = 0x0004000, DCA_XXCH_FRONT_HIGH_RIGHT = 0x0008000,
  DCA_XXCH_LFE2 = 0x0010000, DCA_XXCH_SIDE_FRONT_LEFT = 0x0020000, DCA_XXCH_SIDE_FRONT_RIGHT = 0x0040000, DCA_XXCH_OVERHEAD = 0x0080000,
  DCA_XXCH_SIDE_HIGH_LEFT = 0x0100000, DCA_XXCH_SIDE_HIGH_RIGHT = 0x0200000, DCA_XXCH_REAR_HIGH_CENTER = 0x0400000, DCA_XXCH_REAR_HIGH_LEFT = 0x0800000,
  DCA_XXCH_REAR_HIGH_RIGHT = 0x1000000, DCA_XXCH_REAR_LOW_CENTER = 0x2000000, DCA_XXCH_REAR_LOW_LEFT = 0x4000000, DCA_XXCH_REAR_LOW_RIGHT = 0x8000000
}
 

Functions

static av_always_inline int get_bitalloc (GetBitContext *gb, BitAlloc *ba, int idx)
 
static float dca_dmix_code (unsigned code)
 
static av_cold void dca_init_vlcs (void)
 
static void get_array (GetBitContext *gb, int *dst, int len, int bits)
 
static int dca_xxch2index (DCAContext *s, int xxch_ch)
 
static int dca_parse_audio_coding_header (DCAContext *s, int base_channel, int xxch)
 
static int dca_parse_frame_header (DCAContext *s)
 
static int get_scale (GetBitContext *gb, int level, int value, int log2range)
 
static int dca_subframe_header (DCAContext *s, int base_channel, int block_index)
 
static void qmf_32_subbands (DCAContext *s, int chans, float samples_in[32][8], float *samples_out, float scale)
 
static QMF64_tableqmf64_precompute (void)
 
static void qmf_64_subbands (DCAContext *s, int chans, float samples_in[64][8], float *samples_out, float scale)
 
static void lfe_interpolation_fir (DCAContext *s, const float *samples_in, float *samples_out)
 
static void dca_downmix (float **samples, int srcfmt, int lfe_present, float coef[DCA_PRIM_CHANNELS_MAX+1][2], const int8_t *channel_mapping)
 
static int decode_blockcode (int code, int levels, int32_t *values)
 
static int decode_blockcodes (int code1, int code2, int levels, int32_t *values)
 
static int dca_subsubframe (DCAContext *s, int base_channel, int block_index)
 
static int dca_filter_channels (DCAContext *s, int block_index, int upsample)
 
static int dca_subframe_footer (DCAContext *s, int base_channel)
 
static int dca_decode_block (DCAContext *s, int base_channel, int block_index)
 Decode a dca frame block. More...
 
int ff_dca_xbr_parse_frame (DCAContext *s)
 
int ff_dca_xxch_decode_frame (DCAContext *s)
 
static int dca_decode_frame (AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
 Main frame decoding function FIXME add arguments. More...
 
static av_cold int dca_decode_init (AVCodecContext *avctx)
 DCA initialization. More...
 
static av_cold int dca_decode_end (AVCodecContext *avctx)
 

Variables

static BitAlloc dca_bitalloc_index
 indexes for samples VLC select More...
 
static BitAlloc dca_tmode
 transition mode VLCs More...
 
static BitAlloc dca_scalefactor
 scalefactor VLCs More...
 
static BitAlloc dca_smpl_bitalloc [11]
 samples VLCs More...
 
static const uint8_t abits_sizes [7] = { 7, 10, 12, 13, 15, 17, 19 }
 
static const uint8_t abits_levels [7] = { 3, 5, 7, 9, 13, 17, 25 }
 
static const AVProfile profiles []
 
static const AVOption options []
 
static const AVClass dca_decoder_class
 
AVCodec ff_dca_decoder
 

Macro Definition Documentation

#define DCA_DOLBY   101 /* FIXME */

Definition at line 104 of file dcadec.c.

#define DCA_CHANNEL_BITS   6

Definition at line 106 of file dcadec.c.

#define DCA_CHANNEL_MASK   0x3F

Definition at line 107 of file dcadec.c.

Referenced by dca_decode_frame().

#define DCA_LFE   0x80

Definition at line 109 of file dcadec.c.

Referenced by dca_decode_frame(), and dca_parse_frame_header().

#define HEADER_SIZE   14

Definition at line 111 of file dcadec.c.

#define DCA_NSYNCAUX   0x9A1105A0

Definition at line 113 of file dcadec.c.

Referenced by dca_subframe_footer().

#define MIX_REAR1 (   samples,
  s1,
  rs,
  coef 
)
Value:
samples[0][i] += samples[s1][i] * coef[rs][0]; \
samples[1][i] += samples[s1][i] * coef[rs][1];
#define s1
Definition: regdef.h:38

Definition at line 752 of file dcadec.c.

Referenced by dca_downmix().

#define MIX_REAR2 (   samples,
  s1,
  s2,
  rs,
  coef 
)
Value:
samples[0][i] += samples[s1][i] * coef[rs][0] + samples[s2][i] * coef[rs + 1][0]; \
samples[1][i] += samples[s1][i] * coef[rs][1] + samples[s2][i] * coef[rs + 1][1];
#define s2
Definition: regdef.h:39
#define s1
Definition: regdef.h:38

Definition at line 756 of file dcadec.c.

Referenced by dca_downmix().

#define MIX_FRONT3 (   samples,
  coef 
)
Value:
t = samples[c][i]; \
u = samples[l][i]; \
v = samples[r][i]; \
samples[0][i] = t * coef[0][0] + u * coef[1][0] + v * coef[2][0]; \
samples[1][i] = t * coef[0][1] + u * coef[1][1] + v * coef[2][1];
float v
const char * r
Definition: vf_curves.c:107
float u
static double c[64]

Definition at line 760 of file dcadec.c.

Referenced by dca_downmix().

#define DOWNMIX_TO_STEREO (   op1,
  op2 
)
Value:
for (i = 0; i < 256; i++) { \
op1 \
op2 \
}

Definition at line 767 of file dcadec.c.

Referenced by dca_downmix().

Enumeration Type Documentation

enum DCAMode
Enumerator
DCA_MONO 
DCA_CHANNEL 
DCA_STEREO 
DCA_STEREO_SUMDIFF 
DCA_STEREO_TOTAL 
DCA_3F 
DCA_2F1R 
DCA_3F1R 
DCA_2F2R 
DCA_3F2R 
DCA_4F2R 

Definition at line 58 of file dcadec.c.

Enumerator
DCA_XXCH_FRONT_CENTER 
DCA_XXCH_FRONT_LEFT 
DCA_XXCH_FRONT_RIGHT 
DCA_XXCH_SIDE_REAR_LEFT 
DCA_XXCH_SIDE_REAR_RIGHT 
DCA_XXCH_LFE1 
DCA_XXCH_REAR_CENTER 
DCA_XXCH_SURROUND_REAR_LEFT 
DCA_XXCH_SURROUND_REAR_RIGHT 
DCA_XXCH_SIDE_SURROUND_LEFT 
DCA_XXCH_SIDE_SURROUND_RIGHT 
DCA_XXCH_FRONT_CENTER_LEFT 
DCA_XXCH_FRONT_CENTER_RIGHT 
DCA_XXCH_FRONT_HIGH_LEFT 
DCA_XXCH_FRONT_HIGH_CENTER 
DCA_XXCH_FRONT_HIGH_RIGHT 
DCA_XXCH_LFE2 
DCA_XXCH_SIDE_FRONT_LEFT 
DCA_XXCH_SIDE_FRONT_RIGHT 
DCA_XXCH_OVERHEAD 
DCA_XXCH_SIDE_HIGH_LEFT 
DCA_XXCH_SIDE_HIGH_RIGHT 
DCA_XXCH_REAR_HIGH_CENTER 
DCA_XXCH_REAR_HIGH_LEFT 
DCA_XXCH_REAR_HIGH_RIGHT 
DCA_XXCH_REAR_LOW_CENTER 
DCA_XXCH_REAR_LOW_LEFT 
DCA_XXCH_REAR_LOW_RIGHT 

Definition at line 73 of file dcadec.c.

Function Documentation

static av_always_inline int get_bitalloc ( GetBitContext gb,
BitAlloc ba,
int  idx 
)
static

Definition at line 129 of file dcadec.c.

Referenced by dca_subframe_header(), dca_subsubframe(), and get_scale().

static float dca_dmix_code ( unsigned  code)
static

Definition at line 1449 of file dcadec.c.

Referenced by dca_decode_frame(), and dca_parse_audio_coding_header().

static av_cold void dca_init_vlcs ( void  )
static

Definition at line 138 of file dcadec.c.

Referenced by dca_decode_init().

static void get_array ( GetBitContext gb,
int *  dst,
int  len,
int  bits 
)
inlinestatic

Definition at line 193 of file dcadec.c.

Referenced by dca_parse_audio_coding_header(), and ff_dca_xbr_parse_frame().

static int dca_xxch2index ( DCAContext s,
int  xxch_ch 
)
inlinestatic

Definition at line 199 of file dcadec.c.

Referenced by dca_parse_audio_coding_header().

static int dca_parse_audio_coding_header ( DCAContext s,
int  base_channel,
int  xxch 
)
static

Definition at line 211 of file dcadec.c.

Referenced by dca_decode_frame(), dca_parse_frame_header(), and ff_dca_xxch_decode_frame().

static int dca_parse_frame_header ( DCAContext s)
static

Definition at line 349 of file dcadec.c.

Referenced by dca_decode_frame().

static int get_scale ( GetBitContext gb,
int  level,
int  value,
int  log2range 
)
inlinestatic

Definition at line 413 of file dcadec.c.

Referenced by dca_subframe_header().

static int dca_subframe_header ( DCAContext s,
int  base_channel,
int  block_index 
)
static

Definition at line 430 of file dcadec.c.

Referenced by dca_decode_block().

static void qmf_32_subbands ( DCAContext s,
int  chans,
float  samples_in[32][8],
float *  samples_out,
float  scale 
)
static

Definition at line 618 of file dcadec.c.

Referenced by dca_filter_channels().

static QMF64_table* qmf64_precompute ( void  )
static

Definition at line 641 of file dcadec.c.

Referenced by dca_filter_channels().

static void qmf_64_subbands ( DCAContext s,
int  chans,
float  samples_in[64][8],
float *  samples_out,
float  scale 
)
static

Definition at line 667 of file dcadec.c.

Referenced by dca_filter_channels().

static void lfe_interpolation_fir ( DCAContext s,
const float *  samples_in,
float *  samples_out 
)
static

Definition at line 717 of file dcadec.c.

Referenced by dca_filter_channels().

static void dca_downmix ( float **  samples,
int  srcfmt,
int  lfe_present,
float  coef[DCA_PRIM_CHANNELS_MAX+1][2],
const int8_t *  channel_mapping 
)
static

Definition at line 773 of file dcadec.c.

Referenced by dca_filter_channels().

static int decode_blockcode ( int  code,
int  levels,
int32_t values 
)
static

Definition at line 837 of file dcadec.c.

Referenced by decode_blockcodes().

static int decode_blockcodes ( int  code1,
int  code2,
int  levels,
int32_t values 
)
static

Definition at line 851 of file dcadec.c.

Referenced by dca_subsubframe(), and ff_dca_xbr_parse_frame().

static int dca_subsubframe ( DCAContext s,
int  base_channel,
int  block_index 
)
static

Definition at line 861 of file dcadec.c.

Referenced by dca_decode_block().

static int dca_filter_channels ( DCAContext s,
int  block_index,
int  upsample 
)
static

Definition at line 1013 of file dcadec.c.

Referenced by dca_decode_frame().

static int dca_subframe_footer ( DCAContext s,
int  base_channel 
)
static

Definition at line 1073 of file dcadec.c.

Referenced by dca_decode_block().

static int dca_decode_block ( DCAContext s,
int  base_channel,
int  block_index 
)
static

Decode a dca frame block.

Parameters
spointer to the DCAContext

Definition at line 1182 of file dcadec.c.

Referenced by dca_decode_frame(), and ff_dca_xxch_decode_frame().

int ff_dca_xbr_parse_frame ( DCAContext s)

Definition at line 1218 of file dcadec.c.

Referenced by ff_dca_exss_parse_header().

int ff_dca_xxch_decode_frame ( DCAContext s)

Definition at line 1396 of file dcadec.c.

Referenced by dca_decode_frame(), and ff_dca_exss_parse_header().

static int dca_decode_frame ( AVCodecContext avctx,
void data,
int *  got_frame_ptr,
AVPacket avpkt 
)
static

Main frame decoding function FIXME add arguments.

Definition at line 1460 of file dcadec.c.

static av_cold int dca_decode_init ( AVCodecContext avctx)
static

DCA initialization.

Parameters
avctxpointer to the AVCodecContext

Definition at line 1984 of file dcadec.c.

static av_cold int dca_decode_end ( AVCodecContext avctx)
static

Definition at line 2016 of file dcadec.c.

Variable Documentation

BitAlloc dca_bitalloc_index
static

indexes for samples VLC select

Definition at line 124 of file dcadec.c.

BitAlloc dca_tmode
static

transition mode VLCs

Definition at line 125 of file dcadec.c.

BitAlloc dca_scalefactor
static

scalefactor VLCs

Definition at line 126 of file dcadec.c.

BitAlloc dca_smpl_bitalloc[11]
static

samples VLCs

Definition at line 127 of file dcadec.c.

const uint8_t abits_sizes[7] = { 7, 10, 12, 13, 15, 17, 19 }
static

Definition at line 858 of file dcadec.c.

Referenced by dca_subsubframe(), and ff_dca_xbr_parse_frame().

const uint8_t abits_levels[7] = { 3, 5, 7, 9, 13, 17, 25 }
static

Definition at line 859 of file dcadec.c.

Referenced by dca_subsubframe(), and ff_dca_xbr_parse_frame().

const AVProfile profiles[]
static
Initial value:
= {
{ FF_PROFILE_DTS, "DTS" },
{ FF_PROFILE_DTS_ES, "DTS-ES" },
{ FF_PROFILE_DTS_96_24, "DTS 96/24" },
{ FF_PROFILE_DTS_HD_HRA, "DTS-HD HRA" },
{ FF_PROFILE_DTS_HD_MA, "DTS-HD MA" },
}
#define FF_PROFILE_DTS_ES
Definition: avcodec.h:2851
#define FF_PROFILE_UNKNOWN
Definition: avcodec.h:2836
#define FF_PROFILE_DTS_96_24
Definition: avcodec.h:2852
#define FF_PROFILE_DTS
Definition: avcodec.h:2850
#define FF_PROFILE_DTS_HD_HRA
Definition: avcodec.h:2853
#define FF_PROFILE_DTS_HD_MA
Definition: avcodec.h:2854

Definition at line 2027 of file dcadec.c.

const AVOption options[]
static
Initial value:
= {
{ "disable_xch", "disable decoding of the XCh extension", 0x42, AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM },
{ "disable_xll", "disable decoding of the XLL extension", 0x42, AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM },
{ NULL },
}
#define NULL
Definition: coverity.c:32
#define AV_OPT_FLAG_AUDIO_PARAM
Definition: opt.h:290
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
Definition: opt.h:286

Definition at line 2036 of file dcadec.c.

const AVClass dca_decoder_class
static
Initial value:
= {
.class_name = "DCA decoder",
.item_name = av_default_item_name,
.option = options,
}
#define LIBAVUTIL_VERSION_INT
Definition: version.h:62
av_default_item_name
static const AVOption options[]
Definition: dcadec.c:2036

Definition at line 2042 of file dcadec.c.

AVCodec ff_dca_decoder
Initial value:
= {
.name = "dca",
.long_name = NULL_IF_CONFIG_SMALL("DCA (DTS Coherent Acoustics)"),
.priv_data_size = sizeof(DCAContext),
.close = dca_decode_end,
.priv_class = &dca_decoder_class,
}
float, planar
Definition: samplefmt.h:70
static const AVProfile profiles[]
Definition: dcadec.c:2027
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
static av_cold int dca_decode_end(AVCodecContext *avctx)
Definition: dcadec.c:2016
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Definition: avcodec.h:789
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:175
static int dca_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
Main frame decoding function FIXME add arguments.
Definition: dcadec.c:1460
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:59
static av_cold int dca_decode_init(AVCodecContext *avctx)
DCA initialization.
Definition: dcadec.c:1984
static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avpkt)
Definition: ccaption_dec.c:522
#define CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
Definition: avcodec.h:856
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:701
static const AVClass dca_decoder_class
Definition: dcadec.c:2042

Definition at line 2050 of file dcadec.c.