[FFmpeg-devel] [PATCH 2/2] lavc/audiotoolboxdec: add eac3 decoder

Rodger Combs rodger.combs at gmail.com
Thu Mar 31 04:00:47 CEST 2016


This is added in 10.11, so we add a #define when building against older SDKs.

The decoder actually supports 7.1-channel eac3, but since the parser only
reports 6 channels, we end up decoding the 5.1 downmix (same as the internal
decoder) for now.
---
 configure                    | 1 +
 libavcodec/Makefile          | 1 +
 libavcodec/allcodecs.c       | 1 +
 libavcodec/audiotoolboxdec.c | 7 +++++++
 4 files changed, 10 insertions(+)

diff --git a/configure b/configure
index e550547..f984a13 100755
--- a/configure
+++ b/configure
@@ -2650,6 +2650,7 @@ ac3_at_decoder_deps="audiotoolbox"
 adpcm_ima_qt_at_decoder_deps="audiotoolbox"
 alac_at_decoder_deps="audiotoolbox"
 amr_nb_at_decoder_deps="audiotoolbox"
+eac3_at_decoder_deps="audiotoolbox"
 gsm_ms_at_decoder_deps="audiotoolbox"
 ilbc_at_decoder_deps="audiotoolbox"
 mp1_at_decoder_deps="audiotoolbox"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 8c14268..801cccd 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -806,6 +806,7 @@ OBJS-$(CONFIG_AC3_AT_DECODER)             += audiotoolboxdec.o
 OBJS-$(CONFIG_ADPCM_IMA_QT_AT_DECODER)    += audiotoolboxdec.o
 OBJS-$(CONFIG_ALAC_AT_DECODER)            += audiotoolboxdec.o
 OBJS-$(CONFIG_AMR_NB_AT_DECODER)          += audiotoolboxdec.o
+OBJS-$(CONFIG_EAC3_AT_DECODER)            += audiotoolboxdec.o
 OBJS-$(CONFIG_GSM_MS_AT_DECODER)          += audiotoolboxdec.o
 OBJS-$(CONFIG_ILBC_AT_DECODER)            += audiotoolboxdec.o
 OBJS-$(CONFIG_MP1_AT_DECODER)             += audiotoolboxdec.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index f498041..0bbf7d3 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -568,6 +568,7 @@ void avcodec_register_all(void)
     REGISTER_DECODER(ADPCM_IMA_QT_AT,   adpcm_ima_qt_at);
     REGISTER_ENCDEC (ALAC_AT,           alac_at);
     REGISTER_DECODER(AMR_NB_AT,         amr_nb_at);
+    REGISTER_DECODER(EAC3_AT,           eac3_at);
     REGISTER_DECODER(GSM_MS_AT,         gsm_ms_at);
     REGISTER_ENCDEC (ILBC_AT,           ilbc_at);
     REGISTER_DECODER(MP1_AT,            mp1_at);
diff --git a/libavcodec/audiotoolboxdec.c b/libavcodec/audiotoolboxdec.c
index 4ff46ea..f840a6b 100644
--- a/libavcodec/audiotoolboxdec.c
+++ b/libavcodec/audiotoolboxdec.c
@@ -30,6 +30,10 @@
 #include "libavutil/opt.h"
 #include "libavutil/log.h"
 
+#ifndef __MAC_10_11
+#define kAudioFormatEnhancedAC3 'ec-3'
+#endif
+
 typedef struct ATDecodeContext {
     AVClass *av_class;
 
@@ -58,6 +62,8 @@ static UInt32 ffat_get_format_id(enum AVCodecID codec, int profile)
         return kAudioFormatAppleLossless;
     case AV_CODEC_ID_AMR_NB:
         return kAudioFormatAMR;
+    case AV_CODEC_ID_EAC3:
+        return kAudioFormatEnhancedAC3;
     case AV_CODEC_ID_GSM_MS:
         return kAudioFormatMicrosoftGSM;
     case AV_CODEC_ID_ILBC:
@@ -512,6 +518,7 @@ FFAT_DEC(ac3,          AV_CODEC_ID_AC3)
 FFAT_DEC(adpcm_ima_qt, AV_CODEC_ID_ADPCM_IMA_QT)
 FFAT_DEC(alac,         AV_CODEC_ID_ALAC)
 FFAT_DEC(amr_nb,       AV_CODEC_ID_AMR_NB)
+FFAT_DEC(eac3,         AV_CODEC_ID_EAC3)
 FFAT_DEC(gsm_ms,       AV_CODEC_ID_GSM_MS)
 FFAT_DEC(ilbc,         AV_CODEC_ID_ILBC)
 FFAT_DEC(mp1,          AV_CODEC_ID_MP1)
-- 
2.7.3



More information about the ffmpeg-devel mailing list