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

AAC encoder. More...

#include "libavutil/float_dsp.h"
#include "libavutil/opt.h"
#include "avcodec.h"
#include "put_bits.h"
#include "internal.h"
#include "mpeg4audio.h"
#include "kbdwin.h"
#include "sinewin.h"
#include "aac.h"
#include "aactab.h"
#include "aacenc.h"
#include "aacenctab.h"
#include "aacenc_utils.h"
#include "psymodel.h"

Go to the source code of this file.

Macros

#define WINDOW_FUNC(type)
 
#define AACENC_FLAGS   AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM
 

Functions

static void put_audio_specific_config (AVCodecContext *avctx)
 Make AAC audio config object. More...
 
 WINDOW_FUNC (only_long)
 
 WINDOW_FUNC (long_start)
 
 WINDOW_FUNC (long_stop)
 
 WINDOW_FUNC (eight_short)
 
static void apply_window_and_mdct (AACEncContext *s, SingleChannelElement *sce, float *audio)
 
static void put_ics_info (AACEncContext *s, IndividualChannelStream *info)
 Encode ics_info element. More...
 
static void encode_ms_info (PutBitContext *pb, ChannelElement *cpe)
 Encode MS data. More...
 
static void adjust_frame_information (ChannelElement *cpe, int chans)
 Produce integer coefficients from scalefactors provided by the model. More...
 
static void apply_intensity_stereo (ChannelElement *cpe)
 
static void apply_mid_side_stereo (ChannelElement *cpe)
 
static void encode_band_info (AACEncContext *s, SingleChannelElement *sce)
 Encode scalefactor band coding type. More...
 
static void encode_scale_factors (AVCodecContext *avctx, AACEncContext *s, SingleChannelElement *sce)
 Encode scalefactors. More...
 
static void encode_pulses (AACEncContext *s, Pulse *pulse)
 Encode pulse data. More...
 
static void encode_spectral_coeffs (AACEncContext *s, SingleChannelElement *sce)
 Encode spectral coefficients processed by psychoacoustic model. More...
 
static void avoid_clipping (AACEncContext *s, SingleChannelElement *sce)
 Downscale spectral coefficients for near-clipping windows to avoid artifacts. More...
 
static int encode_individual_channel (AVCodecContext *avctx, AACEncContext *s, SingleChannelElement *sce, int common_window)
 Encode one channel of audio data. More...
 
static void put_bitstream_info (AACEncContext *s, const char *name)
 Write some auxiliary information about the created AAC file. More...
 
static void copy_input_samples (AACEncContext *s, const AVFrame *frame)
 
static int aac_encode_frame (AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
 
static av_cold int aac_encode_end (AVCodecContext *avctx)
 
static av_cold int dsp_init (AVCodecContext *avctx, AACEncContext *s)
 
static av_cold int alloc_buffers (AVCodecContext *avctx, AACEncContext *s)
 
static av_cold int aac_encode_init (AVCodecContext *avctx)
 

Variables

static void(*const apply_window [4])(AVFloatDSPContext *fdsp, SingleChannelElement *sce, const float *audio)
 
static const AVOption aacenc_options []
 
static const AVClass aacenc_class
 
AVCodec ff_aac_encoder
 

Detailed Description

AAC encoder.

Definition in file aacenc.c.

Macro Definition Documentation

#define WINDOW_FUNC (   type)
Value:
static void apply_ ##type ##_window(AVFloatDSPContext *fdsp, \
const float *audio)
GLint GLenum type
Definition: opengl_enc.c:105
Single Channel Element - used for both SCE and LFE elements.
Definition: aac.h:245

Definition at line 74 of file aacenc.c.

Definition at line 876 of file aacenc.c.

Function Documentation

static void put_audio_specific_config ( AVCodecContext avctx)
static

Make AAC audio config object.

See Also
1.6.2.1 "Syntax - AudioSpecificConfig"

Definition at line 53 of file aacenc.c.

Referenced by aac_encode_init().

WINDOW_FUNC ( only_long  )

Definition at line 79 of file aacenc.c.

WINDOW_FUNC ( long_start  )

Definition at line 89 of file aacenc.c.

WINDOW_FUNC ( long_stop  )

Definition at line 101 of file aacenc.c.

WINDOW_FUNC ( eight_short  )

Definition at line 113 of file aacenc.c.

static void apply_window_and_mdct ( AACEncContext s,
SingleChannelElement sce,
float *  audio 
)
static

Definition at line 139 of file aacenc.c.

Referenced by aac_encode_frame().

static void put_ics_info ( AACEncContext s,
IndividualChannelStream info 
)
static

Encode ics_info element.

See Also
Table 4.6 (syntax of ics_info)

Definition at line 160 of file aacenc.c.

Referenced by aac_encode_frame(), and encode_individual_channel().

static void encode_ms_info ( PutBitContext pb,
ChannelElement cpe 
)
static

Encode MS data.

See Also
4.6.8.1 "Joint Coding - M/S Stereo"

Definition at line 181 of file aacenc.c.

Referenced by aac_encode_frame().

static void adjust_frame_information ( ChannelElement cpe,
int  chans 
)
static

Produce integer coefficients from scalefactors provided by the model.

Definition at line 195 of file aacenc.c.

Referenced by aac_encode_frame().

static void apply_intensity_stereo ( ChannelElement cpe)
static

Definition at line 245 of file aacenc.c.

Referenced by aac_encode_frame().

static void apply_mid_side_stereo ( ChannelElement cpe)
static

Definition at line 272 of file aacenc.c.

Referenced by aac_encode_frame().

static void encode_band_info ( AACEncContext s,
SingleChannelElement sce 
)
static

Encode scalefactor band coding type.

Definition at line 301 of file aacenc.c.

Referenced by encode_individual_channel().

static void encode_scale_factors ( AVCodecContext avctx,
AACEncContext s,
SingleChannelElement sce 
)
static

Encode scalefactors.

Definition at line 315 of file aacenc.c.

Referenced by encode_individual_channel().

static void encode_pulses ( AACEncContext s,
Pulse pulse 
)
static

Encode pulse data.

Definition at line 351 of file aacenc.c.

Referenced by encode_individual_channel().

static void encode_spectral_coeffs ( AACEncContext s,
SingleChannelElement sce 
)
static

Encode spectral coefficients processed by psychoacoustic model.

Definition at line 370 of file aacenc.c.

Referenced by encode_individual_channel().

static void avoid_clipping ( AACEncContext s,
SingleChannelElement sce 
)
static

Downscale spectral coefficients for near-clipping windows to avoid artifacts.

Definition at line 398 of file aacenc.c.

Referenced by aac_encode_frame().

static int encode_individual_channel ( AVCodecContext avctx,
AACEncContext s,
SingleChannelElement sce,
int  common_window 
)
static

Encode one channel of audio data.

Definition at line 418 of file aacenc.c.

Referenced by aac_encode_frame().

static void put_bitstream_info ( AACEncContext s,
const char *  name 
)
static

Write some auxiliary information about the created AAC file.

Definition at line 442 of file aacenc.c.

Referenced by aac_encode_frame().

static void copy_input_samples ( AACEncContext s,
const AVFrame frame 
)
static

Definition at line 463 of file aacenc.c.

Referenced by aac_encode_frame().

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

Definition at line 485 of file aacenc.c.

static av_cold int aac_encode_end ( AVCodecContext avctx)
static

Definition at line 736 of file aacenc.c.

Referenced by aac_encode_init().

static av_cold int dsp_init ( AVCodecContext avctx,
AACEncContext s 
)
static

Definition at line 753 of file aacenc.c.

Referenced by aac_encode_init().

static av_cold int alloc_buffers ( AVCodecContext avctx,
AACEncContext s 
)
static

Definition at line 775 of file aacenc.c.

Referenced by aac_encode_init().

static av_cold int aac_encode_init ( AVCodecContext avctx)
static

Definition at line 790 of file aacenc.c.

Variable Documentation

void(*const apply_window[4])(AVFloatDSPContext *fdsp, SingleChannelElement *sce, const float *audio)
static
Initial value:
= {
[ONLY_LONG_SEQUENCE] = apply_only_long_window,
[LONG_START_SEQUENCE] = apply_long_start_window,
[EIGHT_SHORT_SEQUENCE] = apply_eight_short_window,
[LONG_STOP_SEQUENCE] = apply_long_stop_window
}

Definition at line 130 of file aacenc.c.

Referenced by apply_window_and_mdct(), and ff_mpa_synth_filter_TMPL().

const AVOption aacenc_options[]
static
Initial value:
= {
{"stereo_mode", "Stereo coding method", 0x42, AV_OPT_TYPE_INT, {.i64 = 0}, -1, 1, AACENC_FLAGS, "stereo_mode"},
{"auto", "Selected by the Encoder", 0, AV_OPT_TYPE_CONST, {.i64 = -1 }, INT_MIN, INT_MAX, AACENC_FLAGS, "stereo_mode"},
{"ms_off", "Disable Mid/Side coding", 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, INT_MIN, INT_MAX, AACENC_FLAGS, "stereo_mode"},
{"ms_force", "Force Mid/Side for the whole frame if possible", 0, AV_OPT_TYPE_CONST, {.i64 = 1 }, INT_MIN, INT_MAX, AACENC_FLAGS, "stereo_mode"},
{"aac_coder", "Coding algorithm", 0x42, AV_OPT_TYPE_INT, {.i64 = AAC_CODER_TWOLOOP}, 0, AAC_CODER_NB-1, AACENC_FLAGS, "aac_coder"},
{"faac", "FAAC-inspired method", 0, AV_OPT_TYPE_CONST, {.i64 = AAC_CODER_FAAC}, INT_MIN, INT_MAX, AACENC_FLAGS, "aac_coder"},
{"anmr", "ANMR method", 0, AV_OPT_TYPE_CONST, {.i64 = AAC_CODER_ANMR}, INT_MIN, INT_MAX, AACENC_FLAGS, "aac_coder"},
{"twoloop", "Two loop searching method", 0, AV_OPT_TYPE_CONST, {.i64 = AAC_CODER_TWOLOOP}, INT_MIN, INT_MAX, AACENC_FLAGS, "aac_coder"},
{"fast", "Constant quantizer", 0, AV_OPT_TYPE_CONST, {.i64 = AAC_CODER_FAST}, INT_MIN, INT_MAX, AACENC_FLAGS, "aac_coder"},
{"aac_pns", "Perceptual Noise Substitution", 0x42, AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, AACENC_FLAGS, "aac_pns"},
{"disable", "Disable perceptual noise substitution", 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, INT_MIN, INT_MAX, AACENC_FLAGS, "aac_pns"},
{"enable", "Enable perceptual noise substitution", 0, AV_OPT_TYPE_CONST, {.i64 = 1 }, INT_MIN, INT_MAX, AACENC_FLAGS, "aac_pns"},
{"aac_is", "Intensity stereo coding", 0x42, AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, AACENC_FLAGS, "intensity_stereo"},
{"disable", "Disable intensity stereo coding", 0, AV_OPT_TYPE_CONST, {.i64 = 0}, INT_MIN, INT_MAX, AACENC_FLAGS, "intensity_stereo"},
{"enable", "Enable intensity stereo coding", 0, AV_OPT_TYPE_CONST, {.i64 = 1}, INT_MIN, INT_MAX, AACENC_FLAGS, "intensity_stereo"},
{"aac_tns", "Temporal noise shaping", 0x42, AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, AACENC_FLAGS, "aac_tns"},
{"disable", "Disable temporal noise shaping", 0, AV_OPT_TYPE_CONST, {.i64 = 0}, INT_MIN, INT_MAX, AACENC_FLAGS, "aac_tns"},
{"enable", "Enable temporal noise shaping", 0, AV_OPT_TYPE_CONST, {.i64 = 1}, INT_MIN, INT_MAX, AACENC_FLAGS, "aac_tns"},
{"aac_pred", "AAC-Main prediction", 0x42, AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, AACENC_FLAGS, "aac_pred"},
{"disable", "Disable AAC-Main prediction", 0, AV_OPT_TYPE_CONST, {.i64 = 0}, INT_MIN, INT_MAX, AACENC_FLAGS, "aac_pred"},
{"enable", "Enable AAC-Main prediction", 0, AV_OPT_TYPE_CONST, {.i64 = 1}, INT_MIN, INT_MAX, AACENC_FLAGS, "aac_pred"},
{NULL}
}
#define NULL
Definition: coverity.c:32
#define AACENC_FLAGS
Definition: aacenc.c:876

Definition at line 877 of file aacenc.c.

const AVClass aacenc_class
static
Initial value:
= {
"AAC encoder",
}
#define LIBAVUTIL_VERSION_INT
Definition: version.h:62
static const AVOption aacenc_options[]
Definition: aacenc.c:877
av_default_item_name

Definition at line 902 of file aacenc.c.

AVCodec ff_aac_encoder
Initial value:
= {
.name = "aac",
.long_name = NULL_IF_CONFIG_SMALL("AAC (Advanced Audio Coding)"),
.priv_data_size = sizeof(AACEncContext),
.encode2 = aac_encode_frame,
.close = aac_encode_end,
.priv_class = &aacenc_class,
}
float, planar
Definition: samplefmt.h:70
static const AVClass aacenc_class
Definition: aacenc.c:902
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
#define AV_CODEC_CAP_EXPERIMENTAL
Codec is experimental and is thus avoided in favor of non experimental encoders.
Definition: avcodec.h:912
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
Definition: avcodec.h:882
supported_samplerates
AAC encoder context.
Definition: aacenc.h:80
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:175
static const int mpeg4audio_sample_rates[16]
Definition: aacenctab.h:70
#define AV_CODEC_CAP_SMALL_LAST_FRAME
Codec can be fed a final frame with a smaller size.
Definition: avcodec.h:887
static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
Definition: aacenc.c:485
static av_cold int aac_encode_end(AVCodecContext *avctx)
Definition: aacenc.c:736
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:59
static av_cold int aac_encode_init(AVCodecContext *avctx)
Definition: aacenc.c:790
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:701

Definition at line 909 of file aacenc.c.