Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
tipok authored on 2011/09/26 09:28:21... | ... |
@@ -41,6 +41,6 @@ is incompatible with the LGPL v2.1 and the GPL v2, but not with version 3 of |
41 | 41 |
those licenses. So to combine the OpenCORE libraries with FFmpeg, the license |
42 | 42 |
version needs to be upgraded by passing --enable-version3 to configure. |
43 | 43 |
|
44 |
-The nonfree external library libfaac can be hooked up in FFmpeg. You need to |
|
45 |
-pass --enable-nonfree to configure to enable it. Employ this option with care |
|
46 |
-as FFmpeg then becomes nonfree and unredistributable. |
|
44 |
+The nonfree external libraries libfaac and libaacplus can be hooked up in FFmpeg. |
|
45 |
+You need to pass --enable-nonfree to configure to enable it. Employ this option |
|
46 |
+with care as FFmpeg then becomes nonfree and unredistributable. |
... | ... |
@@ -165,6 +165,7 @@ External library support: |
165 | 165 |
--enable-bzlib enable bzlib [autodetect] |
166 | 166 |
--enable-libcelt enable CELT/Opus decoding via libcelt [no] |
167 | 167 |
--enable-frei0r enable frei0r video filtering |
168 |
+ --enable-libaacplus enable AAC+ encoding via libaacplus [no] |
|
168 | 169 |
--enable-libopencore-amrnb enable AMR-NB de/encoding via libopencore-amrnb [no] |
169 | 170 |
--enable-libopencore-amrwb enable AMR-WB decoding via libopencore-amrwb [no] |
170 | 171 |
--enable-libopencv enable video filtering via libopencv [no] |
... | ... |
@@ -994,6 +995,7 @@ CONFIG_LIST=" |
994 | 994 |
h264pred |
995 | 995 |
hardcoded_tables |
996 | 996 |
huffman |
997 |
+ libaacplus |
|
997 | 998 |
libcdio |
998 | 999 |
libcelt |
999 | 1000 |
libdc1394 |
... | ... |
@@ -1483,6 +1485,7 @@ vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h" |
1483 | 1483 |
h264_parser_select="golomb h264dsp h264pred" |
1484 | 1484 |
|
1485 | 1485 |
# external libraries |
1486 |
+libaacplus_encoder_deps="libaacplus" |
|
1486 | 1487 |
libcelt_decoder_deps="libcelt" |
1487 | 1488 |
libdirac_decoder_deps="libdirac !libschroedinger" |
1488 | 1489 |
libdirac_encoder_deps="libdirac" |
... | ... |
@@ -2687,6 +2690,7 @@ die_license_disabled gpl libxavs |
2687 | 2687 |
die_license_disabled gpl libxvid |
2688 | 2688 |
die_license_disabled gpl x11grab |
2689 | 2689 |
|
2690 |
+die_license_disabled nonfree libaacplus |
|
2690 | 2691 |
die_license_disabled nonfree libfaac |
2691 | 2692 |
|
2692 | 2693 |
die_license_disabled version3 libopencore_amrnb |
... | ... |
@@ -3008,6 +3012,7 @@ check_mathfunc truncf |
3008 | 3008 |
enabled avisynth && require2 vfw32 "windows.h vfw.h" AVIFileInit -lavifil32 |
3009 | 3009 |
enabled libcelt && require libcelt celt/celt.h celt_decode -lcelt0 |
3010 | 3010 |
enabled frei0r && { check_header frei0r.h || die "ERROR: frei0r.h header not found"; } |
3011 |
+enabled libaacplus && require "libaacplus >= 2.0.0" aacplus.h aacplusEncOpen -laacplus |
|
3011 | 3012 |
enabled libdc1394 && require_pkg_config libdc1394-2 dc1394/dc1394.h dc1394_new |
3012 | 3013 |
enabled libdirac && require_pkg_config dirac \ |
3013 | 3014 |
"libdirac_decoder/dirac_parser.h libdirac_encoder/dirac_encoder.h" \ |
... | ... |
@@ -3339,6 +3344,7 @@ echo "libcdio support ${libcdio-no}" |
3339 | 3339 |
echo "libdc1394 support ${libdc1394-no}" |
3340 | 3340 |
echo "libdirac enabled ${libdirac-no}" |
3341 | 3341 |
echo "libfaac enabled ${libfaac-no}" |
3342 |
+echo "libaacplus enabled ${libaacplus-no}" |
|
3342 | 3343 |
echo "libgsm enabled ${libgsm-no}" |
3343 | 3344 |
echo "libmp3lame enabled ${libmp3lame-no}" |
3344 | 3345 |
echo "libnut enabled ${libnut-no}" |
... | ... |
@@ -559,6 +559,8 @@ following image formats are supported: |
559 | 559 |
@multitable @columnfractions .4 .1 .1 .4 |
560 | 560 |
@item Name @tab Encoding @tab Decoding @tab Comments |
561 | 561 |
@item 8SVX audio @tab @tab X |
562 |
+@item AAC+ @tab E @tab X |
|
563 |
+ @tab encoding supported through external library libaacplus |
|
562 | 564 |
@item AAC @tab E @tab X |
563 | 565 |
@tab encoding supported through external library libfaac and libvo-aacenc |
564 | 566 |
@item AC-3 @tab IX @tab X |
... | ... |
@@ -1105,7 +1107,7 @@ These library packages are only available from |
1105 | 1105 |
@uref{http://sourceware.org/cygwinports/, Cygwin Ports}: |
1106 | 1106 |
|
1107 | 1107 |
@example |
1108 |
-yasm, libSDL-devel, libdirac-devel, libfaac-devel, libgsm-devel, |
|
1108 |
+yasm, libSDL-devel, libdirac-devel, libfaac-devel, libaacplus-devel, libgsm-devel, |
|
1109 | 1109 |
libmp3lame-devel, libschroedinger1.0-devel, speex-devel, libtheora-devel, |
1110 | 1110 |
libxvidcore-devel |
1111 | 1111 |
@end example |
... | ... |
@@ -579,6 +579,7 @@ OBJS-$(CONFIG_WEBM_MUXER) += xiph.o mpeg4audio.o \ |
579 | 579 |
OBJS-$(CONFIG_WTV_DEMUXER) += mpeg4audio.o mpegaudiodata.o |
580 | 580 |
|
581 | 581 |
# external codec libraries |
582 |
+OBJS-$(CONFIG_LIBAACPLUS_ENCODER) += libaacplus.o |
|
582 | 583 |
OBJS-$(CONFIG_LIBCELT_DECODER) += libcelt_dec.o |
583 | 584 |
OBJS-$(CONFIG_LIBDIRAC_DECODER) += libdiracdec.o |
584 | 585 |
OBJS-$(CONFIG_LIBDIRAC_ENCODER) += libdiracenc.o libdirac_libschro.o |
... | ... |
@@ -374,6 +374,7 @@ void avcodec_register_all(void) |
374 | 374 |
REGISTER_ENCDEC (XSUB, xsub); |
375 | 375 |
|
376 | 376 |
/* external libraries */ |
377 |
+ REGISTER_ENCODER (LIBAACPLUS, libaacplus); |
|
377 | 378 |
REGISTER_DECODER (LIBCELT, libcelt); |
378 | 379 |
REGISTER_ENCDEC (LIBDIRAC, libdirac); |
379 | 380 |
REGISTER_ENCODER (LIBFAAC, libfaac); |
380 | 381 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,136 @@ |
0 |
+/* |
|
1 |
+ * Interface to libaacplus for aac+ (sbr+ps) encoding |
|
2 |
+ * Copyright (c) 2010 tipok <piratfm@gmail.com> |
|
3 |
+ * |
|
4 |
+ * This file is part of FFmpeg. |
|
5 |
+ * |
|
6 |
+ * FFmpeg is free software; you can redistribute it and/or |
|
7 |
+ * modify it under the terms of the GNU Lesser General Public |
|
8 |
+ * License as published by the Free Software Foundation; either |
|
9 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
10 |
+ * |
|
11 |
+ * FFmpeg is distributed in the hope that it will be useful, |
|
12 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 |
+ * Lesser General Public License for more details. |
|
15 |
+ * |
|
16 |
+ * You should have received a copy of the GNU Lesser General Public |
|
17 |
+ * License along with FFmpeg; if not, write to the Free Software |
|
18 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
19 |
+ */ |
|
20 |
+ |
|
21 |
+/** |
|
22 |
+ * @file |
|
23 |
+ * Interface to libaacplus for aac+ (sbr+ps) encoding. |
|
24 |
+ */ |
|
25 |
+ |
|
26 |
+#include "avcodec.h" |
|
27 |
+#include <aacplus.h> |
|
28 |
+ |
|
29 |
+typedef struct aacPlusAudioContext { |
|
30 |
+ aacplusEncHandle aacplus_handle; |
|
31 |
+} aacPlusAudioContext; |
|
32 |
+ |
|
33 |
+static av_cold int aacPlus_encode_init(AVCodecContext *avctx) |
|
34 |
+{ |
|
35 |
+ aacPlusAudioContext *s = avctx->priv_data; |
|
36 |
+ aacplusEncConfiguration *aacplus_cfg; |
|
37 |
+ unsigned long samples_input, max_bytes_output; |
|
38 |
+ |
|
39 |
+ /* number of channels */ |
|
40 |
+ if (avctx->channels < 1 || avctx->channels > 2) { |
|
41 |
+ av_log(avctx, AV_LOG_ERROR, "encoding %d channel(s) is not allowed\n", avctx->channels); |
|
42 |
+ return -1; |
|
43 |
+ } |
|
44 |
+ |
|
45 |
+ s->aacplus_handle = aacplusEncOpen(avctx->sample_rate, |
|
46 |
+ avctx->channels, |
|
47 |
+ &samples_input, &max_bytes_output); |
|
48 |
+ if(!s->aacplus_handle) { |
|
49 |
+ av_log(avctx, AV_LOG_ERROR, "can't open encoder\n"); |
|
50 |
+ return -1; |
|
51 |
+ } |
|
52 |
+ |
|
53 |
+ /* check aacplus version */ |
|
54 |
+ aacplus_cfg = aacplusEncGetCurrentConfiguration(s->aacplus_handle); |
|
55 |
+ |
|
56 |
+ /* put the options in the configuration struct */ |
|
57 |
+ if(avctx->profile != FF_PROFILE_AAC_LOW && avctx->profile != FF_PROFILE_UNKNOWN) { |
|
58 |
+ av_log(avctx, AV_LOG_ERROR, "invalid AAC profile: %d, only LC supported\n", avctx->profile); |
|
59 |
+ aacplusEncClose(s->aacplus_handle); |
|
60 |
+ return -1; |
|
61 |
+ } |
|
62 |
+ |
|
63 |
+ aacplus_cfg->bitRate = avctx->bit_rate; |
|
64 |
+ aacplus_cfg->bandWidth = avctx->cutoff; |
|
65 |
+ if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) { |
|
66 |
+ aacplus_cfg->outputFormat = 0; //raw aac |
|
67 |
+ } |
|
68 |
+ aacplus_cfg->inputFormat = AACPLUS_INPUT_16BIT; |
|
69 |
+ if (!aacplusEncSetConfiguration(s->aacplus_handle, aacplus_cfg)) { |
|
70 |
+ av_log(avctx, AV_LOG_ERROR, "libaacplus doesn't support this output format!\n"); |
|
71 |
+ return -1; |
|
72 |
+ } |
|
73 |
+ |
|
74 |
+ avctx->frame_size = samples_input / avctx->channels; |
|
75 |
+ |
|
76 |
+ avctx->coded_frame= avcodec_alloc_frame(); |
|
77 |
+ avctx->coded_frame->key_frame= 1; |
|
78 |
+ |
|
79 |
+ /* Set decoder specific info */ |
|
80 |
+ avctx->extradata_size = 0; |
|
81 |
+ if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) { |
|
82 |
+ |
|
83 |
+ unsigned char *buffer = NULL; |
|
84 |
+ unsigned long decoder_specific_info_size; |
|
85 |
+ |
|
86 |
+ if (aacplusEncGetDecoderSpecificInfo(s->aacplus_handle, &buffer, |
|
87 |
+ &decoder_specific_info_size) == 1) { |
|
88 |
+ avctx->extradata = av_malloc(decoder_specific_info_size + FF_INPUT_BUFFER_PADDING_SIZE); |
|
89 |
+ avctx->extradata_size = decoder_specific_info_size; |
|
90 |
+ memcpy(avctx->extradata, buffer, avctx->extradata_size); |
|
91 |
+ } |
|
92 |
+#undef free |
|
93 |
+ free(buffer); |
|
94 |
+#define free please_use_av_free |
|
95 |
+ } |
|
96 |
+ return 0; |
|
97 |
+} |
|
98 |
+ |
|
99 |
+static int aacPlus_encode_frame(AVCodecContext *avctx, |
|
100 |
+ unsigned char *frame, int buf_size, void *data) |
|
101 |
+{ |
|
102 |
+ aacPlusAudioContext *s = avctx->priv_data; |
|
103 |
+ int bytes_written; |
|
104 |
+ |
|
105 |
+ bytes_written = aacplusEncEncode(s->aacplus_handle, |
|
106 |
+ data, |
|
107 |
+ avctx->frame_size * avctx->channels, |
|
108 |
+ frame, |
|
109 |
+ buf_size); |
|
110 |
+ |
|
111 |
+ return bytes_written; |
|
112 |
+} |
|
113 |
+ |
|
114 |
+static av_cold int aacPlus_encode_close(AVCodecContext *avctx) |
|
115 |
+{ |
|
116 |
+ aacPlusAudioContext *s = avctx->priv_data; |
|
117 |
+ |
|
118 |
+ av_freep(&avctx->coded_frame); |
|
119 |
+ av_freep(&avctx->extradata); |
|
120 |
+ |
|
121 |
+ aacplusEncClose(s->aacplus_handle); |
|
122 |
+ return 0; |
|
123 |
+} |
|
124 |
+ |
|
125 |
+AVCodec ff_libaacplus_encoder = { |
|
126 |
+ "libaacplus", |
|
127 |
+ AVMEDIA_TYPE_AUDIO, |
|
128 |
+ CODEC_ID_AAC, |
|
129 |
+ sizeof(aacPlusAudioContext), |
|
130 |
+ aacPlus_encode_init, |
|
131 |
+ aacPlus_encode_frame, |
|
132 |
+ aacPlus_encode_close, |
|
133 |
+ .sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE}, |
|
134 |
+ .long_name = NULL_IF_CONFIG_SMALL("libaacplus AAC+ (Advanced Audio Codec with SBR+PS)"), |
|
135 |
+}; |