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
cf00f60b
Unverified
Commit
cf00f60b
authored
Jun 14, 2023
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec/kbdwin: Support arbitrary sized windows
Signed-off-by:
Michael Niedermayer
<
michael@niedermayer.cc
>
parent
94d44dbe
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
11 deletions
+19
-11
kbdwin.c
libavcodec/kbdwin.c
+14
-8
kbdwin.h
libavcodec/kbdwin.h
+5
-3
No files found.
libavcodec/kbdwin.c
View file @
cf00f60b
...
...
@@ -19,20 +19,23 @@
#include "libavutil/avassert.h"
#include "libavutil/mathematics.h"
#include "libavutil/attributes.h"
#include "libavutil/mem.h"
#include "kbdwin.h"
av_cold
static
void
kbd_window_init
(
float
*
float_window
,
int
*
int_window
,
float
alpha
,
int
n
)
av_cold
static
int
kbd_window_init
(
float
*
float_window
,
int
*
int_window
,
float
alpha
,
int
n
)
{
int
i
;
double
sum
=
0
.
0
,
tmp
;
double
scale
=
0
.
0
;
double
temp
[
FF_KBD_WINDOW_MAX
/
2
+
1
];
double
temp_small
[
FF_KBD_WINDOW_MAX
/
2
+
1
];
double
*
temp
=
n
<=
FF_KBD_WINDOW_MAX
?
temp_small
:
av_malloc
((
n
/
2
+
1
)
*
sizeof
(
*
temp
));
double
alpha2
=
4
*
(
alpha
*
M_PI
/
n
)
*
(
alpha
*
M_PI
/
n
);
av_assert0
(
n
<=
FF_KBD_WINDOW_MAX
);
if
(
!
temp
)
return
AVERROR
(
ENOMEM
);
for
(
i
=
0
;
i
<=
n
/
2
;
i
++
)
{
tmp
=
i
*
(
n
-
i
)
*
alpha2
;
tmp
=
alpha2
*
i
*
(
n
-
i
)
;
temp
[
i
]
=
av_bessel_i0
(
sqrt
(
tmp
));
scale
+=
temp
[
i
]
*
(
1
+
(
i
&&
i
<
n
/
2
));
}
...
...
@@ -48,14 +51,17 @@ av_cold static void kbd_window_init(float *float_window, int *int_window, float
if
(
float_window
)
float_window
[
i
]
=
sqrt
(
sum
*
scale
);
else
int_window
[
i
]
=
lrint
(
2147483647
*
sqrt
(
sum
*
scale
));
}
if
(
temp
!=
temp_small
)
av_free
(
temp
);
return
0
;
}
av_cold
void
ff_kbd_window_init
(
float
*
window
,
float
alpha
,
int
n
)
av_cold
int
ff_kbd_window_init
(
float
*
window
,
float
alpha
,
int
n
)
{
kbd_window_init
(
window
,
NULL
,
alpha
,
n
);
return
kbd_window_init
(
window
,
NULL
,
alpha
,
n
);
}
av_cold
void
ff_kbd_window_init_fixed
(
int32_t
*
window
,
float
alpha
,
int
n
)
av_cold
int
ff_kbd_window_init_fixed
(
int32_t
*
window
,
float
alpha
,
int
n
)
{
kbd_window_init
(
NULL
,
window
,
alpha
,
n
);
return
kbd_window_init
(
NULL
,
window
,
alpha
,
n
);
}
libavcodec/kbdwin.h
View file @
cf00f60b
...
...
@@ -30,9 +30,11 @@
* Generate a Kaiser-Bessel Derived Window.
* @param window pointer to half window
* @param alpha determines window shape
* @param n size of half window, max FF_KBD_WINDOW_MAX
* @param n size of half window
*
* @return if n is larger than FF_KBD_WINDOW_MAX then AVERROR(ENOMEM) is possible
*/
void
ff_kbd_window_init
(
float
*
window
,
float
alpha
,
int
n
);
void
ff_kbd_window_init_fixed
(
int32_t
*
window
,
float
alpha
,
int
n
);
int
ff_kbd_window_init
(
float
*
window
,
float
alpha
,
int
n
);
int
ff_kbd_window_init_fixed
(
int32_t
*
window
,
float
alpha
,
int
n
);
#endif
/* AVCODEC_KBDWIN_H */
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