Mercurial > libavcodec.hg
annotate libamr.c @ 9655:1880dcbb6a80 libavcodec
Replace 'x == 0' if conditions with '!x'.
author | diego |
---|---|
date | Fri, 15 May 2009 22:41:26 +0000 |
parents | 7204dc2922be |
children | 03361db4df10 |
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 | 21 |
4575 | 22 /** @file |
23 * Adaptive Multi-Rate (AMR) Audio decoder stub. | |
24 * | |
25 * This code implements both an AMR-NarrowBand (AMR-NB) and an AMR-WideBand | |
26 * (AMR-WB) audio encoder/decoder through external reference code from | |
27 * http://www.3gpp.org/. The license of the code from 3gpp is unclear so you | |
28 * have to download the code separately. Two versions exists: One fixed-point | |
4857 | 29 * and one floating-point. For some reason the float encoder is significantly |
30 * faster at least on a P4 1.5GHz (0.9s instead of 9.9s on a 30s audio clip | |
31 * at MR102). Both float and fixed point are supported for AMR-NB, but only | |
32 * float for AMR-WB. | |
4575 | 33 * |
34 * \section AMR-NB | |
35 * | |
36 * \subsection Float | |
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 | 39 * |
40 * \subsection Specification | |
41 * The specification for AMR-NB can be found in TS 26.071 | |
42 * (http://www.3gpp.org/ftp/Specs/html-info/26071.htm) and some other | |
43 * info at http://www.3gpp.org/ftp/Specs/html-info/26-series.htm. | |
44 * | |
45 * \section AMR-WB | |
4858
3e38885a28bc
Remove the build instructions from the doxygen comments, they are duplicated
diego
parents:
4857
diff
changeset
|
46 * |
4575 | 47 * \subsection Float |
48 * The reference code can be downloaded from: | |
4746
4aedb3b6fa4e
Update specification and reference implementation links.
diego
parents:
4744
diff
changeset
|
49 * http://www.3gpp.org/ftp/Specs/archive/26_series/26.204/26204-600.zip |
4575 | 50 * |
51 * \subsection Specification | |
4746
4aedb3b6fa4e
Update specification and reference implementation links.
diego
parents:
4744
diff
changeset
|
52 * The specification for AMR-WB can be found in TS 26.171 |
4aedb3b6fa4e
Update specification and reference implementation links.
diego
parents:
4744
diff
changeset
|
53 * (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
|
54 * info at http://www.3gpp.org/ftp/Specs/html-info/26-series.htm. |
4575 | 55 * |
1297 | 56 */ |
1486
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
57 |
1297 | 58 #include "avcodec.h" |
59 | |
4843
0e11f292482f
Replace hackish support for amr-nb and amr-wb. Instead of including the source
diego
parents:
4842
diff
changeset
|
60 #include <amrnb/interf_dec.h> |
0e11f292482f
Replace hackish support for amr-nb and amr-wb. Instead of including the source
diego
parents:
4842
diff
changeset
|
61 #include <amrnb/interf_enc.h> |
1297 | 62 |
8347
81238f0bea66
Fix warning "format not a string literal and no format arguments".
benoit
parents:
7451
diff
changeset
|
63 static const char nb_bitrate_unsupported[] = |
4793
e69d9ecaaf84
Print a list of valid AMR bitrates if a wrong one is used.
diego
parents:
4789
diff
changeset
|
64 "bitrate not supported: use one of 4.75k, 5.15k, 5.9k, 6.7k, 7.4k, 7.95k, 10.2k or 12.2k\n"; |
8347
81238f0bea66
Fix warning "format not a string literal and no format arguments".
benoit
parents:
7451
diff
changeset
|
65 static const char wb_bitrate_unsupported[] = |
4793
e69d9ecaaf84
Print a list of valid AMR bitrates if a wrong one is used.
diego
parents:
4789
diff
changeset
|
66 "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
|
67 |
1297 | 68 /* Common code for fixed and float version*/ |
69 typedef struct AMR_bitrates | |
70 { | |
4744 | 71 int rate; |
1297 | 72 enum Mode mode; |
73 } AMR_bitrates; | |
74 | |
4744 | 75 /* Match desired bitrate */ |
76 static int getBitrateMode(int bitrate) | |
1297 | 77 { |
4744 | 78 /* make the correspondance between bitrate and mode */ |
79 AMR_bitrates rates[]={ {4750,MR475}, | |
80 {5150,MR515}, | |
81 {5900,MR59}, | |
82 {6700,MR67}, | |
83 {7400,MR74}, | |
84 {7950,MR795}, | |
85 {10200,MR102}, | |
86 {12200,MR122}, | |
1297 | 87 }; |
88 int i; | |
4633 | 89 |
1486
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
90 for(i=0;i<8;i++) |
4744 | 91 if(rates[i].rate==bitrate) |
6750 | 92 return rates[i].mode; |
4744 | 93 /* no bitrate matching, return an error */ |
94 return -1; | |
1297 | 95 } |
96 | |
4094 | 97 static void amr_decode_fix_avctx(AVCodecContext * avctx) |
98 { | |
99 const int is_amr_wb = 1 + (avctx->codec_id == CODEC_ID_AMR_WB); | |
100 | |
9655 | 101 if(!avctx->sample_rate) |
4094 | 102 avctx->sample_rate = 8000 * is_amr_wb; |
103 | |
9655 | 104 if(!avctx->channels) |
4094 | 105 avctx->channels = 1; |
106 | |
107 avctx->frame_size = 160 * is_amr_wb; | |
7451
85ab7655ad4d
Modify all codecs to report their supported input and output sample format(s).
pross
parents:
7040
diff
changeset
|
108 avctx->sample_fmt = SAMPLE_FMT_S16; |
4094 | 109 } |
110 | |
9582 | 111 #if CONFIG_LIBAMR_NB |
1297 | 112 |
113 typedef struct AMRContext { | |
114 int frameCount; | |
115 void * decState; | |
116 int *enstate; | |
4744 | 117 int enc_bitrate; |
1297 | 118 } AMRContext; |
119 | |
9007
043574c5c153
Add missing av_cold in static init/close functions.
stefano
parents:
8590
diff
changeset
|
120 static av_cold int amr_nb_decode_init(AVCodecContext * avctx) |
1297 | 121 { |
122 AMRContext *s = avctx->priv_data; | |
4633 | 123 |
1297 | 124 s->frameCount=0; |
125 s->decState=Decoder_Interface_init(); | |
126 if(!s->decState) | |
127 { | |
1825 | 128 av_log(avctx, AV_LOG_ERROR, "Decoder_Interface_init error\r\n"); |
1297 | 129 return -1; |
130 } | |
4094 | 131 |
132 amr_decode_fix_avctx(avctx); | |
133 | |
134 if(avctx->channels > 1) | |
135 { | |
136 av_log(avctx, AV_LOG_ERROR, "amr_nb: multichannel decoding not supported\n"); | |
137 return -1; | |
138 } | |
139 | |
1297 | 140 return 0; |
141 } | |
142 | |
9651
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
143 static av_cold int amr_nb_decode_close(AVCodecContext * avctx) |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
144 { |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
145 AMRContext *s = avctx->priv_data; |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
146 |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
147 Decoder_Interface_exit(s->decState); |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
148 return 0; |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
149 } |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
150 |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
151 static int amr_nb_decode_frame(AVCodecContext * avctx, |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
152 void *data, int *data_size, |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
153 AVPacket *avpkt) |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
154 { |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
155 const uint8_t *buf = avpkt->data; |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
156 int buf_size = avpkt->size; |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
157 AMRContext *s = avctx->priv_data; |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
158 const uint8_t*amrData=buf; |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
159 static const uint8_t block_size[16]={ 12, 13, 15, 17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0, 0, 0 }; |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
160 enum Mode dec_mode; |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
161 int packet_size; |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
162 |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
163 /* av_log(NULL,AV_LOG_DEBUG,"amr_decode_frame buf=%p buf_size=%d frameCount=%d!!\n",buf,buf_size,s->frameCount); */ |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
164 |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
165 dec_mode = (buf[0] >> 3) & 0x000F; |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
166 packet_size = block_size[dec_mode]+1; |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
167 |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
168 if(packet_size > buf_size) { |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
169 av_log(avctx, AV_LOG_ERROR, "amr frame too short (%u, should be %u)\n", buf_size, packet_size); |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
170 return -1; |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
171 } |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
172 |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
173 s->frameCount++; |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
174 /* 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]); */ |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
175 /* call decoder */ |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
176 Decoder_Interface_Decode(s->decState, amrData, data, 0); |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
177 *data_size=160*2; |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
178 |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
179 return packet_size; |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
180 } |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
181 |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
182 AVCodec libamr_nb_decoder = |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
183 { |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
184 "libamr_nb", |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
185 CODEC_TYPE_AUDIO, |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
186 CODEC_ID_AMR_NB, |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
187 sizeof(AMRContext), |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
188 amr_nb_decode_init, |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
189 NULL, |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
190 amr_nb_decode_close, |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
191 amr_nb_decode_frame, |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
192 .long_name = NULL_IF_CONFIG_SMALL("libamr-nb Adaptive Multi-Rate (AMR) Narrow-Band"), |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
193 }; |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
194 |
9007
043574c5c153
Add missing av_cold in static init/close functions.
stefano
parents:
8590
diff
changeset
|
195 static av_cold int amr_nb_encode_init(AVCodecContext * avctx) |
1297 | 196 { |
197 AMRContext *s = avctx->priv_data; | |
4633 | 198 |
1297 | 199 s->frameCount=0; |
2967 | 200 |
1297 | 201 if(avctx->sample_rate!=8000) |
202 { | |
4309
1f95aa362562
always print message when error, AV_LOG_DEBUG -> AV_LOG_ERROR
bcoudurier
parents:
4221
diff
changeset
|
203 av_log(avctx, AV_LOG_ERROR, "Only 8000Hz sample rate supported\n"); |
1297 | 204 return -1; |
205 } | |
206 | |
207 if(avctx->channels!=1) | |
208 { | |
4309
1f95aa362562
always print message when error, AV_LOG_DEBUG -> AV_LOG_ERROR
bcoudurier
parents:
4221
diff
changeset
|
209 av_log(avctx, AV_LOG_ERROR, "Only mono supported\n"); |
1297 | 210 return -1; |
211 } | |
212 | |
213 avctx->frame_size=160; | |
214 avctx->coded_frame= avcodec_alloc_frame(); | |
215 | |
216 s->enstate=Encoder_Interface_init(0); | |
217 if(!s->enstate) | |
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, "Encoder_Interface_init error\n"); |
1297 | 220 return -1; |
221 } | |
222 | |
4744 | 223 if((s->enc_bitrate=getBitrateMode(avctx->bit_rate))<0) |
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 | 226 return -1; |
227 } | |
1297 | 228 |
229 return 0; | |
230 } | |
231 | |
9007
043574c5c153
Add missing av_cold in static init/close functions.
stefano
parents:
8590
diff
changeset
|
232 static av_cold int amr_nb_encode_close(AVCodecContext * avctx) |
1297 | 233 { |
234 AMRContext *s = avctx->priv_data; | |
4633 | 235 |
1297 | 236 Encoder_Interface_exit(s->enstate); |
237 av_freep(&avctx->coded_frame); | |
238 return 0; | |
239 } | |
240 | |
241 static int amr_nb_encode_frame(AVCodecContext *avctx, | |
2979 | 242 unsigned char *frame/*out*/, int buf_size, void *data/*in*/) |
1297 | 243 { |
4634 | 244 AMRContext *s = avctx->priv_data; |
1297 | 245 int written; |
246 | |
4744 | 247 if((s->enc_bitrate=getBitrateMode(avctx->bit_rate))<0) |
248 { | |
4793
e69d9ecaaf84
Print a list of valid AMR bitrates if a wrong one is used.
diego
parents:
4789
diff
changeset
|
249 av_log(avctx, AV_LOG_ERROR, nb_bitrate_unsupported); |
4744 | 250 return -1; |
251 } | |
4220
4115a044e31d
allow amr bitrate to be changed "on the fly" through avctx->bitrate.
gpoirier
parents:
4094
diff
changeset
|
252 |
2967 | 253 written = Encoder_Interface_Encode(s->enstate, |
254 s->enc_bitrate, | |
255 data, | |
256 frame, | |
1297 | 257 0); |
2571
b17d868a8f39
04_AMR_no_debug_output.patch by (Calcium | calcium nurs or jp)
michael
parents:
2287
diff
changeset
|
258 /* 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 | 259 |
260 return written; | |
261 } | |
262 | |
4898
3df69e140c33
Give libamr decoders/encoders a lib prefix in the name.
diego
parents:
4858
diff
changeset
|
263 AVCodec libamr_nb_encoder = |
1297 | 264 { |
4898
3df69e140c33
Give libamr decoders/encoders a lib prefix in the name.
diego
parents:
4858
diff
changeset
|
265 "libamr_nb", |
1297 | 266 CODEC_TYPE_AUDIO, |
267 CODEC_ID_AMR_NB, | |
268 sizeof(AMRContext), | |
269 amr_nb_encode_init, | |
270 amr_nb_encode_frame, | |
271 amr_nb_encode_close, | |
272 NULL, | |
7451
85ab7655ad4d
Modify all codecs to report their supported input and output sample format(s).
pross
parents:
7040
diff
changeset
|
273 .sample_fmts = (enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE}, |
7040
e943e1409077
Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents:
6750
diff
changeset
|
274 .long_name = NULL_IF_CONFIG_SMALL("libamr-nb Adaptive Multi-Rate (AMR) Narrow-Band"), |
1297 | 275 }; |
1486
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
276 |
2895 | 277 #endif |
278 | |
1486
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
279 /* -----------AMR wideband ------------*/ |
8590 | 280 #if CONFIG_LIBAMR_WB |
1486
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
281 |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
282 #ifdef _TYPEDEF_H |
6186 | 283 //To avoid duplicate typedefs from typedef in amr-nb |
1486
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
284 #define typedef_h |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
285 #endif |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
286 |
4843
0e11f292482f
Replace hackish support for amr-nb and amr-wb. Instead of including the source
diego
parents:
4842
diff
changeset
|
287 #include <amrwb/dec_if.h> |
0e11f292482f
Replace hackish support for amr-nb and amr-wb. Instead of including the source
diego
parents:
4842
diff
changeset
|
288 #include <amrwb/if_rom.h> |
1486
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
289 |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
290 /* Common code for fixed and float version*/ |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
291 typedef struct AMRWB_bitrates |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
292 { |
4744 | 293 int rate; |
1486
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
294 int mode; |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
295 } AMRWB_bitrates; |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
296 |
9652
356079de3642
cosmetics: Move some more code around to avoid #ifdeffery.
diego
parents:
9651
diff
changeset
|
297 typedef struct AMRWBContext { |
356079de3642
cosmetics: Move some more code around to avoid #ifdeffery.
diego
parents:
9651
diff
changeset
|
298 int frameCount; |
356079de3642
cosmetics: Move some more code around to avoid #ifdeffery.
diego
parents:
9651
diff
changeset
|
299 void *state; |
356079de3642
cosmetics: Move some more code around to avoid #ifdeffery.
diego
parents:
9651
diff
changeset
|
300 int mode; |
356079de3642
cosmetics: Move some more code around to avoid #ifdeffery.
diego
parents:
9651
diff
changeset
|
301 Word16 allow_dtx; |
356079de3642
cosmetics: Move some more code around to avoid #ifdeffery.
diego
parents:
9651
diff
changeset
|
302 } AMRWBContext; |
356079de3642
cosmetics: Move some more code around to avoid #ifdeffery.
diego
parents:
9651
diff
changeset
|
303 |
9653
a572a4628a5a
Surround AMR_WB encoding code by appropriate #ifdefs.
diego
parents:
9652
diff
changeset
|
304 #if CONFIG_LIBAMR_WB_ENCODER |
a572a4628a5a
Surround AMR_WB encoding code by appropriate #ifdefs.
diego
parents:
9652
diff
changeset
|
305 |
9652
356079de3642
cosmetics: Move some more code around to avoid #ifdeffery.
diego
parents:
9651
diff
changeset
|
306 #include <amrwb/enc_if.h> |
356079de3642
cosmetics: Move some more code around to avoid #ifdeffery.
diego
parents:
9651
diff
changeset
|
307 |
1486
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
308 static int getWBBitrateMode(int bitrate) |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
309 { |
4744 | 310 /* make the correspondance between bitrate and mode */ |
311 AMRWB_bitrates rates[]={ {6600,0}, | |
312 {8850,1}, | |
313 {12650,2}, | |
314 {14250,3}, | |
315 {15850,4}, | |
316 {18250,5}, | |
317 {19850,6}, | |
318 {23050,7}, | |
319 {23850,8}, | |
1486
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
320 }; |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
321 int i; |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
322 |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
323 for(i=0;i<9;i++) |
4744 | 324 if(rates[i].rate==bitrate) |
6750 | 325 return rates[i].mode; |
4744 | 326 /* no bitrate matching, return an error */ |
327 return -1; | |
1486
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
328 } |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
329 |
9649
2d4718adf588
Add av_cold attribute to amr_nb decoding/encoding initialization functions.
diego
parents:
9582
diff
changeset
|
330 static av_cold int amr_wb_encode_init(AVCodecContext * avctx) |
1486
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
331 { |
4634 | 332 AMRWBContext *s = avctx->priv_data; |
4633 | 333 |
1486
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
334 s->frameCount=0; |
2967 | 335 |
1486
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
336 if(avctx->sample_rate!=16000) |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
337 { |
4309
1f95aa362562
always print message when error, AV_LOG_DEBUG -> AV_LOG_ERROR
bcoudurier
parents:
4221
diff
changeset
|
338 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
|
339 return -1; |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
340 } |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
341 |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
342 if(avctx->channels!=1) |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
343 { |
4309
1f95aa362562
always print message when error, AV_LOG_DEBUG -> AV_LOG_ERROR
bcoudurier
parents:
4221
diff
changeset
|
344 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
|
345 return -1; |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
346 } |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
347 |
4744 | 348 if((s->mode=getWBBitrateMode(avctx->bit_rate))<0) |
349 { | |
4793
e69d9ecaaf84
Print a list of valid AMR bitrates if a wrong one is used.
diego
parents:
4789
diff
changeset
|
350 av_log(avctx, AV_LOG_ERROR, wb_bitrate_unsupported); |
4744 | 351 return -1; |
352 } | |
353 | |
1486
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
354 avctx->frame_size=320; |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
355 avctx->coded_frame= avcodec_alloc_frame(); |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
356 |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
357 s->state = E_IF_init(); |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
358 s->allow_dtx=0; |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
359 |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
360 return 0; |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
361 } |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
362 |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
363 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
|
364 { |
4634 | 365 AMRWBContext *s = avctx->priv_data; |
4633 | 366 |
1486
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
367 E_IF_exit(s->state); |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
368 av_freep(&avctx->coded_frame); |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
369 s->frameCount++; |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
370 return 0; |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
371 } |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
372 |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
373 static int amr_wb_encode_frame(AVCodecContext *avctx, |
2979 | 374 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
|
375 { |
4634 | 376 AMRWBContext *s = avctx->priv_data; |
4220
4115a044e31d
allow amr bitrate to be changed "on the fly" through avctx->bitrate.
gpoirier
parents:
4094
diff
changeset
|
377 int size; |
4632
260b5f667458
Move the initialization on context definition. In amr.c, only the
takis
parents:
4575
diff
changeset
|
378 |
4744 | 379 if((s->mode=getWBBitrateMode(avctx->bit_rate))<0) |
380 { | |
4793
e69d9ecaaf84
Print a list of valid AMR bitrates if a wrong one is used.
diego
parents:
4789
diff
changeset
|
381 av_log(avctx, AV_LOG_ERROR, wb_bitrate_unsupported); |
4744 | 382 return -1; |
383 } | |
4220
4115a044e31d
allow amr bitrate to be changed "on the fly" through avctx->bitrate.
gpoirier
parents:
4094
diff
changeset
|
384 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
|
385 return size; |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
386 } |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
387 |
9651
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
388 AVCodec libamr_wb_encoder = |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
389 { |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
390 "libamr_wb", |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
391 CODEC_TYPE_AUDIO, |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
392 CODEC_ID_AMR_WB, |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
393 sizeof(AMRWBContext), |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
394 amr_wb_encode_init, |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
395 amr_wb_encode_frame, |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
396 amr_wb_encode_close, |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
397 NULL, |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
398 .sample_fmts = (enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE}, |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
399 .long_name = NULL_IF_CONFIG_SMALL("libamr-wb Adaptive Multi-Rate (AMR) Wide-Band"), |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
400 }; |
e5ea408f6e2a
cosmetics: Move functions around so that encoding and decoding functions are
diego
parents:
9650
diff
changeset
|
401 |
9653
a572a4628a5a
Surround AMR_WB encoding code by appropriate #ifdefs.
diego
parents:
9652
diff
changeset
|
402 #endif |
a572a4628a5a
Surround AMR_WB encoding code by appropriate #ifdefs.
diego
parents:
9652
diff
changeset
|
403 |
9649
2d4718adf588
Add av_cold attribute to amr_nb decoding/encoding initialization functions.
diego
parents:
9582
diff
changeset
|
404 static av_cold int amr_wb_decode_init(AVCodecContext * avctx) |
1486
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
405 { |
4634 | 406 AMRWBContext *s = avctx->priv_data; |
4633 | 407 |
1486
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
408 s->frameCount=0; |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
409 s->state = D_IF_init(); |
4094 | 410 |
411 amr_decode_fix_avctx(avctx); | |
412 | |
413 if(avctx->channels > 1) | |
414 { | |
415 av_log(avctx, AV_LOG_ERROR, "amr_wb: multichannel decoding not supported\n"); | |
416 return -1; | |
417 } | |
418 | |
1486
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
419 return 0; |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
420 } |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
421 |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
422 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
|
423 void *data, int *data_size, |
9355
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
9007
diff
changeset
|
424 AVPacket *avpkt) |
1486
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
425 { |
9355
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
9007
diff
changeset
|
426 const uint8_t *buf = avpkt->data; |
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
9007
diff
changeset
|
427 int buf_size = avpkt->size; |
4634 | 428 AMRWBContext *s = avctx->priv_data; |
8348 | 429 const uint8_t*amrData=buf; |
1486
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
430 int mode; |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
431 int packet_size; |
6427 | 432 static const uint8_t block_size[16] = {18, 23, 33, 37, 41, 47, 51, 59, 61, 6, 6, 0, 0, 0, 1, 1}; |
1486
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
433 |
9655 | 434 if(!buf_size) |
2287
679642dc54cf
segfault in amr decoder fix patch by (Richard van der Hoff - richvdh0)
michael
parents:
2028
diff
changeset
|
435 /* nothing to do */ |
679642dc54cf
segfault in amr decoder fix patch by (Richard van der Hoff - richvdh0)
michael
parents:
2028
diff
changeset
|
436 return 0; |
679642dc54cf
segfault in amr decoder fix patch by (Richard van der Hoff - richvdh0)
michael
parents:
2028
diff
changeset
|
437 |
679642dc54cf
segfault in amr decoder fix patch by (Richard van der Hoff - richvdh0)
michael
parents:
2028
diff
changeset
|
438 mode = (amrData[0] >> 3) & 0x000F; |
679642dc54cf
segfault in amr decoder fix patch by (Richard van der Hoff - richvdh0)
michael
parents:
2028
diff
changeset
|
439 packet_size = block_size[mode]; |
679642dc54cf
segfault in amr decoder fix patch by (Richard van der Hoff - richvdh0)
michael
parents:
2028
diff
changeset
|
440 |
679642dc54cf
segfault in amr decoder fix patch by (Richard van der Hoff - richvdh0)
michael
parents:
2028
diff
changeset
|
441 if(packet_size > buf_size) { |
679642dc54cf
segfault in amr decoder fix patch by (Richard van der Hoff - richvdh0)
michael
parents:
2028
diff
changeset
|
442 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
|
443 return -1; |
679642dc54cf
segfault in amr decoder fix patch by (Richard van der Hoff - richvdh0)
michael
parents:
2028
diff
changeset
|
444 } |
2967 | 445 |
2287
679642dc54cf
segfault in amr decoder fix patch by (Richard van der Hoff - richvdh0)
michael
parents:
2028
diff
changeset
|
446 s->frameCount++; |
679642dc54cf
segfault in amr decoder fix patch by (Richard van der Hoff - richvdh0)
michael
parents:
2028
diff
changeset
|
447 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
|
448 *data_size=320*2; |
679642dc54cf
segfault in amr decoder fix patch by (Richard van der Hoff - richvdh0)
michael
parents:
2028
diff
changeset
|
449 return packet_size; |
1486
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
450 } |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
451 |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
452 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
|
453 { |
4634 | 454 AMRWBContext *s = avctx->priv_data; |
4633 | 455 |
1486
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
456 D_IF_exit(s->state); |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
457 return 0; |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
458 } |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
459 |
4898
3df69e140c33
Give libamr decoders/encoders a lib prefix in the name.
diego
parents:
4858
diff
changeset
|
460 AVCodec libamr_wb_decoder = |
1486
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
461 { |
4898
3df69e140c33
Give libamr decoders/encoders a lib prefix in the name.
diego
parents:
4858
diff
changeset
|
462 "libamr_wb", |
1486
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
463 CODEC_TYPE_AUDIO, |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
464 CODEC_ID_AMR_WB, |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
465 sizeof(AMRWBContext), |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
466 amr_wb_decode_init, |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
467 NULL, |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
468 amr_wb_decode_close, |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
469 amr_wb_decode_frame, |
7040
e943e1409077
Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents:
6750
diff
changeset
|
470 .long_name = NULL_IF_CONFIG_SMALL("libamr-wb Adaptive Multi-Rate (AMR) Wide-Band"), |
1486
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
471 }; |
f22010affdce
AMR-WB support by (Johannes Carlsson <joca at rixmail dot se>)
michaelni
parents:
1297
diff
changeset
|
472 |
4898
3df69e140c33
Give libamr decoders/encoders a lib prefix in the name.
diego
parents:
4858
diff
changeset
|
473 #endif //CONFIG_LIBAMR_WB |