Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefan Westerfeld
ffmpeg
Commits
71536429
Commit
71536429
authored
May 05, 2023
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/af_replaygain: export results into read-only options
parent
782ea8b2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
5 deletions
+42
-5
filters.texi
doc/filters.texi
+10
-0
af_replaygain.c
libavfilter/af_replaygain.c
+32
-5
No files found.
doc/filters.texi
View file @
71536429
...
@@ -6058,6 +6058,16 @@ ReplayGain scanner filter. This filter takes an audio stream as an input and
...
@@ -6058,6 +6058,16 @@ ReplayGain scanner filter. This filter takes an audio stream as an input and
outputs it unchanged.
outputs it unchanged.
At end of filtering it displays @code{track_gain} and @code{track_peak}.
At end of filtering it displays @code{track_gain} and @code{track_peak}.
The filter accepts the following exported read-only options:
@table @option
@item track_gain
Exported track gain in dB at end of stream.
@item track_peak
Exported track peak at end of stream.
@end table
@section resample
@section resample
Convert the audio sample format, sample rate and channel layout. It is
Convert the audio sample format, sample rate and channel layout. It is
...
...
libavfilter/af_replaygain.c
View file @
71536429
...
@@ -23,8 +23,11 @@
...
@@ -23,8 +23,11 @@
* ReplayGain scanner
* ReplayGain scanner
*/
*/
#include <float.h>
#include "libavutil/avassert.h"
#include "libavutil/avassert.h"
#include "libavutil/channel_layout.h"
#include "libavutil/channel_layout.h"
#include "libavutil/opt.h"
#include "audio.h"
#include "audio.h"
#include "avfilter.h"
#include "avfilter.h"
#include "internal.h"
#include "internal.h"
...
@@ -306,8 +309,11 @@ static const ReplayGainFreqInfo freqinfos[] =
...
@@ -306,8 +309,11 @@ static const ReplayGainFreqInfo freqinfos[] =
};
};
typedef
struct
ReplayGainContext
{
typedef
struct
ReplayGainContext
{
const
AVClass
*
class
;
uint32_t
histogram
[
HISTOGRAM_SLOTS
];
uint32_t
histogram
[
HISTOGRAM_SLOTS
];
float
peak
;
float
peak
;
float
gain
;
int
yule_hist_i
,
butter_hist_i
;
int
yule_hist_i
,
butter_hist_i
;
const
double
*
yule_coeff_a
;
const
double
*
yule_coeff_a
;
const
double
*
yule_coeff_b
;
const
double
*
yule_coeff_b
;
...
@@ -576,13 +582,22 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
...
@@ -576,13 +582,22 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
return
ff_filter_frame
(
outlink
,
in
);
return
ff_filter_frame
(
outlink
,
in
);
}
}
static
av_cold
void
uninit
(
AVFilterContext
*
ctx
)
static
int
request_frame
(
AVFilterLink
*
outlink
)
{
{
AVFilterContext
*
ctx
=
outlink
->
src
;
ReplayGainContext
*
s
=
ctx
->
priv
;
ReplayGainContext
*
s
=
ctx
->
priv
;
float
gain
=
calc_replaygain
(
s
->
histogram
)
;
int
ret
=
0
;
av_log
(
ctx
,
AV_LOG_INFO
,
"track_gain = %+.2f dB
\n
"
,
gain
);
ret
=
ff_request_frame
(
ctx
->
inputs
[
0
]);
av_log
(
ctx
,
AV_LOG_INFO
,
"track_peak = %.6f
\n
"
,
s
->
peak
);
if
(
ret
==
AVERROR_EOF
)
{
s
->
gain
=
calc_replaygain
(
s
->
histogram
);
av_log
(
ctx
,
AV_LOG_INFO
,
"track_gain = %+.2f dB
\n
"
,
s
->
gain
);
av_log
(
ctx
,
AV_LOG_INFO
,
"track_peak = %.6f
\n
"
,
s
->
peak
);
}
return
ret
;
}
}
static
const
AVFilterPad
replaygain_inputs
[]
=
{
static
const
AVFilterPad
replaygain_inputs
[]
=
{
...
@@ -598,14 +613,26 @@ static const AVFilterPad replaygain_outputs[] = {
...
@@ -598,14 +613,26 @@ static const AVFilterPad replaygain_outputs[] = {
{
{
.
name
=
"default"
,
.
name
=
"default"
,
.
type
=
AVMEDIA_TYPE_AUDIO
,
.
type
=
AVMEDIA_TYPE_AUDIO
,
.
request_frame
=
request_frame
,
},
},
};
};
#define OFFSET(x) offsetof(ReplayGainContext, x)
#define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_EXPORT|AV_OPT_FLAG_READONLY
static
const
AVOption
replaygain_options
[]
=
{
{
"track_gain"
,
"track gain (dB)"
,
OFFSET
(
gain
),
AV_OPT_TYPE_FLOAT
,{.
dbl
=
0
},
-
FLT_MAX
,
FLT_MAX
,
FLAGS
},
{
"track_peak"
,
"track peak"
,
OFFSET
(
peak
),
AV_OPT_TYPE_FLOAT
,{.
dbl
=
0
},
-
FLT_MAX
,
FLT_MAX
,
FLAGS
},
{
NULL
}
};
AVFILTER_DEFINE_CLASS
(
replaygain
);
const
AVFilter
ff_af_replaygain
=
{
const
AVFilter
ff_af_replaygain
=
{
.
name
=
"replaygain"
,
.
name
=
"replaygain"
,
.
description
=
NULL_IF_CONFIG_SMALL
(
"ReplayGain scanner."
),
.
description
=
NULL_IF_CONFIG_SMALL
(
"ReplayGain scanner."
),
.
uninit
=
uninit
,
.
priv_size
=
sizeof
(
ReplayGainContext
),
.
priv_size
=
sizeof
(
ReplayGainContext
),
.
priv_class
=
&
replaygain_class
,
.
flags
=
AVFILTER_FLAG_METADATA_ONLY
,
.
flags
=
AVFILTER_FLAG_METADATA_ONLY
,
FILTER_INPUTS
(
replaygain_inputs
),
FILTER_INPUTS
(
replaygain_inputs
),
FILTER_OUTPUTS
(
replaygain_outputs
),
FILTER_OUTPUTS
(
replaygain_outputs
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment