FFmpeg
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
dcaenc.c File Reference
#include "libavutil/channel_layout.h"
#include "libavutil/common.h"
#include "libavutil/avassert.h"
#include "avcodec.h"
#include "get_bits.h"
#include "internal.h"
#include "put_bits.h"
#include "dcaenc.h"
#include "dcadata.h"
#include "dca.h"

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.
 
#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
 
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 MAX_CHANNELS   6

Definition at line 37 of file dcaenc.c.

#define DCA_SUBBANDS_32   32

Definition at line 38 of file dcaenc.c.

Referenced by qmf_decompose().

#define DCA_MAX_FRAME_SIZE   16383

Definition at line 39 of file dcaenc.c.

Referenced by encode_frame(), and put_frame().

#define DCA_HEADER_SIZE   13

Definition at line 40 of file dcaenc.c.

Referenced by encode_frame(), and put_frame().

#define DCA_SUBBANDS   32

Subband activity count.

Definition at line 42 of file dcaenc.c.

Referenced by put_primary_audio_header(), and put_subframe().

#define QUANTIZER_BITS   16

Definition at line 43 of file dcaenc.c.

Referenced by put_subframe().

#define SUBFRAMES   1
#define SUBSUBFRAMES   4

Definition at line 45 of file dcaenc.c.

Referenced by put_frame(), and put_subframe().

#define PCM_SAMPLES   (SUBFRAMES*SUBSUBFRAMES*8)

Definition at line 46 of file dcaenc.c.

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

#define LFE_BITS   8

Definition at line 47 of file dcaenc.c.

Referenced by put_subframe().

#define LFE_INTERPOLATION   64

Definition at line 48 of file dcaenc.c.

Referenced by encode_frame().

#define LFE_PRESENT   2

Definition at line 49 of file dcaenc.c.

Referenced by encode_init().

#define LFE_MISSING   0

Definition at line 50 of file dcaenc.c.

Referenced by encode_init().

Function Documentation

static int32_t mul32 ( int32_t  a,
int32_t  b 
)
inlinestatic

Definition at line 118 of file dcaenc.c.

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

static void qmf_init ( void  )
static

Definition at line 127 of file dcaenc.c.

Referenced by encode_init().

static int32_t band_delta_factor ( int  band,
int  sample_num 
)
static

Definition at line 151 of file dcaenc.c.

Referenced by qmf_decompose().

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

Definition at line 160 of file dcaenc.c.

Referenced by lfe_downsample(), and qmf_decompose().

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

Definition at line 176 of file dcaenc.c.

Referenced by encode_frame().

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

Definition at line 206 of file dcaenc.c.

Referenced by encode_frame().

static void init_lfe_fir ( void  )
static

Definition at line 220 of file dcaenc.c.

Referenced by encode_init().

static void put_frame_header ( DCAContext c)
static

Definition at line 232 of file dcaenc.c.

Referenced by put_frame().

static void put_primary_audio_header ( DCAContext c)
static

Definition at line 315 of file dcaenc.c.

Referenced by put_frame().

static uint32_t quantize ( int32_t  sample,
int  bits 
)
inlinestatic

8-23 bits quantization

Parameters
sample
bits

Definition at line 366 of file dcaenc.c.

Referenced by put_sample7().

static int find_scale_factor7 ( int64_t  max_value,
int  bits 
)
inlinestatic

Definition at line 373 of file dcaenc.c.

Referenced by put_subframe().

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

Definition at line 388 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 395 of file dcaenc.c.

Referenced by put_frame().

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

Definition at line 474 of file dcaenc.c.

Referenced by encode_frame().

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

Definition at line 493 of file dcaenc.c.

static int encode_init ( AVCodecContext avctx)
static

Definition at line 534 of file dcaenc.c.

Variable Documentation

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 52 of file dcaenc.c.

Referenced by encode_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 56 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 75 of file dcaenc.c.

Referenced by encode_init().

int32_t cos_table[128]
static

Definition at line 116 of file dcaenc.c.

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

int32_t lfe_fir_64i[512]
static

Definition at line 205 of file dcaenc.c.

Referenced by init_lfe_fir(), and lfe_downsample().

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)"),
}

Definition at line 592 of file dcaenc.c.