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
e169d375
Commit
e169d375
authored
Nov 22, 2019
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/af_aiir: factor out response calculation
parent
c36e72ed
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
50 deletions
+65
-50
af_aiir.c
libavfilter/af_aiir.c
+65
-50
No files found.
libavfilter/af_aiir.c
View file @
e169d375
...
...
@@ -737,41 +737,24 @@ static void draw_line(AVFrame *out, int x0, int y0, int x1, int y1, uint32_t col
}
}
static
void
draw_response
(
AVFilterContext
*
ctx
,
AVFrame
*
out
)
static
void
get_response
(
int
channel
,
int
format
,
double
w
,
const
double
*
b
,
const
double
*
a
,
int
nb_b
,
int
nb_a
,
double
*
r
,
double
*
i
)
{
AudioIIRContext
*
s
=
ctx
->
priv
;
float
*
mag
,
*
phase
,
*
delay
,
min
=
FLT_MAX
,
max
=
FLT_MIN
;
float
min_delay
=
FLT_MAX
,
max_delay
=
FLT_MIN
;
int
prev_ymag
=
-
1
,
prev_yphase
=
-
1
,
prev_ydelay
=
-
1
;
char
text
[
32
];
int
ch
,
i
,
x
;
memset
(
out
->
data
[
0
],
0
,
s
->
h
*
out
->
linesize
[
0
]);
phase
=
av_malloc_array
(
s
->
w
,
sizeof
(
*
phase
));
mag
=
av_malloc_array
(
s
->
w
,
sizeof
(
*
mag
));
delay
=
av_malloc_array
(
s
->
w
,
sizeof
(
*
delay
));
if
(
!
mag
||
!
phase
||
!
delay
)
goto
end
;
ch
=
av_clip
(
s
->
ir_channel
,
0
,
s
->
channels
-
1
);
for
(
i
=
0
;
i
<
s
->
w
;
i
++
)
{
const
double
*
b
=
s
->
iir
[
ch
].
ab
[
0
];
const
double
*
a
=
s
->
iir
[
ch
].
ab
[
1
];
double
w
=
i
*
M_PI
/
(
s
->
w
-
1
);
double
realz
,
realp
;
double
imagz
,
imagp
;
double
real
,
imag
,
div
;
double
real
,
imag
;
double
div
;
if
(
s
->
format
==
0
)
{
if
(
format
==
0
)
{
realz
=
0
.,
realp
=
0
.;
imagz
=
0
.,
imagp
=
0
.;
for
(
x
=
0
;
x
<
s
->
iir
[
ch
].
nb_ab
[
1
]
;
x
++
)
{
for
(
int
x
=
0
;
x
<
nb_a
;
x
++
)
{
realz
+=
cos
(
-
x
*
w
)
*
a
[
x
];
imagz
+=
sin
(
-
x
*
w
)
*
a
[
x
];
}
for
(
x
=
0
;
x
<
s
->
iir
[
ch
].
nb_ab
[
0
]
;
x
++
)
{
for
(
int
x
=
0
;
x
<
nb_b
;
x
++
)
{
realp
+=
cos
(
-
x
*
w
)
*
b
[
x
];
imagp
+=
sin
(
-
x
*
w
)
*
b
[
x
];
}
...
...
@@ -782,7 +765,7 @@ static void draw_response(AVFilterContext *ctx, AVFrame *out)
}
else
{
real
=
1
;
imag
=
0
;
for
(
x
=
0
;
x
<
s
->
iir
[
ch
].
nb_ab
[
1
]
;
x
++
)
{
for
(
int
x
=
0
;
x
<
nb_a
;
x
++
)
{
double
ore
,
oim
,
re
,
im
;
re
=
cos
(
w
)
-
a
[
2
*
x
];
...
...
@@ -795,7 +778,7 @@ static void draw_response(AVFilterContext *ctx, AVFrame *out)
imag
=
ore
*
im
+
oim
*
re
;
}
for
(
x
=
0
;
x
<
s
->
iir
[
ch
].
nb_ab
[
0
]
;
x
++
)
{
for
(
int
x
=
0
;
x
<
nb_b
;
x
++
)
{
double
ore
,
oim
,
re
,
im
;
re
=
cos
(
w
)
-
b
[
2
*
x
];
...
...
@@ -810,6 +793,38 @@ static void draw_response(AVFilterContext *ctx, AVFrame *out)
}
}
*
r
=
real
;
*
i
=
imag
;
}
static
void
draw_response
(
AVFilterContext
*
ctx
,
AVFrame
*
out
)
{
AudioIIRContext
*
s
=
ctx
->
priv
;
float
*
mag
,
*
phase
,
*
delay
,
min
=
FLT_MAX
,
max
=
FLT_MIN
;
float
min_delay
=
FLT_MAX
,
max_delay
=
FLT_MIN
;
int
prev_ymag
=
-
1
,
prev_yphase
=
-
1
,
prev_ydelay
=
-
1
;
char
text
[
32
];
int
ch
,
i
;
memset
(
out
->
data
[
0
],
0
,
s
->
h
*
out
->
linesize
[
0
]);
phase
=
av_malloc_array
(
s
->
w
,
sizeof
(
*
phase
));
mag
=
av_malloc_array
(
s
->
w
,
sizeof
(
*
mag
));
delay
=
av_malloc_array
(
s
->
w
,
sizeof
(
*
delay
));
if
(
!
mag
||
!
phase
||
!
delay
)
goto
end
;
ch
=
av_clip
(
s
->
ir_channel
,
0
,
s
->
channels
-
1
);
for
(
i
=
0
;
i
<
s
->
w
;
i
++
)
{
const
double
*
b
=
s
->
iir
[
ch
].
ab
[
0
];
const
double
*
a
=
s
->
iir
[
ch
].
ab
[
1
];
const
int
nb_b
=
s
->
iir
[
ch
].
nb_ab
[
0
];
const
int
nb_a
=
s
->
iir
[
ch
].
nb_ab
[
1
];
double
w
=
i
*
M_PI
/
(
s
->
w
-
1
);
double
real
,
imag
;
get_response
(
ch
,
s
->
format
,
w
,
b
,
a
,
nb_b
,
nb_a
,
&
real
,
&
imag
);
mag
[
i
]
=
s
->
iir
[
ch
].
g
*
hypot
(
real
,
imag
);
phase
[
i
]
=
atan2
(
imag
,
real
);
min
=
fminf
(
min
,
mag
[
i
]);
...
...
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