libaac+ support

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
pull/2/head
tipok 13 years ago committed by Michael Niedermayer
parent 023e9960d7
commit cbf914cf16
  1. 1
      Changelog
  2. 6
      LICENSE
  3. 6
      configure
  4. 4
      doc/general.texi
  5. 1
      libavcodec/Makefile
  6. 1
      libavcodec/allcodecs.c
  7. 136
      libavcodec/libaacplus.c

@ -72,6 +72,7 @@ version 0.8:
- Demuxer for On2's IVF format
- Pictor/PC Paint decoder
- HE-AAC v2 decoder
- HE-AAC v2 encoding with libaacplus
- libfaad2 wrapper removed
- DTS-ES extension (XCh) decoding support
- native VP8 decoder

@ -41,6 +41,6 @@ is incompatible with the LGPL v2.1 and the GPL v2, but not with version 3 of
those licenses. So to combine the OpenCORE libraries with FFmpeg, the license
version needs to be upgraded by passing --enable-version3 to configure.
The nonfree external library libfaac can be hooked up in FFmpeg. You need to
pass --enable-nonfree to configure to enable it. Employ this option with care
as FFmpeg then becomes nonfree and unredistributable.
The nonfree external libraries libfaac and libaacplus can be hooked up in FFmpeg.
You need to pass --enable-nonfree to configure to enable it. Employ this option
with care as FFmpeg then becomes nonfree and unredistributable.

6
configure vendored

@ -165,6 +165,7 @@ External library support:
--enable-bzlib enable bzlib [autodetect]
--enable-libcelt enable CELT/Opus decoding via libcelt [no]
--enable-frei0r enable frei0r video filtering
--enable-libaacplus enable AAC+ encoding via libaacplus [no]
--enable-libopencore-amrnb enable AMR-NB de/encoding via libopencore-amrnb [no]
--enable-libopencore-amrwb enable AMR-WB decoding via libopencore-amrwb [no]
--enable-libopencv enable video filtering via libopencv [no]
@ -994,6 +995,7 @@ CONFIG_LIST="
h264pred
hardcoded_tables
huffman
libaacplus
libcdio
libcelt
libdc1394
@ -1483,6 +1485,7 @@ vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
h264_parser_select="golomb h264dsp h264pred"
# external libraries
libaacplus_encoder_deps="libaacplus"
libcelt_decoder_deps="libcelt"
libdirac_decoder_deps="libdirac !libschroedinger"
libdirac_encoder_deps="libdirac"
@ -2687,6 +2690,7 @@ die_license_disabled gpl libxavs
die_license_disabled gpl libxvid
die_license_disabled gpl x11grab
die_license_disabled nonfree libaacplus
die_license_disabled nonfree libfaac
die_license_disabled version3 libopencore_amrnb
@ -3008,6 +3012,7 @@ check_mathfunc truncf
enabled avisynth && require2 vfw32 "windows.h vfw.h" AVIFileInit -lavifil32
enabled libcelt && require libcelt celt/celt.h celt_decode -lcelt0
enabled frei0r && { check_header frei0r.h || die "ERROR: frei0r.h header not found"; }
enabled libaacplus && require "libaacplus >= 2.0.0" aacplus.h aacplusEncOpen -laacplus
enabled libdc1394 && require_pkg_config libdc1394-2 dc1394/dc1394.h dc1394_new
enabled libdirac && require_pkg_config dirac \
"libdirac_decoder/dirac_parser.h libdirac_encoder/dirac_encoder.h" \
@ -3339,6 +3344,7 @@ echo "libcdio support ${libcdio-no}"
echo "libdc1394 support ${libdc1394-no}"
echo "libdirac enabled ${libdirac-no}"
echo "libfaac enabled ${libfaac-no}"
echo "libaacplus enabled ${libaacplus-no}"
echo "libgsm enabled ${libgsm-no}"
echo "libmp3lame enabled ${libmp3lame-no}"
echo "libnut enabled ${libnut-no}"

@ -559,6 +559,8 @@ following image formats are supported:
@multitable @columnfractions .4 .1 .1 .4
@item Name @tab Encoding @tab Decoding @tab Comments
@item 8SVX audio @tab @tab X
@item AAC+ @tab E @tab X
@tab encoding supported through external library libaacplus
@item AAC @tab E @tab X
@tab encoding supported through external library libfaac and libvo-aacenc
@item AC-3 @tab IX @tab X
@ -1105,7 +1107,7 @@ These library packages are only available from
@uref{http://sourceware.org/cygwinports/, Cygwin Ports}:
@example
yasm, libSDL-devel, libdirac-devel, libfaac-devel, libgsm-devel,
yasm, libSDL-devel, libdirac-devel, libfaac-devel, libaacplus-devel, libgsm-devel,
libmp3lame-devel, libschroedinger1.0-devel, speex-devel, libtheora-devel,
libxvidcore-devel
@end example

@ -579,6 +579,7 @@ OBJS-$(CONFIG_WEBM_MUXER) += xiph.o mpeg4audio.o \
OBJS-$(CONFIG_WTV_DEMUXER) += mpeg4audio.o mpegaudiodata.o
# external codec libraries
OBJS-$(CONFIG_LIBAACPLUS_ENCODER) += libaacplus.o
OBJS-$(CONFIG_LIBCELT_DECODER) += libcelt_dec.o
OBJS-$(CONFIG_LIBDIRAC_DECODER) += libdiracdec.o
OBJS-$(CONFIG_LIBDIRAC_ENCODER) += libdiracenc.o libdirac_libschro.o

@ -374,6 +374,7 @@ void avcodec_register_all(void)
REGISTER_ENCDEC (XSUB, xsub);
/* external libraries */
REGISTER_ENCODER (LIBAACPLUS, libaacplus);
REGISTER_DECODER (LIBCELT, libcelt);
REGISTER_ENCDEC (LIBDIRAC, libdirac);
REGISTER_ENCODER (LIBFAAC, libfaac);

@ -0,0 +1,136 @@
/*
* Interface to libaacplus for aac+ (sbr+ps) encoding
* Copyright (c) 2010 tipok <piratfm@gmail.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 libaacplus for aac+ (sbr+ps) encoding.
*/
#include "avcodec.h"
#include <aacplus.h>
typedef struct aacPlusAudioContext {
aacplusEncHandle aacplus_handle;
} aacPlusAudioContext;
static av_cold int aacPlus_encode_init(AVCodecContext *avctx)
{
aacPlusAudioContext *s = avctx->priv_data;
aacplusEncConfiguration *aacplus_cfg;
unsigned long samples_input, max_bytes_output;
/* number of channels */
if (avctx->channels < 1 || avctx->channels > 2) {
av_log(avctx, AV_LOG_ERROR, "encoding %d channel(s) is not allowed\n", avctx->channels);
return -1;
}
s->aacplus_handle = aacplusEncOpen(avctx->sample_rate,
avctx->channels,
&samples_input, &max_bytes_output);
if(!s->aacplus_handle) {
av_log(avctx, AV_LOG_ERROR, "can't open encoder\n");
return -1;
}
/* check aacplus version */
aacplus_cfg = aacplusEncGetCurrentConfiguration(s->aacplus_handle);
/* put the options in the configuration struct */
if(avctx->profile != FF_PROFILE_AAC_LOW && avctx->profile != FF_PROFILE_UNKNOWN) {
av_log(avctx, AV_LOG_ERROR, "invalid AAC profile: %d, only LC supported\n", avctx->profile);
aacplusEncClose(s->aacplus_handle);
return -1;
}
aacplus_cfg->bitRate = avctx->bit_rate;
aacplus_cfg->bandWidth = avctx->cutoff;
if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) {
aacplus_cfg->outputFormat = 0; //raw aac
}
aacplus_cfg->inputFormat = AACPLUS_INPUT_16BIT;
if (!aacplusEncSetConfiguration(s->aacplus_handle, aacplus_cfg)) {
av_log(avctx, AV_LOG_ERROR, "libaacplus doesn't support this output format!\n");
return -1;
}
avctx->frame_size = samples_input / avctx->channels;
avctx->coded_frame= avcodec_alloc_frame();
avctx->coded_frame->key_frame= 1;
/* Set decoder specific info */
avctx->extradata_size = 0;
if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) {
unsigned char *buffer = NULL;
unsigned long decoder_specific_info_size;
if (aacplusEncGetDecoderSpecificInfo(s->aacplus_handle, &buffer,
&decoder_specific_info_size) == 1) {
avctx->extradata = av_malloc(decoder_specific_info_size + FF_INPUT_BUFFER_PADDING_SIZE);
avctx->extradata_size = decoder_specific_info_size;
memcpy(avctx->extradata, buffer, avctx->extradata_size);
}
#undef free
free(buffer);
#define free please_use_av_free
}
return 0;
}
static int aacPlus_encode_frame(AVCodecContext *avctx,
unsigned char *frame, int buf_size, void *data)
{
aacPlusAudioContext *s = avctx->priv_data;
int bytes_written;
bytes_written = aacplusEncEncode(s->aacplus_handle,
data,
avctx->frame_size * avctx->channels,
frame,
buf_size);
return bytes_written;
}
static av_cold int aacPlus_encode_close(AVCodecContext *avctx)
{
aacPlusAudioContext *s = avctx->priv_data;
av_freep(&avctx->coded_frame);
av_freep(&avctx->extradata);
aacplusEncClose(s->aacplus_handle);
return 0;
}
AVCodec ff_libaacplus_encoder = {
"libaacplus",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_AAC,
sizeof(aacPlusAudioContext),
aacPlus_encode_init,
aacPlus_encode_frame,
aacPlus_encode_close,
.sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE},
.long_name = NULL_IF_CONFIG_SMALL("libaacplus AAC+ (Advanced Audio Codec with SBR+PS)"),
};
Loading…
Cancel
Save