annotate amr.c @ 4818:2137206961c9 libavcodec

align vertically
author michael
date Sat, 07 Apr 2007 23:31:30 +0000
parents e69d9ecaaf84
children c3b0eb402862
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1258
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
1 /*
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
2 * AMR Audio decoder stub
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
3 * Copyright (c) 2003 the ffmpeg project
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
4 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3463
diff changeset
5 * This file is part of FFmpeg.
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3463
diff changeset
6 *
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3463
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
1258
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3463
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
1258
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
11 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3463
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
1258
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
15 * Lesser General Public License for more details.
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
16 *
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3463
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
3036
0b546eab515d Update licensing information: The FSF changed postal address.
diego
parents: 2979
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1258
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
20 */
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2895
diff changeset
21
4575
715e6e3ac428 Doxygenize the existing amr.c documentation.
takis
parents: 4565
diff changeset
22 /** @file
715e6e3ac428 Doxygenize the existing amr.c documentation.
takis
parents: 4565
diff changeset
23 * Adaptive Multi-Rate (AMR) Audio decoder stub.
715e6e3ac428 Doxygenize the existing amr.c documentation.
takis
parents: 4565
diff changeset
24 *
715e6e3ac428 Doxygenize the existing amr.c documentation.
takis
parents: 4565
diff changeset
25 * This code implements both an AMR-NarrowBand (AMR-NB) and an AMR-WideBand
715e6e3ac428 Doxygenize the existing amr.c documentation.
takis
parents: 4565
diff changeset
26 * (AMR-WB) audio encoder/decoder through external reference code from
715e6e3ac428 Doxygenize the existing amr.c documentation.
takis
parents: 4565
diff changeset
27 * http://www.3gpp.org/. The license of the code from 3gpp is unclear so you
715e6e3ac428 Doxygenize the existing amr.c documentation.
takis
parents: 4565
diff changeset
28 * have to download the code separately. Two versions exists: One fixed-point
715e6e3ac428 Doxygenize the existing amr.c documentation.
takis
parents: 4565
diff changeset
29 * and one with floats. For some reason the float-encoder is significant faster
715e6e3ac428 Doxygenize the existing amr.c documentation.
takis
parents: 4565
diff changeset
30 * at least on a P4 1.5GHz (0.9s instead of 9.9s on a 30s audio clip at MR102).
715e6e3ac428 Doxygenize the existing amr.c documentation.
takis
parents: 4565
diff changeset
31 * Both float and fixed point are supported for AMR-NB, but only float for
715e6e3ac428 Doxygenize the existing amr.c documentation.
takis
parents: 4565
diff changeset
32 * AMR-WB.
715e6e3ac428 Doxygenize the existing amr.c documentation.
takis
parents: 4565
diff changeset
33 *
715e6e3ac428 Doxygenize the existing amr.c documentation.
takis
parents: 4565
diff changeset
34 * \section AMR-NB
715e6e3ac428 Doxygenize the existing amr.c documentation.
takis
parents: 4565
diff changeset
35 *
715e6e3ac428 Doxygenize the existing amr.c documentation.
takis
parents: 4565
diff changeset
36 * \subsection Float
715e6e3ac428 Doxygenize the existing amr.c documentation.
takis
parents: 4565
diff changeset
37 * The float version (default) can be downloaded from:
4746
4aedb3b6fa4e Update specification and reference implementation links.
diego
parents: 4744
diff changeset
38 * http://www.3gpp.org/ftp/Specs/archive/26_series/26.104/26104-610.zip
4575
715e6e3ac428 Doxygenize the existing amr.c documentation.
takis
parents: 4565
diff changeset
39 * Extract the source into \c "ffmpeg/libavcodec/amr_float".
4778
4297f75202d9 Explain which configure options are necessary for which AMR variant.
diego
parents: 4746
diff changeset
40 * Enable it by passing \c "--enable-amr-nb" to \c "./configure".
4575
715e6e3ac428 Doxygenize the existing amr.c documentation.
takis
parents: 4565
diff changeset
41 *
715e6e3ac428 Doxygenize the existing amr.c documentation.
takis
parents: 4565
diff changeset
42 * \subsection Fixed-point
715e6e3ac428 Doxygenize the existing amr.c documentation.
takis
parents: 4565
diff changeset
43 * The fixed-point (TS26.073) can be downloaded from:
715e6e3ac428 Doxygenize the existing amr.c documentation.
takis
parents: 4565
diff changeset
44 * http://www.3gpp.org/ftp/Specs/archive/26_series/26.073/26073-510.zip.
715e6e3ac428 Doxygenize the existing amr.c documentation.
takis
parents: 4565
diff changeset
45 * Extract the source into \c "ffmpeg/libavcodec/amr".
4778
4297f75202d9 Explain which configure options are necessary for which AMR variant.
diego
parents: 4746
diff changeset
46 * Enable it by passing \c "--enable-amr-nb-fixed" to \c "./configure".
4575
715e6e3ac428 Doxygenize the existing amr.c documentation.
takis
parents: 4565
diff changeset
47 *
715e6e3ac428 Doxygenize the existing amr.c documentation.
takis
parents: 4565
diff changeset
48 * \subsection Specification
715e6e3ac428 Doxygenize the existing amr.c documentation.
takis
parents: 4565
diff changeset
49 * The specification for AMR-NB can be found in TS 26.071
715e6e3ac428 Doxygenize the existing amr.c documentation.
takis
parents: 4565
diff changeset
50 * (http://www.3gpp.org/ftp/Specs/html-info/26071.htm) and some other
715e6e3ac428 Doxygenize the existing amr.c documentation.
takis
parents: 4565
diff changeset
51 * info at http://www.3gpp.org/ftp/Specs/html-info/26-series.htm.
715e6e3ac428 Doxygenize the existing amr.c documentation.
takis
parents: 4565
diff changeset
52 *
715e6e3ac428 Doxygenize the existing amr.c documentation.
takis
parents: 4565
diff changeset
53 * \section AMR-WB
715e6e3ac428 Doxygenize the existing amr.c documentation.
takis
parents: 4565
diff changeset
54 * \subsection Float
715e6e3ac428 Doxygenize the existing amr.c documentation.
takis
parents: 4565
diff changeset
55 * The reference code can be downloaded from:
4746
4aedb3b6fa4e Update specification and reference implementation links.
diego
parents: 4744
diff changeset
56 * http://www.3gpp.org/ftp/Specs/archive/26_series/26.204/26204-600.zip
4778
4297f75202d9 Explain which configure options are necessary for which AMR variant.
diego
parents: 4746
diff changeset
57 * It should be extracted to \c "ffmpeg/libavcodec/amrwb_float".
4297f75202d9 Explain which configure options are necessary for which AMR variant.
diego
parents: 4746
diff changeset
58 * Enable it by passing \c "--enable-amr-wb" to \c "./configure".
4575
715e6e3ac428 Doxygenize the existing amr.c documentation.
takis
parents: 4565
diff changeset
59 *
715e6e3ac428 Doxygenize the existing amr.c documentation.
takis
parents: 4565
diff changeset
60 * \subsection Fixed-point
715e6e3ac428 Doxygenize the existing amr.c documentation.
takis
parents: 4565
diff changeset
61 * If someone wants to use the fixed point version it can be downloaded from:
715e6e3ac428 Doxygenize the existing amr.c documentation.
takis
parents: 4565
diff changeset
62 * http://www.3gpp.org/ftp/Specs/archive/26_series/26.173/26173-571.zip.
715e6e3ac428 Doxygenize the existing amr.c documentation.
takis
parents: 4565
diff changeset
63 *
715e6e3ac428 Doxygenize the existing amr.c documentation.
takis
parents: 4565
diff changeset
64 * \subsection Specification
4746
4aedb3b6fa4e Update specification and reference implementation links.
diego
parents: 4744
diff changeset
65 * The specification for AMR-WB can be found in TS 26.171
4aedb3b6fa4e Update specification and reference implementation links.
diego
parents: 4744
diff changeset
66 * (http://www.3gpp.org/ftp/Specs/html-info/26171.htm) and some other
4aedb3b6fa4e Update specification and reference implementation links.
diego
parents: 4744
diff changeset
67 * info at http://www.3gpp.org/ftp/Specs/html-info/26-series.htm.
4575
715e6e3ac428 Doxygenize the existing amr.c documentation.
takis
parents: 4565
diff changeset
68 *
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
69 */
1486
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
70
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
71 #include "avcodec.h"
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
72
3463
444bd402aebe rename AMR config variables to CONFIG_AMR*
mru
parents: 3036
diff changeset
73 #ifdef CONFIG_AMR_NB_FIXED
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
74
1258
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
75 #define MMS_IO
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
76
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
77 #include "amr/sp_dec.h"
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
78 #include "amr/d_homing.h"
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
79 #include "amr/typedef.h"
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
80 #include "amr/sp_enc.h"
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
81 #include "amr/sid_sync.h"
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
82 #include "amr/e_homing.h"
1258
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
83
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
84 #else
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
85 #include "amr_float/interf_dec.h"
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
86 #include "amr_float/interf_enc.h"
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
87 #endif
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
88
4793
e69d9ecaaf84 Print a list of valid AMR bitrates if a wrong one is used.
diego
parents: 4789
diff changeset
89 static const char *nb_bitrate_unsupported =
e69d9ecaaf84 Print a list of valid AMR bitrates if a wrong one is used.
diego
parents: 4789
diff changeset
90 "bitrate not supported: use one of 4.75k, 5.15k, 5.9k, 6.7k, 7.4k, 7.95k, 10.2k or 12.2k\n";
e69d9ecaaf84 Print a list of valid AMR bitrates if a wrong one is used.
diego
parents: 4789
diff changeset
91 static const char *wb_bitrate_unsupported =
e69d9ecaaf84 Print a list of valid AMR bitrates if a wrong one is used.
diego
parents: 4789
diff changeset
92 "bitrate not supported: use one of 6.6k, 8.85k, 12.65k, 14.25k, 15.85k, 18.25k, 19.85k, 23.05k, or 23.85k\n";
e69d9ecaaf84 Print a list of valid AMR bitrates if a wrong one is used.
diego
parents: 4789
diff changeset
93
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
94 /* Common code for fixed and float version*/
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
95 typedef struct AMR_bitrates
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
96 {
4744
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
97 int rate;
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
98 enum Mode mode;
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
99 } AMR_bitrates;
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
100
4744
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
101 /* Match desired bitrate */
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
102 static int getBitrateMode(int bitrate)
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
103 {
4744
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
104 /* make the correspondance between bitrate and mode */
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
105 AMR_bitrates rates[]={ {4750,MR475},
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
106 {5150,MR515},
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
107 {5900,MR59},
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
108 {6700,MR67},
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
109 {7400,MR74},
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
110 {7950,MR795},
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
111 {10200,MR102},
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
112 {12200,MR122},
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
113 };
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
114 int i;
4633
cd67b7ab311c Cosmetics in amr.c.
takis
parents: 4632
diff changeset
115
1486
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
116 for(i=0;i<8;i++)
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
117 {
4744
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
118 if(rates[i].rate==bitrate)
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
119 {
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
120 return(rates[i].mode);
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
121 }
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
122 }
4744
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
123 /* no bitrate matching, return an error */
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
124 return -1;
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
125 }
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
126
4094
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
127 static void amr_decode_fix_avctx(AVCodecContext * avctx)
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
128 {
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
129 const int is_amr_wb = 1 + (avctx->codec_id == CODEC_ID_AMR_WB);
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
130
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
131 if(avctx->sample_rate == 0)
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
132 {
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
133 avctx->sample_rate = 8000 * is_amr_wb;
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
134 }
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
135
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
136 if(avctx->channels == 0)
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
137 {
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
138 avctx->channels = 1;
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
139 }
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
140
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
141 avctx->frame_size = 160 * is_amr_wb;
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
142 }
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
143
3463
444bd402aebe rename AMR config variables to CONFIG_AMR*
mru
parents: 3036
diff changeset
144 #ifdef CONFIG_AMR_NB_FIXED
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
145 /* fixed point version*/
1258
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
146 /* frame size in serial bitstream file (frame type + serial stream + flags) */
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
147 #define SERIAL_FRAMESIZE (1+MAX_SERIAL_SIZE+5)
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
148
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
149 typedef struct AMRContext {
1258
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
150 int frameCount;
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
151 Speech_Decode_FrameState *speech_decoder_state;
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
152 enum RXFrameType rx_type;
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
153 enum Mode mode;
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
154 Word16 reset_flag;
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
155 Word16 reset_flag_old;
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
156
4744
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
157 int enc_bitrate;
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
158 Speech_Encode_FrameState *enstate;
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
159 sid_syncState *sidstate;
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
160 enum TXFrameType tx_frametype;
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
161 } AMRContext;
1258
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
162
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
163 static int amr_nb_decode_init(AVCodecContext * avctx)
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
164 {
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
165 AMRContext *s = avctx->priv_data;
4633
cd67b7ab311c Cosmetics in amr.c.
takis
parents: 4632
diff changeset
166
1258
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
167 s->frameCount=0;
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
168 s->speech_decoder_state=NULL;
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
169 s->rx_type = (enum RXFrameType)0;
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
170 s->mode= (enum Mode)0;
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
171 s->reset_flag=0;
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
172 s->reset_flag_old=1;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2895
diff changeset
173
1258
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
174 if(Speech_Decode_Frame_init(&s->speech_decoder_state, "Decoder"))
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
175 {
1825
231a6c19e28f av_log()
michael
parents: 1736
diff changeset
176 av_log(avctx, AV_LOG_ERROR, "Speech_Decode_Frame_init error\n");
1258
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
177 return -1;
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
178 }
4094
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
179
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
180 amr_decode_fix_avctx(avctx);
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
181
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
182 if(avctx->channels > 1)
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
183 {
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
184 av_log(avctx, AV_LOG_ERROR, "amr_nb: multichannel decoding not supported\n");
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
185 return -1;
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
186 }
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
187
1258
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
188 return 0;
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
189 }
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
190
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
191 static int amr_nb_encode_init(AVCodecContext * avctx)
1258
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
192 {
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
193 AMRContext *s = avctx->priv_data;
4633
cd67b7ab311c Cosmetics in amr.c.
takis
parents: 4632
diff changeset
194
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
195 s->frameCount=0;
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
196 s->speech_decoder_state=NULL;
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
197 s->rx_type = (enum RXFrameType)0;
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
198 s->mode= (enum Mode)0;
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
199 s->reset_flag=0;
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
200 s->reset_flag_old=1;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2895
diff changeset
201
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
202 if(avctx->sample_rate!=8000)
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
203 {
4309
1f95aa362562 always print message when error, AV_LOG_DEBUG -> AV_LOG_ERROR
bcoudurier
parents: 4221
diff changeset
204 av_log(avctx, AV_LOG_ERROR, "Only 8000Hz sample rate supported\n");
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
205 return -1;
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
206 }
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
207
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
208 if(avctx->channels!=1)
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
209 {
4309
1f95aa362562 always print message when error, AV_LOG_DEBUG -> AV_LOG_ERROR
bcoudurier
parents: 4221
diff changeset
210 av_log(avctx, AV_LOG_ERROR, "Only mono supported\n");
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
211 return -1;
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
212 }
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
213
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
214 avctx->frame_size=160;
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
215 avctx->coded_frame= avcodec_alloc_frame();
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
216
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
217 if(Speech_Encode_Frame_init(&s->enstate, 0, "encoder") || sid_sync_init (&s->sidstate))
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
218 {
4309
1f95aa362562 always print message when error, AV_LOG_DEBUG -> AV_LOG_ERROR
bcoudurier
parents: 4221
diff changeset
219 av_log(avctx, AV_LOG_ERROR, "Speech_Encode_Frame_init error\n");
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
220 return -1;
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
221 }
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
222
4744
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
223 if((s->enc_bitrate=getBitrateMode(avctx->bit_rate))<0)
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
224 {
4793
e69d9ecaaf84 Print a list of valid AMR bitrates if a wrong one is used.
diego
parents: 4789
diff changeset
225 av_log(avctx, AV_LOG_ERROR, nb_bitrate_unsupported);
4744
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
226 return -1;
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
227 }
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
228
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
229 return 0;
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
230 }
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
231
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
232 static int amr_nb_encode_close(AVCodecContext * avctx)
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
233 {
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
234 AMRContext *s = avctx->priv_data;
4633
cd67b7ab311c Cosmetics in amr.c.
takis
parents: 4632
diff changeset
235
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
236 Speech_Encode_Frame_exit(&s->enstate);
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
237 sid_sync_exit (&s->sidstate);
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
238 av_freep(&avctx->coded_frame);
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
239 return 0;
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
240 }
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
241
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
242 static int amr_nb_decode_close(AVCodecContext * avctx)
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
243 {
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
244 AMRContext *s = avctx->priv_data;
4633
cd67b7ab311c Cosmetics in amr.c.
takis
parents: 4632
diff changeset
245
1258
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
246 Speech_Decode_Frame_exit(&s->speech_decoder_state);
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
247 return 0;
1258
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
248 }
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
249
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
250 static int amr_nb_decode_frame(AVCodecContext * avctx,
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
251 void *data, int *data_size,
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
252 uint8_t * buf, int buf_size)
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
253 {
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
254 AMRContext *s = avctx->priv_data;
1258
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
255 uint8_t*amrData=buf;
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
256 int offset=0;
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
257 UWord8 toc, q, ft;
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
258 Word16 serial[SERIAL_FRAMESIZE]; /* coded bits */
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
259 Word16 *synth;
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
260 UWord8 *packed_bits;
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
261 static Word16 packed_size[16] = {12, 13, 15, 17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0, 0, 0};
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
262 int i;
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
263
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
264 //printf("amr_decode_frame data_size=%i buf=0x%X buf_size=%d frameCount=%d!!\n",*data_size,buf,buf_size,s->frameCount);
1258
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
265
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
266 synth=data;
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
267
4781
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
268 toc=amrData[offset];
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
269 /* read rest of the frame based on ToC byte */
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
270 q = (toc >> 2) & 0x01;
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
271 ft = (toc >> 3) & 0x0F;
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
272
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
273 //printf("offset=%d, packet_size=%d amrData= 0x%X %X %X %X\n",offset,packed_size[ft],amrData[offset],amrData[offset+1],amrData[offset+2],amrData[offset+3]);
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
274
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
275 offset++;
1258
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
276
4781
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
277 packed_bits=amrData+offset;
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
278
4781
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
279 offset+=packed_size[ft];
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
280
4781
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
281 //Unsort and unpack bits
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
282 s->rx_type = UnpackBits(q, ft, packed_bits, &s->mode, &serial[1]);
1258
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
283
4781
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
284 //We have a new frame
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
285 s->frameCount++;
1258
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
286
4781
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
287 if (s->rx_type == RX_NO_DATA)
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
288 {
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
289 s->mode = s->speech_decoder_state->prev_mode;
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
290 }
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
291 else {
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
292 s->speech_decoder_state->prev_mode = s->mode;
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
293 }
1258
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
294
4781
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
295 /* if homed: check if this frame is another homing frame */
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
296 if (s->reset_flag_old == 1)
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
297 {
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
298 /* only check until end of first subframe */
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
299 s->reset_flag = decoder_homing_frame_test_first(&serial[1], s->mode);
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
300 }
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
301 /* produce encoder homing frame if homed & input=decoder homing frame */
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
302 if ((s->reset_flag != 0) && (s->reset_flag_old != 0))
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
303 {
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
304 for (i = 0; i < L_FRAME; i++)
1258
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
305 {
4781
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
306 synth[i] = EHF_MASK;
1258
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
307 }
4781
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
308 }
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
309 else
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
310 {
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
311 /* decode frame */
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
312 Speech_Decode_Frame(s->speech_decoder_state, s->mode, &serial[1], s->rx_type, synth);
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
313 }
1258
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
314
4781
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
315 //Each AMR-frame results in 160 16-bit samples
4789
bf62c8a0d2fb Return correct decoded size, decoder is called with only one frame at a time.
diego
parents: 4781
diff changeset
316 *data_size=160*2;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2895
diff changeset
317
4781
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
318 /* if not homed: check whether current frame is a homing frame */
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
319 if (s->reset_flag_old == 0)
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
320 {
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
321 /* check whole frame */
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
322 s->reset_flag = decoder_homing_frame_test(&serial[1], s->mode);
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
323 }
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
324 /* reset decoder if current frame is a homing frame */
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
325 if (s->reset_flag != 0)
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
326 {
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
327 Speech_Decode_Frame_reset(s->speech_decoder_state);
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
328 }
bfe6e14839b2 cosmetics: Fix indentation.
diego
parents: 4780
diff changeset
329 s->reset_flag_old = s->reset_flag;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2895
diff changeset
330
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
331 return offset;
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
332 }
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
333
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
334
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
335 static int amr_nb_encode_frame(AVCodecContext *avctx,
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
336 unsigned char *frame/*out*/, int buf_size, void *data/*in*/)
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
337 {
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
338 short serial_data[250] = {0};
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
339 AMRContext *s = avctx->priv_data;
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
340 int written;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2895
diff changeset
341
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
342 s->reset_flag = encoder_homing_frame_test(data);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2895
diff changeset
343
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2895
diff changeset
344 Speech_Encode_Frame(s->enstate, s->enc_bitrate, data, &serial_data[1], &s->mode);
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2895
diff changeset
345
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
346 /* add frame type and mode */
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
347 sid_sync (s->sidstate, s->mode, &s->tx_frametype);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2895
diff changeset
348
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
349 written = PackBits(s->mode, s->enc_bitrate, s->tx_frametype, &serial_data[1], frame);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2895
diff changeset
350
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
351 if (s->reset_flag != 0)
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
352 {
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
353 Speech_Encode_Frame_reset(s->enstate);
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
354 sid_sync_reset(s->sidstate);
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
355 }
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
356 return written;
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
357 }
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
358
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
359
3463
444bd402aebe rename AMR config variables to CONFIG_AMR*
mru
parents: 3036
diff changeset
360 #elif defined(CONFIG_AMR_NB) /* Float point version*/
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
361
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
362 typedef struct AMRContext {
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
363 int frameCount;
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
364 void * decState;
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
365 int *enstate;
4744
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
366 int enc_bitrate;
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
367 } AMRContext;
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
368
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
369 static int amr_nb_decode_init(AVCodecContext * avctx)
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
370 {
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
371 AMRContext *s = avctx->priv_data;
4633
cd67b7ab311c Cosmetics in amr.c.
takis
parents: 4632
diff changeset
372
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
373 s->frameCount=0;
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
374 s->decState=Decoder_Interface_init();
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
375 if(!s->decState)
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
376 {
1825
231a6c19e28f av_log()
michael
parents: 1736
diff changeset
377 av_log(avctx, AV_LOG_ERROR, "Decoder_Interface_init error\r\n");
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
378 return -1;
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
379 }
4094
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
380
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
381 amr_decode_fix_avctx(avctx);
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
382
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
383 if(avctx->channels > 1)
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
384 {
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
385 av_log(avctx, AV_LOG_ERROR, "amr_nb: multichannel decoding not supported\n");
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
386 return -1;
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
387 }
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
388
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
389 return 0;
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
390 }
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
391
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
392 static int amr_nb_encode_init(AVCodecContext * avctx)
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
393 {
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
394 AMRContext *s = avctx->priv_data;
4633
cd67b7ab311c Cosmetics in amr.c.
takis
parents: 4632
diff changeset
395
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
396 s->frameCount=0;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2895
diff changeset
397
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
398 if(avctx->sample_rate!=8000)
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
399 {
4309
1f95aa362562 always print message when error, AV_LOG_DEBUG -> AV_LOG_ERROR
bcoudurier
parents: 4221
diff changeset
400 av_log(avctx, AV_LOG_ERROR, "Only 8000Hz sample rate supported\n");
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
401 return -1;
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
402 }
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
403
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
404 if(avctx->channels!=1)
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
405 {
4309
1f95aa362562 always print message when error, AV_LOG_DEBUG -> AV_LOG_ERROR
bcoudurier
parents: 4221
diff changeset
406 av_log(avctx, AV_LOG_ERROR, "Only mono supported\n");
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
407 return -1;
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
408 }
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
409
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
410 avctx->frame_size=160;
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
411 avctx->coded_frame= avcodec_alloc_frame();
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
412
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
413 s->enstate=Encoder_Interface_init(0);
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
414 if(!s->enstate)
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
415 {
4309
1f95aa362562 always print message when error, AV_LOG_DEBUG -> AV_LOG_ERROR
bcoudurier
parents: 4221
diff changeset
416 av_log(avctx, AV_LOG_ERROR, "Encoder_Interface_init error\n");
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
417 return -1;
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
418 }
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
419
4744
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
420 if((s->enc_bitrate=getBitrateMode(avctx->bit_rate))<0)
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
421 {
4793
e69d9ecaaf84 Print a list of valid AMR bitrates if a wrong one is used.
diego
parents: 4789
diff changeset
422 av_log(avctx, AV_LOG_ERROR, nb_bitrate_unsupported);
4744
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
423 return -1;
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
424 }
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
425
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
426 return 0;
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
427 }
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
428
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
429 static int amr_nb_decode_close(AVCodecContext * avctx)
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
430 {
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
431 AMRContext *s = avctx->priv_data;
4633
cd67b7ab311c Cosmetics in amr.c.
takis
parents: 4632
diff changeset
432
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
433 Decoder_Interface_exit(s->decState);
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
434 return 0;
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
435 }
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
436
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
437 static int amr_nb_encode_close(AVCodecContext * avctx)
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
438 {
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
439 AMRContext *s = avctx->priv_data;
4633
cd67b7ab311c Cosmetics in amr.c.
takis
parents: 4632
diff changeset
440
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
441 Encoder_Interface_exit(s->enstate);
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
442 av_freep(&avctx->coded_frame);
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
443 return 0;
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
444 }
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
445
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
446 static int amr_nb_decode_frame(AVCodecContext * avctx,
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
447 void *data, int *data_size,
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
448 uint8_t * buf, int buf_size)
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
449 {
4634
8b96c50c6723 Remove useless casts as recommended by Mns Rullgrd.
takis
parents: 4633
diff changeset
450 AMRContext *s = avctx->priv_data;
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
451 uint8_t*amrData=buf;
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
452 static short block_size[16]={ 12, 13, 15, 17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0, 0, 0 };
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
453 enum Mode dec_mode;
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
454 int packet_size;
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
455
2287
679642dc54cf segfault in amr decoder fix patch by (Richard van der Hoff - richvdh0)
michael
parents: 2028
diff changeset
456 /* av_log(NULL,AV_LOG_DEBUG,"amr_decode_frame buf=%p buf_size=%d frameCount=%d!!\n",buf,buf_size,s->frameCount); */
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2895
diff changeset
457
2287
679642dc54cf segfault in amr decoder fix patch by (Richard van der Hoff - richvdh0)
michael
parents: 2028
diff changeset
458 dec_mode = (buf[0] >> 3) & 0x000F;
679642dc54cf segfault in amr decoder fix patch by (Richard van der Hoff - richvdh0)
michael
parents: 2028
diff changeset
459 packet_size = block_size[dec_mode]+1;
679642dc54cf segfault in amr decoder fix patch by (Richard van der Hoff - richvdh0)
michael
parents: 2028
diff changeset
460
679642dc54cf segfault in amr decoder fix patch by (Richard van der Hoff - richvdh0)
michael
parents: 2028
diff changeset
461 if(packet_size > buf_size) {
679642dc54cf segfault in amr decoder fix patch by (Richard van der Hoff - richvdh0)
michael
parents: 2028
diff changeset
462 av_log(avctx, AV_LOG_ERROR, "amr frame too short (%u, should be %u)\n", buf_size, packet_size);
679642dc54cf segfault in amr decoder fix patch by (Richard van der Hoff - richvdh0)
michael
parents: 2028
diff changeset
463 return -1;
679642dc54cf segfault in amr decoder fix patch by (Richard van der Hoff - richvdh0)
michael
parents: 2028
diff changeset
464 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2895
diff changeset
465
2287
679642dc54cf segfault in amr decoder fix patch by (Richard van der Hoff - richvdh0)
michael
parents: 2028
diff changeset
466 s->frameCount++;
679642dc54cf segfault in amr decoder fix patch by (Richard van der Hoff - richvdh0)
michael
parents: 2028
diff changeset
467 /* av_log(NULL,AV_LOG_DEBUG,"packet_size=%d amrData= 0x%X %X %X %X\n",packet_size,amrData[0],amrData[1],amrData[2],amrData[3]); */
679642dc54cf segfault in amr decoder fix patch by (Richard van der Hoff - richvdh0)
michael
parents: 2028
diff changeset
468 /* call decoder */
679642dc54cf segfault in amr decoder fix patch by (Richard van der Hoff - richvdh0)
michael
parents: 2028
diff changeset
469 Decoder_Interface_Decode(s->decState, amrData, data, 0);
679642dc54cf segfault in amr decoder fix patch by (Richard van der Hoff - richvdh0)
michael
parents: 2028
diff changeset
470 *data_size=160*2;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2895
diff changeset
471
2287
679642dc54cf segfault in amr decoder fix patch by (Richard van der Hoff - richvdh0)
michael
parents: 2028
diff changeset
472 return packet_size;
1258
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
473 }
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
474
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
475 static int amr_nb_encode_frame(AVCodecContext *avctx,
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
476 unsigned char *frame/*out*/, int buf_size, void *data/*in*/)
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
477 {
4634
8b96c50c6723 Remove useless casts as recommended by Mns Rullgrd.
takis
parents: 4633
diff changeset
478 AMRContext *s = avctx->priv_data;
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
479 int written;
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
480
4744
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
481 if((s->enc_bitrate=getBitrateMode(avctx->bit_rate))<0)
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
482 {
4793
e69d9ecaaf84 Print a list of valid AMR bitrates if a wrong one is used.
diego
parents: 4789
diff changeset
483 av_log(avctx, AV_LOG_ERROR, nb_bitrate_unsupported);
4744
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
484 return -1;
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
485 }
4220
4115a044e31d allow amr bitrate to be changed "on the fly" through avctx->bitrate.
gpoirier
parents: 4094
diff changeset
486
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2895
diff changeset
487 written = Encoder_Interface_Encode(s->enstate,
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2895
diff changeset
488 s->enc_bitrate,
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2895
diff changeset
489 data,
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2895
diff changeset
490 frame,
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
491 0);
2571
b17d868a8f39 04_AMR_no_debug_output.patch by (Calcium | calcium nurs or jp)
michael
parents: 2287
diff changeset
492 /* av_log(NULL,AV_LOG_DEBUG,"amr_nb_encode_frame encoded %u bytes, bitrate %u, first byte was %#02x\n",written, s->enc_bitrate, frame[0] ); */
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
493
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
494 return written;
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
495 }
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
496
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
497 #endif
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
498
3463
444bd402aebe rename AMR config variables to CONFIG_AMR*
mru
parents: 3036
diff changeset
499 #if defined(CONFIG_AMR_NB) || defined(CONFIG_AMR_NB_FIXED)
2895
8fe1dc88294a Fix some #ifdef to allow building amr_wb alone.
diego
parents: 2571
diff changeset
500
1258
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
501 AVCodec amr_nb_decoder =
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
502 {
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
503 "amr_nb",
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
504 CODEC_TYPE_AUDIO,
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
505 CODEC_ID_AMR_NB,
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
506 sizeof(AMRContext),
1258
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
507 amr_nb_decode_init,
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
508 NULL,
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
509 amr_nb_decode_close,
1258
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
510 amr_nb_decode_frame,
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
511 };
802614404398 AMR-NB audio support patch by (<joca at rixmail dot se>)
michaelni
parents:
diff changeset
512
1297
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
513 AVCodec amr_nb_encoder =
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
514 {
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
515 "amr_nb",
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
516 CODEC_TYPE_AUDIO,
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
517 CODEC_ID_AMR_NB,
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
518 sizeof(AMRContext),
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
519 amr_nb_encode_init,
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
520 amr_nb_encode_frame,
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
521 amr_nb_encode_close,
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
522 NULL,
1db67cd7808a * 3gp patch by Joca
kabi
parents: 1258
diff changeset
523 };
1486
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
524
2895
8fe1dc88294a Fix some #ifdef to allow building amr_wb alone.
diego
parents: 2571
diff changeset
525 #endif
8fe1dc88294a Fix some #ifdef to allow building amr_wb alone.
diego
parents: 2571
diff changeset
526
1486
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
527 /* -----------AMR wideband ------------*/
3463
444bd402aebe rename AMR config variables to CONFIG_AMR*
mru
parents: 3036
diff changeset
528 #ifdef CONFIG_AMR_WB
1486
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
529
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
530 #ifdef _TYPEDEF_H
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
531 //To avoid duplicate typedefs from typdef in amr-nb
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
532 #define typedef_h
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
533 #endif
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
534
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
535 #include "amrwb_float/enc_if.h"
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
536 #include "amrwb_float/dec_if.h"
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
537
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
538 /* Common code for fixed and float version*/
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
539 typedef struct AMRWB_bitrates
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
540 {
4744
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
541 int rate;
1486
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
542 int mode;
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
543 } AMRWB_bitrates;
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
544
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
545 static int getWBBitrateMode(int bitrate)
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
546 {
4744
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
547 /* make the correspondance between bitrate and mode */
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
548 AMRWB_bitrates rates[]={ {6600,0},
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
549 {8850,1},
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
550 {12650,2},
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
551 {14250,3},
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
552 {15850,4},
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
553 {18250,5},
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
554 {19850,6},
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
555 {23050,7},
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
556 {23850,8},
1486
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
557 };
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
558 int i;
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
559
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
560 for(i=0;i<9;i++)
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
561 {
4744
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
562 if(rates[i].rate==bitrate)
1486
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
563 {
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
564 return(rates[i].mode);
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
565 }
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
566 }
4744
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
567 /* no bitrate matching, return an error */
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
568 return -1;
1486
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
569 }
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
570
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
571
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
572 typedef struct AMRWBContext {
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
573 int frameCount;
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
574 void *state;
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
575 int mode;
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
576 Word16 allow_dtx;
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
577 } AMRWBContext;
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
578
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
579 static int amr_wb_encode_init(AVCodecContext * avctx)
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
580 {
4634
8b96c50c6723 Remove useless casts as recommended by Mns Rullgrd.
takis
parents: 4633
diff changeset
581 AMRWBContext *s = avctx->priv_data;
4633
cd67b7ab311c Cosmetics in amr.c.
takis
parents: 4632
diff changeset
582
1486
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
583 s->frameCount=0;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2895
diff changeset
584
1486
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
585 if(avctx->sample_rate!=16000)
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
586 {
4309
1f95aa362562 always print message when error, AV_LOG_DEBUG -> AV_LOG_ERROR
bcoudurier
parents: 4221
diff changeset
587 av_log(avctx, AV_LOG_ERROR, "Only 16000Hz sample rate supported\n");
1486
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
588 return -1;
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
589 }
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
590
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
591 if(avctx->channels!=1)
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
592 {
4309
1f95aa362562 always print message when error, AV_LOG_DEBUG -> AV_LOG_ERROR
bcoudurier
parents: 4221
diff changeset
593 av_log(avctx, AV_LOG_ERROR, "Only mono supported\n");
1486
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
594 return -1;
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
595 }
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
596
4744
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
597 if((s->mode=getWBBitrateMode(avctx->bit_rate))<0)
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
598 {
4793
e69d9ecaaf84 Print a list of valid AMR bitrates if a wrong one is used.
diego
parents: 4789
diff changeset
599 av_log(avctx, AV_LOG_ERROR, wb_bitrate_unsupported);
4744
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
600 return -1;
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
601 }
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
602
1486
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
603 avctx->frame_size=320;
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
604 avctx->coded_frame= avcodec_alloc_frame();
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
605
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
606 s->state = E_IF_init();
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
607 s->allow_dtx=0;
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
608
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
609 return 0;
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
610 }
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
611
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
612 static int amr_wb_encode_close(AVCodecContext * avctx)
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
613 {
4634
8b96c50c6723 Remove useless casts as recommended by Mns Rullgrd.
takis
parents: 4633
diff changeset
614 AMRWBContext *s = avctx->priv_data;
4633
cd67b7ab311c Cosmetics in amr.c.
takis
parents: 4632
diff changeset
615
1486
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
616 E_IF_exit(s->state);
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
617 av_freep(&avctx->coded_frame);
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
618 s->frameCount++;
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
619 return 0;
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
620 }
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
621
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
622 static int amr_wb_encode_frame(AVCodecContext *avctx,
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
623 unsigned char *frame/*out*/, int buf_size, void *data/*in*/)
1486
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
624 {
4634
8b96c50c6723 Remove useless casts as recommended by Mns Rullgrd.
takis
parents: 4633
diff changeset
625 AMRWBContext *s = avctx->priv_data;
4220
4115a044e31d allow amr bitrate to be changed "on the fly" through avctx->bitrate.
gpoirier
parents: 4094
diff changeset
626 int size;
4632
260b5f667458 Move the initialization on context definition. In amr.c, only the
takis
parents: 4575
diff changeset
627
4744
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
628 if((s->mode=getWBBitrateMode(avctx->bit_rate))<0)
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
629 {
4793
e69d9ecaaf84 Print a list of valid AMR bitrates if a wrong one is used.
diego
parents: 4789
diff changeset
630 av_log(avctx, AV_LOG_ERROR, wb_bitrate_unsupported);
4744
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
631 return -1;
00f7cd30636f Accept only existing bitrates.
diego
parents: 4634
diff changeset
632 }
4220
4115a044e31d allow amr bitrate to be changed "on the fly" through avctx->bitrate.
gpoirier
parents: 4094
diff changeset
633 size = E_IF_encode(s->state, s->mode, data, frame, s->allow_dtx);
1486
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
634 return size;
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
635 }
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
636
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
637 static int amr_wb_decode_init(AVCodecContext * avctx)
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
638 {
4634
8b96c50c6723 Remove useless casts as recommended by Mns Rullgrd.
takis
parents: 4633
diff changeset
639 AMRWBContext *s = avctx->priv_data;
4633
cd67b7ab311c Cosmetics in amr.c.
takis
parents: 4632
diff changeset
640
1486
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
641 s->frameCount=0;
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
642 s->state = D_IF_init();
4094
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
643
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
644 amr_decode_fix_avctx(avctx);
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
645
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
646 if(avctx->channels > 1)
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
647 {
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
648 av_log(avctx, AV_LOG_ERROR, "amr_wb: multichannel decoding not supported\n");
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
649 return -1;
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
650 }
f812a11be0b1 sample rate fix
diego
parents: 3947
diff changeset
651
1486
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
652 return 0;
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
653 }
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
654
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
655 extern const UWord8 block_size[];
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
656
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
657 static int amr_wb_decode_frame(AVCodecContext * avctx,
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
658 void *data, int *data_size,
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
659 uint8_t * buf, int buf_size)
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
660 {
4634
8b96c50c6723 Remove useless casts as recommended by Mns Rullgrd.
takis
parents: 4633
diff changeset
661 AMRWBContext *s = avctx->priv_data;
1486
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
662 uint8_t*amrData=buf;
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
663 int mode;
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
664 int packet_size;
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
665
2287
679642dc54cf segfault in amr decoder fix patch by (Richard van der Hoff - richvdh0)
michael
parents: 2028
diff changeset
666 if(buf_size==0) {
679642dc54cf segfault in amr decoder fix patch by (Richard van der Hoff - richvdh0)
michael
parents: 2028
diff changeset
667 /* nothing to do */
679642dc54cf segfault in amr decoder fix patch by (Richard van der Hoff - richvdh0)
michael
parents: 2028
diff changeset
668 return 0;
1486
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
669 }
2287
679642dc54cf segfault in amr decoder fix patch by (Richard van der Hoff - richvdh0)
michael
parents: 2028
diff changeset
670
679642dc54cf segfault in amr decoder fix patch by (Richard van der Hoff - richvdh0)
michael
parents: 2028
diff changeset
671 mode = (amrData[0] >> 3) & 0x000F;
679642dc54cf segfault in amr decoder fix patch by (Richard van der Hoff - richvdh0)
michael
parents: 2028
diff changeset
672 packet_size = block_size[mode];
679642dc54cf segfault in amr decoder fix patch by (Richard van der Hoff - richvdh0)
michael
parents: 2028
diff changeset
673
679642dc54cf segfault in amr decoder fix patch by (Richard van der Hoff - richvdh0)
michael
parents: 2028
diff changeset
674 if(packet_size > buf_size) {
679642dc54cf segfault in amr decoder fix patch by (Richard van der Hoff - richvdh0)
michael
parents: 2028
diff changeset
675 av_log(avctx, AV_LOG_ERROR, "amr frame too short (%u, should be %u)\n", buf_size, packet_size+1);
679642dc54cf segfault in amr decoder fix patch by (Richard van der Hoff - richvdh0)
michael
parents: 2028
diff changeset
676 return -1;
679642dc54cf segfault in amr decoder fix patch by (Richard van der Hoff - richvdh0)
michael
parents: 2028
diff changeset
677 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2895
diff changeset
678
2287
679642dc54cf segfault in amr decoder fix patch by (Richard van der Hoff - richvdh0)
michael
parents: 2028
diff changeset
679 s->frameCount++;
679642dc54cf segfault in amr decoder fix patch by (Richard van der Hoff - richvdh0)
michael
parents: 2028
diff changeset
680 D_IF_decode( s->state, amrData, data, _good_frame);
679642dc54cf segfault in amr decoder fix patch by (Richard van der Hoff - richvdh0)
michael
parents: 2028
diff changeset
681 *data_size=320*2;
679642dc54cf segfault in amr decoder fix patch by (Richard van der Hoff - richvdh0)
michael
parents: 2028
diff changeset
682 return packet_size;
1486
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
683 }
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
684
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
685 static int amr_wb_decode_close(AVCodecContext * avctx)
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
686 {
4634
8b96c50c6723 Remove useless casts as recommended by Mns Rullgrd.
takis
parents: 4633
diff changeset
687 AMRWBContext *s = avctx->priv_data;
4633
cd67b7ab311c Cosmetics in amr.c.
takis
parents: 4632
diff changeset
688
1486
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
689 D_IF_exit(s->state);
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
690 return 0;
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
691 }
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
692
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
693 AVCodec amr_wb_decoder =
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
694 {
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
695 "amr_wb",
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
696 CODEC_TYPE_AUDIO,
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
697 CODEC_ID_AMR_WB,
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
698 sizeof(AMRWBContext),
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
699 amr_wb_decode_init,
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
700 NULL,
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
701 amr_wb_decode_close,
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
702 amr_wb_decode_frame,
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
703 };
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
704
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
705 AVCodec amr_wb_encoder =
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
706 {
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
707 "amr_wb",
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
708 CODEC_TYPE_AUDIO,
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
709 CODEC_ID_AMR_WB,
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
710 sizeof(AMRWBContext),
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
711 amr_wb_encode_init,
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
712 amr_wb_encode_frame,
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
713 amr_wb_encode_close,
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
714 NULL,
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
715 };
f22010affdce AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents: 1297
diff changeset
716
3463
444bd402aebe rename AMR config variables to CONFIG_AMR*
mru
parents: 3036
diff changeset
717 #endif //CONFIG_AMR_WB