Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Ffmpeg
提交
21e681ba
F
Ffmpeg
项目概览
小白菜888
/
Ffmpeg
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
Ffmpeg
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
21e681ba
编写于
9月 23, 2010
作者:
M
Martin Storsjö
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add a G.722 encoder
Originally committed as revision 25164 to
svn://svn.ffmpeg.org/ffmpeg/trunk
上级
2efcde73
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
86 addition
and
4 deletion
+86
-4
Changelog
Changelog
+1
-1
doc/general.texi
doc/general.texi
+1
-1
libavcodec/Makefile
libavcodec/Makefile
+1
-0
libavcodec/allcodecs.c
libavcodec/allcodecs.c
+1
-1
libavcodec/g722.c
libavcodec/g722.c
+82
-1
未找到文件。
Changelog
浏览文件 @
21e681ba
...
...
@@ -33,7 +33,7 @@ version <next>:
- Apple HTTP Live Streaming demuxer
- a64 codec
- MMS-HTTP support
- G.722 ADPCM audio decoder
- G.722 ADPCM audio
encoder/
decoder
- R10k video decoder
- ocv_smooth filter
...
...
doc/general.texi
浏览文件 @
21e681ba
...
...
@@ -536,7 +536,7 @@ following image formats are supported:
@item ADPCM Electronic Arts R2 @tab @tab X
@item ADPCM Electronic Arts R3 @tab @tab X
@item ADPCM Electronic Arts XAS @tab @tab X
@item ADPCM G.722 @tab
@tab X
@item ADPCM G.722 @tab
X
@tab X
@item ADPCM G.726 @tab X @tab X
@item ADPCM IMA AMV @tab @tab X
@tab Used in AMV files
...
...
libavcodec/Makefile
浏览文件 @
21e681ba
...
...
@@ -477,6 +477,7 @@ OBJS-$(CONFIG_ADPCM_EA_R2_DECODER) += adpcm.o
OBJS-$(CONFIG_ADPCM_EA_R3_DECODER)
+=
adpcm.o
OBJS-$(CONFIG_ADPCM_EA_XAS_DECODER)
+=
adpcm.o
OBJS-$(CONFIG_ADPCM_G722_DECODER)
+=
g722.o
OBJS-$(CONFIG_ADPCM_G722_ENCODER)
+=
g722.o
OBJS-$(CONFIG_ADPCM_G726_DECODER)
+=
g726.o
OBJS-$(CONFIG_ADPCM_G726_ENCODER)
+=
g726.o
OBJS-$(CONFIG_ADPCM_IMA_AMV_DECODER)
+=
adpcm.o
...
...
libavcodec/allcodecs.c
浏览文件 @
21e681ba
...
...
@@ -318,7 +318,7 @@ void avcodec_register_all(void)
REGISTER_DECODER
(
ADPCM_EA_R2
,
adpcm_ea_r2
);
REGISTER_DECODER
(
ADPCM_EA_R3
,
adpcm_ea_r3
);
REGISTER_DECODER
(
ADPCM_EA_XAS
,
adpcm_ea_xas
);
REGISTER_
DECODER
(
ADPCM_G722
,
adpcm_g722
);
REGISTER_
ENCDEC
(
ADPCM_G722
,
adpcm_g722
);
REGISTER_ENCDEC
(
ADPCM_G726
,
adpcm_g726
);
REGISTER_DECODER
(
ADPCM_IMA_AMV
,
adpcm_ima_amv
);
REGISTER_DECODER
(
ADPCM_IMA_DK3
,
adpcm_ima_dk3
);
...
...
libavcodec/g722.c
浏览文件 @
21e681ba
/*
* G.722 ADPCM audio decoder
* G.722 ADPCM audio
encoder/
decoder
*
* Copyright (c) CMU 1993 Computer Science, Speech Group
* Chengxiang Lu and Alex Hauptmann
...
...
@@ -219,6 +219,7 @@ static av_cold int g722_init(AVCodecContext * avctx)
return
0
;
}
#if CONFIG_ADPCM_G722_DECODER
static
const
int16_t
low_inv_quant5
[
32
]
=
{
-
35
,
-
35
,
-
2919
,
-
2195
,
-
1765
,
-
1458
,
-
1219
,
-
1023
,
-
858
,
-
714
,
-
587
,
-
473
,
-
370
,
-
276
,
-
190
,
-
110
,
...
...
@@ -301,4 +302,84 @@ AVCodec adpcm_g722_decoder = {
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"G.722 ADPCM"
),
.
max_lowres
=
1
,
};
#endif
#if CONFIG_ADPCM_G722_ENCODER
static
const
int16_t
low_quant
[
33
]
=
{
35
,
72
,
110
,
150
,
190
,
233
,
276
,
323
,
370
,
422
,
473
,
530
,
587
,
650
,
714
,
786
,
858
,
940
,
1023
,
1121
,
1219
,
1339
,
1458
,
1612
,
1765
,
1980
,
2195
,
2557
,
2919
};
static
inline
void
filter_samples
(
G722Context
*
c
,
const
int16_t
*
samples
,
int
*
xlow
,
int
*
xhigh
)
{
int
xout1
,
xout2
;
c
->
prev_samples
[
c
->
prev_samples_pos
++
]
=
samples
[
0
];
c
->
prev_samples
[
c
->
prev_samples_pos
++
]
=
samples
[
1
];
apply_qmf
(
c
->
prev_samples
+
c
->
prev_samples_pos
-
24
,
&
xout1
,
&
xout2
);
*
xlow
=
xout1
+
xout2
>>
13
;
*
xhigh
=
xout1
-
xout2
>>
13
;
if
(
c
->
prev_samples_pos
>=
PREV_SAMPLES_BUF_SIZE
)
{
memmove
(
c
->
prev_samples
,
c
->
prev_samples
+
c
->
prev_samples_pos
-
22
,
22
*
sizeof
(
c
->
prev_samples
[
0
]));
c
->
prev_samples_pos
=
22
;
}
}
static
inline
int
encode_high
(
const
struct
G722Band
*
state
,
int
xhigh
)
{
int
diff
=
av_clip_int16
(
xhigh
-
state
->
s_predictor
);
int
pred
=
141
*
state
->
scale_factor
>>
8
;
/* = diff >= 0 ? (diff < pred) + 2 : diff >= -pred */
return
((
diff
^
(
diff
>>
(
sizeof
(
diff
)
*
8
-
1
)))
<
pred
)
+
2
*
(
diff
>=
0
);
}
static
inline
int
encode_low
(
const
struct
G722Band
*
state
,
int
xlow
)
{
int
diff
=
av_clip_int16
(
xlow
-
state
->
s_predictor
);
/* = diff >= 0 ? diff : -(diff + 1) */
int
limit
=
diff
^
(
diff
>>
(
sizeof
(
diff
)
*
8
-
1
));
int
i
=
0
;
limit
=
limit
+
1
<<
10
;
if
(
limit
>
low_quant
[
8
]
*
state
->
scale_factor
)
i
=
9
;
while
(
i
<
29
&&
limit
>
low_quant
[
i
]
*
state
->
scale_factor
)
i
++
;
return
(
diff
<
0
?
(
i
<
2
?
63
:
33
)
:
61
)
-
i
;
}
static
int
g722_encode_frame
(
AVCodecContext
*
avctx
,
uint8_t
*
dst
,
int
buf_size
,
void
*
data
)
{
G722Context
*
c
=
avctx
->
priv_data
;
const
int16_t
*
samples
=
data
;
int
i
;
for
(
i
=
0
;
i
<
buf_size
>>
1
;
i
++
)
{
int
xlow
,
xhigh
,
ihigh
,
ilow
;
filter_samples
(
c
,
&
samples
[
2
*
i
],
&
xlow
,
&
xhigh
);
ihigh
=
encode_high
(
&
c
->
band
[
1
],
xhigh
);
ilow
=
encode_low
(
&
c
->
band
[
0
],
xlow
);
update_high_predictor
(
&
c
->
band
[
1
],
c
->
band
[
1
].
scale_factor
*
high_inv_quant
[
ihigh
]
>>
10
,
ihigh
);
update_low_predictor
(
&
c
->
band
[
0
],
ilow
>>
2
);
*
dst
++
=
ihigh
<<
6
|
ilow
;
}
return
i
;
}
AVCodec
adpcm_g722_encoder
=
{
.
name
=
"g722"
,
.
type
=
AVMEDIA_TYPE_AUDIO
,
.
id
=
CODEC_ID_ADPCM_G722
,
.
priv_data_size
=
sizeof
(
G722Context
),
.
init
=
g722_init
,
.
encode
=
g722_encode_frame
,
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"G.722 ADPCM"
),
.
sample_fmts
=
(
enum
SampleFormat
[]){
SAMPLE_FMT_S16
,
SAMPLE_FMT_NONE
},
};
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录