libavcodec/aacenc.c File Reference

AAC encoder. More...

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

Go to the source code of this file.

Defines

#define AAC_MAX_CHANNELS   6
#define ERROR_IF(cond,...)
#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.
 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.
static void encode_ms_info (PutBitContext *pb, ChannelElement *cpe)
 Encode MS data.
static void adjust_frame_information (AACEncContext *apc, ChannelElement *cpe, int chans)
 Produce integer coefficients from scalefactors provided by the model.
static void encode_band_info (AACEncContext *s, SingleChannelElement *sce)
 Encode scalefactor band coding type.
static void encode_scale_factors (AVCodecContext *avctx, AACEncContext *s, SingleChannelElement *sce)
 Encode scalefactors.
static void encode_pulses (AACEncContext *s, Pulse *pulse)
 Encode pulse data.
static void encode_spectral_coeffs (AACEncContext *s, SingleChannelElement *sce)
 Encode spectral coefficients processed by psychoacoustic model.
static int encode_individual_channel (AVCodecContext *avctx, AACEncContext *s, SingleChannelElement *sce, int common_window)
 Encode one channel of audio data.
static void put_bitstream_info (AVCodecContext *avctx, AACEncContext *s, const char *name)
 Write some auxiliary information about the created AAC file.
static void deinterleave_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

float ff_aac_pow34sf_tab [428]
static const uint8_t swb_size_1024_96 []
static const uint8_t swb_size_1024_64 []
static const uint8_t swb_size_1024_48 []
static const uint8_t swb_size_1024_32 []
static const uint8_t swb_size_1024_24 []
static const uint8_t swb_size_1024_16 []
static const uint8_t swb_size_1024_8 []
static const uint8_tswb_size_1024 []
static const uint8_t swb_size_128_96 []
static const uint8_t swb_size_128_48 []
static const uint8_t swb_size_128_24 []
static const uint8_t swb_size_128_16 []
static const uint8_t swb_size_128_8 []
static const uint8_tswb_size_128 []
static const uint8_t aac_chan_configs [6][5]
 default channel configurations
static const uint8_t aac_chan_maps [AAC_MAX_CHANNELS][AAC_MAX_CHANNELS]
 Table to remap channels from libavcodec's default order to AAC order.
static void(*const apply_window [4])(DSPContext *dsp, 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.


Define Documentation

#define AAC_MAX_CHANNELS   6

Definition at line 49 of file aacenc.c.

Referenced by aac_encode_frame(), and aac_encode_init().

#define AACENC_FLAGS   AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM

Definition at line 802 of file aacenc.c.

#define ERROR_IF ( cond,
...   ) 

Value:

if (cond) { \
        av_log(avctx, AV_LOG_ERROR, __VA_ARGS__); \
        return AVERROR(EINVAL); \
    }

Definition at line 51 of file aacenc.c.

Referenced by aac_encode_init().

#define WINDOW_FUNC ( type   ) 

Value:

static void apply_ ##type ##_window(DSPContext *dsp, AVFloatDSPContext *fdsp, \
                                    SingleChannelElement *sce, \
                                    const float *audio)

Definition at line 185 of file aacenc.c.


Function Documentation

static av_cold int aac_encode_end ( AVCodecContext avctx  )  [static]

Definition at line 678 of file aacenc.c.

Referenced by aac_encode_init().

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

Definition at line 510 of file aacenc.c.

static av_cold int aac_encode_init ( AVCodecContext avctx  )  [static]

Definition at line 737 of file aacenc.c.

static void adjust_frame_information ( AACEncContext apc,
ChannelElement cpe,
int  chans 
) [static]

Produce integer coefficients from scalefactors provided by the model.

Definition at line 305 of file aacenc.c.

Referenced by aac_encode_frame().

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

Definition at line 717 of file aacenc.c.

Referenced by aac_encode_init().

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

Definition at line 250 of file aacenc.c.

Referenced by aac_encode_frame(), encode_superframe(), and vorbis_encode_frame().

static void deinterleave_input_samples ( AACEncContext s,
const AVFrame frame 
) [static]

Definition at line 485 of file aacenc.c.

Referenced by aac_encode_frame(), and encode_frame().

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

Definition at line 696 of file aacenc.c.

Referenced by aac_encode_init().

static void encode_band_info ( AACEncContext s,
SingleChannelElement sce 
) [static]

Encode scalefactor band coding type.

Definition at line 367 of file aacenc.c.

Referenced by encode_individual_channel().

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

Encode one channel of audio data.

Definition at line 444 of file aacenc.c.

Referenced by aac_encode_frame().

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 291 of file aacenc.c.

Referenced by aac_encode_frame().

static void encode_pulses ( AACEncContext s,
Pulse pulse 
) [static]

Encode pulse data.

Definition at line 400 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 378 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 419 of file aacenc.c.

Referenced by encode_individual_channel().

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 164 of file aacenc.c.

Referenced by aac_encode_init().

static void put_bitstream_info ( AVCodecContext avctx,
AACEncContext s,
const char *  name 
) [static]

Write some auxiliary information about the created AAC file.

Definition at line 463 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 270 of file aacenc.c.

Referenced by aac_encode_frame(), and encode_individual_channel().

WINDOW_FUNC ( eight_short   ) 

Definition at line 224 of file aacenc.c.

WINDOW_FUNC ( long_stop   ) 

Definition at line 212 of file aacenc.c.

WINDOW_FUNC ( long_start   ) 

Definition at line 200 of file aacenc.c.

WINDOW_FUNC ( only_long   ) 

Definition at line 190 of file aacenc.c.


Variable Documentation

const uint8_t aac_chan_configs[6][5] [static]

Initial value:

 {
 {1, TYPE_SCE},                               
 {1, TYPE_CPE},                               
 {2, TYPE_SCE, TYPE_CPE},                     
 {3, TYPE_SCE, TYPE_CPE, TYPE_SCE},           
 {3, TYPE_SCE, TYPE_CPE, TYPE_CPE},           
 {4, TYPE_SCE, TYPE_CPE, TYPE_CPE, TYPE_LFE}, 
}
default channel configurations

Definition at line 139 of file aacenc.c.

Referenced by aac_encode_init().

const uint8_t aac_chan_maps[AAC_MAX_CHANNELS][AAC_MAX_CHANNELS] [static]

Initial value:

 {
    { 0 },
    { 0, 1 },
    { 2, 0, 1 },
    { 2, 0, 1, 3 },
    { 2, 0, 1, 3, 4 },
    { 2, 0, 1, 4, 5, 3 },
}
Table to remap channels from libavcodec's default order to AAC order.

Definition at line 151 of file aacenc.c.

Referenced by deinterleave_input_samples().

const AVClass aacenc_class [static]

Initial value:

Definition at line 812 of file aacenc.c.

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", "", 0x42, AV_OPT_TYPE_INT, {.i64 = 2}, 0, AAC_CODER_NB-1, AACENC_FLAGS},
    {NULL}
}

Definition at line 803 of file aacenc.c.

void(*const apply_window[4])(DSPContext *dsp, 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
}

Referenced by apply_mdct(), apply_window_and_mdct(), apply_window_mp3(), and ff_mpa_synth_filter_TMPL().

Initial value:

 {
    .name           = "aac",
    .type           = AVMEDIA_TYPE_AUDIO,
    .id             = AV_CODEC_ID_AAC,
    .priv_data_size = sizeof(AACEncContext),
    .init           = aac_encode_init,
    .encode2        = aac_encode_frame,
    .close          = aac_encode_end,
    .supported_samplerates = avpriv_mpeg4audio_sample_rates,
    .capabilities   = CODEC_CAP_SMALL_LAST_FRAME | CODEC_CAP_DELAY |
                      CODEC_CAP_EXPERIMENTAL,
    .sample_fmts    = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLT,
                                                     AV_SAMPLE_FMT_NONE },
    .long_name      = NULL_IF_CONFIG_SMALL("AAC (Advanced Audio Coding)"),
    .priv_class     = &aacenc_class,
}

Definition at line 819 of file aacenc.c.

float ff_aac_pow34sf_tab[428]

Definition at line 57 of file aacenc.c.

Referenced by aac_encode_init(), and quantize_and_encode_band_cost_template().

const uint8_t* swb_size_1024[] [static]

Initial value:

 {
    swb_size_1024_96, swb_size_1024_96, swb_size_1024_64,
    swb_size_1024_48, swb_size_1024_48, swb_size_1024_32,
    swb_size_1024_24, swb_size_1024_24, swb_size_1024_16,
    swb_size_1024_16, swb_size_1024_16, swb_size_1024_8
}

Definition at line 102 of file aacenc.c.

Referenced by aac_encode_init().

const uint8_t swb_size_1024_16[] [static]

Initial value:

 {
    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
    12, 12, 12, 12, 12, 12, 12, 12, 12, 16, 16, 16, 16, 20, 20, 20, 24, 24, 28, 28,
    32, 36, 40, 40, 44, 48, 52, 56, 60, 64, 64, 64
}

Definition at line 90 of file aacenc.c.

const uint8_t swb_size_1024_24[] [static]

Initial value:

 {
    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
    12, 12, 12, 12, 16, 16, 16, 20, 20, 24, 24, 28, 28,
    32, 36, 36, 40, 44, 48, 52, 52, 64, 64, 64, 64, 64
}

Definition at line 84 of file aacenc.c.

const uint8_t swb_size_1024_32[] [static]

Initial value:

 {
    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8,
    12, 12, 12, 12, 16, 16, 20, 20, 24, 24, 28, 28,
    32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32
}

Definition at line 78 of file aacenc.c.

const uint8_t swb_size_1024_48[] [static]

Initial value:

 {
    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8,
    12, 12, 12, 12, 16, 16, 20, 20, 24, 24, 28, 28,
    32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
    96
}

Definition at line 71 of file aacenc.c.

const uint8_t swb_size_1024_64[] [static]

Initial value:

 {
    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8,
    12, 12, 12, 16, 16, 16, 20, 24, 24, 28, 36,
    40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40
}

Definition at line 65 of file aacenc.c.

const uint8_t swb_size_1024_8[] [static]

Initial value:

 {
    12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
    16, 16, 16, 16, 16, 16, 16, 20, 20, 20, 20, 24, 24, 24, 28, 28,
    32, 36, 36, 40, 44, 48, 52, 56, 60, 64, 80
}

Definition at line 96 of file aacenc.c.

const uint8_t swb_size_1024_96[] [static]

Initial value:

 {
    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8,
    12, 12, 12, 12, 12, 16, 16, 24, 28, 36, 44,
    64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64
}

Definition at line 59 of file aacenc.c.

const uint8_t* swb_size_128[] [static]

Initial value:

 {
    
    swb_size_128_96, swb_size_128_96, swb_size_128_96,
    swb_size_128_48, swb_size_128_48, swb_size_128_48,
    swb_size_128_24, swb_size_128_24, swb_size_128_16,
    swb_size_128_16, swb_size_128_16, swb_size_128_8
}

Definition at line 129 of file aacenc.c.

Referenced by aac_encode_init().

const uint8_t swb_size_128_16[] [static]

Initial value:

 {
    4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 12, 12, 16, 20, 20
}

Definition at line 121 of file aacenc.c.

const uint8_t swb_size_128_24[] [static]

Initial value:

 {
    4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 12, 12, 16, 16, 20
}

Definition at line 117 of file aacenc.c.

const uint8_t swb_size_128_48[] [static]

Initial value:

 {
    4, 4, 4, 4, 4, 8, 8, 8, 12, 12, 12, 16, 16, 16
}

Definition at line 113 of file aacenc.c.

const uint8_t swb_size_128_8[] [static]

Initial value:

 {
    4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 12, 16, 20, 20
}

Definition at line 125 of file aacenc.c.

const uint8_t swb_size_128_96[] [static]

Initial value:

 {
    4, 4, 4, 4, 4, 4, 8, 8, 8, 16, 28, 36
}

Definition at line 109 of file aacenc.c.


Generated on Fri Oct 26 02:50:03 2012 for FFmpeg by  doxygen 1.5.8