The wrapper code is based on the libamr wrapper removed in SVN rev 19365.
Signed-off-by: Martin Storsjö <martin@martin.st>
... | ... |
@@ -179,6 +179,7 @@ External library support: |
179 | 179 |
--enable-libspeex enable Speex decoding via libspeex [no] |
180 | 180 |
--enable-libtheora enable Theora encoding via libtheora [no] |
181 | 181 |
--enable-libvo-aacenc enable AAC encoding via libvo-aacenc [no] |
182 |
+ --enable-libvo-amrwbenc enable AMR-WB encoding via libvo-amrwbenc [no] |
|
182 | 183 |
--enable-libvorbis enable Vorbis encoding via libvorbis, |
183 | 184 |
native implementation exists [no] |
184 | 185 |
--enable-libvpx enable VP8 support via libvpx [no] |
... | ... |
@@ -939,6 +940,7 @@ CONFIG_LIST=" |
939 | 939 |
libspeex |
940 | 940 |
libtheora |
941 | 941 |
libvo_aacenc |
942 |
+ libvo_amrwbenc |
|
942 | 943 |
libvorbis |
943 | 944 |
libvpx |
944 | 945 |
libx264 |
... | ... |
@@ -1387,6 +1389,7 @@ libschroedinger_encoder_deps="libschroedinger" |
1387 | 1387 |
libspeex_decoder_deps="libspeex" |
1388 | 1388 |
libtheora_encoder_deps="libtheora" |
1389 | 1389 |
libvo_aacenc_encoder_deps="libvo_aacenc" |
1390 |
+libvo_amrwbenc_encoder_deps="libvo_amrwbenc" |
|
1390 | 1391 |
libvorbis_encoder_deps="libvorbis" |
1391 | 1392 |
libvpx_decoder_deps="libvpx" |
1392 | 1393 |
libvpx_encoder_deps="libvpx" |
... | ... |
@@ -2529,6 +2532,7 @@ die_license_disabled nonfree libfaac |
2529 | 2529 |
die_license_disabled version3 libopencore_amrnb |
2530 | 2530 |
die_license_disabled version3 libopencore_amrwb |
2531 | 2531 |
die_license_disabled version3 libvo_aacenc |
2532 |
+die_license_disabled version3 libvo_amrwbenc |
|
2532 | 2533 |
|
2533 | 2534 |
enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; } |
2534 | 2535 |
|
... | ... |
@@ -2869,6 +2873,7 @@ enabled libschroedinger && require_pkg_config schroedinger-1.0 schroedinger/schr |
2869 | 2869 |
enabled libspeex && require libspeex speex/speex.h speex_decoder_init -lspeex |
2870 | 2870 |
enabled libtheora && require libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg |
2871 | 2871 |
enabled libvo_aacenc && require libvo_aacenc vo-aacenc/voAAC.h voGetAACEncAPI -lvo-aacenc |
2872 |
+enabled libvo_amrwbenc && require libvo_amrwbenc vo-amrwbenc/enc_if.h E_IF_init -lvo-amrwbenc |
|
2872 | 2873 |
enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg |
2873 | 2874 |
enabled libvpx && { |
2874 | 2875 |
enabled libvpx_decoder && { check_lib2 "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_dec_init_ver -lvpx || |
... | ... |
@@ -3138,6 +3143,7 @@ echo "libspeex enabled ${libspeex-no}" |
3138 | 3138 |
echo "libtheora enabled ${libtheora-no}" |
3139 | 3139 |
echo "libva enabled ${vaapi-no}" |
3140 | 3140 |
echo "libvo-aacenc support ${libvo_aacenc-no}" |
3141 |
+echo "libvo-amrwbenc support ${libvo_amrwbenc-no}" |
|
3141 | 3142 |
echo "libvorbis enabled ${libvorbis-no}" |
3142 | 3143 |
echo "libvpx enabled ${libvpx-no}" |
3143 | 3144 |
echo "libx264 enabled ${libx264-no}" |
... | ... |
@@ -588,7 +588,8 @@ following image formats are supported: |
588 | 588 |
@item ADPCM Yamaha @tab X @tab X |
589 | 589 |
@item AMR-NB @tab E @tab X |
590 | 590 |
@tab encoding supported through external library libopencore-amrnb |
591 |
-@item AMR-WB @tab @tab X |
|
591 |
+@item AMR-WB @tab E @tab X |
|
592 |
+ @tab encoding supported through external library libvo-amrwbenc |
|
592 | 593 |
@item Apple lossless audio @tab X @tab X |
593 | 594 |
@tab QuickTime fourcc 'alac' |
594 | 595 |
@item Atrac 1 @tab @tab X |
... | ... |
@@ -569,6 +569,7 @@ OBJS-$(CONFIG_LIBSCHROEDINGER_ENCODER) += libschroedingerenc.o \ |
569 | 569 |
OBJS-$(CONFIG_LIBSPEEX_DECODER) += libspeexdec.o |
570 | 570 |
OBJS-$(CONFIG_LIBTHEORA_ENCODER) += libtheoraenc.o |
571 | 571 |
OBJS-$(CONFIG_LIBVO_AACENC_ENCODER) += libvo-aacenc.o mpeg4audio.o |
572 |
+OBJS-$(CONFIG_LIBVO_AMRWBENC_ENCODER) += libvo-amrwbenc.o |
|
572 | 573 |
OBJS-$(CONFIG_LIBVORBIS_ENCODER) += libvorbis.o vorbis_data.o |
573 | 574 |
OBJS-$(CONFIG_LIBVPX_DECODER) += libvpxdec.o |
574 | 575 |
OBJS-$(CONFIG_LIBVPX_ENCODER) += libvpxenc.o |
... | ... |
@@ -367,6 +367,7 @@ void avcodec_register_all(void) |
367 | 367 |
REGISTER_DECODER (LIBSPEEX, libspeex); |
368 | 368 |
REGISTER_ENCODER (LIBTHEORA, libtheora); |
369 | 369 |
REGISTER_ENCODER (LIBVO_AACENC, libvo_aacenc); |
370 |
+ REGISTER_ENCODER (LIBVO_AMRWBENC, libvo_amrwbenc); |
|
370 | 371 |
REGISTER_ENCODER (LIBVORBIS, libvorbis); |
371 | 372 |
REGISTER_ENCDEC (LIBVPX, libvpx); |
372 | 373 |
REGISTER_ENCODER (LIBX264, libx264); |
373 | 374 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,127 @@ |
0 |
+/* |
|
1 |
+ * AMR Audio encoder stub |
|
2 |
+ * Copyright (c) 2003 the ffmpeg project |
|
3 |
+ * |
|
4 |
+ * This file is part of Libav. |
|
5 |
+ * |
|
6 |
+ * Libav 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 |
+ * Libav 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 Libav; if not, write to the Free Software |
|
18 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
19 |
+ */ |
|
20 |
+ |
|
21 |
+#include <vo-amrwbenc/enc_if.h> |
|
22 |
+ |
|
23 |
+#include "avcodec.h" |
|
24 |
+ |
|
25 |
+static const char wb_bitrate_unsupported[] = |
|
26 |
+ "bitrate not supported: use one of 6.6k, 8.85k, 12.65k, 14.25k, 15.85k, " |
|
27 |
+ "18.25k, 19.85k, 23.05k, or 23.85k\n"; |
|
28 |
+ |
|
29 |
+typedef struct AMRWB_bitrates { |
|
30 |
+ int rate; |
|
31 |
+ int mode; |
|
32 |
+} AMRWB_bitrates; |
|
33 |
+ |
|
34 |
+typedef struct AMRWBContext { |
|
35 |
+ void *state; |
|
36 |
+ int mode; |
|
37 |
+ int allow_dtx; |
|
38 |
+} AMRWBContext; |
|
39 |
+ |
|
40 |
+static int getWBBitrateMode(int bitrate) |
|
41 |
+{ |
|
42 |
+ /* make the correspondance between bitrate and mode */ |
|
43 |
+ AMRWB_bitrates rates[] = { { 6600, 0}, |
|
44 |
+ { 8850, 1}, |
|
45 |
+ {12650, 2}, |
|
46 |
+ {14250, 3}, |
|
47 |
+ {15850, 4}, |
|
48 |
+ {18250, 5}, |
|
49 |
+ {19850, 6}, |
|
50 |
+ {23050, 7}, |
|
51 |
+ {23850, 8}, }; |
|
52 |
+ int i; |
|
53 |
+ |
|
54 |
+ for (i = 0; i < 9; i++) |
|
55 |
+ if (rates[i].rate == bitrate) |
|
56 |
+ return rates[i].mode; |
|
57 |
+ /* no bitrate matching, return an error */ |
|
58 |
+ return -1; |
|
59 |
+} |
|
60 |
+ |
|
61 |
+static av_cold int amr_wb_encode_init(AVCodecContext *avctx) |
|
62 |
+{ |
|
63 |
+ AMRWBContext *s = avctx->priv_data; |
|
64 |
+ |
|
65 |
+ if (avctx->sample_rate != 16000) { |
|
66 |
+ av_log(avctx, AV_LOG_ERROR, "Only 16000Hz sample rate supported\n"); |
|
67 |
+ return -1; |
|
68 |
+ } |
|
69 |
+ |
|
70 |
+ if (avctx->channels != 1) { |
|
71 |
+ av_log(avctx, AV_LOG_ERROR, "Only mono supported\n"); |
|
72 |
+ return -1; |
|
73 |
+ } |
|
74 |
+ |
|
75 |
+ if ((s->mode = getWBBitrateMode(avctx->bit_rate)) < 0) { |
|
76 |
+ av_log(avctx, AV_LOG_ERROR, wb_bitrate_unsupported); |
|
77 |
+ return -1; |
|
78 |
+ } |
|
79 |
+ |
|
80 |
+ avctx->frame_size = 320; |
|
81 |
+ avctx->coded_frame = avcodec_alloc_frame(); |
|
82 |
+ |
|
83 |
+ s->state = E_IF_init(); |
|
84 |
+ s->allow_dtx = 0; |
|
85 |
+ |
|
86 |
+ return 0; |
|
87 |
+} |
|
88 |
+ |
|
89 |
+static int amr_wb_encode_close(AVCodecContext *avctx) |
|
90 |
+{ |
|
91 |
+ AMRWBContext *s = avctx->priv_data; |
|
92 |
+ |
|
93 |
+ E_IF_exit(s->state); |
|
94 |
+ av_freep(&avctx->coded_frame); |
|
95 |
+ return 0; |
|
96 |
+} |
|
97 |
+ |
|
98 |
+static int amr_wb_encode_frame(AVCodecContext *avctx, |
|
99 |
+ unsigned char *frame/*out*/, |
|
100 |
+ int buf_size, void *data/*in*/) |
|
101 |
+{ |
|
102 |
+ AMRWBContext *s = avctx->priv_data; |
|
103 |
+ int size; |
|
104 |
+ |
|
105 |
+ if ((s->mode = getWBBitrateMode(avctx->bit_rate)) < 0) { |
|
106 |
+ av_log(avctx, AV_LOG_ERROR, wb_bitrate_unsupported); |
|
107 |
+ return -1; |
|
108 |
+ } |
|
109 |
+ size = E_IF_encode(s->state, s->mode, data, frame, s->allow_dtx); |
|
110 |
+ return size; |
|
111 |
+} |
|
112 |
+ |
|
113 |
+AVCodec ff_libvo_amrwbenc_encoder = { |
|
114 |
+ "libvo_amrwbenc", |
|
115 |
+ CODEC_TYPE_AUDIO, |
|
116 |
+ CODEC_ID_AMR_WB, |
|
117 |
+ sizeof(AMRWBContext), |
|
118 |
+ amr_wb_encode_init, |
|
119 |
+ amr_wb_encode_frame, |
|
120 |
+ amr_wb_encode_close, |
|
121 |
+ NULL, |
|
122 |
+ .sample_fmts = (enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE}, |
|
123 |
+ .long_name = NULL_IF_CONFIG_SMALL("libvo-amrwbenc Adaptive Multi-Rate " |
|
124 |
+ "(AMR) Wide-Band"), |
|
125 |
+}; |
|
126 |
+ |
... | ... |
@@ -21,7 +21,7 @@ |
21 | 21 |
#define AVCODEC_VERSION_H |
22 | 22 |
|
23 | 23 |
#define LIBAVCODEC_VERSION_MAJOR 52 |
24 |
-#define LIBAVCODEC_VERSION_MINOR 118 |
|
24 |
+#define LIBAVCODEC_VERSION_MINOR 119 |
|
25 | 25 |
#define LIBAVCODEC_VERSION_MICRO 0 |
26 | 26 |
|
27 | 27 |
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |