Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Ffmpeg
提交
06c3cd3c
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,发现更多精彩内容 >>
提交
06c3cd3c
编写于
2月 19, 2014
作者:
A
Anton Khirnov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
af_volume: support using replaygain frame side data
上级
d161ae0a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
64 addition
and
0 deletion
+64
-0
doc/filters.texi
doc/filters.texi
+17
-0
libavfilter/af_volume.c
libavfilter/af_volume.c
+39
-0
libavfilter/af_volume.h
libavfilter/af_volume.h
+8
-0
未找到文件。
doc/filters.texi
浏览文件 @
06c3cd3c
...
@@ -616,6 +616,23 @@ precision of the volume scaling.
...
@@ -616,6 +616,23 @@ precision of the volume scaling.
@item double
@item double
64-bit floating-point; limits input sample format to DBL.
64-bit floating-point; limits input sample format to DBL.
@end table
@end table
@item replaygain
Behaviour on encountering ReplayGain side data in input frames.
@table @option
@item drop
Remove ReplayGain side data, ignoring its contents (the default).
@item ignore
Ignore ReplayGain side data, but leave it in the frame.
@item track
Prefer track gain, if present.
@item album
Prefer album gain, if present.
@end table
@end table
@end table
@subsection Examples
@subsection Examples
...
...
libavfilter/af_volume.c
浏览文件 @
06c3cd3c
...
@@ -28,7 +28,10 @@
...
@@ -28,7 +28,10 @@
#include "libavutil/common.h"
#include "libavutil/common.h"
#include "libavutil/eval.h"
#include "libavutil/eval.h"
#include "libavutil/float_dsp.h"
#include "libavutil/float_dsp.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/opt.h"
#include "libavutil/opt.h"
#include "libavutil/replaygain.h"
#include "audio.h"
#include "audio.h"
#include "avfilter.h"
#include "avfilter.h"
#include "formats.h"
#include "formats.h"
...
@@ -50,6 +53,12 @@ static const AVOption options[] = {
...
@@ -50,6 +53,12 @@ static const AVOption options[] = {
{
"fixed"
,
"8-bit fixed-point."
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
PRECISION_FIXED
},
INT_MIN
,
INT_MAX
,
A
,
"precision"
},
{
"fixed"
,
"8-bit fixed-point."
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
PRECISION_FIXED
},
INT_MIN
,
INT_MAX
,
A
,
"precision"
},
{
"float"
,
"32-bit floating-point."
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
PRECISION_FLOAT
},
INT_MIN
,
INT_MAX
,
A
,
"precision"
},
{
"float"
,
"32-bit floating-point."
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
PRECISION_FLOAT
},
INT_MIN
,
INT_MAX
,
A
,
"precision"
},
{
"double"
,
"64-bit floating-point."
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
PRECISION_DOUBLE
},
INT_MIN
,
INT_MAX
,
A
,
"precision"
},
{
"double"
,
"64-bit floating-point."
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
PRECISION_DOUBLE
},
INT_MIN
,
INT_MAX
,
A
,
"precision"
},
{
"replaygain"
,
"Apply replaygain side data when present"
,
OFFSET
(
replaygain
),
AV_OPT_TYPE_INT
,
{
.
i64
=
REPLAYGAIN_DROP
},
REPLAYGAIN_DROP
,
REPLAYGAIN_ALBUM
,
A
,
"replaygain"
},
{
"drop"
,
"replaygain side data is dropped"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
REPLAYGAIN_DROP
},
0
,
0
,
A
,
"replaygain"
},
{
"ignore"
,
"replaygain side data is ignored"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
REPLAYGAIN_IGNORE
},
0
,
0
,
A
,
"replaygain"
},
{
"track"
,
"track gain is preferred"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
REPLAYGAIN_TRACK
},
0
,
0
,
A
,
"replaygain"
},
{
"album"
,
"album gain is preferred"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
REPLAYGAIN_ALBUM
},
0
,
0
,
A
,
"replaygain"
},
{
NULL
},
{
NULL
},
};
};
...
@@ -229,8 +238,38 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
...
@@ -229,8 +238,38 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
AVFilterLink
*
outlink
=
inlink
->
dst
->
outputs
[
0
];
AVFilterLink
*
outlink
=
inlink
->
dst
->
outputs
[
0
];
int
nb_samples
=
buf
->
nb_samples
;
int
nb_samples
=
buf
->
nb_samples
;
AVFrame
*
out_buf
;
AVFrame
*
out_buf
;
AVFrameSideData
*
sd
=
av_frame_get_side_data
(
buf
,
AV_FRAME_DATA_REPLAYGAIN
);
int
ret
;
int
ret
;
if
(
sd
&&
vol
->
replaygain
!=
REPLAYGAIN_IGNORE
)
{
if
(
vol
->
replaygain
!=
REPLAYGAIN_DROP
)
{
AVReplayGain
*
replaygain
=
(
AVReplayGain
*
)
sd
->
data
;
int32_t
gain
;
float
g
;
if
(
vol
->
replaygain
==
REPLAYGAIN_TRACK
&&
replaygain
->
track_gain
!=
INT32_MIN
)
gain
=
replaygain
->
track_gain
;
else
if
(
replaygain
->
album_gain
!=
INT32_MIN
)
gain
=
replaygain
->
album_gain
;
else
{
av_log
(
inlink
->
dst
,
AV_LOG_WARNING
,
"Both ReplayGain gain "
"values are unknown.
\n
"
);
gain
=
100000
;
}
g
=
gain
/
100000
.
0
f
;
av_log
(
inlink
->
dst
,
AV_LOG_VERBOSE
,
"Using gain %f dB from replaygain side data.
\n
"
,
g
);
vol
->
volume
=
pow
(
10
,
g
/
20
);
vol
->
volume_i
=
(
int
)(
vol
->
volume
*
256
+
0
.
5
);
volume_init
(
vol
);
}
av_frame_remove_side_data
(
buf
,
AV_FRAME_DATA_REPLAYGAIN
);
}
if
(
vol
->
volume
==
1
.
0
||
vol
->
volume_i
==
256
)
if
(
vol
->
volume
==
1
.
0
||
vol
->
volume_i
==
256
)
return
ff_filter_frame
(
outlink
,
buf
);
return
ff_filter_frame
(
outlink
,
buf
);
...
...
libavfilter/af_volume.h
浏览文件 @
06c3cd3c
...
@@ -35,10 +35,18 @@ enum PrecisionType {
...
@@ -35,10 +35,18 @@ enum PrecisionType {
PRECISION_DOUBLE
,
PRECISION_DOUBLE
,
};
};
enum
ReplayGainType
{
REPLAYGAIN_DROP
,
REPLAYGAIN_IGNORE
,
REPLAYGAIN_TRACK
,
REPLAYGAIN_ALBUM
,
};
typedef
struct
VolumeContext
{
typedef
struct
VolumeContext
{
const
AVClass
*
class
;
const
AVClass
*
class
;
AVFloatDSPContext
fdsp
;
AVFloatDSPContext
fdsp
;
enum
PrecisionType
precision
;
enum
PrecisionType
precision
;
enum
ReplayGainType
replaygain
;
double
volume
;
double
volume
;
int
volume_i
;
int
volume_i
;
int
channels
;
int
channels
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录