FFmpeg
Classes | Macros | Typedefs | Functions | Variables
ac3enc.c File Reference

The simplest AC-3 encoder. More...

#include <stdint.h>
#include "libavutil/attributes.h"
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/channel_layout.h"
#include "libavutil/crc.h"
#include "libavutil/internal.h"
#include "libavutil/opt.h"
#include "avcodec.h"
#include "internal.h"
#include "me_cmp.h"
#include "put_bits.h"
#include "audiodsp.h"
#include "ac3dsp.h"
#include "ac3.h"
#include "fft.h"
#include "ac3enc.h"
#include "eac3enc.h"

Classes

struct  AC3Mant
 

Macros

#define CMIXLEV_NUM_OPTIONS   3
 
#define SURMIXLEV_NUM_OPTIONS   3
 
#define EXTMIXLEV_NUM_OPTIONS   8
 
#define EXP_DIFF_THRESHOLD   500
 Exponent Difference Threshold. More...
 
#define CRC16_POLY   ((1 << 0) | (1 << 2) | (1 << 15) | (1 << 16))
 CRC-16 Polynomial.
 
#define FLT_OPTION_THRESHOLD   0.01
 

Typedefs

typedef struct AC3Mant AC3Mant
 

Functions

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_group_exponents (AC3EncodeContext *s)
 Group exponents. 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_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...
 
int ff_ac3_validate_metadata (AC3EncodeContext *s)
 Validate metadata options as set by AVOption system. More...
 
av_cold int ff_ac3_encode_close (AVCodecContext *avctx)
 Finalize encoding and free any memory allocated by the encoder. More...
 
av_cold int ff_ac3_encode_init (AVCodecContext *avctx)
 

Variables

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

Detailed Description

The simplest AC-3 encoder.

Macro Definition Documentation

§ EXP_DIFF_THRESHOLD

#define EXP_DIFF_THRESHOLD   500

Exponent Difference Threshold.

New exponents are sent if their SAD exceed this number.

Function Documentation

§ ff_ac3_adjust_frame_size()

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

§ ff_ac3_apply_rematrixing()

void ff_ac3_apply_rematrixing ( AC3EncodeContext s)

Apply stereo rematrixing to coefficients based on rematrixing flags.

Parameters
sAC-3 encoder private context

§ ff_ac3_compute_coupling_strategy()

void ff_ac3_compute_coupling_strategy ( AC3EncodeContext s)

Set the initial coupling strategy parameters prior to coupling analysis.

Parameters
sAC-3 encoder private context

§ ff_ac3_encode_close()

av_cold int ff_ac3_encode_close ( AVCodecContext avctx)

Finalize encoding and free any memory allocated by the encoder.

Parameters
avctxCodec context

§ ff_ac3_group_exponents()

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

§ ff_ac3_output_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

§ ff_ac3_process_exponents()

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

§ ff_ac3_quantize_mantissas()

void ff_ac3_quantize_mantissas ( AC3EncodeContext s)

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

Parameters
sAC-3 encoder private context

§ ff_ac3_validate_metadata()

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

Variable Documentation

§ ff_ac3_channel_layouts

const uint64_t ff_ac3_channel_layouts[19]
Initial value:
= {
AV_CH_LAYOUT_MONO,
AV_CH_LAYOUT_STEREO,
AV_CH_LAYOUT_2_1,
AV_CH_LAYOUT_SURROUND,
AV_CH_LAYOUT_2_2,
AV_CH_LAYOUT_QUAD,
AV_CH_LAYOUT_4POINT0,
AV_CH_LAYOUT_5POINT0,
AV_CH_LAYOUT_5POINT0_BACK,
(AV_CH_LAYOUT_MONO | AV_CH_LOW_FREQUENCY),
(AV_CH_LAYOUT_STEREO | AV_CH_LOW_FREQUENCY),
(AV_CH_LAYOUT_2_1 | AV_CH_LOW_FREQUENCY),
(AV_CH_LAYOUT_SURROUND | AV_CH_LOW_FREQUENCY),
(AV_CH_LAYOUT_2_2 | AV_CH_LOW_FREQUENCY),
(AV_CH_LAYOUT_QUAD | AV_CH_LOW_FREQUENCY),
(AV_CH_LAYOUT_4POINT0 | AV_CH_LOW_FREQUENCY),
AV_CH_LAYOUT_5POINT1,
AV_CH_LAYOUT_5POINT1_BACK,
0
}

List of supported channel layouts.