Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
3689b58a
Commit
3689b58a
authored
Dec 23, 2015
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/af_biquads: display clipping warnings once per filtered frame
Signed-off-by:
Paul B Mahol
<
onemda@gmail.com
>
parent
e29db08c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
10 deletions
+14
-10
af_biquads.c
libavfilter/af_biquads.c
+14
-10
No files found.
libavfilter/af_biquads.c
View file @
3689b58a
...
@@ -94,7 +94,7 @@ typedef struct ChanCache {
...
@@ -94,7 +94,7 @@ typedef struct ChanCache {
double
o1
,
o2
;
double
o1
,
o2
;
}
ChanCache
;
}
ChanCache
;
typedef
struct
{
typedef
struct
BiquadsContext
{
const
AVClass
*
class
;
const
AVClass
*
class
;
enum
FilterType
filter_type
;
enum
FilterType
filter_type
;
...
@@ -110,8 +110,9 @@ typedef struct {
...
@@ -110,8 +110,9 @@ typedef struct {
double
b0
,
b1
,
b2
;
double
b0
,
b1
,
b2
;
ChanCache
*
cache
;
ChanCache
*
cache
;
int
clippings
;
void
(
*
filter
)(
AVFilterContext
*
ctx
,
const
void
*
ibuf
,
void
*
obuf
,
int
len
,
void
(
*
filter
)(
struct
BiquadsContext
*
s
,
const
void
*
ibuf
,
void
*
obuf
,
int
len
,
double
*
i1
,
double
*
i2
,
double
*
o1
,
double
*
o2
,
double
*
i1
,
double
*
i2
,
double
*
o1
,
double
*
o2
,
double
b0
,
double
b1
,
double
b2
,
double
a1
,
double
a2
);
double
b0
,
double
b1
,
double
b2
,
double
a1
,
double
a2
);
}
BiquadsContext
;
}
BiquadsContext
;
...
@@ -165,7 +166,7 @@ static int query_formats(AVFilterContext *ctx)
...
@@ -165,7 +166,7 @@ static int query_formats(AVFilterContext *ctx)
}
}
#define BIQUAD_FILTER(name, type, min, max, need_clipping) \
#define BIQUAD_FILTER(name, type, min, max, need_clipping) \
static void biquad_## name (
AVFilterContext *ctx,
\
static void biquad_## name (
BiquadsContext *s,
\
const void *input, void *output, int len, \
const void *input, void *output, int len, \
double *in1, double *in2, \
double *in1, double *in2, \
double *out1, double *out2, \
double *out1, double *out2, \
...
@@ -186,10 +187,10 @@ static void biquad_## name (AVFilterContext *ctx, \
...
@@ -186,10 +187,10 @@ static void biquad_## name (AVFilterContext *ctx, \
o2 = i2 * b2 + i1 * b1 + ibuf[i] * b0 + o2 * a2 + o1 * a1; \
o2 = i2 * b2 + i1 * b1 + ibuf[i] * b0 + o2 * a2 + o1 * a1; \
i2 = ibuf[i]; \
i2 = ibuf[i]; \
if (need_clipping && o2 < min) { \
if (need_clipping && o2 < min) { \
av_log(ctx, AV_LOG_WARNING, "clipping\n");
\
s->clippings++;
\
obuf[i] = min; \
obuf[i] = min; \
} else if (need_clipping && o2 > max) { \
} else if (need_clipping && o2 > max) { \
av_log(ctx, AV_LOG_WARNING, "clipping\n");
\
s->clippings++;
\
obuf[i] = max; \
obuf[i] = max; \
} else { \
} else { \
obuf[i] = o2; \
obuf[i] = o2; \
...
@@ -198,10 +199,10 @@ static void biquad_## name (AVFilterContext *ctx, \
...
@@ -198,10 +199,10 @@ static void biquad_## name (AVFilterContext *ctx, \
o1 = i1 * b2 + i2 * b1 + ibuf[i] * b0 + o1 * a2 + o2 * a1; \
o1 = i1 * b2 + i2 * b1 + ibuf[i] * b0 + o1 * a2 + o2 * a1; \
i1 = ibuf[i]; \
i1 = ibuf[i]; \
if (need_clipping && o1 < min) { \
if (need_clipping && o1 < min) { \
av_log(ctx, AV_LOG_WARNING, "clipping\n");
\
s->clippings++;
\
obuf[i] = min; \
obuf[i] = min; \
} else if (need_clipping && o1 > max) { \
} else if (need_clipping && o1 > max) { \
av_log(ctx, AV_LOG_WARNING, "clipping\n");
\
s->clippings++;
\
obuf[i] = max; \
obuf[i] = max; \
} else { \
} else { \
obuf[i] = o1; \
obuf[i] = o1; \
...
@@ -214,10 +215,10 @@ static void biquad_## name (AVFilterContext *ctx, \
...
@@ -214,10 +215,10 @@ static void biquad_## name (AVFilterContext *ctx, \
o2 = o1; \
o2 = o1; \
o1 = o0; \
o1 = o0; \
if (need_clipping && o0 < min) { \
if (need_clipping && o0 < min) { \
av_log(ctx, AV_LOG_WARNING, "clipping\n");
\
s->clippings++;
\
obuf[i] = min; \
obuf[i] = min; \
} else if (need_clipping && o0 > max) { \
} else if (need_clipping && o0 > max) { \
av_log(ctx, AV_LOG_WARNING, "clipping\n");
\
s->clippings++;
\
obuf[i] = max; \
obuf[i] = max; \
} else { \
} else { \
obuf[i] = o0; \
obuf[i] = o0; \
...
@@ -411,12 +412,15 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
...
@@ -411,12 +412,15 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
}
}
for
(
ch
=
0
;
ch
<
av_frame_get_channels
(
buf
);
ch
++
)
for
(
ch
=
0
;
ch
<
av_frame_get_channels
(
buf
);
ch
++
)
s
->
filter
(
ctx
,
buf
->
extended_data
[
ch
],
s
->
filter
(
s
,
buf
->
extended_data
[
ch
],
out_buf
->
extended_data
[
ch
],
nb_samples
,
out_buf
->
extended_data
[
ch
],
nb_samples
,
&
s
->
cache
[
ch
].
i1
,
&
s
->
cache
[
ch
].
i2
,
&
s
->
cache
[
ch
].
i1
,
&
s
->
cache
[
ch
].
i2
,
&
s
->
cache
[
ch
].
o1
,
&
s
->
cache
[
ch
].
o2
,
&
s
->
cache
[
ch
].
o1
,
&
s
->
cache
[
ch
].
o2
,
s
->
b0
,
s
->
b1
,
s
->
b2
,
s
->
a1
,
s
->
a2
);
s
->
b0
,
s
->
b1
,
s
->
b2
,
s
->
a1
,
s
->
a2
);
if
(
s
->
clippings
>
0
)
av_log
(
ctx
,
AV_LOG_WARNING
,
"clipping %d times. Please reduce gain.
\n
"
,
s
->
clippings
);
if
(
buf
!=
out_buf
)
if
(
buf
!=
out_buf
)
av_frame_free
(
&
buf
);
av_frame_free
(
&
buf
);
...
...
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