This can be useful for decoding AAC object types that are not supported
by the native AAC decoder, e.g. AAC-LD and AAC-ELD.
---
I modified Martin's original patch to update API usage, get channel layout
information, allow user to set error concealment method, and flush buffers
on seek.
configure | 3 +-
libavcodec/Makefile | 1 +
libavcodec/allcodecs.c | 2 +-
libavcodec/libfdk-aacdec.c | 296 +++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 300 insertions(+), 2 deletions(-)
create mode 100644 libavcodec/libfdk-aacdec.c
diff --git a/configure b/configure
index 2af4d2a..90d2c74 100755
--- a/configure
+++ b/configure
@@ -181,7 +181,7 @@ External library support:
--enable-libdc1394 enable IIDC-1394 grabbing using libdc1394
and libraw1394 [no]
--enable-libfaac enable AAC encoding via libfaac [no]
- --enable-libfdk-aac enable AAC encoding via libfdk-aac [no]
+ --enable-libfdk-aac enable AAC de/encoding via libfdk-aac [no]
--enable-libfreetype enable libfreetype [no]
--enable-libgsm enable GSM de/encoding via libgsm [no]
--enable-libilbc enable iLBC de/encoding via libilbc [no]
@@ -1756,6 +1756,7 @@ vc1_parser_select="mpegvideo"
# external libraries
libfaac_encoder_deps="libfaac"
libfaac_encoder_select="audio_frame_queue"
+libfdk_aac_decoder_deps="libfdk_aac"
libfdk_aac_encoder_deps="libfdk_aac"
libfdk_aac_encoder_select="audio_frame_queue"
libgsm_decoder_deps="libgsm"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index fc1bfb2..0a1bde5 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -569,6 +569,7 @@ OBJS-$(CONFIG_WTV_DEMUXER) += mpeg4audio.o
mpegaudiodata.o
# external codec libraries
OBJS-$(CONFIG_LIBFAAC_ENCODER) += libfaac.o
+OBJS-$(CONFIG_LIBFDK_AAC_DECODER) += libfdk-aacdec.o
OBJS-$(CONFIG_LIBFDK_AAC_ENCODER) += libfdk-aacenc.o
OBJS-$(CONFIG_LIBGSM_DECODER) += libgsm.o
OBJS-$(CONFIG_LIBGSM_ENCODER) += libgsm.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index fd73492..d4531f2 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -410,7 +410,7 @@ void avcodec_register_all(void)
/* external libraries */
REGISTER_ENCODER(LIBFAAC, libfaac);
- REGISTER_ENCODER(LIBFDK_AAC, libfdk_aac);
+ REGISTER_ENCDEC (LIBFDK_AAC, libfdk_aac);
REGISTER_ENCDEC (LIBGSM, libgsm);
REGISTER_ENCDEC (LIBGSM_MS, libgsm_ms);
REGISTER_ENCDEC (LIBILBC, libilbc);
diff --git a/libavcodec/libfdk-aacdec.c b/libavcodec/libfdk-aacdec.c
new file mode 100644
index 0000000..d611146
--- /dev/null
+++ b/libavcodec/libfdk-aacdec.c
@@ -0,0 +1,296 @@
+/*
+ * AAC decoder wrapper
+ * Copyright (c) 2012 Martin Storsjo
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <fdk-aac/aacdecoder_lib.h>
+
+#include "libavutil/channel_layout.h"
+#include "libavutil/common.h"
+#include "libavutil/opt.h"
+#include "avcodec.h"
+#include "internal.h"
+
+enum ConcealMethod {
+ CONCEAL_METHOD_DEFAULT = -1,
+ CONCEAL_METHOD_SPECTRAL_MUTING = 0,
+ CONCEAL_METHOD_NOISE_SUBSTITUTION = 1,
+ CONCEAL_METHOD_ENERGY_INTERPOLATION = 2,
+ CONCEAL_METHOD_NB,
+};
+
+typedef struct AACContext {
+ const AVClass *class;
+ HANDLE_AACDECODER handle;
+ int initialized;
+ enum ConcealMethod conceal_method;
+} AACContext;
+
+#define A AV_OPT_FLAG_AUDIO_PARAM
+#define D AV_OPT_FLAG_DECODING_PARAM
+static const AVOption fdk_aac_dec_options[] = {
+ { "conceal", "Error concealment method", offsetof(AACContext, conceal_method),
AV_OPT_TYPE_INT, { .i64 = CONCEAL_METHOD_DEFAULT }, CONCEAL_METHOD_DEFAULT, CONCEAL_METHOD_NB - 1, A|D,
"conceal" },
+ { "default", "Default", 0, AV_OPT_TYPE_CONST, { .i64 =
CONCEAL_METHOD_DEFAULT }, INT_MIN, INT_MAX, A|D, "conceal" },
+ { "spectral", "Spectral muting", 0, AV_OPT_TYPE_CONST, { .i64 =
CONCEAL_METHOD_SPECTRAL_MUTING }, INT_MIN, INT_MAX, A|D, "conceal" },
+ { "noise", "Noise Substitution", 0, AV_OPT_TYPE_CONST, { .i64 =
CONCEAL_METHOD_NOISE_SUBSTITUTION }, INT_MIN, INT_MAX, A|D, "conceal" },
+ { "energy", "Energy Interpolation", 0, AV_OPT_TYPE_CONST, { .i64 =
CONCEAL_METHOD_ENERGY_INTERPOLATION }, INT_MIN, INT_MAX, A|D, "conceal" },
+ { NULL }
+};
+
+static const AVClass fdk_aac_dec_class = {
+ "libfdk_aac", av_default_item_name, fdk_aac_dec_options,
LIBAVUTIL_VERSION_INT
+};