22 #include <fdk-aac/aacdecoder_lib.h>
45 #define OFFSET(x) offsetof(FDKAACDecContext, x)
46 #define AD AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM
63 CStreamInfo *info = aacDecoder_GetStreamInfo(s->
handle);
64 int channel_counts[9] = { 0 };
66 uint64_t ch_layout = 0;
73 if (info->sampleRate <= 0) {
80 for (i = 0; i < info->numChannels; i++) {
81 AUDIO_CHANNEL_TYPE ctype = info->pChannelType[i];
82 if (ctype <= ACT_NONE || ctype > ACT_TOP) {
86 channel_counts[ctype]++;
89 "%d channels - front:%d side:%d back:%d lfe:%d top:%d\n",
91 channel_counts[ACT_FRONT], channel_counts[ACT_SIDE],
92 channel_counts[ACT_BACK], channel_counts[ACT_LFE],
93 channel_counts[ACT_FRONT_TOP] + channel_counts[ACT_SIDE_TOP] +
94 channel_counts[ACT_BACK_TOP] + channel_counts[ACT_TOP]);
96 switch (channel_counts[ACT_FRONT]) {
112 "unsupported number of front channels: %d\n",
113 channel_counts[ACT_FRONT]);
117 if (channel_counts[ACT_SIDE] > 0) {
118 if (channel_counts[ACT_SIDE] == 2) {
122 "unsupported number of side channels: %d\n",
123 channel_counts[ACT_SIDE]);
127 if (channel_counts[ACT_BACK] > 0) {
128 switch (channel_counts[ACT_BACK]) {
140 "unsupported number of back channels: %d\n",
141 channel_counts[ACT_BACK]);
146 if (channel_counts[ACT_LFE] > 0) {
147 if (channel_counts[ACT_LFE] == 1) {
151 "unsupported number of LFE channels: %d\n",
152 channel_counts[ACT_LFE]);
166 avctx->
channels = info->numChannels;
176 aacDecoder_Close(s->
handle);
184 AAC_DECODER_ERROR err;
201 if ((err = aacDecoder_SetParam(s->
handle, AAC_CONCEAL_METHOD,
214 int *got_frame_ptr,
AVPacket *avpkt)
219 AAC_DECODER_ERROR err;
220 UINT valid = avpkt->
size;
224 err = aacDecoder_Fill(s->
handle, &avpkt->
data, &avpkt->
size, &valid);
225 if (err != AAC_DEC_OK) {
240 buf_size = 50 * 1024;
246 err = aacDecoder_DecodeFrame(s->
handle, (INT_PCM *) buf, buf_size, 0);
247 if (err == AAC_DEC_NOT_ENOUGH_BITS) {
248 ret = avpkt->
size - valid;
251 if (err != AAC_DEC_OK) {
253 "aacDecoder_DecodeFrame() failed: %x\n", err);
277 ret = avpkt->
size - valid;
287 AAC_DECODER_ERROR err;
292 if ((err = aacDecoder_SetParam(s->
handle,
293 AAC_TPDEC_CLEAR_BUFFER, 1)) != AAC_DEC_OK)
298 .
name =
"libfdk_aac",
308 .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 av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
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
common internal api header.
static av_cold int fdk_aac_decode_close(AVCodecContext *avctx)
common internal and external API header
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