FFmpeg
Loading...
Searching...
No Matches
libfdk-aacdec.c
Go to the documentation of this file.
1/*
2 * AAC decoder wrapper
3 * Copyright (c) 2012 Martin Storsjo
4 *
5 * This file is part of FFmpeg.
6 *
7 * Permission to use, copy, modify, and/or distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */
19
20#include <fdk-aac/aacdecoder_lib.h>
21
23#include "libavutil/common.h"
24#include "libavutil/mem.h"
25#include "libavutil/opt.h"
26#include "avcodec.h"
27#include "codec_internal.h"
28#include "decode.h"
29
30#ifdef AACDECODER_LIB_VL0
31#define FDKDEC_VER_AT_LEAST(vl0, vl1) \
32 ((AACDECODER_LIB_VL0 > vl0) || \
33 (AACDECODER_LIB_VL0 == vl0 && AACDECODER_LIB_VL1 >= vl1))
34#else
35#define FDKDEC_VER_AT_LEAST(vl0, vl1) 0
36#endif
37
38#if !FDKDEC_VER_AT_LEAST(2, 5) // < 2.5.10
39#define AAC_PCM_MAX_OUTPUT_CHANNELS AAC_PCM_OUTPUT_CHANNELS
40#endif
41
48
49typedef struct FDKAACDecContext {
50 const AVClass *class;
51 HANDLE_AACDECODER handle;
54 uint8_t *anc_buffer;
63#if FDKDEC_VER_AT_LEAST(2, 5) // 2.5.10
64 int output_delay_set;
65 int flush_samples;
66 int delay_samples;
67#endif
70
71
72#define DMX_ANC_BUFFSIZE 128
73#define DECODER_MAX_CHANNELS 8
74#define DECODER_BUFFSIZE 2048 * sizeof(INT_PCM)
75
76#define OFFSET(x) offsetof(FDKAACDecContext, x)
77#define AD AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM
78static const AVOption fdk_aac_dec_options[] = {
79 { "conceal", "Error concealment method", OFFSET(conceal_method), AV_OPT_TYPE_INT, { .i64 = CONCEAL_METHOD_NOISE_SUBSTITUTION }, CONCEAL_METHOD_SPECTRAL_MUTING, CONCEAL_METHOD_NB - 1, AD, .unit = "conceal" },
80 { "spectral", "Spectral muting", 0, AV_OPT_TYPE_CONST, { .i64 = CONCEAL_METHOD_SPECTRAL_MUTING }, INT_MIN, INT_MAX, AD, .unit = "conceal" },
81 { "noise", "Noise Substitution", 0, AV_OPT_TYPE_CONST, { .i64 = CONCEAL_METHOD_NOISE_SUBSTITUTION }, INT_MIN, INT_MAX, AD, .unit = "conceal" },
82 { "energy", "Energy Interpolation", 0, AV_OPT_TYPE_CONST, { .i64 = CONCEAL_METHOD_ENERGY_INTERPOLATION }, INT_MIN, INT_MAX, AD, .unit = "conceal" },
83 { "drc_boost", "Dynamic Range Control: boost, where [0] is none and [127] is max boost",
84 OFFSET(drc_boost), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 127, AD, .unit = NULL },
85 { "drc_cut", "Dynamic Range Control: attenuation factor, where [0] is none and [127] is max compression",
86 OFFSET(drc_cut), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 127, AD, .unit = NULL },
87 { "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",
88 OFFSET(drc_level), AV_OPT_TYPE_INT, { .i64 = -1}, -2, 127, AD, .unit = NULL },
89 { "drc_heavy", "Dynamic Range Control: heavy compression, where [1] is on (RF mode) and [0] is off",
90 OFFSET(drc_heavy), AV_OPT_TYPE_INT, { .i64 = -1}, -1, 1, AD, .unit = NULL },
91#if FDKDEC_VER_AT_LEAST(2, 5) // 2.5.10
92 { "level_limit", "Signal level limiting",
93 OFFSET(level_limit), AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, AD },
94#endif
95#if FDKDEC_VER_AT_LEAST(3, 0) // 3.0.0
96 { "drc_effect","Dynamic Range Control: effect type, where e.g. [0] is none and [6] is general",
97 OFFSET(drc_effect), AV_OPT_TYPE_INT, { .i64 = -1}, -1, 8, AD, .unit = NULL },
98#endif
99#if FDKDEC_VER_AT_LEAST(3, 1) // 3.1.0
100 { "album_mode","Dynamic Range Control: album mode, where [0] is off and [1] is on",
101 OFFSET(album_mode), AV_OPT_TYPE_INT, { .i64 = -1}, -1, 1, AD, .unit = NULL },
102#endif
103 { "downmix", "Request a specific channel layout from the decoder", OFFSET(downmix_layout), AV_OPT_TYPE_CHLAYOUT, {.str = NULL}, .flags = AD },
104 { NULL }
105};
106
108 .class_name = "libfdk-aac decoder",
109 .item_name = av_default_item_name,
110 .option = fdk_aac_dec_options,
111 .version = LIBAVUTIL_VERSION_INT,
112};
113
115{
116 FDKAACDecContext *s = avctx->priv_data;
117 CStreamInfo *info = aacDecoder_GetStreamInfo(s->handle);
118 int channel_counts[0x24] = { 0 };
119 int i, ch_error = 0;
120 uint64_t ch_layout = 0;
121
122 if (!info) {
123 av_log(avctx, AV_LOG_ERROR, "Unable to get stream info\n");
124 return AVERROR_UNKNOWN;
125 }
126
127 if (info->sampleRate <= 0) {
128 av_log(avctx, AV_LOG_ERROR, "Stream info not initialized\n");
129 return AVERROR_UNKNOWN;
130 }
131 avctx->sample_rate = info->sampleRate;
132 avctx->frame_size = info->frameSize;
133 avctx->profile = info->aot - 1;
134
135 frame->flags |= AV_FRAME_FLAG_KEY * !!(info->flags & AC_INDEP);
136#if FDKDEC_VER_AT_LEAST(2, 5) // 2.5.10
137 if (!s->output_delay_set && info->outputDelay) {
138 // Set this only once.
139 s->flush_samples = info->outputDelay;
140 s->delay_samples = info->outputDelay;
141 s->output_delay_set = 1;
142 }
143#endif
144
145 for (i = 0; i < info->numChannels; i++) {
146 AUDIO_CHANNEL_TYPE ctype = info->pChannelType[i];
147 if (ctype <= ACT_NONE || ctype >= FF_ARRAY_ELEMS(channel_counts)) {
148 av_log(avctx, AV_LOG_WARNING, "unknown channel type\n");
149 break;
150 }
151 channel_counts[ctype]++;
152 }
153 av_log(avctx, AV_LOG_DEBUG,
154 "%d channels - front:%d side:%d back:%d lfe:%d top:%d bottom %d\n",
155 info->numChannels,
156 channel_counts[ACT_FRONT], channel_counts[ACT_SIDE],
157 channel_counts[ACT_BACK], channel_counts[ACT_LFE],
158 channel_counts[ACT_FRONT_TOP] + channel_counts[ACT_SIDE_TOP] +
159 channel_counts[ACT_BACK_TOP] + channel_counts[ACT_TOP],
160 channel_counts[ACT_FRONT_BOTTOM] + channel_counts[ACT_SIDE_BOTTOM] +
161 channel_counts[ACT_BACK_BOTTOM] + channel_counts[ACT_BOTTOM]);
162
163 switch (channel_counts[ACT_FRONT]) {
164 case 5:
165 case 4:
166 ch_layout |= AV_CH_FRONT_LEFT_OF_CENTER |
169 case 3:
170 case 2:
171 ch_layout |= AV_CH_LAYOUT_STEREO;
173 case 1:
174 if (channel_counts[ACT_FRONT] & 1)
175 ch_layout |= AV_CH_FRONT_CENTER;
176 break;
177 default:
178 av_log(avctx, AV_LOG_WARNING,
179 "unsupported number of front channels: %d\n",
180 channel_counts[ACT_FRONT]);
181 ch_error = 1;
182 break;
183 }
184
185 if (channel_counts[ACT_SIDE] > 0) {
186 if (channel_counts[ACT_SIDE] == 2) {
187 ch_layout |= AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT;
188 } else {
189 av_log(avctx, AV_LOG_WARNING,
190 "unsupported number of side channels: %d\n",
191 channel_counts[ACT_SIDE]);
192 ch_error = 1;
193 }
194 }
195 if (channel_counts[ACT_BACK] > 0) {
196 switch (channel_counts[ACT_BACK]) {
197 case 4:
198 ch_layout |= AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT;
200 case 3:
201 case 2:
202 ch_layout |= AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT;
204 case 1:
205 if (channel_counts[ACT_BACK] & 1)
206 ch_layout |= AV_CH_BACK_CENTER;
207 break;
208 default:
209 av_log(avctx, AV_LOG_WARNING,
210 "unsupported number of back channels: %d\n",
211 channel_counts[ACT_BACK]);
212 ch_error = 1;
213 break;
214 }
215 }
216 if (channel_counts[ACT_LFE] > 0) {
217 if (channel_counts[ACT_LFE] == 1) {
218 ch_layout |= AV_CH_LOW_FREQUENCY;
219 } else {
220 av_log(avctx, AV_LOG_WARNING,
221 "unsupported number of LFE channels: %d\n",
222 channel_counts[ACT_LFE]);
223 ch_error = 1;
224 }
225 }
226 if (channel_counts[ACT_FRONT_TOP] > 0) {
227 switch (channel_counts[ACT_FRONT_TOP]) {
228 case 3:
229 case 2:
232 case 1:
233 if (channel_counts[ACT_FRONT_TOP] & 1)
234 ch_layout |= AV_CH_TOP_FRONT_CENTER;
235 break;
236 default:
237 av_log(avctx, AV_LOG_WARNING,
238 "unsupported number of top front channels: %d\n",
239 channel_counts[ACT_FRONT_TOP]);
240 ch_error = 1;
241 break;
242 }
243 }
244 if (channel_counts[ACT_BACK_TOP] > 0) {
245 switch (channel_counts[ACT_BACK_TOP]) {
246 case 3:
247 case 2:
250 case 1:
251 if (channel_counts[ACT_BACK_TOP] & 1)
252 ch_layout |= AV_CH_TOP_BACK_CENTER;
253 break;
254 default:
255 av_log(avctx, AV_LOG_WARNING,
256 "unsupported number of top back channels: %d\n",
257 channel_counts[ACT_BACK_TOP]);
258 ch_error = 1;
259 break;
260 }
261 }
262 if (channel_counts[ACT_SIDE_TOP] > 0) {
263 switch (channel_counts[ACT_SIDE_TOP]) {
264 case 3:
265 case 2:
268 case 1:
269 if (channel_counts[ACT_SIDE_TOP] & 1)
270 ch_layout |= AV_CH_TOP_CENTER;
271 break;
272 default:
273 av_log(avctx, AV_LOG_WARNING,
274 "unsupported number of top side channels: %d\n",
275 channel_counts[ACT_SIDE_TOP]);
276 ch_error = 1;
277 break;
278 }
279 }
280 if (channel_counts[ACT_FRONT_BOTTOM] > 0) {
281 switch (channel_counts[ACT_FRONT_BOTTOM]) {
282 case 3:
283 case 2:
286 case 1:
287 if (channel_counts[ACT_FRONT_BOTTOM] & 1)
288 ch_layout |= AV_CH_BOTTOM_FRONT_CENTER;
289 break;
290 default:
291 av_log(avctx, AV_LOG_WARNING,
292 "unsupported number of bottom front channels: %d\n",
293 channel_counts[ACT_FRONT_BOTTOM]);
294 ch_error = 1;
295 break;
296 }
297 }
298
300 av_channel_layout_from_mask(&avctx->ch_layout, ch_layout);
301 if (!ch_error && avctx->ch_layout.nb_channels != info->numChannels) {
302 av_log(avctx, AV_LOG_WARNING, "unsupported channel configuration\n");
303 ch_error = 1;
304 }
305 if (ch_error)
307
308 return 0;
309}
310
312{
313 FDKAACDecContext *s = avctx->priv_data;
314
315 if (s->handle)
316 aacDecoder_Close(s->handle);
317 av_freep(&s->decoder_buffer);
318 av_freep(&s->anc_buffer);
319
320 return 0;
321}
322
324{
325 FDKAACDecContext *s = avctx->priv_data;
326 AAC_DECODER_ERROR err;
327
328 s->handle = aacDecoder_Open(avctx->extradata_size ? TT_MP4_RAW : TT_MP4_ADTS, 1);
329 if (!s->handle) {
330 av_log(avctx, AV_LOG_ERROR, "Error opening decoder\n");
331 return AVERROR_UNKNOWN;
332 }
333
334 if (avctx->extradata_size) {
335 if ((err = aacDecoder_ConfigRaw(s->handle, &avctx->extradata,
336 &avctx->extradata_size)) != AAC_DEC_OK) {
337 av_log(avctx, AV_LOG_ERROR, "Unable to set extradata\n");
338 return AVERROR_INVALIDDATA;
339 }
340 }
341
342 if ((err = aacDecoder_SetParam(s->handle, AAC_CONCEAL_METHOD,
343 s->conceal_method)) != AAC_DEC_OK) {
344 av_log(avctx, AV_LOG_ERROR, "Unable to set error concealment method\n");
345 return AVERROR_UNKNOWN;
346 }
347
348 if (s->downmix_layout.nb_channels > 0 &&
349 s->downmix_layout.order == AV_CHANNEL_ORDER_NATIVE) {
350 int downmix_channels = -1;
351
352 switch (s->downmix_layout.u.mask) {
355 downmix_channels = 2;
356 break;
358 downmix_channels = 1;
359 break;
360 default:
361 av_log(avctx, AV_LOG_WARNING, "Invalid downmix option\n");
362 break;
363 }
364
365 if (downmix_channels != -1) {
366 if (aacDecoder_SetParam(s->handle, AAC_PCM_MAX_OUTPUT_CHANNELS,
367 downmix_channels) != AAC_DEC_OK) {
368 av_log(avctx, AV_LOG_WARNING, "Unable to set output channels in the decoder\n");
369 } else {
370 s->anc_buffer = av_malloc(DMX_ANC_BUFFSIZE);
371 if (!s->anc_buffer) {
372 av_log(avctx, AV_LOG_ERROR, "Unable to allocate ancillary buffer for the decoder\n");
373 return AVERROR(ENOMEM);
374 }
375 if (aacDecoder_AncDataInit(s->handle, s->anc_buffer, DMX_ANC_BUFFSIZE)) {
376 av_log(avctx, AV_LOG_ERROR, "Unable to register downmix ancillary buffer in the decoder\n");
377 return AVERROR_UNKNOWN;
378 }
379 }
380 }
381#if FDKDEC_VER_AT_LEAST(2, 5)
382 } else {
383 // AAC_PCM_MAX_OUTPUT_CHANNELS == 0 means outputting all the coded channels
384 if (aacDecoder_SetParam(s->handle, AAC_PCM_MAX_OUTPUT_CHANNELS, 0) != AAC_DEC_OK)
385 av_log(avctx, AV_LOG_WARNING, "Unable to set output channels in the decoder\n");
386#endif
387 }
388
389 if (s->drc_boost != -1) {
390 if (aacDecoder_SetParam(s->handle, AAC_DRC_BOOST_FACTOR, s->drc_boost) != AAC_DEC_OK) {
391 av_log(avctx, AV_LOG_ERROR, "Unable to set DRC boost factor in the decoder\n");
392 return AVERROR_UNKNOWN;
393 }
394 }
395
396 if (s->drc_cut != -1) {
397 if (aacDecoder_SetParam(s->handle, AAC_DRC_ATTENUATION_FACTOR, s->drc_cut) != AAC_DEC_OK) {
398 av_log(avctx, AV_LOG_ERROR, "Unable to set DRC attenuation factor in the decoder\n");
399 return AVERROR_UNKNOWN;
400 }
401 }
402
403 if (s->drc_level != -1) {
404 // This option defaults to -1, i.e. not calling
405 // aacDecoder_SetParam(AAC_DRC_REFERENCE_LEVEL) at all, which defaults
406 // to the level from DRC metadata, if available. The user can set
407 // -drc_level -2, which calls aacDecoder_SetParam(
408 // AAC_DRC_REFERENCE_LEVEL) with a negative value, which then
409 // explicitly disables the feature.
410 if (aacDecoder_SetParam(s->handle, AAC_DRC_REFERENCE_LEVEL, s->drc_level) != AAC_DEC_OK) {
411 av_log(avctx, AV_LOG_ERROR, "Unable to set DRC reference level in the decoder\n");
412 return AVERROR_UNKNOWN;
413 }
414 }
415
416 if (s->drc_heavy != -1) {
417 if (aacDecoder_SetParam(s->handle, AAC_DRC_HEAVY_COMPRESSION, s->drc_heavy) != AAC_DEC_OK) {
418 av_log(avctx, AV_LOG_ERROR, "Unable to set DRC heavy compression in the decoder\n");
419 return AVERROR_UNKNOWN;
420 }
421 }
422
423#if FDKDEC_VER_AT_LEAST(2, 5) // 2.5.10
424 // Setting this parameter to -1 enables the auto behaviour in the library.
425 if (aacDecoder_SetParam(s->handle, AAC_PCM_LIMITER_ENABLE, s->level_limit) != AAC_DEC_OK) {
426 av_log(avctx, AV_LOG_ERROR, "Unable to set in signal level limiting in the decoder\n");
427 return AVERROR_UNKNOWN;
428 }
429#endif
430
431#if FDKDEC_VER_AT_LEAST(3, 0) // 3.0.0
432 if (s->drc_effect != -1) {
433 if (aacDecoder_SetParam(s->handle, AAC_UNIDRC_SET_EFFECT, s->drc_effect) != AAC_DEC_OK) {
434 av_log(avctx, AV_LOG_ERROR, "Unable to set DRC effect type in the decoder\n");
435 return AVERROR_UNKNOWN;
436 }
437 }
438#endif
439
440#if FDKDEC_VER_AT_LEAST(3, 1) // 3.1.0
441 if (s->album_mode != -1) {
442 if (aacDecoder_SetParam(s->handle, AAC_UNIDRC_ALBUM_MODE, s->album_mode) != AAC_DEC_OK) {
443 av_log(avctx, AV_LOG_ERROR, "Unable to set album mode in the decoder\n");
444 return AVERROR_UNKNOWN;
445 }
446 }
447#endif
448
450
451 s->decoder_buffer_size = DECODER_BUFFSIZE * DECODER_MAX_CHANNELS;
452 s->decoder_buffer = av_malloc(s->decoder_buffer_size);
453 if (!s->decoder_buffer)
454 return AVERROR(ENOMEM);
455
456 return 0;
457}
458
460 int *got_frame_ptr, AVPacket *avpkt)
461{
462 FDKAACDecContext *s = avctx->priv_data;
463 int ret;
464 AAC_DECODER_ERROR err;
465 UINT valid = avpkt->size;
466 UINT flags = 0;
467 int input_offset = 0;
468
469 if (avpkt->size) {
470 err = aacDecoder_Fill(s->handle, &avpkt->data, &avpkt->size, &valid);
471 if (err != AAC_DEC_OK) {
472 av_log(avctx, AV_LOG_ERROR, "aacDecoder_Fill() failed: %x\n", err);
473 return AVERROR_INVALIDDATA;
474 }
475 } else {
476#if FDKDEC_VER_AT_LEAST(2, 5) // 2.5.10
477 /* Handle decoder draining */
478 if (s->flush_samples > 0) {
479 flags |= AACDEC_FLUSH;
480 } else {
481 return AVERROR_EOF;
482 }
483#else
484 return AVERROR_EOF;
485#endif
486 }
487
488 err = aacDecoder_DecodeFrame(s->handle, (INT_PCM *) s->decoder_buffer,
489 s->decoder_buffer_size / sizeof(INT_PCM),
490 flags);
491 if (err == AAC_DEC_NOT_ENOUGH_BITS) {
492 ret = avpkt->size - valid;
493 goto end;
494 }
495 if (err != AAC_DEC_OK) {
496 av_log(avctx, AV_LOG_ERROR,
497 "aacDecoder_DecodeFrame() failed: %x\n", err);
498 ret = AVERROR_UNKNOWN;
499 goto end;
500 }
501
502 if ((ret = get_stream_info(avctx, frame)) < 0)
503 goto end;
504 frame->nb_samples = avctx->frame_size;
505
506#if FDKDEC_VER_AT_LEAST(2, 5) // 2.5.10
507 if (flags & AACDEC_FLUSH) {
508 // Only return the right amount of samples at the end; if calling the
509 // decoder with AACDEC_FLUSH, it will keep returning frames indefinitely.
510 frame->nb_samples = FFMIN(s->flush_samples, frame->nb_samples);
511 av_log(s, AV_LOG_DEBUG, "Returning %d/%d delayed samples.\n",
512 frame->nb_samples, s->flush_samples);
513 s->flush_samples -= frame->nb_samples;
514 } else {
515 // Trim off samples from the start to compensate for extra decoder
516 // delay. We could also just adjust the pts, but this avoids
517 // including the extra samples in the output altogether.
518 if (s->delay_samples) {
519 int drop_samples = FFMIN(s->delay_samples, frame->nb_samples);
520 av_log(s, AV_LOG_DEBUG, "Dropping %d/%d delayed samples.\n",
521 drop_samples, s->delay_samples);
522 s->delay_samples -= drop_samples;
523 frame->nb_samples -= drop_samples;
524 input_offset = drop_samples * avctx->ch_layout.nb_channels;
525 if (frame->nb_samples <= 0)
526 return 0;
527 }
528 }
529#endif
530
531 if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
532 goto end;
533
534 memcpy(frame->extended_data[0], s->decoder_buffer + input_offset,
535 avctx->ch_layout.nb_channels * frame->nb_samples *
537
538 *got_frame_ptr = 1;
539 ret = avpkt->size - valid;
540
541end:
542 return ret;
543}
544
546{
547 FDKAACDecContext *s = avctx->priv_data;
548 AAC_DECODER_ERROR err;
549
550 if (!s->handle)
551 return;
552
553 if ((err = aacDecoder_SetParam(s->handle,
554 AAC_TPDEC_CLEAR_BUFFER, 1)) != AAC_DEC_OK)
555 av_log(avctx, AV_LOG_WARNING, "failed to clear buffer when flushing\n");
556}
557
559 .p.name = "libfdk_aac",
560 CODEC_LONG_NAME("Fraunhofer FDK AAC"),
561 .p.type = AVMEDIA_TYPE_AUDIO,
562 .p.id = AV_CODEC_ID_AAC,
563 .priv_data_size = sizeof(FDKAACDecContext),
566 .close = fdk_aac_decode_close,
567 .flush = fdk_aac_decode_flush,
569#if FDKDEC_VER_AT_LEAST(2, 5) // 2.5.10
571#endif
572 ,
573 .p.priv_class = &fdk_aac_dec_class,
574 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
575 .p.wrapper_name = "libfdk",
576};
#define ctype
const FFCodec ff_libfdk_aac_decoder
Libavcodec external API header.
#define flags(name, subs,...)
Definition cbs_h264.c:74
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define s(width, name)
Definition cbs_vp9.c:198
Public libavutil channel layout APIs header.
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
common internal and external API header
#define NULL
Definition coverity.c:32
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Definition decode.c:1777
static AVFrame * frame
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
#define AD
Definition evrcdec.c:920
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition opt.h:298
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ AV_OPT_TYPE_CHLAYOUT
Underlying C type is AVChannelLayout.
Definition opt.h:330
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition opt.h:326
#define AV_CH_LAYOUT_STEREO_DOWNMIX
#define AV_CH_LAYOUT_MONO
#define AV_CH_LAYOUT_STEREO
#define AV_CH_SIDE_LEFT
#define AV_CH_TOP_FRONT_LEFT
#define AV_CH_TOP_BACK_CENTER
#define AV_CH_BOTTOM_FRONT_CENTER
#define AV_CH_FRONT_RIGHT_OF_CENTER
#define AV_CH_BACK_CENTER
#define AV_CH_TOP_FRONT_CENTER
#define AV_CH_FRONT_LEFT_OF_CENTER
#define AV_CH_BACK_RIGHT
#define AV_CH_TOP_SIDE_RIGHT
#define AV_CH_FRONT_CENTER
#define AV_CH_TOP_BACK_RIGHT
#define AV_CH_TOP_CENTER
#define AV_CH_SIDE_RIGHT
#define AV_CH_BACK_LEFT
#define AV_CH_TOP_SIDE_LEFT
#define AV_CH_TOP_BACK_LEFT
#define AV_CH_LOW_FREQUENCY
#define AV_CH_BOTTOM_FRONT_RIGHT
#define AV_CH_TOP_FRONT_RIGHT
#define AV_CH_BOTTOM_FRONT_LEFT
#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:79
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition codec.h:49
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
Definition codec.h:94
@ AV_CODEC_ID_AAC
Definition codec_id.h:455
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
int av_channel_layout_from_mask(AVChannelLayout *channel_layout, uint64_t mask)
Initialize a native channel layout from a bitmask indicating which channels are present.
@ AV_CHANNEL_ORDER_NATIVE
The native channel order, i.e.
@ AV_CHANNEL_ORDER_UNSPEC
Only the channel count is specified, without any further information about the channel order.
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
Definition error.h:73
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition error.h:61
#define AVERROR_EOF
End of file.
Definition error.h:57
#define AVERROR(e)
Definition error.h:45
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
Definition frame.h:687
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition log.h:231
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition log.h:216
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
const char * av_default_item_name(void *ptr)
Return the context name.
Definition log.c:241
@ AVMEDIA_TYPE_AUDIO
Definition avutil.h:201
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
Definition samplefmt.c:108
@ AV_SAMPLE_FMT_S16
signed 16 bits
Definition samplefmt.h:58
#define LIBAVUTIL_VERSION_INT
Definition version.h:85
#define av_fallthrough
Definition attributes.h:67
#define av_cold
Definition attributes.h:117
static av_cold void fdk_aac_decode_flush(AVCodecContext *avctx)
static const AVOption fdk_aac_dec_options[]
static int get_stream_info(AVCodecContext *avctx, AVFrame *frame)
static av_cold int fdk_aac_decode_init(AVCodecContext *avctx)
#define DECODER_BUFFSIZE
#define AAC_PCM_MAX_OUTPUT_CHANNELS
static av_cold int fdk_aac_decode_close(AVCodecContext *avctx)
#define OFFSET(x)
ConcealMethod
@ CONCEAL_METHOD_NB
@ CONCEAL_METHOD_SPECTRAL_MUTING
@ CONCEAL_METHOD_ENERGY_INTERPOLATION
@ CONCEAL_METHOD_NOISE_SUBSTITUTION
static const AVClass fdk_aac_dec_class
#define DMX_ANC_BUFFSIZE
static int fdk_aac_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
#define DECODER_MAX_CHANNELS
#define FFMIN(a, b)
Definition macros.h:49
Memory handling functions.
#define av_malloc(s)
Definition ops_static.c:52
AVOptions.
#define FF_ARRAY_ELEMS(a)
An AVChannelLayout holds information about the channel layout of audio data.
enum AVChannelOrder order
Channel order used in this layout.
int nb_channels
Number of channels in this layout.
Describe the class of an AVClass context structure.
Definition log.h:76
main external API structure.
Definition avcodec.h:443
AVChannelLayout ch_layout
Audio channel layout.
Definition avcodec.h:1055
enum AVSampleFormat sample_fmt
audio sample format
Definition avcodec.h:1047
int profile
profile
Definition avcodec.h:1637
int sample_rate
samples per second
Definition avcodec.h:1040
uint8_t * extradata
Out-of-band global headers that may be used by some codecs.
Definition avcodec.h:526
int extradata_size
Definition avcodec.h:527
int frame_size
Number of samples per channel in an audio frame.
Definition avcodec.h:1068
void * priv_data
Definition avcodec.h:470
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
AVOption.
Definition opt.h:428
This structure stores compressed data.
Definition packet.h:580
int size
Definition packet.h:604
uint8_t * data
Definition packet.h:603
uint8_t * anc_buffer
uint8_t * decoder_buffer
HANDLE_AACDECODER handle
AVChannelLayout downmix_layout
#define av_freep(p)
#define av_log(a,...)