FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Typedefs | Functions | Variables
ac3enc.h File Reference

AC-3 encoder & E-AC-3 encoder common header. More...

#include <stdint.h>
#include "libavutil/float_dsp.h"
#include "ac3.h"
#include "ac3dsp.h"
#include "avcodec.h"
#include "fft.h"
#include "mathops.h"
#include "me_cmp.h"
#include "put_bits.h"
#include "audiodsp.h"

Go to the source code of this file.

Data Structures

struct  AC3EncOptions
 Encoding Options used by AVOption. More...
 
struct  AC3Block
 Data for a single audio block. More...
 
struct  AC3EncodeContext
 AC-3 encoder private context. More...
 

Macros

#define CONFIG_AC3ENC_FLOAT   0
 
#define OFFSET(param)   offsetof(AC3EncodeContext, options.param)
 
#define AC3ENC_PARAM   (AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
 
#define AC3ENC_TYPE_AC3_FIXED   0
 
#define AC3ENC_TYPE_AC3   1
 
#define AC3ENC_TYPE_EAC3   2
 
#define AC3_NAME(x)   ff_ac3_fixed_ ## x
 
#define MAC_COEF(d, a, b)   MAC64(d,a,b)
 
#define COEF_MIN   -16777215
 
#define COEF_MAX   16777215
 
#define NEW_CPL_COORD_THRESHOLD   503317
 
#define AC3ENC_OPT_NONE   -1
 
#define AC3ENC_OPT_AUTO   -1
 
#define AC3ENC_OPT_OFF   0
 
#define AC3ENC_OPT_ON   1
 
#define AC3ENC_OPT_NOT_INDICATED   0
 
#define AC3ENC_OPT_MODE_ON   2
 
#define AC3ENC_OPT_MODE_OFF   1
 
#define AC3ENC_OPT_DSUREX_DPLIIZ   3
 
#define AC3ENC_OPT_LARGE_ROOM   1
 
#define AC3ENC_OPT_SMALL_ROOM   2
 
#define AC3ENC_OPT_DOWNMIX_LTRT   1
 
#define AC3ENC_OPT_DOWNMIX_LORO   2
 
#define AC3ENC_OPT_DOWNMIX_DPLII   3
 
#define AC3ENC_OPT_ADCONV_STANDARD   0
 
#define AC3ENC_OPT_ADCONV_HDCD   1
 

Typedefs

typedef int16_t SampleType
 
typedef int32_t CoefType
 
typedef int64_t CoefSumType
 

Functions

int ff_ac3_encode_init (AVCodecContext *avctx)
 
int ff_ac3_float_encode_init (AVCodecContext *avctx)
 
int ff_ac3_encode_close (AVCodecContext *avctx)
 Finalize encoding and free any memory allocated by the encoder. More...
 
int ff_ac3_validate_metadata (AC3EncodeContext *s)
 Validate metadata options as set by AVOption system. More...
 
void ff_ac3_adjust_frame_size (AC3EncodeContext *s)
 Adjust the frame size to make the average bit rate match the target bit rate. More...
 
void ff_ac3_compute_coupling_strategy (AC3EncodeContext *s)
 Set the initial coupling strategy parameters prior to coupling analysis. More...
 
void ff_ac3_apply_rematrixing (AC3EncodeContext *s)
 Apply stereo rematrixing to coefficients based on rematrixing flags. More...
 
void ff_ac3_process_exponents (AC3EncodeContext *s)
 Calculate final exponents from the supplied MDCT coefficients and exponent shift. More...
 
int ff_ac3_compute_bit_allocation (AC3EncodeContext *s)
 
void ff_ac3_group_exponents (AC3EncodeContext *s)
 Group exponents. More...
 
void ff_ac3_quantize_mantissas (AC3EncodeContext *s)
 Quantize mantissas using coefficients, exponents, and bit allocation pointers. More...
 
void ff_ac3_output_frame (AC3EncodeContext *s, unsigned char *frame)
 Write the frame to the output bitstream. More...
 
void ff_ac3_fixed_mdct_end (AC3EncodeContext *s)
 Finalize MDCT and free allocated memory. More...
 
void ff_ac3_float_mdct_end (AC3EncodeContext *s)
 Finalize MDCT and free allocated memory. More...
 
int ff_ac3_fixed_mdct_init (AC3EncodeContext *s)
 Initialize MDCT tables. More...
 
int ff_ac3_float_mdct_init (AC3EncodeContext *s)
 Initialize MDCT tables. More...
 
int ff_ac3_fixed_allocate_sample_buffers (AC3EncodeContext *s)
 
int ff_ac3_float_allocate_sample_buffers (AC3EncodeContext *s)
 
int ff_ac3_fixed_encode_frame (AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
 
int ff_ac3_float_encode_frame (AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
 

Variables

const uint64_t ff_ac3_channel_layouts [19]
 List of supported channel layouts. More...
 

Detailed Description

AC-3 encoder & E-AC-3 encoder common header.

Definition in file ac3enc.h.

Macro Definition Documentation

#define CONFIG_AC3ENC_FLOAT   0

Definition at line 45 of file ac3enc.h.

#define OFFSET (   param)    offsetof(AC3EncodeContext, options.param)

Definition at line 48 of file ac3enc.h.

#define AC3ENC_PARAM   (AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)

Definition at line 49 of file ac3enc.h.

#define AC3ENC_TYPE_AC3_FIXED   0

Definition at line 51 of file ac3enc.h.

#define AC3ENC_TYPE_AC3   1

Definition at line 52 of file ac3enc.h.

#define AC3ENC_TYPE_EAC3   2

Definition at line 53 of file ac3enc.h.

#define AC3_NAME (   x)    ff_ac3_fixed_ ## x

Definition at line 65 of file ac3enc.h.

#define MAC_COEF (   d,
  a,
  b 
)    MAC64(d,a,b)

Definition at line 66 of file ac3enc.h.

Referenced by apply_channel_coupling().

#define COEF_MIN   -16777215

Definition at line 67 of file ac3enc.h.

Referenced by clip_coefficients().

#define COEF_MAX   16777215

Definition at line 68 of file ac3enc.h.

Referenced by calc_cpl_coord(), and clip_coefficients().

#define NEW_CPL_COORD_THRESHOLD   503317

Definition at line 69 of file ac3enc.h.

Referenced by apply_channel_coupling().

#define AC3ENC_OPT_NONE   -1

Definition at line 76 of file ac3enc.h.

Referenced by ff_ac3_validate_metadata().

#define AC3ENC_OPT_AUTO   -1

Definition at line 77 of file ac3enc.h.

Referenced by set_bandwidth().

#define AC3ENC_OPT_OFF   0

Definition at line 78 of file ac3enc.h.

Referenced by ff_ac3_validate_metadata().

#define AC3ENC_OPT_ON   1

Definition at line 79 of file ac3enc.h.

Referenced by ff_ac3_validate_metadata().

#define AC3ENC_OPT_NOT_INDICATED   0

Definition at line 80 of file ac3enc.h.

Referenced by dprint_options(), and ff_ac3_validate_metadata().

#define AC3ENC_OPT_MODE_ON   2

Definition at line 81 of file ac3enc.h.

Referenced by dprint_options().

#define AC3ENC_OPT_MODE_OFF   1

Definition at line 82 of file ac3enc.h.

Referenced by dprint_options().

#define AC3ENC_OPT_DSUREX_DPLIIZ   3

Definition at line 83 of file ac3enc.h.

#define AC3ENC_OPT_LARGE_ROOM   1

Definition at line 86 of file ac3enc.h.

Referenced by dprint_options().

#define AC3ENC_OPT_SMALL_ROOM   2

Definition at line 87 of file ac3enc.h.

Referenced by dprint_options().

#define AC3ENC_OPT_DOWNMIX_LTRT   1

Definition at line 88 of file ac3enc.h.

Referenced by dprint_options().

#define AC3ENC_OPT_DOWNMIX_LORO   2

Definition at line 89 of file ac3enc.h.

Referenced by dprint_options().

#define AC3ENC_OPT_DOWNMIX_DPLII   3

Definition at line 90 of file ac3enc.h.

#define AC3ENC_OPT_ADCONV_STANDARD   0

Definition at line 91 of file ac3enc.h.

Referenced by dprint_options(), and ff_ac3_validate_metadata().

#define AC3ENC_OPT_ADCONV_HDCD   1

Definition at line 92 of file ac3enc.h.

Referenced by dprint_options().

Typedef Documentation

typedef int16_t SampleType

Definition at line 70 of file ac3enc.h.

typedef int32_t CoefType

Definition at line 71 of file ac3enc.h.

typedef int64_t CoefSumType

Definition at line 72 of file ac3enc.h.

Function Documentation

int ff_ac3_encode_init ( AVCodecContext avctx)

Definition at line 2425 of file ac3enc.c.

Referenced by ac3_fixed_encode_init(), and ff_ac3_float_encode_init().

int ff_ac3_float_encode_init ( AVCodecContext avctx)

Definition at line 132 of file ac3enc_float.c.

int ff_ac3_encode_close ( AVCodecContext avctx)

Finalize encoding and free any memory allocated by the encoder.

Parameters
avctxCodec context

Definition at line 2017 of file ac3enc.c.

Referenced by ff_ac3_encode_init().

int ff_ac3_validate_metadata ( AC3EncodeContext s)

Validate metadata options as set by AVOption system.

These values can optionally be changed per-frame.

Parameters
sAC-3 encoder private context

Definition at line 1833 of file ac3enc.c.

Referenced by encode_frame(), and validate_options().

void ff_ac3_adjust_frame_size ( AC3EncodeContext s)

Adjust the frame size to make the average bit rate match the target bit rate.

This is only needed for 11025, 22050, and 44100 sample rates or any E-AC-3.

Parameters
sAC-3 encoder private context

Definition at line 183 of file ac3enc.c.

Referenced by encode_frame().

void ff_ac3_compute_coupling_strategy ( AC3EncodeContext s)

Set the initial coupling strategy parameters prior to coupling analysis.

Parameters
sAC-3 encoder private context

Definition at line 201 of file ac3enc.c.

Referenced by encode_frame().

void ff_ac3_apply_rematrixing ( AC3EncodeContext s)

Apply stereo rematrixing to coefficients based on rematrixing flags.

Parameters
sAC-3 encoder private context

Definition at line 272 of file ac3enc.c.

Referenced by encode_frame().

void ff_ac3_process_exponents ( AC3EncodeContext s)

Calculate final exponents from the supplied MDCT coefficients and exponent shift.

Extract exponents from MDCT coefficients, calculate exponent strategies, and encode final exponents.

Parameters
sAC-3 encoder private context

Definition at line 637 of file ac3enc.c.

Referenced by encode_frame().

int ff_ac3_compute_bit_allocation ( AC3EncodeContext s)

Definition at line 1146 of file ac3enc.c.

Referenced by encode_frame().

void ff_ac3_group_exponents ( AC3EncodeContext s)

Group exponents.

3 delta-encoded exponents are in each 7-bit group. The number of groups varies depending on exponent strategy and bandwidth.

Parameters
sAC-3 encoder private context

Definition at line 579 of file ac3enc.c.

Referenced by encode_frame().

void ff_ac3_quantize_mantissas ( AC3EncodeContext s)

Quantize mantissas using coefficients, exponents, and bit allocation pointers.

Parameters
sAC-3 encoder private context

Definition at line 1300 of file ac3enc.c.

Referenced by encode_frame().

void ff_ac3_output_frame ( AC3EncodeContext s,
unsigned char *  frame 
)

Write the frame to the output bitstream.

Parameters
sAC-3 encoder private context
frameoutput data buffer

Definition at line 1661 of file ac3enc.c.

Referenced by encode_frame().

void ff_ac3_fixed_mdct_end ( AC3EncodeContext s)

Finalize MDCT and free allocated memory.

Parameters
sAC-3 encoder private context

Definition at line 118 of file ac3enc_fixed.c.

Referenced by ff_ac3_encode_init().

void ff_ac3_float_mdct_end ( AC3EncodeContext s)

Finalize MDCT and free allocated memory.

Parameters
sAC-3 encoder private context

Definition at line 97 of file ac3enc_float.c.

Referenced by ff_ac3_encode_init().

int ff_ac3_fixed_mdct_init ( AC3EncodeContext s)

Initialize MDCT tables.

Parameters
sAC-3 encoder private context
Returns
0 on success, negative error code on failure

Definition at line 130 of file ac3enc_fixed.c.

Referenced by ff_ac3_encode_init().

int ff_ac3_float_mdct_init ( AC3EncodeContext s)

Initialize MDCT tables.

Parameters
sAC-3 encoder private context
Returns
0 on success, negative error code on failure

Definition at line 110 of file ac3enc_float.c.

Referenced by ff_ac3_encode_init().

int ff_ac3_fixed_allocate_sample_buffers ( AC3EncodeContext s)

Referenced by ff_ac3_encode_init().

int ff_ac3_float_allocate_sample_buffers ( AC3EncodeContext s)

Referenced by ff_ac3_encode_init().

int ff_ac3_fixed_encode_frame ( AVCodecContext avctx,
AVPacket avpkt,
const AVFrame frame,
int got_packet_ptr 
)
int ff_ac3_float_encode_frame ( AVCodecContext avctx,
AVPacket avpkt,
const AVFrame frame,
int got_packet_ptr 
)

Variable Documentation

const uint64_t ff_ac3_channel_layouts[19]

List of supported channel layouts.

Definition at line 81 of file ac3enc.c.