20 #include <fdk-aac/aacdecoder_lib.h>
42 #define OFFSET(x) offsetof(FDKAACDecContext, x)
43 #define AD AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM
59 CStreamInfo *info = aacDecoder_GetStreamInfo(s->
handle);
60 int channel_counts[9] = { 0 };
62 uint64_t ch_layout = 0;
69 if (info->sampleRate <= 0) {
76 for (i = 0; i < info->numChannels; i++) {
77 AUDIO_CHANNEL_TYPE ctype = info->pChannelType[i];
78 if (ctype <= ACT_NONE || ctype > ACT_TOP) {
82 channel_counts[ctype]++;
85 "%d channels - front:%d side:%d back:%d lfe:%d top:%d\n",
87 channel_counts[ACT_FRONT], channel_counts[ACT_SIDE],
88 channel_counts[ACT_BACK], channel_counts[ACT_LFE],
89 channel_counts[ACT_FRONT_TOP] + channel_counts[ACT_SIDE_TOP] +
90 channel_counts[ACT_BACK_TOP] + channel_counts[ACT_TOP]);
92 switch (channel_counts[ACT_FRONT]) {
108 "unsupported number of front channels: %d\n",
109 channel_counts[ACT_FRONT]);
113 if (channel_counts[ACT_SIDE] > 0) {
114 if (channel_counts[ACT_SIDE] == 2) {
118 "unsupported number of side channels: %d\n",
119 channel_counts[ACT_SIDE]);
123 if (channel_counts[ACT_BACK] > 0) {
124 switch (channel_counts[ACT_BACK]) {
136 "unsupported number of back channels: %d\n",
137 channel_counts[ACT_BACK]);
142 if (channel_counts[ACT_LFE] > 0) {
143 if (channel_counts[ACT_LFE] == 1) {
147 "unsupported number of LFE channels: %d\n",
148 channel_counts[ACT_LFE]);
162 avctx->
channels = info->numChannels;
172 aacDecoder_Close(s->
handle);
180 AAC_DECODER_ERROR err;
196 if ((err = aacDecoder_SetParam(s->
handle, AAC_CONCEAL_METHOD,
208 int *got_frame_ptr,
AVPacket *avpkt)
213 AAC_DECODER_ERROR err;
214 UINT valid = avpkt->
size;
218 err = aacDecoder_Fill(s->
handle, &avpkt->
data, &avpkt->
size, &valid);
219 if (err != AAC_DEC_OK) {
234 buf_size = 50 * 1024;
240 err = aacDecoder_DecodeFrame(s->
handle, (INT_PCM *) buf, buf_size, 0);
241 if (err == AAC_DEC_NOT_ENOUGH_BITS) {
242 ret = avpkt->
size - valid;
245 if (err != AAC_DEC_OK) {
247 "aacDecoder_DecodeFrame() failed: %x\n", err);
271 ret = avpkt->
size - valid;
281 AAC_DECODER_ERROR err;
286 if ((err = aacDecoder_SetParam(s->
handle,
287 AAC_TPDEC_CLEAR_BUFFER, 1)) != AAC_DEC_OK)
292 .
name =
"libfdk_aac",
302 .priv_class = &fdk_aac_dec_class,
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_CH_LAYOUT_STEREO
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
enum AVSampleFormat sample_fmt
audio sample format
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
#define AV_CH_LOW_FREQUENCY
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static int get_stream_info(AVCodecContext *avctx)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
static av_cold void fdk_aac_decode_flush(AVCodecContext *avctx)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
AVCodec ff_libfdk_aac_decoder
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
uint64_t channel_layout
Audio channel layout.
audio channel layout utility functions
static const AVOption fdk_aac_dec_options[]
#define AV_CH_FRONT_LEFT_OF_CENTER
#define AV_CH_FRONT_CENTER
#define AV_CH_FRONT_RIGHT_OF_CENTER
int frame_size
Number of samples per channel in an audio frame.
Libavcodec external API header.
int sample_rate
samples per second
static int fdk_aac_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
static const AVClass fdk_aac_dec_class
main external API structure.
static void close(AVCodecParserContext *s)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Describe the class of an AVClass context structure.
#define AV_CH_BACK_CENTER
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
common internal api header.
static av_cold int fdk_aac_decode_close(AVCodecContext *avctx)
common internal and external API header
#define CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
static av_cold void flush(AVCodecContext *avctx)
Flush (reset) the frame ID after seeking.
static av_cold int fdk_aac_decode_init(AVCodecContext *avctx)
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
static av_cold int init(AVCodecParserContext *s)
int channels
number of audio channels
enum ConcealMethod conceal_method
uint8_t ** extended_data
pointers to the data planes/channels.
This structure stores compressed data.
int nb_samples
number of audio samples (per channel) described by this frame