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
30112ada
Commit
30112ada
authored
Jan 20, 2011
by
Justin Ruggles
Committed by
Mans Rullgard
Jan 20, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split out Butterworth filter coeff init to a separate function.
Signed-off-by:
Mans Rullgard
<
mans@mansr.com
>
parent
75b98610
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
18 deletions
+46
-18
iirfilter.c
libavcodec/iirfilter.c
+46
-18
No files found.
libavcodec/iirfilter.c
View file @
30112ada
...
...
@@ -47,29 +47,25 @@ typedef struct FFIIRFilterState{
/// maximum supported filter order
#define MAXORDER 30
av_cold
struct
FFIIRFilterCoeffs
*
ff_iir_filter_init_coeffs
(
void
*
avc
,
enum
IIRFilterType
filt_type
,
enum
IIRFilterMode
filt_mode
,
int
order
,
float
cutoff_ratio
,
float
stopband
,
float
ripple
)
static
int
butterworth_init_coeffs
(
void
*
avc
,
struct
FFIIRFilterCoeffs
*
c
,
enum
IIRFilterMode
filt_mode
,
int
order
,
float
cutoff_ratio
,
float
stopband
)
{
int
i
,
j
;
FFIIRFilterCoeffs
*
c
;
double
wa
;
double
p
[
MAXORDER
+
1
][
2
];
if
(
filt_type
!=
FF_FILTER_TYPE_BUTTERWORTH
||
filt_mode
!=
FF_FILTER_MODE_LOWPASS
)
return
NULL
;
if
(
order
<=
1
||
(
order
&
1
)
||
order
>
MAXORDER
||
cutoff_ratio
>=
1
.
0
)
return
NULL
;
FF_ALLOCZ_OR_GOTO
(
avc
,
c
,
sizeof
(
FFIIRFilterCoeffs
),
init_fail
);
FF_ALLOC_OR_GOTO
(
avc
,
c
->
cx
,
sizeof
(
c
->
cx
[
0
])
*
((
order
>>
1
)
+
1
),
init_fail
);
FF_ALLOC_OR_GOTO
(
avc
,
c
->
cy
,
sizeof
(
c
->
cy
[
0
])
*
order
,
init_fail
);
c
->
order
=
order
;
if
(
filt_mode
!=
FF_FILTER_MODE_LOWPASS
)
{
av_log
(
avc
,
AV_LOG_ERROR
,
"Butterworth filter currently only supports "
"low-pass filter mode
\n
"
);
return
-
1
;
}
if
(
order
&
1
)
{
av_log
(
avc
,
AV_LOG_ERROR
,
"Butterworth filter currently only supports "
"even filter orders
\n
"
);
return
-
1
;
}
wa
=
2
*
tan
(
M_PI
*
0
.
5
*
cutoff_ratio
);
...
...
@@ -113,6 +109,38 @@ av_cold struct FFIIRFilterCoeffs* ff_iir_filter_init_coeffs(void *avc,
}
c
->
gain
/=
1
<<
order
;
return
0
;
}
av_cold
struct
FFIIRFilterCoeffs
*
ff_iir_filter_init_coeffs
(
void
*
avc
,
enum
IIRFilterType
filt_type
,
enum
IIRFilterMode
filt_mode
,
int
order
,
float
cutoff_ratio
,
float
stopband
,
float
ripple
)
{
FFIIRFilterCoeffs
*
c
;
if
(
order
<=
0
||
order
>
MAXORDER
||
cutoff_ratio
>=
1
.
0
)
return
NULL
;
FF_ALLOCZ_OR_GOTO
(
avc
,
c
,
sizeof
(
FFIIRFilterCoeffs
),
init_fail
);
FF_ALLOC_OR_GOTO
(
avc
,
c
->
cx
,
sizeof
(
c
->
cx
[
0
])
*
((
order
>>
1
)
+
1
),
init_fail
);
FF_ALLOC_OR_GOTO
(
avc
,
c
->
cy
,
sizeof
(
c
->
cy
[
0
])
*
order
,
init_fail
);
c
->
order
=
order
;
if
(
filt_type
==
FF_FILTER_TYPE_BUTTERWORTH
)
{
if
(
butterworth_init_coeffs
(
avc
,
c
,
filt_mode
,
order
,
cutoff_ratio
,
stopband
))
{
goto
init_fail
;
}
}
else
{
av_log
(
avc
,
AV_LOG_ERROR
,
"filter type is not currently implemented
\n
"
);
goto
init_fail
;
}
return
c
;
init_fail:
...
...
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