[FFmpeg-devel] [PATCH] avcodec: Remove libfaac, the internal AAC encoder is better

Kieran Kunhya kieran at kunhya.com
Sun Apr 10 17:38:35 CEST 2016


---
 Changelog              |   1 +
 configure              |   6 --
 doc/encoders.texi      | 105 ---------------------
 doc/ffserver.conf      |   2 +-
 doc/general.texi       |   2 +-
 doc/muxers.texi        |   4 +-
 doc/platform.texi      |   2 +-
 libavcodec/Makefile    |   1 -
 libavcodec/allcodecs.c |   1 -
 libavcodec/libfaac.c   | 248 -------------------------------------------------
 libavcodec/version.h   |   2 +-
 11 files changed, 7 insertions(+), 367 deletions(-)
 delete mode 100644 libavcodec/libfaac.c

diff --git a/Changelog b/Changelog
index b4a4dd7..7bcb0c4 100644
--- a/Changelog
+++ b/Changelog
@@ -22,6 +22,7 @@ version <next>:
 - musx demuxer
 - aix demuxer
 - remap filter
+- libfaac removed
 
 version 3.0:
 - Common Encryption (CENC) MP4 encoding and decoding support
diff --git a/configure b/configure
index 94a66d8..32d710d 100755
--- a/configure
+++ b/configure
@@ -219,7 +219,6 @@ External library support:
   --enable-libcdio         enable audio CD grabbing with libcdio [no]
   --enable-libdc1394       enable IIDC-1394 grabbing using libdc1394
                            and libraw1394 [no]
-  --enable-libfaac         enable AAC encoding via libfaac [no]
   --enable-libfdk-aac      enable AAC de/encoding via libfdk-aac [no]
   --enable-libflite        enable flite (voice synthesis) support via libflite [no]
   --enable-libfreetype     enable libfreetype, needed for drawtext filter [no]
@@ -1467,7 +1466,6 @@ EXTERNAL_LIBRARY_LIST="
     libcdio
     libcelt
     libdc1394
-    libfaac
     libfdk_aac
     libflite
     libfontconfig
@@ -2673,8 +2671,6 @@ pcm_mulaw_at_encoder_select="audio_frame_queue"
 chromaprint_muxer_deps="chromaprint"
 h264_videotoolbox_encoder_deps="videotoolbox_encoder pthreads"
 libcelt_decoder_deps="libcelt"
-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"
@@ -4946,7 +4942,6 @@ die_license_disabled gpl libxvid
 die_license_disabled gpl x11grab
 
 die_license_disabled nonfree cuda
-die_license_disabled nonfree libfaac
 die_license_disabled nonfree nvenc
 enabled gpl && die_license_disabled_gpl nonfree libfdk_aac
 enabled gpl && die_license_disabled_gpl nonfree openssl
@@ -5534,7 +5529,6 @@ enabled libcelt           && require libcelt celt/celt.h celt_decode -lcelt0 &&
                              { check_lib celt/celt.h celt_decoder_create_custom -lcelt0 ||
                                die "ERROR: libcelt must be installed and version must be >= 0.11.0."; }
 enabled libcaca           && require_pkg_config caca caca.h caca_create_canvas
-enabled libfaac           && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
 enabled libfdk_aac        && { use_pkg_config fdk-aac "fdk-aac/aacenc_lib.h" aacEncOpen ||
                                { require libfdk_aac fdk-aac/aacenc_lib.h aacEncOpen -lfdk-aac &&
                                  warn "using libfdk without pkg-config"; } }
diff --git a/doc/encoders.texi b/doc/encoders.texi
index f38cad3..5c09136 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -611,111 +611,6 @@ and slightly improves compression.
 
 @end table
 
- at anchor{libfaac}
- at section libfaac
-
-libfaac AAC (Advanced Audio Coding) encoder wrapper.
-
-This encoder is of much lower quality and is more unstable than any other AAC
-encoders, so it's highly recommended to instead use other encoders, like
- at ref{aacenc,,the native FFmpeg AAC encoder}.
-
-This encoder also requires the presence of the libfaac headers and library
-during configuration. You need to explicitly configure the build with
- at code{--enable-libfaac --enable-nonfree}.
-
- at subsection Options
-
-The following shared FFmpeg codec options are recognized.
-
-The following options are supported by the libfaac wrapper. The
- at command{faac}-equivalent of the options are listed in parentheses.
-
- at table @option
- at item b (@emph{-b})
-Set bit rate in bits/s for ABR (Average Bit Rate) mode. If the bit rate
-is not explicitly specified, it is automatically set to a suitable
-value depending on the selected profile. @command{faac} bitrate is
-expressed in kilobits/s.
-
-Note that libfaac does not support CBR (Constant Bit Rate) but only
-ABR (Average Bit Rate).
-
-If VBR mode is enabled this option is ignored.
-
- at item ar (@emph{-R})
-Set audio sampling rate (in Hz).
-
- at item ac (@emph{-c})
-Set the number of audio channels.
-
- at item cutoff (@emph{-C})
-Set cutoff frequency. If not specified (or explicitly set to 0) it
-will use a value automatically computed by the library. Default value
-is 0.
-
- at item profile
-Set audio profile.
-
-The following profiles are recognized:
- at table @samp
- at item aac_main
-Main AAC (Main)
-
- at item aac_low
-Low Complexity AAC (LC)
-
- at item aac_ssr
-Scalable Sample Rate (SSR)
-
- at item aac_ltp
-Long Term Prediction (LTP)
- at end table
-
-If not specified it is set to @samp{aac_low}.
-
- at item flags +qscale
-Set constant quality VBR (Variable Bit Rate) mode.
-
- at item global_quality
-Set quality in VBR mode as an integer number of lambda units.
-
-Only relevant when VBR mode is enabled with @code{flags +qscale}.  The
-value is converted to QP units by dividing it by @code{FF_QP2LAMBDA},
-and used to set the quality value used by libfaac. A reasonable range
-for the option value in QP units is [10-500], the higher the value the
-higher the quality.
-
- at item q (@emph{-q})
-Enable VBR mode when set to a non-negative value, and set constant
-quality value as a double floating point value in QP units.
-
-The value sets the quality value used by libfaac. A reasonable range
-for the option value is [10-500], the higher the value the higher the
-quality.
-
-This option is valid only using the @command{ffmpeg} command-line
-tool. For library interface users, use @option{global_quality}.
- at end table
-
- at subsection Examples
-
- at itemize
- at item
-Use @command{ffmpeg} to convert an audio file to ABR 128 kbps AAC in an M4A (MP4)
-container:
- at example
-ffmpeg -i input.wav -codec:a libfaac -b:a 128k -output.m4a
- at end example
-
- at item
-Use @command{ffmpeg} to convert an audio file to VBR AAC, using the
-LTP AAC profile:
- at example
-ffmpeg -i input.wav -c:a libfaac -profile:a aac_ltp -q:a 100 output.m4a
- at end example
- at end itemize
-
 @anchor{libfdk-aac-enc}
 @section libfdk_aac
 
diff --git a/doc/ffserver.conf b/doc/ffserver.conf
index 7a30fb6..e3f99bb 100644
--- a/doc/ffserver.conf
+++ b/doc/ffserver.conf
@@ -317,7 +317,7 @@ StartSendOnKey
 #AVPresetVideo baseline
 #AVOptionVideo flags +global_header
 #
-#AudioCodec libfaac
+#AudioCodec aac
 #AudioBitRate 32
 #AudioChannels 2
 #AudioSampleRate 22050
diff --git a/doc/general.texi b/doc/general.texi
index 59ea4f4..fbcccdc 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -875,7 +875,7 @@ following image formats are supported:
 @item 8SVX exponential       @tab     @tab  X
 @item 8SVX fibonacci         @tab     @tab  X
 @item AAC                    @tab EX  @tab  X
-    @tab encoding supported through internal encoder and external libraries libfaac and libfdk-aac
+    @tab encoding supported through internal encoder and external library libfdk-aac
 @item AAC+                   @tab  E  @tab  IX
     @tab encoding supported through external library libfdk-aac
 @item AC-3                   @tab IX  @tab  IX
diff --git a/doc/muxers.texi b/doc/muxers.texi
index 2aafbad..839909d 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -1290,9 +1290,9 @@ ffmpeg -i in.mkv -codec copy -map 0 -f segment -segment_list out.csv -segment_fr
 
 @item
 Convert the @file{in.mkv} to TS segments using the @code{libx264}
-and @code{libfaac} encoders:
+and internal AAC encoders:
 @example
-ffmpeg -i in.mkv -map 0 -codec:v libx264 -codec:a libfaac -f ssegment -segment_list out.list out%03d.ts
+ffmpeg -i in.mkv -map 0 -codec:v libx264 -codec:a aac -f ssegment -segment_list out.list out%03d.ts
 @end example
 
 @item
diff --git a/doc/platform.texi b/doc/platform.texi
index f7ee456..65f3cb5 100644
--- a/doc/platform.texi
+++ b/doc/platform.texi
@@ -314,7 +314,7 @@ These library packages are only available from
 @uref{http://sourceware.org/cygwinports/, Cygwin Ports}:
 
 @example
-yasm, libSDL-devel, libfaac-devel, libgsm-devel, libmp3lame-devel,
+yasm, libSDL-devel, libgsm-devel, libmp3lame-devel,
 libschroedinger1.0-devel, speex-devel, libtheora-devel, libxvidcore-devel
 @end example
 
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index d4faf26..9b447fe 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -825,7 +825,6 @@ OBJS-$(CONFIG_ILBC_AT_ENCODER)            += audiotoolboxenc.o
 OBJS-$(CONFIG_PCM_ALAW_AT_ENCODER)        += audiotoolboxenc.o
 OBJS-$(CONFIG_PCM_MULAW_AT_ENCODER)       += audiotoolboxenc.o
 OBJS-$(CONFIG_LIBCELT_DECODER)            += libcelt_dec.o
-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)             += libgsmdec.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 44e7c3f..e4c8d37 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -581,7 +581,6 @@ void avcodec_register_all(void)
     REGISTER_DECODER(QDMC_AT,           qdmc_at);
     REGISTER_DECODER(QDM2_AT,           qdm2_at);
     REGISTER_DECODER(LIBCELT,           libcelt);
-    REGISTER_ENCODER(LIBFAAC,           libfaac);
     REGISTER_ENCDEC (LIBFDK_AAC,        libfdk_aac);
     REGISTER_ENCDEC (LIBGSM,            libgsm);
     REGISTER_ENCDEC (LIBGSM_MS,         libgsm_ms);
diff --git a/libavcodec/libfaac.c b/libavcodec/libfaac.c
deleted file mode 100644
index 98b3ba8..0000000
--- a/libavcodec/libfaac.c
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * Interface to libfaac for aac encoding
- * Copyright (c) 2002 Gildas Bazin <gbazin at netcourrier.com>
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg 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.
- *
- * FFmpeg 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 FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/**
- * @file
- * Interface to libfaac for aac encoding.
- */
-
-#include <faac.h>
-
-#include "libavutil/channel_layout.h"
-#include "libavutil/common.h"
-#include "avcodec.h"
-#include "audio_frame_queue.h"
-#include "internal.h"
-
-
-/* libfaac has an encoder delay of 1024 samples */
-#define FAAC_DELAY_SAMPLES 1024
-
-typedef struct FaacAudioContext {
-    faacEncHandle faac_handle;
-    AudioFrameQueue afq;
-} FaacAudioContext;
-
-static av_cold int Faac_encode_close(AVCodecContext *avctx)
-{
-    FaacAudioContext *s = avctx->priv_data;
-
-    av_freep(&avctx->extradata);
-    ff_af_queue_close(&s->afq);
-
-    if (s->faac_handle)
-        faacEncClose(s->faac_handle);
-
-    return 0;
-}
-
-static const int channel_maps[][6] = {
-    { 2, 0, 1 },          //< C L R
-    { 2, 0, 1, 3 },       //< C L R Cs
-    { 2, 0, 1, 3, 4 },    //< C L R Ls Rs
-    { 2, 0, 1, 4, 5, 3 }, //< C L R Ls Rs LFE
-};
-
-static av_cold int Faac_encode_init(AVCodecContext *avctx)
-{
-    FaacAudioContext *s = avctx->priv_data;
-    faacEncConfigurationPtr faac_cfg;
-    unsigned long samples_input, max_bytes_output;
-    int ret;
-
-    /* number of channels */
-    if (avctx->channels < 1 || avctx->channels > 6) {
-        av_log(avctx, AV_LOG_ERROR, "encoding %d channel(s) is not allowed\n", avctx->channels);
-        ret = AVERROR(EINVAL);
-        goto error;
-    }
-
-    s->faac_handle = faacEncOpen(avctx->sample_rate,
-                                 avctx->channels,
-                                 &samples_input, &max_bytes_output);
-    if (!s->faac_handle) {
-        av_log(avctx, AV_LOG_ERROR, "error in faacEncOpen()\n");
-        ret = AVERROR_UNKNOWN;
-        goto error;
-    }
-
-    /* check faac version */
-    faac_cfg = faacEncGetCurrentConfiguration(s->faac_handle);
-    if (faac_cfg->version != FAAC_CFG_VERSION) {
-        av_log(avctx, AV_LOG_ERROR, "wrong libfaac version (compiled for: %d, using %d)\n", FAAC_CFG_VERSION, faac_cfg->version);
-        ret = AVERROR(EINVAL);
-        goto error;
-    }
-
-    /* put the options in the configuration struct */
-    switch(avctx->profile) {
-        case FF_PROFILE_AAC_MAIN:
-            faac_cfg->aacObjectType = MAIN;
-            break;
-        case FF_PROFILE_UNKNOWN:
-        case FF_PROFILE_AAC_LOW:
-            faac_cfg->aacObjectType = LOW;
-            break;
-        case FF_PROFILE_AAC_SSR:
-            faac_cfg->aacObjectType = SSR;
-            break;
-        case FF_PROFILE_AAC_LTP:
-            faac_cfg->aacObjectType = LTP;
-            break;
-        default:
-            av_log(avctx, AV_LOG_ERROR, "invalid AAC profile\n");
-            ret = AVERROR(EINVAL);
-            goto error;
-    }
-    faac_cfg->mpegVersion = MPEG4;
-    faac_cfg->useTns = 0;
-    faac_cfg->allowMidside = 1;
-    faac_cfg->bitRate = avctx->bit_rate / avctx->channels;
-    faac_cfg->bandWidth = avctx->cutoff;
-    if(avctx->flags & AV_CODEC_FLAG_QSCALE) {
-        faac_cfg->bitRate = 0;
-        faac_cfg->quantqual = avctx->global_quality / FF_QP2LAMBDA;
-    }
-    faac_cfg->outputFormat = 1;
-    faac_cfg->inputFormat = FAAC_INPUT_16BIT;
-    if (avctx->channels > 2)
-        memcpy(faac_cfg->channel_map, channel_maps[avctx->channels-3],
-               avctx->channels * sizeof(int));
-
-    avctx->frame_size = samples_input / avctx->channels;
-
-    /* Set decoder specific info */
-    avctx->extradata_size = 0;
-    if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
-
-        unsigned char *buffer = NULL;
-        unsigned long decoder_specific_info_size;
-
-        if (!faacEncGetDecoderSpecificInfo(s->faac_handle, &buffer,
-                                           &decoder_specific_info_size)) {
-            avctx->extradata = av_malloc(decoder_specific_info_size + AV_INPUT_BUFFER_PADDING_SIZE);
-            if (!avctx->extradata) {
-                ret = AVERROR(ENOMEM);
-                goto error;
-            }
-            avctx->extradata_size = decoder_specific_info_size;
-            memcpy(avctx->extradata, buffer, avctx->extradata_size);
-            faac_cfg->outputFormat = 0;
-        }
-        free(buffer);
-    }
-
-    if (!faacEncSetConfiguration(s->faac_handle, faac_cfg)) {
-        int i;
-        for (i = avctx->bit_rate/1000; i ; i--) {
-            faac_cfg->bitRate = 1000*i / avctx->channels;
-            if (faacEncSetConfiguration(s->faac_handle, faac_cfg))
-                break;
-        }
-        if (!i) {
-            av_log(avctx, AV_LOG_ERROR, "libfaac doesn't support this output format!\n");
-            ret = AVERROR(EINVAL);
-            goto error;
-        } else {
-            avctx->bit_rate = 1000*i;
-            av_log(avctx, AV_LOG_WARNING, "libfaac doesn't support the specified bitrate, using %dkbit/s instead\n", i);
-        }
-    }
-
-    avctx->initial_padding = FAAC_DELAY_SAMPLES;
-    ff_af_queue_init(avctx, &s->afq);
-
-    return 0;
-error:
-    Faac_encode_close(avctx);
-    return ret;
-}
-
-static int Faac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
-                             const AVFrame *frame, int *got_packet_ptr)
-{
-    FaacAudioContext *s = avctx->priv_data;
-    int bytes_written, ret;
-    int num_samples  = frame ? frame->nb_samples : 0;
-    void *samples    = frame ? frame->data[0]    : NULL;
-
-    if ((ret = ff_alloc_packet2(avctx, avpkt, (7 + 768) * avctx->channels, 0)) < 0)
-        return ret;
-
-    bytes_written = faacEncEncode(s->faac_handle, samples,
-                                  num_samples * avctx->channels,
-                                  avpkt->data, avpkt->size);
-    if (bytes_written < 0) {
-        av_log(avctx, AV_LOG_ERROR, "faacEncEncode() error\n");
-        return bytes_written;
-    }
-
-    /* add current frame to the queue */
-    if (frame) {
-        if ((ret = ff_af_queue_add(&s->afq, frame)) < 0)
-            return ret;
-    }
-
-    if (!bytes_written)
-        return 0;
-
-    /* Get the next frame pts/duration */
-    ff_af_queue_remove(&s->afq, avctx->frame_size, &avpkt->pts,
-                       &avpkt->duration);
-
-    avpkt->size = bytes_written;
-    *got_packet_ptr = 1;
-    return 0;
-}
-
-static const AVProfile profiles[] = {
-    { FF_PROFILE_AAC_MAIN, "Main" },
-    { FF_PROFILE_AAC_LOW,  "LC"   },
-    { FF_PROFILE_AAC_SSR,  "SSR"  },
-    { FF_PROFILE_AAC_LTP,  "LTP"  },
-    { FF_PROFILE_UNKNOWN },
-};
-
-static const uint64_t faac_channel_layouts[] = {
-    AV_CH_LAYOUT_MONO,
-    AV_CH_LAYOUT_STEREO,
-    AV_CH_LAYOUT_SURROUND,
-    AV_CH_LAYOUT_4POINT0,
-    AV_CH_LAYOUT_5POINT0_BACK,
-    AV_CH_LAYOUT_5POINT1_BACK,
-    0
-};
-
-AVCodec ff_libfaac_encoder = {
-    .name           = "libfaac",
-    .long_name      = NULL_IF_CONFIG_SMALL("libfaac AAC (Advanced Audio Coding)"),
-    .type           = AVMEDIA_TYPE_AUDIO,
-    .id             = AV_CODEC_ID_AAC,
-    .priv_data_size = sizeof(FaacAudioContext),
-    .init           = Faac_encode_init,
-    .encode2        = Faac_encode_frame,
-    .close          = Faac_encode_close,
-    .capabilities   = AV_CODEC_CAP_SMALL_LAST_FRAME | AV_CODEC_CAP_DELAY,
-    .sample_fmts    = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16,
-                                                     AV_SAMPLE_FMT_NONE },
-    .profiles       = NULL_IF_CONFIG_SMALL(profiles),
-    .channel_layouts = faac_channel_layouts,
-};
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 1438e2e..c0f336b 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -28,7 +28,7 @@
 #include "libavutil/version.h"
 
 #define LIBAVCODEC_VERSION_MAJOR  57
-#define LIBAVCODEC_VERSION_MINOR  34
+#define LIBAVCODEC_VERSION_MINOR  35
 #define LIBAVCODEC_VERSION_MICRO 100
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
-- 
1.9.1



More information about the ffmpeg-devel mailing list