dcaenc.c File Reference
#include "libavutil/channel_layout.h"
#include "libavutil/common.h"
#include "libavutil/avassert.h"
#include "avcodec.h"
#include "internal.h"
#include "put_bits.h"
#include "dcaenc.h"
#include "dcadata.h"
#include "dca.h"
Include dependency graph for dcaenc.c:

Go to the source code of this file.

Data Structures

struct  DCAContext
 

Macros

#define MAX_CHANNELS   6
 
#define DCA_SUBBANDS_32   32
 
#define DCA_MAX_FRAME_SIZE   16383
 
#define DCA_HEADER_SIZE   13
 
#define DCA_SUBBANDS   32
 Subband activity count. More...
 
#define QUANTIZER_BITS   16
 
#define SUBFRAMES   1
 
#define SUBSUBFRAMES   4
 
#define PCM_SAMPLES   (SUBFRAMES*SUBSUBFRAMES*8)
 
#define LFE_BITS   8
 
#define LFE_INTERPOLATION   64
 
#define LFE_PRESENT   2
 
#define LFE_MISSING   0
 

Functions

static int32_t mul32 (int32_t a, int32_t b)
 
static void qmf_init (void)
 
static int32_t band_delta_factor (int band, int sample_num)
 
static void add_new_samples (DCAContext *c, const int32_t *in, int count, int channel)
 
static void qmf_decompose (DCAContext *c, int32_t in[32], int32_t out[32], int channel)
 
static int lfe_downsample (DCAContext *c, int32_t in[LFE_INTERPOLATION])
 
static void init_lfe_fir (void)
 
static void put_frame_header (DCAContext *c)
 
static void put_primary_audio_header (DCAContext *c)
 
static uint32_t quantize (int32_t sample, int bits)
 8-23 bits quantization More...
 
static int find_scale_factor7 (int64_t max_value, int bits)
 
static void put_sample7 (DCAContext *c, int64_t sample, int bits, int scale_factor)
 
static void put_subframe (DCAContext *c, int32_t subband_data[8 *SUBSUBFRAMES][MAX_CHANNELS][32], int subframe)
 
static void put_frame (DCAContext *c, int32_t subband_data[PCM_SAMPLES][MAX_CHANNELS][32], uint8_t *frame)
 
static int encode_frame (AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
 
static int encode_init (AVCodecContext *avctx)
 

Variables

static const int8_t dca_lfe_index []
 
static const int8_t dca_channel_reorder_lfe [][9]
 
static const int8_t dca_channel_reorder_nolfe [][9]
 
static int32_t cos_table [128]
 
static int32_t lfe_fir_64i [512]
 
AVCodec ff_dca_encoder
 

Macro Definition Documentation

#define DCA_HEADER_SIZE   13

Definition at line 39 of file dcaenc.c.

Referenced by encode_frame(), and put_frame().

#define DCA_MAX_FRAME_SIZE   16383

Definition at line 38 of file dcaenc.c.

Referenced by encode_frame(), and put_frame().

#define DCA_SUBBANDS   32

Subband activity count.

Definition at line 41 of file dcaenc.c.

Referenced by put_primary_audio_header(), and put_subframe().

#define DCA_SUBBANDS_32   32

Definition at line 37 of file dcaenc.c.

Referenced by qmf_decompose().

#define LFE_BITS   8

Definition at line 46 of file dcaenc.c.

Referenced by put_subframe().

#define LFE_INTERPOLATION   64

Definition at line 47 of file dcaenc.c.

Referenced by encode_frame().

#define LFE_MISSING   0

Definition at line 49 of file dcaenc.c.

Referenced by encode_init().

#define LFE_PRESENT   2

Definition at line 48 of file dcaenc.c.

Referenced by encode_init().

#define MAX_CHANNELS   6

Definition at line 36 of file dcaenc.c.

#define PCM_SAMPLES   (SUBFRAMES*SUBSUBFRAMES*8)

Definition at line 45 of file dcaenc.c.

Referenced by encode_frame(), encode_init(), and put_frame_header().

#define QUANTIZER_BITS   16

Definition at line 42 of file dcaenc.c.

Referenced by put_subframe().

#define SUBSUBFRAMES   4

Definition at line 44 of file dcaenc.c.

Referenced by put_frame(), and put_subframe().

Function Documentation

static void add_new_samples ( DCAContext c,
const int32_t in,
int  count,
int  channel 
)
static

Definition at line 159 of file dcaenc.c.

Referenced by lfe_downsample(), and qmf_decompose().

static int32_t band_delta_factor ( int  band,
int  sample_num 
)
static

Definition at line 150 of file dcaenc.c.

Referenced by qmf_decompose().

static int encode_frame ( AVCodecContext avctx,
AVPacket avpkt,
const AVFrame frame,
int *  got_packet_ptr 
)
static

Definition at line 492 of file dcaenc.c.

static int encode_init ( AVCodecContext avctx)
static

Definition at line 533 of file dcaenc.c.

static int find_scale_factor7 ( int64_t  max_value,
int  bits 
)
inlinestatic

Definition at line 372 of file dcaenc.c.

Referenced by put_subframe().

static void init_lfe_fir ( void  )
static

Definition at line 219 of file dcaenc.c.

Referenced by encode_init().

static int lfe_downsample ( DCAContext c,
int32_t  in[LFE_INTERPOLATION] 
)
static

Definition at line 205 of file dcaenc.c.

Referenced by encode_frame().

static int32_t mul32 ( int32_t  a,
int32_t  b 
)
inlinestatic

Definition at line 117 of file dcaenc.c.

Referenced by lfe_downsample(), qmf_decompose(), and qmf_init().

static void put_frame ( DCAContext c,
int32_t  subband_data[PCM_SAMPLES][MAX_CHANNELS][32],
uint8_t frame 
)
static

Definition at line 473 of file dcaenc.c.

Referenced by encode_frame().

static void put_frame_header ( DCAContext c)
static

Definition at line 231 of file dcaenc.c.

Referenced by put_frame().

static void put_primary_audio_header ( DCAContext c)
static

Definition at line 314 of file dcaenc.c.

Referenced by put_frame().

static void put_sample7 ( DCAContext c,
int64_t  sample,
int  bits,
int  scale_factor 
)
inlinestatic

Definition at line 387 of file dcaenc.c.

Referenced by put_subframe().

static void put_subframe ( DCAContext c,
int32_t  subband_data[8 *SUBSUBFRAMES][MAX_CHANNELS][32],
int  subframe 
)
static

Definition at line 394 of file dcaenc.c.

Referenced by put_frame().

static void qmf_decompose ( DCAContext c,
int32_t  in[32],
int32_t  out[32],
int  channel 
)
static

Definition at line 175 of file dcaenc.c.

Referenced by encode_frame().

static void qmf_init ( void  )
static

Definition at line 126 of file dcaenc.c.

Referenced by encode_init().

static uint32_t quantize ( int32_t  sample,
int  bits 
)
inlinestatic

8-23 bits quantization

Parameters
sample
bits

Definition at line 365 of file dcaenc.c.

Referenced by put_sample7().

Variable Documentation

int32_t cos_table[128]
static

Definition at line 115 of file dcaenc.c.

Referenced by band_delta_factor(), encode_init(), and qmf_init().

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

Definition at line 55 of file dcaenc.c.

Referenced by encode_init().

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

Definition at line 74 of file dcaenc.c.

Referenced by encode_init().

const int8_t dca_lfe_index[]
static
Initial value:
= {
1,2,2,2,2,3,2,3,2,3,2,3,1,3,2,3
}

Definition at line 51 of file dcaenc.c.

Referenced by encode_init().

AVCodec ff_dca_encoder
Initial value:
= {
.name = "dca",
.priv_data_size = sizeof(DCAContext),
.encode2 = encode_frame,
.capabilities = CODEC_CAP_EXPERIMENTAL,
.long_name = NULL_IF_CONFIG_SMALL("DCA (DTS Coherent Acoustics)"),
}
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
static int encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
Definition: dcaenc.c:492
signed 16 bits
Definition: samplefmt.h:52
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static int encode_init(AVCodecContext *avctx)
Definition: dcaenc.c:533
AVSampleFormat
Audio Sample Formats.
Definition: samplefmt.h:49
#define CODEC_CAP_EXPERIMENTAL
Codec is experimental and is thus avoided in favor of non experimental encoders.
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:700

Definition at line 591 of file dcaenc.c.

int32_t lfe_fir_64i[512]
static

Definition at line 204 of file dcaenc.c.

Referenced by init_lfe_fir(), and lfe_downsample().