FFmpeg
Loading...
Searching...
No Matches
libavcodec
libvo-amrwbenc.c
Go to the documentation of this file.
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
26
#include "
libavutil/avstring.h
"
27
#include "
libavutil/internal.h
"
28
#include "
libavutil/opt.h
"
29
#include "
avcodec.h
"
30
#include "
codec_internal.h
"
31
#include "
encode.h
"
32
33
#define MAX_PACKET_SIZE (1 + (477 + 7) / 8)
34
35
typedef
struct
AMRWBContext
{
36
AVClass
*
av_class
;
37
void
*
state
;
38
int
mode
;
39
int
last_bitrate
;
40
int
allow_dtx
;
41
}
AMRWBContext
;
42
43
static
const
AVOption
options
[] = {
44
{
"dtx"
,
"Allow DTX (generate comfort noise)"
, offsetof(
AMRWBContext
, allow_dtx),
AV_OPT_TYPE_INT
, { .i64 = 0 }, 0, 1,
AV_OPT_FLAG_AUDIO_PARAM
|
AV_OPT_FLAG_ENCODING_PARAM
},
45
{
NULL
}
46
};
47
48
static
const
AVClass
amrwb_class
= {
49
.class_name =
"libvo_amrwbenc"
,
50
.item_name =
av_default_item_name
,
51
.option =
options
,
52
.version =
LIBAVUTIL_VERSION_INT
,
53
};
54
55
static
int
get_wb_bitrate_mode
(
int
bitrate
,
void
*log_ctx)
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];
<