1 /*
2 * AMR Audio encoder stub
3 * Copyright (c) 2003 the ffmpeg project
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #include <vo-amrwbenc/enc_if.h>
23 #include <stdio.h>
24 #include <stdlib.h>
25
32
33 #define MAX_PACKET_SIZE (1 + (477 + 7) / 8)
34
42
46 };
47
50 };
51
53 {
54 /* make the correspondance between bitrate and mode */
55 static const int rates[] = { 6600, 8850, 12650, 14250, 15850, 18250,
56 19850, 23050, 23850 };
57 int i, best = -1, min_diff = 0;
58 char log_buf[200];
59
60 for (i = 0; i < 9; i++) {
61 if (rates[i] == bitrate)
62 return i;
63 if (best < 0 || abs(rates[i] - bitrate) < min_diff) {
64 best = i;
65 min_diff = abs(rates[i] - bitrate);
66 }
67 }
68 /* no bitrate matching exactly, log a warning */
69 snprintf(log_buf,
sizeof(log_buf),
"bitrate not supported: use one of ");
70 for (i = 0; i < 9; i++)
71 av_strlcatf(log_buf,
sizeof(log_buf),
"%.2fk, ", rates[i] / 1000.f);
72 av_strlcatf(log_buf,
sizeof(log_buf),
"using %.2fk", rates[best] / 1000.f);
74
75 return best;
76 }
77
79 {
81
85 }
86
90 }
91
94
97 #if FF_API_OLD_ENCODE_AUDIO
101 #endif
102
103 s->
state = E_IF_init();
104
105 return 0;
106 }
107
109 {
111
114 return 0;
115 }
116
119 {
121 const int16_t *
samples = (
const int16_t *)frame->
data[0];
123
125 return ret;
126
130 }
135 }
136
139
141 *got_packet_ptr = 1;
142 return 0;
143 }
144
146 .
name =
"libvo_amrwbenc",
156 "(Adaptive Multi-Rate Wide-Band)"),
157 .priv_class = &class,
158 };