FFmpeg
Data Structures | Macros | Functions | Variables
audiotoolboxenc.c File Reference
#include <AudioToolbox/AudioToolbox.h>
#include "libavfilter/bufferqueue.h"
#include "config.h"
#include "audio_frame_queue.h"
#include "avcodec.h"
#include "bytestream.h"
#include "encode.h"
#include "internal.h"
#include "libavformat/isom.h"
#include "libavutil/avassert.h"
#include "libavutil/channel_layout.h"
#include "libavutil/opt.h"
#include "libavutil/log.h"

Go to the source code of this file.

Data Structures

struct  ATDecodeContext
 

Macros

#define FF_BUFQUEUE_SIZE   256
 
#define AE   AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 
#define FFAT_ENC_CLASS(NAME)
 
#define FFAT_ENC(NAME, ID, PROFILES, ...)
 

Functions

static UInt32 ffat_get_format_id (enum AVCodecID codec, int profile)
 
static void ffat_update_ctx (AVCodecContext *avctx)
 
static int read_descr (GetByteContext *gb, int *tag)
 
static int get_ilbc_mode (AVCodecContext *avctx)
 
static av_cold int get_channel_label (int channel)
 
static int remap_layout (AudioChannelLayout *layout, uint64_t in_layout, int count)
 
static int get_aac_tag (uint64_t in_layout)
 
static av_cold int ffat_init_encoder (AVCodecContext *avctx)
 
static OSStatus ffat_encode_callback (AudioConverterRef converter, UInt32 *nb_packets, AudioBufferList *data, AudioStreamPacketDescription **packets, void *inctx)
 
static int ffat_encode (AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
 
static av_cold void ffat_encode_flush (AVCodecContext *avctx)
 
static av_cold int ffat_close_encoder (AVCodecContext *avctx)
 

Variables

static const AVProfile aac_profiles []
 
static const AVOption options []
 
static const uint64_t aac_at_channel_layouts []
 

Macro Definition Documentation

◆ FF_BUFQUEUE_SIZE

#define FF_BUFQUEUE_SIZE   256

Definition at line 25 of file audiotoolboxenc.c.

◆ AE

Definition at line 597 of file audiotoolboxenc.c.

◆ FFAT_ENC_CLASS

#define FFAT_ENC_CLASS (   NAME)
Value:
static const AVClass ffat_##NAME##_enc_class = { \
.class_name = "at_" #NAME "_enc", \
.item_name = av_default_item_name, \
.option = options, \
.version = LIBAVUTIL_VERSION_INT, \
};

Definition at line 611 of file audiotoolboxenc.c.

◆ FFAT_ENC

#define FFAT_ENC (   NAME,
  ID,
  PROFILES,
  ... 
)
Value:
const AVCodec ff_##NAME##_at_encoder = { \
.name = #NAME "_at", \
.long_name = NULL_IF_CONFIG_SMALL(#NAME " (AudioToolbox)"), \
.type = AVMEDIA_TYPE_AUDIO, \
.id = ID, \
.priv_data_size = sizeof(ATDecodeContext), \
.close = ffat_close_encoder, \
.encode2 = ffat_encode, \
.priv_class = &ffat_##NAME##_enc_class, \
.capabilities = AV_CODEC_CAP_DELAY | \
.sample_fmts = (const enum AVSampleFormat[]) { \
AV_SAMPLE_FMT_S16, \
AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_NONE \
}, \
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, \
.profiles = PROFILES, \
.wrapper_name = "at", \
};

Definition at line 619 of file audiotoolboxenc.c.

Function Documentation

◆ ffat_get_format_id()

static UInt32 ffat_get_format_id ( enum AVCodecID  codec,
int  profile 
)
static

Definition at line 57 of file audiotoolboxenc.c.

Referenced by ffat_init_encoder().

◆ ffat_update_ctx()

static void ffat_update_ctx ( AVCodecContext avctx)
static

Definition at line 90 of file audiotoolboxenc.c.

Referenced by ffat_init_encoder().

◆ read_descr()

static int read_descr ( GetByteContext gb,
int tag 
)
static

Definition at line 130 of file audiotoolboxenc.c.

Referenced by ffat_init_encoder().

◆ get_ilbc_mode()

static int get_ilbc_mode ( AVCodecContext avctx)
static

Definition at line 144 of file audiotoolboxenc.c.

Referenced by ffat_init_encoder().

◆ get_channel_label()

static av_cold int get_channel_label ( int  channel)
static

Definition at line 156 of file audiotoolboxenc.c.

Referenced by remap_layout().

◆ remap_layout()

static int remap_layout ( AudioChannelLayout *  layout,
uint64_t  in_layout,
int  count 
)
static

Definition at line 181 of file audiotoolboxenc.c.

Referenced by ffat_init_encoder().

◆ get_aac_tag()

static int get_aac_tag ( uint64_t  in_layout)
static

Definition at line 202 of file audiotoolboxenc.c.

Referenced by ffat_init_encoder().

◆ ffat_init_encoder()

static av_cold int ffat_init_encoder ( AVCodecContext avctx)
static

Definition at line 236 of file audiotoolboxenc.c.

◆ ffat_encode_callback()

static OSStatus ffat_encode_callback ( AudioConverterRef  converter,
UInt32 *  nb_packets,
AudioBufferList *  data,
AudioStreamPacketDescription **  packets,
void *  inctx 
)
static

Definition at line 456 of file audiotoolboxenc.c.

Referenced by ffat_encode().

◆ ffat_encode()

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

Definition at line 499 of file audiotoolboxenc.c.

◆ ffat_encode_flush()

static av_cold void ffat_encode_flush ( AVCodecContext avctx)
static

Definition at line 569 of file audiotoolboxenc.c.

◆ ffat_close_encoder()

static av_cold int ffat_close_encoder ( AVCodecContext avctx)
static

Definition at line 577 of file audiotoolboxenc.c.

Variable Documentation

◆ aac_profiles

const AVProfile aac_profiles[]
static
Initial value:
= {
{ FF_PROFILE_AAC_LOW, "LC" },
{ FF_PROFILE_AAC_HE, "HE-AAC" },
{ FF_PROFILE_AAC_HE_V2, "HE-AACv2" },
{ FF_PROFILE_AAC_LD, "LD" },
{ FF_PROFILE_AAC_ELD, "ELD" },
}

Definition at line 588 of file audiotoolboxenc.c.

◆ options

const AVOption options[]
static
Initial value:
= {
{"aac_at_mode", "ratecontrol mode", 0x42, AV_OPT_TYPE_INT, {.i64 = -1}, -1, kAudioCodecBitRateControlMode_Variable, AE, "mode"},
{"auto", "VBR if global quality is given; CBR otherwise", 0, AV_OPT_TYPE_CONST, {.i64 = -1}, INT_MIN, INT_MAX, AE, "mode"},
{"cbr", "constant bitrate", 0, AV_OPT_TYPE_CONST, {.i64 = kAudioCodecBitRateControlMode_Constant}, INT_MIN, INT_MAX, AE, "mode"},
{"abr", "long-term average bitrate", 0, AV_OPT_TYPE_CONST, {.i64 = kAudioCodecBitRateControlMode_LongTermAverage}, INT_MIN, INT_MAX, AE, "mode"},
{"cvbr", "constrained variable bitrate", 0, AV_OPT_TYPE_CONST, {.i64 = kAudioCodecBitRateControlMode_VariableConstrained}, INT_MIN, INT_MAX, AE, "mode"},
{"vbr" , "variable bitrate", 0, AV_OPT_TYPE_CONST, {.i64 = kAudioCodecBitRateControlMode_Variable}, INT_MIN, INT_MAX, AE, "mode"},
{"aac_at_quality", "quality vs speed control", 0x42, AV_OPT_TYPE_INT, {.i64 = 0}, 0, 2, AE},
{ NULL },
}

Definition at line 598 of file audiotoolboxenc.c.

◆ aac_at_channel_layouts

const uint64_t aac_at_channel_layouts[]
static
AV_CH_LAYOUT_7POINT0
#define AV_CH_LAYOUT_7POINT0
Definition: channel_layout.h:110
AVCodec
AVCodec.
Definition: codec.h:202
AV_CH_LAYOUT_6POINT1
#define AV_CH_LAYOUT_6POINT1
Definition: channel_layout.h:107
AV_CH_LAYOUT_7POINT1_WIDE_BACK
#define AV_CH_LAYOUT_7POINT1_WIDE_BACK
Definition: channel_layout.h:114
FF_CODEC_CAP_INIT_THREADSAFE
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
Definition: internal.h:42
init
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:31
sample_fmts
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:948
AV_CH_LAYOUT_MONO
#define AV_CH_LAYOUT_MONO
Definition: channel_layout.h:90
ffat_init_encoder
static av_cold int ffat_init_encoder(AVCodecContext *avctx)
Definition: audiotoolboxenc.c:236
AV_CH_LAYOUT_6POINT0
#define AV_CH_LAYOUT_6POINT0
Definition: channel_layout.h:104
ffat_close_encoder
static av_cold int ffat_close_encoder(AVCodecContext *avctx)
Definition: audiotoolboxenc.c:577
AE
#define AE
Definition: audiotoolboxenc.c:597
AV_CODEC_CAP_ENCODER_FLUSH
#define AV_CODEC_CAP_ENCODER_FLUSH
This encoder can be flushed using avcodec_flush_buffers().
Definition: codec.h:183
AV_CH_LAYOUT_STEREO
#define AV_CH_LAYOUT_STEREO
Definition: channel_layout.h:91
AV_CH_LAYOUT_QUAD
#define AV_CH_LAYOUT_QUAD
Definition: channel_layout.h:99
FFAT_ENC_CLASS
#define FFAT_ENC_CLASS(NAME)
Definition: audiotoolboxenc.c:611
options
static const AVOption options[]
Definition: audiotoolboxenc.c:598
FF_PROFILE_AAC_HE_V2
#define FF_PROFILE_AAC_HE_V2
Definition: avcodec.h:1534
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
FF_PROFILE_UNKNOWN
#define FF_PROFILE_UNKNOWN
Definition: avcodec.h:1526
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
NULL
#define NULL
Definition: coverity.c:32
flush
static void flush(AVCodecContext *avctx)
Definition: aacdec_template.c:593
FF_PROFILE_AAC_LD
#define FF_PROFILE_AAC_LD
Definition: avcodec.h:1535
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:235
AV_CH_LAYOUT_5POINT1
#define AV_CH_LAYOUT_5POINT1
Definition: channel_layout.h:101
FF_PROFILE_AAC_ELD
#define FF_PROFILE_AAC_ELD
Definition: avcodec.h:1536
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
FF_PROFILE_AAC_LOW
#define FF_PROFILE_AAC_LOW
Definition: avcodec.h:1530
AV_SAMPLE_FMT_NONE
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:59
AV_CH_LAYOUT_OCTAGONAL
#define AV_CH_LAYOUT_OCTAGONAL
Definition: channel_layout.h:115
AV_CH_LAYOUT_5POINT0
#define AV_CH_LAYOUT_5POINT0
Definition: channel_layout.h:100
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:58
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:209
FF_PROFILE_AAC_HE
#define FF_PROFILE_AAC_HE
Definition: avcodec.h:1533
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:71
AV_CH_LAYOUT_SURROUND
#define AV_CH_LAYOUT_SURROUND
Definition: channel_layout.h:94
ffat_encode_flush
static av_cold void ffat_encode_flush(AVCodecContext *avctx)
Definition: audiotoolboxenc.c:569
ffat_encode
static int ffat_encode(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
Definition: audiotoolboxenc.c:499
ATDecodeContext
Definition: audiotoolboxdec.c:40
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:224
AV_CODEC_CAP_DELAY
#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: codec.h:82
ID
#define ID(x)
Definition: cast5.c:29
AV_CH_LAYOUT_4POINT0
#define AV_CH_LAYOUT_4POINT0
Definition: channel_layout.h:96
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:233