Go to the documentation of this file.
20 #include <fdk-aac/aacdecoder_lib.h>
28 #ifdef AACDECODER_LIB_VL0
29 #define FDKDEC_VER_AT_LEAST(vl0, vl1) \
30 ((AACDECODER_LIB_VL0 > vl0) || \
31 (AACDECODER_LIB_VL0 == vl0 && AACDECODER_LIB_VL1 >= vl1))
33 #define FDKDEC_VER_AT_LEAST(vl0, vl1) 0
36 #if !FDKDEC_VER_AT_LEAST(2, 5) // < 2.5.10
37 #define AAC_PCM_MAX_OUTPUT_CHANNELS AAC_PCM_OUTPUT_CHANNELS
64 #define DMX_ANC_BUFFSIZE 128
65 #define DECODER_MAX_CHANNELS 8
66 #define DECODER_BUFFSIZE 2048 * sizeof(INT_PCM)
68 #define OFFSET(x) offsetof(FDKAACDecContext, x)
69 #define AD AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM
75 {
"drc_boost",
"Dynamic Range Control: boost, where [0] is none and [127] is max boost",
77 {
"drc_cut",
"Dynamic Range Control: attenuation factor, where [0] is none and [127] is max compression",
79 {
"drc_level",
"Dynamic Range Control: reference level, quantized to 0.25dB steps where [0] is 0dB and [127] is -31.75dB, -1 for auto, and -2 for disabled",
81 {
"drc_heavy",
"Dynamic Range Control: heavy compression, where [1] is on (RF mode) and [0] is off",
83 #if FDKDEC_VER_AT_LEAST(2, 5) // 2.5.10
84 {
"level_limit",
"Signal level limiting",
87 #if FDKDEC_VER_AT_LEAST(3, 0) // 3.0.0
88 {
"drc_effect",
"Dynamic Range Control: effect type, where e.g. [0] is none and [6] is general",
104 CStreamInfo *
info = aacDecoder_GetStreamInfo(
s->handle);
107 uint64_t ch_layout = 0;
114 if (
info->sampleRate <= 0) {
120 #if FDKDEC_VER_AT_LEAST(2, 5) // 2.5.10
121 s->output_delay =
info->outputDelay;
124 for (
i = 0;
i <
info->numChannels;
i++) {
125 AUDIO_CHANNEL_TYPE ctype =
info->pChannelType[
i];
133 "%d channels - front:%d side:%d back:%d lfe:%d top:%d\n",
156 "unsupported number of front channels: %d\n",
166 "unsupported number of side channels: %d\n",
184 "unsupported number of back channels: %d\n",
195 "unsupported number of LFE channels: %d\n",
220 aacDecoder_Close(
s->handle);
230 AAC_DECODER_ERROR err;
232 s->handle = aacDecoder_Open(avctx->
extradata_size ? TT_MP4_RAW : TT_MP4_ADTS, 1);
239 if ((err = aacDecoder_ConfigRaw(
s->handle, &avctx->
extradata,
246 if ((err = aacDecoder_SetParam(
s->handle, AAC_CONCEAL_METHOD,
247 s->conceal_method)) != AAC_DEC_OK) {
254 int downmix_channels = -1;
259 downmix_channels = 2;
262 downmix_channels = 1;
269 if (downmix_channels != -1) {
271 downmix_channels) != AAC_DEC_OK) {
275 if (!
s->anc_buffer) {
280 av_log(avctx,
AV_LOG_ERROR,
"Unable to register downmix ancillary buffer in the decoder\n");
287 if (
s->drc_boost != -1) {
288 if (aacDecoder_SetParam(
s->handle, AAC_DRC_BOOST_FACTOR,
s->drc_boost) != AAC_DEC_OK) {
294 if (
s->drc_cut != -1) {
295 if (aacDecoder_SetParam(
s->handle, AAC_DRC_ATTENUATION_FACTOR,
s->drc_cut) != AAC_DEC_OK) {
301 if (
s->drc_level != -1) {
308 if (aacDecoder_SetParam(
s->handle, AAC_DRC_REFERENCE_LEVEL,
s->drc_level) != AAC_DEC_OK) {
314 if (
s->drc_heavy != -1) {
315 if (aacDecoder_SetParam(
s->handle, AAC_DRC_HEAVY_COMPRESSION,
s->drc_heavy) != AAC_DEC_OK) {
321 #if FDKDEC_VER_AT_LEAST(2, 5) // 2.5.10
323 if (aacDecoder_SetParam(
s->handle, AAC_PCM_LIMITER_ENABLE,
s->level_limit) != AAC_DEC_OK) {
324 av_log(avctx,
AV_LOG_ERROR,
"Unable to set in signal level limiting in the decoder\n");
329 #if FDKDEC_VER_AT_LEAST(3, 0) // 3.0.0
330 if (
s->drc_effect != -1) {
331 if (aacDecoder_SetParam(
s->handle, AAC_UNIDRC_SET_EFFECT,
s->drc_effect) != AAC_DEC_OK) {
341 s->decoder_buffer =
av_malloc(
s->decoder_buffer_size);
342 if (!
s->decoder_buffer)
349 int *got_frame_ptr,
AVPacket *avpkt)
354 AAC_DECODER_ERROR err;
355 UINT valid = avpkt->
size;
357 err = aacDecoder_Fill(
s->handle, &avpkt->
data, &avpkt->
size, &valid);
358 if (err != AAC_DEC_OK) {
363 err = aacDecoder_DecodeFrame(
s->handle, (INT_PCM *)
s->decoder_buffer,
s->decoder_buffer_size /
sizeof(INT_PCM), 0);
364 if (err == AAC_DEC_NOT_ENOUGH_BITS) {
368 if (err != AAC_DEC_OK) {
370 "aacDecoder_DecodeFrame() failed: %x\n", err);
387 memcpy(
frame->extended_data[0],
s->decoder_buffer,
401 AAC_DECODER_ERROR err;
406 if ((err = aacDecoder_SetParam(
s->handle,
407 AAC_TPDEC_CLEAR_BUFFER, 1)) != AAC_DEC_OK)
412 .
name =
"libfdk_aac",
425 .wrapper_name =
"libfdk",
int frame_size
Number of samples per channel in an audio frame.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
static av_cold int init(AVCodecContext *avctx)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
uint64_t channel_layout
Audio channel layout.
int sample_rate
samples per second
#define AV_CH_LAYOUT_MONO
static av_cold int end(AVCodecContext *avctx)
This structure describes decoded (raw) audio or video data.
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
uint64_t request_channel_layout
Request decoder to use this channel layout if it can (0 for default)
AVCodec ff_libfdk_aac_decoder
static int get_stream_info(AVCodecContext *avctx)
#define AV_CH_LAYOUT_STEREO
#define AAC_PCM_MAX_OUTPUT_CHANNELS
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define AV_CH_LOW_FREQUENCY
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
#define AV_CH_LAYOUT_STEREO_DOWNMIX
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
static av_cold void fdk_aac_decode_flush(AVCodecContext *avctx)
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
static void flush(AVCodecContext *avctx)
Rational number (pair of numerator and denominator).
const char * av_default_item_name(void *ptr)
Return the context name.
#define AV_CH_FRONT_CENTER
#define AV_CH_FRONT_LEFT_OF_CENTER
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static const AVOption fdk_aac_dec_options[]
enum AVSampleFormat sample_fmt
audio sample format
#define AV_NOPTS_VALUE
Undefined timestamp value.
static const AVClass fdk_aac_dec_class
#define AV_CH_FRONT_RIGHT_OF_CENTER
@ CONCEAL_METHOD_ENERGY_INTERPOLATION
int channels
number of audio channels
#define i(width, name, range_min, range_max)
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
static int fdk_aac_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
#define AV_CH_LAYOUT_NATIVE
Channel mask value used for AVCodecContext.request_channel_layout to indicate that the user requests ...
#define AV_CH_BACK_CENTER
@ CONCEAL_METHOD_SPECTRAL_MUTING
@ AV_SAMPLE_FMT_S16
signed 16 bits
const char * name
Name of the codec implementation.
@ CONCEAL_METHOD_NOISE_SUBSTITUTION
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
static av_cold int fdk_aac_decode_close(AVCodecContext *avctx)
#define FF_ARRAY_ELEMS(a)
static const uint8_t channel_counts[7]
main external API structure.
This structure stores compressed data.
#define DECODER_MAX_CHANNELS
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static av_cold int fdk_aac_decode_init(AVCodecContext *avctx)