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
53 };
54
56 {
57 /* make the correspondence between bitrate and mode */
58 static const int rates[] = { 6600, 8850, 12650, 14250, 15850, 18250,
59 19850, 23050, 23850 };
60 int i, best = -1, min_diff = 0;
61 char log_buf[200];
62
63 for (i = 0; i < 9; i++) {
64 if (rates[i] == bitrate)
65 return i;
66 if (best < 0 || abs(rates[i] - bitrate) < min_diff) {
67 best = i;
68 min_diff = abs(rates[i] - bitrate);
69 }
70 }
71 /* no bitrate matching exactly, log a warning */
72 snprintf(log_buf,
sizeof(log_buf),
"bitrate not supported: use one of ");
73 for (i = 0; i < 9; i++)
74 av_strlcatf(log_buf,
sizeof(log_buf),
"%.2fk, ", rates[i] / 1000.f);
75 av_strlcatf(log_buf,
sizeof(log_buf),
"using %.2fk", rates[best] / 1000.f);
77
78 return best;
79 }
80
82 {
84
88 }
89
93 }
94
97
100
101 s->
state = E_IF_init();
102
103 return 0;
104 }
105
107 {
109
111 return 0;
112 }
113
116 {
118 const int16_t *samples = (
const int16_t *)frame->
data[0];
120
122 return ret;
123
127 }
132 }
133
136
138 *got_packet_ptr = 1;
139 return 0;
140 }
141
143 .
name =
"libvo_amrwbenc",
145 "(Adaptive Multi-Rate Wide-Band)"),
155 .wrapper_name = "libvo_amrwbenc",
156 };
This structure describes decoded (raw) audio or video data.
#define AV_LOG_WARNING
Something somehow does not look correct.
int64_t bit_rate
the average bitrate
#define LIBAVUTIL_VERSION_INT
Memory handling functions.
static av_cold int init(AVCodecContext *avctx)
#define AV_OPT_FLAG_AUDIO_PARAM
const char * av_default_item_name(void *ptr)
Return the context name.
static int amr_wb_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size)
Check AVPacket size and/or allocate data.
static const AVClass amrwb_class
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
#define AV_OPT_FLAG_ENCODING_PARAM
a generic parameter which can be set by the user for muxing or encoding
#define FF_COMPLIANCE_UNOFFICIAL
Allow unofficial extensions.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
int initial_padding
Audio only.
const char * name
Name of the codec implementation.
common internal API header
static int get_wb_bitrate_mode(int bitrate, void *log_ctx)
int frame_size
Number of samples per channel in an audio frame.
Libavcodec external API header.
AVSampleFormat
Audio sample formats.
int sample_rate
samples per second
main external API structure.
Describe the class of an AVClass context structure.
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static const AVOption options[]
common internal api header.
static int amr_wb_encode_close(AVCodecContext *avctx)
static av_cold int amr_wb_encode_init(AVCodecContext *avctx)
int channels
number of audio channels
static enum AVSampleFormat sample_fmts[]
static av_always_inline int64_t ff_samples_to_time_base(AVCodecContext *avctx, int64_t samples)
Rescale from sample rate to AVCodecContext.time_base.
This structure stores compressed data.
int strict_std_compliance
strictly follow the standard (MPEG-4, ...).
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
AVCodec ff_libvo_amrwbenc_encoder
#define AV_NOPTS_VALUE
Undefined timestamp value.