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;
224 err = aacDecoder_Fill(s->
handle, &avpkt->
data, &avpkt->
size, &valid);
225 if (err != AAC_DEC_OK) {
238 buf_size = 50 * 1024;
244 err = aacDecoder_DecodeFrame(s->
handle, (INT_PCM *) buf, buf_size, 0);
245 if (err == AAC_DEC_NOT_ENOUGH_BITS) {
246 ret = avpkt->
size - valid;
249 if (err != AAC_DEC_OK) {
251 "aacDecoder_DecodeFrame() failed: %x\n", err);
273 ret = avpkt->
size - valid;
283 AAC_DECODER_ERROR err;
288 if ((err = aacDecoder_SetParam(s->
handle,
289 AAC_TPDEC_CLEAR_BUFFER, 1)) != AAC_DEC_OK)
294 .
name =
"libfdk_aac",
304 .priv_class = &fdk_aac_dec_class,