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

Go to the source code of this file.

Data Structures

struct  DCAContext
 
struct  cplx32
 

Macros

#define MAX_CHANNELS   6
 
#define DCA_MAX_FRAME_SIZE   16384
 
#define DCA_HEADER_SIZE   13
 
#define DCA_LFE_SAMPLES   8
 
#define DCA_SUBBANDS   32
 
#define SUBFRAMES   1
 
#define SUBSUBFRAMES   2
 
#define SUBBAND_SAMPLES   (SUBFRAMES * SUBSUBFRAMES * 8)
 
#define AUBANDS   25
 
#define USED_1ABITS   1
 
#define USED_NABITS   2
 
#define USED_26ABITS   4
 

Typedefs

typedef void(* walk_band_t )(DCAContext *c, int band1, int band2, int f, int32_t spectrum1, int32_t spectrum2, int channel, int32_t *arg)
 

Functions

static double hom (double f)
 
static double gammafilter (int i, double f)
 
static int encode_init (AVCodecContext *avctx)
 
static int32_t cos_t (int x)
 
static int32_t sin_t (int x)
 
static int32_t half32 (int32_t a)
 
static int32_t mul32 (int32_t a, int32_t b)
 
static void subband_transform (DCAContext *c, const int32_t *input)
 
static void lfe_downsample (DCAContext *c, const int32_t *input)
 
static void fft (const int32_t in[2 *256], cplx32 out[256])
 
static int32_t get_cb (int32_t in)
 
static int32_t add_cb (int32_t a, int32_t b)
 
static void adjust_jnd (int samplerate_index, const int32_t in[512], int32_t out_cb[256])
 
static void walk_band_low (DCAContext *c, int band, int channel, walk_band_t walk, int32_t *arg)
 
static void walk_band_high (DCAContext *c, int band, int channel, walk_band_t walk, int32_t *arg)
 
static void update_band_masking (DCAContext *c, int band1, int band2, int f, int32_t spectrum1, int32_t spectrum2, int channel, int32_t *arg)
 
static void calc_masking (DCAContext *c, const int32_t *input)
 
static void find_peaks (DCAContext *c)
 
static int init_quantization_noise (DCAContext *c, int noise)
 
static void assign_bits (DCAContext *c)
 
static void shift_history (DCAContext *c, const int32_t *input)
 
static int32_t quantize_value (int32_t value, softfloat quant)
 
static int calc_one_scale (int32_t peak_cb, int abits, softfloat *quant)
 
static void calc_scales (DCAContext *c)
 
static void quantize_all (DCAContext *c)
 
static void put_frame_header (DCAContext *c)
 
static void put_primary_audio_header (DCAContext *c)
 
static void put_subframe_samples (DCAContext *c, int ss, int band, int ch)
 
static void put_subframe (DCAContext *c, int subframe)
 
static int encode_frame (AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
 

Variables

static int32_t cos_table [2048]
 
static int32_t band_interpolation [2][512]
 
static int32_t band_spectrum [2][8]
 
static int32_t auf [9][AUBANDS][256]
 
static int32_t cb_to_add [256]
 
static int32_t cb_to_level [2048]
 
static int32_t lfe_fir_64i [512]
 
static const int snr_fudge = 128
 
static const AVCodecDefault defaults []
 
AVCodec ff_dca_encoder
 

Macro Definition Documentation

#define MAX_CHANNELS   6

Definition at line 34 of file dcaenc.c.

#define DCA_MAX_FRAME_SIZE   16384

Definition at line 35 of file dcaenc.c.

Referenced by encode_init().

#define DCA_HEADER_SIZE   13

Definition at line 36 of file dcaenc.c.

#define DCA_LFE_SAMPLES   8

Definition at line 37 of file dcaenc.c.

Referenced by find_peaks(), lfe_downsample(), and put_subframe().

#define DCA_SUBBANDS   32

Definition at line 39 of file dcaenc.c.

Referenced by put_primary_audio_header(), and put_subframe().

#define SUBFRAMES   1
#define SUBSUBFRAMES   2

Definition at line 41 of file dcaenc.c.

Referenced by calc_masking(), and put_subframe().

#define SUBBAND_SAMPLES   (SUBFRAMES * SUBSUBFRAMES * 8)

Definition at line 42 of file dcaenc.c.

Referenced by encode_init(), find_peaks(), put_frame_header(), quantize_all(), and subband_transform().

#define AUBANDS   25

Definition at line 43 of file dcaenc.c.

Referenced by adjust_jnd(), and encode_init().

#define USED_1ABITS   1

Definition at line 550 of file dcaenc.c.

Referenced by assign_bits(), and init_quantization_noise().

#define USED_NABITS   2

Definition at line 551 of file dcaenc.c.

Referenced by init_quantization_noise().

#define USED_26ABITS   4

Definition at line 552 of file dcaenc.c.

Referenced by assign_bits(), and init_quantization_noise().

Typedef Documentation

typedef void(* walk_band_t)(DCAContext *c, int band1, int band2, int f, int32_t spectrum1, int32_t spectrum2, int channel, int32_t *arg)

Definition at line 444 of file dcaenc.c.

Function Documentation

static double hom ( double  f)
static

Definition at line 86 of file dcaenc.c.

Referenced by encode_init().

static double gammafilter ( int  i,
double  f 
)
static

Definition at line 96 of file dcaenc.c.

Referenced by encode_init().

static int encode_init ( AVCodecContext avctx)
static

Definition at line 105 of file dcaenc.c.

static int32_t cos_t ( int  x)
inlinestatic

Definition at line 216 of file dcaenc.c.

Referenced by fft(), sin_t(), and subband_transform().

static int32_t sin_t ( int  x)
inlinestatic

Definition at line 221 of file dcaenc.c.

Referenced by fft().

static int32_t half32 ( int32_t  a)
inlinestatic

Definition at line 226 of file dcaenc.c.

Referenced by fft().

static int32_t mul32 ( int32_t  a,
int32_t  b 
)
inlinestatic
static void subband_transform ( DCAContext c,
const int32_t input 
)
static

Definition at line 237 of file dcaenc.c.

Referenced by encode_frame().

static void lfe_downsample ( DCAContext c,
const int32_t input 
)
static

Definition at line 287 of file dcaenc.c.

Referenced by encode_frame().

static void fft ( const int32_t  in[2 *256],
cplx32  out[256] 
)
static

Definition at line 322 of file dcaenc.c.

Referenced by adjust_jnd().

static int32_t get_cb ( int32_t  in)
static

Definition at line 389 of file dcaenc.c.

Referenced by adjust_jnd(), and find_peaks().

static int32_t add_cb ( int32_t  a,
int32_t  b 
)
static

Definition at line 403 of file dcaenc.c.

Referenced by adjust_jnd().

static void adjust_jnd ( int  samplerate_index,
const int32_t  in[512],
int32_t  out_cb[256] 
)
static

Definition at line 413 of file dcaenc.c.

Referenced by calc_masking().

static void walk_band_low ( DCAContext c,
int  band,
int  channel,
walk_band_t  walk,
int32_t arg 
)
static

Definition at line 448 of file dcaenc.c.

Referenced by calc_masking().

static void walk_band_high ( DCAContext c,
int  band,
int  channel,
walk_band_t  walk,
int32_t arg 
)
static

Definition at line 463 of file dcaenc.c.

Referenced by calc_masking().

static void update_band_masking ( DCAContext c,
int  band1,
int  band2,
int  f,
int32_t  spectrum1,
int32_t  spectrum2,
int  channel,
int32_t arg 
)
static

Definition at line 478 of file dcaenc.c.

Referenced by calc_masking().

static void calc_masking ( DCAContext c,
const int32_t input 
)
static

Definition at line 488 of file dcaenc.c.

Referenced by encode_frame().

static void find_peaks ( DCAContext c)
static

Definition at line 521 of file dcaenc.c.

Referenced by encode_frame().

static int init_quantization_noise ( DCAContext c,
int  noise 
)
static

Definition at line 554 of file dcaenc.c.

Referenced by assign_bits().

static void assign_bits ( DCAContext c)
static

Definition at line 591 of file dcaenc.c.

Referenced by encode_frame().

static void shift_history ( DCAContext c,
const int32_t input 
)
static

Definition at line 629 of file dcaenc.c.

Referenced by encode_frame().

static int32_t quantize_value ( int32_t  value,
softfloat  quant 
)
static

Definition at line 638 of file dcaenc.c.

Referenced by calc_one_scale(), put_subframe(), and quantize_all().

static int calc_one_scale ( int32_t  peak_cb,
int  abits,
softfloat quant 
)
static

Definition at line 647 of file dcaenc.c.

Referenced by calc_scales().

static void calc_scales ( DCAContext c)
static

Definition at line 679 of file dcaenc.c.

Referenced by encode_frame().

static void quantize_all ( DCAContext c)
static

Definition at line 693 of file dcaenc.c.

Referenced by encode_frame().

static void put_frame_header ( DCAContext c)
static

Definition at line 703 of file dcaenc.c.

Referenced by encode_frame().

static void put_primary_audio_header ( DCAContext c)
static

Definition at line 786 of file dcaenc.c.

Referenced by encode_frame().

static void put_subframe_samples ( DCAContext c,
int  ss,
int  band,
int  ch 
)
static

Definition at line 832 of file dcaenc.c.

Referenced by put_subframe().

static void put_subframe ( DCAContext c,
int  subframe 
)
static

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

Variable Documentation

int32_t cos_table[2048]
static

Definition at line 77 of file dcaenc.c.

Referenced by cos_t(), and encode_init().

int32_t band_interpolation[2][512]
static

Definition at line 78 of file dcaenc.c.

Referenced by encode_init().

int32_t band_spectrum[2][8]
static

Definition at line 79 of file dcaenc.c.

Referenced by encode_init().

int32_t auf[9][AUBANDS][256]
static

Definition at line 80 of file dcaenc.c.

Referenced by adjust_jnd(), and encode_init().

int32_t cb_to_add[256]
static

Definition at line 81 of file dcaenc.c.

Referenced by add_cb(), and encode_init().

int32_t cb_to_level[2048]
static

Definition at line 82 of file dcaenc.c.

Referenced by calc_one_scale(), encode_init(), and get_cb().

int32_t lfe_fir_64i[512]
static

Definition at line 83 of file dcaenc.c.

Referenced by encode_init(), and lfe_downsample().

const int snr_fudge = 128
static

Definition at line 549 of file dcaenc.c.

Referenced by assign_bits().

const AVCodecDefault defaults[]
static
Initial value:
= {
{ "b", "1411200" },
{ NULL },
}

Definition at line 950 of file dcaenc.c.

AVCodec ff_dca_encoder
Initial value:
= {
.name = "dca",
.long_name = NULL_IF_CONFIG_SMALL("DCA (DTS Coherent Acoustics)"),
.priv_data_size = sizeof(DCAContext),
.encode2 = encode_frame,
.capabilities = CODEC_CAP_EXPERIMENTAL,
.supported_samplerates = sample_rates,
.channel_layouts = (const uint64_t[]) { AV_CH_LAYOUT_MONO,
0 },
.defaults = defaults,
}

Definition at line 955 of file dcaenc.c.