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;
218 err = aacDecoder_Fill(s->
handle, &avpkt->
data, &avpkt->
size, &valid);
219 if (err != AAC_DEC_OK) {
232 buf_size = 50 * 1024;
238 err = aacDecoder_DecodeFrame(s->
handle, (INT_PCM *) buf, buf_size, 0);
239 if (err == AAC_DEC_NOT_ENOUGH_BITS) {
240 ret = avpkt->
size - valid;
243 if (err != AAC_DEC_OK) {
245 "aacDecoder_DecodeFrame() failed: %x\n", err);
267 ret = avpkt->
size - valid;
277 AAC_DECODER_ERROR err;
282 if ((err = aacDecoder_SetParam(s->
handle,
283 AAC_TPDEC_CLEAR_BUFFER, 1)) != AAC_DEC_OK)
288 .
name =
"libfdk_aac",
298 .priv_class = &fdk_aac_dec_class,